diff options
author | Ove Murberg Henriksen <sorayasilvermoon@hotmail.com> | 2012-07-04 19:56:42 +0400 |
---|---|---|
committer | Ove Murberg Henriksen <sorayasilvermoon@hotmail.com> | 2012-07-04 19:56:42 +0400 |
commit | d43e1fa7beb03368eaaa3c89ef95d69ebd693734 (patch) | |
tree | 2a63c1d49c735c48edb1ee036a8db4e424293078 | |
parent | a953e4bbe33f24bef6fd018c7413e904a9628e5b (diff) | |
parent | 558721ab59bd4e6186005f5e9aca50e094c9e72c (diff) |
svn merge ^/trunk/blender -r48095:48592
1126 files changed, 21125 insertions, 11037 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b70110947b..9e1ef4f5d4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,13 +123,14 @@ mark_as_advanced(WITH_PYTHON) # dont want people disabling this unless they rea mark_as_advanced(WITH_PYTHON_SECURITY) # some distrobutions see this as a security issue, rather than have them patch it, make a build option. option(WITH_PYTHON_SAFETY "Enable internal API error checking to track invalid data to prevent crash on access (at the expense of some effeciency, only enable for development)." OFF) -option(WITH_PYTHON_MODULE "Enable building as a python module (experimental, only enable for development)" OFF) +option(WITH_PYTHON_MODULE "Enable building as a python module which runs without a user interface, like running regular blender in background mode (experimental, only enable for development)" OFF) option(WITH_BUILDINFO "Include extra build details (only disable for development & faster builds)" ON) option(WITH_IK_ITASC "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON) option(WITH_FFTW3 "Enable FFTW3 support (Used for smoke and audio effects)" OFF) option(WITH_BULLET "Enable Bullet (Physics Engine)" ON) option(WITH_GAMEENGINE "Enable Game Engine" ON) option(WITH_PLAYER "Build Player" OFF) +option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON) # GHOST Windowing Library Options option(WITH_GHOST_DEBUG "Enable debugging output for the GHOST library" OFF) @@ -159,7 +160,7 @@ unset(PLATFORM_DEFAULT) if(UNIX AND NOT APPLE) option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)" ON) option(WITH_X11_XF86VMODE "Enable X11 video mode switching" ON) - option(WITH_BUILTIN_GLEW "Use GLEW OpenGL wrapper library bundled with blender" ON) + option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" ON) # freebsd doesn't seems to support XDND if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") @@ -167,9 +168,20 @@ if(UNIX AND NOT APPLE) endif() else() # not an option for other OS's - set(WITH_BUILTIN_GLEW ON) + set(WITH_SYSTEM_GLEW OFF) endif() + +# (unix defaults to System OpenJPEG On) +if(UNIX AND NOT APPLE) + set(PLATFORM_DEFAULT ON) +else() + set(PLATFORM_DEFAULT OFF) +endif() +option(WITH_SYSTEM_OPENJPEG "Use the operating systems OpenJPEG library" ${PLATFORM_DEFAULT}) +unset(PLATFORM_DEFAULT) + + # Modifiers option(WITH_MOD_FLUID "Enable Elbeem Modifier (Fluid Simulation)" ON) option(WITH_MOD_SMOKE "Enable Smoke Modifier (Smoke Simulation)" ON) @@ -451,11 +463,6 @@ set(PLATFORM_LINKFLAGS_DEBUG "") if(UNIX AND NOT APPLE) - # needed for ubuntu 11.04 - if(EXISTS "/usr/lib/x86_64-linux-gnu") - set(CMAKE_LIBRARY_PATH "/usr/lib/x86_64-linux-gnu;${CMAKE_LIBRARY_PATH}") - endif() - # set lib directory if it exists if(CMAKE_SYSTEM_NAME MATCHES "Linux") if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") @@ -660,7 +667,6 @@ if(UNIX AND NOT APPLE) if(NOT OPENIMAGEIO_FOUND) set(WITH_OPENIMAGEIO OFF) - set(WITH_CYCLES OFF) message(STATUS "OpenImageIO not found, disabling WITH_CYCLES") endif() endif() @@ -987,8 +993,8 @@ elseif(WIN32) set(BOOST_POSTFIX "vc100-mt-s-1_47.lib") set(BOOST_DEBUG_POSTFIX "vc100-mt-sgd-1_47.lib") else() - set(BOOST_POSTFIX "vc90-mt-s-1_47.lib") - set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_47.lib") + set(BOOST_POSTFIX "vc90-mt-s-1_49.lib") + set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_49.lib") endif() set(BOOST_LIBRARIES optimized libboost_date_time-${BOOST_POSTFIX} optimized libboost_filesystem-${BOOST_POSTFIX} @@ -1451,6 +1457,16 @@ if(APPLE OR WIN32) endif() endif() +if(WITH_CYCLES) + if(NOT WITH_OPENIMAGEIO) + message(FATAL_ERROR "Cycles reqires WITH_OPENIMAGEIO, the library may not have been found. Configure OIIO or disable WITH_CYCLES") + endif() + if(NOT WITH_BOOST) + message(FATAL_ERROR "Cycles reqires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_CYCLES") + endif() +endif() + + # See TEST_SSE_SUPPORT() for how this is defined. if(WITH_RAYOPTIMIZATION) @@ -1485,10 +1501,11 @@ endif() if(WITH_IMAGE_OPENJPEG) - if(UNIX AND NOT APPLE) + if(WITH_SYSTEM_OPENJPEG) # dealt with above else() set(OPENJPEG_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/libopenjpeg") + add_definitions(-DOPJ_STATIC) endif() endif() @@ -1539,20 +1556,20 @@ endif() #----------------------------------------------------------------------------- # Configure GLEW -if(WITH_BUILTIN_GLEW) - # set(GLEW_LIBRARY "") # unused - set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include") -else() +if(WITH_SYSTEM_GLEW) find_package(GLEW) if(NOT GLEW_FOUND) - message(FATAL_ERROR "GLEW is required to build blender, install it or use WITH_BUILTIN_GLEW") + message(FATAL_ERROR "GLEW is required to build blender, install it or disable WITH_SYSTEM_GLEW") endif() mark_as_advanced( GLEW_LIBRARY GLEW_INCLUDE_PATH ) +else() + # set(GLEW_LIBRARY "") # unused + set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include") endif() #----------------------------------------------------------------------------- @@ -1711,6 +1728,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}") # better not set includes here but this debugging option is off by default. if(WITH_CXX_GUARDEDALLOC) include_directories(${CMAKE_SOURCE_DIR}/intern/guardedalloc) + add_definitions(-DWITH_CXX_GUARDEDALLOC) endif() if(WITH_ASSERT_ABORT) @@ -1790,8 +1808,9 @@ if(FIRST_RUN) info_cfg_option(WITH_INSTALL_PORTABLE) info_cfg_option(WITH_X11_XF86VMODE) info_cfg_option(WITH_X11_XINPUT) - info_cfg_option(WITH_BUILTIN_GLEW) info_cfg_option(WITH_MEM_JEMALLOC) + info_cfg_option(WITH_SYSTEM_GLEW) + info_cfg_option(WITH_SYSTEM_OPENJPEG) info_cfg_text("Image Formats:") info_cfg_option(WITH_IMAGE_CINEON) diff --git a/GNUmakefile b/GNUmakefile index f5cba00d452..88ce32959af 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -162,21 +162,21 @@ help: @echo " * package_pacman - build an arch linux pacmanpackage" @echo " * package_archive - build an archive package" @echo "" - @echo "Testing Targets (not assosiated with building blender)" + @echo "Testing Targets (not associated with building blender)" @echo " * test - run ctest, currently tests import/export, operator execution and that python modules load" @echo " * test_cmake - runs our own cmake file checker which detects errors in the cmake file list definitions" @echo " * test_pep8 - checks all python script are pep8 which are tagged to use the stricter formatting" @echo " * test_deprecated - checks for deprecation tags in our code which may need to be removed" @echo " * test_style - checks C/C++ conforms with blenders style guide: http://wiki.blender.org/index.php/Dev:Doc/CodeStyle" @echo "" - @echo "Static Source Code Checking (not assosiated with building blender)" + @echo "Static Source Code Checking (not associated with building blender)" @echo " * check_cppcheck - run blender source through cppcheck (C & C++)" @echo " * check_splint - run blenders source through splint (C only)" @echo " * check_sparse - run blenders source through sparse (C only)" @echo " * check_spelling_c - check for spelling errors (C/C++ only)" @echo " * check_spelling_py - check for spelling errors (Python only)" @echo "" - @echo "Documentation Targets (not assosiated with building blender)" + @echo "Documentation Targets (not associated with building blender)" @echo " * doc_py - generate sphinx python api docs" @echo " * doc_doxy - generate doxygen C/C++ docs" @echo " * doc_dna - generate blender file format reference" diff --git a/SConstruct b/SConstruct index 9bc61d7aeb2..088361af649 100644 --- a/SConstruct +++ b/SConstruct @@ -240,6 +240,7 @@ print B.bc.OKGREEN + "Build with debug symbols%s: %s" % (B.bc.ENDC, env['BF_DEBU if 'blenderlite' in B.targets: target_env_defs = {} target_env_defs['WITH_BF_GAMEENGINE'] = False + target_env_defs['WITH_BF_CYCLES'] = False target_env_defs['WITH_BF_OPENAL'] = False target_env_defs['WITH_BF_OPENEXR'] = False target_env_defs['WITH_BF_OPENMP'] = False diff --git a/build_files/cmake/config/blender_lite.cmake b/build_files/cmake/config/blender_lite.cmake index d19f0cf32e8..e2adc17a2e8 100644 --- a/build_files/cmake/config/blender_lite.cmake +++ b/build_files/cmake/config/blender_lite.cmake @@ -6,9 +6,9 @@ # set(WITH_INSTALL_PORTABLE ON CACHE FORCE BOOL) +set(WITH_SYSTEM_GLEW ON CACHE FORCE BOOL) set(WITH_BUILDINFO OFF CACHE FORCE BOOL) -set(WITH_BUILTIN_GLEW OFF CACHE FORCE BOOL) set(WITH_BULLET OFF CACHE FORCE BOOL) set(WITH_CODEC_FFMPEG OFF CACHE FORCE BOOL) set(WITH_CODEC_SNDFILE OFF CACHE FORCE BOOL) diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 2b61ddca648..3608f41e369 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -193,7 +193,7 @@ macro(SETUP_LIBDIRS) if(WITH_OPENIMAGEIO) link_directories(${OPENIMAGEIO_LIBPATH}) endif() - if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE) + if(WITH_IMAGE_OPENJPEG AND WITH_SYSTEM_OPENJPEG) link_directories(${OPENJPEG_LIBPATH}) endif() if(WITH_CODEC_QUICKTIME) @@ -236,8 +236,7 @@ macro(setup_liblinks ${OPENGL_glu_LIBRARY} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} - ${FREETYPE_LIBRARY} - ${LAPACK_LIBRARIES}) + ${FREETYPE_LIBRARY}) # since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions if(WITH_PYTHON) # AND NOT WITH_PYTHON_MODULE # WIN32 needs @@ -253,7 +252,7 @@ macro(setup_liblinks endif() endif() - if(NOT WITH_BUILTIN_GLEW) + if(WITH_SYSTEM_GLEW) target_link_libraries(${target} ${GLEW_LIBRARY}) endif() @@ -303,7 +302,7 @@ macro(setup_liblinks target_link_libraries(${target} ${OPENEXR_LIBRARIES}) endif() endif() - if(WITH_IMAGE_OPENJPEG AND UNIX AND NOT APPLE) + if(WITH_IMAGE_OPENJPEG AND WITH_SYSTEM_OPENJPEG) target_link_libraries(${target} ${OPENJPEG_LIBRARIES}) endif() if(WITH_CODEC_FFMPEG) @@ -346,7 +345,9 @@ macro(setup_liblinks if(WITH_INPUT_NDOF) target_link_libraries(${target} ${NDOF_LIBRARIES}) endif() - + if(WITH_MOD_CLOTH_ELTOPO) + target_link_libraries(${target} ${LAPACK_LIBRARIES}) + endif() if(WIN32 AND NOT UNIX) target_link_libraries(${target} ${PTHREADS_LIBRARIES}) endif() @@ -452,6 +453,12 @@ macro(remove_strict_flags) add_cc_flag("${CC_REMOVE_STRICT_FLAGS}") endif() + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + remove_cc_flag("-Wunused-parameter") + remove_cc_flag("-Wunused-variable") + remove_cc_flag("-Werror") + endif() + if(MSVC) # TODO endif() diff --git a/build_files/scons/config/win32-mingw-config.py b/build_files/scons/config/win32-mingw-config.py index dc83411adac..723651971d0 100644 --- a/build_files/scons/config/win32-mingw-config.py +++ b/build_files/scons/config/win32-mingw-config.py @@ -181,7 +181,7 @@ CXX = 'g++' CCFLAGS = [ '-pipe', '-funsigned-char', '-fno-strict-aliasing' ] CXXFLAGS = [] -CPPFLAGS = ['-DWIN32', '-DFREE_WINDOWS', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE64_SOURCE', '-DBOOST_ALL_NO_LIB', '-DBOOST_THREAD_USE_LIB', '-DGLEW_STATIC'] +CPPFLAGS = ['-DWIN32', '-DFREE_WINDOWS', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE64_SOURCE', '-DBOOST_ALL_NO_LIB', '-DBOOST_THREAD_USE_LIB', '-DGLEW_STATIC', '-DOPJ_STATIC'] REL_CFLAGS = [] REL_CXXFLAGS = [] REL_CCFLAGS = ['-DNDEBUG', '-O2'] diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py index db30f453228..609ee867eec 100644 --- a/build_files/scons/config/win32-vc-config.py +++ b/build_files/scons/config/win32-vc-config.py @@ -159,7 +159,7 @@ BF_OIIO_LIBPATH = '${BF_OIIO}/lib' WITH_BF_BOOST = True BF_BOOST = '${LIBDIR}/boost' BF_BOOST_INC = '${BF_BOOST}/include' -BF_BOOST_LIB = 'libboost_date_time-vc90-mt-s-1_47 libboost_filesystem-vc90-mt-s-1_47 libboost_regex-vc90-mt-s-1_47 libboost_system-vc90-mt-s-1_47 libboost_thread-vc90-mt-s-1_47' +BF_BOOST_LIB = 'libboost_date_time-vc90-mt-s-1_49 libboost_filesystem-vc90-mt-s-1_49 libboost_regex-vc90-mt-s-1_49 libboost_system-vc90-mt-s-1_49 libboost_thread-vc90-mt-s-1_49' BF_BOOST_LIBPATH = '${BF_BOOST}/lib' #CUDA @@ -188,7 +188,7 @@ BGE_CXXFLAGS = ['/O2', '/EHsc', '/GR', '/fp:fast', '/arch:SSE'] BF_DEBUG_CCFLAGS = ['/Zi', '/FR${TARGET}.sbr'] -CPPFLAGS = ['-DWIN32','-D_CONSOLE', '-D_LIB', '-D_CRT_SECURE_NO_DEPRECATE'] +CPPFLAGS = ['-DWIN32','-D_CONSOLE', '-D_LIB', '-D_CRT_SECURE_NO_DEPRECATE', '-DOPJ_STATIC'] REL_CFLAGS = [] REL_CXXFLAGS = [] REL_CCFLAGS = ['-O2', '-DNDEBUG'] diff --git a/build_files/scons/config/win64-mingw-config.py b/build_files/scons/config/win64-mingw-config.py index cecf91e48a8..2649c5505d5 100644 --- a/build_files/scons/config/win64-mingw-config.py +++ b/build_files/scons/config/win64-mingw-config.py @@ -179,7 +179,7 @@ CXX = 'g++' CCFLAGS = [ '-pipe', '-funsigned-char', '-fno-strict-aliasing' ] CXXFLAGS = [ '-fpermissive' ] -CPPFLAGS = ['-DWIN32', '-DMS_WIN64', '-DFREE_WINDOWS', '-DFREE_WINDOWS64', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE64_SOURCE', '-DBOOST_ALL_NO_LIB', '-DBOOST_THREAD_USE_LIB', '-DGLEW_STATIC'] +CPPFLAGS = ['-DWIN32', '-DMS_WIN64', '-DFREE_WINDOWS', '-DFREE_WINDOWS64', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE64_SOURCE', '-DBOOST_ALL_NO_LIB', '-DBOOST_THREAD_USE_LIB', '-DGLEW_STATIC', '-DOPJ_STATIC'] REL_CFLAGS = [] REL_CXXFLAGS = [] REL_CCFLAGS = ['-DNDEBUG', '-O2', '-ftree-vectorize'] diff --git a/build_files/scons/config/win64-vc-config.py b/build_files/scons/config/win64-vc-config.py index fe16278dd19..681e058f5be 100644 --- a/build_files/scons/config/win64-vc-config.py +++ b/build_files/scons/config/win64-vc-config.py @@ -156,7 +156,7 @@ BF_OIIO_LIBPATH = '${BF_OIIO}/lib' WITH_BF_BOOST = True BF_BOOST = '${LIBDIR}/boost' BF_BOOST_INC = '${BF_BOOST}/include' -BF_BOOST_LIB = 'libboost_date_time-vc90-mt-s-1_47 libboost_filesystem-vc90-mt-s-1_47 libboost_regex-vc90-mt-s-1_47 libboost_system-vc90-mt-s-1_47 libboost_thread-vc90-mt-s-1_47' +BF_BOOST_LIB = 'libboost_date_time-vc90-mt-s-1_49 libboost_filesystem-vc90-mt-s-1_49 libboost_regex-vc90-mt-s-1_49 libboost_system-vc90-mt-s-1_49 libboost_thread-vc90-mt-s-1_49' BF_BOOST_LIBPATH = '${BF_BOOST}/lib' #CUDA @@ -186,7 +186,7 @@ BGE_CXXFLAGS = ['/O2', '/EHsc', '/GR', '/fp:fast'] BF_DEBUG_CCFLAGS = ['/Zi', '/FR${TARGET}.sbr', '/Od'] -CPPFLAGS = ['-DWIN32', '-D_CONSOLE', '-D_LIB', '-D_CRT_SECURE_NO_DEPRECATE'] +CPPFLAGS = ['-DWIN32', '-D_CONSOLE', '-D_LIB', '-D_CRT_SECURE_NO_DEPRECATE', '-DOPJ_STATIC'] REL_CFLAGS = [] REL_CXXFLAGS = [] REL_CCFLAGS = ['-O2', '-DNDEBUG'] diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index d3a334b3c96..af484ed382e 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -108,6 +108,7 @@ def validate_arguments(args, bc): 'WITH_BF_STATICFFMPEG', 'BF_FFMPEG_LIB_STATIC', 'WITH_BF_OGG', 'BF_OGG', 'BF_OGG_LIB', 'WITH_BF_FRAMESERVER', + 'WITH_BF_COMPOSITOR', 'WITH_BF_JPEG', 'BF_JPEG', 'BF_JPEG_INC', 'BF_JPEG_LIB', 'BF_JPEG_LIBPATH', 'WITH_BF_OPENJPEG', 'BF_OPENJPEG', 'BF_OPENJPEG_INC', 'BF_OPENJPEG_LIB', 'BF_OPENJPEG_LIBPATH', 'WITH_BF_REDCODE', 'BF_REDCODE', 'BF_REDCODE_INC', 'BF_REDCODE_LIB', 'BF_REDCODE_LIBPATH', @@ -531,6 +532,8 @@ def read_opts(env, cfg, args): (BoolVariable('WITH_BF_CARVE', 'Enable carve library for mesh boolean operations', True)), (BoolVariable('WITH_BF_LIBMV', 'Enable libmv structure from motion library', True)), + + (BoolVariable('WITH_BF_COMPOSITOR', 'Enable the tile based nodal compositor', True)), ('BF_X264_CONFIG', 'configuration flags for x264', ''), ('BF_XVIDCORE_CONFIG', 'configuration flags for xvidcore', ''), diff --git a/doc/build_systems/scons-dev.txt b/doc/build_systems/scons-dev.txt index b7cac8109d4..ae2be2b2a94 100644 --- a/doc/build_systems/scons-dev.txt +++ b/doc/build_systems/scons-dev.txt @@ -37,7 +37,7 @@ Much of the actual functionality can be found in the python scripts in the directory $BLENDERHOME/tools, with Blender.py defining the bulk of the functionality. btools.py has some helper functions, and - bcolors.py is for the terminal colours. mstoolkit.py and crossmingw.py + bcolors.py is for the terminal colors. mstoolkit.py and crossmingw.py are modules which set up SCons for the MS VC++ 2003 toolkit and the cross-compile toolset for compiling Windows binaries on Linux respectively. Note: the cross-compile doesn't work yet for Blender, diff --git a/doc/build_systems/scons.txt b/doc/build_systems/scons.txt index d6ead8d32ae..cb88c56ddbc 100644 --- a/doc/build_systems/scons.txt +++ b/doc/build_systems/scons.txt @@ -48,7 +48,7 @@ % python ./scons/scons.py This will start the build process with default values. Depending - on your platform you may see colour in your output (non-Windows + on your platform you may see color in your output (non-Windows machines). In the the beginning an overview of targets and arguments from the command-line is given, then all libraries and binaries to build are configured. @@ -123,11 +123,11 @@ This rewrite features a cleaner output during the build process. If you need to see the full command-line for compiles, then you can - change that behaviour. Also the use of colours can be changed: + change that behaviour. Also the use of colors can be changed: % python scons\scons.py BF_FANCY=0 - This will disable the use of colours. + This will disable the use of colors. % python scons\scons.py BF_QUIET=0 diff --git a/doc/guides/interface_API.txt b/doc/guides/interface_API.txt index c98794444e6..5f601dd3ebc 100644 --- a/doc/guides/interface_API.txt +++ b/doc/guides/interface_API.txt @@ -173,7 +173,7 @@ drawtype: UI_EMBOSSN 2 /* Button with no border */ UI_EMBOSSF 3 /* Square embossed button (file select) */ UI_EMBOSSM 4 /* Colored, for pulldown menus */ - UI_EMBOSSP 5 /* Simple borderless coloured button (like blender sensors) */ + UI_EMBOSSP 5 /* Simple borderless colored button (like blender sensors) */ font: UI_HELV 0 /* normal font */ diff --git a/doc/python_api/examples/bpy.ops.1.py b/doc/python_api/examples/bpy.ops.1.py index f43be2b0f63..a00dbdafb90 100644 --- a/doc/python_api/examples/bpy.ops.1.py +++ b/doc/python_api/examples/bpy.ops.1.py @@ -1,22 +1,17 @@ """ -Execution Context -+++++++++++++++++ +Overriding Context +------------------ -When calling an operator you may want to pass the execution context. +It is possible to override context members that the operator sees, so that they +act on specified rather than the selected or active data, or to execute an +operator in the different part of the user interface. -This determines the context thats given to the operator to run in, and weather -invoke() is called or execute(). - -'EXEC_DEFAULT' is used by default but you may want the operator to take user -interaction with 'INVOKE_DEFAULT'. - -The execution context is as a non keyword, string argument in: -('INVOKE_DEFAULT', 'INVOKE_REGION_WIN', 'INVOKE_REGION_CHANNELS', -'INVOKE_REGION_PREVIEW', 'INVOKE_AREA', 'INVOKE_SCREEN', 'EXEC_DEFAULT', -'EXEC_REGION_WIN', 'EXEC_REGION_CHANNELS', 'EXEC_REGION_PREVIEW', 'EXEC_AREA', -'EXEC_SCREEN') +The context overrides are passed as a dictionary, with keys matching the context +member names in bpy.context. For example to override bpy.context.active_object, +you would pass {'active_object': object}. """ -# group add popup +# remove all objects in scene rather than the selected ones import bpy -bpy.ops.object.group_instance_add('INVOKE_DEFAULT') +override = {'selected_bases': list(bpy.context.scene.object_bases)} +bpy.ops.object.delete(override) diff --git a/doc/python_api/examples/bpy.ops.2.py b/doc/python_api/examples/bpy.ops.2.py index 86b7438888c..01e7dc1902e 100644 --- a/doc/python_api/examples/bpy.ops.2.py +++ b/doc/python_api/examples/bpy.ops.2.py @@ -1,18 +1,22 @@ """ -Overriding Context -++++++++++++++++++ +Execution Context +----------------- -It is possible to override context members that the operator sees, so that they -act on specified rather than the selected or active data, or to execute an -operator in the different part of the user interface. +When calling an operator you may want to pass the execution context. -The context overrides are passed as a dictionary, with keys matching the context -member names in bpy.context. For example to override bpy.context.active_object, -you would pass {'active_object': object}. +This determines the context thats given to the operator to run in, and weather +invoke() is called or execute(). + +'EXEC_DEFAULT' is used by default but you may want the operator to take user +interaction with 'INVOKE_DEFAULT'. + +The execution context is as a non keyword, string argument in: +('INVOKE_DEFAULT', 'INVOKE_REGION_WIN', 'INVOKE_REGION_CHANNELS', +'INVOKE_REGION_PREVIEW', 'INVOKE_AREA', 'INVOKE_SCREEN', 'EXEC_DEFAULT', +'EXEC_REGION_WIN', 'EXEC_REGION_CHANNELS', 'EXEC_REGION_PREVIEW', 'EXEC_AREA', +'EXEC_SCREEN') """ -# remove all objects in scene rather than the selected ones +# group add popup import bpy -override = {'selected_bases': list(bpy.context.scene.object_bases)} -bpy.ops.object.delete(override) - +bpy.ops.object.group_instance_add('INVOKE_DEFAULT')
\ No newline at end of file diff --git a/doc/python_api/examples/bpy.ops.3.py b/doc/python_api/examples/bpy.ops.3.py index 0b5bcafe5be..7dec69cf566 100644 --- a/doc/python_api/examples/bpy.ops.3.py +++ b/doc/python_api/examples/bpy.ops.3.py @@ -9,10 +9,9 @@ import bpy for window in bpy.context.window_manager.windows: screen = window.screen - + for area in screen.areas: if area.type == 'VIEW_3D': override = {'window': window, 'screen': screen, 'area': area} bpy.ops.screen.screen_full_area(override) break - diff --git a/doc/python_api/examples/bpy.ops.py b/doc/python_api/examples/bpy.ops.py index 20e8773652d..9964ad915bf 100644 --- a/doc/python_api/examples/bpy.ops.py +++ b/doc/python_api/examples/bpy.ops.py @@ -1,6 +1,6 @@ """ Calling Operators -+++++++++++++++++ +----------------- Provides python access to calling operators, this includes operators written in C, Python or Macros. @@ -18,6 +18,26 @@ there is a poll() method to avoid this problem. Note that the operator ID (bl_idname) in this example is 'mesh.subdivide', 'bpy.ops' is just the access path for python. + + +Keywords and Positional Arguments +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +For calling operators keywords are used for operator properties and +positional arguments are used to define how the operator is called. + +There are 3 optional positional arguments (documented in detail below). + +.. code-block:: python + + bpy.ops.test.operator(override_context, execution_context, undo) + +* override_context - dict type +* execution_context - string (enum) +* undo - boolean + + +Each of these arguments is optional, but must be given in the order above. """ import bpy diff --git a/doc/python_api/examples/bpy.types.Mesh.py b/doc/python_api/examples/bpy.types.Mesh.py index d30303f3b05..19ccd177d64 100644 --- a/doc/python_api/examples/bpy.types.Mesh.py +++ b/doc/python_api/examples/bpy.types.Mesh.py @@ -17,7 +17,7 @@ Each polygon reference a slice in the loop array, this way, polygons do not stor only a reference to loops that the polygon uses. :class:`Mesh.loops`, :class:`Mesh.uv_layers` :class:`Mesh.vertex_colors` are all aligned so the same polygon loop -indicies can be used to find the UV's and vertex colors as with as the vertices. +indices can be used to find the UV's and vertex colors as with as the vertices. To compare mesh API options see: :ref:`NGons and Tessellation Faces <info_gotcha_mesh_faces>` diff --git a/doc/python_api/rst/bge.render.rst b/doc/python_api/rst/bge.render.rst index a253b6df26f..d07d7a8734f 100644 --- a/doc/python_api/rst/bge.render.rst +++ b/doc/python_api/rst/bge.render.rst @@ -94,11 +94,11 @@ Functions If filename starts with // the image will be saved relative to the current directory. If the filename contains # it will be replaced with the frame number. - The standalone player saves .png files. It does not support colour space conversion + The standalone player saves .png files. It does not support color space conversion or gamma correction. When run from Blender, makeScreenshot supports Iris, IrisZ, TGA, Raw TGA, PNG, HamX, and Jpeg. - Gamma, Colourspace conversion and Jpeg compression are taken from the Render settings panels. + Gamma, Colorspace conversion and Jpeg compression are taken from the Render settings panels. :type filename: string @@ -125,14 +125,14 @@ Functions .. function:: setBackgroundColor(rgba) - Sets the window background colour. + Sets the window background color. :type rgba: list [r, g, b, a] .. function:: setMistColor(rgb) - Sets the mist colour. + Sets the mist color. :type rgb: list [r, g, b] @@ -153,8 +153,8 @@ Functions .. function:: setMistEnd(end) - Sets the mist end value. Objects further away from this will be coloured solid with - the colour set by setMistColor(). + Sets the mist end value. Objects further away from this will be colored solid with + the color set by setMistColor(). :type end: float diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst index ff85df1f68b..d0a848ee6f7 100644 --- a/doc/python_api/rst/bge.types.rst +++ b/doc/python_api/rst/bge.types.rst @@ -72,6 +72,20 @@ Game Types (bge.types) :type: dictionary {:ref:`keycode<keyboard-keys>`::ref:`status<input-status>`, ...} + + .. function:: getClipboard() + + Gets the clipboard text. + + :rtype: string + + .. function:: setClipboard(text) + + Sets the clipboard text. + + :arg text: New clipboard text + :type text: string + .. class:: SCA_PythonMouse(PyObjectPlus) The current mouse. @@ -242,12 +256,6 @@ Game Types (bge.types) :type: string - .. attribute:: channelNames - - A list of channel names that may be used with :data:`setChannel` and :data:`getChannel`. - - :type: list of strings - .. attribute:: frameStart Specifies the starting frame of the animation. @@ -308,26 +316,6 @@ Game Types (bge.types) :type: string - .. method:: setChannel(channel, matrix) - - Alternative to the 2 arguments, 4 arguments (channel, matrix, loc, size, quat) are also supported. - - :arg channel: A string specifying the name of the bone channel, error raised if not in :data:`channelNames`. - :type channel: string - :arg matrix: A 4x4 matrix specifying the overriding transformation as an offset from the bone's rest position. - :arg matrix: list [[float]] - - .. note:: - - These values are relative to the bones rest position, currently the api has no way to get this info (which is annoying), but can be worked around by using bones with a rest pose that has no translation. - - .. method:: getChannel(channel) - - :arg channel: A string specifying the name of the bone channel. error raised if not in :data:`channelNames`. - :type channel: string - :return: (loc, size, quat) - :rtype: tuple - .. class:: BL_Shader(PyObjectPlus) BL_Shader GLSL shaders. @@ -1695,7 +1683,7 @@ Game Types (bge.types) light = co.owner light.energy = 1.0 - light.colour = [1.0, 0.0, 0.0] + light.color = [1.0, 0.0, 0.0] .. data:: SPOT @@ -1731,15 +1719,15 @@ Game Types (bge.types) :type: float - .. attribute:: colour + .. attribute:: color - The colour of this light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0]. + The color of this light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0]. :type: list [r, g, b] - .. attribute:: color + .. attribute:: colour - Synonym for colour. + Synonym for color. .. attribute:: lin_attenuation @@ -1794,7 +1782,7 @@ Game Types (bge.types) #. They are at the same position #. UV coordinates are the same #. Their normals are the same (both polygons are "Set Smooth") - #. They are the same colour, for example: a cube has 24 vertices: 6 faces with 4 vertices per face. + #. They are the same color, for example: a cube has 24 vertices: 6 faces with 4 vertices per face. The correct method of iterating over every :class:`KX_VertexProxy` in a game object @@ -1810,8 +1798,8 @@ Game Types (bge.types) for v_index in range(mesh.getVertexArrayLength(m_index)): vertex = mesh.getVertex(m_index, v_index) # Do something with vertex here... - # ... eg: colour the vertex red. - vertex.colour = [1.0, 0.0, 0.0, 1.0] + # ... eg: color the vertex red. + vertex.color = [1.0, 0.0, 0.0, 1.0] .. attribute:: materials @@ -2550,13 +2538,13 @@ Game Types (bge.types) .. attribute:: diffuse - The diffuse colour of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0]. + The diffuse color of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0]. :type: list [r, g, b] .. attribute:: specular - The specular colour of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0]. + The specular color of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0]. :type: list [r, g, b] @@ -3393,7 +3381,7 @@ Game Types (bge.types) .. class:: KX_VertexProxy(SCA_IObject) - A vertex holds position, UV, colour and normal information. + A vertex holds position, UV, color and normal information. Note: The physics simulation is NOT currently updated - physics will not respond @@ -3417,17 +3405,17 @@ Game Types (bge.types) :type: list [nx, ny, nz] - .. attribute:: colour + .. attribute:: color - The colour of the vertex. + The color of the vertex. :type: list [r, g, b, a] Black = [0.0, 0.0, 0.0, 1.0], White = [1.0, 1.0, 1.0, 1.0] - .. attribute:: color + .. attribute:: colour - Synonym for colour. + Synonym for color. .. attribute:: x @@ -3473,25 +3461,25 @@ Game Types (bge.types) .. attribute:: r - The red component of the vertex colour. 0.0 <= r <= 1.0. + The red component of the vertex color. 0.0 <= r <= 1.0. :type: float .. attribute:: g - The green component of the vertex colour. 0.0 <= g <= 1.0. + The green component of the vertex color. 0.0 <= g <= 1.0. :type: float .. attribute:: b - The blue component of the vertex colour. 0.0 <= b <= 1.0. + The blue component of the vertex color. 0.0 <= b <= 1.0. :type: float .. attribute:: a - The alpha component of the vertex colour. 0.0 <= a <= 1.0. + The alpha component of the vertex color. 0.0 <= a <= 1.0. :type: float @@ -3541,15 +3529,15 @@ Game Types (bge.types) .. method:: getRGBA() - Gets the colour of this vertex. + Gets the color of this vertex. - The colour is represented as four bytes packed into an integer value. The colour is + The color is represented as four bytes packed into an integer value. The color is packed as RGBA. Since Python offers no way to get each byte without shifting, you must use the struct module to - access colour in an machine independent way. + access color in an machine independent way. - Because of this, it is suggested you use the r, g, b and a attributes or the colour attribute instead. + Because of this, it is suggested you use the r, g, b and a attributes or the color attribute instead. .. code-block:: python @@ -3559,17 +3547,17 @@ Game Types (bge.types) # black = ( 0, 0, 0, 255) # white = (255, 255, 255, 255) - :return: packed colour. 4 byte integer with one byte per colour channel in RGBA format. + :return: packed color. 4 byte integer with one byte per color channel in RGBA format. :rtype: integer .. method:: setRGBA(col) - Sets the colour of this vertex. + Sets the color of this vertex. See getRGBA() for the format of col, and its relevant problems. Use the r, g, b and a attributes - or the colour attribute instead. + or the color attribute instead. - setRGBA() also accepts a four component list as argument col. The list represents the colour as [r, g, b, a] + setRGBA() also accepts a four component list as argument col. The list represents the color as [r, g, b, a] with black = [0.0, 0.0, 0.0, 1.0] and white = [1.0, 1.0, 1.0, 1.0] .. code-block:: python @@ -3579,14 +3567,14 @@ Game Types (bge.types) v.setRGBA([1.0, 0.0, 0.0, 1.0]) # Red v.setRGBA([0.0, 1.0, 0.0, 1.0]) # Green on all platforms. - :arg col: the new colour of this vertex in packed RGBA format. + :arg col: the new color of this vertex in packed RGBA format. :type col: integer or list [r, g, b, a] .. method:: getNormal() Gets the normal vector of this vertex. - :return: normalised normal vector. + :return: normalized normal vector. :rtype: list [nx, ny, nz] .. method:: setNormal(normal) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 1d83410a3d7..b5f94c06d4c 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -40,7 +40,7 @@ if(WITH_BINRELOC) add_subdirectory(binreloc) endif() -if(WITH_BUILTIN_GLEW) +if(NOT WITH_SYSTEM_GLEW) add_subdirectory(glew) endif() @@ -48,7 +48,7 @@ if(WITH_GAMEENGINE) add_subdirectory(recastnavigation) endif() -if(WITH_IMAGE_OPENJPEG AND (NOT UNIX OR APPLE)) +if(WITH_IMAGE_OPENJPEG AND (NOT WITH_SYSTEM_OPENJPEG)) add_subdirectory(libopenjpeg) endif() diff --git a/extern/libopenjpeg/CMakeLists.txt b/extern/libopenjpeg/CMakeLists.txt index 6967048ac83..c602ddcabb9 100644 --- a/extern/libopenjpeg/CMakeLists.txt +++ b/extern/libopenjpeg/CMakeLists.txt @@ -54,6 +54,11 @@ set(SRC t2.c tcd.c tgt.c + cidx_manager.c + phix_manager.c + ppix_manager.c + thix_manager.c + tpix_manager.c bio.h cio.h @@ -78,6 +83,9 @@ set(SRC t2.h tcd.h tgt.h + cidx_manager.h + indexbox_manager.h + opj_config.h ) blender_add_lib(extern_openjpeg "${SRC}" "${INC}" "${INC_SYS}") diff --git a/extern/libopenjpeg/cidx_manager.c b/extern/libopenjpeg/cidx_manager.c new file mode 100644 index 00000000000..6131b938ea6 --- /dev/null +++ b/extern/libopenjpeg/cidx_manager.c @@ -0,0 +1,213 @@ +/* + * $Id: cidx_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2003-2004, Yannick Verschueren + * Copyright (c) 2010-2011, Kaori Hagihara + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdio.h> +#include <stdlib.h> +#include "opj_includes.h" + + +/* + * Write CPTR Codestream finder box + * + * @param[in] coff offset of j2k codestream + * @param[in] clen length of j2k codestream + * @param[in] cio file output handle + */ +void write_cptr(int coff, int clen, opj_cio_t *cio); + + +/* + * Write main header index table (box) + * + * @param[in] coff offset of j2k codestream + * @param[in] cstr_info codestream information + * @param[in] cio file output handle + * @return length of mainmhix box + */ +int write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio); + + +/* + * Check if EPH option is used + * + * @param[in] coff offset of j2k codestream + * @param[in] markers marker information + * @param[in] marknum number of markers + * @param[in] cio file output handle + * @return true if EPH is used + */ +opj_bool check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_cio_t *cio); + + +int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen) +{ + int len, i, lenp; + opj_jp2_box_t *box; + int num_box = 0; + opj_bool EPHused; + (void)image; /* unused ? */ + + lenp = -1; + box = (opj_jp2_box_t *)opj_calloc( 32, sizeof(opj_jp2_box_t)); + + for (i=0;i<2;i++){ + + if(i) + cio_seek( cio, lenp); + + lenp = cio_tell( cio); + + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_CIDX, 4); /* CIDX */ + write_cptr( offset, cstr_info.codestream_size, cio); + + write_manf( i, num_box, box, cio); + + num_box = 0; + box[num_box].length = write_mainmhix( offset, cstr_info, cio); + box[num_box].type = JPIP_MHIX; + num_box++; + + box[num_box].length = write_tpix( offset, cstr_info, j2klen, cio); + box[num_box].type = JPIP_TPIX; + num_box++; + + box[num_box].length = write_thix( offset, cstr_info, cio); + box[num_box].type = JPIP_THIX; + num_box++; + + EPHused = check_EPHuse( offset, cstr_info.marker, cstr_info.marknum, cio); + + box[num_box].length = write_ppix( offset, cstr_info, EPHused, j2klen, cio); + box[num_box].type = JPIP_PPIX; + num_box++; + + box[num_box].length = write_phix( offset, cstr_info, EPHused, j2klen, cio); + box[num_box].type = JPIP_PHIX; + num_box++; + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + } + + opj_free( box); + + return len; +} + +void write_cptr(int coff, int clen, opj_cio_t *cio) +{ + int len, lenp; + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_CPTR, 4); /* T */ + cio_write( cio, 0, 2); /* DR A PRECISER !! */ + cio_write( cio, 0, 2); /* CONT */ + cio_write( cio, coff, 8); /* COFF A PRECISER !! */ + cio_write( cio, clen, 8); /* CLEN */ + len = cio_tell( cio) - lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); +} + +void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio) +{ + int len, lenp, i; + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_MANF,4); /* T */ + + if (second){ /* Write only during the second pass */ + for( i=0; i<v; i++){ + cio_write( cio, box[i].length, 4); /* Box length */ + cio_write( cio, box[i].type, 4); /* Box type */ + } + } + + len = cio_tell( cio) - lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); +} + +int write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio) +{ + int i; + int len, lenp; + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_MHIX, 4); /* MHIX */ + + cio_write( cio, cstr_info.main_head_end-cstr_info.main_head_start+1, 8); /* TLEN */ + + for(i = 1; i < cstr_info.marknum; i++){ /* Marker restricted to 1 apparition, skip SOC marker */ + cio_write( cio, cstr_info.marker[i].type, 2); + cio_write( cio, 0, 2); + cio_write( cio, cstr_info.marker[i].pos-coff, 8); + cio_write( cio, cstr_info.marker[i].len, 2); + } + + len = cio_tell( cio) - lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + + return len; +} + +opj_bool check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_cio_t *cio) +{ + opj_bool EPHused = OPJ_FALSE; + int i=0; + int org_pos; + unsigned int Scod; + + for(i = 0; i < marknum; i++){ + if( markers[i].type == J2K_MS_COD){ + org_pos = cio_tell( cio); + cio_seek( cio, coff+markers[i].pos+2); + + Scod = cio_read( cio, 1); + if( ((Scod >> 2) & 1)) + EPHused = OPJ_TRUE; + cio_seek( cio, org_pos); + + break; + } + } + return EPHused; +} diff --git a/extern/libopenjpeg/cidx_manager.h b/extern/libopenjpeg/cidx_manager.h new file mode 100644 index 00000000000..23eebd52baa --- /dev/null +++ b/extern/libopenjpeg/cidx_manager.h @@ -0,0 +1,56 @@ +/* + * $Id: cidx_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2003-2004, Yannick Verschueren + * Copyright (c) 2010-2011, Kaori Hagihara + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*! \file + * \brief Modification of jpip.h from 2KAN indexer + */ + + +#ifndef CIDX_MANAGER_H_ +# define CIDX_MANAGER_H_ + +#include "openjpeg.h" + + +/* + * Write Codestream index box (superbox) + * + * @param[in] offset offset of j2k codestream + * @param[in] cio file output handle + * @param[in] image image data + * @param[in] cstr_info codestream information + * @param[in] j2klen length of j2k codestream + * @return length of cidx box + */ +int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen); + + +#endif /* !CIDX_MANAGER_H_ */ diff --git a/extern/libopenjpeg/cio.c b/extern/libopenjpeg/cio.c index 2ac262a1f6b..b8a7ecf8a87 100644 --- a/extern/libopenjpeg/cio.c +++ b/extern/libopenjpeg/cio.c @@ -126,13 +126,13 @@ unsigned char *cio_getbp(opj_cio_t *cio) { /* * Write a byte. */ -bool cio_byteout(opj_cio_t *cio, unsigned char v) { +opj_bool cio_byteout(opj_cio_t *cio, unsigned char v) { if (cio->bp >= cio->end) { opj_event_msg(cio->cinfo, EVT_ERROR, "write error\n"); - return false; + return OPJ_FALSE; } *cio->bp++ = v; - return true; + return OPJ_TRUE; } /* @@ -152,7 +152,7 @@ unsigned char cio_bytein(opj_cio_t *cio) { * v : value to write * n : number of bytes to write */ -unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n) { +unsigned int cio_write(opj_cio_t *cio, unsigned long long int v, int n) { int i; for (i = n - 1; i >= 0; i--) { if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) ) diff --git a/extern/libopenjpeg/cio.h b/extern/libopenjpeg/cio.h index 580bf9c0d12..ce1a13ecb3a 100644 --- a/extern/libopenjpeg/cio.h +++ b/extern/libopenjpeg/cio.h @@ -63,7 +63,7 @@ Write some bytes @param n Number of bytes to write @return Returns the number of bytes written or 0 if an error occured */ -unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n); +unsigned int cio_write(opj_cio_t *cio, unsigned long long int v, int n); /** Read some bytes @param cio CIO handle diff --git a/extern/libopenjpeg/dwt.c b/extern/libopenjpeg/dwt.c index 357b475b9ac..0fbfc2033fe 100644 --- a/extern/libopenjpeg/dwt.c +++ b/extern/libopenjpeg/dwt.c @@ -64,12 +64,12 @@ typedef struct v4dwt_local { int cas ; } v4dwt_t ; -static const float dwt_alpha = 1.586134342f; // 12994 -static const float dwt_beta = 0.052980118f; // 434 -static const float dwt_gamma = -0.882911075f; // -7233 -static const float dwt_delta = -0.443506852f; // -3633 +static const float dwt_alpha = 1.586134342f; /* 12994 */ +static const float dwt_beta = 0.052980118f; /* 434 */ +static const float dwt_gamma = -0.882911075f; /* -7233 */ +static const float dwt_delta = -0.443506852f; /* -3633 */ -static const float K = 1.230174105f; // 10078 +static const float K = 1.230174105f; /* 10078 */ /* FIXME: What is this constant? */ static const float c13318 = 1.625732422f; @@ -527,7 +527,7 @@ static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int numres, DWT1DFN dwt_1 int w = tilec->x1 - tilec->x0; - h.mem = opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int)); + h.mem = (int*)opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int)); v.mem = h.mem; while( --numres) { @@ -570,6 +570,20 @@ static void v4dwt_interleave_h(v4dwt_t* restrict w, float* restrict a, int x, in int count = w->sn; int i, k; for(k = 0; k < 2; ++k){ + if (count + 3 * x < size && ((size_t) a & 0x0f) == 0 && ((size_t) bi & 0x0f) == 0 && (x & 0x0f) == 0) { + /* Fast code path */ + for(i = 0; i < count; ++i){ + int j = i; + bi[i*8 ] = a[j]; + j += x; + bi[i*8 + 1] = a[j]; + j += x; + bi[i*8 + 2] = a[j]; + j += x; + bi[i*8 + 3] = a[j]; + } + } else { + /* Slow code path */ for(i = 0; i < count; ++i){ int j = i; bi[i*8 ] = a[j]; @@ -583,6 +597,7 @@ static void v4dwt_interleave_h(v4dwt_t* restrict w, float* restrict a, int x, in if(j > size) continue; bi[i*8 + 3] = a[j]; } + } bi = (float*) (w->wavelet + 1 - w->cas); a += w->sn; size -= w->sn; @@ -608,9 +623,21 @@ static void v4dwt_interleave_v(v4dwt_t* restrict v , float* restrict a , int x){ static void v4dwt_decode_step1_sse(v4* w, int count, const __m128 c){ __m128* restrict vw = (__m128*) w; int i; + /* 4x unrolled loop */ + for(i = 0; i < count >> 2; ++i){ + *vw = _mm_mul_ps(*vw, c); + vw += 2; + *vw = _mm_mul_ps(*vw, c); + vw += 2; + *vw = _mm_mul_ps(*vw, c); + vw += 2; + *vw = _mm_mul_ps(*vw, c); + vw += 2; + } + count &= 3; for(i = 0; i < count; ++i){ - __m128 tmp = vw[i*2]; - vw[i*2] = _mm_mul_ps(tmp, c); + *vw = _mm_mul_ps(*vw, c); + vw += 2; } } @@ -618,14 +645,16 @@ static void v4dwt_decode_step2_sse(v4* l, v4* w, int k, int m, __m128 c){ __m128* restrict vl = (__m128*) l; __m128* restrict vw = (__m128*) w; int i; + __m128 tmp1, tmp2, tmp3; + tmp1 = vl[0]; for(i = 0; i < m; ++i){ - __m128 tmp1 = vl[ 0]; - __m128 tmp2 = vw[-1]; - __m128 tmp3 = vw[ 0]; + tmp2 = vw[-1]; + tmp3 = vw[ 0]; vw[-1] = _mm_add_ps(tmp2, _mm_mul_ps(_mm_add_ps(tmp1, tmp3), c)); - vl = vw; + tmp1 = tmp3; vw += 2; } + vl = vw - 2; if(m >= k){ return; } @@ -773,19 +802,24 @@ void dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, int numres){ h.dn = rw - h.sn; h.cas = res->x0 % 2; - for(j = rh; j > 0; j -= 4){ + for(j = rh; j > 3; j -= 4){ + int k; v4dwt_interleave_h(&h, aj, w, bufsize); v4dwt_decode(&h); - if(j >= 4){ - int k; for(k = rw; --k >= 0;){ aj[k ] = h.wavelet[k].f[0]; aj[k+w ] = h.wavelet[k].f[1]; aj[k+w*2] = h.wavelet[k].f[2]; aj[k+w*3] = h.wavelet[k].f[3]; } - }else{ + aj += w*4; + bufsize -= w*4; + } + if (rh & 0x03) { int k; + j = rh & 0x03; + v4dwt_interleave_h(&h, aj, w, bufsize); + v4dwt_decode(&h); for(k = rw; --k >= 0;){ switch(j) { case 3: aj[k+w*2] = h.wavelet[k].f[2]; @@ -794,30 +828,29 @@ void dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, int numres){ } } } - aj += w*4; - bufsize -= w*4; - } v.dn = rh - v.sn; v.cas = res->y0 % 2; aj = (float*) tilec->data; - for(j = rw; j > 0; j -= 4){ + for(j = rw; j > 3; j -= 4){ + int k; v4dwt_interleave_v(&v, aj, w); v4dwt_decode(&v); - if(j >= 4){ - int k; for(k = 0; k < rh; ++k){ memcpy(&aj[k*w], &v.wavelet[k], 4 * sizeof(float)); } - }else{ + aj += 4; + } + if (rw & 0x03){ int k; + j = rw & 0x03; + v4dwt_interleave_v(&v, aj, w); + v4dwt_decode(&v); for(k = 0; k < rh; ++k){ memcpy(&aj[k*w], &v.wavelet[k], j * sizeof(float)); } } - aj += 4; - } } opj_aligned_free(h.wavelet); diff --git a/extern/libopenjpeg/event.c b/extern/libopenjpeg/event.c index fe46e423552..0dc22f12549 100644 --- a/extern/libopenjpeg/event.c +++ b/extern/libopenjpeg/event.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,8 +29,9 @@ /* ========================================================== Utility functions ==========================================================*/ -#if 0 -#if !defined(_MSC_VER) && !defined(__MINGW32__) + +#ifdef OPJ_CODE_NOT_USED +#ifndef _WIN32 static char* i2a(unsigned i, char *a, unsigned r) { if (i/r > 0) a = i2a(i/r,a,r); @@ -57,8 +58,8 @@ _itoa(int i, char *a, int r) { return a; } -#endif /* !WIN32 */ -#endif /* unused - campbell */ +#endif /* !_WIN32 */ +#endif /* ----------------------------------------------------------------------- */ opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) { @@ -72,7 +73,7 @@ opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_ return NULL; } -bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) { +opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) { #define MSG_SIZE 512 /* 512 bytes should be more than enough for a short message */ opj_msg_callback msg_handler = NULL; @@ -92,10 +93,10 @@ bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) { break; } if(msg_handler == NULL) { - return false; + return OPJ_FALSE; } } else { - return false; + return OPJ_FALSE; } if ((fmt != NULL) && (event_mgr != NULL)) { @@ -116,6 +117,6 @@ bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) { msg_handler(message, cinfo->client_data); } - return true; + return OPJ_TRUE; } diff --git a/extern/libopenjpeg/event.h b/extern/libopenjpeg/event.h index 11910b0e4bc..9c59787caf3 100644 --- a/extern/libopenjpeg/event.h +++ b/extern/libopenjpeg/event.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,7 +49,7 @@ Write formatted data to a string and send the string to a user callback. @param fmt Format-control string (plus optionnal arguments) @return Returns true if successful, returns false otherwise */ -bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...); +opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...); /* ----------------------------------------------------------------------- */ /*@}*/ diff --git a/extern/libopenjpeg/image.c b/extern/libopenjpeg/image.c index ea8e59ea547..7c1e7f7faa2 100644 --- a/extern/libopenjpeg/image.c +++ b/extern/libopenjpeg/image.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,7 +27,7 @@ #include "opj_includes.h" opj_image_t* opj_image_create0(void) { - opj_image_t *image = (opj_image_t*)opj_malloc(sizeof(opj_image_t)); + opj_image_t *image = (opj_image_t*)opj_calloc(1, sizeof(opj_image_t)); return image; } @@ -86,4 +86,3 @@ void OPJ_CALLCONV opj_image_destroy(opj_image_t *image) { opj_free(image); } } - diff --git a/extern/libopenjpeg/image.h b/extern/libopenjpeg/image.h index 04c362eb834..f828b5b77c8 100644 --- a/extern/libopenjpeg/image.h +++ b/extern/libopenjpeg/image.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/extern/libopenjpeg/indexbox_manager.h b/extern/libopenjpeg/indexbox_manager.h new file mode 100644 index 00000000000..7364df62c22 --- /dev/null +++ b/extern/libopenjpeg/indexbox_manager.h @@ -0,0 +1,118 @@ +/* + * $Id: indexbox_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2003-2004, Yannick Verschueren + * Copyright (c) 2010-2011, Kaori Hagihara + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*! \file + * \brief Modification of jpip.c from 2KAN indexer + */ + +#ifndef INDEXBOX_MANAGER_H_ +# define INDEXBOX_MANAGER_H_ + +#include "openjpeg.h" +#include "j2k.h" /* needed to use jp2.h */ +#include "jp2.h" + +#define JPIP_CIDX 0x63696478 /* Codestream index */ +#define JPIP_CPTR 0x63707472 /* Codestream Finder Box */ +#define JPIP_MANF 0x6d616e66 /* Manifest Box */ +#define JPIP_FAIX 0x66616978 /* Fragment array Index box */ +#define JPIP_MHIX 0x6d686978 /* Main Header Index Table */ +#define JPIP_TPIX 0x74706978 /* Tile-part Index Table box */ +#define JPIP_THIX 0x74686978 /* Tile header Index Table box */ +#define JPIP_PPIX 0x70706978 /* Precinct Packet Index Table box */ +#define JPIP_PHIX 0x70686978 /* Packet Header index Table */ +#define JPIP_FIDX 0x66696478 /* File Index */ +#define JPIP_FPTR 0x66707472 /* File Finder */ +#define JPIP_PRXY 0x70727879 /* Proxy boxes */ +#define JPIP_IPTR 0x69707472 /* Index finder box */ +#define JPIP_PHLD 0x70686c64 /* Place holder */ + + +/* + * Write tile-part Index table box (superbox) + * + * @param[in] coff offset of j2k codestream + * @param[in] cstr_info codestream information + * @param[in] j2klen length of j2k codestream + * @param[in] cio file output handle + * @return length of tpix box + */ +int write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio); + + +/* + * Write tile header index table box (superbox) + * + * @param[in] coff offset of j2k codestream + * @param[in] cstr_info codestream information pointer + * @param[in] cio file output handle + * @return length of thix box + */ +int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio); + + +/* + * Write precinct packet index table box (superbox) + * + * @param[in] coff offset of j2k codestream + * @param[in] cstr_info codestream information + * @param[in] EPHused true if EPH option used + * @param[in] j2klen length of j2k codestream + * @param[in] cio file output handle + * @return length of ppix box + */ +int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio); + + +/* + * Write packet header index table box (superbox) + * + * @param[in] coff offset of j2k codestream + * @param[in] cstr_info codestream information + * @param[in] EPHused true if EPH option used + * @param[in] j2klen length of j2k codestream + * @param[in] cio file output handle + * @return length of ppix box + */ +int write_phix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio); + +/* + * Wriet manifest box (box) + * + * @param[in] second number to be visited + * @param[in] v number of boxes + * @param[in] box box to be manifested + * @param[in] cio file output handle + */ +void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio); + + +#endif /* !INDEXBOX_MANAGER_H_ */ diff --git a/extern/libopenjpeg/j2k.c b/extern/libopenjpeg/j2k.c index 8e7b1ce081f..d34c75faa7b 100644 --- a/extern/libopenjpeg/j2k.c +++ b/extern/libopenjpeg/j2k.c @@ -6,6 +6,7 @@ * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2006-2007, Parvatha Elangovan + * Copyright (c) 2010-2011, Kaori Hagihara * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -228,6 +229,23 @@ Read an unknown marker @param j2k J2K handle */ static void j2k_read_unk(opj_j2k_t *j2k); +/** +Add main header marker information +@param cstr_info Codestream information structure +@param type marker type +@param pos byte offset of marker segment +@param len length of marker segment + */ +static void j2k_add_mhmarker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len); +/** +Add tile header marker information +@param tileno tile index number +@param cstr_info Codestream information structure +@param type marker type +@param pos byte offset of marker segment +@param len length of marker segment + */ +static void j2k_add_tlmarker( int tileno, opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len); /*@}*/ @@ -236,7 +254,7 @@ static void j2k_read_unk(opj_j2k_t *j2k); /* ----------------------------------------------------------------------- */ typedef struct j2k_prog_order{ OPJ_PROG_ORDER enum_prog; - char str_prog[4]; + char str_prog[5]; }j2k_prog_order_t; j2k_prog_order_t j2k_prog_order_list[] = { @@ -245,7 +263,7 @@ j2k_prog_order_t j2k_prog_order_list[] = { {PCRL, "PCRL"}, {RLCP, "RLCP"}, {RPCL, "RPCL"}, - {-1, ""} + {(OPJ_PROG_ORDER)-1, ""} }; char *j2k_convert_progression_order(OPJ_PROG_ORDER prg_order){ @@ -258,79 +276,6 @@ char *j2k_convert_progression_order(OPJ_PROG_ORDER prg_order){ return po->str_prog; } -void j2k_dump_image(FILE *fd, opj_image_t * img) { - int compno; - fprintf(fd, "image {\n"); - fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1); - fprintf(fd, " numcomps=%d\n", img->numcomps); - for (compno = 0; compno < img->numcomps; compno++) { - opj_image_comp_t *comp = &img->comps[compno]; - fprintf(fd, " comp %d {\n", compno); - fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy); - fprintf(fd, " prec=%d\n", comp->prec); - fprintf(fd, " sgnd=%d\n", comp->sgnd); - fprintf(fd, " }\n"); - } - fprintf(fd, "}\n"); -} - -void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) { - int tileno, compno, layno, bandno, resno, numbands; - fprintf(fd, "coding parameters {\n"); - fprintf(fd, " tx0=%d, ty0=%d\n", cp->tx0, cp->ty0); - fprintf(fd, " tdx=%d, tdy=%d\n", cp->tdx, cp->tdy); - fprintf(fd, " tw=%d, th=%d\n", cp->tw, cp->th); - for (tileno = 0; tileno < cp->tw * cp->th; tileno++) { - opj_tcp_t *tcp = &cp->tcps[tileno]; - fprintf(fd, " tile %d {\n", tileno); - fprintf(fd, " csty=%x\n", tcp->csty); - fprintf(fd, " prg=%d\n", tcp->prg); - fprintf(fd, " numlayers=%d\n", tcp->numlayers); - fprintf(fd, " mct=%d\n", tcp->mct); - fprintf(fd, " rates="); - for (layno = 0; layno < tcp->numlayers; layno++) { - fprintf(fd, "%.1f ", tcp->rates[layno]); - } - fprintf(fd, "\n"); - for (compno = 0; compno < img->numcomps; compno++) { - opj_tccp_t *tccp = &tcp->tccps[compno]; - fprintf(fd, " comp %d {\n", compno); - fprintf(fd, " csty=%x\n", tccp->csty); - fprintf(fd, " numresolutions=%d\n", tccp->numresolutions); - fprintf(fd, " cblkw=%d\n", tccp->cblkw); - fprintf(fd, " cblkh=%d\n", tccp->cblkh); - fprintf(fd, " cblksty=%x\n", tccp->cblksty); - fprintf(fd, " qmfbid=%d\n", tccp->qmfbid); - fprintf(fd, " qntsty=%d\n", tccp->qntsty); - fprintf(fd, " numgbits=%d\n", tccp->numgbits); - fprintf(fd, " roishift=%d\n", tccp->roishift); - fprintf(fd, " stepsizes="); - numbands = tccp->qntsty == J2K_CCP_QNTSTY_SIQNT ? 1 : tccp->numresolutions * 3 - 2; - for (bandno = 0; bandno < numbands; bandno++) { - fprintf(fd, "(%d,%d) ", tccp->stepsizes[bandno].mant, - tccp->stepsizes[bandno].expn); - } - fprintf(fd, "\n"); - - if (tccp->csty & J2K_CCP_CSTY_PRT) { - fprintf(fd, " prcw="); - for (resno = 0; resno < tccp->numresolutions; resno++) { - fprintf(fd, "%d ", tccp->prcw[resno]); - } - fprintf(fd, "\n"); - fprintf(fd, " prch="); - for (resno = 0; resno < tccp->numresolutions; resno++) { - fprintf(fd, "%d ", tccp->prch[resno]); - } - fprintf(fd, "\n"); - } - fprintf(fd, " }\n"); - } - fprintf(fd, " }\n"); - } - fprintf(fd, "}\n"); -} - /* ----------------------------------------------------------------------- */ static int j2k_get_num_tp(opj_cp_t *cp,int pino,int tileno){ char *prog; @@ -370,6 +315,9 @@ static int j2k_get_num_tp(opj_cp_t *cp,int pino,int tileno){ /** mem allocation for TLM marker*/ int j2k_calculate_tp(opj_cp_t *cp,int img_numcomp,opj_image_t *image,opj_j2k_t *j2k ){ int pino,tileno,totnum_tp=0; + + OPJ_ARG_NOT_USED(img_numcomp); + j2k->cur_totnum_tp = (int *) opj_malloc(cp->tw * cp->th * sizeof(int)); for (tileno = 0; tileno < cp->tw * cp->th; tileno++) { int cur_totnum_tp = 0; @@ -398,12 +346,14 @@ static void j2k_write_soc(opj_j2k_t *j2k) { opj_cio_t *cio = j2k->cio; cio_write(cio, J2K_MS_SOC, 2); + if(j2k->cstr_info) + j2k_add_mhmarker(j2k->cstr_info, J2K_MS_SOC, cio_tell(cio), 0); + /* UniPG>> */ #ifdef USE_JPWL /* update markers struct */ j2k_add_marker(j2k->cstr_info, J2K_MS_SOC, cio_tell(cio) - 2, 2); - #endif /* USE_JPWL */ /* <<UniPG */ } @@ -424,7 +374,7 @@ static void j2k_write_siz(opj_j2k_t *j2k) { opj_cio_t *cio = j2k->cio; opj_image_t *image = j2k->image; opj_cp_t *cp = j2k->cp; - + cio_write(cio, J2K_MS_SIZ, 2); /* SIZ */ lenp = cio_tell(cio); cio_skip(cio, 2); @@ -447,6 +397,9 @@ static void j2k_write_siz(opj_j2k_t *j2k) { cio_seek(cio, lenp); cio_write(cio, len, 2); /* Lsiz */ cio_seek(cio, lenp + len); + + if(j2k->cstr_info) + j2k_add_mhmarker(j2k->cstr_info, J2K_MS_SIZ, lenp, len); } static void j2k_read_siz(opj_j2k_t *j2k) { @@ -467,6 +420,13 @@ static void j2k_read_siz(opj_j2k_t *j2k) { cp->tx0 = cio_read(cio, 4); /* XT0siz */ cp->ty0 = cio_read(cio, 4); /* YT0siz */ + if ((image->x0<0)||(image->x1<0)||(image->y0<0)||(image->y1<0)) { + opj_event_msg(j2k->cinfo, EVT_ERROR, + "%s: invalid image size (x0:%d, x1:%d, y0:%d, y1:%d)\n", + image->x0,image->x1,image->y0,image->y1); + return; + } + image->numcomps = cio_read(cio, 2); /* Csiz */ #ifdef USE_JPWL @@ -670,6 +630,11 @@ static void j2k_write_com(opj_j2k_t *j2k) { cio_seek(cio, lenp); cio_write(cio, len, 2); cio_seek(cio, lenp + len); + + + if(j2k->cstr_info) + j2k_add_mhmarker(j2k->cstr_info, J2K_MS_COM, lenp, len); + } } @@ -713,7 +678,7 @@ static void j2k_read_cox(opj_j2k_t *j2k, int compno) { tccp->numresolutions = cio_read(cio, 1) + 1; /* SPcox (D) */ - // If user wants to remove more resolutions than the codestream contains, return error + /* If user wants to remove more resolutions than the codestream contains, return error*/ if (cp->reduce >= tccp->numresolutions) { opj_event_msg(j2k->cinfo, EVT_ERROR, "Error decoding component %d.\nThe number of resolutions to remove is higher than the number " "of resolutions of this component\nModify the cp_reduce parameter.\n\n", compno); @@ -773,6 +738,10 @@ static void j2k_write_cod(opj_j2k_t *j2k) { cio_seek(cio, lenp); cio_write(cio, len, 2); /* Lcod */ cio_seek(cio, lenp + len); + + if(j2k->cstr_info) + j2k_add_mhmarker(j2k->cstr_info, J2K_MS_COD, lenp, len); + } static void j2k_read_cod(opj_j2k_t *j2k) { @@ -901,6 +870,15 @@ static void j2k_read_qcx(opj_j2k_t *j2k, int compno, int len) { }; }; + +#else + /* We check whether there are too many subbands */ + if ((numbands < 0) || (numbands >= J2K_MAXBANDS)) { + opj_event_msg(j2k->cinfo, EVT_WARNING , + "bad number of subbands in Sqcx (%d) regarding to J2K_MAXBANDS (%d) \n" + "- limiting number of bands to J2K_MAXBANDS and try to move to the next markers\n", numbands, J2K_MAXBANDS); + } + #endif /* USE_JPWL */ for (bandno = 0; bandno < numbands; bandno++) { @@ -913,8 +891,10 @@ static void j2k_read_qcx(opj_j2k_t *j2k, int compno, int len) { expn = tmp >> 11; mant = tmp & 0x7ff; } - tccp->stepsizes[bandno].expn = expn; - tccp->stepsizes[bandno].mant = mant; + if (bandno < J2K_MAXBANDS){ + tccp->stepsizes[bandno].expn = expn; + tccp->stepsizes[bandno].mant = mant; + } } /* Add Antonin : if scalar_derived -> compute other stepsizes */ @@ -942,6 +922,9 @@ static void j2k_write_qcd(opj_j2k_t *j2k) { cio_seek(cio, lenp); cio_write(cio, len, 2); /* Lqcd */ cio_seek(cio, lenp + len); + + if(j2k->cstr_info) + j2k_add_mhmarker(j2k->cstr_info, J2K_MS_QCD, lenp, len); } static void j2k_read_qcd(opj_j2k_t *j2k) { @@ -978,7 +961,7 @@ static void j2k_read_qcc(opj_j2k_t *j2k) { int len, compno; int numcomp = j2k->image->numcomps; opj_cio_t *cio = j2k->cio; - + len = cio_read(cio, 2); /* Lqcc */ compno = cio_read(cio, numcomp <= 256 ? 1 : 2); /* Cqcc */ @@ -1263,6 +1246,10 @@ static void j2k_write_sot(opj_j2k_t *j2k) { j2k_add_marker(j2k->cstr_info, J2K_MS_SOT, j2k->sot_start, len + 2); #endif /* USE_JPWL */ /* <<UniPG */ + + if( j2k->cstr_info && j2k->cur_tp_num==0){ + j2k_add_tlmarker( j2k->curtileno, j2k->cstr_info, J2K_MS_SOT, lenp, len); + } } static void j2k_read_sot(opj_j2k_t *j2k) { @@ -1346,6 +1333,11 @@ static void j2k_read_sot(opj_j2k_t *j2k) { partno = cio_read(cio, 1); numparts = cio_read(cio, 1); + + if (partno >= numparts) { + opj_event_msg(j2k->cinfo, EVT_WARNING, "SOT marker inconsistency in tile %d: tile-part index greater (%d) than number of tile-parts (%d)\n", tileno, partno, numparts); + numparts = partno+1; + } j2k->curtileno = tileno; j2k->cur_tp_num = partno; @@ -1361,15 +1353,14 @@ static void j2k_read_sot(opj_j2k_t *j2k) { j2k->cstr_info->tile[tileno].tileno = tileno; j2k->cstr_info->tile[tileno].start_pos = cio_tell(cio) - 12; j2k->cstr_info->tile[tileno].end_pos = j2k->cstr_info->tile[tileno].start_pos + totlen - 1; - j2k->cstr_info->tile[tileno].num_tps = numparts; - if (numparts) - j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(numparts * sizeof(opj_tp_info_t)); - else - j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_malloc(10 * sizeof(opj_tp_info_t)); // Fixme (10) - } - else { + } else { j2k->cstr_info->tile[tileno].end_pos += totlen; - } + } + j2k->cstr_info->tile[tileno].num_tps = numparts; + if (numparts) + j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_realloc(j2k->cstr_info->tile[tileno].tp, numparts * sizeof(opj_tp_info_t)); + else + j2k->cstr_info->tile[tileno].tp = (opj_tp_info_t *) opj_realloc(j2k->cstr_info->tile[tileno].tp, 10 * sizeof(opj_tp_info_t)); /* Fixme (10)*/ j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos = cio_tell(cio) - 12; j2k->cstr_info->tile[tileno].tp[partno].tp_end_pos = j2k->cstr_info->tile[tileno].tp[partno].tp_start_pos + totlen - 1; @@ -1405,6 +1396,11 @@ static void j2k_write_sod(opj_j2k_t *j2k, void *tile_coder) { tcd->cur_tp_num = j2k->cur_tp_num; cio_write(cio, J2K_MS_SOD, 2); + + if( j2k->cstr_info && j2k->cur_tp_num==0){ + j2k_add_tlmarker( j2k->curtileno, j2k->cstr_info, J2K_MS_SOD, cio_tell(cio), 0); + } + if (j2k->curtileno == 0) { j2k->sod_start = cio_tell(cio) + j2k->pos_correction; } @@ -1431,7 +1427,11 @@ static void j2k_write_sod(opj_j2k_t *j2k, void *tile_coder) { tcp = &cp->tcps[j2k->curtileno]; for (layno = 0; layno < tcp->numlayers; layno++) { - tcp->rates[layno] -= tcp->rates[layno] ? (j2k->sod_start / (cp->th * cp->tw)) : 0; + if (tcp->rates[layno]>(j2k->sod_start / (cp->th * cp->tw))) { + tcp->rates[layno]-=(j2k->sod_start / (cp->th * cp->tw)); + } else if (tcp->rates[layno]) { + tcp->rates[layno]=1; + } } if(j2k->cur_tp_num == 0){ tcd->tcd_image->tiles->packno = 0; @@ -1554,7 +1554,7 @@ static void j2k_write_eoc(opj_j2k_t *j2k) { static void j2k_read_eoc(opj_j2k_t *j2k) { int i, tileno; - bool success; + opj_bool success; /* if packets should be decoded */ if (j2k->cp->limit_decoding != DECODE_ALL_BUT_PACKETS) { @@ -1567,7 +1567,7 @@ static void j2k_read_eoc(opj_j2k_t *j2k) { opj_free(j2k->tile_data[tileno]); j2k->tile_data[tileno] = NULL; tcd_free_decode_tile(tcd, i); - if (success == false) { + if (success == OPJ_FALSE) { j2k->state |= J2K_STATE_ERR; break; } @@ -1822,7 +1822,7 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c if (j2k->cp->correct) { int orig_pos = cio_tell(cio); - bool status; + opj_bool status; /* call the corrector */ status = jpwl_correct(j2k); @@ -1861,13 +1861,13 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c return 0; } e = j2k_dec_mstab_lookup(id); - // Check if the marker is known + /* Check if the marker is known*/ if (!(j2k->state & e->states)) { opj_image_destroy(image); opj_event_msg(cinfo, EVT_ERROR, "%.8x: unexpected marker %x\n", cio_tell(cio) - 2, id); return 0; } - // Check if the decoding is limited to the main header + /* Check if the decoding is limited to the main header*/ if (e->id == J2K_MS_SOT && j2k->cp->limit_decoding == LIMIT_TO_MAIN_HEADER) { opj_event_msg(cinfo, EVT_INFO, "Main Header decoded.\n"); return image; @@ -1893,7 +1893,6 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c if (j2k->state != J2K_STATE_MT) { opj_event_msg(cinfo, EVT_WARNING, "Incomplete bitstream\n"); } - return image; } @@ -1905,9 +1904,10 @@ opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestre opj_image_t *image = NULL; opj_jpt_msg_header_t header; int position; - opj_common_ptr cinfo = j2k->cinfo; - + + OPJ_ARG_NOT_USED(cstr_info); + j2k->cio = cio; /* create an empty image */ @@ -2098,12 +2098,12 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_ int i; /* set JPWL on */ - cp->epc_on = true; - cp->info_on = false; /* no informative technique */ + cp->epc_on = OPJ_TRUE; + cp->info_on = OPJ_FALSE; /* no informative technique */ /* set EPB on */ if ((parameters->jpwl_hprot_MH > 0) || (parameters->jpwl_hprot_TPH[0] > 0)) { - cp->epb_on = true; + cp->epb_on = OPJ_TRUE; cp->hprot_MH = parameters->jpwl_hprot_MH; for (i = 0; i < JPWL_MAX_NO_TILESPECS; i++) { @@ -2124,7 +2124,7 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_ /* set ESD writing */ if ((parameters->jpwl_sens_size == 1) || (parameters->jpwl_sens_size == 2)) { - cp->esd_on = true; + cp->esd_on = OPJ_TRUE; cp->sens_size = parameters->jpwl_sens_size; cp->sens_addr = parameters->jpwl_sens_addr; @@ -2138,10 +2138,10 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_ } /* always set RED writing to false: we are at the encoder */ - cp->red_on = false; + cp->red_on = OPJ_FALSE; } else { - cp->epc_on = false; + cp->epc_on = OPJ_FALSE; } #endif /* USE_JPWL */ @@ -2214,10 +2214,10 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_ if(parameters->cp_cinema) { - //Precinct size for lowest frequency subband=128 + /*Precinct size for lowest frequency subband=128*/ tccp->prcw[0] = 7; tccp->prch[0] = 7; - //Precinct size at all other resolutions = 256 + /*Precinct size at all other resolutions = 256*/ for (j = 1; j < tccp->numresolutions; j++) { tccp->prcw[j] = 8; tccp->prch[j] = 8; @@ -2259,7 +2259,7 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_ } p++; /*printf("\nsize precinct for level %d : %d,%d\n", j,tccp->prcw[j], tccp->prch[j]); */ - } //end for + } /*end for*/ } else { for (j = 0; j < tccp->numresolutions; j++) { tccp->prcw[j] = 15; @@ -2273,7 +2273,7 @@ void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_ } } -bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { +opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { int tileno, compno; opj_cp_t *cp = NULL; @@ -2284,8 +2284,6 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre cp = j2k->cp; - /* j2k_dump_cp(stdout, image, cp); */ - /* INDEX >> */ j2k->cstr_info = cstr_info; if (cstr_info) { @@ -2382,6 +2380,9 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre /* INDEX >> */ if(cstr_info) { cstr_info->tile[j2k->curtileno].start_pos = cio_tell(cio) + j2k->pos_correction; + cstr_info->tile[j2k->curtileno].maxmarknum = 10; + cstr_info->tile[j2k->curtileno].marker = (opj_marker_info_t *) opj_malloc(cstr_info->tile[j2k->curtileno].maxmarknum * sizeof(opj_marker_info_t)); + cstr_info->tile[j2k->curtileno].marknum = 0; } /* << INDEX */ @@ -2488,11 +2489,46 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestre } #endif /* USE_JPWL */ - return true; + return OPJ_TRUE; +} + +static void j2k_add_mhmarker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) { + + if (!cstr_info) + return; + + /* expand the list? */ + if ((cstr_info->marknum + 1) > cstr_info->maxmarknum) { + cstr_info->maxmarknum = 100 + (int) ((float) cstr_info->maxmarknum * 1.0F); + cstr_info->marker = (opj_marker_info_t*)opj_realloc(cstr_info->marker, cstr_info->maxmarknum); + } + + /* add the marker */ + cstr_info->marker[cstr_info->marknum].type = type; + cstr_info->marker[cstr_info->marknum].pos = pos; + cstr_info->marker[cstr_info->marknum].len = len; + cstr_info->marknum++; + } +static void j2k_add_tlmarker( int tileno, opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) { + opj_marker_info_t *marker; + if (!cstr_info) + return; + /* expand the list? */ + if ((cstr_info->tile[tileno].marknum + 1) > cstr_info->tile[tileno].maxmarknum) { + cstr_info->tile[tileno].maxmarknum = 100 + (int) ((float) cstr_info->tile[tileno].maxmarknum * 1.0F); + cstr_info->tile[tileno].marker = (opj_marker_info_t*)opj_realloc(cstr_info->tile[tileno].marker, cstr_info->maxmarknum); + } + marker = &(cstr_info->tile[tileno].marker[cstr_info->tile[tileno].marknum]); + /* add the marker */ + marker->type = type; + marker->pos = pos; + marker->len = len; + cstr_info->tile[tileno].marknum++; +} diff --git a/extern/libopenjpeg/j2k.h b/extern/libopenjpeg/j2k.h index 5599be47a8d..6338c290dfd 100644 --- a/extern/libopenjpeg/j2k.h +++ b/extern/libopenjpeg/j2k.h @@ -45,12 +45,12 @@ The functions in J2K.C have for goal to read/write the several parts of the code #define J2K_CP_CSTY_SOP 0x02 #define J2K_CP_CSTY_EPH 0x04 #define J2K_CCP_CSTY_PRT 0x01 -#define J2K_CCP_CBLKSTY_LAZY 0x01 -#define J2K_CCP_CBLKSTY_RESET 0x02 -#define J2K_CCP_CBLKSTY_TERMALL 0x04 -#define J2K_CCP_CBLKSTY_VSC 0x08 -#define J2K_CCP_CBLKSTY_PTERM 0x10 -#define J2K_CCP_CBLKSTY_SEGSYM 0x20 +#define J2K_CCP_CBLKSTY_LAZY 0x01 /**< Selective arithmetic coding bypass */ +#define J2K_CCP_CBLKSTY_RESET 0x02 /**< Reset context probabilities on coding pass boundaries */ +#define J2K_CCP_CBLKSTY_TERMALL 0x04 /**< Termination on each coding pass */ +#define J2K_CCP_CBLKSTY_VSC 0x08 /**< Vertically stripe causal context */ +#define J2K_CCP_CBLKSTY_PTERM 0x10 /**< Predictable termination */ +#define J2K_CCP_CBLKSTY_SEGSYM 0x20 /**< Segmentation symbols are used */ #define J2K_CCP_QNTSTY_NOQNT 0 #define J2K_CCP_QNTSTY_SIQNT 1 #define J2K_CCP_QNTSTY_SEQNT 2 @@ -265,15 +265,15 @@ typedef struct opj_cp { /* UniPG>> */ #ifdef USE_JPWL /** enables writing of EPC in MH, thus activating JPWL */ - bool epc_on; + opj_bool epc_on; /** enables writing of EPB, in case of activated JPWL */ - bool epb_on; + opj_bool epb_on; /** enables writing of ESD, in case of activated JPWL */ - bool esd_on; + opj_bool esd_on; /** enables writing of informative techniques of ESD, in case of activated JPWL */ - bool info_on; + opj_bool info_on; /** enables writing of RED, in case of activated JPWL */ - bool red_on; + opj_bool red_on; /** error protection method for MH (0,1,16,32,37-128) */ int hprot_MH; /** tile number of header protection specification (>=0) */ @@ -299,7 +299,7 @@ typedef struct opj_cp { /** sensitivity methods for TPHs (-1,0-7) */ int sens_TPH[JPWL_MAX_NO_TILESPECS]; /** enables JPWL correction at the decoder */ - bool correct; + opj_bool correct; /** expected number of components at the decoder */ int exp_comps; /** maximum number of tiles at the decoder */ @@ -436,7 +436,7 @@ Encode an image into a JPEG-2000 codestream @param cstr_info Codestream information structure if required, NULL otherwise @return Returns true if successful, returns false otherwise */ -bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); +opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); /* ----------------------------------------------------------------------- */ /*@}*/ diff --git a/extern/libopenjpeg/j2k_lib.c b/extern/libopenjpeg/j2k_lib.c index 91aee007152..a66e31e9afb 100644 --- a/extern/libopenjpeg/j2k_lib.c +++ b/extern/libopenjpeg/j2k_lib.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,18 +24,18 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifdef WIN32 +#ifdef _WIN32 #include <windows.h> #else #include <sys/time.h> #include <sys/resource.h> #include <sys/times.h> -#endif /* WIN32 */ +#endif /* _WIN32 */ #include "opj_includes.h" double opj_clock(void) { -#ifdef WIN32 - /* WIN32: use QueryPerformance (very accurate) */ +#ifdef _WIN32 + /* _WIN32: use QueryPerformance (very accurate) */ LARGE_INTEGER freq , t ; /* freq is the clock speed of the CPU */ QueryPerformanceFrequency(&freq) ; diff --git a/extern/libopenjpeg/j2k_lib.h b/extern/libopenjpeg/j2k_lib.h index 7df4d367757..5f3406e5106 100644 --- a/extern/libopenjpeg/j2k_lib.h +++ b/extern/libopenjpeg/j2k_lib.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/extern/libopenjpeg/jp2.c b/extern/libopenjpeg/jp2.c index b2831cfb0b5..5ae114c33b9 100644 --- a/extern/libopenjpeg/jp2.c +++ b/extern/libopenjpeg/jp2.c @@ -5,6 +5,7 @@ * Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team + * Copyright (c) 2010-2011, Kaori Hagihara * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,7 +29,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - #include "opj_includes.h" /** @defgroup JP2 JP2 - JPEG-2000 file format reader/writer */ @@ -44,7 +44,7 @@ Read box headers @param box @return Returns true if successful, returns false otherwise */ -static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box); +static opj_bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box); /*static void jp2_write_url(opj_cio_t *cio, char *Idx_file);*/ /** Read the IHDR box - Image Header box @@ -52,12 +52,11 @@ Read the IHDR box - Image Header box @param cio Input buffer stream @return Returns true if successful, returns false otherwise */ -static bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio); +static opj_bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio); static void jp2_write_ihdr(opj_jp2_t *jp2, opj_cio_t *cio); static void jp2_write_bpcc(opj_jp2_t *jp2, opj_cio_t *cio); -static bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio); +static opj_bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio); static void jp2_write_colr(opj_jp2_t *jp2, opj_cio_t *cio); -static bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio); /** Write the FTYP box - File type box @param jp2 JP2 handle @@ -70,9 +69,9 @@ Read the FTYP box - File type box @param cio Input buffer stream @return Returns true if successful, returns false otherwise */ -static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio); +static opj_bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio); static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); -static bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset); +static opj_bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset); static void jp2_write_jp(opj_cio_t *cio); /** Read the JP box - JPEG 2000 signature @@ -80,29 +79,92 @@ Read the JP box - JPEG 2000 signature @param cio Input buffer stream @return Returns true if successful, returns false otherwise */ -static bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio); +static opj_bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio); /** Decode the structure of a JP2 file @param jp2 JP2 handle @param cio Input buffer stream +@param color Collector for profile, cdef and pclr data @return Returns true if successful, returns false otherwise */ -static bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio); - +static opj_bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_color_t *color); +/** +Apply collected palette data +@param color Collector for profile, cdef and pclr data +@param image +*/ +static void jp2_apply_pclr(opj_jp2_color_t *color, opj_image_t *image, opj_common_ptr cinfo); +/** +Collect palette data +@param jp2 JP2 handle +@param cio Input buffer stream +@param box +@param color Collector for profile, cdef and pclr data +@return Returns true if successful, returns false otherwise +*/ +static opj_bool jp2_read_pclr(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_box_t *box, opj_jp2_color_t *color); +/** +Collect component mapping data +@param jp2 JP2 handle +@param cio Input buffer stream +@param box +@param color Collector for profile, cdef and pclr data +@return Returns true if successful, returns false otherwise +*/ +static opj_bool jp2_read_cmap(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_box_t *box, opj_jp2_color_t *color); +/** +Collect colour specification data +@param jp2 JP2 handle +@param cio Input buffer stream +@param box +@param color Collector for profile, cdef and pclr data +@return Returns true if successful, returns false otherwise +*/ +static opj_bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_box_t *box, opj_jp2_color_t *color); +/** +Write file Index (superbox) +@param[in] offset_jp2c offset of jp2c box +@param[in] length_jp2c length of jp2c box +@param[in] offset_idx offset of cidx box +@param[in] length_idx length of cidx box +@param[in] cio file output handle +@return length of fidx box +*/ +static int write_fidx( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio); +/** +Write index Finder box +@param[in] offset offset of fidx box +@param[in] length length of fidx box +@param[in] cio file output handle +*/ +static void write_iptr( int offset, int length, opj_cio_t *cio); +/** +Write proxy box +@param[in] offset_jp2c offset of jp2c box +@param[in] length_jp2c length of jp2c box +@param[in] offset_idx offset of cidx box +@param[in] length_idx length of cidx box +@param[in] cio file output handle +*/ +static void write_prxy( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio); /*@}*/ /*@}*/ /* ----------------------------------------------------------------------- */ -static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box) { +static opj_bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t *box) { box->init_pos = cio_tell(cio); box->length = cio_read(cio, 4); box->type = cio_read(cio, 4); if (box->length == 1) { if (cio_read(cio, 4) != 0) { opj_event_msg(cinfo, EVT_ERROR, "Cannot handle box sizes higher than 2^32\n"); - return false; + return OPJ_FALSE; } box->length = cio_read(cio, 4); if (box->length == 0) @@ -112,7 +174,7 @@ static bool jp2_read_boxhdr(opj_common_ptr cinfo, opj_cio_t *cio, opj_jp2_box_t box->length = cio_numbytesleft(cio) + 8; } - return true; + return OPJ_TRUE; } #if 0 @@ -139,7 +201,7 @@ static void jp2_write_url(opj_cio_t *cio, char *Idx_file) { } #endif -static bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) { +static opj_bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) { opj_jp2_box_t box; opj_common_ptr cinfo = jp2->cinfo; @@ -147,7 +209,7 @@ static bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) { jp2_read_boxhdr(cinfo, cio, &box); if (JP2_IHDR != box.type) { opj_event_msg(cinfo, EVT_ERROR, "Expected IHDR Marker\n"); - return false; + return OPJ_FALSE; } jp2->h = cio_read(cio, 4); /* HEIGHT */ @@ -163,10 +225,10 @@ static bool jp2_read_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) { if (cio_tell(cio) - box.init_pos != box.length) { opj_event_msg(cinfo, EVT_ERROR, "Error with IHDR Box\n"); - return false; + return OPJ_FALSE; } - return true; + return OPJ_TRUE; } static void jp2_write_ihdr(opj_jp2_t *jp2, opj_cio_t *cio) { @@ -211,7 +273,7 @@ static void jp2_write_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) { } -static bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) { +static opj_bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) { unsigned int i; opj_jp2_box_t box; @@ -220,7 +282,7 @@ static bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) { jp2_read_boxhdr(cinfo, cio, &box); if (JP2_BPCC != box.type) { opj_event_msg(cinfo, EVT_ERROR, "Expected BPCC Marker\n"); - return false; + return OPJ_FALSE; } for (i = 0; i < jp2->numcomps; i++) { @@ -229,10 +291,10 @@ static bool jp2_read_bpcc(opj_jp2_t *jp2, opj_cio_t *cio) { if (cio_tell(cio) - box.init_pos != box.length) { opj_event_msg(cinfo, EVT_ERROR, "Error with BPCC Box\n"); - return false; + return OPJ_FALSE; } - return true; + return OPJ_TRUE; } static void jp2_write_colr(opj_jp2_t *jp2, opj_cio_t *cio) { @@ -246,11 +308,10 @@ static void jp2_write_colr(opj_jp2_t *jp2, opj_cio_t *cio) { cio_write(cio, jp2->precedence, 1); /* PRECEDENCE */ cio_write(cio, jp2->approx, 1); /* APPROX */ - if (jp2->meth == 1) { - cio_write(cio, jp2->enumcs, 4); /* EnumCS */ - } else { - cio_write(cio, 0, 1); /* PROFILE (??) */ - } + if(jp2->meth == 2) + jp2->enumcs = 0; + + cio_write(cio, jp2->enumcs, 4); /* EnumCS */ box.length = cio_tell(cio) - box.init_pos; cio_seek(cio, box.init_pos); @@ -258,42 +319,478 @@ static void jp2_write_colr(opj_jp2_t *jp2, opj_cio_t *cio) { cio_seek(cio, box.init_pos + box.length); } -static bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio) { - opj_jp2_box_t box; +static void jp2_free_pclr(opj_jp2_color_t *color) +{ + opj_free(color->jp2_pclr->channel_sign); + opj_free(color->jp2_pclr->channel_size); + opj_free(color->jp2_pclr->entries); + + if(color->jp2_pclr->cmap) opj_free(color->jp2_pclr->cmap); + + opj_free(color->jp2_pclr); color->jp2_pclr = NULL; +} + +static void free_color_data(opj_jp2_color_t *color) +{ + if(color->jp2_pclr) + { + jp2_free_pclr(color); + } + if(color->jp2_cdef) + { + if(color->jp2_cdef->info) opj_free(color->jp2_cdef->info); + opj_free(color->jp2_cdef); + } + if(color->icc_profile_buf) opj_free(color->icc_profile_buf); +} + +static void jp2_apply_pclr(opj_jp2_color_t *color, opj_image_t *image, opj_common_ptr cinfo) +{ + opj_image_comp_t *old_comps, *new_comps; + unsigned char *channel_size, *channel_sign; + unsigned int *entries; + opj_jp2_cmap_comp_t *cmap; + int *src, *dst; + unsigned int j, max; + unsigned short i, nr_channels, cmp, pcol; + int k, top_k; + + channel_size = color->jp2_pclr->channel_size; + channel_sign = color->jp2_pclr->channel_sign; + entries = color->jp2_pclr->entries; + cmap = color->jp2_pclr->cmap; + nr_channels = color->jp2_pclr->nr_channels; + + old_comps = image->comps; + new_comps = (opj_image_comp_t*) + opj_malloc(nr_channels * sizeof(opj_image_comp_t)); + + for(i = 0; i < nr_channels; ++i) + { + pcol = cmap[i].pcol; cmp = cmap[i].cmp; + + if( pcol < nr_channels ) + new_comps[pcol] = old_comps[cmp]; + else + { + opj_event_msg(cinfo, EVT_ERROR, "Error with pcol value %d (max: %d). skipping\n", pcol, nr_channels); + continue; + } + + if(cmap[i].mtyp == 0) /* Direct use */ + { + old_comps[cmp].data = NULL; continue; + } +/* Palette mapping: */ + new_comps[pcol].data = (int*) + opj_malloc(old_comps[cmp].w * old_comps[cmp].h * sizeof(int)); + new_comps[pcol].prec = channel_size[i]; + new_comps[pcol].sgnd = channel_sign[i]; + } + top_k = color->jp2_pclr->nr_entries - 1; + + for(i = 0; i < nr_channels; ++i) + { +/* Direct use: */ + if(cmap[i].mtyp == 0) continue; + +/* Palette mapping: */ + cmp = cmap[i].cmp; pcol = cmap[i].pcol; + src = old_comps[cmp].data; + dst = new_comps[pcol].data; + max = new_comps[pcol].w * new_comps[pcol].h; + + for(j = 0; j < max; ++j) + { +/* The index */ + if((k = src[j]) < 0) k = 0; else if(k > top_k) k = top_k; +/* The colour */ + dst[j] = entries[k * nr_channels + pcol]; + } + } + max = image->numcomps; + for(i = 0; i < max; ++i) + { + if(old_comps[i].data) opj_free(old_comps[i].data); + } + opj_free(old_comps); + image->comps = new_comps; + image->numcomps = nr_channels; + + jp2_free_pclr(color); + +}/* apply_pclr() */ + +static opj_bool jp2_read_pclr(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_box_t *box, opj_jp2_color_t *color) +{ + opj_jp2_pclr_t *jp2_pclr; + unsigned char *channel_size, *channel_sign; + unsigned int *entries; + unsigned short nr_entries, nr_channels; + unsigned short i, j; + unsigned char uc; + + OPJ_ARG_NOT_USED(box); + OPJ_ARG_NOT_USED(jp2); + +/* Part 1, I.5.3.4: 'There shall be at most one Palette box inside + * a JP2 Header box' : +*/ + if(color->jp2_pclr) return OPJ_FALSE; + + nr_entries = (unsigned short)cio_read(cio, 2); /* NE */ + nr_channels = (unsigned short)cio_read(cio, 1);/* NPC */ + + entries = (unsigned int*) + opj_malloc(nr_channels * nr_entries * sizeof(unsigned int)); + channel_size = (unsigned char*)opj_malloc(nr_channels); + channel_sign = (unsigned char*)opj_malloc(nr_channels); + + jp2_pclr = (opj_jp2_pclr_t*)opj_malloc(sizeof(opj_jp2_pclr_t)); + jp2_pclr->channel_sign = channel_sign; + jp2_pclr->channel_size = channel_size; + jp2_pclr->entries = entries; + jp2_pclr->nr_entries = nr_entries; + jp2_pclr->nr_channels = nr_channels; + jp2_pclr->cmap = NULL; + + color->jp2_pclr = jp2_pclr; + + for(i = 0; i < nr_channels; ++i) + { + uc = cio_read(cio, 1); /* Bi */ + channel_size[i] = (uc & 0x7f) + 1; + channel_sign[i] = (uc & 0x80)?1:0; + } + + for(j = 0; j < nr_entries; ++j) + { + for(i = 0; i < nr_channels; ++i) + { +/* Cji */ + *entries++ = cio_read(cio, channel_size[i]>>3); + } + } + + return OPJ_TRUE; +}/* jp2_read_pclr() */ + +static opj_bool jp2_read_cmap(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_box_t *box, opj_jp2_color_t *color) +{ + opj_jp2_cmap_comp_t *cmap; + unsigned short i, nr_channels; + + OPJ_ARG_NOT_USED(box); + OPJ_ARG_NOT_USED(jp2); + +/* Need nr_channels: */ + if(color->jp2_pclr == NULL) return OPJ_FALSE; + +/* Part 1, I.5.3.5: 'There shall be at most one Component Mapping box + * inside a JP2 Header box' : +*/ + if(color->jp2_pclr->cmap) return OPJ_FALSE; + + nr_channels = color->jp2_pclr->nr_channels; + cmap = (opj_jp2_cmap_comp_t*) + opj_malloc(nr_channels * sizeof(opj_jp2_cmap_comp_t)); + + for(i = 0; i < nr_channels; ++i) + { + cmap[i].cmp = (unsigned short)cio_read(cio, 2); + cmap[i].mtyp = cio_read(cio, 1); + cmap[i].pcol = cio_read(cio, 1); + + } + color->jp2_pclr->cmap = cmap; + + return OPJ_TRUE; +}/* jp2_read_cmap() */ + +static void jp2_apply_cdef(opj_image_t *image, opj_jp2_color_t *color) +{ + opj_jp2_cdef_info_t *info; + int color_space; + unsigned short i, n, cn, typ, asoc, acn; + + color_space = image->color_space; + info = color->jp2_cdef->info; + n = color->jp2_cdef->n; + + for(i = 0; i < n; ++i) + { +/* WATCH: acn = asoc - 1 ! */ + if((asoc = info[i].asoc) == 0) continue; + + cn = info[i].cn; typ = info[i].typ; acn = asoc - 1; + + if(cn != acn) + { + opj_image_comp_t saved; + + memcpy(&saved, &image->comps[cn], sizeof(opj_image_comp_t)); + memcpy(&image->comps[cn], &image->comps[acn], sizeof(opj_image_comp_t)); + memcpy(&image->comps[acn], &saved, sizeof(opj_image_comp_t)); + + info[i].asoc = cn + 1; + info[acn].asoc = info[acn].cn + 1; + } + } + if(color->jp2_cdef->info) opj_free(color->jp2_cdef->info); + + opj_free(color->jp2_cdef); color->jp2_cdef = NULL; + +}/* jp2_apply_cdef() */ + +static opj_bool jp2_read_cdef(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_box_t *box, opj_jp2_color_t *color) +{ + opj_jp2_cdef_info_t *info; + unsigned short i, n; + + OPJ_ARG_NOT_USED(box); + OPJ_ARG_NOT_USED(jp2); + +/* Part 1, I.5.3.6: 'The shall be at most one Channel Definition box + * inside a JP2 Header box.' +*/ + if(color->jp2_cdef) return OPJ_FALSE; + + if((n = (unsigned short)cio_read(cio, 2)) == 0) return OPJ_FALSE; /* szukw000: FIXME */ + + info = (opj_jp2_cdef_info_t*) + opj_malloc(n * sizeof(opj_jp2_cdef_info_t)); + + color->jp2_cdef = (opj_jp2_cdef_t*)opj_malloc(sizeof(opj_jp2_cdef_t)); + color->jp2_cdef->info = info; + color->jp2_cdef->n = n; + + for(i = 0; i < n; ++i) + { + info[i].cn = (unsigned short)cio_read(cio, 2); + info[i].typ = (unsigned short)cio_read(cio, 2); + info[i].asoc = (unsigned short)cio_read(cio, 2); + + } + return OPJ_TRUE; +}/* jp2_read_cdef() */ + +static opj_bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_box_t *box, opj_jp2_color_t *color) +{ int skip_len; + opj_common_ptr cinfo; - opj_common_ptr cinfo = jp2->cinfo; +/* Part 1, I.5.3.3 : 'A conforming JP2 reader shall ignore all Colour + * Specification boxes after the first.' +*/ + if(color->jp2_has_colr) return OPJ_FALSE; - jp2_read_boxhdr(cinfo, cio, &box); - do { - if (JP2_COLR != box.type) { - cio_skip(cio, box.length - 8); - jp2_read_boxhdr(cinfo, cio, &box); - } - } while(JP2_COLR != box.type); + cinfo = jp2->cinfo; jp2->meth = cio_read(cio, 1); /* METH */ jp2->precedence = cio_read(cio, 1); /* PRECEDENCE */ jp2->approx = cio_read(cio, 1); /* APPROX */ - if (jp2->meth == 1) { - jp2->enumcs = cio_read(cio, 4); /* EnumCS */ - } else { - /* skip PROFILE */ - skip_len = box.init_pos + box.length - cio_tell(cio); - if (skip_len < 0) { - opj_event_msg(cinfo, EVT_ERROR, "Error with JP2H box size\n"); - return false; - } - cio_skip(cio, box.init_pos + box.length - cio_tell(cio)); - } + if (jp2->meth == 1) + { + jp2->enumcs = cio_read(cio, 4); /* EnumCS */ + } + else + if (jp2->meth == 2) + { +/* skip PROFILE */ + skip_len = box->init_pos + box->length - cio_tell(cio); + if (skip_len < 0) + { + opj_event_msg(cinfo, EVT_ERROR, "Error with COLR box size\n"); + return OPJ_FALSE; + } + if(skip_len > 0) + { + unsigned char *start; + + start = cio_getbp(cio); + color->icc_profile_buf = (unsigned char*)opj_malloc(skip_len); + color->icc_profile_len = skip_len; + + cio_skip(cio, box->init_pos + box->length - cio_tell(cio)); + + memcpy(color->icc_profile_buf, start, skip_len); + } + } + + if (cio_tell(cio) - box->init_pos != box->length) + { + opj_event_msg(cinfo, EVT_ERROR, "Error with COLR Box\n"); + return OPJ_FALSE; + } + color->jp2_has_colr = 1; + + return OPJ_TRUE; +}/* jp2_read_colr() */ + +opj_bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_color_t *color) +{ + opj_jp2_box_t box; + int jp2h_end; + + opj_common_ptr cinfo = jp2->cinfo; + + jp2_read_boxhdr(cinfo, cio, &box); + do + { + if (JP2_JP2H != box.type) + { + if (box.type == JP2_JP2C) + { + opj_event_msg(cinfo, EVT_ERROR, "Expected JP2H Marker\n"); + return OPJ_FALSE; + } + cio_skip(cio, box.length - 8); + + if(cio->bp >= cio->end) return OPJ_FALSE; + + jp2_read_boxhdr(cinfo, cio, &box); + } + } while(JP2_JP2H != box.type); + + if (!jp2_read_ihdr(jp2, cio)) + return OPJ_FALSE; + jp2h_end = box.init_pos + box.length; + + if (jp2->bpc == 255) + { + if (!jp2_read_bpcc(jp2, cio)) + return OPJ_FALSE; + } + jp2_read_boxhdr(cinfo, cio, &box); + + while(cio_tell(cio) < jp2h_end) + { + if(box.type == JP2_COLR) + { + if( !jp2_read_colr(jp2, cio, &box, color)) + { + cio_seek(cio, box.init_pos + 8); + cio_skip(cio, box.length - 8); + } + jp2_read_boxhdr(cinfo, cio, &box); + continue; + } + if(box.type == JP2_CDEF && !jp2->ignore_pclr_cmap_cdef) + { + if( !jp2_read_cdef(jp2, cio, &box, color)) + { + cio_seek(cio, box.init_pos + 8); + cio_skip(cio, box.length - 8); + } + jp2_read_boxhdr(cinfo, cio, &box); + continue; + } + if(box.type == JP2_PCLR && !jp2->ignore_pclr_cmap_cdef) + { + if( !jp2_read_pclr(jp2, cio, &box, color)) + { + cio_seek(cio, box.init_pos + 8); + cio_skip(cio, box.length - 8); + } + jp2_read_boxhdr(cinfo, cio, &box); + continue; + } + if(box.type == JP2_CMAP && !jp2->ignore_pclr_cmap_cdef) + { + if( !jp2_read_cmap(jp2, cio, &box, color)) + { + cio_seek(cio, box.init_pos + 8); + cio_skip(cio, box.length - 8); + } + jp2_read_boxhdr(cinfo, cio, &box); + continue; + } + cio_seek(cio, box.init_pos + 8); + cio_skip(cio, box.length - 8); + jp2_read_boxhdr(cinfo, cio, &box); + + }/* while(cio_tell(cio) < box_end) */ + + cio_seek(cio, jp2h_end); + +/* Part 1, I.5.3.3 : 'must contain at least one' */ + return (color->jp2_has_colr == 1); + +}/* jp2_read_jp2h() */ + +opj_image_t* opj_jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, + opj_codestream_info_t *cstr_info) +{ + opj_common_ptr cinfo; + opj_image_t *image = NULL; + opj_jp2_color_t color; + + if(!jp2 || !cio) + { + return NULL; + } + memset(&color, 0, sizeof(opj_jp2_color_t)); + cinfo = jp2->cinfo; + +/* JP2 decoding */ + if(!jp2_read_struct(jp2, cio, &color)) + { + free_color_data(&color); + opj_event_msg(cinfo, EVT_ERROR, "Failed to decode jp2 structure\n"); + return NULL; + } + +/* J2K decoding */ + image = j2k_decode(jp2->j2k, cio, cstr_info); + + if(!image) + { + free_color_data(&color); + opj_event_msg(cinfo, EVT_ERROR, "Failed to decode J2K image\n"); + return NULL; + } + + if (!jp2->ignore_pclr_cmap_cdef){ + + /* Set Image Color Space */ + if (jp2->enumcs == 16) + image->color_space = CLRSPC_SRGB; + else if (jp2->enumcs == 17) + image->color_space = CLRSPC_GRAY; + else if (jp2->enumcs == 18) + image->color_space = CLRSPC_SYCC; + else + image->color_space = CLRSPC_UNKNOWN; + + if(color.jp2_cdef) + { + jp2_apply_cdef(image, &color); + } + if(color.jp2_pclr) + { +/* Part 1, I.5.3.4: Either both or none : */ + if( !color.jp2_pclr->cmap) + jp2_free_pclr(&color); + else + jp2_apply_pclr(&color, image, cinfo); + } + if(color.icc_profile_buf) + { + image->icc_profile_buf = color.icc_profile_buf; + color.icc_profile_buf = NULL; + image->icc_profile_len = color.icc_profile_len; + } + } + + return image; + +}/* opj_jp2_decode() */ - if (cio_tell(cio) - box.init_pos != box.length) { - opj_event_msg(cinfo, EVT_ERROR, "Error with BPCC Box\n"); - return false; - } - return true; -} void jp2_write_jp2h(opj_jp2_t *jp2, opj_cio_t *cio) { opj_jp2_box_t box; @@ -315,44 +812,6 @@ void jp2_write_jp2h(opj_jp2_t *jp2, opj_cio_t *cio) { cio_seek(cio, box.init_pos + box.length); } -bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio) { - opj_jp2_box_t box; - int skip_len; - - opj_common_ptr cinfo = jp2->cinfo; - - jp2_read_boxhdr(cinfo, cio, &box); - do { - if (JP2_JP2H != box.type) { - if (box.type == JP2_JP2C) { - opj_event_msg(cinfo, EVT_ERROR, "Expected JP2H Marker\n"); - return false; - } - cio_skip(cio, box.length - 8); - jp2_read_boxhdr(cinfo, cio, &box); - } - } while(JP2_JP2H != box.type); - - if (!jp2_read_ihdr(jp2, cio)) - return false; - - if (jp2->bpc == 255) { - if (!jp2_read_bpcc(jp2, cio)) - return false; - } - if (!jp2_read_colr(jp2, cio)) - return false; - - skip_len = box.init_pos + box.length - cio_tell(cio); - if (skip_len < 0) { - opj_event_msg(cinfo, EVT_ERROR, "Error with JP2H Box\n"); - return false; - } - cio_skip(cio, box.init_pos + box.length - cio_tell(cio)); - - return true; -} - static void jp2_write_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) { unsigned int i; opj_jp2_box_t box; @@ -374,7 +833,7 @@ static void jp2_write_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) { cio_seek(cio, box.init_pos + box.length); } -static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) { +static opj_bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) { int i; opj_jp2_box_t box; @@ -384,7 +843,7 @@ static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) { if (JP2_FTYP != box.type) { opj_event_msg(cinfo, EVT_ERROR, "Expected FTYP Marker\n"); - return false; + return OPJ_FALSE; } jp2->brand = cio_read(cio, 4); /* BR */ @@ -398,10 +857,10 @@ static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) { if (cio_tell(cio) - box.init_pos != box.length) { opj_event_msg(cinfo, EVT_ERROR, "Error with FTYP Box\n"); - return false; + return OPJ_FALSE; } - return true; + return OPJ_TRUE; } static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { @@ -433,7 +892,7 @@ static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, op return box.length; } -static bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset) { +static opj_bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset) { opj_jp2_box_t box; opj_common_ptr cinfo = jp2->cinfo; @@ -449,7 +908,7 @@ static bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_code *j2k_codestream_offset = cio_tell(cio); *j2k_codestream_length = box.length - 8; - return true; + return OPJ_TRUE; } static void jp2_write_jp(opj_cio_t *cio) { @@ -466,7 +925,7 @@ static void jp2_write_jp(opj_cio_t *cio) { cio_seek(cio, box.init_pos + box.length); } -static bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio) { +static opj_bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio) { opj_jp2_box_t box; opj_common_ptr cinfo = jp2->cinfo; @@ -474,34 +933,96 @@ static bool jp2_read_jp(opj_jp2_t *jp2, opj_cio_t *cio) { jp2_read_boxhdr(cinfo, cio, &box); if (JP2_JP != box.type) { opj_event_msg(cinfo, EVT_ERROR, "Expected JP Marker\n"); - return false; + return OPJ_FALSE; } if (0x0d0a870a != cio_read(cio, 4)) { opj_event_msg(cinfo, EVT_ERROR, "Error with JP Marker\n"); - return false; + return OPJ_FALSE; } if (cio_tell(cio) - box.init_pos != box.length) { opj_event_msg(cinfo, EVT_ERROR, "Error with JP Box size\n"); - return false; + return OPJ_FALSE; } - return true; + return OPJ_TRUE; } -static bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio) { +static opj_bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio, + opj_jp2_color_t *color) { if (!jp2_read_jp(jp2, cio)) - return false; + return OPJ_FALSE; if (!jp2_read_ftyp(jp2, cio)) - return false; - if (!jp2_read_jp2h(jp2, cio)) - return false; + return OPJ_FALSE; + if (!jp2_read_jp2h(jp2, cio, color)) + return OPJ_FALSE; if (!jp2_read_jp2c(jp2, cio, &jp2->j2k_codestream_length, &jp2->j2k_codestream_offset)) - return false; + return OPJ_FALSE; - return true; + return OPJ_TRUE; +} + + +static int write_fidx( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio) +{ + int len, lenp; + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_FIDX, 4); /* IPTR */ + + write_prxy( offset_jp2c, length_jp2c, offset_idx, length_idx, cio); + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + + return len; +} + +static void write_prxy( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio) +{ + int len, lenp; + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_PRXY, 4); /* IPTR */ + + cio_write( cio, offset_jp2c, 8); /* OOFF */ + cio_write( cio, length_jp2c, 4); /* OBH part 1 */ + cio_write( cio, JP2_JP2C, 4); /* OBH part 2 */ + + cio_write( cio, 1,1); /* NI */ + + cio_write( cio, offset_idx, 8); /* IOFF */ + cio_write( cio, length_idx, 4); /* IBH part 1 */ + cio_write( cio, JPIP_CIDX, 4); /* IBH part 2 */ + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); } +static void write_iptr( int offset, int length, opj_cio_t *cio) +{ + int len, lenp; + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_IPTR, 4); /* IPTR */ + + cio_write( cio, offset, 8); + cio_write( cio, length, 8); + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); +} + + /* ----------------------------------------------------------------------- */ /* JP2 decoder interface */ /* ----------------------------------------------------------------------- */ @@ -539,42 +1060,7 @@ void jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters) { /* setup the J2K codec */ j2k_setup_decoder(jp2->j2k, parameters); /* further JP2 initializations go here */ -} - -opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *cstr_info) { - opj_common_ptr cinfo; - opj_image_t *image = NULL; - - if(!jp2 || !cio) { - return NULL; - } - - cinfo = jp2->cinfo; - - /* JP2 decoding */ - if(!jp2_read_struct(jp2, cio)) { - opj_event_msg(cinfo, EVT_ERROR, "Failed to decode jp2 structure\n"); - return NULL; - } - - /* J2K decoding */ - image = j2k_decode(jp2->j2k, cio, cstr_info); - if(!image) { - opj_event_msg(cinfo, EVT_ERROR, "Failed to decode J2K image\n"); - return NULL; - } - - /* Set Image Color Space */ - if (jp2->enumcs == 16) - image->color_space = CLRSPC_SRGB; - else if (jp2->enumcs == 17) - image->color_space = CLRSPC_GRAY; - else if (jp2->enumcs == 18) - image->color_space = CLRSPC_SYCC; - else - image->color_space = CLRSPC_UNKNOWN; - - return image; + jp2->ignore_pclr_cmap_cdef = parameters->flags & OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG; } /* ----------------------------------------------------------------------- */ @@ -664,30 +1150,23 @@ void jp2_setup_encoder(opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_ for (i = 0; i < image->numcomps; i++) { jp2->comps[i].bpcc = image->comps[i].prec - 1 + (image->comps[i].sgnd << 7); } - - /* Colour Specification box */ - - if ((image->numcomps == 1 || image->numcomps == 3) && (jp2->bpc != 255)) { - jp2->meth = 1; /* METH: Enumerated colourspace */ - } else { - jp2->meth = 2; /* METH: Restricted ICC profile */ - } - if (jp2->meth == 1) { - if (image->color_space == 1) - jp2->enumcs = 16; /* sRGB as defined by IEC 61966–2–1 */ - else if (image->color_space == 2) - jp2->enumcs = 17; /* greyscale */ - else if (image->color_space == 3) - jp2->enumcs = 18; /* YUV */ - } else { - jp2->enumcs = 0; /* PROFILE (??) */ - } + jp2->meth = 1; + if (image->color_space == 1) + jp2->enumcs = 16; /* sRGB as defined by IEC 61966-2.1 */ + else if (image->color_space == 2) + jp2->enumcs = 17; /* greyscale */ + else if (image->color_space == 3) + jp2->enumcs = 18; /* YUV */ jp2->precedence = 0; /* PRECEDENCE */ jp2->approx = 0; /* APPROX */ - + + jp2->jpip_on = parameters->jpip_on; } -bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { +opj_bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { + + int pos_iptr, pos_cidx, pos_jp2c, len_jp2c, len_cidx, end_pos, pos_fidx, len_fidx; + pos_jp2c = pos_iptr = -1; /* remove a warning */ /* JP2 encoding */ @@ -698,14 +1177,34 @@ bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestre /* JP2 Header box */ jp2_write_jp2h(jp2, cio); + if( jp2->jpip_on){ + pos_iptr = cio_tell( cio); + cio_skip( cio, 24); /* IPTR further ! */ + + pos_jp2c = cio_tell( cio); + } + /* J2K encoding */ + if(!(len_jp2c = jp2_write_jp2c( jp2, cio, image, cstr_info))){ + opj_event_msg(jp2->cinfo, EVT_ERROR, "Failed to encode image\n"); + return OPJ_FALSE; + } - if(!jp2_write_jp2c(jp2, cio, image, cstr_info)) { - opj_event_msg(jp2->cinfo, EVT_ERROR, "Failed to encode image\n"); - return false; + if( jp2->jpip_on){ + pos_cidx = cio_tell( cio); + + len_cidx = write_cidx( pos_jp2c+8, cio, image, *cstr_info, len_jp2c-8); + + pos_fidx = cio_tell( cio); + len_fidx = write_fidx( pos_jp2c, len_jp2c, pos_cidx, len_cidx, cio); + + end_pos = cio_tell( cio); + + cio_seek( cio, pos_iptr); + write_iptr( pos_fidx, len_fidx, cio); + + cio_seek( cio, end_pos); } - return true; + return OPJ_TRUE; } - - diff --git a/extern/libopenjpeg/jp2.h b/extern/libopenjpeg/jp2.h index 7e363be2eee..acb643cad77 100644 --- a/extern/libopenjpeg/jp2.h +++ b/extern/libopenjpeg/jp2.h @@ -46,11 +46,64 @@ #define JP2_COLR 0x636f6c72 /**< Colour specification box */ #define JP2_JP2C 0x6a703263 /**< Contiguous codestream box */ #define JP2_URL 0x75726c20 /**< URL box */ -#define JP2_DBTL 0x6474626c /**< ??? */ +#define JP2_DTBL 0x6474626c /**< Data Reference box */ #define JP2_BPCC 0x62706363 /**< Bits per component box */ #define JP2_JP2 0x6a703220 /**< File type fields */ +#define JP2_PCLR 0x70636c72 /**< Palette box */ +#define JP2_CMAP 0x636d6170 /**< Component Mapping box */ +#define JP2_CDEF 0x63646566 /**< Channel Definition box */ /* ----------------------------------------------------------------------- */ +/** +Channel description: channel index, type, assocation +*/ +typedef struct opj_jp2_cdef_info +{ + unsigned short cn, typ, asoc; +} opj_jp2_cdef_info_t; + +/** +Channel descriptions and number of descriptions +*/ +typedef struct opj_jp2_cdef +{ + opj_jp2_cdef_info_t *info; + unsigned short n; +} opj_jp2_cdef_t; + +/** +Component mappings: channel index, mapping type, palette index +*/ +typedef struct opj_jp2_cmap_comp +{ + unsigned short cmp; + unsigned char mtyp, pcol; +} opj_jp2_cmap_comp_t; + +/** +Palette data: table entries, palette columns +*/ +typedef struct opj_jp2_pclr +{ + unsigned int *entries; + unsigned char *channel_sign; + unsigned char *channel_size; + opj_jp2_cmap_comp_t *cmap; + unsigned short nr_entries, nr_channels; +} opj_jp2_pclr_t; + +/** +Collector for ICC profile, palette, component mapping, channel description +*/ +typedef struct opj_jp2_color +{ + unsigned char *icc_profile_buf; + int icc_profile_len; + + opj_jp2_cdef_t *jp2_cdef; + opj_jp2_pclr_t *jp2_pclr; + unsigned char jp2_has_colr; +} opj_jp2_color_t; /** JP2 component @@ -87,6 +140,8 @@ typedef struct opj_jp2 { opj_jp2_comps_t *comps; unsigned int j2k_codestream_offset; unsigned int j2k_codestream_length; + opj_bool jpip_on; + opj_bool ignore_pclr_cmap_cdef; } opj_jp2_t; /** @@ -111,9 +166,10 @@ void jp2_write_jp2h(opj_jp2_t *jp2, opj_cio_t *cio); Read the JP2H box - JP2 Header box (used in MJ2) @param jp2 JP2 handle @param cio Input buffer stream +@param ext Collector for profile, cdef and pclr data @return Returns true if successful, returns false otherwise */ -bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio); +opj_bool jp2_read_jp2h(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_color_t *color); /** Creates a JP2 decompression structure @param cinfo Codec context info @@ -139,7 +195,7 @@ Decode an image from a JPEG-2000 file stream @param cstr_info Codestream information structure if required, NULL otherwise @return Returns a decoded image if successful, returns NULL otherwise */ -opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *cstr_info); +opj_image_t* opj_jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *cstr_info); /** Creates a JP2 compression structure @param cinfo Codec context info @@ -167,7 +223,8 @@ Encode an image into a JPEG-2000 file stream @param cstr_info Codestream information structure if required, NULL otherwise @return Returns true if successful, returns false otherwise */ -bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); +opj_bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); + /* ----------------------------------------------------------------------- */ /*@}*/ diff --git a/extern/libopenjpeg/mct.c b/extern/libopenjpeg/mct.c index ca21744f3e4..870993b06d2 100644 --- a/extern/libopenjpeg/mct.c +++ b/extern/libopenjpeg/mct.c @@ -29,6 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#ifdef __SSE__ +#include <xmmintrin.h> +#endif + #include "opj_includes.h" /* <summary> */ @@ -127,6 +131,44 @@ void mct_decode_real( int n) { int i; +#ifdef __SSE__ + __m128 vrv, vgu, vgv, vbu; + vrv = _mm_set1_ps(1.402f); + vgu = _mm_set1_ps(0.34413f); + vgv = _mm_set1_ps(0.71414f); + vbu = _mm_set1_ps(1.772f); + for (i = 0; i < (n >> 3); ++i) { + __m128 vy, vu, vv; + __m128 vr, vg, vb; + + vy = _mm_load_ps(c0); + vu = _mm_load_ps(c1); + vv = _mm_load_ps(c2); + vr = _mm_add_ps(vy, _mm_mul_ps(vv, vrv)); + vg = _mm_sub_ps(_mm_sub_ps(vy, _mm_mul_ps(vu, vgu)), _mm_mul_ps(vv, vgv)); + vb = _mm_add_ps(vy, _mm_mul_ps(vu, vbu)); + _mm_store_ps(c0, vr); + _mm_store_ps(c1, vg); + _mm_store_ps(c2, vb); + c0 += 4; + c1 += 4; + c2 += 4; + + vy = _mm_load_ps(c0); + vu = _mm_load_ps(c1); + vv = _mm_load_ps(c2); + vr = _mm_add_ps(vy, _mm_mul_ps(vv, vrv)); + vg = _mm_sub_ps(_mm_sub_ps(vy, _mm_mul_ps(vu, vgu)), _mm_mul_ps(vv, vgv)); + vb = _mm_add_ps(vy, _mm_mul_ps(vu, vbu)); + _mm_store_ps(c0, vr); + _mm_store_ps(c1, vg); + _mm_store_ps(c2, vb); + c0 += 4; + c1 += 4; + c2 += 4; + } + n &= 7; +#endif for(i = 0; i < n; ++i) { float y = c0[i]; float u = c1[i]; diff --git a/extern/libopenjpeg/mqc.c b/extern/libopenjpeg/mqc.c index 9aa9d2c2e5b..14129fbf4e5 100644 --- a/extern/libopenjpeg/mqc.c +++ b/extern/libopenjpeg/mqc.c @@ -68,24 +68,23 @@ FIXME: documentation ??? @param mqc MQC handle @return */ -static int mqc_mpsexchange(opj_mqc_t *mqc); +static INLINE int mqc_mpsexchange(opj_mqc_t *const mqc); /** FIXME: documentation ??? @param mqc MQC handle @return */ -static int mqc_lpsexchange(opj_mqc_t *mqc); +static INLINE int mqc_lpsexchange(opj_mqc_t *const mqc); /** Input a byte @param mqc MQC handle */ -static void mqc_bytein(opj_mqc_t *mqc); +static INLINE void mqc_bytein(opj_mqc_t *const mqc); /** Renormalize mqc->a and mqc->c while decoding @param mqc MQC handle */ -static void mqc_renormd(opj_mqc_t *mqc); - +static INLINE void mqc_renormd(opj_mqc_t *const mqc); /*@}*/ /*@}*/ @@ -271,7 +270,7 @@ static void mqc_setbits(opj_mqc_t *mqc) { } } -static int mqc_mpsexchange(opj_mqc_t *mqc) { +static INLINE int mqc_mpsexchange(opj_mqc_t *const mqc) { int d; if (mqc->a < (*mqc->curctx)->qeval) { d = 1 - (*mqc->curctx)->mps; @@ -284,7 +283,7 @@ static int mqc_mpsexchange(opj_mqc_t *mqc) { return d; } -static int mqc_lpsexchange(opj_mqc_t *mqc) { +static INLINE int mqc_lpsexchange(opj_mqc_t *const mqc) { int d; if (mqc->a < (*mqc->curctx)->qeval) { mqc->a = (*mqc->curctx)->qeval; @@ -299,7 +298,15 @@ static int mqc_lpsexchange(opj_mqc_t *mqc) { return d; } -static void mqc_bytein(opj_mqc_t *mqc) { +#ifdef MQC_PERF_OPT +static INLINE void mqc_bytein(opj_mqc_t *const mqc) { + unsigned int i = *((unsigned int *) mqc->bp); + mqc->c += i & 0xffff00; + mqc->ct = i & 0x0f; + mqc->bp += (i >> 2) & 0x04; +} +#else +static void mqc_bytein(opj_mqc_t *const mqc) { if (mqc->bp != mqc->end) { unsigned int c; if (mqc->bp + 1 != mqc->end) { @@ -326,8 +333,9 @@ static void mqc_bytein(opj_mqc_t *mqc) { mqc->ct = 8; } } +#endif -static void mqc_renormd(opj_mqc_t *mqc) { +static INLINE void mqc_renormd(opj_mqc_t *const mqc) { do { if (mqc->ct == 0) { mqc_bytein(mqc); @@ -346,11 +354,19 @@ static void mqc_renormd(opj_mqc_t *mqc) { opj_mqc_t* mqc_create(void) { opj_mqc_t *mqc = (opj_mqc_t*)opj_malloc(sizeof(opj_mqc_t)); +#ifdef MQC_PERF_OPT + mqc->buffer = NULL; +#endif return mqc; } void mqc_destroy(opj_mqc_t *mqc) { if(mqc) { +#ifdef MQC_PERF_OPT + if (mqc->buffer) { + opj_free(mqc->buffer); + } +#endif opj_free(mqc); } } @@ -499,13 +515,51 @@ void mqc_init_dec(opj_mqc_t *mqc, unsigned char *bp, int len) { mqc->bp = bp; if (len==0) mqc->c = 0xff << 16; else mqc->c = *mqc->bp << 16; + +#ifdef MQC_PERF_OPT + { + unsigned int c; + unsigned int *ip; + unsigned char *end = mqc->end - 1; + mqc->buffer = opj_realloc(mqc->buffer, (len + 1) * sizeof(unsigned int)); + ip = (unsigned int *) mqc->buffer; + + while (bp < end) { + c = *(bp + 1); + if (*bp == 0xff) { + if (c > 0x8f) { + break; + } else { + *ip = 0x00000017 | (c << 9); + } + } else { + *ip = 0x00000018 | (c << 8); + } + bp++; + ip++; + } + + /* Handle last byte of data */ + c = 0xff; + if (*bp == 0xff) { + *ip = 0x0000ff18; + } else { + bp++; + *ip = 0x00000018 | (c << 8); + } + ip++; + + *ip = 0x0000ff08; + mqc->bp = mqc->buffer; + } +#endif mqc_bytein(mqc); mqc->c <<= 7; mqc->ct -= 7; mqc->a = 0x8000; } -int mqc_decode(opj_mqc_t *mqc) { +int mqc_decode(opj_mqc_t *const mqc) { int d; mqc->a -= (*mqc->curctx)->qeval; if ((mqc->c >> 16) < (*mqc->curctx)->qeval) { diff --git a/extern/libopenjpeg/mqc.h b/extern/libopenjpeg/mqc.h index 8cc8c934598..d00cd1067d8 100644 --- a/extern/libopenjpeg/mqc.h +++ b/extern/libopenjpeg/mqc.h @@ -70,6 +70,9 @@ typedef struct opj_mqc { unsigned char *end; opj_mqc_state_t *ctxs[MQC_NUMCTXS]; opj_mqc_state_t **curctx; +#ifdef MQC_PERF_OPT + unsigned char *buffer; +#endif } opj_mqc_t; /** @name Exported functions */ @@ -188,7 +191,7 @@ Decode a symbol @param mqc MQC handle @return Returns the decoded symbol (0 or 1) */ -int mqc_decode(opj_mqc_t *mqc); +int mqc_decode(opj_mqc_t *const mqc); /* ----------------------------------------------------------------------- */ /*@}*/ diff --git a/extern/libopenjpeg/openjpeg.c b/extern/libopenjpeg/openjpeg.c index 96fa0ad57e5..180cc844ab5 100644 --- a/extern/libopenjpeg/openjpeg.c +++ b/extern/libopenjpeg/openjpeg.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -24,17 +24,22 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifdef WIN32 +#ifdef _WIN32 #include <windows.h> -#endif /* WIN32 */ +#endif /* _WIN32 */ +#include "opj_config.h" #include "opj_includes.h" /* ---------------------------------------------------------------------- */ -#ifdef WIN32 +#ifdef _WIN32 #ifndef OPJ_STATIC BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { + + OPJ_ARG_NOT_USED(lpReserved); + OPJ_ARG_NOT_USED(hModule); + switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH : break; @@ -48,19 +53,19 @@ DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { return TRUE; } #endif /* OPJ_STATIC */ -#endif /* WIN32 */ +#endif /* _WIN32 */ /* ---------------------------------------------------------------------- */ const char* OPJ_CALLCONV opj_version(void) { - return OPENJPEG_VERSION; + return PACKAGE_VERSION; } opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) { - opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_malloc(sizeof(opj_dinfo_t)); + opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_calloc(1, sizeof(opj_dinfo_t)); if(!dinfo) return NULL; - dinfo->is_decompressor = true; + dinfo->is_decompressor = OPJ_TRUE; switch(format) { case CODEC_J2K: case CODEC_JPT: @@ -120,9 +125,10 @@ void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *paramete parameters->decod_format = -1; parameters->cod_format = -1; + parameters->flags = 0; /* UniPG>> */ #ifdef USE_JPWL - parameters->jpwl_correct = false; + parameters->jpwl_correct = OPJ_FALSE; parameters->jpwl_exp_comps = JPWL_EXPECTED_COMPONENTS; parameters->jpwl_max_tiles = JPWL_MAXIMUM_TILES; #endif /* USE_JPWL */ @@ -159,7 +165,7 @@ opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *ci case CODEC_JPT: return j2k_decode_jpt_stream((opj_j2k_t*)dinfo->j2k_handle, cio, cstr_info); case CODEC_JP2: - return jp2_decode((opj_jp2_t*)dinfo->jp2_handle, cio, cstr_info); + return opj_jp2_decode((opj_jp2_t*)dinfo->jp2_handle, cio, cstr_info); case CODEC_UNKNOWN: default: break; @@ -169,9 +175,9 @@ opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *ci } opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) { - opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_malloc(sizeof(opj_cinfo_t)); + opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_calloc(1, sizeof(opj_cinfo_t)); if(!cinfo) return NULL; - cinfo->is_decompressor = false; + cinfo->is_decompressor = OPJ_FALSE; switch(format) { case CODEC_J2K: /* get a J2K coder handle */ @@ -238,9 +244,15 @@ void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *paramete parameters->tp_on = 0; parameters->decod_format = -1; parameters->cod_format = -1; + parameters->tcp_rates[0] = 0; + parameters->tcp_numlayers = 0; + parameters->cp_disto_alloc = 0; + parameters->cp_fixed_alloc = 0; + parameters->cp_fixed_quality = 0; + parameters->jpip_on = OPJ_FALSE; /* UniPG>> */ #ifdef USE_JPWL - parameters->jpwl_epc_on = false; + parameters->jpwl_epc_on = OPJ_FALSE; parameters->jpwl_hprot_MH = -1; /* -1 means unassigned */ { int i; @@ -290,7 +302,7 @@ void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *param } } -bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) { +opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index) { if (index != NULL) opj_event_msg((opj_common_ptr)cinfo, EVT_WARNING, "Set index to NULL when calling the opj_encode function.\n" "To extract the index, use the opj_encode_with_info() function.\n" @@ -298,20 +310,20 @@ bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *im return opj_encode_with_info(cinfo, cio, image, NULL); } -bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { +opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { if(cinfo && cio && image) { switch(cinfo->codec_format) { case CODEC_J2K: return j2k_encode((opj_j2k_t*)cinfo->j2k_handle, cio, image, cstr_info); case CODEC_JP2: - return jp2_encode((opj_jp2_t*)cinfo->jp2_handle, cio, image, cstr_info); + return opj_jp2_encode((opj_jp2_t*)cinfo->jp2_handle, cio, image, cstr_info); case CODEC_JPT: case CODEC_UNKNOWN: default: break; } } - return false; + return OPJ_FALSE; } void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) { @@ -322,8 +334,10 @@ void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) { opj_free(tile_info->thresh); opj_free(tile_info->packet); opj_free(tile_info->tp); + opj_free(tile_info->marker); } opj_free(cstr_info->tile); opj_free(cstr_info->marker); + opj_free(cstr_info->numdecompos); } } diff --git a/extern/libopenjpeg/openjpeg.h b/extern/libopenjpeg/openjpeg.h index ae7764eab2f..53e9fac0438 100644 --- a/extern/libopenjpeg/openjpeg.h +++ b/extern/libopenjpeg/openjpeg.h @@ -6,6 +6,7 @@ * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2006-2007, Parvatha Elangovan + * Copyright (c) 2010-2011, Kaori Hagihara * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,7 +33,6 @@ #ifndef OPENJPEG_H #define OPENJPEG_H -#define OPENJPEG_VERSION "1.3.0" /* ========================================================== @@ -40,34 +40,32 @@ ========================================================== */ +#if defined(OPJ_STATIC) || !defined(_WIN32) #define OPJ_API #define OPJ_CALLCONV - -#ifndef __cplusplus -#if defined(HAVE_STDBOOL_H) -/* -The C language implementation does correctly provide the standard header -file "stdbool.h". - */ -#include <stdbool.h> #else +#define OPJ_CALLCONV __stdcall /* -The C language implementation does not provide the standard header file -"stdbool.h" as required by ISO/IEC 9899:1999. Try to compensate for this -braindamage below. -*/ -#if !defined(bool) -#define bool int -#endif -#if !defined(true) -#define true 1 -#endif -#if !defined(false) -#define false 0 -#endif -#endif -#endif /* __cplusplus */ +The following ifdef block is the standard way of creating macros which make exporting +from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS +symbol defined on the command line. this symbol should not be defined on any project +that uses this DLL. This way any other project whose source files include this file see +OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols +defined with this macro as being exported. +*/ +#if defined(OPJ_EXPORTS) || defined(DLL_EXPORT) +#define OPJ_API __declspec(dllexport) +#else +#define OPJ_API __declspec(dllimport) +#endif /* OPJ_EXPORTS */ +#endif /* !OPJ_STATIC || !_WIN32 */ +typedef int opj_bool; +#define OPJ_TRUE 1 +#define OPJ_FALSE 0 + +/* Avoid compile-time warning because parameter is not used */ +#define OPJ_ARG_NOT_USED(x) (void)(x) /* ========================================================== Useful constant definitions @@ -130,7 +128,8 @@ typedef enum PROG_ORDER { Supported image color spaces */ typedef enum COLOR_SPACE { - CLRSPC_UNKNOWN = -1, /**< place-holder */ + CLRSPC_UNKNOWN = -1, /**< not supported by the library */ + CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */ CLRSPC_SRGB = 1, /**< sRGB */ CLRSPC_GRAY = 2, /**< grayscale */ CLRSPC_SYCC = 3 /**< YUV */ @@ -141,9 +140,9 @@ Supported codec */ typedef enum CODEC_FORMAT { CODEC_UNKNOWN = -1, /**< place-holder */ - CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */ - CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */ - CODEC_JP2 = 2 /**< JPEG-2000 file format : read/write */ + CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */ + CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */ + CODEC_JP2 = 2 /**< JPEG-2000 file format : read/write */ } OPJ_CODEC_FORMAT; /** @@ -226,7 +225,7 @@ Compression parameters */ typedef struct opj_cparameters { /** size of tile: tile_size_on = false (not in argument) or = true (in argument) */ - bool tile_size_on; + opj_bool tile_size_on; /** XTOsiz */ int cp_tx0; /** YTOsiz */ @@ -308,7 +307,7 @@ typedef struct opj_cparameters { /**@name JPWL encoding parameters */ /*@{*/ /** enables writing of EPC in MH, thus activating JPWL */ - bool jpwl_epc_on; + opj_bool jpwl_epc_on; /** error protection method for MH (0,1,16,32,37-128) */ int jpwl_hprot_MH; /** tile number of header protection specification (>=0) */ @@ -348,8 +347,12 @@ typedef struct opj_cparameters { char tp_flag; /** MCT (multiple component transform) */ char tcp_mct; + /** Enable JPIP indexing*/ + opj_bool jpip_on; } opj_cparameters_t; +#define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001 + /** Decompression parameters */ @@ -386,7 +389,7 @@ typedef struct opj_dparameters { /**@name JPWL decoding parameters */ /*@{*/ /** activates the JPWL correction capabilities */ - bool jpwl_correct; + opj_bool jpwl_correct; /** expected number of components */ int jpwl_exp_comps; /** maximum number of tiles */ @@ -402,6 +405,7 @@ typedef struct opj_dparameters { */ OPJ_LIMIT_DECODING cp_limit_decoding; + unsigned int flags; } opj_dparameters_t; /** Common fields between JPEG-2000 compression and decompression master structs. */ @@ -409,7 +413,7 @@ typedef struct opj_dparameters { #define opj_common_fields \ opj_event_mgr_t *event_mgr; /**< pointer to the event manager */\ void * client_data; /**< Available for use by application */\ - bool is_decompressor; /**< So common code can tell which is which */\ + opj_bool is_decompressor; /**< So common code can tell which is which */\ OPJ_CODEC_FORMAT codec_format; /**< selected codec */\ void *j2k_handle; /**< pointer to the J2K codec */\ void *jp2_handle; /**< pointer to the JP2 codec */\ @@ -537,6 +541,10 @@ typedef struct opj_image { OPJ_COLOR_SPACE color_space; /** image components */ opj_image_comp_t *comps; + /** 'restricted' ICC profile */ + unsigned char *icc_profile_buf; + /** size of ICC profile */ + int icc_profile_len; } opj_image_t; /** @@ -583,6 +591,21 @@ typedef struct opj_packet_info { double disto; } opj_packet_info_t; + +/* UniPG>> */ +/** +Marker structure +*/ +typedef struct opj_marker_info_t { + /** marker type */ + unsigned short int type; + /** position in codestream */ + int pos; + /** length, marker val included */ + int len; +} opj_marker_info_t; +/* <<UniPG */ + /** Index structure : Information concerning tile-parts */ @@ -627,26 +650,18 @@ typedef struct opj_tile_info { int numpix; /** add fixed_quality */ double distotile; + /** number of markers */ + int marknum; + /** list of markers */ + opj_marker_info_t *marker; + /** actual size of markers array */ + int maxmarknum; /** number of tile parts */ int num_tps; /** information concerning tile parts */ opj_tp_info_t *tp; } opj_tile_info_t; -/* UniPG>> */ -/** -Marker structure -*/ -typedef struct opj_marker_info_t { - /** marker type */ - unsigned short int type; - /** position in codestream */ - int pos; - /** length, marker val included */ - int len; -} opj_marker_info_t; -/* <<UniPG */ - /** Index structure of the codestream */ @@ -865,13 +880,13 @@ Setup the encoder parameters using the current image and using user parameters. OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image); /** Encode an image into a JPEG-2000 codestream -@param cinfo compressor handle +3@param cinfo compressor handle @param cio Output buffer stream @param image Image to encode @param index Depreacted -> Set to NULL. To extract index, used opj_encode_wci() @return Returns true if successful, returns false otherwise */ -OPJ_API bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index); +OPJ_API opj_bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index); /** Encode an image into a JPEG-2000 codestream and extract the codestream information @param cinfo compressor handle @@ -880,13 +895,14 @@ Encode an image into a JPEG-2000 codestream and extract the codestream informati @param cstr_info Codestream information structure if needed afterwards, NULL otherwise @return Returns true if successful, returns false otherwise */ -OPJ_API bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); +OPJ_API opj_bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); /** Destroy Codestream information after compression or decompression @param cstr_info Codestream information structure */ OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info); + #ifdef __cplusplus } #endif diff --git a/extern/libopenjpeg/opj_config.h b/extern/libopenjpeg/opj_config.h new file mode 100644 index 00000000000..82e12be03a9 --- /dev/null +++ b/extern/libopenjpeg/opj_config.h @@ -0,0 +1,38 @@ +/* for BLENDER - we hand-maintain this, + * for the original OpenJpeg package it is generated, + * the endian check is a blender define */ + +/* create config.h for CMake */ +#define PACKAGE_VERSION "1.5.0" + +#define HAVE_INTTYPES_H +#define HAVE_MEMORY_H +#define HAVE_STDINT_H +#define HAVE_STDLIB_H +#define HAVE_STRINGS_H +#define HAVE_STRING_H +#define HAVE_SYS_STAT_H +#define HAVE_SYS_TYPES_H +#define HAVE_UNISTD_H +/* #define HAVE_LIBPNG */ +/* #define HAVE_PNG_H */ +/* #define HAVE_LIBTIFF */ +/* #define HAVE_TIFF_H */ + +/* #undef HAVE_LIBLCMS1 */ +/* #undef HAVE_LIBLCMS2 */ +/* #undef HAVE_LCMS1_H */ +/* #undef HAVE_LCMS2_H */ + +/* Byte order. */ +/* All compilers that support Mac OS X define either __BIG_ENDIAN__ or +__LITTLE_ENDIAN__ to match the endianness of the architecture being +compiled for. This is not necessarily the same as the architecture of the +machine doing the building. In order to support Universal Binaries on +Mac OS X, we prefer those defines to decide the endianness. +On other platforms we use the result of the TRY_RUN. */ +#if defined(__BIG_ENDIAN__) +# define OPJ_BIG_ENDIAN +#else +# undef OPJ_BIG_ENDIAN +#endif diff --git a/extern/libopenjpeg/opj_includes.h b/extern/libopenjpeg/opj_includes.h index 3464cfcf9ed..2b5866a9990 100644 --- a/extern/libopenjpeg/opj_includes.h +++ b/extern/libopenjpeg/opj_includes.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -65,7 +65,7 @@ Most compilers implement their own version of this keyword ... */ #ifndef INLINE #if defined(_MSC_VER) - #define INLINE __inline + #define INLINE __forceinline #elif defined(__GNUC__) #define INLINE __inline__ #elif defined(__MWERKS__) @@ -86,30 +86,28 @@ Most compilers implement their own version of this keyword ... #endif #endif -/* MSVC does not have lrintf */ -#ifdef _MSC_VER +/* MSVC and Borland C do not have lrintf */ +#if defined(_MSC_VER) || defined(__BORLANDC__) +static INLINE long lrintf(float f){ #ifdef _M_X64 -#include <emmintrin.h> -static INLINE long lrintf(float f) { - return _mm_cvtss_si32(_mm_load_ss(&f)); -} + return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); #else -static INLINE long lrintf(float f){ - int i; - - _asm{ - fld f - fistp i - }; - - return i; -} + int i; + + _asm{ + fld f + fistp i + }; + + return i; #endif +} #endif #include "j2k_lib.h" #include "opj_malloc.h" #include "event.h" +#include "bio.h" #include "cio.h" #include "image.h" @@ -130,9 +128,12 @@ static INLINE long lrintf(float f){ #include "int.h" #include "fix.h" +#include "cidx_manager.h" +#include "indexbox_manager.h" + /* JPWL>> */ #ifdef USE_JPWL -#include "../jpwl/jpwl.h" +#include "./jpwl/jpwl.h" #endif /* USE_JPWL */ /* <<JPWL */ diff --git a/extern/libopenjpeg/opj_malloc.h b/extern/libopenjpeg/opj_malloc.h index 960bdb3ec4b..87493f497c7 100644 --- a/extern/libopenjpeg/opj_malloc.h +++ b/extern/libopenjpeg/opj_malloc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Hervé Drolon, FreeImage Team + * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2007, Callum Lerwick <seg@haxxed.com> * All rights reserved. * @@ -45,7 +45,11 @@ Allocate an uninitialized memory block @param size Bytes to allocate @return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available */ +#ifdef ALLOC_PERF_OPT +void * OPJ_CALLCONV opj_malloc(size_t size); +#else #define opj_malloc(size) malloc(size) +#endif /** Allocate a memory block with elements initialized to 0 @@ -53,7 +57,11 @@ Allocate a memory block with elements initialized to 0 @param size Bytes per block to allocate @return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available */ +#ifdef ALLOC_PERF_OPT +void * OPJ_CALLCONV opj_calloc(size_t _NumOfElements, size_t _SizeOfElements); +#else #define opj_calloc(num, size) calloc(num, size) +#endif /** Allocate memory aligned to a 16 byte boundry @@ -61,7 +69,7 @@ Allocate memory aligned to a 16 byte boundry @return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available */ /* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */ -#ifdef WIN32 +#ifdef _WIN32 /* Someone should tell the mingw people that their malloc.h ought to provide _mm_malloc() */ #ifdef __GNUC__ #include <mm_malloc.h> @@ -72,23 +80,16 @@ Allocate memory aligned to a 16 byte boundry #define HAVE_MM_MALLOC #endif #endif -#else /* Not WIN32 */ +#else /* Not _WIN32 */ #if defined(__sun) - #define HAVE_MEMALIGN - #elif defined(__GNUC__) - #if !defined(__APPLE__) && !defined(__FreeBSD__) - #define HAVE_MEMALIGN - #include <malloc.h> - #endif - /* Linux x86_64 and OSX always align allocations to 16 bytes */ - #elif !defined(__amd64__) && !defined(__APPLE__) - /* FIXME: Yes, this is a big assumption */ - #define HAVE_POSIX_MEMALIGN + #define HAVE_MEMALIGN + /* Linux x86_64 and OSX always align allocations to 16 bytes */ + #elif !defined(__amd64__) && !defined(__APPLE__) + #define HAVE_MEMALIGN + #include <malloc.h> #endif #endif - - #define opj_aligned_malloc(size) malloc(size) #define opj_aligned_free(m) free(m) @@ -120,19 +121,34 @@ Allocate memory aligned to a 16 byte boundry #define opj_aligned_free(m) free(m) #endif +#ifdef ALLOC_PERF_OPT + #undef opj_aligned_malloc + #define opj_aligned_malloc(size) opj_malloc(size) + #undef opj_aligned_free + #define opj_aligned_free(m) opj_free(m) +#endif + /** Reallocate memory blocks. -@param memblock Pointer to previously allocated memory block -@param size New size in bytes +@param m Pointer to previously allocated memory block +@param s New size in bytes @return Returns a void pointer to the reallocated (and possibly moved) memory block */ +#ifdef ALLOC_PERF_OPT +void * OPJ_CALLCONV opj_realloc(void * m, size_t s); +#else #define opj_realloc(m, s) realloc(m, s) +#endif /** Deallocates or frees a memory block. -@param memblock Previously allocated memory block to be freed +@param m Previously allocated memory block to be freed */ +#ifdef ALLOC_PERF_OPT +void OPJ_CALLCONV opj_free(void * m); +#else #define opj_free(m) free(m) +#endif #ifdef __GNUC__ #pragma GCC poison malloc calloc realloc free diff --git a/extern/libopenjpeg/phix_manager.c b/extern/libopenjpeg/phix_manager.c new file mode 100644 index 00000000000..60a02811785 --- /dev/null +++ b/extern/libopenjpeg/phix_manager.c @@ -0,0 +1,170 @@ +/* + * $Id: phix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2003-2004, Yannick Verschueren + * Copyright (c) 2010-2011, Kaori Hagihara + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*! \file + * \brief Modification of jpip.c from 2KAN indexer + */ + +#include <stdlib.h> +#include <math.h> +#include "opj_includes.h" + +/* + * Write faix box of phix + * + * @param[in] coff offset of j2k codestream + * @param[in] compno component number + * @param[in] cstr_info codestream information + * @param[in] EPHused true if if EPH option used + * @param[in] j2klen length of j2k codestream + * @param[in] cio file output handle + * @return length of faix box + */ +int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio); + +int write_phix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio) +{ + int len, lenp=0, compno, i; + opj_jp2_box_t *box; + + box = (opj_jp2_box_t *)opj_calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t)); + + for( i=0;i<2;i++){ + if (i) cio_seek( cio, lenp); + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_PHIX, 4); /* PHIX */ + + write_manf( i, cstr_info.numcomps, box, cio); + + for( compno=0; compno<cstr_info.numcomps; compno++){ + box[compno].length = write_phixfaix( coff, compno, cstr_info, EPHused, j2klen, cio); + box[compno].type = JPIP_FAIX; + } + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + } + + opj_free(box); + + return len; +} + +int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio) +{ + int len, lenp, tileno, version, i, nmax, size_of_coding; /* 4 or 8 */ + opj_tile_info_t *tile_Idx; + opj_packet_info_t packet; + int resno, precno, layno, num_packet; + int numOfres, numOfprec, numOflayers; + packet.end_ph_pos = packet.start_pos = -1; + (void)EPHused; /* unused ? */ + + if( j2klen > pow( 2, 32)){ + size_of_coding = 8; + version = 1; + } + else{ + size_of_coding = 4; + version = 0; + } + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_FAIX, 4); /* FAIX */ + cio_write( cio, version,1); /* Version 0 = 4 bytes */ + + nmax = 0; + for( i=0; i<=cstr_info.numdecompos[compno]; i++) + nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers; + + cio_write( cio, nmax, size_of_coding); /* NMAX */ + cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */ + + for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){ + tile_Idx = &cstr_info.tile[ tileno]; + + num_packet = 0; + numOfres = cstr_info.numdecompos[compno] + 1; + + for( resno=0; resno<numOfres ; resno++){ + numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno]; + for( precno=0; precno<numOfprec; precno++){ + numOflayers = cstr_info.numlayers; + for( layno=0; layno<numOflayers; layno++){ + + switch ( cstr_info.prog){ + case LRCP: + packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno]; + break; + case RLCP: + packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno]; + break; + case RPCL: + packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno]; + break; + case PCRL: + packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno]; + break; + case CPRL: + packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno]; + break; + default: + fprintf( stderr, "failed to ppix indexing\n"); + } + + cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */ + cio_write( cio, packet.end_ph_pos-packet.start_pos+1, size_of_coding); /* length */ + + num_packet++; + } + } + } + + /* PADDING */ + while( num_packet < nmax){ + cio_write( cio, 0, size_of_coding); /* start position */ + cio_write( cio, 0, size_of_coding); /* length */ + num_packet++; + } + } + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + + return len; +} diff --git a/extern/libopenjpeg/pi.c b/extern/libopenjpeg/pi.c index ac7654c5f14..e8e33bfe600 100644 --- a/extern/libopenjpeg/pi.c +++ b/extern/libopenjpeg/pi.c @@ -43,31 +43,31 @@ Get next packet in layer-resolution-component-precinct order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ -static bool pi_next_lrcp(opj_pi_iterator_t * pi); +static opj_bool pi_next_lrcp(opj_pi_iterator_t * pi); /** Get next packet in resolution-layer-component-precinct order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ -static bool pi_next_rlcp(opj_pi_iterator_t * pi); +static opj_bool pi_next_rlcp(opj_pi_iterator_t * pi); /** Get next packet in resolution-precinct-component-layer order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ -static bool pi_next_rpcl(opj_pi_iterator_t * pi); +static opj_bool pi_next_rpcl(opj_pi_iterator_t * pi); /** Get next packet in precinct-component-resolution-layer order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ -static bool pi_next_pcrl(opj_pi_iterator_t * pi); +static opj_bool pi_next_pcrl(opj_pi_iterator_t * pi); /** Get next packet in component-precinct-resolution-layer order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ -static bool pi_next_cprl(opj_pi_iterator_t * pi); +static opj_bool pi_next_cprl(opj_pi_iterator_t * pi); /*@}*/ @@ -79,7 +79,7 @@ static bool pi_next_cprl(opj_pi_iterator_t * pi); ========================================================== */ -static bool pi_next_lrcp(opj_pi_iterator_t * pi) { +static opj_bool pi_next_lrcp(opj_pi_iterator_t * pi) { opj_pi_comp_t *comp = NULL; opj_pi_resolution_t *res = NULL; long index = 0; @@ -108,7 +108,7 @@ static bool pi_next_lrcp(opj_pi_iterator_t * pi) { index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p; if (!pi->include[index]) { pi->include[index] = 1; - return true; + return OPJ_TRUE; } LABEL_SKIP:; } @@ -116,10 +116,10 @@ LABEL_SKIP:; } } - return false; + return OPJ_FALSE; } -static bool pi_next_rlcp(opj_pi_iterator_t * pi) { +static opj_bool pi_next_rlcp(opj_pi_iterator_t * pi) { opj_pi_comp_t *comp = NULL; opj_pi_resolution_t *res = NULL; long index = 0; @@ -147,7 +147,7 @@ static bool pi_next_rlcp(opj_pi_iterator_t * pi) { index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p; if (!pi->include[index]) { pi->include[index] = 1; - return true; + return OPJ_TRUE; } LABEL_SKIP:; } @@ -155,10 +155,10 @@ LABEL_SKIP:; } } - return false; + return OPJ_FALSE; } -static bool pi_next_rpcl(opj_pi_iterator_t * pi) { +static opj_bool pi_next_rpcl(opj_pi_iterator_t * pi) { opj_pi_comp_t *comp = NULL; opj_pi_resolution_t *res = NULL; long index = 0; @@ -209,14 +209,14 @@ if (!pi->tp_on){ try1 = int_ceildiv(pi->ty1, comp->dy << levelno); rpx = res->pdx + levelno; rpy = res->pdy + levelno; - if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpx))))){ + if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){ continue; } if (!((pi->x % (comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){ continue; } - if ((res->pw==0)||(res->pw==0)) continue; + if ((res->pw==0)||(res->ph==0)) continue; if ((trx0==trx1)||(try0==try1)) continue; @@ -229,7 +229,7 @@ if (!pi->tp_on){ index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p; if (!pi->include[index]) { pi->include[index] = 1; - return true; + return OPJ_TRUE; } LABEL_SKIP:; } @@ -238,10 +238,10 @@ LABEL_SKIP:; } } - return false; + return OPJ_FALSE; } -static bool pi_next_pcrl(opj_pi_iterator_t * pi) { +static opj_bool pi_next_pcrl(opj_pi_iterator_t * pi) { opj_pi_comp_t *comp = NULL; opj_pi_resolution_t *res = NULL; long index = 0; @@ -290,14 +290,14 @@ static bool pi_next_pcrl(opj_pi_iterator_t * pi) { try1 = int_ceildiv(pi->ty1, comp->dy << levelno); rpx = res->pdx + levelno; rpy = res->pdy + levelno; - if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpx))))){ + if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){ continue; } if (!((pi->x % (comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){ continue; } - if ((res->pw==0)||(res->pw==0)) continue; + if ((res->pw==0)||(res->ph==0)) continue; if ((trx0==trx1)||(try0==try1)) continue; @@ -310,7 +310,7 @@ static bool pi_next_pcrl(opj_pi_iterator_t * pi) { index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p; if (!pi->include[index]) { pi->include[index] = 1; - return true; + return OPJ_TRUE; } LABEL_SKIP:; } @@ -319,10 +319,10 @@ LABEL_SKIP:; } } - return false; + return OPJ_FALSE; } -static bool pi_next_cprl(opj_pi_iterator_t * pi) { +static opj_bool pi_next_cprl(opj_pi_iterator_t * pi) { opj_pi_comp_t *comp = NULL; opj_pi_resolution_t *res = NULL; long index = 0; @@ -369,14 +369,14 @@ static bool pi_next_cprl(opj_pi_iterator_t * pi) { try1 = int_ceildiv(pi->ty1, comp->dy << levelno); rpx = res->pdx + levelno; rpy = res->pdy + levelno; - if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpx))))){ + if (!((pi->y % (comp->dy << rpy) == 0) || ((pi->y == pi->ty0) && ((try0 << levelno) % (1 << rpy))))){ continue; } if (!((pi->x % (comp->dx << rpx) == 0) || ((pi->x == pi->tx0) && ((trx0 << levelno) % (1 << rpx))))){ continue; } - if ((res->pw==0)||(res->pw==0)) continue; + if ((res->pw==0)||(res->ph==0)) continue; if ((trx0==trx1)||(try0==try1)) continue; @@ -389,7 +389,7 @@ static bool pi_next_cprl(opj_pi_iterator_t * pi) { index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p; if (!pi->include[index]) { pi->include[index] = 1; - return true; + return OPJ_TRUE; } LABEL_SKIP:; } @@ -398,7 +398,7 @@ LABEL_SKIP:; } } - return false; + return OPJ_FALSE; } /* @@ -707,7 +707,7 @@ void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno) { } } -bool pi_next(opj_pi_iterator_t * pi) { +opj_bool pi_next(opj_pi_iterator_t * pi) { switch (pi->poc.prg) { case LRCP: return pi_next_lrcp(pi); @@ -720,13 +720,13 @@ bool pi_next(opj_pi_iterator_t * pi) { case CPRL: return pi_next_cprl(pi); case PROG_UNKNOWN: - return false; + return OPJ_FALSE; } - return false; + return OPJ_FALSE; } -bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){ +opj_bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp){ char prog[4]; int i; int incr_top=1,resetX=0; @@ -748,7 +748,7 @@ bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino, case RPCL: strncpy(prog, "RPCL",4); break; case PROG_UNKNOWN: - return true; + return OPJ_TRUE; } if(!(cp->tp_on && ((!cp->cinema && (t2_mode == FINAL_PASS)) || cp->cinema))){ @@ -958,6 +958,6 @@ bool pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino, } } } - return false; + return OPJ_FALSE; } diff --git a/extern/libopenjpeg/pi.h b/extern/libopenjpeg/pi.h index b5e0f6a4df8..cf9135fd1f5 100644 --- a/extern/libopenjpeg/pi.h +++ b/extern/libopenjpeg/pi.h @@ -115,12 +115,14 @@ Modify the packet iterator for enabling tile part generation @param pi Handle to the packet iterator generated in pi_initialise_encode @param cp Coding parameters @param tileno Number that identifies the tile for which to list the packets +@param pino Iterator index for pi @param tpnum Tile part number of the current tile @param tppos The position of the tile part flag in the progression order +@param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass @param cur_totnum_tp The total number of tile parts in the current tile @return Returns true if an error is detected */ -bool pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp); +opj_bool pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp); /** Create a packet iterator for Decoder @param image Raw image for which the packets will be listed @@ -145,7 +147,7 @@ Modify the packet iterator to point to the next packet @param pi Packet iterator to modify @return Returns false if pi pointed to the last packet or else returns true */ -bool pi_next(opj_pi_iterator_t * pi); +opj_bool pi_next(opj_pi_iterator_t * pi); /* ----------------------------------------------------------------------- */ /*@}*/ diff --git a/extern/libopenjpeg/ppix_manager.c b/extern/libopenjpeg/ppix_manager.c new file mode 100644 index 00000000000..58d324ceb41 --- /dev/null +++ b/extern/libopenjpeg/ppix_manager.c @@ -0,0 +1,173 @@ +/* + * $Id: ppix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2003-2004, Yannick Verschueren + * Copyright (c) 2010-2011, Kaori Hagihara + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*! \file + * \brief Modification of jpip.c from 2KAN indexer + */ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "opj_includes.h" + +/* + * Write faix box of ppix + * + * @param[in] coff offset of j2k codestream + * @param[in] compno component number + * @param[in] cstr_info codestream information + * @param[in] EPHused true if if EPH option used + * @param[in] j2klen length of j2k codestream + * @param[in] cio file output handle + * @return length of faix box + */ +int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio); + +int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio) +{ + int len, lenp, compno, i; + opj_jp2_box_t *box; + + /* printf("cstr_info.packno %d\n", cstr_info.packno); //NMAX? */ + + lenp = -1; + box = (opj_jp2_box_t *)opj_calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t)); + + for (i=0;i<2;i++){ + if (i) cio_seek( cio, lenp); + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_PPIX, 4); /* PPIX */ + + write_manf( i, cstr_info.numcomps, box, cio); + + for (compno=0; compno<cstr_info.numcomps; compno++){ + box[compno].length = write_ppixfaix( coff, compno, cstr_info, EPHused, j2klen, cio); + box[compno].type = JPIP_FAIX; + } + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + } + + opj_free(box); + + return len; +} + +int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio) +{ + int len, lenp, tileno, version, i, nmax, size_of_coding; /* 4 or 8*/ + opj_tile_info_t *tile_Idx; + opj_packet_info_t packet; + int resno, precno, layno, num_packet; + int numOfres, numOfprec, numOflayers; + packet.end_pos = packet.end_ph_pos = packet.start_pos = -1; + (void)EPHused; /* unused ? */ + + if( j2klen > pow( 2, 32)){ + size_of_coding = 8; + version = 1; + } + else{ + size_of_coding = 4; + version = 0; + } + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_FAIX, 4); /* FAIX */ + cio_write( cio, version, 1); /* Version 0 = 4 bytes */ + + nmax = 0; + for( i=0; i<=cstr_info.numdecompos[compno]; i++) + nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers; + + cio_write( cio, nmax, size_of_coding); /* NMAX */ + cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */ + + for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){ + tile_Idx = &cstr_info.tile[ tileno]; + + num_packet=0; + numOfres = cstr_info.numdecompos[compno] + 1; + + for( resno=0; resno<numOfres ; resno++){ + numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno]; + for( precno=0; precno<numOfprec; precno++){ + numOflayers = cstr_info.numlayers; + for( layno=0; layno<numOflayers; layno++){ + + switch ( cstr_info.prog){ + case LRCP: + packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno]; + break; + case RLCP: + packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno]; + break; + case RPCL: + packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno]; + break; + case PCRL: + packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno]; + break; + case CPRL: + packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno]; + break; + default: + fprintf( stderr, "failed to ppix indexing\n"); + } + + cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */ + cio_write( cio, packet.end_pos-packet.start_pos+1, size_of_coding); /* length */ + + num_packet++; + } + } + } + + while( num_packet < nmax){ /* PADDING */ + cio_write( cio, 0, size_of_coding); /* start position */ + cio_write( cio, 0, size_of_coding); /* length */ + num_packet++; + } + } + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + + return len; +} diff --git a/extern/libopenjpeg/t1.c b/extern/libopenjpeg/t1.c index ad1c6a83ab6..477720412aa 100644 --- a/extern/libopenjpeg/t1.c +++ b/extern/libopenjpeg/t1.c @@ -62,13 +62,25 @@ static void t1_enc_sigpass_step( /** Decode significant pass */ -static void t1_dec_sigpass_step( +static INLINE void t1_dec_sigpass_step_raw( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, + int oneplushalf, + int vsc); +static INLINE void t1_dec_sigpass_step_mqc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, + int oneplushalf); +static INLINE void t1_dec_sigpass_step_mqc_vsc( opj_t1_t *t1, flag_t *flagsp, int *datap, int orient, int oneplushalf, - char type, int vsc); /** Encode significant pass @@ -83,12 +95,19 @@ static void t1_enc_sigpass( /** Decode significant pass */ -static void t1_dec_sigpass( +static void t1_dec_sigpass_raw( opj_t1_t *t1, int bpno, int orient, - char type, int cblksty); +static void t1_dec_sigpass_mqc( + opj_t1_t *t1, + int bpno, + int orient); +static void t1_dec_sigpass_mqc_vsc( + opj_t1_t *t1, + int bpno, + int orient); /** Encode refinement pass */ @@ -104,14 +123,27 @@ static void t1_enc_refpass_step( /** Decode refinement pass */ -static void t1_dec_refpass_step( +static INLINE void t1_dec_refpass_step_raw( opj_t1_t *t1, flag_t *flagsp, int *datap, int poshalf, int neghalf, - char type, int vsc); +static INLINE void t1_dec_refpass_step_mqc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int poshalf, + int neghalf); +static INLINE void t1_dec_refpass_step_mqc_vsc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int poshalf, + int neghalf, + int vsc); + /** Encode refinement pass */ @@ -124,11 +156,16 @@ static void t1_enc_refpass( /** Decode refinement pass */ -static void t1_dec_refpass( +static void t1_dec_refpass_raw( opj_t1_t *t1, int bpno, - char type, int cblksty); +static void t1_dec_refpass_mqc( + opj_t1_t *t1, + int bpno); +static void t1_dec_refpass_mqc_vsc( + opj_t1_t *t1, + int bpno); /** Encode clean-up pass */ @@ -145,11 +182,23 @@ static void t1_enc_clnpass_step( /** Decode clean-up pass */ +static void t1_dec_clnpass_step_partial( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, + int oneplushalf); static void t1_dec_clnpass_step( opj_t1_t *t1, flag_t *flagsp, int *datap, int orient, + int oneplushalf); +static void t1_dec_clnpass_step_vsc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, int oneplushalf, int partial, int vsc); @@ -178,7 +227,8 @@ static double t1_getwmsedec( int bpno, int qmfbid, double stepsize, - int numcomps); + int numcomps, + int mct); /** Encode 1 code-block @param t1 T1 handle @@ -190,6 +240,7 @@ Encode 1 code-block @param stepsize @param cblksty Code-block style @param numcomps +@param mct @param tile */ static void t1_encode_cblk( @@ -202,6 +253,7 @@ static void t1_encode_cblk( double stepsize, int cblksty, int numcomps, + int mct, opj_tcd_tile_t * tile); /** Decode 1 code-block @@ -321,29 +373,43 @@ static void t1_enc_sigpass_step( } } -static void t1_dec_sigpass_step( +static INLINE void t1_dec_sigpass_step_raw( opj_t1_t *t1, flag_t *flagsp, int *datap, int orient, int oneplushalf, - char type, int vsc) { int v, flag; - opj_raw_t *raw = t1->raw; /* RAW component */ - opj_mqc_t *mqc = t1->mqc; /* MQC component */ + + OPJ_ARG_NOT_USED(orient); flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp); if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { - if (type == T1_TYPE_RAW) { if (raw_decode(raw)) { v = raw_decode(raw); /* ESSAI */ *datap = v ? -oneplushalf : oneplushalf; t1_updateflags(flagsp, v, t1->flags_stride); } - } else { + *flagsp |= T1_VISIT; + } +} /* VSC and BYPASS by Antonin */ + +static INLINE void t1_dec_sigpass_step_mqc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, + int oneplushalf) +{ + int v, flag; + + opj_mqc_t *mqc = t1->mqc; /* MQC component */ + + flag = *flagsp; + if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient)); if (mqc_decode(mqc)) { mqc_setcurctx(mqc, t1_getctxno_sc(flag)); @@ -351,6 +417,30 @@ static void t1_dec_sigpass_step( *datap = v ? -oneplushalf : oneplushalf; t1_updateflags(flagsp, v, t1->flags_stride); } + *flagsp |= T1_VISIT; + } +} /* VSC and BYPASS by Antonin */ + +static INLINE void t1_dec_sigpass_step_mqc_vsc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, + int oneplushalf, + int vsc) +{ + int v, flag; + + opj_mqc_t *mqc = t1->mqc; /* MQC component */ + + flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp); + if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { + mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient)); + if (mqc_decode(mqc)) { + mqc_setcurctx(mqc, t1_getctxno_sc(flag)); + v = mqc_decode(mqc) ^ t1_getspb(flag); + *datap = v ? -oneplushalf : oneplushalf; + t1_updateflags(flagsp, v, t1->flags_stride); } *flagsp |= T1_VISIT; } @@ -386,11 +476,10 @@ static void t1_enc_sigpass( } } -static void t1_dec_sigpass( +static void t1_dec_sigpass_raw( opj_t1_t *t1, int bpno, int orient, - char type, int cblksty) { int i, j, k, one, half, oneplushalf, vsc; @@ -401,13 +490,79 @@ static void t1_dec_sigpass( for (i = 0; i < t1->w; ++i) { for (j = k; j < k + 4 && j < t1->h; ++j) { vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0; - t1_dec_sigpass_step( + t1_dec_sigpass_step_raw( + t1, + &t1->flags[((j+1) * t1->flags_stride) + i + 1], + &t1->data[(j * t1->w) + i], + orient, + oneplushalf, + vsc); + } + } + } +} /* VSC and BYPASS by Antonin */ + +static void t1_dec_sigpass_mqc( + opj_t1_t *t1, + int bpno, + int orient) +{ + int i, j, k, one, half, oneplushalf; + int *data1 = t1->data; + flag_t *flags1 = &t1->flags[1]; + one = 1 << bpno; + half = one >> 1; + oneplushalf = one | half; + for (k = 0; k < (t1->h & ~3); k += 4) { + for (i = 0; i < t1->w; ++i) { + int *data2 = data1 + i; + flag_t *flags2 = flags1 + i; + flags2 += t1->flags_stride; + t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + } + data1 += t1->w << 2; + flags1 += t1->flags_stride << 2; + } + for (i = 0; i < t1->w; ++i) { + int *data2 = data1 + i; + flag_t *flags2 = flags1 + i; + for (j = k; j < t1->h; ++j) { + flags2 += t1->flags_stride; + t1_dec_sigpass_step_mqc(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + } + } +} /* VSC and BYPASS by Antonin */ + +static void t1_dec_sigpass_mqc_vsc( + opj_t1_t *t1, + int bpno, + int orient) +{ + int i, j, k, one, half, oneplushalf, vsc; + one = 1 << bpno; + half = one >> 1; + oneplushalf = one | half; + for (k = 0; k < t1->h; k += 4) { + for (i = 0; i < t1->w; ++i) { + for (j = k; j < k + 4 && j < t1->h; ++j) { + vsc = (j == k + 3 || j == t1->h - 1) ? 1 : 0; + t1_dec_sigpass_step_mqc_vsc( t1, &t1->flags[((j+1) * t1->flags_stride) + i + 1], &t1->data[(j * t1->w) + i], orient, oneplushalf, - type, vsc); } } @@ -442,28 +597,64 @@ static void t1_enc_refpass_step( } } -static void t1_dec_refpass_step( +static INLINE void t1_dec_refpass_step_raw( opj_t1_t *t1, flag_t *flagsp, int *datap, int poshalf, int neghalf, - char type, int vsc) { int v, t, flag; - opj_mqc_t *mqc = t1->mqc; /* MQC component */ opj_raw_t *raw = t1->raw; /* RAW component */ flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp); if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { - mqc_setcurctx(mqc, t1_getctxno_mag(flag)); /* ESSAI */ - if (type == T1_TYPE_RAW) { v = raw_decode(raw); - } else { + t = v ? poshalf : neghalf; + *datap += *datap < 0 ? -t : t; + *flagsp |= T1_REFINE; + } +} /* VSC and BYPASS by Antonin */ + +static INLINE void t1_dec_refpass_step_mqc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int poshalf, + int neghalf) +{ + int v, t, flag; + + opj_mqc_t *mqc = t1->mqc; /* MQC component */ + + flag = *flagsp; + if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { + mqc_setcurctx(mqc, t1_getctxno_mag(flag)); /* ESSAI */ v = mqc_decode(mqc); + t = v ? poshalf : neghalf; + *datap += *datap < 0 ? -t : t; + *flagsp |= T1_REFINE; } +} /* VSC and BYPASS by Antonin */ + +static INLINE void t1_dec_refpass_step_mqc_vsc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int poshalf, + int neghalf, + int vsc) +{ + int v, t, flag; + + opj_mqc_t *mqc = t1->mqc; /* MQC component */ + + flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp); + if ((flag & (T1_SIG | T1_VISIT)) == T1_SIG) { + mqc_setcurctx(mqc, t1_getctxno_mag(flag)); /* ESSAI */ + v = mqc_decode(mqc); t = v ? poshalf : neghalf; *datap += *datap < 0 ? -t : t; *flagsp |= T1_REFINE; @@ -498,10 +689,9 @@ static void t1_enc_refpass( } } -static void t1_dec_refpass( +static void t1_dec_refpass_raw( opj_t1_t *t1, int bpno, - char type, int cblksty) { int i, j, k, one, poshalf, neghalf; @@ -513,13 +703,78 @@ static void t1_dec_refpass( for (i = 0; i < t1->w; ++i) { for (j = k; j < k + 4 && j < t1->h; ++j) { vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0; - t1_dec_refpass_step( + t1_dec_refpass_step_raw( + t1, + &t1->flags[((j+1) * t1->flags_stride) + i + 1], + &t1->data[(j * t1->w) + i], + poshalf, + neghalf, + vsc); + } + } + } +} /* VSC and BYPASS by Antonin */ + +static void t1_dec_refpass_mqc( + opj_t1_t *t1, + int bpno) +{ + int i, j, k, one, poshalf, neghalf; + int *data1 = t1->data; + flag_t *flags1 = &t1->flags[1]; + one = 1 << bpno; + poshalf = one >> 1; + neghalf = bpno > 0 ? -poshalf : -1; + for (k = 0; k < (t1->h & ~3); k += 4) { + for (i = 0; i < t1->w; ++i) { + int *data2 = data1 + i; + flag_t *flags2 = flags1 + i; + flags2 += t1->flags_stride; + t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf); + data2 += t1->w; + } + data1 += t1->w << 2; + flags1 += t1->flags_stride << 2; + } + for (i = 0; i < t1->w; ++i) { + int *data2 = data1 + i; + flag_t *flags2 = flags1 + i; + for (j = k; j < t1->h; ++j) { + flags2 += t1->flags_stride; + t1_dec_refpass_step_mqc(t1, flags2, data2, poshalf, neghalf); + data2 += t1->w; + } + } +} /* VSC and BYPASS by Antonin */ + +static void t1_dec_refpass_mqc_vsc( + opj_t1_t *t1, + int bpno) +{ + int i, j, k, one, poshalf, neghalf; + int vsc; + one = 1 << bpno; + poshalf = one >> 1; + neghalf = bpno > 0 ? -poshalf : -1; + for (k = 0; k < t1->h; k += 4) { + for (i = 0; i < t1->w; ++i) { + for (j = k; j < k + 4 && j < t1->h; ++j) { + vsc = ((j == k + 3 || j == t1->h - 1)) ? 1 : 0; + t1_dec_refpass_step_mqc_vsc( t1, &t1->flags[((j+1) * t1->flags_stride) + i + 1], &t1->data[(j * t1->w) + i], poshalf, neghalf, - type, vsc); } } @@ -561,11 +816,55 @@ LABEL_PARTIAL: *flagsp &= ~T1_VISIT; } +static void t1_dec_clnpass_step_partial( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, + int oneplushalf) +{ + int v, flag; + opj_mqc_t *mqc = t1->mqc; /* MQC component */ + + OPJ_ARG_NOT_USED(orient); + + flag = *flagsp; + mqc_setcurctx(mqc, t1_getctxno_sc(flag)); + v = mqc_decode(mqc) ^ t1_getspb(flag); + *datap = v ? -oneplushalf : oneplushalf; + t1_updateflags(flagsp, v, t1->flags_stride); + *flagsp &= ~T1_VISIT; +} /* VSC and BYPASS by Antonin */ + static void t1_dec_clnpass_step( opj_t1_t *t1, flag_t *flagsp, int *datap, int orient, + int oneplushalf) +{ + int v, flag; + + opj_mqc_t *mqc = t1->mqc; /* MQC component */ + + flag = *flagsp; + if (!(flag & (T1_SIG | T1_VISIT))) { + mqc_setcurctx(mqc, t1_getctxno_zc(flag, orient)); + if (mqc_decode(mqc)) { + mqc_setcurctx(mqc, t1_getctxno_sc(flag)); + v = mqc_decode(mqc) ^ t1_getspb(flag); + *datap = v ? -oneplushalf : oneplushalf; + t1_updateflags(flagsp, v, t1->flags_stride); + } + } + *flagsp &= ~T1_VISIT; +} /* VSC and BYPASS by Antonin */ + +static void t1_dec_clnpass_step_vsc( + opj_t1_t *t1, + flag_t *flagsp, + int *datap, + int orient, int oneplushalf, int partial, int vsc) @@ -589,7 +888,7 @@ LABEL_PARTIAL: } } *flagsp &= ~T1_VISIT; -} /* VSC and BYPASS by Antonin */ +} static void t1_enc_clnpass( opj_t1_t *t1, @@ -669,22 +968,16 @@ static void t1_dec_clnpass( one = 1 << bpno; half = one >> 1; oneplushalf = one | half; + if (cblksty & J2K_CCP_CBLKSTY_VSC) { for (k = 0; k < t1->h; k += 4) { for (i = 0; i < t1->w; ++i) { if (k + 3 < t1->h) { - if (cblksty & J2K_CCP_CBLKSTY_VSC) { agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) || MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) || MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) || (MACRO_t1_flags(1 + k + 3,1 + i) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) & (T1_SIG | T1_VISIT | T1_SIG_OTH)); } else { - agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) - || MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) - || MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) - || MACRO_t1_flags(1 + k + 3,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)); - } - } else { agg = 0; } if (agg) { @@ -699,8 +992,8 @@ static void t1_dec_clnpass( runlen = 0; } for (j = k + runlen; j < k + 4 && j < t1->h; ++j) { - vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j == k + 3 || j == t1->h - 1)) ? 1 : 0; - t1_dec_clnpass_step( + vsc = (j == k + 3 || j == t1->h - 1) ? 1 : 0; + t1_dec_clnpass_step_vsc( t1, &t1->flags[((j+1) * t1->flags_stride) + i + 1], &t1->data[(j * t1->w) + i], @@ -711,6 +1004,65 @@ static void t1_dec_clnpass( } } } + } else { + int *data1 = t1->data; + flag_t *flags1 = &t1->flags[1]; + for (k = 0; k < (t1->h & ~3); k += 4) { + for (i = 0; i < t1->w; ++i) { + int *data2 = data1 + i; + flag_t *flags2 = flags1 + i; + agg = !(MACRO_t1_flags(1 + k,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) + || MACRO_t1_flags(1 + k + 1,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) + || MACRO_t1_flags(1 + k + 2,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) + || MACRO_t1_flags(1 + k + 3,1 + i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)); + if (agg) { + mqc_setcurctx(mqc, T1_CTXNO_AGG); + if (!mqc_decode(mqc)) { + continue; + } + mqc_setcurctx(mqc, T1_CTXNO_UNI); + runlen = mqc_decode(mqc); + runlen = (runlen << 1) | mqc_decode(mqc); + flags2 += runlen * t1->flags_stride; + data2 += runlen * t1->w; + for (j = k + runlen; j < k + 4 && j < t1->h; ++j) { + flags2 += t1->flags_stride; + if (agg && (j == k + runlen)) { + t1_dec_clnpass_step_partial(t1, flags2, data2, orient, oneplushalf); + } else { + t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf); + } + data2 += t1->w; + } + } else { + flags2 += t1->flags_stride; + t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + flags2 += t1->flags_stride; + t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + } + } + data1 += t1->w << 2; + flags1 += t1->flags_stride << 2; + } + for (i = 0; i < t1->w; ++i) { + int *data2 = data1 + i; + flag_t *flags2 = flags1 + i; + for (j = k; j < t1->h; ++j) { + flags2 += t1->flags_stride; + t1_dec_clnpass_step(t1, flags2, data2, orient, oneplushalf); + data2 += t1->w; + } + } + } + if (segsym) { int v = 0; mqc_setcurctx(mqc, T1_CTXNO_UNI); @@ -736,14 +1088,15 @@ static double t1_getwmsedec( int bpno, int qmfbid, double stepsize, - int numcomps) + int numcomps, + int mct) { double w1, w2, wmsedec; if (qmfbid == 1) { - w1 = (numcomps > 1) ? mct_getnorm(compno) : 1.0; + w1 = (mct && numcomps==3) ? mct_getnorm(compno) : 1.0; w2 = dwt_getnorm(level, orient); } else { /* if (qmfbid == 0) */ - w1 = (numcomps > 1) ? mct_getnorm_real(compno) : 1.0; + w1 = (mct && numcomps==3) ? mct_getnorm_real(compno) : 1.0; w2 = dwt_getnorm_real(level, orient); } wmsedec = w1 * w2 * stepsize * (1 << bpno); @@ -752,7 +1105,7 @@ static double t1_getwmsedec( return wmsedec; } -static bool allocate_buffers( +static opj_bool allocate_buffers( opj_t1_t *t1, int w, int h) @@ -764,7 +1117,7 @@ static bool allocate_buffers( opj_aligned_free(t1->data); t1->data = (int*) opj_aligned_malloc(datasize * sizeof(int)); if(!t1->data){ - return false; + return OPJ_FALSE; } t1->datasize=datasize; } @@ -777,7 +1130,7 @@ static bool allocate_buffers( opj_aligned_free(t1->flags); t1->flags = (flag_t*) opj_aligned_malloc(flagssize * sizeof(flag_t)); if(!t1->flags){ - return false; + return OPJ_FALSE; } t1->flagssize=flagssize; } @@ -786,7 +1139,7 @@ static bool allocate_buffers( t1->w=w; t1->h=h; - return true; + return OPJ_TRUE; } /** mod fixed_quality */ @@ -800,6 +1153,7 @@ static void t1_encode_cblk( double stepsize, int cblksty, int numcomps, + int mct, opj_tcd_tile_t * tile) { double cumwmsedec = 0.0; @@ -850,7 +1204,7 @@ static void t1_encode_cblk( } /* fixed_quality */ - tempwmsedec = t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps); + tempwmsedec = t1_getwmsedec(nmsedec, compno, level, orient, bpno, qmfbid, stepsize, numcomps, mct); cumwmsedec += tempwmsedec; tile->distotile += tempwmsedec; @@ -971,10 +1325,26 @@ static void t1_decode_cblk( for (passno = 0; passno < seg->numpasses; ++passno) { switch (passtype) { case 0: - t1_dec_sigpass(t1, bpno+1, orient, type, cblksty); + if (type == T1_TYPE_RAW) { + t1_dec_sigpass_raw(t1, bpno+1, orient, cblksty); + } else { + if (cblksty & J2K_CCP_CBLKSTY_VSC) { + t1_dec_sigpass_mqc_vsc(t1, bpno+1, orient); + } else { + t1_dec_sigpass_mqc(t1, bpno+1, orient); + } + } break; case 1: - t1_dec_refpass(t1, bpno+1, type, cblksty); + if (type == T1_TYPE_RAW) { + t1_dec_refpass_raw(t1, bpno+1, cblksty); + } else { + if (cblksty & J2K_CCP_CBLKSTY_VSC) { + t1_dec_refpass_mqc_vsc(t1, bpno+1); + } else { + t1_dec_refpass_mqc(t1, bpno+1); + } + } break; case 2: t1_dec_clnpass(t1, bpno+1, orient, cblksty); @@ -1045,6 +1415,7 @@ void t1_encode_cblks( for (bandno = 0; bandno < res->numbands; ++bandno) { opj_tcd_band_t* restrict band = &res->bands[bandno]; + int bandconst = 8192 * 8192 / ((int) floor(band->stepsize * 8192)); for (precno = 0; precno < res->pw * res->ph; ++precno) { opj_tcd_precinct_t *prc = &band->precincts[precno]; @@ -1095,7 +1466,7 @@ void t1_encode_cblks( datap[(j * cblk_w) + i] = fix_mul( tmp, - 8192 * 8192 / ((int) floor(band->stepsize * 8192))) >> (11 - T1_NMSEDEC_FRACBITS); + bandconst) >> (11 - T1_NMSEDEC_FRACBITS); } } } @@ -1110,6 +1481,7 @@ void t1_encode_cblks( band->stepsize, tccp->cblksty, tile->numcomps, + tcp->mct, tile); } /* cblkno */ @@ -1140,7 +1512,6 @@ void t1_decode_cblks( for (cblkno = 0; cblkno < precinct->cw * precinct->ch; ++cblkno) { opj_tcd_cblk_dec_t* cblk = &precinct->cblks.dec[cblkno]; int* restrict datap; - void* restrict tiledp; int cblk_w, cblk_h; int x, y; int i, j; @@ -1181,8 +1552,8 @@ void t1_decode_cblks( } } - tiledp=(void*)&tilec->data[(y * tile_w) + x]; if (tccp->qmfbid == 1) { + int* restrict tiledp = &tilec->data[(y * tile_w) + x]; for (j = 0; j < cblk_h; ++j) { for (i = 0; i < cblk_w; ++i) { int tmp = datap[(j * cblk_w) + i]; @@ -1190,11 +1561,16 @@ void t1_decode_cblks( } } } else { /* if (tccp->qmfbid == 0) */ + float* restrict tiledp = (float*) &tilec->data[(y * tile_w) + x]; for (j = 0; j < cblk_h; ++j) { + float* restrict tiledp2 = tiledp; for (i = 0; i < cblk_w; ++i) { - float tmp = datap[(j * cblk_w) + i] * band->stepsize; - ((float*)tiledp)[(j * tile_w) + i] = tmp; + float tmp = *datap * band->stepsize; + *tiledp2 = tmp; + datap++; + tiledp2++; } + tiledp += tile_w; } } opj_free(cblk->data); diff --git a/extern/libopenjpeg/t1.h b/extern/libopenjpeg/t1.h index 0b4294e1d6b..572ec88d2f6 100644 --- a/extern/libopenjpeg/t1.h +++ b/extern/libopenjpeg/t1.h @@ -135,8 +135,8 @@ void t1_encode_cblks(opj_t1_t *t1, opj_tcd_tile_t *tile, opj_tcp_t *tcp); /** Decode the code-blocks of a tile @param t1 T1 handle -@param tile The tile to decode -@param tcp Tile coding parameters +@param tilec The tile to decode +@param tccp Tile coding parameters */ void t1_decode_cblks(opj_t1_t* t1, opj_tcd_tilecomp_t* tilec, opj_tccp_t* tccp); /* ----------------------------------------------------------------------- */ diff --git a/extern/libopenjpeg/t2.c b/extern/libopenjpeg/t2.c index be9b42a4132..232a5437329 100644 --- a/extern/libopenjpeg/t2.c +++ b/extern/libopenjpeg/t2.c @@ -59,7 +59,8 @@ Encode a packet of a tile to a destination buffer */ static int t2_encode_packet(opj_tcd_tile_t *tile, opj_tcp_t *tcp, opj_pi_iterator_t *pi, unsigned char *dest, int len, opj_codestream_info_t *cstr_info, int tileno); /** -@param seg +@param cblk +@param index @param cblksty @param first */ @@ -72,6 +73,7 @@ Decode a packet of a tile from a source buffer @param tile Tile for which to write the packets @param tcp Tile coding parameters @param pi Packet identity +@param pack_info Packet information @return */ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_tile_t *tile, @@ -147,8 +149,8 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera c[1] = 145; c[2] = 0; c[3] = 4; - c[4] = (tile->packno % 65536) / 256; - c[5] = (tile->packno % 65536) % 256; + c[4] = (unsigned char)((tile->packno % 65536) / 256); + c[5] = (unsigned char)((tile->packno % 65536) % 256); c += 6; } /* </SOP> */ @@ -253,8 +255,8 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera /* </EPH> */ /* << INDEX */ - // End of packet header position. Currently only represents the distance to start of packet - // Will be updated later by incrementing with packet start value + /* End of packet header position. Currently only represents the distance to start of packet + // Will be updated later by incrementing with packet start value */ if(cstr_info && cstr_info->index_write) { opj_packet_info_t *info_PK = &cstr_info->tile[tileno].packet[cstr_info->packno]; info_PK->end_ph_pos = (int)(c - dest); @@ -401,8 +403,8 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t } /* << INDEX */ - // End of packet header position. Currently only represents the distance to start of packet - // Will be updated later by incrementing with packet start value + /* End of packet header position. Currently only represents the distance to start of packet + // Will be updated later by incrementing with packet start value*/ if(pack_info) { pack_info->end_ph_pos = (int)(c - src); } @@ -494,14 +496,15 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t if (tcp->csty & J2K_CP_CSTY_EPH) { if ((*hd) != 0xff || (*(hd + 1) != 0x92)) { opj_event_msg(t2->cinfo, EVT_ERROR, "Expected EPH marker\n"); + return -999; } else { hd += 2; } } /* << INDEX */ - // End of packet header position. Currently only represents the distance to start of packet - // Will be updated later by incrementing with packet start value + /* End of packet header position. Currently only represents the distance to start of packet + // Will be updated later by incrementing with packet start value*/ if(pack_info) { pack_info->end_ph_pos = (int)(hd - src); } @@ -565,7 +568,7 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t #endif /* USE_JPWL */ - cblk->data = (unsigned char*) opj_realloc(cblk->data, (cblk->len + seg->newlen) * sizeof(unsigned char*)); + cblk->data = (unsigned char*) opj_realloc(cblk->data, (cblk->len + seg->newlen) * sizeof(unsigned char)); memcpy(cblk->data + cblk->len, c, seg->newlen); if (seg->numpasses == 0) { seg->data = &cblk->data; @@ -614,6 +617,7 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye int tpnum = compno; if (pi_create_encode(pi, cp,tileno,poc,tpnum,tppos,t2_mode,cur_totnum_tp)) { opj_event_msg(t2->cinfo, EVT_ERROR, "Error initializing Packet Iterator\n"); + pi_destroy(pi, cp, tileno); return -999; } while (pi_next(&pi[poc])) { @@ -658,8 +662,8 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye info_PK->start_pos = ((cp->tp_on | tcp->POC)&& info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno - 1].end_pos + 1; } info_PK->end_pos = info_PK->start_pos + e - 1; - info_PK->end_ph_pos += info_PK->start_pos - 1; // End of packet header which now only represents the distance - // to start of packet is incremented by value of start of packet + info_PK->end_ph_pos += info_PK->start_pos - 1; /* End of packet header which now only represents the distance + // to start of packet is incremented by value of start of packet*/ } cstr_info->packno++; @@ -710,7 +714,7 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj } else { e = 0; } - + if(e == -999) return -999; /* progression in resolution */ image->comps[pi[pino].compno].resno_decoded = (e > 0) ? @@ -724,8 +728,9 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj opj_packet_info_t *info_PK = &info_TL->packet[cstr_info->packno]; if (!cstr_info->packno) { info_PK->start_pos = info_TL->end_header + 1; - } else if (info_TL->packet[cstr_info->packno-1].end_pos >= (int)cstr_info->tile[tileno].tp[curtp].tp_end_pos){ // New tile part - info_TL->tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; // Number of packets in previous tile-part + } else if (info_TL->packet[cstr_info->packno-1].end_pos >= (int)cstr_info->tile[tileno].tp[curtp].tp_end_pos){ /* New tile part*/ + info_TL->tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; /* Number of packets in previous tile-part*/ + info_TL->tp[curtp].tp_start_pack = tp_start_packno; tp_start_packno = cstr_info->packno; curtp++; info_PK->start_pos = cstr_info->tile[tileno].tp[curtp].tp_end_header+1; @@ -733,8 +738,8 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj info_PK->start_pos = (cp->tp_on && info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[cstr_info->packno - 1].end_pos + 1; } info_PK->end_pos = info_PK->start_pos + e - 1; - info_PK->end_ph_pos += info_PK->start_pos - 1; // End of packet header which now only represents the distance - // to start of packet is incremented by value of start of packet + info_PK->end_ph_pos += info_PK->start_pos - 1; /* End of packet header which now only represents the distance + // to start of packet is incremented by value of start of packet*/ cstr_info->packno++; } /* << INDEX */ @@ -748,7 +753,8 @@ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj } /* INDEX >> */ if(cstr_info) { - cstr_info->tile[tileno].tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; // Number of packets in last tile-part + cstr_info->tile[tileno].tp[curtp].tp_numpacks = cstr_info->packno - tp_start_packno; /* Number of packets in last tile-part*/ + cstr_info->tile[tileno].tp[curtp].tp_start_pack = tp_start_packno; } /* << INDEX */ diff --git a/extern/libopenjpeg/t2.h b/extern/libopenjpeg/t2.h index b15b7520019..2151ba67f48 100644 --- a/extern/libopenjpeg/t2.h +++ b/extern/libopenjpeg/t2.h @@ -67,6 +67,7 @@ Encode the packets of a tile to a destination buffer @param cstr_info Codestream information structure @param tpnum Tile part number of the current tile @param tppos The position of the tile part flag in the progression order +@param pino @param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass @param cur_totnum_tp The total number of tile parts in the current tile */ @@ -78,6 +79,7 @@ Decode the packets of a tile from a source buffer @param len length of the source buffer @param tileno number that identifies the tile for which to decode the packets @param tile tile for which to decode the packets +@param cstr_info Codestream information structure */ int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile, opj_codestream_info_t *cstr_info); diff --git a/extern/libopenjpeg/tcd.c b/extern/libopenjpeg/tcd.c index f4a54553e28..18cdbc786bc 100644 --- a/extern/libopenjpeg/tcd.c +++ b/extern/libopenjpeg/tcd.c @@ -33,7 +33,7 @@ #include "opj_includes.h" void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img) { - int tileno, compno, resno, bandno, precno;//, cblkno; + int tileno, compno, resno, bandno, precno;/*, cblkno;*/ fprintf(fd, "image {\n"); fprintf(fd, " tw=%d, th=%d x0=%d x1=%d y0=%d y1=%d\n", @@ -290,6 +290,7 @@ void tcd_malloc_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int c for (i = 0; i < res->pw * res->ph * 3; i++) { band->precincts[i].imsbtree = NULL; band->precincts[i].incltree = NULL; + band->precincts[i].cblks.enc = NULL; } for (precno = 0; precno < res->pw * res->ph; precno++) { @@ -418,12 +419,19 @@ void tcd_init_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int cur /* Modification of the RATE >> */ for (j = 0; j < tcp->numlayers; j++) { tcp->rates[j] = tcp->rates[j] ? - ((float) (tile->numcomps - * (tile->x1 - tile->x0) - * (tile->y1 - tile->y0) - * image->comps[0].prec))/ - (tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy) - : 0; + cp->tp_on ? + (((float) (tile->numcomps + * (tile->x1 - tile->x0) + * (tile->y1 - tile->y0) + * image->comps[0].prec)) + /(tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy)) - (((tcd->cur_totnum_tp - 1) * 14 )/ tcp->numlayers) + : + ((float) (tile->numcomps + * (tile->x1 - tile->x0) + * (tile->y1 - tile->y0) + * image->comps[0].prec))/ + (tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy) + : 0; if (tcp->rates[j]) { if (j && tcp->rates[j] < tcp->rates[j - 1] + 10) { @@ -584,7 +592,9 @@ void tcd_init_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int cur cblk->y0 = int_max(cblkystart, prc->y0); cblk->x1 = int_min(cblkxend, prc->x1); cblk->y1 = int_min(cblkyend, prc->y1); - cblk->data = (unsigned char*) opj_calloc(8192, sizeof(unsigned char)); + cblk->data = (unsigned char*) opj_calloc(8192+2, sizeof(unsigned char)); + /* FIXME: mqc_init_enc and mqc_byteout underrun the buffer if we don't do this. Why? */ + cblk->data += 2; cblk->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t)); cblk->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t)); } @@ -647,7 +657,7 @@ void tcd_malloc_decode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp) { tilec->y1 = int_ceildiv(tile->y1, image->comps[i].dy); x0 = j == 0 ? tilec->x0 : int_min(x0, (unsigned int) tilec->x0); - y0 = j == 0 ? tilec->y0 : int_min(y0, (unsigned int) tilec->x0); + y0 = j == 0 ? tilec->y0 : int_min(y0, (unsigned int) tilec->y0); x1 = j == 0 ? tilec->x1 : int_max(x1, (unsigned int) tilec->x1); y1 = j == 0 ? tilec->y1 : int_max(y1, (unsigned int) tilec->y1); } @@ -667,6 +677,8 @@ void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, opj_tcp_t *tcp; opj_tcd_tile_t *tile; + OPJ_ARG_NOT_USED(cstr_info); + tcd->cp = cp; tcp = &(cp->tcps[cp->tileno[tileno]]); @@ -988,7 +1000,7 @@ void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final) { } } -bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) { +opj_bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) { int compno, resno, bandno, precno, cblkno, passno, layno; double min, max; double cumdisto[100]; /* fixed_quality */ @@ -1085,7 +1097,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestre opj_t2_t *t2 = t2_create(tcd->cinfo, tcd->image, cp); double thresh = 0; - for (i = 0; i < 32; i++) { + for (i = 0; i < 128; i++) { int l = 0; double distoachieved = 0; /* fixed_quality */ thresh = (lo + hi) / 2; @@ -1140,7 +1152,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestre } if (!success) { - return false; + return OPJ_FALSE; } if(cstr_info) { /* Threshold for Marcela Index */ @@ -1152,7 +1164,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestre cumdisto[layno] = (layno == 0) ? tcd_tile->distolayer[0] : (cumdisto[layno - 1] + tcd_tile->distolayer[layno]); } - return true; + return OPJ_TRUE; } int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) { @@ -1304,7 +1316,7 @@ int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, op return l; } -bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info) { +opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info) { int l; int compno; int eof = 0; @@ -1340,7 +1352,7 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op } else { cstr_info->tile[tileno].pdx[resno] = 15; - cstr_info->tile[tileno].pdx[resno] = 15; + cstr_info->tile[tileno].pdy[resno] = 15; } } } @@ -1387,7 +1399,7 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op if (tcd->image->comps[compno].resno_decoded < 0) { opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. The number of resolutions to remove [%d+1] is higher than the number " " of resolutions in the original codestream [%d]\nModify the cp_reduce parameter.\n", tcd->cp->reduce, tile->comps[compno].numresolutions); - return false; + return OPJ_FALSE; } } @@ -1407,18 +1419,23 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op if (tcd->tcp->mct) { int n = (tile->comps[0].x1 - tile->comps[0].x0) * (tile->comps[0].y1 - tile->comps[0].y0); - if (tcd->tcp->tccps[0].qmfbid == 1) { - mct_decode( - tile->comps[0].data, - tile->comps[1].data, - tile->comps[2].data, - n); - } else { - mct_decode_real( - (float*)tile->comps[0].data, - (float*)tile->comps[1].data, - (float*)tile->comps[2].data, - n); + + if (tile->numcomps >= 3 ){ + if (tcd->tcp->tccps[0].qmfbid == 1) { + mct_decode( + tile->comps[0].data, + tile->comps[1].data, + tile->comps[2].data, + n); + } else { + mct_decode_real( + (float*)tile->comps[0].data, + (float*)tile->comps[1].data, + (float*)tile->comps[2].data, + n); + } + } else{ + opj_event_msg(tcd->cinfo, EVT_WARNING,"Number of components (%d) is inconsistent with a MCT. Skip the MCT step.\n",tile->numcomps); } } @@ -1467,10 +1484,10 @@ bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, op opj_event_msg(tcd->cinfo, EVT_INFO, "- tile decoded in %f s\n", tile_time); if (eof) { - return false; + return OPJ_FALSE; } - return true; + return OPJ_TRUE; } void tcd_free_decode(opj_tcd_t *tcd) { @@ -1504,3 +1521,4 @@ void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno) { } + diff --git a/extern/libopenjpeg/tcd.h b/extern/libopenjpeg/tcd.h index f0ac5619f1e..e3f93adc37f 100644 --- a/extern/libopenjpeg/tcd.h +++ b/extern/libopenjpeg/tcd.h @@ -251,7 +251,7 @@ void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, void tcd_makelayer_fixed(opj_tcd_t *tcd, int layno, int final); void tcd_rateallocate_fixed(opj_tcd_t *tcd); void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final); -bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info); +opj_bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info); /** Encode a tile from the raw image into a buffer @param tcd TCD handle @@ -268,8 +268,9 @@ Decode a tile from a buffer into a raw image @param src Source buffer @param len Length of source buffer @param tileno Number that identifies one of the tiles to be decoded +@param cstr_info Codestream information structure */ -bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info); +opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info); /** Free the memory allocated for decoding @param tcd TCD handle diff --git a/extern/libopenjpeg/thix_manager.c b/extern/libopenjpeg/thix_manager.c new file mode 100644 index 00000000000..aa55f217c06 --- /dev/null +++ b/extern/libopenjpeg/thix_manager.c @@ -0,0 +1,120 @@ +/* + * $Id: thix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2003-2004, Yannick Verschueren + * Copyright (c) 2010-2011, Kaori Hagihara + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*! \file + * \brief Modification of jpip.c from 2KAN indexer + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include "opj_includes.h" + +/* + * Write tile-part headers mhix box + * + * @param[in] coff offset of j2k codestream + * @param[in] cstr_info codestream information + * @param[in] tileno tile number + * @param[in] cio file output handle + * @return length of mhix box + */ +int write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio); + +int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio) +{ + int len, lenp, i; + int tileno; + opj_jp2_box_t *box; + + lenp = 0; + box = (opj_jp2_box_t *)opj_calloc( cstr_info.tw*cstr_info.th, sizeof(opj_jp2_box_t)); + + for ( i = 0; i < 2 ; i++ ){ + if (i) + cio_seek( cio, lenp); + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_THIX, 4); /* THIX */ + write_manf( i, cstr_info.tw*cstr_info.th, box, cio); + + for (tileno = 0; tileno < cstr_info.tw*cstr_info.th; tileno++){ + box[tileno].length = write_tilemhix( coff, cstr_info, tileno, cio); + box[tileno].type = JPIP_MHIX; + } + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + } + + opj_free(box); + + return len; +} + +int write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio) +{ + int i; + opj_tile_info_t tile; + opj_tp_info_t tp; + int len, lenp; + opj_marker_info_t *marker; + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_MHIX, 4); /* MHIX */ + + tile = cstr_info.tile[tileno]; + tp = tile.tp[0]; + + cio_write( cio, tp.tp_end_header-tp.tp_start_pos+1, 8); /* TLEN */ + + marker = cstr_info.tile[tileno].marker; + + for( i=0; i<cstr_info.tile[tileno].marknum; i++){ /* Marker restricted to 1 apparition */ + cio_write( cio, marker[i].type, 2); + cio_write( cio, 0, 2); + cio_write( cio, marker[i].pos-coff, 8); + cio_write( cio, marker[i].len, 2); + } + + /* free( marker);*/ + + len = cio_tell( cio) - lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + + return len; +} diff --git a/extern/libopenjpeg/tpix_manager.c b/extern/libopenjpeg/tpix_manager.c new file mode 100644 index 00000000000..9ba9e7fdabc --- /dev/null +++ b/extern/libopenjpeg/tpix_manager.c @@ -0,0 +1,153 @@ +/* + * $Id: tpix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $ + * + * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium + * Copyright (c) 2002-2011, Professor Benoit Macq + * Copyright (c) 2003-2004, Yannick Verschueren + * Copyright (c) 2010-2011, Kaori Hagihara + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/*! \file + * \brief Modification of jpip.c from 2KAN indexer + */ + +#include <math.h> +#include "opj_includes.h" + +#define MAX(a,b) ((a)>(b)?(a):(b)) + + +/* + * Write faix box of tpix + * + * @param[in] coff offset of j2k codestream + * @param[in] compno component number + * @param[in] cstr_info codestream information + * @param[in] j2klen length of j2k codestream + * @param[in] cio file output handle + * @return length of faix box + */ +int write_tpixfaix( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio); + + +int write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio) +{ + int len, lenp; + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_TPIX, 4); /* TPIX */ + + write_tpixfaix( coff, 0, cstr_info, j2klen, cio); + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + + return len; +} + + +/* + * Get number of maximum tile parts per tile + * + * @param[in] cstr_info codestream information + * @return number of maximum tile parts per tile + */ +int get_num_max_tile_parts( opj_codestream_info_t cstr_info); + +int write_tpixfaix( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio) +{ + int len, lenp; + int i, j; + int Aux; + int num_max_tile_parts; + int size_of_coding; /* 4 or 8 */ + opj_tp_info_t tp; + int version; + + num_max_tile_parts = get_num_max_tile_parts( cstr_info); + + if( j2klen > pow( 2, 32)){ + size_of_coding = 8; + version = num_max_tile_parts == 1 ? 1:3; + } + else{ + size_of_coding = 4; + version = num_max_tile_parts == 1 ? 0:2; + } + + lenp = cio_tell( cio); + cio_skip( cio, 4); /* L [at the end] */ + cio_write( cio, JPIP_FAIX, 4); /* FAIX */ + cio_write( cio, version, 1); /* Version 0 = 4 bytes */ + + cio_write( cio, num_max_tile_parts, size_of_coding); /* NMAX */ + cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */ + for (i = 0; i < cstr_info.tw*cstr_info.th; i++){ + for (j = 0; j < cstr_info.tile[i].num_tps; j++){ + tp = cstr_info.tile[i].tp[j]; + cio_write( cio, tp.tp_start_pos-coff, size_of_coding); /* start position */ + cio_write( cio, tp.tp_end_pos-tp.tp_start_pos+1, size_of_coding); /* length */ + if (version & 0x02){ + if( cstr_info.tile[i].num_tps == 1 && cstr_info.numdecompos[compno] > 1) + Aux = cstr_info.numdecompos[compno] + 1; + else + Aux = j + 1; + + cio_write( cio, Aux,4); + /*cio_write(img.tile[i].tile_parts[j].num_reso_AUX,4);*/ /* Aux_i,j : Auxiliary value */ + /* fprintf(stderr,"AUX value %d\n",Aux);*/ + } + /*cio_write(0,4);*/ + } + /* PADDING */ + while (j < num_max_tile_parts){ + cio_write( cio, 0, size_of_coding); /* start position */ + cio_write( cio, 0, size_of_coding); /* length */ + if (version & 0x02) + cio_write( cio, 0,4); /* Aux_i,j : Auxiliary value */ + j++; + } + } + + len = cio_tell( cio)-lenp; + cio_seek( cio, lenp); + cio_write( cio, len, 4); /* L */ + cio_seek( cio, lenp+len); + + return len; + +} + +int get_num_max_tile_parts( opj_codestream_info_t cstr_info) +{ + int num_max_tp = 0, i; + + for( i=0; i<cstr_info.tw*cstr_info.th; i++) + num_max_tp = MAX( cstr_info.tile[i].num_tps, num_max_tp); + + return num_max_tp; +} diff --git a/intern/bsp/test/BSP_GhostTest/BSP_GhostTest3D.cpp b/intern/bsp/test/BSP_GhostTest/BSP_GhostTest3D.cpp index 543e7e087b1..46cde625cf2 100644 --- a/intern/bsp/test/BSP_GhostTest/BSP_GhostTest3D.cpp +++ b/intern/bsp/test/BSP_GhostTest/BSP_GhostTest3D.cpp @@ -205,15 +205,15 @@ Operate( void BSP_GhostTestApp3D:: UpdateFrame( -){ -if (m_window) { +) { + if (m_window) { - GHOST_Rect v_rect; - m_window->getClientBounds(v_rect); + GHOST_Rect v_rect; + m_window->getClientBounds(v_rect); - glViewport(0,0,v_rect.getWidth(),v_rect.getHeight()); + glViewport(0,0,v_rect.getWidth(),v_rect.getHeight()); -} + } } diff --git a/intern/bsp/test/BSP_GhostTest/main.cpp b/intern/bsp/test/BSP_GhostTest/main.cpp index d5fa884afa1..25185f40192 100644 --- a/intern/bsp/test/BSP_GhostTest/main.cpp +++ b/intern/bsp/test/BSP_GhostTest/main.cpp @@ -93,8 +93,8 @@ NewTestMesh( #endif -int main() { - +int main() +{ MT_Vector3 min,max; MT_Vector3 min2,max2; diff --git a/intern/container/CTR_UHeap.h b/intern/container/CTR_UHeap.h index 8711d4375cb..8330faa2f54 100644 --- a/intern/container/CTR_UHeap.h +++ b/intern/container/CTR_UHeap.h @@ -53,47 +53,47 @@ class CTR_UHeapable { -public : - int & +public: + int & HeapPos( - ) { + ) { return m_ind; }; - float & + float & HeapKey( - ) { + ) { return m_key; }; const - float & + float & HeapKey( - ) const { + ) const { return m_key; }; const - int & + int & HeapPos( - ) const { + ) const { return m_ind; }; -private : +private: float m_key; int m_ind; -protected : +protected: CTR_UHeapable( - ) : m_key (0), - m_ind (0) + ) : m_key(0), + m_ind(0) { }; ~CTR_UHeapable( - ) { + ) { }; }; @@ -104,50 +104,50 @@ class CTR_UHeap : public MEM_NonCopyable public: static - CTR_UHeap * + CTR_UHeap * New( - ) { + ) { return new CTR_UHeap(); } - void + void MakeHeap( - HeapType *base - ) { + HeapType *base + ) { int i; - int start = Parent(m_vector.size()-1); - for (i = start; i >=0; --i) { - DownHeap(base,i); + int start = Parent(m_vector.size() - 1); + for (i = start; i >= 0; --i) { + DownHeap(base, i); } }; - void + void Insert( - HeapType *base, - int elem - ) { + HeapType *base, + int elem + ) { // add element to vector m_vector.push_back(elem); - base[elem].HeapPos() = m_vector.size()-1; + base[elem].HeapPos() = m_vector.size() - 1; // push the element up the heap - UpHeap(base,m_vector.size()-1); + UpHeap(base, m_vector.size() - 1); } // access to the vector for initial loading of elements - std::vector<int> & + std::vector<int> & HeapVector( - ) { + ) { return m_vector; }; - void + void Remove( - HeapType *base, - int i - ) { + HeapType *base, + int i + ) { // exchange with last element - pop last // element and move up or down the heap as appropriate @@ -155,37 +155,38 @@ public: assert(false); } - if (i != int(m_vector.size())-1) { + if (i != int(m_vector.size()) - 1) { - Swap(base,i,m_vector.size() - 1); + Swap(base, i, m_vector.size() - 1); m_vector.pop_back(); if (!m_vector.empty()) { - UpHeap(base,i); - DownHeap(base,i); + UpHeap(base, i); + DownHeap(base, i); } - } else { + } + else { m_vector.pop_back(); } } - int + int Top( - ) const { + ) const { if (m_vector.empty()) return -1; return m_vector[0]; } - void + void SC_Heap( - HeapType *base - ) { + HeapType *base + ) { int i; - for (i = 1; i < int(m_vector.size()) ; i++) { + for (i = 1; i < int(m_vector.size()); i++) { - CTR_UHeapable * elem = base + m_vector[i]; - CTR_UHeapable * p_elem = base + m_vector[Parent(i)]; + CTR_UHeapable *elem = base + m_vector[i]; + CTR_UHeapable *p_elem = base + m_vector[Parent(i)]; assert(p_elem->HeapKey() >= elem->HeapKey()); assert(elem->HeapPos() == i); @@ -195,27 +196,27 @@ public: ~CTR_UHeap( - ) { + ) { }; private: CTR_UHeap( - ) { + ) { }; std::vector<int> m_vector; private: - void + void Swap( - HeapType *base, - int i, - int j - ) { - std::swap(m_vector[i],m_vector[j]); + HeapType *base, + int i, + int j + ) { + std::swap(m_vector[i], m_vector[j]); CTR_UHeapable *heap_i = base + m_vector[i]; CTR_UHeapable *heap_j = base + m_vector[j]; @@ -225,77 +226,78 @@ private: heap_j->HeapPos() = j; } - int + int Parent( - unsigned int i - ) { - return (i-1) >> 1; + unsigned int i + ) { + return (i - 1) >> 1; } - int + int Left( - int i - ) { - return (i<<1)+1; + int i + ) { + return (i << 1) + 1; } - int + int Right( - int i - ) { - return (i<<1)+2; + int i + ) { + return (i << 1) + 2; } - float + float HeapVal( - HeapType *base, - int i - ) { + HeapType *base, + int i + ) { return base[m_vector[i]].HeapKey(); } - void + void DownHeap( - HeapType *base, - int i - ) { + HeapType *base, + int i + ) { int heap_size = m_vector.size(); int l = Left(i); int r = Right(i); int largest; - if (l < heap_size && HeapVal(base,l) > HeapVal(base,i)) { + if (l < heap_size && HeapVal(base, l) > HeapVal(base, i)) { largest = l; - } else { + } + else { largest = i; } - if (r < heap_size && HeapVal(base,r) > HeapVal(base,largest)) { + if (r < heap_size && HeapVal(base, r) > HeapVal(base, largest)) { largest = r; } if (largest != i) { // exchange i and largest - Swap(base,i,largest); - DownHeap(base,largest); + Swap(base, i, largest); + DownHeap(base, largest); } } - void + void UpHeap( - HeapType *base, - int i - ) { + HeapType *base, + int i + ) { // swap parents untill it's found a place in the heap < it's parent or // top of heap while (i > 0) { int p = Parent(i); - if (HeapVal(base,i) < HeapVal(base,p)) { + if (HeapVal(base, i) < HeapVal(base, p)) { break; } - Swap(base,p,i); + Swap(base, p, i); i = p; } } diff --git a/intern/cycles/SConscript b/intern/cycles/SConscript index 03880bddd8a..a7b8637e3ad 100644 --- a/intern/cycles/SConscript +++ b/intern/cycles/SConscript @@ -14,7 +14,7 @@ sources.remove(path.join('kernel', 'kernel_optimized.cpp')) incs = [] defs = [] -cxxflags = [] +cxxflags = Split(env['CXXFLAGS']) defs.append('CCL_NAMESPACE_BEGIN=namespace ccl {') defs.append('CCL_NAMESPACE_END=}') @@ -58,9 +58,9 @@ if env['WITH_BF_RAYOPTIMIZATION']: optim_sources = [path.join('kernel', 'kernel_optimized.cpp')] cycles_optim = cycles.Clone() - cycles_optim.BlenderLib('bf_intern_cycles_optimized', optim_sources, incs, optim_defs, libtype=['intern'], priority=[10], compileflags=[None], cxx_compileflags=optim_cxxflags) + cycles_optim.BlenderLib('bf_intern_cycles_optimized', optim_sources, incs, optim_defs, libtype=['intern'], priority=[10], cxx_compileflags=optim_cxxflags) -cycles.BlenderLib('bf_intern_cycles', sources, incs, defs, libtype=['intern'], priority=[0], compileflags=[None], cxx_compileflags=cxxflags) +cycles.BlenderLib('bf_intern_cycles', sources, incs, defs, libtype=['intern'], priority=[0], cxx_compileflags=cxxflags) # cuda kernel binaries if env['WITH_BF_CYCLES_CUDA_BINARIES']: diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index 1190ee185fd..5ec5cb929d6 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -254,6 +254,16 @@ static void xml_read_film(const XMLReadState& state, pugi::xml_node node) static void xml_read_integrator(const XMLReadState& state, pugi::xml_node node) { Integrator *integrator = state.scene->integrator; + + xml_read_bool(&integrator->progressive, node, "progressive"); + + if(!integrator->progressive) { + xml_read_int(&integrator->diffuse_samples, node, "diffuse_samples"); + xml_read_int(&integrator->glossy_samples, node, "glossy_samples"); + xml_read_int(&integrator->transmission_samples, node, "transmission_samples"); + xml_read_int(&integrator->ao_samples, node, "ao_samples"); + xml_read_int(&integrator->mesh_light_samples, node, "mesh_light_samples"); + } xml_read_int(&integrator->min_bounce, node, "min_bounce"); xml_read_int(&integrator->max_bounce, node, "max_bounce"); @@ -267,8 +277,10 @@ static void xml_read_integrator(const XMLReadState& state, pugi::xml_node node) xml_read_bool(&integrator->transparent_shadows, node, "transparent_shadows"); xml_read_bool(&integrator->no_caustics, node, "no_caustics"); + xml_read_float(&integrator->filter_glossy, node, "blur_glossy"); xml_read_int(&integrator->seed, node, "seed"); + xml_read_float(&integrator->sample_clamp, node, "sample_clamp"); } /* Camera */ diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index b4673ec6206..7a22cba316e 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -143,7 +143,9 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): cls.min_bounces = IntProperty( name="Min Bounces", - description="Minimum number of bounces, setting this lower than the maximum enables probalistic path termination (faster but noisier)", + description="Minimum number of bounces, setting this lower " + "than the maximum enables probabilistic path " + "termination (faster but noisier)", min=0, max=1024, default=3, ) @@ -175,7 +177,10 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): cls.transparent_min_bounces = IntProperty( name="Transparent Min Bounces", - description="Minimum number of transparent bounces, setting this lower than the maximum enables probalistic path termination (faster but noisier)", + 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, ) @@ -336,7 +341,7 @@ class CyclesCameraSettings(bpy.types.PropertyGroup): cls.fisheye_fov = FloatProperty( name="Field of View", description="Field of view for the fisheye lens", - min=0.1745, soft_max=2*math.pi, max=10.0*math.pi, + min=0.1745, soft_max=2 * math.pi, max=10.0 * math.pi, subtype='ANGLE', default=math.pi, ) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index bda8249c17e..5234db5255e 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -85,6 +85,7 @@ class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel): sub.prop(cscene, "ao_samples", text="AO") sub.prop(cscene, "mesh_light_samples", text="Mesh Light") + class CyclesRender_PT_light_paths(CyclesButtonsPanel, Panel): bl_label = "Light Paths" bl_options = {'DEFAULT_CLOSED'} @@ -545,6 +546,7 @@ class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel): if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'): layout.prop(lamp, "color") + class CyclesLamp_PT_spot(CyclesButtonsPanel, Panel): bl_label = "Spot Shape" bl_context = "data" @@ -569,6 +571,7 @@ class CyclesLamp_PT_spot(CyclesButtonsPanel, Panel): col = split.column() col.prop(lamp, "show_cone") + class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel): bl_label = "Surface" bl_context = "world" diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index d5b884cfccd..a928bd9a6ea 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -305,7 +305,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion) for(; b_sce; b_sce = b_sce.background_set()) { for(b_sce.objects.begin(b_ob); b_ob != b_sce.objects.end(); ++b_ob) { bool hide = (render_layer.use_viewport_visibility)? b_ob->hide(): b_ob->hide_render(); - uint ob_layer = get_layer(b_ob->layers()); + uint ob_layer = get_layer(b_ob->layers(), b_ob->layers_local_view(), object_is_light(*b_ob)); hide = hide || !(ob_layer & scene_layer); if(!hide) { diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index 12d7d00fb61..d09e43bd76d 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -218,7 +218,7 @@ void BlenderSession::render() } buffer_params.passes = passes; - scene->film->passes = passes; + scene->film->tag_passes_update(scene, passes); scene->film->tag_update(scene); scene->integrator->tag_update(scene); diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 5640a411fd7..c9d2d68da0a 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -219,7 +219,7 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d, const char *layer) layer = layername.c_str(); } else { - render_layer.scene_layer = get_layer(b_v3d.layers()); + render_layer.scene_layer = get_layer(b_v3d.layers(), b_v3d.layers_local_view()); render_layer.layer = render_layer.scene_layer; render_layer.holdout_layer = 0; render_layer.material_override = PointerRNA_NULL; diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index b5a76836bed..ebbd4e1221c 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -166,6 +166,28 @@ static inline uint get_layer(BL::Array<int, 20> array) return layer; } +static inline uint get_layer(BL::Array<int, 20> array, BL::Array<int, 8> local_array, bool is_light = false) +{ + uint layer = 0; + + for(uint i = 0; i < 20; i++) + if(array[i]) + layer |= (1 << i); + + if(is_light) { + /* consider lamps on all local view layers */ + for(uint i = 0; i < 8; i++) + layer |= (1 << (20+i)); + } + else { + for(uint i = 0; i < 8; i++) + if(local_array[i]) + layer |= (1 << (20+i)); + } + + return layer; +} + #if 0 static inline float3 get_float3(PointerRNA& ptr, const char *name) { diff --git a/intern/cycles/cmake/external_libs.cmake b/intern/cycles/cmake/external_libs.cmake index 7d12e261068..23a919530f9 100644 --- a/intern/cycles/cmake/external_libs.cmake +++ b/intern/cycles/cmake/external_libs.cmake @@ -11,10 +11,10 @@ if(WITH_CYCLES_TEST) include_directories(${GLUT_INCLUDE_DIR}) endif() -if(WITH_BUILTIN_GLEW) - set(CYCLES_GLEW_LIBRARY extern_glew) -else() +if(WITH_SYSTEM_GLEW) set(CYCLES_GLEW_LIBRARY ${GLEW_LIBRARY}) +else() + set(CYCLES_GLEW_LIBRARY extern_glew) endif() ########################################################################### diff --git a/intern/cycles/kernel/kernel_triangle.h b/intern/cycles/kernel/kernel_triangle.h index 384c3a8a506..6c1ea465515 100644 --- a/intern/cycles/kernel/kernel_triangle.h +++ b/intern/cycles/kernel/kernel_triangle.h @@ -191,7 +191,7 @@ __device int triangle_find_attribute(KernelGlobals *kg, ShaderData *sd, uint id) attr_map = kernel_tex_fetch(__attributes_map, ++attr_offset); /* return result */ - return (attr_map.y == ATTR_ELEMENT_NONE)? ATTR_STD_NOT_FOUND: attr_map.z; + return (attr_map.y == ATTR_ELEMENT_NONE) ? (int)ATTR_STD_NOT_FOUND : attr_map.z; } __device float4 triangle_motion_vector(KernelGlobals *kg, ShaderData *sd) diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp index 035821fadde..fdf25ca7908 100644 --- a/intern/cycles/render/film.cpp +++ b/intern/cycles/render/film.cpp @@ -20,6 +20,7 @@ #include "device.h" #include "film.h" #include "integrator.h" +#include "mesh.h" #include "scene.h" #include "util_algorithm.h" @@ -296,6 +297,16 @@ bool Film::modified(const Film& film) && Pass::equals(passes, film.passes)); } +void Film::tag_passes_update(Scene *scene, const vector<Pass>& passes_) +{ + if(Pass::contains(passes, PASS_UV) != Pass::contains(passes_, PASS_UV)) + scene->mesh_manager->tag_update(scene); + else if(Pass::contains(passes, PASS_MOTION) != Pass::contains(passes_, PASS_MOTION)) + scene->mesh_manager->tag_update(scene); + + passes = passes_; +} + void Film::tag_update(Scene *scene) { need_update = true; diff --git a/intern/cycles/render/film.h b/intern/cycles/render/film.h index c7d2ee24388..52d1a8428f8 100644 --- a/intern/cycles/render/film.h +++ b/intern/cycles/render/film.h @@ -56,6 +56,7 @@ public: void device_free(Device *device, DeviceScene *dscene); bool modified(const Film& film); + void tag_passes_update(Scene *scene, const vector<Pass>& passes_); void tag_update(Scene *scene); }; diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index dc20dbdbea2..1af0972ecf9 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -109,8 +109,11 @@ int ImageManager::add_image(const string& filename, bool& is_float) if(slot == float_images.size()) { /* max images limit reached */ - if(float_images.size() == TEX_NUM_FLOAT_IMAGES) + if(float_images.size() == TEX_NUM_FLOAT_IMAGES) { + printf("ImageManager::add_image: byte image limit reached %d, skipping '%s'\n", + TEX_NUM_IMAGES, filename.c_str()); return -1; + } float_images.resize(float_images.size() + 1); } @@ -141,8 +144,11 @@ int ImageManager::add_image(const string& filename, bool& is_float) if(slot == images.size()) { /* max images limit reached */ - if(images.size() == TEX_NUM_IMAGES) + if(images.size() == TEX_NUM_IMAGES) { + printf("ImageManager::add_image: byte image limit reached %d, skipping '%s'\n", + TEX_NUM_IMAGES, filename.c_str()); return -1; + } images.resize(images.size() + 1); } @@ -353,13 +359,13 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl device->tex_free(tex_img); if(!file_load_float_image(img, tex_img)) { - /* on failure to load, we set a 1x1 pixels black image */ + /* on failure to load, we set a 1x1 pixels pink image */ float *pixels = (float*)tex_img.resize(1, 1); - pixels[0] = 0.0f; - pixels[1] = 0.0f; - pixels[2] = 0.0f; - pixels[3] = 0.0f; + pixels[0] = TEX_IMAGE_MISSING_R; + pixels[1] = TEX_IMAGE_MISSING_G; + pixels[2] = TEX_IMAGE_MISSING_B; + pixels[3] = TEX_IMAGE_MISSING_A; } string name; @@ -380,13 +386,13 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl device->tex_free(tex_img); if(!file_load_image(img, tex_img)) { - /* on failure to load, we set a 1x1 pixels black image */ + /* on failure to load, we set a 1x1 pixels pink image */ uchar *pixels = (uchar*)tex_img.resize(1, 1); - pixels[0] = 0; - pixels[1] = 0; - pixels[2] = 0; - pixels[3] = 0; + pixels[0] = (TEX_IMAGE_MISSING_R * 255); + pixels[1] = (TEX_IMAGE_MISSING_G * 255); + pixels[2] = (TEX_IMAGE_MISSING_B * 255); + pixels[3] = (TEX_IMAGE_MISSING_A * 255); } string name; diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h index 2b5e53cabe1..ef046cfcafb 100644 --- a/intern/cycles/render/image.h +++ b/intern/cycles/render/image.h @@ -31,6 +31,12 @@ CCL_NAMESPACE_BEGIN #define TEX_IMAGE_MAX (TEX_NUM_IMAGES + TEX_NUM_FLOAT_IMAGES) #define TEX_IMAGE_FLOAT_START TEX_NUM_IMAGES +/* color to use when textures are not found */ +#define TEX_IMAGE_MISSING_R 1 +#define TEX_IMAGE_MISSING_G 0 +#define TEX_IMAGE_MISSING_B 1 +#define TEX_IMAGE_MISSING_A 1 + class Device; class DeviceScene; class Progress; diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 0f64d858de0..e4a4b874964 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -184,10 +184,12 @@ void ImageTextureNode::compile(SVMCompiler& compiler) /* image not found */ if(!color_out->links.empty()) { compiler.add_node(NODE_VALUE_V, color_out->stack_offset); - compiler.add_node(NODE_VALUE_V, make_float3(0, 0, 0)); + compiler.add_node(NODE_VALUE_V, make_float3(TEX_IMAGE_MISSING_R, + TEX_IMAGE_MISSING_G, + TEX_IMAGE_MISSING_B)); } if(!alpha_out->links.empty()) - compiler.add_node(NODE_VALUE_F, __float_as_int(0.0f), alpha_out->stack_offset); + compiler.add_node(NODE_VALUE_F, __float_as_int(TEX_IMAGE_MISSING_A), alpha_out->stack_offset); } } @@ -288,10 +290,12 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler) /* image not found */ if(!color_out->links.empty()) { compiler.add_node(NODE_VALUE_V, color_out->stack_offset); - compiler.add_node(NODE_VALUE_V, make_float3(0, 0, 0)); + compiler.add_node(NODE_VALUE_V, make_float3(TEX_IMAGE_MISSING_R, + TEX_IMAGE_MISSING_G, + TEX_IMAGE_MISSING_B)); } if(!alpha_out->links.empty()) - compiler.add_node(NODE_VALUE_F, __float_as_int(0.0f), alpha_out->stack_offset); + compiler.add_node(NODE_VALUE_F, __float_as_int(TEX_IMAGE_MISSING_A), alpha_out->stack_offset); } } diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h index 703c528bdea..2fd61570011 100644 --- a/intern/ffmpeg/ffmpeg_compat.h +++ b/intern/ffmpeg/ffmpeg_compat.h @@ -80,12 +80,24 @@ #endif #if ((LIBAVFORMAT_VERSION_MAJOR > 53) || ((LIBAVFORMAT_VERSION_MAJOR == 53) && (LIBAVFORMAT_VERSION_MINOR > 32)) || ((LIBAVFORMAT_VERSION_MAJOR == 53) && (LIBAVFORMAT_VERSION_MINOR == 24) && (LIBAVFORMAT_VERSION_MICRO >= 100))) -void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); +static inline +void my_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp) +{ + int i; + + for (i = 0; i < s->nb_streams; i++) { + AVStream *st = s->streams[i]; + + st->cur_dts = av_rescale(timestamp, + st->time_base.den * (int64_t)ref_st->time_base.num, + st->time_base.num * (int64_t)ref_st->time_base.den); + } +} static inline void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp) { - ff_update_cur_dts(s, ref_st, timestamp); + my_update_cur_dts(s, ref_st, timestamp); } #endif diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h index 7f33f2bdcde..764df79230d 100644 --- a/intern/ghost/GHOST_C-api.h +++ b/intern/ghost/GHOST_C-api.h @@ -128,8 +128,8 @@ extern GHOST_TSuccess GHOST_RemoveTimer(GHOST_SystemHandle systemhandle, GHOST_TimerTaskHandle timertaskhandle); /*************************************************************************************** -** Display/window management functionality -***************************************************************************************/ + * Display/window management functionality + ***************************************************************************************/ /** * Returns the number of displays on this system. @@ -235,8 +235,8 @@ extern GHOST_TSuccess GHOST_EndFullScreen(GHOST_SystemHandle systemhandle); extern int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle); /*************************************************************************************** -** Event management functionality -***************************************************************************************/ + * Event management functionality + ***************************************************************************************/ /** * Retrieves events from the system and stores them in the queue. @@ -273,8 +273,8 @@ extern GHOST_TSuccess GHOST_RemoveEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle); /*************************************************************************************** -** Progress bar functionality -***************************************************************************************/ + * Progress bar functionality + ***************************************************************************************/ /** * Sets the progress bar value displayed in the window/application icon @@ -290,8 +290,8 @@ extern GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle, floa extern GHOST_TSuccess GHOST_EndProgressBar(GHOST_WindowHandle windowhandle); /*************************************************************************************** -** Cursor management functionality -***************************************************************************************/ + * Cursor management functionality + ***************************************************************************************/ /** * Returns the current cursor shape. @@ -394,8 +394,8 @@ extern GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle, int *bounds); /*************************************************************************************** -** Access to mouse button and keyboard states. -***************************************************************************************/ + * Access to mouse button and keyboard states. + ***************************************************************************************/ /** * Returns the state of a modifier key (ouside the message queue). @@ -421,8 +421,8 @@ extern GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle, /*************************************************************************************** -** Drag'n'drop operations -***************************************************************************************/ + * Drag'n'drop operations + ***************************************************************************************/ /** * Tells if the ongoing drag'n'drop object can be accepted upon mouse drop diff --git a/intern/ghost/GHOST_IEvent.h b/intern/ghost/GHOST_IEvent.h index 3c3111a2e6d..ef63c57caa5 100644 --- a/intern/ghost/GHOST_IEvent.h +++ b/intern/ghost/GHOST_IEvent.h @@ -86,13 +86,7 @@ public: virtual GHOST_TEventDataPtr getData() = 0; #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { - return MEM_mallocN(num_bytes, "GHOST:GHOST_IEvent"); - } - void operator delete(void *mem) { - MEM_freeN(mem); - } + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IEvent") #endif }; diff --git a/intern/ghost/GHOST_IEventConsumer.h b/intern/ghost/GHOST_IEventConsumer.h index d437f219f8d..cfc4fae7978 100644 --- a/intern/ghost/GHOST_IEventConsumer.h +++ b/intern/ghost/GHOST_IEventConsumer.h @@ -64,9 +64,7 @@ public: virtual bool processEvent(GHOST_IEvent *event) = 0; #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GHOST:GHOST_IEventConsumer"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IEventConsumer") #endif }; diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index bd4f3aed5aa..474e3e97c45 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -177,8 +177,8 @@ protected: public: /*************************************************************************************** - ** Time(r) functionality - ***************************************************************************************/ + * Time(r) functionality + ***************************************************************************************/ /** * Returns the system time. @@ -211,8 +211,8 @@ public: virtual GHOST_TSuccess removeTimer(GHOST_ITimerTask *timerTask) = 0; /*************************************************************************************** - ** Display/window management functionality - ***************************************************************************************/ + * Display/window management functionality + ***************************************************************************************/ /** * Returns the number of displays on this system. @@ -296,8 +296,8 @@ public: virtual bool getFullScreen(void) = 0; /*************************************************************************************** - ** Event management functionality - ***************************************************************************************/ + * Event management functionality + ***************************************************************************************/ /** * Retrieves events from the system and stores them in the queue. @@ -327,8 +327,8 @@ public: virtual GHOST_TSuccess removeEventConsumer(GHOST_IEventConsumer *consumer) = 0; /*************************************************************************************** - ** Cursor management functionality - ***************************************************************************************/ + * Cursor management functionality + ***************************************************************************************/ /** * Returns the current location of the cursor (location in screen coordinates) @@ -348,8 +348,8 @@ public: virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) = 0; /*************************************************************************************** - ** Access to mouse button and keyboard states. - ***************************************************************************************/ + * Access to mouse button and keyboard states. + ***************************************************************************************/ /** * Returns the state of a modifier key (ouside the message queue). @@ -379,8 +379,8 @@ public: virtual int toggleConsole(int action) = 0; /*************************************************************************************** - ** Access to clipboard. - ***************************************************************************************/ + * Access to clipboard. + ***************************************************************************************/ /** * Returns the selection buffer @@ -415,14 +415,9 @@ protected: /** The one and only system */ static GHOST_ISystem *m_system; + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { - return MEM_mallocN(num_bytes, "GHOST:GHOST_ISystem"); - } - void operator delete(void *mem) { - MEM_freeN(mem); - } + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_ISystem") #endif }; diff --git a/intern/ghost/GHOST_ISystemPaths.h b/intern/ghost/GHOST_ISystemPaths.h index ee8bd9d1eda..1ba4ceaaaba 100644 --- a/intern/ghost/GHOST_ISystemPaths.h +++ b/intern/ghost/GHOST_ISystemPaths.h @@ -98,6 +98,11 @@ public: private: /** The one and only system paths*/ static GHOST_ISystemPaths *m_systemPaths; + + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_ISystemPaths") +#endif }; #endif diff --git a/intern/ghost/GHOST_ITimerTask.h b/intern/ghost/GHOST_ITimerTask.h index bb4a81be5f8..08c4890939f 100644 --- a/intern/ghost/GHOST_ITimerTask.h +++ b/intern/ghost/GHOST_ITimerTask.h @@ -84,14 +84,9 @@ public: */ virtual void setUserData(const GHOST_TUserDataPtr userData) = 0; + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { - return MEM_mallocN(num_bytes, "GHOST:GHOST_ITimerTask"); - } - void operator delete(void *mem) { - MEM_freeN(mem); - } + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_ITimerTask") #endif }; diff --git a/intern/ghost/GHOST_IWindow.h b/intern/ghost/GHOST_IWindow.h index e754883504d..5005718e4a5 100644 --- a/intern/ghost/GHOST_IWindow.h +++ b/intern/ghost/GHOST_IWindow.h @@ -235,8 +235,8 @@ public: virtual const GHOST_TabletData *GetTabletData() = 0; /*************************************************************************************** - ** Progress bar functionality - ***************************************************************************************/ + * Progress bar functionality + ***************************************************************************************/ /** * Sets the progress bar value displayed in the window/application icon @@ -250,8 +250,8 @@ public: virtual GHOST_TSuccess endProgressBar() = 0; /*************************************************************************************** - ** Cursor management functionality - ***************************************************************************************/ + * Cursor management functionality + ***************************************************************************************/ /** * Returns the current cursor shape. @@ -306,9 +306,7 @@ public: virtual GHOST_TSuccess setCursorGrab(GHOST_TGrabCursorMode mode, GHOST_Rect *bounds) { return GHOST_kSuccess; } #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GHOST:GHOST_IWindow"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_IWindow") #endif }; diff --git a/intern/ghost/GHOST_Rect.h b/intern/ghost/GHOST_Rect.h index 90678c6dfa2..745e402cdc8 100644 --- a/intern/ghost/GHOST_Rect.h +++ b/intern/ghost/GHOST_Rect.h @@ -190,9 +190,7 @@ public: GHOST_TInt32 m_b; #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GHOST:GHOST_Rect"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_Rect") #endif }; diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 8454f338645..4921acde670 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -37,7 +37,11 @@ #include "MEM_guardedalloc.h" #endif -#define GHOST_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name +#if defined(WITH_CXX_GUARDEDALLOC) && defined(__cplusplus) +# define GHOST_DECLARE_HANDLE(name) typedef struct name##__ { int unused; MEM_CXX_CLASS_ALLOC_FUNCS(#name) } *name +#else +# define GHOST_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name +#endif typedef char GHOST_TInt8; typedef unsigned char GHOST_TUns8; diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp index ad43798bc60..4cdd9384eee 100644 --- a/intern/ghost/intern/GHOST_C-api.cpp +++ b/intern/ghost/intern/GHOST_C-api.cpp @@ -27,15 +27,8 @@ /** \file ghost/intern/GHOST_C-api.cpp * \ingroup GHOST - */ - - -/* - - * GHOST_C-Api.cpp * * C Api for GHOST - * */ #include <stdlib.h> diff --git a/intern/ghost/intern/GHOST_CallbackEventConsumer.cpp b/intern/ghost/intern/GHOST_CallbackEventConsumer.cpp index 2e602f33b43..47121562604 100644 --- a/intern/ghost/intern/GHOST_CallbackEventConsumer.cpp +++ b/intern/ghost/intern/GHOST_CallbackEventConsumer.cpp @@ -31,7 +31,6 @@ /** - * Copyright (C) 2001 NaN Technologies B.V. * @author Maarten Gribnau * @date October 25, 2001 diff --git a/intern/ghost/intern/GHOST_CallbackEventConsumer.h b/intern/ghost/intern/GHOST_CallbackEventConsumer.h index 61aef742a48..e13a56c38f4 100644 --- a/intern/ghost/intern/GHOST_CallbackEventConsumer.h +++ b/intern/ghost/intern/GHOST_CallbackEventConsumer.h @@ -73,6 +73,10 @@ protected: GHOST_EventCallbackProcPtr m_eventCallback; /** The data passed back though the call-back routine. */ GHOST_TUserDataPtr m_userData; + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_CallbackEventConsumer") +#endif }; #endif // __GHOST_CALLBACKEVENTCONSUMER_H__ diff --git a/intern/ghost/intern/GHOST_DisplayManager.h b/intern/ghost/intern/GHOST_DisplayManager.h index 3e867054d01..7893f0936b3 100644 --- a/intern/ghost/intern/GHOST_DisplayManager.h +++ b/intern/ghost/intern/GHOST_DisplayManager.h @@ -133,6 +133,11 @@ protected: bool m_settingsInitialized; /** The list with display settings for the main display. */ std::vector<GHOST_DisplaySettings> m_settings; + + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_DisplayManager") +#endif }; diff --git a/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp b/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp index 7752ae8cbc0..21798ed2d0a 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp +++ b/intern/ghost/intern/GHOST_DisplayManagerCarbon.cpp @@ -31,7 +31,6 @@ /** - * Copyright (C) 2001 NaN Technologies B.V. * @author Maarten Gribnau * @date September 21, 2001 diff --git a/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp b/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp index fbfbce264a5..86f0380c8d6 100644 --- a/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp +++ b/intern/ghost/intern/GHOST_DisplayManagerSDL.cpp @@ -177,7 +177,7 @@ GHOST_DisplayManagerSDL:: setCurrentDisplaySetting(GHOST_TUns8 display, } else { /* this is a problem for the BGE player :S, perhaps SDL2 will resolve at some point. - * we really need SDL_SetDisplayModeForDisplay() to become an API func! - campbell */ + * we really need SDL_SetDisplayModeForDisplay() to become an API func! - campbell */ printf("no windows available, cant fullscreen"); /* do not fail, we will try again later when the window is created - wander */ diff --git a/intern/ghost/intern/GHOST_DropTargetWin32.cpp b/intern/ghost/intern/GHOST_DropTargetWin32.cpp index 0f07435d417..4142b19f21d 100644 --- a/intern/ghost/intern/GHOST_DropTargetWin32.cpp +++ b/intern/ghost/intern/GHOST_DropTargetWin32.cpp @@ -136,7 +136,7 @@ HRESULT __stdcall GHOST_DropTargetWin32::DragOver(DWORD grfKeyState, POINTL pt, } else { *pdwEffect = DROPEFFECT_NONE; - //*pdwEffect = DROPEFFECT_COPY; // XXX Uncomment to test drop. Drop will not be called if pdwEffect == DROPEFFECT_NONE. + // *pdwEffect = DROPEFFECT_COPY; // XXX Uncomment to test drop. Drop will not be called if pdwEffect == DROPEFFECT_NONE. } m_system->pushDragDropEvent(GHOST_kEventDraggingUpdated, m_draggedObjectType, m_window, pt.x, pt.y, NULL); return S_OK; diff --git a/intern/ghost/intern/GHOST_EventManager.cpp b/intern/ghost/intern/GHOST_EventManager.cpp index 4c03dad2e73..33e0afb797a 100644 --- a/intern/ghost/intern/GHOST_EventManager.cpp +++ b/intern/ghost/intern/GHOST_EventManager.cpp @@ -31,7 +31,6 @@ /** - * Copyright (C) 2001 NaN Technologies B.V. * @author Maarten Gribnau * @date May 14, 2001 diff --git a/intern/ghost/intern/GHOST_EventManager.h b/intern/ghost/intern/GHOST_EventManager.h index f941dac9fb4..eec00789800 100644 --- a/intern/ghost/intern/GHOST_EventManager.h +++ b/intern/ghost/intern/GHOST_EventManager.h @@ -168,6 +168,11 @@ protected: /** The list with event consumers. */ TConsumerVector m_consumers; + + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_EventManager") +#endif }; #endif // __GHOST_EVENTMANAGER_H__ diff --git a/intern/ghost/intern/GHOST_ISystem.cpp b/intern/ghost/intern/GHOST_ISystem.cpp index e983bd8214a..fe1132e7996 100644 --- a/intern/ghost/intern/GHOST_ISystem.cpp +++ b/intern/ghost/intern/GHOST_ISystem.cpp @@ -31,7 +31,6 @@ /** - * Copyright (C) 2001 NaN Technologies B.V. * @author Maarten Gribnau * @date May 7, 2001 diff --git a/intern/ghost/intern/GHOST_ISystemPaths.cpp b/intern/ghost/intern/GHOST_ISystemPaths.cpp index 0ad9dd48d2b..f84c50770f0 100644 --- a/intern/ghost/intern/GHOST_ISystemPaths.cpp +++ b/intern/ghost/intern/GHOST_ISystemPaths.cpp @@ -31,7 +31,6 @@ /** - * Copyright (C) 2001 NaN Technologies B.V. * @author Maarten Gribnau * @date May 7, 2001 diff --git a/intern/ghost/intern/GHOST_ModifierKeys.cpp b/intern/ghost/intern/GHOST_ModifierKeys.cpp index a02e6218891..ffc7a09e4dd 100644 --- a/intern/ghost/intern/GHOST_ModifierKeys.cpp +++ b/intern/ghost/intern/GHOST_ModifierKeys.cpp @@ -31,7 +31,6 @@ /** - * Copyright (C) 2001 NaN Technologies B.V. * @author Maarten Gribnau * @date May 31, 2001 diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp index 79102967f3e..d62d4437972 100644 --- a/intern/ghost/intern/GHOST_NDOFManager.cpp +++ b/intern/ghost/intern/GHOST_NDOFManager.cpp @@ -395,7 +395,7 @@ void GHOST_NDOFManager::setDeadZone(float dz) dz = 0.f; } else if (dz > 0.5f) { - // warn the rogue user/programmer, but allow it + // warn the rogue user/developer, but allow it GHOST_PRINTF("ndof: dead zone of %.2f is rather high...\n", dz); } m_deadZone = dz; diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index b25f24e653c..de475c79f43 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -76,8 +76,8 @@ protected: public: /*************************************************************************************** - ** Time(r) functionality - ***************************************************************************************/ + * Time(r) functionality + ***************************************************************************************/ /** * Returns the system time. @@ -110,8 +110,8 @@ public: virtual GHOST_TSuccess removeTimer(GHOST_ITimerTask *timerTask); /*************************************************************************************** - ** Display/window management functionality - ***************************************************************************************/ + * Display/window management functionality + ***************************************************************************************/ /** * Inherited from GHOST_ISystem but left pure virtual @@ -169,8 +169,8 @@ public: /*************************************************************************************** - ** Event management functionality - ***************************************************************************************/ + * Event management functionality + ***************************************************************************************/ /** * Inherited from GHOST_ISystem but left pure virtual @@ -202,8 +202,8 @@ public: virtual GHOST_TSuccess removeEventConsumer(GHOST_IEventConsumer *consumer); /*************************************************************************************** - ** Cursor management functionality - ***************************************************************************************/ + * Cursor management functionality + ***************************************************************************************/ /** Inherited from GHOST_ISystem but left pure virtual * GHOST_TSuccess getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const = 0; @@ -211,8 +211,8 @@ public: */ /*************************************************************************************** - ** Access to mouse button and keyboard states. - ***************************************************************************************/ + * Access to mouse button and keyboard states. + ***************************************************************************************/ /** * Returns the state of a modifier key (ouside the message queue). @@ -231,8 +231,8 @@ public: virtual GHOST_TSuccess getButtonState(GHOST_TButtonMask mask, bool& isDown) const; /*************************************************************************************** - ** Other (internal) functionality. - ***************************************************************************************/ + * Other (internal) functionality. + ***************************************************************************************/ /** * Pushes an event on the stack. diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp index 1e53e7f4291..ffb8388543b 100644 --- a/intern/ghost/intern/GHOST_SystemCarbon.cpp +++ b/intern/ghost/intern/GHOST_SystemCarbon.cpp @@ -31,7 +31,6 @@ /** - * Copyright (C) 2001 NaN Technologies B.V. * @author Maarten Gribnau * @date May 7, 2001 @@ -70,10 +69,10 @@ enum { const EventTypeSpec kEvents[] = { { kEventClassAppleEvent, kEventAppleEvent }, -/* - { kEventClassApplication, kEventAppActivated }, - { kEventClassApplication, kEventAppDeactivated }, - */ +#if 0 + { kEventClassApplication, kEventAppActivated }, + { kEventClassApplication, kEventAppDeactivated }, + #endif { kEventClassKeyboard, kEventRawKeyDown }, { kEventClassKeyboard, kEventRawKeyRepeat }, { kEventClassKeyboard, kEventRawKeyUp }, @@ -994,7 +993,7 @@ bool GHOST_SystemCarbon::handleMouseDown(EventRef event) * @see GHOST_SystemCarbon::handleWindowEvent(EventRef event) */ /* even worse: scale window also generates a load of events, and nothing - is handled (read: client's event proc called) until you release mouse (ton) */ + * is handled (read: client's event proc called) until you release mouse (ton) */ GHOST_ASSERT(validWindow(ghostWindow), "GHOST_SystemCarbon::handleMouseDown: invalid window"); m_ignoreWindowSizedMessages = true; diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h index 47a7a6a9a73..cb4e9fe3c99 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.h +++ b/intern/ghost/intern/GHOST_SystemCocoa.h @@ -62,8 +62,8 @@ public: ~GHOST_SystemCocoa(); /*************************************************************************************** - ** Time(r) functionality - ***************************************************************************************/ + * Time(r) functionality + ***************************************************************************************/ /** * Returns the system time. @@ -74,8 +74,8 @@ public: virtual GHOST_TUns64 getMilliSeconds() const; /*************************************************************************************** - ** Display/window management functionality - ***************************************************************************************/ + * Display/window management functionality + ***************************************************************************************/ /** * Returns the number of displays on this system. @@ -119,8 +119,8 @@ public: ); /*************************************************************************************** - ** Event management functionality - ***************************************************************************************/ + * Event management functionality + ***************************************************************************************/ /** * Gets events from the system and stores them in the queue. @@ -154,8 +154,8 @@ public: GHOST_WindowCocoa *window, int mouseX, int mouseY, void *data); /*************************************************************************************** - ** Cursor management functionality - ***************************************************************************************/ + * Cursor management functionality + ***************************************************************************************/ /** * Returns the current location of the cursor (location in screen coordinates) @@ -174,8 +174,8 @@ public: virtual GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y); /*************************************************************************************** - ** Access to mouse button and keyboard states. - ***************************************************************************************/ + * Access to mouse button and keyboard states. + ***************************************************************************************/ /** * Returns the state of all modifier keys. diff --git a/intern/ghost/intern/GHOST_SystemPaths.h b/intern/ghost/intern/GHOST_SystemPaths.h index 75acbf885e3..fe0fae71955 100644 --- a/intern/ghost/intern/GHOST_SystemPaths.h +++ b/intern/ghost/intern/GHOST_SystemPaths.h @@ -57,11 +57,11 @@ public: */ virtual const GHOST_TUns8 *getSystemDir(int version, const char *versionstr) const = 0; - /** - * Determine the base dir in which user configuration is stored, including versioning. - * If needed, it will create the base directory. - * @return Unsigned char string pointing to user dir (eg ~/.blender/). - */ + /** + * Determine the base dir in which user configuration is stored, including versioning. + * If needed, it will create the base directory. + * @return Unsigned char string pointing to user dir (eg ~/.blender/). + */ virtual const GHOST_TUns8 *getUserDir(int version, const char *versionstr) const = 0; /** @@ -74,7 +74,6 @@ public: * Add the file to the operating system most recently used files */ virtual void addToSystemRecentFiles(const char *filename) const = 0; - }; #endif diff --git a/intern/ghost/intern/GHOST_SystemPathsX11.cpp b/intern/ghost/intern/GHOST_SystemPathsX11.cpp index 95f82fe0e60..83f7e87977c 100644 --- a/intern/ghost/intern/GHOST_SystemPathsX11.cpp +++ b/intern/ghost/intern/GHOST_SystemPathsX11.cpp @@ -61,10 +61,10 @@ GHOST_SystemPathsX11::~GHOST_SystemPathsX11() const GHOST_TUns8 *GHOST_SystemPathsX11::getSystemDir(int, const char *versionstr) const { /* no prefix assumes a portable build which only uses bundled scripts */ - if(static_path) { + if (static_path) { static char system_path[PATH_MAX]; snprintf(system_path, sizeof(system_path), "%s/blender/%s", static_path, versionstr); - return (GHOST_TUns8*)system_path; + return (GHOST_TUns8 *)system_path; } return NULL; @@ -76,27 +76,27 @@ const GHOST_TUns8 *GHOST_SystemPathsX11::getUserDir(int version, const char *ver /* in blender 2.64, we migrate to XDG. to ensure the copy previous settings * operator works we give a different path depending on the requested version */ - if(version < 264) { + if (version < 264) { const char *home = getenv("HOME"); - if(home) { + if (home) { snprintf(user_path, sizeof(user_path), "%s/.blender/%s", home, versionstr); - return (GHOST_TUns8*)user_path; + return (GHOST_TUns8 *)user_path; } return NULL; } else { - const char *home= getenv("XDG_CONFIG_HOME"); + const char *home = getenv("XDG_CONFIG_HOME"); if (home) { snprintf(user_path, sizeof(user_path), "%s/blender/%s", home, versionstr); } else { - home= getenv("HOME"); + home = getenv("HOME"); if (home == NULL) - home= getpwuid(getuid())->pw_dir; + home = getpwuid(getuid())->pw_dir; snprintf(user_path, sizeof(user_path), "%s/.config/blender/%s", home, versionstr); } diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index c2456fed800..6c201c24c3d 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -1093,7 +1093,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, system->storeModifierKeys(modifiers); event = processWindowEvent(LOWORD(wParam) ? GHOST_kEventWindowActivate : GHOST_kEventWindowDeactivate, window); /* WARNING: Let DefWindowProc handle WM_ACTIVATE, otherwise WM_MOUSEWHEEL - will not be dispatched to OUR active window if we minimize one of OUR windows. */ + * will not be dispatched to OUR active window if we minimize one of OUR windows. */ lResult = ::DefWindowProc(hwnd, msg, wParam, lParam); break; } @@ -1230,11 +1230,11 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, // Event found for a window before the pointer to the class has been set. GHOST_PRINT("GHOST_SystemWin32::wndProc: GHOST window event before creation\n"); /* These are events we typically miss at this point: - WM_GETMINMAXINFO 0x24 - WM_NCCREATE 0x81 - WM_NCCALCSIZE 0x83 - WM_CREATE 0x01 - We let DefWindowProc do the work. + * WM_GETMINMAXINFO 0x24 + * WM_NCCREATE 0x81 + * WM_NCCALCSIZE 0x83 + * WM_CREATE 0x01 + * We let DefWindowProc do the work. */ } } @@ -1274,7 +1274,7 @@ GHOST_TUns8 *GHOST_SystemWin32::getClipboard(bool selection) const temp_buff = alloc_utf_8_from_16(buffer, 0); /* Buffer mustn't be accessed after CloseClipboard - it would like accessing free-d memory */ + * it would like accessing free-d memory */ GlobalUnlock(hData); CloseClipboard(); @@ -1300,7 +1300,7 @@ GHOST_TUns8 *GHOST_SystemWin32::getClipboard(bool selection) const temp_buff[len] = '\0'; /* Buffer mustn't be accessed after CloseClipboard - it would like accessing free-d memory */ + * it would like accessing free-d memory */ GlobalUnlock(hData); CloseClipboard(); diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index c58ed93425d..2d8f5e7890c 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -566,7 +566,7 @@ GHOST_SystemX11::processEvent(XEvent *xe) } else if (status == XLookupKeySym) { /* this key doesn't have a text representation, it is a command - key of some sort */; + * key of some sort */; } else { printf("Bad keycode lookup. Keysym 0x%x Status: %s\n", @@ -745,11 +745,11 @@ GHOST_SystemX11::processEvent(XEvent *xe) case LeaveNotify: { /* XCrossingEvents pointer leave enter window. - also do cursor move here, MotionNotify only - happens when motion starts & ends inside window. - we only do moves when the crossing mode is 'normal' - (really crossing between windows) since some windowmanagers - also send grab/ungrab crossings for mousewheel events. + * also do cursor move here, MotionNotify only + * happens when motion starts & ends inside window. + * we only do moves when the crossing mode is 'normal' + * (really crossing between windows) since some windowmanagers + * also send grab/ungrab crossings for mousewheel events. */ XCrossingEvent &xce = xe->xcrossing; if (xce.mode == NotifyNormal) { @@ -1077,15 +1077,15 @@ convertXKey(KeySym key) 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 + * 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 */ } diff --git a/intern/ghost/intern/GHOST_TimerManager.cpp b/intern/ghost/intern/GHOST_TimerManager.cpp index 4780a4a0d44..4ad28d6633d 100644 --- a/intern/ghost/intern/GHOST_TimerManager.cpp +++ b/intern/ghost/intern/GHOST_TimerManager.cpp @@ -31,7 +31,6 @@ /** - * Copyright (C) 2001 NaN Technologies B.V. * @author Maarten Gribnau * @date May 31, 2001 diff --git a/intern/ghost/intern/GHOST_TimerManager.h b/intern/ghost/intern/GHOST_TimerManager.h index 0b189cf3aa9..88d27088c1d 100644 --- a/intern/ghost/intern/GHOST_TimerManager.h +++ b/intern/ghost/intern/GHOST_TimerManager.h @@ -119,6 +119,11 @@ protected: typedef std::vector<GHOST_TimerTask *> TTimerVector; /** The list with event consumers. */ TTimerVector m_timers; + + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_TimerManager") +#endif }; #endif // __GHOST_TIMERMANAGER_H__ diff --git a/intern/ghost/intern/GHOST_WindowCarbon.cpp b/intern/ghost/intern/GHOST_WindowCarbon.cpp index d67b02fce6b..ca3366004d3 100644 --- a/intern/ghost/intern/GHOST_WindowCarbon.cpp +++ b/intern/ghost/intern/GHOST_WindowCarbon.cpp @@ -31,7 +31,6 @@ /** - * Copyright (C) 2001 NaN Technologies B.V. * @author Maarten Gribnau * @date May 10, 2001 diff --git a/intern/ghost/intern/GHOST_WindowManager.cpp b/intern/ghost/intern/GHOST_WindowManager.cpp index a6211b42fe6..2b7fb6686f2 100644 --- a/intern/ghost/intern/GHOST_WindowManager.cpp +++ b/intern/ghost/intern/GHOST_WindowManager.cpp @@ -31,7 +31,6 @@ /** - * Copyright (C) 2001 NaN Technologies B.V. * @author Maarten Gribnau * @date May 11, 2001 diff --git a/intern/ghost/intern/GHOST_WindowManager.h b/intern/ghost/intern/GHOST_WindowManager.h index 47931347ed6..e754595e881 100644 --- a/intern/ghost/intern/GHOST_WindowManager.h +++ b/intern/ghost/intern/GHOST_WindowManager.h @@ -162,9 +162,7 @@ protected: GHOST_IWindow *m_activeWindowBeforeFullScreen; #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GHOST:GHOST_WindowManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_WindowManager") #endif }; diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 81eefdfdc9c..e3fe28e2e64 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -31,7 +31,6 @@ /** - * Copyright (C) 2001 NaN Technologies B.V. * @author Maarten Gribnau * @date May 10, 2001 @@ -106,10 +105,10 @@ static PIXELFORMATDESCRIPTOR sPreferredFormat = { }; /* Intel videocards don't work fine with multiple contexts and - have to share the same context for all windows. - But if we just share context for all windows it could work incorrect - with multiple videocards configuration. Suppose, that Intel videocards - can't be in multiple-devices configuration. */ + * have to share the same context for all windows. + * But if we just share context for all windows it could work incorrect + * with multiple videocards configuration. Suppose, that Intel videocards + * can't be in multiple-devices configuration. */ static int is_crappy_intel_card(void) { int crappy = 0; @@ -1279,8 +1278,8 @@ GHOST_TSuccess GHOST_WindowWin32::endProgressBar() return GHOST_kFailure; } -/* Ron Fosner's code for weighting pixel formats and forcing software. - See http://www.opengl.org/resources/faq/technical/weight.cpp */ +/* Ron Fosner's code for weighting pixel formats and forcing software. + * See http://www.opengl.org/resources/faq/technical/weight.cpp */ static int WeightPixelFormat(PIXELFORMATDESCRIPTOR& pfd) { @@ -1335,7 +1334,7 @@ static int EnumPixelFormats(HDC hdc) sizeof(PIXELFORMATDESCRIPTOR), &pfd); /* choose a pixel format using the useless Windows function in case - we come up empty handed */ + * we come up empty handed */ iPixelFormat = ::ChoosePixelFormat(hdc, &sPreferredFormat); if (!iPixelFormat) return 0; /* couldn't find one to use */ diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp index 1f4111c8cf3..cdb274b0e61 100644 --- a/intern/ghost/intern/GHOST_WindowX11.cpp +++ b/intern/ghost/intern/GHOST_WindowX11.cpp @@ -228,7 +228,7 @@ GHOST_WindowX11( m_visual = glXChooseVisual(m_display, DefaultScreen(m_display), attributes); /* Any sample level or even zero, which means oversampling disabled, is good - but we need a valid visual to continue */ + * but we need a valid visual to continue */ if (m_visual == NULL) { if (samples == 0) { /* All options exhausted, cannot continue */ @@ -1155,8 +1155,8 @@ setOrder( Atom atom; /* We use both XRaiseWindow and _NET_ACTIVE_WINDOW, since some - window managers ignore the former (e.g. kwin from kde) and others - don't implement the latter (e.g. fluxbox pre 0.9.9) */ + * window managers ignore the former (e.g. kwin from kde) and others + * don't implement the latter (e.g. fluxbox pre 0.9.9) */ XRaiseWindow(m_display, m_window); diff --git a/intern/ghost/test/gears/GHOST_C-Test.c b/intern/ghost/test/gears/GHOST_C-Test.c index c32d78f0358..98e2b9c2497 100644 --- a/intern/ghost/test/gears/GHOST_C-Test.c +++ b/intern/ghost/test/gears/GHOST_C-Test.c @@ -26,7 +26,6 @@ */ /** - * Copyright (C) 2001 NaN Technologies B.V. * * Simple test file for the GHOST library. @@ -294,14 +293,14 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData) switch (GHOST_GetEventType(hEvent)) { - /* - case GHOST_kEventUnknown: - break; - case GHOST_kEventCursorButton: - break; - case GHOST_kEventCursorMove: - break; - */ +#if 0 + case GHOST_kEventUnknown: + break; + case GHOST_kEventCursorButton: + break; + case GHOST_kEventCursorMove: + break; +#endif case GHOST_kEventWheel: { wheelData = (GHOST_TEventWheelData *)GHOST_GetEventData(hEvent); @@ -345,10 +344,10 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData) setting.yPixels = 480; /* - setting.bpp = 16; - setting.frequency = 75; - setting.xPixels = 640; - setting.yPixels = 480; + * setting.bpp = 16; + * setting.frequency = 75; + * setting.xPixels = 640; + * setting.yPixels = 480; */ sFullScreenWindow = GHOST_BeginFullScreen(shSystem, &setting, diff --git a/intern/ghost/test/gears/GHOST_Test.cpp b/intern/ghost/test/gears/GHOST_Test.cpp index d338f11ddde..c02272094f4 100644 --- a/intern/ghost/test/gears/GHOST_Test.cpp +++ b/intern/ghost/test/gears/GHOST_Test.cpp @@ -1,4 +1,4 @@ -/** +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -26,7 +26,6 @@ */ /** - * Copyright (C) 2001 NaN Technologies B.V. * Simple test file for the GHOST library. * The OpenGL gear code is taken from the Qt sample code which, @@ -344,27 +343,27 @@ void StereoProjection(float left, float right, float bottom, float top, float ne float zero_plane, float dist, float eye) /* Perform the perspective projection for one eye's subfield. - The projection is in the direction of the negative z axis. - - -6.0, 6.0, -4.8, 4.8, - left, right, bottom, top = the coordinate range, in the plane of zero - parallax setting, which will be displayed on the screen. The - ratio between (right-left) and (top-bottom) should equal the aspect - ratio of the display. - - 6.0, -6.0, - near, far = the z-coordinate values of the clipping planes. - - 0.0, - zero_plane = the z-coordinate of the plane of zero parallax setting. - - 14.5, - dist = the distance from the center of projection to the plane - of zero parallax. - - -0.31 - eye = half the eye separation; positive for the right eye subfield, - negative for the left eye subfield. + * The projection is in the direction of the negative z axis. + * + * -6.0, 6.0, -4.8, 4.8, + * left, right, bottom, top = the coordinate range, in the plane of zero + * parallax setting, which will be displayed on the screen. The + * ratio between (right-left) and (top-bottom) should equal the aspect + * ratio of the display. + * + * 6.0, -6.0, + * near, far = the z-coordinate values of the clipping planes. + * + * 0.0, + * zero_plane = the z-coordinate of the plane of zero parallax setting. + * + * 14.5, + * dist = the distance from the center of projection to the plane + * of zero parallax. + * + * -0.31 + * eye = half the eye separation; positive for the right eye subfield, + * negative for the left eye subfield. */ { float xmid, ymid, clip_near, clip_far, topw, bottomw, leftw, rightw, @@ -462,13 +461,14 @@ bool Application::processEvent(GHOST_IEvent *event) bool handled = true; switch (event->getType()) { -/* case GHOST_kEventUnknown: - break; - case GHOST_kEventCursorButton: - std::cout << "GHOST_kEventCursorButton"; break; - case GHOST_kEventCursorMove: - std::cout << "GHOST_kEventCursorMove"; break; - */ +#if 0 + case GHOST_kEventUnknown: + break; + case GHOST_kEventCursorButton: + std::cout << "GHOST_kEventCursorButton"; break; + case GHOST_kEventCursorMove: + std::cout << "GHOST_kEventCursorMove"; break; + #endif case GHOST_kEventWheel: { GHOST_TEventWheelData *wheelData = (GHOST_TEventWheelData *) event->getData(); diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h index 83d6549218a..4bb8cba6810 100644 --- a/intern/guardedalloc/MEM_guardedalloc.h +++ b/intern/guardedalloc/MEM_guardedalloc.h @@ -97,10 +97,10 @@ extern "C" { void *MEM_dupallocN(void *vmemh) WARN_UNUSED; /** - * Reallocates a block of memory, and returns pointer to the newly - * allocated block, the old one is freed. this is not as optimized - * as a system realloc but just makes a new allocation and copies - * over from existing memory. */ + * Reallocates a block of memory, and returns pointer to the newly + * allocated block, the old one is freed. this is not as optimized + * as a system realloc but just makes a new allocation and copies + * over from existing memory. */ void *MEM_reallocN(void *vmemh, size_t len) WARN_UNUSED; /** @@ -110,13 +110,13 @@ extern "C" { void *MEM_callocN(size_t len, const char * str) WARN_UNUSED; /** Allocate a block of memory of size len, with tag name str. The - * name must be a static, because only a pointer to it is stored ! - * */ + * name must be a static, because only a pointer to it is stored ! + * */ void *MEM_mallocN(size_t len, const char * str) WARN_UNUSED; /** Same as callocN, clears memory and uses mmap (disk cached) if supported. - Can be free'd with MEM_freeN as usual. - * */ + * Can be free'd with MEM_freeN as usual. + * */ void *MEM_mapallocN(size_t len, const char * str) WARN_UNUSED; /** Print a list of the names and sizes of all allocated memory @@ -143,7 +143,7 @@ extern "C" { int MEM_check_memory_integrity(void); /** Set thread locking functions for safe memory allocation from multiple - threads, pass NULL pointers to disable thread locking again. */ + * threads, pass NULL pointers to disable thread locking again. */ void MEM_set_lock_callback(void (*lock)(void), void (*unlock)(void)); /** Attempt to enforce OSX (or other OS's) to have malloc and stack nonzero */ @@ -167,10 +167,31 @@ extern "C" { #ifndef NDEBUG const char *MEM_name_ptr(void *vmemh); #endif - + #ifdef __cplusplus -} +/* alloc funcs for C++ only */ +#define MEM_CXX_CLASS_ALLOC_FUNCS(_id) \ +public: \ + void *operator new(size_t num_bytes) { \ + return MEM_mallocN(num_bytes, _id); \ + } \ + void operator delete(void *mem) { \ + if (mem) \ + MEM_freeN(mem); \ + } \ + void *operator new[](size_t num_bytes) { \ + return MEM_mallocN(num_bytes, _id "[]"); \ + } \ + void operator delete[](void *mem) { \ + if (mem) \ + MEM_freeN(mem); \ + } \ + #endif + +#ifdef __cplusplus +} #endif +#endif diff --git a/intern/guardedalloc/cpp/mallocn.cpp b/intern/guardedalloc/cpp/mallocn.cpp index 130fcb6960b..da77f0e1c83 100644 --- a/intern/guardedalloc/cpp/mallocn.cpp +++ b/intern/guardedalloc/cpp/mallocn.cpp @@ -28,20 +28,36 @@ #include <new> #include "../MEM_guardedalloc.h" -void* operator new (size_t size) +/* not default but can be used when needing to set a string */ +void *operator new(size_t size, const char *str) throw(std::bad_alloc) { - return MEM_mallocN(size, "C++/anonymous"); + return MEM_mallocN(size, str); } - -/* not default but can be used when needing to set a string */ -void* operator new (size_t size, const char *str) +void *operator new[](size_t size, const char *str) throw(std::bad_alloc) { return MEM_mallocN(size, str); } -void operator delete (void *p) + +void *operator new(size_t size) throw(std::bad_alloc) +{ + return MEM_mallocN(size, "C++/anonymous"); +} +void *operator new[](size_t size) throw(std::bad_alloc) +{ + return MEM_mallocN(size, "C++/anonymous[]"); +} + + +void operator delete(void *p) throw() +{ + /* delete NULL is valid in c++ */ + if (p) + MEM_freeN(p); +} +void operator delete[](void *p) throw() { /* delete NULL is valid in c++ */ - if(p) + if (p) MEM_freeN(p); } diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c index f1a83583715..c00e9466674 100644 --- a/intern/guardedalloc/intern/mallocn.c +++ b/intern/guardedalloc/intern/mallocn.c @@ -57,7 +57,7 @@ * lets you count the allocations so as to find the allocator of unfreed memory * in situations where the leak is predictable */ -// #define DEBUG_MEMCOUNTER +//#define DEBUG_MEMCOUNTER #ifdef DEBUG_MEMCOUNTER /* set this to the value that isn't being freed */ diff --git a/intern/raskter/raskter.c b/intern/raskter/raskter.c index 910cd4c6a3d..26d879091c1 100644 --- a/intern/raskter/raskter.c +++ b/intern/raskter/raskter.c @@ -31,6 +31,8 @@ #include <stdlib.h> #include "raskter.h" +#define __PLX__FAKE_AA__ + /* from BLI_utildefines.h */ #define MIN2(x, y) ( (x) < (y) ? (x) : (y) ) #define MAX2(x, y) ( (x) > (y) ? (x) : (y) ) @@ -67,7 +69,8 @@ struct r_fill_context { * just the poly. Since the DEM code could end up being coupled with this, we'll keep it separate * for now. */ -static void preprocess_all_edges(struct r_fill_context *ctx, struct poly_vert *verts, int num_verts, struct e_status *open_edge) { +static void preprocess_all_edges(struct r_fill_context *ctx, struct poly_vert *verts, int num_verts, struct e_status *open_edge) +{ int i; int xbeg; int ybeg; @@ -165,7 +168,8 @@ static void preprocess_all_edges(struct r_fill_context *ctx, struct poly_vert *v * for speed, but waiting on final design choices for curve-data before eliminating data the DEM code will need * if it ends up being coupled with this function. */ -static int rast_scan_fill(struct r_fill_context *ctx, struct poly_vert *verts, int num_verts, float intensity) { +static int rast_scan_fill(struct r_fill_context *ctx, struct poly_vert *verts, int num_verts, float intensity) +{ int x_curr; /* current pixel position in X */ int y_curr; /* current scan line being drawn */ int yp; /* y-pixel's position in frame buffer */ @@ -757,18 +761,23 @@ int PLX_raskterize_feather(float (*base_verts)[2], int num_base_verts, float (*f return i; /* Return the value returned by the rasterizer. */ } -int get_range_expanded_pixel_coord(float normalized_value, int max_value) { +#ifndef __PLX__FAKE_AA__ + +static int get_range_expanded_pixel_coord(float normalized_value, int max_value) +{ return (int)((normalized_value * (float)(max_value)) + 0.5f); } -float get_pixel_intensity(float *buf, int buf_x, int buf_y, int pos_x, int pos_y) { +static float get_pixel_intensity(float *buf, int buf_x, int buf_y, int pos_x, int pos_y) +{ if(pos_x < 0 || pos_x >= buf_x || pos_y < 0 || pos_y >= buf_y) { return 0.0f; } return buf[(pos_y * buf_y) + buf_x]; } -float get_pixel_intensity_bilinear(float *buf, int buf_x, int buf_y, float u, float v) { +static float get_pixel_intensity_bilinear(float *buf, int buf_x, int buf_y, float u, float v) +{ int a; int b; int a_plus_1; @@ -794,14 +803,17 @@ float get_pixel_intensity_bilinear(float *buf, int buf_x, int buf_y, float u, fl } -void set_pixel_intensity(float *buf, int buf_x, int buf_y, int pos_x, int pos_y, float intensity) { +static void set_pixel_intensity(float *buf, int buf_x, int buf_y, int pos_x, int pos_y, float intensity) +{ if(pos_x < 0 || pos_x >= buf_x || pos_y < 0 || pos_y >= buf_y) { return; } buf[(pos_y * buf_y) + buf_x] = intensity; } -#define __PLX__FAKE_AA__ -int PLX_antialias_buffer(float *buf, int buf_x, int buf_y) { +#endif + +int PLX_antialias_buffer(float *buf, int buf_x, int buf_y) +{ #ifdef __PLX__FAKE_AA__ #ifdef __PLX_GREY_AA__ int i=0; diff --git a/intern/smoke/intern/FLUID_3D.cpp b/intern/smoke/intern/FLUID_3D.cpp index f638a936049..e006132ea8f 100644 --- a/intern/smoke/intern/FLUID_3D.cpp +++ b/intern/smoke/intern/FLUID_3D.cpp @@ -1298,7 +1298,7 @@ void FLUID_3D::addVorticity(int zBegin, int zEnd) N[2] = (_vorticity[out] - _vorticity[in]) * dz; float magnitude = sqrtf(N[0] * N[0] + N[1] * N[1] + N[2] * N[2]); - if (magnitude > 0.0f) + if (magnitude > FLT_EPSILON) { magnitude = 1.0f / magnitude; N[0] *= magnitude; @@ -1306,7 +1306,7 @@ void FLUID_3D::addVorticity(int zBegin, int zEnd) N[2] *= magnitude; _xForce[index] += (N[1] * _zVorticity[vIndex] - N[2] * _yVorticity[vIndex]) * _dx * eps; - _yForce[index] -= (N[0] * _zVorticity[vIndex] - N[2] * _xVorticity[vIndex]) * _dx * eps; + _yForce[index] += (N[2] * _xVorticity[vIndex] - N[0] * _zVorticity[vIndex]) * _dx * eps; _zForce[index] += (N[0] * _yVorticity[vIndex] - N[1] * _xVorticity[vIndex]) * _dx * eps; } } // if diff --git a/intern/smoke/intern/MERSENNETWISTER.h b/intern/smoke/intern/MERSENNETWISTER.h index 116568c2834..5a9ccf88ae7 100644 --- a/intern/smoke/intern/MERSENNETWISTER.h +++ b/intern/smoke/intern/MERSENNETWISTER.h @@ -234,7 +234,7 @@ inline void MTRand::seed( uint32 *const bigSeed, const uint32 seedLength ) initialize(19650218UL); register int i = 1; register uint32 j = 0; - register int k = ( N > seedLength ? N : seedLength ); + register int k = ( (uint32)N > seedLength ? (uint32)N : seedLength ); for( ; k; --k ) { state[i] = diff --git a/intern/smoke/intern/smoke_API.cpp b/intern/smoke/intern/smoke_API.cpp index ce298cff0d2..b45fef26504 100644 --- a/intern/smoke/intern/smoke_API.cpp +++ b/intern/smoke/intern/smoke_API.cpp @@ -198,8 +198,8 @@ extern "C" void smoke_export(FLUID_3D *fluid, float *dt, float *dx, float **dens *vyold = fluid->_yVelocityOld; *vzold = fluid->_zVelocityOld; *obstacles = fluid->_obstacles; - dt = &(fluid->_dt); - dx = &(fluid->_dx); + *dt = fluid->_dt; + *dx = fluid->_dx; } diff --git a/intern/string/STR_String.h b/intern/string/STR_String.h index 2f17b059c8f..1705d7855e0 100644 --- a/intern/string/STR_String.h +++ b/intern/string/STR_String.h @@ -115,23 +115,23 @@ public: void Replace(int pos, int num, rcSTR_String str); // Substrings - inline STR_String Left(int num) const { num = (num < Len ? num:Len ); return STR_String(pData, num); } - inline STR_String Right(int num) const { num = (num < Len ? num:Len ); return STR_String(pData+Len-num, num); } - inline STR_String Mid(int pos, int num = INT_MAX) const { pos = (pos < Len ? pos:Len ); num = (num < (Len - pos) ? num : (Len - pos)); return STR_String(pData+pos, num); } + inline STR_String Left(int num) const { num = (num < Len ? num:Len ); return STR_String(pData, num); } + inline STR_String Right(int num) const { num = (num < Len ? num:Len ); return STR_String(pData+Len-num, num); } + inline STR_String Mid(int pos, int num = INT_MAX) const { pos = (pos < Len ? pos:Len ); num = (num < (Len - pos) ? num : (Len - pos)); return STR_String(pData+pos, num); } // Comparison - int Compare(rcSTR_String rhs) const; - int CompareNoCase(rcSTR_String rhs) const; - inline bool IsEqual(rcSTR_String rhs) const { return (Compare(rhs)==0); } - inline bool IsEqualNoCase(rcSTR_String rhs) const { return (CompareNoCase(rhs)==0); } + int Compare(rcSTR_String rhs) const; + int CompareNoCase(rcSTR_String rhs) const; + inline bool IsEqual(rcSTR_String rhs) const { return (Compare(rhs)==0); } + inline bool IsEqualNoCase(rcSTR_String rhs) const { return (CompareNoCase(rhs)==0); } // Search/replace - int Find(char c, int pos = 0) const; - int Find(const char *str, int pos = 0) const; - int Find(rcSTR_String str, int pos = 0) const; - int RFind(char c) const; - int FindOneOf(const char *set, int pos = 0) const; - int RFindOneOf(const char *set, int pos = 0) const; + int Find(char c, int pos = 0) const; + int Find(const char *str, int pos = 0) const; + int Find(rcSTR_String str, int pos = 0) const; + int RFind(char c) const; + int FindOneOf(const char *set, int pos = 0) const; + int RFindOneOf(const char *set, int pos = 0) const; std::vector<STR_String> Explode(char c) const; @@ -148,42 +148,42 @@ public: STR_String& TrimQuotes(); // Conversions -// inline operator char*() { return pData; } - inline operator const char *() const { return pData; } - inline char *Ptr() { return pData; } - inline const char *ReadPtr() const { return pData; } - inline float ToFloat() const { float x=(float)(atof(pData)); return x; } - inline int ToInt() const { return atoi(pData); } +// inline operator char*() { return pData; } + inline operator const char *() const { return pData; } + inline char *Ptr() { return pData; } + inline const char *ReadPtr() const { return pData; } + inline float ToFloat() const { float x=(float)(atof(pData)); return x; } + inline int ToInt() const { return atoi(pData); } // Operators - inline rcSTR_String operator=(const byte *rhs) { return Copy((const char *)rhs, strlen((const char *)rhs)); } - inline rcSTR_String operator=(rcSTR_String rhs) { return Copy(rhs.ReadPtr(), rhs.Length()); } - inline rcSTR_String operator=(char rhs) { return Copy(&rhs, 1); } - inline rcSTR_String operator=(const char *rhs) { return Copy(rhs, strlen(rhs)); } - - inline rcSTR_String operator+=(const char *rhs) { return Concat(rhs, strlen(rhs)); } - inline rcSTR_String operator+=(rcSTR_String rhs) { return Concat(rhs.ReadPtr(), rhs.Length()); } - inline rcSTR_String operator+=(char rhs) { return Concat(&rhs, 1); } - - - inline friend bool operator<(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<0); } - inline friend bool operator<(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)<0); }; - inline friend bool operator<(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<0); } - inline friend bool operator>(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>0); } - inline friend bool operator>(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)>0); } - inline friend bool operator>(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>0); } - inline friend bool operator<=(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<=0); } - inline friend bool operator<=(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)<=0); } - inline friend bool operator<=(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<=0); } - inline friend bool operator>=(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>=0); } - inline friend bool operator>=(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)>=0); } - inline friend bool operator>=(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>=0); } - inline friend bool operator==(rcSTR_String lhs, rcSTR_String rhs) { return ((lhs.Length() == rhs.Length()) && (memcmp(lhs, rhs, lhs.Length())==0)); } - inline friend bool operator==(rcSTR_String lhs, const char *rhs) { return (memcmp(lhs, rhs, lhs.Length()+1)==0); } - inline friend bool operator==(const char *lhs, rcSTR_String rhs) { return (memcmp(lhs, rhs, rhs.Length()+1)==0); } - inline friend bool operator!=(rcSTR_String lhs, rcSTR_String rhs) { return ((lhs.Length() != rhs.Length()) || (memcmp(lhs, rhs, lhs.Length())!=0)); } - inline friend bool operator!=(rcSTR_String lhs, const char *rhs) { return (memcmp(lhs, rhs, lhs.Length()+1)!=0); } - inline friend bool operator!=(const char *lhs, rcSTR_String rhs) { return (memcmp(lhs, rhs, rhs.Length()+1)!=0); } + inline rcSTR_String operator=(const byte *rhs) { return Copy((const char *)rhs, strlen((const char *)rhs)); } + inline rcSTR_String operator=(rcSTR_String rhs) { return Copy(rhs.ReadPtr(), rhs.Length()); } + inline rcSTR_String operator=(char rhs) { return Copy(&rhs, 1); } + inline rcSTR_String operator=(const char *rhs) { return Copy(rhs, strlen(rhs)); } + + inline rcSTR_String operator+=(const char *rhs) { return Concat(rhs, strlen(rhs)); } + inline rcSTR_String operator+=(rcSTR_String rhs) { return Concat(rhs.ReadPtr(), rhs.Length()); } + inline rcSTR_String operator+=(char rhs) { return Concat(&rhs, 1); } + + + inline friend bool operator<(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<0); } + inline friend bool operator<(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)<0); } + inline friend bool operator<(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<0); } + inline friend bool operator>(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>0); } + inline friend bool operator>(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)>0); } + inline friend bool operator>(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>0); } + inline friend bool operator<=(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<=0); } + inline friend bool operator<=(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)<=0); } + inline friend bool operator<=(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<=0); } + inline friend bool operator>=(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>=0); } + inline friend bool operator>=(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)>=0); } + inline friend bool operator>=(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>=0); } + inline friend bool operator==(rcSTR_String lhs, rcSTR_String rhs) { return ((lhs.Length() == rhs.Length()) && (memcmp(lhs, rhs, lhs.Length())==0)); } + inline friend bool operator==(rcSTR_String lhs, const char *rhs) { return (memcmp(lhs, rhs, lhs.Length()+1)==0); } + inline friend bool operator==(const char *lhs, rcSTR_String rhs) { return (memcmp(lhs, rhs, rhs.Length()+1)==0); } + inline friend bool operator!=(rcSTR_String lhs, rcSTR_String rhs) { return ((lhs.Length() != rhs.Length()) || (memcmp(lhs, rhs, lhs.Length())!=0)); } + inline friend bool operator!=(rcSTR_String lhs, const char *rhs) { return (memcmp(lhs, rhs, lhs.Length()+1)!=0); } + inline friend bool operator!=(const char *lhs, rcSTR_String rhs) { return (memcmp(lhs, rhs, rhs.Length()+1)!=0); } // serializing //int Serialize(pCStream stream); @@ -198,23 +198,21 @@ protected: static bool isUpper(char c) { return (c>='A') && (c <= 'Z'); } static bool isSpace(char c) { return (c==' ') || (c=='\t'); } - char *pData; // -> STR_String data + char *pData; // -> STR_String data int Len; // Data length int Max; // Space in data buffer #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "CXX:STR_String"); } - void operator delete(void *mem) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("CXX:STR_String") #endif }; inline STR_String operator+(rcSTR_String lhs, rcSTR_String rhs) { return STR_String(lhs.ReadPtr(), lhs.Length(), rhs.ReadPtr(), rhs.Length()); } -inline STR_String operator+(rcSTR_String lhs, char rhs) { return STR_String(lhs.ReadPtr(), lhs.Length(), &rhs, 1); } -inline STR_String operator+(char lhs, rcSTR_String rhs) { return STR_String(&lhs, 1, rhs.ReadPtr(), rhs.Length()); } -inline STR_String operator+(rcSTR_String lhs, const char *rhs) { return STR_String(lhs.ReadPtr(), lhs.Length(), rhs, strlen(rhs)); } -inline STR_String operator+(const char *lhs, rcSTR_String rhs) { return STR_String(lhs, strlen(lhs), rhs.ReadPtr(), rhs.Length()); } +inline STR_String operator+(rcSTR_String lhs, char rhs) { return STR_String(lhs.ReadPtr(), lhs.Length(), &rhs, 1); } +inline STR_String operator+(char lhs, rcSTR_String rhs) { return STR_String(&lhs, 1, rhs.ReadPtr(), rhs.Length()); } +inline STR_String operator+(rcSTR_String lhs, const char *rhs) { return STR_String(lhs.ReadPtr(), lhs.Length(), rhs, strlen(rhs)); } +inline STR_String operator+(const char *lhs, rcSTR_String rhs) { return STR_String(lhs, strlen(lhs), rhs.ReadPtr(), rhs.Length()); } #endif //__STR_STRING_H__ diff --git a/intern/string/intern/STR_String.cpp b/intern/string/intern/STR_String.cpp index 5ad41c696e3..bea6e88cfff 100644 --- a/intern/string/intern/STR_String.cpp +++ b/intern/string/intern/STR_String.cpp @@ -39,10 +39,10 @@ #include <stdio.h> #include <stdarg.h> -#include <stdlib.h> +#include <stdlib.h> #include <ctype.h> #include <string.h> -#if defined(__sun__) || defined( __sun ) || defined (__sparc) || defined (__sparc__) || defined (_AIX) +#if defined(__sun__) || defined(__sun) || defined(__sparc) || defined(__sparc__) || defined(_AIX) # include <strings.h> #endif #include "STR_String.h" @@ -57,7 +57,7 @@ // Construct an empty string // STR_String::STR_String() : - pData(new char [32]), + pData(new char[32]), Len(0), Max(32) { @@ -70,7 +70,7 @@ STR_String::STR_String() : // Construct a string of one character // STR_String::STR_String(char c) : - pData(new char [9]), + pData(new char[9]), Len(1), Max(9) { @@ -84,9 +84,9 @@ STR_String::STR_String(char c) : // Construct a string of multiple repeating characters // STR_String::STR_String(char c, int len) : - pData(new char [len+8]), + pData(new char[len + 8]), Len(len), - Max(len+8) + Max(len + 8) { assertd(pData != NULL); memset(pData, c, len); @@ -104,7 +104,7 @@ STR_String::STR_String(const char *str) if (str) { Len = ::strlen(str); Max = Len + 8; - pData = new char [Max]; + pData = new char[Max]; assertd(pData != NULL); ::memcpy(pData, str, Len); pData[Len] = 0; @@ -122,9 +122,9 @@ STR_String::STR_String(const char *str) // Construct a string from a pointer-to-ASCII-string and a length // STR_String::STR_String(const char *str, int len) : - pData(new char [len+8]), + pData(new char[len + 8]), Len(len), - Max(len+8) + Max(len + 8) { assertd(pData != NULL); memcpy(pData, str, len); @@ -137,9 +137,9 @@ STR_String::STR_String(const char *str, int len) : // Construct a string from another string // STR_String::STR_String(rcSTR_String str) : - pData(new char [str.Length()+8]), + pData(new char[str.Length() + 8]), Len(str.Length()), - Max(str.Length()+8) + Max(str.Length() + 8) { assertd(pData != NULL); assertd(str.pData != NULL); @@ -153,9 +153,9 @@ STR_String::STR_String(rcSTR_String str) : // Construct a string from the first number of characters in another string // STR_String::STR_String(rcSTR_String str, int len) : - pData(new char [len+8]), + pData(new char[len + 8]), Len(len), - Max(len+8) + Max(len + 8) { assertd(pData != NULL); assertd(str.pData != NULL); @@ -169,14 +169,14 @@ STR_String::STR_String(rcSTR_String str, int len) : // Create a string by concatenating two sources // STR_String::STR_String(const char *src1, int len1, const char *src2, int len2) : - pData(new char [len1+len2+8]), - Len(len1+len2), - Max(len1+len2+8) + pData(new char[len1 + len2 + 8]), + Len(len1 + len2), + Max(len1 + len2 + 8) { assertd(pData != NULL); memcpy(pData, src1, len1); - memcpy(pData+len1, src2, len2); - pData[len1+len2] = 0; + memcpy(pData + len1, src2, len2); + pData[len1 + len2] = 0; } @@ -185,13 +185,13 @@ STR_String::STR_String(const char *src1, int len1, const char *src2, int len2) : // Create a string with an integer value // STR_String::STR_String(int val) : - pData(new char [32]), + pData(new char[32]), Max(32) { assertd(pData != NULL); - Len=sprintf(pData, "%d", val); + Len = sprintf(pData, "%d", val); } - + @@ -199,11 +199,11 @@ STR_String::STR_String(int val) : // Create a string with a dword value // STR_String::STR_String(dword val) : - pData(new char [32]), + pData(new char[32]), Max(32) { assertd(pData != NULL); - Len=sprintf(pData, "%lu", val); + Len = sprintf(pData, "%lu", val); } @@ -212,11 +212,11 @@ STR_String::STR_String(dword val) : // Create a string with a floating point value // STR_String::STR_String(float val) : - pData(new char [32]), + pData(new char[32]), Max(32) { assertd(pData != NULL); - Len=sprintf(pData, "%g", val); + Len = sprintf(pData, "%g", val); } @@ -225,11 +225,11 @@ STR_String::STR_String(float val) : // Create a string with a double value // STR_String::STR_String(double val) : - pData(new char [32]), + pData(new char[32]), Max(32) { assertd(pData != NULL); - Len=sprintf(pData, "%g", val); + Len = sprintf(pData, "%g", val); } @@ -246,19 +246,19 @@ STR_String::STR_String(double val) : void STR_String::AllocBuffer(int len, bool keep_contents) { // Check if we have enough space - if (len+1 <= Max) return; + if (len + 1 <= Max) return; // Reallocate string - char *new_data = new char [len+8]; + char *new_data = new char[len + 8]; if (keep_contents) memcpy(new_data, pData, Len); delete[] pData; // Accept new data - Max = len+8; + Max = len + 8; pData = new_data; assertd(pData != NULL); } - + /*------------------------------------------------------------------------------------------------- @@ -298,7 +298,7 @@ STR_String& STR_String::FormatAdd(const char *fmt, ...) // Expand arguments and format to string va_list args; va_start(args, fmt); - Len += vsprintf(pData+Len, fmt, args); + Len += vsprintf(pData + Len, fmt, args); assertd(Len <= 2048); va_end(args); @@ -318,7 +318,7 @@ STR_String& STR_String::FormatAdd(const char *fmt, ...) // bool STR_String::IsUpper() const { - for (int i=0; i<Len; i++) + for (int i = 0; i < Len; i++) if (isLower(pData[i])) return false; @@ -332,7 +332,7 @@ bool STR_String::IsUpper() const // bool STR_String::IsLower() const { - for (int i=0; i<Len; i++) + for (int i = 0; i < Len; i++) if (isUpper(pData[i])) return false; @@ -353,10 +353,10 @@ bool STR_String::IsLower() const int STR_String::Find(char c, int pos) const { assertd(pos >= 0); - assertd(Len==0 || pos<Len); + assertd(Len == 0 || pos < Len); assertd(pData != NULL); - char *find_pos = strchr(pData+pos, c); - return (find_pos) ? (find_pos-pData) : -1; + char *find_pos = strchr(pData + pos, c); + return (find_pos) ? (find_pos - pData) : -1; } @@ -364,13 +364,13 @@ int STR_String::Find(char c, int pos) const // // Find the first occurrence of <str> in the string // -int STR_String::Find(const char *str, int pos) const +int STR_String::Find(const char *str, int pos) const { assertd(pos >= 0); - assertd(Len==0 || pos<Len); + assertd(Len == 0 || pos < Len); assertd(pData != NULL); - char *find_pos = strstr(pData+pos, str); - return (find_pos) ? (find_pos-pData) : -1; + char *find_pos = strstr(pData + pos, str); + return (find_pos) ? (find_pos - pData) : -1; } @@ -378,13 +378,13 @@ int STR_String::Find(const char *str, int pos) const // // Find the first occurrence of <str> in the string // -int STR_String::Find(rcSTR_String str, int pos) const +int STR_String::Find(rcSTR_String str, int pos) const { assertd(pos >= 0); - assertd(Len==0 || pos<Len); + assertd(Len == 0 || pos < Len); assertd(pData != NULL); - char *find_pos = strstr(pData+pos, str.ReadPtr()); - return (find_pos) ? (find_pos-pData) : -1; + char *find_pos = strstr(pData + pos, str.ReadPtr()); + return (find_pos) ? (find_pos - pData) : -1; } @@ -396,7 +396,7 @@ int STR_String::RFind(char c) const { assertd(pData != NULL); char *pos = strrchr(pData, c); - return (pos) ? (pos-pData) : -1; + return (pos) ? (pos - pData) : -1; } @@ -407,10 +407,10 @@ int STR_String::RFind(char c) const int STR_String::FindOneOf(const char *set, int pos) const { assertd(pos >= 0); - assertd(Len==0 || pos<Len); + assertd(Len == 0 || pos < Len); assertd(pData != NULL); - char *find_pos = strpbrk(pData+pos, set); - return (find_pos) ? (find_pos-pData) : -1; + char *find_pos = strpbrk(pData + pos, set); + return (find_pos) ? (find_pos - pData) : -1; } @@ -425,17 +425,16 @@ void STR_String::Replace(int pos, rcSTR_String str) if (str.Length() < 1) { // Remove one character from the string - memcpy(pData+pos, pData+pos+1, Len-pos); + memcpy(pData + pos, pData + pos + 1, Len - pos); } - else - { + else { // Insert zero or more characters into the string AllocBuffer(Len + str.Length() - 1, true); - if (str.Length() != 1) memcpy(pData+pos+str.Length(), pData+pos+1, Length()-pos); - memcpy(pData+pos, str.ReadPtr(), str.Length()); + if (str.Length() != 1) memcpy(pData + pos + str.Length(), pData + pos + 1, Length() - pos); + memcpy(pData + pos, str.ReadPtr(), str.Length()); } - Len += str.Length()-1; + Len += str.Length() - 1; } @@ -452,18 +451,17 @@ void STR_String::Replace(int pos, int num, rcSTR_String str) if (str.Length() < num) { // Remove some data from the string by replacement - memcpy(pData+pos+str.Length(), pData+pos+num, Len-pos-num+1); - memcpy(pData+pos, str.ReadPtr(), str.Length()); + memcpy(pData + pos + str.Length(), pData + pos + num, Len - pos - num + 1); + memcpy(pData + pos, str.ReadPtr(), str.Length()); } - else - { + else { // Insert zero or more characters into the string AllocBuffer(Len + str.Length() - num, true); - if (str.Length() != num) memcpy(pData+pos+str.Length(), pData+pos+num, Length()-pos-num+1); - memcpy(pData+pos, str.ReadPtr(), str.Length()); + if (str.Length() != num) memcpy(pData + pos + str.Length(), pData + pos + num, Length() - pos - num + 1); + memcpy(pData + pos, str.ReadPtr(), str.Length()); } - Len += str.Length()-num; + Len += str.Length() - num; } @@ -477,7 +475,7 @@ void STR_String::Replace(int pos, int num, rcSTR_String str) // // Compare two strings and return the result, <0 if *this<rhs, >0 if *this>rhs or 0 if *this==rhs // -int STR_String::Compare(rcSTR_String rhs) const +int STR_String::Compare(rcSTR_String rhs) const { return strcmp(pData, rhs.pData); } @@ -507,14 +505,14 @@ int STR_String::CompareNoCase(rcSTR_String rhs) const // // Capitalize string, "heLLo" -> "HELLO" // -STR_String& STR_String::Upper() +STR_String& STR_String::Upper() { assertd(pData != NULL); #ifdef WIN32 _strupr(pData); #else - for (int i=0;i<Len;i++) - pData[i] = (pData[i] >= 'a' && pData[i] <= 'z')?pData[i]+'A'-'a':pData[i]; + for (int i = 0; i < Len; i++) + pData[i] = (pData[i] >= 'a' && pData[i] <= 'z') ? pData[i] + 'A' - 'a' : pData[i]; #endif return *this; } @@ -524,14 +522,14 @@ STR_String& STR_String::Upper() // // Lower string, "heLLo" -> "hello" // -STR_String& STR_String::Lower() +STR_String& STR_String::Lower() { assertd(pData != NULL); #ifdef WIN32 _strlwr(pData); #else - for (int i=0;i<Len;i++) - pData[i] = (pData[i] >= 'A' && pData[i] <= 'Z')?pData[i]+'a'-'A':pData[i]; + for (int i = 0; i < Len; i++) + pData[i] = (pData[i] >= 'A' && pData[i] <= 'Z') ? pData[i] + 'a' - 'A' : pData[i]; #endif return *this; } @@ -541,17 +539,17 @@ STR_String& STR_String::Lower() // // Capitalize string, "heLLo" -> "Hello" // -STR_String& STR_String::Capitalize() +STR_String& STR_String::Capitalize() { assertd(pData != NULL); #ifdef WIN32 - if (Len>0) pData[0] = toupper(pData[0]); - if (Len>1) _strlwr(pData+1); + if (Len > 0) pData[0] = toupper(pData[0]); + if (Len > 1) _strlwr(pData + 1); #else if (Len > 0) - pData[0] = (pData[0] >= 'A' && pData[0] <= 'A')?pData[0]+'a'-'A':pData[0]; - for (int i=1;i<Len;i++) - pData[i] = (pData[i] >= 'a' && pData[i] <= 'z')?pData[i]+'A'-'a':pData[i]; + pData[0] = (pData[0] >= 'A' && pData[0] <= 'A') ? pData[0] + 'a' - 'A' : pData[0]; + for (int i = 1; i < Len; i++) + pData[i] = (pData[i] >= 'a' && pData[i] <= 'z') ? pData[i] + 'A' - 'a' : pData[i]; #endif return *this; } @@ -561,13 +559,13 @@ STR_String& STR_String::Capitalize() // // Trim whitespace from the left side of the string // -STR_String& STR_String::TrimLeft() +STR_String& STR_String::TrimLeft() { int skip; assertd(pData != NULL); - for (skip=0; isSpace(pData[skip]); skip++, Len--) - {}; - memmove(pData, pData+skip, Len+1); + for (skip = 0; isSpace(pData[skip]); skip++, Len--) + {}; + memmove(pData, pData + skip, Len + 1); return *this; } @@ -576,11 +574,11 @@ STR_String& STR_String::TrimLeft() // // Trim whitespaces from the right side of the string // -STR_String& STR_String::TrimRight() +STR_String& STR_String::TrimRight() { assertd(pData != NULL); - while (Len && isSpace(pData[Len-1])) Len--; - pData[Len]=0; + while (Len && isSpace(pData[Len - 1])) Len--; + pData[Len] = 0; return *this; } @@ -589,7 +587,7 @@ STR_String& STR_String::TrimRight() // // Trim spaces from both sides of the character set // -STR_String& STR_String::Trim() +STR_String& STR_String::Trim() { TrimRight(); TrimLeft(); @@ -601,13 +599,13 @@ STR_String& STR_String::Trim() // // Trim characters from the character set <set> from the left side of the string // -STR_String& STR_String::TrimLeft(char *set) +STR_String& STR_String::TrimLeft(char *set) { int skip; assertd(pData != NULL); - for (skip=0; Len && strchr(set, pData[skip]); skip++, Len--) - {}; - memmove(pData, pData+skip, Len+1); + for (skip = 0; Len && strchr(set, pData[skip]); skip++, Len--) + {}; + memmove(pData, pData + skip, Len + 1); return *this; } @@ -616,11 +614,11 @@ STR_String& STR_String::TrimLeft(char *set) // // Trim characters from the character set <set> from the right side of the string // -STR_String& STR_String::TrimRight(char *set) +STR_String& STR_String::TrimRight(char *set) { assertd(pData != NULL); - while (Len && strchr(set, pData[Len-1])) Len--; - pData[Len]=0; + while (Len && strchr(set, pData[Len - 1])) Len--; + pData[Len] = 0; return *this; } @@ -629,7 +627,7 @@ STR_String& STR_String::TrimRight(char *set) // // Trim characters from the character set <set> from both sides of the character set // -STR_String& STR_String::Trim(char *set) +STR_String& STR_String::Trim(char *set) { TrimRight(set); TrimLeft(set); @@ -641,14 +639,14 @@ STR_String& STR_String::Trim(char *set) // // Trim quotes from both sides of the string // -STR_String& STR_String::TrimQuotes() +STR_String& STR_String::TrimQuotes() { // Trim quotes if they are on both sides of the string assertd(pData != NULL); - if ((Len >= 2) && (pData[0] == '\"') && (pData[Len-1] == '\"')) + if ((Len >= 2) && (pData[0] == '\"') && (pData[Len - 1] == '\"')) { - memmove(pData, pData+1, Len-2+1); - Len-=2; + memmove(pData, pData + 1, Len - 2 + 1); + Len -= 2; } return *this; } @@ -666,7 +664,7 @@ STR_String& STR_String::TrimQuotes() // rcSTR_String STR_String::Copy(const char *src, int len) { - assertd(len>=0); + assertd(len >= 0); assertd(src); assertd(pData != NULL); @@ -685,23 +683,23 @@ rcSTR_String STR_String::Copy(const char *src, int len) // rcSTR_String STR_String::Concat(const char *data, int len) { - assertd(Len>=0); - assertd(len>=0); + assertd(Len >= 0); + assertd(len >= 0); assertd(data); assertd(pData != NULL); - AllocBuffer(Len+len, true); - memcpy(pData+Len, data, len); - Len+=len; + AllocBuffer(Len + len, true); + memcpy(pData + Len, data, len); + Len += len; pData[Len] = 0; return *this; } -std::vector<STR_String> STR_String::Explode(char c) const +std::vector<STR_String> STR_String::Explode(char c) const { - STR_String lcv = *this; + STR_String lcv = *this; std::vector<STR_String> uc; while (lcv.Length()) @@ -713,7 +711,7 @@ std::vector<STR_String> STR_String::Explode(char c) const } else { uc.push_back(lcv.Left(pos)); - lcv = lcv.Mid(pos+1); + lcv = lcv.Mid(pos + 1); } } @@ -723,25 +721,24 @@ std::vector<STR_String> STR_String::Explode(char c) const } -/* +#if 0 int STR_String::Serialize(pCStream stream) { - if (stream->GetAccess() == CStream::Access_Read) - { + if (stream->GetAccess() == CStream::Access_Read) { int ln; stream->Read(&ln, sizeof(ln)); AllocBuffer(ln, false); stream->Read(pData, ln); pData[ln] = '\0'; Len = ln; - } else - { + } + else { stream->Write(&Len, sizeof(Len)); stream->Write(pData, Len); } return Len + sizeof(Len); } -*/ +#endif diff --git a/intern/utfconv/utf_winfunc.c b/intern/utfconv/utf_winfunc.c index 68d1d6bb403..3840dc25648 100644 --- a/intern/utfconv/utf_winfunc.c +++ b/intern/utfconv/utf_winfunc.c @@ -67,7 +67,7 @@ int uopen(const char *filename, int oflag, int pmode) UTF16_UN_ENCODE(filename); if (f == -1) { - if ((f=open(filename,oflag, pmode)) != -1) { + if ((f = open(filename,oflag, pmode)) != -1) { printf("WARNING: %s is not utf path. Please update it.\n",filename); } } diff --git a/release/datafiles/clkernelstoh.py b/release/datafiles/clkernelstoh.py index 8fb5d4e6bae..9c24c9e2d03 100755 --- a/release/datafiles/clkernelstoh.py +++ b/release/datafiles/clkernelstoh.py @@ -61,9 +61,9 @@ fpout.write("const char * clkernelstoh_%s = " % filename) lines = fpin.readlines() for line in lines: - fpout.write("\"") - fpout.write(line.rstrip()) - fpout.write("\\n\" \\\n") + fpout.write("\"") + fpout.write(line.rstrip()) + fpout.write("\\n\" \\\n") fpout.write("\"\\0\";\n") fpin.close() diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 695bb8cb6b6..02d9cd2d1c6 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -139,6 +139,8 @@ def modules(module_cache): return mod else: + print("fake_module: addon missing 'bl_info' " + "gives bad performance!: %r" % mod_path) return None modules_stale = set(module_cache.keys()) @@ -183,8 +185,8 @@ def modules(module_cache): del modules_stale mod_list = list(module_cache.values()) - mod_list.sort(key=lambda mod: (mod.bl_info['category'], - mod.bl_info['name'], + mod_list.sort(key=lambda mod: (mod.bl_info["category"], + mod.bl_info["name"], )) return mod_list diff --git a/release/scripts/modules/animsys_refactor.py b/release/scripts/modules/animsys_refactor.py index 097a0296a8e..fd6087b38e6 100644 --- a/release/scripts/modules/animsys_refactor.py +++ b/release/scripts/modules/animsys_refactor.py @@ -157,8 +157,8 @@ def find_path_new(id_data, data_path, rna_update_dict, rna_update_from_map): def update_data_paths(rna_update): - ''' rna_update triple [(class_name, from, to), ...] - ''' + """ rna_update triple [(class_name, from, to), ...] + """ # make a faster lookup dict rna_update_dict = {} @@ -887,9 +887,9 @@ if __name__ == "__main__": # Example, should be called externally # (class, from, to) replace_ls = [ - ('AnimVizMotionPaths', 'frame_after', 'frame_after'), - ('AnimVizMotionPaths', 'frame_before', 'frame_before'), - ('AnimVizOnionSkinning', 'frame_after', 'frame_after'), + ("AnimVizMotionPaths", "frame_after", "frame_after"), + ("AnimVizMotionPaths", "frame_before", "frame_before"), + ("AnimVizOnionSkinning", "frame_after", "frame_after"), ] update_data_paths(replace_ls) diff --git a/release/scripts/modules/bl_i18n_utils/__init__.py b/release/scripts/modules/bl_i18n_utils/__init__.py new file mode 100644 index 00000000000..4072247c6d6 --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/__init__.py @@ -0,0 +1,21 @@ +# ##### 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 ##### + +# <pep8 compliant> + +"""Package for translation (i18n) tools.""" diff --git a/release/scripts/modules/bl_i18n_utils/bl_process_msg.py b/release/scripts/modules/bl_i18n_utils/bl_process_msg.py new file mode 100644 index 00000000000..353b911ab2c --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/bl_process_msg.py @@ -0,0 +1,547 @@ +# ***** 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 ***** + +# <pep8-80 compliant> + +# Write out messages.txt from Blender. +# XXX: This script is meant to be used from inside Blender! +# You should not directly use this script, rather use update_msg.py! + +import os + +# XXX Relative import does not work here when used from Blender... +#from . import settings +import bl_i18n_utils.settings as settings + + +#classes = set() + + +SOURCE_DIR = settings.SOURCE_DIR + +CUSTOM_PY_UI_FILES = [os.path.abspath(os.path.join(SOURCE_DIR, p)) + for p in settings.CUSTOM_PY_UI_FILES] +FILE_NAME_MESSAGES = settings.FILE_NAME_MESSAGES +COMMENT_PREFIX = settings.COMMENT_PREFIX +CONTEXT_PREFIX = settings.CONTEXT_PREFIX +CONTEXT_DEFAULT = settings.CONTEXT_DEFAULT +UNDOC_OPS_STR = settings.UNDOC_OPS_STR + +NC_ALLOWED = settings.WARN_MSGID_NOT_CAPITALIZED_ALLOWED + +def check(check_ctxt, messages, key, msgsrc): + if check_ctxt is None: + return + multi_rnatip = check_ctxt.get("multi_rnatip") + multi_lines = check_ctxt.get("multi_lines") + py_in_rna = check_ctxt.get("py_in_rna") + not_capitalized = check_ctxt.get("not_capitalized") + end_point = check_ctxt.get("end_point") + undoc_ops = check_ctxt.get("undoc_ops") + + if multi_rnatip is not None: + if key in messages and key not in multi_rnatip: + multi_rnatip.add(key) + if multi_lines is not None: + if '\n' in key[1]: + multi_lines.add(key) + if py_in_rna is not None: + if key in py_in_rna[1]: + py_in_rna[0].add(key) + if not_capitalized is not None: + if(key[1] not in NC_ALLOWED and key[1][0].isalpha() and + not key[1][0].isupper()): + not_capitalized.add(key) + if end_point is not None: + if key[1].strip().endswith('.'): + end_point.add(key) + if undoc_ops is not None: + if key[1] == UNDOC_OPS_STR: + undoc_ops.add(key) + + +def dump_messages_rna(messages, check_ctxt): + import bpy + + def classBlackList(): + blacklist_rna_class = [# core classes + "Context", "Event", "Function", "UILayout", + "BlendData", + # registerable classes + "Panel", "Menu", "Header", "RenderEngine", + "Operator", "OperatorMacro", "Macro", + "KeyingSetInfo", "UnknownType", + # window classes + "Window", + ] + + # --------------------------------------------------------------------- + # Collect internal operators + + # extend with all internal operators + # note that this uses internal api introspection functions + # all possible operator names + op_ids = set(cls.bl_rna.identifier for cls in + bpy.types.OperatorProperties.__subclasses__()) | \ + set(cls.bl_rna.identifier for cls in + bpy.types.Operator.__subclasses__()) | \ + set(cls.bl_rna.identifier for cls in + bpy.types.OperatorMacro.__subclasses__()) + + get_instance = __import__("_bpy").ops.get_instance + path_resolve = type(bpy.context).__base__.path_resolve + for idname in op_ids: + op = get_instance(idname) + # XXX Do not skip INTERNAL's anymore, some of those ops + # show up in UI now! +# if 'INTERNAL' in path_resolve(op, "bl_options"): +# blacklist_rna_class.append(idname) + + # --------------------------------------------------------------------- + # Collect builtin classes we don't need to doc + blacklist_rna_class.append("Property") + blacklist_rna_class.extend( + [cls.__name__ for cls in + bpy.types.Property.__subclasses__()]) + + # --------------------------------------------------------------------- + # Collect classes which are attached to collections, these are api + # access only. + collection_props = set() + for cls_id in dir(bpy.types): + cls = getattr(bpy.types, cls_id) + for prop in cls.bl_rna.properties: + if prop.type == 'COLLECTION': + prop_cls = prop.srna + if prop_cls is not None: + collection_props.add(prop_cls.identifier) + blacklist_rna_class.extend(sorted(collection_props)) + + return blacklist_rna_class + + blacklist_rna_class = classBlackList() + + def filterRNA(bl_rna): + rid = bl_rna.identifier + if rid in blacklist_rna_class: + print(" skipping", rid) + return True + return False + + check_ctxt_rna = check_ctxt_rna_tip = None + if check_ctxt: + check_ctxt_rna = {"multi_lines": check_ctxt.get("multi_lines"), + "not_capitalized": check_ctxt.get("not_capitalized"), + "end_point": check_ctxt.get("end_point"), + "undoc_ops": check_ctxt.get("undoc_ops")} + check_ctxt_rna_tip = check_ctxt_rna + check_ctxt_rna_tip["multi_rnatip"] = check_ctxt.get("multi_rnatip") + + # ------------------------------------------------------------------------- + # Function definitions + + def walkProperties(bl_rna): + import bpy + + # Get our parents' properties, to not export them multiple times. + bl_rna_base = bl_rna.base + if bl_rna_base: + bl_rna_base_props = bl_rna_base.properties.values() + else: + bl_rna_base_props = () + + for prop in bl_rna.properties: + # Only write this property if our parent hasn't got it. + if prop in bl_rna_base_props: + continue + if prop.identifier == "rna_type": + continue + + msgsrc = "bpy.types.{}.{}".format(bl_rna.identifier, prop.identifier) + context = getattr(prop, "translation_context", CONTEXT_DEFAULT) + if prop.name and (prop.name != prop.identifier or context): + key = (context, prop.name) + check(check_ctxt_rna, messages, key, msgsrc) + messages.setdefault(key, []).append(msgsrc) + if prop.description: + key = (CONTEXT_DEFAULT, prop.description) + check(check_ctxt_rna_tip, messages, key, msgsrc) + messages.setdefault(key, []).append(msgsrc) + if isinstance(prop, bpy.types.EnumProperty): + for item in prop.enum_items: + msgsrc = "bpy.types.{}.{}:'{}'".format(bl_rna.identifier, + prop.identifier, + item.identifier) + if item.name and item.name != item.identifier: + key = (CONTEXT_DEFAULT, item.name) + check(check_ctxt_rna, messages, key, msgsrc) + messages.setdefault(key, []).append(msgsrc) + if item.description: + key = (CONTEXT_DEFAULT, item.description) + check(check_ctxt_rna_tip, messages, key, msgsrc) + messages.setdefault(key, []).append(msgsrc) + + def walkRNA(bl_rna): + if filterRNA(bl_rna): + return + + msgsrc = ".".join(("bpy.types", bl_rna.identifier)) + context = getattr(bl_rna, "translation_context", CONTEXT_DEFAULT) + + if bl_rna.name and (bl_rna.name != bl_rna.identifier or context): + key = (context, bl_rna.name) + check(check_ctxt_rna, messages, key, msgsrc) + messages.setdefault(key, []).append(msgsrc) + + if bl_rna.description: + key = (CONTEXT_DEFAULT, bl_rna.description) + check(check_ctxt_rna_tip, messages, key, msgsrc) + messages.setdefault(key, []).append(msgsrc) + + if hasattr(bl_rna, 'bl_label') and bl_rna.bl_label: + key = (context, bl_rna.bl_label) + check(check_ctxt_rna, messages, key, msgsrc) + messages.setdefault(key, []).append(msgsrc) + + walkProperties(bl_rna) + + def walkClass(cls): + walkRNA(cls.bl_rna) + + def walk_keymap_hierarchy(hier, msgsrc_prev): + for lvl in hier: + msgsrc = "{}.{}".format(msgsrc_prev, lvl[1]) + messages.setdefault((CONTEXT_DEFAULT, lvl[0]), []).append(msgsrc) + + if lvl[3]: + walk_keymap_hierarchy(lvl[3], msgsrc) + + # ------------------------------------------------------------------------- + # Dump Messages + + def process_cls_list(cls_list): + if not cls_list: + return 0 + + def full_class_id(cls): + """ gives us 'ID.Lamp.AreaLamp' which is best for sorting. + """ + cls_id = "" + bl_rna = cls.bl_rna + while bl_rna: + cls_id = "{}.{}".format(bl_rna.identifier, cls_id) + bl_rna = bl_rna.base + return cls_id + + cls_list.sort(key=full_class_id) + processed = 0 + for cls in cls_list: + walkClass(cls) +# classes.add(cls) + # Recursively process subclasses. + processed += process_cls_list(cls.__subclasses__()) + 1 + return processed + + # Parse everything (recursively parsing from bpy_struct "class"...). + processed = process_cls_list(type(bpy.context).__base__.__subclasses__()) + print("{} classes processed!".format(processed)) +# import pickle +# global classes +# classes = {str(c) for c in classes} +# with open("/home/i7deb64/Bureau/tpck_2", "wb") as f: +# pickle.dump(classes, f, protocol=0) + + from bpy_extras.keyconfig_utils import KM_HIERARCHY + + walk_keymap_hierarchy(KM_HIERARCHY, "KM_HIERARCHY") + + + +def dump_messages_pytext(messages, check_ctxt): + """ dumps text inlined in the python user interface: eg. + + layout.prop("someprop", text="My Name") + """ + import ast + + # ------------------------------------------------------------------------- + # Gather function names + + import bpy + # key: func_id + # val: [(arg_kw, arg_pos), (arg_kw, arg_pos), ...] + func_translate_args = {} + + # so far only 'text' keywords, but we may want others translated later + translate_kw = ("text", ) + + # Break recursive nodes look up on some kind of nodes. + # E.g. we don’t want to get strings inside subscripts (blah["foo"])! + stopper_nodes = {ast.Subscript,} + + for func_id, func in bpy.types.UILayout.bl_rna.functions.items(): + # check it has a 'text' argument + for (arg_pos, (arg_kw, arg)) in enumerate(func.parameters.items()): + if ((arg_kw in translate_kw) and + (arg.is_output == False) and + (arg.type == 'STRING')): + + func_translate_args.setdefault(func_id, []).append((arg_kw, + arg_pos)) + # print(func_translate_args) + + check_ctxt_py = None + if check_ctxt: + check_ctxt_py = {"py_in_rna": (check_ctxt["py_in_rna"], messages.copy()), + "multi_lines": check_ctxt["multi_lines"], + "not_capitalized": check_ctxt["not_capitalized"], + "end_point": check_ctxt["end_point"]} + + # ------------------------------------------------------------------------- + # Function definitions + + def extract_strings(fp_rel, node): + """ Recursively get strings, needed in case we have "Blah" + "Blah", + passed as an argument in that case it wont evaluate to a string. + However, break on some kind of stopper nodes, like e.g. Subscript. + """ + + if type(node) == ast.Str: + eval_str = ast.literal_eval(node) + if eval_str: + key = (CONTEXT_DEFAULT, eval_str) + msgsrc = "{}:{}".format(fp_rel, node.lineno) + check(check_ctxt_py, messages, key, msgsrc) + messages.setdefault(key, []).append(msgsrc) + return + + for nd in ast.iter_child_nodes(node): + if type(nd) not in stopper_nodes: + extract_strings(fp_rel, nd) + + def extract_strings_from_file(fp): + filedata = open(fp, 'r', encoding="utf8") + root_node = ast.parse(filedata.read(), fp, 'exec') + filedata.close() + + fp_rel = os.path.relpath(fp, SOURCE_DIR) + + for node in ast.walk(root_node): + if type(node) == ast.Call: + # print("found function at") + # print("%s:%d" % (fp, node.lineno)) + + # lambda's + if type(node.func) == ast.Name: + continue + + # getattr(self, con.type)(context, box, con) + if not hasattr(node.func, "attr"): + continue + + translate_args = func_translate_args.get(node.func.attr, ()) + + # do nothing if not found + for arg_kw, arg_pos in translate_args: + if arg_pos < len(node.args): + extract_strings(fp_rel, node.args[arg_pos]) + else: + for kw in node.keywords: + if kw.arg == arg_kw: + extract_strings(fp_rel, kw.value) + + # ------------------------------------------------------------------------- + # Dump Messages + + mod_dir = os.path.join(SOURCE_DIR, + "release", + "scripts", + "startup", + "bl_ui") + + files = [os.path.join(mod_dir, fn) + for fn in sorted(os.listdir(mod_dir)) + if not fn.startswith("_") + if fn.endswith("py") + ] + + # Dummy Cycles has its py addon in its own dir! + files += CUSTOM_PY_UI_FILES + + for fp in files: + extract_strings_from_file(fp) + + +def dump_messages(do_messages, do_checks): + import collections + + def enable_addons(): + """For now, enable all official addons, before extracting msgids.""" + import addon_utils + import bpy + + userpref = bpy.context.user_preferences + used_ext = {ext.module for ext in userpref.addons} + support = {"OFFICIAL"} + # collect the categories that can be filtered on + addons = [(mod, addon_utils.module_bl_info(mod)) for mod in + addon_utils.modules(addon_utils.addons_fake_modules)] + + for mod, info in addons: + module_name = mod.__name__ + if module_name in used_ext or info["support"] not in support: + continue + print(" Enabling module ", module_name) + bpy.ops.wm.addon_enable(module=module_name) + + # XXX There are currently some problems with bpy/rna... + # *Very* tricky to solve! + # So this is a hack to make all newly added operator visible by + # bpy.types.OperatorProperties.__subclasses__() + for cat in dir(bpy.ops): + cat = getattr(bpy.ops, cat) + for op in dir(cat): + getattr(cat, op).get_rna() + + # check for strings like ": %d" + ignore = ("%d", "%f", "%s", "%r", # string formatting + "*", ".", "(", ")", "-", "/", "\\", "+", ":", "#", "%" + "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", + "x", # used on its own eg: 100x200 + "X", "Y", "Z", "W", # used alone. no need to include + ) + + def filter_message(msg): + msg_tmp = msg + for ign in ignore: + msg_tmp = msg_tmp.replace(ign, "") + if not msg_tmp.strip(): + return True + # we could filter out different strings here + return False + + if hasattr(collections, 'OrderedDict'): + messages = collections.OrderedDict() + else: + messages = {} + + messages[(CONTEXT_DEFAULT, "")] = [] + + # Enable all wanted addons. + enable_addons() + + check_ctxt = None + if do_checks: + check_ctxt = {"multi_rnatip": set(), + "multi_lines": set(), + "py_in_rna": set(), + "not_capitalized": set(), + "end_point": set(), + "undoc_ops": set()} + + # get strings from RNA + dump_messages_rna(messages, check_ctxt) + + # get strings from UI layout definitions text="..." args + dump_messages_pytext(messages, check_ctxt) + + del messages[(CONTEXT_DEFAULT, "")] + + if do_checks: + print("WARNINGS:") + keys = set() + for c in check_ctxt.values(): + keys |= c + # XXX Temp, see below + keys -= check_ctxt["multi_rnatip"] + for key in keys: + if key in check_ctxt["undoc_ops"]: + print("\tThe following operators are undocumented:") + else: + print("\t“{}â€|“{}â€:".format(*key)) + if key in check_ctxt["multi_lines"]: + print("\t\t-> newline in this message!") + if key in check_ctxt["not_capitalized"]: + print("\t\t-> message not capitalized!") + if key in check_ctxt["end_point"]: + print("\t\t-> message with endpoint!") + # XXX Hide this one for now, too much false positives. +# if key in check_ctxt["multi_rnatip"]: +# print("\t\t-> tip used in several RNA items") + if key in check_ctxt["py_in_rna"]: + print("\t\t-> RNA message also used in py UI code:") + print("\t\t{}".format("\n\t\t".join(messages[key]))) + + if do_messages: + print("Writing messages…") + num_written = 0 + num_filtered = 0 + with open(FILE_NAME_MESSAGES, 'w', encoding="utf8") as message_file: + for (ctx, key), value in messages.items(): + # filter out junk values + if filter_message(key): + num_filtered += 1 + continue + + # Remove newlines in key and values! + message_file.write("\n".join(COMMENT_PREFIX + msgsrc.replace("\n", "") for msgsrc in value)) + message_file.write("\n") + if ctx: + message_file.write(CONTEXT_PREFIX + ctx.replace("\n", "") + "\n") + message_file.write(key.replace("\n", "") + "\n") + num_written += 1 + + print("Written {} messages to: {} ({} were filtered out)." \ + "".format(num_written, FILE_NAME_MESSAGES, num_filtered)) + + +def main(): + try: + import bpy + except ImportError: + print("This script must run from inside blender") + return + + import sys + back_argv = sys.argv + sys.argv = sys.argv[sys.argv.index("--") + 1:] + + import argparse + parser = argparse.ArgumentParser(description="Process UI messages " \ + "from inside Blender.") + parser.add_argument('-c', '--no_checks', default=True, + action="store_false", + help="No checks over UI messages.") + parser.add_argument('-m', '--no_messages', default=True, + action="store_false", + help="No export of UI messages.") + parser.add_argument('-o', '--output', help="Output messages file path.") + args = parser.parse_args() + + if args.output: + global FILE_NAME_MESSAGES + FILE_NAME_MESSAGES = args.output + + dump_messages(do_messages=args.no_messages, do_checks=args.no_checks) + + sys.argv = back_argv + + +if __name__ == "__main__": + print("\n\n *** Running {} *** \n".format(__file__)) + main() diff --git a/release/scripts/modules/bl_i18n_utils/check_po.py b/release/scripts/modules/bl_i18n_utils/check_po.py new file mode 100755 index 00000000000..a688d38df88 --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/check_po.py @@ -0,0 +1,175 @@ +#!/usr/bin/python3 + +# ***** 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 ***** + +# <pep8 compliant> + +# Check po’s in branches (or in trunk) for missing/unneeded messages. + +import os +import sys +from codecs import open + +import settings +import utils + +TRUNK_PO_DIR = settings.TRUNK_PO_DIR +BRANCHES_DIR = settings.BRANCHES_DIR + +FILE_NAME_POT = settings.FILE_NAME_POT + + +def print_diff(ref_messages, messages, states): + # Remove comments from messages list! + messages = set(messages.keys()) - states["comm_msg"] + unneeded = (messages - ref_messages) + for msgid in unneeded: + print('\tUnneeded message id "{}"'.format(msgid)) + + missing = (ref_messages - messages) + for msgid in missing: + print('\tMissing message id "{}"'.format(msgid)) + + for msgid in states["comm_msg"]: + print('\tCommented message id "{}"'.format(msgid)) + + print("\t{} unneeded messages, {} missing messages, {} commented messages." \ + "".format(len(unneeded), len(missing), len(states["comm_msg"]))) + return 0 + + +def process_po(ref_messages, po, glob_stats, do_stats, do_messages): + print("Checking {}...".format(po)) + ret = 0 + + messages, states, stats = utils.parse_messages(po) + if do_messages: + t = print_diff(ref_messages, messages, states) + if t: + ret = t + if do_stats: + print("\tStats:") + t = utils.print_stats(stats, glob_stats, prefix=" ") + if t: + ret = t + if states["is_broken"]: + print("\tERROR! This .po is broken!") + ret = 1 + return ret + + +def main(): + import argparse + parser = argparse.ArgumentParser(description="Check po’s in branches " \ + "(or in trunk) for missing" \ + "/unneeded messages.") + parser.add_argument('-s', '--stats', action="store_true", + help="Print po’s stats.") + parser.add_argument('-m', '--messages', action="store_true", + help="Print po’s missing/unneeded/commented messages.") + parser.add_argument('-t', '--trunk', action="store_true", + help="Check po’s in /trunk/po rather than /branches.") + parser.add_argument('-p', '--pot', + help="Specify the .pot file used as reference.") + parser.add_argument('langs', metavar='ISO_code', nargs='*', + help="Restrict processed languages to those.") + args = parser.parse_args() + + + if args.pot: + global FILE_NAME_POT + FILE_NAME_POT = args.pot + glob_stats = {"nbr" : 0.0, + "lvl" : 0.0, + "lvl_ttips" : 0.0, + "lvl_trans_ttips" : 0.0, + "lvl_ttips_in_trans": 0.0, + "lvl_comm" : 0.0, + "nbr_signs" : 0, + "nbr_trans_signs" : 0, + "contexts" : set()} + ret = 0 + + pot_messages = None + if args.messages: + pot_messages, u1, pot_stats = utils.parse_messages(FILE_NAME_POT) + pot_messages = set(pot_messages.keys()) + glob_stats["nbr_signs"] = pot_stats["nbr_signs"] + + if args.langs: + for lang in args.langs: + if args.trunk: + po = os.path.join(TRUNK_PO_DIR, ".".join((lang, "po"))) + else: + po = os.path.join(BRANCHES_DIR, lang, ".".join((lang, "po"))) + if os.path.exists(po): + t = process_po(pot_messages, po, glob_stats, + args.stats, args.messages) + if t: + ret = t + elif args.trunk: + for po in os.listdir(TRUNK_PO_DIR): + if po.endswith(".po"): + po = os.path.join(TRUNK_PO_DIR, po) + t = process_po(pot_messages, po, glob_stats, + args.stats, args.messages) + if t: + ret = t + else: + for lang in os.listdir(BRANCHES_DIR): + for po in os.listdir(os.path.join(BRANCHES_DIR, lang)): + if po.endswith(".po"): + po = os.path.join(BRANCHES_DIR, lang, po) + t = process_po(pot_messages, po, glob_stats, + args.stats, args.messages) + if t: + ret = t + + if args.stats and glob_stats["nbr"] != 0.0: + nbr_contexts = len(glob_stats["contexts"]-{""}) + if nbr_contexts != 1: + if nbr_contexts == 0: + nbr_contexts = "No" + _ctx_txt = "s are" + else: + _ctx_txt = " is" + print("\nAverage stats for all {:.0f} processed files:\n" \ + " {:>6.1%} done!\n" \ + " {:>6.1%} of messages are tooltips.\n" \ + " {:>6.1%} of tooltips are translated.\n" \ + " {:>6.1%} of translated messages are tooltips.\n" \ + " {:>6.1%} of messages are commented.\n" \ + " The org msgids are currently made of {} signs.\n" \ + " All processed translations are currently made of {} signs.\n" \ + " {} specific context{} present:\n {}\n" \ + "".format(glob_stats["nbr"], glob_stats["lvl"]/glob_stats["nbr"], + glob_stats["lvl_ttips"]/glob_stats["nbr"], + glob_stats["lvl_trans_ttips"]/glob_stats["nbr"], + glob_stats["lvl_ttips_in_trans"]/glob_stats["nbr"], + glob_stats["lvl_comm"]/glob_stats["nbr"], glob_stats["nbr_signs"], + glob_stats["nbr_trans_signs"], nbr_contexts, _ctx_txt, + "\n ".join(glob_stats["contexts"]-{""}))) + + return ret + + +if __name__ == "__main__": + print("\n\n *** Running {} *** \n".format(__file__)) + print(" *** WARNING! Number of tooltips is only an estimation! ***\n") + sys.exit(main()) diff --git a/release/scripts/modules/bl_i18n_utils/clean_po.py b/release/scripts/modules/bl_i18n_utils/clean_po.py new file mode 100755 index 00000000000..7e91b41065c --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/clean_po.py @@ -0,0 +1,97 @@ +#!/usr/bin/python3 + +# ***** 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 ***** + +# <pep8 compliant> + +# Clean (i.e. remove commented messages) po’s in branches or trunk. + +import os +import sys +import collections +from codecs import open + +import settings +import utils + +TRUNK_PO_DIR = settings.TRUNK_PO_DIR +BRANCHES_DIR = settings.BRANCHES_DIR + + +def do_clean(po, strict): + print("Cleaning {}...".format(po)) + messages, states, u1 = utils.parse_messages(po) + + if strict and states["is_broken"]: + print("ERROR! This .po file is broken!") + return 1 + + for msgkey in states["comm_msg"]: + del messages[msgkey] + utils.write_messages(po, messages, states["comm_msg"], states["fuzzy_msg"]) + print("Removed {} commented messages.".format(len(states["comm_msg"]))) + return 0 + + +def main(): + import argparse + parser = argparse.ArgumentParser(description="Clean po’s in branches " \ + "or trunk (i.e. remove " \ + "all commented messages).") + parser.add_argument('-t', '--trunk', action="store_true", + help="Clean po’s in trunk rather than branches.") + parser.add_argument('-s', '--strict', action="store_true", + help="Raise an error if a po is broken.") + parser.add_argument('langs', metavar='ISO_code', nargs='*', + help="Restrict processed languages to those.") + args = parser.parse_args() + + + ret = 0 + + if args.langs: + for lang in args.langs: + if args.trunk: + po = os.path.join(TRUNK_PO_DIR, ".".join((lang, "po"))) + else: + po = os.path.join(BRANCHES_DIR, lang, ".".join((lang, "po"))) + if os.path.exists(po): + t = do_clean(po, args.strict) + if t: + ret = t + elif args.trunk: + for po in os.listdir(TRUNK_PO_DIR): + if po.endswith(".po"): + po = os.path.join(TRUNK_PO_DIR, po) + t = do_clean(po, args.strict) + if t: + ret = t + else: + for lang in os.listdir(BRANCHES_DIR): + for po in os.listdir(os.path.join(BRANCHES_DIR, lang)): + if po.endswith(".po"): + po = os.path.join(BRANCHES_DIR, lang, po) + t = do_clean(po, args.strict) + if t: + ret = t + + +if __name__ == "__main__": + print("\n\n *** Running {} *** \n".format(__file__)) + sys.exit(main()) diff --git a/release/scripts/modules/bl_i18n_utils/import_po_from_branches.py b/release/scripts/modules/bl_i18n_utils/import_po_from_branches.py new file mode 100755 index 00000000000..4739a98920f --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/import_po_from_branches.py @@ -0,0 +1,119 @@ +#!/usr/bin/python3 + +# ***** 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 ***** + +# <pep8 compliant> + +# Import in trunk/po all po from branches translated above the given threshold. + +import os +import shutil +import sys +import subprocess +from codecs import open + +import settings +import utils +import rtl_preprocess + + +TRUNK_PO_DIR = settings.TRUNK_PO_DIR +BRANCHES_DIR = settings.BRANCHES_DIR + +RTL_PREPROCESS_FILE = settings.RTL_PREPROCESS_FILE + +PY3 = settings.PYTHON3_EXEC + + +def main(): + import argparse + parser = argparse.ArgumentParser(description="Import advanced enough po’s " \ + "from branches to trunk.") + parser.add_argument('-t', '--threshold', type=int, + help="Import threshold, as a percentage.") + parser.add_argument('-s', '--strict', action="store_true", + help="Raise an error if a po is broken.") + parser.add_argument('langs', metavar='ISO_code', nargs='*', + help="Restrict processed languages to those.") + args = parser.parse_args() + + + ret = 0 + + threshold = float(settings.IMPORT_MIN_LEVEL)/100.0 + if args.threshold is not None: + threshold = float(args.threshold)/100.0 + + for lang in os.listdir(BRANCHES_DIR): + if args.langs and lang not in args.langs: + continue + po = os.path.join(BRANCHES_DIR, lang, ".".join((lang, "po"))) + if os.path.exists(po): + po_is_rtl = os.path.join(BRANCHES_DIR, lang, RTL_PREPROCESS_FILE) + msgs, state, stats = utils.parse_messages(po) + tot_msgs = stats["tot_msg"] + trans_msgs = stats["trans_msg"] + lvl = 0.0 + if tot_msgs: + lvl = float(trans_msgs)/float(tot_msgs) + if lvl > threshold: + if state["is_broken"] and args.strict: + print("{:<10}: {:>6.1%} done, but BROKEN, skipped." \ + "".format(lang, lvl)) + ret = 1 + else: + if os.path.exists(po_is_rtl): + out_po = os.path.join(TRUNK_PO_DIR, + ".".join((lang, "po"))) + out_raw_po = os.path.join(TRUNK_PO_DIR, + "_".join((lang, "raw.po"))) + keys = [] + trans = [] + for k, m in msgs.items(): + keys.append(k) + trans.append("".join(m["msgstr_lines"])) + trans = rtl_preprocess.log2vis(trans) + for k, t in zip(keys, trans): + # Mono-line for now... + msgs[k]["msgstr_lines"] = [t] + utils.write_messages(out_po, msgs, state["comm_msg"], + state["fuzzy_msg"]) + # Also copies org po! + shutil.copy(po, out_raw_po) + print("{:<10}: {:>6.1%} done, enough translated " \ + "messages, processed and copied to trunk." \ + "".format(lang, lvl)) + else: + shutil.copy(po, TRUNK_PO_DIR) + print("{:<10}: {:>6.1%} done, enough translated " \ + "messages, copied to trunk.".format(lang, lvl)) + else: + if state["is_broken"] and args.strict: + print("{:<10}: {:>6.1%} done, BROKEN and not enough " \ + "translated messages, skipped".format(lang, lvl)) + ret = 1 + else: + print("{:<10}: {:>6.1%} done, not enough translated " \ + "messages, skipped.".format(lang, lvl)) + return ret + + +if __name__ == "__main__": + print("\n\n *** Running {} *** \n".format(__file__)) + sys.exit(main()) diff --git a/release/scripts/modules/bl_i18n_utils/merge_po.py b/release/scripts/modules/bl_i18n_utils/merge_po.py new file mode 100755 index 00000000000..1a55cd670b0 --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/merge_po.py @@ -0,0 +1,156 @@ +#!/usr/bin/python3 + +# ***** 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 ***** + +# <pep8 compliant> + +# Merge one or more .po files into the first dest one. +# If a msgkey is present in more than one merged po, the one in the first file wins, unless +# it’s marked as fuzzy and one later is not. +# The fuzzy flag is removed if necessary. +# All other comments are never modified. +# However, commented messages in dst will always remain commented, and commented messages are +# never merged from sources. + +import sys +from codecs import open + +import utils + + +def main(): + import argparse + parser = argparse.ArgumentParser(description="" \ + "Merge one or more .po files into the first dest one.\n" \ + "If a msgkey (msgid, msgctxt) is present in more than " \ + "one merged po, the one in the first file wins, unless " \ + "it’s marked as fuzzy and one later is not.\n" \ + "The fuzzy flag is removed if necessary.\n" \ + "All other comments are never modified.\n" \ + "Commented messages in dst will always remain " \ + "commented, and commented messages are never merged " \ + "from sources.") + parser.add_argument('-s', '--stats', action="store_true", + help="Show statistics info.") + parser.add_argument('-r', '--replace', action="store_true", + help="Replace existing messages of same \"level\" already in dest po.") + parser.add_argument('dst', metavar='dst.po', + help="The dest po into which merge the others.") + parser.add_argument('src', metavar='src.po', nargs='+', + help="The po's to merge into the dst.po one.") + args = parser.parse_args() + + + ret = 0 + done_msgkeys = set() + done_fuzzy_msgkeys = set() + nbr_merged = 0 + nbr_replaced = 0 + nbr_added = 0 + nbr_unfuzzied = 0 + + dst_messages, dst_states, dst_stats = utils.parse_messages(args.dst) + if dst_states["is_broken"]: + print("Dest po is BROKEN, aborting.") + return 1 + if args.stats: + print("Dest po, before merging:") + utils.print_stats(dst_stats, prefix="\t") + # If we don’t want to replace existing valid translations, pre-populate + # done_msgkeys and done_fuzzy_msgkeys. + if not args.replace: + done_msgkeys = dst_states["trans_msg"].copy() + done_fuzzy_msgkeys = dst_states["fuzzy_msg"].copy() + for po in args.src: + messages, states, stats = utils.parse_messages(po) + if states["is_broken"]: + print("\tSrc po {} is BROKEN, skipping.".format(po)) + ret = 1 + continue + print("\tMerging {}...".format(po)) + if args.stats: + print("\t\tMerged po stats:") + utils.print_stats(stats, prefix="\t\t\t") + for msgkey, val in messages.items(): + msgctxt, msgid = msgkey + # This msgkey has already been completely merged, or is a commented one, + # or the new message is commented, skip it. + if msgkey in (done_msgkeys | dst_states["comm_msg"] | states["comm_msg"]): + continue + is_ttip = utils.is_tooltip(msgid) + # New messages does not yet exists in dest. + if msgkey not in dst_messages: + dst_messages[msgkey] = messages[msgkey] + if msgkey in states["fuzzy_msg"]: + done_fuzzy_msgkeys.add(msgkey) + dst_states["fuzzy_msg"].add(msgkey) + elif msgkey in states["trans_msg"]: + done_msgkeys.add(msgkey) + dst_states["trans_msg"].add(msgkey) + dst_stats["trans_msg"] += 1 + if is_ttip: + dst_stats["trans_ttips"] += 1 + nbr_added += 1 + dst_stats["tot_msg"] += 1 + if is_ttip: + dst_stats["tot_ttips"] += 1 + # From now on, the new messages is already in dst. + # New message is neither translated nor fuzzy, skip it. + elif msgkey not in (states["trans_msg"] | states["fuzzy_msg"]): + continue + # From now on, the new message is either translated or fuzzy! + # The new message is translated. + elif msgkey in states["trans_msg"]: + dst_messages[msgkey]["msgstr_lines"] = messages[msgkey]["msgstr_lines"] + done_msgkeys.add(msgkey) + done_fuzzy_msgkeys.discard(msgkey) + if msgkey in dst_states["fuzzy_msg"]: + dst_states["fuzzy_msg"].remove(msgkey) + nbr_unfuzzied += 1 + if msgkey not in dst_states["trans_msg"]: + dst_states["trans_msg"].add(msgkey) + dst_stats["trans_msg"] += 1 + if is_ttip: + dst_stats["trans_ttips"] += 1 + else: + nbr_replaced += 1 + nbr_merged += 1 + # The new message is fuzzy, org one is fuzzy too, + # and this msgkey has not yet been merged. + elif msgkey not in (dst_states["trans_msg"] | done_fuzzy_msgkeys): + dst_messages[msgkey]["msgstr_lines"] = messages[msgkey]["msgstr_lines"] + done_fuzzy_msgkeys.add(msgkey) + dst_states["fuzzy_msg"].add(msgkey) + nbr_merged += 1 + nbr_replaced += 1 + + utils.write_messages(args.dst, dst_messages, dst_states["comm_msg"], dst_states["fuzzy_msg"]) + + print("Merged completed. {} messages were merged (among which {} were replaced), " \ + "{} were added, {} were \"un-fuzzied\"." \ + "".format(nbr_merged, nbr_replaced, nbr_added, nbr_unfuzzied)) + if args.stats: + print("Final merged po stats:") + utils.print_stats(dst_stats, prefix="\t") + return ret + + +if __name__ == "__main__": + print("\n\n *** Running {} *** \n".format(__file__)) + sys.exit(main()) diff --git a/release/scripts/modules/bl_i18n_utils/rtl_preprocess.py b/release/scripts/modules/bl_i18n_utils/rtl_preprocess.py new file mode 100755 index 00000000000..c6fc5fc787e --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/rtl_preprocess.py @@ -0,0 +1,231 @@ +#!/usr/bin/python3 + +# ***** 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 ***** + +# <pep8 compliant> + +# Preprocess right-to-left languages. +# You can use it either standalone, or through import_po_from_branches or +# update_trunk. +# +# Notes: This has been tested on Linux, not 100% it will work nicely on +# Windows or OsX. +# This uses ctypes, as there is no py3 binding for fribidi currently. +# This implies you only need the compiled C library to run it. +# Finally, note that it handles some formating/escape codes (like +# \", %s, %x12, %.4f, etc.), protecting them from ugly (evil) fribidi, +# which seems completely unaware of such things (as unicode is...). + +import sys +import ctypes + +import settings +import utils + +FRIBIDI_LIB = settings.FRIBIDI_LIB + +###### Import C library and recreate "defines". ##### +fbd = ctypes.CDLL(FRIBIDI_LIB) + + +#define FRIBIDI_MASK_NEUTRAL 0x00000040L /* Is neutral */ +FRIBIDI_PAR_ON = 0x00000040 + + +#define FRIBIDI_FLAG_SHAPE_MIRRORING 0x00000001 +#define FRIBIDI_FLAG_REORDER_NSM 0x00000002 + +#define FRIBIDI_FLAG_SHAPE_ARAB_PRES 0x00000100 +#define FRIBIDI_FLAG_SHAPE_ARAB_LIGA 0x00000200 +#define FRIBIDI_FLAG_SHAPE_ARAB_CONSOLE 0x00000400 + +#define FRIBIDI_FLAG_REMOVE_BIDI 0x00010000 +#define FRIBIDI_FLAG_REMOVE_JOINING 0x00020000 +#define FRIBIDI_FLAG_REMOVE_SPECIALS 0x00040000 + +#define FRIBIDI_FLAGS_DEFAULT ( \ +# FRIBIDI_FLAG_SHAPE_MIRRORING | \ +# FRIBIDI_FLAG_REORDER_NSM | \ +# FRIBIDI_FLAG_REMOVE_SPECIALS ) + +#define FRIBIDI_FLAGS_ARABIC ( \ +# FRIBIDI_FLAG_SHAPE_ARAB_PRES | \ +# FRIBIDI_FLAG_SHAPE_ARAB_LIGA ) + +FRIBIDI_FLAG_SHAPE_MIRRORING = 0x00000001 +FRIBIDI_FLAG_REORDER_NSM = 0x00000002 +FRIBIDI_FLAG_REMOVE_SPECIALS = 0x00040000 + +FRIBIDI_FLAG_SHAPE_ARAB_PRES = 0x00000100 +FRIBIDI_FLAG_SHAPE_ARAB_LIGA = 0x00000200 + +FRIBIDI_FLAGS_DEFAULT = FRIBIDI_FLAG_SHAPE_MIRRORING | \ + FRIBIDI_FLAG_REORDER_NSM | \ + FRIBIDI_FLAG_REMOVE_SPECIALS + +FRIBIDI_FLAGS_ARABIC = FRIBIDI_FLAG_SHAPE_ARAB_PRES | \ + FRIBIDI_FLAG_SHAPE_ARAB_LIGA + +##### Kernel processing funcs. ##### +def protect_format_seq(msg): + """ + Find some specific escaping/formating sequences (like \", %s, etc., + and protect them from any modification! + """ + LRE = "\u202A" + PDF = "\u202C" + # Most likely incomplete, but seems to cover current needs. + format_codes = set("tslfd") + digits = set(".0123456789") + + idx = 0 + ret = [] + ln = len(msg) + while idx < ln: + dlt = 1 + # \" or \' + if idx < (ln - 1) and msg[idx] == '\\' and msg[idx + 1] in "\"\'": + dlt = 2 + # %x12 + elif idx < (ln - 2) and msg[idx] == '%' and msg[idx + 1] in "x" and \ + msg[idx + 2] in digits: + dlt = 2 + while (idx + dlt + 1) < ln and msg[idx + dlt + 1] in digits: + dlt += 1 + # %.4f + elif idx < (ln - 3) and msg[idx] == '%' and msg[idx + 1] in digits: + dlt = 2 + while (idx + dlt + 1) < ln and msg[idx + dlt + 1] in digits: + dlt += 1 + if (idx + dlt + 1) < ln and msg[idx + dlt + 1] in format_codes: + dlt += 1 + else: + dlt = 1 + # %s + elif idx < (ln - 1) and msg[idx] == '%' and \ + msg[idx + 1] in format_codes: + dlt = 2 + + if dlt > 1: + ret.append(LRE) + ret += msg[idx:idx + dlt] + idx += dlt + if dlt > 1: + ret.append(PDF) + + return "".join(ret) + + +def log2vis(msgs): + """ + Globally mimics deprecated fribidi_log2vis. + msgs should be an iterable of messages to rtl-process. + """ + for msg in msgs: + msg = protect_format_seq(msg) + + fbc_str = ctypes.create_unicode_buffer(msg) + ln = len(fbc_str) - 1 +# print(fbc_str.value, ln) + btypes = (ctypes.c_int * ln)() + embed_lvl = (ctypes.c_uint8 * ln)() + pbase_dir = ctypes.c_int(FRIBIDI_PAR_ON) + jtypes = (ctypes.c_uint8 * ln)() + flags = FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC + + # Find out direction of each char. + fbd.fribidi_get_bidi_types(fbc_str, ln, ctypes.byref(btypes)) + +# print(*btypes) + + fbd.fribidi_get_par_embedding_levels(btypes, ln, + ctypes.byref(pbase_dir), + embed_lvl) + +# print(*embed_lvl) + + # Joinings for arabic chars. + fbd.fribidi_get_joining_types(fbc_str, ln, jtypes) +# print(*jtypes) + fbd.fribidi_join_arabic(btypes, ln, embed_lvl, jtypes) +# print(*jtypes) + + # Final Shaping! + fbd.fribidi_shape(flags, embed_lvl, ln, jtypes, fbc_str) + +# print(fbc_str.value) +# print(*(ord(c) for c in fbc_str)) + # And now, the reordering. + # Note that here, we expect a single line, so no need to do + # fancy things... + fbd.fribidi_reorder_line(flags, btypes, ln, 0, pbase_dir, embed_lvl, + fbc_str, None) +# print(fbc_str.value) +# print(*(ord(c) for c in fbc_str)) + + yield fbc_str.value + +##### Command line stuff. ##### +def main(): + import argparse + parser = argparse.ArgumentParser(description="" \ + "Preprocesses right-to-left languages.\n" \ + "You can use it either standalone, or through " \ + "import_po_from_branches or update_trunk.\n\n" \ + "Note: This has been tested on Linux, not 100% it will " \ + "work nicely on Windows or OsX.\n" \ + "Note: This uses ctypes, as there is no py3 binding for " \ + "fribidi currently. This implies you only need the " \ + "compiled C library to run it.\n" \ + "Note: It handles some formating/escape codes (like " \ + "\\\", %s, %x12, %.4f, etc.), protecting them from ugly " \ + "(evil) fribidi, which seems completely unaware of such " \ + "things (as unicode is...).") + parser.add_argument('dst', metavar='dst.po', + help="The dest po into which write the " \ + "pre-processed messages.") + parser.add_argument('src', metavar='src.po', + help="The po's to pre-process messages.") + args = parser.parse_args() + + + msgs, state, u1 = utils.parse_messages(args.src) + if state["is_broken"]: + print("Source po is BROKEN, aborting.") + return 1 + + keys = [] + trans = [] + for key, val in msgs.items(): + keys.append(key) + trans.append("".join(val["msgstr_lines"])) + trans = log2vis(trans) + for key, trn in zip(keys, trans): + # Mono-line for now... + msgs[key]["msgstr_lines"] = [trn] + + utils.write_messages(args.dst, msgs, state["comm_msg"], state["fuzzy_msg"]) + + print("RTL pre-process completed.") + return 0 + + +if __name__ == "__main__": + print("\n\n *** Running {} *** \n".format(__file__)) + sys.exit(main()) diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py new file mode 100644 index 00000000000..7ee81c1dc47 --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/settings.py @@ -0,0 +1,286 @@ +# ***** 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 ***** + +# <pep8 compliant> + +# Global settings used by all scripts in this dir. +# XXX Before any use of the tools in this dir, please make a copy of this file +# named "setting.py" +# XXX This is a template, most values should be OK, but some you’ll have to +# edit (most probably, BLENDER_EXEC and SOURCE_DIR). + +import os.path + + +############################################################################### +# MISC +############################################################################### + +# The min level of completeness for a po file to be imported from /branches +# into /trunk, as a percentage. -1 means "import everything". +IMPORT_MIN_LEVEL = -1 + +# The comment prefix used in generated messages.txt file. +COMMENT_PREFIX = "#~ " + +# The comment prefix used to mark sources of msgids, in po's. +COMMENT_PREFIX_SOURCE = "#: " + +# The comment prefix used in generated messages.txt file. +CONTEXT_PREFIX = "MSGCTXT:" + +# Default context. +CONTEXT_DEFAULT = "" + +# Undocumented operator placeholder string. +UNDOC_OPS_STR = "(undocumented operator)" + +# The gettext domain. +DOMAIN = "blender" + +# Our own "gettext" stuff. +# File type (ext) to parse. +PYGETTEXT_ALLOWED_EXTS = {".c", ".cpp", ".cxx", ".hpp", ".hxx", ".h"} + +# Where to search contexts definitions, relative to SOURCE_DIR (defined below). +PYGETTEXT_CONTEXTS_DEFSRC = os.path.join("source", "blender", "blenfont", + "BLF_translation.h") + +# Regex to extract contexts defined in BLF_translation.h +# XXX Not full-proof, but should be enough here! +PYGETTEXT_CONTEXTS = "#define\\s+(BLF_I18NCONTEXT_[A-Z_0-9]+)\\s+\"([^\"]*)\"" + +# Keywords' regex. +# XXX Most unfortunately, we can't use named backreferences inside character sets, +# which makes the regexes even more twisty... :/ +_str_base = ( + # Match void string + "(?P<{_}1>[\"'])(?P={_}1)" # Get opening quote (' or "), and closing immediately. + "|" + # Or match non-void string + "(?P<{_}2>[\"'])" # Get opening quote (' or "). + "(?{capt}(?:" + # This one is for crazy things like "hi \\\\\" folks!"... + r"(?:(?!<\\)(?:\\\\)*\\(?=(?P={_}2)))|" + # The most common case. + ".(?!(?P={_}2))" + ")+.)" # Don't forget the last char! + "(?P={_}2)" # And closing quote. +) +str_clean_re = _str_base.format(_="g", capt="P<clean>") +# Here we have to consider two different cases (empty string and other). +_str_whole_re = ( + _str_base.format(_="{_}1_", capt=":") + + # Optional loop start, this handles "split" strings... + "(?:(?<=[\"'])\\s*(?=[\"'])(?:" + + _str_base.format(_="{_}2_", capt=":") + + # End of loop. + "))*" +) +_ctxt_re = r"(?P<ctxt_raw>(?:" + _str_whole_re.format(_="_ctxt") + r")|(?:[A-Z_0-9]+))" +_msg_re = r"(?P<msg_raw>" + _str_whole_re.format(_="_msg") + r")" +PYGETTEXT_KEYWORDS = (() + + tuple((r"{}\(\s*" + _msg_re + r"\s*\)").format(it) + for it in ("IFACE_", "TIP_", "N_")) + + tuple((r"{}\(\s*" + _ctxt_re + r"\s*,\s*"+ _msg_re + r"\s*\)").format(it) + for it in ("CTX_IFACE_", "CTX_TIP_", "CTX_N_")) +) +#GETTEXT_KEYWORDS = ("IFACE_", "CTX_IFACE_:1c,2", "TIP_", "CTX_TIP_:1c,2", +# "N_", "CTX_N_:1c,2") + +# Should po parser warn when finding a first letter not capitalized? +WARN_MSGID_NOT_CAPITALIZED = True + +# Strings that should not raise above warning! +WARN_MSGID_NOT_CAPITALIZED_ALLOWED = { + "", # Simplifies things... :p + "sin(x) / x", + "fBM", + "sqrt(x*x+y*y+z*z)", + "iTaSC", + "bItasc", + "px", + "mm", + "fStop", + "sRGB", + "iso-8859-15", + "utf-8", + "ascii", + "re", + "y", + "ac3", + "flac", + "mkv", + "mp2", + "mp3", + "ogg", + "wav", + "iTaSC parameters", + "vBVH", + "rv", + "en_US", + "fr_FR", + "it_IT", + "ru_RU", + "zh_CN", + "es", + "zh_TW", + "ar_EG", + "pt", + "bg_BG", + "ca_AD", + "hr_HR", + "cs_CZ", + "nl_NL", + "fi_FI", + "de_DE", + "el_GR", + "id_ID", + "ja_JP", + "ky_KG", + "ko_KR", + "ne_NP", + "fa_IR", + "pl_PL", + "ro_RO", + "sr_RS", + "sr_RS@latin", + "sv_SE", + "uk_UA", + "tr_TR", + "hu_HU", + "available with", # Is part of multi-line msg. + "virtual parents", # Is part of multi-line msg. + "description", # Addons' field. :/ + "location", # Addons' field. :/ + "author", # Addons' field. :/ + "in memory to enable editing!", # Is part of multi-line msg. + "iScale", + "dx", + "p0", + "res", +} + + +############################################################################### +# PATHS +############################################################################### + +# The tools path, should be OK. +TOOLS_DIR = os.path.join(os.path.dirname(__file__)) + +# The Python3 executable.You’ll likely have to edit it in your user_settings.py +# if you’re under Windows. +PYTHON3_EXEC = "python3" + +# The Blender executable! +# This is just an example, you’ll most likely have to edit it in your +# user_settings.py! +BLENDER_EXEC = os.path.abspath(os.path.join(TOOLS_DIR, "..", "..", "..", "..", + "blender")) + +# The xgettext tool. You’ll likely have to edit it in your user_settings.py +# if you’re under Windows. +GETTEXT_XGETTEXT_EXECUTABLE = "xgettext" + +# The gettext msgmerge tool. You’ll likely have to edit it in your +# user_settings.py if you’re under Windows. +GETTEXT_MSGMERGE_EXECUTABLE = "msgmerge" + +# The gettext msgfmt "compiler". You’ll likely have to edit it in your +# user_settings.py if you’re under Windows. +GETTEXT_MSGFMT_EXECUTABLE = "msgfmt" + +# The svn binary... You’ll likely have to edit it in your +# user_settings.py if you’re under Windows. +SVN_EXECUTABLE = "svn" + +# The FriBidi C compiled library (.so under Linux, .dll under windows...). +# You’ll likely have to edit it in your user_settings.py if you’re under +# Windows., e.g. using the included one: +# FRIBIDI_LIB = os.path.join(TOOLS_DIR, "libfribidi.dll") +FRIBIDI_LIB = "libfribidi.so.0" + +# The name of the (currently empty) file that must be present in a po's +# directory to enable rtl-preprocess. +RTL_PREPROCESS_FILE = "is_rtl" + +# The Blender source root path. +# This is just an example, you’ll most likely have to override it in your +# user_settings.py! +SOURCE_DIR = os.path.abspath(os.path.join(TOOLS_DIR, "..", "..", "..", "..", + "..", "..", "blender_msgs")) + +# The bf-translation repository (you'll likely have to override this in your +# user_settings.py). +I18N_DIR = os.path.abspath(os.path.join(TOOLS_DIR, "..", "..", "..", "..", + "..", "..", "i18n")) + +# The /branches path (overriden in bf-translation's i18n_override_settings.py). +BRANCHES_DIR = os.path.join(I18N_DIR, "branches") + +# The /trunk path (overriden in bf-translation's i18n_override_settings.py). +TRUNK_DIR = os.path.join(I18N_DIR, "trunk") + +# The /trunk/po path (overriden in bf-translation's i18n_override_settings.py). +TRUNK_PO_DIR = os.path.join(TRUNK_DIR, "po") + +# The /trunk/mo path (overriden in bf-translation's i18n_override_settings.py). +TRUNK_MO_DIR = os.path.join(TRUNK_DIR, "locale") + +# The file storing Blender-generated messages. +FILE_NAME_MESSAGES = os.path.join(TRUNK_PO_DIR, "messages.txt") + +# The Blender source path to check for i18n macros. +POTFILES_SOURCE_DIR = os.path.join(SOURCE_DIR, "source") + +# The "source" file storing which files should be processed by xgettext, +# used to create FILE_NAME_POTFILES +FILE_NAME_SRC_POTFILES = os.path.join(TRUNK_PO_DIR, "_POTFILES.in") + +# The final (generated) file storing which files +# should be processed by xgettext. +FILE_NAME_POTFILES = os.path.join(TRUNK_PO_DIR, "POTFILES.in") + +# The template messages file. +FILE_NAME_POT = os.path.join(TRUNK_PO_DIR, ".".join((DOMAIN, "pot"))) + +# Other py files that should be searched for ui strings, relative to SOURCE_DIR. +# Needed for Cycles, currently... +CUSTOM_PY_UI_FILES = [os.path.join("intern", "cycles", "blender", + "addon", "ui.py"), + ] + + +# A cache storing validated msgids, to avoid re-spellchecking them. +SPELL_CACHE = os.path.join("/tmp", ".spell_cache") + + +# Custom override settings must be one dir above i18n tools itself! +import sys +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) +try: + from i18n_override_settings import * +except ImportError: # If no i18n_override_settings available, it’s no error! + pass + +# Override with custom user settings, if available. +try: + from user_settings import * +except ImportError: # If no user_settings available, it’s no error! + pass diff --git a/release/scripts/modules/bl_i18n_utils/spell_check_utils.py b/release/scripts/modules/bl_i18n_utils/spell_check_utils.py new file mode 100644 index 00000000000..e5b065c7ceb --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/spell_check_utils.py @@ -0,0 +1,503 @@ +# ##### 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 ##### + +# <pep8 compliant> + +import re + + +_valid_before = "(?<=[\\s*'\"`])|(?<=[a-zA-Z][/-])|(?<=^)" +_valid_after = "(?=[\\s'\"`.!?,;:])|(?=[/-]\\s*[a-zA-Z])|(?=$)" +_valid_words = "(?:{})(?:(?:[A-Z]+[a-z]*)|[A-Z]*|[a-z]*)(?:{})".format(_valid_before, _valid_after) +_reg = re.compile(_valid_words) + + +def split_words(text): + return [w for w in _reg.findall(text) if w] + + +# These must be all lower case for comparisons +dict_uimsgs = { + # OK words + "aren", # aren't + "betweens", # yuck! in-betweens! + "boolean", "booleans", + "decrement", + "derivate", + "doesn", # doesn't + "fader", + "hoc", # ad-hoc + "indices", + "iridas", + "isn", # isn't + "iterable", + "kyrgyz", + "latin", + "merchantability", + "mplayer", + "vertices", + + # Merged words + "addon", "addons", + "antialiasing", + "arcsine", "arccosine", "arctangent", + "autoclip", + "autocomplete", + "autoname", + "autosave", + "autoscale", + "autosmooth", + "autosplit", + "backface", "backfacing", + "backimage", + "backscattered", + "bandnoise", + "bindcode", + "bitrate", + "blendin", + "bonesize", + "boundbox", + "boxpack", + "buffersize", + "builtin", "builtins", + "chunksize", + "de", + "defocus", + "denoise", + "despill", "despilling", + "filebrowser", + "filelist", + "filename", "filenames", + "filepath", "filepaths", + "forcefield", "forcefields", + "fulldome", "fulldomes", + "fullscreen", + "gridline", + "hemi", + "inscatter", "inscattering", + "lightless", + "lookup", "lookups", + "mathutils", + "midlevel", + "midground", + "mixdown", + "multi", + "multifractal", + "multires", "multiresolution", + "multisampling", + "multitexture", + "namespace", + "keyconfig", + "playhead", + "polyline", + "popup", "popups", + "pre", + "precalculate", + "prefetch", + "premultiply", "premultiplied", + "prepass", + "prepend", + "preprocess", "preprocessing", + "preseek", + "readonly", + "realtime", + "rekey", + "remesh", + "reprojection", + "resize", + "restpose", + "retarget", "retargets", "retargeting", "retargeted", + "ringnoise", + "rolloff", + "screencast", "screenshot", "screenshots", + "selfcollision", + "singletexture", + "startup", + "stateful", + "starfield", + "subflare", "subflares", + "subframe", "subframes", + "subclass", "subclasses", "subclassing", + "subdirectory", "subdirectories", "subdir", "subdirs", + "submodule", "submodules", + "subpath", + "subsize", + "substep", "substeps", + "targetless", + "textbox", "textboxes", + "tilemode", + "timestamp", "timestamps", + "timestep", "timesteps", + "un", + "unbake", + "uncomment", + "undeformed", + "undistort", "undistortion", + "ungroup", + "unhide", + "unindent", + "unkeyed", + "unpremultiply", + "unprojected", + "unreacted", + "unregister", + "unselected", + "unsubdivided", + "unshadowed", + "unspill", + "unstitchable", + "vectorscope", + "whitespace", + "worldspace", + "workflow", + + # Neologisms, slangs + "affectable", + "automagic", "automagically", + "blobby", + "blockiness", "blocky", + "collider", "colliders", + "deformer", "deformers", + "determinator", + "editability", + "keyer", + "lacunarity", + "numerics", + "occluder", + "passepartout", + "perspectively", + "polygonization", + "selectability", + "slurph", + "stitchable", + "trackability", + "transmissivity", + "rasterized", "rasterization", + "renderer", "renderable", "renderability", + + # Abbreviations + "aero", + "amb", + "anim", + "bool", + "calc", + "config", "configs", + "const", + "coord", "coords", + "degr", + "dof", + "dupli", "duplis", + "eg", + "esc", + "expr", + "fac", + "fra", + "frs", + "grless", + "http", + "init", + "kbit", + "lensdist", + "loc", "rot", "pos", + "lorem", + "luma", + "multicam", + "num", + "ok", + "orco", + "ortho", + "persp", + "pref", "prefs", + "prev", + "param", + "premul", + "quad", "quads", + "quat", "quats", + "recalc", "recalcs", + "refl", + "spec", + "struct", "structs", + "tex", + "tri", "tris", + "uv", "uvs", "uvw", "uw", "uvmap", + "vec", + "vert", "verts", + "vis", + "xyz", "xzy", "yxz", "yzx", "zxy", "zyx", + "xy", "xz", "yx", "yz", "zx", "zy", + + # General computer/science terms + "boid", "boids", + "equisolid", + "euler", "eulers", + "hashable", + "intrinsics", + "isosurface", + "jitter", "jittering", "jittered", + "keymap", "keymaps", + "lambertian", + "laplacian", + "metadata", + "nand", "xnor", + "normals", + "numpad", + "octree", + "opengl", + "pulldown", "pulldowns", + "quantized", + "samplerate", + "scrollback", + "scrollbar", + "scroller", + "searchable", + "spacebar", + "tooltip", "tooltips", + "trackpad", + "unicode", + "viewport", "viewports", + "viscoelastic", + "wildcard", "wildcards", + + # General computer graphics terms + "anaglyph", + "bezier", "beziers", + "bicubic", + "bilinear", + "blackpoint", "whitepoint", + "blinn", + "bokeh", + "catadioptric", + "centroid", + "chrominance", + "codec", "codecs", + "collada", + "compositing", + "crossfade", + "deinterlace", + "dropoff", + "eigenvectors", + "equirectangular", + "fisheye", + "framerate", + "gimbal", + "grayscale", + "icosphere", + "lightmap", + "lossless", "lossy", + "midtones", + "mipmap", "mipmaps", "mip", + "ngon", "ngons", + "nurb", "nurbs", + "perlin", + "phong", + "radiosity", + "raytrace", "raytracing", "raytraced", + "renderfarm", + "shader", "shaders", + "specular", "specularity", + "spillmap", + "sobel", + "tonemap", + "toon", + "timecode", + "voronoi", + "voxel", "voxels", + "wireframe", + "zmask", + "ztransp", + + # Blender terms + "bbone", + "breakdowner", + "bspline", + "bweight", + "colorband", + "datablock", "datablocks", + "dopesheet", + "dupliface", "duplifaces", + "dupliframe", "dupliframes", + "dupliobject", "dupliob", + "dupligroup", + "duplivert", + "editbone", + "editmode", + "fcurve", "fcurves", + "fluidsim", + "frameserver", + "enum", + "keyframe", "keyframes", "keyframing", "keyframed", + "metaball", "metaballs", + "metaelement", "metaelements", + "metastrip", "metastrips", + "movieclip", + "nabla", + "navmesh", + "outliner", + "paintmap", "paintmaps", + "polygroup", "polygroups", + "poselib", + "pushpull", + "pyconstraint", "pyconstraints", + "shapekey", "shapekeys", + "shrinkfatten", + "shrinkwrap", + "softbody", + "stucci", + "sunsky", + "subsurf", + "texface", + "timeline", "timelines", + "tosphere", + "vcol", "vcols", + "vgroup", "vgroups", + "vinterlace", + "wetmap", "wetmaps", + "wpaint", + + # Algorithm names + "beckmann", + "catmull", + "catrom", + "chebychev", + "kutta", + "lennard", + "minkowsky", + "minnaert", + "musgrave", + "nayar", + "netravali", + "oren", + "prewitt", + "runge", + "verlet", + "worley", + + # Acronyms + "aa", "msaa", + "api", + "asc", "cdl", + "ascii", + "atrac", + "bw", + "ccd", + "cmd", + "cpus", + "ctrl", + "cw", "ccw", + "dev", + "djv", + "dpi", + "dvar", + "dx", + "fh", + "fov", + "fft", + "gfx", + "gl", + "glsl", + "gpl", + "gpu", "gpus", + "hc", + "hdr", + "hh", "mm", "ss", "ff", # hh:mm:ss:ff timecode + "hsv", "hsva", + "id", + "itu", + "lhs", + "lmb", "mmb", "rmb", + "mux", + "ndof", + "ppc", + "px", + "qmc", + "rgb", "rgba", + "rhs", + "rv", + "sdl", + "sl", + "smpte", + "svn", + "ui", + "unix", + "vbo", "vbos", + "ycc", "ycca", + "yuv", "yuva", + + # Blender acronyms + "bge", + "bli", + "bvh", + "dbvt", + "dop", # BLI K-Dop BVH + "ik", + "nla", + "qbvh", + "rna", + "rvo", + "simd", + "sph", + "svbvh", + + # CG acronyms + "ao", + "bsdf", + "ior", + "mocap", + + # Files types/formats + "avi", + "attrac", + "autodesk", + "bmp", + "btx", + "cineon", + "dpx", + "dxf", + "eps", + "exr", + "fbx", + "ffmpeg", + "flac", + "gzip", + "ico", + "jpg", "jpeg", + "matroska", + "mdd", + "mkv", + "mpeg", "mjpeg", + "mtl", + "ogg", + "openjpeg", + "piz", + "png", + "po", + "quicktime", + "rle", + "sgi", + "stl", + "svg", + "targa", "tga", + "tiff", + "theora", + "vorbis", + "wav", + "xiph", + "xml", + "xna", + "xvid", +} diff --git a/release/scripts/modules/bl_i18n_utils/update_branches.py b/release/scripts/modules/bl_i18n_utils/update_branches.py new file mode 100755 index 00000000000..1a856b14944 --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/update_branches.py @@ -0,0 +1,104 @@ +#!/usr/bin/python3 + +# ***** 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 ***** + +# <pep8 compliant> + +# Update all branches: +# * Generate a temp messages.txt file. +# * Use it to generate a temp .pot file. +# * Use it to update all .po’s in /branches. + +import subprocess +import os +import sys +import tempfile + +import settings + +PY3 = settings.PYTHON3_EXEC + +def main(): + import argparse + parser = argparse.ArgumentParser(description="" \ + "Update all branches:\n" \ + "* Generate a temp messages.txt file.\n" \ + "* Use it to generate a temp .pot file.\n" \ + "* Use it to update all .po’s in /branches.") + parser.add_argument('--pproc-contexts', action="store_true", + help="Pre-process po’s to avoid having plenty of " + "fuzzy msgids just because a context was " + "added/changed!") + parser.add_argument('-c', '--no_checks', default=True, + action="store_false", + help="No checks over UI messages.") + parser.add_argument('-a', '--add', action="store_true", + help="Add missing po’s (useful only when one or " \ + "more languages are given!).") + parser.add_argument('langs', metavar='ISO_code', nargs='*', + help="Restrict processed languages to those.") + args = parser.parse_args() + + + ret = 0 + + # Generate a temp messages file. + dummy, msgfile = tempfile.mkstemp(suffix=".txt", + prefix="blender_messages_") + os.close(dummy) + cmd = (PY3, "./update_msg.py", "-o", msgfile) + t = subprocess.call(cmd) + if t: + ret = t + + # Regenerate POTFILES.in. +# cmd = (PY3, "./update_potinput.py") +# t = subprocess.call(cmd) +# if t: +# ret = t + + # Generate a temp pot file. + dummy, potfile = tempfile.mkstemp(suffix=".pot", + prefix="blender_pot_") + os.close(dummy) + cmd = [PY3, "./update_pot.py", "-i", msgfile, "-o", potfile] + if not args.no_checks: + cmd.append("-c") + t = subprocess.call(cmd) + if t: + ret = t + + # Update branches’ po files. + cmd = [PY3, "./update_po.py", "-i", potfile] + if args.langs: + if args.add: + cmd.append("-a") + cmd += args.langs + if args.pproc_contexts: + cmd.append("--pproc-contexts") + t = subprocess.call(cmd) + if t: + ret = t + + return ret + + +if __name__ == "__main__": + print("\n\n *** Running {} *** \n".format(__file__)) + sys.exit(main()) diff --git a/release/scripts/modules/bl_i18n_utils/update_mo.py b/release/scripts/modules/bl_i18n_utils/update_mo.py new file mode 100755 index 00000000000..9804eb8ce34 --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/update_mo.py @@ -0,0 +1,91 @@ +#!/usr/bin/python3 + +# ***** 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 ***** + +# <pep8 compliant> + +# Create or update mo’s under /trunk/locale/… + +import subprocess +import os +import sys + +import settings +import utils + + +GETTEXT_MSGFMT_EXECUTABLE = settings.GETTEXT_MSGFMT_EXECUTABLE + +SOURCE_DIR = settings.SOURCE_DIR +TRUNK_MO_DIR = settings.TRUNK_MO_DIR +TRUNK_PO_DIR = settings.TRUNK_PO_DIR + +DOMAIN = settings.DOMAIN + + +def process_po(po, lang): + mo_dir = os.path.join(TRUNK_MO_DIR, lang, "LC_MESSAGES") + + # Create dirs if not existing! + os.makedirs(mo_dir, exist_ok = True) + # show stats + cmd = (GETTEXT_MSGFMT_EXECUTABLE, + "--statistics", + po, + "-o", + os.path.join(mo_dir, ".".join((DOMAIN, "mo"))), + ) + + print("Running ", " ".join(cmd)) + ret = subprocess.call(cmd) + print("Finished.") + return ret + + +def main(): + import argparse + parser = argparse.ArgumentParser(description="Create or update mo’s " \ + "under {}.".format(TRUNK_MO_DIR)) + parser.add_argument('langs', metavar='ISO_code', nargs='*', + help="Restrict processed languages to those.") + args = parser.parse_args() + + ret = 0 + + if args.langs: + for lang in args.langs: + po = os.path.join(TRUNK_PO_DIR, ".".join((lang, "po"))) + if os.path.exists(po): + t = process_po(po, lang) + if t: + ret = t + else: + for po in os.listdir(TRUNK_PO_DIR): + if po.endswith(".po") and not po.endswith("_raw.po"): + lang = os.path.basename(po)[:-3] + po = os.path.join(TRUNK_PO_DIR, po) + t = process_po(po, lang) + if t: + ret = t + return ret + + +if __name__ == "__main__": + print("\n\n *** Running {} *** \n".format(__file__)) + sys.exit(main()) diff --git a/release/scripts/modules/bl_i18n_utils/update_msg.py b/release/scripts/modules/bl_i18n_utils/update_msg.py new file mode 100755 index 00000000000..e5154632cfe --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/update_msg.py @@ -0,0 +1,69 @@ +#!/usr/bin/python3 + +# ***** 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 ***** + +# <pep8-80 compliant> + +# Write out messages.txt from Blender. + +import os +import sys +import subprocess + +import settings + + +BLENDER_ARGS = [ + settings.BLENDER_EXEC, + "--background", + "--factory-startup", + "--python", + os.path.join(settings.TOOLS_DIR, "bl_process_msg.py"), + "--", + "-m", +] + + +def main(): + import argparse + parser = argparse.ArgumentParser(description="Write out messages.txt " \ + "from Blender.") + parser.add_argument('-c', '--no_checks', default=True, + action="store_false", + help="No checks over UI messages.") + parser.add_argument('-b', '--blender', help="Blender executable path.") + parser.add_argument('-o', '--output', help="Output messages file path.") + args = parser.parse_args() + if args.blender: + BLENDER_ARGS[0] = args.blender + if not args.no_checks: + BLENDER_ARGS.append("-c") + if args.output: + BLENDER_ARGS.append("-o") + BLENDER_ARGS.append(args.output) + ret = subprocess.call(BLENDER_ARGS) + + return ret + + +if __name__ == "__main__": + print("\n\n *** Running {} *** \n".format(__file__)) + ret = main() + if ret: + raise(Exception(ret)) diff --git a/release/scripts/modules/bl_i18n_utils/update_po.py b/release/scripts/modules/bl_i18n_utils/update_po.py new file mode 100755 index 00000000000..042b46c03f2 --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/update_po.py @@ -0,0 +1,166 @@ +#!/usr/bin/python3 + +# ***** 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 ***** + +# <pep8 compliant> + +# Update po’s in the branches from blender.pot in /trunk/po dir. + +import subprocess +import os +import sys +from codecs import open +import shutil + +import settings +import utils + +GETTEXT_MSGMERGE_EXECUTABLE = settings.GETTEXT_MSGMERGE_EXECUTABLE +BRANCHES_DIR = settings.BRANCHES_DIR +TRUNK_PO_DIR = settings.TRUNK_PO_DIR +FILE_NAME_POT = settings.FILE_NAME_POT + + +def pproc_newcontext_po(po, pot_messages, pot_stats): + print("Adding new contexts to {}...".format(po)) + messages, state, stats = utils.parse_messages(po) + known_ctxt = stats["contexts"] + print("Already known (present) context(s): {}".format(str(known_ctxt))) + + new_ctxt = set() + added = 0 + # Only use valid already translated messages! + allowed_keys = state["trans_msg"] - state["fuzzy_msg"] - state["comm_msg"] + for key in pot_messages.keys(): + ctxt, msgid = key + if ctxt in known_ctxt: + continue + new_ctxt.add(ctxt) + for t_ctxt in known_ctxt: + # XXX The first match will win, this might not be optimal... + t_key = (t_ctxt, msgid) + if t_key in allowed_keys: + # Wrong comments (sources) will be removed by msgmerge... + messages[key] = messages[t_key] + messages[key]["msgctxt_lines"] = [ctxt] + added += 1 + + utils.write_messages(po, messages, state["comm_msg"], state["fuzzy_msg"]) + print("Finished!\n {} new context(s) was/were added {}, adding {} new " + "messages.\n".format(len(new_ctxt), str(new_ctxt), added)) + return 0 + + +def process_po(po, lang): + # update po file + cmd = (GETTEXT_MSGMERGE_EXECUTABLE, + "--update", + "--no-wrap", + "--backup=none", + "--lang={}".format(lang), + po, + FILE_NAME_POT, + ) + + print("Updating {}...".format(po)) + print("Running ", " ".join(cmd)) + ret = subprocess.call(cmd) + print("Finished!\n") + return ret + + +def main(): + import argparse + parser = argparse.ArgumentParser(description="Write out messages.txt " + "from Blender.") + parser.add_argument('-t', '--trunk', action="store_true", + help="Update po’s in /trunk/po rather than /branches.") + parser.add_argument('-i', '--input', metavar="File", + help="Input pot file path.") + parser.add_argument('--pproc-contexts', action="store_true", + help="Pre-process po’s to avoid having plenty of " + "fuzzy msgids just because a context was " + "added/changed!") + parser.add_argument('-a', '--add', action="store_true", + help="Add missing po’s (useful only when one or " + "more languages are given!).") + parser.add_argument('langs', metavar='ISO_code', nargs='*', + help="Restrict processed languages to those.") + args = parser.parse_args() + + if args.input: + global FILE_NAME_POT + FILE_NAME_POT = args.input + ret = 0 + + if args.pproc_contexts: + _ctxt_proc = pproc_newcontext_po + pot_messages, _a, pot_stats = utils.parse_messages(FILE_NAME_POT) + else: + _ctxt_proc = lambda a, b, c: 0 + pot_messages, pot_stats = None, None + + if args.langs: + for lang in args.langs: + if args.trunk: + dr = TRUNK_PO_DIR + po = os.path.join(dr, ".".join((lang, "po"))) + else: + dr = os.path.join(BRANCHES_DIR, lang) + po = os.path.join(dr, ".".join((lang, "po"))) + if args.add: + if not os.path.exists(dr): + os.makedirs(dr) + if not os.path.exists(po): + shutil.copy(FILE_NAME_POT, po) + if args.add or os.path.exists(po): + t = _ctxt_proc(po, pot_messages, pot_stats) + if t: + ret = t + t = process_po(po, lang) + if t: + ret = t + elif args.trunk: + for po in os.listdir(TRUNK_PO_DIR): + if po.endswith(".po"): + lang = os.path.basename(po)[:-3] + po = os.path.join(TRUNK_PO_DIR, po) + t = _ctxt_proc(po, pot_messages, pot_stats) + if t: + ret = t + t = process_po(po, lang) + if t: + ret = t + else: + for lang in os.listdir(BRANCHES_DIR): + po = os.path.join(BRANCHES_DIR, lang, ".".join((lang, "po"))) + if os.path.exists(po): + t = _ctxt_proc(po, pot_messages, pot_stats) + if t: + ret = t + t = process_po(po, lang) + if t: + ret = t + + return ret + + +if __name__ == "__main__": + print("\n\n *** Running {} *** \n".format(__file__)) + sys.exit(main()) diff --git a/release/scripts/modules/bl_i18n_utils/update_pot.py b/release/scripts/modules/bl_i18n_utils/update_pot.py new file mode 100755 index 00000000000..ceef51aa072 --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/update_pot.py @@ -0,0 +1,314 @@ +#!/usr/bin/python3 + +# ***** 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 ***** + +# <pep8 compliant> + +# Update blender.pot file from messages.txt + +import subprocess +import os +import sys +import re +#from codecs import open +import tempfile +import argparse +import time +import pickle + +import settings +import utils + + +COMMENT_PREFIX = settings.COMMENT_PREFIX +COMMENT_PREFIX_SOURCE = settings.COMMENT_PREFIX_SOURCE +CONTEXT_PREFIX = settings.CONTEXT_PREFIX +FILE_NAME_MESSAGES = settings.FILE_NAME_MESSAGES +#FILE_NAME_POTFILES = settings.FILE_NAME_POTFILES +FILE_NAME_POT = settings.FILE_NAME_POT +SOURCE_DIR = settings.SOURCE_DIR +POTFILES_DIR = settings.POTFILES_SOURCE_DIR +SRC_POTFILES = settings.FILE_NAME_SRC_POTFILES + +#GETTEXT_XGETTEXT_EXECUTABLE = settings.GETTEXT_XGETTEXT_EXECUTABLE +#GETTEXT_KEYWORDS = settings.GETTEXT_KEYWORDS +CONTEXT_DEFAULT = settings.CONTEXT_DEFAULT +PYGETTEXT_ALLOWED_EXTS = settings.PYGETTEXT_ALLOWED_EXTS + +SVN_EXECUTABLE = settings.SVN_EXECUTABLE + +WARN_NC = settings.WARN_MSGID_NOT_CAPITALIZED +NC_ALLOWED = settings.WARN_MSGID_NOT_CAPITALIZED_ALLOWED + +SPELL_CACHE = settings.SPELL_CACHE + + +#def generate_valid_potfiles(final_potfiles): +# "Generates a temp potfiles.in with aboslute paths." +# with open(FILE_NAME_POTFILES, 'r', 'utf-8') as f, \ +# open(final_potfiles, 'w', 'utf-8') as w: +# for line in f: +# line = utils.stripeol(line) +# if line: +# w.write("".join((os.path.join(SOURCE_DIR, +# os.path.normpath(line)), "\n"))) + +# Do this only once! +# Get contexts defined in blf. +CONTEXTS = {} +with open(os.path.join(SOURCE_DIR, settings.PYGETTEXT_CONTEXTS_DEFSRC)) as f: + reg = re.compile(settings.PYGETTEXT_CONTEXTS) + f = f.read() + # This regex is supposed to yield tuples + # (key=C_macro_name, value=C_string). + CONTEXTS = dict(m.groups() for m in reg.finditer(f)) + +# Build regexes to extract messages (with optinal contexts) from C source. +pygettexts = tuple(re.compile(r).search + for r in settings.PYGETTEXT_KEYWORDS) +_clean_str = re.compile(settings.str_clean_re).finditer +clean_str = lambda s: "".join(m.group("clean") for m in _clean_str(s)) + +def check_file(path, rel_path, messages): + with open(path, encoding="utf-8") as f: + f = f.read() + for srch in pygettexts: + m = srch(f) + line = pos =0 + while m: + d = m.groupdict() + # Context. + ctxt = d.get("ctxt_raw") + if ctxt: + if ctxt in CONTEXTS: + ctxt = CONTEXTS[ctxt] + elif '"' in ctxt or "'" in ctxt: + ctxt = clean_str(ctxt) + else: + print("WARNING: raw context “{}†couldn’t be resolved!" + "".format(ctxt)) + ctxt = CONTEXT_DEFAULT + else: + ctxt = CONTEXT_DEFAULT + # Message. + msg = d.get("msg_raw") + if msg: + if '"' in msg or "'" in msg: + msg = clean_str(msg) + else: + print("WARNING: raw message “{}†couldn’t be resolved!" + "".format(msg)) + msg = "" + else: + msg = "" + # Line. + line += f[pos:m.start()].count('\n') + # And we are done for this item! + messages.setdefault((ctxt, msg), []).append(":".join((rel_path, str(line)))) + pos = m.end() + line += f[m.start():pos].count('\n') + m = srch(f, pos) + + +def py_xgettext(messages): + with open(SRC_POTFILES) as src: + forbidden = set() + forced = set() + for l in src: + if l[0] == '-': + forbidden.add(l[1:].rstrip('\n')) + elif l[0] != '#': + forced.add(l.rstrip('\n')) + for root, dirs, files in os.walk(POTFILES_DIR): + if "/.svn" in root: + continue + for fname in files: + if os.path.splitext(fname)[1] not in PYGETTEXT_ALLOWED_EXTS: + continue + path = os.path.join(root, fname) + rel_path = os.path.relpath(path, SOURCE_DIR) + if rel_path in forbidden | forced: + continue + check_file(path, rel_path, messages) + for path in forced: + if os.path.exists(path): + check_file(os.path.join(SOURCE_DIR, path), path, messages) + + +# Spell checking! +import enchant +dict_spelling = enchant.Dict("en_US") + +from spell_check_utils import (dict_uimsgs, + split_words, + ) + +_spell_checked = set() +def spell_check(txt, cache): + ret = [] + + if cache is not None and txt in cache: + return ret + + for w in split_words(txt): + w_lower = w.lower() + if w_lower in dict_uimsgs | _spell_checked: + continue + if not dict_spelling.check(w): + ret.append("{}: suggestions are ({})" + .format(w, "'" + "', '".join(dict_spelling.suggest(w)) + + "'")) + else: + _spell_checked.add(w_lower) + + if not ret: + if cache is not None: + cache.add(txt) + + return ret + + +def get_svnrev(): + cmd = [SVN_EXECUTABLE, + "info", + "--xml", + SOURCE_DIR, + ] + xml = subprocess.check_output(cmd) + return re.search(b'revision="(\d+)"', xml).group(1) + + +def gen_empty_pot(): + blender_rev = get_svnrev() + utctime = time.gmtime() + time_str = time.strftime("%Y-%m-%d %H:%M+0000", utctime) + year_str = time.strftime("%Y", utctime) + + return utils.gen_empty_messages(blender_rev, time_str, year_str) + + +def merge_messages(msgs, states, messages, do_checks, spell_cache): + num_added = num_present = 0 + for (context, msgid), srcs in messages.items(): + if do_checks: + err = spell_check(msgid, spell_cache) + if err: + print("WARNING: spell check failed on “" + msgid + "â€:") + print("\t\t" + "\n\t\t".join(err)) + print("\tFrom:\n\t\t" + "\n\t\t".join(srcs)) + + # Escape some chars in msgid! + msgid = msgid.replace("\\", "\\\\") + msgid = msgid.replace("\"", "\\\"") + msgid = msgid.replace("\t", "\\t") + + srcs = [COMMENT_PREFIX_SOURCE + s for s in srcs] + + key = (context, msgid) + if key not in msgs: + msgs[key] = {"msgid_lines": [msgid], + "msgstr_lines": [""], + "comment_lines": srcs, + "msgctxt_lines": [context]} + num_added += 1 + else: + # We need to merge comments! + msgs[key]["comment_lines"].extend(srcs) + num_present += 1 + + return num_added, num_present + + +def main(): + parser = argparse.ArgumentParser(description="Update blender.pot file " \ + "from messages.txt") + parser.add_argument('-w', '--warning', action="store_true", + help="Show warnings.") + parser.add_argument('-i', '--input', metavar="File", + help="Input messages file path.") + parser.add_argument('-o', '--output', metavar="File", + help="Output pot file path.") + + args = parser.parse_args() + if args.input: + global FILE_NAME_MESSAGES + FILE_NAME_MESSAGES = args.input + if args.output: + global FILE_NAME_POT + FILE_NAME_POT = args.output + + print("Running fake py gettext…") + # Not using any more xgettext, simpler to do it ourself! + messages = {} + py_xgettext(messages) + print("Finished, found {} messages.".format(len(messages))) + + if SPELL_CACHE and os.path.exists(SPELL_CACHE): + with open(SPELL_CACHE, 'rb') as f: + spell_cache = pickle.load(f) + else: + spell_cache = set() + print(len(spell_cache)) + + print("Generating POT file {}…".format(FILE_NAME_POT)) + msgs, states = gen_empty_pot() + tot_messages, _a = merge_messages(msgs, states, messages, + True, spell_cache) + + # add messages collected automatically from RNA + print("\tMerging RNA messages from {}…".format(FILE_NAME_MESSAGES)) + messages = {} + with open(FILE_NAME_MESSAGES, encoding="utf-8") as f: + srcs = [] + context = "" + for line in f: + line = utils.stripeol(line) + + if line.startswith(COMMENT_PREFIX): + srcs.append(line[len(COMMENT_PREFIX):].strip()) + elif line.startswith(CONTEXT_PREFIX): + context = line[len(CONTEXT_PREFIX):].strip() + else: + key = (context, line) + messages[key] = srcs + srcs = [] + context = "" + num_added, num_present = merge_messages(msgs, states, messages, + True, spell_cache) + tot_messages += num_added + print("\tMerged {} messages ({} were already present)." + "".format(num_added, num_present)) + + # Write back all messages into blender.pot. + utils.write_messages(FILE_NAME_POT, msgs, states["comm_msg"], + states["fuzzy_msg"]) + + print(len(spell_cache)) + if SPELL_CACHE and spell_cache: + with open(SPELL_CACHE, 'wb') as f: + pickle.dump(spell_cache, f) + + print("Finished, total: {} messages!".format(tot_messages - 1)) + + return 0 + + +if __name__ == "__main__": + print("\n\n *** Running {} *** \n".format(__file__)) + sys.exit(main()) diff --git a/release/scripts/modules/bl_i18n_utils/update_trunk.py b/release/scripts/modules/bl_i18n_utils/update_trunk.py new file mode 100755 index 00000000000..f4a2e0b3f8f --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/update_trunk.py @@ -0,0 +1,132 @@ +#!/usr/bin/python3 + +# ***** 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 ***** + +# <pep8 compliant> + +# Update trunk from branches: +# * Remove po’s in trunk. +# * Copy po’s from branches advanced enough. +# * Clean po’s in trunk. +# * Compile po’s in trunk in mo’s, keeping track of those failing. +# * Remove po’s, mo’s (and their dir’s) that failed to compile or +# are no more present in trunk. + +import subprocess +import os +import sys +import shutil + +import settings + +TRUNK_PO_DIR = settings.TRUNK_PO_DIR +TRUNK_MO_DIR = settings.TRUNK_MO_DIR + +PY3 = settings.PYTHON3_EXEC + + +def main(): + import argparse + parser = argparse.ArgumentParser(description="" \ + "Update trunk from branches:\n" \ + "* Remove po’s in trunk.\n" \ + "* Copy po’s from branches advanced enough.\n" \ + "* Clean po’s in trunk.\n" \ + "* Compile po’s in trunk in mo’s, keeping " \ + "track of those failing.\n" \ + "* Remove po’s and mo’s (and their dir’s) that " \ + "failed to compile or are no more present in trunk.") + parser.add_argument('-t', '--threshold', type=int, + help="Import threshold, as a percentage.") + parser.add_argument('-p', '--po', action="store_false", + help="Do not remove failing po’s.") + parser.add_argument('-m', '--mo', action="store_false", + help="Do not remove failing mo’s.") + parser.add_argument('langs', metavar='ISO_code', nargs='*', + help="Restrict processed languages to those.") + args = parser.parse_args() + + + ret = 0 + failed = set() + + # Remove po’s in trunk. + for po in os.listdir(TRUNK_PO_DIR): + if po.endswith(".po"): + lang = os.path.basename(po)[:-3] + if args.langs and lang not in args.langs: + continue + po = os.path.join(TRUNK_PO_DIR, po) + os.remove(po) + + # Copy po’s from branches. + cmd = [PY3, "./import_po_from_branches.py", "-s"] + if args.threshold is not None: + cmd += ["-t", str(args.threshold)] + if args.langs: + cmd += args.langs + t = subprocess.call(cmd) + if t: + ret = t + + # Add in failed all mo’s no more having relevant po’s in trunk. + for lang in os.listdir(TRUNK_MO_DIR): + if lang == ".svn": + continue # !!! + if not os.path.exists(os.path.join(TRUNK_PO_DIR, ".".join((lang, "po")))): + failed.add(lang) + + # Check and compile each po separatly, to keep track of those failing. + # XXX There should not be any failing at this stage, import step is + # supposed to have already filtered them out! + for po in os.listdir(TRUNK_PO_DIR): + if po.endswith(".po") and not po.endswith("_raw.po"): + lang = os.path.basename(po)[:-3] + if args.langs and lang not in args.langs: + continue + + cmd = [PY3, "./clean_po.py", "-t", "-s", lang] + t = subprocess.call(cmd) + if t: + ret = t + failed.add(lang) + continue + + cmd = [PY3, "./update_mo.py", lang] + t = subprocess.call(cmd) + if t: + ret = t + failed.add(lang) + + # Remove failing po’s, mo’s and related dir’s. + for lang in failed: + print("Lang “{}†failed, removing it...".format(lang)) + if args.po: + po = os.path.join(TRUNK_PO_DIR, ".".join((lang, "po"))) + if os.path.exists(po): + os.remove(po) + if args.mo: + mo = os.path.join(TRUNK_MO_DIR, lang) + if os.path.exists(mo): + shutil.rmtree(mo) + + +if __name__ == "__main__": + print("\n\n *** Running {} *** \n".format(__file__)) + sys.exit(main()) diff --git a/release/scripts/modules/bl_i18n_utils/user_settings.py b/release/scripts/modules/bl_i18n_utils/user_settings.py new file mode 100644 index 00000000000..23d9783cd0f --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/user_settings.py @@ -0,0 +1,23 @@ +# ***** 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 ***** + +# <pep8 compliant> + +import os + +import settings diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py new file mode 100644 index 00000000000..dfed2088878 --- /dev/null +++ b/release/scripts/modules/bl_i18n_utils/utils.py @@ -0,0 +1,377 @@ +# ***** 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 ***** + +# <pep8 compliant> + +# Some misc utilities... + +import os +import sys +import collections +from codecs import open + +import settings + + +COMMENT_PREFIX = settings.COMMENT_PREFIX +WARN_NC = settings.WARN_MSGID_NOT_CAPITALIZED +NC_ALLOWED = settings.WARN_MSGID_NOT_CAPITALIZED_ALLOWED + + +def stripeol(s): + return s.rstrip("\n\r") + + +# XXX For now, we assume that all messages > 30 chars are tooltips! +def is_tooltip(msgid): + return len(msgid) > 30 + +def parse_messages(fname): + """ + Returns a tupple (messages, states, stats). + messages is an odereddict of dicts + {(ctxt, msgid): {msgid_lines:, msgstr_lines:, + comment_lines:, msgctxt_lines:}}. + states is a dict of three sets of (msgid, ctxt), and a boolean flag + indicating the .po is somewhat broken + {trans_msg:, fuzzy_msg:, comm_msg:, is_broken:}. + stats is a dict of values + {tot_msg:, trans_msg:, tot_ttips:, trans_ttips:, comm_msg:, + nbr_signs:, nbr_trans_signs:, contexts: set()}. + Note: This function will silently "arrange" mis-formated entries, thus + using afterward write_messages() should always produce a po-valid file, + though not correct! + """ + tot_messages = 0 + tot_tooltips = 0 + trans_messages = 0 + trans_tooltips = 0 + comm_messages = 0 + nbr_signs = 0 + nbr_trans_signs = 0 + contexts = set() + reading_msgid = False + reading_msgstr = False + reading_msgctxt = False + reading_comment = False + is_translated = False + is_fuzzy = False + is_commented = False + is_broken = False + msgid_lines = [] + msgstr_lines = [] + msgctxt_lines = [] + comment_lines = [] + + messages = getattr(collections, 'OrderedDict', dict)() + translated_messages = set() + fuzzy_messages = set() + commented_messages = set() + + + def clean_vars(): + nonlocal reading_msgid, reading_msgstr, reading_msgctxt, \ + reading_comment, is_fuzzy, is_translated, is_commented, \ + msgid_lines, msgstr_lines, msgctxt_lines, comment_lines + reading_msgid = reading_msgstr = reading_msgctxt = \ + reading_comment = False + is_tooltip = is_fuzzy = is_translated = is_commented = False + msgid_lines = [] + msgstr_lines = [] + msgctxt_lines = [] + comment_lines = [] + + + def finalize_message(): + nonlocal reading_msgid, reading_msgstr, reading_msgctxt, \ + reading_comment, is_fuzzy, is_translated, is_commented, \ + msgid_lines, msgstr_lines, msgctxt_lines, comment_lines, \ + messages, translated_messages, fuzzy_messages, \ + commented_messages, \ + tot_messages, tot_tooltips, trans_messages, trans_tooltips, \ + comm_messages, nbr_signs, nbr_trans_signs, contexts + + msgid = "".join(msgid_lines) + msgctxt = "".join(msgctxt_lines) + msgkey = (msgctxt, msgid) + is_ttip = is_tooltip(msgid) + + # Never allow overriding existing msgid/msgctxt pairs! + if msgkey in messages: + clean_vars() + return + + nbr_signs += len(msgid) + if is_commented: + commented_messages.add(msgkey) + elif is_fuzzy: + fuzzy_messages.add(msgkey) + elif is_translated: + translated_messages.add(msgkey) + nbr_trans_signs += len("".join(msgstr_lines)) + messages[msgkey] = {"msgid_lines" : msgid_lines, + "msgstr_lines" : msgstr_lines, + "comment_lines": comment_lines, + "msgctxt_lines": msgctxt_lines} + + if is_commented: + comm_messages += 1 + else: + tot_messages += 1 + if is_ttip: + tot_tooltips += 1 + if not is_fuzzy and is_translated: + trans_messages += 1 + if is_ttip: + trans_tooltips += 1 + if msgctxt not in contexts: + contexts.add(msgctxt) + + clean_vars() + + + with open(fname, 'r', "utf-8") as f: + for line_nr, line in enumerate(f): + line = stripeol(line) + if line == "": + finalize_message() + + elif line.startswith("msgctxt") or \ + line.startswith("".join((COMMENT_PREFIX, "msgctxt"))): + reading_comment = False + reading_ctxt = True + if line.startswith(COMMENT_PREFIX): + is_commented = True + line = line[9+len(COMMENT_PREFIX):-1] + else: + line = line[9:-1] + msgctxt_lines.append(line) + + elif line.startswith("msgid") or \ + line.startswith("".join((COMMENT_PREFIX, "msgid"))): + reading_comment = False + reading_msgid = True + if line.startswith(COMMENT_PREFIX): + is_commented = True + line = line[7+len(COMMENT_PREFIX):-1] + else: + line = line[7:-1] + msgid_lines.append(line) + + elif line.startswith("msgstr") or \ + line.startswith("".join((COMMENT_PREFIX, "msgstr"))): + if not reading_msgid: + is_broken = True + else: + reading_msgid = False + reading_msgstr = True + if line.startswith(COMMENT_PREFIX): + line = line[8+len(COMMENT_PREFIX):-1] + if not is_commented: + is_broken = True + else: + line = line[8:-1] + if is_commented: + is_broken = True + msgstr_lines.append(line) + if line: + is_translated = True + + elif line.startswith("#"): + if reading_msgid: + if is_commented: + msgid_lines.append(line[1+len(COMMENT_PREFIX):-1]) + else: + msgid_lines.append(line) + is_broken = True + elif reading_msgstr: + if is_commented: + msgstr_lines.append(line[1+len(COMMENT_PREFIX):-1]) + else: + msgstr_lines.append(line) + is_broken = True + else: + if line.startswith("#, fuzzy"): + is_fuzzy = True + else: + comment_lines.append(line) + reading_comment = True + + else: + if reading_msgid: + msgid_lines.append(line[1:-1]) + elif reading_msgstr: + line = line[1:-1] + msgstr_lines.append(line) + if not is_translated and line: + is_translated = True + else: + is_broken = True + + # If no final empty line, last message is not finalized! + if reading_msgstr: + finalize_message() + + + return (messages, + {"trans_msg": translated_messages, + "fuzzy_msg": fuzzy_messages, + "comm_msg" : commented_messages, + "is_broken": is_broken}, + {"tot_msg" : tot_messages, + "trans_msg" : trans_messages, + "tot_ttips" : tot_tooltips, + "trans_ttips" : trans_tooltips, + "comm_msg" : comm_messages, + "nbr_signs" : nbr_signs, + "nbr_trans_signs": nbr_trans_signs, + "contexts" : contexts}) + + +def write_messages(fname, messages, commented, fuzzy): + "Write in fname file the content of messages (similar to parse_messages " \ + "returned values). commented and fuzzy are two sets containing msgid. " \ + "Returns the number of written messages." + num = 0 + with open(fname, 'w', "utf-8") as f: + for msgkey, val in messages.items(): + msgctxt, msgid = msgkey + f.write("\n".join(val["comment_lines"])) + # Only mark as fuzzy if msgstr is not empty! + if msgkey in fuzzy and "".join(val["msgstr_lines"]): + f.write("\n#, fuzzy") + if msgkey in commented: + if msgctxt: + f.write("\n{}msgctxt \"".format(COMMENT_PREFIX)) + f.write("\"\n{}\"".format(COMMENT_PREFIX).join( + val["msgctxt_lines"])) + f.write("\"") + f.write("\n{}msgid \"".format(COMMENT_PREFIX)) + f.write("\"\n{}\"".format(COMMENT_PREFIX).join( + val["msgid_lines"])) + f.write("\"\n{}msgstr \"".format(COMMENT_PREFIX)) + f.write("\"\n{}\"".format(COMMENT_PREFIX).join( + val["msgstr_lines"])) + f.write("\"\n\n") + else: + if msgctxt: + f.write("\nmsgctxt \"") + f.write("\"\n\"".join(val["msgctxt_lines"])) + f.write("\"") + f.write("\nmsgid \"") + f.write("\"\n\"".join(val["msgid_lines"])) + f.write("\"\nmsgstr \"") + f.write("\"\n\"".join(val["msgstr_lines"])) + f.write("\"\n\n") + num += 1 + return num + + +def gen_empty_messages(blender_rev, time_str, year_str): + """Generate an empty messages & state data (only header if present!).""" + header_key = ("", "") + + messages = getattr(collections, 'OrderedDict', dict)() + messages[header_key] = { + "msgid_lines": [""], + "msgctxt_lines": [], + "msgstr_lines": [ + "Project-Id-Version: Blender r{}\\n" + "".format(blender_rev), + "Report-Msgid-Bugs-To: \\n", + "POT-Creation-Date: {}\\n" + "".format(time_str), + "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n", + "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n", + "Language-Team: LANGUAGE <LL@li.org>\\n", + "Language: \\n", + "MIME-Version: 1.0\\n", + "Content-Type: text/plain; charset=UTF-8\\n", + "Content-Transfer-Encoding: 8bit\\n" + ], + "comment_lines": [ + "# Blender's translation file (po format).", + "# Copyright (C) {} The Blender Foundation." + "".format(year_str), + "# This file is distributed under the same " + "# license as the Blender package.", + "# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.", + "#", + ], + } + + states = {"trans_msg": set(), + "fuzzy_msg": {header_key}, + "comm_msg": set(), + "is_broken": False} + + return messages, states + + +def print_stats(stats, glob_stats=None, prefix=""): + """ + Print out some stats about a po file. + glob_stats is for making global stats over several po's. + """ + tot_msgs = stats["tot_msg"] + trans_msgs = stats["trans_msg"] + tot_ttips = stats["tot_ttips"] + trans_ttips = stats["trans_ttips"] + comm_msgs = stats["comm_msg"] + nbr_signs = stats["nbr_signs"] + nbr_trans_signs = stats["nbr_trans_signs"] + contexts = stats["contexts"] + lvl = lvl_ttips = lvl_trans_ttips = lvl_ttips_in_trans = lvl_comm = 0.0 + + if tot_msgs > 0: + lvl = float(trans_msgs)/float(tot_msgs) + lvl_ttips = float(tot_ttips)/float(tot_msgs) + lvl_comm = float(comm_msgs)/float(tot_msgs+comm_msgs) + if tot_ttips > 0: + lvl_trans_ttips = float(trans_ttips)/float(tot_ttips) + if trans_msgs > 0: + lvl_ttips_in_trans = float(trans_ttips)/float(trans_msgs) + + if glob_stats: + glob_stats["nbr"] += 1.0 + glob_stats["lvl"] += lvl + glob_stats["lvl_ttips"] += lvl_ttips + glob_stats["lvl_trans_ttips"] += lvl_trans_ttips + glob_stats["lvl_ttips_in_trans"] += lvl_ttips_in_trans + glob_stats["lvl_comm"] += lvl_comm + glob_stats["nbr_trans_signs"] += nbr_trans_signs + if glob_stats["nbr_signs"] == 0: + glob_stats["nbr_signs"] = nbr_signs + glob_stats["contexts"] |= contexts + + lines = ("", + "{:>6.1%} done! ({} translated messages over {}).\n" + "".format(lvl, trans_msgs, tot_msgs), + "{:>6.1%} of messages are tooltips ({} over {}).\n" + "".format(lvl_ttips, tot_ttips, tot_msgs), + "{:>6.1%} of tooltips are translated ({} over {}).\n" + "".format(lvl_trans_ttips, trans_ttips, tot_ttips), + "{:>6.1%} of translated messages are tooltips ({} over {}).\n" + "".format(lvl_ttips_in_trans, trans_ttips, trans_msgs), + "{:>6.1%} of messages are commented ({} over {}).\n" + "".format(lvl_comm, comm_msgs, comm_msgs+tot_msgs), + "This translation is currently made of {} signs.\n" + "".format(nbr_trans_signs)) + print(prefix.join(lines)) + return 0 + diff --git a/release/scripts/modules/blend_render_info.py b/release/scripts/modules/blend_render_info.py index 5a09f664637..8762ea0e287 100755 --- a/release/scripts/modules/blend_render_info.py +++ b/release/scripts/modules/blend_render_info.py @@ -36,14 +36,14 @@ def read_blend_rend_chunk(path): import struct - blendfile = open(path, 'rb') + blendfile = open(path, "rb") head = blendfile.read(7) if head[0:2] == b'\x1f\x8b': # gzip magic import gzip blendfile.close() - blendfile = gzip.open(path, 'rb') + blendfile = gzip.open(path, "rb") head = blendfile.read(7) if head != b'BLENDER': @@ -80,7 +80,7 @@ def read_blend_rend_chunk(path): scene_name = scene_name[:scene_name.index(b'\0')] try: - scene_name = str(scene_name, 'utf8') + scene_name = str(scene_name, "utf8") except TypeError: pass diff --git a/release/scripts/modules/bpy/__init__.py b/release/scripts/modules/bpy/__init__.py index 621484fc896..34b7a9ea7b6 100644 --- a/release/scripts/modules/bpy/__init__.py +++ b/release/scripts/modules/bpy/__init__.py @@ -63,11 +63,11 @@ def main(): #~ if "-d" in sys.argv: # Enable this to measure start up speed if 0: import cProfile - cProfile.run('import bpy; bpy.utils.load_scripts()', 'blender.prof') + cProfile.run("import bpy; bpy.utils.load_scripts()", "blender.prof") import pstats - p = pstats.Stats('blender.prof') - p.sort_stats('cumulative').print_stats(100) + p = pstats.Stats("blender.prof") + p.sort_stats("cumulative").print_stats(100) else: utils.load_scripts() diff --git a/release/scripts/modules/bpy/ops.py b/release/scripts/modules/bpy/ops.py index d01b706cc37..34beb6035ae 100644 --- a/release/scripts/modules/bpy/ops.py +++ b/release/scripts/modules/bpy/ops.py @@ -31,16 +31,16 @@ op_get_instance = ops_module.get_instance class BPyOps(object): - ''' + """ Fake module like class. bpy.ops - ''' + """ def __getattr__(self, module): - ''' + """ gets a bpy.ops submodule - ''' + """ if module.startswith('__'): raise AttributeError(module) return BPyOpsSubMod(module) @@ -69,20 +69,20 @@ class BPyOps(object): class BPyOpsSubMod(object): - ''' + """ Utility class to fake submodules. eg. bpy.ops.object - ''' - __keys__ = ('module',) + """ + __keys__ = ("module",) def __init__(self, module): self.module = module def __getattr__(self, func): - ''' + """ gets a bpy.ops.submodule function - ''' + """ if func.startswith('__'): raise AttributeError(func) return BPyOpsSubModOp(self.module, func) @@ -105,13 +105,13 @@ class BPyOpsSubMod(object): class BPyOpsSubModOp(object): - ''' + """ Utility class to fake submodule operators. eg. bpy.ops.object.somefunc - ''' + """ - __keys__ = ('module', 'func') + __keys__ = ("module", "func") def _get_doc(self): return op_as_string(self.idname()) @@ -120,20 +120,28 @@ class BPyOpsSubModOp(object): def _parse_args(args): C_dict = None C_exec = 'EXEC_DEFAULT' - - if len(args) == 0: - pass - elif len(args) == 1: - if type(args[0]) != str: - C_dict = args[0] + C_undo = False + + is_dict = is_exec = is_undo = False + + for i, arg in enumerate(args): + if is_dict is False and isinstance(arg, dict): + if is_exec is True or is_undo is True: + raise ValueError("dict arg must come first") + C_dict = arg + is_dict = True + elif is_exec is False and isinstance(arg, str): + if is_undo is True: + raise ValueError("string arg must come before the boolean") + C_exec = arg + is_exec = True + elif is_undo is False and isinstance(arg, int): + C_undo = arg + is_undo = True else: - C_exec = args[0] - elif len(args) == 2: - C_exec, C_dict = args - else: - raise ValueError("1 or 2 args execution context is supported") + raise ValueError("1-3 args execution context is supported") - return C_dict, C_exec + return C_dict, C_exec, C_undo @staticmethod def _scene_update(context): @@ -152,7 +160,7 @@ class BPyOpsSubModOp(object): self.func = func def poll(self, *args): - C_dict, C_exec = BPyOpsSubModOp._parse_args(args) + C_dict, C_exec, C_undo = BPyOpsSubModOp._parse_args(args) return op_poll(self.idname_py(), C_dict, C_exec) def idname(self): @@ -174,8 +182,8 @@ class BPyOpsSubModOp(object): BPyOpsSubModOp._scene_update(context) if args: - C_dict, C_exec = BPyOpsSubModOp._parse_args(args) - ret = op_call(self.idname_py(), C_dict, kw, C_exec) + C_dict, C_exec, C_undo = BPyOpsSubModOp._parse_args(args) + ret = op_call(self.idname_py(), C_dict, kw, C_exec, C_undo) else: ret = op_call(self.idname_py(), None, kw) diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index 4e8179775d5..ad657284492 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -20,7 +20,7 @@ """ This module contains utility functions specific to blender but -not assosiated with blenders internal data. +not associated with blenders internal data. """ __all__ = ( @@ -253,8 +253,8 @@ _scripts = (_os.path.normpath(_scripts), ) def user_script_path(): - prefs = _bpy.context.user_preferences - path = prefs.filepaths.script_directory + # returns the env var and falls back to userprefs + path = _user_resource('SCRIPTS') if path: path = _os.path.normpath(path) @@ -281,7 +281,7 @@ def script_paths(subdir=None, user_pref=True, check_all=False): prefs = _bpy.context.user_preferences # add user scripts dir - user_script = prefs.filepaths.script_directory if user_pref else None + user_script = user_script_path() if check_all: # all possible paths @@ -489,7 +489,7 @@ def keyconfig_set(filepath): try: keyfile = open(filepath) - exec(compile(keyfile.read(), filepath, 'exec'), {"__file__": filepath}) + exec(compile(keyfile.read(), filepath, "exec"), {"__file__": filepath}) keyfile.close() except: import traceback diff --git a/release/scripts/modules/bpy_extras/__init__.py b/release/scripts/modules/bpy_extras/__init__.py index 7d74bc32f91..c8d12070de8 100644 --- a/release/scripts/modules/bpy_extras/__init__.py +++ b/release/scripts/modules/bpy_extras/__init__.py @@ -19,7 +19,7 @@ # <pep8-80 compliant> """ -Utility modules assosiated with the bpy module. +Utility modules associated with the bpy module. """ __all__ = ( diff --git a/release/scripts/modules/bpy_extras/image_utils.py b/release/scripts/modules/bpy_extras/image_utils.py index c21b750fd1f..36994d3fddd 100644 --- a/release/scripts/modules/bpy_extras/image_utils.py +++ b/release/scripts/modules/bpy_extras/image_utils.py @@ -71,7 +71,7 @@ def load_image(imagepath, def _image_load_placeholder(path): name = bpy.path.basename(path) if type(name) == bytes: - name = name.decode('utf-8', "replace") + name = name.decode("utf-8", "replace") image = bpy.data.images.new(name, 128, 128) # allow the path to be resolved later image.filepath = path diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py index 593fc85e9cb..4457ecb43e6 100644 --- a/release/scripts/modules/bpy_extras/io_utils.py +++ b/release/scripts/modules/bpy_extras/io_utils.py @@ -330,7 +330,7 @@ path_reference_mode = EnumProperty( description="Method used to reference paths", items=(('AUTO', "Auto", "Use Relative paths with subdirectories only"), ('ABSOLUTE', "Absolute", "Always write absolute paths"), - ('RELATIVE', "Relative", "Always write relative patsh " + ('RELATIVE', "Relative", "Always write relative paths " "(where possible)"), ('MATCH', "Match", "Match Absolute/Relative " "setting with input path"), diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py index f8b0abd03ea..dbff90c2447 100644 --- a/release/scripts/modules/bpy_extras/keyconfig_utils.py +++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py @@ -171,7 +171,7 @@ def keyconfig_export(wm, kc, filepath): # First add all user_modified keymaps (found in keyconfigs.user.keymaps list), # then add all remaining keymaps from the currently active custom keyconfig. # - # This will create a final list of keymaps that can be used as a 'diff' against + # This will create a final list of keymaps that can be used as a "diff" against # the default blender keyconfig, recreating the current setup from a fresh blender # without needing to export keymaps which haven't been edited. diff --git a/release/scripts/modules/bpy_extras/mesh_utils.py b/release/scripts/modules/bpy_extras/mesh_utils.py index 3ce45154765..ad0fe06b68b 100644 --- a/release/scripts/modules/bpy_extras/mesh_utils.py +++ b/release/scripts/modules/bpy_extras/mesh_utils.py @@ -19,6 +19,7 @@ # <pep8-80 compliant> __all__ = ( + "mesh_linked_uv_islands", "mesh_linked_tessfaces", "edge_face_count_dict", "edge_face_count", @@ -29,6 +30,66 @@ __all__ = ( ) +def mesh_linked_uv_islands(mesh): + """ + Splits the mesh into connected polygons, use this for seperating cubes from + other mesh elements within 1 mesh datablock. + + :arg mesh: the mesh used to group with. + :type mesh: :class:`bpy.types.Mesh` + :return: lists of lists containing polygon indices + :rtype: list + """ + uv_loops = [luv.uv[:] for luv in mesh.uv_layers.active.data] + poly_loops = [poly.loop_indices for poly in mesh.polygons] + luv_hash = {} + luv_hash_get = luv_hash.get + luv_hash_ls = [None] * len(uv_loops) + for pi, poly_indices in enumerate(poly_loops): + for li in poly_indices: + uv = uv_loops[li] + uv_hub = luv_hash_get(uv) + if uv_hub is None: + uv_hub = luv_hash[uv] = [pi] + else: + uv_hub.append(pi) + luv_hash_ls[li] = uv_hub + + poly_islands = [] + + # 0 = none, 1 = added, 2 = searched + poly_tag = [0] * len(poly_loops) + + while True: + poly_index = -1 + for i in range(len(poly_loops)): + if poly_tag[i] == 0: + poly_index = i + break + + if poly_index != -1: + island = [poly_index] + poly_tag[poly_index] = 1 + poly_islands.append(island) + else: + break # we're done + + added = True + while added: + added = False + for poly_index in island[:]: + if poly_tag[poly_index] == 1: + for li in poly_loops[poly_index]: + for poly_index_shared in luv_hash_ls[li]: + if poly_tag[poly_index_shared] == 0: + added = True + poly_tag[poly_index_shared] = 1 + island.append(poly_index_shared) + poly_tag[poly_index] = 2 + + return poly_islands + + def mesh_linked_tessfaces(mesh): """ Splits the mesh into connected faces, use this for seperating cubes from @@ -258,7 +319,7 @@ def edge_loops_from_edges(mesh, edges=None): def ngon_tessellate(from_data, indices, fix_loops=True): - ''' + """ Takes a polyline of indices (fgon) and returns a list of face indicie lists. Designed to be used for importers that need indices for an fgon to create from existing verts. @@ -268,7 +329,7 @@ def ngon_tessellate(from_data, indices, fix_loops=True): to fill, and can be a subset of the data given. fix_loops: If this is enabled polylines that use loops to make multiple polylines are delt with correctly. - ''' + """ from mathutils.geometry import tessellate_polygon from mathutils import Vector @@ -291,9 +352,9 @@ def ngon_tessellate(from_data, indices, fix_loops=True): return v1[1], v2[1] if not fix_loops: - ''' + """ Normal single concave loop filling - ''' + """ if type(from_data) in {tuple, list}: verts = [Vector(from_data[i]) for ii, i in enumerate(indices)] else: @@ -307,10 +368,10 @@ def ngon_tessellate(from_data, indices, fix_loops=True): fill = tessellate_polygon([verts]) else: - ''' + """ Seperate this loop into multiple loops be finding edges that are used twice. This is used by lightwave LWO files a lot - ''' + """ if type(from_data) in {tuple, list}: verts = [vert_treplet(Vector(from_data[i]), ii) @@ -414,7 +475,7 @@ def ngon_tessellate(from_data, indices, fix_loops=True): fill = tessellate_polygon([[v[0] for v in loop] for loop in loop_list]) #draw_loops(loop_list) - #raise 'done loop' + #raise Exception("done loop") # map to original indices fill = [[vert_map[i] for i in reversed(f)] for f in fill] diff --git a/release/scripts/modules/bpy_extras/view3d_utils.py b/release/scripts/modules/bpy_extras/view3d_utils.py index edc17c36c36..b2f366d5d1e 100644 --- a/release/scripts/modules/bpy_extras/view3d_utils.py +++ b/release/scripts/modules/bpy_extras/view3d_utils.py @@ -20,6 +20,7 @@ __all__ = ( "region_2d_to_vector_3d", + "region_2d_to_origin_3d", "region_2d_to_location_3d", "location_3d_to_region_2d", ) @@ -58,6 +59,40 @@ def region_2d_to_vector_3d(region, rv3d, coord): return viewinv.col[2].xyz.normalized() +def region_2d_to_origin_3d(region, rv3d, coord): + """ + Return the 3d view origin from the region relative 2d coords. + + :arg region: region of the 3D viewport, typically bpy.context.region. + :type region: :class:`bpy.types.Region` + :arg rv3d: 3D region data, typically bpy.context.space_data.region_3d. + :type rv3d: :class:`bpy.types.RegionView3D` + :arg coord: 2d coordinates relative to the region; + (event.mouse_region_x, event.mouse_region_y) for example. + :type coord: 2d vector + :return: The origin of the viewpoint in 3d space. + :rtype: :class:`mathutils.Vector` + """ + from mathutils import Vector + + viewinv = rv3d.view_matrix.inverted() + + if rv3d.is_perspective: + from mathutils.geometry import intersect_line_plane + + origin_start = viewinv.translation.copy() + else: + from mathutils.geometry import intersect_point_line + persmat = rv3d.perspective_matrix.copy() + dx = (2.0 * coord[0] / region.width) - 1.0 + dy = (2.0 * coord[1] / region.height) - 1.0 + persinv = persmat.inverted() + origin_start = ((persinv.col[0].xyz * dx) + + (persinv.col[1].xyz * dy) + + viewinv.translation) + return origin_start + + def region_2d_to_location_3d(region, rv3d, coord, depth_location): """ Return a 3d location from the region relative 2d coords, aligned with @@ -77,18 +112,16 @@ def region_2d_to_location_3d(region, rv3d, coord, depth_location): :rtype: :class:`mathutils.Vector` """ from mathutils import Vector - from mathutils.geometry import intersect_point_line - persmat = rv3d.perspective_matrix.copy() - viewinv = rv3d.view_matrix.inverted() coord_vec = region_2d_to_vector_3d(region, rv3d, coord) depth_location = Vector(depth_location) + origin_start = region_2d_to_origin_3d(region, rv3d, coord) + origin_end = origin_start + coord_vec + if rv3d.is_perspective: from mathutils.geometry import intersect_line_plane - - origin_start = viewinv.translation.copy() - origin_end = origin_start + coord_vec + viewinv = rv3d.view_matrix.inverted() view_vec = viewinv.col[2].copy() return intersect_line_plane(origin_start, origin_end, @@ -96,14 +129,7 @@ def region_2d_to_location_3d(region, rv3d, coord, depth_location): view_vec, 1, ) else: - dx = (2.0 * coord[0] / region.width) - 1.0 - dy = (2.0 * coord[1] / region.height) - 1.0 - persinv = persmat.inverted() - viewinv = rv3d.view_matrix.inverted() - origin_start = ((persinv.col[0].xyz * dx) + - (persinv.col[1].xyz * dy) + - viewinv.translation) - origin_end = origin_start + coord_vec + from mathutils.geometry import intersect_point_line return intersect_point_line(depth_location, origin_start, origin_end, diff --git a/release/scripts/modules/bpyml_ui.py b/release/scripts/modules/bpyml_ui.py index 4828b3649d3..b4ad4e0b54a 100644 --- a/release/scripts/modules/bpyml_ui.py +++ b/release/scripts/modules/bpyml_ui.py @@ -73,7 +73,7 @@ def _call_recursive(context, base, py_node): value = eval(value, {"context": _bpy.context}) setattr(base, py_node[TAG], value) else: - value = py_node[ARGS]['value'] # have to have this + value = py_node[ARGS]["value"] # have to have this setattr(base, py_node[TAG], value) else: args = _parse_rna_args(base, py_node) @@ -85,10 +85,10 @@ def _call_recursive(context, base, py_node): class BPyML_BaseUI(): - ''' + """ This is a mix-in class that defines a draw function which checks for draw_data - ''' + """ def draw(self, context): layout = self.layout diff --git a/release/scripts/modules/console_python.py b/release/scripts/modules/console_python.py index 4ddde0de17c..2aaadb17b71 100644 --- a/release/scripts/modules/console_python.py +++ b/release/scripts/modules/console_python.py @@ -48,14 +48,14 @@ def replace_help(namespace): def get_console(console_id): - ''' + """ helper function for console operators currently each text data block gets its own console - code.InteractiveConsole() ...which is stored in this function. console_id can be any hashable type - ''' + """ from code import InteractiveConsole consoles = getattr(get_console, "consoles", None) @@ -96,7 +96,10 @@ def get_console(console_id): namespace["__builtins__"] = sys.modules["builtins"] namespace["bpy"] = bpy + + # weak! - but highly convenient namespace["C"] = bpy.context + namespace["D"] = bpy.data replace_help(namespace) @@ -305,6 +308,7 @@ def banner(context): 'OUTPUT') add_scrollback("Convenience Imports: from mathutils import *; " "from math import *", 'OUTPUT') + add_scrollback("Convenience Variables: C = bpy.context, D = bpy.data", 'OUTPUT') add_scrollback("", 'OUTPUT') sc.prompt = PROMPT diff --git a/release/scripts/modules/console_shell.py b/release/scripts/modules/console_shell.py index 772d46c8bf3..c27524ffe44 100644 --- a/release/scripts/modules/console_shell.py +++ b/release/scripts/modules/console_shell.py @@ -20,7 +20,7 @@ import os import bpy -language_id = 'shell' +language_id = "shell" def add_scrollback(text, text_type): diff --git a/release/scripts/modules/graphviz_export.py b/release/scripts/modules/graphviz_export.py index b60952a2f88..88f8b15a728 100644 --- a/release/scripts/modules/graphviz_export.py +++ b/release/scripts/modules/graphviz_export.py @@ -172,7 +172,7 @@ def graph_armature(obj, filepath, FAKE_PARENT=True, CONSTRAINTS=True, DRIVERS=Tr fileobject.close() ''' - print(".", end='') + print(".", end="") import sys sys.stdout.flush() ''' diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py index 4116bfda0c7..0ef2ac5164d 100644 --- a/release/scripts/modules/rna_info.py +++ b/release/scripts/modules/rna_info.py @@ -66,9 +66,9 @@ def rna_id_ignore(rna_id): def range_str(val): if val < -10000000: - return '-inf' + return "-inf" elif val > 10000000: - return 'inf' + return "inf" elif type(val) == float: return '%g' % val else: @@ -305,8 +305,8 @@ class InfoPropertyRNA: return type_str def __str__(self): - txt = '' - txt += ' * ' + self.identifier + ': ' + self.description + txt = "" + txt += " * " + self.identifier + ": " + self.description return txt @@ -398,7 +398,7 @@ class InfoOperatorRNA: return None, None -def _GetInfoRNA(bl_rna, cls, parent_id=''): +def _GetInfoRNA(bl_rna, cls, parent_id=""): if bl_rna is None: return None @@ -437,9 +437,9 @@ def BuildRNAInfo(): # rna_functions_dict = {} # store all functions directly in this type (not inherited) def full_rna_struct_path(rna_struct): - ''' + """ Needed when referencing one struct from another - ''' + """ nested = rna_struct.nested if nested: return "%s.%s" % (full_rna_struct_path(nested), rna_struct.identifier) @@ -641,7 +641,7 @@ if __name__ == "__main__": props = [(prop.identifier, prop) for prop in v.properties] for prop_id, prop in sorted(props): - # if prop.type == 'boolean': + # if prop.type == "boolean": # continue prop_type = prop.type if prop.array_length > 0: diff --git a/release/scripts/modules/rna_xml.py b/release/scripts/modules/rna_xml.py index 710035dc29f..5354fd1c776 100644 --- a/release/scripts/modules/rna_xml.py +++ b/release/scripts/modules/rna_xml.py @@ -352,7 +352,7 @@ def xml_file_run(context, filepath, rna_map): def xml_file_write(context, filepath, rna_map): - file = open(filepath, 'w', encoding='utf-8') + file = open(filepath, "w", encoding="utf-8") fw = file.write fw("<bpy>\n") diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py index 0fa80a8f855..6fc50bcfe0d 100644 --- a/release/scripts/modules/sys_info.py +++ b/release/scripts/modules/sys_info.py @@ -27,7 +27,7 @@ import sys def cutPoint(text, length): - "Returns position of the last space found before 'length' chars" + """Returns position of the last space found before 'length' chars""" l = length c = text[l] while c != ' ': @@ -98,7 +98,7 @@ def write_sysinfo(op): output.write(lilies) ffmpeg = bpy.app.ffmpeg if ffmpeg.supported: - for lib in ['avcodec', 'avdevice', 'avformat', 'avutil', 'swscale']: + for lib in ("avcodec", "avdevice", "avformat", "avutil", "swscale"): output.write("%r:%r%r\n" % (lib, " " * (10 - len(lib)), getattr(ffmpeg, lib + "_version_string"))) else: diff --git a/release/scripts/presets/interface_theme/back_to_black.xml b/release/scripts/presets/interface_theme/back_to_black.xml index 866c4ab412d..24f135e8548 100644 --- a/release/scripts/presets/interface_theme/back_to_black.xml +++ b/release/scripts/presets/interface_theme/back_to_black.xml @@ -2,7 +2,7 @@ <Theme> <view_3d> <ThemeView3D object_active="#ff8c19" - editmesh_active="#ffffff80" + editmesh_active="#ff020080" act_spline="#db2512" handle_align="#803060" handle_sel_align="#f090a0" @@ -461,7 +461,7 @@ <ThemeTextEditor cursor="#ff0000" syntax_special="#969629" line_numbers_background="#191919" - selected_text="#ffffff" + selected_text="#202020" syntax_builtin="#cf3d99" syntax_comment="#249d60" syntax_numbers="#3c68ff" diff --git a/release/scripts/presets/operator/wm.collada_export/second_life.py b/release/scripts/presets/operator/wm.collada_export/second_life_rigged.py index bacf49a61ae..2c695a22ff9 100644 --- a/release/scripts/presets/operator/wm.collada_export/second_life.py +++ b/release/scripts/presets/operator/wm.collada_export/second_life_rigged.py @@ -1,10 +1,16 @@ import bpy op = bpy.context.active_operator + op.apply_modifiers = True +op.export_mesh_type = 0 +op.export_mesh_type_selection = 'view' op.selected = True op.include_children = False op.include_armatures = True op.deform_bones_only = True +op.active_uv_only = True +op.include_uv_textures = True +op.use_texture_copies = True op.use_object_instantiation = False op.sort_by_name = True op.second_life = True diff --git a/release/scripts/presets/operator/wm.collada_export/second_life_static.py b/release/scripts/presets/operator/wm.collada_export/second_life_static.py new file mode 100644 index 00000000000..081788b7e9d --- /dev/null +++ b/release/scripts/presets/operator/wm.collada_export/second_life_static.py @@ -0,0 +1,16 @@ +import bpy +op = bpy.context.active_operator + +op.apply_modifiers = True +op.export_mesh_type = 0 +op.export_mesh_type_selection = 'view' +op.selected = True +op.include_children = False +op.include_armatures = False +op.deform_bones_only = False +op.active_uv_only = True +op.include_uv_textures = True +op.use_texture_copies = True +op.use_object_instantiation = False +op.sort_by_name = True +op.second_life = False diff --git a/release/scripts/startup/bl_operators/add_mesh_torus.py b/release/scripts/startup/bl_operators/add_mesh_torus.py index 75a6cd73d64..6c48ae72e4b 100644 --- a/release/scripts/startup/bl_operators/add_mesh_torus.py +++ b/release/scripts/startup/bl_operators/add_mesh_torus.py @@ -84,7 +84,7 @@ def add_torus(major_rad, minor_rad, major_seg, minor_seg): class AddTorus(Operator, object_utils.AddObjectHelper): - '''Add a torus mesh''' + """Add a torus mesh""" bl_idname = "mesh.primitive_torus_add" bl_label = "Add Torus" bl_options = {'REGISTER', 'UNDO', 'PRESET'} diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py index 5a428467f12..98bad276109 100644 --- a/release/scripts/startup/bl_operators/anim.py +++ b/release/scripts/startup/bl_operators/anim.py @@ -227,7 +227,7 @@ class BakeAction(Operator): self.frame_start = scene.frame_start self.frame_end = scene.frame_end self.bake_types = {'POSE'} if context.mode == 'POSE' else {'OBJECT'} - + wm = context.window_manager return wm.invoke_props_dialog(self) diff --git a/release/scripts/startup/bl_operators/console.py b/release/scripts/startup/bl_operators/console.py index ff87f98658d..82a54077bdc 100644 --- a/release/scripts/startup/bl_operators/console.py +++ b/release/scripts/startup/bl_operators/console.py @@ -77,7 +77,7 @@ class ConsoleBanner(Operator): # default to python if not sc.language: - sc.language = 'python' + sc.language = "python" module = _lang_module_get(sc) banner = getattr(module, "banner", None) diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py index f2e5e57fad8..074069255bc 100644 --- a/release/scripts/startup/bl_operators/image.py +++ b/release/scripts/startup/bl_operators/image.py @@ -24,7 +24,7 @@ from bpy.props import StringProperty class EditExternally(Operator): - '''Edit image in an external application''' + """Edit image in an external application""" bl_idname = "image.external_edit" bl_label = "Image Edit Externally" bl_options = {'REGISTER'} diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py index 4ed43a68e48..3dc25d84aca 100644 --- a/release/scripts/startup/bl_operators/mesh.py +++ b/release/scripts/startup/bl_operators/mesh.py @@ -25,7 +25,7 @@ from bpy.props import EnumProperty class MeshMirrorUV(Operator): - '''Copy mirror UV coordinates on the X axis based on a mirrored mesh''' + """Copy mirror UV coordinates on the X axis based on a mirrored mesh""" bl_idname = "mesh.faces_mirror_uv" bl_label = "Copy Mirrored UV coords" bl_options = {'REGISTER', 'UNDO'} @@ -58,12 +58,9 @@ class MeshMirrorUV(Operator): vcos = (v.co.to_tuple(5) for v in mesh.vertices) for i, co in enumerate(vcos): - if co[0] > 0.0: - mirror_gt[co] = i - elif co[0] < 0.0: - mirror_lt[co] = i - else: + if co[0] >= 0.0: mirror_gt[co] = i + if co[0] <= 0.0: mirror_lt[co] = i #for i, v in enumerate(mesh.vertices): @@ -97,14 +94,13 @@ class MeshMirrorUV(Operator): puvsel[i] = (False not in (uv.select for uv in uv_loops[lstart:lend])) # Vert idx of the poly. - vidxs[i] = tuple(sorted(l.vertex_index - for l in loops[lstart:lend])) + vidxs[i] = tuple(l.vertex_index for l in loops[lstart:lend]) # As we have no poly.center yet... pcents[i] = tuple(map(lambda x: x / p.loop_total, map(sum, zip(*(verts[idx].co for idx in vidxs[i]))))) # Preparing next step finding matching polys. - mirror_pm[vidxs[i]] = i + mirror_pm[tuple(sorted(vidxs[i]))] = i for i in range(nbr_polys): # Find matching mirror poly. diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index fbf0e47f0c8..5000d718182 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -27,14 +27,15 @@ from bpy.props import (StringProperty, class SelectPattern(Operator): - '''Select objects matching a naming pattern''' + """Select objects matching a naming pattern""" bl_idname = "object.select_pattern" bl_label = "Select Pattern" bl_options = {'REGISTER', 'UNDO'} pattern = StringProperty( name="Pattern", - description="Name filter using '*', '?' and '[abc]' unix style wildcards", + description="Name filter using '*', '?' and " + "'[abc]' unix style wildcards", maxlen=64, default="*", ) @@ -104,7 +105,7 @@ class SelectPattern(Operator): class SelectCamera(Operator): - '''Select the active camera''' + """Select the active camera""" bl_idname = "object.select_camera" bl_label = "Select Camera" bl_options = {'REGISTER', 'UNDO'} @@ -130,8 +131,8 @@ class SelectCamera(Operator): class SelectHierarchy(Operator): - '''Select object relative to the active object's position ''' \ - '''in the hierarchy''' + """Select object relative to the active object's position """ \ + """in the hierarchy""" bl_idname = "object.select_hierarchy" bl_label = "Select Hierarchy" bl_options = {'REGISTER', 'UNDO'} @@ -197,7 +198,7 @@ class SelectHierarchy(Operator): class SubdivisionSet(Operator): - '''Sets a Subdivision Surface Level (1-5)''' + """Sets a Subdivision Surface Level (1-5)""" bl_idname = "object.subdivision_set" bl_label = "Subdivision Set" @@ -277,8 +278,8 @@ class SubdivisionSet(Operator): class ShapeTransfer(Operator): - '''Copy another selected objects active shape to this one by ''' \ - '''applying the relative offsets''' + """Copy another selected objects active shape to this one by """ \ + """applying the relative offsets""" bl_idname = "object.shape_key_transfer" bl_label = "Transfer Shape Key" @@ -467,7 +468,7 @@ class ShapeTransfer(Operator): class JoinUVs(Operator): - '''Copy UV Layout to objects with matching geometry''' + """Copy UV Layout to objects with matching geometry""" bl_idname = "object.join_uvs" bl_label = "Join as UVs" @@ -546,7 +547,7 @@ class JoinUVs(Operator): class MakeDupliFace(Operator): - '''Make linked objects into dupli-faces''' + """Make linked objects into dupli-faces""" bl_idname = "object.make_dupli_face" bl_label = "Make Dupli-Face" @@ -641,7 +642,7 @@ class IsolateTypeRender(Operator): class ClearAllRestrictRender(Operator): - '''Reveal all render objects by setting the hide render flag''' + """Reveal all render objects by setting the hide render flag""" bl_idname = "object.hide_render_clear_all" bl_label = "Clear All Restrict Render" bl_options = {'REGISTER', 'UNDO'} @@ -653,7 +654,7 @@ class ClearAllRestrictRender(Operator): class TransformsToDeltasAnim(Operator): - '''Convert object animation for normal transforms to delta transforms''' + """Convert object animation for normal transforms to delta transforms""" bl_idname = "object.anim_transforms_to_deltas" bl_label = "Animated Transforms to Deltas" bl_options = {'REGISTER', 'UNDO'} @@ -699,7 +700,7 @@ class TransformsToDeltasAnim(Operator): class DupliOffsetFromCursor(Operator): - '''Set offset used for DupliGroup based on cursor position''' + """Set offset used for DupliGroup based on cursor position""" bl_idname = "object.dupli_offset_from_cursor" bl_label = "Set Offset From Cursor" bl_options = {'REGISTER', 'UNDO'} diff --git a/release/scripts/startup/bl_operators/object_align.py b/release/scripts/startup/bl_operators/object_align.py index dd052c36ade..a32bb8c5353 100644 --- a/release/scripts/startup/bl_operators/object_align.py +++ b/release/scripts/startup/bl_operators/object_align.py @@ -341,7 +341,7 @@ from bpy.props import EnumProperty, BoolProperty class AlignObjects(Operator): - '''Align Objects''' + """Align Objects""" bl_idname = "object.align" bl_label = "Align Objects" bl_options = {'REGISTER', 'UNDO'} diff --git a/release/scripts/startup/bl_operators/object_randomize_transform.py b/release/scripts/startup/bl_operators/object_randomize_transform.py index 834df04fe01..ec0b17b773b 100644 --- a/release/scripts/startup/bl_operators/object_randomize_transform.py +++ b/release/scripts/startup/bl_operators/object_randomize_transform.py @@ -95,7 +95,7 @@ from bpy.props import (IntProperty, class RandomizeLocRotSize(Operator): - '''Randomize objects loc/rot/scale''' + """Randomize objects loc/rot/scale""" bl_idname = "object.randomize_transform" bl_label = "Randomize Transform" bl_options = {'REGISTER', 'UNDO'} diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 4171b8b3c2c..0bd9a5065a2 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -16,7 +16,7 @@ # # ##### END GPL LICENSE BLOCK ##### -# <pep8-80 compliant> +# <pep8 compliant> import bpy from bpy.types import Menu, Operator @@ -24,10 +24,10 @@ from bpy.props import StringProperty, BoolProperty class AddPresetBase(): - '''Base preset class, only for subclassing + """Base preset class, only for subclassing subclasses must define - preset_values - - preset_subdir ''' + - preset_subdir """ # bl_idname = "script.preset_base_add" # bl_label = "Add a Python Preset" bl_options = {'REGISTER'} # only because invoke_props_popup requires. @@ -179,7 +179,7 @@ class AddPresetBase(): class ExecutePreset(Operator): - '''Execute a preset''' + """Execute a preset""" bl_idname = "script.execute_preset" bl_label = "Execute a Python Preset" @@ -217,7 +217,7 @@ class ExecutePreset(Operator): class AddPresetRender(AddPresetBase, Operator): - '''Add a Render Preset''' + """Add a Render Preset""" bl_idname = "render.preset_add" bl_label = "Add Render Preset" preset_menu = "RENDER_MT_presets" @@ -243,7 +243,7 @@ class AddPresetRender(AddPresetBase, Operator): class AddPresetCamera(AddPresetBase, Operator): - '''Add a Camera Preset''' + """Add a Camera Preset""" bl_idname = "camera.preset_add" bl_label = "Add Camera Preset" preset_menu = "CAMERA_MT_presets" @@ -262,7 +262,7 @@ class AddPresetCamera(AddPresetBase, Operator): class AddPresetSSS(AddPresetBase, Operator): - '''Add a Subsurface Scattering Preset''' + """Add a Subsurface Scattering Preset""" bl_idname = "material.sss_preset_add" bl_label = "Add SSS Preset" preset_menu = "MATERIAL_MT_sss_presets" @@ -290,7 +290,7 @@ class AddPresetSSS(AddPresetBase, Operator): class AddPresetCloth(AddPresetBase, Operator): - '''Add a Cloth Preset''' + """Add a Cloth Preset""" bl_idname = "cloth.preset_add" bl_label = "Add Cloth Preset" preset_menu = "CLOTH_MT_presets" @@ -312,7 +312,7 @@ class AddPresetCloth(AddPresetBase, Operator): class AddPresetFluid(AddPresetBase, Operator): - '''Add a Fluid Preset''' + """Add a Fluid Preset""" bl_idname = "fluid.preset_add" bl_label = "Add Fluid Preset" preset_menu = "FLUID_MT_presets" @@ -330,7 +330,7 @@ class AddPresetFluid(AddPresetBase, Operator): class AddPresetSunSky(AddPresetBase, Operator): - '''Add a Sky & Atmosphere Preset''' + """Add a Sky & Atmosphere Preset""" bl_idname = "lamp.sunsky_preset_add" bl_label = "Add Sunsky Preset" preset_menu = "LAMP_MT_sunsky_presets" @@ -359,7 +359,7 @@ class AddPresetSunSky(AddPresetBase, Operator): class AddPresetInteraction(AddPresetBase, Operator): - '''Add an Application Interaction Preset''' + """Add an Application Interaction Preset""" bl_idname = "wm.interaction_preset_add" bl_label = "Add Interaction Preset" preset_menu = "USERPREF_MT_interaction_presets" @@ -385,7 +385,7 @@ class AddPresetInteraction(AddPresetBase, Operator): class AddPresetTrackingCamera(AddPresetBase, Operator): - '''Add a Tracking Camera Intrinsics Preset''' + """Add a Tracking Camera Intrinsics Preset""" bl_idname = "clip.camera_preset_add" bl_label = "Add Camera Preset" preset_menu = "CLIP_MT_camera_presets" @@ -408,7 +408,7 @@ class AddPresetTrackingCamera(AddPresetBase, Operator): class AddPresetTrackingTrackColor(AddPresetBase, Operator): - '''Add a Clip Track Color Preset''' + """Add a Clip Track Color Preset""" bl_idname = "clip.track_color_preset_add" bl_label = "Add Track Color Preset" preset_menu = "CLIP_MT_track_color_presets" @@ -426,7 +426,7 @@ class AddPresetTrackingTrackColor(AddPresetBase, Operator): class AddPresetTrackingSettings(AddPresetBase, Operator): - '''Add a motion tracking settings preset''' + """Add a motion tracking settings preset""" bl_idname = "clip.tracking_settings_preset_add" bl_label = "Add Tracking Settings Preset" preset_menu = "CLIP_MT_tracking_settings_presets" @@ -453,7 +453,7 @@ class AddPresetTrackingSettings(AddPresetBase, Operator): class AddPresetNodeColor(AddPresetBase, Operator): - '''Add a Node Color Preset''' + """Add a Node Color Preset""" bl_idname = "node.node_color_preset_add" bl_label = "Add Node Color Preset" preset_menu = "NODE_MT_node_color_presets" @@ -471,7 +471,7 @@ class AddPresetNodeColor(AddPresetBase, Operator): class AddPresetInterfaceTheme(AddPresetBase, Operator): - '''Add a theme preset''' + """Add a theme preset""" bl_idname = "wm.interface_theme_preset_add" bl_label = "Add Tracking Settings Preset" preset_menu = "USERPREF_MT_interface_theme_presets" @@ -479,7 +479,7 @@ class AddPresetInterfaceTheme(AddPresetBase, Operator): class AddPresetKeyconfig(AddPresetBase, Operator): - '''Add a Key-config Preset''' + """Add a Key-config Preset""" bl_idname = "wm.keyconfig_preset_add" bl_label = "Add Keyconfig Preset" preset_menu = "USERPREF_MT_keyconfigs" @@ -502,7 +502,7 @@ class AddPresetKeyconfig(AddPresetBase, Operator): class AddPresetOperator(AddPresetBase, Operator): - '''Add an Application Interaction Preset''' + """Add an Application Interaction Preset""" bl_idname = "wm.operator_preset_add" bl_label = "Operator Preset" preset_menu = "WM_MT_operator_presets" diff --git a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py index 5ee7cf86142..9cb9dfc708c 100644 --- a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py +++ b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py @@ -66,7 +66,7 @@ def guess_player_path(preset): class PlayRenderedAnim(Operator): - '''Play back rendered frames/movies using an external player''' + """Play back rendered frames/movies using an external player""" bl_idname = "render.play_rendered_anim" bl_label = "Play Rendered Animation" bl_options = {'REGISTER'} diff --git a/release/scripts/startup/bl_operators/sequencer.py b/release/scripts/startup/bl_operators/sequencer.py index c51ec74ddd6..ebb499012ea 100644 --- a/release/scripts/startup/bl_operators/sequencer.py +++ b/release/scripts/startup/bl_operators/sequencer.py @@ -25,7 +25,7 @@ from bpy.props import IntProperty class SequencerCrossfadeSounds(Operator): - '''Do cross-fading volume animation of two selected sound strips''' + """Do cross-fading volume animation of two selected sound strips""" bl_idname = "sequencer.crossfade_sounds" bl_label = "Crossfade sounds" @@ -76,7 +76,7 @@ class SequencerCrossfadeSounds(Operator): class SequencerCutMulticam(Operator): - '''Cut multi-cam strip and select camera''' + """Cut multi-cam strip and select camera""" bl_idname = "sequencer.cut_multicam" bl_label = "Cut multicam" @@ -118,7 +118,7 @@ class SequencerCutMulticam(Operator): class SequencerDeinterlaceSelectedMovies(Operator): - '''Deinterlace all selected movie sources''' + """Deinterlace all selected movie sources""" bl_idname = "sequencer.deinterlace_selected_movies" bl_label = "Deinterlace Movies" diff --git a/release/scripts/startup/bl_operators/uvcalc_follow_active.py b/release/scripts/startup/bl_operators/uvcalc_follow_active.py index d6f657683a5..bcab6f078c2 100644 --- a/release/scripts/startup/bl_operators/uvcalc_follow_active.py +++ b/release/scripts/startup/bl_operators/uvcalc_follow_active.py @@ -46,11 +46,11 @@ def extend(obj, operator, EXTEND_MODE): OTHER_INDEX = 2, 3, 0, 1 def extend_uvs(face_source, face_target, edge_key): - ''' + """ Takes 2 faces, Projects its extends its UV coords onto the face next to it. Both faces must share an edge - ''' + """ def face_edge_vs(vi): vlen = len(vi) @@ -224,7 +224,7 @@ def main(context, operator): class FollowActiveQuads(Operator): - '''Follow UVs from active quads along continuous face loops''' + """Follow UVs from active quads along continuous face loops""" bl_idname = "uv.follow_active_quads" bl_label = "Follow Active Quads" bl_options = {'REGISTER', 'UNDO'} diff --git a/release/scripts/startup/bl_operators/uvcalc_lightmap.py b/release/scripts/startup/bl_operators/uvcalc_lightmap.py index b184c81d6a7..0a4c44cd52f 100644 --- a/release/scripts/startup/bl_operators/uvcalc_lightmap.py +++ b/release/scripts/startup/bl_operators/uvcalc_lightmap.py @@ -197,12 +197,12 @@ def lightmap_uvpack(meshes, PREF_BOX_DIV=8, PREF_MARGIN_DIV=512 ): - ''' + """ BOX_DIV if the maximum division of the UV map that a box may be consolidated into. Basically, a lower value will be slower but waist less space and a higher value will have more clumpy boxes but more wasted space - ''' + """ import time from math import sqrt @@ -545,7 +545,7 @@ from bpy.props import BoolProperty, FloatProperty, IntProperty class LightMapPack(Operator): - '''Follow UVs from active quads along continuous face loops''' + """Follow UVs from active quads along continuous face loops""" bl_idname = "uv.lightmap_pack" bl_label = "Lightmap Pack" diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py index 1e18825a155..c9b41914419 100644 --- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py +++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py @@ -107,7 +107,6 @@ def boundsEdgeLoop(edges): # print len(faces), minx, maxx, miny , maxy for ed in edges: for pt in ed: - print 'ass' x= pt[0] y= pt[1] if x<minx: x= minx @@ -493,7 +492,7 @@ def mergeUvIslands(islandList): pass if Intersect == 2: # Source inside target - ''' + """ We have an intersection, if we are inside the target then move us 1 whole width across, Its possible this is a bad idea since 2 skinny Angular faces @@ -501,8 +500,7 @@ def mergeUvIslands(islandList): since we have already tested for it. It gives about 10% speedup with minimal errors. - ''' - #print 'ass' + """ # Move the test along its width + SMALL_NUM #boxLeft += sourceIsland[4] + SMALL_NUM boxLeft += sourceIsland[4] @@ -696,11 +694,11 @@ def packIslands(islandList): islandIdx -=1 continue - '''Save the offset to be applied later, + """Save the offset to be applied later, we could apply to the UVs now and allign them to the bottom left hand area of the UV coords like the box packer imagines they are but, its quicker just to remember their offset and - apply the packing and offset in 1 pass ''' + apply the packing and offset in 1 pass """ islandOffsetList.append((minx, miny)) # Add to boxList. use the island idx for the BOX id. @@ -832,7 +830,7 @@ def main(context, USER_ONLY_SELECTED_FACES = False if not obList: - raise('error, no selected mesh objects') + raise Exception("error, no selected mesh objects") # Reuse variable if len(obList) == 1: @@ -1106,8 +1104,9 @@ from bpy.props import FloatProperty class SmartProject(Operator): - '''This script projection unwraps the selected faces of a mesh ''' \ - '''(it operates on all selected mesh objects, and can be used to unwrap selected faces, or all faces)''' + """This script projection unwraps the selected faces of a mesh """ \ + """(it operates on all selected mesh objects, and can be used """ \ + """to unwrap selected faces, or all faces)""" bl_idname = "uv.smart_project" bl_label = "Smart UV Project" bl_options = {'REGISTER', 'UNDO'} diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 4d95c2d5d03..2ebc8e80b71 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -31,7 +31,8 @@ from rna_prop_ui import rna_idprop_ui_prop_get, rna_idprop_ui_prop_clear class MESH_OT_delete_edgeloop(Operator): - '''Delete an edge loop by merging the faces on each side to a single face loop''' + """Delete an edge loop by merging the faces on each side """ \ + """to a single face loop""" bl_idname = "mesh.delete_edgeloop" bl_label = "Delete Edge Loop" @@ -138,7 +139,7 @@ def execute_context_assign(self, context): class BRUSH_OT_active_index_set(Operator): - '''Set active sculpt/paint brush from it's number''' + """Set active sculpt/paint brush from it's number""" bl_idname = "brush.active_index_set" bl_label = "Set Brush Number" @@ -173,7 +174,7 @@ class BRUSH_OT_active_index_set(Operator): class WM_OT_context_set_boolean(Operator): - '''Set a context value''' + """Set a context value""" bl_idname = "wm.context_set_boolean" bl_label = "Context Set Boolean" bl_options = {'UNDO', 'INTERNAL'} @@ -189,7 +190,7 @@ class WM_OT_context_set_boolean(Operator): class WM_OT_context_set_int(Operator): # same as enum - '''Set a context value''' + """Set a context value""" bl_idname = "wm.context_set_int" bl_label = "Context Set" bl_options = {'UNDO', 'INTERNAL'} @@ -206,7 +207,7 @@ class WM_OT_context_set_int(Operator): # same as enum class WM_OT_context_scale_int(Operator): - '''Scale an int context value''' + """Scale an int context value""" bl_idname = "wm.context_scale_int" bl_label = "Context Set" bl_options = {'UNDO', 'INTERNAL'} @@ -249,7 +250,7 @@ class WM_OT_context_scale_int(Operator): class WM_OT_context_set_float(Operator): # same as enum - '''Set a context value''' + """Set a context value""" bl_idname = "wm.context_set_float" bl_label = "Context Set Float" bl_options = {'UNDO', 'INTERNAL'} @@ -266,7 +267,7 @@ class WM_OT_context_set_float(Operator): # same as enum class WM_OT_context_set_string(Operator): # same as enum - '''Set a context value''' + """Set a context value""" bl_idname = "wm.context_set_string" bl_label = "Context Set String" bl_options = {'UNDO', 'INTERNAL'} @@ -282,7 +283,7 @@ class WM_OT_context_set_string(Operator): # same as enum class WM_OT_context_set_enum(Operator): - '''Set a context value''' + """Set a context value""" bl_idname = "wm.context_set_enum" bl_label = "Context Set Enum" bl_options = {'UNDO', 'INTERNAL'} @@ -298,7 +299,7 @@ class WM_OT_context_set_enum(Operator): class WM_OT_context_set_value(Operator): - '''Set a context value''' + """Set a context value""" bl_idname = "wm.context_set_value" bl_label = "Context Set Value" bl_options = {'UNDO', 'INTERNAL'} @@ -319,7 +320,7 @@ class WM_OT_context_set_value(Operator): class WM_OT_context_toggle(Operator): - '''Toggle a context value''' + """Toggle a context value""" bl_idname = "wm.context_toggle" bl_label = "Context Toggle" bl_options = {'UNDO', 'INTERNAL'} @@ -338,7 +339,7 @@ class WM_OT_context_toggle(Operator): class WM_OT_context_toggle_enum(Operator): - '''Toggle a context value''' + """Toggle a context value""" bl_idname = "wm.context_toggle_enum" bl_label = "Context Toggle Values" bl_options = {'UNDO', 'INTERNAL'} @@ -371,8 +372,8 @@ class WM_OT_context_toggle_enum(Operator): class WM_OT_context_cycle_int(Operator): - '''Set a context value. Useful for cycling active material, ''' - '''vertex keys, groups' etc''' + """Set a context value. Useful for cycling active material, """ \ + """vertex keys, groups' etc""" bl_idname = "wm.context_cycle_int" bl_label = "Context Int Cycle" bl_options = {'UNDO', 'INTERNAL'} @@ -406,7 +407,7 @@ class WM_OT_context_cycle_int(Operator): class WM_OT_context_cycle_enum(Operator): - '''Toggle a context value''' + """Toggle a context value""" bl_idname = "wm.context_cycle_enum" bl_label = "Context Enum Cycle" bl_options = {'UNDO', 'INTERNAL'} @@ -458,8 +459,8 @@ class WM_OT_context_cycle_enum(Operator): class WM_OT_context_cycle_array(Operator): - '''Set a context array value. ''' - '''Useful for cycling the active mesh edit mode''' + """Set a context array value """ \ + """(useful for cycling the active mesh edit mode)""" bl_idname = "wm.context_cycle_array" bl_label = "Context Array Cycle" bl_options = {'UNDO', 'INTERNAL'} @@ -519,7 +520,7 @@ class WM_OT_context_menu_enum(Operator): class WM_OT_context_set_id(Operator): - '''Toggle a context value''' + """Toggle a context value""" bl_idname = "wm.context_set_id" bl_label = "Set Library ID" bl_options = {'UNDO', 'INTERNAL'} @@ -575,7 +576,7 @@ data_path_item = StringProperty( class WM_OT_context_collection_boolean_set(Operator): - '''Set boolean values for a collection of items''' + """Set boolean values for a collection of items""" bl_idname = "wm.context_collection_boolean_set" bl_label = "Context Collection Boolean Set" bl_options = {'UNDO', 'REGISTER', 'INTERNAL'} @@ -634,7 +635,7 @@ class WM_OT_context_collection_boolean_set(Operator): class WM_OT_context_modal_mouse(Operator): - '''Adjust arbitrary values with mouse input''' + """Adjust arbitrary values with mouse input""" bl_idname = "wm.context_modal_mouse" bl_label = "Context Modal Mouse" bl_options = {'GRAB_POINTER', 'BLOCKING', 'UNDO', 'INTERNAL'} @@ -799,7 +800,6 @@ class WM_OT_path_open(Operator): return {'FINISHED'} - def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""): id_split = doc_id.split(".") url = rna = None @@ -832,12 +832,12 @@ def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""): url = ("%s/bpy.types.%s.html#bpy.types.%s.%s" % (url_prefix, class_name, class_name, class_prop)) else: rna = ("bpy.types.%s.%s" % (class_name, class_prop)) - + return url if do_url else rna class WM_OT_doc_view_manual(Operator): - '''Load online manual''' + """Load online manual""" bl_idname = "wm.doc_view_manual" bl_label = "View Manual" @@ -882,7 +882,7 @@ class WM_OT_doc_view_manual(Operator): class WM_OT_doc_view(Operator): - '''Load online reference docs''' + """Load online reference docs""" bl_idname = "wm.doc_view" bl_label = "View Documentation" @@ -906,7 +906,7 @@ class WM_OT_doc_view(Operator): class WM_OT_doc_edit(Operator): - '''Load online reference docs''' + """Load online reference docs""" bl_idname = "wm.doc_edit" bl_label = "Edit Documentation" @@ -1009,7 +1009,7 @@ rna_max = FloatProperty( class WM_OT_properties_edit(Operator): - '''Internal use (edit a property data_path)''' + """Internal use (edit a property data_path)""" bl_idname = "wm.properties_edit" bl_label = "Edit Property" bl_options = {'REGISTER'} # only because invoke_props_popup requires. @@ -1061,7 +1061,7 @@ class WM_OT_properties_edit(Operator): prop_ui["soft_min"] = prop_ui["min"] = prop_type(self.min) prop_ui["soft_max"] = prop_ui["max"] = prop_type(self.max) - prop_ui['description'] = self.description + prop_ui["description"] = self.description # otherwise existing buttons which reference freed # memory may crash blender [#26510] @@ -1095,7 +1095,7 @@ class WM_OT_properties_edit(Operator): class WM_OT_properties_add(Operator): - '''Internal use (edit a property data_path)''' + """Internal use (edit a property data_path)""" bl_idname = "wm.properties_add" bl_label = "Add Property" bl_options = {'UNDO'} @@ -1138,7 +1138,7 @@ class WM_OT_properties_context_change(Operator): class WM_OT_properties_remove(Operator): - '''Internal use (edit a property data_path)''' + """Internal use (edit a property data_path)""" bl_idname = "wm.properties_remove" bl_label = "Remove Property" bl_options = {'UNDO'} @@ -1204,7 +1204,7 @@ class WM_OT_appconfig_activate(Operator): class WM_OT_sysinfo(Operator): - '''Generate System Info''' + """Generate System Info""" bl_idname = "wm.sysinfo" bl_label = "System Info" @@ -1215,7 +1215,7 @@ class WM_OT_sysinfo(Operator): class WM_OT_copy_prev_settings(Operator): - '''Copy settings from previous version''' + """Copy settings from previous version""" bl_idname = "wm.copy_prev_settings" bl_label = "Copy Previous Settings" @@ -1252,7 +1252,7 @@ class WM_OT_copy_prev_settings(Operator): class WM_OT_blenderplayer_start(Operator): - '''Launch the blender-player with the current blend-file''' + """Launch the blender-player with the current blend-file""" bl_idname = "wm.blenderplayer_start" bl_label = "Start Game In Player" @@ -1597,10 +1597,11 @@ class WM_OT_addon_disable(Operator): addon_utils.disable(self.module) return {'FINISHED'} + class WM_OT_theme_install(Operator): "Install a theme" bl_idname = "wm.theme_install" - bl_label = "Install Theme..." + bl_label = "Install Theme..." overwrite = BoolProperty( name="Overwrite", @@ -1624,10 +1625,10 @@ class WM_OT_theme_install(Operator): import os import shutil import traceback - + xmlfile = self.filepath - path_themes = bpy.utils.user_resource('SCRIPTS','presets/interface_theme',create=True) + path_themes = bpy.utils.user_resource('SCRIPTS', "presets/interface_theme", create=True) if not path_themes: self.report({'ERROR'}, "Failed to get themes path") @@ -1642,7 +1643,7 @@ class WM_OT_theme_install(Operator): try: shutil.copyfile(xmlfile, path_dest) - bpy.ops.script.execute_preset(filepath=path_dest,menu_idname="USERPREF_MT_interface_theme_presets") + bpy.ops.script.execute_preset(filepath=path_dest, menu_idname="USERPREF_MT_interface_theme_presets") except: traceback.print_exc() @@ -1650,7 +1651,6 @@ class WM_OT_theme_install(Operator): return {'FINISHED'} - def invoke(self, context, event): wm = context.window_manager wm.fileselect_add(self) diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py index 6bec652045e..03aa41bb9aa 100644 --- a/release/scripts/startup/bl_ui/properties_data_armature.py +++ b/release/scripts/startup/bl_ui/properties_data_armature.py @@ -203,7 +203,7 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel): col.operator("poselib.pose_remove", icon='ZOOMOUT', text="") col.operator("poselib.apply_pose", icon='ZOOM_SELECTED', text="").pose_index = poselib.pose_markers.active_index - col.operator("poselib.action_sanitise", icon='HELP', text="") # XXX: put in menu? + col.operator("poselib.action_sanitize", icon='HELP', text="") # XXX: put in menu? # properties for active marker if pose_marker_active is not None: @@ -304,7 +304,7 @@ class DATA_PT_motion_paths(MotionPathButtonsPanel, Panel): layout = self.layout ob = context.object - avs = ob.pose.animation_visualisation + avs = ob.pose.animation_visualization pchan = context.active_pose_bone mpath = pchan.motion_path if pchan else None @@ -323,7 +323,7 @@ class DATA_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit from def draw(self, context): ob = context.object - self.draw_settings(context, ob.pose.animation_visualisation, bones=True) + self.draw_settings(context, ob.pose.animation_visualization, bones=True) class DATA_PT_custom_props_arm(ArmatureButtonsPanel, PropertyPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py b/release/scripts/startup/bl_ui/properties_data_bone.py index 0f09893647a..e6d9affee93 100644 --- a/release/scripts/startup/bl_ui/properties_data_bone.py +++ b/release/scripts/startup/bl_ui/properties_data_bone.py @@ -120,13 +120,13 @@ class BONE_PT_transform_locks(BoneButtonsPanel, Panel): pchan = ob.pose.bones[bone.name] split = layout.split(percentage=0.1) - + col = split.column(align=True) col.label(text="") col.label(text="X:") col.label(text="Y:") col.label(text="Z:") - + col = split.row() sub = col.row() sub.active = not (bone.parent and bone.use_connect) @@ -137,7 +137,7 @@ class BONE_PT_transform_locks(BoneButtonsPanel, Panel): if pchan.rotation_mode in {'QUATERNION', 'AXIS_ANGLE'}: row = layout.row() row.prop(pchan, "lock_rotations_4d", text="Lock Rotation") - + sub = row.row() sub.active = pchan.lock_rotations_4d sub.prop(pchan, "lock_rotation_w", text="W") diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py index 6a7415f7cec..1e9fd5dd8a9 100644 --- a/release/scripts/startup/bl_ui/properties_data_curve.py +++ b/release/scripts/startup/bl_ui/properties_data_curve.py @@ -33,7 +33,7 @@ class CurveButtonsPanel(): class CurveButtonsPanelCurve(CurveButtonsPanel): - '''Same as above but for curves only''' + """Same as above but for curves only""" @classmethod def poll(cls, context): @@ -41,7 +41,7 @@ class CurveButtonsPanelCurve(CurveButtonsPanel): class CurveButtonsPanelActive(CurveButtonsPanel): - '''Same as above but for curves only''' + """Same as above but for curves only""" @classmethod def poll(cls, context): @@ -406,7 +406,7 @@ class DATA_PT_text_boxes(CurveButtonsPanel, Panel): col.prop(box, "x", text="X") col.prop(box, "y", text="Y") - row.operator("font.textbox_remove", text='', icon='X', emboss=False).index = i + row.operator("font.textbox_remove", text="", icon='X', emboss=False).index = i class DATA_PT_custom_props_curve(CurveButtonsPanel, PropertyPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 2e980f776a1..abcd27c308e 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -969,7 +969,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.label(text="Selected Vertices:") split = layout.split() - + col = split.column(align=True) col.operator("object.skin_loose_mark_clear", text="Mark Loose").action = "MARK" col.operator("object.skin_loose_mark_clear", text="Clear Loose").action = "CLEAR" @@ -983,6 +983,6 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col.prop(md, "use_x_symmetry") col.prop(md, "use_y_symmetry") col.prop(md, "use_z_symmetry") - + if __name__ == "__main__": # only for live edit. bpy.utils.register_module(__name__) diff --git a/release/scripts/startup/bl_ui/properties_game.py b/release/scripts/startup/bl_ui/properties_game.py index 549e2181a2b..0b6e4154050 100644 --- a/release/scripts/startup/bl_ui/properties_game.py +++ b/release/scripts/startup/bl_ui/properties_game.py @@ -50,6 +50,8 @@ class PHYSICS_PT_game_physics(PhysicsButtonsPanel, Panel): physics_type = game.physics_type if physics_type == 'CHARACTER': + layout.prop(game, "use_actor") + layout.prop(ob, "hide_render", text="Invisible") # out of place but useful layout.prop(game, "step_height", slider=True) layout.prop(game, "jump_speed") layout.prop(game, "fall_speed") diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py index 87c62e2791f..86fc1dac4fc 100644 --- a/release/scripts/startup/bl_ui/properties_object.py +++ b/release/scripts/startup/bl_ui/properties_object.py @@ -105,13 +105,13 @@ class OBJECT_PT_transform_locks(ObjectButtonsPanel, Panel): ob = context.object split = layout.split(percentage=0.1) - + col = split.column(align=True) col.label(text="") col.label(text="X:") col.label(text="Y:") col.label(text="Z:") - + col = split.row() col.column().prop(ob, "lock_location", text="Location") col.column().prop(ob, "lock_rotation", text="Rotation") @@ -120,7 +120,7 @@ class OBJECT_PT_transform_locks(ObjectButtonsPanel, Panel): if ob.rotation_mode in {'QUATERNION', 'AXIS_ANGLE'}: row = layout.row() row.prop(ob, "lock_rotations_4d", text="Lock Rotation") - + sub = row.row() sub.active = ob.lock_rotations_4d sub.prop(ob, "lock_rotation_w", text="W") @@ -159,7 +159,7 @@ class OBJECT_PT_groups(ObjectButtonsPanel, Panel): def draw(self, context): layout = self.layout - ob = context.object + obj = context.object row = layout.row(align=True) row.operator("object.group_link", text="Add to Group") @@ -167,8 +167,13 @@ class OBJECT_PT_groups(ObjectButtonsPanel, Panel): # XXX, this is bad practice, yes, I wrote it :( - campbell index = 0 + obj_name = obj.name for group in bpy.data.groups: - if ob.name in group.objects: + # XXX this is slow and stupid!, we need 2 checks, one thats fast + # and another that we can be sure its not a name collission + # from linked library data + group_objects = group.objects + if obj_name in group.objects and obj in group_objects[:]: col = layout.column(align=True) col.context_pointer_set("group", group) @@ -304,7 +309,7 @@ class OBJECT_PT_motion_paths(MotionPathButtonsPanel, Panel): layout = self.layout ob = context.object - avs = ob.animation_visualisation + avs = ob.animation_visualization mpath = ob.motion_path self.draw_settings(context, avs, mpath) @@ -321,7 +326,7 @@ class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit fr def draw(self, context): ob = context.object - self.draw_settings(context, ob.animation_visualisation) + self.draw_settings(context, ob.animation_visualization) class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_physics_field.py b/release/scripts/startup/bl_ui/properties_physics_field.py index 2054215df4a..65603c65041 100644 --- a/release/scripts/startup/bl_ui/properties_physics_field.py +++ b/release/scripts/startup/bl_ui/properties_physics_field.py @@ -195,7 +195,7 @@ class PHYSICS_PT_collision(PhysicButtonsPanel, Panel): col = split.column() col.label(text="Particle:") col.prop(settings, "permeability", slider=True) - col.prop(settings, "stickness") + col.prop(settings, "stickiness") col.prop(settings, "use_particle_kill") col.label(text="Particle Damping:") sub = col.column(align=True) diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py index 751f3e18acc..a53c1c97336 100644 --- a/release/scripts/startup/bl_ui/properties_physics_fluid.py +++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py @@ -117,10 +117,14 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel): col.prop(fluid, "use_animated_mesh") col = split.column() - col.label(text="Slip Type:") - col.prop(fluid, "slip_type", text="") + subsplit = col.split() + subcol = subsplit.column() + if fluid.use_animated_mesh: + subcol.enabled = False + subcol.label(text="Slip Type:") + subcol.prop(fluid, "slip_type", text="") if fluid.slip_type == 'PARTIALSLIP': - col.prop(fluid, "partial_slip_factor", slider=True, text="Amount") + subcol.prop(fluid, "partial_slip_factor", slider=True, text="Amount") col.label(text="Impact:") col.prop(fluid, "impact_factor", text="Factor") diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 9dc6c62a9e0..1ed3638080a 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -526,7 +526,7 @@ class RENDER_PT_encoding(RenderButtonsPanel, Panel): if ffmpeg.format in {'AVI', 'QUICKTIME', 'MKV', 'OGG'}: split.prop(ffmpeg, "codec") elif rd.ffmpeg.format == 'H264': - split.prop(ffmpeg, 'use_lossless_output') + split.prop(ffmpeg, "use_lossless_output") else: split.label() @@ -575,7 +575,7 @@ class RENDER_PT_bake(RenderButtonsPanel, Panel): multires_bake = False if rd.bake_type in ['NORMALS', 'DISPLACEMENT']: - layout.prop(rd, 'use_bake_multires') + layout.prop(rd, "use_bake_multires") multires_bake = rd.use_bake_multires if not multires_bake: diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index af8fcc6cbdc..c9c9c36217b 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -165,7 +165,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel): row.label(text="Array Target:") row.prop(ksp, "use_entire_array", text="All Items") if ksp.use_entire_array: - row.label(text=" ") # padding + row.label(text=" ") # padding else: row.prop(ksp, "array_index", text="Index") @@ -177,7 +177,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, Panel): col.prop(ksp, "group_method", text="") if ksp.group_method == 'NAMED': col.prop(ksp, "group") - + col = row.column(align=True) col.label(text="Keyframing Settings:") col.prop(ksp, "bl_options") diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index 1d5e96cf701..5bde9538e54 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -23,6 +23,7 @@ from bpy.types import Menu, Panel from bpy.types import (Brush, Lamp, Material, + Object, ParticleSettings, Texture, World) @@ -80,6 +81,15 @@ def context_tex_datablock(context): return idblock +def id_tex_datablock(bid): + if isinstance(bid, Object): + if bid.type == 'LAMP': + return bid.data + return bid.active_material + + return bid + + class TextureButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' @@ -114,7 +124,7 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel): pin_id = space.pin_id if space.use_pin_id and not isinstance(pin_id, Texture): - idblock = pin_id + idblock = id_tex_datablock(pin_id) pin_id = None if not space.use_pin_id: diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index a77302ff4ae..374588939e2 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -48,7 +48,7 @@ class CLIP_HT_header(Header): sub.menu("CLIP_MT_clip") row = layout.row() - row.template_ID(sc, "clip", open='clip.open') + row.template_ID(sc, "clip", open="clip.open") if clip: tracking = clip.tracking @@ -95,7 +95,8 @@ class CLIP_HT_header(Header): row = layout.row(align=True) row.prop(dopesheet, "sort_method", text="") - row.prop(dopesheet, "use_invert_sort", text="Invert", toggle=True) + row.prop(dopesheet, "use_invert_sort", + text="Invert", toggle=True) else: layout.prop(sc, "view", text="", expand=True) @@ -121,7 +122,7 @@ class CLIP_HT_header(Header): sub.menu("CLIP_MT_clip") row = layout.row() - row.template_ID(sc, "clip", open='clip.open') + row.template_ID(sc, "clip", open="clip.open") layout.prop(sc, "mode", text="") @@ -255,7 +256,7 @@ class CLIP_PT_tools_marker(CLIP_PT_tracking_panel, Panel): col.prop(settings, "default_pattern_match", text="") col.separator() - col.operator('clip.track_settings_as_default', + col.operator("clip.track_settings_as_default", text="Copy From Active Track") @@ -340,9 +341,9 @@ class CLIP_PT_tools_cleanup(CLIP_PT_tracking_panel, Panel): layout.operator("clip.clean_tracks") - layout.prop(settings, 'clean_frames', text="Frames") - layout.prop(settings, 'clean_error', text="Error") - layout.prop(settings, 'clean_action', text="") + layout.prop(settings, "clean_frames", text="Frames") + layout.prop(settings, "clean_error", text="Error") + layout.prop(settings, "clean_action", text="") class CLIP_PT_tools_geometry(CLIP_PT_reconstruction_panel, Panel): @@ -553,7 +554,8 @@ class CLIP_PT_track(CLIP_PT_tracking_panel, Panel): row.separator() sub = row.row() - sub.prop(act_track, "use_alpha_preview", text="", toggle=True, icon='IMAGE_ALPHA') + sub.prop(act_track, "use_alpha_preview", + text="", toggle=True, icon='IMAGE_ALPHA') layout.separator() @@ -735,7 +737,9 @@ class CLIP_PT_active_mask_point(Panel): mask = sc.mask if mask and sc.mode == 'MASKEDIT': - return mask.layers.active and mask.layers.active.splines.active_point + mask_layer_active = mask.layers.active + return (mask_layer_active and + mask_layer_active.splines.active_point) return False @@ -979,7 +983,7 @@ class CLIP_PT_proxy(CLIP_PT_clip_view_panel, Panel): layout.prop(clip.proxy, "quality") - layout.prop(clip, 'use_proxy_custom_directory') + layout.prop(clip, "use_proxy_custom_directory") if clip.use_proxy_custom_directory: layout.prop(clip.proxy, "directory") @@ -1053,7 +1057,8 @@ class CLIP_MT_view(Menu): for a, b in ratios: text = "Zoom %d:%d" % (a, b) - layout.operator("clip.view_zoom_ratio", text=text).ratio = a / b + layout.operator("clip.view_zoom_ratio", + text=text).ratio = a / b else: layout.prop(sc, "show_seconds") layout.separator() @@ -1203,16 +1208,20 @@ class CLIP_MT_select(Menu): layout.separator() - layout.operator("mask.select_all").action = 'TOGGLE' - layout.operator("mask.select_all", text="Inverse").action = 'INVERT' + layout.operator("mask.select_all" + ).action = 'TOGGLE' + layout.operator("mask.select_all", + text="Inverse").action = 'INVERT' else: layout.operator("clip.select_border") layout.operator("clip.select_circle") layout.separator() - layout.operator("clip.select_all").action = 'TOGGLE' - layout.operator("clip.select_all", text="Inverse").action = 'INVERT' + layout.operator("clip.select_all" + ).action = 'TOGGLE' + layout.operator("clip.select_all", + text="Inverse").action = 'INVERT' layout.menu("CLIP_MT_select_grouped") @@ -1317,6 +1326,7 @@ class CLIP_MT_mask_animation(Menu): layout.operator("mask.shape_key_clear") layout.operator("mask.shape_key_insert") layout.operator("mask.shape_key_feather_reset") + layout.operator("mask.shape_key_rekey") class CLIP_MT_camera_presets(Menu): @@ -1349,7 +1359,7 @@ class CLIP_MT_track_color_specials(Menu): def draw(self, context): layout = self.layout - layout.operator('clip.track_copy_color', icon='COPY_ID') + layout.operator("clip.track_copy_color", icon='COPY_ID') class CLIP_MT_stabilize_2d_specials(Menu): @@ -1358,7 +1368,7 @@ class CLIP_MT_stabilize_2d_specials(Menu): def draw(self, context): layout = self.layout - layout.operator('clip.stabilize_2d_select') + layout.operator("clip.stabilize_2d_select") if __name__ == "__main__": # only for live edit. bpy.utils.register_module(__name__) diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index 9cf4a337483..8ddb2df352a 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -371,16 +371,16 @@ class INFO_MT_help(Menu): def draw(self, context): layout = self.layout - layout.operator("wm.url_open", text="Manual", icon='HELP').url = 'http://wiki.blender.org/index.php/Doc:2.6/Manual' - layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-263/' + layout.operator("wm.url_open", text="Manual", icon='HELP').url = "http://wiki.blender.org/index.php/Doc:2.6/Manual" + layout.operator("wm.url_open", text="Release Log", icon='URL').url = "http://www.blender.org/development/release-logs/blender-263" layout.separator() - layout.operator("wm.url_open", text="Blender Website", icon='URL').url = 'http://www.blender.org/' - layout.operator("wm.url_open", text="Blender e-Shop", icon='URL').url = 'http://www.blender.org/e-shop' - layout.operator("wm.url_open", text="Developer Community", icon='URL').url = 'http://www.blender.org/community/get-involved/' - layout.operator("wm.url_open", text="User Community", icon='URL').url = 'http://www.blender.org/community/user-community/' + layout.operator("wm.url_open", text="Blender Website", icon='URL').url = "http://www.blender.org" + layout.operator("wm.url_open", text="Blender e-Shop", icon='URL').url = "http://www.blender.org/e-shop" + layout.operator("wm.url_open", text="Developer Community", icon='URL').url = "http://www.blender.org/community/get-involved" + layout.operator("wm.url_open", text="User Community", icon='URL').url = "http://www.blender.org/community/user-community" layout.separator() - layout.operator("wm.url_open", text="Report a Bug", icon='URL').url = 'http://projects.blender.org/tracker/?atid=498&group_id=9&func=browse' + layout.operator("wm.url_open", text="Report a Bug", icon='URL').url = "http://projects.blender.org/tracker/?atid=498&group_id=9&func=browse" layout.separator() layout.operator("wm.url_open", text="Python API Reference", icon='URL').url = bpy.types.WM_OT_doc_view._prefix diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index b4100819ab0..40c7b632247 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -32,6 +32,7 @@ class NODE_HT_header(Header): snode = context.space_data snode_id = snode.id id_from = snode.id_from + toolsettings = context.tool_settings row = layout.row(align=True) row.template_header() @@ -86,6 +87,13 @@ class NODE_HT_header(Header): layout.separator() + # Snap + row = layout.row(align=True) + row.prop(toolsettings, "use_snap", text="") + row.prop(toolsettings, "snap_node_element", text="", icon_only=True) + if toolsettings.snap_node_element != 'INCREMENT': + row.prop(toolsettings, "snap_target", text="") + layout.template_running_jobs() @@ -205,10 +213,11 @@ class NODE_PT_properties(Panel): col.prop(snode, "backdrop_y", text="Y") col.operator("node.backimage_move", text="Move") + class NODE_PT_quality(bpy.types.Panel): bl_space_type = 'NODE_EDITOR' bl_region_type = 'UI' - bl_label = "Quality" + bl_label = "Performance" @classmethod def poll(cls, context): @@ -224,8 +233,10 @@ class NODE_PT_quality(bpy.types.Panel): layout.prop(tree, "edit_quality", text="Edit") layout.prop(tree, "chunk_size") layout.prop(tree, "use_opencl") - + layout.prop(tree, "two_pass") + layout.prop(snode, "show_highlight") + class NODE_MT_node_color_presets(Menu): """Predefined node color""" bl_label = "Color Presets" @@ -240,8 +251,8 @@ class NODE_MT_node_color_specials(Menu): def draw(self, context): layout = self.layout - layout.operator('node.node_copy_color', icon='COPY_ID') + layout.operator("node.node_copy_color", icon='COPY_ID') + - if __name__ == "__main__": # only for live edit. bpy.utils.register_module(__name__) diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 276e8e5ae1d..76053987843 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -256,7 +256,7 @@ class SEQUENCER_MT_strip(Menu): layout.operator("sequencer.rebuild_proxy") layout.separator() - layout.operator("sequencer.duplicate") + layout.operator("sequencer.duplicate_move") layout.operator("sequencer.delete") strip = act_strip(context) @@ -352,7 +352,7 @@ class SEQUENCER_PT_edit(SequencerButtonsPanel, Panel): def draw(self, context): layout = self.layout - + scene = context.scene frame_current = scene.frame_current strip = act_strip(context) @@ -474,7 +474,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): elif strip.type == 'TRANSFORM': layout = self.layout col = layout.column() - + col.prop(strip, "interpolation") col.prop(strip, "translation_unit") col = layout.column(align=True) @@ -483,7 +483,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): col.prop(strip, "translate_start_y", text="Y") layout.separator() - + col = layout.column(align=True) col.prop(strip, "use_uniform_scale") if (strip.use_uniform_scale): @@ -568,10 +568,10 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, Panel): split = layout.split(percentage=0.2) split.label(text="Path:") split.prop(strip, "filepath", text="") - + layout.prop(strip, "mpeg_preseek") layout.prop(strip, "stream_index") - + layout.prop(strip, "use_translation", text="Image Offset") if strip.use_translation: col = layout.column(align=True) @@ -740,13 +740,13 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel): col = layout.column() col.label(text="Distortion:") col.prop(strip, "undistort") - + split = layout.split(percentage=0.65) col = split.column() col.prop(strip, "use_reverse_frames", text="Backwards") col.prop(strip, "use_deinterlace") - + col = split.column() col.label(text="Flip:") col.prop(strip, "use_flip_x", text="X") diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 2d349931dc4..7a147bac38c 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -245,7 +245,7 @@ class USERPREF_PT_interface(Panel): col.prop(view, "show_splash") - if os.name == 'nt': + if os.name == "nt": col.prop(view, "quit_dialog") @@ -419,7 +419,7 @@ class USERPREF_PT_system(Panel): col.separator() col.separator() - if hasattr(system, 'compute_device'): + if hasattr(system, "compute_device"): col.label(text="Compute Device:") col.row().prop(system, "compute_device_type", expand=True) sub = col.row() @@ -1094,7 +1094,7 @@ class USERPREF_PT_addons(Panel): rowsub = row.row() rowsub.active = is_enabled - rowsub.label(text='%s: %s' % (info['category'], info["name"])) + rowsub.label(text='%s: %s' % (info["category"], info["name"])) if info["warning"]: rowsub.label(icon='ERROR') diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index b525ab922d2..3819ae60b49 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -979,7 +979,9 @@ class VIEW3D_MT_object_group(Menu): layout = self.layout layout.operator("group.create") + # layout.operator_menu_enum("group.objects_remove", "group") # BUGGY layout.operator("group.objects_remove") + layout.operator("group.objects_remove_all") layout.separator() @@ -2391,7 +2393,7 @@ class VIEW3D_PT_view3d_display(Panel): col.prop(gs, "material_mode", text="") col.prop(view, "show_textured_solid") - col.prop(view, "show_backface_culling") + col.prop(view, "show_backface_culling") layout.separator() @@ -2556,7 +2558,7 @@ class VIEW3D_PT_background_image(Panel): has_bg = True elif bg.source == 'MOVIE_CLIP': - box.prop(bg, 'use_camera_clip') + box.prop(bg, "use_camera_clip") column = box.column() column.active = not bg.use_camera_clip diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 454541f7069..4818d42c99f 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -676,6 +676,8 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): row.prop(brush, "jitter", slider=True) row.prop(brush, "use_pressure_jitter", toggle=True, text="") + col.prop(brush, "vertex_tool", text="Blend") + # Vertex Paint Mode # elif context.vertex_paint_object and brush: col = layout.column() @@ -695,6 +697,8 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): #row.prop(brush, "jitter", slider=True) #row.prop(brush, "use_pressure_jitter", toggle=True, text="") + col.prop(brush, "vertex_tool", text="Blend") + class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel): bl_label = "Texture" @@ -988,7 +992,7 @@ class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel): col.prop(mesh, "use_mirror_topology") col.prop(wpaint, "input_samples") - + self.unified_paint_settings(col, context) # Commented out because the Apply button isn't an operator yet, making these settings useless @@ -1139,7 +1143,7 @@ class VIEW3D_MT_tools_projectpaint_stencil(Menu): class VIEW3D_PT_tools_particlemode(View3DPanel, Panel): - '''default tools for particle mode''' + """default tools for particle mode""" bl_context = "particlemode" bl_label = "Options" diff --git a/release/scripts/templates/operator_file_export.py b/release/scripts/templates/operator_file_export.py index e3e0217e26a..9511cb163bc 100644 --- a/release/scripts/templates/operator_file_export.py +++ b/release/scripts/templates/operator_file_export.py @@ -18,7 +18,7 @@ from bpy.types import Operator class ExportSomeData(Operator, ExportHelper): - '''This appears in the tooltip of the operator and in the generated docs''' + """This appears in the tooltip of the operator and in the generated docs""" bl_idname = "export_test.some_data" # important since its how bpy.ops.import_test.some_data is constructed bl_label = "Export Some Data" diff --git a/release/scripts/templates/operator_file_import.py b/release/scripts/templates/operator_file_import.py index 80d850aae60..9940a1b98eb 100644 --- a/release/scripts/templates/operator_file_import.py +++ b/release/scripts/templates/operator_file_import.py @@ -21,7 +21,7 @@ from bpy.types import Operator class ImportSomeData(Operator, ImportHelper): - '''This appears in the tooltip of the operator and in the generated docs''' + """This appears in the tooltip of the operator and in the generated docs""" bl_idname = "import_test.some_data" # important since its how bpy.ops.import_test.some_data is constructed bl_label = "Import Some Data" diff --git a/release/scripts/templates/operator_mesh_add.py b/release/scripts/templates/operator_mesh_add.py index 3228e3c4d62..f2bb231cb7a 100644 --- a/release/scripts/templates/operator_mesh_add.py +++ b/release/scripts/templates/operator_mesh_add.py @@ -37,7 +37,7 @@ from bpy.props import FloatProperty, BoolProperty, FloatVectorProperty class AddBox(bpy.types.Operator): - '''Add a simple box mesh''' + """Add a simple box mesh""" bl_idname = "mesh.primitive_box_add" bl_label = "Add Box" bl_options = {'REGISTER', 'UNDO'} diff --git a/release/scripts/templates/operator_modal.py b/release/scripts/templates/operator_modal.py index a428b097f82..d8115bc95bf 100644 --- a/release/scripts/templates/operator_modal.py +++ b/release/scripts/templates/operator_modal.py @@ -3,7 +3,7 @@ from bpy.props import IntProperty, FloatProperty class ModalOperator(bpy.types.Operator): - '''Move an object with the mouse, example.''' + """Move an object with the mouse, example""" bl_idname = "object.modal_operator" bl_label = "Simple Modal Operator" diff --git a/release/scripts/templates/operator_modal_draw.py b/release/scripts/templates/operator_modal_draw.py index b3d525a59bf..f2d5ad8982b 100644 --- a/release/scripts/templates/operator_modal_draw.py +++ b/release/scripts/templates/operator_modal_draw.py @@ -31,7 +31,7 @@ def draw_callback_px(self, context): class ModalDrawOperator(bpy.types.Operator): - '''Draw a line with the mouse''' + """Draw a line with the mouse""" bl_idname = "view3d.modal_operator" bl_label = "Simple Modal View3D Operator" diff --git a/release/scripts/templates/operator_modal_timer.py b/release/scripts/templates/operator_modal_timer.py index ebbf6395df5..6d2ec95aedb 100644 --- a/release/scripts/templates/operator_modal_timer.py +++ b/release/scripts/templates/operator_modal_timer.py @@ -2,7 +2,7 @@ import bpy class ModalTimerOperator(bpy.types.Operator): - '''Operator which runs its self from a timer.''' + """Operator which runs its self from a timer""" bl_idname = "wm.modal_timer_operator" bl_label = "Modal Timer Operator" diff --git a/release/scripts/templates/operator_modal_view3d.py b/release/scripts/templates/operator_modal_view3d.py index 263bf72f129..0babf169610 100644 --- a/release/scripts/templates/operator_modal_view3d.py +++ b/release/scripts/templates/operator_modal_view3d.py @@ -4,7 +4,7 @@ from bpy.props import FloatVectorProperty class ViewOperator(bpy.types.Operator): - '''Translate the view using mouse events.''' + """Translate the view using mouse events""" bl_idname = "view3d.modal_operator" bl_label = "Simple View Operator" diff --git a/release/scripts/templates/operator_modal_view3d_raycast.py b/release/scripts/templates/operator_modal_view3d_raycast.py new file mode 100644 index 00000000000..3236c08cc8c --- /dev/null +++ b/release/scripts/templates/operator_modal_view3d_raycast.py @@ -0,0 +1,107 @@ +import bpy +from mathutils import Vector +from bpy_extras import view3d_utils + + +def main(context, event, ray_max=10000.0): + """Run this function on left mouse, execute the ray cast""" + # get the context arguments + scene = context.scene + region = context.region + rv3d = context.region_data + coord = event.mouse_region_x, event.mouse_region_y + + # get the ray from the viewport and mouse + view_vector = view3d_utils.region_2d_to_vector_3d(region, rv3d, coord) + ray_origin = view3d_utils.region_2d_to_origin_3d(region, rv3d, coord) + ray_target = ray_origin + (view_vector * ray_max) + + scene.cursor_location = ray_target + + def visible_objects_and_duplis(): + """Loop over (object, matrix) pairs (mesh only)""" + + for obj in context.visible_objects: + if obj.type == 'MESH': + yield (obj, obj.matrix_world.copy()) + + if obj.dupli_type != 'NONE': + obj.dupli_list_create(scene) + for dob in obj.dupli_list: + obj_dupli = dob.object + if obj_dupli.type == 'MESH': + yield (obj_dupli, dob.matrix.copy()) + + obj.dupli_list_clear() + + def obj_ray_cast(obj, matrix): + """Wrapper for ray casting that moves the ray into object space""" + + # get the ray relative to the object + matrix_inv = matrix.inverted() + ray_origin_obj = matrix_inv * ray_origin + ray_target_obj = matrix_inv * ray_target + + # cast the ray + hit, normal, face_index = obj.ray_cast(ray_origin_obj, ray_target_obj) + + if face_index != -1: + return hit, normal, face_index + else: + return None, None, None + + # cast rays and find the closest object + best_length_squared = ray_max * ray_max + best_obj = None + + for obj, matrix in visible_objects_and_duplis(): + if obj.type == 'MESH': + hit, normal, face_index = obj_ray_cast(obj, matrix) + if hit is not None: + length_squared = (hit - ray_origin).length_squared + if length_squared < best_length_squared: + best_length_squared = length_squared + best_obj = obj + + # now we have the object under the mouse cursor, + # we could do lots of stuff but for the example just select. + if best_obj is not None: + best_obj.select = True + + +class ViewOperatorRayCast(bpy.types.Operator): + """Modal object selection with a ray cast""" + bl_idname = "view3d.modal_operator_raycast" + bl_label = "RayCast View Operator" + + def modal(self, context, event): + if event.type in {'MIDDLEMOUSE', 'WHEELUPMOUSE', 'WHEELDOWNMOUSE'}: + # allow navigation + return {'PASS_THROUGH'} + elif event.type == 'LEFTMOUSE': + main(context, event) + return {'RUNNING_MODAL'} + elif event.type in {'RIGHTMOUSE', 'ESC'}: + return {'CANCELLED'} + + return {'RUNNING_MODAL'} + + def invoke(self, context, event): + if context.space_data.type == 'VIEW_3D': + context.window_manager.modal_handler_add(self) + return {'RUNNING_MODAL'} + else: + self.report({'WARNING'}, "Active space must be a View3d") + return {'CANCELLED'} + + +def register(): + bpy.utils.register_class(ViewOperatorRayCast) + + +def unregister(): + bpy.utils.unregister_class(ViewOperatorRayCast) + + +if __name__ == "__main__": + register() diff --git a/release/scripts/templates/operator_node.py b/release/scripts/templates/operator_node.py index 5962651995b..b689ce7634e 100644 --- a/release/scripts/templates/operator_node.py +++ b/release/scripts/templates/operator_node.py @@ -1,7 +1,7 @@ import bpy -def main(operator, context): +def main(context): space = context.space_data node_tree = space.node_tree node_active = context.active_node @@ -33,7 +33,7 @@ def main(operator, context): class NodeOperator(bpy.types.Operator): - '''Tooltip''' + """Tooltip""" bl_idname = "node.simple_operator" bl_label = "Simple Node Operator" diff --git a/release/scripts/templates/operator_simple.py b/release/scripts/templates/operator_simple.py index 05d9afc0ad1..715daa3a8b4 100644 --- a/release/scripts/templates/operator_simple.py +++ b/release/scripts/templates/operator_simple.py @@ -7,7 +7,7 @@ def main(context): class SimpleOperator(bpy.types.Operator): - '''Tooltip''' + """Tooltip""" bl_idname = "object.simple_operator" bl_label = "Simple Object Operator" diff --git a/release/scripts/templates/operator_uv.py b/release/scripts/templates/operator_uv.py index 93fec117fa1..fdd0b993f8b 100644 --- a/release/scripts/templates/operator_uv.py +++ b/release/scripts/templates/operator_uv.py @@ -27,7 +27,7 @@ def main(context): class UvOperator(bpy.types.Operator): - '''UV Operator description''' + """UV Operator description""" bl_idname = "uv.simple_operator" bl_label = "Simple UV Operator" diff --git a/source/SConscript b/source/SConscript index cfb204cd52a..fdd126b28c6 100644 --- a/source/SConscript +++ b/source/SConscript @@ -1,7 +1,7 @@ #!/usr/bin/python Import ('env') -SConscript(['blender/SConscript', 'creator/SConscript']) +SConscript(['blender/SConscript']) if env['WITH_BF_GAMEENGINE']: SConscript (['gameengine/SConscript']) diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index a0d840b5de6..3c756668578 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -95,12 +95,10 @@ add_subdirectory(blenkernel) add_subdirectory(blenlib) add_subdirectory(bmesh) add_subdirectory(render) -add_subdirectory(compositor) add_subdirectory(blenfont) add_subdirectory(blenloader) add_subdirectory(ikplugin) add_subdirectory(gpu) -add_subdirectory(opencl) add_subdirectory(imbuf) add_subdirectory(avi) add_subdirectory(nodes) @@ -108,6 +106,11 @@ add_subdirectory(modifiers) add_subdirectory(makesdna) add_subdirectory(makesrna) +if(WITH_COMPOSITOR) + add_subdirectory(opencl) # later on this may be used more generally + add_subdirectory(compositor) +endif() + if(WITH_IMAGE_OPENEXR) add_subdirectory(imbuf/intern/openexr) endif() diff --git a/source/blender/SConscript b/source/blender/SConscript index c2ca6eb5ae5..e1f81f9aaba 100644 --- a/source/blender/SConscript +++ b/source/blender/SConscript @@ -8,11 +8,9 @@ SConscript(['avi/SConscript', 'blenlib/SConscript', 'blenloader/SConscript', 'gpu/SConscript', - 'opencl/SConscript', 'editors/SConscript', 'imbuf/SConscript', 'makesdna/SConscript', - 'compositor/SConscript', 'render/SConscript', 'nodes/SConscript', 'modifiers/SConscript', @@ -39,3 +37,7 @@ if env['WITH_BF_QUICKTIME']: if env['WITH_BF_COLLADA']: SConscript (['collada/SConscript']) + +if env['WITH_BF_COMPOSITOR']: + SConscript (['compositor/SConscript', + 'opencl/SConscript']) diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index c7ddab47952..64512dcaac8 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -28,12 +28,14 @@ #ifndef __BKE_DERIVEDMESH_H__ #define __BKE_DERIVEDMESH_H__ -/* +/** * Basic design of the DerivedMesh system: * * DerivedMesh is a common set of interfaces for mesh systems. * - * There are three main mesh data structures in Blender: Mesh, CDDM, and BMesh. + * There are three main mesh data structures in Blender: + * #Mesh, #CDDerivedMesh and #BMesh. + * * These, and a few others, all implement DerivedMesh interfaces, * which contains unified drawing interfaces, a few utility interfaces, * and a bunch of read-only interfaces intended mostly for conversion from @@ -67,7 +69,6 @@ * as it is and stick with using BMesh and CDDM. */ - #include "DNA_customdata_types.h" #include "DNA_meshdata_types.h" @@ -151,7 +152,7 @@ typedef enum DMDirtyFlag { typedef struct DerivedMesh DerivedMesh; struct DerivedMesh { - /* Private DerivedMesh data, only for internal DerivedMesh use */ + /** Private DerivedMesh data, only for internal DerivedMesh use */ CustomData vertData, edgeData, faceData, loopData, polyData; int numVertData, numEdgeData, numTessFaceData, numLoopData, numPolyData; int needsFree; /* checked on ->release, is set to 0 for cached results */ @@ -162,10 +163,10 @@ struct DerivedMesh { float auto_bump_scale; DMDirtyFlag dirty; - /* calculate vert and face normals */ + /** Calculate vert and face normals */ void (*calcNormals)(DerivedMesh *dm); - /* recalculates mesh tessellation */ + /** Recalculates mesh tessellation */ void (*recalcTessellation)(DerivedMesh *dm); /* Misc. Queries */ @@ -177,7 +178,7 @@ struct DerivedMesh { int (*getNumLoops)(DerivedMesh *dm); int (*getNumPolys)(DerivedMesh *dm); - /* copy a single vert/edge/tessellated face from the derived mesh into + /** Copy a single vert/edge/tessellated face from the derived mesh into * *{vert/edge/face}_r. note that the current implementation * of this function can be quite slow, iterating over all * elements (editmesh) @@ -186,7 +187,7 @@ struct DerivedMesh { void (*getEdge)(DerivedMesh *dm, int index, struct MEdge *edge_r); void (*getTessFace)(DerivedMesh *dm, int index, struct MFace *face_r); - /* return a pointer to the entire array of verts/edges/face from the + /** Return a pointer to the entire array of verts/edges/face from the * derived mesh. if such an array does not exist yet, it will be created, * and freed on the next ->release(). consider using getVert/Edge/Face if * you are only interested in a few verts/edges/faces. @@ -197,7 +198,7 @@ struct DerivedMesh { struct MLoop *(*getLoopArray)(DerivedMesh * dm); struct MPoly *(*getPolyArray)(DerivedMesh * dm); - /* copy all verts/edges/faces from the derived mesh into + /** Copy all verts/edges/faces from the derived mesh into * *{vert/edge/face}_r (must point to a buffer large enough) */ void (*copyVertArray)(DerivedMesh *dm, struct MVert *vert_r); @@ -206,7 +207,7 @@ struct DerivedMesh { void (*copyLoopArray)(DerivedMesh *dm, struct MLoop *loop_r); void (*copyPolyArray)(DerivedMesh *dm, struct MPoly *poly_r); - /* return a copy of all verts/edges/faces from the derived mesh + /** Return a copy of all verts/edges/faces from the derived mesh * it is the caller's responsibility to free the returned pointer */ struct MVert *(*dupVertArray)(DerivedMesh * dm); @@ -215,7 +216,7 @@ struct DerivedMesh { struct MLoop *(*dupLoopArray)(DerivedMesh * dm); struct MPoly *(*dupPolyArray)(DerivedMesh * dm); - /* return a pointer to a single element of vert/edge/face custom data + /** Return a pointer to a single element of vert/edge/face custom data * from the derived mesh (this gives a pointer to the actual data, not * a copy) */ @@ -223,7 +224,7 @@ struct DerivedMesh { void *(*getEdgeData)(DerivedMesh * dm, int index, int type); void *(*getTessFaceData)(DerivedMesh * dm, int index, int type); - /* return a pointer to the entire array of vert/edge/face custom data + /** Return a pointer to the entire array of vert/edge/face custom data * from the derived mesh (this gives a pointer to the actual data, not * a copy) */ @@ -231,7 +232,7 @@ struct DerivedMesh { void *(*getEdgeDataArray)(DerivedMesh * dm, int type); void *(*getTessFaceDataArray)(DerivedMesh * dm, int type); - /* retrieves the base CustomData structures for + /** Retrieves the base CustomData structures for * verts/edges/tessfaces/loops/facdes*/ CustomData *(*getVertDataLayout)(DerivedMesh * dm); CustomData *(*getEdgeDataLayout)(DerivedMesh * dm); @@ -239,12 +240,12 @@ struct DerivedMesh { CustomData *(*getLoopDataLayout)(DerivedMesh * dm); CustomData *(*getPolyDataLayout)(DerivedMesh * dm); - /*copies all customdata for an element source into dst at index dest*/ + /** Copies all customdata for an element source into dst at index dest */ void (*copyFromVertCData)(DerivedMesh *dm, int source, CustomData *dst, int dest); void (*copyFromEdgeCData)(DerivedMesh *dm, int source, CustomData *dst, int dest); void (*copyFromFaceCData)(DerivedMesh *dm, int source, CustomData *dst, int dest); - /* optional grid access for subsurf */ + /** Optional grid access for subsurf */ int (*getNumGrids)(DerivedMesh *dm); int (*getGridSize)(DerivedMesh *dm); struct CCGElem **(*getGridData)(DerivedMesh * dm); @@ -255,7 +256,7 @@ struct DerivedMesh { unsigned int **(*getGridHidden)(DerivedMesh * dm); - /* Iterate over each mapped vertex in the derived mesh, calling the + /** Iterate over each mapped vertex in the derived mesh, calling the * given function with the original vert and the mapped vert's new * coordinate and normal. For historical reasons the normal can be * passed as a float or short array, only one should be non-NULL. @@ -265,7 +266,7 @@ struct DerivedMesh { const float no_f[3], const short no_s[3]), void *userData); - /* Iterate over each mapped edge in the derived mesh, calling the + /** Iterate over each mapped edge in the derived mesh, calling the * given function with the original edge and the mapped edge's new * coordinates. */ @@ -274,7 +275,7 @@ struct DerivedMesh { const float v0co[3], const float v1co[3]), void *userData); - /* Iterate over each mapped face in the derived mesh, calling the + /** Iterate over each mapped face in the derived mesh, calling the * given function with the original face and the mapped face's (or * faces') center and normal. */ @@ -283,51 +284,51 @@ struct DerivedMesh { const float cent[3], const float no[3]), void *userData); - /* Iterate over all vertex points, calling DO_MINMAX with given args. + /** Iterate over all vertex points, calling DO_MINMAX with given args. * * Also called in Editmode */ void (*getMinMax)(DerivedMesh *dm, float min_r[3], float max_r[3]); - /* Direct Access Operations */ - /* o Can be undefined */ - /* o Must be defined for modifiers that only deform however */ + /** Direct Access Operations + * - Can be undefined + * - Must be defined for modifiers that only deform however */ - /* Get vertex location, undefined if index is not valid */ + /** Get vertex location, undefined if index is not valid */ void (*getVertCo)(DerivedMesh *dm, int index, float co_r[3]); - /* Fill the array (of length .getNumVerts()) with all vertex locations */ + /** Fill the array (of length .getNumVerts()) with all vertex locations */ void (*getVertCos)(DerivedMesh *dm, float (*cos_r)[3]); - /* Get smooth vertex normal, undefined if index is not valid */ + /** Get smooth vertex normal, undefined if index is not valid */ void (*getVertNo)(DerivedMesh *dm, int index, float no_r[3]); - /* Get a map of vertices to faces + /** Get a map of vertices to faces */ const struct MeshElemMap *(*getPolyMap)(struct Object *ob, DerivedMesh *dm); - /* Get the BVH used for paint modes + /** Get the BVH used for paint modes */ struct PBVH *(*getPBVH)(struct Object *ob, DerivedMesh *dm); /* Drawing Operations */ - /* Draw all vertices as bgl points (no options) */ + /** Draw all vertices as bgl points (no options) */ void (*drawVerts)(DerivedMesh *dm); - /* Draw edges in the UV mesh (if exists) */ + /** Draw edges in the UV mesh (if exists) */ void (*drawUVEdges)(DerivedMesh *dm); - /* Draw all edges as lines (no options) + /** Draw all edges as lines (no options) * * Also called for *final* editmode DerivedMeshes */ void (*drawEdges)(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges); - /* Draw all loose edges (edges w/ no adjoining faces) */ + /** Draw all loose edges (edges w/ no adjoining faces) */ void (*drawLooseEdges)(DerivedMesh *dm); - /* Draw all faces + /** Draw all faces * o Set face normal or vertex normal based on inherited face flag * o Use inherited face material index to call setMaterial * o Only if setMaterial returns true @@ -337,24 +338,24 @@ struct DerivedMesh { void (*drawFacesSolid)(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast, DMSetMaterial setMaterial); - /* Draw all faces using MTFace - * o Drawing options too complicated to enumerate, look at code. + /** Draw all faces using MTFace + * - Drawing options too complicated to enumerate, look at code. */ void (*drawFacesTex)(DerivedMesh *dm, DMSetDrawOptionsTex setDrawOptions, DMCompareDrawOptions compareDrawOptions, void *userData); - /* Draw all faces with GLSL materials + /** Draw all faces with GLSL materials * o setMaterial is called for every different material nr * o Only if setMaterial returns true */ void (*drawFacesGLSL)(DerivedMesh *dm, DMSetMaterial setMaterial); - /* Draw mapped faces (no color, or texture) - * o Only if !setDrawOptions or - * setDrawOptions(userData, mapped-face-index, drawSmooth_r) - * returns true + /** Draw mapped faces (no color, or texture) + * - Only if !setDrawOptions or + * setDrawOptions(userData, mapped-face-index, drawSmooth_r) + * returns true * * If drawSmooth is set to true then vertex normals should be set and * glShadeModel called with GL_SMOOTH. Otherwise the face normal should @@ -371,36 +372,36 @@ struct DerivedMesh { void *userData, DMDrawFlag flag); - /* Draw mapped faces using MTFace - * o Drawing options too complicated to enumerate, look at code. + /** Draw mapped faces using MTFace + * - Drawing options too complicated to enumerate, look at code. */ void (*drawMappedFacesTex)(DerivedMesh *dm, DMSetDrawOptions setDrawOptions, DMCompareDrawOptions compareDrawOptions, void *userData); - /* Draw mapped faces with GLSL materials - * o setMaterial is called for every different material nr - * o setDrawOptions is called for every face - * o Only if setMaterial and setDrawOptions return true + /** Draw mapped faces with GLSL materials + * - setMaterial is called for every different material nr + * - setDrawOptions is called for every face + * - Only if setMaterial and setDrawOptions return true */ void (*drawMappedFacesGLSL)(DerivedMesh *dm, DMSetMaterial setMaterial, DMSetDrawOptions setDrawOptions, void *userData); - /* Draw mapped edges as lines - * o Only if !setDrawOptions or setDrawOptions(userData, mapped-edge) - * returns true + /** Draw mapped edges as lines + * - Only if !setDrawOptions or setDrawOptions(userData, mapped-edge) + * returns true */ void (*drawMappedEdges)(DerivedMesh *dm, DMSetDrawOptions setDrawOptions, void *userData); - /* Draw mapped edges as lines with interpolation values - * o Only if !setDrawOptions or - * setDrawOptions(userData, mapped-edge, mapped-v0, mapped-v1, t) - * returns true + /** Draw mapped edges as lines with interpolation values + * - Only if !setDrawOptions or + * setDrawOptions(userData, mapped-edge, mapped-v0, mapped-v1, t) + * returns true * * NOTE: This routine is optional! */ @@ -409,32 +410,32 @@ struct DerivedMesh { DMSetDrawInterpOptions setDrawInterpOptions, void *userData); - /* Draw all faces with materials - * o setMaterial is called for every different material nr - * o setFace is called to verify if a face must be hidden + /** Draw all faces with materials + * - setMaterial is called for every different material nr + * - setFace is called to verify if a face must be hidden */ void (*drawMappedFacesMat)(DerivedMesh *dm, void (*setMaterial)(void *userData, int, void *attribs), int (*setFace)(void *userData, int index), void *userData); - /* Release reference to the DerivedMesh. This function decides internally + /** Release reference to the DerivedMesh. This function decides internally * if the DerivedMesh will be freed, or cached for later use. */ void (*release)(DerivedMesh *dm); }; -/* utility function to initialize a DerivedMesh's function pointers to +/** utility function to initialize a DerivedMesh's function pointers to * the default implementation (for those functions which have a default) */ void DM_init_funcs(DerivedMesh *dm); -/* utility function to initialize a DerivedMesh for the desired number +/** utility function to initialize a DerivedMesh for the desired number * of vertices, edges and faces (doesn't allocate memory for them, just * sets up the custom data layers) */ void DM_init(DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges, int numFaces, int numLoops, int numPolys); -/* utility function to initialize a DerivedMesh for the desired number +/** utility function to initialize a DerivedMesh for the desired number * of vertices, edges and faces, with a layer setup copied from source */ void DM_from_template(DerivedMesh *dm, DerivedMesh *source, @@ -442,12 +443,12 @@ void DM_from_template(DerivedMesh *dm, DerivedMesh *source, int numVerts, int numEdges, int numFaces, int numLoops, int numPolys); -/* utility function to release a DerivedMesh's layers +/** utility function to release a DerivedMesh's layers * returns 1 if DerivedMesh has to be released by the backend, 0 otherwise */ int DM_release(DerivedMesh *dm); -/* utility function to convert a DerivedMesh to a Mesh +/** utility function to convert a DerivedMesh to a Mesh */ void DM_to_mesh(DerivedMesh *dm, struct Mesh *me, struct Object *ob); @@ -459,11 +460,10 @@ void DM_to_bmesh_ex(struct DerivedMesh *dm, struct BMesh *bm); struct BMesh *DM_to_bmesh(struct DerivedMesh *dm); -/* utility function to convert a DerivedMesh to a shape key block - */ +/** Utility function to convert a DerivedMesh to a shape key block */ void DM_to_meshkey(DerivedMesh *dm, struct Mesh *me, struct KeyBlock *kb); -/* set the CD_FLAG_NOCOPY flag in custom data layers where the mask is +/** set the CD_FLAG_NOCOPY flag in custom data layers where the mask is * zero for the layer type, so only layer types specified by the mask * will be copied */ @@ -545,7 +545,7 @@ void DM_ensure_tessface(DerivedMesh *dm); void DM_update_tessface_data(DerivedMesh *dm); -/* interpolates vertex data from the vertices indexed by src_indices in the +/** interpolates vertex data from the vertices indexed by src_indices in the * source mesh using the given weights and stores the result in the vertex * indexed by dest_index in the dest mesh */ @@ -553,7 +553,7 @@ void DM_interp_vert_data(struct DerivedMesh *source, struct DerivedMesh *dest, int *src_indices, float *weights, int count, int dest_index); -/* interpolates edge data from the edges indexed by src_indices in the +/** interpolates edge data from the edges indexed by src_indices in the * source mesh using the given weights and stores the result in the edge indexed * by dest_index in the dest mesh. * if weights is NULL, all weights default to 1. @@ -566,7 +566,7 @@ void DM_interp_edge_data(struct DerivedMesh *source, struct DerivedMesh *dest, float *weights, EdgeVertWeight *vert_weights, int count, int dest_index); -/* interpolates face data from the faces indexed by src_indices in the +/** interpolates face data from the faces indexed by src_indices in the * source mesh using the given weights and stores the result in the face indexed * by dest_index in the dest mesh. * if weights is NULL, all weights default to 1. @@ -592,7 +592,7 @@ void DM_interp_poly_data(struct DerivedMesh *source, struct DerivedMesh *dest, /* Temporary? A function to give a colorband to derivedmesh for vertexcolor ranges */ void vDM_ColorBand_store(struct ColorBand *coba); -/* Simple function to get me->totvert amount of vertices/normals, +/** Simple function to get me->totvert amount of vertices/normals, * correctly deformed and subsurfered. Needed especially when vertexgroups are involved. * In use now by vertex/weight paint and particles */ float *mesh_get_mapped_verts_nors(struct Scene *scene, struct Object *ob); @@ -641,13 +641,13 @@ int editbmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, void makeDerivedMesh(struct Scene *scene, struct Object *ob, struct BMEditMesh *em, CustomDataMask dataMask, int build_shapekey_layers); -/* returns an array of deform matrices for crazyspace correction, and the +/** returns an array of deform matrices for crazyspace correction, and the * number of modifiers left */ int editbmesh_get_first_deform_matrices(struct Scene *, struct Object *, struct BMEditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]); void weight_to_rgb(float r_rgb[3], const float weight); -/* Update the weight MCOL preview layer. +/** Update the weight MCOL preview layer. * If weights are NULL, use object's active vgroup(s). * Else, weights must be an array of weight float values. * If indices is NULL, it must be of numVerts length. @@ -657,7 +657,7 @@ void weight_to_rgb(float r_rgb[3], const float weight); void DM_update_weight_mcol(struct Object *ob, struct DerivedMesh *dm, int const draw_flag, float *weights, int num, const int *indices); -/* convert layers requested by a GLSL material to actually available layers in +/** convert layers requested by a GLSL material to actually available layers in * the DerivedMesh, with both a pointer for arrays and an offset for editmesh */ typedef struct DMVertexAttribs { struct { @@ -689,7 +689,7 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, void DM_add_tangent_layer(DerivedMesh *dm); void DM_calc_auto_bump_scale(DerivedMesh *dm); -/* Set object's bounding box based on DerivedMesh min/max data */ +/** Set object's bounding box based on DerivedMesh min/max data */ void DM_set_object_boundbox(struct Object *ob, DerivedMesh *dm); void DM_init_origspace(DerivedMesh *dm); diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 527d85c7cf3..7df491c0fef 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -113,7 +113,7 @@ struct bActionGroup *get_active_actiongroup(struct bAction *act); void set_active_action_group(struct bAction *act, struct bActionGroup *agrp, short select); /* Sync colors used for action/bone group with theme settings */ -void action_group_colors_sync(struct bActionGroup *grp); +void action_group_colors_sync(struct bActionGroup *grp, const struct bActionGroup *ref_grp); /* Add a new action group with the given name to the action */ struct bActionGroup *action_groups_add_new(struct bAction *act, const char name[]); diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h index d605776ed50..acb9234b2d4 100644 --- a/source/blender/blenkernel/BKE_anim.h +++ b/source/blender/blenkernel/BKE_anim.h @@ -43,7 +43,7 @@ struct bPoseChannel; struct ReportList; /* ---------------------------------------------------- */ -/* Animation Visualisation */ +/* Animation Visualization */ void animviz_settings_init(struct bAnimVizSettings *avs); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 144cbe2c18d..171b62461a0 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 263 -#define BLENDER_SUBVERSION 12 +#define BLENDER_SUBVERSION 13 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 @@ -51,7 +51,7 @@ extern "C" { /* can be left blank, otherwise a,b,c... etc with no quotes */ #define BLENDER_VERSION_CHAR a /* alpha/beta/rc/release, docs use this */ -#define BLENDER_VERSION_CYCLE alpha +#define BLENDER_VERSION_CYCLE beta extern char versionstr[]; /* from blender.c */ diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 593b4afb85c..2d30844af80 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -119,7 +119,8 @@ enum { G_DEBUG_FFMPEG = (1 << 1), G_DEBUG_PYTHON = (1 << 2), /* extra python info */ G_DEBUG_EVENTS = (1 << 3), /* input/window/screen events */ - G_DEBUG_WM = (1 << 4) /* operator, undo */ + G_DEBUG_WM = (1 << 4), /* operator, undo */ + G_DEBUG_JOBS = (1 << 5) /* jobs time profiling */ }; #define G_DEBUG_ALL (G_DEBUG | G_DEBUG_FFMPEG | G_DEBUG_PYTHON | G_DEBUG_EVENTS | G_DEBUG_WM) diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index baa530c0599..909ed471081 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -70,6 +70,7 @@ char BKE_imtype_valid_depths(const char imtype); char BKE_imtype_from_arg(const char *arg); void BKE_imformat_defaults(struct ImageFormatData *im_format); +void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const struct ImBuf *imbuf); struct anim *openanim(const char *name, int flags, int streamindex); @@ -156,7 +157,7 @@ void BKE_image_assign_ibuf(struct Image *ima, struct ImBuf *ibuf); /* called on frame change or before render */ void BKE_image_user_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr); void BKE_image_user_check_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr); -int BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, int fieldnr); +int BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, int fieldnr, short *r_is_in_range); void BKE_image_user_file_path(struct ImageUser *iuser, struct Image *ima, char *path); /* sets index offset for multilayer files */ @@ -190,7 +191,7 @@ struct Image *BKE_image_copy(struct Image *ima); void BKE_image_merge(struct Image *dest, struct Image *source); /* scale the image */ -void BKE_image_scale(struct Image *image, int width, int height); +int BKE_image_scale(struct Image *image, int width, int height); /* check if texture has alpha (depth=32) */ int BKE_image_has_alpha(struct Image *image); diff --git a/source/blender/blenkernel/BKE_mask.h b/source/blender/blenkernel/BKE_mask.h index 0e93869a8b0..ee7c13ba7cb 100644 --- a/source/blender/blenkernel/BKE_mask.h +++ b/source/blender/blenkernel/BKE_mask.h @@ -27,6 +27,7 @@ #ifndef __BKE_MASK_H__ #define __BKE_MASK_H__ +struct ListBase; struct Main; struct Mask; struct MaskParent; @@ -50,12 +51,16 @@ void BKE_mask_layer_remove(struct Mask *mask, struct MaskLayer *masklay); void BKE_mask_layer_free_shapes(struct MaskLayer *masklay); void BKE_mask_layer_free(struct MaskLayer *masklay); +void BKE_mask_layer_free_list(struct ListBase *masklayers); void BKE_mask_spline_free(struct MaskSpline *spline); struct MaskSpline *BKE_mask_spline_copy(struct MaskSpline *spline); void BKE_mask_point_free(struct MaskSplinePoint *point); void BKE_mask_layer_unique_name(struct Mask *mask, struct MaskLayer *masklay); +struct MaskLayer *BKE_mask_layer_copy(struct MaskLayer *layer); +void BKE_mask_layer_copy_list(struct ListBase *masklayers_new, struct ListBase *masklayers); + /* splines */ struct MaskSpline *BKE_mask_spline_add(struct MaskLayer *masklay); @@ -122,6 +127,7 @@ void BKE_mask_update_display(struct Mask *mask, float ctime); void BKE_mask_evaluate_all_masks(struct Main *bmain, float ctime, const int do_newframe); void BKE_mask_evaluate(struct Mask *mask, const float ctime, const int do_newframe); +void BKE_mask_layer_evaluate(struct MaskLayer *masklay, const float ctime, const int do_newframe); void BKE_mask_update_scene(struct Main *bmain, struct Scene *scene, const int do_newframe); void BKE_mask_parent_init(struct MaskParent *parent); void BKE_mask_calc_handle_adjacent_interp(struct MaskSpline *spline, struct MaskSplinePoint *point, const float u); @@ -169,8 +175,14 @@ void BKE_mask_layer_shape_changed_remove(struct MaskLayer *masklay, int index, i /* rasterization */ int BKE_mask_get_duration(struct Mask *mask); + +void BKE_mask_rasterize_layers(struct ListBase *masklayers, int width, int height, float *buffer, + const short do_aspect_correct, const short do_mask_aa, + const short do_feather); + void BKE_mask_rasterize(struct Mask *mask, int width, int height, float *buffer, - const short do_aspect_correct, int do_mask_aa); + const short do_aspect_correct, const short do_mask_aa, + const short do_feather); #define MASKPOINT_ISSEL_ANY(p) ( ((p)->bezt.f1 | (p)->bezt.f2 | (p)->bezt.f2) & SELECT) #define MASKPOINT_ISSEL_KNOT(p) ( (p)->bezt.f2 & SELECT) diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 8aa25a235a8..2407330a237 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -42,6 +42,7 @@ struct ID; struct Object; struct Mesh; struct MTFace; +struct Scene; /* materials */ @@ -92,6 +93,9 @@ int material_in_material(struct Material *parmat, struct Material *mat); void ramp_blend(int type, float r_col[3], const float fac, const float col[3]); +/* driver update hacks */ +void material_drivers_update(struct Scene *scene, struct Material *mat, float ctime); + /* copy/paste */ void clear_matcopybuf(void); void free_matcopybuf(void); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 887340622ad..abd0c4d96db 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -296,6 +296,7 @@ int BKE_mesh_validate_arrays( struct Mesh *me, struct MVert *mverts, unsigned int totvert, struct MEdge *medges, unsigned int totedge, + struct MFace *mfaces, unsigned int totface, struct MLoop *mloops, unsigned int totloop, struct MPoly *mpolys, unsigned int totpoly, struct MDeformVert *dverts, /* assume totvert length */ diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h index 221ae99a0ec..739b63ca174 100644 --- a/source/blender/blenkernel/BKE_movieclip.h +++ b/source/blender/blenkernel/BKE_movieclip.h @@ -63,8 +63,8 @@ void BKE_movieclip_get_cache_segments(struct MovieClip *clip, struct MovieClipUs void BKE_movieclip_build_proxy_frame(struct MovieClip *clip, int clip_flag, struct MovieDistortion *distortion, int cfra, int *build_sizes, int build_count, int undistorted); -int BKE_movieclip_remap_scene_to_clip_frame(struct MovieClip *clip, int framenr); -int BKE_movieclip_remap_clip_to_scene_frame(struct MovieClip *clip, int framenr); +float BKE_movieclip_remap_scene_to_clip_frame(struct MovieClip *clip, float framenr); +float BKE_movieclip_remap_clip_to_scene_frame(struct MovieClip *clip, float framenr); /* cacheing flags */ #define MOVIECLIP_CACHE_SKIP (1 << 0) diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index 1ff53291044..82a791348dd 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -47,6 +47,9 @@ struct Scene; /* Delete mesh mdisps and grid paint masks */ void multires_customdata_delete(struct Mesh *me); +void multires_set_tot_level(struct Object *ob, + struct MultiresModifierData *mmd, int lvl); + void multires_mark_as_modified(struct Object *ob, enum MultiresModifiedFlags flags); void multires_force_update(struct Object *ob); diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 575c721bd54..35bf4c0961f 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1882,7 +1882,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, VertDataMulN(q, 0.25f, ss); VertDataAdd(r, q, ss); - /* nCo = nCo + (r - nCo) * avgSharpness */ + /* nCo = nCo + (r - nCo) * avgSharpness */ VertDataSub(r, nCo, ss); VertDataMulN(r, avgSharpness, ss); VertDataAdd(nCo, r, ss); @@ -2331,7 +2331,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) VertDataMulN(q, 0.25f, ss); VertDataAdd(r, q, ss); - /* nCo = nCo + (r - nCo) * avgSharpness */ + /* nCo = nCo + (r - nCo) * avgSharpness */ VertDataSub(r, nCo, ss); VertDataMulN(r, avgSharpness, ss); VertDataAdd(nCo, r, ss); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index b3d2e3371f4..8d1707725b5 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -253,7 +253,7 @@ void set_active_action_group(bAction *act, bActionGroup *agrp, short select) } /* Sync colors used for action/bone group with theme settings */ -void action_group_colors_sync(bActionGroup *grp) +void action_group_colors_sync(bActionGroup *grp, const bActionGroup *ref_grp) { /* only do color copying if using a custom color (i.e. not default color) */ if (grp->customCol) { @@ -265,9 +265,15 @@ void action_group_colors_sync(bActionGroup *grp) memcpy(&grp->cs, col_set, sizeof(ThemeWireColor)); } else { - /* init custom colors with a generic multi-color rgb set, if not initialized already - * (for custom color set) */ - if (grp->cs.solid[0] == 0) { + /* if a reference group is provided, use the custom color from there... */ + if (ref_grp) { + /* assumption: reference group has a color set */ + memcpy(&grp->cs, &ref_grp->cs, sizeof(ThemeWireColor)); + } + /* otherwise, init custom color with a generic/placeholder color set if + * no previous theme color was used that we can just keep using + */ + else if (grp->cs.solid[0] == 0) { /* define for setting colors in theme below */ rgba_char_args_set(grp->cs.solid, 0xff, 0x00, 0x00, 255); rgba_char_args_set(grp->cs.select, 0x81, 0xe6, 0x14, 255); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 170638f0e8d..52399801691 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -78,9 +78,9 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4], int par_index, int level, int animated); /* ******************************************************************** */ -/* Animation Visualisation */ +/* Animation Visualization */ -/* Initialize the default settings for animation visualisation */ +/* Initialize the default settings for animation visualization */ void animviz_settings_init(bAnimVizSettings *avs) { /* sanity check */ @@ -1490,7 +1490,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p } /* only counts visible particles */ - ++index; + index++; } /* restore objects since they were changed in BKE_object_where_is_calc_time */ diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index a0da23a8f8f..943bad35cf2 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1857,7 +1857,7 @@ static void nlastrip_evaluate_transition(PointerRNA *ptr, ListBase *channels, Li /* prepare template for 'evaluation strip' * - based on the transition strip's evaluation strip data * - strip_mode is NES_TIME_TRANSITION_* based on which endpoint - * - strip_time is the 'normalised' (i.e. in-strip) time for evaluation, + * - strip_time is the 'normalized' (i.e. in-strip) time for evaluation, * which doubles up as an additional weighting factor for the strip influences * which allows us to appear to be 'interpolating' between the two extremes */ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 9af1d5f52c4..5822b296a8a 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1588,7 +1588,11 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { pchanp = BKE_pose_channel_find_name(frompose, pchan->name); - if (pchan->bone->layer & layer_protected) { + if (UNLIKELY(pchanp == NULL)) { + /* happens for proxies that become invalid because of a missing link + * for regulat cases it shouldn't happen at all */ + } + else if (pchan->bone->layer & layer_protected) { ListBase proxylocal_constraints = {NULL, NULL}; /* copy posechannel to temp, but restore important pointers */ @@ -2203,7 +2207,7 @@ void BKE_pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4]) axis_angle_to_mat3(rmat, pchan->rotAxis, pchan->rotAngle); } else { - /* quats are normalised before use to eliminate scaling issues */ + /* quats are normalized before use to eliminate scaling issues */ float quat[4]; /* NOTE: we now don't normalize the stored values anymore, since this was kindof evil in some cases diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 014b3f5e40b..edb3120cf87 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -920,7 +920,8 @@ static BoidState *get_boid_state(BoidSettings *boids, ParticleData *pa) return state; } -//static int boid_condition_is_true(BoidCondition *cond) { +//static int boid_condition_is_true(BoidCondition *cond) +//{ // /* TODO */ // return 0; //} diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index a0cca25a841..f9e72be4fc1 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -106,7 +106,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ); * ******************************************************************************/ /** - * cloth_init - creates a new cloth simulation. + * cloth_init - creates a new cloth simulation. * * 1. create object * 2. fill object with standard values or with the GUI settings if given @@ -821,8 +821,9 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ) if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) { if ( dvert->dw[j].def_nr == (clmd->coll_parms->vgroup_selfcol-1)) { - if( dvert->dw [j].weight > 0.0) + if (dvert->dw [j].weight > 0.0f) { verts->flags |= CLOTH_VERT_FLAG_NOSELFCOLL; + } } } /* diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 71b2f6952d5..d99c36b6c91 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -325,8 +325,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM result = 1; } - else - { + else { // Apply repulse impulse if distance too short // I_r = -min(dt*kd, max(0, 1d/dt - v_n)) // DG: this formula ineeds to be changed for this code since we apply impulses/repulses like this: @@ -841,9 +840,11 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData * clmd, float step, flo } } - if( ( cloth->verts[i].flags & CLOTH_VERT_FLAG_NOSELFCOLL ) || - ( cloth->verts[j].flags & CLOTH_VERT_FLAG_NOSELFCOLL ) ) + if ((cloth->verts[i].flags & CLOTH_VERT_FLAG_NOSELFCOLL) || + (cloth->verts[j].flags & CLOTH_VERT_FLAG_NOSELFCOLL)) + { continue; + } sub_v3_v3v3(temp, verts[i].tx, verts[j].tx); diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index a1e67ebd414..a1553a24ad2 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -66,6 +66,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_node.h" +#include "BKE_material.h" #include "BKE_mball.h" #include "BKE_modifier.h" #include "BKE_object.h" @@ -311,7 +312,7 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node for (fcu = adt->drivers.first; fcu; fcu = fcu->next) { ChannelDriver *driver = fcu->driver; DriverVar *dvar; - int isdata_fcu = isdata || (fcu->rna_path && strstr(fcu->rna_path, "modifiers[")); + int isdata_fcu = (isdata) || (fcu->rna_path && strstr(fcu->rna_path, "modifiers[")); /* loop over variables to get the target relationships */ for (dvar = driver->variables.first; dvar; dvar = dvar->next) { @@ -347,6 +348,48 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node } } +/* XXX: forward def for material driver handling... */ +static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Material *ma); + +/* recursive handling for material nodetree drivers */ +static void dag_add_material_nodetree_driver_relations(DagForest *dag, DagNode *node, bNodeTree *ntree) +{ + bNode *n; + + /* nodetree itself */ + if (ntree->adt) { + dag_add_driver_relation(ntree->adt, dag, node, 1); + } + + /* nodetree's nodes... */ + for (n = ntree->nodes.first; n; n = n->next) { + if (n->id && GS(n->id->name) == ID_MA) { + dag_add_material_driver_relations(dag, node, (Material *)n->id); + } + else if (n->type == NODE_GROUP && n->id) { + dag_add_material_nodetree_driver_relations(dag, node, (bNodeTree *)n->id); + } + } +} + +/* recursive handling for material drivers */ +static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Material *ma) +{ + /* material itself */ + if (ma->adt) { + dag_add_driver_relation(ma->adt, dag, node, 1); + } + + /* textures */ + // TODO... + //dag_add_texture_driver_relations(DagForest *dag, DagNode *node, ID *id); + + /* material's nodetree */ + if (ma->nodetree) { + dag_add_material_nodetree_driver_relations(dag, node, ma->nodetree); + } +} + static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Object *ob, DagNode *node) { Base *base; @@ -572,6 +615,20 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O break; } + /* material drivers */ + if (ob->totcol) { + int a; + + for (a = 1; a <= ob->totcol; a++) { + Material *ma = give_current_material(ob, a); + + if (ma) { + /* recursively figure out if there are drivers, and hook these up to this object */ + dag_add_material_driver_relations(dag, node, ma); + } + } + } + /* particles */ psys = ob->particlesystem.first; if (psys) { @@ -605,15 +662,15 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O /* note that this relation actually runs in the wrong direction, the problem * is that dupli system all have this (due to parenting), and the render * engine instancing assumes particular ordering of objects in list */ - dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Object Visualisation"); + dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Object Visualization"); if (part->dup_ob->type == OB_MBALL) - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA, "Particle Object Visualisation"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA, "Particle Object Visualization"); } if (part->ren_as == PART_DRAW_GR && part->dup_group) { for (go = part->dup_group->gobject.first; go; go = go->next) { node2 = dag_get_node(dag, go->ob); - dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualisation"); + dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualization"); } } diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index eb5e4e4f8b5..dd5751c5d1f 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -33,6 +33,7 @@ #include "BLI_utildefines.h" #include "DNA_anim_types.h" +#include "DNA_armature_types.h" #include "DNA_constraint_types.h" #include "DNA_dynamicpaint_types.h" #include "DNA_group_types.h" /*GroupObject*/ @@ -46,6 +47,7 @@ #include "DNA_texture_types.h" #include "BKE_animsys.h" +#include "BKE_armature.h" #include "BKE_bvhutils.h" /* bvh tree */ #include "BKE_blender.h" #include "BKE_cdderivedmesh.h" @@ -528,11 +530,6 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, float fram } } } - /* for curve following objects, parented curve has to be updated too */ - if (ob->type == OB_CURVE) { - Curve *cu = ob->data; - BKE_animsys_evaluate_animdata(scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM); - } /* was originally OB_RECALC_ALL - TODO - which flags are really needed??? */ ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; @@ -547,6 +544,18 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, float fram else BKE_object_where_is_calc_time(scene, ob, frame); + /* for curve following objects, parented curve has to be updated too */ + if (ob->type == OB_CURVE) { + Curve *cu = ob->data; + BKE_animsys_evaluate_animdata(scene, &cu->id, cu->adt, frame, ADT_RECALC_ANIM); + } + /* and armatures... */ + 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); + } + return 0; } @@ -734,7 +743,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface) /* deactivate zero axises */ for (i = 0; i < 3; i++) { - if (td[i] < min_dim) {td[i] = 1.0f; axis -= 1; } + if (td[i] < min_dim) { td[i] = 1.0f; axis -= 1; } } if (axis == 0 || MAX3(td[0], td[1], td[2]) < 0.0001f) { @@ -1677,7 +1686,7 @@ struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, c[1] = material->g; c[2] = material->b; } - else { /* default grey */ + else { /* default gray */ c[0] = 0.65f; c[1] = 0.65f; c[2] = 0.65f; @@ -2016,11 +2025,11 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh /* Dist to second edge */ t_dist = dist_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[uindex[1]], tface[cPoint->face_index].uv[uindex[2]]); - if (t_dist < dist) {e1_index = cPoint->v2; e2_index = cPoint->v3; edge1_index = uindex[1]; edge2_index = uindex[2]; dist = t_dist; } + if (t_dist < dist) { e1_index = cPoint->v2; e2_index = cPoint->v3; edge1_index = uindex[1]; edge2_index = uindex[2]; dist = t_dist; } /* Dist to third edge */ t_dist = dist_to_line_segment_v2(pixel, tface[cPoint->face_index].uv[uindex[2]], tface[cPoint->face_index].uv[uindex[0]]); - if (t_dist < dist) {e1_index = cPoint->v3; e2_index = cPoint->v1; edge1_index = uindex[2]; edge2_index = uindex[0]; dist = t_dist; } + if (t_dist < dist) { e1_index = cPoint->v3; e2_index = cPoint->v1; edge1_index = uindex[2]; edge2_index = uindex[0]; dist = t_dist; } /* @@ -2284,7 +2293,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) u = (dot11 * dot02 - dot01 * dot12) * invDenom; v = (dot00 * dot12 - dot01 * dot02) * invDenom; - if ((u > 0) && (v > 0) && (u + v < 1)) {isInside = 1; } /* is inside a triangle */ + if ((u > 0) && (v > 0) && (u + v < 1)) { isInside = 1; } /* is inside a triangle */ /* If collision wasn't found but the face is a quad * do another check for the second half */ @@ -2304,7 +2313,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) u = (dot11 * dot02 - dot01 * dot12) * invDenom; v = (dot00 * dot12 - dot01 * dot02) * invDenom; - if ((u > 0) && (v > 0) && (u + v < 1)) {isInside = 2; } /* is inside the second half of the quad */ + if ((u > 0) && (v > 0) && (u + v < 1)) { isInside = 2; } /* is inside the second half of the quad */ } @@ -2583,7 +2592,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam int format = (surface->image_fileformat & MOD_DPAINT_IMGFORMAT_OPENEXR) ? R_IMF_IMTYPE_OPENEXR : R_IMF_IMTYPE_PNG; char output_file[FILE_MAX]; - if (!sData || !sData->type_data) {setError(surface->canvas, "Image save failed: Invalid surface."); return; } + if (!sData || !sData->type_data) { setError(surface->canvas, "Image save failed: Invalid surface."); return; } /* if selected format is openexr, but current build doesnt support one */ #ifndef WITH_OPENEXR if (format == R_IMF_IMTYPE_OPENEXR) format = R_IMF_IMTYPE_PNG; @@ -2597,7 +2606,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam /* Init image buffer */ ibuf = IMB_allocImBuf(surface->image_resolution, surface->image_resolution, 32, IB_rectfloat); - if (ibuf == NULL) {setError(surface->canvas, "Image save failed: Not enough free memory."); return; } + if (ibuf == NULL) { setError(surface->canvas, "Image save failed: Not enough free memory."); return; } #pragma omp parallel for schedule(static) for (index = 0; index < sData->total_points; index++) { @@ -3287,7 +3296,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, int v1 = mface[hit.index].v1, v2 = mface[hit.index].v2, v3 = mface[hit.index].v3, quad = (hit.no[0] == 1.0f); float dot; - if (quad) {v2 = mface[hit.index].v3; v3 = mface[hit.index].v4; } + if (quad) { v2 = mface[hit.index].v3; v3 = mface[hit.index].v4; } normal_tri_v3(hit.no, mvert[v1].co, mvert[v2].co, mvert[v3].co); dot = ray_dir[0] * hit.no[0] + ray_dir[1] * hit.no[1] + ray_dir[2] * hit.no[2]; @@ -3580,7 +3589,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, /* for debug purposes check if any NAN particle proceeds * For some reason they get past activity check, this should rule most of them out */ - if (isnan(pa->state.co[0]) || isnan(pa->state.co[1]) || isnan(pa->state.co[2])) {invalidParticles++; continue; } + if (isnan(pa->state.co[0]) || isnan(pa->state.co[1]) || isnan(pa->state.co[2])) { invalidParticles++; continue; } /* make sure particle is close enough to canvas */ if (!boundIntersectPoint(&grid->grid_bounds, pa->state.co, range)) continue; @@ -3953,7 +3962,7 @@ void surface_determineForceTargetPoints(PaintSurfaceData *sData, int index, floa int n_index = sData->adj_data->n_index[index] + i; float dir_dot = dot_v3v3(bNeighs[n_index].dir, force); - if (dir_dot > closest_d[0] && dir_dot > 0.0f) {closest_d[0] = dir_dot; closest_id[0] = n_index; } + if (dir_dot > closest_d[0] && dir_dot > 0.0f) { closest_d[0] = dir_dot; closest_id[0] = n_index; } } if (closest_d[0] < 0.0f) return; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index b5254b97844..b32ac24084f 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -789,6 +789,12 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+3); if (mode == PFIELD_TEX_GRAD || !hasrgb) { /* if we don't have rgb fall back to grad */ + /* generate intensity if texture only has rgb value */ + if (hasrgb & TEX_RGB) { + int i; + for (i=0; i<4; i++) + result[i].tin = (1.0f / 3.0f) * (result[i].tr + result[i].tg + result[i].tb); + } force[0] = (result[0].tin - result[1].tin) * strength; force[1] = (result[0].tin - result[2].tin) * strength; force[2] = (result[0].tin - result[3].tin) * strength; diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index e20a74e713c..d072ffb72ec 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -811,7 +811,7 @@ void calchandles_fcurve(FCurve *fcu) if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0] = bezt->vec[1][0]; /* calculate auto-handles */ - BKE_nurb_handle_calc(bezt, prev, next, 1); /* 1==special autohandle */ + BKE_nurb_handle_calc(bezt, prev, next, 1); /* (1 == special) autohandle */ /* for automatic ease in and out */ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index b7ede15d00b..f981ecaf810 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -285,7 +285,7 @@ static FModifierTypeInfo FMI_GENERATOR = { * x is the evaluation 'time', and 'y' is the resultant value * * Functions available are - * sin, cos, tan, sinc (normalised sin), natural log, square root + * sin, cos, tan, sinc (normalized sin), natural log, square root */ static void fcm_fn_generator_new_data(void *mdata) @@ -297,7 +297,7 @@ static void fcm_fn_generator_new_data(void *mdata) data->phase_multiplier = 1.0f; } -/* Unary 'normalised sine' function +/* Unary 'normalized sine' function * y = sin(PI + x) / (PI * x), * except for x = 0 when y = 1. */ @@ -326,7 +326,7 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float case FCM_GENERATOR_FN_COS: /* cosine wave */ fn = cos; break; - case FCM_GENERATOR_FN_SINC: /* normalised sine wave */ + case FCM_GENERATOR_FN_SINC: /* normalized sine wave */ fn = sinc; break; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index eaf4c898b86..d2a2412843a 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -32,7 +32,7 @@ #include <string.h> #include <fcntl.h> #include <math.h> -#ifndef WIN32 +#ifndef WIN32 #include <unistd.h> #else #include <io.h> @@ -112,25 +112,25 @@ static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ { struct ImBuf *tbuf1, *tbuf2; - + if (ibuf == NULL) return; if (ibuf->flags & IB_fields) return; ibuf->flags |= IB_fields; - + if (ibuf->rect) { /* make copies */ tbuf1 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, (int)IB_rect); tbuf2 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, (int)IB_rect); - + ibuf->x *= 2; - + IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y); IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y); - + ibuf->x /= 2; IMB_rectcpy(ibuf, tbuf1, 0, 0, 0, 0, tbuf1->x, tbuf1->y); IMB_rectcpy(ibuf, tbuf2, 0, tbuf2->y, 0, 0, tbuf2->x, tbuf2->y); - + IMB_freeImBuf(tbuf1); IMB_freeImBuf(tbuf2); } @@ -140,25 +140,25 @@ static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */ { struct ImBuf *tbuf1, *tbuf2; - + if (ibuf == NULL) return; if (ibuf->flags & IB_fields) return; ibuf->flags |= IB_fields; - + if (ibuf->rect) { /* make copies */ tbuf1 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, IB_rect); tbuf2 = IMB_allocImBuf(ibuf->x, (ibuf->y >> 1), (unsigned char)32, IB_rect); - + ibuf->x *= 2; - + IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y); IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y); - + ibuf->x /= 2; IMB_rectcpy(ibuf, tbuf2, 0, 0, 0, 0, tbuf2->x, tbuf2->y); IMB_rectcpy(ibuf, tbuf1, 0, tbuf2->y, 0, 0, tbuf1->x, tbuf1->y); - + IMB_freeImBuf(tbuf1); IMB_freeImBuf(tbuf2); } @@ -181,27 +181,27 @@ void BKE_image_de_interlace(Image *ima, int odd) static void image_free_buffers(Image *ima) { ImBuf *ibuf; - + while ((ibuf = ima->ibufs.first)) { BLI_remlink(&ima->ibufs, ibuf); - + if (ibuf->userdata) { MEM_freeN(ibuf->userdata); ibuf->userdata = NULL; } IMB_freeImBuf(ibuf); } - + if (ima->anim) IMB_free_anim(ima->anim); ima->anim = NULL; if (ima->rr) { RE_FreeRenderResult(ima->rr); ima->rr = NULL; - } - + } + GPU_free_image(ima); - + ima->ok = IMA_OK; } @@ -232,16 +232,16 @@ void BKE_image_free(Image *ima) static Image *image_alloc(const char *name, short source, short type) { Image *ima; - + ima = BKE_libblock_alloc(&G.main->image, ID_IM, name); if (ima) { ima->ok = IMA_OK; - + ima->xrep = ima->yrep = 1; ima->aspx = ima->aspy = 1.0; ima->gen_x = 1024; ima->gen_y = 1024; ima->gen_type = 1; /* no defines yet? */ - + ima->source = source; ima->type = type; } @@ -283,10 +283,10 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame) { if (ibuf) { ImBuf *link; - + if (index != IMA_NO_INDEX) index = IMA_MAKE_INDEX(frame, index); - + /* insert based on index */ for (link = ima->ibufs.first; link; link = link->next) if (link->index >= index) @@ -316,7 +316,7 @@ Image *BKE_image_copy(Image *ima) nima->flag = ima->flag; nima->tpageflag = ima->tpageflag; - + nima->gen_x = ima->gen_x; nima->gen_y = ima->gen_y; nima->gen_type = ima->gen_type; @@ -500,31 +500,35 @@ void BKE_image_make_local(struct Image *ima) void BKE_image_merge(Image *dest, Image *source) { ImBuf *ibuf; - + /* sanity check */ if (dest && source && dest != source) { - + while ((ibuf = source->ibufs.first)) { BLI_remlink(&source->ibufs, ibuf); image_assign_ibuf(dest, ibuf, IMA_INDEX_PASS(ibuf->index), IMA_INDEX_FRAME(ibuf->index)); } - + BKE_libblock_free(&G.main->image, source); } } /* note, we could be clever and scale all imbuf's but since some are mipmaps its not so simple */ -void BKE_image_scale(Image *image, int width, int height) +int BKE_image_scale(Image *image, int width, int height) { ImBuf *ibuf; void *lock; ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); - IMB_scaleImBuf(ibuf, width, height); - ibuf->userflags |= IB_BITMAPDIRTY; + if (ibuf) { + IMB_scaleImBuf(ibuf, width, height); + ibuf->userflags |= IB_BITMAPDIRTY; + } BKE_image_release_ibuf(image, lock); + + return (ibuf != NULL); } Image *BKE_image_load(const char *filepath) @@ -565,7 +569,7 @@ Image *BKE_image_load_exists(const char *filepath) { Image *ima; char str[FILE_MAX], strtest[FILE_MAX]; - + BLI_strncpy(str, filepath, sizeof(str)); BLI_path_abs(str, G.main->name); @@ -574,7 +578,7 @@ Image *BKE_image_load_exists(const char *filepath) if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) { BLI_strncpy(strtest, ima->name, sizeof(ima->name)); BLI_path_abs(strtest, G.main->name); - + if (BLI_path_cmp(strtest, str) == 0) { if (ima->anim == NULL || ima->id.us == 0) { BLI_strncpy(ima->name, filepath, sizeof(ima->name)); /* for stringcode */ @@ -596,7 +600,7 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char ImBuf *ibuf; unsigned char *rect = NULL; float *rect_float = NULL; - + if (floatbuf) { ibuf = IMB_allocImBuf(width, height, depth, IB_rectfloat); rect_float = (float *)ibuf->rect_float; @@ -607,10 +611,10 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char rect = (unsigned char *)ibuf->rect; ibuf->profile = IB_PROFILE_SRGB; } - + BLI_strncpy(ibuf->name, name, sizeof(ibuf->name)); ibuf->userflags |= IB_BITMAPDIRTY; - + switch (uvtestgrid) { case 1: BKE_image_buf_fill_checker(rect, rect_float, width, height); @@ -630,19 +634,19 @@ Image *BKE_image_add_generated(unsigned int width, unsigned int height, const ch { /* on save, type is changed to FILE in editsima.c */ Image *ima = image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); - + if (ima) { ImBuf *ibuf; - + /* BLI_strncpy(ima->name, name, FILE_MAX); */ /* don't do this, this writes in ain invalid filepath! */ ima->gen_x = width; ima->gen_y = height; ima->gen_type = uvtestgrid; ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0); - + ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, uvtestgrid, color); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); - + ima->ok = IMA_OK_LOADED; } @@ -670,31 +674,31 @@ Image *BKE_image_add_from_imbuf(ImBuf *ibuf) void BKE_image_memorypack(Image *ima) { ImBuf *ibuf = image_get_ibuf(ima, IMA_NO_INDEX, 0); - + if (ibuf == NULL) return; if (ima->packedfile) { freePackedFile(ima->packedfile); ima->packedfile = NULL; } - + ibuf->ftype = PNG; ibuf->planes = R_IMF_PLANES_RGBA; - + IMB_saveiff(ibuf, ibuf->name, IB_rect | IB_mem); if (ibuf->encodedbuffer == NULL) { printf("memory save for pack error\n"); } else { PackedFile *pf = MEM_callocN(sizeof(*pf), "PackedFile"); - + pf->data = ibuf->encodedbuffer; pf->size = ibuf->encodedsize; ima->packedfile = pf; ibuf->encodedbuffer = NULL; ibuf->encodedsize = 0; ibuf->userflags &= ~IB_BITMAPDIRTY; - + if (ima->source == IMA_SRC_GENERATED) { ima->source = IMA_SRC_FILE; ima->type = IMA_TYPE_IMAGE; @@ -709,7 +713,7 @@ void BKE_image_tag_time(Image *ima) } #if 0 -static void tag_all_images_time() +static void tag_all_images_time() { Image *ima; int ctime = (int)PIL_check_seconds_timer(); @@ -728,9 +732,9 @@ void free_old_images(void) Image *ima; static int lasttime = 0; int ctime = (int)PIL_check_seconds_timer(); - - /* - * Run garbage collector once for every collecting period of time + + /* + * Run garbage collector once for every collecting period of time * if textimeout is 0, that's the option to NOT run the collector */ if (U.textimeout == 0 || ctime % U.texcollectrate || ctime == lasttime) @@ -739,7 +743,7 @@ void free_old_images(void) /* of course not! */ if (G.rendering) return; - + lasttime = ctime; ima = G.main->image.first; @@ -767,11 +771,11 @@ static uintptr_t image_mem_size(Image *ima) uintptr_t size = 0; size = 0; - + /* viewers have memory depending on other rules, has no valid rect pointer */ if (ima->source == IMA_SRC_VIEWER) return 0; - + for (ibuf = ima->ibufs.first; ibuf; ibuf = ibuf->next) { if (ibuf->rect) size += MEM_allocN_len(ibuf->rect); else if (ibuf->rect_float) size += MEM_allocN_len(ibuf->rect_float); @@ -811,25 +815,25 @@ void BKE_image_free_all_textures(void) Tex *tex; Image *ima; /* unsigned int totsize = 0; */ - + for (ima = G.main->image.first; ima; ima = ima->id.next) ima->id.flag &= ~LIB_DOIT; - + for (tex = G.main->tex.first; tex; tex = tex->id.next) if (tex->ima) tex->ima->id.flag |= LIB_DOIT; - + for (ima = G.main->image.first; ima; ima = ima->id.next) { if (ima->ibufs.first && (ima->id.flag & LIB_DOIT)) { ImBuf *ibuf; - + for (ibuf = ima->ibufs.first; ibuf; ibuf = ibuf->next) { /* escape when image is painted on */ if (ibuf->userflags & IB_BITMAPDIRTY) break; - + #if 0 - if (ibuf->mipmap[0]) + if (ibuf->mipmap[0]) totsize += 1.33 * ibuf->x * ibuf->y * 4; else totsize += ibuf->x * ibuf->y * 4; @@ -855,20 +859,20 @@ void BKE_image_free_anim_ibufs(Image *ima, int except_frame) continue; if (except_frame != IMA_INDEX_FRAME(ibuf->index)) { BLI_remlink(&ima->ibufs, ibuf); - + if (ibuf->userdata) { MEM_freeN(ibuf->userdata); ibuf->userdata = NULL; } IMB_freeImBuf(ibuf); - } + } } } void BKE_image_all_free_anim_ibufs(int cfra) { Image *ima; - + for (ima = G.main->image.first; ima; ima = ima->id.next) if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) BKE_image_free_anim_ibufs(ima, cfra); @@ -921,7 +925,7 @@ char BKE_ftype_to_imtype(const int ftype) { if (ftype == 0) return R_IMF_IMTYPE_TARGA; - else if (ftype == IMAGIC) + else if (ftype == IMAGIC) return R_IMF_IMTYPE_IRIS; #ifdef WITH_HDR else if (ftype & RADHDR) @@ -1108,7 +1112,7 @@ char BKE_imtype_from_arg(const char *imtype_arg) int BKE_add_image_extension(char *string, const char imtype) { const char *extension = NULL; - + if (imtype == R_IMF_IMTYPE_IRIS) { if (!BLI_testextensie(string, ".rgb")) extension = ".rgb"; @@ -1192,7 +1196,7 @@ int BKE_add_image_extension(char *string, const char imtype) else { return BLI_ensure_extension(string, FILE_MAX, extension); } - + } else { return FALSE; @@ -1208,6 +1212,106 @@ void BKE_imformat_defaults(ImageFormatData *im_format) im_format->compress = 90; } +void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const ImBuf *imbuf) +{ + BKE_imformat_defaults(im_format); + + // file type + + if (imbuf->ftype == IMAGIC) + im_format->imtype = R_IMF_IMTYPE_IRIS; + +#ifdef WITH_HDR + else if (imbuf->ftype == RADHDR) + im_format->imtype = R_IMF_IMTYPE_RADHDR; +#endif + + else if (imbuf->ftype == PNG) + im_format->imtype = R_IMF_IMTYPE_PNG; + +#ifdef WITH_DDS + else if (imbuf->ftype == DDS) + im_format->imtype = R_IMF_IMTYPE_DDS; +#endif + + else if (imbuf->ftype == BMP) + im_format->imtype = R_IMF_IMTYPE_BMP; + +#ifdef WITH_TIFF + else if (imbuf->ftype & TIF) { + im_format->imtype = R_IMF_IMTYPE_TIFF; + if (imbuf->ftype & TIF_16BIT) + im_format->depth = R_IMF_CHAN_DEPTH_16; + } +#endif + +#ifdef WITH_OPENEXR + else if (imbuf->ftype & OPENEXR) { + im_format->imtype = R_IMF_IMTYPE_OPENEXR; + if (imbuf->ftype & OPENEXR_HALF) + im_format->depth = R_IMF_CHAN_DEPTH_16; + if (imbuf->ftype & OPENEXR_COMPRESS) + im_format->exr_codec = R_IMF_EXR_CODEC_ZIP; // Can't determine compression + if (imbuf->zbuf_float) + im_format->flag |= R_IMF_FLAG_ZBUF; + } +#endif + +#ifdef WITH_CINEON + else if (imbuf->ftype == CINEON) + im_format->imtype = R_IMF_IMTYPE_CINEON; + else if (imbuf->ftype == DPX) + im_format->imtype = R_IMF_IMTYPE_DPX; +#endif + + else if (imbuf->ftype == TGA) { + im_format->imtype = R_IMF_IMTYPE_TARGA; + } + else if (imbuf->ftype == RAWTGA) { + im_format->imtype = R_IMF_IMTYPE_RAWTGA; + } + +#ifdef WITH_OPENJPEG + else if (imbuf->ftype & JP2) { + im_format->imtype = R_IMF_IMTYPE_JP2; + im_format->quality = imbuf->ftype & ~JPG_MSK; + + if (imbuf->ftype & JP2_16BIT) + im_format->depth = R_IMF_CHAN_DEPTH_16; + else if (imbuf->ftype & JP2_12BIT) + im_format->depth = R_IMF_CHAN_DEPTH_12; + + if (imbuf->ftype & JP2_YCC) + im_format->jp2_flag |= R_IMF_JP2_FLAG_YCC; + + if (imbuf->ftype & JP2_CINE) { + im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_PRESET; + if (imbuf->ftype & JP2_CINE_48FPS) + im_format->jp2_flag |= R_IMF_JP2_FLAG_CINE_48; + } + } +#endif + + else { + im_format->imtype = R_IMF_IMTYPE_JPEG90; + im_format->quality = imbuf->ftype & ~JPG_MSK; + } + + // planes + switch (imbuf->channels) { + case 0: + case 4: im_format->planes = R_IMF_PLANES_RGBA; + break; + case 3: im_format->planes = R_IMF_PLANES_RGB; + break; + case 1: im_format->planes = R_IMF_PLANES_BW; + break; + default: im_format->planes = R_IMF_PLANES_RGB; + break; + } + +} + /* could allow access externally - 512 is for long names, 64 is for id names */ typedef struct StampData { char file[512]; @@ -1235,7 +1339,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d else { stamp_data->file[0] = '\0'; } - + if (scene->r.stamp & R_STAMP_NOTE) { /* Never do prefix for Note */ BLI_snprintf(stamp_data->note, sizeof(stamp_data->note), "%s", scene->r.stamp_udata); @@ -1243,7 +1347,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d else { stamp_data->note[0] = '\0'; } - + if (scene->r.stamp & R_STAMP_DATE) { t = time(NULL); tl = localtime(&t); @@ -1253,7 +1357,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d else { stamp_data->date[0] = '\0'; } - + if (scene->r.stamp & R_STAMP_MARKER) { char *name = BKE_scene_find_last_marker_name(scene, CFRA); @@ -1265,7 +1369,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d else { stamp_data->marker[0] = '\0'; } - + if (scene->r.stamp & R_STAMP_TIME) { int f = (int)(scene->r.cfra % scene->r.frs_sec); int s = (int)(scene->r.cfra / scene->r.frs_sec); @@ -1292,11 +1396,11 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d else { stamp_data->time[0] = '\0'; } - + if (scene->r.stamp & R_STAMP_FRAME) { char fmtstr[32]; int digits = 1; - + if (scene->r.efra > 9) digits = 1 + (int) log10(scene->r.efra); @@ -1332,10 +1436,10 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d else { stamp_data->scene[0] = '\0'; } - + if (scene->r.stamp & R_STAMP_SEQSTRIP) { Sequence *seq = seq_foreground_frame_get(scene, scene->r.cfra); - + if (seq) BLI_strncpy(text, seq->name + 2, sizeof(text)); else BLI_strncpy(text, "<none>", sizeof(text)); @@ -1373,7 +1477,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec if (!rect && !rectf) return; - + stampdata(scene, camera, &stamp_data, 1); /* TODO, do_versions */ @@ -1382,7 +1486,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* set before return */ BLF_size(mono, scene->r.stamp_font_id, 72); - + BLF_buffer(mono, rectf, rect, width, height, channels); BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); pad = BLF_width_max(mono); @@ -1424,7 +1528,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; } - + /* Top left corner, below File (or Note) */ if (stamp_data.date[0]) { BLF_width_and_height(mono, stamp_data.date, &w, &h); h = h_fixed; @@ -1469,7 +1573,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* space width. */ x += w + pad; } - + /* Left bottom corner */ if (stamp_data.time[0]) { BLF_width_and_height(mono, stamp_data.time, &w, &h); h = h_fixed; @@ -1484,7 +1588,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* space width. */ x += w + pad; } - + if (stamp_data.frame[0]) { BLF_width_and_height(mono, stamp_data.frame, &w, &h); h = h_fixed; @@ -1519,7 +1623,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.cameralens); } - + if (stamp_data.scene[0]) { BLF_width_and_height(mono, stamp_data.scene, &w, &h); h = h_fixed; @@ -1533,7 +1637,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.scene); } - + if (stamp_data.strip[0]) { BLF_width_and_height(mono, stamp_data.strip, &w, &h); h = h_fixed; @@ -1560,10 +1664,10 @@ void BKE_imbuf_stamp_info(Scene *scene, Object *camera, struct ImBuf *ibuf) struct StampData stamp_data; if (!ibuf) return; - + /* fill all the data values, no prefix */ stampdata(scene, camera, &stamp_data, 0); - + if (stamp_data.file[0]) IMB_metadata_change_field(ibuf, "File", stamp_data.file); if (stamp_data.note[0]) IMB_metadata_change_field(ibuf, "Note", stamp_data.note); if (stamp_data.date[0]) IMB_metadata_change_field(ibuf, "Date", stamp_data.date); @@ -1647,10 +1751,10 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf) if (imf->depth == R_IMF_CHAN_DEPTH_16) ibuf->ftype |= OPENEXR_HALF; ibuf->ftype |= (imf->exr_codec & OPENEXR_COMPRESS); - + if (!(imf->flag & R_IMF_FLAG_ZBUF)) ibuf->zbuf_float = NULL; /* signal for exr saving */ - + } #endif #ifdef WITH_CINEON @@ -1671,14 +1775,14 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf) else if (imtype == R_IMF_IMTYPE_JP2) { if (quality < 10) quality = 90; ibuf->ftype = JP2 | quality; - + if (imf->depth == R_IMF_CHAN_DEPTH_16) { ibuf->ftype |= JP2_16BIT; } else if (imf->depth == R_IMF_CHAN_DEPTH_12) { ibuf->ftype |= JP2_12BIT; } - + if (imf->jp2_flag & R_IMF_JP2_FLAG_YCC) { ibuf->ftype |= JP2_YCC; } @@ -1695,14 +1799,14 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf) if (quality < 10) quality = 90; ibuf->ftype = JPG | quality; } - + BLI_make_existing_file(name); - + ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat); if (ok == 0) { perror(name); } - + return(ok); } @@ -1749,7 +1853,7 @@ void BKE_makepicstring(char *string, const char *base, const char *relbase, int if (use_ext) BKE_add_image_extension(string, imtype); - + } /* used by sequencer too */ @@ -1757,7 +1861,7 @@ struct anim *openanim(const char *name, int flags, int streamindex) { struct anim *anim; struct ImBuf *ibuf; - + anim = IMB_open_anim(name, flags, streamindex); if (anim == NULL) return NULL; @@ -1771,14 +1875,14 @@ struct anim *openanim(const char *name, int flags, int streamindex) return NULL; } IMB_freeImBuf(ibuf); - + return(anim); } /* ************************* New Image API *************** */ -/* Notes about Image storage +/* Notes about Image storage * - packedfile * -> written in .blend * - filename @@ -1801,15 +1905,15 @@ struct anim *openanim(const char *name, int flags, int streamindex) Image *BKE_image_verify_viewer(int type, const char *name) { Image *ima; - + for (ima = G.main->image.first; ima; ima = ima->id.next) if (ima->source == IMA_SRC_VIEWER) if (ima->type == type) break; - + if (ima == NULL) ima = image_alloc(name, IMA_SRC_VIEWER, type); - + /* happens on reload, imagewindow cannot be image user when hidden*/ if (ima->id.us == 0) id_us_plus(&ima->id); @@ -1885,7 +1989,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) { if (ima == NULL) return; - + switch (signal) { case IMA_SIGNAL_FREE: image_free_buffers(ima); @@ -1935,10 +2039,10 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) } else image_free_buffers(ima); - + if (iuser) iuser->ok = 1; - + break; case IMA_SIGNAL_USER_NEW_IMAGE: if (iuser) { @@ -1952,7 +2056,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) } break; } - + /* don't use notifiers because they are not 100% sure to succeeded * this also makes sure all scenes are accounted for. */ { @@ -1972,13 +2076,13 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser) { RenderLayer *rl; RenderPass *rpass = NULL; - + if (rr == NULL) return NULL; - + if (iuser) { short index = 0, rl_index = 0, rp_index; - + for (rl = rr->layers.first; rl; rl = rl->next, rl_index++) { rp_index = 0; for (rpass = rl->passes.first; rpass; rpass = rpass->next, index++, rp_index++) @@ -1987,10 +2091,10 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser) if (rpass) break; } - + if (rpass) iuser->multi_index = index; - else + else iuser->multi_index = 0; } if (rpass == NULL) { @@ -1998,7 +2102,7 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser) if (rl) rpass = rl->passes.first; } - + return rpass; } @@ -2050,7 +2154,7 @@ void BKE_image_backup_render(Scene *scene, Image *ima) /* in that case we have to build a render-result */ static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr) { - + ima->rr = RE_MultilayerConvert(ibuf->userdata, ibuf->x, ibuf->y); #ifdef WITH_OPENEXR @@ -2076,9 +2180,9 @@ static void image_initialize_after_load(Image *ima, ImBuf *ibuf) } /* timer */ ima->lastused = clock() / CLOCKS_PER_SEC; - + ima->ok = IMA_OK_LOADED; - + } static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) @@ -2086,14 +2190,14 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) struct ImBuf *ibuf; char name[FILE_MAX]; int flag; - + /* XXX temp stuff? */ if (ima->lastframe != frame) ima->tpageflag |= IMA_TPAGE_REFRESH; ima->lastframe = frame; BKE_image_user_file_path(iuser, ima, name); - + flag = IB_rect | IB_multilayer; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; @@ -2114,7 +2218,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) #ifdef WITH_OPENEXR /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_get_ibuf */ if (ibuf->ftype == OPENEXR && ibuf->userdata) { - image_create_multilayer(ima, ibuf, frame); + image_create_multilayer(ima, ibuf, frame); ima->type = IMA_TYPE_MULTILAYER; IMB_freeImBuf(ibuf); ibuf = NULL; @@ -2130,27 +2234,27 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) } else ima->ok = 0; - + if (iuser) iuser->ok = ima->ok; - + return ibuf; } static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int frame) { struct ImBuf *ibuf = NULL; - + /* either we load from RenderResult, or we have to load a new one */ - + /* check for new RenderResult */ if (ima->rr == NULL || frame != ima->rr->framenr) { /* copy to survive not found multilayer image */ RenderResult *oldrr = ima->rr; - + ima->rr = NULL; ibuf = image_load_sequence_file(ima, iuser, frame); - + if (ibuf) { /* actually an error */ ima->type = IMA_TYPE_IMAGE; printf("error, multi is normal image\n"); @@ -2168,7 +2272,7 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f } if (ima->rr) { RenderPass *rpass = BKE_image_multilayer_index(ima->rr, iuser); - + if (rpass) { // printf("load from pass %s\n", rpass->name); /* since we free render results, we copy the rect */ @@ -2178,19 +2282,19 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f ibuf->mall = IB_rectfloat; ibuf->channels = rpass->channels; ibuf->profile = IB_PROFILE_LINEAR_RGB; - + image_initialize_after_load(ima, ibuf); image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : 0, frame); - + } // else printf("pass not found\n"); } else ima->ok = 0; - + if (iuser) iuser->ok = ima->ok; - + return ibuf; } @@ -2198,35 +2302,35 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) { struct ImBuf *ibuf = NULL; - + ima->lastframe = frame; - + if (ima->anim == NULL) { char str[FILE_MAX]; - + BKE_image_user_file_path(iuser, ima, str); /* FIXME: make several stream accessible in image editor, too*/ ima->anim = openanim(str, IB_rect, 0); - + /* let's initialize this user */ if (ima->anim && iuser && iuser->frames == 0) iuser->frames = IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN); } - + if (ima->anim) { int dur = IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN); int fra = frame - 1; - + if (fra < 0) fra = 0; if (fra > (dur - 1)) fra = dur - 1; ibuf = IMB_makeSingleUser( IMB_anim_absolute(ima->anim, fra, IMB_TC_RECORD_RUN, IMB_PROXY_NONE)); - + if (ibuf) { image_initialize_after_load(ima, ibuf); image_assign_ibuf(ima, ibuf, 0, frame); @@ -2236,10 +2340,10 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) } else ima->ok = 0; - + if (iuser) iuser->ok = ima->ok; - + return ibuf; } @@ -2249,35 +2353,35 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) struct ImBuf *ibuf; char str[FILE_MAX]; int assign = 0, flag; - + /* always ensure clean ima */ image_free_buffers(ima); - + /* is there a PackedFile with this image ? */ if (ima->packedfile) { flag = IB_rect | IB_multilayer; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; - + ibuf = IMB_ibImageFromMemory((unsigned char *)ima->packedfile->data, ima->packedfile->size, flag, "<packed data>"); - } + } else { flag = IB_rect | IB_multilayer | IB_metadata; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; - + /* get the right string */ BKE_image_user_frame_calc(iuser, cfra, 0); BKE_image_user_file_path(iuser, ima, str); - + /* read ibuf */ ibuf = IMB_loadiffname(str, flag); } - + if (ibuf) { /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_get_ibuf */ if (ibuf->ftype == OPENEXR && ibuf->userdata) { - image_create_multilayer(ima, ibuf, cfra); + image_create_multilayer(ima, ibuf, cfra); ima->type = IMA_TYPE_MULTILAYER; IMB_freeImBuf(ibuf); ibuf = NULL; @@ -2288,7 +2392,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) /* check if the image is a font image... */ detectBitmapFont(ibuf); - + /* make packed file for autopack */ if ((ima->packedfile == NULL) && (G.fileflags & G_AUTOPACK)) ima->packedfile = newPackedFile(NULL, str, ID_BLEND_PATH(G.main, &ima->id)); @@ -2296,20 +2400,20 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) } else ima->ok = 0; - + if (assign) image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); if (iuser) iuser->ok = ima->ok; - + return ibuf; } static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser) { ImBuf *ibuf = NULL; - + if (ima->rr == NULL) { ibuf = image_load_image_file(ima, iuser, 0); if (ibuf) { /* actually an error */ @@ -2322,9 +2426,9 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser) if (rpass) { ibuf = IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0); - + image_initialize_after_load(ima, ibuf); - + ibuf->rect_float = rpass->rect; ibuf->flags |= IB_rectfloat; ibuf->channels = rpass->channels; @@ -2333,12 +2437,12 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser) image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : IMA_NO_INDEX, 0); } } - + if (ibuf == NULL) ima->ok = 0; if (iuser) iuser->ok = ima->ok; - + return ibuf; } @@ -2379,7 +2483,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ } else memset(&rres, 0, sizeof(RenderResult)); - + if (!(rres.rectx > 0 && rres.recty > 0)) { if (from_render) RE_ReleaseResultImage(re); @@ -2434,7 +2538,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ ibuf->x = rres.rectx; ibuf->y = rres.recty; - + /* free rect buffer if float buffer changes, so it can be recreated with * the updated result, and also in case we got byte buffer from sequencer, * so we don't keep reference to freed buffer */ @@ -2443,7 +2547,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ if (rect) ibuf->rect = rect; - + if (rectf) { ibuf->rect_float = rectf; ibuf->flags |= IB_rectfloat; @@ -2499,13 +2603,13 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame if (ima->type == IMA_TYPE_IMAGE) { frame = iuser ? iuser->framenr : ima->lastframe; ibuf = image_get_ibuf(ima, 0, frame); - + /* XXX temp stuff? */ if (ima->lastframe != frame) { ima->tpageflag |= IMA_TPAGE_REFRESH; } ima->lastframe = frame; - } + } else if (ima->type == IMA_TYPE_MULTILAYER) { frame = iuser ? iuser->framenr : ima->lastframe; index = iuser ? iuser->multi_index : IMA_NO_INDEX; @@ -2552,7 +2656,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) * things in a threadsafe way for image_get_ibuf_threadsafe to work correct. * That means, the last two steps must be, 1) add the ibuf to the list and * 2) set ima/iuser->ok to 0 to IMA_OK_LOADED */ - + if (lock_r) *lock_r = NULL; @@ -2565,7 +2669,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) } else if (ima->ok == 0) return NULL; - + /* try to get the ibuf without locking */ ibuf = image_get_ibuf_threadsafe(ima, iuser, &frame, &index); @@ -2607,14 +2711,14 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) } } else if (ima->source == IMA_SRC_FILE) { - + if (ima->type == IMA_TYPE_IMAGE) ibuf = image_load_image_file(ima, iuser, frame); /* cfra only for '#', this global is OK */ /* no else; on load the ima type can change */ if (ima->type == IMA_TYPE_MULTILAYER) /* keeps render result, stores ibufs in listbase, allows saving */ ibuf = image_get_ibuf_multilayer(ima, iuser); - + } else if (ima->source == IMA_SRC_GENERATED) { /* generated is: ibuf is allocated dynamically */ @@ -2680,10 +2784,14 @@ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser) return BKE_image_acquire_ibuf(ima, iuser, NULL); } -int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr) +int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr, short *r_is_in_range) { const int len = (iuser->fie_ima * iuser->frames) / 2; + if (r_is_in_range) { + *r_is_in_range = FALSE; + } + if (len == 0) { return 0; } @@ -2696,10 +2804,23 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr) cfra = ((cfra) % len); if (cfra < 0) cfra += len; if (cfra == 0) cfra = len; + + if (r_is_in_range) { + *r_is_in_range = TRUE; + } } - if (cfra < 0) cfra = 0; - else if (cfra > len) cfra = len; + if (cfra < 0) { + cfra = 0; + } + else if (cfra > len) { + cfra = len; + } + else { + if (r_is_in_range) { + *r_is_in_range = TRUE; + } + } /* convert current frame to current field */ cfra = 2 * (cfra); @@ -2708,7 +2829,6 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr) /* transform to images space */ framenr = (cfra + iuser->fie_ima - 2) / iuser->fie_ima; if (framenr > iuser->frames) framenr = iuser->frames; - framenr += iuser->offset; if (iuser->cycl) { framenr = ((framenr) % len); @@ -2716,6 +2836,9 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr) if (framenr == 0) framenr = len; } + /* important to apply after else we cant loop on frames 100 - 110 for eg. */ + framenr += iuser->offset; + return framenr; } } @@ -2723,13 +2846,21 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr) void BKE_image_user_frame_calc(ImageUser *iuser, int cfra, int fieldnr) { if (iuser) { - const int framenr = BKE_image_user_frame_get(iuser, cfra, fieldnr); - + short is_in_range; + const int framenr = BKE_image_user_frame_get(iuser, cfra, fieldnr, &is_in_range); + + if (is_in_range) { + iuser->flag |= IMA_USER_FRAME_IN_RANGE; + } + else { + iuser->flag &= ~IMA_USER_FRAME_IN_RANGE; + } + /* allows image users to handle redraws */ if (iuser->flag & IMA_ANIM_ALWAYS) if (framenr != iuser->framenr) iuser->flag |= IMA_ANIM_REFRESHED; - + iuser->framenr = framenr; if (iuser->ok == 0) iuser->ok = 1; } @@ -2751,7 +2882,7 @@ void BKE_image_user_file_path(ImageUser *iuser, Image *ima, char *filepath) if (ima->source == IMA_SRC_SEQUENCE) { char head[FILE_MAX], tail[FILE_MAX]; unsigned short numlen; - int frame = iuser->framenr; + int frame = iuser ? iuser->framenr : ima->lastframe; BLI_stringdec(filepath, head, tail, &numlen); BLI_stringenc(filepath, head, tail, numlen, frame); @@ -2765,7 +2896,7 @@ int BKE_image_has_alpha(struct Image *image) ImBuf *ibuf; void *lock; int planes; - + ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); planes = (ibuf ? ibuf->planes : 0); BKE_image_release_ibuf(image, lock); diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index bbc1874c2ae..f51fee674cf 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -46,6 +46,7 @@ /* since we have versioning code here */ #define DNA_DEPRECATED_ALLOW +#include "DNA_actuator_types.h" #include "DNA_anim_types.h" #include "DNA_constraint_types.h" #include "DNA_camera_types.h" @@ -1753,6 +1754,24 @@ void do_versions_ipos_to_animato(Main *main) ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL); ob->ipo->id.us--; ob->ipo = NULL; + + { + /* If we have any empty action actuators, assume they were + converted IPO Actuators using the object IPO */ + bActuator *act; + bActionActuator *aa; + + for (act = ob->actuators.first; act; act = act->next) { + /* Any actuators set to ACT_IPO at this point are actually Action Actuators that + need this converted IPO to finish converting the actuator. */ + if (act->type == ACT_IPO) + { + aa = (bActionActuator*)act->data; + aa->act = ob->adt->action; + act->type = ACT_ACTION; + } + } + } } } diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index deb294a6738..bed70bbd780 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -771,7 +771,7 @@ void do_rel_key(const int start, int end, const int tot, char *basispoin, Key *k ofsp = ofs; - while (cp[0]) { /* cp[0]==amount */ + while (cp[0]) { /* (cp[0] == amount) */ switch (cp[1]) { case IPO_FLOAT: @@ -936,7 +936,7 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key ofsp = ofs; - while (cp[0]) { /* cp[0]==amount */ + while (cp[0]) { /* (cp[0] == amount) */ switch (cp[1]) { case IPO_FLOAT: diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index c81e607ce93..6e6891684c9 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1321,7 +1321,7 @@ void clear_id_newpoins(void) } } -#define LIBTAG(a) if (a && a->id.lib) {a->id.flag &= ~LIB_INDIRECT; a->id.flag |= LIB_EXTERN; } (void)0 +#define LIBTAG(a) if (a && a->id.lib) { a->id.flag &= ~LIB_INDIRECT; a->id.flag |= LIB_EXTERN; } (void)0 static void lib_indirect_test_id(ID *id, Library *lib) { diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 48db916b4ba..b400332db81 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -64,7 +64,7 @@ static MaskSplinePoint *mask_spline_point_next(MaskSpline *spline, MaskSplinePoi if (spline->flag & MASK_SPLINE_CYCLIC) { return &points_array[0]; } - else { + else { return NULL; } } @@ -79,7 +79,7 @@ static MaskSplinePoint *mask_spline_point_prev(MaskSpline *spline, MaskSplinePoi if (spline->flag & MASK_SPLINE_CYCLIC) { return &points_array[spline->tot_point - 1]; } - else { + else { return NULL; } } @@ -94,7 +94,7 @@ static BezTriple *mask_spline_point_next_bezt(MaskSpline *spline, MaskSplinePoin if (spline->flag & MASK_SPLINE_CYCLIC) { return &(points_array[0].bezt); } - else { + else { return NULL; } } @@ -188,6 +188,41 @@ void BKE_mask_layer_unique_name(Mask *mask, MaskLayer *masklay) BLI_uniquename(&mask->masklayers, masklay, "MaskLayer", '.', offsetof(MaskLayer, name), sizeof(masklay->name)); } +MaskLayer *BKE_mask_layer_copy(MaskLayer *layer) +{ + MaskLayer *layer_new; + MaskSpline *spline; + + layer_new = MEM_callocN(sizeof(MaskLayer), "new mask layer"); + + BLI_strncpy(layer_new->name, layer->name, sizeof(layer_new->name)); + + layer_new->alpha = layer->alpha; + layer_new->blend = layer->blend; + layer_new->blend_flag = layer->blend_flag; + layer_new->flag = layer->flag; + layer_new->restrictflag = layer->restrictflag; + + for (spline = layer->splines.first; spline; spline = spline->next) { + MaskSpline *spline_new = BKE_mask_spline_copy(spline); + + BLI_addtail(&layer_new->splines, spline_new); + } + + return layer_new; +} + +void BKE_mask_layer_copy_list(ListBase *masklayers_new, ListBase *masklayers) +{ + MaskLayer *layer; + + for (layer = masklayers->first; layer; layer = layer->next) { + MaskLayer *layer_new = BKE_mask_layer_copy(layer); + + BLI_addtail(masklayers_new, layer_new); + } +} + /* splines */ MaskSpline *BKE_mask_spline_add(MaskLayer *masklay) @@ -988,21 +1023,34 @@ void BKE_mask_spline_free(MaskSpline *spline) MEM_freeN(spline); } +static MaskSplinePoint *mask_spline_points_copy(MaskSplinePoint *points, int tot_point) +{ + MaskSplinePoint *npoints; + int i; + + npoints = MEM_dupallocN(points); + + for (i = 0; i < tot_point; i++) { + MaskSplinePoint *point = &npoints[i]; + + if (point->uw) + point->uw = MEM_dupallocN(point->uw); + } + + return npoints; +} + MaskSpline *BKE_mask_spline_copy(MaskSpline *spline) { MaskSpline *nspline = MEM_callocN(sizeof(MaskSpline), "new spline"); - int i; *nspline = *spline; nspline->points_deform = NULL; - nspline->points = MEM_dupallocN(nspline->points); - - for (i = 0; i < nspline->tot_point; i++) { - MaskSplinePoint *point = &nspline->points[i]; + nspline->points = mask_spline_points_copy(spline->points, spline->tot_point); - if (point->uw) - point->uw = MEM_dupallocN(point->uw); + if (spline->points_deform) { + nspline->points_deform = mask_spline_points_copy(spline->points_deform, spline->tot_point); } return nspline; @@ -1068,20 +1116,25 @@ void BKE_mask_layer_free(MaskLayer *masklay) MEM_freeN(masklay); } -void BKE_mask_free(Mask *mask) +void BKE_mask_layer_free_list(ListBase *masklayers) { - MaskLayer *masklay = mask->masklayers.first; + MaskLayer *masklay = masklayers->first; while (masklay) { - MaskLayer *next_masklay = masklay->next; + MaskLayer *masklay_next = masklay->next; - BLI_remlink(&mask->masklayers, masklay); + BLI_remlink(masklayers, masklay); BKE_mask_layer_free(masklay); - masklay = next_masklay; + masklay = masklay_next; } } +void BKE_mask_free(Mask *mask) +{ + BKE_mask_layer_free_list(&mask->masklayers); +} + void BKE_mask_unlink(Main *bmain, Mask *mask) { bScreen *scr; @@ -1160,12 +1213,13 @@ static int BKE_mask_evaluate_parent(MaskParent *parent, float ctime, float r_co[ if (ob) { MovieTrackingTrack *track = BKE_tracking_track_get_named(tracking, ob, parent->sub_parent); + float clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, ctime); MovieClipUser user = {0}; user.framenr = ctime; if (track) { - MovieTrackingMarker *marker = BKE_tracking_marker_get(track, ctime); + MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_framenr); float marker_pos_ofs[2]; add_v2_v2v2(marker_pos_ofs, marker->pos, track->offset); BKE_mask_coord_from_movieclip(clip, &user, r_co, marker_pos_ofs); @@ -1452,7 +1506,7 @@ void BKE_mask_spline_ensure_deform(MaskSpline *spline) // printf("SPLINE ALLOC %p %d\n", spline->points_deform, allocated_points); if (spline->points_deform == NULL || allocated_points != spline->tot_point) { - printf("alloc new deform spline\n"); + // printf("alloc new deform spline\n"); if (spline->points_deform) { int i; @@ -1472,51 +1526,46 @@ void BKE_mask_spline_ensure_deform(MaskSpline *spline) } } -void BKE_mask_evaluate(Mask *mask, const float ctime, const int do_newframe) +void BKE_mask_layer_evaluate(MaskLayer *masklay, const float ctime, const int do_newframe) { - MaskLayer *masklay; - - for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { - - /* animation if available */ - if (do_newframe) { - MaskLayerShape *masklay_shape_a; - MaskLayerShape *masklay_shape_b; - int found; + /* 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 ((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_countlist(&masklay->splines_shapes), - masklay_shape_a->frame); + printf("%s: exact %d %d (%d)\n", __func__, (int)ctime, BLI_countlist(&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; + 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_countlist(&masklay->splines_shapes), - masklay_shape_a->frame, masklay_shape_b->frame); + printf("%s: tween %d %d (%d %d)\n", __func__, (int)ctime, BLI_countlist(&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); - } + 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... */ } + /* animation done... */ - BKE_mask_calc_handles(mask); - + BKE_mask_layer_calc_handles(masklay); - for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + /* update deform */ + { MaskSpline *spline; for (spline = masklay->splines.first; spline; spline = spline->next) { @@ -1560,6 +1609,15 @@ void BKE_mask_evaluate(Mask *mask, const float ctime, const int do_newframe) } } +void BKE_mask_evaluate(Mask *mask, const float ctime, const int do_newframe) +{ + MaskLayer *masklay; + + for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + BKE_mask_layer_evaluate(masklay, ctime, do_newframe); + } +} + /* the purpose of this function is to ensure spline->points_deform is never out of date. * for now re-evaluate all. eventually this might work differently */ void BKE_mask_update_display(Mask *mask, float ctime) @@ -2088,8 +2146,9 @@ int BKE_mask_get_duration(Mask *mask) } /* rasterization */ -void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, - const short do_aspect_correct, int do_mask_aa) +void BKE_mask_rasterize_layers(ListBase *masklayers, int width, int height, float *buffer, + const short do_aspect_correct, const short do_mask_aa, + const short do_feather) { MaskLayer *masklay; @@ -2097,7 +2156,7 @@ void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, const int buffer_size = width * height; float *buffer_tmp = MEM_mallocN(sizeof(float) * buffer_size, __func__); - for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + for (masklay = masklayers->first; masklay; masklay = masklay->next) { MaskSpline *spline; float alpha; @@ -2118,9 +2177,15 @@ void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, &tot_diff_point); if (tot_diff_point) { - diff_feather_points = - BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, - &tot_diff_feather_points); + if (do_feather) { + diff_feather_points = + BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, + &tot_diff_feather_points); + } + else { + tot_diff_feather_points = 0; + diff_feather_points = NULL; + } if (do_aspect_correct) { if (width != height) { @@ -2214,3 +2279,10 @@ void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, MEM_freeN(buffer_tmp); } + +void BKE_mask_rasterize(Mask *mask, int width, int height, float *buffer, + const short do_aspect_correct, const short do_mask_aa, + const short do_feather) +{ + BKE_mask_rasterize_layers(&mask->masklayers, width, height, buffer, do_aspect_correct, do_mask_aa, do_feather); +} diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 48d629a2944..23f197155a1 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -36,6 +36,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_curve_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" @@ -1050,6 +1051,52 @@ int material_in_material(Material *parmat, Material *mat) else return 0; } + + +/* ****************** */ + +/* Update drivers for materials in a nodetree */ +static void material_node_drivers_update(Scene *scene, bNodeTree *ntree, float ctime) +{ + bNode *node; + + /* nodetree itself */ + if (ntree->adt && ntree->adt->drivers.first) { + BKE_animsys_evaluate_animdata(scene, &ntree->id, ntree->adt, ctime, ADT_RECALC_DRIVERS); + } + + /* nodes... */ + for (node = ntree->nodes.first; node; node = node->next) { + if (node->id && GS(node->id->name) == ID_MA) { + /* TODO: prevent infinite recursion here... */ + material_drivers_update(scene, (Material *)node->id, ctime); + } + else if (node->type == NODE_GROUP && node->id) { + material_node_drivers_update(scene, (bNodeTree *)node->id, ctime); + } + } +} + +/* Calculate all drivers for materials + * FIXME: this is really a terrible method which may result in some things being calculated + * multiple times. However, without proper despgraph support for these things, we are forced + * into this sort of thing... + */ +void material_drivers_update(Scene *scene, Material *ma, float ctime) +{ + //if (G.f & G_DEBUG) + // printf("material_drivers_update(%s, %s)\n", scene->id.name, ma->id.name); + + /* material itself */ + if (ma->adt && ma->adt->drivers.first) { + BKE_animsys_evaluate_animdata(scene, &ma->id, ma->adt, ctime, ADT_RECALC_DRIVERS); + } + + /* nodes */ + if (ma->nodetree) { + material_node_drivers_update(scene, ma->nodetree, ctime); + } +} /* ****************** */ #if 0 /* UNUSED */ @@ -1060,19 +1107,19 @@ static char colname_array[125][20]= { "LightGreen", "Chartreuse", "YellowGreen", "Yellow", "Gold", "Green", "LawnGreen", "GreenYellow", "LightOlive", "Yellow", "DarkBlue", "DarkPurple", "HotPink", "VioletPink", "RedPink", -"SlateGray", "DarkGrey", "PalePurple", "IndianRed", "Tomato", +"SlateGray", "DarkGray", "PalePurple", "IndianRed", "Tomato", "SeaGreen", "PaleGreen", "GreenKhaki", "LightBrown", "LightSalmon", "SpringGreen", "PaleGreen", "MediumOlive", "YellowBrown", "LightGold", "LightGreen", "LightGreen", "LightGreen", "GreenYellow", "PaleYellow", "HalfBlue", "DarkSky", "HalfMagenta", "VioletRed", "DeepPink", "SteelBlue", "SkyBlue", "Orchid", "LightHotPink", "HotPink", -"SeaGreen", "SlateGray", "MediumGrey", "Burlywood", "LightPink", +"SeaGreen", "SlateGray", "MediumGray", "Burlywood", "LightPink", "SpringGreen", "Aquamarine", "PaleGreen", "Khaki", "PaleOrange", "SpringGreen", "SeaGreen", "PaleGreen", "PaleWhite", "YellowWhite", "LightBlue", "Purple", "MediumOrchid", "Magenta", "Magenta", "RoyalBlue", "SlateBlue", "MediumOrchid", "Orchid", "Magenta", "DeepSkyBlue", "LightSteelBlue", "LightSkyBlue", "Violet", "LightPink", -"Cyan", "DarkTurquoise", "SkyBlue", "Grey", "Snow", +"Cyan", "DarkTurquoise", "SkyBlue", "Gray", "Snow", "Mint", "Mint", "Aquamarine", "MintCream", "Ivory", "Blue", "Blue", "DarkMagenta", "DarkOrchid", "Magenta", "SkyBlue", "RoyalBlue", "LightSlateBlue", "MediumOrchid", "Magenta", diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index e3b13ca0f17..6d47575b372 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -3146,19 +3146,17 @@ void BKE_mesh_translate(Mesh *me, float offset[3], int do_keys) } } - void BKE_mesh_ensure_navmesh(Mesh *me) { if (!CustomData_has_layer(&me->pdata, CD_RECAST)) { int i; int numFaces = me->totpoly; int *recastData; - CustomData_add_layer_named(&me->pdata, CD_RECAST, CD_CALLOC, NULL, numFaces, "recastData"); - recastData = (int *)CustomData_get_layer(&me->pdata, CD_RECAST); + recastData = (int *)MEM_mallocN(numFaces * sizeof(int), __func__); for (i = 0; i < numFaces; i++) { recastData[i] = i + 1; } - CustomData_add_layer_named(&me->pdata, CD_RECAST, CD_REFERENCE, recastData, numFaces, "recastData"); + CustomData_add_layer_named(&me->pdata, CD_RECAST, CD_ASSIGN, recastData, numFaces, "recastData"); } } diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 669ae4f198a..4528b748412 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -50,6 +50,16 @@ #define SELECT 1 +typedef union { + uint32_t verts[2]; + int64_t edval; +} EdgeUUID; + +typedef struct SortFace { + EdgeUUID es[4]; + unsigned int index; +} SortFace; + /* Used to detect polys (faces) using exactly the same vertices. */ /* Used to detect loops used by no (disjoint) or more than one (intersect) polys. */ typedef struct SortPoly { @@ -60,6 +70,84 @@ typedef struct SortPoly { int invalid; /* Poly index. */ } SortPoly; +static void edge_store_assign(uint32_t verts[2], const uint32_t v1, const uint32_t v2) +{ + if (v1 < v2) { + verts[0] = v1; + verts[1] = v2; + } + else { + verts[0] = v2; + verts[1] = v1; + } +} + +static void edge_store_from_mface_quad(EdgeUUID es[4], MFace *mf) +{ + edge_store_assign(es[0].verts, mf->v1, mf->v2); + edge_store_assign(es[1].verts, mf->v2, mf->v3); + edge_store_assign(es[2].verts, mf->v3, mf->v4); + edge_store_assign(es[3].verts, mf->v4, mf->v1); +} + +static void edge_store_from_mface_tri(EdgeUUID es[4], MFace *mf) +{ + edge_store_assign(es[0].verts, mf->v1, mf->v2); + edge_store_assign(es[1].verts, mf->v2, mf->v3); + edge_store_assign(es[2].verts, mf->v3, mf->v1); + es[3].verts[0] = es[3].verts[1] = UINT_MAX; +} + +static int int64_cmp(const void *v1, const void *v2) +{ + const int64_t x1 = *(const int64_t *)v1; + const int64_t x2 = *(const int64_t *)v2; + + if (x1 > x2) { + return 1; + } + else if (x1 < x2) { + return -1; + } + + return 0; +} + +static int search_face_cmp(const void *v1, const void *v2) +{ + const SortFace *sfa = v1, *sfb = v2; + + if (sfa->es[0].edval > sfb->es[0].edval) { + return 1; + } + else if (sfa->es[0].edval < sfb->es[0].edval) { + return -1; + } + + else if (sfa->es[1].edval > sfb->es[1].edval) { + return 1; + } + else if (sfa->es[1].edval < sfb->es[1].edval) { + return -1; + } + + else if (sfa->es[2].edval > sfb->es[2].edval) { + return 1; + } + else if (sfa->es[2].edval < sfb->es[2].edval) { + return -1; + } + + else if (sfa->es[3].edval > sfb->es[3].edval) { + return 1; + } + else if (sfa->es[3].edval < sfb->es[3].edval) { + return -1; + } + + return 0; +} + /* TODO check there is not some standard define of this somewhere! */ static int int_cmp(const void *v1, const void *v2) { @@ -98,6 +186,7 @@ static int search_polyloop_cmp(const void *v1, const void *v2) int BKE_mesh_validate_arrays(Mesh *mesh, MVert *mverts, unsigned int totvert, MEdge *medges, unsigned int totedge, + MFace *mfaces, unsigned int totface, MLoop *mloops, unsigned int totloop, MPoly *mpolys, unsigned int totpoly, MDeformVert *dverts, /* assume totvert length */ @@ -117,10 +206,12 @@ int BKE_mesh_validate_arrays(Mesh *mesh, int *v; short do_edge_free = FALSE; + short do_face_free = FALSE; short do_polyloop_free = FALSE; /* This regroups loops and polys! */ short verts_fixed = FALSE; short vert_weights_fixed = FALSE; + int msel_fixed = FALSE; int do_edge_recalc = FALSE; @@ -193,6 +284,143 @@ int BKE_mesh_validate_arrays(Mesh *mesh, } } + if (mfaces && !mpolys) { +# define REMOVE_FACE_TAG(_mf) { _mf->v3 = 0; do_face_free = TRUE; } (void)0 +# define CHECK_FACE_VERT_INDEX(a, b) \ + if (mf->a == mf->b) { \ + PRINT(" face %u: verts invalid, " STRINGIFY(a) "/" STRINGIFY(b) " both %u\n", i, mf->a); \ + remove = do_fixes; \ + } (void)0 +# define CHECK_FACE_EDGE(a, b) \ + if (!BLI_edgehash_haskey(edge_hash, mf->a, mf->b)) { \ + PRINT(" face %u: edge " STRINGIFY(a) "/" STRINGIFY(b) \ + " (%u,%u) is missing egde data\n", i, mf->a, mf->b); \ + do_edge_recalc = TRUE; \ + } + + MFace *mf; + MFace *mf_prev; + + SortFace *sort_faces = MEM_callocN(sizeof(SortFace) * totface, "search faces"); + SortFace *sf; + SortFace *sf_prev; + unsigned int totsortface = 0; + + for (i = 0, mf = mfaces, sf = sort_faces; i < totface; i++, mf++) { + int remove = FALSE; + int fidx; + unsigned int fv[4]; + + fidx = mf->v4 ? 3 : 2; + do { + fv[fidx] = *(&(mf->v1) + fidx); + if (fv[fidx] >= totvert) { + PRINT(" face %u: 'v%d' index out of range, %u\n", i, fidx + 1, fv[fidx]); + remove = do_fixes; + } + } while (fidx--); + + if (remove == FALSE) { + if (mf->v4) { + CHECK_FACE_VERT_INDEX(v1, v2); + CHECK_FACE_VERT_INDEX(v1, v3); + CHECK_FACE_VERT_INDEX(v1, v4); + + CHECK_FACE_VERT_INDEX(v2, v3); + CHECK_FACE_VERT_INDEX(v2, v4); + + CHECK_FACE_VERT_INDEX(v3, v4); + } + else { + CHECK_FACE_VERT_INDEX(v1, v2); + CHECK_FACE_VERT_INDEX(v1, v3); + + CHECK_FACE_VERT_INDEX(v2, v3); + } + + if (remove == FALSE) { + if (totedge) { + if (mf->v4) { + CHECK_FACE_EDGE(v1, v2); + CHECK_FACE_EDGE(v2, v3); + CHECK_FACE_EDGE(v3, v4); + CHECK_FACE_EDGE(v4, v1); + } + else { + CHECK_FACE_EDGE(v1, v2); + CHECK_FACE_EDGE(v2, v3); + CHECK_FACE_EDGE(v3, v1); + } + } + + sf->index = i; + + if (mf->v4) { + edge_store_from_mface_quad(sf->es, mf); + + qsort(sf->es, 4, sizeof(int64_t), int64_cmp); + } + else { + edge_store_from_mface_tri(sf->es, mf); + qsort(sf->es, 3, sizeof(int64_t), int64_cmp); + } + + totsortface++; + sf++; + } + } + + if (remove) { + REMOVE_FACE_TAG(mf); + } + } + + qsort(sort_faces, totsortface, sizeof(SortFace), search_face_cmp); + + sf = sort_faces; + sf_prev = sf; + sf++; + + for (i = 1; i < totsortface; i++, sf++) { + int remove = FALSE; + + /* on a valid mesh, code below will never run */ + if (memcmp(sf->es, sf_prev->es, sizeof(sf_prev->es)) == 0) { + mf = mfaces + sf->index; + + if (do_verbose) { + mf_prev = mfaces + sf_prev->index; + + if (mf->v4) { + PRINT(" face %u & %u: are duplicates (%u,%u,%u,%u) (%u,%u,%u,%u)\n", + sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, mf->v4, + mf_prev->v1, mf_prev->v2, mf_prev->v3, mf_prev->v4); + } + else { + PRINT(" face %u & %u: are duplicates (%u,%u,%u) (%u,%u,%u)\n", + sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, + mf_prev->v1, mf_prev->v2, mf_prev->v3); + } + } + + remove = do_fixes; + } + else { + sf_prev = sf; + } + + if (remove) { + REMOVE_FACE_TAG(mf); + } + } + + MEM_freeN(sort_faces); + +# undef REMOVE_FACE_TAG +# undef CHECK_FACE_VERT_INDEX +# undef CHECK_FACE_EDGE + } + /* Checking loops and polys is a bit tricky, as they are quite intricated... * * Polys must have: @@ -527,14 +755,16 @@ int BKE_mesh_validate_arrays(Mesh *mesh, } } - PRINT("BKE_mesh_validate: finished\n\n"); - # undef REMOVE_EDGE_TAG # undef IS_REMOVED_EDGE # undef REMOVE_LOOP_TAG # undef REMOVE_POLY_TAG if (mesh) { + if (do_face_free) { + BKE_mesh_strip_loose_faces(mesh); + } + if (do_polyloop_free) { BKE_mesh_strip_loose_polysloops(mesh); } @@ -548,7 +778,51 @@ int BKE_mesh_validate_arrays(Mesh *mesh, } } - return (verts_fixed || vert_weights_fixed || do_polyloop_free || do_edge_free || do_edge_recalc); + if (mesh && mesh->mselect) { + MSelect *msel; + int free_msel = FALSE; + + for (i = 0, msel = mesh->mselect; i < mesh->totselect; i++, msel++) { + int tot_elem; + + if (msel->index < 0) { + PRINT("Mesh select element %d type %d index is negative, " + "resetting selection stack.\n", i, msel->type); + free_msel = TRUE; + break; + } + + switch (msel->type) { + case ME_VSEL: + tot_elem = mesh->totvert; + break; + case ME_ESEL: + tot_elem = mesh->totedge; + break; + case ME_FSEL: + tot_elem = mesh->totface; + break; + } + + if (msel->index > tot_elem) { + PRINT("Mesh select element %d type %d index %d is larger than data array size %d, " + "resetting selection stack.\n", i, msel->type, msel->index, tot_elem); + + free_msel = TRUE; + break; + } + } + + if (free_msel) { + MEM_freeN(mesh->mselect); + mesh->mselect = NULL; + mesh->totselect = 0; + } + } + + PRINT("BKE_mesh_validate: finished\n\n"); + + return (verts_fixed || vert_weights_fixed || do_polyloop_free || do_edge_free || do_edge_recalc || msel_fixed); } static int mesh_validate_customdata(CustomData *data, short do_verbose, const short do_fixes) @@ -605,6 +879,7 @@ int BKE_mesh_validate(Mesh *me, int do_verbose) arrays_fixed = BKE_mesh_validate_arrays(me, me->mvert, me->totvert, me->medge, me->totedge, + me->mface, me->totface, me->mloop, me->totloop, me->mpoly, me->totpoly, me->dvert, @@ -622,6 +897,7 @@ int BKE_mesh_validate_dm(DerivedMesh *dm) return BKE_mesh_validate_arrays(NULL, dm->getVertArray(dm), dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm), + dm->getTessFaceArray(dm), dm->getNumTessFaces(dm), dm->getLoopArray(dm), dm->getNumLoops(dm), dm->getPolyArray(dm), dm->getNumPolys(dm), dm->getVertDataArray(dm, CD_MDEFORMVERT), diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c index 99bb3468320..72c3cda9272 100644 --- a/source/blender/blenkernel/intern/modifiers_bmesh.c +++ b/source/blender/blenkernel/intern/modifiers_bmesh.c @@ -72,8 +72,8 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm) BM_data_layer_add(bm, &bm->edata, CD_BWEIGHT); BM_data_layer_add(bm, &bm->vdata, CD_BWEIGHT); - vtable = MEM_callocN(sizeof(void**) * totvert, "vert table in BMDM_Copy"); - etable = MEM_callocN(sizeof(void**) * totedge, "edge table in BMDM_Copy"); + vtable = MEM_callocN(sizeof(void **) * totvert, "vert table in BMDM_Copy"); + etable = MEM_callocN(sizeof(void **) * totedge, "edge table in BMDM_Copy"); /*do verts*/ mv = mvert = dm->dupVertArray(dm); diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 04edc58157b..54e93f58307 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -1067,6 +1067,9 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr); MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); + scopes->marker = marker; + scopes->track = track; + if (marker->flag & MARKER_DISABLED) { scopes->track_disabled = TRUE; } @@ -1074,8 +1077,6 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip ImBuf *ibuf = BKE_movieclip_get_ibuf(clip, user); scopes->track_disabled = FALSE; - scopes->marker = marker; - scopes->track = track; if (ibuf && (ibuf->rect || ibuf->rect_float)) { ImBuf *search_ibuf; @@ -1270,12 +1271,12 @@ void BKE_movieclip_unlink(Main *bmain, MovieClip *clip) clip->id.us = 0; } -int BKE_movieclip_remap_scene_to_clip_frame(MovieClip *clip, int framenr) +float BKE_movieclip_remap_scene_to_clip_frame(MovieClip *clip, float framenr) { - return framenr - clip->start_frame + 1; + return framenr - (float) clip->start_frame + 1.0f; } -int BKE_movieclip_remap_clip_to_scene_frame(MovieClip *clip, int framenr) +float BKE_movieclip_remap_clip_to_scene_frame(MovieClip *clip, float framenr) { - return framenr + clip->start_frame - 1; + return framenr + (float) clip->start_frame - 1.0f; } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index cb6f6823f48..2bc5c37b41b 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -347,7 +347,7 @@ static int multires_get_level(Object *ob, MultiresModifierData *mmd, int render) return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl) : mmd->lvl; } -static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl) +void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl) { mmd->totlvl = lvl; @@ -2105,6 +2105,8 @@ void multires_load_old(Object *ob, Mesh *me) me->mr = NULL; } +/* If 'ob' and 'to_ob' both have multires modifiers, syncronize them + * such that 'ob' has the same total number of levels as 'to_ob'. */ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob) { MultiresModifierData *mmd = get_multires_modifier(scene, ob, 1); @@ -2119,10 +2121,12 @@ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob) multires_customdata_delete(ob->data); } - if (!mmd || !to_mmd) return; - - if (mmd->totlvl > to_mmd->totlvl) multires_del_higher(mmd, ob, to_mmd->totlvl); - else multires_subdivide(mmd, ob, to_mmd->totlvl, 0, mmd->simple); + if (mmd && to_mmd) { + if (mmd->totlvl > to_mmd->totlvl) + multires_del_higher(mmd, ob, to_mmd->totlvl); + else + multires_subdivide(mmd, ob, to_mmd->totlvl, 0, mmd->simple); + } } static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 2b4fe72e8bb..fb15aa82fa2 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1391,7 +1391,7 @@ static void BKE_nlastrip_validate_autoblends(NlaTrack *nlt, NlaStrip *nls) /* set overlaps for this strip * - don't use the values obtained though if the end in question - * is directly followed/preceeded by another strip, forming an + * is directly followed/preceded by another strip, forming an * 'island' of continuous strips */ if ((ps || ns) && ((nls->prev == NULL) || IS_EQF(nls->prev->end, nls->start) == 0)) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 1f5ba8ae305..f0d47791374 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -843,7 +843,7 @@ Object *BKE_object_add_only_object(int type, const char *name) ob->pc_ids.first = ob->pc_ids.last = NULL; - /* Animation Visualisation defaults */ + /* Animation Visualization defaults */ animviz_settings_init(&ob->avs); return ob; @@ -1455,12 +1455,12 @@ void BKE_object_rot_to_mat3(Object *ob, float mat[][3]) eulO_to_mat3(dmat, ob->drot, ob->rotmode); } else if (ob->rotmode == ROT_MODE_AXISANGLE) { - /* axis-angle - not really that great for 3D-changing orientations */ + /* axis-angle - not really that great for 3D-changing orientations */ axis_angle_to_mat3(rmat, ob->rotAxis, ob->rotAngle); axis_angle_to_mat3(dmat, ob->drotAxis, ob->drotAngle); } else { - /* quats are normalised before use to eliminate scaling issues */ + /* quats are normalized before use to eliminate scaling issues */ float tquat[4]; normalize_qt_qt(tquat, ob->quat); @@ -2538,7 +2538,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) printf("recalcdata %s\n", ob->id.name + 2); if (adt) { - /* evaluate drivers */ + /* evaluate drivers - datalevel */ // XXX: for mesh types, should we push this to derivedmesh instead? BKE_animsys_evaluate_animdata(scene, data_id, adt, ctime, ADT_RECALC_DRIVERS); } @@ -2595,8 +2595,26 @@ void BKE_object_handle_update(Scene *scene, Object *ob) BKE_lattice_modifiers_calc(scene, ob); break; } - - + + /* related materials */ + /* XXX: without depsgraph tagging, this will always need to be run, which will be slow! + * However, not doing anything (or trying to hack around this lack) is not an option + * anymore, especially due to Cycles [#31834] + */ + if (ob->totcol) { + int a; + + for (a = 1; a <= ob->totcol; a++) { + Material *ma = give_current_material(ob, a); + + if (ma) { + /* recursively update drivers for this material */ + material_drivers_update(scene, ma, ctime); + } + } + } + + /* particles */ if (ob->particlesystem.first) { ParticleSystem *tpsys, *psys; DerivedMesh *dm; @@ -3101,7 +3119,8 @@ static Object *obrel_armature_find(Object *ob) return ob_arm; } -static int obrel_is_recursive_child(Object *ob, Object *child) { +static int obrel_is_recursive_child(Object *ob, Object *child) +{ Object *par; for (par = child->parent; par; par = par->parent) { if (par == ob) { diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 3d3a5ed7556..13ea70d652d 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -199,7 +199,7 @@ static float Ph(struct Ocean *o, float kx, float kz) } // damp out the waves going in the direction opposite the wind - tmp = (o->_wx * kx + o->_wz * kz) / sqrtf(k2); + tmp = (o->_wx * kx + o->_wz * kz) / sqrtf(k2); if (tmp < 0) { tmp *= o->_damp_reflections; } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 9537a31838c..a1fe1f7b8a9 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3752,7 +3752,7 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, co } #define SET_PARTICLE_TEXTURE(type, pvalue, texfac) \ - if ((event & mtex->mapto) & type) {pvalue = texture_value_blend(def, pvalue, value, texfac, blend); } (void)0 + if ((event & mtex->mapto) & type) { pvalue = texture_value_blend(def, pvalue, value, texfac, blend); } (void)0 #define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) \ if (event & type) { if (pvalue < 0.0f) pvalue = 1.0f + pvalue; CLAMP(pvalue, 0.0f, 1.0f); } (void)0 diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 569e69f2d51..65f22ebc88f 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3320,7 +3320,7 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR } } - /* stickness was possibly added before, so cancel that before calculating new normal velocity */ + /* stickiness was possibly added before, so cancel that before calculating new normal velocity */ /* otherwise particles go flying out of the surface because of high reversed sticky velocity */ if (v0_dot < 0.0f) { v0_dot += pd->pdef_stickness; @@ -3379,7 +3379,7 @@ static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeR madd_v3_v3fl(pa->state.vel, nor, -dot); } - /* add stickness to surface */ + /* add stickiness to surface */ madd_v3_v3fl(pa->state.vel, pce->nor, -pd->pdef_stickness); /* set coordinates for next iteration */ diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 91023513d4d..a3fa8f8be89 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -842,7 +842,7 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p if (psys->part->rotmode != PART_ROT_VEL || psys->part->avemode == PART_AVE_RAND || - psys->part->avefac != 0.0f) + psys->part->avefac != 0.0f) { pid->data_types |= (1 << BPHYS_DATA_AVELOCITY); } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index ddf30ecfa81..78ccdc425e5 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1220,7 +1220,11 @@ static void seq_open_anim_file(Sequence *seq) } if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) { - IMB_anim_set_index_dir(seq->anim, seq->strip->proxy->dir); + char dir[FILE_MAX]; + BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir)); + BLI_path_abs(dir, G.main->name); + + IMB_anim_set_index_dir(seq->anim, dir); } } @@ -2082,12 +2086,14 @@ static ImBuf *seq_render_mask_strip( context.rectx, context.recty, maskbuf, TRUE, - FALSE /*XXX- TODO: make on/off for anti-aliasing*/); + FALSE, /*XXX- TODO: make on/off for anti-aliasing */ + TRUE /*XXX- TODO: make on/off for feather */ + ); fp_src = maskbuf; fp_dst = ibuf->rect_float; i = context.rectx * context.recty; - while(--i) { + while (--i) { fp_dst[0] = fp_dst[1] = fp_dst[2] = *fp_src; fp_dst[3] = 1.0f; @@ -2106,12 +2112,14 @@ static ImBuf *seq_render_mask_strip( context.rectx, context.recty, maskbuf, TRUE, - FALSE /*XXX- TODO: mask on/off for anti-aliasing*/); + FALSE, /*XXX- TODO: make on/off for anti-aliasing */ + TRUE /*XXX- TODO: make on/off for feather */ + ); fp_src = maskbuf; ub_dst = (unsigned char *)ibuf->rect; i = context.rectx * context.recty; - while(--i) { + while (--i) { ub_dst[0] = ub_dst[1] = ub_dst[2] = (unsigned char)(*fp_src * 255.0f); /* already clamped */ ub_dst[3] = 255; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 3992f2be052..6167536fb9b 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -2396,7 +2396,7 @@ int BKE_tracking_context_step(MovieTrackingContext *context) ImBuf *destination_ibuf; int frame_delta = context->backwards ? -1 : 1; int curfra = BKE_movieclip_remap_scene_to_clip_frame(context->clip, context->user.framenr); - int nextfra; + /* int nextfra; */ /* UNUSED */ int a, ok = FALSE, map_size; int frame_width, frame_height; @@ -2414,7 +2414,7 @@ int BKE_tracking_context_step(MovieTrackingContext *context) if (!destination_ibuf) return FALSE; - nextfra = curfra + frame_delta; + /* nextfra = curfra + frame_delta; */ /* UNUSED */ frame_width = destination_ibuf->x; frame_height = destination_ibuf->y; @@ -2551,7 +2551,8 @@ static struct libmv_Tracks *libmv_tracks_new(ListBase *tracksbase, int width, in if ((marker->flag & MARKER_DISABLED) == 0) { libmv_tracksInsert(tracks, marker->framenr, tracknr, - marker->pos[0] * width, marker->pos[1] * height); + (marker->pos[0] + track->offset[0]) * width, + (marker->pos[1] + track->offset[1]) * height); } } @@ -3027,9 +3028,9 @@ static unsigned char *detect_get_frame_ucharbuf(ImBuf *ibuf) if (ibuf->rect_float) { const float *rrgbf = ibuf->rect_float + pixel * 4; - const float grey_f = 0.2126f * rrgbf[0] + 0.7152f * rrgbf[1] + 0.0722f * rrgbf[2]; + const float gray_f = 0.2126f * rrgbf[0] + 0.7152f * rrgbf[1] + 0.0722f * rrgbf[2]; - *cp = FTOCHAR(grey_f); + *cp = FTOCHAR(gray_f); } else { const unsigned char *rrgb = (unsigned char *)ibuf->rect + pixel * 4; diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index aa9cc40f71f..df4d2d8cc38 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -108,154 +108,154 @@ static struct bUnitCollection buDummyCollecton = {buDummyDef, 0, 0, sizeof(buDum /* Lengths */ static struct bUnitDef buMetricLenDef[] = { - {"kilometer", "kilometers", "km", NULL, "Kilometers", UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, - {"hectometer", "hectometers", "hm", NULL, "100 Meters", UN_SC_HM, 0.0, B_UNIT_DEF_SUPPRESS}, - {"dekameter", "dekameters", "dam",NULL, "10 Meters", UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, - {"meter", "meters", "m", NULL, "Meters", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"decimetre", "decimetres", "dm", NULL, "10 Centimeters", UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, - {"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, - {"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, - {"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, // micron too? + {"kilometer", "kilometers", "km", NULL, "Kilometers", UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, + {"hectometer", "hectometers", "hm", NULL, "100 Meters", UN_SC_HM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"dekameter", "dekameters", "dam", NULL, "10 Meters", UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"meter", "meters", "m", NULL, "Meters", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"decimeter", "decimeters", "dm", NULL, "10 Centimeters", UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, + {"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, + {"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, // micron too? /* These get displayed because of float precision problems in the transform header, * could work around, but for now probably people wont use these */ #if 0 - {"nanometer", "Nanometers", "nm", NULL, 0.000000001, 0.0, B_UNIT_DEF_NONE}, - {"picometer", "Picometers", "pm", NULL, 0.000000000001, 0.0,B_UNIT_DEF_NONE}, + {"nanometer", "Nanometers", "nm", NULL, 0.000000001, 0.0, B_UNIT_DEF_NONE}, + {"picometer", "Picometers", "pm", NULL, 0.000000000001, 0.0, B_UNIT_DEF_NONE}, #endif {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricLenCollecton = {buMetricLenDef, 3, 0, sizeof(buMetricLenDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricLenCollecton = {buMetricLenDef, 3, 0, sizeof(buMetricLenDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialLenDef[] = { - {"mile", "miles", "mi", "m", "Miles", UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, - {"furlong", "furlongs", "fur", NULL, "Furlongs",UN_SC_FUR, 0.0, B_UNIT_DEF_SUPPRESS}, - {"chain", "chains", "ch", NULL, "Chains", UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, - {"yard", "yards", "yd", NULL, "Yards", UN_SC_YD, 0.0, B_UNIT_DEF_SUPPRESS}, - {"foot", "feet", "'", "ft", "Feet", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"inch", "inches", "\"", "in", "Inches", UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, - {"thou", "thou", "thou", "mil", "Thou", UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, /* plural for thou has no 's' */ + {"mile", "miles", "mi", "m", "Miles", UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, + {"furlong", "furlongs", "fur", NULL, "Furlongs", UN_SC_FUR, 0.0, B_UNIT_DEF_SUPPRESS}, + {"chain", "chains", "ch", NULL, "Chains", UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, + {"yard", "yards", "yd", NULL, "Yards", UN_SC_YD, 0.0, B_UNIT_DEF_SUPPRESS}, + {"foot", "feet", "'", "ft", "Feet", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"inch", "inches", "\"", "in", "Inches", UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, + {"thou", "thou", "thou", "mil", "Thou", UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, /* plural for thou has no 's' */ {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 4, 0, sizeof(buImperialLenDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 4, 0, sizeof(buImperialLenDef) / sizeof(bUnitDef)}; /* Areas */ static struct bUnitDef buMetricAreaDef[] = { - {"square kilometer", "square kilometers", "km²", "km2", "Square Kilometers", UN_SC_KM*UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, - {"square hectometer","square hectometers", "hm²", "hm2", "Square Hectometers", UN_SC_HM*UN_SC_HM, 0.0, B_UNIT_DEF_NONE}, /* hectare */ - {"square dekameter", "square dekameters", "dam²","dam2", "Square Dekameters", UN_SC_DAM*UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, /* are */ - {"square meter", "square meters", "m²", "m2", "Square Meters", UN_SC_M*UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"square decimetre", "square decimetres", "dm²", "dm2", "Square Decimetres", UN_SC_DM*UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, - {"square centimeter", "square centimeters", "cm²", "cm2", "Square Centimeters", UN_SC_CM*UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, - {"square millimeter", "square millimeters", "mm²", "mm2", "Square Millimeters", UN_SC_MM*UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, - {"square micrometer", "square micrometers", "µm²", "um2", "Square Micrometers", UN_SC_UM*UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, - {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} + {"square kilometer", "square kilometers", "km²", "km2", "Square Kilometers", UN_SC_KM * UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, + {"square hectometer", "square hectometers", "hm²", "hm2", "Square Hectometers", UN_SC_HM * UN_SC_HM, 0.0, B_UNIT_DEF_NONE}, /* hectare */ + {"square dekameter", "square dekameters", "dam²", "dam2", "Square Dekameters", UN_SC_DAM * UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, /* are */ + {"square meter", "square meters", "m²", "m2", "Square Meters", UN_SC_M * UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"square decimeter", "square decimetees", "dm²", "dm2", "Square Decimeters", UN_SC_DM * UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"square centimeter", "square centimeters", "cm²", "cm2", "Square Centimeters", UN_SC_CM * UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, + {"square millimeter", "square millimeters", "mm²", "mm2", "Square Millimeters", UN_SC_MM * UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, + {"square micrometer", "square micrometers", "µm²", "um2", "Square Micrometers", UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricAreaCollecton = {buMetricAreaDef, 3, 0, sizeof(buMetricAreaDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricAreaCollecton = {buMetricAreaDef, 3, 0, sizeof(buMetricAreaDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialAreaDef[] = { - {"square mile", "square miles", "sq mi", "sq m","Square Miles", UN_SC_MI*UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, - {"square furlong", "square furlongs", "sq fur",NULL, "Square Furlongs", UN_SC_FUR*UN_SC_FUR, 0.0,B_UNIT_DEF_SUPPRESS}, - {"square chain", "square chains", "sq ch", NULL, "Square Chains", UN_SC_CH*UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, - {"square yard", "square yards", "sq yd", NULL, "Square Yards", UN_SC_YD*UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, - {"square foot", "square feet", "sq ft", NULL, "Square Feet", UN_SC_FT*UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"square inch", "square inches", "sq in", NULL, "Square Inches", UN_SC_IN*UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, - {"square thou", "square thous", "sq mil",NULL, "Square Thous", UN_SC_MIL*UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, + {"square mile", "square miles", "sq mi", "sq m", "Square Miles", UN_SC_MI * UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, + {"square furlong", "square furlongs", "sq fur", NULL, "Square Furlongs", UN_SC_FUR * UN_SC_FUR, 0.0, B_UNIT_DEF_SUPPRESS}, + {"square chain", "square chains", "sq ch", NULL, "Square Chains", UN_SC_CH * UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, + {"square yard", "square yards", "sq yd", NULL, "Square Yards", UN_SC_YD * UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, + {"square foot", "square feet", "sq ft", NULL, "Square Feet", UN_SC_FT * UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"square inch", "square inches", "sq in", NULL, "Square Inches", UN_SC_IN * UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, + {"square thou", "square thous", "sq mil", NULL, "Square Thous", UN_SC_MIL * UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialAreaCollecton = {buImperialAreaDef, 4, 0, sizeof(buImperialAreaDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialAreaCollecton = {buImperialAreaDef, 4, 0, sizeof(buImperialAreaDef) / sizeof(bUnitDef)}; /* Volumes */ static struct bUnitDef buMetricVolDef[] = { - {"cubic kilometer", "cubic kilometers", "km³", "km3", "Cubic Kilometers", UN_SC_KM*UN_SC_KM*UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, - {"cubic hectometer","cubic hectometers", "hm³", "hm3", "Cubic Hectometers", UN_SC_HM*UN_SC_HM*UN_SC_HM, 0.0, B_UNIT_DEF_NONE}, - {"cubic dekameter", "cubic dekameters", "dam³","dam3", "Cubic Dekameters", UN_SC_DAM*UN_SC_DAM*UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, - {"cubic meter", "cubic meters", "m³", "m3", "Cubic Meters", UN_SC_M*UN_SC_M*UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"cubic decimetre", "cubic decimetres", "dm³", "dm3", "Cubic Decimetres", UN_SC_DM*UN_SC_DM*UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, - {"cubic centimeter", "cubic centimeters", "cm³", "cm3", "Cubic Centimeters", UN_SC_CM*UN_SC_CM*UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, - {"cubic millimeter", "cubic millimeters", "mm³", "mm3", "Cubic Millimeters", UN_SC_MM*UN_SC_MM*UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, - {"cubic micrometer", "cubic micrometers", "µm³", "um3", "Cubic Micrometers", UN_SC_UM*UN_SC_UM*UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, - {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} + {"cubic kilometer", "cubic kilometers", "km³", "km3", "Cubic Kilometers", UN_SC_KM * UN_SC_KM * UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, + {"cubic hectometer", "cubic hectometers", "hm³", "hm3", "Cubic Hectometers", UN_SC_HM * UN_SC_HM * UN_SC_HM, 0.0, B_UNIT_DEF_NONE}, + {"cubic dekameter", "cubic dekameters", "dam³", "dam3", "Cubic Dekameters", UN_SC_DAM * UN_SC_DAM * UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"cubic meter", "cubic meters", "m³", "m3", "Cubic Meters", UN_SC_M * UN_SC_M * UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"cubic decimeter", "cubic decimeters", "dm³", "dm3", "Cubic Decimeters", UN_SC_DM * UN_SC_DM * UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"cubic centimeter", "cubic centimeters", "cm³", "cm3", "Cubic Centimeters", UN_SC_CM * UN_SC_CM * UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, + {"cubic millimeter", "cubic millimeters", "mm³", "mm3", "Cubic Millimeters", UN_SC_MM * UN_SC_MM * UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, + {"cubic micrometer", "cubic micrometers", "µm³", "um3", "Cubic Micrometers", UN_SC_UM * UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricVolCollecton = {buMetricVolDef, 3, 0, sizeof(buMetricVolDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricVolCollecton = {buMetricVolDef, 3, 0, sizeof(buMetricVolDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialVolDef[] = { - {"cubic mile", "cubic miles", "cu mi", "cu m","Cubic Miles", UN_SC_MI*UN_SC_MI*UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, - {"cubic furlong", "cubic furlongs", "cu fur",NULL, "Cubic Furlongs", UN_SC_FUR*UN_SC_FUR*UN_SC_FUR, 0.0,B_UNIT_DEF_SUPPRESS}, - {"cubic chain", "cubic chains", "cu ch", NULL, "Cubic Chains", UN_SC_CH*UN_SC_CH*UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, - {"cubic yard", "cubic yards", "cu yd", NULL, "Cubic Yards", UN_SC_YD*UN_SC_YD*UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, - {"cubic foot", "cubic feet", "cu ft", NULL, "Cubic Feet", UN_SC_FT*UN_SC_FT*UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"cubic inch", "cubic inches", "cu in", NULL, "Cubic Inches", UN_SC_IN*UN_SC_IN*UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, - {"cubic thou", "cubic thous", "cu mil",NULL, "Cubic Thous", UN_SC_MIL*UN_SC_MIL*UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, + {"cubic mile", "cubic miles", "cu mi", "cu m", "Cubic Miles", UN_SC_MI * UN_SC_MI * UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, + {"cubic furlong", "cubic furlongs", "cu fur", NULL, "Cubic Furlongs", UN_SC_FUR * UN_SC_FUR * UN_SC_FUR, 0.0, B_UNIT_DEF_SUPPRESS}, + {"cubic chain", "cubic chains", "cu ch", NULL, "Cubic Chains", UN_SC_CH * UN_SC_CH * UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, + {"cubic yard", "cubic yards", "cu yd", NULL, "Cubic Yards", UN_SC_YD * UN_SC_YD * UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, + {"cubic foot", "cubic feet", "cu ft", NULL, "Cubic Feet", UN_SC_FT * UN_SC_FT * UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"cubic inch", "cubic inches", "cu in", NULL , "Cubic Inches", UN_SC_IN * UN_SC_IN * UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, + {"cubic thou", "cubic thous", "cu mil", NULL, "Cubic Thous", UN_SC_MIL * UN_SC_MIL * UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialVolCollecton = {buImperialVolDef, 4, 0, sizeof(buImperialVolDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialVolCollecton = {buImperialVolDef, 4, 0, sizeof(buImperialVolDef) / sizeof(bUnitDef)}; /* Mass */ static struct bUnitDef buMetricMassDef[] = { - {"ton", "tonnes", "ton", "t", "1000 Kilograms", UN_SC_MTON, 0.0, B_UNIT_DEF_NONE}, - {"quintal", "quintals", "ql", "q", "100 Kilograms", UN_SC_QL, 0.0, B_UNIT_DEF_NONE}, - {"kilogram", "kilograms", "kg", NULL, "Kilograms", UN_SC_KG, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"hectogram", "hectograms", "hg", NULL, "Hectograms", UN_SC_HG, 0.0, B_UNIT_DEF_NONE}, - {"dekagram", "dekagrams", "dag",NULL, "10 Grams", UN_SC_DAG, 0.0, B_UNIT_DEF_SUPPRESS}, - {"gram", "grams", "g", NULL, "Grams", UN_SC_G, 0.0, B_UNIT_DEF_NONE}, - {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} + {"ton", "tonnes", "ton", "t", "1000 Kilograms", UN_SC_MTON, 0.0, B_UNIT_DEF_NONE}, + {"quintal", "quintals", "ql", "q", "100 Kilograms", UN_SC_QL, 0.0, B_UNIT_DEF_NONE}, + {"kilogram", "kilograms", "kg", NULL, "Kilograms", UN_SC_KG, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"hectogram", "hectograms", "hg", NULL, "Hectograms", UN_SC_HG, 0.0, B_UNIT_DEF_NONE}, + {"dekagram", "dekagrams", "dag", NULL, "10 Grams", UN_SC_DAG, 0.0, B_UNIT_DEF_SUPPRESS}, + {"gram", "grams", "g", NULL, "Grams", UN_SC_G, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricMassCollecton = {buMetricMassDef, 2, 0, sizeof(buMetricMassDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricMassCollecton = {buMetricMassDef, 2, 0, sizeof(buMetricMassDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialMassDef[] = { - {"ton", "tonnes", "ton", "t", "Tonnes", UN_SC_ITON, 0.0, B_UNIT_DEF_NONE}, + {"ton", "tonnes", "ton", "t", "Tonnes", UN_SC_ITON, 0.0, B_UNIT_DEF_NONE}, {"centum weight", "centum weights", "cwt", NULL, "Centum weights", UN_SC_CWT, 0.0, B_UNIT_DEF_NONE}, - {"stone", "stones", "st", NULL, "Stones", UN_SC_ST, 0.0, B_UNIT_DEF_NONE}, - {"pound", "pounds", "lb", NULL, "Pounds", UN_SC_LB, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"ounce", "ounces", "oz", NULL, "Ounces", UN_SC_OZ, 0.0, B_UNIT_DEF_NONE}, + {"stone", "stones", "st", NULL, "Stones", UN_SC_ST, 0.0, B_UNIT_DEF_NONE}, + {"pound", "pounds", "lb", NULL, "Pounds", UN_SC_LB, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"ounce", "ounces", "oz", NULL, "Ounces", UN_SC_OZ, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialMassCollecton = {buImperialMassDef, 3, 0, sizeof(buImperialMassDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialMassCollecton = {buImperialMassDef, 3, 0, sizeof(buImperialMassDef) / sizeof(bUnitDef)}; /* Even if user scales the system to a point where km^3 is used, velocity and * acceleration aren't scaled: that's why we have so few units for them */ /* Velocity */ static struct bUnitDef buMetricVelDef[] = { - {"meter per second", "meters per second", "m/s", NULL, "Meters per second", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"kilometer per hour", "kilometers per hour", "km/h", NULL, "Kilometers per hour", UN_SC_KM/3600.0f, 0.0, B_UNIT_DEF_SUPPRESS}, - {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} + {"meter per second", "meters per second", "m/s", NULL, "Meters per second", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"kilometer per hour", "kilometers per hour", "km/h", NULL, "Kilometers per hour", UN_SC_KM / 3600.0f, 0.0, B_UNIT_DEF_SUPPRESS}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricVelCollecton = {buMetricVelDef, 0, 0, sizeof(buMetricVelDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricVelCollecton = {buMetricVelDef, 0, 0, sizeof(buMetricVelDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialVelDef[] = { - {"foot per second", "feet per second", "ft/s", "fps", "Feet per second", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"mile per hour", "miles per hour", "mph", NULL, "Miles per hour", UN_SC_MI/3600.0f, 0.0,B_UNIT_DEF_SUPPRESS}, + {"foot per second", "feet per second", "ft/s", "fps", "Feet per second", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"mile per hour", "miles per hour", "mph", NULL, "Miles per hour", UN_SC_MI / 3600.0f, 0.0, B_UNIT_DEF_SUPPRESS}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialVelCollecton = {buImperialVelDef, 0, 0, sizeof(buImperialVelDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialVelCollecton = {buImperialVelDef, 0, 0, sizeof(buImperialVelDef) / sizeof(bUnitDef)}; /* Acceleration */ static struct bUnitDef buMetricAclDef[] = { {"meter per second squared", "meters per second squared", "m/s²", "m/s2", "Meters per second squared", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buMetricAclCollecton = {buMetricAclDef, 0, 0, sizeof(buMetricAclDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buMetricAclCollecton = {buMetricAclDef, 0, 0, sizeof(buMetricAclDef) / sizeof(bUnitDef)}; static struct bUnitDef buImperialAclDef[] = { {"foot per second squared", "feet per second squared", "ft/s²", "ft/s2", "Feet per second squared", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buImperialAclCollecton = {buImperialAclDef, 0, 0, sizeof(buImperialAclDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buImperialAclCollecton = {buImperialAclDef, 0, 0, sizeof(buImperialAclDef) / sizeof(bUnitDef)}; /* Time */ static struct bUnitDef buNaturalTimeDef[] = { /* weeks? - probably not needed for blender */ - {"day", "days", "d", NULL, "Days", 90000.0, 0.0, B_UNIT_DEF_NONE}, - {"hour", "hours", "hr", "h", "Hours", 3600.0, 0.0, B_UNIT_DEF_NONE}, - {"minute", "minutes", "min", "m", "Minutes", 60.0, 0.0, B_UNIT_DEF_NONE}, - {"second", "seconds", "sec", "s", "Seconds", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0, B_UNIT_DEF_NONE}, - {"microsecond", "microseconds", "µs", "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE}, + {"day", "days", "d", NULL, "Days", 90000.0, 0.0, B_UNIT_DEF_NONE}, + {"hour", "hours", "hr", "h", "Hours", 3600.0, 0.0, B_UNIT_DEF_NONE}, + {"minute", "minutes", "min", "m", "Minutes", 60.0, 0.0, B_UNIT_DEF_NONE}, + {"second", "seconds", "sec", "s", "Seconds", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0, B_UNIT_DEF_NONE}, + {"microsecond", "microseconds", "µs", "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef) / sizeof(bUnitDef)}; static struct bUnitDef buNaturalRotDef[] = { @@ -264,7 +264,7 @@ static struct bUnitDef buNaturalRotDef[] = { // {"turn", "turns", "t", NULL, "Turns", 1.0/(M_PI*2.0), 0.0,B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; -static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef)/sizeof(bUnitDef)}; +static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef) / sizeof(bUnitDef)}; #define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / 9) / sizeof(void *)) - 1) static struct bUnitCollection *bUnitSystems[][9] = { diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index b3101638a4e..f72942df8b3 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -924,7 +924,7 @@ void BKE_ffmpeg_filepath_get(char *string, RenderData *rd) fe++; } - if (!*fe) { + if (*fe == NULL) { strcat(string, autosplit); BLI_path_frame_range(string, rd->sfra, rd->efra, 4); diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h index 4fbed23d5e6..18258014529 100644 --- a/source/blender/blenlib/BLI_array.h +++ b/source/blender/blenlib/BLI_array.h @@ -25,7 +25,10 @@ * ***** END GPL LICENSE BLOCK ***** */ -/* +/** \file BLI_array.h + * \ingroup bli + * \brief A macro array library. + * * this library needs to be changed to not use macros quite so heavily, * and to be more of a complete array API. The way arrays are * exposed to client code as normal C arrays is very useful though, imho. @@ -118,7 +121,7 @@ /* grow an array by a specified number of items */ #define BLI_array_grow_items(arr, num) ( \ ((void *)(arr) == NULL && (void *)(_##arr##_static) != NULL) ? \ - ((arr = (void *)_##arr##_static), (_##arr##_count += num)) : \ + ((arr = (void *)_##arr##_static), (_##arr##_count += num)) : \ _bli_array_grow_items(arr, num) \ ) @@ -184,6 +187,5 @@ MEM_mallocN(sizeof(*(arr)) * (realsize), allocstr) \ ) \ -#define BLI_array_fixedstack_free(arr) \ - if (_##arr##_is_static) MEM_freeN(arr) \ - +#define BLI_array_fixedstack_free(arr) \ + if (_##arr##_is_static) MEM_freeN(arr) diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index ca810ee5b93..ac0ec6a52a7 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -65,7 +65,7 @@ int BLI_is_dir(const char *path); int BLI_is_file(const char *path); void BLI_dir_create_recursive(const char *dir); double BLI_dir_free_space(const char *dir); -char *BLI_current_working_dir(char *dir, const int maxlen); +char *BLI_current_working_dir(char *dir, const size_t maxlen); unsigned int BLI_dir_contents(const char *dir, struct direntry **filelist); diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index be492fb6fdd..8499a7f219c 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -191,6 +191,7 @@ float angle_v2v2v2(const float a[2], const float b[2], const float c[2]); float angle_normalized_v2v2(const float a[2], const float b[2]); float angle_v3v3(const float a[3], const float b[3]); float angle_v3v3v3(const float a[3], const float b[3], const float c[3]); +float cos_v3v3v3(const float p1[3], const float p2[3], const float p3[3]); float angle_normalized_v3v3(const float v1[3], const float v2[3]); float angle_on_axis_v3v3v3_v3(const float v1[3], const float v2[3], const float v3[3], const float axis[3]); void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const float v3[3]); diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 74f5e7fc2bd..9b68406cc54 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -89,7 +89,16 @@ void BLI_split_dir_part(const char *string, char *dir, const size_t dirlen); void BLI_split_file_part(const char *string, char *file, const size_t filelen); void BLI_join_dirfile(char *string, const size_t maxlen, const char *dir, const char *file); char *BLI_path_basename(char *path); -int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir); + +typedef enum bli_rebase_state { + BLI_REBASE_NO_SRCDIR = 0, + BLI_REBASE_OK = 1, + BLI_REBASE_IDENTITY = 2 +} bli_rebase_state; + +int BLI_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir); +#define BKE_rebase_path BLI_rebase_path /* remove after a 2012 */ + char *BLI_last_slash(const char *string); int BLI_add_slash(char *string); void BLI_del_slash(char *string); diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index a265505cc8f..19985c56b84 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -399,7 +399,7 @@ int BLI_kdtree_range_search(KDTree *tree, float range, const float co[3], const } else { dist2 = squared_distance(root->co, co, root->nor, nor); - if (dist2 <= range2) + if (dist2 <= range2) add_in_range(&foundstack, found++, &totfoundstack, root->index, dist2, root->co); if (root->left) diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c index feaa60b40b2..5da719cd500 100644 --- a/source/blender/blenlib/intern/boxpack2d.c +++ b/source/blender/blenlib/intern/boxpack2d.c @@ -63,35 +63,35 @@ typedef struct BoxVert { #define TL 2 #define BR 3 -#define BOXLEFT(b) ((b)->v[BL]->x) -#define BOXRIGHT(b) ((b)->v[TR]->x) -#define BOXBOTTOM(b) ((b)->v[BL]->y) -#define BOXTOP(b) ((b)->v[TR]->y) -#define BOXAREA(b) ((b)->w * (b)->h) - -#define UPDATE_V34X(b) ((b)->v[TL]->x = (b)->v[BL]->x); \ - ((b)->v[BR]->x = (b)->v[TR]->x) -#define UPDATE_V34Y(b) ((b)->v[TL]->y = (b)->v[TR]->y); \ - ((b)->v[BR]->y = (b)->v[BL]->y) +#define BOXLEFT(b) ((b)->v[BL]->x) +#define BOXRIGHT(b) ((b)->v[TR]->x) +#define BOXBOTTOM(b) ((b)->v[BL]->y) +#define BOXTOP(b) ((b)->v[TR]->y) +#define BOXAREA(b) ((b)->w * (b)->h) + +#define UPDATE_V34X(b) ((b)->v[TL]->x = (b)->v[BL]->x); \ + ((b)->v[BR]->x = (b)->v[TR]->x) +#define UPDATE_V34Y(b) ((b)->v[TL]->y = (b)->v[TR]->y); \ + ((b)->v[BR]->y = (b)->v[BL]->y) #define UPDATE_V34(b) UPDATE_V34X(b); UPDATE_V34Y(b) -#define SET_BOXLEFT(b, f) (b)->v[TR]->x = f + (b)->w; \ - (b)->v[BL]->x = f; \ - UPDATE_V34X(b) -#define SET_BOXRIGHT(b, f) (b)->v[BL]->x = f - (b)->w; \ - (b)->v[TR]->x = f; \ - UPDATE_V34X(b) -#define SET_BOXBOTTOM(b, f) (b)->v[TR]->y = f + (b)->h; \ - (b)->v[BL]->y = f; \ - UPDATE_V34Y(b) -#define SET_BOXTOP(b, f) (b)->v[BL]->y = f - (b)->h; \ - (b)->v[TR]->y = f; \ - UPDATE_V34Y(b) +#define SET_BOXLEFT(b, f) (b)->v[TR]->x = f + (b)->w; \ + (b)->v[BL]->x = f; \ + UPDATE_V34X(b) +#define SET_BOXRIGHT(b, f) (b)->v[BL]->x = f - (b)->w; \ + (b)->v[TR]->x = f; \ + UPDATE_V34X(b) +#define SET_BOXBOTTOM(b, f) (b)->v[TR]->y = f + (b)->h; \ + (b)->v[BL]->y = f; \ + UPDATE_V34Y(b) +#define SET_BOXTOP(b, f) (b)->v[BL]->y = f - (b)->h; \ + (b)->v[TR]->y = f; \ + UPDATE_V34Y(b) #define BOXINTERSECT(b1, b2) \ - !(BOXLEFT(b1) + EPSILON >= BOXRIGHT(b2) || \ - BOXBOTTOM(b1) + EPSILON >= BOXTOP(b2) || \ - BOXRIGHT(b1) - EPSILON <= BOXLEFT(b2) || \ - BOXTOP(b1) - EPSILON <= BOXBOTTOM(b2)) + !(BOXLEFT(b1) + EPSILON >= BOXRIGHT(b2) || \ + BOXBOTTOM(b1) + EPSILON >= BOXTOP(b2) || \ + BOXRIGHT(b1) - EPSILON <= BOXLEFT(b2) || \ + BOXTOP(b1) - EPSILON <= BOXBOTTOM(b2)) #define MIN2(x, y) ((x) < (y) ? (x) : (y)) #define MAX2(x, y) ((x) > (y) ? (x) : (y)) diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index ec7b59702bd..5f564f71646 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -401,7 +401,7 @@ static void join_dirfile_alloc(char **dst, size_t *alloc_len, const char *dir, c { size_t len = strlen(dir) + strlen(file) + 1; - if (!*dst) + if (*dst == NULL) *dst = MEM_callocN(len + 1, "join_dirfile_alloc path"); else if (*alloc_len < len) *dst = MEM_reallocN(*dst, len + 1); diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index ef2eb25a891..eb2070bce76 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -136,7 +136,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf onpoints[j]++; if (k < npoints[j] - 1) { - if (ftoutline.tags[l] == FT_Curve_Tag_Conic && + if (ftoutline.tags[l] == FT_Curve_Tag_Conic && ftoutline.tags[l + 1] == FT_Curve_Tag_Conic) { onpoints[j]++; @@ -545,90 +545,90 @@ typedef struct FT_Outline_ #endif -/***//* -from: http://www.freetype.org/freetype2/docs/glyphs/glyphs-6.html#section-1 - -Vectorial representation of Freetype glyphs - -The source format of outlines is a collection of closed paths called "contours". Each contour is -made of a series of line segments and bezier arcs. Depending on the file format, these can be -second-order or third-order polynomials. The former are also called quadratic or conic arcs, and -they come from the TrueType format. The latter are called cubic arcs and mostly come from the -Type1 format. - -Each arc is described through a series of start, end and control points. Each point of the outline -has a specific tag which indicates wether it is used to describe a line segment or an arc. - - -The following rules are applied to decompose the contour's points into segments and arcs : - -# two successive "on" points indicate a line segment joining them. - -# one conic "off" point amidst two "on" points indicates a conic bezier arc, the "off" point being - the control point, and the "on" ones the start and end points. - -# Two successive cubic "off" points amidst two "on" points indicate a cubic bezier arc. There must - be exactly two cubic control points and two on points for each cubic arc (using a single cubic - "off" point between two "on" points is forbidden, for example). - -# finally, two successive conic "off" points forces the rasterizer to create (during the scan-line - conversion process exclusively) a virtual "on" point amidst them, at their exact middle. This - greatly facilitates the definition of successive conic bezier arcs. Moreover, it's the way - outlines are described in the TrueType specification. - -Note that it is possible to mix conic and cubic arcs in a single contour, even though no current -font driver produces such outlines. - - * # on - * off - __---__ - #-__ _-- -_ - --__ _- - - --__ # \ - --__ # - -# - Two "on" points - Two "on" points and one "conic" point - between them - - - - * - # __ Two "on" points with two "conic" - \ - - points between them. The point - \ / \ marked '0' is the middle of the - - 0 \ "off" points, and is a 'virtual' - -_ _- # "on" point where the curve passes. - -- It does not appear in the point - list. - * - - - - - * # on - * * off - __---__ - _-- -_ - _- - - # \ - # - - Two "on" points - and two "cubic" point - between them - - -Each glyph's original outline points are located on a grid of indivisible units. The points are stored -in the font file as 16-bit integer grid coordinates, with the grid origin's being at (0, 0); they thus -range from -16384 to 16383. - -Convert conic to bezier arcs: -Conic P0 P1 P2 -Bezier B0 B1 B2 B3 -B0=P0 -B1=(P0+2*P1)/3 -B2=(P2+2*P1)/3 -B3=P2 - -*//****/ +/* + * from: http://www.freetype.org/freetype2/docs/glyphs/glyphs-6.html#section-1 + * + * Vectorial representation of Freetype glyphs + * + * The source format of outlines is a collection of closed paths called "contours". Each contour is + * made of a series of line segments and bezier arcs. Depending on the file format, these can be + * second-order or third-order polynomials. The former are also called quadratic or conic arcs, and + * they come from the TrueType format. The latter are called cubic arcs and mostly come from the + * Type1 format. + * + * Each arc is described through a series of start, end and control points. Each point of the outline + * has a specific tag which indicates wether it is used to describe a line segment or an arc. + * + * + * The following rules are applied to decompose the contour's points into segments and arcs : + * + * # two successive "on" points indicate a line segment joining them. + * + * # one conic "off" point amidst two "on" points indicates a conic bezier arc, the "off" point being + * the control point, and the "on" ones the start and end points. + * + * # Two successive cubic "off" points amidst two "on" points indicate a cubic bezier arc. There must + * be exactly two cubic control points and two on points for each cubic arc (using a single cubic + * "off" point between two "on" points is forbidden, for example). + * + * # finally, two successive conic "off" points forces the rasterizer to create (during the scan-line + * conversion process exclusively) a virtual "on" point amidst them, at their exact middle. This + * greatly facilitates the definition of successive conic bezier arcs. Moreover, it's the way + * outlines are described in the TrueType specification. + * + * Note that it is possible to mix conic and cubic arcs in a single contour, even though no current + * font driver produces such outlines. + * + * * # on + * * off + * __---__ + * #-__ _-- -_ + * --__ _- - + * --__ # \ + * --__ # + * -# + * Two "on" points + * Two "on" points and one "conic" point + * between them + * + * + * + * * + * # __ Two "on" points with two "conic" + * \ - - points between them. The point + * \ / \ marked '0' is the middle of the + * - 0 \ "off" points, and is a 'virtual' + * -_ _- # "on" point where the curve passes. + * -- It does not appear in the point + * list. + * * + * + * + * + * + * * # on + * * * off + * __---__ + * _-- -_ + * _- - + * # \ + * # + * + * Two "on" points + * and two "cubic" point + * between them + * + * + * Each glyph's original outline points are located on a grid of indivisible units. The points are stored + * in the font file as 16-bit integer grid coordinates, with the grid origin's being at (0, 0); they thus + * range from -16384 to 16383. + * + * Convert conic to bezier arcs: + * Conic P0 P1 P2 + * Bezier B0 B1 B2 B3 + * B0=P0 + * B1=(P0+2*P1)/3 + * B2=(P2+2*P1)/3 + * B3=P2 + * + */ diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index 417c557af8a..a3835b5bb4a 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -222,6 +222,20 @@ MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack) r_col[2] = ((pack) >> 16) & 0xFF; } +/* TODO: + * + * regarding #rgb_to_bw vs #rgb_to_grayscale, + * it seems nobody knows why we have both functions which convert color to grays + * but with different influences, this is quite stupid, and should be resolved + * by someone who knows this stuff: see this thread + * http://lists.blender.org/pipermail/bf-committers/2012-June/037180.html + * + * Only conclusion is that rgb_to_grayscale is used more for compositing. + */ +MINLINE float rgb_to_bw(const float rgb[3]) +{ + return 0.35f * rgb[0] + 0.45f * rgb[1] + 0.2f * rgb[2]; +} MINLINE float rgb_to_grayscale(const float rgb[3]) { @@ -233,6 +247,7 @@ MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3]) return (76 * (unsigned short) rgb[0] + 148 * (unsigned short) rgb[1] + 31 * (unsigned short) rgb[2]) / 255; } +/* luma from defined by 'YCC_JFIF', see #rgb_to_ycc */ MINLINE float rgb_to_luma(const float rgb[3]) { return 0.299f * rgb[0] + 0.587f * rgb[1] + 0.114f * rgb[2]; diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index d35624e84d2..e51d0d2645f 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -901,8 +901,8 @@ static int getLowestRoot(const float a, const float b, const float c, const floa // If determinant is negative it means no solutions. if (determinant >= 0.0f) { - // calculate the two roots: (if determinant == 0 then - // x1==x2 but lets disregard that slight optimization) + /* calculate the two roots: (if determinant == 0 then + * x1==x2 but lets disregard that slight optimization) */ float sqrtD = (float)sqrt(determinant); float r1 = (-b - sqrtD) / (2.0f * a); float r2 = (-b + sqrtD) / (2.0f * a); diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index d939576904e..5cda1c0b81f 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -136,6 +136,19 @@ float angle_v3v3v3(const float v1[3], const float v2[3], const float v3[3]) return angle_normalized_v3v3(vec1, vec2); } +/* Quicker than full angle computation */ +float cos_v3v3v3(const float p1[3], const float p2[3], const float p3[3]) +{ + float vec1[3], vec2[3]; + + sub_v3_v3v3(vec1, p2, p1); + sub_v3_v3v3(vec2, p2, p3); + normalize_v3(vec1); + normalize_v3(vec2); + + return dot_v3v3(vec1, vec2); +} + /* Return the shortest angle in radians between the 2 vectors */ float angle_v3v3(const float v1[3], const float v2[3]) { diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 1bda7b5ee7e..c85efc1fd9a 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -806,7 +806,7 @@ void BLI_getlastdir(const char *dir, char *last, const size_t maxlen) const char *BLI_getDefaultDocumentFolder(void) { #ifndef WIN32 - const char *xdg_documents_dir= getenv("XDG_DOCUMENTS_DIR"); + const char *xdg_documents_dir = getenv("XDG_DOCUMENTS_DIR"); if (xdg_documents_dir) return xdg_documents_dir; @@ -1547,31 +1547,40 @@ char *BLI_path_basename(char *path) /** * Produce image export path. - * - * Fails returning 0 if image filename is empty or if destination path - * matches image path (i.e. both are the same file). - * - * Trailing slash in dest_dir is optional. + * + * Returns: + * 0 if image filename is empty or if destination path + * matches image path (i.e. both are the same file). + * 2 if source is identical to destination. + * 1 if rebase was successfull + * ------------------------------------------------------------- + * Hint: Trailing slash in dest_dir is optional. * * Logic: * - * - if an image is "below" current .blend file directory, rebuild the - * same dir structure in dest_dir + * - if an image is "below" current .blend file directory: + * rebuild the same dir structure in dest_dir * - * For example //textures/foo/bar.png becomes - * [dest_dir]/textures/foo/bar.png. + * Example: + * src : //textures/foo/bar.png + * dest: [dest_dir]/textures/foo/bar.png. * * - if an image is not "below" current .blend file directory, - * disregard it's path and copy it in the same directory where 3D file - * goes. + * disregard it's path and copy it into the destination + * directory. * - * For example //../foo/bar.png becomes [dest_dir]/bar.png. + * Example: + * src : //../foo/bar.png becomes + * dest: [dest_dir]/bar.png. * - * This logic will help ensure that all image paths are relative and + * This logic ensures that all image paths are relative and * that a user gets his images in one place. It'll also provide * consistent behavior across exporters. + * IMPORTANT NOTE: If base_dir contains an empty string, then + * this function returns wrong results! + * XXX: test on empty base_dir and return an error ? */ -int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir) +int BLI_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const char *base_dir, const char *src_dir, const char *dest_dir) { char path[FILE_MAX]; char dir[FILE_MAX]; @@ -1590,7 +1599,7 @@ int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const BLI_split_dir_part(base_dir, blend_dir, sizeof(blend_dir)); if (src_dir[0] == '\0') - return 0; + return BLI_REBASE_NO_SRCDIR; BLI_strncpy(path, src_dir, sizeof(path)); @@ -1634,13 +1643,13 @@ int BKE_rebase_path(char *abs, size_t abs_len, char *rel, size_t rel_len, const strncat(rel, base, rel_len); } - /* return 2 if src=dest */ + /* return 2 if (src == dest) */ if (BLI_path_cmp(path, dest_path) == 0) { // if (G.debug & G_DEBUG) printf("%s and %s are the same file\n", path, dest_path); - return 2; + return BLI_REBASE_IDENTITY; } - return 1; + return BLI_REBASE_OK; } char *BLI_first_slash(char *string) diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 94752965f3a..1f0bd445831 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -288,7 +288,7 @@ static void mergepolysSimp(ScanFillContext *sf_ctx, PolyFill *pf1, PolyFill *pf2 } static short testedgeside(const float v1[2], const float v2[2], const float v3[2]) -/* is v3 to the right of v1-v2 ? With exception: v3==v1 || v3==v2 */ +/* is v3 to the right of v1-v2 ? With exception: v3 == v1 || v3 == v2 */ { float inp; diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index d4f251d4f5e..965e8b5eec3 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -102,7 +102,7 @@ static struct ListBase dirbase_ = {NULL, NULL}; static struct ListBase *dirbase = &dirbase_; /* can return NULL when the size is not big enough */ -char *BLI_current_working_dir(char *dir, const int maxncpy) +char *BLI_current_working_dir(char *dir, const size_t maxncpy) { const char *pwd = getenv("PWD"); if (pwd) { diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c index d591f98ddc0..348fa29eae7 100644 --- a/source/blender/blenlib/intern/threads.c +++ b/source/blender/blenlib/intern/threads.c @@ -96,7 +96,7 @@ static void *thread_tls_data; * } * // conditions to exit loop * if (if escape loop event) { - * if (BLI_available_threadslots(&lb)==maxthreads) + * if (BLI_available_threadslots(&lb) == maxthreads) * break; * } * } diff --git a/source/blender/blenlib/intern/time.c b/source/blender/blenlib/intern/time.c index 64f007513ed..bf9720fee09 100644 --- a/source/blender/blenlib/intern/time.c +++ b/source/blender/blenlib/intern/time.c @@ -37,7 +37,7 @@ double PIL_check_seconds_timer(void) { - static int hasperfcounter = -1; /* -1==unknown */ + static int hasperfcounter = -1; /* (-1 == unknown) */ static double perffreq; if (hasperfcounter == -1) { diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c index 727e42dc8de..eeb0187b74c 100644 --- a/source/blender/blenlib/intern/voronoi.c +++ b/source/blender/blenlib/intern/voronoi.c @@ -28,7 +28,7 @@ * http://blog.ivank.net/fortunes-algorithm-and-implementation.html */ -/** \file blender/blenkernel/intern/tracking.c +/** \file blender/blenkernel/intern/voronoi.c * \ingroup bli */ @@ -790,16 +790,15 @@ void BLI_voronoi_triangulate(const VoronoiSite *sites, int sites_total, ListBase int ok_start = TRUE, ok_end = TRUE; while (test_edge) { - float v1[2], v2[2]; - - sub_v2_v2v2(v1, edge->start, sites[i].co); - sub_v2_v2v2(v2, edge->end, sites[i].co); - - if (ok_start && !testVoronoiEdge(sites[i].co, edge->start, test_edge)) + if (ok_start && !testVoronoiEdge(sites[i].co, edge->start, test_edge)) { ok_start = FALSE; + break; + } - if (ok_end && !testVoronoiEdge(sites[i].co, edge->end, test_edge)) + if (ok_end && !testVoronoiEdge(sites[i].co, edge->end, test_edge)) { ok_end = FALSE; + break; + } test_edge = test_edge->next; } diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index 10eb4e82912..3a8705bbbba 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -93,9 +93,9 @@ float BLI_voxel_sample_trilinear(float *data, const int res[3], const float co[3 const float w[2] = {1.f - dz, dz}; return w[0] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[0]] + u[1] * data[xc[1] + yc[0] + zc[0]] ) - + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] ) ) - + w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] ) - + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] ) ); + + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] ) ) + + w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] ) + + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] ) ); } return 0.f; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index b481fd421dc..7133f79f880 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -159,52 +159,52 @@ #include <errno.h> /* - Remark: still a weak point is the newaddress() function, that doesnt solve reading from - multiple files at the same time - - (added remark: oh, i thought that was solved? will look at that... (ton) - -READ -- Existing Library (Main) push or free -- allocate new Main -- load file -- read SDNA -- for each LibBlock - - read LibBlock - - if a Library - - make a new Main - - attach ID's to it - - else - - read associated 'direct data' - - link direct data (internal and to LibBlock) -- read FileGlobal -- read USER data, only when indicated (file is ~/X.XX/startup.blend) -- free file -- per Library (per Main) - - read file - - read SDNA - - find LibBlocks and attach IDs to Main - - if external LibBlock - - search all Main's - - or it's already read, - - or not read yet - - or make new Main - - per LibBlock - - read recursive - - read associated direct data - - link direct data (internal and to LibBlock) - - free file -- per Library with unread LibBlocks - - read file - - read SDNA - - per LibBlock - - read recursive - - read associated direct data - - link direct data (internal and to LibBlock) - - free file -- join all Mains -- link all LibBlocks and indirect pointers to libblocks -- initialize FileGlobal and copy pointers to Global + * Remark: still a weak point is the newaddress() function, that doesnt solve reading from + * multiple files at the same time + * + * (added remark: oh, i thought that was solved? will look at that... (ton) + * + * READ + * - Existing Library (Main) push or free + * - allocate new Main + * - load file + * - read SDNA + * - for each LibBlock + * - read LibBlock + * - if a Library + * - make a new Main + * - attach ID's to it + * - else + * - read associated 'direct data' + * - link direct data (internal and to LibBlock) + * - read FileGlobal + * - read USER data, only when indicated (file is ~/X.XX/startup.blend) + * - free file + * - per Library (per Main) + * - read file + * - read SDNA + * - find LibBlocks and attach IDs to Main + * - if external LibBlock + * - search all Main's + * - or it's already read, + * - or not read yet + * - or make new Main + * - per LibBlock + * - read recursive + * - read associated direct data + * - link direct data (internal and to LibBlock) + * - free file + * - per Library with unread LibBlocks + * - read file + * - read SDNA + * - per LibBlock + * - read recursive + * - read associated direct data + * - link direct data (internal and to LibBlock) + * - free file + * - join all Mains + * - link all LibBlocks and indirect pointers to libblocks + * - initialize FileGlobal and copy pointers to Global */ /* also occurs in library.c */ @@ -4426,7 +4426,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) } else if (md->type == eModifierType_Collision) { CollisionModifierData *collmd = (CollisionModifierData *)md; - /* +#if 0 // TODO: CollisionModifier should use pointcache // + have proper reset events before enabling this collmd->x = newdataadr(fd, collmd->x); @@ -4436,7 +4436,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) collmd->current_x = MEM_callocN(sizeof(MVert)*collmd->numverts, "current_x"); collmd->current_xnew = MEM_callocN(sizeof(MVert)*collmd->numverts, "current_xnew"); collmd->current_v = MEM_callocN(sizeof(MVert)*collmd->numverts, "current_v"); - */ +#endif collmd->x = NULL; collmd->xnew = NULL; @@ -5496,7 +5496,7 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) v3d->localvd->camera = sc->scene->camera; /* localview can become invalid during undo/redo steps, so we exit it when no could be found */ - /* XXX regionlocalview ? +#if 0 /* XXX regionlocalview ? */ for (base= sc->scene->base.first; base; base= base->next) { if (base->lay & v3d->lay) break; } @@ -5506,7 +5506,7 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) MEM_freeN(v3d->localvd); v3d->localvd= NULL; } - */ +#endif } else if (v3d->scenelock) v3d->lay = sc->scene->lay; @@ -5533,6 +5533,11 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) if (ads->filter_grp) ads->filter_grp = restore_pointer_by_name(newmain, (ID *)ads->filter_grp, 0); } + + /* force recalc of list of channels (i.e. includes calculating F-Curve colors) + * thus preventing the "black curves" problem post-undo + */ + sipo->flag |= SIPO_TEMP_NEEDCHANSYNC; } else if (sl->spacetype == SPACE_BUTS) { SpaceButs *sbuts = (SpaceButs *)sl; @@ -5547,10 +5552,10 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) SpaceAction *saction = (SpaceAction *)sl; saction->action = restore_pointer_by_name(newmain, (ID *)saction->action, 1); - saction->ads.source= restore_pointer_by_name(newmain, (ID *)saction->ads.source, 1); + saction->ads.source = restore_pointer_by_name(newmain, (ID *)saction->ads.source, 1); if (saction->ads.filter_grp) - saction->ads.filter_grp= restore_pointer_by_name(newmain, (ID *)saction->ads.filter_grp, 0); + saction->ads.filter_grp = restore_pointer_by_name(newmain, (ID *)saction->ads.filter_grp, 0); /* force recalc of list of channels, potentially updating the active action @@ -5909,11 +5914,20 @@ static void direct_link_screen(FileData *fd, bScreen *sc) } } else if (sl->spacetype == SPACE_SEQ) { + /* grease pencil data is not a direct data and can't be linked from direct_link* + * functions, it should be linked from lib_link* funcrions instead + * + * otherwise it'll lead to lost grease data on open because it'll likely be + * read from file after all other users of grease pencil and newdataadr would + * simple return NULL here (sergey) + */ +#if 0 SpaceSeq *sseq = (SpaceSeq *)sl; if (sseq->gpd) { sseq->gpd = newdataadr(fd, sseq->gpd); direct_link_gpencil(fd, sseq->gpd); } +#endif } else if (sl->spacetype == SPACE_BUTS) { SpaceButs *sbuts = (SpaceButs *)sl; @@ -6982,6 +6996,21 @@ static void do_version_ntree_image_user_264(void *UNUSED(data), ID *UNUSED(id), } } +static void do_version_ntree_dilateerode_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree) +{ + bNode *node; + + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_DILATEERODE) { + if (node->storage == NULL) { + NodeDilateErode *data = MEM_callocN(sizeof(NodeDilateErode), __func__); + data->falloff = PROP_SMOOTH; + node->storage = data; + } + } + } +} + static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ @@ -7406,7 +7435,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if (main->versionfile < 263) { /* set fluidsim rate. the version patch for this in 2.62 was wrong, so - try to correct it, if rate is 0.0 that's likely not intentional */ + * try to correct it, if rate is 0.0 that's likely not intentional */ Object *ob; for (ob = main->object.first; ob; ob = ob->id.next) { @@ -7789,6 +7818,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ma->strand_widthfade = 0.0f; } + if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 13)) { + bNodeTreeType *ntreetype = ntreeGetType(NTREE_COMPOSIT); + + if (ntreetype && ntreetype->foreach_nodetree) + ntreetype->foreach_nodetree(main, NULL, do_version_ntree_dilateerode_264); + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 5ed39ad5307..ca071e0cc25 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -2558,11 +2558,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) for (ob = main->object.first; ob; ob = ob->id.next) { for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_IPO) { - // Create the new actuator + /* Create the new actuator */ ia = act->data; aa = MEM_callocN(sizeof(bActionActuator), "fcurve -> action actuator do_version"); - // Copy values + /* Copy values */ aa->type = ia->type; aa->flag = ia->flag; aa->sta = ia->sta; @@ -2572,12 +2572,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) if (ob->adt) aa->act = ob->adt->action; - // Get rid of the old actuator + /* Get rid of the old actuator */ MEM_freeN(ia); - // Assign the new actuator + /* Assign the new actuator */ act->data = aa; act->type = act->otype = ACT_ACTION; + + /* Fix for converting 2.4x files: if we don't have an action, but we have an + * object IPO, then leave the actuator as an IPO actuator for now and let the + * IPO conversion code handle it */ + if (ob->ipo && !aa->act) + act->type = ACT_IPO; } else if (act->type == ACT_SHAPEACTION) { act->type = act->otype = ACT_ACTION; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index f257994bc1c..02b4537e9c8 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1380,14 +1380,14 @@ static void write_modifiers(WriteData *wd, ListBase *modbase) } else if (md->type==eModifierType_Collision) { - /* +#if 0 CollisionModifierData *collmd = (CollisionModifierData*) md; // TODO: CollisionModifier should use pointcache // + have proper reset events before enabling this writestruct(wd, DATA, "MVert", collmd->numverts, collmd->x); writestruct(wd, DATA, "MVert", collmd->numverts, collmd->xnew); writestruct(wd, DATA, "MFace", collmd->numfaces, collmd->mfaces); - */ +#endif } else if (md->type==eModifierType_MeshDeform) { MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt index 730b741fa38..4bce7a6ff51 100644 --- a/source/blender/bmesh/CMakeLists.txt +++ b/source/blender/bmesh/CMakeLists.txt @@ -32,6 +32,10 @@ set(INC ../../../intern/guardedalloc ) +set(INC_SYS + +) + set(SRC operators/bmo_bevel.c operators/bmo_connect.c diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index a14d602c586..a51d6bd2940 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -384,7 +384,7 @@ int bmesh_elem_check(void *element, const char htype) err |= 256; if (l->e->head.htype != BM_EDGE) err |= 512; - if (l->v->head.htype != BM_VERT) + if (l->v->head.htype != BM_VERT) err |= 1024; if (!BM_vert_in_edge(l->e, l->v)) { fprintf(stderr, "%s: fatal bmesh error (vert not in edge)! (bmesh internal error)\n", __func__); diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index 8d9f2ed7336..385572cceff 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -318,10 +318,10 @@ static void bm_rationalize_normals(BMesh *bm, int undo) return; } - BMO_op_initf(bm, &bmop, "righthandfaces faces=%af do_flip=%b", FALSE); + BMO_op_initf(bm, &bmop, "recalc_face_normals faces=%af do_flip=%b", FALSE); BMO_push(bm, &bmop); - bmo_righthandfaces_exec(bm, &bmop); + bmo_recalc_face_normals_exec(bm, &bmop); BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { BM_elem_flag_set(f, BM_ELEM_TAG, BMO_elem_flag_test(bm, f, FACE_FLIP)); diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index a8c27e0a761..123eb6829a3 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -768,7 +768,7 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess) /* editing the base key should update others */ if ((me->key->type == KEY_RELATIVE) && /* only need offsets for relative shape keys */ - (actkey != NULL) && /* unlikely, but the active key may not be valid if the + (actkey != NULL) && /* unlikely, but the active key may not be valid if the * bmesh and the mesh are out of sync */ (oldverts != NULL)) /* not used here, but 'oldverts' is used later for applying 'ofs' */ { diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 2c7007d1961..b29970dc886 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -354,12 +354,12 @@ BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **r_l l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { - BM_loop_interp_from_face(bm, l_iter, of, FALSE, TRUE); + BM_loop_interp_multires(bm, l_iter, of); } while ((l_iter = l_iter->next) != l_first); l_iter = l_first = BM_FACE_FIRST_LOOP(nf); do { - BM_loop_interp_from_face(bm, l_iter, of, FALSE, TRUE); + BM_loop_interp_multires(bm, l_iter, of); } while ((l_iter = l_iter->next) != l_first); BM_face_kill(bm, of); diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 4186f5d47eb..b6d9fbc85a2 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -97,8 +97,8 @@ * * Smooths vertices by using a basic vertex averaging scheme. */ -static BMOpDefine bmo_vertexsmooth_def = { - "vertexsmooth", +static BMOpDefine bmo_smooth_vert_def = { + "smooth_vert", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices {BMO_OP_SLOT_BOOL, "mirror_clip_x"}, //set vertices close to the x axis before the operation to 0 {BMO_OP_SLOT_BOOL, "mirror_clip_y"}, //set vertices close to the y axis before the operation to 0 @@ -106,7 +106,7 @@ static BMOpDefine bmo_vertexsmooth_def = { {BMO_OP_SLOT_FLT, "clipdist"}, //clipping threshod for the above three slots {0} /* null-terminating sentinel */, }, - bmo_vertexsmooth_exec, + bmo_smooth_vert_exec, 0 }; @@ -116,13 +116,13 @@ static BMOpDefine bmo_vertexsmooth_def = { * Computes an "outside" normal for the specified input faces. */ -static BMOpDefine bmo_righthandfaces_def = { - "righthandfaces", +static BMOpDefine bmo_recalc_face_normals_def = { + "recalc_face_normals", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, {BMO_OP_SLOT_BOOL, "do_flip"}, //internal flag, used by bmesh_rationalize_normals {0} /* null-terminating sentinel */, }, - bmo_righthandfaces_exec, + bmo_recalc_face_normals_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -136,15 +136,15 @@ static BMOpDefine bmo_righthandfaces_def = { * if usefaces is 0 then geomout spits out verts and edges, * otherwise it spits out faces. */ -static BMOpDefine bmo_regionextend_def = { - "regionextend", +static BMOpDefine bmo_region_extend_def = { + "region_extend", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, //input geometry {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, //output slot, computed boundary geometry. {BMO_OP_SLOT_BOOL, "constrict"}, //find boundary inside the regions, not outside. {BMO_OP_SLOT_BOOL, "use_faces"}, //extend from faces instead of edges {0} /* null-terminating sentinel */, }, - bmo_regionextend_exec, + bmo_region_extend_exec, 0 }; @@ -154,14 +154,14 @@ static BMOpDefine bmo_regionextend_def = { * Rotates edges topologically. Also known as "spin edge" to some people. * Simple example: [/] becomes [|] then [\]. */ -static BMOpDefine bmo_edgerotate_def = { - "edgerotate", +static BMOpDefine bmo_rotate_edges_def = { + "rotate_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, //input edges {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, //newly spun edges {BMO_OP_SLOT_BOOL, "ccw"}, //rotate edge counter-clockwise if true, othewise clockwise {0} /* null-terminating sentinel */, }, - bmo_edgerotate_exec, + bmo_rotate_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -171,12 +171,12 @@ static BMOpDefine bmo_edgerotate_def = { * Reverses the winding (vertex order) of faces. This has the effect of * flipping the normal. */ -static BMOpDefine bmo_reversefaces_def = { - "reversefaces", +static BMOpDefine bmo_reverse_faces_def = { + "reverse_faces", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, //input faces {0} /* null-terminating sentinel */, }, - bmo_reversefaces_exec, + bmo_reverse_faces_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -186,14 +186,14 @@ static BMOpDefine bmo_reversefaces_def = { * Splits input edges (but doesn't do anything else). * This creates a 2-valence vert. */ -static BMOpDefine bmo_edgebisect_def = { - "edgebisect", +static BMOpDefine bmo_bisect_edges_def = { + "bisect_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, //input edges {BMO_OP_SLOT_INT, "numcuts"}, //number of cuts {BMO_OP_SLOT_ELEMENT_BUF, "outsplit"}, //newly created vertices and edges {0} /* null-terminating sentinel */, }, - bmo_edgebisect_exec, + bmo_bisect_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -225,17 +225,17 @@ static BMOpDefine bmo_mirror_def = { * Takes input verts and find vertices they should weld to. Outputs a * mapping slot suitable for use with the weld verts bmop. * - * If keepverts is used, vertices outside that set can only be merged + * If keep_verts is used, vertices outside that set can only be merged * with vertices in that set. */ -static BMOpDefine bmo_finddoubles_def = { - "finddoubles", +static BMOpDefine bmo_find_doubles_def = { + "find_doubles", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices - {BMO_OP_SLOT_ELEMENT_BUF, "keepverts"}, //list of verts to keep + {BMO_OP_SLOT_ELEMENT_BUF, "keep_verts"}, //list of verts to keep {BMO_OP_SLOT_FLT, "dist"}, //minimum distance {BMO_OP_SLOT_MAPPING, "targetmapout"}, {0, /* null-terminating sentinel */}}, - bmo_finddoubles_exec, + bmo_find_doubles_exec, 0, }; @@ -245,12 +245,12 @@ static BMOpDefine bmo_finddoubles_def = { * Finds groups of vertices closer then dist and merges them together, * using the weld verts bmop. */ -static BMOpDefine bmo_removedoubles_def = { - "removedoubles", +static BMOpDefine bmo_remove_doubles_def = { + "remove_doubles", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input verts {BMO_OP_SLOT_FLT, "dist"}, //minimum distance {0, /* null-terminating sentinel */}}, - bmo_removedoubles_exec, + bmo_remove_doubles_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -305,11 +305,11 @@ static BMOpDefine bmo_pointmerge_facedata_def = { * the bounding box center. (I know, it's not averaging but * the vert_snap_to_bb_center is just too long). */ -static BMOpDefine bmo_vert_average_facedata_def = { - "vert_average_facedata", +static BMOpDefine bmo_average_vert_facedata_def = { + "average_vert_facedata", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */ {0, /* null-terminating sentinel */}}, - bmo_vert_average_facedata_exec, + bmo_average_vert_facedata_exec, 0, }; @@ -321,7 +321,7 @@ static BMOpDefine bmo_vert_average_facedata_def = { static BMOpDefine bmo_pointmerge_def = { "pointmerge", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertice */ - {BMO_OP_SLOT_VEC, "mergeco"}, + {BMO_OP_SLOT_VEC, "merge_co"}, {0, /* null-terminating sentinel */}}, bmo_pointmerge_exec, BMO_OP_FLAG_UNTAN_MULTIRES, @@ -347,11 +347,11 @@ static BMOpDefine bmo_collapse_uvs_def = { * use or will use this bmop). You pass in mappings from vertices to the vertices * they weld with. */ -static BMOpDefine bmo_weldverts_def = { - "weldverts", +static BMOpDefine bmo_weld_verts_def = { + "weld_verts", {{BMO_OP_SLOT_MAPPING, "targetmap"}, /* maps welded vertices to verts they should weld to */ {0, /* null-terminating sentinel */}}, - bmo_weldverts_exec, + bmo_weld_verts_exec, BMO_OP_FLAG_UNTAN_MULTIRES, }; @@ -361,12 +361,12 @@ static BMOpDefine bmo_weldverts_def = { * Creates a single vertex; this bmop was necessary * for click-create-vertex. */ -static BMOpDefine bmo_makevert_def = { - "makevert", +static BMOpDefine bmo_create_vert_def = { + "create_vert", {{BMO_OP_SLOT_VEC, "co"}, //the coordinate of the new vert {BMO_OP_SLOT_ELEMENT_BUF, "newvertout"}, //the new vert {0, /* null-terminating sentinel */}}, - bmo_makevert_exec, + bmo_create_vert_exec, 0, }; @@ -528,8 +528,8 @@ static BMOpDefine bmo_transform_def = { */ static BMOpDefine bmo_object_load_bmesh_def = { "object_load_bmesh", - {{BMO_OP_SLOT_PNT, "scene"}, - {BMO_OP_SLOT_PNT, "object"}, + {{BMO_OP_SLOT_PTR, "scene"}, + {BMO_OP_SLOT_PTR, "object"}, {0, /* null-terminating sentinel */}}, bmo_object_load_bmesh_exec, 0, @@ -543,8 +543,8 @@ static BMOpDefine bmo_object_load_bmesh_def = { */ static BMOpDefine bmo_bmesh_to_mesh_def = { "bmesh_to_mesh", - {{BMO_OP_SLOT_PNT, "mesh"}, //pointer to a mesh structure to fill in - {BMO_OP_SLOT_PNT, "object"}, //pointer to an object structure + {{BMO_OP_SLOT_PTR, "mesh"}, //pointer to a mesh structure to fill in + {BMO_OP_SLOT_PTR, "object"}, //pointer to an object structure {BMO_OP_SLOT_BOOL, "notessellation"}, //don't calculate mfaces {0, /* null-terminating sentinel */}}, bmo_bmesh_to_mesh_exec, @@ -559,8 +559,8 @@ static BMOpDefine bmo_bmesh_to_mesh_def = { */ static BMOpDefine bmo_mesh_to_bmesh_def = { "mesh_to_bmesh", - {{BMO_OP_SLOT_PNT, "mesh"}, //pointer to a Mesh structure - {BMO_OP_SLOT_PNT, "object"}, //pointer to an Object structure + {{BMO_OP_SLOT_PTR, "mesh"}, //pointer to a Mesh structure + {BMO_OP_SLOT_PTR, "object"}, //pointer to an Object structure {BMO_OP_SLOT_BOOL, "set_shapekey"}, //load active shapekey coordinates into verts {0, /* null-terminating sentinel */}}, bmo_mesh_to_bmesh_exec, @@ -572,13 +572,13 @@ static BMOpDefine bmo_mesh_to_bmesh_def = { * * Extrudes faces individually. */ -static BMOpDefine bmo_extrude_indivface_def = { - "extrude_face_indiv", +static BMOpDefine bmo_extrude_discrete_faces_def = { + "extrude_discrete_faces", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, //input faces {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, //output faces {BMO_OP_SLOT_ELEMENT_BUF, "skirtout"}, //output skirt geometry, faces and edges {0} /* null-terminating sentinel */}, - bmo_extrude_face_indiv_exec, + bmo_extrude_discrete_faces_exec, 0 }; @@ -612,12 +612,12 @@ static BMOpDefine bmo_extrude_vert_indiv_def = { 0 }; -static BMOpDefine bmo_connectverts_def = { - "connectverts", +static BMOpDefine bmo_connect_verts_def = { + "connect_verts", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, {0} /* null-terminating sentinel */}, - bmo_connectverts_exec, + bmo_connect_verts_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -691,8 +691,8 @@ static BMOpDefine bmo_triangulate_def = { BMO_OP_FLAG_UNTAN_MULTIRES }; -static BMOpDefine bmo_esubd_def = { - "esubd", +static BMOpDefine bmo_subdivide_edges_def = { + "subdivide_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, {BMO_OP_SLOT_FLT, "smooth"}, {BMO_OP_SLOT_FLT, "fractal"}, @@ -714,21 +714,21 @@ static BMOpDefine bmo_esubd_def = { {0} /* null-terminating sentinel */, }, - bmo_esubd_exec, + bmo_subdivide_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; -static BMOpDefine bmo_del_def = { - "del", +static BMOpDefine bmo_delete_def = { + "delete", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, {BMO_OP_SLOT_INT, "context"}, {0} /* null-terminating sentinel */}, - bmo_del_exec, + bmo_delete_exec, 0 }; -static BMOpDefine bmo_dupe_def = { - "dupe", +static BMOpDefine bmo_duplicate_def = { + "duplicate", {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, {BMO_OP_SLOT_ELEMENT_BUF, "origout"}, {BMO_OP_SLOT_ELEMENT_BUF, "newout"}, @@ -737,9 +737,9 @@ static BMOpDefine bmo_dupe_def = { {BMO_OP_SLOT_MAPPING, "facemap"}, {BMO_OP_SLOT_MAPPING, "boundarymap"}, {BMO_OP_SLOT_MAPPING, "isovertmap"}, - {BMO_OP_SLOT_PNT, "dest"}, /* destination bmesh, if NULL will use current on */ + {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current on */ {0} /* null-terminating sentinel */}, - bmo_dupe_exec, + bmo_duplicate_exec, 0 }; @@ -749,7 +749,7 @@ static BMOpDefine bmo_split_def = { {BMO_OP_SLOT_ELEMENT_BUF, "geomout"}, {BMO_OP_SLOT_MAPPING, "boundarymap"}, {BMO_OP_SLOT_MAPPING, "isovertmap"}, - {BMO_OP_SLOT_PNT, "dest"}, /* destination bmesh, if NULL will use current on */ + {BMO_OP_SLOT_PTR, "dest"}, /* destination bmesh, if NULL will use current on */ {BMO_OP_SLOT_BOOL, "use_only_faces"}, /* when enabled. don't duplicate loose verts/edges */ {0} /* null-terminating sentinel */}, bmo_split_exec, @@ -783,14 +783,14 @@ static BMOpDefine bmo_spin_def = { * * Find similar faces (area/material/perimeter, ...). */ -static BMOpDefine bmo_similarfaces_def = { - "similarfaces", +static BMOpDefine bmo_similar_faces_def = { + "similar_faces", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMO_OP_SLOT_ELEMENT_BUF, "faceout"}, /* output faces */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */ {0} /* null-terminating sentinel */}, - bmo_similarfaces_exec, + bmo_similar_faces_exec, 0 }; @@ -799,14 +799,14 @@ static BMOpDefine bmo_similarfaces_def = { * * Find similar edges (length, direction, edge, seam, ...). */ -static BMOpDefine bmo_similaredges_def = { - "similaredges", +static BMOpDefine bmo_similar_edges_def = { + "similar_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* output edges */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */ {0} /* null-terminating sentinel */}, - bmo_similaredges_exec, + bmo_similar_edges_exec, 0 }; @@ -815,14 +815,14 @@ static BMOpDefine bmo_similaredges_def = { * * Find similar vertices (normal, face, vertex group, ...). */ -static BMOpDefine bmo_similarverts_def = { - "similarverts", +static BMOpDefine bmo_similar_verts_def = { + "similar_verts", {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* input vertices */ {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {BMO_OP_SLOT_FLT, "thresh"}, /* threshold of selection */ {0} /* null-terminating sentinel */}, - bmo_similarverts_exec, + bmo_similar_verts_exec, 0 }; @@ -830,12 +830,12 @@ static BMOpDefine bmo_similarverts_def = { * uv rotation * cycle the uvs */ -static BMOpDefine bmo_face_rotateuvs_def = { - "face_rotateuvs", +static BMOpDefine bmo_rotate_uvs_def = { + "rotate_uvs", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMO_OP_SLOT_INT, "dir"}, /* direction */ {0} /* null-terminating sentinel */}, - bmo_face_rotateuvs_exec, + bmo_rotate_uvs_exec, 0 }; @@ -843,11 +843,11 @@ static BMOpDefine bmo_face_rotateuvs_def = { * uv reverse * reverse the uvs */ -static BMOpDefine bmo_face_reverseuvs_def = { - "face_reverseuvs", +static BMOpDefine bmo_reverse_uvs_def = { + "reverse_uvs", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {0} /* null-terminating sentinel */}, - bmo_face_reverseuvs_exec, + bmo_reverse_uvs_exec, 0 }; @@ -855,12 +855,12 @@ static BMOpDefine bmo_face_reverseuvs_def = { * color rotation * cycle the colors */ -static BMOpDefine bmo_face_rotatecolors_def = { - "face_rotatecolors", +static BMOpDefine bmo_rotate_colors_def = { + "rotate_colors", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {BMO_OP_SLOT_INT, "dir"}, /* direction */ {0} /* null-terminating sentinel */}, - bmo_rotatecolors_exec, + bmo_rotate_colors_exec, 0 }; @@ -868,11 +868,11 @@ static BMOpDefine bmo_face_rotatecolors_def = { * color reverse * reverse the colors */ -static BMOpDefine bmo_face_reversecolors_def = { - "face_reversecolors", +static BMOpDefine bmo_reverse_colors_def = { + "reverse_colors", {{BMO_OP_SLOT_ELEMENT_BUF, "faces"}, /* input faces */ {0} /* null-terminating sentinel */}, - bmo_face_reversecolors_exec, + bmo_reverse_colors_exec, 0 }; @@ -881,14 +881,14 @@ static BMOpDefine bmo_face_reversecolors_def = { * * Find similar vertices (normal, face, vertex group, ...). */ -static BMOpDefine bmo_vertexshortestpath_def = { - "vertexshortestpath", +static BMOpDefine bmo_shortest_path_def = { + "shortest_path", {{BMO_OP_SLOT_ELEMENT_BUF, "startv"}, /* start vertex */ {BMO_OP_SLOT_ELEMENT_BUF, "endv"}, /* end vertex */ {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, /* output vertices */ {BMO_OP_SLOT_INT, "type"}, /* type of selection */ {0} /* null-terminating sentinel */}, - bmo_vertexshortestpath_exec, + bmo_shortest_path_exec, 0 }; @@ -897,15 +897,15 @@ static BMOpDefine bmo_vertexshortestpath_def = { * * Disconnects faces along input edges. */ -static BMOpDefine bmo_edgesplit_def = { - "edgesplit", +static BMOpDefine bmo_split_edges_def = { + "split_edges", {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, /* input edges */ {BMO_OP_SLOT_ELEMENT_BUF, "edgeout"}, /* old output disconnected edges */ /* needed for vertex rip so we can rip only half an edge at a boundary wich would otherwise split off */ {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, /* optional tag verts, use to have greater control of splits */ {BMO_OP_SLOT_BOOL, "use_verts"}, /* use 'verts' for splitting, else just find verts to split from edges */ {0} /* null-terminating sentinel */}, - bmo_edgesplit_exec, + bmo_split_edges_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -1034,12 +1034,12 @@ static BMOpDefine bmo_bevel_def = { {{BMO_OP_SLOT_ELEMENT_BUF, "geom"}, /* input edges and vertices */ {BMO_OP_SLOT_ELEMENT_BUF, "face_spans"}, /* new geometry */ {BMO_OP_SLOT_ELEMENT_BUF, "face_holes"}, /* new geometry */ - {BMO_OP_SLOT_BOOL, "use_lengths"}, /* grab edge lengths from a PROP_FLT customdata laye */ + {BMO_OP_SLOT_BOOL, "use_lengths"}, /* grab edge lengths from a PROP_FLT customdata layer */ {BMO_OP_SLOT_BOOL, "use_even"}, /* corner vert placement: use shell/angle calculations */ {BMO_OP_SLOT_BOOL, "use_dist"}, /* corner vert placement: evaluate percent as a distance, * modifier uses this. We could do this as another float setting */ {BMO_OP_SLOT_INT, "lengthlayer"}, /* which PROP_FLT layer to us */ - {BMO_OP_SLOT_FLT, "percent"}, /* percentage to expand bevelled edge */ + {BMO_OP_SLOT_FLT, "percent"}, /* percentage to expand beveled edge */ {0} /* null-terminating sentinel */}, bmo_bevel_exec, BMO_OP_FLAG_UNTAN_MULTIRES @@ -1134,14 +1134,14 @@ static BMOpDefine bmo_wireframe_def = { * * Translates vertes along an edge */ -static BMOpDefine bmo_vertex_slide_def = { - "vertex_slide", +static BMOpDefine bmo_slide_vert_def = { + "slide_vert", {{BMO_OP_SLOT_ELEMENT_BUF, "vert"}, {BMO_OP_SLOT_ELEMENT_BUF, "edge"}, {BMO_OP_SLOT_ELEMENT_BUF, "vertout"}, {BMO_OP_SLOT_FLT, "distance_t"}, {0} /* null-terminating sentinel */}, - bmo_vertex_slide_exec, + bmo_slide_vert_exec, BMO_OP_FLAG_UNTAN_MULTIRES }; @@ -1176,75 +1176,76 @@ static BMOpDefine bmo_convex_hull_def = { }; BMOpDefine *opdefines[] = { - &bmo_split_def, - &bmo_spin_def, - &bmo_dupe_def, - &bmo_del_def, - &bmo_esubd_def, - &bmo_triangulate_def, - &bmo_dissolve_faces_def, - &bmo_dissolve_edges_def, + &bmo_automerge_def, + &bmo_average_vert_facedata_def, + &bmo_beautify_fill_def, + &bmo_bevel_def, + &bmo_bisect_edges_def, + &bmo_bmesh_to_mesh_def, + &bmo_bridge_loops_def, + &bmo_collapse_def, + &bmo_collapse_uvs_def, + &bmo_connect_verts_def, + &bmo_contextual_create_def, + &bmo_convex_hull_def, + &bmo_create_circle_def, + &bmo_create_cone_def, + &bmo_create_cube_def, + &bmo_create_grid_def, + &bmo_create_icosphere_def, + &bmo_create_monkey_def, + &bmo_create_uvsphere_def, + &bmo_create_vert_def, + &bmo_delete_def, &bmo_dissolve_edge_loop_def, - &bmo_dissolve_verts_def, + &bmo_dissolve_edges_def, + &bmo_dissolve_faces_def, &bmo_dissolve_limit_def, + &bmo_dissolve_verts_def, + &bmo_duplicate_def, + &bmo_edgenet_fill_def, + &bmo_edgenet_prepare_def, + &bmo_extrude_discrete_faces_def, + &bmo_extrude_edge_only_def, &bmo_extrude_face_region_def, - &bmo_connectverts_def, &bmo_extrude_vert_indiv_def, + &bmo_find_doubles_def, + &bmo_inset_def, + &bmo_join_triangles_def, &bmo_mesh_to_bmesh_def, - &bmo_object_load_bmesh_def, - &bmo_transform_def, - &bmo_translate_def, - &bmo_rotate_def, - &bmo_edgenet_fill_def, - &bmo_contextual_create_def, - &bmo_makevert_def, - &bmo_weldverts_def, - &bmo_removedoubles_def, - &bmo_finddoubles_def, &bmo_mirror_def, - &bmo_edgebisect_def, - &bmo_reversefaces_def, - &bmo_edgerotate_def, - &bmo_regionextend_def, - &bmo_righthandfaces_def, - &bmo_vertexsmooth_def, - &bmo_extrude_edge_only_def, - &bmo_extrude_indivface_def, - &bmo_collapse_uvs_def, + &bmo_object_load_bmesh_def, &bmo_pointmerge_def, - &bmo_collapse_def, - &bmo_similarfaces_def, - &bmo_similaredges_def, - &bmo_similarverts_def, &bmo_pointmerge_facedata_def, - &bmo_vert_average_facedata_def, - &bmo_face_rotateuvs_def, - &bmo_bmesh_to_mesh_def, - &bmo_face_reverseuvs_def, - &bmo_edgenet_prepare_def, - &bmo_face_rotatecolors_def, - &bmo_face_reversecolors_def, - &bmo_vertexshortestpath_def, + &bmo_recalc_face_normals_def, + &bmo_region_extend_def, + &bmo_remove_doubles_def, + &bmo_reverse_colors_def, + &bmo_reverse_faces_def, + &bmo_reverse_uvs_def, + &bmo_rotate_colors_def, + &bmo_rotate_def, + &bmo_rotate_edges_def, + &bmo_rotate_uvs_def, &bmo_scale_def, - &bmo_edgesplit_def, - &bmo_automerge_def, - &bmo_create_uvsphere_def, - &bmo_create_grid_def, - &bmo_create_icosphere_def, - &bmo_create_monkey_def, - &bmo_create_cube_def, - &bmo_create_circle_def, - &bmo_create_cone_def, - &bmo_join_triangles_def, - &bmo_bevel_def, - &bmo_beautify_fill_def, - &bmo_triangle_fill_def, - &bmo_bridge_loops_def, + &bmo_shortest_path_def, + &bmo_similar_edges_def, + &bmo_similar_faces_def, + &bmo_similar_verts_def, + &bmo_slide_vert_def, + &bmo_smooth_vert_def, &bmo_solidify_def, - &bmo_inset_def, + &bmo_spin_def, + &bmo_split_def, + &bmo_split_edges_def, + &bmo_subdivide_edges_def, + &bmo_transform_def, + &bmo_translate_def, + &bmo_triangle_fill_def, + &bmo_triangulate_def, + &bmo_weld_verts_def, &bmo_wireframe_def, - &bmo_vertex_slide_def, - &bmo_convex_hull_def, + }; int bmesh_total_ops = (sizeof(opdefines) / sizeof(void *)); diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h index b5e6534de3e..74087c00940 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api.h +++ b/source/blender/bmesh/intern/bmesh_operator_api.h @@ -99,7 +99,7 @@ enum { /* normally store pointers to object, scene, * _never_ store arrays corresponding to mesh elements with this */ - BMO_OP_SLOT_PNT = 4, + BMO_OP_SLOT_PTR = 4, BMO_OP_SLOT_MAT = 5, BMO_OP_SLOT_VEC = 8, @@ -116,7 +116,7 @@ enum { * for when your defining an operator with BMOpDefine.*/ typedef struct BMOpSlot { - int slottype; + int slot_type; int len; int flag; int index; /* index within slot array */ @@ -132,16 +132,13 @@ typedef struct BMOpSlot { #define BMO_OP_MAX_SLOTS 16 /* way more than probably needed */ -#ifdef slots -#undef slots -#endif - typedef struct BMOperator { int type; - int slottype; + int slot_type; int needflag; int flag; - struct BMOpSlot slots[BMO_OP_MAX_SLOTS]; void (*exec)(BMesh *bm, struct BMOperator *op); + struct BMOpSlot slot_args[BMO_OP_MAX_SLOTS]; + void (*exec)(BMesh *bm, struct BMOperator *op); struct MemArena *arena; } BMOperator; @@ -154,7 +151,7 @@ typedef struct BMOSlotType { typedef struct BMOpDefine { const char *name; - BMOSlotType slottypes[BMO_OP_MAX_SLOTS]; + BMOSlotType slot_types[BMO_OP_MAX_SLOTS]; void (*exec)(BMesh *bm, BMOperator *op); int flag; } BMOpDefine; @@ -197,11 +194,11 @@ int BMO_mesh_disabled_flag_count(BMesh *bm, const char htype, const short oflag) * this system is used to execute or initialize an operator, * using a formatted-string system. * - * for example, BMO_op_callf(bm, "del geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES); + * for example, BMO_op_callf(bm, "delete geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES); * . . .will execute the delete operator, feeding in selected faces, deleting them. * * the basic format for the format string is: - * [operatorname] [slotname]=%[code] [slotname]=%[code] + * [operatorname] [slot_name]=%[code] [slot_name]=%[code] * * as in printf, you pass in one additional argument to the function * for every code. @@ -246,10 +243,10 @@ int BMO_op_initf(BMesh *bm, BMOperator *op, const char *fmt, ...); int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *fmt, va_list vlist); /* test whether a named slot exists */ -int BMO_slot_exists(BMOperator *op, const char *slotname); +int BMO_slot_exists(BMOperator *op, const char *slot_name); /* get a pointer to a slot. this may be removed layer on from the public API. */ -BMOpSlot *BMO_slot_get(BMOperator *op, const char *slotname); +BMOpSlot *BMO_slot_get(BMOperator *op, const char *slot_name); /* copies the data of a slot from one operator to another. src and dst are the * source/destination slot codes, respectively. */ @@ -270,30 +267,30 @@ enum { void BMO_op_flag_enable(BMesh *bm, BMOperator *op, const int op_flag); void BMO_op_flag_disable(BMesh *bm, BMOperator *op, const int op_flag); -void BMO_slot_float_set(BMOperator *op, const char *slotname, const float f); -float BMO_slot_float_get(BMOperator *op, const char *slotname); -void BMO_slot_int_set(BMOperator *op, const char *slotname, const int i); -int BMO_slot_int_get(BMOperator *op, const char *slotname); -void BMO_slot_bool_set(BMOperator *op, const char *slotname, const int i); -int BMO_slot_bool_get(BMOperator *op, const char *slotname); +void BMO_slot_float_set(BMOperator *op, const char *slot_name, const float f); +float BMO_slot_float_get(BMOperator *op, const char *slot_name); +void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i); +int BMO_slot_int_get(BMOperator *op, const char *slot_name); +void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i); +int BMO_slot_bool_get(BMOperator *op, const char *slot_name); /* don't pass in arrays that are supposed to map to elements this way. * * so, e.g. passing in list of floats per element in another slot is bad. * passing in, e.g. pointer to an editmesh for the conversion operator is fine * though. */ -void BMO_slot_ptr_set(BMOperator *op, const char *slotname, void *p); -void *BMO_slot_ptr_get(BMOperator *op, const char *slotname); -void BMO_slot_vec_set(BMOperator *op, const char *slotname, const float vec[3]); -void BMO_slot_vec_get(BMOperator *op, const char *slotname, float r_vec[3]); +void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p); +void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name); +void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3]); +void BMO_slot_vec_get(BMOperator *op, const char *slot_name, float r_vec[3]); /* only supports square mats */ /* size must be 3 or 4; this api is meant only for transformation matrices. * note that internally the matrix is stored in 4x4 form, and it's safe to * call whichever BMO_Get_Mat* function you want. */ -void BMO_slot_mat_set(BMOperator *op, const char *slotname, const float *mat, int size); -void BMO_slot_mat4_get(BMOperator *op, const char *slotname, float r_mat[4][4]); -void BMO_slot_mat3_set(BMOperator *op, const char *slotname, float r_mat[3][3]); +void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, int size); +void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4]); +void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3]); void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *op, const char htype, const short oflag); @@ -303,47 +300,47 @@ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_op_slot, /* puts every element of type 'type' (which is a bitmask) with tool * flag 'flag', into a slot. */ -void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag); /* puts every element of type 'type' (which is a bitmask) without tool * flag 'flag', into a slot. */ -void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag); /* tool-flags all elements inside an element slot array with flag flag. */ -void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag); /* clears tool-flag flag from all elements inside a slot array. */ -void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag); /* tool-flags all elements inside an element slot array with flag flag. */ -void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const char do_flush); /* clears tool-flag flag from all elements inside a slot array. */ -void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const char do_flush); /* puts every element of type 'type' (which is a bitmask) with header * flag 'flag', into a slot. note: ignores hidden elements * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/ void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, - const char *slotname, + const char *slot_name, const char htype, const char hflag); /* puts every element of type 'type' (which is a bitmask) without * header flag 'flag', into a slot. note: ignores hidden elements * (e.g. elements with header flag BM_ELEM_HIDDEN set).*/ void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, - const char *slotname, + const char *slot_name, const char htype, const char hflag); /* counts number of elements inside a slot array. */ -int BMO_slot_buffer_count(BMesh *bm, BMOperator *op, const char *slotname); -int BMO_slot_map_count(BMesh *bm, BMOperator *op, const char *slotname); +int BMO_slot_buffer_count(BMesh *bm, BMOperator *op, const char *slot_name); +int BMO_slot_map_count(BMesh *bm, BMOperator *op, const char *slot_name); -void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, +void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element, void *data, int len); /* Counts the number of edges with tool flag toolflag around @@ -352,9 +349,14 @@ int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag); /* flags all elements in a mapping. note that the mapping must only have * bmesh elements in it.*/ -void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char hflag, const short oflag); +void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len); + +void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, + const char htype); + /* this part of the API is used to iterate over element buffer or * mapping slots. * @@ -363,7 +365,7 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, * BMOIter oiter; * BMFace *f; * - * f = BMO_iter_new(&oiter, bm, some_operator, "slotname", BM_FACE); + * f = BMO_iter_new(&oiter, bm, some_operator, "slot_name", BM_FACE); * for (; f; f = BMO_iter_step(&oiter)) { * /do something with the face * } @@ -373,7 +375,7 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, * void *key; * void *val; * - * key = BMO_iter_new(&oiter, bm, some_operator, "slotname", 0); + * key = BMO_iter_new(&oiter, bm, some_operator, "slot_name", 0); * for (; key; key = BMO_iter_step(&oiter)) { * val = BMO_iter_map_value(&oiter); * //do something with the key/val pair @@ -396,10 +398,10 @@ typedef struct BMOIter { char restrictmask; /* bitwise '&' with BMHeader.htype */ } BMOIter; -void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slotname); +void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name); void *BMO_iter_new(BMOIter *iter, BMesh *bm, BMOperator *op, - const char *slotname, const char restrictmask); + const char *slot_name, const char restrictmask); void *BMO_iter_step(BMOIter *iter); /* returns a pointer to the key value when iterating over mappings. @@ -412,8 +414,8 @@ void *BMO_iter_map_value_p(BMOIter *iter); /* use this for float mappings */ float BMO_iter_map_value_f(BMOIter *iter); -#define BMO_ITER(ele, iter, bm, op, slotname, restrict) \ - for (ele = BMO_iter_new(iter, bm, op, slotname, restrict); ele; ele = BMO_iter_step(iter)) +#define BMO_ITER(ele, iter, bm, op, slot_name, restrict) \ + for (ele = BMO_iter_new(iter, bm, op, slot_name, restrict); ele; ele = BMO_iter_step(iter)) /******************* Inlined Functions********************/ typedef void (*opexec)(BMesh *bm, BMOperator *op); diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h index e04079f42c9..16c2b8b0505 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h +++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h @@ -69,16 +69,16 @@ BLI_INLINE void _bmo_elem_flag_toggle(BMesh *bm, BMFlagLayer *oflags, const shor oflags[bm->stackdepth - 1].f ^= oflag; } -BLI_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slot_name, void *element, int val) { - BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(int)); + BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(int)); } -BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char *slot_name, void *element, float val) { - BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(float)); + BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(float)); } @@ -87,16 +87,16 @@ BLI_INLINE void BMO_slot_map_float_insert(BMesh *bm, BMOperator *op, const char * do NOT use these for non-operator-api-allocated memory! instead * use BMO_slot_map_data_get and BMO_slot_map_insert, which copies the data. */ -BLI_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE void BMO_slot_map_ptr_insert(BMesh *bm, BMOperator *op, const char *slot_name, void *element, void *val) { - BMO_slot_map_insert(bm, op, slotname, element, &val, sizeof(void *)); + BMO_slot_map_insert(bm, op, slot_name, element, &val, sizeof(void *)); } -BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, void *element) +BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* sanity check */ if (!slot->data.ghash) return 0; @@ -104,12 +104,12 @@ BLI_INLINE int BMO_slot_map_contains(BMesh *UNUSED(bm), BMOperator *op, const ch return BLI_ghash_haskey(slot->data.ghash, element); } -BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, +BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element) { BMOElemMapping *mapping; - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* sanity check */ if (!slot->data.ghash) return NULL; @@ -121,28 +121,28 @@ BLI_INLINE void *BMO_slot_map_data_get(BMesh *UNUSED(bm), BMOperator *op, const return mapping + 1; } -BLI_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE float BMO_slot_map_float_get(BMesh *bm, BMOperator *op, const char *slot_name, void *element) { - float *val = (float *) BMO_slot_map_data_get(bm, op, slotname, element); + float *val = (float *) BMO_slot_map_data_get(bm, op, slot_name, element); if (val) return *val; return 0.0f; } -BLI_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE int BMO_slot_map_int_get(BMesh *bm, BMOperator *op, const char *slot_name, void *element) { - int *val = (int *) BMO_slot_map_data_get(bm, op, slotname, element); + int *val = (int *) BMO_slot_map_data_get(bm, op, slot_name, element); if (val) return *val; return 0; } -BLI_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slotname, +BLI_INLINE void *BMO_slot_map_ptr_get(BMesh *bm, BMOperator *op, const char *slot_name, void *element) { - void **val = (void **) BMO_slot_map_data_get(bm, op, slotname, element); + void **val = (void **) BMO_slot_map_data_get(bm, op, slot_name, element); if (val) return *val; return NULL; diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 65288522b3b..5447e6b5a55 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -145,9 +145,9 @@ void BMO_op_init(BMesh *bm, BMOperator *op, const char *opname) op->flag = opdefines[opcode]->flag; /* initialize the operator slot types */ - for (i = 0; opdefines[opcode]->slottypes[i].type; i++) { - op->slots[i].slottype = opdefines[opcode]->slottypes[i].type; - op->slots[i].index = i; + for (i = 0; opdefines[opcode]->slot_types[i].type; i++) { + op->slot_args[i].slot_type = opdefines[opcode]->slot_types[i].type; + op->slot_args[i].index = i; } /* callback */ @@ -192,9 +192,9 @@ void BMO_op_finish(BMesh *bm, BMOperator *op) BMOpSlot *slot; int i; - for (i = 0; opdefines[op->type]->slottypes[i].type; i++) { - slot = &op->slots[i]; - if (slot->slottype == BMO_OP_SLOT_MAPPING) { + for (i = 0; opdefines[op->type]->slot_types[i].type; i++) { + slot = &op->slot_args[i]; + if (slot->slot_type == BMO_OP_SLOT_MAPPING) { if (slot->data.ghash) BLI_ghash_free(slot->data.ghash, NULL, NULL); } @@ -214,26 +214,26 @@ void BMO_op_finish(BMesh *bm, BMOperator *op) * * \return Success if the slot if found. */ -int BMO_slot_exists(BMOperator *op, const char *slotname) +int BMO_slot_exists(BMOperator *op, const char *slot_name) { - int slotcode = bmo_name_to_slotcode(opdefines[op->type], slotname); - return (slotcode >= 0); + int slot_code = bmo_name_to_slotcode(opdefines[op->type], slot_name); + return (slot_code >= 0); } /** * \brief BMESH OPSTACK GET SLOT * - * Returns a pointer to the slot of type 'slotcode' + * Returns a pointer to the slot of type 'slot_code' */ -BMOpSlot *BMO_slot_get(BMOperator *op, const char *slotname) +BMOpSlot *BMO_slot_get(BMOperator *op, const char *slot_name) { - int slotcode = bmo_name_to_slotcode_check(opdefines[op->type], slotname); + int slot_code = bmo_name_to_slotcode_check(opdefines[op->type], slot_name); - if (slotcode < 0) { + if (slot_code < 0) { return &BMOpEmptySlot; } - return &(op->slots[slotcode]); + return &(op->slot_args[slot_code]); } /** @@ -249,22 +249,22 @@ void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, const char *src, if (source_slot == dest_slot) return; - if (source_slot->slottype != dest_slot->slottype) { + if (source_slot->slot_type != dest_slot->slot_type) { /* possibly assert here? */ return; } - if (dest_slot->slottype == BMO_OP_SLOT_ELEMENT_BUF) { + if (dest_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF) { /* do buffer copy */ dest_slot->data.buf = NULL; dest_slot->len = source_slot->len; if (dest_slot->len) { - const int slot_alloc_size = BMO_OPSLOT_TYPEINFO[dest_slot->slottype] * dest_slot->len; + const int slot_alloc_size = BMO_OPSLOT_TYPEINFO[dest_slot->slot_type] * dest_slot->len; dest_slot->data.buf = BLI_memarena_alloc(dest_op->arena, slot_alloc_size); memcpy(dest_slot->data.buf, source_slot->data.buf, slot_alloc_size); } } - else if (dest_slot->slottype == BMO_OP_SLOT_MAPPING) { + else if (dest_slot->slot_type == BMO_OP_SLOT_MAPPING) { GHashIterator it; BMOElemMapping *srcmap, *dstmap; @@ -301,42 +301,42 @@ void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, const char *src, * Sets the value of a slot depending on it's type */ -void BMO_slot_float_set(BMOperator *op, const char *slotname, const float f) +void BMO_slot_float_set(BMOperator *op, const char *slot_name, const float f) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_FLT); - if (!(slot->slottype == BMO_OP_SLOT_FLT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT); + if (!(slot->slot_type == BMO_OP_SLOT_FLT)) return; slot->data.f = f; } -void BMO_slot_int_set(BMOperator *op, const char *slotname, const int i) +void BMO_slot_int_set(BMOperator *op, const char *slot_name, const int i) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_INT); - if (!(slot->slottype == BMO_OP_SLOT_INT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_INT); + if (!(slot->slot_type == BMO_OP_SLOT_INT)) return; slot->data.i = i; } -void BMO_slot_bool_set(BMOperator *op, const char *slotname, const int i) +void BMO_slot_bool_set(BMOperator *op, const char *slot_name, const int i) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_BOOL); - if (!(slot->slottype == BMO_OP_SLOT_BOOL)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL); + if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) return; slot->data.i = i; } /* only supports square mats */ -void BMO_slot_mat_set(BMOperator *op, const char *slotname, const float *mat, int size) +void BMO_slot_mat_set(BMOperator *op, const char *slot_name, const float *mat, int size) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAT); - if (!(slot->slottype == BMO_OP_SLOT_MAT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); + if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; slot->len = 4; @@ -355,93 +355,93 @@ void BMO_slot_mat_set(BMOperator *op, const char *slotname, const float *mat, in } } -void BMO_slot_mat4_get(BMOperator *op, const char *slotname, float r_mat[4][4]) +void BMO_slot_mat4_get(BMOperator *op, const char *slot_name, float r_mat[4][4]) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAT); - if (!(slot->slottype == BMO_OP_SLOT_MAT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); + if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; copy_m4_m4(r_mat, (float (*)[4])slot->data.p); } -void BMO_slot_mat3_set(BMOperator *op, const char *slotname, float r_mat[3][3]) +void BMO_slot_mat3_set(BMOperator *op, const char *slot_name, float r_mat[3][3]) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAT); - if (!(slot->slottype == BMO_OP_SLOT_MAT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAT); + if (!(slot->slot_type == BMO_OP_SLOT_MAT)) return; copy_m3_m4(r_mat, slot->data.p); } -void BMO_slot_ptr_set(BMOperator *op, const char *slotname, void *p) +void BMO_slot_ptr_set(BMOperator *op, const char *slot_name, void *p) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_PNT); - if (!(slot->slottype == BMO_OP_SLOT_PNT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR); + if (!(slot->slot_type == BMO_OP_SLOT_PTR)) return; slot->data.p = p; } -void BMO_slot_vec_set(BMOperator *op, const char *slotname, const float vec[3]) +void BMO_slot_vec_set(BMOperator *op, const char *slot_name, const float vec[3]) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_VEC); - if (!(slot->slottype == BMO_OP_SLOT_VEC)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC); + if (!(slot->slot_type == BMO_OP_SLOT_VEC)) return; copy_v3_v3(slot->data.vec, vec); } -float BMO_slot_float_get(BMOperator *op, const char *slotname) +float BMO_slot_float_get(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_FLT); - if (!(slot->slottype == BMO_OP_SLOT_FLT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_FLT); + if (!(slot->slot_type == BMO_OP_SLOT_FLT)) return 0.0f; return slot->data.f; } -int BMO_slot_int_get(BMOperator *op, const char *slotname) +int BMO_slot_int_get(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_INT); - if (!(slot->slottype == BMO_OP_SLOT_INT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_INT); + if (!(slot->slot_type == BMO_OP_SLOT_INT)) return 0; return slot->data.i; } -int BMO_slot_bool_get(BMOperator *op, const char *slotname) +int BMO_slot_bool_get(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_BOOL); - if (!(slot->slottype == BMO_OP_SLOT_BOOL)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_BOOL); + if (!(slot->slot_type == BMO_OP_SLOT_BOOL)) return 0; return slot->data.i; } -void *BMO_slot_ptr_get(BMOperator *op, const char *slotname) +void *BMO_slot_ptr_get(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_PNT); - if (!(slot->slottype == BMO_OP_SLOT_PNT)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_PTR); + if (!(slot->slot_type == BMO_OP_SLOT_PTR)) return NULL; return slot->data.p; } -void BMO_slot_vec_get(BMOperator *op, const char *slotname, float r_vec[3]) +void BMO_slot_vec_get(BMOperator *op, const char *slot_name, float r_vec[3]) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_VEC); - if (!(slot->slottype == BMO_OP_SLOT_VEC)) + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_VEC); + if (!(slot->slot_type == BMO_OP_SLOT_VEC)) return; copy_v3_v3(r_vec, slot->data.vec); @@ -515,25 +515,25 @@ void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *UNUSED(op), const char hty } } -int BMO_slot_buffer_count(BMesh *UNUSED(bm), BMOperator *op, const char *slotname) +int BMO_slot_buffer_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); /* check if its actually a buffer */ - if (slot->slottype != BMO_OP_SLOT_ELEMENT_BUF) + if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) return 0; return slot->len; } -int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slotname) +int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* check if its actually a buffer */ - if (!(slot->slottype == BMO_OP_SLOT_MAPPING)) + if (!(slot->slot_type == BMO_OP_SLOT_MAPPING)) return 0; return slot->data.ghash ? BLI_ghash_size(slot->data.ghash) : 0; @@ -542,12 +542,12 @@ int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slotname) /* inserts a key/value mapping into a mapping slot. note that it copies the * value, it doesn't store a reference to it. */ -void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, +void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slot_name, void *element, void *data, int len) { BMOElemMapping *mapping; - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); mapping = (BMOElemMapping *) BLI_memarena_alloc(op->arena, sizeof(*mapping) + len); @@ -563,9 +563,9 @@ void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname } #if 0 -void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slotcode, int totadd) +void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slot_code, int totadd) { - BMOpSlot *slot = &op->slots[slotcode]; + BMOpSlot *slot = &op->slots[slot_code]; void *tmp; ssize_t allocsize; @@ -579,7 +579,7 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slotcode, int totadd) if (slot->len >= slot->size) { slot->size = (slot->size + 1 + totadd) * 2; - allocsize = BMO_OPSLOT_TYPEINFO[opdefines[op->type]->slottypes[slotcode].type] * slot->size; + allocsize = BMO_OPSLOT_TYPEINFO[opdefines[op->type]->slot_types[slot_code].type] * slot->size; tmp = slot->data.buf; slot->data.buf = MEM_callocN(allocsize, "opslot dynamic array"); @@ -594,7 +594,7 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slotcode, int totadd) slot->len += totadd; slot->size = slot->len + 2; - allocsize = BMO_OPSLOT_TYPEINFO[opdefines[op->type]->slottypes[slotcode].type] * slot->len; + allocsize = BMO_OPSLOT_TYPEINFO[opdefines[op->type]->slot_types[slot_code].type] * slot->len; tmp = slot->data.buf; slot->data.buf = MEM_callocN(allocsize, "opslot dynamic array"); @@ -605,14 +605,14 @@ void *bmo_slot_buffer_grow(BMesh *bm, BMOperator *op, int slotcode, int totadd) } #endif -void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { GHashIterator it; - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMElemF *ele_f; - BLI_assert(slot->slottype == BMO_OP_SLOT_MAPPING); + BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING); /* sanity check */ if (!slot->data.ghash) return; @@ -625,18 +625,18 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, } } -static void *bmo_slot_buffer_alloc(BMOperator *op, const char *slotname, int len) +void *BMO_slot_buffer_alloc(BMOperator *op, const char *slot_name, const int len) { - BMOpSlot *slot = BMO_slot_get(op, slotname); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BMOpSlot *slot = BMO_slot_get(op, slot_name); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); /* check if its actually a buffer */ - if (slot->slottype != BMO_OP_SLOT_ELEMENT_BUF) + if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) return NULL; slot->len = len; if (len) - slot->data.buf = BLI_memarena_alloc(op->arena, BMO_OPSLOT_TYPEINFO[slot->slottype] * len); + slot->data.buf = BLI_memarena_alloc(op->arena, BMO_OPSLOT_TYPEINFO[slot->slot_type] * len); return slot->data.buf; } @@ -645,9 +645,9 @@ static void *bmo_slot_buffer_alloc(BMOperator *op, const char *slotname, int len * * Copies all elements of a certain type into an operator slot. */ -static void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slotname, const char htype) +void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot_name, const char htype) { - BMOpSlot *output = BMO_slot_get(op, slotname); + BMOpSlot *output = BMO_slot_get(op, slot_name); int totelement = 0, i = 0; if (htype & BM_VERT) totelement += bm->totvert; @@ -658,7 +658,7 @@ static void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot BMIter iter; BMHeader *ele; - bmo_slot_buffer_alloc(op, slotname, totelement); + BMO_slot_buffer_alloc(op, slot_name, totelement); /* TODO - collapse these loops into one */ @@ -691,11 +691,11 @@ static void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, const char *slot * Copies elements of a certain type, which have a certain header flag * enabled/disabled into a slot for an operator. */ -static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *slotname, +static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const short test_for_enabled) { - BMOpSlot *output = BMO_slot_get(op, slotname); + BMOpSlot *output = BMO_slot_get(op, slot_name); int totelement = 0, i = 0; BLI_assert(ELEM(test_for_enabled, TRUE, FALSE)); @@ -709,7 +709,7 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl BMIter iter; BMElem *ele; - bmo_slot_buffer_alloc(op, slotname, totelement); + BMO_slot_buffer_alloc(op, slot_name, totelement); /* TODO - collapse these loops into one */ @@ -751,16 +751,16 @@ static void bmo_slot_buffer_from_hflag(BMesh *bm, BMOperator *op, const char *sl } } -void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag) { - bmo_slot_buffer_from_hflag(bm, op, slotname, htype, hflag, TRUE); + bmo_slot_buffer_from_hflag(bm, op, slot_name, htype, hflag, TRUE); } -void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_disabled_hflag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag) { - bmo_slot_buffer_from_hflag(bm, op, slotname, htype, hflag, FALSE); + bmo_slot_buffer_from_hflag(bm, op, slot_name, htype, hflag, FALSE); } /** @@ -772,15 +772,15 @@ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name, BMOpSlot *output_slot = BMO_slot_get(output_op, output_slot_name); BMOpSlot *other_slot = BMO_slot_get(other_op, other_slot_name); - BLI_assert(output_slot->slottype == BMO_OP_SLOT_ELEMENT_BUF && - other_slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(output_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF && + other_slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); if (output_slot->len == 0) { /* output slot is empty, copy rather than append */ BMO_slot_copy(other_op, output_op, other_slot_name, output_slot_name); } else if (other_slot->len != 0) { - int elem_size = BMO_OPSLOT_TYPEINFO[output_slot->slottype]; + int elem_size = BMO_OPSLOT_TYPEINFO[output_slot->slot_type]; int alloc_size = elem_size * (output_slot->len + other_slot->len); /* allocate new buffer */ void *buf = BLI_memarena_alloc(output_op->arena, alloc_size); @@ -800,11 +800,11 @@ void BMO_slot_buffer_append(BMOperator *output_op, const char *output_slot_name, * Copies elements of a certain type, which have a certain flag set * into an output slot for an operator. */ -static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slotname, +static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag, const short test_for_enabled) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); int totelement, i = 0; BLI_assert(ELEM(TRUE, FALSE, test_for_enabled)); @@ -814,14 +814,14 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo else totelement = BMO_mesh_disabled_flag_count(bm, htype, oflag); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); if (totelement) { BMIter iter; BMHeader *ele; BMHeader **ele_array; - bmo_slot_buffer_alloc(op, slotname, totelement); + BMO_slot_buffer_alloc(op, slot_name, totelement); ele_array = (BMHeader **)slot->data.p; @@ -859,16 +859,16 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, const char *slo } } -void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { - bmo_slot_buffer_from_flag(bm, op, slotname, htype, oflag, TRUE); + bmo_slot_buffer_from_flag(bm, op, slot_name, htype, oflag, TRUE); } -void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { - bmo_slot_buffer_from_flag(bm, op, slotname, htype, oflag, FALSE); + bmo_slot_buffer_from_flag(bm, op, slot_name, htype, oflag, FALSE); } /** @@ -877,16 +877,16 @@ void BMO_slot_buffer_from_disabled_flag(BMesh *bm, BMOperator *op, const char *s * Header Flags elements in a slots buffer, automatically * using the selection API where appropriate. */ -void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const char do_flush) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMElem **data = slot->data.p; int i; const char do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT)); const char do_flush_hide = (do_flush && (hflag & BM_ELEM_HIDDEN)); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); for (i = 0; i < slot->len; i++, data++) { if (!(htype & (*data)->head.htype)) @@ -910,16 +910,16 @@ void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOperator *op, const char *slotnam * Removes flags from elements in a slots buffer, automatically * using the selection API where appropriate. */ -void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_hflag_disable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const char hflag, const char do_flush) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMElem **data = slot->data.p; int i; const char do_flush_select = (do_flush && (hflag & BM_ELEM_SELECT)); const char do_flush_hide = (do_flush && (hflag & BM_ELEM_HIDDEN)); - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); for (i = 0; i < slot->len; i++, data++) { if (!(htype & (*data)->head.htype)) @@ -961,14 +961,14 @@ int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag) * * Flags elements in a slots buffer */ -void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMHeader **data = slot->data.p; int i; - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); for (i = 0; i < slot->len; i++) { if (!(htype & data[i]->htype)) @@ -983,14 +983,14 @@ void BMO_slot_buffer_flag_enable(BMesh *bm, BMOperator *op, const char *slotname * * Removes flags from elements in a slots buffer */ -void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slotname, +void BMO_slot_buffer_flag_disable(BMesh *bm, BMOperator *op, const char *slot_name, const char htype, const short oflag) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); BMHeader **data = slot->data.p; int i; - BLI_assert(slot->slottype == BMO_OP_SLOT_ELEMENT_BUF); + BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF); for (i = 0; i < slot->len; i++) { if (!(htype & data[i]->htype)) @@ -1131,11 +1131,11 @@ static void bmo_flag_layer_clear(BMesh *bm) bm->elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE); } -void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slotname) +void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slot_name) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); - if (slot->slottype != BMO_OP_SLOT_ELEMENT_BUF) + if (slot->slot_type != BMO_OP_SLOT_ELEMENT_BUF) return NULL; return slot->data.buf ? *(void **)slot->data.buf : NULL; @@ -1148,9 +1148,9 @@ void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slotname) * (e.g. combination of BM_VERT, BM_EDGE, BM_FACE), if iterating * over an element buffer (not a mapping). */ void *BMO_iter_new(BMOIter *iter, BMesh *UNUSED(bm), BMOperator *op, - const char *slotname, const char restrictmask) + const char *slot_name, const char restrictmask) { - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); memset(iter, 0, sizeof(BMOIter)); @@ -1158,7 +1158,7 @@ void *BMO_iter_new(BMOIter *iter, BMesh *UNUSED(bm), BMOperator *op, iter->cur = 0; iter->restrictmask = restrictmask; - if (iter->slot->slottype == BMO_OP_SLOT_MAPPING) { + if (iter->slot->slot_type == BMO_OP_SLOT_MAPPING) { if (iter->slot->data.ghash) { BLI_ghashIterator_init(&iter->giter, slot->data.ghash); } @@ -1172,7 +1172,7 @@ void *BMO_iter_new(BMOIter *iter, BMesh *UNUSED(bm), BMOperator *op, void *BMO_iter_step(BMOIter *iter) { - if (iter->slot->slottype == BMO_OP_SLOT_ELEMENT_BUF) { + if (iter->slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF) { BMHeader *h; if (iter->cur >= iter->slot->len) { @@ -1190,7 +1190,7 @@ void *BMO_iter_step(BMOIter *iter) return h; } - else if (iter->slot->slottype == BMO_OP_SLOT_MAPPING) { + else if (iter->slot->slot_type == BMO_OP_SLOT_MAPPING) { BMOElemMapping *map; void *ret = BLI_ghashIterator_getKey(&iter->giter); map = BLI_ghashIterator_getValue(&iter->giter); @@ -1286,8 +1286,8 @@ static int bmo_name_to_slotcode(BMOpDefine *def, const char *name) { int i; - for (i = 0; def->slottypes[i].type; i++) { - if (!strncmp(name, def->slottypes[i].name, MAX_SLOTNAME)) { + for (i = 0; def->slot_types[i].type; i++) { + if (!strncmp(name, def->slot_types[i].name, MAX_SLOTNAME)) { return i; } } @@ -1320,7 +1320,7 @@ static int bmo_opname_to_opcode(const char *opname) } /* Example: - * BMO_op_callf(bm, "del %i %hv", DEL_ONLYFACES, BM_ELEM_SELECT); + * BMO_op_callf(bm, "delete %i %hv", DEL_ONLYFACES, BM_ELEM_SELECT); * * i - int * b - boolean (same as int but 1/0 only) @@ -1331,14 +1331,17 @@ static int bmo_opname_to_opcode(const char *opname) * fv - flagged verts (oflag) * fe - flagged edges (oflag) * ff - flagged faces (oflag) + * + * capitals - H, F to use the flag flipped (when the flag is off) + * Hv, He, Hf, Fv, Fe, Ff, */ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) { BMOpDefine *def; char *opname, *ofmt, *fmt; - char slotname[64] = {0}; - int i /*, n = strlen(fmt) */, stop /*, slotcode = -1 */, type, state; + char slot_name[64] = {0}; + int i /*, n = strlen(fmt) */, stop /*, slot_code = -1 */, type, state; char htype; int noslot = 0; @@ -1377,7 +1380,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) def = opdefines[i]; i = 0; - state = 1; /* 0: not inside slotcode name, 1: inside slotcode name */ + state = 1; /* 0: not inside slot_code name, 1: inside slot_code name */ while (*fmt) { if (state) { @@ -1401,7 +1404,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) GOTO_ERROR("name to slot code check failed"); } - BLI_strncpy(slotname, fmt, sizeof(slotname)); + BLI_strncpy(slot_name, fmt, sizeof(slot_name)); state = 0; fmt += i; @@ -1422,18 +1425,18 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) else if (c == '4') size = 4; else GOTO_ERROR("matrix size was not 3 or 4"); - BMO_slot_mat_set(op, slotname, va_arg(vlist, void *), size); + BMO_slot_mat_set(op, slot_name, va_arg(vlist, void *), size); state = 1; break; } case 'v': { - BMO_slot_vec_set(op, slotname, va_arg(vlist, float *)); + BMO_slot_vec_set(op, slot_name, va_arg(vlist, float *)); state = 1; break; } case 'e': { BMHeader *ele = va_arg(vlist, void *); - BMOpSlot *slot = BMO_slot_get(op, slotname); + BMOpSlot *slot = BMO_slot_get(op, slot_name); slot->data.buf = BLI_memarena_alloc(op->arena, sizeof(void *) * 4); slot->len = 1; @@ -1444,22 +1447,22 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) } case 's': { BMOperator *op2 = va_arg(vlist, void *); - const char *slotname2 = va_arg(vlist, char *); + const char *slot_name2 = va_arg(vlist, char *); - BMO_slot_copy(op2, op, slotname2, slotname); + BMO_slot_copy(op2, op, slot_name2, slot_name); state = 1; break; } case 'i': - BMO_slot_int_set(op, slotname, va_arg(vlist, int)); + BMO_slot_int_set(op, slot_name, va_arg(vlist, int)); state = 1; break; case 'b': - BMO_slot_bool_set(op, slotname, va_arg(vlist, int)); + BMO_slot_bool_set(op, slot_name, va_arg(vlist, int)); state = 1; break; case 'p': - BMO_slot_ptr_set(op, slotname, va_arg(vlist, void *)); + BMO_slot_ptr_set(op, slot_name, va_arg(vlist, void *)); state = 1; break; case 'f': @@ -1470,7 +1473,7 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) type = *fmt; if (NEXT_CHAR(fmt) == ' ' || NEXT_CHAR(fmt) == '\0') { - BMO_slot_float_set(op, slotname, va_arg(vlist, double)); + BMO_slot_float_set(op, slot_name, va_arg(vlist, double)); } else { htype = 0; @@ -1492,19 +1495,19 @@ int BMO_op_vinitf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist) } if (type == 'h') { - BMO_slot_buffer_from_enabled_hflag(bm, op, slotname, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_enabled_hflag(bm, op, slot_name, htype, va_arg(vlist, int)); } else if (type == 'H') { - BMO_slot_buffer_from_disabled_hflag(bm, op, slotname, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_disabled_hflag(bm, op, slot_name, htype, va_arg(vlist, int)); } else if (type == 'a') { - BMO_slot_buffer_from_all(bm, op, slotname, htype); + BMO_slot_buffer_from_all(bm, op, slot_name, htype); } else if (type == 'f') { - BMO_slot_buffer_from_enabled_flag(bm, op, slotname, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_enabled_flag(bm, op, slot_name, htype, va_arg(vlist, int)); } else if (type == 'F') { - BMO_slot_buffer_from_disabled_flag(bm, op, slotname, htype, va_arg(vlist, int)); + BMO_slot_buffer_from_disabled_flag(bm, op, slot_name, htype, va_arg(vlist, int)); } } diff --git a/source/blender/bmesh/intern/bmesh_operators_private.h b/source/blender/bmesh/intern/bmesh_operators_private.h index df48ec8468f..dc1bdaa4689 100644 --- a/source/blender/bmesh/intern/bmesh_operators_private.h +++ b/source/blender/bmesh/intern/bmesh_operators_private.h @@ -33,74 +33,74 @@ struct BMOperator; void BMO_push(BMesh *bm, BMOperator *op); void BMO_pop(BMesh *bm); -void bmo_split_exec(BMesh *bm, BMOperator *op); -void bmo_spin_exec(BMesh *bm, BMOperator *op); -void bmo_dupe_exec(BMesh *bm, BMOperator *op); -void bmo_del_exec(BMesh *bm, BMOperator *op); -void bmo_esubd_exec(BMesh *bm, BMOperator *op); -void bmo_triangulate_exec(BMesh *bm, BMOperator *op); +void bmo_automerge_exec(BMesh *bm, BMOperator *op); +void bmo_average_vert_facedata_exec(BMesh *bm, BMOperator *op); +void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op); +void bmo_bevel_exec(BMesh *bm, BMOperator *op); +void bmo_bisect_edges_exec(BMesh *bm, BMOperator *op); +void bmo_bmesh_to_mesh_exec(BMesh *bm, BMOperator *op); +void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op); +void bmo_collapse_exec(BMesh *bm, BMOperator *op); +void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op); +void bmo_connect_verts_exec(BMesh *bm, BMOperator *op); +void bmo_contextual_create_exec(BMesh *bm, BMOperator *op); +void bmo_convex_hull_exec(BMesh *bm, BMOperator *op); +void bmo_create_circle_exec(BMesh *bm, BMOperator *op); +void bmo_create_cone_exec(BMesh *bm, BMOperator *op); +void bmo_create_cube_exec(BMesh *bm, BMOperator *op); +void bmo_create_grid_exec(BMesh *bm, BMOperator *op); +void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op); +void bmo_create_monkey_exec(BMesh *bm, BMOperator *op); +void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op); +void bmo_create_vert_exec(BMesh *bm, BMOperator *op); +void bmo_delete_exec(BMesh *bm, BMOperator *op); +void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op); +void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op); void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op); -void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op); void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op); +void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op); +void bmo_duplicate_exec(BMesh *bm, BMOperator *op); +void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op); +void bmo_edgenet_prepare(BMesh *bm, BMOperator *op); +void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op); +void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op); void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op); -void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op); -void bmo_connectverts_exec(BMesh *bm, BMOperator *op); void bmo_extrude_vert_indiv_exec(BMesh *bm, BMOperator *op); +void bmo_find_doubles_exec(BMesh *bm, BMOperator *op); +void bmo_inset_exec(BMesh *bm, BMOperator *op); +void bmo_join_triangles_exec(BMesh *bm, BMOperator *op); void bmo_mesh_to_bmesh_exec(BMesh *bm, BMOperator *op); -void bmo_bmesh_to_mesh_exec(BMesh *bm, BMOperator *op); -void bmo_translate_exec(BMesh *bm, BMOperator *op); -void bmo_transform_exec(BMesh *bm, BMOperator *op); -void bmo_contextual_create_exec(BMesh *bm, BMOperator *op); -void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op); -void bmo_rotate_exec(BMesh *bm, BMOperator *op); -void bmo_makevert_exec(BMesh *bm, BMOperator *op); -void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op); -void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op); -void bmo_weldverts_exec(BMesh *bm, BMOperator *op); -void bmo_removedoubles_exec(BMesh *bm, BMOperator *op); -void bmo_finddoubles_exec(BMesh *bm, BMOperator *op); void bmo_mirror_exec(BMesh *bm, BMOperator *op); -void bmo_edgebisect_exec(BMesh *bm, BMOperator *op); -void bmo_reversefaces_exec(BMesh *bm, BMOperator *op); -void bmo_edgerotate_exec(BMesh *bm, BMOperator *op); -void bmo_regionextend_exec(BMesh *bm, BMOperator *op); -void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op); -void bmo_vertexsmooth_exec(BMesh *bm, BMOperator *op); -void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op); -void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op); -void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op); +void bmo_object_load_bmesh_exec(BMesh *bm, BMOperator *op); void bmo_pointmerge_exec(BMesh *bm, BMOperator *op); -void bmo_collapse_exec(BMesh *bm, BMOperator *op); -void bmo_similarfaces_exec(BMesh *bm, BMOperator *op); -void bmo_similaredges_exec(BMesh *bm, BMOperator *op); -void bmo_similarverts_exec(BMesh *bm, BMOperator *op); void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op); -void bmo_vert_average_facedata_exec(BMesh *bm, BMOperator *op); -void bmo_face_rotateuvs_exec(BMesh *bm, BMOperator *op); -void bmo_object_load_bmesh_exec(BMesh *bm, BMOperator *op); -void bmo_face_reverseuvs_exec(BMesh *bm, BMOperator *op); -void bmo_edgenet_prepare(BMesh *bm, BMOperator *op); -void bmo_rotatecolors_exec(BMesh *bm, BMOperator *op); -void bmo_face_reversecolors_exec(BMesh *bm, BMOperator *op); -void bmo_vertexshortestpath_exec(BMesh *bm, BMOperator *op); +void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op); +void bmo_region_extend_exec(BMesh *bm, BMOperator *op); +void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op); +void bmo_reverse_colors_exec(BMesh *bm, BMOperator *op); +void bmo_reverse_faces_exec(BMesh *bm, BMOperator *op); +void bmo_reverse_uvs_exec(BMesh *bm, BMOperator *op); +void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op); +void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op); +void bmo_rotate_exec(BMesh *bm, BMOperator *op); +void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op); void bmo_scale_exec(BMesh *bm, BMOperator *op); -void bmo_edgesplit_exec(BMesh *bm, BMOperator *op); -void bmo_automerge_exec(BMesh *bm, BMOperator *op); -void bmo_create_cone_exec(BMesh *bm, BMOperator *op); -void bmo_create_monkey_exec(BMesh *bm, BMOperator *op); -void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op); -void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op); -void bmo_create_grid_exec(BMesh *bm, BMOperator *op); -void bmo_create_cube_exec(BMesh *bm, BMOperator *op); -void bmo_join_triangles_exec(BMesh *bm, BMOperator *op); -void bmo_bevel_exec(BMesh *bm, BMOperator *op); -void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op); -void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op); -void bmo_create_circle_exec(BMesh *bm, BMOperator *op); -void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op); +void bmo_shortest_path_exec(BMesh *bm, BMOperator *op); +void bmo_similar_edges_exec(BMesh *bm, BMOperator *op); +void bmo_similar_faces_exec(BMesh *bm, BMOperator *op); +void bmo_similar_verts_exec(BMesh *bm, BMOperator *op); +void bmo_slide_vert_exec(BMesh *bm, BMOperator *op); +void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op); void bmo_solidify_face_region_exec(BMesh *bm, BMOperator *op); -void bmo_inset_exec(BMesh *bm, BMOperator *op); +void bmo_spin_exec(BMesh *bm, BMOperator *op); +void bmo_split_edges_exec(BMesh *bm, BMOperator *op); +void bmo_split_exec(BMesh *bm, BMOperator *op); +void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op); +void bmo_transform_exec(BMesh *bm, BMOperator *op); +void bmo_translate_exec(BMesh *bm, BMOperator *op); +void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op); +void bmo_triangulate_exec(BMesh *bm, BMOperator *op); +void bmo_weld_verts_exec(BMesh *bm, BMOperator *op); void bmo_wireframe_exec(BMesh *bm, BMOperator *op); -void bmo_convex_hull_exec(BMesh *bm, BMOperator *op); #endif /* __BMESH_OPERATORS_PRIVATE_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 72eb4cb89e9..094b5af9a00 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -642,7 +642,7 @@ static int bm_face_goodline(float const (*projectverts)[3], BMFace *f, //if (linecrossesf(pv1, pv2, v1, v3)) return FALSE; if (isect_point_tri_v2(pv1, v1, v2, v3) || - isect_point_tri_v2(pv1, v3, v2, v1)) + isect_point_tri_v2(pv2, v3, v2, v1)) { return FALSE; } @@ -658,18 +658,22 @@ static int bm_face_goodline(float const (*projectverts)[3], BMFace *f, * of a polygon while tessellating. * * \param use_beauty Currently only applies to quads, can be extended later on. + * \param abscoss Must be allocated by caller, and at least f->len length + * (allow to avoid allocating a new one for each tri!). */ -static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int use_beauty) +static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int use_beauty, float *abscoss) { BMLoop *bestear = NULL; BMLoop *l_iter; BMLoop *l_first; + const float cos_threshold = 0.9f; + if (f->len == 4) { BMLoop *larr[4]; - int i = 0; - + int i = 0, i4; + float cos1, cos2; l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { larr[i] = l_iter; @@ -677,17 +681,64 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int } while ((l_iter = l_iter->next) != l_first); /* pick 0/1 based on best lenth */ - bestear = larr[(((len_squared_v3v3(larr[0]->v->co, larr[2]->v->co) > - len_squared_v3v3(larr[1]->v->co, larr[3]->v->co))) != use_beauty)]; + /* XXX Can't only rely on such test, also must check we do not get (too much) degenerated triangles!!! */ + i = (((len_squared_v3v3(larr[0]->v->co, larr[2]->v->co) > + len_squared_v3v3(larr[1]->v->co, larr[3]->v->co))) != use_beauty); + i4 = (i + 3) % 4; + /* Check produced tris aren’t too flat/narrow... + * Probably not the best test, but is quite efficient and should at least avoid null-area faces! */ + cos1 = fabsf(cos_v3v3v3(larr[i4]->v->co, larr[i]->v->co, larr[i + 1]->v->co)); + cos2 = fabsf(cos_v3v3v3(larr[i4]->v->co, larr[i + 2]->v->co, larr[i + 1]->v->co)); +#if 0 + printf("%d, (%f, %f), (%f, %f)\n", i, cos1, cos2, + fabsf(cos_v3v3v3(larr[i]->v->co, larr[i4]->v->co, larr[i + 2]->v->co)), + fabsf(cos_v3v3v3(larr[i]->v->co, larr[i + 1]->v->co, larr[i + 2]->v->co))); +#endif + if (cos1 < cos2) + cos1 = cos2; + if (cos1 > cos_threshold) { + if (cos1 > fabsf(cos_v3v3v3(larr[i]->v->co, larr[i4]->v->co, larr[i + 2]->v->co)) && + cos1 > fabsf(cos_v3v3v3(larr[i]->v->co, larr[i + 1]->v->co, larr[i + 2]->v->co))) + { + i = !i; + } + } + /* Last check we do not get overlapping triangles + * (as much as possible, ther are some cases with no good solution!) */ + i4 = (i + 3) % 4; + if (!bm_face_goodline((float const (*)[3])verts, f, BM_elem_index_get(larr[i4]->v), BM_elem_index_get(larr[i]->v), + BM_elem_index_get(larr[i + 1]->v), nvert)) + { + i = !i; + } +/* printf("%d\n", i);*/ + bestear = larr[i]; } else { BMVert *v1, *v2, *v3; /* float angle, bestangle = 180.0f; */ - int isear /*, i = 0 */; + float cos, tcos, bestcos = 1.0f; + float *tcoss; + int isear, i = 0, j, len; + /* Compute cos of all corners! */ l_iter = l_first = BM_FACE_FIRST_LOOP(f); + len = l_iter->f->len; + tcoss = abscoss; + do { + v1 = l_iter->prev->v; + v2 = l_iter->v; + v3 = l_iter->next->v; + + *tcoss = fabsf(cos_v3v3v3(v1->co, v2->co, v3->co)); +/* printf("tcoss: %f\n", *tcoss);*/ + tcoss++; + } while ((l_iter = l_iter->next) != l_first); + + l_iter = l_first; + tcoss = abscoss; do { isear = TRUE; @@ -695,6 +746,7 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int v2 = l_iter->v; v3 = l_iter->next->v; + /* We may have already internal edges... */ if (BM_edge_exists(v1, v3)) { isear = FALSE; } @@ -706,7 +758,7 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int } if (isear) { - #if 0 +#if 0 /* Old, already commented code */ /* if this code comes back, it needs to be converted to radians */ angle = angle_v3v3v3(verts[v1->head.eflag2], verts[v2->head.eflag2], verts[v3->head.eflag2]); if (!bestear || ABS(angle - 45.0f) < bestangle) { @@ -717,11 +769,46 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int if (angle > 20 && angle < 90) break; if (angle < 100 && i > 5) break; i += 1; - #endif +#endif - bestear = l_iter; - break; + /* Compute highest cos (i.e. narrowest angle) of this tri. */ + cos = *tcoss; + tcos = fabsf(cos_v3v3v3(v2->co, v3->co, v1->co)); + if (tcos > cos) + cos = tcos; + tcos = fabsf(cos_v3v3v3(v3->co, v1->co, v2->co)); + if (tcos > cos) + cos = tcos; + + /* Compare to prev best (i.e. lowest) cos. */ + if (cos < bestcos) { + /* We must check this tri would not leave a (too much) degenerated remaining face! */ + /* For now just assume if the average of cos of all "remaining face"'s corners is below a given threshold, it’s OK. */ + float avgcos = fabsf(cos_v3v3v3(v1->co, v3->co, l_iter->next->next->v->co)); + const int i_limit = (i - 1 + len) % len; + avgcos += fabsf(cos_v3v3v3(l_iter->prev->prev->v->co, v1->co, v3->co)); + j = (i + 2) % len; + do { + avgcos += abscoss[j]; + } while ((j = (j + 1) % len) != i_limit); + avgcos /= len - 1; + + /* We need a best ear in any case... */ + if (avgcos < cos_threshold || (!bestear && avgcos < 1.0f)) { + /* OKI, keep this ear (corner...) as a potential best one! */ + bestear = l_iter; + bestcos = cos; + } +#if 0 + else + printf("Had a nice tri (higest cos of %f, current bestcos is %f), " + "but average cos of all \"remaining face\"'s corners is too high (%f)!\n", + cos, bestcos, avgcos); +#endif + } } + tcoss++; + i++; } while ((l_iter = l_iter->next) != l_first); } @@ -731,14 +818,20 @@ static BMLoop *find_ear(BMFace *f, float (*verts)[3], const int nvert, const int /** * \brief BMESH TRIANGULATE FACE * + * --- Prev description (wasn’t correct, ear clipping was currently simply picking the first tri in the loop!) * Triangulates a face using a simple 'ear clipping' algorithm that tries to * favor non-skinny triangles (angles less than 90 degrees). * * If the triangulator has bits left over (or cannot triangulate at all) * it uses a simple fan triangulation, + * --- End of prev description + * + * Currently tries to repeatedly find the best triangle (i.e. the most "open" one), provided it does not + * produces a "remaining" face with too much wide/narrow angles + * (using cos (i.e. dot product of normalized vectors) of angles). * * newfaces, if non-null, must be an array of BMFace pointers, - * with a length equal to f->len. it will be filled with the new + * with a length equal to f->len. It will be filled with the new * triangles, and will be NULL-terminated. * * \note newedgeflag sets a flag layer flag, obviously not the header flag. @@ -748,10 +841,11 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], const short use_beauty) { int i, done, nvert, nf_i = 0; - BMLoop *newl, *nextloop; + BMLoop *newl; BMLoop *l_iter; BMLoop *l_first; - /* BMVert *v; */ /* UNUSED */ + float *abscoss = NULL; + BLI_array_fixedstack_declare(abscoss, 16, f->len, "BM_face_triangulate: temp absolute cosines of face corners"); /* copy vertex coordinates to vertspace arra */ i = 0; @@ -764,14 +858,14 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], bm->elem_index_dirty |= BM_VERT; /* see above */ - ///bmesh_face_normal_update(bm, f, f->no, projectverts); + /* bmesh_face_normal_update(bm, f, f->no, projectverts); */ calc_poly_normal(f->no, projectverts, f->len); poly_rotate_plane(f->no, projectverts, i); nvert = f->len; - //calc_poly_plane(projectverts, i); + /* calc_poly_plane(projectverts, i); */ for (i = 0; i < nvert; i++) { projectverts[i][2] = 0.0f; } @@ -779,10 +873,10 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], done = FALSE; while (!done && f->len > 3) { done = TRUE; - l_iter = find_ear(f, projectverts, nvert, use_beauty); + l_iter = find_ear(f, projectverts, nvert, use_beauty, abscoss); if (l_iter) { done = FALSE; - /* v = l->v; */ /* UNUSED */ +/* printf("Subdividing face...\n");*/ f = BM_face_split(bm, l_iter->f, l_iter->prev->v, l_iter->next->v, &newl, NULL, TRUE); @@ -812,6 +906,7 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], } } +#if 0 /* XXX find_ear should now always return a corner, so no more need for this piece of code... */ if (f->len > 3) { l_iter = BM_FACE_FIRST_LOOP(f); while (l_iter->f->len > 3) { @@ -833,7 +928,10 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], l_iter = nextloop; } } - +#endif + + BLI_array_fixedstack_free(abscoss); + /* NULL-terminate */ if (newfaces) newfaces[nf_i] = NULL; } diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 3ec4c51bcb1..b6a56e64dcf 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -190,6 +190,22 @@ BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v) } /** + * Get the first loop of a vert. Uses the same initialization code for the first loop of the + * iterator API + */ + +BMLoop *BM_vert_find_first_loop(BMVert *v) +{ + BMEdge *e; + + if(!v || !v->e) + return NULL; + + e = bmesh_disk_faceedge_find_first(v->e, v); + return bmesh_radial_faceloop_find_first(e->l, v); +} + +/** * Returns TRUE if the vertex is used in a given face. */ diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index 2df5adcfae3..36ffc296759 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -42,6 +42,7 @@ BMVert *BM_edge_other_vert(BMEdge *e, BMVert *v); BMLoop *BM_face_other_edge_loop(BMFace *f, BMEdge *e, BMVert *v); BMLoop *BM_face_other_vert_loop(BMFace *f, BMVert *v_prev, BMVert *v); BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v); +BMLoop *BM_vert_find_first_loop(BMVert *v); int BM_vert_edge_count_nonwire(BMVert *v); int BM_vert_edge_count(BMVert *v); diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index 4ae7b6cc350..a72bfe47127 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -547,7 +547,7 @@ static void *bmw_LoopWalker_step(BMWalker *walker) ((vert_edge_tot == 4 || vert_edge_tot == 2) && owalk.is_boundary == FALSE) || /* walk over boundary of faces but stop at corners */ - (owalk.is_boundary == TRUE && owalk.is_single == FALSE && vert_edge_tot > 2) || + (owalk.is_boundary == TRUE && owalk.is_single == FALSE && vert_edge_tot > 2) || /* initial edge was a boundary, so is this edge and vertex is only apart of this face * this lets us walk over the the boundary of an ngon which is handy */ diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index f02b88c5b05..0b036c6ff2b 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -865,7 +865,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) } #endif - BMO_op_callf(bm, "del geom=%fv context=%i", BEVEL_DEL, DEL_VERTS); + BMO_op_callf(bm, "delete geom=%fv context=%i", BEVEL_DEL, DEL_VERTS); /* clean up any edges that might not get properly delete */ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { @@ -873,8 +873,8 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) BMO_elem_flag_enable(bm, e, BEVEL_DEL); } - BMO_op_callf(bm, "del geom=%fe context=%i", BEVEL_DEL, DEL_EDGES); - BMO_op_callf(bm, "del geom=%ff context=%i", BEVEL_DEL, DEL_FACES); + BMO_op_callf(bm, "delete geom=%fe context=%i", BEVEL_DEL, DEL_EDGES); + BMO_op_callf(bm, "delete geom=%ff context=%i", BEVEL_DEL, DEL_FACES); BLI_smallhash_release(&hash); BLI_array_free(tags); diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c index 653bbaf8602..7418be3565c 100644 --- a/source/blender/bmesh/operators/bmo_connect.c +++ b/source/blender/bmesh/operators/bmo_connect.c @@ -40,7 +40,7 @@ #define EDGE_MARK 4 #define EDGE_DONE 8 -void bmo_connectverts_exec(BMesh *bm, BMOperator *op) +void bmo_connect_verts_exec(BMesh *bm, BMOperator *op) { BMIter iter, liter; BMFace *f, *nf; diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index 1451625d3bb..8e69696f771 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -164,7 +164,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op) } - BMO_op_callf(bm, "del geom=%ff context=%i", FACE_ORIG, DEL_FACES); + BMO_op_callf(bm, "delete geom=%ff context=%i", FACE_ORIG, DEL_FACES); if (use_verts) { diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index 6e6037239b9..1421ae294bc 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -314,7 +314,7 @@ static void BKE_mesh_copy(BMOperator *op, BMesh *source, BMesh *target) * BMOP_DUPE_FNEW: Buffer containing pointers to the new mesh faces */ -void bmo_dupe_exec(BMesh *bm, BMOperator *op) +void bmo_duplicate_exec(BMesh *bm, BMOperator *op) { BMOperator *dupeop = op; BMesh *bm2 = BMO_slot_ptr_get(op, "dest"); @@ -345,7 +345,7 @@ void BMO_dupe_from_flag(BMesh *bm, int htype, const char hflag) { BMOperator dupeop; - BMO_op_init(bm, &dupeop, "dupe"); + BMO_op_init(bm, &dupeop, "duplicate"); BMO_slot_buffer_from_enabled_hflag(bm, &dupeop, "geom", htype, hflag); BMO_op_exec(bm, &dupeop); @@ -381,8 +381,8 @@ void bmo_split_exec(BMesh *bm, BMOperator *op) const short use_only_faces = BMO_slot_bool_get(op, "use_only_faces"); /* initialize our sub-operator */ - BMO_op_init(bm, &dupeop, "dupe"); - BMO_op_init(bm, &delop, "del"); + BMO_op_init(bm, &dupeop, "duplicate"); + BMO_op_init(bm, &delop, "delete"); BMO_slot_copy(splitop, &dupeop, "geom", "geom"); BMO_op_exec(bm, &dupeop); @@ -443,7 +443,7 @@ void bmo_split_exec(BMesh *bm, BMOperator *op) } -void bmo_del_exec(BMesh *bm, BMOperator *op) +void bmo_delete_exec(BMesh *bm, BMOperator *op) { #define DEL_INPUT 1 @@ -487,7 +487,7 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op) BMO_slot_copy(op, op, "geom", "lastout"); for (a = 0; a < steps; a++) { if (do_dupli) { - BMO_op_initf(bm, &dupop, "dupe geom=%s", op, "lastout"); + BMO_op_initf(bm, &dupop, "duplicate geom=%s", op, "lastout"); BMO_op_exec(bm, &dupop); BMO_op_callf(bm, "rotate cent=%v mat=%m3 verts=%s", cent, rmat, &dupop, "newout"); diff --git a/source/blender/bmesh/operators/bmo_edgesplit.c b/source/blender/bmesh/operators/bmo_edgesplit.c index ccbcb293915..1f6689ed06c 100644 --- a/source/blender/bmesh/operators/bmo_edgesplit.c +++ b/source/blender/bmesh/operators/bmo_edgesplit.c @@ -100,7 +100,7 @@ static void bm_edgesplit_validate_seams(BMesh *bm, BMOperator *op) } /* keep this operator fast, its used in a modifier */ -void bmo_edgesplit_exec(BMesh *bm, BMOperator *op) +void bmo_split_edges_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMEdge *e; diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index 09b79376ff6..b8993b41caf 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -49,7 +49,7 @@ enum { #define VERT_NONMAN 2 #define EDGE_NONMAN 2 -void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op) +void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMIter liter, liter2; @@ -118,7 +118,7 @@ void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op) BLI_array_free(edges); - BMO_op_callf(bm, "del geom=%ff context=%i", EXT_DEL, DEL_ONLYFACES); + BMO_op_callf(bm, "delete geom=%ff context=%i", EXT_DEL, DEL_ONLYFACES); BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, EXT_KEEP); } @@ -172,7 +172,7 @@ static void bm_extrude_copy_face_loop_attributes(BMesh *bm, BMFace *f, BMEdge *e } /* Disable the skin root flag on the input vert, assumes that the vert - data includes an CD_MVERT_SKIN layer */ + * data includes an CD_MVERT_SKIN layer */ static void bm_extrude_disable_skin_root(BMesh *bm, BMVert *v) { MVertSkin *vs; @@ -195,7 +195,7 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op) BMO_elem_flag_enable(bm, e->v2, EXT_INPUT); } - BMO_op_initf(bm, &dupeop, "dupe geom=%fve", EXT_INPUT); + BMO_op_initf(bm, &dupeop, "duplicate geom=%fve", EXT_INPUT); BMO_op_exec(bm, &dupeop); /* disable root flag on all new skin nodes */ @@ -273,7 +273,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) int found, fwd, delorig = FALSE; /* initialize our sub-operators */ - BMO_op_init(bm, &dupeop, "dupe"); + BMO_op_init(bm, &dupeop, "duplicate"); BMO_slot_buffer_flag_enable(bm, op, "edgefacein", BM_EDGE | BM_FACE, EXT_INPUT); @@ -341,7 +341,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) } if (delorig == TRUE) { - BMO_op_initf(bm, &delop, "del geom=%fvef context=%i", + BMO_op_initf(bm, &delop, "delete geom=%fvef context=%i", EXT_DEL, DEL_ONLYTAGGED); } @@ -647,7 +647,7 @@ void bmo_solidify_face_region_exec(BMesh *bm, BMOperator *op) thickness = BMO_slot_float_get(op, "thickness"); /* Flip original faces (so the shell is extruded inward) */ - BMO_op_init(bm, &reverseop, "reversefaces"); + BMO_op_init(bm, &reverseop, "reverse_faces"); BMO_slot_copy(op, &reverseop, "geom", "faces"); BMO_op_exec(bm, &reverseop); BMO_op_finish(bm, &reverseop); diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c index 160db7cba75..1bd2f41209b 100644 --- a/source/blender/bmesh/operators/bmo_hull.c +++ b/source/blender/bmesh/operators/bmo_hull.c @@ -140,11 +140,14 @@ static void hull_add_triangle(BMesh *bm, GHash *hull_triangles, BLI_mempool *poo static int hull_point_tri_side(const HullTriangle *t, const float co[3]) { - float p[3], d; + /* Added epsilon to fix bug [#31941], improves output when some + * vertices are nearly coplanar. Might need further tweaking for + * other cases though. */ + float p[3], d, epsilon = 0.0001; sub_v3_v3v3(p, co, t->v[0]->co); d = dot_v3v3(t->no, p); - if (d < 0) return -1; - else if (d > 0) return 1; + if (d < -epsilon) return -1; + else if (d > epsilon) return 1; else return 0; } diff --git a/source/blender/bmesh/operators/bmo_mirror.c b/source/blender/bmesh/operators/bmo_mirror.c index 53c51dfd483..1ab439b38bb 100644 --- a/source/blender/bmesh/operators/bmo_mirror.c +++ b/source/blender/bmesh/operators/bmo_mirror.c @@ -62,7 +62,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) BMO_slot_mat4_get(op, "mat", mtx); invert_m4_m4(imtx, mtx); - BMO_op_initf(bm, &dupeop, "dupe geom=%s", op, "geom"); + BMO_op_initf(bm, &dupeop, "duplicate geom=%s", op, "geom"); BMO_op_exec(bm, &dupeop); BMO_slot_buffer_flag_enable(bm, &dupeop, "newout", BM_ALL, ELE_NEW); @@ -84,7 +84,7 @@ void bmo_mirror_exec(BMesh *bm, BMOperator *op) BMO_op_callf(bm, "scale verts=%fv vec=%v", ELE_NEW, scale); BMO_op_callf(bm, "transform verts=%fv mat=%m4", ELE_NEW, imtx); - BMO_op_init(bm, &weldop, "weldverts"); + BMO_op_init(bm, &weldop, "weld_verts"); v = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); for (i = 0; i < ototvert; i++) { diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c index 08cd3835b2d..d59a90ba3a1 100644 --- a/source/blender/bmesh/operators/bmo_primitive.c +++ b/source/blender/bmesh/operators/bmo_primitive.c @@ -365,7 +365,7 @@ void bmo_create_uvsphere_exec(BMesh *bm, BMOperator *op) len2 = len_v3v3(vec, vec2); /* use shortest segment length divided by 3 as merge threshold */ - BMO_op_callf(bm, "removedoubles verts=%fv dist=%f", VERT_MARK, MIN2(len, len2) / 3.0f); + BMO_op_callf(bm, "remove_doubles verts=%fv dist=%f", VERT_MARK, MIN2(len, len2) / 3.0f); } /* and now do imat */ @@ -427,7 +427,7 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op) BMOperator bmop; BMO_op_initf(bm, &bmop, - "esubd edges=%fe " + "subdivide_edges edges=%fe " "smooth=%f " "numcuts=%i " "use_gridfill=%b use_sphere=%b", @@ -661,7 +661,7 @@ void bmo_create_cone_exec(BMesh *bm, BMOperator *op) BM_face_create_quad_tri(bm, v1, v2, firstv2, firstv1, NULL, FALSE); - BMO_op_callf(bm, "removedoubles verts=%fv dist=%f", VERT_MARK, 0.000001); + BMO_op_callf(bm, "remove_doubles verts=%fv dist=%f", VERT_MARK, 0.000001); BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK); } diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c index 52c693efc84..b3c348a330c 100644 --- a/source/blender/bmesh/operators/bmo_removedoubles.c +++ b/source/blender/bmesh/operators/bmo_removedoubles.c @@ -96,7 +96,7 @@ int remdoubles_face_overlaps(BMesh *bm, BMVert **varr, } #endif -void bmo_weldverts_exec(BMesh *bm, BMOperator *op) +void bmo_weld_verts_exec(BMesh *bm, BMOperator *op) { BMIter iter, liter; BMVert *v, *v2; @@ -227,7 +227,7 @@ void bmo_weldverts_exec(BMesh *bm, BMOperator *op) } } - BMO_op_callf(bm, "del geom=%fvef context=%i", ELE_DEL, DEL_ONLYTAGGED); + BMO_op_callf(bm, "delete geom=%fvef context=%i", ELE_DEL, DEL_ONLYTAGGED); BLI_array_free(edges); BLI_array_free(loops); @@ -301,7 +301,7 @@ void bmo_pointmerge_facedata_exec(BMesh *bm, BMOperator *op) } } -void bmo_vert_average_facedata_exec(BMesh *bm, BMOperator *op) +void bmo_average_vert_facedata_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMIter iter; @@ -345,10 +345,10 @@ void bmo_pointmerge_exec(BMesh *bm, BMOperator *op) BMVert *v, *snapv = NULL; float vec[3]; - BMO_slot_vec_get(op, "mergeco", vec); + BMO_slot_vec_get(op, "merge_co", vec); //BMO_op_callf(bm, "collapse_uvs edges=%s", op, "edges"); - BMO_op_init(bm, &weldop, "weldverts"); + BMO_op_init(bm, &weldop, "weld_verts"); BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { if (!snapv) { @@ -375,7 +375,7 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op) int i, tot; BMO_op_callf(bm, "collapse_uvs edges=%s", op, "edges"); - BMO_op_init(bm, &weldop, "weldverts"); + BMO_op_init(bm, &weldop, "weld_verts"); BMO_slot_buffer_flag_enable(bm, op, "edges", BM_EDGE, EDGE_MARK); @@ -487,7 +487,7 @@ void bmo_collapse_uvs_exec(BMesh *bm, BMOperator *op) } } -void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, const char *targetmapname) +void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, const char *targetmapname) { BMOIter oiter; BMVert *v, *v2; @@ -505,17 +505,17 @@ void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, c verts[i++] = v; } - /* Test whether keepverts arg exists and is non-empty */ - if (BMO_slot_exists(op, "keepverts")) { - keepvert = BMO_iter_new(&oiter, bm, op, "keepverts", BM_VERT) != NULL; + /* Test whether keep_verts arg exists and is non-empty */ + if (BMO_slot_exists(op, "keep_verts")) { + keepvert = BMO_iter_new(&oiter, bm, op, "keep_verts", BM_VERT) != NULL; } /* sort by vertex coordinates added together */ qsort(verts, BLI_array_count(verts), sizeof(void *), vergaverco); - /* Flag keepverts */ + /* Flag keep_verts */ if (keepvert) { - BMO_slot_buffer_flag_enable(bm, op, "keepverts", BM_VERT, VERT_KEEP); + BMO_slot_buffer_flag_enable(bm, op, "keep_verts", BM_VERT, VERT_KEEP); } len = BLI_array_count(verts); @@ -557,20 +557,20 @@ void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, c BLI_array_free(verts); } -void bmo_removedoubles_exec(BMesh *bm, BMOperator *op) +void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op) { BMOperator weldop; - BMO_op_init(bm, &weldop, "weldverts"); - bmesh_finddoubles_common(bm, op, &weldop, "targetmap"); + BMO_op_init(bm, &weldop, "weld_verts"); + bmesh_find_doubles_common(bm, op, &weldop, "targetmap"); BMO_op_exec(bm, &weldop); BMO_op_finish(bm, &weldop); } -void bmo_finddoubles_exec(BMesh *bm, BMOperator *op) +void bmo_find_doubles_exec(BMesh *bm, BMOperator *op) { - bmesh_finddoubles_common(bm, op, op, "targetmapout"); + bmesh_find_doubles_common(bm, op, op, "targetmapout"); } void bmo_automerge_exec(BMesh *bm, BMOperator *op) @@ -591,12 +591,12 @@ void bmo_automerge_exec(BMesh *bm, BMOperator *op) /* Search for doubles among all vertices, but only merge non-VERT_KEEP * vertices into VERT_KEEP vertices. */ - BMO_op_initf(bm, &findop, "finddoubles verts=%av keepverts=%fv", VERT_KEEP); + BMO_op_initf(bm, &findop, "find_doubles verts=%av keep_verts=%fv", VERT_KEEP); BMO_slot_copy(op, &findop, "dist", "dist"); BMO_op_exec(bm, &findop); /* weld the vertices */ - BMO_op_init(bm, &weldop, "weldverts"); + BMO_op_init(bm, &weldop, "weld_verts"); BMO_slot_copy(&findop, &weldop, "targetmapout", "targetmap"); BMO_op_exec(bm, &weldop); diff --git a/source/blender/bmesh/operators/bmo_slide.c b/source/blender/bmesh/operators/bmo_slide.c index 238cc5ac66f..0036f095d00 100644 --- a/source/blender/bmesh/operators/bmo_slide.c +++ b/source/blender/bmesh/operators/bmo_slide.c @@ -40,7 +40,7 @@ * Slides a vertex along a connected edge * */ -void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op) +void bmo_slide_vert_exec(BMesh *bm, BMOperator *op) { BMOIter oiter; BMIter iter; @@ -61,7 +61,7 @@ void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op) if (!vertex) { if (G.debug & G_DEBUG) { - fprintf(stderr, "vertex_slide: No vertex selected..."); + fprintf(stderr, "slide_vert: No vertex selected..."); } BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Vertex Slide Error: Invalid selection."); return; @@ -81,7 +81,7 @@ void bmo_vertex_slide_exec(BMesh *bm, BMOperator *op) /* Only allow sliding if an edge is selected */ if (selected_edges == 0) { if (G.debug & G_DEBUG) { - fprintf(stderr, "vertex_slide: select a single edge\n"); + fprintf(stderr, "slide_vert: select a single edge\n"); } BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Vertex Slide Error: Invalid selection."); return; diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index 03a691e3e9c..ee3e34c527f 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -672,7 +672,7 @@ typedef struct SubDFaceData { BMFace *face; } SubDFaceData; -void bmo_esubd_exec(BMesh *bm, BMOperator *op) +void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) { BMOpSlot *einput; SubDPattern *pat; @@ -1038,7 +1038,7 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, /* use_sphere isnt exposed here since its only used for new primitives */ BMO_op_initf(bm, &op, - "esubd edges=%he " + "subdivide_edges edges=%he " "smooth=%f fractal=%f along_normal=%f " "numcuts=%i " "quadcornertype=%i " @@ -1096,7 +1096,7 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, BMO_op_finish(bm, &op); } -void bmo_edgebisect_exec(BMesh *bm, BMOperator *op) +void bmo_bisect_edges_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMEdge *e; diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index e0cd3e2ba90..7d6e34b3a05 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -41,7 +41,7 @@ #include "intern/bmesh_operators_private.h" /* own include */ -void bmo_makevert_exec(BMesh *bm, BMOperator *op) +void bmo_create_vert_exec(BMesh *bm, BMOperator *op) { float vec[3]; @@ -108,7 +108,7 @@ void bmo_rotate_exec(BMesh *bm, BMOperator *op) BMO_op_callf(bm, "translate verts=%s vec=%v", op, "verts", vec); } -void bmo_reversefaces_exec(BMesh *bm, BMOperator *op) +void bmo_reverse_faces_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMFace *f; @@ -118,7 +118,7 @@ void bmo_reversefaces_exec(BMesh *bm, BMOperator *op) } } -void bmo_edgerotate_exec(BMesh *bm, BMOperator *op) +void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMEdge *e, *e2; @@ -172,7 +172,7 @@ void bmo_edgerotate_exec(BMesh *bm, BMOperator *op) #define SEL_FLAG 1 #define SEL_ORIG 2 -static void bmo_regionextend_extend(BMesh *bm, BMOperator *op, int usefaces) +static void bmo_region_extend_extend(BMesh *bm, BMOperator *op, int usefaces) { BMVert *v; BMEdge *e; @@ -211,7 +211,7 @@ static void bmo_regionextend_extend(BMesh *bm, BMOperator *op, int usefaces) } } -static void bmo_regionextend_constrict(BMesh *bm, BMOperator *op, int usefaces) +static void bmo_region_extend_constrict(BMesh *bm, BMOperator *op, int usefaces) { BMVert *v; BMEdge *e; @@ -253,7 +253,7 @@ static void bmo_regionextend_constrict(BMesh *bm, BMOperator *op, int usefaces) } } -void bmo_regionextend_exec(BMesh *bm, BMOperator *op) +void bmo_region_extend_exec(BMesh *bm, BMOperator *op) { int use_faces = BMO_slot_bool_get(op, "use_faces"); int constrict = BMO_slot_bool_get(op, "constrict"); @@ -261,9 +261,9 @@ void bmo_regionextend_exec(BMesh *bm, BMOperator *op) BMO_slot_buffer_flag_enable(bm, op, "geom", BM_ALL, SEL_ORIG); if (constrict) - bmo_regionextend_constrict(bm, op, use_faces); + bmo_region_extend_constrict(bm, op, use_faces); else - bmo_regionextend_extend(bm, op, use_faces); + bmo_region_extend_extend(bm, op, use_faces); BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, SEL_FLAG); } @@ -275,7 +275,7 @@ void bmo_regionextend_exec(BMesh *bm, BMOperator *op) #define FACE_MARK 4 #define FACE_FLIP 8 -/* NOTE: these are the original righthandfaces comment in editmesh_mods.c, +/* NOTE: these are the original recalc_face_normals comment in editmesh_mods.c, * copied here for reference. */ /* based at a select-connected to witness loose objects */ @@ -296,7 +296,7 @@ void bmo_regionextend_exec(BMesh *bm, BMOperator *op) /* NOTE: BM_ELEM_TAG is used on faces to tell if they are flipped. */ -void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op) +void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op) { BMIter liter, liter2; BMOIter siter; @@ -397,13 +397,13 @@ void bmo_righthandfaces_exec(BMesh *bm, BMOperator *op) /* check if we have faces yet to do. if so, recurse */ BMO_ITER (f, &siter, bm, op, "faces", BM_FACE) { if (!BMO_elem_flag_test(bm, f, FACE_VIS)) { - bmo_righthandfaces_exec(bm, op); + bmo_recalc_face_normals_exec(bm, op); break; } } } -void bmo_vertexsmooth_exec(BMesh *bm, BMOperator *op) +void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMIter iter; @@ -511,7 +511,7 @@ typedef struct SimSel_FaceExt { * Select similar faces, the choices are in the enum in source/blender/bmesh/bmesh_operators.h * We select either similar faces based on material, image, area, perimeter, normal, or the coplanar faces */ -void bmo_similarfaces_exec(BMesh *bm, BMOperator *op) +void bmo_similar_faces_exec(BMesh *bm, BMOperator *op) { BMIter fm_iter; BMFace *fs, *fm; @@ -684,7 +684,7 @@ typedef struct SimSel_EdgeExt { * select similar edges: the choices are in the enum in source/blender/bmesh/bmesh_operators.h * choices are length, direction, face, ... */ -void bmo_similaredges_exec(BMesh *bm, BMOperator *op) +void bmo_similar_edges_exec(BMesh *bm, BMOperator *op) { BMOIter es_iter; /* selected edges iterator */ BMIter e_iter; /* mesh edges iterator */ @@ -882,7 +882,7 @@ typedef struct SimSel_VertExt { * select similar vertices: the choices are in the enum in source/blender/bmesh/bmesh_operators.h * choices are normal, face, vertex group... */ -void bmo_similarverts_exec(BMesh *bm, BMOperator *op) +void bmo_similar_verts_exec(BMesh *bm, BMOperator *op) { BMOIter vs_iter; /* selected verts iterator */ BMIter v_iter; /* mesh verts iterator */ @@ -996,7 +996,7 @@ void bmo_similarverts_exec(BMesh *bm, BMOperator *op) * Cycle UVs for a face **************************************************************************** */ -void bmo_face_rotateuvs_exec(BMesh *bm, BMOperator *op) +void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op) { BMOIter fs_iter; /* selected faces iterator */ BMFace *fs; /* current face */ @@ -1063,7 +1063,7 @@ void bmo_face_rotateuvs_exec(BMesh *bm, BMOperator *op) * Reverse UVs for a face **************************************************************************** */ -void bmo_face_reverseuvs_exec(BMesh *bm, BMOperator *op) +void bmo_reverse_uvs_exec(BMesh *bm, BMOperator *op) { BMOIter fs_iter; /* selected faces iterator */ BMFace *fs; /* current face */ @@ -1103,7 +1103,7 @@ void bmo_face_reverseuvs_exec(BMesh *bm, BMOperator *op) * Cycle colors for a face **************************************************************************** */ -void bmo_rotatecolors_exec(BMesh *bm, BMOperator *op) +void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op) { BMOIter fs_iter; /* selected faces iterator */ BMFace *fs; /* current face */ @@ -1169,7 +1169,7 @@ void bmo_rotatecolors_exec(BMesh *bm, BMOperator *op) * Reverse colors for a face *************************************************************************** */ -void bmo_face_reversecolors_exec(BMesh *bm, BMOperator *op) +void bmo_reverse_colors_exec(BMesh *bm, BMOperator *op) { BMOIter fs_iter; /* selected faces iterator */ BMFace *fs; /* current face */ @@ -1213,7 +1213,7 @@ typedef struct ElemNode { HeapNode *hn; /* heap node */ } ElemNode; -void bmo_vertexshortestpath_exec(BMesh *bm, BMOperator *op) +void bmo_shortest_path_exec(BMesh *bm, BMOperator *op) { BMOIter vs_iter /* , vs2_iter */; /* selected verts iterator */ BMIter v_iter; /* mesh verts iterator */ diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 625804e4ecd..4182a9c4c93 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -473,10 +473,10 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * { COLLADAFW::Transformation::TransformationType tm_type = transform->getTransformationType(); bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX; - bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE; + bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE; //to check if the no of curves are valid - bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE || tm_type == COLLADAFW::Transformation::SCALE) && binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ); + bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE || tm_type == COLLADAFW::Transformation::SCALE) && binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ); if (!((!xyz && curves->size() == 1) || (xyz && curves->size() == 3) || is_matrix)) { diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 9ac943f369c..c5feb62fd80 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -111,7 +111,7 @@ bool ArmatureExporter::add_instance_controller(Object *ob) write_bone_URLs(ins, ob_arm, bone); } - InstanceWriter::add_material_bindings(ins.getBindMaterial(), ob); + InstanceWriter::add_material_bindings(ins.getBindMaterial(), ob, this->export_settings->active_uv_only); ins.add(); return true; diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 115f129cb88..cd2574d055e 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -279,7 +279,7 @@ void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW: TagsMap::iterator etit; ExtraTags *et = 0; etit = uid_tags_map.find(node->getUniqueId().toAscii()); - if (etit != uid_tags_map.end()) { + if (etit != uid_tags_map.end()) { et = etit->second; //else return; diff --git a/source/blender/collada/CMakeLists.txt b/source/blender/collada/CMakeLists.txt index 58a65db0489..3b7a38eb950 100644 --- a/source/blender/collada/CMakeLists.txt +++ b/source/blender/collada/CMakeLists.txt @@ -34,6 +34,7 @@ set(INC ../makesdna ../makesrna ../windowmanager + ../imbuf ../../../intern/guardedalloc ) diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index 3ed689628f7..f11ecc7f16d 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -27,6 +27,7 @@ #include <map> +#include <set> #include "COLLADASWEffectProfile.h" @@ -39,6 +40,8 @@ #include "DNA_world_types.h" #include "BKE_customdata.h" +#include "BKE_mesh.h" +#include "BKE_material.h" #include "collada_internal.h" #include "collada_utils.h" @@ -118,11 +121,60 @@ void EffectsExporter::writePhong(COLLADASW::EffectProfile &ep, Material *ma) ep.setSpecular(cot, false, "specular"); } +void EffectsExporter::writeTextures(COLLADASW::EffectProfile &ep, + std::string &key, + COLLADASW::Sampler *sampler, + MTex *t, Image *ima, + std::string &uvname ) { + + // Image not set for texture + if (!ima) return; + + // color + if (t->mapto & (MAP_COL | MAP_COLSPEC)) { + ep.setDiffuse(createTexture(ima, uvname, sampler), false, "diffuse"); + } + // ambient + if (t->mapto & MAP_AMB) { + ep.setAmbient(createTexture(ima, uvname, sampler), false, "ambient"); + } + // specular + if (t->mapto & MAP_SPEC) { + ep.setSpecular(createTexture(ima, uvname, sampler), false, "specular"); + } + // emission + if (t->mapto & MAP_EMIT) { + ep.setEmission(createTexture(ima, uvname, sampler), false, "emission"); + } + // reflective + if (t->mapto & MAP_REF) { + ep.setReflective(createTexture(ima, uvname, sampler)); + } + // alpha + if (t->mapto & MAP_ALPHA) { + ep.setTransparent(createTexture(ima, uvname, sampler)); + } + // extension: + // Normal map --> Must be stored with <extra> tag as different technique, + // since COLLADA doesn't support normal maps, even in current COLLADA 1.5. + if (t->mapto & MAP_NORM) { + COLLADASW::Texture texture(key); + texture.setTexcoord(uvname); + texture.setSampler(*sampler); + // technique FCOLLADA, with the <bump> tag, is most likely the best understood, + // most widespread de-facto standard. + texture.setProfileName("FCOLLADA"); + texture.setChildElementName("bump"); + ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture)); + } +} + void EffectsExporter::operator()(Material *ma, Object *ob) { // create a list of indices to textures of type TEX_IMAGE std::vector<int> tex_indices; - createTextureIndices(ma, tex_indices); + if(this->export_settings->include_material_textures) + createTextureIndices(ma, tex_indices); openEffect(translate_id(id_name(ma)) + "-effect"); @@ -256,6 +308,52 @@ void EffectsExporter::operator()(Material *ma, Object *ob) } } + + std::set<Image *> uv_textures; + if (ob->type == OB_MESH && ob->totcol && this->export_settings->include_uv_textures) { + Mesh *me = (Mesh *) ob->data; + BKE_mesh_tessface_ensure(me); + for (int i = 0; i < me->pdata.totlayer; i++) { + if (me->pdata.layers[i].type == CD_MTEXPOLY) { + MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data; + MFace *mface = me->mface; + for (int j = 0; j < me->totpoly; j++, mface++, txface++) { + + Material *mat = give_current_material(ob, mface->mat_nr + 1); + if (mat != ma) + continue; + + Image *ima = txface->tpage; + if (ima == NULL) + continue; + + + bool not_in_list = uv_textures.find(ima)==uv_textures.end(); + if (not_in_list) { + std::string name = id_name(ima); + std::string key(name); + key = translate_id(key); + + // create only one <sampler>/<surface> pair for each unique image + if (im_samp_map.find(key) == im_samp_map.end()) { + //<newparam> <sampler> <source> + COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D, + key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX, + key + COLLADASW::Sampler::SURFACE_SID_SUFFIX); + sampler.setImageId(key); + samplers[a] = sampler; + samp_surf[b][0] = &samplers[a]; + im_samp_map[key] = b; + b++; + a++; + uv_textures.insert(ima); + } + } + } + } + } + } + // used as fallback when MTex->uvname is "" (this is pretty common) // it is indeed the correct value to use in that case std::string active_uv(getActiveUVLayerName(ob)); @@ -265,58 +363,25 @@ void EffectsExporter::operator()(Material *ma, Object *ob) for (a = 0; a < tex_indices.size(); a++) { MTex *t = ma->mtex[tex_indices[a]]; Image *ima = t->tex->ima; - - // Image not set for texture - if (!ima) continue; - - // we assume map input is always TEXCO_UV std::string key(id_name(ima)); key = translate_id(key); int i = im_samp_map[key]; - COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)samp_surf[i][0]; - //COLLADASW::Surface *surface = (COLLADASW::Surface*)samp_surf[i][1]; - std::string uvname = strlen(t->uvname) ? t->uvname : active_uv; + COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)samp_surf[i][0]; + writeTextures(ep, key, sampler, t, ima, uvname); + } - // color - if (t->mapto & (MAP_COL | MAP_COLSPEC)) { - ep.setDiffuse(createTexture(ima, uvname, sampler), false, "diffuse"); - } - // ambient - if (t->mapto & MAP_AMB) { - ep.setAmbient(createTexture(ima, uvname, sampler), false, "ambient"); - } - // specular - if (t->mapto & MAP_SPEC) { - ep.setSpecular(createTexture(ima, uvname, sampler), false, "specular"); - } - // emission - if (t->mapto & MAP_EMIT) { - ep.setEmission(createTexture(ima, uvname, sampler), false, "emission"); - } - // reflective - if (t->mapto & MAP_REF) { - ep.setReflective(createTexture(ima, uvname, sampler)); - } - // alpha - if (t->mapto & MAP_ALPHA) { - ep.setTransparent(createTexture(ima, uvname, sampler)); - } - // extension: - // Normal map --> Must be stored with <extra> tag as different technique, - // since COLLADA doesn't support normal maps, even in current COLLADA 1.5. - if (t->mapto & MAP_NORM) { - COLLADASW::Texture texture(key); - texture.setTexcoord(uvname); - texture.setSampler(*sampler); - // technique FCOLLADA, with the <bump> tag, is most likely the best understood, - // most widespread de-facto standard. - texture.setProfileName("FCOLLADA"); - texture.setChildElementName("bump"); - ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture)); - } + std::set<Image *>::iterator uv_t_iter; + for(uv_t_iter = uv_textures.begin(); uv_t_iter != uv_textures.end(); uv_t_iter++ ) { + Image *ima = *uv_t_iter; + std::string key(id_name(ima)); + key = translate_id(key); + int i = im_samp_map[key]; + COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)samp_surf[i][0]; + ep.setDiffuse(createTexture(ima, active_uv, sampler), false, "diffuse"); } + // performs the actual writing ep.addProfileElements(); bool twoSided = false; diff --git a/source/blender/collada/EffectExporter.h b/source/blender/collada/EffectExporter.h index 6b7caf439b7..d20cbfdfe0b 100644 --- a/source/blender/collada/EffectExporter.h +++ b/source/blender/collada/EffectExporter.h @@ -64,7 +64,12 @@ private: void writeBlinn(COLLADASW::EffectProfile &ep, Material *ma); void writeLambert(COLLADASW::EffectProfile &ep, Material *ma); void writePhong(COLLADASW::EffectProfile &ep, Material *ma); - + void writeTextures(COLLADASW::EffectProfile &ep, + std::string &key, + COLLADASW::Sampler *sampler, + MTex *t, Image *ima, + std::string &uvname ); + bool hasEffects(Scene *sce); const ExportSettings *export_settings; diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h index 1b2dfde641b..2504c276036 100644 --- a/source/blender/collada/ExportSettings.h +++ b/source/blender/collada/ExportSettings.h @@ -33,13 +33,21 @@ struct ExportSettings { public: bool apply_modifiers; BC_export_mesh_type export_mesh_type; + bool selected; bool include_children; bool include_armatures; bool deform_bones_only; + + bool active_uv_only; + bool include_uv_textures; + bool include_material_textures; + bool use_texture_copies; + bool use_object_instantiation; bool sort_by_name; bool second_life; + char *filepath; LinkNode *export_set; }; diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index baa20ab07b7..c3d1106b288 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -261,8 +261,9 @@ void GeometryExporter::createPolylist(short material_index, // sets material name if (ma) { + std::string material_id = get_material_id(ma); std::ostringstream ostr; - ostr << translate_id(id_name(ma)); + ostr << translate_id(material_id); polylist.setMaterial(ostr.str()); } @@ -436,33 +437,38 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me) // write <source> for each layer // each <source> will get id like meshName + "map-channel-1" + int map_index = 0; + int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE)-1; for (int a = 0; a < num_layers; a++) { - MTFace *tface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, a); - // char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, a); - - COLLADASW::FloatSourceF source(mSW); - std::string layer_id = makeTexcoordSourceId(geom_id, a); - source.setId(layer_id); - source.setArrayId(layer_id + ARRAY_ID_SUFFIX); - - source.setAccessorCount(totuv); - source.setAccessorStride(2); - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("S"); - param.push_back("T"); - - source.prepareToAppendValues(); - - for (i = 0; i < totfaces; i++) { - MFace *f = &mfaces[i]; + + if (!this->export_settings->active_uv_only || a == active_uv_index) { + MTFace *tface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, a); + // char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, a); - for (int j = 0; j < (f->v4 == 0 ? 3 : 4); j++) { - source.appendValues(tface[i].uv[j][0], - tface[i].uv[j][1]); + COLLADASW::FloatSourceF source(mSW); + std::string layer_id = makeTexcoordSourceId(geom_id, map_index++); + source.setId(layer_id); + source.setArrayId(layer_id + ARRAY_ID_SUFFIX); + + source.setAccessorCount(totuv); + source.setAccessorStride(2); + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + param.push_back("S"); + param.push_back("T"); + + source.prepareToAppendValues(); + + for (i = 0; i < totfaces; i++) { + MFace *f = &mfaces[i]; + + for (int j = 0; j < (f->v4 == 0 ? 3 : 4); j++) { + source.appendValues(tface[i].uv[j][0], + tface[i].uv[j][1]); + } } + + source.finish(); } - - source.finish(); } } diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index c777a7d1fab..f789cfe3660 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -29,22 +29,150 @@ #include "COLLADABUURI.h" #include "COLLADASWImage.h" -#include "ImageExporter.h" -#include "MaterialExporter.h" - +extern "C" { #include "DNA_texture_types.h" +#include "DNA_image_types.h" +#include "DNA_meshdata_types.h" +#include "BKE_customdata.h" #include "BKE_global.h" +#include "BKE_image.h" #include "BKE_main.h" +#include "BKE_mesh.h" #include "BKE_utildefines.h" #include "BLI_fileops.h" #include "BLI_path_util.h" #include "BLI_string.h" +#include "IMB_imbuf_types.h" +} + +#include "ImageExporter.h" +#include "MaterialExporter.h" + ImagesExporter::ImagesExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryImages(sw), export_settings(export_settings) { } +void ImagesExporter::export_UV_Image(Image *image, bool use_copies) +{ + std::string name(id_name(image)); + std::string translated_name(translate_id(name)); + bool not_yet_exported = find(mImages.begin(), mImages.end(), translated_name) == mImages.end(); + + if (not_yet_exported) { + + ImBuf *imbuf = BKE_image_get_ibuf(image, NULL); + bool is_dirty = imbuf->userflags & IB_BITMAPDIRTY; + + ImageFormatData imageFormat; + BKE_imbuf_to_image_format(&imageFormat, imbuf); + + short image_source = image->source; + bool is_generated = image_source == IMA_SRC_GENERATED; + + char export_path[FILE_MAX]; + char source_path[FILE_MAX]; + char export_dir[FILE_MAX]; + char export_file[FILE_MAX]; + + // Destination folder for exported assets + BLI_split_dir_part(this->export_settings->filepath, export_dir, sizeof(export_dir)); + + if (is_generated || is_dirty || use_copies) { + + // make absolute destination path + + BLI_strncpy(export_file, name.c_str(), sizeof(export_file)); + BKE_add_image_extension(export_file, imageFormat.imtype); + + BLI_join_dirfile(export_path, sizeof(export_path), export_dir, export_file); + + // make dest directory if it doesn't exist + BLI_make_existing_file(export_path); + } + + if (is_generated || is_dirty) { + + // This image in its current state only exists in Blender memory. + // So we have to export it. The export will keep the image state intact, + // so the exported file will not be associated with the image. + + if (BKE_imbuf_write_as(imbuf, export_path, &imageFormat, true) == 0) { + fprintf(stderr, "Collada export: Cannot export image to:\n%s\n", export_path); + } + BLI_strncpy(export_path, export_file, sizeof(export_path)); + } + else { + + // make absolute source path + BLI_strncpy(source_path, image->name, sizeof(source_path)); + BLI_path_abs(source_path, G.main->name); + BLI_cleanup_path(NULL, source_path); + + if (use_copies) { + + // This image is already located on the file system. + // But we want to create copies here. + // To avoid overwroting images with same file name but + // differenet source locations + + if (BLI_copy(source_path, export_path) != 0) { + fprintf(stderr, "Collada export: Cannot copy image:\n source:%s\ndest :%s\n", source_path, export_path); + } + + BLI_strncpy(export_path, export_file, sizeof(export_path)); + + } + else { + + // Do not make any vopies, but use the source path directly as reference + // to the original image + + BLI_strncpy(export_path, source_path, sizeof(export_path)); + } + } + + COLLADASW::Image img(COLLADABU::URI(COLLADABU::URI::nativePathToUri(export_path)), translated_name, translated_name); /* set name also to mNameNC. This helps other viewers import files exported from Blender better */ + img.add(mSW); + fprintf(stdout, "Collada export: Added image: %s\n",export_file); + mImages.push_back(translated_name); + } +} + +void ImagesExporter::export_UV_Images() +{ + std::set<Image *> uv_textures; + LinkNode *node; + bool use_copies = this->export_settings->use_texture_copies; + for (node=this->export_settings->export_set; node; node=node->next) { + Object *ob = (Object *)node->link; + if (ob->type == OB_MESH && ob->totcol) { + Mesh *me = (Mesh *) ob->data; + BKE_mesh_tessface_ensure(me); + for (int i = 0; i < me->pdata.totlayer; i++) { + if (me->pdata.layers[i].type == CD_MTEXPOLY) { + MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data; + MFace *mface = me->mface; + for (int j = 0; j < me->totpoly; j++, mface++, txface++) { + + Image *ima = txface->tpage; + if (ima == NULL) + continue; + + bool not_in_list = uv_textures.find(ima)==uv_textures.end(); + if (not_in_list) { + uv_textures.insert(ima); + export_UV_Image(ima, use_copies); + } + } + } + } + } + } +} + + bool ImagesExporter::hasImages(Scene *sce) { LinkNode *node; @@ -64,60 +192,51 @@ bool ImagesExporter::hasImages(Scene *sce) } } + if (ob->type == OB_MESH) { + Mesh *me = (Mesh *) ob->data; + BKE_mesh_tessface_ensure(me); + bool has_uvs = (bool)CustomData_has_layer(&me->fdata, CD_MTFACE); + if (has_uvs) { + int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE); + for (int a = 0; a < num_layers; a++) { + MTFace *tface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, a); + Image *img = tface->tpage; + if (img) return true; + } + } + } + } return false; } void ImagesExporter::exportImages(Scene *sce) { - if (hasImages(sce)) { - openLibrary(); - MaterialFunctor mf; + openLibrary(); + + MaterialFunctor mf; + if (this->export_settings->include_material_textures) { mf.forEachMaterialInExportSet<ImagesExporter>(sce, *this, this->export_settings->export_set); + } - closeLibrary(); + if (this->export_settings->include_uv_textures) { + export_UV_Images(); } + + closeLibrary(); } + + void ImagesExporter::operator()(Material *ma, Object *ob) { int a; + bool use_texture_copies = this->export_settings->use_texture_copies; for (a = 0; a < MAX_MTEX; a++) { MTex *mtex = ma->mtex[a]; if (mtex && mtex->tex && mtex->tex->ima) { - Image *image = mtex->tex->ima; - std::string name(id_name(image)); - name = translate_id(name); - char rel[FILE_MAX]; - char abs[FILE_MAX]; - char src[FILE_MAX]; - char dir[FILE_MAX]; - - BLI_split_dir_part(this->export_settings->filepath, dir, sizeof(dir)); - - BKE_rebase_path(abs, sizeof(abs), rel, sizeof(rel), G.main->name, image->name, dir); - - if (abs[0] != '\0') { - - // make absolute source path - BLI_strncpy(src, image->name, sizeof(src)); - BLI_path_abs(src, G.main->name); - - // make dest directory if it doesn't exist - BLI_make_existing_file(abs); - - if (BLI_copy(src, abs) != 0) { - fprintf(stderr, "Cannot copy image to file's directory.\n"); - } - } - - if (find(mImages.begin(), mImages.end(), name) == mImages.end()) { - COLLADASW::Image img(COLLADABU::URI(COLLADABU::URI::nativePathToUri(rel)), name, name); /* set name also to mNameNC. This helps other viewers import files exported from Blender better */ - img.add(mSW); - - mImages.push_back(name); - } + export_UV_Image(image, use_texture_copies); } } } diff --git a/source/blender/collada/ImageExporter.h b/source/blender/collada/ImageExporter.h index a2abc893a56..0eaebdd5cdd 100644 --- a/source/blender/collada/ImageExporter.h +++ b/source/blender/collada/ImageExporter.h @@ -35,6 +35,7 @@ #include "COLLADASWLibraryImages.h" #include "DNA_material_types.h" +#include "DNA_image_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -49,6 +50,9 @@ public: void operator()(Material *ma, Object *ob); private: std::vector<std::string> mImages; // contains list of written images, to avoid duplicates + + void export_UV_Images(); + void export_UV_Image(Image *image, bool use_texture_copies); bool hasImages(Scene *sce); const ExportSettings *export_settings; }; diff --git a/source/blender/collada/InstanceWriter.cpp b/source/blender/collada/InstanceWriter.cpp index 788bd2a98b7..5908037d782 100644 --- a/source/blender/collada/InstanceWriter.cpp +++ b/source/blender/collada/InstanceWriter.cpp @@ -41,7 +41,7 @@ #include "collada_internal.h" #include "collada_utils.h" -void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_material, Object *ob) +void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_material, Object *ob, bool active_uv_only) { for (int a = 0; a < ob->totcol; a++) { Material *ma = give_current_material(ob, a + 1); @@ -52,16 +52,20 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia std::string matid(get_material_id(ma)); matid = translate_id(matid); std::ostringstream ostr; - ostr << translate_id(id_name(ma)); + ostr << matid; COLLADASW::InstanceMaterial im(ostr.str(), COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, matid)); // create <bind_vertex_input> for each uv map Mesh *me = (Mesh *)ob->data; int totlayer = CustomData_number_of_layers(&me->fdata, CD_MTFACE); + int map_index = 0; + int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE) -1; for (int b = 0; b < totlayer; b++) { - char *name = bc_CustomData_get_layer_name(&me->fdata, CD_MTFACE, b); - im.push_back(COLLADASW::BindVertexInput(name, "TEXCOORD", b)); + if (!active_uv_only || b == active_uv_index) { + char *name = bc_CustomData_get_layer_name(&me->fdata, CD_MTFACE, map_index); + im.push_back(COLLADASW::BindVertexInput(name, "TEXCOORD", map_index++)); + } } iml.push_back(im); diff --git a/source/blender/collada/InstanceWriter.h b/source/blender/collada/InstanceWriter.h index 87ddc7fb1f7..49ddf091b1c 100644 --- a/source/blender/collada/InstanceWriter.h +++ b/source/blender/collada/InstanceWriter.h @@ -35,7 +35,7 @@ class InstanceWriter { protected: - void add_material_bindings(COLLADASW::BindMaterial& bind_material, Object *ob); + void add_material_bindings(COLLADASW::BindMaterial& bind_material, Object *ob, bool active_uv_only); }; #endif diff --git a/source/blender/collada/MaterialExporter.cpp b/source/blender/collada/MaterialExporter.cpp index 07e11183dd0..5a1d8b7602a 100644 --- a/source/blender/collada/MaterialExporter.cpp +++ b/source/blender/collada/MaterialExporter.cpp @@ -31,7 +31,9 @@ #include "COLLADABUUtils.h" #include "collada_internal.h" -MaterialsExporter::MaterialsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryMaterials(sw), export_settings(export_settings) { +MaterialsExporter::MaterialsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryMaterials(sw), export_settings(export_settings) +{ + /* pass */ } void MaterialsExporter::exportMaterials(Scene *sce) diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 59927e961bf..ded937bf8f3 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -294,8 +294,7 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has su } - else if (type == COLLADAFW::MeshPrimitive::LINES) - { + else if (type == COLLADAFW::MeshPrimitive::LINES) { // TODO: Add Checker for line syntax here } @@ -582,8 +581,7 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me) COLLADAFW::MeshPrimitive *mp = prim_arr[i]; int type = mp->getPrimitiveType(); - if (type == COLLADAFW::MeshPrimitive::LINES) - { + if (type == COLLADAFW::MeshPrimitive::LINES) { unsigned int edge_count = mp->getFaceCount(); unsigned int *indices = mp->getPositionIndices().getData(); @@ -857,8 +855,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T indices += vcount; } } - else if (type == COLLADAFW::MeshPrimitive::LINES) - { + else if (type == COLLADAFW::MeshPrimitive::LINES) { continue; // read the lines later after all the rest is done } diff --git a/source/blender/collada/SConscript b/source/blender/collada/SConscript index 90d0d83d793..5d921681aea 100644 --- a/source/blender/collada/SConscript +++ b/source/blender/collada/SConscript @@ -32,9 +32,9 @@ defs = [] # TODO sanitize inc path building # relative paths to include dirs, space-separated, string if env['OURPLATFORM']=='darwin': - incs = '../blenlib ../blenkernel ../windowmanager ../blenloader ../makesdna ../makesrna ../editors/include ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter [OPENCOLLADA]/COLLADABaseUtils [OPENCOLLADA]/COLLADAFramework [OPENCOLLADA]/COLLADASaxFrameworkLoader [OPENCOLLADA]/GeneratedSaxParser '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC']) + incs = '../blenlib ../blenkernel ../windowmanager ../blenloader ../makesdna ../makesrna ../editors/include ../imbuf ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter [OPENCOLLADA]/COLLADABaseUtils [OPENCOLLADA]/COLLADAFramework [OPENCOLLADA]/COLLADASaxFrameworkLoader [OPENCOLLADA]/GeneratedSaxParser '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC']) else: - incs = '../blenlib ../blenkernel ../windowmanager ../makesdna ../blenloader ../makesrna ../editors/include ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter/include [OPENCOLLADA]/COLLADABaseUtils/include [OPENCOLLADA]/COLLADAFramework/include [OPENCOLLADA]/COLLADASaxFrameworkLoader/include [OPENCOLLADA]/GeneratedSaxParser/include '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC']) + incs = '../blenlib ../blenkernel ../windowmanager ../makesdna ../blenloader ../makesrna ../editors/include ../imbuf ../../../intern/guardedalloc [OPENCOLLADA]/COLLADAStreamWriter/include [OPENCOLLADA]/COLLADABaseUtils/include [OPENCOLLADA]/COLLADAFramework/include [OPENCOLLADA]/COLLADASaxFrameworkLoader/include [OPENCOLLADA]/GeneratedSaxParser/include '.replace('[OPENCOLLADA]', env['BF_OPENCOLLADA_INC']) if env['BF_BUILDINFO']: defs.append('WITH_BUILDINFO') diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp index bd746e241ca..4aaff024cac 100644 --- a/source/blender/collada/SceneExporter.cpp +++ b/source/blender/collada/SceneExporter.cpp @@ -57,8 +57,7 @@ void SceneExporter::exportHierarchy(Scene *sce) // Now find all exportable base ojects (highest in export hierarchy) for (node = this->export_settings->export_set; node; node = node->next) { Object *ob = (Object *) node->link; - if (bc_is_base_node(this->export_settings->export_set, ob)) - { + if (bc_is_base_node(this->export_settings->export_set, ob)) { switch (ob->type) { case OB_MESH: case OB_CAMERA: @@ -86,8 +85,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) // Add associated armature first if available bool armature_exported = false; Object *ob_arm = bc_get_assigned_armature(ob); - if (ob_arm != NULL) - { + if (ob_arm != NULL) { 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); @@ -141,7 +139,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) COLLADASW::InstanceGeometry instGeom(mSW); instGeom.setUrl(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_geometry_id(ob, this->export_settings->use_object_instantiation))); - InstanceWriter::add_material_bindings(instGeom.getBindMaterial(), ob); + InstanceWriter::add_material_bindings(instGeom.getBindMaterial(), ob, this->export_settings->active_uv_only); instGeom.add(); } diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp index 0116f89361b..9b0d59d66ea 100644 --- a/source/blender/collada/SkinInfo.cpp +++ b/source/blender/collada/SkinInfo.cpp @@ -57,7 +57,9 @@ static const char *bc_get_joint_name(T *node) // This is used to store data passed in write_controller_data. // Arrays from COLLADAFW::SkinControllerData lose ownership, so do this class members // so that arrays don't get freed until we free them explicitly. -SkinInfo::SkinInfo() { +SkinInfo::SkinInfo() +{ + /* pass */ } SkinInfo::SkinInfo(const SkinInfo& skin) : weights(skin.weights), diff --git a/source/blender/collada/TransformReader.cpp b/source/blender/collada/TransformReader.cpp index be615f83787..d10cd7378e9 100644 --- a/source/blender/collada/TransformReader.cpp +++ b/source/blender/collada/TransformReader.cpp @@ -29,7 +29,9 @@ #include "TransformReader.h" -TransformReader::TransformReader(UnitConverter *conv) : unit_converter(conv) { +TransformReader::TransformReader(UnitConverter *conv) : unit_converter(conv) +{ + /* pass */ } void TransformReader::get_node_mat(float mat[][4], COLLADAFW::Node *node, std::map<COLLADAFW::UniqueId, Animation> *animation_map, Object *ob) diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index da1ca6c30c8..f7e0f75ec5c 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -61,6 +61,11 @@ int collada_export(Scene *sce, int include_armatures, int deform_bones_only, + int active_uv_only, + int include_uv_textures, + int include_material_textures, + int use_texture_copies, + int use_object_instantiation, int sort_by_name, int second_life) @@ -79,12 +84,17 @@ int collada_export(Scene *sce, export_settings.filepath = (char *)filepath; export_settings.apply_modifiers = apply_modifiers != 0; - export_settings.export_mesh_type = export_mesh_type; + export_settings.export_mesh_type = export_mesh_type; export_settings.selected = selected != 0; export_settings.include_children = include_children != 0; export_settings.include_armatures = include_armatures != 0; export_settings.deform_bones_only = deform_bones_only != 0; + export_settings.active_uv_only = active_uv_only != 0; + export_settings.include_uv_textures = include_uv_textures != 0; + export_settings.include_material_textures= include_material_textures != 0; + export_settings.use_texture_copies = use_texture_copies != 0; + export_settings.use_object_instantiation = use_object_instantiation != 0; export_settings.sort_by_name = sort_by_name != 0; export_settings.second_life = second_life != 0; diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h index 63f791ba80e..13f8151da3d 100644 --- a/source/blender/collada/collada.h +++ b/source/blender/collada/collada.h @@ -57,6 +57,11 @@ int collada_export(Scene *sce, int include_armatures, int deform_bones_only, + int active_uv_only, + int include_uv_textures, + int include_material_textures, + int use_texture_copies, + int use_object_instantiation, int sort_by_name, int second_life); diff --git a/source/blender/collada/collada_internal.cpp b/source/blender/collada/collada_internal.cpp index 0ee8419eda7..a4969735757 100644 --- a/source/blender/collada/collada_internal.cpp +++ b/source/blender/collada/collada_internal.cpp @@ -31,7 +31,9 @@ #include "BLI_linklist.h" -UnitConverter::UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP) { +UnitConverter::UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP) +{ + /* pass */ } void UnitConverter::read_asset(const COLLADAFW::FileInfo *asset) diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index cf7c9e49b63..955d699d96c 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -187,8 +187,7 @@ Object *bc_get_assigned_armature(Object *ob) Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob) { Object *ancestor = ob; - while (ob->parent && bc_is_marked(ob->parent)) - { + while (ob->parent && bc_is_marked(ob->parent)) { ob = ob->parent; ancestor = ob; } @@ -260,7 +259,8 @@ void bc_bubble_sort_by_Object_name(LinkNode *export_set) * can be root bones. Otherwise the top most deform bones in the hierarchy * are root bones. */ -bool bc_is_root_bone(Bone *aBone, bool deform_bones_only) { +bool bc_is_root_bone(Bone *aBone, bool deform_bones_only) +{ if (deform_bones_only) { Bone *root = NULL; Bone *bone = aBone; @@ -274,3 +274,9 @@ bool bc_is_root_bone(Bone *aBone, bool deform_bones_only) { else return !(aBone->parent); } + +int bc_get_active_UVLayer(Object *ob) +{ + Mesh *me = (Mesh *)ob->data; + return CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); +} diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h index ab0b7421aa1..5f72581f584 100644 --- a/source/blender/collada/collada_utils.h +++ b/source/blender/collada/collada_utils.h @@ -73,5 +73,6 @@ extern char *bc_CustomData_get_active_layer_name(const CustomData *data, int typ extern void bc_bubble_sort_by_Object_name(LinkNode *export_set); extern bool bc_is_root_bone(Bone *aBone, bool deform_bones_only); +extern int bc_get_active_UVLayer(Object *ob); #endif diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index d0093c58d23..9bad1b55d95 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -46,6 +46,10 @@ set(INC ../../../intern/guardedalloc ) +set(INC_SYS + +) + set(SRC COM_compositor.h COM_defines.h @@ -415,10 +419,10 @@ set(SRC operations/COM_PreviewOperation.cpp operations/COM_SplitViewerOperation.h operations/COM_SplitViewerOperation.cpp - operations/COM_ConvertValueToColourProg.h - operations/COM_ConvertValueToColourProg.cpp - operations/COM_ConvertColourToValueProg.h - operations/COM_ConvertColourToValueProg.cpp + operations/COM_ConvertValueToColorProg.h + operations/COM_ConvertValueToColorProg.cpp + operations/COM_ConvertColorToValueProg.h + operations/COM_ConvertColorToValueProg.cpp operations/COM_ConvertColorToBWOperation.h operations/COM_ConvertColorToBWOperation.cpp operations/COM_ConvertColorToVectorOperation.h diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h index 4789fed2efd..86390e5650a 100644 --- a/source/blender/compositor/COM_compositor.h +++ b/source/blender/compositor/COM_compositor.h @@ -224,7 +224,7 @@ extern "C" { * For every CPUcore a working thread is created. These working threads will ask the WorkScheduler if there is work * for a specific Device. * the workscheduler will find work for the device and the device will be asked to execute the WorkPackage - + * * @subsection singlethread Single threaded * For debugging reasons the multi-threading can be disabled. This is done by changing the COM_CURRENT_THREADING_MODEL * to COM_TM_NOTHREAD. When compiling the workscheduler @@ -268,7 +268,7 @@ extern "C" { * * @section executePixel executing a pixel * Finally the last step, the node functionality :) - + * * @page newnode Creating new nodes */ @@ -297,7 +297,7 @@ extern "C" { * - output nodes can have different priorities in the WorkScheduler. * This is implemented in the COM_execute function. */ -void COM_execute(bNodeTree *editingtree, int rendering); +void COM_execute(RenderData* rd, bNodeTree *editingtree, int rendering); #ifdef __cplusplus } diff --git a/source/blender/compositor/intern/COM_ChannelInfo.cpp b/source/blender/compositor/intern/COM_ChannelInfo.cpp index f2fa62006d5..557075cdc80 100644 --- a/source/blender/compositor/intern/COM_ChannelInfo.cpp +++ b/source/blender/compositor/intern/COM_ChannelInfo.cpp @@ -29,7 +29,7 @@ */ ChannelInfo::ChannelInfo() { - this->number = 0; - this->premultiplied = true; - this->type = COM_CT_UNUSED; + this->m_number = 0; + this->m_premultiplied = true; + this->m_type = COM_CT_UNUSED; } diff --git a/source/blender/compositor/intern/COM_ChannelInfo.h b/source/blender/compositor/intern/COM_ChannelInfo.h index 399fdc62fa2..44664442359 100644 --- a/source/blender/compositor/intern/COM_ChannelInfo.h +++ b/source/blender/compositor/intern/COM_ChannelInfo.h @@ -61,23 +61,23 @@ private: /** * @brief the channel number, in the connection. [0-3] */ - int number; + int m_number; /** * @brief type of channel */ - ChannelType type; + ChannelType m_type; /** * @brieg Is this value in this channel premultiplied with its alpha * @note only valid if type = ColorComponent; */ - bool premultiplied; + bool m_premultiplied; // /** -// * Color space of this value. -// * only valid when type = ColorComponent; -// */ +// * Color space of this value. +// * only valid when type = ColorComponent; +// */ // string colorspacename; public: @@ -89,32 +89,32 @@ public: /** * @brief set the index of this channel in the SocketConnection */ - void setNumber(const int number) { this->number = number; } + void setNumber(const int number) { this->m_number = number; } /** * @brief get the index of this channel in the SocketConnection */ - const int getNumber() const { return this->number; } + const int getNumber() const { return this->m_number; } /** * @brief set the type of channel */ - void setType(const ChannelType type) { this->type = type; } + void setType(const ChannelType type) { this->m_type = type; } /** * @brief get the type of channel */ - const ChannelType getType() const { return this->type; } + const ChannelType getType() const { return this->m_type; } /** * @brief set the premultiplicatioin of this channel */ - void setPremultiplied(const bool premultiplied) { this->premultiplied = premultiplied; } + void setPremultiplied(const bool premultiplied) { this->m_premultiplied = premultiplied; } /** * @brief is this channel premultiplied */ - const bool isPremultiplied() const { return this->premultiplied; } + const bool isPremultiplied() const { return this->m_premultiplied; } }; diff --git a/source/blender/compositor/intern/COM_ChunkOrder.cpp b/source/blender/compositor/intern/COM_ChunkOrder.cpp index 02c28a1997a..38a3350c263 100644 --- a/source/blender/compositor/intern/COM_ChunkOrder.cpp +++ b/source/blender/compositor/intern/COM_ChunkOrder.cpp @@ -25,10 +25,10 @@ ChunkOrder::ChunkOrder() { - this->distance = 0.0; - this->number = 0; - this->x = 0; - this->y = 0; + this->m_distance = 0.0; + this->m_number = 0; + this->m_x = 0; + this->m_y = 0; } void ChunkOrder::determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots) @@ -37,15 +37,15 @@ void ChunkOrder::determineDistance(ChunkOrderHotspot **hotspots, unsigned int nu double distance = MAXFLOAT; for (index = 0; index < numberOfHotspots; index++) { ChunkOrderHotspot *hotspot = hotspots[index]; - double ndistance = hotspot->determineDistance(this->x, this->y); + double ndistance = hotspot->determineDistance(this->m_x, this->m_y); if (ndistance < distance) { distance = ndistance; } } - this->distance = distance; + this->m_distance = distance; } bool operator<(const ChunkOrder& a, const ChunkOrder& b) { - return a.distance < b.distance; + return a.m_distance < b.m_distance; } diff --git a/source/blender/compositor/intern/COM_ChunkOrder.h b/source/blender/compositor/intern/COM_ChunkOrder.h index f096ebeebfe..190ecb9c380 100644 --- a/source/blender/compositor/intern/COM_ChunkOrder.h +++ b/source/blender/compositor/intern/COM_ChunkOrder.h @@ -26,20 +26,20 @@ #include "COM_ChunkOrderHotspot.h" class ChunkOrder { private: - unsigned int number; - int x; - int y; - double distance; + unsigned int m_number; + int m_x; + int m_y; + double m_distance; public: ChunkOrder(); void determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots); friend bool operator<(const ChunkOrder& a, const ChunkOrder& b); - void setChunkNumber(unsigned int chunknumber) { this->number = chunknumber; } - void setX(int x) { this->x = x; } - void setY(int y) { this->y = y; } - unsigned int getChunkNumber() { return this->number; } - double getDistance() { return this->distance; } + void setChunkNumber(unsigned int chunknumber) { this->m_number = chunknumber; } + void setX(int x) { this->m_x = x; } + void setY(int y) { this->m_y = y; } + unsigned int getChunkNumber() { return this->m_number; } + double getDistance() { return this->m_distance; } }; #endif diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp index 96568092b72..1e64e0b9ea0 100644 --- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp +++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp @@ -25,16 +25,16 @@ ChunkOrderHotspot::ChunkOrderHotspot(int x, int y, float addition) { - this->x = x; - this->y = y; - this->addition = addition; + this->m_x = x; + this->m_y = y; + this->m_addition = addition; } double ChunkOrderHotspot::determineDistance(int x, int y) { - int dx = x - this->x; - int dy = y - this->y; + int dx = x - this->m_x; + int dy = y - this->m_y; double result = sqrt((double)(dx * dx + dy * dy)); - result += (double)this->addition; + result += (double)this->m_addition; return result; } diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h index ceb5934a7df..b166a7af57f 100644 --- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h +++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h @@ -23,15 +23,24 @@ #ifndef _COM_ChunkOrderHotSpot_h_ #define _COM_ChunkOrderHotSpot_h_ +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class ChunkOrderHotspot { private: - int x; - int y; - float addition; + int m_x; + int m_y; + float m_addition; public: ChunkOrderHotspot(int x, int y, float addition); double determineDistance(int x, int y); + + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:ChunkOrderHotspot") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp index bb8e7d9606d..fbdb4cd6b28 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.cpp +++ b/source/blender/compositor/intern/COM_CompositorContext.cpp @@ -26,16 +26,17 @@ CompositorContext::CompositorContext() { - this->scene = NULL; - this->quality = COM_QUALITY_HIGH; - this->hasActiveOpenCLDevices = false; - this->activegNode = NULL; + this->m_rd = NULL; + this->m_quality = COM_QUALITY_HIGH; + this->m_hasActiveOpenCLDevices = false; + this->m_activegNode = NULL; + this->m_fastCalculation = false; } const int CompositorContext::getFramenumber() const { - if (this->scene) { - return this->scene->r.cfra; + if (this->m_rd) { + return this->m_rd->cfra; } else { return -1; /* this should never happen */ @@ -44,8 +45,8 @@ const int CompositorContext::getFramenumber() const const int CompositorContext::isColorManaged() const { - if (this->scene) { - return this->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; + if (this->m_rd) { + return this->m_rd->color_mgt_flag & R_COLOR_MANAGEMENT; } else { return 0; /* this should never happen */ diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h index 93872f4839f..2f6abf39985 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.h +++ b/source/blender/compositor/intern/COM_CompositorContext.h @@ -41,38 +41,43 @@ private: * This field is initialized in ExecutionSystem and must only be read from that point on. * @see ExecutionSystem */ - bool rendering; + bool m_rendering; /** * @brief The quality of the composite. * This field is initialized in ExecutionSystem and must only be read from that point on. * @see ExecutionSystem */ - CompositorQuality quality; + CompositorQuality m_quality; /** - * @brief Reference to the scene that is being composited. + * @brief Reference to the render data that is being composited. * This field is initialized in ExecutionSystem and must only be read from that point on. * @see ExecutionSystem */ - Scene *scene; + RenderData *m_rd; /** * @brief reference to the bNodeTree * This field is initialized in ExecutionSystem and must only be read from that point on. * @see ExecutionSystem */ - bNodeTree *bnodetree; + bNodeTree *m_bnodetree; /** * @brief activegNode the group node that is currently being edited. */ - bNode *activegNode; + bNode *m_activegNode; /** * @brief does this system have active opencl devices? */ - bool hasActiveOpenCLDevices; + bool m_hasActiveOpenCLDevices; + + /** + * @brief Skip slow nodes + */ + bool m_fastCalculation; public: /** @@ -83,56 +88,52 @@ public: /** * @brief set the rendering field of the context */ - void setRendering(bool rendering) { this->rendering = rendering; } + void setRendering(bool rendering) { this->m_rendering = rendering; } /** * @brief get the rendering field of the context */ - bool isRendering() const { return this->rendering; } + bool isRendering() const { return this->m_rendering; } /** * @brief set the scene of the context */ - void setScene(Scene *scene) { this->scene = scene; } + void setRenderData(RenderData *rd) { this->m_rd = rd; } /** * @brief set the bnodetree of the context */ - void setbNodeTree(bNodeTree *bnodetree) { this->bnodetree = bnodetree; } + void setbNodeTree(bNodeTree *bnodetree) { this->m_bnodetree = bnodetree; } /** * @brief get the bnodetree of the context */ - const bNodeTree *getbNodeTree() const { return this->bnodetree; } + const bNodeTree *getbNodeTree() const { return this->m_bnodetree; } /** * @brief set the active groupnode of the context */ - void setActivegNode(bNode *gnode) { this->activegNode = gnode; } + void setActivegNode(bNode *gnode) { this->m_activegNode = gnode; } /** * @brief get the active groupnode of the context */ - const bNode *getActivegNode() const { return this->activegNode; } + const bNode *getActivegNode() const { return this->m_activegNode; } /** * @brief get the scene of the context */ - const Scene *getScene() const { return this->scene; } + const RenderData *getRenderData() const { return this->m_rd; } /** * @brief set the quality */ - void setQuality(CompositorQuality quality) { - this->quality = quality; - } + void setQuality(CompositorQuality quality) { this->m_quality = quality; } /** * @brief get the quality */ - const CompositorQuality getQuality() const { - return quality; - } + const CompositorQuality getQuality() const { return this->m_quality; } /** * @brief get the current framenumber of the scene in this context @@ -142,20 +143,19 @@ public: /** * @brief has this system active openclDevices? */ - const bool getHasActiveOpenCLDevices() const { - return this->hasActiveOpenCLDevices; - } + const bool getHasActiveOpenCLDevices() const { return this->m_hasActiveOpenCLDevices; } /** * @brief set has this system active openclDevices? */ - void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices) { - this->hasActiveOpenCLDevices = hasAvtiveOpenCLDevices; - } + void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices) { this->m_hasActiveOpenCLDevices = hasAvtiveOpenCLDevices; } int getChunksize() { return this->getbNodeTree()->chunksize; } const int isColorManaged() const; + + void setFastCalculation(bool fastCalculation) {this->m_fastCalculation = fastCalculation;} + bool isFastCalculation() {return this->m_fastCalculation;} }; diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp index 0a8862e4017..4ed7ae7ca8a 100644 --- a/source/blender/compositor/intern/COM_Converter.cpp +++ b/source/blender/compositor/intern/COM_Converter.cpp @@ -48,8 +48,8 @@ #include "COM_CompositorNode.h" #include "COM_ConvertAlphaNode.h" #include "COM_ConvertColorToVectorOperation.h" -#include "COM_ConvertColourToValueProg.h" -#include "COM_ConvertValueToColourProg.h" +#include "COM_ConvertColorToValueProg.h" +#include "COM_ConvertValueToColorProg.h" #include "COM_ConvertValueToVectorOperation.h" #include "COM_ConvertVectorToColorOperation.h" #include "COM_ConvertVectorToValueOperation.h" @@ -117,253 +117,269 @@ #include "COM_ViewerNode.h" #include "COM_ZCombineNode.h" -Node *Converter::convert(bNode *bNode) +Node *Converter::convert(bNode *b_node, bool fast) { Node *node; - if (bNode->flag & NODE_MUTED) { - node = new MuteNode(bNode); + if (b_node->flag & NODE_MUTED) { + node = new MuteNode(b_node); return node; } + if (fast) { + if (b_node->type == CMP_NODE_BLUR || + b_node->type == CMP_NODE_VECBLUR || + b_node->type == CMP_NODE_BILATERALBLUR || + b_node->type == CMP_NODE_DEFOCUS || + b_node->type == CMP_NODE_BOKEHBLUR || + b_node->type == CMP_NODE_GLARE || + b_node->type == CMP_NODE_DBLUR || + b_node->type == CMP_NODE_MOVIEDISTORTION || + b_node->type == CMP_NODE_LENSDIST || + b_node->type == CMP_NODE_DOUBLEEDGEMASK || + b_node->type == CMP_NODE_DILATEERODE) + { + return new MuteNode(b_node); + } + } - switch (bNode->type) { + switch (b_node->type) { case CMP_NODE_COMPOSITE: - node = new CompositorNode(bNode); + node = new CompositorNode(b_node); break; case CMP_NODE_R_LAYERS: - node = new RenderLayersNode(bNode); + node = new RenderLayersNode(b_node); break; case CMP_NODE_TEXTURE: - node = new TextureNode(bNode); + node = new TextureNode(b_node); break; case CMP_NODE_RGBTOBW: - node = new ColourToBWNode(bNode); + node = new ColorToBWNode(b_node); break; case CMP_NODE_MIX_RGB: - node = new MixNode(bNode); + node = new MixNode(b_node); break; case CMP_NODE_TRANSLATE: - node = new TranslateNode(bNode); + node = new TranslateNode(b_node); break; case CMP_NODE_SCALE: - node = new ScaleNode(bNode); + node = new ScaleNode(b_node); break; case CMP_NODE_ROTATE: - node = new RotateNode(bNode); + node = new RotateNode(b_node); break; case CMP_NODE_FLIP: - node = new FlipNode(bNode); + node = new FlipNode(b_node); break; case CMP_NODE_FILTER: - node = new FilterNode(bNode); + node = new FilterNode(b_node); break; case CMP_NODE_ID_MASK: - node = new IDMaskNode(bNode); + node = new IDMaskNode(b_node); break; case CMP_NODE_BRIGHTCONTRAST: - node = new BrightnessNode(bNode); + node = new BrightnessNode(b_node); break; case CMP_NODE_SEPRGBA: - node = new SeparateRGBANode(bNode); + node = new SeparateRGBANode(b_node); break; case CMP_NODE_COMBRGBA: - node = new CombineRGBANode(bNode); + node = new CombineRGBANode(b_node); break; case CMP_NODE_SEPHSVA: - node = new SeparateHSVANode(bNode); + node = new SeparateHSVANode(b_node); break; case CMP_NODE_COMBHSVA: - node = new CombineHSVANode(bNode); + node = new CombineHSVANode(b_node); break; case CMP_NODE_SEPYUVA: - node = new SeparateYUVANode(bNode); + node = new SeparateYUVANode(b_node); break; case CMP_NODE_COMBYUVA: - node = new CombineYUVANode(bNode); + node = new CombineYUVANode(b_node); break; case CMP_NODE_SEPYCCA: - node = new SeparateYCCANode(bNode); + node = new SeparateYCCANode(b_node); break; case CMP_NODE_COMBYCCA: - node = new CombineYCCANode(bNode); + node = new CombineYCCANode(b_node); break; case CMP_NODE_ALPHAOVER: - node = new AlphaOverNode(bNode); + node = new AlphaOverNode(b_node); break; case CMP_NODE_COLORBALANCE: - node = new ColorBalanceNode(bNode); + node = new ColorBalanceNode(b_node); break; case CMP_NODE_VIEWER: - node = new ViewerNode(bNode); + node = new ViewerNode(b_node); break; case CMP_NODE_SPLITVIEWER: - node = new SplitViewerNode(bNode); + node = new SplitViewerNode(b_node); break; case CMP_NODE_INVERT: - node = new InvertNode(bNode); + node = new InvertNode(b_node); break; case NODE_GROUP: - node = new GroupNode(bNode); + node = new GroupNode(b_node); break; case CMP_NODE_NORMAL: - node = new NormalNode(bNode); + node = new NormalNode(b_node); break; case CMP_NODE_NORMALIZE: - node = new NormalizeNode(bNode); + node = new NormalizeNode(b_node); break; case CMP_NODE_IMAGE: - node = new ImageNode(bNode); + node = new ImageNode(b_node); break; case CMP_NODE_SETALPHA: - node = new SetAlphaNode(bNode); + node = new SetAlphaNode(b_node); break; case CMP_NODE_PREMULKEY: - node = new ConvertAlphaNode(bNode); + node = new ConvertAlphaNode(b_node); break; case CMP_NODE_MATH: - node = new MathNode(bNode); + node = new MathNode(b_node); break; case CMP_NODE_HUE_SAT: - node = new HueSaturationValueNode(bNode); + node = new HueSaturationValueNode(b_node); break; case CMP_NODE_COLORCORRECTION: - node = new ColorCorrectionNode(bNode); + node = new ColorCorrectionNode(b_node); break; case CMP_NODE_MASK_BOX: - node = new BoxMaskNode(bNode); + node = new BoxMaskNode(b_node); break; case CMP_NODE_MASK_ELLIPSE: - node = new EllipseMaskNode(bNode); + node = new EllipseMaskNode(b_node); break; case CMP_NODE_GAMMA: - node = new GammaNode(bNode); + node = new GammaNode(b_node); break; case CMP_NODE_CURVE_RGB: - node = new ColorCurveNode(bNode); + node = new ColorCurveNode(b_node); break; case CMP_NODE_CURVE_VEC: - node = new VectorCurveNode(bNode); + node = new VectorCurveNode(b_node); break; case CMP_NODE_HUECORRECT: - node = new HueSaturationValueCorrectNode(bNode); + node = new HueSaturationValueCorrectNode(b_node); break; case CMP_NODE_MAP_UV: - node = new MapUVNode(bNode); + node = new MapUVNode(b_node); break; case CMP_NODE_DISPLACE: - node = new DisplaceNode(bNode); + node = new DisplaceNode(b_node); break; case CMP_NODE_VALTORGB: - node = new ColorRampNode(bNode); + node = new ColorRampNode(b_node); break; case CMP_NODE_DIFF_MATTE: - node = new DifferenceMatteNode(bNode); + node = new DifferenceMatteNode(b_node); break; case CMP_NODE_LUMA_MATTE: - node = new LuminanceMatteNode(bNode); + node = new LuminanceMatteNode(b_node); break; case CMP_NODE_DIST_MATTE: - node = new DistanceMatteNode(bNode); + node = new DistanceMatteNode(b_node); break; case CMP_NODE_CHROMA_MATTE: - node = new ChromaMatteNode(bNode); + node = new ChromaMatteNode(b_node); break; case CMP_NODE_COLOR_MATTE: - node = new ColorMatteNode(bNode); + node = new ColorMatteNode(b_node); break; case CMP_NODE_CHANNEL_MATTE: - node = new ChannelMatteNode(bNode); + node = new ChannelMatteNode(b_node); break; case CMP_NODE_BLUR: - node = new BlurNode(bNode); + node = new BlurNode(b_node); break; case CMP_NODE_BOKEHIMAGE: - node = new BokehImageNode(bNode); + node = new BokehImageNode(b_node); break; case CMP_NODE_BOKEHBLUR: - node = new BokehBlurNode(bNode); + node = new BokehBlurNode(b_node); break; case CMP_NODE_DILATEERODE: - node = new DilateErodeNode(bNode); + node = new DilateErodeNode(b_node); break; case CMP_NODE_LENSDIST: - node = new LensDistortionNode(bNode); + node = new LensDistortionNode(b_node); break; case CMP_NODE_RGB: - node = new ColorNode(bNode); + node = new ColorNode(b_node); break; case CMP_NODE_VALUE: - node = new ValueNode(bNode); + node = new ValueNode(b_node); break; case CMP_NODE_TIME: - node = new TimeNode(bNode); + node = new TimeNode(b_node); break; case CMP_NODE_DBLUR: - node = new DirectionalBlurNode(bNode); + node = new DirectionalBlurNode(b_node); break; case CMP_NODE_ZCOMBINE: - node = new ZCombineNode(bNode); + node = new ZCombineNode(b_node); break; case CMP_NODE_TONEMAP: - node = new TonemapNode(bNode); + node = new TonemapNode(b_node); break; case CMP_NODE_SWITCH: - node = new SwitchNode(bNode); + node = new SwitchNode(b_node); break; case CMP_NODE_GLARE: - node = new GlareNode(bNode); + node = new GlareNode(b_node); break; case CMP_NODE_MOVIECLIP: - node = new MovieClipNode(bNode); + node = new MovieClipNode(b_node); break; case CMP_NODE_COLOR_SPILL: - node = new ColorSpillNode(bNode); + node = new ColorSpillNode(b_node); break; case CMP_NODE_OUTPUT_FILE: - node = new OutputFileNode(bNode); + node = new OutputFileNode(b_node); break; case CMP_NODE_MAP_VALUE: - node = new MapValueNode(bNode); + node = new MapValueNode(b_node); break; case CMP_NODE_TRANSFORM: - node = new TransformNode(bNode); + node = new TransformNode(b_node); break; case CMP_NODE_STABILIZE2D: - node = new Stabilize2dNode(bNode); + node = new Stabilize2dNode(b_node); break; case CMP_NODE_BILATERALBLUR: - node = new BilateralBlurNode(bNode); + node = new BilateralBlurNode(b_node); break; case CMP_NODE_VECBLUR: - node = new VectorBlurNode(bNode); + node = new VectorBlurNode(b_node); break; case CMP_NODE_MOVIEDISTORTION: - node = new MovieDistortionNode(bNode); + node = new MovieDistortionNode(b_node); break; case CMP_NODE_VIEW_LEVELS: - node = new ViewLevelsNode(bNode); + node = new ViewLevelsNode(b_node); break; case CMP_NODE_DEFOCUS: - node = new DefocusNode(bNode); + node = new DefocusNode(b_node); break; case CMP_NODE_DOUBLEEDGEMASK: - node = new DoubleEdgeMaskNode(bNode); + node = new DoubleEdgeMaskNode(b_node); break; case CMP_NODE_CROP: - node = new CropNode(bNode); + node = new CropNode(b_node); break; case CMP_NODE_MASK: - node = new MaskNode(bNode); + node = new MaskNode(b_node); break; case CMP_NODE_KEYINGSCREEN: - node = new KeyingScreenNode(bNode); + node = new KeyingScreenNode(b_node); break; case CMP_NODE_KEYING: - node = new KeyingNode(bNode); + node = new KeyingNode(b_node); break; /* not inplemented yet */ default: - node = new MuteNode(bNode); + node = new MuteNode(b_node); break; } return node; @@ -376,13 +392,13 @@ void Converter::convertDataType(SocketConnection *connection, ExecutionSystem *s DataType toDatatype = inputSocket->getDataType(); NodeOperation *converter = NULL; if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_COLOR) { - converter = new ConvertValueToColourProg(); + converter = new ConvertValueToColorProg(); } else if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_VECTOR) { converter = new ConvertValueToVectorOperation(); } else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VALUE) { - converter = new ConvertColourToValueProg(); + converter = new ConvertColorToValueProg(); } else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VECTOR) { converter = new ConvertColorToVectorOperation(); diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h index d01556cc79c..15bda0839fa 100644 --- a/source/blender/compositor/intern/COM_Converter.h +++ b/source/blender/compositor/intern/COM_Converter.h @@ -42,7 +42,7 @@ public: * @see Node * @see MuteNode */ - static Node *convert(bNode *bNode); + static Node *convert(bNode *b_node, bool fast); /** * @brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type. @@ -60,11 +60,15 @@ public: * * @note Conversion logic is implemented in this method * @see InputSocketResizeMode for the possible conversions. - + * * @param connection the SocketConnection what needs conversion * @param system the ExecutionSystem to add the conversion to. * @see SocketConnection - a link between two sockets */ static void convertResolution(SocketConnection *connection, ExecutionSystem *system); + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:Converter") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_Device.h b/source/blender/compositor/intern/COM_Device.h index 08fdb5bb578..e33a2a4288f 100644 --- a/source/blender/compositor/intern/COM_Device.h +++ b/source/blender/compositor/intern/COM_Device.h @@ -23,11 +23,7 @@ #ifndef _COM_Device_h #define _COM_Device_h -#include "COM_ExecutionSystem.h" #include "COM_WorkPackage.h" -#include "COM_NodeOperation.h" -#include "BLI_rect.h" -#include "COM_MemoryBuffer.h" /** * @brief Abstract class for device implementations to be used by the Compositor. @@ -52,6 +48,9 @@ public: */ virtual void execute(WorkPackage *work) = 0; +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:Device") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index 4dfb9c7d26c..e437b069e33 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -27,6 +27,8 @@ #include "BLI_math.h" #include "PIL_time.h" +#include "WM_api.h" +#include "WM_types.h" #include "COM_ExecutionGroup.h" #include "COM_InputSocket.h" @@ -43,20 +45,20 @@ ExecutionGroup::ExecutionGroup() { - this->isOutput = false; - this->complex = false; - this->chunkExecutionStates = NULL; - this->bTree = NULL; - this->height = 0; - this->width = 0; - this->cachedMaxReadBufferOffset = 0; - this->numberOfXChunks = 0; - this->numberOfYChunks = 0; - this->numberOfChunks = 0; - this->initialized = false; - this->openCL = false; - this->singleThreaded = false; - this->chunksFinished = 0; + this->m_isOutput = false; + this->m_complex = false; + this->m_chunkExecutionStates = NULL; + this->m_bTree = NULL; + this->m_height = 0; + this->m_width = 0; + this->m_cachedMaxReadBufferOffset = 0; + this->m_numberOfXChunks = 0; + this->m_numberOfYChunks = 0; + this->m_numberOfChunks = 0; + this->m_initialized = false; + this->m_openCL = false; + this->m_singleThreaded = false; + this->m_chunksFinished = 0; } CompositorPriority ExecutionGroup::getRenderPriotrity() @@ -66,7 +68,7 @@ CompositorPriority ExecutionGroup::getRenderPriotrity() bool ExecutionGroup::containsOperation(NodeOperation *operation) { - for (vector<NodeOperation *>::const_iterator iterator = this->operations.begin(); iterator != this->operations.end(); ++iterator) { + for (vector<NodeOperation *>::const_iterator iterator = this->m_operations.begin(); iterator != this->m_operations.end(); ++iterator) { NodeOperation *inListOperation = *iterator; if (inListOperation == operation) { return true; @@ -77,12 +79,12 @@ bool ExecutionGroup::containsOperation(NodeOperation *operation) const bool ExecutionGroup::isComplex() const { - return this->complex; + return this->m_complex; } bool ExecutionGroup::canContainOperation(NodeOperation *operation) { - if (!this->initialized) { return true; } + if (!this->m_initialized) { return true; } if (operation->isReadBufferOperation()) { return true; } if (operation->isWriteBufferOperation()) { return false; } if (operation->isSetOperation()) { return true; } @@ -100,12 +102,12 @@ void ExecutionGroup::addOperation(ExecutionSystem *system, NodeOperation *operat if (containsOperation(operation)) return; if (canContainOperation(operation)) { if (!operation->isBufferOperation()) { - this->complex = operation->isComplex(); - this->openCL = operation->isOpenCL(); - this->singleThreaded = operation->isSingleThreaded(); - this->initialized = true; + this->m_complex = operation->isComplex(); + this->m_openCL = operation->isOpenCL(); + this->m_singleThreaded = operation->isSingleThreaded(); + this->m_initialized = true; } - this->operations.push_back(operation); + this->m_operations.push_back(operation); if (operation->isReadBufferOperation()) { ReadBufferOperation *readOperation = (ReadBufferOperation *)operation; WriteBufferOperation *writeOperation = readOperation->getMemoryProxy()->getWriteBufferOperation(); @@ -137,52 +139,52 @@ void ExecutionGroup::addOperation(ExecutionSystem *system, NodeOperation *operat NodeOperation *ExecutionGroup::getOutputNodeOperation() const { - return this->operations[0]; // the first operation of the group is always the output operation. + return this->m_operations[0]; // the first operation of the group is always the output operation. } void ExecutionGroup::initExecution() { - if (this->chunkExecutionStates != NULL) { - delete[] this->chunkExecutionStates; + if (this->m_chunkExecutionStates != NULL) { + delete[] this->m_chunkExecutionStates; } unsigned int index; determineNumberOfChunks(); - this->chunkExecutionStates = NULL; - if (this->numberOfChunks != 0) { - this->chunkExecutionStates = new ChunkExecutionState[numberOfChunks]; - for (index = 0; index < numberOfChunks; index++) { - this->chunkExecutionStates[index] = COM_ES_NOT_SCHEDULED; + this->m_chunkExecutionStates = NULL; + if (this->m_numberOfChunks != 0) { + this->m_chunkExecutionStates = new ChunkExecutionState[this->m_numberOfChunks]; + for (index = 0; index < this->m_numberOfChunks; index++) { + this->m_chunkExecutionStates[index] = COM_ES_NOT_SCHEDULED; } } unsigned int maxNumber = 0; - for (index = 0; index < this->operations.size(); index++) { - NodeOperation *operation = this->operations[index]; + for (index = 0; index < this->m_operations.size(); index++) { + NodeOperation *operation = this->m_operations[index]; if (operation->isReadBufferOperation()) { ReadBufferOperation *readOperation = (ReadBufferOperation *)operation; - this->cachedReadOperations.push_back(readOperation); + this->m_cachedReadOperations.push_back(readOperation); maxNumber = max(maxNumber, readOperation->getOffset()); } } maxNumber++; - this->cachedMaxReadBufferOffset = maxNumber; + this->m_cachedMaxReadBufferOffset = maxNumber; } void ExecutionGroup::deinitExecution() { - if (this->chunkExecutionStates != NULL) { - delete[] this->chunkExecutionStates; - this->chunkExecutionStates = NULL; - } - this->numberOfChunks = 0; - this->numberOfXChunks = 0; - this->numberOfYChunks = 0; - this->cachedReadOperations.clear(); - this->bTree = NULL; + if (this->m_chunkExecutionStates != NULL) { + delete[] this->m_chunkExecutionStates; + this->m_chunkExecutionStates = NULL; + } + this->m_numberOfChunks = 0; + this->m_numberOfXChunks = 0; + this->m_numberOfYChunks = 0; + this->m_cachedReadOperations.clear(); + this->m_bTree = NULL; } void ExecutionGroup::determineResolution(unsigned int resolution[]) { @@ -194,16 +196,16 @@ void ExecutionGroup::determineResolution(unsigned int resolution[]) void ExecutionGroup::determineNumberOfChunks() { - if (singleThreaded) { - this->numberOfXChunks = 1; - this->numberOfYChunks = 1; - this->numberOfChunks = 1; + if (this->m_singleThreaded) { + this->m_numberOfXChunks = 1; + this->m_numberOfYChunks = 1; + this->m_numberOfChunks = 1; } else { - const float chunkSizef = this->chunkSize; - this->numberOfXChunks = ceil(this->width / chunkSizef); - this->numberOfYChunks = ceil(this->height / chunkSizef); - this->numberOfChunks = this->numberOfXChunks * this->numberOfYChunks; + const float chunkSizef = this->m_chunkSize; + this->m_numberOfXChunks = ceil(this->m_width / chunkSizef); + this->m_numberOfYChunks = ceil(this->m_height / chunkSizef); + this->m_numberOfChunks = this->m_numberOfXChunks * this->m_numberOfYChunks; } } @@ -214,17 +216,17 @@ void ExecutionGroup::execute(ExecutionSystem *graph) { CompositorContext& context = graph->getContext(); const bNodeTree *bTree = context.getbNodeTree(); - if (this->width == 0 || this->height == 0) {return; } /// @note: break out... no pixels to calculate. + if (this->m_width == 0 || this->m_height == 0) {return; } /// @note: break out... no pixels to calculate. if (bTree->test_break && bTree->test_break(bTree->tbh)) {return; } /// @note: early break out for blur and preview nodes - if (this->numberOfChunks == 0) {return; } /// @note: early break out + if (this->m_numberOfChunks == 0) {return; } /// @note: early break out unsigned int chunkNumber; - this->chunksFinished = 0; - this->bTree = bTree; + this->m_chunksFinished = 0; + this->m_bTree = bTree; unsigned int index; - unsigned int *chunkOrder = new unsigned int[this->numberOfChunks]; + unsigned int *chunkOrder = new unsigned int[this->m_numberOfChunks]; - for (chunkNumber = 0; chunkNumber < this->numberOfChunks; chunkNumber++) { + for (chunkNumber = 0; chunkNumber < this->m_numberOfChunks; chunkNumber++) { chunkOrder[chunkNumber] = chunkNumber; } NodeOperation *operation = this->getOutputNodeOperation(); @@ -241,9 +243,9 @@ void ExecutionGroup::execute(ExecutionSystem *graph) switch (chunkorder) { case COM_TO_RANDOM: - for (index = 0; index < 2 * numberOfChunks; index++) { - int index1 = rand() % numberOfChunks; - int index2 = rand() % numberOfChunks; + for (index = 0; index < 2 * this->m_numberOfChunks; index++) { + int index1 = rand() % this->m_numberOfChunks; + int index2 = rand() % this->m_numberOfChunks; int s = chunkOrder[index1]; chunkOrder[index1] = chunkOrder[index2]; chunkOrder[index2] = s; @@ -252,10 +254,10 @@ void ExecutionGroup::execute(ExecutionSystem *graph) case COM_TO_CENTER_OUT: { ChunkOrderHotspot **hotspots = new ChunkOrderHotspot *[1]; - hotspots[0] = new ChunkOrderHotspot(this->width * centerX, this->height * centerY, 0.0f); + hotspots[0] = new ChunkOrderHotspot(this->m_width * centerX, this->m_height * centerY, 0.0f); rcti rect; - ChunkOrder *chunkOrders = new ChunkOrder[this->numberOfChunks]; - for (index = 0; index < this->numberOfChunks; index++) { + ChunkOrder *chunkOrders = new ChunkOrder[this->m_numberOfChunks]; + for (index = 0; index < this->m_numberOfChunks; index++) { determineChunkRect(&rect, index); chunkOrders[index].setChunkNumber(index); chunkOrders[index].setX(rect.xmin); @@ -263,8 +265,8 @@ void ExecutionGroup::execute(ExecutionSystem *graph) chunkOrders[index].determineDistance(hotspots, 1); } - sort(&chunkOrders[0], &chunkOrders[numberOfChunks - 1]); - for (index = 0; index < numberOfChunks; index++) { + sort(&chunkOrders[0], &chunkOrders[this->m_numberOfChunks - 1]); + for (index = 0; index < this->m_numberOfChunks; index++) { chunkOrder[index] = chunkOrders[index].getChunkNumber(); } @@ -276,14 +278,14 @@ void ExecutionGroup::execute(ExecutionSystem *graph) case COM_TO_RULE_OF_THIRDS: { ChunkOrderHotspot **hotspots = new ChunkOrderHotspot *[9]; - unsigned int tx = this->width / 6; - unsigned int ty = this->height / 6; - unsigned int mx = this->width / 2; - unsigned int my = this->height / 2; + unsigned int tx = this->m_width / 6; + unsigned int ty = this->m_height / 6; + unsigned int mx = this->m_width / 2; + unsigned int my = this->m_height / 2; unsigned int bx = mx + 2 * tx; unsigned int by = my + 2 * ty; - float addition = numberOfChunks / COM_RULE_OF_THIRDS_DIVIDER; + float addition = this->m_numberOfChunks / COM_RULE_OF_THIRDS_DIVIDER; hotspots[0] = new ChunkOrderHotspot(mx, my, addition * 0); hotspots[1] = new ChunkOrderHotspot(tx, my, addition * 1); hotspots[2] = new ChunkOrderHotspot(bx, my, addition * 2); @@ -294,8 +296,8 @@ void ExecutionGroup::execute(ExecutionSystem *graph) hotspots[7] = new ChunkOrderHotspot(mx, ty, addition * 7); hotspots[8] = new ChunkOrderHotspot(mx, by, addition * 8); rcti rect; - ChunkOrder *chunkOrders = new ChunkOrder[this->numberOfChunks]; - for (index = 0; index < this->numberOfChunks; index++) { + ChunkOrder *chunkOrders = new ChunkOrder[this->m_numberOfChunks]; + for (index = 0; index < this->m_numberOfChunks; index++) { determineChunkRect(&rect, index); chunkOrders[index].setChunkNumber(index); chunkOrders[index].setX(rect.xmin); @@ -303,9 +305,9 @@ void ExecutionGroup::execute(ExecutionSystem *graph) chunkOrders[index].determineDistance(hotspots, 9); } - sort(&chunkOrders[0], &chunkOrders[numberOfChunks]); + sort(&chunkOrders[0], &chunkOrders[this->m_numberOfChunks]); - for (index = 0; index < numberOfChunks; index++) { + for (index = 0; index < this->m_numberOfChunks; index++) { chunkOrder[index] = chunkOrders[index].getChunkNumber(); } @@ -333,21 +335,22 @@ void ExecutionGroup::execute(ExecutionSystem *graph) const int maxNumberEvaluated = BLI_system_thread_count() * 2; while (!finished && !breaked) { - unsigned int index; bool startEvaluated = false; finished = true; int numberEvaluated = 0; - for (index = startIndex; index < numberOfChunks && numberEvaluated < maxNumberEvaluated; index++) { - int chunkNumber = chunkOrder[index]; - int yChunk = chunkNumber / this->numberOfXChunks; - int xChunk = chunkNumber - (yChunk * this->numberOfXChunks); - const ChunkExecutionState state = this->chunkExecutionStates[chunkNumber]; + for (index = startIndex; index < this->m_numberOfChunks && numberEvaluated < maxNumberEvaluated; index++) { + chunkNumber = chunkOrder[index]; + int yChunk = chunkNumber / this->m_numberOfXChunks; + int xChunk = chunkNumber - (yChunk * this->m_numberOfXChunks); + const ChunkExecutionState state = this->m_chunkExecutionStates[chunkNumber]; if (state == COM_ES_NOT_SCHEDULED) { scheduleChunkWhenPossible(graph, xChunk, yChunk); finished = false; startEvaluated = true; numberEvaluated++; + + WM_main_add_notifier(NC_WINDOW | ND_DRAW, NULL); } else if (state == COM_ES_SCHEDULED) { finished = false; @@ -375,12 +378,12 @@ MemoryBuffer **ExecutionGroup::getInputBuffersCPU() unsigned int index; this->determineDependingMemoryProxies(&memoryproxies); - MemoryBuffer **memoryBuffers = new MemoryBuffer *[this->cachedMaxReadBufferOffset]; - for (index = 0; index < this->cachedMaxReadBufferOffset; index++) { + MemoryBuffer **memoryBuffers = new MemoryBuffer *[this->m_cachedMaxReadBufferOffset]; + for (index = 0; index < this->m_cachedMaxReadBufferOffset; index++) { memoryBuffers[index] = NULL; } - for (index = 0; index < this->cachedReadOperations.size(); index++) { - ReadBufferOperation *readOperation = (ReadBufferOperation *)this->cachedReadOperations[index]; + for (index = 0; index < this->m_cachedReadOperations.size(); index++) { + ReadBufferOperation *readOperation = (ReadBufferOperation *)this->m_cachedReadOperations[index]; memoryBuffers[readOperation->getOffset()] = readOperation->getMemoryProxy()->getBuffer(); } return memoryBuffers; @@ -394,13 +397,13 @@ MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber) determineChunkRect(&rect, chunkNumber); this->determineDependingMemoryProxies(&memoryproxies); - MemoryBuffer **memoryBuffers = new MemoryBuffer *[this->cachedMaxReadBufferOffset]; - for (index = 0; index < this->cachedMaxReadBufferOffset; index++) { + MemoryBuffer **memoryBuffers = new MemoryBuffer *[this->m_cachedMaxReadBufferOffset]; + for (index = 0; index < this->m_cachedMaxReadBufferOffset; index++) { memoryBuffers[index] = NULL; } rcti output; - for (index = 0; index < this->cachedReadOperations.size(); index++) { - ReadBufferOperation *readOperation = (ReadBufferOperation *)this->cachedReadOperations[index]; + for (index = 0; index < this->m_cachedReadOperations.size(); index++) { + ReadBufferOperation *readOperation = (ReadBufferOperation *)this->m_cachedReadOperations[index]; MemoryProxy *memoryProxy = readOperation->getMemoryProxy(); this->determineDependingAreaOfInterest(&rect, readOperation, &output); MemoryBuffer *memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer(memoryProxy, &output); @@ -419,12 +422,12 @@ MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *mem void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers) { - if (this->chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED) - this->chunkExecutionStates[chunkNumber] = COM_ES_EXECUTED; + if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED) + this->m_chunkExecutionStates[chunkNumber] = COM_ES_EXECUTED; - this->chunksFinished++; + this->m_chunksFinished++; if (memoryBuffers) { - for (unsigned int index = 0; index < this->cachedMaxReadBufferOffset; index++) { + for (unsigned int index = 0; index < this->m_cachedMaxReadBufferOffset; index++) { MemoryBuffer *buffer = memoryBuffers[index]; if (buffer) { if (buffer->isTemporarily()) { @@ -435,30 +438,30 @@ void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memo } delete[] memoryBuffers; } - if (bTree) { + if (this->m_bTree) { // status report is only performed for top level Execution Groups. - float progress = chunksFinished; - progress /= numberOfChunks; - bTree->progress(bTree->prh, progress); + float progress = this->m_chunksFinished; + progress /= this->m_numberOfChunks; + this->m_bTree->progress(this->m_bTree->prh, progress); } } inline void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int xChunk, const unsigned int yChunk) const { - if (singleThreaded) { - BLI_init_rcti(rect, 0, this->width, 0, this->height); + if (this->m_singleThreaded) { + BLI_init_rcti(rect, 0, this->m_width, 0, this->m_height); } else { - const unsigned int minx = xChunk * chunkSize; - const unsigned int miny = yChunk * chunkSize; - BLI_init_rcti(rect, minx, min(minx + this->chunkSize, this->width), miny, min(miny + this->chunkSize, this->height)); + const unsigned int minx = xChunk * this->m_chunkSize; + const unsigned int miny = yChunk * this->m_chunkSize; + BLI_init_rcti(rect, minx, min(minx + this->m_chunkSize, this->m_width), miny, min(miny + this->m_chunkSize, this->m_height)); } } void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int chunkNumber) const { - const unsigned int yChunk = chunkNumber / numberOfXChunks; - const unsigned int xChunk = chunkNumber - (yChunk * numberOfXChunks); + const unsigned int yChunk = chunkNumber / this->m_numberOfXChunks; + const unsigned int xChunk = chunkNumber - (yChunk * this->m_numberOfXChunks); determineChunkRect(rect, xChunk, yChunk); } @@ -477,23 +480,27 @@ MemoryBuffer *ExecutionGroup::allocateOutputBuffer(int chunkNumber, rcti *rect) bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area) { - if (singleThreaded) { + if (this->m_singleThreaded) { return scheduleChunkWhenPossible(graph, 0, 0); } // find all chunks inside the rect // determine minxchunk, minychunk, maxxchunk, maxychunk where x and y are chunknumbers - float chunkSizef = this->chunkSize; + float chunkSizef = this->m_chunkSize; int indexx, indexy; - const int minxchunk = floor(area->xmin / chunkSizef); - const int maxxchunk = ceil((area->xmax - 1) / chunkSizef); - const int minychunk = floor(area->ymin / chunkSizef); - const int maxychunk = ceil((area->ymax - 1) / chunkSizef); + int minxchunk = floor(area->xmin / chunkSizef); + int maxxchunk = ceil((area->xmax - 1) / chunkSizef); + int minychunk = floor(area->ymin / chunkSizef); + int maxychunk = ceil((area->ymax - 1) / chunkSizef); + minxchunk = MAX2(minxchunk, 0); + minychunk = MAX2(minychunk, 0); + maxxchunk = MIN2(maxxchunk, this->m_numberOfXChunks); + maxychunk = MIN2(maxychunk, this->m_numberOfYChunks); bool result = true; - for (indexx = max(minxchunk, 0); indexx < maxxchunk; indexx++) { - for (indexy = max(minychunk, 0); indexy < maxychunk; indexy++) { + for (indexx = minxchunk; indexx < maxxchunk; indexx++) { + for (indexy = minychunk; indexy < maxychunk; indexy++) { if (!scheduleChunkWhenPossible(graph, indexx, indexy)) { result = false; } @@ -505,8 +512,8 @@ bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber) { - if (this->chunkExecutionStates[chunkNumber] == COM_ES_NOT_SCHEDULED) { - this->chunkExecutionStates[chunkNumber] = COM_ES_SCHEDULED; + if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_NOT_SCHEDULED) { + this->m_chunkExecutionStates[chunkNumber] = COM_ES_SCHEDULED; WorkScheduler::schedule(this, chunkNumber); return true; } @@ -515,20 +522,20 @@ bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber) bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, int xChunk, int yChunk) { - if (xChunk < 0 || xChunk >= (int)this->numberOfXChunks) { + if (xChunk < 0 || xChunk >= (int)this->m_numberOfXChunks) { return true; } - if (yChunk < 0 || yChunk >= (int)this->numberOfYChunks) { + if (yChunk < 0 || yChunk >= (int)this->m_numberOfYChunks) { return true; } - int chunkNumber = yChunk * this->numberOfXChunks + xChunk; + int chunkNumber = yChunk * this->m_numberOfXChunks + xChunk; // chunk is already executed - if (this->chunkExecutionStates[chunkNumber] == COM_ES_EXECUTED) { + if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_EXECUTED) { return true; } // chunk is scheduled, but not executed - if (this->chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED) { + if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED) { return false; } @@ -542,8 +549,8 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, int xChun bool canBeExecuted = true; rcti area; - for (index = 0; index < cachedReadOperations.size(); index++) { - ReadBufferOperation *readOperation = (ReadBufferOperation *)cachedReadOperations[index]; + for (index = 0; index < this->m_cachedReadOperations.size(); index++) { + ReadBufferOperation *readOperation = (ReadBufferOperation *)this->m_cachedReadOperations[index]; BLI_init_rcti(&area, 0, 0, 0, 0); MemoryProxy *memoryProxy = memoryProxies[index]; determineDependingAreaOfInterest(&rect, readOperation, &area); @@ -574,13 +581,13 @@ void ExecutionGroup::determineDependingAreaOfInterest(rcti *input, ReadBufferOpe void ExecutionGroup::determineDependingMemoryProxies(vector<MemoryProxy *> *memoryProxies) { unsigned int index; - for (index = 0; index < this->cachedReadOperations.size(); index++) { - ReadBufferOperation *readOperation = (ReadBufferOperation *) this->cachedReadOperations[index]; + for (index = 0; index < this->m_cachedReadOperations.size(); index++) { + ReadBufferOperation *readOperation = (ReadBufferOperation *) this->m_cachedReadOperations[index]; memoryProxies->push_back(readOperation->getMemoryProxy()); } } bool ExecutionGroup::isOpenCL() { - return this->openCL; + return this->m_openCL; } diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h index 541b3e4866d..43c2bfac52e 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.h +++ b/source/blender/compositor/intern/COM_ExecutionGroup.h @@ -67,81 +67,81 @@ private: /** * @brief list of operations in this ExecutionGroup */ - vector<NodeOperation *> operations; + vector<NodeOperation *> m_operations; /** * @brief is this ExecutionGroup an input ExecutionGroup * an input execution group is a group that is at the end of the calculation (the output is important for the user) */ - int isOutput; + int m_isOutput; /** * @brief Width of the output */ - unsigned int width; + unsigned int m_width; /** * @brief Height of the output */ - unsigned int height; + unsigned int m_height; /** * @brief size of a single chunk, being Width or of height * a chunk is always a square, except at the edges of the MemoryBuffer */ - unsigned int chunkSize; + unsigned int m_chunkSize; /** * @brief number of chunks in the x-axis */ - unsigned int numberOfXChunks; + unsigned int m_numberOfXChunks; /** * @brief number of chunks in the y-axis */ - unsigned int numberOfYChunks; + unsigned int m_numberOfYChunks; /** * @brief total number of chunks */ - unsigned int numberOfChunks; + unsigned int m_numberOfChunks; /** * @brief contains this ExecutionGroup a complex NodeOperation. */ - bool complex; + bool m_complex; /** * @brief can this ExecutionGroup be scheduled on an OpenCLDevice */ - bool openCL; + bool m_openCL; /** * @brief Is this Execution group SingleThreaded */ - bool singleThreaded; + bool m_singleThreaded; /** * @brief what is the maximum number field of all ReadBufferOperation in this ExecutionGroup. * @note this is used to construct the MemoryBuffers that will be passed during execution. */ - unsigned int cachedMaxReadBufferOffset; + unsigned int m_cachedMaxReadBufferOffset; /** * @brief a cached vector of all read operations in the execution group. */ - vector<NodeOperation *> cachedReadOperations; + vector<NodeOperation *> m_cachedReadOperations; /** * @brief reference to the original bNodeTree, this field is only set for the 'top' execution group. * @note can only be used to call the callbacks for progress, status and break */ - const bNodeTree *bTree; + const bNodeTree *m_bTree; /** * @brief total number of chunks that have been calculated for this ExecutionGroup */ - unsigned int chunksFinished; + unsigned int m_chunksFinished; /** * @brief the chunkExecutionStates holds per chunk the execution state. this state can be @@ -149,7 +149,7 @@ private: * - COM_ES_SCHEDULED: scheduled * - COM_ES_EXECUTED: executed */ - ChunkExecutionState *chunkExecutionStates; + ChunkExecutionState *m_chunkExecutionStates; /** * @brief indicator when this ExecutionGroup has valid NodeOperations in its vector for Execution @@ -160,7 +160,7 @@ private: * @see complex * @see openCL */ - bool initialized; + bool m_initialized; // methods /** @@ -258,13 +258,13 @@ public: * @note ViewerOperation, CompositeOperation, PreviewOperation. * @see NodeOperation.isOutputOperation */ - const int isOutputExecutionGroup() const { return this->isOutput; } + const int isOutputExecutionGroup() const { return this->m_isOutput; } /** * @brief set whether this ExecutionGroup is an output * @param isOutput */ - void setOutputExecutionGroup(int isOutput) { this->isOutput = isOutput; } + void setOutputExecutionGroup(int isOutput) { this->m_isOutput = isOutput; } /** * @brief determine the resolution of this ExecutionGroup @@ -276,17 +276,17 @@ public: * @brief set the resolution of this executiongroup * @param resolution */ - void setResolution(unsigned int resolution[]) { this->width = resolution[0]; this->height = resolution[1]; } + void setResolution(unsigned int resolution[]) { this->m_width = resolution[0]; this->m_height = resolution[1]; } /** * @brief get the width of this execution group */ - const unsigned int getWidth() { return this->width; } + const unsigned int getWidth() { return this->m_width; } /** * @brief get the height of this execution group */ - const unsigned int getHeight() { return this->height; } + const unsigned int getHeight() { return this->m_height; } /** * @brief does this ExecutionGroup contains a complex NodeOperation @@ -387,14 +387,17 @@ public: */ bool isOpenCL(); - void setChunksize(int chunksize) { this->chunkSize = chunksize; } + void setChunksize(int chunksize) { this->m_chunkSize = chunksize; } /** * @brief get the Render priority of this ExecutionGroup * @see ExecutionSystem.execute */ CompositorPriority getRenderPriotrity(); - + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionGroup") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index b644f405f00..ff841092848 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -23,7 +23,6 @@ #include "COM_ExecutionSystem.h" #include <sstream> -#include <stdio.h> #include "PIL_time.h" #include "BKE_node.h" @@ -41,43 +40,44 @@ #include "BKE_global.h" -ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering) +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + +ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation) { - context.setbNodeTree(editingtree); + this->m_context.setbNodeTree(editingtree); + this->m_context.setFastCalculation(fastcalculation); bNode *gnode; for (gnode = (bNode *)editingtree->nodes.first; gnode; gnode = (bNode *)gnode->next) { if (gnode->type == NODE_GROUP && gnode->typeinfo->group_edit_get(gnode)) { - context.setActivegNode(gnode); + this->m_context.setActivegNode(gnode); break; } } /* initialize the CompositorContext */ if (rendering) { - context.setQuality((CompositorQuality)editingtree->render_quality); + this->m_context.setQuality((CompositorQuality)editingtree->render_quality); } else { - context.setQuality((CompositorQuality)editingtree->edit_quality); + this->m_context.setQuality((CompositorQuality)editingtree->edit_quality); } - context.setRendering(rendering); - context.setHasActiveOpenCLDevices(WorkScheduler::hasGPUDevices() && (editingtree->flag & NTREE_COM_OPENCL)); - - Node *mainOutputNode = NULL; + this->m_context.setRendering(rendering); + this->m_context.setHasActiveOpenCLDevices(WorkScheduler::hasGPUDevices() && (editingtree->flag & NTREE_COM_OPENCL)); - mainOutputNode = ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NULL); + ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NULL); - if (mainOutputNode) { - context.setScene((Scene *)mainOutputNode->getbNode()->id); - this->convertToOperations(); - this->groupOperations(); /* group operations in ExecutionGroups */ - unsigned int index; - unsigned int resolution[2]; - for (index = 0; index < this->groups.size(); index++) { - resolution[0] = 0; - resolution[1] = 0; - ExecutionGroup *executionGroup = groups[index]; - executionGroup->determineResolution(resolution); - } + this->m_context.setRenderData(rd); + this->convertToOperations(); + this->groupOperations(); /* group operations in ExecutionGroups */ + unsigned int index; + unsigned int resolution[2]; + for (index = 0; index < this->m_groups.size(); index++) { + resolution[0] = 0; + resolution[1] = 0; + ExecutionGroup *executionGroup = this->m_groups[index]; + executionGroup->determineResolution(resolution); } #ifdef COM_DEBUG @@ -88,32 +88,32 @@ ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering) ExecutionSystem::~ExecutionSystem() { unsigned int index; - for (index = 0; index < this->connections.size(); index++) { - SocketConnection *connection = this->connections[index]; + for (index = 0; index < this->m_connections.size(); index++) { + SocketConnection *connection = this->m_connections[index]; delete connection; } - this->connections.clear(); - for (index = 0; index < this->nodes.size(); index++) { - Node *node = this->nodes[index]; + this->m_connections.clear(); + for (index = 0; index < this->m_nodes.size(); index++) { + Node *node = this->m_nodes[index]; delete node; } - this->nodes.clear(); - for (index = 0; index < this->operations.size(); index++) { - NodeOperation *operation = this->operations[index]; + this->m_nodes.clear(); + for (index = 0; index < this->m_operations.size(); index++) { + NodeOperation *operation = this->m_operations[index]; delete operation; } - this->operations.clear(); - for (index = 0; index < this->groups.size(); index++) { - ExecutionGroup *group = this->groups[index]; + this->m_operations.clear(); + for (index = 0; index < this->m_groups.size(); index++) { + ExecutionGroup *group = this->m_groups[index]; delete group; } - this->groups.clear(); + this->m_groups.clear(); } void ExecutionSystem::execute() { unsigned int order = 0; - for (vector<NodeOperation *>::iterator iter = this->operations.begin(); iter != operations.end(); ++iter) { + for (vector<NodeOperation *>::iterator iter = this->m_operations.begin(); iter != this->m_operations.end(); ++iter) { NodeBase *node = *iter; NodeOperation *operation = (NodeOperation *) node; if (operation->isReadBufferOperation()) { @@ -124,32 +124,34 @@ void ExecutionSystem::execute() } unsigned int index; - for (index = 0; index < this->operations.size(); index++) { - NodeOperation *operation = this->operations[index]; - operation->setbNodeTree(this->context.getbNodeTree()); + for (index = 0; index < this->m_operations.size(); index++) { + NodeOperation *operation = this->m_operations[index]; + operation->setbNodeTree(this->m_context.getbNodeTree()); operation->initExecution(); } - for (index = 0; index < this->groups.size(); index++) { - ExecutionGroup *executionGroup = this->groups[index]; - executionGroup->setChunksize(context.getChunksize()); + for (index = 0; index < this->m_groups.size(); index++) { + ExecutionGroup *executionGroup = this->m_groups[index]; + executionGroup->setChunksize(this->m_context.getChunksize()); executionGroup->initExecution(); } - WorkScheduler::start(this->context); + WorkScheduler::start(this->m_context); executeGroups(COM_PRIORITY_HIGH); - executeGroups(COM_PRIORITY_MEDIUM); - executeGroups(COM_PRIORITY_LOW); + if (!this->getContext().isFastCalculation()) { + executeGroups(COM_PRIORITY_MEDIUM); + executeGroups(COM_PRIORITY_LOW); + } WorkScheduler::finish(); WorkScheduler::stop(); - for (index = 0; index < this->operations.size(); index++) { - NodeOperation *operation = this->operations[index]; + for (index = 0; index < this->m_operations.size(); index++) { + NodeOperation *operation = this->m_operations[index]; operation->deinitExecution(); } - for (index = 0; index < this->groups.size(); index++) { - ExecutionGroup *executionGroup = this->groups[index]; + for (index = 0; index < this->m_groups.size(); index++) { + ExecutionGroup *executionGroup = this->m_groups[index]; executionGroup->deinitExecution(); } } @@ -168,7 +170,7 @@ void ExecutionSystem::executeGroups(CompositorPriority priority) void ExecutionSystem::addOperation(NodeOperation *operation) { - ExecutionSystemHelper::addOperation(this->operations, operation); + ExecutionSystemHelper::addOperation(this->m_operations, operation); // operation->setBTree } @@ -209,7 +211,6 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation) */ OutputSocket *outputsocket = operation->getOutputSocket(); if (outputsocket->isConnected()) { - int index; WriteBufferOperation *writeOperation; writeOperation = new WriteBufferOperation(); writeOperation->setbNodeTree(this->getContext().getbNodeTree()); @@ -231,13 +232,13 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation) void ExecutionSystem::convertToOperations() { unsigned int index; - for (index = 0; index < this->nodes.size(); index++) { - Node *node = (Node *)this->nodes[index]; - node->convertToOperations(this, &this->context); + for (index = 0; index < this->m_nodes.size(); index++) { + Node *node = (Node *)this->m_nodes[index]; + node->convertToOperations(this, &this->m_context); } - for (index = 0; index < this->connections.size(); index++) { - SocketConnection *connection = this->connections[index]; + for (index = 0; index < this->m_connections.size(); index++) { + SocketConnection *connection = this->m_connections[index]; if (connection->isValid()) { if (connection->getFromSocket()->getDataType() != connection->getToSocket()->getDataType()) { Converter::convertDataType(connection, this); @@ -246,18 +247,18 @@ void ExecutionSystem::convertToOperations() } // determine all resolutions of the operations (Width/Height) - for (index = 0; index < this->operations.size(); index++) { - NodeOperation *operation = this->operations[index]; - if (operation->isOutputOperation(context.isRendering()) && !operation->isPreviewOperation()) { + for (index = 0; index < this->m_operations.size(); index++) { + NodeOperation *operation = this->m_operations[index]; + if (operation->isOutputOperation(this->m_context.isRendering()) && !operation->isPreviewOperation()) { unsigned int resolution[2] = {0, 0}; unsigned int preferredResolution[2] = {0, 0}; operation->determineResolution(resolution, preferredResolution); operation->setResolution(resolution); } } - for (index = 0; index < this->operations.size(); index++) { - NodeOperation *operation = this->operations[index]; - if (operation->isOutputOperation(context.isRendering()) && operation->isPreviewOperation()) { + for (index = 0; index < this->m_operations.size(); index++) { + NodeOperation *operation = this->m_operations[index]; + if (operation->isOutputOperation(this->m_context.isRendering()) && operation->isPreviewOperation()) { unsigned int resolution[2] = {0, 0}; unsigned int preferredResolution[2] = {0, 0}; operation->determineResolution(resolution, preferredResolution); @@ -266,8 +267,8 @@ void ExecutionSystem::convertToOperations() } // add convert resolution operations when needed. - for (index = 0; index < this->connections.size(); index++) { - SocketConnection *connection = this->connections[index]; + for (index = 0; index < this->m_connections.size(); index++) { + SocketConnection *connection = this->m_connections[index]; if (connection->isValid()) { if (connection->needsResolutionConversion()) { Converter::convertResolution(connection, this); @@ -282,13 +283,13 @@ void ExecutionSystem::groupOperations() NodeOperation *operation; unsigned int index; // surround complex operations with ReadBufferOperation and WriteBufferOperation - for (index = 0; index < this->operations.size(); index++) { - operation = this->operations[index]; + for (index = 0; index < this->m_operations.size(); index++) { + operation = this->m_operations[index]; if (operation->isComplex()) { this->addReadWriteBufferOperations(operation); } } - ExecutionSystemHelper::findOutputNodeOperations(&outputOperations, this->getOperations(), this->context.isRendering()); + ExecutionSystemHelper::findOutputNodeOperations(&outputOperations, this->getOperations(), this->m_context.isRendering()); for (vector<NodeOperation *>::iterator iter = outputOperations.begin(); iter != outputOperations.end(); ++iter) { operation = *iter; ExecutionGroup *group = new ExecutionGroup(); @@ -300,15 +301,15 @@ void ExecutionSystem::groupOperations() void ExecutionSystem::addSocketConnection(SocketConnection *connection) { - this->connections.push_back(connection); + this->m_connections.push_back(connection); } void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup *> *result, CompositorPriority priority) const { unsigned int index; - for (index = 0; index < this->groups.size(); index++) { - ExecutionGroup *group = this->groups[index]; + for (index = 0; index < this->m_groups.size(); index++) { + ExecutionGroup *group = this->m_groups[index]; if (group->isOutputExecutionGroup() && group->getRenderPriotrity() == priority) { result->push_back(group); } @@ -318,8 +319,8 @@ void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup *> *result, void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup *> *result) const { unsigned int index; - for (index = 0; index < this->groups.size(); index++) { - ExecutionGroup *group = this->groups[index]; + for (index = 0; index < this->m_groups.size(); index++) { + ExecutionGroup *group = this->m_groups[index]; if (group->isOutputExecutionGroup()) { result->push_back(group); } diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h index 70fd94ca57f..209358ec786 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.h +++ b/source/blender/compositor/intern/COM_ExecutionSystem.h @@ -108,27 +108,27 @@ private: /** * @brief the context used during execution */ - CompositorContext context; + CompositorContext m_context; /** * @brief vector of nodes */ - vector<Node *> nodes; + vector<Node *> m_nodes; /** * @brief vector of operations */ - vector<NodeOperation *> operations; + vector<NodeOperation *> m_operations; /** * @brief vector of groups */ - vector<ExecutionGroup *> groups + vector<ExecutionGroup *> m_groups; /** * @brief vector of connections - */; - vector<SocketConnection *> connections; + */ + vector<SocketConnection *> m_connections; private: //methods /** @@ -156,7 +156,7 @@ public: * @param editingtree [bNodeTree*] * @param rendering [true false] */ - ExecutionSystem(bNodeTree *editingtree, bool rendering); + ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering, bool fastcalculation); /** * Destructor @@ -200,27 +200,27 @@ public: /** * @brief get the reference to the compositor context */ - CompositorContext& getContext() { return this->context; } + CompositorContext& getContext() { return this->m_context; } /** * @brief get the reference to the compositor nodes */ - vector<Node *>& getNodes() { return this->nodes; } + vector<Node *>& getNodes() { return this->m_nodes; } /** * @brief get the reference to the compositor connections */ - vector<SocketConnection *>& getConnections() { return this->connections; } + vector<SocketConnection *>& getConnections() { return this->m_connections; } /** * @brief get the reference to the list of execution groups */ - vector<ExecutionGroup *>& getExecutionGroups() { return this->groups; } + vector<ExecutionGroup *>& getExecutionGroups() { return this->m_groups; } /** * @brief get the reference to the list of operations */ - vector<NodeOperation *>& getOperations() { return this->operations; } + vector<NodeOperation *>& getOperations() { return this->m_operations; } private: @@ -232,5 +232,9 @@ private: void executeGroups(CompositorPriority priority); -}; +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionSystem") #endif +}; + +#endif /* _COM_ExecutionSystem_h */ diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp index b7d75732a84..0abf7efdcfa 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp @@ -39,21 +39,17 @@ #include "COM_ReadBufferOperation.h" #include "COM_ViewerBaseOperation.h" -Node *ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNode *groupnode) +void ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNode *groupnode) { vector<Node *>& nodes = system.getNodes(); vector<SocketConnection *>& links = system.getConnections(); - Node *mainnode = NULL; const bNode *activeGroupNode = system.getContext().getActivegNode(); bool isActiveGroup = activeGroupNode == groupnode; /* add all nodes of the tree to the node list */ bNode *node = (bNode *)tree->nodes.first; while (node != NULL) { - Node *execnode = addNode(nodes, node, isActiveGroup); - if (node->type == CMP_NODE_COMPOSITE) { - mainnode = execnode; - } + addNode(nodes, node, isActiveGroup, system.getContext().isFastCalculation()); node = (bNode *)node->next; } @@ -74,8 +70,6 @@ Node *ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_sta groupNode->ungroup(system); } } - - return mainnode; } void ExecutionSystemHelper::addNode(vector<Node *>& nodes, Node *node) @@ -83,11 +77,11 @@ void ExecutionSystemHelper::addNode(vector<Node *>& nodes, Node *node) nodes.push_back(node); } -Node *ExecutionSystemHelper::addNode(vector<Node *>& nodes, bNode *bNode, bool inActiveGroup) +Node *ExecutionSystemHelper::addNode(vector<Node *>& nodes, bNode *b_node, bool inActiveGroup, bool fast) { Converter converter; Node *node; - node = converter.convert(bNode); + node = converter.convert(b_node, fast); node->setIsInActiveGroup(inActiveGroup); if (node != NULL) { addNode(nodes, node); @@ -159,17 +153,17 @@ static OutputSocket *find_output(NodeRange &node_range, bNode *bnode, bNodeSocke } return NULL; } -SocketConnection *ExecutionSystemHelper::addNodeLink(NodeRange &node_range, vector<SocketConnection *>& links, bNodeLink *bNodeLink) +SocketConnection *ExecutionSystemHelper::addNodeLink(NodeRange &node_range, vector<SocketConnection *>& links, bNodeLink *b_nodelink) { /// @note: cyclic lines will be ignored. This has been copied from node.c - if (bNodeLink->tonode != 0 && bNodeLink->fromnode != 0) { - if (!(bNodeLink->fromnode->level >= bNodeLink->tonode->level && bNodeLink->tonode->level != 0xFFF)) { // only add non cyclic lines! so execution will procede + if (b_nodelink->tonode != 0 && b_nodelink->fromnode != 0) { + if (!(b_nodelink->fromnode->level >= b_nodelink->tonode->level && b_nodelink->tonode->level != 0xFFF)) { // only add non cyclic lines! so execution will procede return NULL; } } - InputSocket *inputSocket = find_input(node_range, bNodeLink->tonode, bNodeLink->tosock); - OutputSocket *outputSocket = find_output(node_range, bNodeLink->fromnode, bNodeLink->fromsock); + InputSocket *inputSocket = find_input(node_range, b_nodelink->tonode, b_nodelink->tosock); + OutputSocket *outputSocket = find_output(node_range, b_nodelink->fromnode, b_nodelink->fromsock); if (inputSocket == NULL || outputSocket == NULL) { return NULL; } diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h index 99a05472075..bd34fe8ab02 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h @@ -48,7 +48,7 @@ public: * @param tree bNodeTree to add * @return Node representing the "Compositor node" of the maintree. or NULL when a subtree is added */ - static Node *addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNode *groupnode); + static void addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree, bNode *groupnode); /** * @brief add an editor node to the system. @@ -58,7 +58,7 @@ public: * @param bNode node to add * @return Node that represents the bNode or null when not able to convert. */ - static Node *addNode(vector<Node *>& nodes, bNode *bNode, bool isInActiveGroup); + static Node *addNode(vector<Node *>& nodes, bNode *b_node, bool isInActiveGroup, bool fast); /** * @brief Add a Node to a list @@ -123,5 +123,10 @@ public: * @param system the execution system to dump */ static void debugDump(ExecutionSystem *system); -}; + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionSystemHelper") #endif +}; + +#endif /* _COM_ExecutionSystemHelper_h */ diff --git a/source/blender/compositor/intern/COM_InputSocket.cpp b/source/blender/compositor/intern/COM_InputSocket.cpp index 3ca74f157b4..94cb5ff5396 100644 --- a/source/blender/compositor/intern/COM_InputSocket.cpp +++ b/source/blender/compositor/intern/COM_InputSocket.cpp @@ -27,37 +27,37 @@ InputSocket::InputSocket(DataType datatype) : Socket(datatype) { - this->connection = NULL; - this->resizeMode = COM_SC_CENTER; + this->m_connection = NULL; + this->m_resizeMode = COM_SC_CENTER; } InputSocket::InputSocket(DataType datatype, InputSocketResizeMode resizeMode) : Socket(datatype) { - this->connection = NULL; - this->resizeMode = resizeMode; + this->m_connection = NULL; + this->m_resizeMode = resizeMode; } InputSocket::InputSocket(InputSocket *from) : Socket(from->getDataType()) { - this->connection = NULL; - this->resizeMode = from->getResizeMode(); + this->m_connection = NULL; + this->m_resizeMode = from->getResizeMode(); } int InputSocket::isInputSocket() const { return true; } -const int InputSocket::isConnected() const { return this->connection != NULL; } +const int InputSocket::isConnected() const { return this->m_connection != NULL; } void InputSocket::setConnection(SocketConnection *connection) { - this->connection = connection; + this->m_connection = connection; } SocketConnection *InputSocket::getConnection() { - return this->connection; + return this->m_connection; } void InputSocket::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { if (this->isConnected()) { - this->connection->getFromSocket()->determineResolution(resolution, preferredResolution); + this->m_connection->getFromSocket()->determineResolution(resolution, preferredResolution); } else { return; @@ -140,7 +140,7 @@ SocketReader *InputSocket::getReader() NodeOperation *InputSocket::getOperation() const { if (isConnected()) { - return (NodeOperation *)this->connection->getFromSocket()->getNode(); + return (NodeOperation *)this->m_connection->getFromSocket()->getNode(); } else { return NULL; diff --git a/source/blender/compositor/intern/COM_InputSocket.h b/source/blender/compositor/intern/COM_InputSocket.h index c066b5d8303..5d0923ff204 100644 --- a/source/blender/compositor/intern/COM_InputSocket.h +++ b/source/blender/compositor/intern/COM_InputSocket.h @@ -65,12 +65,12 @@ private: * @brief connection connected to this InputSocket. * An input socket can only have a single connection */ - SocketConnection *connection; + SocketConnection *m_connection; /** * @brief resize mode of this socket */ - InputSocketResizeMode resizeMode; + InputSocketResizeMode m_resizeMode; public: @@ -126,7 +126,7 @@ public: * @param resizeMode the new resize mode. */ void setResizeMode(InputSocketResizeMode resizeMode) { - this->resizeMode = resizeMode; + this->m_resizeMode = resizeMode; } /** @@ -134,7 +134,7 @@ public: * @return InputSocketResizeMode */ InputSocketResizeMode getResizeMode() const { - return this->resizeMode; + return this->m_resizeMode; } const ChannelInfo *getChannelInfo(const int channelnumber); diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp index ceed53c4c0d..8dd1e55274f 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp @@ -32,43 +32,43 @@ unsigned int MemoryBuffer::determineBufferSize() int MemoryBuffer::getWidth() const { - return this->rect.xmax - this->rect.xmin; + return this->m_rect.xmax - this->m_rect.xmin; } int MemoryBuffer::getHeight() const { - return this->rect.ymax - this->rect.ymin; + return this->m_rect.ymax - this->m_rect.ymin; } MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect) { - BLI_init_rcti(&this->rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); - this->memoryProxy = memoryProxy; - this->chunkNumber = chunkNumber; - this->buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer"); - this->state = COM_MB_ALLOCATED; - this->datatype = COM_DT_COLOR; - this->chunkWidth = this->rect.xmax - this->rect.xmin; + BLI_init_rcti(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + this->m_memoryProxy = memoryProxy; + this->m_chunkNumber = chunkNumber; + this->m_buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer"); + this->m_state = COM_MB_ALLOCATED; + this->m_datatype = COM_DT_COLOR; + this->m_chunkWidth = this->m_rect.xmax - this->m_rect.xmin; } MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect) { - BLI_init_rcti(&this->rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); - this->memoryProxy = memoryProxy; - this->chunkNumber = -1; - this->buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer"); - this->state = COM_MB_TEMPORARILY; - this->datatype = COM_DT_COLOR; - this->chunkWidth = this->rect.xmax - this->rect.xmin; + BLI_init_rcti(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + this->m_memoryProxy = memoryProxy; + this->m_chunkNumber = -1; + this->m_buffer = (float *)MEM_mallocN(sizeof(float) * determineBufferSize() * COM_NUMBER_OF_CHANNELS, "COM_MemoryBuffer"); + this->m_state = COM_MB_TEMPORARILY; + this->m_datatype = COM_DT_COLOR; + this->m_chunkWidth = this->m_rect.xmax - this->m_rect.xmin; } MemoryBuffer *MemoryBuffer::duplicate() { - MemoryBuffer *result = new MemoryBuffer(this->memoryProxy, &this->rect); - memcpy(result->buffer, this->buffer, this->determineBufferSize() * COM_NUMBER_OF_CHANNELS * sizeof(float)); + MemoryBuffer *result = new MemoryBuffer(this->m_memoryProxy, &this->m_rect); + memcpy(result->m_buffer, this->m_buffer, this->determineBufferSize() * COM_NUMBER_OF_CHANNELS * sizeof(float)); return result; } void MemoryBuffer::clear() { - memset(this->buffer, 0, this->determineBufferSize() * COM_NUMBER_OF_CHANNELS * sizeof(float)); + memset(this->m_buffer, 0, this->determineBufferSize() * COM_NUMBER_OF_CHANNELS * sizeof(float)); } float *MemoryBuffer::convertToValueBuffer() @@ -78,7 +78,7 @@ float *MemoryBuffer::convertToValueBuffer() float *result = new float[size]; - const float *fp_src = this->buffer; + const float *fp_src = this->m_buffer; float *fp_dst = result; for (i = 0; i < size; i++, fp_dst++, fp_src += COM_NUMBER_OF_CHANNELS) { @@ -90,9 +90,9 @@ float *MemoryBuffer::convertToValueBuffer() MemoryBuffer::~MemoryBuffer() { - if (this->buffer) { - MEM_freeN(this->buffer); - this->buffer = NULL; + if (this->m_buffer) { + MEM_freeN(this->m_buffer); + this->m_buffer = NULL; } } @@ -102,30 +102,30 @@ void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer) return; } unsigned int otherY; - unsigned int minX = max(this->rect.xmin, otherBuffer->rect.xmin); - unsigned int maxX = min(this->rect.xmax, otherBuffer->rect.xmax); - unsigned int minY = max(this->rect.ymin, otherBuffer->rect.ymin); - unsigned int maxY = min(this->rect.ymax, otherBuffer->rect.ymax); + unsigned int minX = max(this->m_rect.xmin, otherBuffer->m_rect.xmin); + unsigned int maxX = min(this->m_rect.xmax, otherBuffer->m_rect.xmax); + unsigned int minY = max(this->m_rect.ymin, otherBuffer->m_rect.ymin); + unsigned int maxY = min(this->m_rect.ymax, otherBuffer->m_rect.ymax); int offset; int otherOffset; for (otherY = minY; otherY < maxY; otherY++) { - otherOffset = ((otherY - otherBuffer->rect.ymin) * otherBuffer->chunkWidth + minX - otherBuffer->rect.xmin) * COM_NUMBER_OF_CHANNELS; - offset = ((otherY - this->rect.ymin) * this->chunkWidth + minX - this->rect.xmin) * COM_NUMBER_OF_CHANNELS; - memcpy(&this->buffer[offset], &otherBuffer->buffer[otherOffset], (maxX - minX) * COM_NUMBER_OF_CHANNELS * sizeof(float)); + otherOffset = ((otherY - otherBuffer->m_rect.ymin) * otherBuffer->m_chunkWidth + minX - otherBuffer->m_rect.xmin) * COM_NUMBER_OF_CHANNELS; + offset = ((otherY - this->m_rect.ymin) * this->m_chunkWidth + minX - this->m_rect.xmin) * COM_NUMBER_OF_CHANNELS; + memcpy(&this->m_buffer[offset], &otherBuffer->m_buffer[otherOffset], (maxX - minX) * COM_NUMBER_OF_CHANNELS * sizeof(float)); } } void MemoryBuffer::read(float result[4], int x, int y) { - if (x >= this->rect.xmin && x < this->rect.xmax && - y >= this->rect.ymin && y < this->rect.ymax) + if (x >= this->m_rect.xmin && x < this->m_rect.xmax && + y >= this->m_rect.ymin && y < this->m_rect.ymax) { - const int dx = x - this->rect.xmin; - const int dy = y - this->rect.ymin; - const int offset = (this->chunkWidth * dy + dx) * COM_NUMBER_OF_CHANNELS; - copy_v4_v4(result, &this->buffer[offset]); + const int dx = x - this->m_rect.xmin; + const int dy = y - this->m_rect.ymin; + const int offset = (this->m_chunkWidth * dy + dx) * COM_NUMBER_OF_CHANNELS; + copy_v4_v4(result, &this->m_buffer[offset]); } else { zero_v4(result); @@ -133,21 +133,21 @@ void MemoryBuffer::read(float result[4], int x, int y) } void MemoryBuffer::writePixel(int x, int y, const float color[4]) { - if (x >= this->rect.xmin && x < this->rect.xmax && - y >= this->rect.ymin && y < this->rect.ymax) + if (x >= this->m_rect.xmin && x < this->m_rect.xmax && + y >= this->m_rect.ymin && y < this->m_rect.ymax) { - const int offset = (this->chunkWidth * y + x) * COM_NUMBER_OF_CHANNELS; - copy_v4_v4(&this->buffer[offset], color); + const int offset = (this->m_chunkWidth * y + x) * COM_NUMBER_OF_CHANNELS; + copy_v4_v4(&this->m_buffer[offset], color); } } void MemoryBuffer::addPixel(int x, int y, const float color[4]) { - if (x >= this->rect.xmin && x < this->rect.xmax && - y >= this->rect.ymin && y < this->rect.ymax) + if (x >= this->m_rect.xmin && x < this->m_rect.xmax && + y >= this->m_rect.ymin && y < this->m_rect.ymax) { - const int offset = (this->chunkWidth * y + x) * COM_NUMBER_OF_CHANNELS; - add_v4_v4(&this->buffer[offset], color); + const int offset = (this->m_chunkWidth * y + x) * COM_NUMBER_OF_CHANNELS; + add_v4_v4(&this->m_buffer[offset], color); } } diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h index dd24a30e85e..63b41aeddde 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.h +++ b/source/blender/compositor/intern/COM_MemoryBuffer.h @@ -56,39 +56,39 @@ private: /** * @brief proxy of the memory (same for all chunks in the same buffer) */ - MemoryProxy *memoryProxy; + MemoryProxy *m_memoryProxy; /** * @brief the type of buffer COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR */ - DataType datatype; + DataType m_datatype; /** * @brief region of this buffer inside reative to the MemoryProxy */ - rcti rect; + rcti m_rect; /** * brief refers to the chunknumber within the executiongroup where related to the MemoryProxy * @see memoryProxy */ - unsigned int chunkNumber; + unsigned int m_chunkNumber; /** * @brief width of the chunk */ - unsigned int chunkWidth; + unsigned int m_chunkWidth; /** * @brief state of the buffer */ - MemoryBufferState state; + MemoryBufferState m_state; /** * @brief the actual float buffer/data */ - float *buffer; + float *m_buffer; public: /** @@ -109,19 +109,19 @@ public: /** * @brief read the ChunkNumber of this MemoryBuffer */ - unsigned int getChunkNumber() { return this->chunkNumber; } + unsigned int getChunkNumber() { return this->m_chunkNumber; } /** * @brief get the data of this MemoryBuffer * @note buffer should already be available in memory */ - float *getBuffer() { return this->buffer; } + float *getBuffer() { return this->m_buffer; } /** * @brief after execution the state will be set to available by calling this method */ void setCreatedState() { - this->state = COM_MB_AVAILABLE; + this->m_state = COM_MB_AVAILABLE; } void read(float result[4], int x, int y); @@ -133,7 +133,7 @@ public: /** * @brief is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk) */ - inline const bool isTemporarily() const { return this->state == COM_MB_TEMPORARILY; } + inline const bool isTemporarily() const { return this->m_state == COM_MB_TEMPORARILY; } /** * @brief add the content from otherBuffer to this MemoryBuffer @@ -144,7 +144,7 @@ public: /** * @brief get the rect of this MemoryBuffer */ - rcti *getRect() { return &this->rect; } + rcti *getRect() { return &this->m_rect; } /** * @brief get the width of this MemoryBuffer @@ -166,6 +166,10 @@ public: float *convertToValueBuffer(); private: unsigned int determineBufferSize(); + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:MemoryBuffer") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_MemoryProxy.cpp b/source/blender/compositor/intern/COM_MemoryProxy.cpp index 3a2c690d7de..90ca0baea06 100644 --- a/source/blender/compositor/intern/COM_MemoryProxy.cpp +++ b/source/blender/compositor/intern/COM_MemoryProxy.cpp @@ -25,8 +25,8 @@ MemoryProxy::MemoryProxy() { - this->writeBufferOperation = NULL; - this->executor = NULL; + this->m_writeBufferOperation = NULL; + this->m_executor = NULL; } void MemoryProxy::allocate(unsigned int width, unsigned int height) @@ -37,14 +37,14 @@ void MemoryProxy::allocate(unsigned int width, unsigned int height) result.ymin = 0; result.ymax = height; - buffer = new MemoryBuffer(this, 1, &result); + this->m_buffer = new MemoryBuffer(this, 1, &result); } void MemoryProxy::free() { - if (buffer) { - delete buffer; - buffer = NULL; + if (this->m_buffer) { + delete this->m_buffer; + this->m_buffer = NULL; } } diff --git a/source/blender/compositor/intern/COM_MemoryProxy.h b/source/blender/compositor/intern/COM_MemoryProxy.h index e7e7f1cf3a0..130c5f5057a 100644 --- a/source/blender/compositor/intern/COM_MemoryProxy.h +++ b/source/blender/compositor/intern/COM_MemoryProxy.h @@ -23,8 +23,8 @@ class MemoryProxy; -#ifndef _COM_MemoryProxy_h -#define _COM_MemoryProxy_h +#ifndef _COM_MemoryProxy_h_ +#define _COM_MemoryProxy_h_ #include "COM_ExecutionGroup.h" class ExecutionGroup; @@ -40,27 +40,27 @@ private: /** * @brief reference to the ouput operation of the executiongroup */ - WriteBufferOperation *writeBufferOperation; + WriteBufferOperation *m_writeBufferOperation; /** * @brief reference to the executor. the Execution group that can fill a chunk */ - ExecutionGroup *executor; + ExecutionGroup *m_executor; /** * @brief datatype of this MemoryProxy */ - DataType datatype; + /* DataType m_datatype; */ /* UNUSED */ /** * @brief channel information of this buffer */ - ChannelInfo channelInfo[COM_NUMBER_OF_CHANNELS]; + /* ChannelInfo m_channelInfo[COM_NUMBER_OF_CHANNELS]; */ /* UNUSED */ /** * @brief the allocated memory */ - MemoryBuffer *buffer; + MemoryBuffer *m_buffer; public: MemoryProxy(); @@ -69,24 +69,24 @@ public: * @brief set the ExecutionGroup that can be scheduled to calculate a certain chunk. * @param group the ExecutionGroup to set */ - void setExecutor(ExecutionGroup *executor) { this->executor = executor; } + void setExecutor(ExecutionGroup *executor) { this->m_executor = executor; } /** * @brief get the ExecutionGroup that can be scheduled to calculate a certain chunk. */ - ExecutionGroup *getExecutor() { return this->executor; } + ExecutionGroup *getExecutor() { return this->m_executor; } /** * @brief set the WriteBufferOperation that is responsible for writing to this MemoryProxy * @param operation */ - void setWriteBufferOperation(WriteBufferOperation *operation) { this->writeBufferOperation = operation; } + void setWriteBufferOperation(WriteBufferOperation *operation) { this->m_writeBufferOperation = operation; } /** * @brief get the WriteBufferOperation that is responsible for writing to this MemoryProxy * @return WriteBufferOperation */ - WriteBufferOperation *getWriteBufferOperation() { return this->writeBufferOperation; } + WriteBufferOperation *getWriteBufferOperation() { return this->m_writeBufferOperation; } /** * @brief allocate memory of size widht x height @@ -101,7 +101,11 @@ public: /** * @brief get the allocated memory */ - inline MemoryBuffer *getBuffer() { return this->buffer; } + inline MemoryBuffer *getBuffer() { return this->m_buffer; } + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:MemoryProxy") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp index a65849901ed..320baacb669 100644 --- a/source/blender/compositor/intern/COM_Node.cpp +++ b/source/blender/compositor/intern/COM_Node.cpp @@ -39,9 +39,9 @@ //#include <stdio.h> #include "COM_defines.h" -Node::Node(bNode *editorNode, bool create_sockets) +Node::Node(bNode *editorNode, bool create_sockets): NodeBase() { - this->editorNode = editorNode; + setbNode(editorNode); if (create_sockets) { bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first; @@ -64,15 +64,6 @@ Node::Node(bNode *editorNode, bool create_sockets) } } } -Node::Node() -{ - this->editorNode = NULL; -} - -bNode *Node::getbNode() -{ - return this->editorNode; -} void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex) { @@ -87,11 +78,15 @@ void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket) { if (this->isInActiveGroup()) { - PreviewOperation *operation = new PreviewOperation(); - system->addOperation(operation); - operation->setbNode(this->getbNode()); - operation->setbNodeTree(system->getContext().getbNodeTree()); - this->addLink(system, outputSocket, operation->getInputSocket(0)); + if (!(this->getbNode()->flag & NODE_HIDDEN)) { // do not calculate previews of hidden nodes. + if (this->getbNode()->flag & NODE_PREVIEW) { + PreviewOperation *operation = new PreviewOperation(); + system->addOperation(operation); + operation->setbNode(this->getbNode()); + operation->setbNodeTree(system->getContext().getbNodeTree()); + this->addLink(system, outputSocket, operation->getInputSocket(0)); + } + } } } diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h index 12baa26cd6e..bc4a25db605 100644 --- a/source/blender/compositor/intern/COM_Node.h +++ b/source/blender/compositor/intern/COM_Node.h @@ -29,6 +29,7 @@ #include "COM_CompositorContext.h" #include "DNA_node_types.h" #include "BKE_text.h" +#include "COM_ExecutionSystem.h" #include <vector> #include <string> @@ -47,29 +48,20 @@ typedef pair<NodeIterator, NodeIterator> NodeRange; */ class Node : public NodeBase { private: - /** - * @brief stores the reference to the SDNA bNode struct - */ - bNode *editorNode; /** * @brief Is this node part of the active group */ - bool inActiveGroup; + bool m_inActiveGroup; public: Node(bNode *editorNode, bool create_sockets = true); - - /** - * @brief get the reference to the SDNA bNode struct - */ - bNode *getbNode(); - + /** * @brief Is this node in the active group (the group that is being edited) * @param isInActiveGroup */ - void setIsInActiveGroup(bool isInActiveGroup) { this->inActiveGroup = isInActiveGroup; } + void setIsInActiveGroup(bool value) { this->m_inActiveGroup = value; } /** * @brief Is this node part of the active group @@ -77,7 +69,7 @@ public: * the active group will be the main tree (all nodes that are not part of a group will be active) * @return bool [false:true] */ - inline bool isInActiveGroup() { return this->inActiveGroup; } + inline bool isInActiveGroup() { return this->m_inActiveGroup; } /** * @brief convert node to operation @@ -136,9 +128,6 @@ public: */ OutputSocket *findOutputSocketBybNodeSocket(bNodeSocket *socket); protected: - - Node(); - void addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket); void addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket); diff --git a/source/blender/compositor/intern/COM_NodeBase.cpp b/source/blender/compositor/intern/COM_NodeBase.cpp index 1a895cf93b1..5c2ce37bdea 100644 --- a/source/blender/compositor/intern/COM_NodeBase.cpp +++ b/source/blender/compositor/intern/COM_NodeBase.cpp @@ -33,19 +33,19 @@ NodeBase::NodeBase() { - /* pass */ + this->m_editorNode = NULL; } NodeBase::~NodeBase() { - while (!this->outputsockets.empty()) { - delete (this->outputsockets.back()); - this->outputsockets.pop_back(); + while (!this->m_outputsockets.empty()) { + delete (this->m_outputsockets.back()); + this->m_outputsockets.pop_back(); } - while (!this->inputsockets.empty()) { - delete (this->inputsockets.back()); - this->inputsockets.pop_back(); + while (!this->m_inputsockets.empty()) { + delete (this->m_inputsockets.back()); + this->m_inputsockets.pop_back(); } } @@ -63,7 +63,7 @@ void NodeBase::addInputSocket(DataType datatype, InputSocketResizeMode resizeMod InputSocket *socket = new InputSocket(datatype, resizeMode); socket->setEditorSocket(bSocket); socket->setNode(this); - this->inputsockets.push_back(socket); + this->m_inputsockets.push_back(socket); } void NodeBase::addOutputSocket(DataType datatype) @@ -76,21 +76,21 @@ void NodeBase::addOutputSocket(DataType datatype, bNodeSocket *bSocket) OutputSocket *socket = new OutputSocket(datatype); socket->setEditorSocket(bSocket); socket->setNode(this); - this->outputsockets.push_back(socket); + this->m_outputsockets.push_back(socket); } const bool NodeBase::isInputNode() const { - return this->inputsockets.size() == 0; + return this->m_inputsockets.size() == 0; } OutputSocket *NodeBase::getOutputSocket(unsigned int index) { - BLI_assert(index < this->outputsockets.size()); - return this->outputsockets[index]; + BLI_assert(index < this->m_outputsockets.size()); + return this->m_outputsockets[index]; } InputSocket *NodeBase::getInputSocket(unsigned int index) { - BLI_assert(index < this->inputsockets.size()); - return this->inputsockets[index]; + BLI_assert(index < this->m_inputsockets.size()); + return this->m_inputsockets[index]; } diff --git a/source/blender/compositor/intern/COM_NodeBase.h b/source/blender/compositor/intern/COM_NodeBase.h index 54f80926b84..3c390f6bcdb 100644 --- a/source/blender/compositor/intern/COM_NodeBase.h +++ b/source/blender/compositor/intern/COM_NodeBase.h @@ -47,23 +47,28 @@ private: /** * @brief the list of actual inputsockets @see InputSocket */ - vector<InputSocket *> inputsockets; + vector<InputSocket *> m_inputsockets; /** * @brief the list of actual outputsockets @see OutputSocket */ - vector<OutputSocket *> outputsockets; + vector<OutputSocket *> m_outputsockets; + + /** + * @brief stores the reference to the SDNA bNode struct + */ + bNode *m_editorNode; protected: /** * @brief get access to the vector of input sockets */ - inline vector<InputSocket *>& getInputSockets() { return this->inputsockets; } + inline vector<InputSocket *>& getInputSockets() { return this->m_inputsockets; } /** * @brief get access to the vector of input sockets */ - inline vector<OutputSocket *>& getOutputSockets() { return this->outputsockets; } + inline vector<OutputSocket *>& getOutputSockets() { return this->m_outputsockets; } public: @@ -74,6 +79,18 @@ public: virtual ~NodeBase(); /** + * @brief get the reference to the SDNA bNode struct + */ + bNode *getbNode() {return m_editorNode;} + + /** + * @brief set the reference to the bNode + * @note used in Node instances to receive the storage/settings and complex node for highlight during execution + * @param bNode + */ + void setbNode(bNode *bNode) {this->m_editorNode = bNode;} + + /** * @brief is this node an operation? * This is true when the instance is of the subclass NodeOperation. * @return [true:false] @@ -91,12 +108,12 @@ public: /** * @brief Return the number of input sockets of this node. */ - const unsigned int getNumberOfInputSockets() const { return this->inputsockets.size(); } + const unsigned int getNumberOfInputSockets() const { return this->m_inputsockets.size(); } /** * @brief Return the number of output sockets of this node. */ - const unsigned int getNumberOfOutputSockets() const { return this->outputsockets.size(); } + const unsigned int getNumberOfOutputSockets() const { return this->m_outputsockets.size(); } /** * get the reference to a certain outputsocket @@ -141,6 +158,11 @@ protected: */ void addOutputSocket(DataType datatype); void addOutputSocket(DataType datatype, bNodeSocket *socket); + + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeBase") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp index f416be5dedf..c3fa308971c 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.cpp +++ b/source/blender/compositor/intern/COM_NodeOperation.cpp @@ -28,14 +28,14 @@ #include "COM_SocketConnection.h" #include "COM_defines.h" -NodeOperation::NodeOperation() +NodeOperation::NodeOperation() : NodeBase() { - this->resolutionInputSocketIndex = 0; - this->complex = false; - this->width = 0; - this->height = 0; - this->openCL = false; - this->btree = NULL; + this->m_resolutionInputSocketIndex = 0; + this->m_complex = false; + this->m_width = 0; + this->m_height = 0; + this->m_openCL = false; + this->m_btree = NULL; } void NodeOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) @@ -47,7 +47,7 @@ void NodeOperation::determineResolution(unsigned int resolution[], unsigned int for (unsigned int index = 0; index < inputsockets.size(); index++) { InputSocket *inputSocket = inputsockets[index]; if (inputSocket->isConnected()) { - if (index == this->resolutionInputSocketIndex) { + if (index == this->m_resolutionInputSocketIndex) { inputSocket->determineResolution(resolution, preferredResolution); temp2[0] = resolution[0]; temp2[1] = resolution[1]; @@ -58,7 +58,7 @@ void NodeOperation::determineResolution(unsigned int resolution[], unsigned int for (unsigned int index = 0; index < inputsockets.size(); index++) { InputSocket *inputSocket = inputsockets[index]; if (inputSocket->isConnected()) { - if (index != resolutionInputSocketIndex) { + if (index != this->m_resolutionInputSocketIndex) { inputSocket->determineResolution(temp, temp2); } } @@ -66,7 +66,7 @@ void NodeOperation::determineResolution(unsigned int resolution[], unsigned int } void NodeOperation::setResolutionInputSocketIndex(unsigned int index) { - this->resolutionInputSocketIndex = index; + this->m_resolutionInputSocketIndex = index; } void NodeOperation::initExecution() { @@ -75,22 +75,22 @@ void NodeOperation::initExecution() void NodeOperation::initMutex() { - BLI_mutex_init(&mutex); + BLI_mutex_init(&this->m_mutex); } void NodeOperation::lockMutex() { - BLI_mutex_lock(&mutex); + BLI_mutex_lock(&this->m_mutex); } void NodeOperation::unlockMutex() { - BLI_mutex_unlock(&mutex); + BLI_mutex_unlock(&this->m_mutex); } void NodeOperation::deinitMutex() { - BLI_mutex_end(&mutex); + BLI_mutex_end(&this->m_mutex); } void NodeOperation::deinitExecution() @@ -140,116 +140,3 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOper return false; } } - -cl_mem NodeOperation::COM_clAttachMemoryBufferToKernelParameter(cl_context context, cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader) -{ - cl_int error; - MemoryBuffer *result = (MemoryBuffer *)reader->initializeTileData(NULL, inputMemoryBuffers); - - const cl_image_format imageFormat = { - CL_RGBA, - CL_FLOAT - }; - - cl_mem clBuffer = clCreateImage2D(context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, result->getWidth(), - result->getHeight(), 0, result->getBuffer(), &error); - - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - if (error == CL_SUCCESS) cleanup->push_back(clBuffer); - - error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clBuffer); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - - COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, offsetIndex, result); - return clBuffer; -} - -void NodeOperation::COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffer) -{ - if (offsetIndex != -1) { - cl_int error; - rcti *rect = memoryBuffer->getRect(); - cl_int2 offset = {rect->xmin, rect->ymin}; - - error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - } -} - -void NodeOperation::COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex) -{ - if (offsetIndex != -1) { - cl_int error; - cl_int2 offset = {this->getWidth(), this->getHeight()}; - - error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - } -} - -void NodeOperation::COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer) -{ - cl_int error; - error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clOutputMemoryBuffer); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } -} - -void NodeOperation::COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer) { - cl_int error; - const size_t size[] = {outputMemoryBuffer->getWidth(), outputMemoryBuffer->getHeight()}; - - error = clEnqueueNDRangeKernel(queue, kernel, 2, NULL, size, 0, 0, 0, NULL); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } -} - -void NodeOperation::COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex) { - cl_int error; - const int width = outputMemoryBuffer->getWidth(); - const int height = outputMemoryBuffer->getHeight(); - int offsetx; - int offsety; - const int localSize = 128; - size_t size[2]; - cl_int2 offset; - - bool breaked = false; - for (offsety = 0; offsety < height && (!breaked); offsety += localSize) { - offset[1] = offsety; - if (offsety + localSize < height) { - size[1] = localSize; - } - else { - size[1] = height - offsety; - } - for (offsetx = 0; offsetx < width && (!breaked); offsetx += localSize) { - if (offsetx + localSize < width) { - size[0] = localSize; - } - else { - size[0] = width - offsetx; - } - offset[0] = offsetx; - - error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - error = clEnqueueNDRangeKernel(queue, kernel, 2, NULL, size, 0, 0, 0, NULL); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - clFlush(queue); - if (isBreaked()) { - breaked = false; - } - } - } -} - -cl_kernel NodeOperation::COM_clCreateKernel(cl_program program, const char *kernelname, list<cl_kernel> *clKernelsToCleanUp) -{ - cl_int error; - cl_kernel kernel = clCreateKernel(program, kernelname, &error); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - else { - if (clKernelsToCleanUp) clKernelsToCleanUp->push_back(kernel); - } - return kernel; - -} diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index 30731572712..d316cfa0aa4 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -22,9 +22,7 @@ #ifndef _COM_NodeOperation_h #define _COM_NodeOperation_h - -class NodeOperation; - +class OpenCLDevice; #include "COM_Node.h" #include <string> #include <sstream> @@ -51,7 +49,7 @@ private: /** * @brief the index of the input socket that will be used to determine the resolution */ - unsigned int resolutionInputSocketIndex; + unsigned int m_resolutionInputSocketIndex; /** * @brief is this operation a complex one. @@ -59,13 +57,13 @@ private: * Complex operations are typically doing many reads to calculate the output of a single pixel. * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true. */ - bool complex; + bool m_complex; /** * @brief can this operation be scheduled on an OpenCL device. * @note Only applicable if complex is True */ - bool openCL; + bool m_openCL; /** * @brief mutex reference for very special node initializations @@ -76,12 +74,12 @@ private: * @see NodeOperation.deinitMutex deinitializes this mutex * @see NodeOperation.getMutex retrieve a pointer to this mutex. */ - ThreadMutex mutex; + ThreadMutex m_mutex; /** * @brief reference to the editing bNodeTree only used for break callback */ - const bNodeTree *btree; + const bNodeTree *m_btree; public: /** @@ -126,7 +124,7 @@ public: virtual int isBufferOperation() { return false; } virtual int isSingleThreaded() { return false; } - void setbNodeTree(const bNodeTree *tree) { this->btree = tree; } + void setbNodeTree(const bNodeTree *tree) { this->m_btree = tree; } virtual void initExecution(); /** @@ -150,7 +148,7 @@ public: * @param memoryBuffers all input MemoryBuffer's needed * @param outputBuffer the outputbuffer to write to */ - virtual void executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, + virtual void executeOpenCLRegion(OpenCLDevice* device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer) {} /** @@ -165,11 +163,11 @@ public: * @param clMemToCleanUp all created cl_mem references must be added to this list. Framework will clean this after execution * @param clKernelsToCleanUp all created cl_kernel references must be added to this list. Framework will clean this after execution */ - virtual void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) {} + virtual void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) {} virtual void deinitExecution(); bool isResolutionSet() { - return this->width != 0 && height != 0; + return this->m_width != 0 && this->m_height != 0; } /** @@ -178,8 +176,8 @@ public: */ void setResolution(unsigned int resolution[]) { if (!isResolutionSet()) { - this->width = resolution[0]; - this->height = resolution[1]; + this->m_width = resolution[0]; + this->m_height = resolution[1]; } } @@ -192,7 +190,7 @@ public: * Complex operations are typically doing many reads to calculate the output of a single pixel. * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true. */ - const bool isComplex() const { return this->complex; } + const bool isComplex() const { return this->m_complex; } virtual const bool isSetOperation() const { return false; } /** @@ -237,20 +235,20 @@ public: * @see WorkScheduler.schedule * @see ExecutionGroup.addOperation */ - bool isOpenCL() { return this->openCL; } + bool isOpenCL() { return this->m_openCL; } virtual bool isViewerOperation() { return false; } virtual bool isPreviewOperation() { return false; } inline bool isBreaked() { - return btree->test_break(btree->tbh); + return this->m_btree->test_break(this->m_btree->tbh); } protected: NodeOperation(); - void setWidth(unsigned int width) { this->width = width; } - void setHeight(unsigned int height) { this->height = height; } + void setWidth(unsigned int width) { this->m_width = width; } + void setHeight(unsigned int height) { this->m_height = height; } SocketReader *getInputSocketReader(unsigned int inputSocketindex); NodeOperation *getInputOperation(unsigned int inputSocketindex); @@ -266,21 +264,16 @@ protected: * Complex operations are typically doing many reads to calculate the output of a single pixel. * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true. */ - void setComplex(bool complex) { this->complex = complex; } + void setComplex(bool complex) { this->m_complex = complex; } /** * @brief set if this NodeOperation can be scheduled on a OpenCLDevice */ - void setOpenCL(bool openCL) { this->openCL = openCL; } - - static cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_context context, cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader); - static void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffers); - static void COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer); - void COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex); - static void COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer); - void COM_clEnqueueRange(cl_command_queue queue, cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex); - cl_kernel COM_clCreateKernel(cl_program program, const char *kernelname, list<cl_kernel> *clKernelsToCleanUp); + void setOpenCL(bool openCL) { this->m_openCL = openCL; } +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp index 9d005804098..eae1ffeb08a 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp +++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp @@ -23,26 +23,28 @@ #include "COM_OpenCLDevice.h" #include "COM_WorkScheduler.h" +typedef enum COM_VendorID {NVIDIA = 0x10DE, AMD = 0x1002} COM_VendorID; -OpenCLDevice::OpenCLDevice(cl_context context, cl_device_id device, cl_program program) +OpenCLDevice::OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendorId) { - this->device = device; - this->context = context; - this->program = program; - this->queue = NULL; + this->m_device = device; + this->m_context = context; + this->m_program = program; + this->m_queue = NULL; + this->m_vendorID = vendorId; } bool OpenCLDevice::initialize() { cl_int error; - queue = clCreateCommandQueue(context, device, 0, &error); + this->m_queue = clCreateCommandQueue(this->m_context, this->m_device, 0, &error); return false; } void OpenCLDevice::deinitialize() { - if (queue) { - clReleaseCommandQueue(queue); + if (this->m_queue) { + clReleaseCommandQueue(this->m_queue); } } @@ -56,10 +58,126 @@ void OpenCLDevice::execute(WorkPackage *work) MemoryBuffer **inputBuffers = executionGroup->getInputBuffersOpenCL(chunkNumber); MemoryBuffer *outputBuffer = executionGroup->allocateOutputBuffer(chunkNumber, &rect); - executionGroup->getOutputNodeOperation()->executeOpenCLRegion(this->context, this->program, this->queue, &rect, + executionGroup->getOutputNodeOperation()->executeOpenCLRegion(this, &rect, chunkNumber, inputBuffers, outputBuffer); delete outputBuffer; executionGroup->finalizeChunkExecution(chunkNumber, inputBuffers); } + +cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader) +{ + cl_int error; + MemoryBuffer *result = (MemoryBuffer *)reader->initializeTileData(NULL, inputMemoryBuffers); + + const cl_image_format imageFormat = { + CL_RGBA, + CL_FLOAT + }; + + cl_mem clBuffer = clCreateImage2D(this->m_context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, result->getWidth(), + result->getHeight(), 0, result->getBuffer(), &error); + + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + if (error == CL_SUCCESS) cleanup->push_back(clBuffer); + + error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clBuffer); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + + COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, offsetIndex, result); + return clBuffer; +} + +void OpenCLDevice::COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffer) +{ + if (offsetIndex != -1) { + cl_int error; + rcti *rect = memoryBuffer->getRect(); + cl_int2 offset = {rect->xmin, rect->ymin}; + + error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + } +} + +void OpenCLDevice::COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex, NodeOperation* operation) +{ + if (offsetIndex != -1) { + cl_int error; + cl_int2 offset = {operation->getWidth(), operation->getHeight()}; + + error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + } +} + +void OpenCLDevice::COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer) +{ + cl_int error; + error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clOutputMemoryBuffer); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } +} + +void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer) +{ + cl_int error; + const size_t size[] = {outputMemoryBuffer->getWidth(), outputMemoryBuffer->getHeight()}; + + error = clEnqueueNDRangeKernel(this->m_queue, kernel, 2, NULL, size, 0, 0, 0, NULL); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } +} + +void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex, NodeOperation* operation) +{ + cl_int error; + const int width = outputMemoryBuffer->getWidth(); + const int height = outputMemoryBuffer->getHeight(); + int offsetx; + int offsety; + int localSize = 1024; + size_t size[2]; + cl_int2 offset; + + if (this->m_vendorID == NVIDIA) {localSize = 32;} + bool breaked = false; + for (offsety = 0; offsety < height && (!breaked); offsety += localSize) { + offset[1] = offsety; + if (offsety + localSize < height) { + size[1] = localSize; + } + else { + size[1] = height - offsety; + } + for (offsetx = 0; offsetx < width && (!breaked); offsetx += localSize) { + if (offsetx + localSize < width) { + size[0] = localSize; + } + else { + size[0] = width - offsetx; + } + offset[0] = offsetx; + + error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + error = clEnqueueNDRangeKernel(this->m_queue, kernel, 2, NULL, size, 0, 0, 0, NULL); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + clFlush(this->m_queue); + if (operation->isBreaked()) { + breaked = false; + } + } + } +} + +cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname, list<cl_kernel> *clKernelsToCleanUp) +{ + cl_int error; + cl_kernel kernel = clCreateKernel(this->m_program, kernelname, &error); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + else { + if (clKernelsToCleanUp) clKernelsToCleanUp->push_back(kernel); + } + return kernel; + +} diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.h b/source/blender/compositor/intern/COM_OpenCLDevice.h index 83ce8cec811..30a90dabc3e 100644 --- a/source/blender/compositor/intern/COM_OpenCLDevice.h +++ b/source/blender/compositor/intern/COM_OpenCLDevice.h @@ -29,7 +29,6 @@ class OpenCLDevice; #include "OCL_opencl.h" #include "COM_WorkScheduler.h" - /** * @brief device representing an GPU OpenCL device. * an instance of this class represents a single cl_device @@ -39,29 +38,37 @@ private: /** * @brief opencl context */ - cl_context context; + cl_context m_context; /** * @brief opencl device */ - cl_device_id device; + cl_device_id m_device; /** * @brief opencl program */ - cl_program program; + cl_program m_program; /** * @brief opencl command queue */ - cl_command_queue queue; + cl_command_queue m_queue; + + /** + * @brief opencl vendor ID + */ + cl_int m_vendorID; + public: /** * @brief constructor with opencl device * @param context * @param device + * @param program + * @param vendorID */ - OpenCLDevice(cl_context context, cl_device_id device, cl_program program); + OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendorId); /** @@ -83,6 +90,18 @@ public: * @param work the WorkPackage to execute */ void execute(WorkPackage *work); + + cl_context getContext(){ return this->m_context; } + + cl_command_queue getQueue(){ return this->m_queue; } + + cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader); + void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffers); + void COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer); + void COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex, NodeOperation* operation); + void COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer); + void COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex, NodeOperation* operation); + cl_kernel COM_clCreateKernel(const char *kernelname, list<cl_kernel> *clKernelsToCleanUp); }; #endif diff --git a/source/blender/compositor/intern/COM_OutputSocket.cpp b/source/blender/compositor/intern/COM_OutputSocket.cpp index 484254fe6de..865ab0472e8 100644 --- a/source/blender/compositor/intern/COM_OutputSocket.cpp +++ b/source/blender/compositor/intern/COM_OutputSocket.cpp @@ -31,7 +31,7 @@ OutputSocket::OutputSocket(DataType datatype) : Socket(datatype) } int OutputSocket::isOutputSocket() const { return true; } -const int OutputSocket::isConnected() const { return this->connections.size() != 0; } +const int OutputSocket::isConnected() const { return this->m_connections.size() != 0; } void OutputSocket::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { @@ -51,37 +51,37 @@ void OutputSocket::determineResolution(unsigned int resolution[], unsigned int p void OutputSocket::addConnection(SocketConnection *connection) { - this->connections.push_back(connection); + this->m_connections.push_back(connection); } void OutputSocket::relinkConnections(OutputSocket *relinkToSocket, bool single) { if (isConnected()) { if (single) { - SocketConnection *connection = this->connections[0]; + SocketConnection *connection = this->m_connections[0]; connection->setFromSocket(relinkToSocket); relinkToSocket->addConnection(connection); - this->connections.erase(this->connections.begin()); + this->m_connections.erase(this->m_connections.begin()); } else { unsigned int index; - for (index = 0; index < this->connections.size(); index++) { - SocketConnection *connection = this->connections[index]; + for (index = 0; index < this->m_connections.size(); index++) { + SocketConnection *connection = this->m_connections[index]; connection->setFromSocket(relinkToSocket); relinkToSocket->addConnection(connection); } - this->connections.clear(); + this->m_connections.clear(); } } } void OutputSocket::removeFirstConnection() { - SocketConnection *connection = this->connections[0]; + SocketConnection *connection = this->m_connections[0]; InputSocket *inputSocket = connection->getToSocket(); if (inputSocket != NULL) { inputSocket->setConnection(NULL); } - this->connections.erase(this->connections.begin()); + this->m_connections.erase(this->m_connections.begin()); } void OutputSocket::clearConnections() @@ -94,8 +94,8 @@ void OutputSocket::clearConnections() WriteBufferOperation *OutputSocket::findAttachedWriteBufferOperation() const { unsigned int index; - for (index = 0; index < this->connections.size(); index++) { - SocketConnection *connection = this->connections[index]; + for (index = 0; index < this->m_connections.size(); index++) { + SocketConnection *connection = this->m_connections[index]; NodeBase *node = connection->getToNode(); if (node->isOperation()) { NodeOperation *operation = (NodeOperation *)node; diff --git a/source/blender/compositor/intern/COM_OutputSocket.h b/source/blender/compositor/intern/COM_OutputSocket.h index c073703c423..4810e1ae065 100644 --- a/source/blender/compositor/intern/COM_OutputSocket.h +++ b/source/blender/compositor/intern/COM_OutputSocket.h @@ -42,7 +42,7 @@ class WriteBufferOperation; */ class OutputSocket : public Socket { private: - vector<SocketConnection *> connections; + vector<SocketConnection *> m_connections; void removeFirstConnection(); public: @@ -50,7 +50,7 @@ public: OutputSocket(DataType datatype, int inputSocketDataTypeDeterminatorIndex); OutputSocket(OutputSocket *from); void addConnection(SocketConnection *connection); - SocketConnection *getConnection(unsigned int index) { return this->connections[index]; } + SocketConnection *getConnection(unsigned int index) { return this->m_connections[index]; } const int isConnected() const; int isOutputSocket() const; @@ -66,7 +66,7 @@ public: */ void relinkConnections(OutputSocket *relinkToSocket) { this->relinkConnections(relinkToSocket, false); }; void relinkConnections(OutputSocket *relinkToSocket, bool single); - const int getNumberOfConnections() { return connections.size(); } + const int getNumberOfConnections() { return this->m_connections.size(); } void clearConnections(); diff --git a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp index 01043664412..a6f81410b74 100644 --- a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp +++ b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp @@ -24,7 +24,7 @@ SingleThreadedNodeOperation::SingleThreadedNodeOperation() : NodeOperation() { - this->cachedInstance = NULL; + this->m_cachedInstance = NULL; setComplex(true); } @@ -35,26 +35,26 @@ void SingleThreadedNodeOperation::initExecution() void SingleThreadedNodeOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - this->cachedInstance->read(color, x, y); + this->m_cachedInstance->read(color, x, y); } void SingleThreadedNodeOperation::deinitExecution() { deinitMutex(); - if (this->cachedInstance) { - delete cachedInstance; - this->cachedInstance = NULL; + if (this->m_cachedInstance) { + delete this->m_cachedInstance; + this->m_cachedInstance = NULL; } } void *SingleThreadedNodeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->cachedInstance) return this->cachedInstance; + if (this->m_cachedInstance) return this->m_cachedInstance; lockMutex(); - if (this->cachedInstance == NULL) { + if (this->m_cachedInstance == NULL) { // - this->cachedInstance = createMemoryBuffer(rect, memoryBuffers); + this->m_cachedInstance = createMemoryBuffer(rect, memoryBuffers); } unlockMutex(); - return this->cachedInstance; + return this->m_cachedInstance; } diff --git a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h index b1bf28c9c07..c6db5381f48 100644 --- a/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h +++ b/source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h @@ -26,11 +26,11 @@ class SingleThreadedNodeOperation : public NodeOperation { private: - MemoryBuffer *cachedInstance; + MemoryBuffer *m_cachedInstance; protected: inline bool isCached() { - return cachedInstance != NULL; + return this->m_cachedInstance != NULL; } public: diff --git a/source/blender/compositor/intern/COM_Socket.cpp b/source/blender/compositor/intern/COM_Socket.cpp index 11739a4e9c5..30f28f9dddb 100644 --- a/source/blender/compositor/intern/COM_Socket.cpp +++ b/source/blender/compositor/intern/COM_Socket.cpp @@ -26,18 +26,18 @@ Socket::Socket(DataType datatype) { - this->datatype = datatype; - this->editorSocket = NULL; - this->node = NULL; + this->m_datatype = datatype; + this->m_editorSocket = NULL; + this->m_node = NULL; } DataType Socket::getDataType() const { - return this->datatype; + return this->m_datatype; } int Socket::isInputSocket() const { return false; } int Socket::isOutputSocket() const { return false; } const int Socket::isConnected() const { return false; } -void Socket::setNode(NodeBase *node) { this->node = node; } -NodeBase *Socket::getNode() const { return this->node; } +void Socket::setNode(NodeBase *node) { this->m_node = node; } +NodeBase *Socket::getNode() const { return this->m_node; } diff --git a/source/blender/compositor/intern/COM_Socket.h b/source/blender/compositor/intern/COM_Socket.h index 7c5c2198a16..5607d2f4569 100644 --- a/source/blender/compositor/intern/COM_Socket.h +++ b/source/blender/compositor/intern/COM_Socket.h @@ -29,6 +29,10 @@ #include "DNA_node_types.h" #include "COM_defines.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + using namespace std; class SocketConnection; class NodeBase; @@ -49,15 +53,15 @@ private: /** * Reference to the node where this Socket belongs to */ - NodeBase *node; + NodeBase *m_node; /** * the datatype of this socket. Is used for automatically data transformation. * @section data-conversion */ - DataType datatype; + DataType m_datatype; - bNodeSocket *editorSocket; + bNodeSocket *m_editorSocket; public: Socket(DataType datatype); @@ -71,9 +75,12 @@ public: int isOutputSocket() const; virtual void determineResolution(int resolution[], unsigned int preferredResolution[]) {} - void setEditorSocket(bNodeSocket *editorSocket) { this->editorSocket = editorSocket; } - bNodeSocket *getbNodeSocket() const { return this->editorSocket; } + void setEditorSocket(bNodeSocket *editorSocket) { this->m_editorSocket = editorSocket; } + bNodeSocket *getbNodeSocket() const { return this->m_editorSocket; } +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:Socket") +#endif }; diff --git a/source/blender/compositor/intern/COM_SocketConnection.cpp b/source/blender/compositor/intern/COM_SocketConnection.cpp index 1edeb6158b9..1f2cba72dc0 100644 --- a/source/blender/compositor/intern/COM_SocketConnection.cpp +++ b/source/blender/compositor/intern/COM_SocketConnection.cpp @@ -25,8 +25,8 @@ SocketConnection::SocketConnection() { - this->fromSocket = NULL; - this->toSocket = NULL; + this->m_fromSocket = NULL; + this->m_toSocket = NULL; this->setIgnoreResizeCheck(false); } @@ -35,19 +35,19 @@ void SocketConnection::setFromSocket(OutputSocket *fromsocket) if (fromsocket == NULL) { throw "ERROR"; } - this->fromSocket = fromsocket; + this->m_fromSocket = fromsocket; } -OutputSocket *SocketConnection::getFromSocket() const { return this->fromSocket; } +OutputSocket *SocketConnection::getFromSocket() const { return this->m_fromSocket; } void SocketConnection::setToSocket(InputSocket *tosocket) { if (tosocket == NULL) { throw "ERROR"; } - this->toSocket = tosocket; + this->m_toSocket = tosocket; } -InputSocket *SocketConnection::getToSocket() const { return this->toSocket; } +InputSocket *SocketConnection::getToSocket() const { return this->m_toSocket; } NodeBase *SocketConnection::getFromNode() const { @@ -79,10 +79,10 @@ bool SocketConnection::isValid() const bool SocketConnection::needsResolutionConversion() const { - if (this->ignoreResizeCheck) { return false; } + if (this->m_ignoreResizeCheck) { return false; } NodeOperation *fromOperation = (NodeOperation *)this->getFromNode(); NodeOperation *toOperation = (NodeOperation *)this->getToNode(); - if (this->toSocket->getResizeMode() == COM_SC_NO_RESIZE) { return false; } + if (this->m_toSocket->getResizeMode() == COM_SC_NO_RESIZE) { return false; } const unsigned int fromWidth = fromOperation->getWidth(); const unsigned int fromHeight = fromOperation->getHeight(); const unsigned int toWidth = toOperation->getWidth(); diff --git a/source/blender/compositor/intern/COM_SocketConnection.h b/source/blender/compositor/intern/COM_SocketConnection.h index 5385c5be49b..9777bd45be2 100644 --- a/source/blender/compositor/intern/COM_SocketConnection.h +++ b/source/blender/compositor/intern/COM_SocketConnection.h @@ -48,17 +48,17 @@ private: /** * @brief Startpoint of the connection */ - OutputSocket *fromSocket; + OutputSocket *m_fromSocket; /** * @brief Endpoint of the connection */ - InputSocket *toSocket; + InputSocket *m_toSocket; /** * @brief has the resize already been done for this connection */ - bool ignoreResizeCheck; + bool m_ignoreResizeCheck; public: SocketConnection(); @@ -104,12 +104,12 @@ public: /** * @brief set, whether the resize has already been done for this SocketConnection */ - void setIgnoreResizeCheck(bool check) { this->ignoreResizeCheck = check; } + void setIgnoreResizeCheck(bool check) { this->m_ignoreResizeCheck = check; } /** * @brief has the resize already been done for this SocketConnection */ - bool isIgnoreResizeCheck() const { return this->ignoreResizeCheck; } + bool isIgnoreResizeCheck() const { return this->m_ignoreResizeCheck; } /** * @brief does this SocketConnection need resolution conversion @@ -118,6 +118,10 @@ public: * @return needs conversion [true:false] */ bool needsResolutionConversion() const; + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:SocketConnection") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h index 3eb39e4bf02..0f35fcfb0df 100644 --- a/source/blender/compositor/intern/COM_SocketReader.h +++ b/source/blender/compositor/intern/COM_SocketReader.h @@ -25,6 +25,10 @@ #include "BLI_rect.h" #include "COM_defines.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + typedef enum PixelSampler { COM_PS_NEAREST, COM_PS_BILINEAR, @@ -43,12 +47,12 @@ protected: /** * @brief Holds the width of the output of this operation. */ - unsigned int width; + unsigned int m_width; /** * @brief Holds the height of the output of this operation. */ - unsigned int height; + unsigned int m_height; /** @@ -104,8 +108,12 @@ public: virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return 0; } - inline const unsigned int getWidth() const { return this->width; } - inline const unsigned int getHeight() const { return this->height; } -}; + inline const unsigned int getWidth() const { return this->m_width; } + inline const unsigned int getHeight() const { return this->m_height; } +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:SocketReader") #endif +}; + +#endif /* _COM_SocketReader_h */ diff --git a/source/blender/compositor/intern/COM_WorkPackage.cpp b/source/blender/compositor/intern/COM_WorkPackage.cpp index 07974b9aafc..fa332ffa23e 100644 --- a/source/blender/compositor/intern/COM_WorkPackage.cpp +++ b/source/blender/compositor/intern/COM_WorkPackage.cpp @@ -24,6 +24,6 @@ WorkPackage::WorkPackage(ExecutionGroup *group, unsigned int chunkNumber) { - this->executionGroup = group; - this->chunkNumber = chunkNumber; + this->m_executionGroup = group; + this->m_chunkNumber = chunkNumber; } diff --git a/source/blender/compositor/intern/COM_WorkPackage.h b/source/blender/compositor/intern/COM_WorkPackage.h index 18d83cc151c..953a164e95e 100644 --- a/source/blender/compositor/intern/COM_WorkPackage.h +++ b/source/blender/compositor/intern/COM_WorkPackage.h @@ -24,7 +24,7 @@ class WorkPackage; #ifndef _COM_WorkPackage_h_ #define _COM_WorkPackage_h_ - +class ExecutionGroup; #include "COM_ExecutionGroup.h" /** @@ -36,12 +36,12 @@ private: /** * @brief executionGroup with the operations-setup to be evaluated */ - ExecutionGroup *executionGroup; + ExecutionGroup *m_executionGroup; /** * @brief number of the chunk to be executed */ - unsigned int chunkNumber; + unsigned int m_chunkNumber; public: /** * @constructor @@ -53,12 +53,16 @@ public: /** * @brief get the ExecutionGroup */ - ExecutionGroup *getExecutionGroup() const { return this->executionGroup; } + ExecutionGroup *getExecutionGroup() const { return this->m_executionGroup; } /** * @brief get the number of the chunk */ - unsigned int getChunkNumber() const { return this->chunkNumber; } + unsigned int getChunkNumber() const { return this->m_chunkNumber; } + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:WorkPackage") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index a410c28f47d..c49ac24e018 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -43,24 +43,24 @@ /// @brief list of all CPUDevices. for every hardware thread an instance of CPUDevice is created -static vector<CPUDevice *> cpudevices; +static vector<CPUDevice *> g_cpudevices; #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE /// @brief list of all thread for every CPUDevice in cpudevices a thread exists -static ListBase cputhreads; +static ListBase g_cputhreads; /// @brief all scheduled work for the cpu -static ThreadQueue *cpuqueue; -static ThreadQueue *gpuqueue; +static ThreadQueue *g_cpuqueue; +static ThreadQueue *g_gpuqueue; #ifdef COM_OPENCL_ENABLED -static cl_context context; -static cl_program program; +static cl_context g_context; +static cl_program g_program; /// @brief list of all OpenCLDevices. for every OpenCL GPU device an instance of OpenCLDevice is created -static vector<OpenCLDevice *> gpudevices; +static vector<OpenCLDevice *> g_gpudevices; /// @brief list of all thread for every GPUDevice in cpudevices a thread exists -static ListBase gputhreads; +static ListBase g_gputhreads; /// @brief all scheduled work for the gpu #ifdef COM_OPENCL_ENABLED -static bool openclActive = false; +static bool g_openclActive = false; #endif #endif #endif @@ -72,7 +72,7 @@ void *WorkScheduler::thread_execute_cpu(void *data) Device *device = (Device *)data; WorkPackage *work; - while ((work = (WorkPackage *)BLI_thread_queue_pop(cpuqueue))) { + while ((work = (WorkPackage *)BLI_thread_queue_pop(g_cpuqueue))) { device->execute(work); delete work; } @@ -85,7 +85,7 @@ void *WorkScheduler::thread_execute_gpu(void *data) Device *device = (Device *)data; WorkPackage *work; - while ((work = (WorkPackage *)BLI_thread_queue_pop(gpuqueue))) { + while ((work = (WorkPackage *)BLI_thread_queue_pop(g_gpuqueue))) { device->execute(work); delete work; } @@ -105,11 +105,11 @@ void WorkScheduler::schedule(ExecutionGroup *group, int chunkNumber) delete package; #elif COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE #ifdef COM_OPENCL_ENABLED - if (group->isOpenCL() && openclActive) { - BLI_thread_queue_push(gpuqueue, package); + if (group->isOpenCL() && g_openclActive) { + BLI_thread_queue_push(g_gpuqueue, package); } else { - BLI_thread_queue_push(cpuqueue, package); + BLI_thread_queue_push(g_cpuqueue, package); } #else BLI_thread_queue_push(cpuqueue, package); @@ -121,24 +121,24 @@ void WorkScheduler::start(CompositorContext &context) { #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE unsigned int index; - cpuqueue = BLI_thread_queue_init(); - BLI_init_threads(&cputhreads, thread_execute_cpu, cpudevices.size()); - for (index = 0; index < cpudevices.size(); index++) { - Device *device = cpudevices[index]; - BLI_insert_thread(&cputhreads, device); + g_cpuqueue = BLI_thread_queue_init(); + BLI_init_threads(&g_cputhreads, thread_execute_cpu, g_cpudevices.size()); + for (index = 0; index < g_cpudevices.size(); index++) { + Device *device = g_cpudevices[index]; + BLI_insert_thread(&g_cputhreads, device); } #ifdef COM_OPENCL_ENABLED if (context.getHasActiveOpenCLDevices()) { - gpuqueue = BLI_thread_queue_init(); - BLI_init_threads(&gputhreads, thread_execute_gpu, gpudevices.size()); - for (index = 0; index < gpudevices.size(); index++) { - Device *device = gpudevices[index]; - BLI_insert_thread(&gputhreads, device); + g_gpuqueue = BLI_thread_queue_init(); + BLI_init_threads(&g_gputhreads, thread_execute_gpu, g_gpudevices.size()); + for (index = 0; index < g_gpudevices.size(); index++) { + Device *device = g_gpudevices[index]; + BLI_insert_thread(&g_gputhreads, device); } - openclActive = true; + g_openclActive = true; } else { - openclActive = false; + g_openclActive = false; } #endif #endif @@ -147,12 +147,12 @@ void WorkScheduler::finish() { #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE #ifdef COM_OPENCL_ENABLED - if (openclActive) { - BLI_thread_queue_wait_finish(gpuqueue); - BLI_thread_queue_wait_finish(cpuqueue); + if (g_openclActive) { + BLI_thread_queue_wait_finish(g_gpuqueue); + BLI_thread_queue_wait_finish(g_cpuqueue); } else { - BLI_thread_queue_wait_finish(cpuqueue); + BLI_thread_queue_wait_finish(g_cpuqueue); } #else BLI_thread_queue_wait_finish(cpuqueue); @@ -162,16 +162,16 @@ void WorkScheduler::finish() void WorkScheduler::stop() { #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE - BLI_thread_queue_nowait(cpuqueue); - BLI_end_threads(&cputhreads); - BLI_thread_queue_free(cpuqueue); - cpuqueue = NULL; + BLI_thread_queue_nowait(g_cpuqueue); + BLI_end_threads(&g_cputhreads); + BLI_thread_queue_free(g_cpuqueue); + g_cpuqueue = NULL; #ifdef COM_OPENCL_ENABLED - if (openclActive) { - BLI_thread_queue_nowait(gpuqueue); - BLI_end_threads(&gputhreads); - BLI_thread_queue_free(gpuqueue); - gpuqueue = NULL; + if (g_openclActive) { + BLI_thread_queue_nowait(g_gpuqueue); + BLI_end_threads(&g_gputhreads); + BLI_thread_queue_free(g_gpuqueue); + g_gpuqueue = NULL; } #endif #endif @@ -181,7 +181,7 @@ bool WorkScheduler::hasGPUDevices() { #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE #ifdef COM_OPENCL_ENABLED - return gpudevices.size() > 0; + return g_gpudevices.size() > 0; #else return 0; #endif @@ -203,11 +203,11 @@ void WorkScheduler::initialize() for (int index = 0; index < numberOfCPUThreads; index++) { CPUDevice *device = new CPUDevice(); device->initialize(); - cpudevices.push_back(device); + g_cpudevices.push_back(device); } #ifdef COM_OPENCL_ENABLED - context = NULL; - program = NULL; + g_context = NULL; + g_program = NULL; if (clCreateContextFromType) { cl_uint numberOfPlatforms = 0; cl_int error; @@ -217,60 +217,46 @@ void WorkScheduler::initialize() cl_platform_id *platforms = new cl_platform_id[numberOfPlatforms]; error = clGetPlatformIDs(numberOfPlatforms, platforms, 0); unsigned int indexPlatform; - cl_uint totalNumberOfDevices = 0; for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) { cl_platform_id platform = platforms[indexPlatform]; - cl_uint numberOfDevices; + cl_uint numberOfDevices = 0; clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices); - totalNumberOfDevices += numberOfDevices; - } + if (numberOfDevices>0) { + cl_device_id *cldevices = new cl_device_id[numberOfDevices]; + clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices, 0); - cl_device_id *cldevices = new cl_device_id[totalNumberOfDevices]; - unsigned int numberOfDevicesReceived = 0; - for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) { - cl_platform_id platform = platforms[indexPlatform]; - cl_uint numberOfDevices; - clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices); - clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices + numberOfDevicesReceived * sizeof(cl_device_id), 0); - numberOfDevicesReceived += numberOfDevices; - } - if (totalNumberOfDevices > 0) { - context = clCreateContext(NULL, totalNumberOfDevices, cldevices, clContextError, NULL, &error); - if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - program = clCreateProgramWithSource(context, 1, &clkernelstoh_COM_OpenCLKernels_cl, 0, &error); - error = clBuildProgram(program, totalNumberOfDevices, cldevices, 0, 0, 0); - if (error != CL_SUCCESS) { - cl_int error2; - size_t ret_val_size = 0; - printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); - error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size); - if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - char *build_log = new char[ret_val_size + 1]; - error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL); - if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - build_log[ret_val_size] = '\0'; - printf("%s", build_log); - delete build_log; - - } - else { - unsigned int indexDevices; - for (indexDevices = 0; indexDevices < totalNumberOfDevices; indexDevices++) { - cl_device_id device = cldevices[indexDevices]; - OpenCLDevice *clDevice = new OpenCLDevice(context, device, program); - clDevice->initialize(), - gpudevices.push_back(clDevice); - if (G.f & G_DEBUG) { - char resultString[32]; - error = clGetDeviceInfo(device, CL_DEVICE_NAME, 32, resultString, 0); - printf("OPENCL_DEVICE: %s, ", resultString); - error = clGetDeviceInfo(device, CL_DEVICE_VENDOR, 32, resultString, 0); - printf("%s\n", resultString); + g_context = clCreateContext(NULL, numberOfDevices, cldevices, clContextError, NULL, &error); + if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + g_program = clCreateProgramWithSource(g_context, 1, &clkernelstoh_COM_OpenCLKernels_cl, 0, &error); + error = clBuildProgram(g_program, numberOfDevices, cldevices, 0, 0, 0); + if (error != CL_SUCCESS) { + cl_int error2; + size_t ret_val_size = 0; + printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); + error2 = clGetProgramBuildInfo(g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size); + if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + char *build_log = new char[ret_val_size + 1]; + error2 = clGetProgramBuildInfo(g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL); + if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } + build_log[ret_val_size] = '\0'; + printf("%s", build_log); + delete build_log; + } + else { + unsigned int indexDevices; + for (indexDevices = 0; indexDevices < numberOfDevices; indexDevices++) { + cl_device_id device = cldevices[indexDevices]; + cl_int vendorID = 0; + cl_int error2 = clGetDeviceInfo(device, CL_DEVICE_VENDOR_ID, sizeof(cl_int), &vendorID, NULL); + if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error2, clewErrorString(error2)); } + OpenCLDevice *clDevice = new OpenCLDevice(g_context, device, g_program, vendorID); + clDevice->initialize(); + g_gpudevices.push_back(clDevice); } } + delete[] cldevices; } } - delete[] cldevices; delete[] platforms; } #endif @@ -281,26 +267,26 @@ void WorkScheduler::deinitialize() { #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE Device *device; - while (cpudevices.size() > 0) { - device = cpudevices.back(); - cpudevices.pop_back(); + while (g_cpudevices.size() > 0) { + device = g_cpudevices.back(); + g_cpudevices.pop_back(); device->deinitialize(); delete device; } #ifdef COM_OPENCL_ENABLED - while (gpudevices.size() > 0) { - device = gpudevices.back(); - gpudevices.pop_back(); + while (g_gpudevices.size() > 0) { + device = g_gpudevices.back(); + g_gpudevices.pop_back(); device->deinitialize(); delete device; } - if (program) { - clReleaseProgram(program); - program = NULL; + if (g_program) { + clReleaseProgram(g_program); + g_program = NULL; } - if (context) { - clReleaseContext(context); - context = NULL; + if (g_context) { + clReleaseContext(g_context); + g_context = NULL; } #endif #endif diff --git a/source/blender/compositor/intern/COM_WorkScheduler.h b/source/blender/compositor/intern/COM_WorkScheduler.h index e52e0295607..f56fe94201e 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.h +++ b/source/blender/compositor/intern/COM_WorkScheduler.h @@ -110,5 +110,10 @@ public: * @see CompositorContext.getHasActiveOpenCLDevices */ static bool hasGPUDevices(); -}; + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:WorkScheduler") #endif +}; + +#endif /* _COM_WorkScheduler_h_ */ diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp index 2bbfd18e7c5..9e48334bcca 100644 --- a/source/blender/compositor/intern/COM_compositor.cpp +++ b/source/blender/compositor/intern/COM_compositor.cpp @@ -25,37 +25,57 @@ extern "C" { #include "BLI_threads.h" } +#include "BKE_main.h" +#include "BKE_global.h" #include "COM_compositor.h" #include "COM_ExecutionSystem.h" #include "COM_WorkScheduler.h" #include "OCL_opencl.h" -static ThreadMutex *compositorMutex; -void COM_execute(bNodeTree *editingtree, int rendering) +static ThreadMutex compositorMutex; +static char is_compositorMutex_init = FALSE; +void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) { - if (compositorMutex == NULL) { /// TODO: move to blender startup phase - compositorMutex = new ThreadMutex(); - BLI_mutex_init(compositorMutex); + if (is_compositorMutex_init == FALSE) { /// TODO: move to blender startup phase + memset(&compositorMutex, 0, sizeof(compositorMutex)); + BLI_mutex_init(&compositorMutex); OCL_init(); WorkScheduler::initialize(); ///TODO: call workscheduler.deinitialize somewhere + is_compositorMutex_init = TRUE; } - BLI_mutex_lock(compositorMutex); - if (editingtree->test_break && editingtree->test_break(editingtree->tbh)) { + BLI_mutex_lock(&compositorMutex); + if (editingtree->test_break(editingtree->tbh)) { // during editing multiple calls to this method can be triggered. // make sure one the last one will be doing the work. - BLI_mutex_unlock(compositorMutex); + BLI_mutex_unlock(&compositorMutex); return; } + /* set progress bar to 0% and status to init compositing*/ editingtree->progress(editingtree->prh, 0.0); + bool twopass = (editingtree->flag&NTREE_TWO_PASS) > 0 || rendering; /* initialize execution system */ - ExecutionSystem *system = new ExecutionSystem(editingtree, rendering); + if (twopass) { + ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, twopass); + system->execute(); + delete system; + + if (editingtree->test_break(editingtree->tbh)) { + // during editing multiple calls to this method can be triggered. + // make sure one the last one will be doing the work. + BLI_mutex_unlock(&compositorMutex); + return; + } + } + + + ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, false); system->execute(); delete system; - BLI_mutex_unlock(compositorMutex); + BLI_mutex_unlock(&compositorMutex); } diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.h b/source/blender/compositor/nodes/COM_AlphaOverNode.h index f7375d9a7c5..e25e9e11975 100644 --- a/source/blender/compositor/nodes/COM_AlphaOverNode.h +++ b/source/blender/compositor/nodes/COM_AlphaOverNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_AlphaOverNode_h -#define _COM_AlphaOverNode_h +#ifndef _COM_AlphaOverNode_h_ +#define _COM_AlphaOverNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp index f96a92068f4..683093302c1 100644 --- a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp @@ -35,6 +35,7 @@ void BilateralBlurNode::convertToOperations(ExecutionSystem *graph, CompositorCo { NodeBilateralBlurData *data = (NodeBilateralBlurData *)this->getbNode()->storage; BilateralBlurOperation *operation = new BilateralBlurOperation(); + operation->setbNode(this->getbNode()); operation->setQuality(context->getQuality()); operation->setData(data); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp index 1b541d81c33..5447652c238 100644 --- a/source/blender/compositor/nodes/COM_BlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BlurNode.cpp @@ -49,6 +49,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co if (data->filtertype == R_FILTER_FAST_GAUSS) { FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation(); operationfgb->setData(data); + operationfgb->setbNode(editorNode); this->getInputSocket(0)->relinkConnections(operationfgb->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operationfgb->getInputSocket(1), 1, graph); this->getOutputSocket(0)->relinkConnections(operationfgb->getOutputSocket(0)); @@ -58,12 +59,14 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co else if (!data->bokeh) { GaussianXBlurOperation *operationx = new GaussianXBlurOperation(); operationx->setData(data); + operationx->setbNode(editorNode); operationx->setQuality(quality); this->getInputSocket(0)->relinkConnections(operationx->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operationx->getInputSocket(1), 1, graph); graph->addOperation(operationx); GaussianYBlurOperation *operationy = new GaussianYBlurOperation(); operationy->setData(data); + operationy->setbNode(editorNode); operationy->setQuality(quality); this->getOutputSocket(0)->relinkConnections(operationy->getOutputSocket()); graph->addOperation(operationy); @@ -79,6 +82,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co else { GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation(); operation->setData(data); + operation->setbNode(editorNode); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); operation->setQuality(quality); diff --git a/source/blender/compositor/nodes/COM_BlurNode.h b/source/blender/compositor/nodes/COM_BlurNode.h index e7daff1c414..95b0516dae0 100644 --- a/source/blender/compositor/nodes/COM_BlurNode.h +++ b/source/blender/compositor/nodes/COM_BlurNode.h @@ -29,7 +29,6 @@ * @brief BlurNode * @ingroup Node */ - class BlurNode : public Node { public: BlurNode(bNode *editorNode); diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp index 59ec9525fa6..0ea4b20c793 100644 --- a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp +++ b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp @@ -61,6 +61,7 @@ void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContex this->getInputSocket(3)->relinkConnections(operation->getInputSocket(2), 3, graph); operation->setSize(((bNodeSocketValueFloat *)this->getInputSocket(2)->getbNodeSocket()->default_value)->value); operation->setQuality(context->getQuality()); + operation->setbNode(this->getbNode()); graph->addOperation(operation); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); // } diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.h b/source/blender/compositor/nodes/COM_BokehBlurNode.h index 5ce75a7d42b..c2bc7552ac0 100644 --- a/source/blender/compositor/nodes/COM_BokehBlurNode.h +++ b/source/blender/compositor/nodes/COM_BokehBlurNode.h @@ -29,7 +29,6 @@ * @brief BokehBlurNode * @ingroup Node */ - class BokehBlurNode : public Node { public: BokehBlurNode(bNode *editorNode); diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.h b/source/blender/compositor/nodes/COM_ChannelMatteNode.h index 45d03e18a6a..4efb06c9f87 100644 --- a/source/blender/compositor/nodes/COM_ChannelMatteNode.h +++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef COM_ChannelMatteNODE_H -#define COM_ChannelMatteNODE_H +#ifndef _COM_ChannelMatteNode_h_ +#define _COM_ChannelMatteNode_h_ #include "COM_Node.h" @@ -28,8 +28,7 @@ * @brief ChannelMatteNode * @ingroup Node */ -class ChannelMatteNode : public Node -{ +class ChannelMatteNode : public Node { public: ChannelMatteNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.h b/source/blender/compositor/nodes/COM_ChromaMatteNode.h index ed8250b0329..ddd350aab40 100644 --- a/source/blender/compositor/nodes/COM_ChromaMatteNode.h +++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef COM_ChromaMatteNODE_H -#define COM_ChromaMatteNODE_H +#ifndef _COM_ChromaMatteNode_h_ +#define _COM_ChromaMatteNode_h_ #include "COM_Node.h" @@ -28,8 +28,7 @@ * @brief ChromaMatteNode * @ingroup Node */ -class ChromaMatteNode : public Node -{ +class ChromaMatteNode : public Node { public: ChromaMatteNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.h b/source/blender/compositor/nodes/COM_ColorBalanceNode.h index c2bdc306e20..cdad02fc831 100644 --- a/source/blender/compositor/nodes/COM_ColorBalanceNode.h +++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef COM_ColorBalanceNODE_H -#define COM_ColorBalanceNODE_H +#ifndef _COM_ColorBalanceNode_h_ +#define _COM_ColorBalanceNode_h_ #include "COM_Node.h" @@ -29,8 +29,7 @@ * @brief ColorBalanceNode * @ingroup Node */ -class ColorBalanceNode : public Node -{ +class ColorBalanceNode : public Node { public: ColorBalanceNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.h b/source/blender/compositor/nodes/COM_ColorMatteNode.h index 375c914a122..92a4fa79408 100644 --- a/source/blender/compositor/nodes/COM_ColorMatteNode.h +++ b/source/blender/compositor/nodes/COM_ColorMatteNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef COM_ColorMatteNODE_H -#define COM_ColorMatteNODE_H +#ifndef _COM_ColorMatteNode_h_ +#define _COM_ColorMatteNode_h_ #include "COM_Node.h" @@ -28,8 +28,7 @@ * @brief ColorMatteNode * @ingroup Node */ -class ColorMatteNode : public Node -{ +class ColorMatteNode : public Node { public: ColorMatteNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.h b/source/blender/compositor/nodes/COM_ColorRampNode.h index 4d706e126e1..6c256c09e68 100644 --- a/source/blender/compositor/nodes/COM_ColorRampNode.h +++ b/source/blender/compositor/nodes/COM_ColorRampNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef COM_ColorRampNODE_H -#define COM_ColorRampNODE_H +#ifndef _COM_ColorRampNode_h_ +#define _COM_ColorRampNode_h_ #include "COM_Node.h" @@ -29,8 +29,7 @@ * @brief ColorRampNode * @ingroup Node */ -class ColorRampNode : public Node -{ +class ColorRampNode : public Node { public: ColorRampNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.h b/source/blender/compositor/nodes/COM_ColorSpillNode.h index d8ce6878fa0..1d976fc65ae 100644 --- a/source/blender/compositor/nodes/COM_ColorSpillNode.h +++ b/source/blender/compositor/nodes/COM_ColorSpillNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef COM_ColorSpillNODE_H -#define COM_ColorSpillNODE_H +#ifndef _COM_ColorSpillNode_h_ +#define _COM_ColorSpillNode_h_ #include "COM_Node.h" @@ -29,8 +29,7 @@ * @brief ColorSpillNode * @ingroup Node */ -class ColorSpillNode : public Node -{ +class ColorSpillNode : public Node { public: ColorSpillNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp index 430f317eae2..511fdf09f41 100644 --- a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp +++ b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp @@ -25,18 +25,18 @@ #include "COM_ConvertColorToBWOperation.h" #include "COM_ExecutionSystem.h" -ColourToBWNode::ColourToBWNode(bNode *editorNode) : Node(editorNode) +ColorToBWNode::ColorToBWNode(bNode *editorNode) : Node(editorNode) { /* pass */ } -void ColourToBWNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) +void ColorToBWNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { - InputSocket *colourSocket = this->getInputSocket(0); + InputSocket *colorSocket = this->getInputSocket(0); OutputSocket *valueSocket = this->getOutputSocket(0); ConvertColorToBWOperation *convertProg = new ConvertColorToBWOperation(); - colourSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph); + colorSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph); valueSocket->relinkConnections(convertProg->getOutputSocket(0)); graph->addOperation(convertProg); } diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.h b/source/blender/compositor/nodes/COM_ColorToBWNode.h index 34a157c73d8..f21c6ecef52 100644 --- a/source/blender/compositor/nodes/COM_ColorToBWNode.h +++ b/source/blender/compositor/nodes/COM_ColorToBWNode.h @@ -20,18 +20,18 @@ * Monique Dewanchand */ -#ifndef _COM_ColourToBWNode_h -#define _COM_ColourToBWNode_h +#ifndef _COM_ColorToBWNode_h_ +#define _COM_ColorToBWNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" /** - * @brief ColourToBWNode + * @brief ColorToBWNode * @ingroup Node */ -class ColourToBWNode : public Node { +class ColorToBWNode : public Node { public: - ColourToBWNode(bNode *editorNode); + ColorToBWNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); }; #endif diff --git a/source/blender/compositor/nodes/COM_CombineHSVANode.h b/source/blender/compositor/nodes/COM_CombineHSVANode.h index d8aba71d456..95d3cf9ecdd 100644 --- a/source/blender/compositor/nodes/COM_CombineHSVANode.h +++ b/source/blender/compositor/nodes/COM_CombineHSVANode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_CombineHSVANode_h -#define _COM_CombineHSVANode_h +#ifndef _COM_CombineHSVANode_h_ +#define _COM_CombineHSVANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_CombineRGBANode.h b/source/blender/compositor/nodes/COM_CombineRGBANode.h index 1f25d8deed9..5cc0b1ea6da 100644 --- a/source/blender/compositor/nodes/COM_CombineRGBANode.h +++ b/source/blender/compositor/nodes/COM_CombineRGBANode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_CombineRGBANode_h -#define _COM_CombineRGBANode_h +#ifndef _COM_CombineRGBANode_h_ +#define _COM_CombineRGBANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_CombineYCCANode.h b/source/blender/compositor/nodes/COM_CombineYCCANode.h index 3b143aabc7f..6ff2938c161 100644 --- a/source/blender/compositor/nodes/COM_CombineYCCANode.h +++ b/source/blender/compositor/nodes/COM_CombineYCCANode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_CombineYCCANode_h -#define _COM_CombineYCCANode_h +#ifndef _COM_CombineYCCANode_h_ +#define _COM_CombineYCCANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_CombineYUVANode.h b/source/blender/compositor/nodes/COM_CombineYUVANode.h index 1eae44c83a5..e3d8f36a5dd 100644 --- a/source/blender/compositor/nodes/COM_CombineYUVANode.h +++ b/source/blender/compositor/nodes/COM_CombineYUVANode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_CombineYUVANode_h -#define _COM_CombineYUVANode_h +#ifndef _COM_CombineYUVANode_h_ +#define _COM_CombineYUVANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp index fccb92ddd8b..28e466203c4 100644 --- a/source/blender/compositor/nodes/COM_CompositorNode.cpp +++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp @@ -34,12 +34,12 @@ void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorConte InputSocket *imageSocket = this->getInputSocket(0); InputSocket *alphaSocket = this->getInputSocket(1); if (imageSocket->isConnected()) { - CompositorOperation *colourAlphaProg = new CompositorOperation(); - colourAlphaProg->setScene(context->getScene()); - colourAlphaProg->setbNodeTree(context->getbNodeTree()); - imageSocket->relinkConnections(colourAlphaProg->getInputSocket(0)); - alphaSocket->relinkConnections(colourAlphaProg->getInputSocket(1)); - graph->addOperation(colourAlphaProg); - addPreviewOperation(graph, colourAlphaProg->getInputSocket(0)); + CompositorOperation *colorAlphaProg = new CompositorOperation(); + colorAlphaProg->setRenderData(context->getRenderData()); + colorAlphaProg->setbNodeTree(context->getbNodeTree()); + imageSocket->relinkConnections(colorAlphaProg->getInputSocket(0)); + alphaSocket->relinkConnections(colorAlphaProg->getInputSocket(1)); + graph->addOperation(colorAlphaProg); + addPreviewOperation(graph, colorAlphaProg->getInputSocket(0)); } } diff --git a/source/blender/compositor/nodes/COM_CompositorNode.h b/source/blender/compositor/nodes/COM_CompositorNode.h index 585dae7761e..54d52d7db9e 100644 --- a/source/blender/compositor/nodes/COM_CompositorNode.h +++ b/source/blender/compositor/nodes/COM_CompositorNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_CompositorNode_h -#define _COM_CompositorNode_h +#ifndef _COM_CompositorNode_h_ +#define _COM_CompositorNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.h b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h index d9077c23a02..a80f8de1607 100644 --- a/source/blender/compositor/nodes/COM_ConvertAlphaNode.h +++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_ConvertAlphaNode_h -#define _COM_ConvertAlphaNode_h +#ifndef _COM_ConvertAlphaNode_h_ +#define _COM_ConvertAlphaNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_CropNode.h b/source/blender/compositor/nodes/COM_CropNode.h index 44fdeecc180..1003728a9d4 100644 --- a/source/blender/compositor/nodes/COM_CropNode.h +++ b/source/blender/compositor/nodes/COM_CropNode.h @@ -25,6 +25,10 @@ #include "COM_Node.h" +/** + * @brief CropNode + * @ingroup Node + */ class CropNode : public Node { public: CropNode(bNode *editorNode); diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp index 461505871c6..4c6b3ad137b 100644 --- a/source/blender/compositor/nodes/COM_DefocusNode.cpp +++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp @@ -46,6 +46,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext NodeDefocus *data = (NodeDefocus *)node->storage; NodeOperation *radiusOperation; + OutputSocket * depthOperation; if (data->no_zbuf) { MathMultiplyOperation *multiply = new MathMultiplyOperation(); SetValueOperation *multiplier = new SetValueOperation(); @@ -63,6 +64,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext graph->addOperation(maxRadius); graph->addOperation(minimize); radiusOperation = minimize; + depthOperation = minimize->getOutputSocket(0); } else { ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation(); @@ -72,6 +74,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext this->getInputSocket(1)->relinkConnections(converter->getInputSocket(0), 1, graph); graph->addOperation(converter); radiusOperation = converter; + depthOperation = converter->getInputSocket(0)->getConnection()->getFromSocket(); } BokehImageOperation *bokeh = new BokehImageOperation(); @@ -89,7 +92,15 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext bokeh->setData(bokehdata); bokeh->deleteDataOnFinish(); graph->addOperation(bokeh); - + +#ifdef COM_DEFOCUS_SEARCH + InverseSearchRadiusOperation *search = new InverseSearchRadiusOperation(); + addLink(graph, radiusOperation->getOutputSocket(0), search->getInputSocket(0)); + addLink(graph, depthOperation, search->getInputSocket(1)); + search->setMaxBlur(data->maxblur); + search->setThreshold(data->bthresh); + graph->addOperation(search); +#endif VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); if (data->preview) { operation->setQuality(COM_QUALITY_LOW); @@ -97,10 +108,14 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext operation->setQuality(context->getQuality()); } operation->setMaxBlur(data->maxblur); + operation->setbNode(node); operation->setThreshold(data->bthresh); addLink(graph, bokeh->getOutputSocket(), operation->getInputSocket(1)); addLink(graph, radiusOperation->getOutputSocket(), operation->getInputSocket(2)); - addLink(graph, radiusOperation->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(3)); + addLink(graph, depthOperation, operation->getInputSocket(3)); +#ifdef COM_DEFOCUS_SEARCH + addLink(graph, search->getOutputSocket(), operation->getInputSocket(4)); +#endif if (data->gamco) { GammaCorrectOperation *correct = new GammaCorrectOperation(); GammaUncorrectOperation *inverse = new GammaUncorrectOperation(); @@ -115,6 +130,5 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket()->relinkConnections(operation->getOutputSocket()); } - graph->addOperation(operation); } diff --git a/source/blender/compositor/nodes/COM_DefocusNode.h b/source/blender/compositor/nodes/COM_DefocusNode.h index a3cffbd98c4..7d69b6413bb 100644 --- a/source/blender/compositor/nodes/COM_DefocusNode.h +++ b/source/blender/compositor/nodes/COM_DefocusNode.h @@ -29,7 +29,6 @@ * @brief DefocusNode * @ingroup Node */ - class DefocusNode : public Node { public: DefocusNode(bNode *editorNode); diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h index faaf235bf34..191b7361c3c 100644 --- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h +++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef COM_DifferenceMatteNODE_H -#define COM_DifferenceMatteNODE_H +#ifndef _COM_DifferenceMatteNode_h_ +#define _COM_DifferenceMatteNode_h_ #include "COM_Node.h" @@ -29,8 +29,7 @@ * @brief DifferenceMatteNode * @ingroup Node */ -class DifferenceMatteNode : public Node -{ +class DifferenceMatteNode : public Node { public: DifferenceMatteNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp index fbec1522e27..043ae367fbb 100644 --- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp +++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp @@ -40,6 +40,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont bNode *editorNode = this->getbNode(); if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_THRESH) { DilateErodeThresholdOperation *operation = new DilateErodeThresholdOperation(); + operation->setbNode(editorNode); operation->setDistance(editorNode->custom2); operation->setInset(editorNode->custom3); @@ -59,6 +60,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE) { if (editorNode->custom2 > 0) { DilateDistanceOperation *operation = new DilateDistanceOperation(); + operation->setbNode(editorNode); operation->setDistance(editorNode->custom2); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); @@ -66,6 +68,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont } else { ErodeDistanceOperation *operation = new ErodeDistanceOperation(); + operation->setbNode(editorNode); operation->setDistance(-editorNode->custom2); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); @@ -77,7 +80,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont CompositorQuality quality = context->getQuality(); /* initialize node data */ - NodeBlurData *data = (NodeBlurData *)&this->alpha_blur; + NodeBlurData *data = (NodeBlurData *)&this->m_alpha_blur; memset(data, 0, sizeof(*data)); data->filtertype = R_FILTER_GAUSS; @@ -90,12 +93,14 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont } GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation(); + operationx->setbNode(editorNode); operationx->setData(data); operationx->setQuality(quality); this->getInputSocket(0)->relinkConnections(operationx->getInputSocket(0), 0, graph); // this->getInputSocket(1)->relinkConnections(operationx->getInputSocket(1), 1, graph); // no size input yet graph->addOperation(operationx); GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); + operationy->setbNode(editorNode); operationy->setData(data); operationy->setQuality(quality); this->getOutputSocket(0)->relinkConnections(operationy->getOutputSocket()); @@ -117,10 +122,17 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont #endif operationx->setSubtract(editorNode->custom2 < 0); operationy->setSubtract(editorNode->custom2 < 0); + + if (editorNode->storage) { + NodeDilateErode *data_storage = (NodeDilateErode *)editorNode->storage; + operationx->setFalloff(data_storage->falloff); + operationy->setFalloff(data_storage->falloff); + } } else { if (editorNode->custom2 > 0) { DilateStepOperation *operation = new DilateStepOperation(); + operation->setbNode(editorNode); operation->setIterations(editorNode->custom2); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); @@ -128,6 +140,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont } else { ErodeStepOperation *operation = new ErodeStepOperation(); + operation->setbNode(editorNode); operation->setIterations(-editorNode->custom2); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.h b/source/blender/compositor/nodes/COM_DilateErodeNode.h index ac374d7375b..4b02042ffc9 100644 --- a/source/blender/compositor/nodes/COM_DilateErodeNode.h +++ b/source/blender/compositor/nodes/COM_DilateErodeNode.h @@ -30,7 +30,7 @@ * @ingroup Node */ class DilateErodeNode : public Node { - NodeBlurData alpha_blur; /* only used for blurring alpha, since the dilate/erode node doesnt have this */ + NodeBlurData m_alpha_blur; /* only used for blurring alpha, since the dilate/erode node doesnt have this */ public: DilateErodeNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.h b/source/blender/compositor/nodes/COM_DisplaceNode.h index ecbe07b06b9..af6afc25366 100644 --- a/source/blender/compositor/nodes/COM_DisplaceNode.h +++ b/source/blender/compositor/nodes/COM_DisplaceNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_DisplaceNode_h -#define _COM_DisplaceNode_h +#ifndef _COM_DisplaceNode_h_ +#define _COM_DisplaceNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.h b/source/blender/compositor/nodes/COM_DistanceMatteNode.h index 42582ef10a0..4e6682424e8 100644 --- a/source/blender/compositor/nodes/COM_DistanceMatteNode.h +++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef COM_DistanceMatteNODE_H -#define COM_DistanceMatteNODE_H +#ifndef _COM_DistanceMatteNode_h_ +#define _COM_DistanceMatteNode_h_ #include "COM_Node.h" @@ -28,8 +28,7 @@ * @brief DistanceMatteNode * @ingroup Node */ -class DistanceMatteNode : public Node -{ +class DistanceMatteNode : public Node { public: DistanceMatteNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp index 57c319e7630..ab1d83385c7 100644 --- a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp +++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp @@ -36,6 +36,7 @@ void DoubleEdgeMaskNode::convertToOperations(ExecutionSystem *system, Compositor bNode *bnode = this->getbNode(); operation = new DoubleEdgeMaskOperation(); + operation->setbNode(bnode); operation->setAdjecentOnly(bnode->custom1); operation->setKeepInside(bnode->custom2); diff --git a/source/blender/compositor/nodes/COM_FilterNode.cpp b/source/blender/compositor/nodes/COM_FilterNode.cpp index 23f87805821..021ec6c2508 100644 --- a/source/blender/compositor/nodes/COM_FilterNode.cpp +++ b/source/blender/compositor/nodes/COM_FilterNode.cpp @@ -73,7 +73,7 @@ void FilterNode::convertToOperations(ExecutionSystem *graph, CompositorContext * operation->set3x3Filter(0, 0, 0, 0, 1, 0, 0, 0, 0); break; } - + operation->setbNode(this->getbNode()); inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph); inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph); outputSocket->relinkConnections(operation->getOutputSocket()); diff --git a/source/blender/compositor/nodes/COM_FilterNode.h b/source/blender/compositor/nodes/COM_FilterNode.h index 17f590b9cfc..d65166944d8 100644 --- a/source/blender/compositor/nodes/COM_FilterNode.h +++ b/source/blender/compositor/nodes/COM_FilterNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef COM_FILTERNODE_H -#define COM_FILTERNODE_H +#ifndef _COM_FilterNode_h_ +#define _COM_FilterNode_h_ #include "COM_Node.h" @@ -29,11 +29,10 @@ * @brief FilterNode * @ingroup Node */ -class FilterNode : public Node -{ +class FilterNode : public Node { public: FilterNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); }; -#endif // COM_FILTERNODE_H +#endif // _COM_FilterNode_h_ diff --git a/source/blender/compositor/nodes/COM_GlareNode.cpp b/source/blender/compositor/nodes/COM_GlareNode.cpp index 7b34fa4d286..8782e6bb6d9 100644 --- a/source/blender/compositor/nodes/COM_GlareNode.cpp +++ b/source/blender/compositor/nodes/COM_GlareNode.cpp @@ -63,6 +63,8 @@ void GlareNode::convertToOperations(ExecutionSystem *system, CompositorContext * SetValueOperation *mixvalueoperation = new SetValueOperation(); MixGlareOperation *mixoperation = new MixGlareOperation(); mixoperation->getInputSocket(2)->setResizeMode(COM_SC_FIT); + thresholdOperation->setbNode(node); + glareoperation->setbNode(node); this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), 0, system); addLink(system, thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_GroupNode.cpp b/source/blender/compositor/nodes/COM_GroupNode.cpp index e5255b6bb87..6ad58caf17b 100644 --- a/source/blender/compositor/nodes/COM_GroupNode.cpp +++ b/source/blender/compositor/nodes/COM_GroupNode.cpp @@ -37,6 +37,7 @@ void GroupNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c void GroupNode::ungroup(ExecutionSystem &system) { bNode *bnode = this->getbNode(); + bNodeTree *subtree = (bNodeTree *)bnode->id; vector<InputSocket *> &inputsockets = this->getInputSockets(); vector<OutputSocket *> &outputsockets = this->getOutputSockets(); unsigned int index; @@ -44,6 +45,10 @@ void GroupNode::ungroup(ExecutionSystem &system) /* get the node list size _before_ adding proxy nodes, so they are available for linking */ int nodes_start = system.getNodes().size(); + /* missing node group datablock can happen with library linking */ + if (!subtree) + return; + for (index = 0; index < inputsockets.size(); index++) { InputSocket *inputSocket = inputsockets[index]; bNodeSocket *editorInput = inputSocket->getbNodeSocket(); @@ -64,6 +69,5 @@ void GroupNode::ungroup(ExecutionSystem &system) } } - bNodeTree *subtree = (bNodeTree *)bnode->id; ExecutionSystemHelper::addbNodeTree(system, nodes_start, subtree, bnode); } diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp index 6057a7f0e6c..fd961030ebf 100644 --- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp +++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp @@ -22,7 +22,7 @@ #include "COM_HueSaturationValueCorrectNode.h" -#include "COM_ConvertColourToValueProg.h" +#include "COM_ConvertColorToValueProg.h" #include "COM_ExecutionSystem.h" #include "COM_ConvertRGBToHSVOperation.h" #include "COM_ConvertHSVToRGBOperation.h" @@ -41,32 +41,30 @@ HueSaturationValueCorrectNode::HueSaturationValueCorrectNode(bNode *editorNode) void HueSaturationValueCorrectNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *valueSocket = this->getInputSocket(0); - InputSocket *colourSocket = this->getInputSocket(1); + InputSocket *colorSocket = this->getInputSocket(1); OutputSocket *outputSocket = this->getOutputSocket(0); bNode *editorsnode = getbNode(); CurveMapping *storage = (CurveMapping *)editorsnode->storage; - if (colourSocket->isConnected() && outputSocket->isConnected()) { - ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation(); - ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation(); - HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation(); - MixBlendOperation *blend = new MixBlendOperation(); - - colourSocket->relinkConnections(rgbToHSV->getInputSocket(0), 1, graph); - addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); - addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); - addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); - addLink(graph, rgbToHSV->getInputSocket(0)->getConnection()->getFromSocket(), blend->getInputSocket(1)); - valueSocket->relinkConnections(blend->getInputSocket(0), 0, graph); - outputSocket->relinkConnections(blend->getOutputSocket()); - - changeHSV->setCurveMapping(storage); - - blend->setResolutionInputSocketIndex(1); - - graph->addOperation(rgbToHSV); - graph->addOperation(hsvToRGB); - graph->addOperation(changeHSV); - graph->addOperation(blend); - } + ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation(); + ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation(); + HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation(); + MixBlendOperation *blend = new MixBlendOperation(); + + colorSocket->relinkConnections(rgbToHSV->getInputSocket(0), 1, graph); + addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); + addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); + addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); + addLink(graph, rgbToHSV->getInputSocket(0)->getConnection()->getFromSocket(), blend->getInputSocket(1)); + valueSocket->relinkConnections(blend->getInputSocket(0), 0, graph); + outputSocket->relinkConnections(blend->getOutputSocket()); + + changeHSV->setCurveMapping(storage); + + blend->setResolutionInputSocketIndex(1); + + graph->addOperation(rgbToHSV); + graph->addOperation(hsvToRGB); + graph->addOperation(changeHSV); + graph->addOperation(blend); } diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h index ed5f2b51ce3..dd5f70f6579 100644 --- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h +++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_HueSaturationValueCorrectNode_h -#define _COM_HueSaturationValueCorrectNode_h +#ifndef _COM_HueSaturationValueCorrectNode_h_ +#define _COM_HueSaturationValueCorrectNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp index ef501317e48..9b55b809212 100644 --- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp +++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp @@ -22,7 +22,7 @@ #include "COM_HueSaturationValueNode.h" -#include "COM_ConvertColourToValueProg.h" +#include "COM_ConvertColorToValueProg.h" #include "COM_ExecutionSystem.h" #include "COM_ConvertRGBToHSVOperation.h" #include "COM_ConvertHSVToRGBOperation.h" @@ -40,7 +40,7 @@ HueSaturationValueNode::HueSaturationValueNode(bNode *editorNode) : Node(editorN void HueSaturationValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { InputSocket *valueSocket = this->getInputSocket(0); - InputSocket *colourSocket = this->getInputSocket(1); + InputSocket *colorSocket = this->getInputSocket(1); OutputSocket *outputSocket = this->getOutputSocket(0); bNode *editorsnode = getbNode(); NodeHueSat *storage = (NodeHueSat *)editorsnode->storage; @@ -50,7 +50,7 @@ void HueSaturationValueNode::convertToOperations(ExecutionSystem *graph, Composi ChangeHSVOperation *changeHSV = new ChangeHSVOperation(); MixBlendOperation *blend = new MixBlendOperation(); - colourSocket->relinkConnections(rgbToHSV->getInputSocket(0), 0, graph); + colorSocket->relinkConnections(rgbToHSV->getInputSocket(0), 0, graph); addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h index 92c18019196..47b89a35269 100644 --- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h +++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_HueSaturationValueNode_h -#define _COM_HueSaturationValueNode_h +#ifndef _COM_HueSaturationValueNode_h_ +#define _COM_HueSaturationValueNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.cpp b/source/blender/compositor/nodes/COM_IDMaskNode.cpp index 4005e5d2900..31d2ccb391e 100644 --- a/source/blender/compositor/nodes/COM_IDMaskNode.cpp +++ b/source/blender/compositor/nodes/COM_IDMaskNode.cpp @@ -38,7 +38,7 @@ void IDMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * operation->setObjectIndex(bnode->custom1); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); - if (bnode->custom2 == 0 || context->getScene()->r.scemode & R_FULL_SAMPLE) { + if (bnode->custom2 == 0 || context->getRenderData()->scemode & R_FULL_SAMPLE) { this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); } else { diff --git a/source/blender/compositor/nodes/COM_ImageNode.h b/source/blender/compositor/nodes/COM_ImageNode.h index 384dd6c09ff..49006efbed5 100644 --- a/source/blender/compositor/nodes/COM_ImageNode.h +++ b/source/blender/compositor/nodes/COM_ImageNode.h @@ -34,7 +34,6 @@ extern "C" { * @ingroup Node */ class ImageNode : public Node { - private: NodeOperation *doMultilayerCheck(ExecutionSystem *system, RenderLayer *rl, Image *image, ImageUser *user, int framenumber, int outputsocketIndex, int pass, DataType datatype); public: diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp index 50c1903982e..7c39765fbf1 100644 --- a/source/blender/compositor/nodes/COM_KeyingNode.cpp +++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp @@ -34,13 +34,15 @@ #include "COM_CombineChannelsOperation.h" #include "COM_ConvertRGBToYCCOperation.h" #include "COM_ConvertYCCToRGBOperation.h" -#include "COM_GaussianBokehBlurOperation.h" #include "COM_SetValueOperation.h" #include "COM_DilateErodeOperation.h" #include "COM_SetAlphaOperation.h" +#include "COM_GaussianAlphaXBlurOperation.h" +#include "COM_GaussianAlphaYBlurOperation.h" + KeyingNode::KeyingNode(bNode *editorNode) : Node(editorNode) { /* pass */ @@ -67,13 +69,23 @@ OutputSocket *KeyingNode::setupPreBlur(ExecutionSystem *graph, InputSocket *inpu addLink(graph, separateOperation->getOutputSocket(0), combineOperation->getInputSocket(channel)); } else { - KeyingBlurOperation *blurOperation = new KeyingBlurOperation(); + KeyingBlurOperation *blurXOperation = new KeyingBlurOperation(); + KeyingBlurOperation *blurYOperation = new KeyingBlurOperation(); + + blurXOperation->setSize(size); + blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X); + blurXOperation->setbNode(this->getbNode()); + + blurYOperation->setSize(size); + blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y); + blurYOperation->setbNode(this->getbNode()); - blurOperation->setSize(size); + addLink(graph, separateOperation->getOutputSocket(), blurXOperation->getInputSocket(0)); + addLink(graph, blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0)); + addLink(graph, blurYOperation->getOutputSocket(0), combineOperation->getInputSocket(channel)); - addLink(graph, separateOperation->getOutputSocket(0), blurOperation->getInputSocket(0)); - addLink(graph, blurOperation->getOutputSocket(0), combineOperation->getInputSocket(channel)); - graph->addOperation(blurOperation); + graph->addOperation(blurXOperation); + graph->addOperation(blurYOperation); } } @@ -87,31 +99,41 @@ OutputSocket *KeyingNode::setupPreBlur(ExecutionSystem *graph, InputSocket *inpu return convertYCCToRGBOperation->getOutputSocket(0); } -OutputSocket *KeyingNode::setupPostBlur(ExecutionSystem *graph, OutputSocket *postBLurInput, int size) +OutputSocket *KeyingNode::setupPostBlur(ExecutionSystem *graph, OutputSocket *postBlurInput, int size) { - KeyingBlurOperation *blurOperation = new KeyingBlurOperation(); + KeyingBlurOperation *blurXOperation = new KeyingBlurOperation(); + KeyingBlurOperation *blurYOperation = new KeyingBlurOperation(); - blurOperation->setSize(size); + blurXOperation->setSize(size); + blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X); + blurXOperation->setbNode(this->getbNode()); - addLink(graph, postBLurInput, blurOperation->getInputSocket(0)); + blurYOperation->setSize(size); + blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y); + blurYOperation->setbNode(this->getbNode()); - graph->addOperation(blurOperation); + addLink(graph, postBlurInput, blurXOperation->getInputSocket(0)); + addLink(graph, blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0)); - return blurOperation->getOutputSocket(); + graph->addOperation(blurXOperation); + graph->addOperation(blurYOperation); + + return blurYOperation->getOutputSocket(); } OutputSocket *KeyingNode::setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance) { - DilateStepOperation *dilateErodeOperation; + DilateDistanceOperation *dilateErodeOperation; if (distance > 0) { - dilateErodeOperation = new DilateStepOperation(); - dilateErodeOperation->setIterations(distance); + dilateErodeOperation = new DilateDistanceOperation(); + dilateErodeOperation->setDistance(distance); } else { - dilateErodeOperation = new ErodeStepOperation(); - dilateErodeOperation->setIterations(-distance); + dilateErodeOperation = new ErodeDistanceOperation(); + dilateErodeOperation->setDistance(-distance); } + dilateErodeOperation->setbNode(this->getbNode()); addLink(graph, dilateErodeInput, dilateErodeOperation->getInputSocket(0)); @@ -120,6 +142,48 @@ OutputSocket *KeyingNode::setupDilateErode(ExecutionSystem *graph, OutputSocket return dilateErodeOperation->getOutputSocket(0); } +OutputSocket *KeyingNode::setupFeather(ExecutionSystem *graph, CompositorContext *context, + OutputSocket *featherInput, int falloff, int distance) +{ + /* this uses a modified gaussian blur function otherwise its far too slow */ + CompositorQuality quality = context->getQuality(); + + /* initialize node data */ + NodeBlurData *data = (NodeBlurData *)&this->m_alpha_blur; + memset(data, 0, sizeof(*data)); + data->filtertype = R_FILTER_GAUSS; + + if (distance > 0) { + data->sizex = data->sizey = distance; + } + else { + data->sizex = data->sizey = -distance; + } + + GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation(); + operationx->setData(data); + operationx->setQuality(quality); + operationx->setSize(1.0f); + operationx->setSubtract(distance < 0); + operationx->setFalloff(falloff); + operationx->setbNode(this->getbNode()); + graph->addOperation(operationx); + + GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); + operationy->setData(data); + operationy->setQuality(quality); + operationy->setSize(1.0f); + operationy->setSubtract(distance < 0); + operationy->setFalloff(falloff); + operationy->setbNode(this->getbNode()); + graph->addOperation(operationy); + + addLink(graph, featherInput, operationx->getInputSocket(0)); + addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0)); + + return operationy->getOutputSocket(); +} + OutputSocket *KeyingNode::setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputScreen, float factor) { KeyingDespillOperation *despillOperation = new KeyingDespillOperation(); @@ -162,7 +226,7 @@ void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext * OutputSocket *outputImage = this->getOutputSocket(0); OutputSocket *outputMatte = this->getOutputSocket(1); OutputSocket *outputEdges = this->getOutputSocket(2); - OutputSocket *postprocessedMatte, *postprocessedImage, *originalImage, *edgesMatte; + OutputSocket *postprocessedMatte = NULL, *postprocessedImage = NULL, *originalImage = NULL, *edgesMatte = NULL; bNode *editorNode = this->getbNode(); NodeKeyingData *keying_data = (NodeKeyingData *) editorNode->storage; @@ -196,9 +260,11 @@ void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext * keying_data->clip_black, keying_data->clip_white, false); } - edgesMatte = setupClip(graph, postprocessedMatte, - keying_data->edge_kernel_radius, keying_data->edge_kernel_tolerance, - keying_data->clip_black, keying_data->clip_white, true); + if (outputEdges->isConnected()) { + edgesMatte = setupClip(graph, postprocessedMatte, + keying_data->edge_kernel_radius, keying_data->edge_kernel_tolerance, + keying_data->clip_black, keying_data->clip_white, true); + } /* apply blur on matte if needed */ if (keying_data->blur_post) @@ -209,6 +275,12 @@ void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext * postprocessedMatte = setupDilateErode(graph, postprocessedMatte, keying_data->dilate_distance); } + /* matte feather */ + if (keying_data->feather_distance != 0) { + postprocessedMatte = setupFeather(graph, context, postprocessedMatte, keying_data->feather_falloff, + keying_data->feather_distance); + } + /* set alpha channel to output image */ SetAlphaOperation *alphaOperation = new SetAlphaOperation(); addLink(graph, originalImage, alphaOperation->getInputSocket(0)); @@ -226,7 +298,9 @@ void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext * /* connect result to output sockets */ outputImage->relinkConnections(postprocessedImage); outputMatte->relinkConnections(postprocessedMatte); - outputEdges->relinkConnections(edgesMatte); + + if (edgesMatte) + outputEdges->relinkConnections(edgesMatte); graph->addOperation(alphaOperation); } diff --git a/source/blender/compositor/nodes/COM_KeyingNode.h b/source/blender/compositor/nodes/COM_KeyingNode.h index cc1d447c66e..294a27bb52c 100644 --- a/source/blender/compositor/nodes/COM_KeyingNode.h +++ b/source/blender/compositor/nodes/COM_KeyingNode.h @@ -24,14 +24,18 @@ #include "COM_Node.h" /** - * @brief KeyingNode - * @ingroup Node - */ + * @brief KeyingNode + * @ingroup Node + */ class KeyingNode : public Node { protected: + NodeBlurData m_alpha_blur; /* only used for blurring alpha, since the dilate/erode node doesnt have this */ + OutputSocket *setupPreBlur(ExecutionSystem *graph, InputSocket *inputImage, int size, OutputSocket **originalImage); - OutputSocket *setupPostBlur(ExecutionSystem *graph, OutputSocket *postBLurInput, int size); + OutputSocket *setupPostBlur(ExecutionSystem *graph, OutputSocket *postBlurInput, int size); OutputSocket *setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance); + OutputSocket *setupFeather(ExecutionSystem *graph, CompositorContext *context, OutputSocket *featherInput, + int falloff, int distance); OutputSocket *setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputSrceen, float factor); OutputSocket *setupClip(ExecutionSystem *graph, OutputSocket *clipInput, int kernelRadius, float kernelTolerance, float clipBlack, float clipWhite, bool edgeMatte); diff --git a/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp b/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp index 0fb8d45d066..cd1f79235ea 100644 --- a/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp +++ b/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp @@ -45,6 +45,7 @@ void KeyingScreenNode::convertToOperations(ExecutionSystem *graph, CompositorCon // always connect the output image KeyingScreenOperation *operation = new KeyingScreenOperation(); + operation->setbNode(editorNode); if (outputScreen->isConnected()) { outputScreen->relinkConnections(operation->getOutputSocket()); diff --git a/source/blender/compositor/nodes/COM_KeyingScreenNode.h b/source/blender/compositor/nodes/COM_KeyingScreenNode.h index 7c87219ef6e..9b8ac88bb6e 100644 --- a/source/blender/compositor/nodes/COM_KeyingScreenNode.h +++ b/source/blender/compositor/nodes/COM_KeyingScreenNode.h @@ -25,9 +25,9 @@ #include "DNA_node_types.h" /** - * @brief KeyingScreenNode - * @ingroup Node - */ + * @brief KeyingScreenNode + * @ingroup Node + */ class KeyingScreenNode : public Node { public: KeyingScreenNode(bNode *editorNode); diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp index 03034e34eb7..4870e252b74 100644 --- a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp +++ b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp @@ -37,9 +37,9 @@ void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorC NodeLensDist *data = (NodeLensDist *)editorNode->storage; if (data->proj) { ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation(); - + operation->setbNode(editorNode); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); - operation->setDispertion(this->getInputSocket(2)->getStaticValues()[0]); + this->getInputSocket(2)->relinkConnections(operation->getInputSocket(1), 2, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); operation->setData(data); @@ -48,13 +48,22 @@ void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorC } else { ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation(); + operation->setbNode(editorNode); + operation->setData(data); + if (!(this->getInputSocket(1)->isConnected() || this->getInputSocket(2)->isConnected())) + { + // no nodes connected to the distortion and dispersion. We can precalculate some values + float distortion = ((const bNodeSocketValueFloat *)this->getInputSocket(1)->getbNodeSocket()->default_value)->value; + float dispersion = ((const bNodeSocketValueFloat *)this->getInputSocket(2)->getbNodeSocket()->default_value)->value; + operation->setDistortionAndDispersion(distortion, dispersion); + } this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); - operation->setDistortion(this->getInputSocket(1)->getStaticValues()[0]); - operation->setDispertion(this->getInputSocket(2)->getStaticValues()[0]); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph); + this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); - operation->setData(data); graph->addOperation(operation); } diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h index c699a0d1168..37f3c31113f 100644 --- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h +++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef COM_LuminanceMatteNODE_H -#define COM_LuminanceMatteNODE_H +#ifndef _COM_LuminanceMatteNode_h_ +#define _COM_LuminanceMatteNode_h_ #include "COM_Node.h" @@ -28,11 +28,10 @@ * @brief LuminanceMatteNode * @ingroup Node */ -class LuminanceMatteNode : public Node -{ +class LuminanceMatteNode : public Node { public: LuminanceMatteNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); }; -#endif // COM_LuminanceMatteNODE_H +#endif // _COM_LuminanceMatteNode_h_ diff --git a/source/blender/compositor/nodes/COM_MapUVNode.h b/source/blender/compositor/nodes/COM_MapUVNode.h index a1df790f192..2e5616e0bd0 100644 --- a/source/blender/compositor/nodes/COM_MapUVNode.h +++ b/source/blender/compositor/nodes/COM_MapUVNode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_MapUVNode_h -#define _COM_MapUVNode_h +#ifndef _COM_MapUVNode_h_ +#define _COM_MapUVNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_MapValueNode.cpp b/source/blender/compositor/nodes/COM_MapValueNode.cpp index ba2fc804f42..ac57ffed9da 100644 --- a/source/blender/compositor/nodes/COM_MapValueNode.cpp +++ b/source/blender/compositor/nodes/COM_MapValueNode.cpp @@ -32,12 +32,12 @@ MapValueNode::MapValueNode(bNode *editorNode) : Node(editorNode) void MapValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { - InputSocket *colourSocket = this->getInputSocket(0); + InputSocket *colorSocket = this->getInputSocket(0); OutputSocket *valueSocket = this->getOutputSocket(0); TexMapping *storage = (TexMapping *)this->getbNode()->storage; MapValueOperation *convertProg = new MapValueOperation(); convertProg->setSettings(storage); - colourSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph); + colorSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph); valueSocket->relinkConnections(convertProg->getOutputSocket(0)); graph->addOperation(convertProg); } diff --git a/source/blender/compositor/nodes/COM_MapValueNode.h b/source/blender/compositor/nodes/COM_MapValueNode.h index c7a842dff95..22aa5459ec0 100644 --- a/source/blender/compositor/nodes/COM_MapValueNode.h +++ b/source/blender/compositor/nodes/COM_MapValueNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_MapValueNode_h -#define _COM_MapValueNode_h +#ifndef _COM_MapValueNode_h_ +#define _COM_MapValueNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" @@ -34,4 +34,5 @@ public: MapValueNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); }; -#endif + +#endif // _COM_MapValueNode_h_ diff --git a/source/blender/compositor/nodes/COM_MaskNode.cpp b/source/blender/compositor/nodes/COM_MaskNode.cpp index ed07e41a649..b6300300f6f 100644 --- a/source/blender/compositor/nodes/COM_MaskNode.cpp +++ b/source/blender/compositor/nodes/COM_MaskNode.cpp @@ -36,7 +36,7 @@ MaskNode::MaskNode(bNode *editorNode) : Node(editorNode) void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { - const RenderData *data = &context->getScene()->r; + const RenderData *data = context->getRenderData(); OutputSocket *outputMask = this->getOutputSocket(0); @@ -45,7 +45,7 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co // always connect the output image MaskOperation *operation = new MaskOperation(); - + operation->setbNode(editorNode); operation->setMaskWidth(data->xsch * data->size / 100.0f); operation->setMaskHeight(data->ysch * data->size / 100.0f); @@ -55,7 +55,8 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co operation->setMask(mask); operation->setFramenumber(context->getFramenumber()); - operation->setSmooth((bool)editorNode->custom1); + operation->setSmooth((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_AA) != 0); + operation->setFeather((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); graph->addOperation(operation); } diff --git a/source/blender/compositor/nodes/COM_MaskNode.h b/source/blender/compositor/nodes/COM_MaskNode.h index 8a9bc50eac7..cdd5d3c362e 100644 --- a/source/blender/compositor/nodes/COM_MaskNode.h +++ b/source/blender/compositor/nodes/COM_MaskNode.h @@ -21,6 +21,9 @@ * Sergey Sharybin */ +#ifndef _COM_MaskNode_h_ +#define _COM_MaskNode_h_ + #include "COM_Node.h" #include "DNA_node_types.h" @@ -29,10 +32,10 @@ * @ingroup Node */ class MaskNode : public Node { - - public: MaskNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); }; + +#endif // _COM_MaskNode_h_ diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp index 6e9b49253e7..300c9967cc4 100644 --- a/source/blender/compositor/nodes/COM_MathNode.cpp +++ b/source/blender/compositor/nodes/COM_MathNode.cpp @@ -28,8 +28,7 @@ void MathNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co { MathBaseOperation *operation = NULL; - switch (this->getbNode()->custom1) - { + switch (this->getbNode()->custom1) { case 0: /* Add */ operation = new MathAddOperation(); break; diff --git a/source/blender/compositor/nodes/COM_MathNode.h b/source/blender/compositor/nodes/COM_MathNode.h index 16d65843b0d..4f8e64754e7 100644 --- a/source/blender/compositor/nodes/COM_MathNode.h +++ b/source/blender/compositor/nodes/COM_MathNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_MathNode_h -#define _COM_MathNode_h +#ifndef _COM_MathNode_h_ +#define _COM_MathNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_MixNode.h b/source/blender/compositor/nodes/COM_MixNode.h index 99e8b4d48f0..76076d01427 100644 --- a/source/blender/compositor/nodes/COM_MixNode.h +++ b/source/blender/compositor/nodes/COM_MixNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_MixNode_h -#define _COM_MixNode_h +#ifndef _COM_MixNode_h_ +#define _COM_MixNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.h b/source/blender/compositor/nodes/COM_MovieClipNode.h index d70881a6725..52ea11ea8e9 100644 --- a/source/blender/compositor/nodes/COM_MovieClipNode.h +++ b/source/blender/compositor/nodes/COM_MovieClipNode.h @@ -20,6 +20,9 @@ * Monique Dewanchand */ +#ifndef _COM_MovieClipNode_h_ +#define _COM_MovieClipNode_h_ + #include "COM_Node.h" #include "DNA_node_types.h" @@ -28,10 +31,9 @@ * @ingroup Node */ class MovieClipNode : public Node { - - public: MovieClipNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); - }; + +#endif // _COM_MovieClipNode_h_ diff --git a/source/blender/compositor/nodes/COM_NormalNode.h b/source/blender/compositor/nodes/COM_NormalNode.h index bf684298e65..660d90040bd 100644 --- a/source/blender/compositor/nodes/COM_NormalNode.h +++ b/source/blender/compositor/nodes/COM_NormalNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef COM_NORMALNODE_H -#define COM_NORMALNODE_H +#ifndef _COM_NormalNode_h_ +#define _COM_NormalNode_h_ #include "COM_Node.h" @@ -29,8 +29,7 @@ * @brief NormalNode * @ingroup Node */ -class NormalNode : public Node -{ +class NormalNode : public Node { public: NormalNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp index db7fbffea4f..e85f521def0 100644 --- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp +++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp @@ -47,7 +47,7 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte if (storage->format.imtype == R_IMF_IMTYPE_MULTILAYER) { /* single output operation for the multilayer file */ OutputOpenExrMultiLayerOperation *outputOperation = new OutputOpenExrMultiLayerOperation( - context->getScene(), context->getbNodeTree(), storage->base_path, storage->format.exr_codec); + context->getRenderData(), context->getbNodeTree(), storage->base_path, storage->format.exr_codec); int num_inputs = getNumberOfInputSockets(); bool hasConnections = false; @@ -80,7 +80,7 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte BLI_join_dirfile(path, FILE_MAX, storage->base_path, sockdata->path); OutputSingleLayerOperation *outputOperation = new OutputSingleLayerOperation( - context->getScene(), context->getbNodeTree(), input->getDataType(), format, path); + context->getRenderData(), context->getbNodeTree(), input->getDataType(), format, path); input->relinkConnections(outputOperation->getInputSocket(0)); graph->addOperation(outputOperation); if (!previewAdded) { diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.h b/source/blender/compositor/nodes/COM_OutputFileNode.h index 79c9b577643..e3194436f7f 100644 --- a/source/blender/compositor/nodes/COM_OutputFileNode.h +++ b/source/blender/compositor/nodes/COM_OutputFileNode.h @@ -21,8 +21,8 @@ * Lukas Tönne */ -#ifndef _COM_OutputFileNode_h -#define _COM_OutputFileNode_h +#ifndef _COM_OutputFileNode_h_ +#define _COM_OutputFileNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp index 95e759fde24..dfb46af841c 100644 --- a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp +++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp @@ -82,7 +82,7 @@ void RenderLayersNode::testSocketConnection(ExecutionSystem *system, int outputS void RenderLayersNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { - testSocketConnection(graph, 0, new RenderLayersColourProg()); + testSocketConnection(graph, 0, new RenderLayersColorProg()); testSocketConnection(graph, 1, new RenderLayersAlphaProg()); testSocketConnection(graph, 2, new RenderLayersDepthProg()); testSocketConnection(graph, 3, new RenderLayersNormalOperation()); diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cpp b/source/blender/compositor/nodes/COM_ScaleNode.cpp index 17b521c589d..95b048b6cad 100644 --- a/source/blender/compositor/nodes/COM_ScaleNode.cpp +++ b/source/blender/compositor/nodes/COM_ScaleNode.cpp @@ -52,7 +52,7 @@ void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c break; case CMP_SCALE_SCENEPERCENT: { SetValueOperation *scaleFactorOperation = new SetValueOperation(); - scaleFactorOperation->setValue(context->getScene()->r.size / 100.0f); + scaleFactorOperation->setValue(context->getRenderData()->size / 100.0f); ScaleOperation *operation = new ScaleOperation(); inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph); addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1)); @@ -64,7 +64,7 @@ void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c break; case CMP_SCALE_RENDERPERCENT: { - const RenderData *data = &context->getScene()->r; + const RenderData *data = context->getRenderData(); ScaleFixedSizeOperation *operation = new ScaleFixedSizeOperation(); /* framing options */ diff --git a/source/blender/compositor/nodes/COM_SeparateHSVANode.h b/source/blender/compositor/nodes/COM_SeparateHSVANode.h index 4a7e86849dc..6199237ebda 100644 --- a/source/blender/compositor/nodes/COM_SeparateHSVANode.h +++ b/source/blender/compositor/nodes/COM_SeparateHSVANode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_SeparateHSVANode_h -#define _COM_SeparateHSVANode_h +#ifndef _COM_SeparateHSVANode_h_ +#define _COM_SeparateHSVANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_SeparateRGBANode.h b/source/blender/compositor/nodes/COM_SeparateRGBANode.h index c1be02753da..35321304d99 100644 --- a/source/blender/compositor/nodes/COM_SeparateRGBANode.h +++ b/source/blender/compositor/nodes/COM_SeparateRGBANode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_SeparateRGBANode_h -#define _COM_SeparateRGBANode_h +#ifndef _COM_SeparateRGBANode_h_ +#define _COM_SeparateRGBANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_SeparateYCCANode.h b/source/blender/compositor/nodes/COM_SeparateYCCANode.h index 4b216841e2a..542e1693932 100644 --- a/source/blender/compositor/nodes/COM_SeparateYCCANode.h +++ b/source/blender/compositor/nodes/COM_SeparateYCCANode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_SeparateYCCANode_h -#define _COM_SeparateYCCANode_h +#ifndef _COM_SeparateYCCANode_h_ +#define _COM_SeparateYCCANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_SeparateYUVANode.h b/source/blender/compositor/nodes/COM_SeparateYUVANode.h index e1763e37dff..e51c0ce4fa6 100644 --- a/source/blender/compositor/nodes/COM_SeparateYUVANode.h +++ b/source/blender/compositor/nodes/COM_SeparateYUVANode.h @@ -19,8 +19,8 @@ * Dalai Felinto */ -#ifndef _COM_SeparateYUVANode_h -#define _COM_SeparateYUVANode_h +#ifndef _COM_SeparateYUVANode_h_ +#define _COM_SeparateYUVANode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.h b/source/blender/compositor/nodes/COM_SetAlphaNode.h index 0707cf5dac1..e82fa210a89 100644 --- a/source/blender/compositor/nodes/COM_SetAlphaNode.h +++ b/source/blender/compositor/nodes/COM_SetAlphaNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_SetAlphaNode_h -#define _COM_SetAlphaNode_h +#ifndef _COM_SetAlphaNode_h_ +#define _COM_SetAlphaNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp index 22a00410384..388466cee3c 100644 --- a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp @@ -39,8 +39,8 @@ void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorCont ImageUser *imageUser = (ImageUser *) this->getbNode()->storage; if (image1Socket->isConnected() && image2Socket->isConnected()) { SplitViewerOperation *splitViewerOperation = new SplitViewerOperation(); - splitViewerOperation->setColorManagement(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT); - splitViewerOperation->setColorPredivide(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); + splitViewerOperation->setColorManagement(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT); + splitViewerOperation->setColorPredivide(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); splitViewerOperation->setImage(image); splitViewerOperation->setImageUser(imageUser); splitViewerOperation->setActive((this->getbNode()->flag & NODE_DO_OUTPUT) && this->isInActiveGroup()); diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.h b/source/blender/compositor/nodes/COM_SplitViewerNode.h index 6c532d4e813..f17cfd57cbf 100644 --- a/source/blender/compositor/nodes/COM_SplitViewerNode.h +++ b/source/blender/compositor/nodes/COM_SplitViewerNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_SplitViewerNode_h -#define _COM_SplitViewerNode_h +#ifndef _COM_SplitViewerNode_h_ +#define _COM_SplitViewerNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.h b/source/blender/compositor/nodes/COM_Stabilize2dNode.h index 589e090b48c..3363ff4142c 100644 --- a/source/blender/compositor/nodes/COM_Stabilize2dNode.h +++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.h @@ -20,6 +20,9 @@ * Monique Dewanchand */ +#ifndef _COM_Stabilize2dNode_h_ +#define _COM_Stabilize2dNode_h_ + #include "COM_Node.h" #include "DNA_node_types.h" @@ -32,3 +35,5 @@ public: Stabilize2dNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); }; + +#endif diff --git a/source/blender/compositor/nodes/COM_SwitchNode.h b/source/blender/compositor/nodes/COM_SwitchNode.h index be3d54c3000..16d9e18885b 100644 --- a/source/blender/compositor/nodes/COM_SwitchNode.h +++ b/source/blender/compositor/nodes/COM_SwitchNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_SwitchNode_h -#define _COM_SwitchNode_h +#ifndef _COM_SwitchNode_h_ +#define _COM_SwitchNode_h_ #include "COM_Node.h" #include "COM_NodeOperation.h" diff --git a/source/blender/compositor/nodes/COM_TextureNode.cpp b/source/blender/compositor/nodes/COM_TextureNode.cpp index a3526e3c1a1..b035e0a392c 100644 --- a/source/blender/compositor/nodes/COM_TextureNode.cpp +++ b/source/blender/compositor/nodes/COM_TextureNode.cpp @@ -38,7 +38,7 @@ void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system); this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, system); operation->setTexture(texture); - operation->setScene(context->getScene()); + operation->setRenderData(context->getRenderData()); system->addOperation(operation); addPreviewOperation(system, operation->getOutputSocket()); @@ -48,7 +48,7 @@ void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext addLink(system, operation->getInputSocket(0)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(0)); addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(1)); alphaOperation->setTexture(texture); - alphaOperation->setScene(context->getScene()); + alphaOperation->setRenderData(context->getRenderData()); system->addOperation(alphaOperation); } } diff --git a/source/blender/compositor/nodes/COM_TonemapNode.cpp b/source/blender/compositor/nodes/COM_TonemapNode.cpp index a1f33ed464b..68e322e9dcf 100644 --- a/source/blender/compositor/nodes/COM_TonemapNode.cpp +++ b/source/blender/compositor/nodes/COM_TonemapNode.cpp @@ -34,7 +34,7 @@ void TonemapNode::convertToOperations(ExecutionSystem *system, CompositorContext { NodeTonemap *data = (NodeTonemap *)this->getbNode()->storage; TonemapOperation *operation = data->type == 1 ? new PhotoreceptorTonemapOperation() : new TonemapOperation(); - + operation->setbNode(this->getbNode()); operation->setData(data); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_TransformNode.h b/source/blender/compositor/nodes/COM_TransformNode.h index da40b655f29..57a7a0229ec 100644 --- a/source/blender/compositor/nodes/COM_TransformNode.h +++ b/source/blender/compositor/nodes/COM_TransformNode.h @@ -20,6 +20,9 @@ * Monique Dewanchand */ +#ifndef _COM_TransformNode_h_ +#define _COM_TransformNode_h_ + #include "COM_Node.h" #include "DNA_node_types.h" @@ -32,3 +35,5 @@ public: TransformNode(bNode *editorNode); void convertToOperations(ExecutionSystem *graph, CompositorContext *context); }; + +#endif // _COM_TransformNode_h_ diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp index 5ef384a9984..07c8120b1d2 100644 --- a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp +++ b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp @@ -34,6 +34,7 @@ void VectorBlurNode::convertToOperations(ExecutionSystem *system, CompositorCont bNode *node = this->getbNode(); NodeBlurData *vectorBlurSettings = (NodeBlurData *)node->storage; VectorBlurOperation *operation = new VectorBlurOperation(); + operation->setbNode(node); operation->setVectorBlurSettings(vectorBlurSettings); operation->setQuality(context->getQuality()); this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system); diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp index 9228fdbef85..1205767cb28 100644 --- a/source/blender/compositor/nodes/COM_ViewerNode.cpp +++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp @@ -40,8 +40,8 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * bNode *editorNode = this->getbNode(); if (imageSocket->isConnected()) { ViewerOperation *viewerOperation = new ViewerOperation(); - viewerOperation->setColorManagement(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT); - viewerOperation->setColorPredivide(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); + viewerOperation->setColorManagement(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT); + viewerOperation->setColorPredivide(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); viewerOperation->setbNodeTree(context->getbNodeTree()); viewerOperation->setImage(image); viewerOperation->setImageUser(imageUser); diff --git a/source/blender/compositor/nodes/COM_ViewerNode.h b/source/blender/compositor/nodes/COM_ViewerNode.h index e1f1226f1f1..3a9954b8aea 100644 --- a/source/blender/compositor/nodes/COM_ViewerNode.h +++ b/source/blender/compositor/nodes/COM_ViewerNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_ViewerNode_h -#define _COM_ViewerNode_h +#ifndef _COM_ViewerNode_h_ +#define _COM_ViewerNode_h_ #include "COM_Node.h" #include "DNA_node_types.h" diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.h b/source/blender/compositor/nodes/COM_ZCombineNode.h index a2ceedfc2cd..61f4037be90 100644 --- a/source/blender/compositor/nodes/COM_ZCombineNode.h +++ b/source/blender/compositor/nodes/COM_ZCombineNode.h @@ -20,8 +20,8 @@ * Monique Dewanchand */ -#ifndef _COM_ZCombineNode_h -#define _COM_ZCombineNode_h +#ifndef _COM_ZCombineNode_h_ +#define _COM_ZCombineNode_h_ #include "COM_Node.h" diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp index e614e1fa15a..e688332a039 100644 --- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp +++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp @@ -33,9 +33,9 @@ void AlphaOverKeyOperation::executePixel(float *outputValue, float x, float y, P float inputOverColor[4]; float value[4]; - inputValueOperation->read(value, x, y, sampler, inputBuffers); - inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); if (inputOverColor[3] <= 0.0f) { copy_v4_v4(outputValue, inputColor1); diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h index e5b1f56f06c..113ec245ee6 100644 --- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class AlphaOverKeyOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp index 81c1e4d2587..e56fb9151f2 100644 --- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp +++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp @@ -24,7 +24,7 @@ AlphaOverMixedOperation::AlphaOverMixedOperation() : MixBaseOperation() { - this->x = 0.0f; + this->m_x = 0.0f; } void AlphaOverMixedOperation::executePixel(float outputValue[4], float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -33,9 +33,9 @@ void AlphaOverMixedOperation::executePixel(float outputValue[4], float x, float float inputOverColor[4]; float value[4]; - inputValueOperation->read(value, x, y, sampler, inputBuffers); - inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); if (inputOverColor[3] <= 0.0f) { copy_v4_v4(outputValue, inputColor1); @@ -44,7 +44,7 @@ void AlphaOverMixedOperation::executePixel(float outputValue[4], float x, float copy_v4_v4(outputValue, inputOverColor); } else { - float addfac = 1.0f - this->x + inputOverColor[3] * this->x; + float addfac = 1.0f - this->m_x + inputOverColor[3] * this->m_x; float premul = value[0] * addfac; float mul = 1.0f - value[0] * inputOverColor[3]; diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h index 2807b3b489a..3c0b955e360 100644 --- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h @@ -20,18 +20,18 @@ * Monique Dewanchand */ -#ifndef _COM_AlphaOverMixedOperation_h -#define _COM_AlphaOverMixedOperation_h +#ifndef _COM_AlphaOverMixedOperation_h_ +#define _COM_AlphaOverMixedOperation_h_ #include "COM_MixBaseOperation.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class AlphaOverMixedOperation : public MixBaseOperation { private: - float x; + float m_x; public: /** * Default constructor @@ -43,6 +43,6 @@ public: */ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); - void setX(float x) { this->x = x; } + void setX(float x) { this->m_x = x; } }; #endif diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp index a6bf8b8834c..b2c40a058ba 100644 --- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp +++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp @@ -33,9 +33,9 @@ void AlphaOverPremultiplyOperation::executePixel(float *outputValue, float x, fl float inputOverColor[4]; float value[4]; - inputValueOperation->read(value, x, y, sampler, inputBuffers); - inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers); /* Zero alpha values should still permit an add of RGB data */ if (inputOverColor[3] < 0.0f) { diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h index bba3b714f6b..7b7b9238794 100644 --- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class AlphaOverPremultiplyOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp index 458d11f2616..46fa07893e8 100644 --- a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp +++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp @@ -32,33 +32,33 @@ AntiAliasOperation::AntiAliasOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->valueReader = NULL; - this->buffer = NULL; + this->m_valueReader = NULL; + this->m_buffer = NULL; this->setComplex(true); } void AntiAliasOperation::initExecution() { - this->valueReader = this->getInputSocketReader(0); + this->m_valueReader = this->getInputSocketReader(0); NodeOperation::initMutex(); } void AntiAliasOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - if (y < 0 || (unsigned int)y >= this->height || x < 0 || (unsigned int)x >= this->width) { + if (y < 0 || (unsigned int)y >= this->m_height || x < 0 || (unsigned int)x >= this->m_width) { color[0] = 0.0f; } else { - int offset = y * this->width + x; - color[0] = buffer[offset] / 255.0f; + int offset = y * this->m_width + x; + color[0] = this->m_buffer[offset] / 255.0f; } } void AntiAliasOperation::deinitExecution() { - this->valueReader = NULL; - if (this->buffer) { - delete buffer; + this->m_valueReader = NULL; + if (this->m_buffer) { + delete this->m_buffer; } NodeOperation::deinitMutex(); } @@ -66,7 +66,7 @@ void AntiAliasOperation::deinitExecution() bool AntiAliasOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti imageInput; - if (this->buffer) { + if (this->m_buffer) { return false; } else { @@ -84,10 +84,10 @@ bool AntiAliasOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe void *AntiAliasOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->buffer) {return buffer; } + if (this->m_buffer) { return this->m_buffer; } lockMutex(); - if (this->buffer == NULL) { - MemoryBuffer *tile = (MemoryBuffer *)valueReader->initializeTileData(rect, memoryBuffers); + if (this->m_buffer == NULL) { + MemoryBuffer *tile = (MemoryBuffer *)this->m_valueReader->initializeTileData(rect, memoryBuffers); int size = tile->getHeight() * tile->getWidth(); float *input = tile->getBuffer(); char *valuebuffer = new char[size]; @@ -98,8 +98,8 @@ void *AntiAliasOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu valuebuffer[i] = in * 255; } antialias_tagbuf(tile->getWidth(), tile->getHeight(), valuebuffer); - this->buffer = valuebuffer; + this->m_buffer = valuebuffer; } unlockMutex(); - return this->buffer; + return this->m_buffer; } diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.h b/source/blender/compositor/operations/COM_AntiAliasOperation.h index 906da598da1..3d9bcf6d90a 100644 --- a/source/blender/compositor/operations/COM_AntiAliasOperation.h +++ b/source/blender/compositor/operations/COM_AntiAliasOperation.h @@ -35,8 +35,8 @@ protected: /** * @brief Cached reference to the reader */ - SocketReader *valueReader; - char *buffer; + SocketReader *m_valueReader; + char *m_buffer; public: AntiAliasOperation(); diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp index 3628c399581..4f7f5eea8a0 100644 --- a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp @@ -34,15 +34,15 @@ BilateralBlurOperation::BilateralBlurOperation() : NodeOperation() this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); - this->inputColorProgram = NULL; - this->inputDeterminatorProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_inputDeterminatorProgram = NULL; } void BilateralBlurOperation::initExecution() { - this->inputColorProgram = getInputSocketReader(0); - this->inputDeterminatorProgram = getInputSocketReader(1); - this->space = this->data->sigma_space + this->data->iter; + this->m_inputColorProgram = getInputSocketReader(0); + this->m_inputDeterminatorProgram = getInputSocketReader(1); + this->m_space = this->m_data->sigma_space + this->m_data->iter; QualityStepHelper::initExecution(COM_QH_INCREASE); } @@ -54,27 +54,27 @@ void BilateralBlurOperation::executePixel(float *color, int x, int y, MemoryBuff float tempColor[4]; float blurColor[4]; float blurDivider; - float space = this->space; - float sigmacolor = this->data->sigma_color; + float space = this->m_space; + float sigmacolor = this->m_data->sigma_color; int minx = floor(x - space); int maxx = ceil(x + space); int miny = floor(y - space); int maxy = ceil(y + space); float deltaColor; - this->inputDeterminatorProgram->read(determinatorReferenceColor, x, y, inputBuffers, data); + this->m_inputDeterminatorProgram->read(determinatorReferenceColor, x, y, inputBuffers, data); zero_v4(blurColor); blurDivider = 0.0f; for (int yi = miny; yi < maxy; yi += QualityStepHelper::getStep()) { for (int xi = minx; xi < maxx; xi += QualityStepHelper::getStep()) { // read determinator - this->inputDeterminatorProgram->read(determinator, xi, yi, inputBuffers, data); + this->m_inputDeterminatorProgram->read(determinator, xi, yi, inputBuffers, data); deltaColor = (fabsf(determinatorReferenceColor[0] - determinator[0]) + fabsf(determinatorReferenceColor[1] - determinator[1]) + fabsf(determinatorReferenceColor[2] - determinator[2])); // do not take the alpha channel into account if (deltaColor < sigmacolor) { // add this to the blur - this->inputColorProgram->read(tempColor, xi, yi, inputBuffers, data); + this->m_inputColorProgram->read(tempColor, xi, yi, inputBuffers, data); add_v4_v4(blurColor, tempColor); blurDivider += 1.0f; } @@ -94,14 +94,14 @@ void BilateralBlurOperation::executePixel(float *color, int x, int y, MemoryBuff void BilateralBlurOperation::deinitExecution() { - this->inputColorProgram = NULL; - this->inputDeterminatorProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_inputDeterminatorProgram = NULL; } bool BilateralBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - int add = ceil(this->space) + 1; + int add = ceil(this->m_space) + 1; newInput.xmax = input->xmax + (add); newInput.xmin = input->xmin - (add); diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.h b/source/blender/compositor/operations/COM_BilateralBlurOperation.h index 08b379dc4ea..be6ce7a221e 100644 --- a/source/blender/compositor/operations/COM_BilateralBlurOperation.h +++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.h @@ -27,10 +27,10 @@ class BilateralBlurOperation : public NodeOperation, public QualityStepHelper { private: - SocketReader *inputColorProgram; - SocketReader *inputDeterminatorProgram; - NodeBilateralBlurData *data; - float space; + SocketReader *m_inputColorProgram; + SocketReader *m_inputDeterminatorProgram; + NodeBilateralBlurData *m_data; + float m_space; public: BilateralBlurOperation(); @@ -52,6 +52,6 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void setData(NodeBilateralBlurData *data) { this->data = data; } + void setData(NodeBilateralBlurData *data) { this->m_data = data; } }; #endif diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp index a233c7a50ae..696c0748d69 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp @@ -27,37 +27,38 @@ extern "C" { #include "RE_pipeline.h" } -BlurBaseOperation::BlurBaseOperation(DataType data_type=COM_DT_COLOR) : NodeOperation() +BlurBaseOperation::BlurBaseOperation(DataType data_type) : NodeOperation() { + /* data_type is almost always COM_DT_COLOR except for alpha-blur */ this->addInputSocket(data_type); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(data_type); this->setComplex(true); - this->inputProgram = NULL; - this->data = NULL; - this->size = 1.0f; - this->deleteData = false; - this->sizeavailable = false; + this->m_inputProgram = NULL; + this->m_data = NULL; + this->m_size = 1.0f; + this->m_deleteData = false; + this->m_sizeavailable = false; } void BlurBaseOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); - this->inputSize = this->getInputSocketReader(1); - this->data->image_in_width = this->getWidth(); - this->data->image_in_height = this->getHeight(); - if (this->data->relative) { - switch (this->data->aspect) { + this->m_inputProgram = this->getInputSocketReader(0); + this->m_inputSize = this->getInputSocketReader(1); + this->m_data->image_in_width = this->getWidth(); + this->m_data->image_in_height = this->getHeight(); + if (this->m_data->relative) { + switch (this->m_data->aspect) { case CMP_NODE_BLUR_ASPECT_NONE: - this->data->sizex = (int)(this->data->percentx * 0.01f * this->data->image_in_width); - this->data->sizey = (int)(this->data->percenty * 0.01f * this->data->image_in_height); + this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_width); + this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_height); break; case CMP_NODE_BLUR_ASPECT_Y: - this->data->sizex = (int)(this->data->percentx * 0.01f * this->data->image_in_width); - this->data->sizey = (int)(this->data->percenty * 0.01f * this->data->image_in_width); + this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_width); + this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_width); break; case CMP_NODE_BLUR_ASPECT_X: - this->data->sizex = (int)(this->data->percentx * 0.01f * this->data->image_in_height); - this->data->sizey = (int)(this->data->percenty * 0.01f * this->data->image_in_height); + this->m_data->sizex = (int)(this->m_data->percentx * 0.01f * this->m_data->image_in_height); + this->m_data->sizey = (int)(this->m_data->percenty * 0.01f * this->m_data->image_in_height); break; } } @@ -77,7 +78,7 @@ float *BlurBaseOperation::make_gausstab(int rad) sum = 0.0f; for (i = -rad; i <= rad; i++) { - val = RE_filter_value(this->data->filtertype, (float)i / (float)rad); + val = RE_filter_value(this->m_data->filtertype, (float)i / (float)rad); sum += val; gausstab[i + rad] = val; } @@ -91,7 +92,7 @@ float *BlurBaseOperation::make_gausstab(int rad) /* normalized distance from the current (inverted so 1.0 is close and 0.0 is far) * 'ease' is applied after, looks nicer */ -float *BlurBaseOperation::make_dist_fac_inverse(int rad) +float *BlurBaseOperation::make_dist_fac_inverse(int rad, int falloff) { float *dist_fac_invert, val; int i, n; @@ -103,9 +104,26 @@ float *BlurBaseOperation::make_dist_fac_inverse(int rad) for (i = -rad; i <= rad; i++) { val = 1.0f - fabsf(((float)i / (float)rad)); - /* ease - gives less hard lines for dilate/erode feather */ - val = (3.0f * val * val - 2.0f * val * val * val); - + /* keep in sync with proportional_falloff_curve_only_items */ + switch (falloff) { + case PROP_SMOOTH: + /* ease - gives less hard lines for dilate/erode feather */ + val = (3.0f * val * val - 2.0f * val * val * val); + break; + case PROP_SPHERE: + val = sqrtf(2.0f * val - val * val); + break; + case PROP_ROOT: + val = sqrtf(val); + break; + case PROP_SHARP: + val = val * val; + break; + case PROP_LIN: + default: + /* nothing */ + break; + } dist_fac_invert[i + rad] = val; } @@ -114,20 +132,20 @@ float *BlurBaseOperation::make_dist_fac_inverse(int rad) void BlurBaseOperation::deinitExecution() { - this->inputProgram = NULL; - this->inputSize = NULL; - if (this->deleteData) { - delete this->data; + this->m_inputProgram = NULL; + this->m_inputSize = NULL; + if (this->m_deleteData) { + delete this->m_data; } - this->data = NULL; + this->m_data = NULL; } void BlurBaseOperation::updateSize(MemoryBuffer **memoryBuffers) { - if (!this->sizeavailable) { + if (!this->m_sizeavailable) { float result[4]; this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, memoryBuffers); - this->size = result[0]; - this->sizeavailable = true; + this->m_size = result[0]; + this->m_sizeavailable = true; } } diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.h b/source/blender/compositor/operations/COM_BlurBaseOperation.h index 33c07abbb36..6d60abf09bf 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.h +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.h @@ -29,19 +29,24 @@ class BlurBaseOperation : public NodeOperation, public QualityStepHelper { private: protected: - /** - * Cached reference to the inputProgram - */ - SocketReader *inputProgram; - SocketReader *inputSize; - NodeBlurData *data; + BlurBaseOperation(DataType data_type); float *make_gausstab(int rad); - float *make_dist_fac_inverse(int rad); - float size; - bool deleteData; - bool sizeavailable; + float *make_dist_fac_inverse(int rad, int falloff); + void updateSize(MemoryBuffer **memoryBuffers); + + /** + * Cached reference to the inputProgram + */ + SocketReader *m_inputProgram; + SocketReader *m_inputSize; + NodeBlurData *m_data; + + float m_size; + bool m_deleteData; + bool m_sizeavailable; + public: /** * Initialize the execution @@ -53,10 +58,10 @@ public: */ void deinitExecution(); - void setData(NodeBlurData *data) { this->data = data; } + void setData(NodeBlurData *data) { this->m_data = data; } - void deleteDataWhenFinished() { this->deleteData = true; } + void deleteDataWhenFinished() { this->m_deleteData = true; } - void setSize(float size) { this->size = size; sizeavailable = true; } + void setSize(float size) { this->m_size = size; this->m_sizeavailable = true; } }; #endif diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp index e2fce504791..fb06f6d3761 100644 --- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp @@ -22,6 +22,7 @@ #include "COM_BokehBlurOperation.h" #include "BLI_math.h" +#include "COM_OpenCLDevice.h" extern "C" { #include "RE_pipeline.h" @@ -36,11 +37,11 @@ BokehBlurOperation::BokehBlurOperation() : NodeOperation() this->setComplex(true); this->setOpenCL(true); - this->size = 1.0f; + this->m_size = 1.0f; - this->inputProgram = NULL; - this->inputBokehProgram = NULL; - this->inputBoundingBoxReader = NULL; + this->m_inputProgram = NULL; + this->m_inputBokehProgram = NULL; + this->m_inputBoundingBoxReader = NULL; } void *BokehBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) @@ -51,12 +52,12 @@ void *BokehBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu void BokehBlurOperation::initExecution() { - this->inputProgram = getInputSocketReader(0); - this->inputBokehProgram = getInputSocketReader(1); - this->inputBoundingBoxReader = getInputSocketReader(2); + this->m_inputProgram = getInputSocketReader(0); + this->m_inputBokehProgram = getInputSocketReader(1); + this->m_inputBoundingBoxReader = getInputSocketReader(2); - int width = inputBokehProgram->getWidth(); - int height = inputBokehProgram->getHeight(); + int width = this->m_inputBokehProgram->getWidth(); + int height = this->m_inputBokehProgram->getHeight(); float dimension; if (width < height) { @@ -65,9 +66,9 @@ void BokehBlurOperation::initExecution() else { dimension = height; } - this->bokehMidX = width / 2.0f; - this->bokehMidY = height / 2.0f; - this->bokehDimension = dimension / 2.0f; + this->m_bokehMidX = width / 2.0f; + this->m_bokehMidY = height / 2.0f; + this->m_bokehDimension = dimension / 2.0f; QualityStepHelper::initExecution(COM_QH_INCREASE); } @@ -77,7 +78,7 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * float tempBoundingBox[4]; float bokeh[4]; - inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST, inputBuffers); if (tempBoundingBox[0] > 0.0f) { float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; @@ -85,7 +86,7 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * int bufferwidth = inputBuffer->getWidth(); int bufferstartx = inputBuffer->getRect()->xmin; int bufferstarty = inputBuffer->getRect()->ymin; - int pixelSize = this->size * this->getWidth() / 100.0f; + int pixelSize = this->m_size * this->getWidth() / 100.0f; int miny = y - pixelSize; int maxy = y + pixelSize; @@ -101,13 +102,13 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * int step = getStep(); int offsetadd = getOffsetAdd(); - float m = this->bokehDimension / pixelSize; + float m = this->m_bokehDimension / pixelSize; for (int ny = miny; ny < maxy; ny += step) { int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); for (int nx = minx; nx < maxx; nx += step) { - float u = this->bokehMidX - (nx - x) * m; - float v = this->bokehMidY - (ny - y) * m; - inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); + float u = this->m_bokehMidX - (nx - x) * m; + float v = this->m_bokehMidY - (ny - y) * m; + this->m_inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]); add_v4_v4(multiplier_accum, bokeh); bufferindex += offsetadd; @@ -119,15 +120,15 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer * color[3] = color_accum[3] * (1.0f / multiplier_accum[3]); } else { - inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers); } } void BokehBlurOperation::deinitExecution() { - this->inputProgram = NULL; - this->inputBokehProgram = NULL; - this->inputBoundingBoxReader = NULL; + this->m_inputProgram = NULL; + this->m_inputBokehProgram = NULL; + this->m_inputBoundingBoxReader = NULL; } bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -135,10 +136,10 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe rcti newInput; rcti bokehInput; - newInput.xmax = input->xmax + (size * this->getWidth() / 100.0f); - newInput.xmin = input->xmin - (size * this->getWidth() / 100.0f); - newInput.ymax = input->ymax + (size * this->getWidth() / 100.0f); - newInput.ymin = input->ymin - (size * this->getWidth() / 100.0f); + newInput.xmax = input->xmax + (this->m_size * this->getWidth() / 100.0f); + newInput.xmin = input->xmin - (this->m_size * this->getWidth() / 100.0f); + newInput.ymax = input->ymax + (this->m_size * this->getWidth() / 100.0f); + newInput.ymin = input->ymin - (this->m_size * this->getWidth() / 100.0f); NodeOperation *operation = getInputOperation(1); bokehInput.xmax = operation->getWidth(); @@ -160,25 +161,25 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe } static cl_kernel kernel = 0; -void BokehBlurOperation::executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, +void BokehBlurOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { if (!kernel) { - kernel = COM_clCreateKernel(program, "bokehBlurKernel", NULL); + kernel = device->COM_clCreateKernel("bokehBlurKernel", NULL); } - cl_int radius = this->getWidth() * this->size / 100.0f; + cl_int radius = this->getWidth() * this->m_size / 100.0f; cl_int step = this->getStep(); - COM_clAttachMemoryBufferToKernelParameter(context, kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->inputBoundingBoxReader); - COM_clAttachMemoryBufferToKernelParameter(context, kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); - COM_clAttachMemoryBufferToKernelParameter(context, kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, this->inputBokehProgram); - COM_clAttachOutputMemoryBufferToKernelParameter(kernel, 3, clOutputBuffer); - COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, 5, outputMemoryBuffer); + device->COM_clAttachMemoryBufferToKernelParameter(kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBoundingBoxReader); + device->COM_clAttachMemoryBufferToKernelParameter(kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram); + device->COM_clAttachMemoryBufferToKernelParameter(kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram); + device->COM_clAttachOutputMemoryBufferToKernelParameter(kernel, 3, clOutputBuffer); + device->COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, 5, outputMemoryBuffer); clSetKernelArg(kernel, 6, sizeof(cl_int), &radius); clSetKernelArg(kernel, 7, sizeof(cl_int), &step); - COM_clAttachSizeToKernelParameter(kernel, 8); + device->COM_clAttachSizeToKernelParameter(kernel, 8, this); - COM_clEnqueueRange(queue, kernel, outputMemoryBuffer, 9); + device->COM_clEnqueueRange(kernel, outputMemoryBuffer, 9, this); } diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.h b/source/blender/compositor/operations/COM_BokehBlurOperation.h index 3ec61c5ce01..0433a4156a8 100644 --- a/source/blender/compositor/operations/COM_BokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_BokehBlurOperation.h @@ -27,13 +27,13 @@ class BokehBlurOperation : public NodeOperation, public QualityStepHelper { private: - SocketReader *inputProgram; - SocketReader *inputBokehProgram; - SocketReader *inputBoundingBoxReader; - float size; - float bokehMidX; - float bokehMidY; - float bokehDimension; + SocketReader *m_inputProgram; + SocketReader *m_inputBokehProgram; + SocketReader *m_inputBoundingBoxReader; + float m_size; + float m_bokehMidX; + float m_bokehMidY; + float m_bokehDimension; public: BokehBlurOperation(); @@ -55,8 +55,8 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void setSize(float size) { this->size = size; } + void setSize(float size) { this->m_size = size; } - void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp); + void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp); }; #endif diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cpp b/source/blender/compositor/operations/COM_BokehImageOperation.cpp index abb378e2adb..90e272438d6 100644 --- a/source/blender/compositor/operations/COM_BokehImageOperation.cpp +++ b/source/blender/compositor/operations/COM_BokehImageOperation.cpp @@ -26,35 +26,35 @@ BokehImageOperation::BokehImageOperation() : NodeOperation() { this->addOutputSocket(COM_DT_COLOR); - this->deleteData = false; + this->m_deleteData = false; } void BokehImageOperation::initExecution() { - this->centerX = getWidth() / 2; - this->centerY = getHeight() / 2; - this->center[0] = this->centerX; - this->center[1] = this->centerY; - this->inverseRounding = 1.0f - this->data->rounding; - this->circularDistance = getWidth() / 2; - this->flapRad = (float)(M_PI * 2) / this->data->flaps; - this->flapRadAdd = (this->data->angle / 360.0f) * (float)(M_PI * 2.0); - while (this->flapRadAdd < 0.0f) { - this->flapRadAdd += (float)(M_PI * 2.0); + this->m_centerX = getWidth() / 2; + this->m_centerY = getHeight() / 2; + this->m_center[0] = this->m_centerX; + this->m_center[1] = this->m_centerY; + this->m_inverseRounding = 1.0f - this->m_data->rounding; + this->m_circularDistance = getWidth() / 2; + this->m_flapRad = (float)(M_PI * 2) / this->m_data->flaps; + this->m_flapRadAdd = (this->m_data->angle / 360.0f) * (float)(M_PI * 2.0); + while (this->m_flapRadAdd < 0.0f) { + this->m_flapRadAdd += (float)(M_PI * 2.0); } - while (this->flapRadAdd > (float)M_PI) { - this->flapRadAdd -= (float)(M_PI * 2.0); + while (this->m_flapRadAdd > (float)M_PI) { + this->m_flapRadAdd -= (float)(M_PI * 2.0); } } void BokehImageOperation::detemineStartPointOfFlap(float r[2], int flapNumber, float distance) { - r[0] = sinf(flapRad * flapNumber + flapRadAdd) * distance + centerX; - r[1] = cosf(flapRad * flapNumber + flapRadAdd) * distance + centerY; + r[0] = sinf(this->m_flapRad * flapNumber + this->m_flapRadAdd) * distance + this->m_centerX; + r[1] = cosf(this->m_flapRad * flapNumber + this->m_flapRadAdd) * distance + this->m_centerY; } float BokehImageOperation::isInsideBokeh(float distance, float x, float y) { float insideBokeh = 0.0f; - const float deltaX = x - centerX; - const float deltaY = y - centerY; + const float deltaX = x - this->m_centerX; + const float deltaY = y - this->m_centerY; float closestPoint[2]; float lineP1[2]; float lineP2[2]; @@ -62,23 +62,23 @@ float BokehImageOperation::isInsideBokeh(float distance, float x, float y) point[0] = x; point[1] = y; - const float distanceToCenter = len_v2v2(point, center); + const float distanceToCenter = len_v2v2(point, this->m_center); const float bearing = (atan2f(deltaX, deltaY) + (float)(M_PI * 2.0)); - int flapNumber = (int)((bearing - flapRadAdd) / flapRad); + int flapNumber = (int)((bearing - this->m_flapRadAdd) / this->m_flapRad); detemineStartPointOfFlap(lineP1, flapNumber, distance); detemineStartPointOfFlap(lineP2, flapNumber + 1, distance); closest_to_line_v2(closestPoint, point, lineP1, lineP2); - const float distanceLineToCenter = len_v2v2(center, closestPoint); - const float distanceRoundingToCenter = inverseRounding * distanceLineToCenter + this->data->rounding * distance; + const float distanceLineToCenter = len_v2v2(this->m_center, closestPoint); + const float distanceRoundingToCenter = this->m_inverseRounding * distanceLineToCenter + this->m_data->rounding * distance; - const float catadioptricDistanceToCenter = distanceRoundingToCenter * this->data->catadioptric; + const float catadioptricDistanceToCenter = distanceRoundingToCenter * this->m_data->catadioptric; if (distanceRoundingToCenter >= distanceToCenter && catadioptricDistanceToCenter <= distanceToCenter) { if (distanceRoundingToCenter - distanceToCenter < 1.0f) { insideBokeh = (distanceRoundingToCenter - distanceToCenter); } - else if (this->data->catadioptric != 0.0f && distanceToCenter - catadioptricDistanceToCenter < 1.0f) { + else if (this->m_data->catadioptric != 0.0f && distanceToCenter - catadioptricDistanceToCenter < 1.0f) { insideBokeh = (distanceToCenter - catadioptricDistanceToCenter); } else { @@ -89,9 +89,9 @@ float BokehImageOperation::isInsideBokeh(float distance, float x, float y) } void BokehImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - float shift = this->data->lensshift; + float shift = this->m_data->lensshift; float shift2 = shift / 2.0f; - float distance = this->circularDistance; + float distance = this->m_circularDistance; float insideBokehMax = isInsideBokeh(distance, x, y); float insideBokehMed = isInsideBokeh(distance - fabsf(shift2 * distance), x, y); float insideBokehMin = isInsideBokeh(distance - fabsf(shift * distance), x, y); @@ -110,10 +110,10 @@ void BokehImageOperation::executePixel(float *color, float x, float y, PixelSamp void BokehImageOperation::deinitExecution() { - if (deleteData) { - if (data) { - delete data; - data = NULL; + if (this->m_deleteData) { + if (this->m_data) { + delete this->m_data; + this->m_data = NULL; } } } diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.h b/source/blender/compositor/operations/COM_BokehImageOperation.h index 8edd32a4f77..085aaa471f0 100644 --- a/source/blender/compositor/operations/COM_BokehImageOperation.h +++ b/source/blender/compositor/operations/COM_BokehImageOperation.h @@ -27,17 +27,17 @@ class BokehImageOperation : public NodeOperation { private: - NodeBokehImage *data; + NodeBokehImage *m_data; - float center[2]; - float centerX; - float centerY; - float inverseRounding; - float circularDistance; - float flapRad; - float flapRadAdd; + float m_center[2]; + float m_centerX; + float m_centerY; + float m_inverseRounding; + float m_circularDistance; + float m_flapRad; + float m_flapRadAdd; - bool deleteData; + bool m_deleteData; void detemineStartPointOfFlap(float r[2], int flapNumber, float distance); float isInsideBokeh(float distance, float x, float y); @@ -61,7 +61,7 @@ public: void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); - void setData(NodeBokehImage *data) { this->data = data; } - void deleteDataOnFinish() { this->deleteData = true; } + void setData(NodeBokehImage *data) { this->m_data = data; } + void deleteDataOnFinish() { this->m_deleteData = true; } }; #endif diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp index 3b99fc9a2a0..96738a2920a 100644 --- a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp @@ -29,19 +29,19 @@ BoxMaskOperation::BoxMaskOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->inputMask = NULL; - this->inputValue = NULL; - this->cosine = 0.0f; - this->sine = 0.0f; + this->m_inputMask = NULL; + this->m_inputValue = NULL; + this->m_cosine = 0.0f; + this->m_sine = 0.0f; } void BoxMaskOperation::initExecution() { - this->inputMask = this->getInputSocketReader(0); - this->inputValue = this->getInputSocketReader(1); - const double rad = DEG2RAD((double)this->data->rotation); - this->cosine = cos(rad); - this->sine = sin(rad); - this->aspectRatio = ((float)this->getWidth()) / this->getHeight(); + this->m_inputMask = this->getInputSocketReader(0); + this->m_inputValue = this->getInputSocketReader(1); + const double rad = DEG2RAD((double)this->m_data->rotation); + this->m_cosine = cos(rad); + this->m_sine = sin(rad); + this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight(); } void BoxMaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -52,22 +52,22 @@ void BoxMaskOperation::executePixel(float *color, float x, float y, PixelSampler float rx = x / this->getWidth(); float ry = y / this->getHeight(); - const float dy = (ry - this->data->y) / this->aspectRatio; - const float dx = rx - this->data->x; - rx = this->data->x + (this->cosine * dx + this->sine * dy); - ry = this->data->y + (-this->sine * dx + this->cosine * dy); + const float dy = (ry - this->m_data->y) / this->m_aspectRatio; + const float dx = rx - this->m_data->x; + rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy); + ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy); - this->inputMask->read(inputMask, x, y, sampler, inputBuffers); - this->inputValue->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputMask->read(inputMask, x, y, sampler, inputBuffers); + this->m_inputValue->read(inputValue, x, y, sampler, inputBuffers); - float halfHeight = this->data->height / 2.0f; - float halfWidth = this->data->width / 2.0f; - bool inside = (rx > this->data->x - halfWidth && - rx < this->data->x + halfWidth && - ry > this->data->y - halfHeight && - ry < this->data->y + halfHeight); + float halfHeight = this->m_data->height / 2.0f; + float halfWidth = this->m_data->width / 2.0f; + bool inside = (rx > this->m_data->x - halfWidth && + rx < this->m_data->x + halfWidth && + ry > this->m_data->y - halfHeight && + ry < this->m_data->y + halfHeight); - switch (this->maskType) { + switch (this->m_maskType) { case CMP_NODE_MASKTYPE_ADD: if (inside) { color[0] = max(inputMask[0], inputValue[0]); @@ -113,7 +113,7 @@ void BoxMaskOperation::executePixel(float *color, float x, float y, PixelSampler void BoxMaskOperation::deinitExecution() { - this->inputMask = NULL; - this->inputValue = NULL; + this->m_inputMask = NULL; + this->m_inputValue = NULL; } diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.h b/source/blender/compositor/operations/COM_BoxMaskOperation.h index 65327abc9a6..cec680ef6c3 100644 --- a/source/blender/compositor/operations/COM_BoxMaskOperation.h +++ b/source/blender/compositor/operations/COM_BoxMaskOperation.h @@ -30,15 +30,15 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputMask; - SocketReader *inputValue; + SocketReader *m_inputMask; + SocketReader *m_inputValue; - float sine; - float cosine; - float aspectRatio; - int maskType; + float m_sine; + float m_cosine; + float m_aspectRatio; + int m_maskType; - NodeBoxMask *data; + NodeBoxMask *m_data; public: BoxMaskOperation(); @@ -57,9 +57,9 @@ public: */ void deinitExecution(); - void setData(NodeBoxMask *data) { this->data = data; } + void setData(NodeBoxMask *data) { this->m_data = data; } - void setMaskType(int maskType) { this->maskType = maskType; } + void setMaskType(int maskType) { this->m_maskType = maskType; } }; #endif diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.cpp b/source/blender/compositor/operations/COM_BrightnessOperation.cpp index 95862a1fd83..8c9fb6394a7 100644 --- a/source/blender/compositor/operations/COM_BrightnessOperation.cpp +++ b/source/blender/compositor/operations/COM_BrightnessOperation.cpp @@ -28,13 +28,13 @@ BrightnessOperation::BrightnessOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void BrightnessOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); - this->inputBrightnessProgram = this->getInputSocketReader(1); - this->inputContrastProgram = this->getInputSocketReader(2); + this->m_inputProgram = this->getInputSocketReader(0); + this->m_inputBrightnessProgram = this->getInputSocketReader(1); + this->m_inputContrastProgram = this->getInputSocketReader(2); } void BrightnessOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -43,9 +43,9 @@ void BrightnessOperation::executePixel(float *color, float x, float y, PixelSamp float a, b; float inputBrightness[4]; float inputContrast[4]; - this->inputProgram->read(inputValue, x, y, sampler, inputBuffers); - this->inputBrightnessProgram->read(inputBrightness, x, y, sampler, inputBuffers); - this->inputContrastProgram->read(inputContrast, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputBrightnessProgram->read(inputBrightness, x, y, sampler, inputBuffers); + this->m_inputContrastProgram->read(inputContrast, x, y, sampler, inputBuffers); float brightness = inputBrightness[0]; float contrast = inputContrast[0]; brightness /= 100.0f; @@ -73,8 +73,8 @@ void BrightnessOperation::executePixel(float *color, float x, float y, PixelSamp void BrightnessOperation::deinitExecution() { - this->inputProgram = NULL; - this->inputBrightnessProgram = NULL; - this->inputContrastProgram = NULL; + this->m_inputProgram = NULL; + this->m_inputBrightnessProgram = NULL; + this->m_inputContrastProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.h b/source/blender/compositor/operations/COM_BrightnessOperation.h index 74c648fd8fb..61f667aa1be 100644 --- a/source/blender/compositor/operations/COM_BrightnessOperation.h +++ b/source/blender/compositor/operations/COM_BrightnessOperation.h @@ -30,9 +30,9 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; - SocketReader *inputBrightnessProgram; - SocketReader *inputContrastProgram; + SocketReader *m_inputProgram; + SocketReader *m_inputBrightnessProgram; + SocketReader *m_inputContrastProgram; public: BrightnessOperation(); diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp index 3f9003b8c48..a1c679b3e15 100644 --- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp +++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp @@ -30,33 +30,33 @@ CalculateMeanOperation::CalculateMeanOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); this->addOutputSocket(COM_DT_VALUE); - this->imageReader = NULL; - this->iscalculated = false; - this->setting = 1; + this->m_imageReader = NULL; + this->m_iscalculated = false; + this->m_setting = 1; this->setComplex(true); } void CalculateMeanOperation::initExecution() { - this->imageReader = this->getInputSocketReader(0); - this->iscalculated = false; + this->m_imageReader = this->getInputSocketReader(0); + this->m_iscalculated = false; NodeOperation::initMutex(); } void CalculateMeanOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - color[0] = this->result; + color[0] = this->m_result; } void CalculateMeanOperation::deinitExecution() { - this->imageReader = NULL; + this->m_imageReader = NULL; NodeOperation::deinitMutex(); } bool CalculateMeanOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti imageInput; - if (iscalculated) { + if (this->m_iscalculated) { return false; } NodeOperation *operation = getInputOperation(0); @@ -73,10 +73,10 @@ bool CalculateMeanOperation::determineDependingAreaOfInterest(rcti *input, ReadB void *CalculateMeanOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { lockMutex(); - if (!this->iscalculated) { - MemoryBuffer *tile = (MemoryBuffer *)imageReader->initializeTileData(rect, memoryBuffers); + if (!this->m_iscalculated) { + MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect, memoryBuffers); calculateMean(tile); - this->iscalculated = true; + this->m_iscalculated = true; } unlockMutex(); return NULL; @@ -84,20 +84,19 @@ void *CalculateMeanOperation::initializeTileData(rcti *rect, MemoryBuffer **memo void CalculateMeanOperation::calculateMean(MemoryBuffer *tile) { - this->result = 0.0f; + this->m_result = 0.0f; float *buffer = tile->getBuffer(); int size = tile->getWidth() * tile->getHeight(); int pixels = 0; - float sum; + float sum = 0.0f; for (int i = 0, offset = 0; i < size; i++, offset += 4) { if (buffer[offset + 3] > 0) { pixels++; - switch (this->setting) - { + switch (this->m_setting) { case 1: { - sum += buffer[offset] * 0.35f + buffer[offset + 1] * 0.45f + buffer[offset + 2] * 0.2f; + sum += rgb_to_bw(&buffer[offset]); break; } case 2: @@ -125,5 +124,5 @@ void CalculateMeanOperation::calculateMean(MemoryBuffer *tile) } } } - this->result = sum / pixels; + this->m_result = sum / pixels; } diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.h b/source/blender/compositor/operations/COM_CalculateMeanOperation.h index 7a28eb3774a..2bd723c40a3 100644 --- a/source/blender/compositor/operations/COM_CalculateMeanOperation.h +++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.h @@ -34,11 +34,11 @@ protected: /** * @brief Cached reference to the reader */ - SocketReader *imageReader; + SocketReader *m_imageReader; - bool iscalculated; - float result; - int setting; + bool m_iscalculated; + float m_result; + int m_setting; public: CalculateMeanOperation(); @@ -61,7 +61,7 @@ public: void deinitExecution(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void setSetting(int setting) { this->setting = setting; } + void setSetting(int setting) { this->m_setting = setting; } protected: void calculateMean(MemoryBuffer *tile); diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp index b0739cd7567..2d860df449c 100644 --- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp +++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp @@ -33,30 +33,29 @@ CalculateStandardDeviationOperation::CalculateStandardDeviationOperation() : Cal void CalculateStandardDeviationOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - color[0] = this->standardDeviation; + color[0] = this->m_standardDeviation; } void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { lockMutex(); - if (!this->iscalculated) { - MemoryBuffer *tile = (MemoryBuffer *)imageReader->initializeTileData(rect, memoryBuffers); + if (!this->m_iscalculated) { + MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect, memoryBuffers); CalculateMeanOperation::calculateMean(tile); - this->standardDeviation = 0.0f; + this->m_standardDeviation = 0.0f; float *buffer = tile->getBuffer(); int size = tile->getWidth() * tile->getHeight(); int pixels = 0; - float sum; - float mean = this->result; + float sum = 0.0f; + float mean = this->m_result; for (int i = 0, offset = 0; i < size; i++, offset += 4) { if (buffer[offset + 3] > 0) { pixels++; - switch (this->setting) - { + switch (this->m_setting) { case 1: { - float value = buffer[offset] * 0.35f + buffer[offset + 1] * 0.45f + buffer[offset + 2] * 0.2f; + float value = rgb_to_bw(&buffer[offset]); sum += (value - mean) * (value - mean); break; } @@ -90,8 +89,8 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect, Memory } } } - this->standardDeviation = sqrt(sum / (float)(pixels - 1)); - this->iscalculated = true; + this->m_standardDeviation = sqrt(sum / (float)(pixels - 1)); + this->m_iscalculated = true; } unlockMutex(); return NULL; diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h index d3163d4cc32..506c5d6fe3a 100644 --- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h +++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h @@ -31,7 +31,7 @@ */ class CalculateStandardDeviationOperation : public CalculateMeanOperation { protected: - float standardDeviation; + float m_standardDeviation; public: CalculateStandardDeviationOperation(); diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp index 487c1869782..0812dd45bf6 100644 --- a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp +++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp @@ -26,30 +26,30 @@ ChangeHSVOperation::ChangeHSVOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ChangeHSVOperation::initExecution() { - this->inputOperation = getInputSocketReader(0); + this->m_inputOperation = getInputSocketReader(0); } void ChangeHSVOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ChangeHSVOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor1[4]; - inputOperation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor1, x, y, sampler, inputBuffers); - outputValue[0] = inputColor1[0] + (this->hue - 0.5f); + outputValue[0] = inputColor1[0] + (this->m_hue - 0.5f); if (outputValue[0] > 1.0f) outputValue[0] -= 1.0f; else if (outputValue[0] < 0.0f) outputValue[0] += 1.0f; - outputValue[1] = inputColor1[1] * this->saturation; - outputValue[2] = inputColor1[2] * this->value; + outputValue[1] = inputColor1[1] * this->m_saturation; + outputValue[2] = inputColor1[2] * this->m_value; outputValue[3] = inputColor1[3]; } diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.h b/source/blender/compositor/operations/COM_ChangeHSVOperation.h index a2a6c034a82..ee35fbe01d4 100644 --- a/source/blender/compositor/operations/COM_ChangeHSVOperation.h +++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.h @@ -26,16 +26,16 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ChangeHSVOperation : public NodeOperation { private: - SocketReader *inputOperation; + SocketReader *m_inputOperation; - float hue; - float saturation; - float value; + float m_hue; + float m_saturation; + float m_value; public: /** @@ -51,9 +51,9 @@ public: */ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); - void setHue(float hue) { this->hue = hue; } - void setSaturation(float saturation) { this->saturation = saturation; } - void setValue(float value) { this->value = value; } + void setHue(float hue) { this->m_hue = hue; } + void setSaturation(float saturation) { this->m_saturation = saturation; } + void setValue(float value) { this->m_value = value; } }; #endif diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp index 24af1a3aa53..b2de934e6d8 100644 --- a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp @@ -27,45 +27,45 @@ ChannelMatteOperation::ChannelMatteOperation() : NodeOperation() addInputSocket(COM_DT_COLOR); addOutputSocket(COM_DT_VALUE); - inputImageProgram = NULL; + this->m_inputImageProgram = NULL; } void ChannelMatteOperation::initExecution() { - this->inputImageProgram = this->getInputSocketReader(0); + this->m_inputImageProgram = this->getInputSocketReader(0); - this->limit_range = this->limit_max - this->limit_min; + this->m_limit_range = this->m_limit_max - this->m_limit_min; - switch (this->limit_method) { + switch (this->m_limit_method) { /* SINGLE */ case 0: { /* 123 / RGB / HSV / YUV / YCC */ - const int matte_channel = this->matte_channel - 1; - const int limit_channel = this->limit_channel - 1; - this->ids[0] = matte_channel; - this->ids[1] = limit_channel; - this->ids[2] = limit_channel; + const int matte_channel = this->m_matte_channel - 1; + const int limit_channel = this->m_limit_channel - 1; + this->m_ids[0] = matte_channel; + this->m_ids[1] = limit_channel; + this->m_ids[2] = limit_channel; break; } /* MAX */ case 1: { - switch (this->matte_channel) { + switch (this->m_matte_channel) { case 1: { - this->ids[0] = 0; - this->ids[1] = 1; - this->ids[2] = 2; + this->m_ids[0] = 0; + this->m_ids[1] = 1; + this->m_ids[2] = 2; break; } case 2: { - this->ids[0] = 1; - this->ids[1] = 0; - this->ids[2] = 2; + this->m_ids[0] = 1; + this->m_ids[1] = 0; + this->m_ids[2] = 2; break; } case 3: { - this->ids[0] = 2; - this->ids[1] = 0; - this->ids[2] = 1; + this->m_ids[0] = 2; + this->m_ids[1] = 0; + this->m_ids[2] = 1; break; } default: @@ -80,7 +80,7 @@ void ChannelMatteOperation::initExecution() void ChannelMatteOperation::deinitExecution() { - this->inputImageProgram = NULL; + this->m_inputImageProgram = NULL; } void ChannelMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -88,17 +88,17 @@ void ChannelMatteOperation::executePixel(float *outputValue, float x, float y, P float inColor[4]; float alpha; - const float limit_max = this->limit_max; - const float limit_min = this->limit_min; - const float limit_range = this->limit_range; + const float limit_max = this->m_limit_max; + const float limit_min = this->m_limit_min; + const float limit_range = this->m_limit_range; - this->inputImageProgram->read(inColor, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(inColor, x, y, sampler, inputBuffers); /* matte operation */ - alpha = inColor[this->ids[0]] - max(inColor[this->ids[1]], inColor[this->ids[2]]); + alpha = inColor[this->m_ids[0]] - max(inColor[this->m_ids[1]], inColor[this->m_ids[2]]); /* flip because 0.0 is transparent, not 1.0 */ - alpha = 1.f - alpha; + alpha = 1.0f - alpha; /* test range*/ if (alpha > limit_max) { diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.h b/source/blender/compositor/operations/COM_ChannelMatteOperation.h index 17db0f9ffe2..ee17036a78d 100644 --- a/source/blender/compositor/operations/COM_ChannelMatteOperation.h +++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.h @@ -25,21 +25,21 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ChannelMatteOperation : public NodeOperation { private: - SocketReader *inputImageProgram; + SocketReader *m_inputImageProgram; - int color_space; /* node->custom1 */ - int matte_channel; /* node->custom2 */ - int limit_method; /* node->algorithm */ - int limit_channel; /* node->channel */ - float limit_max; /* node->storage->t1 */ - float limit_min; /* node->storage->t2 */ + /* int m_color_space; */ /* node->custom1 */ /* UNUSED */ /* TODO ? */ + int m_matte_channel; /* node->custom2 */ + int m_limit_method; /* node->algorithm */ + int m_limit_channel; /* node->channel */ + float m_limit_max; /* node->storage->t1 */ + float m_limit_min; /* node->storage->t2 */ - float limit_range; + float m_limit_range; /** ids to use for the operations (max and simple) * alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]]) @@ -49,7 +49,7 @@ private: * ids[2] = ids[1] * alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]]) */ - int ids[3]; + int m_ids[3]; public: /** * Default constructor @@ -66,11 +66,11 @@ public: void setSettings(NodeChroma *nodeChroma, const int custom2) { - this->limit_max = nodeChroma->t1; - this->limit_min = nodeChroma->t2; - this->limit_method = nodeChroma->algorithm; - this->limit_channel = nodeChroma->channel; - this->matte_channel = custom2; + this->m_limit_max = nodeChroma->t1; + this->m_limit_min = nodeChroma->t2; + this->m_limit_method = nodeChroma->algorithm; + this->m_limit_channel = nodeChroma->channel; + this->m_matte_channel = custom2; } }; #endif diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp index 0ce1a585598..e88feb6db9c 100644 --- a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp @@ -28,20 +28,20 @@ ChromaMatteOperation::ChromaMatteOperation() : NodeOperation() addInputSocket(COM_DT_COLOR); addOutputSocket(COM_DT_VALUE); - inputImageProgram = NULL; - inputKeyProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputKeyProgram = NULL; } void ChromaMatteOperation::initExecution() { - this->inputImageProgram = this->getInputSocketReader(0); - this->inputKeyProgram = this->getInputSocketReader(1); + this->m_inputImageProgram = this->getInputSocketReader(0); + this->m_inputKeyProgram = this->getInputSocketReader(1); } void ChromaMatteOperation::deinitExecution() { - this->inputImageProgram = NULL; - this->inputKeyProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputKeyProgram = NULL; } void ChromaMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -49,16 +49,16 @@ void ChromaMatteOperation::executePixel(float *outputValue, float x, float y, Pi float inKey[4]; float inImage[4]; - const float acceptance = this->settings->t1; /* in radians */ - const float cutoff = this->settings->t2; /* in radians */ - const float gain = this->settings->fstrength; + const float acceptance = this->m_settings->t1; /* in radians */ + const float cutoff = this->m_settings->t2; /* in radians */ + const float gain = this->m_settings->fstrength; float x_angle, z_angle, alpha; float theta, beta; float kfg; - this->inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); - this->inputImageProgram->read(inImage, x, y, sampler, inputBuffers); + this->m_inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(inImage, x, y, sampler, inputBuffers); /* store matte(alpha) value in [0] to go with * COM_SetAlphaOperation and the Value output diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.h b/source/blender/compositor/operations/COM_ChromaMatteOperation.h index a09203f29b3..eaca05e66ca 100644 --- a/source/blender/compositor/operations/COM_ChromaMatteOperation.h +++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.h @@ -25,14 +25,14 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ChromaMatteOperation : public NodeOperation { private: - NodeChroma *settings; - SocketReader *inputImageProgram; - SocketReader *inputKeyProgram; + NodeChroma *m_settings; + SocketReader *m_inputImageProgram; + SocketReader *m_inputKeyProgram; public: /** * Default constructor @@ -47,6 +47,6 @@ public: void initExecution(); void deinitExecution(); - void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; } + void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; } }; #endif diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp index a48fe169fd7..66ce86234b7 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp @@ -38,15 +38,15 @@ ColorBalanceASCCDLOperation::ColorBalanceASCCDLOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputValueOperation = NULL; - this->inputColorOperation = NULL; + this->m_inputValueOperation = NULL; + this->m_inputColorOperation = NULL; this->setResolutionInputSocketIndex(1); } void ColorBalanceASCCDLOperation::initExecution() { - this->inputValueOperation = this->getInputSocketReader(0); - this->inputColorOperation = this->getInputSocketReader(1); + this->m_inputValueOperation = this->getInputSocketReader(0); + this->m_inputColorOperation = this->getInputSocketReader(1); } void ColorBalanceASCCDLOperation::executePixel(float *outputColor, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -54,22 +54,22 @@ void ColorBalanceASCCDLOperation::executePixel(float *outputColor, float x, floa float inputColor[4]; float value[4]; - inputValueOperation->read(value, x, y, sampler, inputBuffers); - inputColorOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); + this->m_inputColorOperation->read(inputColor, x, y, sampler, inputBuffers); float fac = value[0]; fac = min(1.0f, fac); const float mfac = 1.0f - fac; - outputColor[0] = mfac * inputColor[0] + fac *colorbalance_cdl(inputColor[0], this->lift[0], this->gamma[0], this->gain[0]); - outputColor[1] = mfac * inputColor[1] + fac *colorbalance_cdl(inputColor[1], this->lift[1], this->gamma[1], this->gain[1]); - outputColor[2] = mfac * inputColor[2] + fac *colorbalance_cdl(inputColor[2], this->lift[2], this->gamma[2], this->gain[2]); + outputColor[0] = mfac * inputColor[0] + fac *colorbalance_cdl(inputColor[0], this->m_lift[0], this->m_gamma[0], this->m_gain[0]); + outputColor[1] = mfac * inputColor[1] + fac *colorbalance_cdl(inputColor[1], this->m_lift[1], this->m_gamma[1], this->m_gain[1]); + outputColor[2] = mfac * inputColor[2] + fac *colorbalance_cdl(inputColor[2], this->m_lift[2], this->m_gamma[2], this->m_gain[2]); outputColor[3] = inputColor[3]; } void ColorBalanceASCCDLOperation::deinitExecution() { - this->inputValueOperation = NULL; - this->inputColorOperation = NULL; + this->m_inputValueOperation = NULL; + this->m_inputColorOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h index 9e7db59d99d..a9c0dff9ad4 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h @@ -25,20 +25,20 @@ #include "COM_NodeOperation.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ColorBalanceASCCDLOperation : public NodeOperation { protected: /** * Prefetched reference to the inputProgram */ - SocketReader *inputValueOperation; - SocketReader *inputColorOperation; + SocketReader *m_inputValueOperation; + SocketReader *m_inputColorOperation; - float gain[3]; - float lift[3]; - float gamma[3]; + float m_gain[3]; + float m_lift[3]; + float m_gamma[3]; public: /** @@ -61,8 +61,8 @@ public: */ void deinitExecution(); - void setGain(float gain[3]) { copy_v3_v3(this->gain, gain); } - void setLift(float lift[3]) { copy_v3_v3(this->lift, lift); } - void setGamma(float gamma[3]) { copy_v3_v3(this->gamma, gamma); } + void setGain(float gain[3]) { copy_v3_v3(this->m_gain, gain); } + void setLift(float lift[3]) { copy_v3_v3(this->m_lift, lift); } + void setGamma(float gamma[3]) { copy_v3_v3(this->m_gamma, gamma); } }; #endif diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp index 7a8d62dfe21..13863a9ec5a 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp @@ -43,15 +43,15 @@ ColorBalanceLGGOperation::ColorBalanceLGGOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputValueOperation = NULL; - this->inputColorOperation = NULL; + this->m_inputValueOperation = NULL; + this->m_inputColorOperation = NULL; this->setResolutionInputSocketIndex(1); } void ColorBalanceLGGOperation::initExecution() { - this->inputValueOperation = this->getInputSocketReader(0); - this->inputColorOperation = this->getInputSocketReader(1); + this->m_inputValueOperation = this->getInputSocketReader(0); + this->m_inputColorOperation = this->getInputSocketReader(1); } void ColorBalanceLGGOperation::executePixel(float *outputColor, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -59,22 +59,22 @@ void ColorBalanceLGGOperation::executePixel(float *outputColor, float x, float y float inputColor[4]; float value[4]; - inputValueOperation->read(value, x, y, sampler, inputBuffers); - inputColorOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(value, x, y, sampler, inputBuffers); + this->m_inputColorOperation->read(inputColor, x, y, sampler, inputBuffers); float fac = value[0]; fac = min(1.0f, fac); const float mfac = 1.0f - fac; - outputColor[0] = mfac * inputColor[0] + fac *colorbalance_lgg(inputColor[0], this->lift[0], this->gamma_inv[0], this->gain[0]); - outputColor[1] = mfac * inputColor[1] + fac *colorbalance_lgg(inputColor[1], this->lift[1], this->gamma_inv[1], this->gain[1]); - outputColor[2] = mfac * inputColor[2] + fac *colorbalance_lgg(inputColor[2], this->lift[2], this->gamma_inv[2], this->gain[2]); + outputColor[0] = mfac * inputColor[0] + fac *colorbalance_lgg(inputColor[0], this->m_lift[0], this->m_gamma_inv[0], this->m_gain[0]); + outputColor[1] = mfac * inputColor[1] + fac *colorbalance_lgg(inputColor[1], this->m_lift[1], this->m_gamma_inv[1], this->m_gain[1]); + outputColor[2] = mfac * inputColor[2] + fac *colorbalance_lgg(inputColor[2], this->m_lift[2], this->m_gamma_inv[2], this->m_gain[2]); outputColor[3] = inputColor[3]; } void ColorBalanceLGGOperation::deinitExecution() { - this->inputValueOperation = NULL; - this->inputColorOperation = NULL; + this->m_inputValueOperation = NULL; + this->m_inputColorOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h index 54cfb49327f..ffc78fae6f1 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h +++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h @@ -26,20 +26,20 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ColorBalanceLGGOperation : public NodeOperation { protected: /** * Prefetched reference to the inputProgram */ - SocketReader *inputValueOperation; - SocketReader *inputColorOperation; + SocketReader *m_inputValueOperation; + SocketReader *m_inputColorOperation; - float gain[3]; - float lift[3]; - float gamma_inv[3]; + float m_gain[3]; + float m_lift[3]; + float m_gamma_inv[3]; public: /** @@ -62,20 +62,8 @@ public: */ void deinitExecution(); - void setGain(float gain[3]) { - this->gain[0] = gain[0]; - this->gain[1] = gain[1]; - this->gain[2] = gain[2]; - } - void setLift(float lift[3]) { - this->lift[0] = lift[0]; - this->lift[1] = lift[1]; - this->lift[2] = lift[2]; - } - void setGammaInv(float gamma_inv[3]) { - this->gamma_inv[0] = gamma_inv[0]; - this->gamma_inv[1] = gamma_inv[1]; - this->gamma_inv[2] = gamma_inv[2]; - } + void setGain(const float gain[3]) { copy_v3_v3(this->m_gain, gain); } + void setLift(const float lift[3]) { copy_v3_v3(this->m_lift, lift); } + void setGammaInv(const float gamma_inv[3]) { copy_v3_v3(this->m_gamma_inv, gamma_inv); } }; #endif diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp index 5f62f9ec403..8008866752f 100644 --- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp @@ -28,31 +28,31 @@ ColorCorrectionOperation::ColorCorrectionOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->inputImage = NULL; - this->inputMask = NULL; - this->redChannelEnabled = true; - this->greenChannelEnabled = true; - this->blueChannelEnabled = true; + this->m_inputImage = NULL; + this->m_inputMask = NULL; + this->m_redChannelEnabled = true; + this->m_greenChannelEnabled = true; + this->m_blueChannelEnabled = true; } void ColorCorrectionOperation::initExecution() { - this->inputImage = this->getInputSocketReader(0); - this->inputMask = this->getInputSocketReader(1); + this->m_inputImage = this->getInputSocketReader(0); + this->m_inputMask = this->getInputSocketReader(1); } void ColorCorrectionOperation::executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputImageColor[4]; float inputMask[4]; - this->inputImage->read(inputImageColor, x, y, sampler, inputBuffers); - this->inputMask->read(inputMask, x, y, sampler, inputBuffers); + this->m_inputImage->read(inputImageColor, x, y, sampler, inputBuffers); + this->m_inputMask->read(inputMask, x, y, sampler, inputBuffers); float level = (inputImageColor[0] + inputImageColor[1] + inputImageColor[2]) / 3.0f; - float contrast = this->data->master.contrast; - float saturation = this->data->master.saturation; - float gamma = this->data->master.gamma; - float gain = this->data->master.gain; - float lift = this->data->master.lift; + float contrast = this->m_data->master.contrast; + float saturation = this->m_data->master.saturation; + float gamma = this->m_data->master.gamma; + float gain = this->m_data->master.gain; + float lift = this->m_data->master.lift; float r, g, b; float value = inputMask[0]; @@ -64,18 +64,18 @@ void ColorCorrectionOperation::executePixel(float *output, float x, float y, Pix float levelHighlights = 0.0; #define MARGIN 0.10f #define MARGIN_DIV (0.5f / MARGIN) - if (level < this->data->startmidtones - MARGIN) { + if (level < this->m_data->startmidtones - MARGIN) { levelShadows = 1.0f; } - else if (level < this->data->startmidtones + MARGIN) { - levelMidtones = ((level - this->data->startmidtones) * MARGIN_DIV) + 0.5f; + else if (level < this->m_data->startmidtones + MARGIN) { + levelMidtones = ((level - this->m_data->startmidtones) * MARGIN_DIV) + 0.5f; levelShadows = 1.0f - levelMidtones; } - else if (level < this->data->endmidtones - MARGIN) { + else if (level < this->m_data->endmidtones - MARGIN) { levelMidtones = 1.0f; } - else if (level < this->data->endmidtones + MARGIN) { - levelHighlights = ((level - this->data->endmidtones) * MARGIN_DIV) + 0.5f; + else if (level < this->m_data->endmidtones + MARGIN) { + levelHighlights = ((level - this->m_data->endmidtones) * MARGIN_DIV) + 0.5f; levelMidtones = 1.0f - levelHighlights; } else { @@ -83,11 +83,11 @@ void ColorCorrectionOperation::executePixel(float *output, float x, float y, Pix } #undef MARGIN #undef MARGIN_DIV - contrast *= (levelShadows * this->data->shadows.contrast) + (levelMidtones * this->data->midtones.contrast) + (levelHighlights * this->data->highlights.contrast); - saturation *= (levelShadows * this->data->shadows.saturation) + (levelMidtones * this->data->midtones.saturation) + (levelHighlights * this->data->highlights.saturation); - gamma *= (levelShadows * this->data->shadows.gamma) + (levelMidtones * this->data->midtones.gamma) + (levelHighlights * this->data->highlights.gamma); - gain *= (levelShadows * this->data->shadows.gain) + (levelMidtones * this->data->midtones.gain) + (levelHighlights * this->data->highlights.gain); - lift += (levelShadows * this->data->shadows.lift) + (levelMidtones * this->data->midtones.lift) + (levelHighlights * this->data->highlights.lift); + contrast *= (levelShadows * this->m_data->shadows.contrast) + (levelMidtones * this->m_data->midtones.contrast) + (levelHighlights * this->m_data->highlights.contrast); + saturation *= (levelShadows * this->m_data->shadows.saturation) + (levelMidtones * this->m_data->midtones.saturation) + (levelHighlights * this->m_data->highlights.saturation); + gamma *= (levelShadows * this->m_data->shadows.gamma) + (levelMidtones * this->m_data->midtones.gamma) + (levelHighlights * this->m_data->highlights.gamma); + gain *= (levelShadows * this->m_data->shadows.gain) + (levelMidtones * this->m_data->midtones.gain) + (levelHighlights * this->m_data->highlights.gain); + lift += (levelShadows * this->m_data->shadows.lift) + (levelMidtones * this->m_data->midtones.lift) + (levelHighlights * this->m_data->highlights.lift); float invgamma = 1.0f / gamma; float luma = rgb_to_luma_y(inputImageColor); @@ -114,19 +114,19 @@ void ColorCorrectionOperation::executePixel(float *output, float x, float y, Pix g = mvalue * inputImageColor[1] + value * g; b = mvalue * inputImageColor[2] + value * b; - if (this->redChannelEnabled) { + if (this->m_redChannelEnabled) { output[0] = r; } else { output[0] = inputImageColor[0]; } - if (this->greenChannelEnabled) { + if (this->m_greenChannelEnabled) { output[1] = g; } else { output[1] = inputImageColor[1]; } - if (this->blueChannelEnabled) { + if (this->m_blueChannelEnabled) { output[2] = b; } else { @@ -137,7 +137,7 @@ void ColorCorrectionOperation::executePixel(float *output, float x, float y, Pix void ColorCorrectionOperation::deinitExecution() { - this->inputImage = NULL; - this->inputMask = NULL; + this->m_inputImage = NULL; + this->m_inputMask = NULL; } diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h index c0c33f7f2fa..8db3870709e 100644 --- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h +++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h @@ -30,13 +30,13 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputImage; - SocketReader *inputMask; - NodeColorCorrection *data; + SocketReader *m_inputImage; + SocketReader *m_inputMask; + NodeColorCorrection *m_data; - bool redChannelEnabled; - bool greenChannelEnabled; - bool blueChannelEnabled; + bool m_redChannelEnabled; + bool m_greenChannelEnabled; + bool m_blueChannelEnabled; public: ColorCorrectionOperation(); @@ -56,9 +56,9 @@ public: */ void deinitExecution(); - void setData(NodeColorCorrection *data) { this->data = data; } - void setRedChannelEnabled(bool enabled) { this->redChannelEnabled = enabled; } - void setGreenChannelEnabled(bool enabled) { this->greenChannelEnabled = enabled; } - void setBlueChannelEnabled(bool enabled) { this->blueChannelEnabled = enabled; } + void setData(NodeColorCorrection *data) { this->m_data = data; } + void setRedChannelEnabled(bool enabled) { this->m_redChannelEnabled = enabled; } + void setGreenChannelEnabled(bool enabled) { this->m_greenChannelEnabled = enabled; } + void setBlueChannelEnabled(bool enabled) { this->m_blueChannelEnabled = enabled; } }; #endif diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp index 4feac3e7273..9848d191c04 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp @@ -39,28 +39,28 @@ ColorCurveOperation::ColorCurveOperation() : CurveBaseOperation() this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputFacProgram = NULL; - this->inputImageProgram = NULL; - this->inputBlackProgram = NULL; - this->inputWhiteProgram = NULL; + this->m_inputFacProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputBlackProgram = NULL; + this->m_inputWhiteProgram = NULL; this->setResolutionInputSocketIndex(1); } void ColorCurveOperation::initExecution() { CurveBaseOperation::initExecution(); - this->inputFacProgram = this->getInputSocketReader(0); - this->inputImageProgram = this->getInputSocketReader(1); - this->inputBlackProgram = this->getInputSocketReader(2); - this->inputWhiteProgram = this->getInputSocketReader(3); + this->m_inputFacProgram = this->getInputSocketReader(0); + this->m_inputImageProgram = this->getInputSocketReader(1); + this->m_inputBlackProgram = this->getInputSocketReader(2); + this->m_inputWhiteProgram = this->getInputSocketReader(3); - curvemapping_premultiply(this->curveMapping, 0); + curvemapping_premultiply(this->m_curveMapping, 0); } void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - CurveMapping *cumap = this->curveMapping; + CurveMapping *cumap = this->m_curveMapping; CurveMapping *workingCopy = (CurveMapping *)MEM_dupallocN(cumap); float black[4]; @@ -68,13 +68,13 @@ void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSamp float fac[4]; float image[4]; - this->inputBlackProgram->read(black, x, y, sampler, inputBuffers); - this->inputWhiteProgram->read(white, x, y, sampler, inputBuffers); + this->m_inputBlackProgram->read(black, x, y, sampler, inputBuffers); + this->m_inputWhiteProgram->read(white, x, y, sampler, inputBuffers); curvemapping_set_black_white(workingCopy, black, white); - this->inputFacProgram->read(fac, x, y, sampler, inputBuffers); - this->inputImageProgram->read(image, x, y, sampler, inputBuffers); + this->m_inputFacProgram->read(fac, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(image, x, y, sampler, inputBuffers); if (*fac >= 1.0f) curvemapping_evaluate_premulRGBF(workingCopy, color, image); @@ -94,11 +94,11 @@ void ColorCurveOperation::executePixel(float *color, float x, float y, PixelSamp void ColorCurveOperation::deinitExecution() { - this->inputFacProgram = NULL; - this->inputImageProgram = NULL; - this->inputBlackProgram = NULL; - this->inputWhiteProgram = NULL; - curvemapping_premultiply(this->curveMapping, 1); + this->m_inputFacProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputBlackProgram = NULL; + this->m_inputWhiteProgram = NULL; + curvemapping_premultiply(this->m_curveMapping, 1); } @@ -110,20 +110,20 @@ ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation() : CurveBase this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputFacProgram = NULL; - this->inputImageProgram = NULL; + this->m_inputFacProgram = NULL; + this->m_inputImageProgram = NULL; this->setResolutionInputSocketIndex(1); } void ConstantLevelColorCurveOperation::initExecution() { CurveBaseOperation::initExecution(); - this->inputFacProgram = this->getInputSocketReader(0); - this->inputImageProgram = this->getInputSocketReader(1); + this->m_inputFacProgram = this->getInputSocketReader(0); + this->m_inputImageProgram = this->getInputSocketReader(1); - curvemapping_premultiply(this->curveMapping, 0); + curvemapping_premultiply(this->m_curveMapping, 0); - curvemapping_set_black_white(this->curveMapping, this->black, this->white); + curvemapping_set_black_white(this->m_curveMapping, this->m_black, this->m_white); } void ConstantLevelColorCurveOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -132,17 +132,17 @@ void ConstantLevelColorCurveOperation::executePixel(float *color, float x, float float image[4]; - this->inputFacProgram->read(fac, x, y, sampler, inputBuffers); - this->inputImageProgram->read(image, x, y, sampler, inputBuffers); + this->m_inputFacProgram->read(fac, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(image, x, y, sampler, inputBuffers); if (*fac >= 1.0f) - curvemapping_evaluate_premulRGBF(this->curveMapping, color, image); + curvemapping_evaluate_premulRGBF(this->m_curveMapping, color, image); else if (*fac <= 0.0f) { copy_v3_v3(color, image); } else { float col[4], mfac = 1.0f - *fac; - curvemapping_evaluate_premulRGBF(this->curveMapping, col, image); + curvemapping_evaluate_premulRGBF(this->m_curveMapping, col, image); color[0] = mfac * image[0] + *fac * col[0]; color[1] = mfac * image[1] + *fac * col[1]; color[2] = mfac * image[2] + *fac * col[2]; @@ -152,7 +152,7 @@ void ConstantLevelColorCurveOperation::executePixel(float *color, float x, float void ConstantLevelColorCurveOperation::deinitExecution() { - this->inputFacProgram = NULL; - this->inputImageProgram = NULL; - curvemapping_premultiply(this->curveMapping, 1); + this->m_inputFacProgram = NULL; + this->m_inputImageProgram = NULL; + curvemapping_premultiply(this->m_curveMapping, 1); } diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.h b/source/blender/compositor/operations/COM_ColorCurveOperation.h index fcd78be8372..3bcbc31650c 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.h +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.h @@ -31,10 +31,10 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputFacProgram; - SocketReader *inputImageProgram; - SocketReader *inputBlackProgram; - SocketReader *inputWhiteProgram; + SocketReader *m_inputFacProgram; + SocketReader *m_inputImageProgram; + SocketReader *m_inputBlackProgram; + SocketReader *m_inputWhiteProgram; public: ColorCurveOperation(); @@ -59,10 +59,10 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputFacProgram; - SocketReader *inputImageProgram; - float black[3]; - float white[3]; + SocketReader *m_inputFacProgram; + SocketReader *m_inputImageProgram; + float m_black[3]; + float m_white[3]; public: ConstantLevelColorCurveOperation(); @@ -82,8 +82,8 @@ public: */ void deinitExecution(); - void setBlackLevel(float black[3]) { this->black[0] = black[0]; this->black[1] = black[1]; this->black[2] = black[2]; } - void setWhiteLevel(float white[3]) { this->white[0] = white[0]; this->white[1] = white[1]; this->white[2] = white[2]; } + void setBlackLevel(float black[3]) { this->m_black[0] = black[0]; this->m_black[1] = black[1]; this->m_black[2] = black[2]; } + void setWhiteLevel(float white[3]) { this->m_white[0] = white[0]; this->m_white[1] = white[1]; this->m_white[2] = white[2]; } }; #endif diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp index afb362dbdcd..4a01499b060 100644 --- a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp @@ -28,20 +28,20 @@ ColorMatteOperation::ColorMatteOperation() : NodeOperation() addInputSocket(COM_DT_COLOR); addOutputSocket(COM_DT_VALUE); - inputImageProgram = NULL; - inputKeyProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputKeyProgram = NULL; } void ColorMatteOperation::initExecution() { - this->inputImageProgram = this->getInputSocketReader(0); - this->inputKeyProgram = this->getInputSocketReader(1); + this->m_inputImageProgram = this->getInputSocketReader(0); + this->m_inputKeyProgram = this->getInputSocketReader(1); } void ColorMatteOperation::deinitExecution() { - this->inputImageProgram = NULL; - this->inputKeyProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputKeyProgram = NULL; } void ColorMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -49,14 +49,14 @@ void ColorMatteOperation::executePixel(float *outputValue, float x, float y, Pix float inColor[4]; float inKey[4]; - const float hue = this->settings->t1; - const float sat = this->settings->t2; - const float val = this->settings->t3; + const float hue = this->m_settings->t1; + const float sat = this->m_settings->t2; + const float val = this->m_settings->t3; float h_wrap; - this->inputImageProgram->read(inColor, x, y, sampler, inputBuffers); - this->inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(inColor, x, y, sampler, inputBuffers); + this->m_inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); /* store matte(alpha) value in [0] to go with diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.h b/source/blender/compositor/operations/COM_ColorMatteOperation.h index e5dd9efd820..d996ce34667 100644 --- a/source/blender/compositor/operations/COM_ColorMatteOperation.h +++ b/source/blender/compositor/operations/COM_ColorMatteOperation.h @@ -25,14 +25,14 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ColorMatteOperation : public NodeOperation { private: - NodeChroma *settings; - SocketReader *inputImageProgram; - SocketReader *inputKeyProgram; + NodeChroma *m_settings; + SocketReader *m_inputImageProgram; + SocketReader *m_inputKeyProgram; public: /** * Default constructor @@ -47,6 +47,6 @@ public: void initExecution(); void deinitExecution(); - void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; } + void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; } }; #endif diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.cpp b/source/blender/compositor/operations/COM_ColorRampOperation.cpp index 9af70ddc5a7..95dca0dc410 100644 --- a/source/blender/compositor/operations/COM_ColorRampOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorRampOperation.cpp @@ -35,23 +35,23 @@ ColorRampOperation::ColorRampOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; - this->colorBand = NULL; + this->m_inputProgram = NULL; + this->m_colorBand = NULL; } void ColorRampOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void ColorRampOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float values[4]; - this->inputProgram->read(values, x, y, sampler, inputBuffers); - do_colorband(this->colorBand, values[0], color); + this->m_inputProgram->read(values, x, y, sampler, inputBuffers); + do_colorband(this->m_colorBand, values[0], color); } void ColorRampOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.h b/source/blender/compositor/operations/COM_ColorRampOperation.h index eef5321eb19..42bc6b943b7 100644 --- a/source/blender/compositor/operations/COM_ColorRampOperation.h +++ b/source/blender/compositor/operations/COM_ColorRampOperation.h @@ -30,8 +30,8 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; - ColorBand *colorBand; + SocketReader *m_inputProgram; + ColorBand *m_colorBand; public: ColorRampOperation(); @@ -51,7 +51,7 @@ public: void deinitExecution(); void setColorBand(ColorBand *colorBand) { - this->colorBand = colorBand; + this->m_colorBand = colorBand; } diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp index 1a534d778c0..e2773f3a6b4 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp @@ -30,72 +30,72 @@ ColorSpillOperation::ColorSpillOperation() : NodeOperation() addInputSocket(COM_DT_VALUE); addOutputSocket(COM_DT_COLOR); - inputImageReader = NULL; - inputFacReader = NULL; - this->spillChannel = 1; // GREEN + this->m_inputImageReader = NULL; + this->m_inputFacReader = NULL; + this->m_spillChannel = 1; // GREEN } void ColorSpillOperation::initExecution() { - this->inputImageReader = this->getInputSocketReader(0); - this->inputFacReader = this->getInputSocketReader(1); - if (spillChannel == 0) { - this->rmut = -1.0f; - this->gmut = 1.0f; - this->bmut = 1.0f; - this->channel2 = 1; - this->channel3 = 2; - if (this->settings->unspill == 0) { - this->settings->uspillr = 1.0f; - this->settings->uspillg = 0.0f; - this->settings->uspillb = 0.0f; + this->m_inputImageReader = this->getInputSocketReader(0); + this->m_inputFacReader = this->getInputSocketReader(1); + if (this->m_spillChannel == 0) { + this->m_rmut = -1.0f; + this->m_gmut = 1.0f; + this->m_bmut = 1.0f; + this->m_channel2 = 1; + this->m_channel3 = 2; + if (this->m_settings->unspill == 0) { + this->m_settings->uspillr = 1.0f; + this->m_settings->uspillg = 0.0f; + this->m_settings->uspillb = 0.0f; } } - else if (spillChannel == 1) { - this->rmut = 1.0f; - this->gmut = -1.0f; - this->bmut = 1.0f; - this->channel2 = 0; - this->channel3 = 2; - if (this->settings->unspill == 0) { - this->settings->uspillr = 0.0f; - this->settings->uspillg = 1.0f; - this->settings->uspillb = 0.0f; + else if (this->m_spillChannel == 1) { + this->m_rmut = 1.0f; + this->m_gmut = -1.0f; + this->m_bmut = 1.0f; + this->m_channel2 = 0; + this->m_channel3 = 2; + if (this->m_settings->unspill == 0) { + this->m_settings->uspillr = 0.0f; + this->m_settings->uspillg = 1.0f; + this->m_settings->uspillb = 0.0f; } } else { - this->rmut = 1.0f; - this->gmut = 1.0f; - this->bmut = -1.0f; + this->m_rmut = 1.0f; + this->m_gmut = 1.0f; + this->m_bmut = -1.0f; - this->channel2 = 0; - this->channel3 = 1; - if (this->settings->unspill == 0) { - this->settings->uspillr = 0.0f; - this->settings->uspillg = 0.0f; - this->settings->uspillb = 1.0f; + this->m_channel2 = 0; + this->m_channel3 = 1; + if (this->m_settings->unspill == 0) { + this->m_settings->uspillr = 0.0f; + this->m_settings->uspillg = 0.0f; + this->m_settings->uspillb = 1.0f; } } } void ColorSpillOperation::deinitExecution() { - this->inputImageReader = NULL; - this->inputFacReader = NULL; + this->m_inputImageReader = NULL; + this->m_inputFacReader = NULL; } void ColorSpillOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float fac[4]; float input[4]; - this->inputFacReader->read(fac, x, y, sampler, inputBuffers); - this->inputImageReader->read(input, x, y, sampler, inputBuffers); + this->m_inputFacReader->read(fac, x, y, sampler, inputBuffers); + this->m_inputImageReader->read(input, x, y, sampler, inputBuffers); float rfac = min(1.0f, fac[0]); float map = calculateMapValue(rfac, input); if (map > 0.0f) { - outputValue[0] = input[0] + this->rmut * (this->settings->uspillr * map); - outputValue[1] = input[1] + this->gmut * (this->settings->uspillg * map); - outputValue[2] = input[2] + this->bmut * (this->settings->uspillb * map); + outputValue[0] = input[0] + this->m_rmut * (this->m_settings->uspillr * map); + outputValue[1] = input[1] + this->m_gmut * (this->m_settings->uspillg * map); + outputValue[2] = input[2] + this->m_bmut * (this->m_settings->uspillb * map); outputValue[3] = input[3]; } else { @@ -104,11 +104,11 @@ void ColorSpillOperation::executePixel(float *outputValue, float x, float y, Pix } float ColorSpillOperation::calculateMapValue(float fac, float *input) { - return fac * (input[this->spillChannel] - (this->settings->limscale * input[this->settings->limchan])); + return fac * (input[this->m_spillChannel] - (this->m_settings->limscale * input[this->m_settings->limchan])); } float ColorSpillAverageOperation::calculateMapValue(float fac, float *input) { - return fac * (input[this->spillChannel] - (this->settings->limscale * AVG(input[this->channel2], input[this->channel3]))); + return fac * (input[this->m_spillChannel] - (this->m_settings->limscale * AVG(input[this->m_channel2], input[this->m_channel3]))); } diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.h b/source/blender/compositor/operations/COM_ColorSpillOperation.h index e890a1e1564..7aac612cb8c 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.h +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.h @@ -25,18 +25,18 @@ #include "COM_NodeOperation.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ColorSpillOperation : public NodeOperation { protected: - NodeColorspill *settings; - SocketReader *inputImageReader; - SocketReader *inputFacReader; - int spillChannel; - int channel2; - int channel3; - float rmut, gmut, bmut; + NodeColorspill *m_settings; + SocketReader *m_inputImageReader; + SocketReader *m_inputFacReader; + int m_spillChannel; + int m_channel2; + int m_channel3; + float m_rmut, m_gmut, m_bmut; public: /** * Default constructor @@ -51,8 +51,8 @@ public: void initExecution(); void deinitExecution(); - void setSettings(NodeColorspill *nodeColorSpill) { this->settings = nodeColorSpill; } - void setSpillChannel(int channel) { this->spillChannel = channel; } + void setSettings(NodeColorspill *nodeColorSpill) { this->m_settings = nodeColorSpill; } + void setSpillChannel(int channel) { this->m_spillChannel = channel; } float calculateMapValue(float fac, float *input); }; diff --git a/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp b/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp index dff8ccf7e73..9f175a381a4 100644 --- a/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp +++ b/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp @@ -21,7 +21,7 @@ */ #include "COM_CombineChannelsOperation.h" -#include <stdio.h> +#include "BLI_utildefines.h" CombineChannelsOperation::CombineChannelsOperation() : NodeOperation() { @@ -31,25 +31,50 @@ CombineChannelsOperation::CombineChannelsOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputChannel1Operation = NULL; - this->inputChannel2Operation = NULL; - this->inputChannel3Operation = NULL; - this->inputChannel4Operation = NULL; + this->m_inputChannel1Operation = NULL; + this->m_inputChannel2Operation = NULL; + this->m_inputChannel3Operation = NULL; + this->m_inputChannel4Operation = NULL; } + +bool CombineChannelsOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + rcti tempOutput; + bool first = true; + for (int i = 0 ; i < 4 ; i ++) { + NodeOperation * inputOperation = this->getInputOperation(i); + if (inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) { + if (first) { + output->xmin = tempOutput.xmin; + output->ymin = tempOutput.ymin; + output->xmax = tempOutput.xmax; + output->ymax = tempOutput.ymax; + first = false; + } else { + output->xmin = MIN2(output->xmin, tempOutput.xmin); + output->ymin = MIN2(output->ymin, tempOutput.ymin); + output->xmax = MAX2(output->xmax, tempOutput.xmax); + output->ymax = MAX2(output->ymax, tempOutput.ymax); + } + } + } + return !first; +} + void CombineChannelsOperation::initExecution() { - this->inputChannel1Operation = this->getInputSocketReader(0); - this->inputChannel2Operation = this->getInputSocketReader(1); - this->inputChannel3Operation = this->getInputSocketReader(2); - this->inputChannel4Operation = this->getInputSocketReader(3); + this->m_inputChannel1Operation = this->getInputSocketReader(0); + this->m_inputChannel2Operation = this->getInputSocketReader(1); + this->m_inputChannel3Operation = this->getInputSocketReader(2); + this->m_inputChannel4Operation = this->getInputSocketReader(3); } void CombineChannelsOperation::deinitExecution() { - this->inputChannel1Operation = NULL; - this->inputChannel2Operation = NULL; - this->inputChannel3Operation = NULL; - this->inputChannel4Operation = NULL; + this->m_inputChannel1Operation = NULL; + this->m_inputChannel2Operation = NULL; + this->m_inputChannel3Operation = NULL; + this->m_inputChannel4Operation = NULL; } @@ -57,20 +82,20 @@ void CombineChannelsOperation::executePixel(float *color, float x, float y, Pixe { float input[4]; /// @todo: remove if statements - if (this->inputChannel1Operation) { - this->inputChannel1Operation->read(input, x, y, sampler, inputBuffers); + if (this->m_inputChannel1Operation) { + this->m_inputChannel1Operation->read(input, x, y, sampler, inputBuffers); color[0] = input[0]; } - if (this->inputChannel2Operation) { - this->inputChannel2Operation->read(input, x, y, sampler, inputBuffers); + if (this->m_inputChannel2Operation) { + this->m_inputChannel2Operation->read(input, x, y, sampler, inputBuffers); color[1] = input[0]; } - if (this->inputChannel3Operation) { - this->inputChannel3Operation->read(input, x, y, sampler, inputBuffers); + if (this->m_inputChannel3Operation) { + this->m_inputChannel3Operation->read(input, x, y, sampler, inputBuffers); color[2] = input[0]; } - if (this->inputChannel4Operation) { - this->inputChannel4Operation->read(input, x, y, sampler, inputBuffers); + if (this->m_inputChannel4Operation) { + this->m_inputChannel4Operation->read(input, x, y, sampler, inputBuffers); color[3] = input[0]; } } diff --git a/source/blender/compositor/operations/COM_CombineChannelsOperation.h b/source/blender/compositor/operations/COM_CombineChannelsOperation.h index d2977155e14..8e4c2120614 100644 --- a/source/blender/compositor/operations/COM_CombineChannelsOperation.h +++ b/source/blender/compositor/operations/COM_CombineChannelsOperation.h @@ -27,16 +27,18 @@ class CombineChannelsOperation : public NodeOperation { private: - SocketReader *inputChannel1Operation; - SocketReader *inputChannel2Operation; - SocketReader *inputChannel3Operation; - SocketReader *inputChannel4Operation; + SocketReader *m_inputChannel1Operation; + SocketReader *m_inputChannel2Operation; + SocketReader *m_inputChannel3Operation; + SocketReader *m_inputChannel4Operation; public: CombineChannelsOperation(); void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); void initExecution(); void deinitExecution(); + + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); }; #endif diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp index 2b1a804b432..717b6ce76cc 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.cpp +++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp @@ -41,37 +41,37 @@ CompositorOperation::CompositorOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VALUE); - this->setScene(NULL); - this->outputBuffer = NULL; - this->imageInput = NULL; - this->alphaInput = NULL; + this->setRenderData(NULL); + this->m_outputBuffer = NULL; + this->m_imageInput = NULL; + this->m_alphaInput = NULL; } void CompositorOperation::initExecution() { // When initializing the tree during initial load the width and height can be zero. - this->imageInput = getInputSocketReader(0); - this->alphaInput = getInputSocketReader(1); + this->m_imageInput = getInputSocketReader(0); + this->m_alphaInput = getInputSocketReader(1); if (this->getWidth() * this->getHeight() != 0) { - this->outputBuffer = (float *) MEM_callocN(this->getWidth() * this->getHeight() * 4 * sizeof(float), "CompositorOperation"); + this->m_outputBuffer = (float *) MEM_callocN(this->getWidth() * this->getHeight() * 4 * sizeof(float), "CompositorOperation"); } } void CompositorOperation::deinitExecution() { if (!isBreaked()) { - const Scene *scene = this->scene; - Render *re = RE_GetRender(scene->id.name); + const RenderData *rd = this->m_rd; + Render *re = RE_GetRender_FromData(rd); RenderResult *rr = RE_AcquireResultWrite(re); if (rr) { - if (rr->rectf != NULL) { + if (rr->rectf != NULL) { MEM_freeN(rr->rectf); } - rr->rectf = outputBuffer; + rr->rectf = this->m_outputBuffer; } else { - if (this->outputBuffer) { - MEM_freeN(this->outputBuffer); + if (this->m_outputBuffer) { + MEM_freeN(this->m_outputBuffer); } } @@ -83,21 +83,21 @@ void CompositorOperation::deinitExecution() } } else { - if (this->outputBuffer) { - MEM_freeN(this->outputBuffer); + if (this->m_outputBuffer) { + MEM_freeN(this->m_outputBuffer); } } - this->outputBuffer = NULL; - this->imageInput = NULL; - this->alphaInput = NULL; + this->m_outputBuffer = NULL; + this->m_imageInput = NULL; + this->m_alphaInput = NULL; } void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) { float color[8]; // 7 is enough - float *buffer = this->outputBuffer; + float *buffer = this->m_outputBuffer; if (!buffer) return; int x1 = rect->xmin; @@ -111,9 +111,9 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, Mem for (y = y1; y < y2 && (!breaked); y++) { for (x = x1; x < x2 && (!breaked); x++) { - imageInput->read(color, x, y, COM_PS_NEAREST, memoryBuffers); - if (alphaInput != NULL) { - alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_imageInput->read(color, x, y, COM_PS_NEAREST, memoryBuffers); + if (this->m_alphaInput != NULL) { + this->m_alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST, memoryBuffers); } copy_v4_v4(buffer + offset, color); offset += COM_NUMBER_OF_CHANNELS; @@ -127,12 +127,12 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, Mem void CompositorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { - int width = this->scene->r.xsch * this->scene->r.size / 100; - int height = this->scene->r.ysch * this->scene->r.size / 100; + int width = this->m_rd->xsch * this->m_rd->size / 100; + int height = this->m_rd->ysch * this->m_rd->size / 100; // 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->scene->id.name); + Render *re = RE_GetRender_FromData(this->m_rd); 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 0129c953946..2719d376339 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.h +++ b/source/blender/compositor/operations/COM_CompositorOperation.h @@ -34,26 +34,26 @@ private: /** * @brief local reference to the scene */ - const Scene *scene; + const RenderData *m_rd; /** * @brief reference to the output float buffer */ - float *outputBuffer; + float *m_outputBuffer; /** * @brief local reference to the input image operation */ - SocketReader *imageInput; + SocketReader *m_imageInput; /** * @brief local reference to the input alpha operation */ - SocketReader *alphaInput; + SocketReader *m_alphaInput; public: CompositorOperation(); void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); - void setScene(const Scene *scene) { this->scene = scene; } + void setRenderData(const RenderData *rd) { this->m_rd = rd; } bool isOutputOperation(bool rendering) const { return true; } void initExecution(); void deinitExecution(); diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp index 2e8fc9005b8..4d829eae7a0 100644 --- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp @@ -29,23 +29,23 @@ ConvertColorProfileOperation::ConvertColorProfileOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; - this->predivided = false; + this->m_inputOperation = NULL; + this->m_predivided = false; } void ConvertColorProfileOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertColorProfileOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float color[4]; - inputOperation->read(color, x, y, sampler, inputBuffers); - IMB_buffer_float_from_float(outputValue, color, 4, this->toProfile, this->fromProfile, this->predivided, 1, 1, 0, 0); + this->m_inputOperation->read(color, x, y, sampler, inputBuffers); + IMB_buffer_float_from_float(outputValue, color, 4, this->m_toProfile, this->m_fromProfile, this->m_predivided, 1, 1, 0, 0); } void ConvertColorProfileOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h index b11a06f7749..b237448d16e 100644 --- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h @@ -26,30 +26,30 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertColorProfileOperation : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; /** * @brief color profile where to convert from */ - int fromProfile; + int m_fromProfile; /** * @brief color profile where to convert to */ - int toProfile; + int m_toProfile; /** * @brief is color predivided */ - bool predivided; + bool m_predivided; public: /** * Default constructor @@ -71,8 +71,8 @@ public: */ void deinitExecution(); - void setFromColorProfile(int colorProfile) { this->fromProfile = colorProfile; } - void setToColorProfile(int colorProfile) { this->toProfile = colorProfile; } - void setPredivided(bool predivided) { this->predivided = predivided; } + void setFromColorProfile(int colorProfile) { this->m_fromProfile = colorProfile; } + void setToColorProfile(int colorProfile) { this->m_toProfile = colorProfile; } + void setPredivided(bool predivided) { this->m_predivided = predivided; } }; #endif diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp index c66cb8df9be..a8c57449a2e 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp @@ -26,22 +26,22 @@ ConvertColorToBWOperation::ConvertColorToBWOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_VALUE); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertColorToBWOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertColorToBWOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers); - outputValue[0] = inputColor[0] * 0.35f + inputColor[1] * 0.45f + inputColor[2] * 0.2f; + this->m_inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers); + outputValue[0] = rgb_to_bw(inputColor); } void ConvertColorToBWOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h index 814c0c2e808..9c62ad8dd39 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h @@ -26,15 +26,15 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertColorToBWOperation : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp b/source/blender/compositor/operations/COM_ConvertColorToValueProg.cpp index 2c8caec6f61..c09842b1aa9 100644 --- a/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorToValueProg.cpp @@ -20,28 +20,28 @@ * Monique Dewanchand */ -#include "COM_ConvertColourToValueProg.h" +#include "COM_ConvertColorToValueProg.h" -ConvertColourToValueProg::ConvertColourToValueProg() : NodeOperation() +ConvertColorToValueProg::ConvertColorToValueProg() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_VALUE); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } -void ConvertColourToValueProg::initExecution() +void ConvertColorToValueProg::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertColourToValueProg::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertColorToValueProg::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers); + this->m_inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers); outputValue[0] = (inputColor[0] + inputColor[1] + inputColor[2]) / 3.0f; } -void ConvertColourToValueProg::deinitExecution() +void ConvertColorToValueProg::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertColourToValueProg.h b/source/blender/compositor/operations/COM_ConvertColorToValueProg.h index 9c43ec47604..c1ac7ca69ce 100644 --- a/source/blender/compositor/operations/COM_ConvertColourToValueProg.h +++ b/source/blender/compositor/operations/COM_ConvertColorToValueProg.h @@ -20,26 +20,26 @@ * Monique Dewanchand */ -#ifndef _COM_ConvertColourToValueProg_h -#define _COM_ConvertColourToValueProg_h +#ifndef _COM_ConvertColorToValueProg_h +#define _COM_ConvertColorToValueProg_h #include "COM_NodeOperation.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ -class ConvertColourToValueProg : public NodeOperation { +class ConvertColorToValueProg : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor */ - ConvertColourToValueProg(); + ConvertColorToValueProg(); /** * the inner loop of this program diff --git a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp index 613bfe68fbb..6c79c4ea6a3 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp @@ -26,20 +26,20 @@ ConvertColorToVectorOperation::ConvertColorToVectorOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_VECTOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertColorToVectorOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertColorToVectorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - inputOperation->read(outputValue, x, y, sampler, inputBuffers); + this->m_inputOperation->read(outputValue, x, y, sampler, inputBuffers); } void ConvertColorToVectorOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h index 1167b565a8e..51fa3a677cd 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h @@ -26,15 +26,15 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertColorToVectorOperation : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp index 1746afea713..91b68a90126 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp @@ -28,27 +28,27 @@ ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->inputOperation = NULL; - this->fStop = 128.0f; - this->cameraObject = NULL; - this->maxRadius = 32.0f; + this->m_inputOperation = NULL; + this->m_fStop = 128.0f; + this->m_cameraObject = NULL; + this->m_maxRadius = 32.0f; } float ConvertDepthToRadiusOperation::determineFocalDistance() { - if (cameraObject == NULL || cameraObject->type != OB_CAMERA) { + if (this->m_cameraObject == NULL || this->m_cameraObject->type != OB_CAMERA) { return 10.0f; } else { - Camera *camera = (Camera *)this->cameraObject->data; - cam_lens = camera->lens; + Camera *camera = (Camera *)this->m_cameraObject->data; + this->m_cam_lens = camera->lens; if (camera->dof_ob) { /* too simple, better to return the distance on the view axis only * return len_v3v3(ob->obmat[3], cam->dof_ob->obmat[3]); */ float mat[4][4], imat[4][4], obmat[4][4]; - copy_m4_m4(obmat, cameraObject->obmat); + copy_m4_m4(obmat, this->m_cameraObject->obmat); normalize_m4(obmat); invert_m4_m4(imat, obmat); mult_m4_m4m4(mat, imat, camera->dof_ob->obmat); @@ -60,14 +60,14 @@ float ConvertDepthToRadiusOperation::determineFocalDistance() void ConvertDepthToRadiusOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); float focalDistance = determineFocalDistance(); if (focalDistance == 0.0f) focalDistance = 1e10f; /* if the dof is 0.0 then set it be be far away */ - inverseFocalDistance = 1.f / focalDistance; - this->aspect = (this->getWidth() > this->getHeight()) ? (this->getHeight() / (float)this->getWidth()) : (this->getWidth() / (float)this->getHeight()); - this->aperture = 0.5f * (this->cam_lens / (this->aspect * 32.f)) / this->fStop; + this->m_inverseFocalDistance = 1.f / focalDistance; + this->m_aspect = (this->getWidth() > this->getHeight()) ? (this->getHeight() / (float)this->getWidth()) : (this->getWidth() / (float)this->getHeight()); + this->m_aperture = 0.5f * (this->m_cam_lens / (this->m_aspect * 32.0f)) / this->m_fStop; float minsz = MIN2(getWidth(), getHeight()); - this->dof_sp = (float)minsz / (16.f / cam_lens); // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov); + this->m_dof_sp = (float)minsz / (16.f / this->m_cam_lens); // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov); } void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -75,7 +75,7 @@ void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, fl float inputValue[4]; float z; float radius; - inputOperation->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputValue, x, y, sampler, inputBuffers); z = inputValue[0]; if (z != 0.f) { float iZ = (1.f / z); @@ -86,11 +86,11 @@ void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, fl // scale crad back to original maximum and blend crad->rect[px] = bcrad + wts->rect[px]*(scf*crad->rect[px] - bcrad); #endif - radius = 0.5f * fabsf(this->aperture * (dof_sp * (inverseFocalDistance - iZ) - 1.f)); + radius = 0.5f * fabsf(this->m_aperture * (this->m_dof_sp * (this->m_inverseFocalDistance - iZ) - 1.f)); // 'bug' #6615, limit minimum radius to 1 pixel, not really a solution, but somewhat mitigates the problem if (radius < 0.5f) radius = 0.5f; - if (radius > maxRadius) { - radius = maxRadius; + if (radius > this->m_maxRadius) { + radius = this->m_maxRadius; } outputValue[0] = radius; } @@ -99,5 +99,5 @@ void ConvertDepthToRadiusOperation::executePixel(float *outputValue, float x, fl void ConvertDepthToRadiusOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h index c6da6bc94a9..415befea168 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h @@ -26,23 +26,23 @@ #include "DNA_object_types.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertDepthToRadiusOperation : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; - float fStop; - float aspect; - float maxRadius; - float inverseFocalDistance; - float aperture; - float cam_lens; - float dof_sp; - Object *cameraObject; + SocketReader *m_inputOperation; + float m_fStop; + float m_aspect; + float m_maxRadius; + float m_inverseFocalDistance; + float m_aperture; + float m_cam_lens; + float m_dof_sp; + Object *m_cameraObject; public: /** * Default constructor @@ -64,9 +64,9 @@ public: */ void deinitExecution(); - void setfStop(float fStop) { this->fStop = fStop; } - void setMaxRadius(float maxRadius) { this->maxRadius = maxRadius; } - void setCameraObject(Object *camera) { this->cameraObject = camera; } + void setfStop(float fStop) { this->m_fStop = fStop; } + void setMaxRadius(float maxRadius) { this->m_maxRadius = maxRadius; } + void setCameraObject(Object *camera) { this->m_cameraObject = camera; } float determineFocalDistance(); }; #endif diff --git a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp index e8c0061319c..5149e370208 100644 --- a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp @@ -27,24 +27,24 @@ ConvertHSVToRGBOperation::ConvertHSVToRGBOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertHSVToRGBOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertHSVToRGBOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); hsv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]); outputValue[3] = inputColor[3]; } void ConvertHSVToRGBOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h index 29c82361d12..3babbfb7c1d 100644 --- a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h @@ -26,15 +26,15 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertHSVToRGBOperation : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp index 842546a2755..b7db0a6a2c7 100644 --- a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp @@ -27,12 +27,12 @@ ConvertKeyToPremulOperation::ConvertKeyToPremulOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputColor = NULL; + this->m_inputColor = NULL; } void ConvertKeyToPremulOperation::initExecution() { - this->inputColor = getInputSocketReader(0); + this->m_inputColor = getInputSocketReader(0); } void ConvertKeyToPremulOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -40,7 +40,7 @@ void ConvertKeyToPremulOperation::executePixel(float *outputValue, float x, floa float inputValue[4]; float alpha; - this->inputColor->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColor->read(inputValue, x, y, sampler, inputBuffers); alpha = inputValue[3]; mul_v3_v3fl(outputValue, inputValue, alpha); @@ -51,5 +51,5 @@ void ConvertKeyToPremulOperation::executePixel(float *outputValue, float x, floa void ConvertKeyToPremulOperation::deinitExecution() { - this->inputColor = NULL; + this->m_inputColor = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h index fe0586f7a88..50b39928305 100644 --- a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h +++ b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h @@ -25,12 +25,12 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertKeyToPremulOperation : public NodeOperation { private: - SocketReader *inputColor; + SocketReader *m_inputColor; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp index 3554be53e3f..0ba23b2ec2e 100644 --- a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp @@ -27,12 +27,12 @@ ConvertPremulToKeyOperation::ConvertPremulToKeyOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputColor = NULL; + this->m_inputColor = NULL; } void ConvertPremulToKeyOperation::initExecution() { - this->inputColor = getInputSocketReader(0); + this->m_inputColor = getInputSocketReader(0); } void ConvertPremulToKeyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -40,7 +40,7 @@ void ConvertPremulToKeyOperation::executePixel(float *outputValue, float x, floa float inputValue[4]; float alpha; - this->inputColor->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColor->read(inputValue, x, y, sampler, inputBuffers); alpha = inputValue[3]; if (fabsf(alpha) < 1e-5f) { @@ -56,5 +56,5 @@ void ConvertPremulToKeyOperation::executePixel(float *outputValue, float x, floa void ConvertPremulToKeyOperation::deinitExecution() { - this->inputColor = NULL; + this->m_inputColor = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h index 093f28df3e5..173cbb4fc0a 100644 --- a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h +++ b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h @@ -25,12 +25,12 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertPremulToKeyOperation : public NodeOperation { private: - SocketReader *inputColor; + SocketReader *m_inputColor; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp index 051d9d2b8f9..dd5e9907642 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp @@ -27,23 +27,23 @@ ConvertRGBToHSVOperation::ConvertRGBToHSVOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertRGBToHSVOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertRGBToHSVOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); rgb_to_hsv(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]); outputValue[3] = inputColor[3]; } void ConvertRGBToHSVOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h index 61270539e70..42bd439c8c2 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h @@ -26,15 +26,15 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertRGBToHSVOperation : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp index d984a1ab943..7f41a79b7f4 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp @@ -26,27 +26,26 @@ ConvertRGBToYCCOperation::ConvertRGBToYCCOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertRGBToYCCOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertRGBToYCCOperation::setMode(int mode) { - switch (mode) - { + switch (mode) { case 1: - this->mode = BLI_YCC_ITU_BT709; + this->m_mode = BLI_YCC_ITU_BT709; break; case 2: - this->mode = BLI_YCC_JFIF_0_255; + this->m_mode = BLI_YCC_JFIF_0_255; break; case 0: default: - this->mode = BLI_YCC_ITU_BT601; + this->m_mode = BLI_YCC_ITU_BT601; break; } } @@ -56,8 +55,8 @@ void ConvertRGBToYCCOperation::executePixel(float *outputValue, float x, float y float inputColor[4]; float color[3]; - inputOperation->read(inputColor, x, y, sampler, inputBuffers); - rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->mode); + this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); + rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->m_mode); /* divided by 255 to normalize for viewing in */ /* R,G,B --> Y,Cb,Cr */ @@ -67,5 +66,5 @@ void ConvertRGBToYCCOperation::executePixel(float *outputValue, float x, float y void ConvertRGBToYCCOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h index 33075cda509..744e0657dc6 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h @@ -25,20 +25,20 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertRGBToYCCOperation : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; /** * YCbCr mode (Jpeg, ITU601, ITU709) */ - int mode; + int m_mode; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp index e5a8e7de1bb..e87a765f2eb 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp @@ -26,23 +26,23 @@ ConvertRGBToYUVOperation::ConvertRGBToYUVOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertRGBToYUVOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertRGBToYUVOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); rgb_to_yuv(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]); outputValue[3] = inputColor[3]; } void ConvertRGBToYUVOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h index 4fc525456f8..b470378704e 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h @@ -25,15 +25,15 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertRGBToYUVOperation : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp b/source/blender/compositor/operations/COM_ConvertValueToColorProg.cpp index 9d95c51a546..100a4931d69 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp +++ b/source/blender/compositor/operations/COM_ConvertValueToColorProg.cpp @@ -20,30 +20,30 @@ * Monique Dewanchand */ -#include "COM_ConvertValueToColourProg.h" +#include "COM_ConvertValueToColorProg.h" -ConvertValueToColourProg::ConvertValueToColourProg() : NodeOperation() +ConvertValueToColorProg::ConvertValueToColorProg() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } -void ConvertValueToColourProg::initExecution() +void ConvertValueToColorProg::initExecution() { - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } -void ConvertValueToColourProg::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertValueToColorProg::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputValue[4]; - this->inputProgram->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputValue, x, y, sampler, inputBuffers); color[0] = inputValue[0]; color[1] = inputValue[0]; color[2] = inputValue[0]; color[3] = 1.0f; } -void ConvertValueToColourProg::deinitExecution() +void ConvertValueToColorProg::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertValueToColourProg.h b/source/blender/compositor/operations/COM_ConvertValueToColorProg.h index ff1d1aaeae7..d59964dd400 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToColourProg.h +++ b/source/blender/compositor/operations/COM_ConvertValueToColorProg.h @@ -20,19 +20,19 @@ * Monique Dewanchand */ -#ifndef _COM_ConvertValueToColourProg_h -#define _COM_ConvertValueToColourProg_h +#ifndef _COM_ConvertValueToColorProg_h +#define _COM_ConvertValueToColorProg_h #include "COM_NodeOperation.h" -class ConvertValueToColourProg : public NodeOperation { +class ConvertValueToColorProg : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; public: - ConvertValueToColourProg(); + ConvertValueToColorProg(); /** * the inner loop of this program diff --git a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp index 5ba3f6ef4a9..37760fe26d7 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp @@ -26,18 +26,18 @@ ConvertValueToVectorOperation::ConvertValueToVectorOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VECTOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertValueToVectorOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertValueToVectorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float input[4]; - inputOperation->read(input, x, y, sampler, inputBuffers); + this->m_inputOperation->read(input, x, y, sampler, inputBuffers); outputValue[0] = input[0]; outputValue[1] = input[0]; outputValue[2] = input[0]; @@ -46,5 +46,5 @@ void ConvertValueToVectorOperation::executePixel(float *outputValue, float x, fl void ConvertValueToVectorOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h index fbb294d6a26..0e79c1ff3df 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h @@ -26,15 +26,15 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertValueToVectorOperation : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp index f6a2072932c..395b96e8b25 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp @@ -26,21 +26,21 @@ ConvertVectorToColorOperation::ConvertVectorToColorOperation() : NodeOperation() { this->addInputSocket(COM_DT_VECTOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertVectorToColorOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertVectorToColorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - inputOperation->read(outputValue, x, y, sampler, inputBuffers); + this->m_inputOperation->read(outputValue, x, y, sampler, inputBuffers); outputValue[3] = 1.0f; } void ConvertVectorToColorOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h index c26adc5a6b1..8225d03d58e 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h @@ -26,15 +26,15 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertVectorToColorOperation : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp index ef2d45eea03..68842c5a055 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp @@ -26,22 +26,22 @@ ConvertVectorToValueOperation::ConvertVectorToValueOperation() : NodeOperation() { this->addInputSocket(COM_DT_VECTOR); this->addOutputSocket(COM_DT_VALUE); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertVectorToValueOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertVectorToValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float input[4]; - inputOperation->read(input, x, y, sampler, inputBuffers); + this->m_inputOperation->read(input, x, y, sampler, inputBuffers); outputValue[0] = (input[0] + input[1] + input[2]) / 3.0f; } void ConvertVectorToValueOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h index dd29d1bb9a9..a7981e8dc59 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h +++ b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h @@ -26,15 +26,15 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertVectorToValueOperation : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp index 373de25a276..78b7a7af60d 100644 --- a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp @@ -26,27 +26,26 @@ ConvertYCCToRGBOperation::ConvertYCCToRGBOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertYCCToRGBOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertYCCToRGBOperation::setMode(int mode) { - switch (mode) - { + switch (mode) { case 1: - this->mode = BLI_YCC_ITU_BT709; + this->m_mode = BLI_YCC_ITU_BT709; break; case 2: - this->mode = BLI_YCC_JFIF_0_255; + this->m_mode = BLI_YCC_JFIF_0_255; break; case 0: default: - this->mode = BLI_YCC_ITU_BT601; + this->m_mode = BLI_YCC_ITU_BT601; break; } } @@ -54,18 +53,18 @@ void ConvertYCCToRGBOperation::setMode(int mode) void ConvertYCCToRGBOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); /* need to un-normalize the data */ /* R,G,B --> Y,Cb,Cr */ mul_v3_fl(inputColor, 255.0f); - ycc_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2], this->mode); + ycc_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2], this->m_mode); outputValue[3] = inputColor[3]; } void ConvertYCCToRGBOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h index d7ddd910ed7..e23dfd8a985 100644 --- a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h @@ -25,20 +25,20 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertYCCToRGBOperation : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; /** * YCbCr mode (Jpeg, ITU601, ITU709) */ - int mode; + int m_mode; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp index a77806d16d0..b4393c53b92 100644 --- a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp @@ -26,24 +26,24 @@ ConvertYUVToRGBOperation::ConvertYUVToRGBOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ConvertYUVToRGBOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void ConvertYUVToRGBOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - inputOperation->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputOperation->read(inputColor, x, y, sampler, inputBuffers); yuv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]); outputValue[3] = inputColor[3]; } void ConvertYUVToRGBOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h index f77954606cf..3368e0a24df 100644 --- a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h @@ -25,15 +25,15 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertYUVToRGBOperation : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: /** * Default constructor diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp index 5ac8c2254dc..cf3ffe6d8f4 100644 --- a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp @@ -46,7 +46,7 @@ void ConvolutionEdgeFilterOperation::executePixel(float *color, int x, int y, Me CLAMP(y3, 0, getHeight() - 1); float value[4]; - this->inputValueOperation->read(value, x2, y2, inputBuffers, NULL); + this->m_inputValueOperation->read(value, x2, y2, inputBuffers, NULL); float mval = 1.0f - value[0]; res1[0] = 0.0f; @@ -58,41 +58,41 @@ void ConvolutionEdgeFilterOperation::executePixel(float *color, int x, int y, Me res2[2] = 0.0f; res2[3] = 0.0f; - this->inputOperation->read(in1, x1, y1, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[0]); - madd_v3_v3fl(res2, in1, this->filter[0]); + this->m_inputOperation->read(in1, x1, y1, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[0]); + madd_v3_v3fl(res2, in1, this->m_filter[0]); - this->inputOperation->read(in1, x2, y1, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[1]); - madd_v3_v3fl(res2, in1, this->filter[3]); + this->m_inputOperation->read(in1, x2, y1, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[1]); + madd_v3_v3fl(res2, in1, this->m_filter[3]); - this->inputOperation->read(in1, x3, y1, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[2]); - madd_v3_v3fl(res2, in1, this->filter[6]); + this->m_inputOperation->read(in1, x3, y1, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[2]); + madd_v3_v3fl(res2, in1, this->m_filter[6]); - this->inputOperation->read(in1, x1, y2, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[3]); - madd_v3_v3fl(res2, in1, this->filter[1]); + this->m_inputOperation->read(in1, x1, y2, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[3]); + madd_v3_v3fl(res2, in1, this->m_filter[1]); - this->inputOperation->read(in2, x2, y2, inputBuffers, NULL); - madd_v3_v3fl(res1, in2, this->filter[4]); - madd_v3_v3fl(res2, in2, this->filter[4]); + this->m_inputOperation->read(in2, x2, y2, inputBuffers, NULL); + madd_v3_v3fl(res1, in2, this->m_filter[4]); + madd_v3_v3fl(res2, in2, this->m_filter[4]); - this->inputOperation->read(in1, x3, y2, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[5]); - madd_v3_v3fl(res2, in1, this->filter[7]); + this->m_inputOperation->read(in1, x3, y2, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[5]); + madd_v3_v3fl(res2, in1, this->m_filter[7]); - this->inputOperation->read(in1, x1, y3, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[6]); - madd_v3_v3fl(res2, in1, this->filter[2]); + this->m_inputOperation->read(in1, x1, y3, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[6]); + madd_v3_v3fl(res2, in1, this->m_filter[2]); - this->inputOperation->read(in1, x2, y3, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[7]); - madd_v3_v3fl(res2, in1, this->filter[5]); + this->m_inputOperation->read(in1, x2, y3, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[7]); + madd_v3_v3fl(res2, in1, this->m_filter[5]); - this->inputOperation->read(in1, x3, y3, inputBuffers, NULL); - madd_v3_v3fl(res1, in1, this->filter[8]); - madd_v3_v3fl(res2, in1, this->filter[8]); + this->m_inputOperation->read(in1, x3, y3, inputBuffers, NULL); + madd_v3_v3fl(res1, in1, this->m_filter[8]); + madd_v3_v3fl(res2, in1, this->m_filter[8]); color[0] = sqrt(res1[0] * res1[0] + res2[0] * res2[0]); color[1] = sqrt(res1[1] * res1[1] + res2[1] * res2[1]); diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp index b4f2714360e..3840e775fe3 100644 --- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp @@ -30,39 +30,39 @@ ConvolutionFilterOperation::ConvolutionFilterOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputOperation = NULL; - this->filter = NULL; + this->m_inputOperation = NULL; + this->m_filter = NULL; this->setComplex(true); } void ConvolutionFilterOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); - this->inputValueOperation = this->getInputSocketReader(1); + this->m_inputOperation = this->getInputSocketReader(0); + this->m_inputValueOperation = this->getInputSocketReader(1); } void ConvolutionFilterOperation::set3x3Filter(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9) { - this->filter = new float[9]; - this->filter[0] = f1; - this->filter[1] = f2; - this->filter[2] = f3; - this->filter[3] = f4; - this->filter[4] = f5; - this->filter[5] = f6; - this->filter[6] = f7; - this->filter[7] = f8; - this->filter[8] = f9; - this->filterHeight = 3; - this->filterWidth = 3; + this->m_filter = new float[9]; + this->m_filter[0] = f1; + this->m_filter[1] = f2; + this->m_filter[2] = f3; + this->m_filter[3] = f4; + this->m_filter[4] = f5; + this->m_filter[5] = f6; + this->m_filter[6] = f7; + this->m_filter[7] = f8; + this->m_filter[8] = f9; + this->m_filterHeight = 3; + this->m_filterWidth = 3; } void ConvolutionFilterOperation::deinitExecution() { - this->inputOperation = NULL; - this->inputValueOperation = NULL; - if (this->filter) { - delete[] this->filter; - this->filter = NULL; + this->m_inputOperation = NULL; + this->m_inputValueOperation = NULL; + if (this->m_filter) { + delete[] this->m_filter; + this->m_filter = NULL; } } @@ -84,28 +84,28 @@ void ConvolutionFilterOperation::executePixel(float *color, int x, int y, Memory CLAMP(y2, 0, getHeight() - 1); CLAMP(y3, 0, getHeight() - 1); float value[4]; - this->inputValueOperation->read(value, x2, y2, inputBuffers, NULL); + this->m_inputValueOperation->read(value, x2, y2, inputBuffers, NULL); const float mval = 1.0f - value[0]; zero_v4(color); - this->inputOperation->read(in1, x1, y1, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[0]); - this->inputOperation->read(in1, x2, y1, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[1]); - this->inputOperation->read(in1, x3, y1, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[2]); - this->inputOperation->read(in1, x1, y2, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[3]); - this->inputOperation->read(in2, x2, y2, inputBuffers, NULL); - madd_v4_v4fl(color, in2, this->filter[4]); - this->inputOperation->read(in1, x3, y2, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[5]); - this->inputOperation->read(in1, x1, y3, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[6]); - this->inputOperation->read(in1, x2, y3, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[7]); - this->inputOperation->read(in1, x3, y3, inputBuffers, NULL); - madd_v4_v4fl(color, in1, this->filter[8]); + this->m_inputOperation->read(in1, x1, y1, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[0]); + this->m_inputOperation->read(in1, x2, y1, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[1]); + this->m_inputOperation->read(in1, x3, y1, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[2]); + this->m_inputOperation->read(in1, x1, y2, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[3]); + this->m_inputOperation->read(in2, x2, y2, inputBuffers, NULL); + madd_v4_v4fl(color, in2, this->m_filter[4]); + this->m_inputOperation->read(in1, x3, y2, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[5]); + this->m_inputOperation->read(in1, x1, y3, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[6]); + this->m_inputOperation->read(in1, x2, y3, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[7]); + this->m_inputOperation->read(in1, x3, y3, inputBuffers, NULL); + madd_v4_v4fl(color, in1, this->m_filter[8]); color[0] = color[0] * value[0] + in2[0] * mval; color[1] = color[1] * value[0] + in2[1] * mval; @@ -116,8 +116,8 @@ void ConvolutionFilterOperation::executePixel(float *color, int x, int y, Memory bool ConvolutionFilterOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - int addx = (this->filterWidth - 1) / 2 + 1; - int addy = (this->filterHeight - 1) / 2 + 1; + int addx = (this->m_filterWidth - 1) / 2 + 1; + int addy = (this->m_filterHeight - 1) / 2 + 1; newInput.xmax = input->xmax + addx; newInput.xmin = input->xmin - addx; newInput.ymax = input->ymax + addy; diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h index f3347eb583a..0b5dfb4d75a 100644 --- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h +++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h @@ -27,13 +27,13 @@ class ConvolutionFilterOperation : public NodeOperation { private: - int filterWidth; - int filterHeight; + int m_filterWidth; + int m_filterHeight; protected: - SocketReader *inputOperation; - SocketReader *inputValueOperation; - float *filter; + SocketReader *m_inputOperation; + SocketReader *m_inputValueOperation; + float *m_filter; public: ConvolutionFilterOperation(); diff --git a/source/blender/compositor/operations/COM_CropOperation.cpp b/source/blender/compositor/operations/COM_CropOperation.cpp index 0bdd2cfcb51..0a40f2370c8 100644 --- a/source/blender/compositor/operations/COM_CropOperation.cpp +++ b/source/blender/compositor/operations/COM_CropOperation.cpp @@ -27,8 +27,8 @@ CropBaseOperation::CropBaseOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); this->addOutputSocket(COM_DT_COLOR); - this->inputOperation = NULL; - this->settings = NULL; + this->m_inputOperation = NULL; + this->m_settings = NULL; } void CropBaseOperation::updateArea() @@ -36,36 +36,36 @@ void CropBaseOperation::updateArea() SocketReader *inputReference = this->getInputSocketReader(0); float width = inputReference->getWidth(); float height = inputReference->getHeight(); - if (this->relative) { - settings->x1 = width * settings->fac_x1; - settings->x2 = width * settings->fac_x2; - settings->y1 = height * settings->fac_y1; - settings->y2 = height * settings->fac_y2; + if (this->m_relative) { + this->m_settings->x1 = width * this->m_settings->fac_x1; + this->m_settings->x2 = width * this->m_settings->fac_x2; + this->m_settings->y1 = height * this->m_settings->fac_y1; + this->m_settings->y2 = height * this->m_settings->fac_y2; } - if (width <= settings->x1 + 1) - settings->x1 = width - 1; - if (height <= settings->y1 + 1) - settings->y1 = height - 1; - if (width <= settings->x2 + 1) - settings->x2 = width - 1; - if (height <= settings->y2 + 1) - settings->y2 = height - 1; + if (width <= this->m_settings->x1 + 1) + this->m_settings->x1 = width - 1; + if (height <= this->m_settings->y1 + 1) + this->m_settings->y1 = height - 1; + if (width <= this->m_settings->x2 + 1) + this->m_settings->x2 = width - 1; + if (height <= this->m_settings->y2 + 1) + this->m_settings->y2 = height - 1; - this->xmax = MAX2(settings->x1, settings->x2) + 1; - this->xmin = MIN2(settings->x1, settings->x2); - this->ymax = MAX2(settings->y1, settings->y2) + 1; - this->ymin = MIN2(settings->y1, settings->y2); + this->m_xmax = MAX2(this->m_settings->x1, this->m_settings->x2) + 1; + this->m_xmin = MIN2(this->m_settings->x1, this->m_settings->x2); + this->m_ymax = MAX2(this->m_settings->y1, this->m_settings->y2) + 1; + this->m_ymin = MIN2(this->m_settings->y1, this->m_settings->y2); } void CropBaseOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); updateArea(); } void CropBaseOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } CropOperation::CropOperation() : CropBaseOperation() @@ -75,14 +75,11 @@ CropOperation::CropOperation() : CropBaseOperation() void CropOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if ((x < this->xmax && x >= xmin) && (y < ymax && y >= ymin)) { - inputOperation->read(color, x, y, sampler, inputBuffers); + if ((x < this->m_xmax && x >= this->m_xmin) && (y < this->m_ymax && y >= this->m_ymin)) { + this->m_inputOperation->read(color, x, y, sampler, inputBuffers); } else { - color[0] = 0.0f; - color[1] = 0.0f; - color[2] = 0.0f; - color[3] = 0.0f; + zero_v4(color); } } @@ -95,10 +92,10 @@ bool CropImageOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe { rcti newInput; - newInput.xmax = input->xmax + this->xmin; - newInput.xmin = input->xmin + this->xmin; - newInput.ymax = input->ymax + this->ymin; - newInput.ymin = input->ymin + this->ymin; + newInput.xmax = input->xmax + this->m_xmin; + newInput.xmin = input->xmin + this->m_xmin; + newInput.ymax = input->ymax + this->m_ymin; + newInput.ymin = input->ymin + this->m_ymin; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } @@ -107,11 +104,11 @@ void CropImageOperation::determineResolution(unsigned int resolution[], unsigned { NodeOperation::determineResolution(resolution, preferedResolution); updateArea(); - resolution[0] = this->xmax - this->xmin; - resolution[1] = this->ymax - this->ymin; + resolution[0] = this->m_xmax - this->m_xmin; + resolution[1] = this->m_ymax - this->m_ymin; } void CropImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - this->inputOperation->read(color, (x + this->xmin), (y + this->ymin), sampler, inputBuffers); + this->m_inputOperation->read(color, (x + this->m_xmin), (y + this->m_ymin), sampler, inputBuffers); } diff --git a/source/blender/compositor/operations/COM_CropOperation.h b/source/blender/compositor/operations/COM_CropOperation.h index 48e5ab7f75b..39dbb8aa873 100644 --- a/source/blender/compositor/operations/COM_CropOperation.h +++ b/source/blender/compositor/operations/COM_CropOperation.h @@ -27,21 +27,21 @@ class CropBaseOperation : public NodeOperation { protected: - SocketReader *inputOperation; - NodeTwoXYs *settings; - bool relative; - int xmax; - int xmin; - int ymax; - int ymin; + SocketReader *m_inputOperation; + NodeTwoXYs *m_settings; + bool m_relative; + int m_xmax; + int m_xmin; + int m_ymax; + int m_ymin; void updateArea(); public: CropBaseOperation(); void initExecution(); void deinitExecution(); - void setCropSettings(NodeTwoXYs *settings) { this->settings = settings; } - void setRelative(bool rel) { this->relative = rel; } + void setCropSettings(NodeTwoXYs *settings) { this->m_settings = settings; } + void setRelative(bool rel) { this->m_relative = rel; } }; class CropOperation : public CropBaseOperation { diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp index 6aa8bc2a0df..48d2bcd0ef9 100644 --- a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp @@ -32,9 +32,9 @@ extern "C" { CurveBaseOperation::CurveBaseOperation() : NodeOperation() { - this->curveMapping = NULL; + this->m_curveMapping = NULL; } void CurveBaseOperation::initExecution() { - curvemapping_initialize(this->curveMapping); + curvemapping_initialize(this->m_curveMapping); } diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.h b/source/blender/compositor/operations/COM_CurveBaseOperation.h index 9cddb3be46b..1636c13a571 100644 --- a/source/blender/compositor/operations/COM_CurveBaseOperation.h +++ b/source/blender/compositor/operations/COM_CurveBaseOperation.h @@ -30,7 +30,7 @@ protected: /** * Cached reference to the inputProgram */ - CurveMapping *curveMapping; + CurveMapping *m_curveMapping; public: CurveBaseOperation(); @@ -39,6 +39,6 @@ public: */ void initExecution(); - void setCurveMapping(CurveMapping *mapping) { this->curveMapping = mapping; } + void setCurveMapping(CurveMapping *mapping) { this->m_curveMapping = mapping; } }; #endif diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp index c27e699f627..3c4bdfe8e5b 100644 --- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp @@ -29,19 +29,19 @@ DifferenceMatteOperation::DifferenceMatteOperation() : NodeOperation() addInputSocket(COM_DT_COLOR); addOutputSocket(COM_DT_VALUE); - inputImage1Program = NULL; - inputImage2Program = NULL; + this->m_inputImage1Program = NULL; + this->m_inputImage2Program = NULL; } void DifferenceMatteOperation::initExecution() { - this->inputImage1Program = this->getInputSocketReader(0); - this->inputImage2Program = this->getInputSocketReader(1); + this->m_inputImage1Program = this->getInputSocketReader(0); + this->m_inputImage2Program = this->getInputSocketReader(1); } void DifferenceMatteOperation::deinitExecution() { - this->inputImage1Program = NULL; - this->inputImage2Program = NULL; + this->m_inputImage1Program = NULL; + this->m_inputImage2Program = NULL; } void DifferenceMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -49,13 +49,13 @@ void DifferenceMatteOperation::executePixel(float *outputValue, float x, float y float inColor1[4]; float inColor2[4]; - const float tolerence = this->settings->t1; - const float falloff = this->settings->t2; + const float tolerance = this->m_settings->t1; + const float falloff = this->m_settings->t2; float difference; float alpha; - this->inputImage1Program->read(inColor1, x, y, sampler, inputBuffers); - this->inputImage2Program->read(inColor2, x, y, sampler, inputBuffers); + this->m_inputImage1Program->read(inColor1, x, y, sampler, inputBuffers); + this->m_inputImage2Program->read(inColor2, x, y, sampler, inputBuffers); difference = (fabsf(inColor2[0] - inColor1[0]) + fabsf(inColor2[1] - inColor1[1]) + @@ -65,12 +65,12 @@ void DifferenceMatteOperation::executePixel(float *outputValue, float x, float y difference = difference / 3.0f; /*make 100% transparent*/ - if (difference < tolerence) { + if (difference < tolerance) { outputValue[0] = 0.0f; } /*in the falloff region, make partially transparent */ - else if (difference < falloff + tolerence) { - difference = difference - tolerence; + else if (difference < falloff + tolerance) { + difference = difference - tolerance; alpha = difference / falloff; /*only change if more transparent than before */ if (alpha < inColor1[3]) { diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h index 3bdc3384556..c35550560e1 100644 --- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h +++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h @@ -26,14 +26,14 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class DifferenceMatteOperation : public NodeOperation { private: - NodeChroma *settings; - SocketReader *inputImage1Program; - SocketReader *inputImage2Program; + NodeChroma *m_settings; + SocketReader *m_inputImage1Program; + SocketReader *m_inputImage2Program; public: /** * Default constructor @@ -48,6 +48,6 @@ public: void initExecution(); void deinitExecution(); - void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; } + void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; } }; #endif diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp index 306a2d96985..338a3a0b59b 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp @@ -22,6 +22,7 @@ #include "COM_DilateErodeOperation.h" #include "BLI_math.h" +#include "COM_OpenCLDevice.h" // DilateErode Distance Threshold DilateErodeThresholdOperation::DilateErodeThresholdOperation() : NodeOperation() @@ -29,57 +30,57 @@ DilateErodeThresholdOperation::DilateErodeThresholdOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); this->setComplex(true); - this->inputProgram = NULL; - this->inset = 0.0f; - this->_switch = 0.5f; - this->distance = 0.0f; + this->m_inputProgram = NULL; + this->m_inset = 0.0f; + this->m__switch = 0.5f; + this->m_distance = 0.0f; } void DilateErodeThresholdOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); - if (this->distance < 0.0f) { - this->scope = -this->distance + this->inset; + this->m_inputProgram = this->getInputSocketReader(0); + if (this->m_distance < 0.0f) { + this->m_scope = -this->m_distance + this->m_inset; } else { - if (this->inset * 2 > this->distance) { - this->scope = max(this->inset * 2 - this->distance, this->distance); + if (this->m_inset * 2 > this->m_distance) { + this->m_scope = max(this->m_inset * 2 - this->m_distance, this->m_distance); } else { - this->scope = distance; + this->m_scope = this->m_distance; } } - if (scope < 3) { - scope = 3; + if (this->m_scope < 3) { + this->m_scope = 3; } } void *DilateErodeThresholdOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers); + void *buffer = this->m_inputProgram->initializeTileData(NULL, memoryBuffers); return buffer; } void DilateErodeThresholdOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { float inputValue[4]; - const float sw = this->_switch; - const float distance = this->distance; + const float sw = this->m__switch; + const float distance = this->m_distance; float pixelvalue; - const float rd = scope * scope; - const float inset = this->inset; + const float rd = this->m_scope * this->m_scope; + const float inset = this->m_inset; float mindist = rd * 2; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); rcti *rect = inputBuffer->getRect(); - const int minx = max(x - scope, rect->xmin); - const int miny = max(y - scope, rect->ymin); - const int maxx = min(x + scope, rect->xmax); - const int maxy = min(y + scope, rect->ymax); + const int minx = max(x - this->m_scope, rect->xmin); + const int miny = max(y - this->m_scope, rect->ymin); + const int maxx = min(x + this->m_scope, rect->xmax); + const int maxy = min(y + this->m_scope, rect->ymax); const int bufferWidth = rect->xmax - rect->xmin; int offset; - this->inputProgram->read(inputValue, x, y, inputBuffers, NULL); + this->m_inputProgram->read(inputValue, x, y, inputBuffers, NULL); if (inputValue[0] > sw) { for (int yi = miny; yi < maxy; yi++) { const float dy = yi - y; @@ -144,17 +145,17 @@ void DilateErodeThresholdOperation::executePixel(float *color, int x, int y, Mem void DilateErodeThresholdOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } bool DilateErodeThresholdOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - newInput.xmax = input->xmax + scope; - newInput.xmin = input->xmin - scope; - newInput.ymax = input->ymax + scope; - newInput.ymin = input->ymin - scope; + newInput.xmax = input->xmax + this->m_scope; + newInput.xmin = input->xmin - this->m_scope; + newInput.ymax = input->ymax + this->m_scope; + newInput.ymin = input->ymin - this->m_scope; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } @@ -165,37 +166,37 @@ DilateDistanceOperation::DilateDistanceOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); this->setComplex(true); - this->inputProgram = NULL; - this->distance = 0.0f; + this->m_inputProgram = NULL; + this->m_distance = 0.0f; this->setOpenCL(true); } void DilateDistanceOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); - this->scope = distance; - if (scope < 3) { - scope = 3; + this->m_inputProgram = this->getInputSocketReader(0); + this->m_scope = this->m_distance; + if (this->m_scope < 3) { + this->m_scope = 3; } } void *DilateDistanceOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers); + void *buffer = this->m_inputProgram->initializeTileData(NULL, memoryBuffers); return buffer; } void DilateDistanceOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - const float distance = this->distance; + const float distance = this->m_distance; const float mindist = distance * distance; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); rcti *rect = inputBuffer->getRect(); - const int minx = max(x - scope, rect->xmin); - const int miny = max(y - scope, rect->ymin); - const int maxx = min(x + scope, rect->xmax); - const int maxy = min(y + scope, rect->ymax); + const int minx = max(x - this->m_scope, rect->xmin); + const int miny = max(y - this->m_scope, rect->ymin); + const int maxx = min(x + this->m_scope, rect->xmax); + const int maxy = min(y + this->m_scope, rect->ymax); const int bufferWidth = rect->xmax - rect->xmin; int offset; @@ -218,40 +219,40 @@ void DilateDistanceOperation::executePixel(float *color, int x, int y, MemoryBuf void DilateDistanceOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - newInput.xmax = input->xmax + scope; - newInput.xmin = input->xmin - scope; - newInput.ymax = input->ymax + scope; - newInput.ymin = input->ymin - scope; + newInput.xmax = input->xmax + this->m_scope; + newInput.xmin = input->xmin - this->m_scope; + newInput.ymax = input->ymax + this->m_scope; + newInput.ymin = input->ymin - this->m_scope; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } static cl_kernel dilateKernel = 0; -void DilateDistanceOperation::executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, +void DilateDistanceOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { if (!dilateKernel) { - dilateKernel = COM_clCreateKernel(program, "dilateKernel", NULL); + dilateKernel = device->COM_clCreateKernel("dilateKernel", NULL); } - cl_int distanceSquared = this->distance * this->distance; - cl_int scope = this->scope; + cl_int distanceSquared = this->m_distance * this->m_distance; + cl_int scope = this->m_scope; - COM_clAttachMemoryBufferToKernelParameter(context, dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); - COM_clAttachOutputMemoryBufferToKernelParameter(dilateKernel, 1, clOutputBuffer); - COM_clAttachMemoryBufferOffsetToKernelParameter(dilateKernel, 3, outputMemoryBuffer); + device->COM_clAttachMemoryBufferToKernelParameter(dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram); + device->COM_clAttachOutputMemoryBufferToKernelParameter(dilateKernel, 1, clOutputBuffer); + device->COM_clAttachMemoryBufferOffsetToKernelParameter(dilateKernel, 3, outputMemoryBuffer); clSetKernelArg(dilateKernel, 4, sizeof(cl_int), &scope); clSetKernelArg(dilateKernel, 5, sizeof(cl_int), &distanceSquared); - COM_clAttachSizeToKernelParameter(dilateKernel, 6); - COM_clEnqueueRange(queue, dilateKernel, outputMemoryBuffer, 7); + device->COM_clAttachSizeToKernelParameter(dilateKernel, 6, this); + device->COM_clEnqueueRange(dilateKernel, outputMemoryBuffer, 7, this); } // Erode Distance @@ -262,16 +263,16 @@ ErodeDistanceOperation::ErodeDistanceOperation() : DilateDistanceOperation() void ErodeDistanceOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - const float distance = this->distance; + const float distance = this->m_distance; const float mindist = distance * distance; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); rcti *rect = inputBuffer->getRect(); - const int minx = max(x - scope, rect->xmin); - const int miny = max(y - scope, rect->ymin); - const int maxx = min(x + scope, rect->xmax); - const int maxy = min(y + scope, rect->ymax); + const int minx = max(x - this->m_scope, rect->xmin); + const int miny = max(y - this->m_scope, rect->ymin); + const int maxx = min(x + this->m_scope, rect->xmax); + const int maxy = min(y + this->m_scope, rect->ymax); const int bufferWidth = rect->xmax - rect->xmin; int offset; @@ -293,24 +294,24 @@ void ErodeDistanceOperation::executePixel(float *color, int x, int y, MemoryBuff } static cl_kernel erodeKernel = 0; -void ErodeDistanceOperation::executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, +void ErodeDistanceOperation::executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) { if (!erodeKernel) { - erodeKernel = COM_clCreateKernel(program, "erodeKernel", NULL); + erodeKernel = device->COM_clCreateKernel("erodeKernel", NULL); } - cl_int distanceSquared = this->distance * this->distance; - cl_int scope = this->scope; + cl_int distanceSquared = this->m_distance * this->m_distance; + cl_int scope = this->m_scope; - COM_clAttachMemoryBufferToKernelParameter(context, erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->inputProgram); - COM_clAttachOutputMemoryBufferToKernelParameter(erodeKernel, 1, clOutputBuffer); - COM_clAttachMemoryBufferOffsetToKernelParameter(erodeKernel, 3, outputMemoryBuffer); + device->COM_clAttachMemoryBufferToKernelParameter(erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram); + device->COM_clAttachOutputMemoryBufferToKernelParameter(erodeKernel, 1, clOutputBuffer); + device->COM_clAttachMemoryBufferOffsetToKernelParameter(erodeKernel, 3, outputMemoryBuffer); clSetKernelArg(erodeKernel, 4, sizeof(cl_int), &scope); clSetKernelArg(erodeKernel, 5, sizeof(cl_int), &distanceSquared); - COM_clAttachSizeToKernelParameter(erodeKernel, 6); - COM_clEnqueueRange(queue, erodeKernel, outputMemoryBuffer, 7); + device->COM_clAttachSizeToKernelParameter(erodeKernel, 6, this); + device->COM_clEnqueueRange(erodeKernel, outputMemoryBuffer, 7, this); } // Dilate step @@ -319,29 +320,29 @@ DilateStepOperation::DilateStepOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); this->setComplex(true); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void DilateStepOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); - this->cached_buffer = NULL; + this->m_inputProgram = this->getInputSocketReader(0); + this->m_cached_buffer = NULL; this->initMutex(); } void *DilateStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->cached_buffer != NULL) { - return this->cached_buffer; + if (this->m_cached_buffer != NULL) { + return this->m_cached_buffer; } lockMutex(); - if (this->cached_buffer == NULL) { - MemoryBuffer *buffer = (MemoryBuffer *)inputProgram->initializeTileData(NULL, memoryBuffers); + if (this->m_cached_buffer == NULL) { + MemoryBuffer *buffer = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL, memoryBuffers); float *rectf = buffer->convertToValueBuffer(); int x, y, i; float *p; int bwidth = buffer->getWidth(); int bheight = buffer->getHeight(); - for (i = 0; i < this->iterations; i++) { + for (i = 0; i < this->m_iterations; i++) { for (y = 0; y < bheight; y++) { for (x = 0; x < bwidth - 1; x++) { p = rectf + (bwidth * y + x); @@ -370,31 +371,31 @@ void *DilateStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB } } } - this->cached_buffer = rectf; + this->m_cached_buffer = rectf; } unlockMutex(); - return this->cached_buffer; + return this->m_cached_buffer; } void DilateStepOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - color[0] = this->cached_buffer[y * this->getWidth() + x]; + color[0] = this->m_cached_buffer[y * this->getWidth() + x]; } void DilateStepOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; this->deinitMutex(); - if (this->cached_buffer) { - delete cached_buffer; - this->cached_buffer = NULL; + if (this->m_cached_buffer) { + delete this->m_cached_buffer; + this->m_cached_buffer = NULL; } } bool DilateStepOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { - if (this->cached_buffer) { + if (this->m_cached_buffer) { return false; } else { @@ -417,18 +418,18 @@ ErodeStepOperation::ErodeStepOperation() : DilateStepOperation() void *ErodeStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->cached_buffer != NULL) { - return this->cached_buffer; + if (this->m_cached_buffer != NULL) { + return this->m_cached_buffer; } lockMutex(); - if (this->cached_buffer == NULL) { - MemoryBuffer *buffer = (MemoryBuffer *)inputProgram->initializeTileData(NULL, memoryBuffers); + if (this->m_cached_buffer == NULL) { + MemoryBuffer *buffer = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL, memoryBuffers); float *rectf = buffer->convertToValueBuffer(); int x, y, i; float *p; int bwidth = buffer->getWidth(); int bheight = buffer->getHeight(); - for (i = 0; i < this->iterations; i++) { + for (i = 0; i < this->m_iterations; i++) { for (y = 0; y < bheight; y++) { for (x = 0; x < bwidth - 1; x++) { p = rectf + (bwidth * y + x); @@ -457,8 +458,8 @@ void *ErodeStepOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu } } } - this->cached_buffer = rectf; + this->m_cached_buffer = rectf; } unlockMutex(); - return this->cached_buffer; + return this->m_cached_buffer; } diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.h b/source/blender/compositor/operations/COM_DilateErodeOperation.h index b11356129b4..bc6049bf992 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.h +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.h @@ -30,17 +30,17 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; - float distance; - float _switch; - float inset; + float m_distance; + float m__switch; + float m_inset; /** * determines the area of interest to track pixels * keep this one as small as possible for speed gain. */ - int scope; + int m_scope; public: DilateErodeThresholdOperation(); @@ -60,9 +60,9 @@ public: */ void deinitExecution(); - void setDistance(float distance) { this->distance = distance; } - void setSwitch(float sw) { this->_switch = sw; } - void setInset(float inset) { this->inset = inset; } + void setDistance(float distance) { this->m_distance = distance; } + void setSwitch(float sw) { this->m__switch = sw; } + void setInset(float inset) { this->m_inset = inset; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); @@ -74,9 +74,9 @@ protected: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; - float distance; - int scope; + SocketReader *m_inputProgram; + float m_distance; + int m_scope; public: DilateDistanceOperation(); @@ -96,10 +96,10 @@ public: */ void deinitExecution(); - void setDistance(float distance) { this->distance = distance; } + void setDistance(float distance) { this->m_distance = distance; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, + void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp); @@ -113,7 +113,7 @@ public: */ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); - void executeOpenCL(cl_context context, cl_program program, cl_command_queue queue, + void executeOpenCL(OpenCLDevice* device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp); @@ -124,11 +124,11 @@ protected: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; - int iterations; + int m_iterations; - float *cached_buffer; + float *m_cached_buffer; public: DilateStepOperation(); @@ -148,7 +148,7 @@ public: */ void deinitExecution(); - void setIterations(int iterations) { this->iterations = iterations; } + void setIterations(int iterations) { this->m_iterations = iterations; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); }; diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp index 271a165f0ff..da7336afc07 100644 --- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp @@ -33,20 +33,20 @@ DirectionalBlurOperation::DirectionalBlurOperation() : NodeOperation() this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void DirectionalBlurOperation::initExecution() { - this->inputProgram = getInputSocketReader(0); + this->m_inputProgram = getInputSocketReader(0); QualityStepHelper::initExecution(COM_QH_INCREASE); - const float angle = this->data->angle; - const float zoom = this->data->zoom; - const float spin = this->data->spin; - const float iterations = this->data->iter; - const float distance = this->data->distance; - const float center_x = this->data->center_x; - const float center_y = this->data->center_y; + const float angle = this->m_data->angle; + const float zoom = this->m_data->zoom; + const float spin = this->m_data->spin; + const float iterations = this->m_data->iter; + const float distance = this->m_data->distance; + const float center_x = this->m_data->center_x; + const float center_y = this->m_data->center_y; const float width = getWidth(); const float height = getHeight(); @@ -55,43 +55,46 @@ void DirectionalBlurOperation::initExecution() float D; D = distance * sqrtf(width * width + height * height); - center_x_pix = center_x * width; - center_y_pix = center_y * height; + this->m_center_x_pix = center_x * width; + this->m_center_y_pix = center_y * height; - tx = itsc * D * cosf(a); - ty = -itsc *D *sinf(a); - sc = itsc * zoom; - rot = itsc * spin; + this->m_tx = itsc * D * cosf(a); + this->m_ty = -itsc *D *sinf(a); + this->m_sc = itsc * zoom; + this->m_rot = itsc * spin; } void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - const int iterations = pow(2.f, this->data->iter); + const int iterations = pow(2.0f, this->m_data->iter); float col[4] = {0, 0, 0, 0}; float col2[4] = {0, 0, 0, 0}; - this->inputProgram->read(col2, x, y, COM_PS_NEAREST, inputBuffers); - float ltx = tx; - float lty = ty; - float lsc = sc; - float lrot = rot; + this->m_inputProgram->read(col2, x, y, COM_PS_NEAREST, inputBuffers); + float ltx = this->m_tx; + float lty = this->m_ty; + float lsc = this->m_sc; + float lrot = this->m_rot; /* blur the image */ for (int i = 0; i < iterations; ++i) { const float cs = cos(lrot), ss = sin(lrot); - const float isc = 1.f / (1.f + lsc); + const float isc = 1.0f / (1.0f + lsc); - const float v = isc * (y - center_y_pix) + lty; - const float u = isc * (x - center_x_pix) + ltx; + const float v = isc * (y - this->m_center_y_pix) + lty; + const float u = isc * (x - this->m_center_x_pix) + ltx; - this->inputProgram->read(col, cs * u + ss * v + center_x_pix, cs * v - ss * u + center_y_pix, COM_PS_NEAREST, inputBuffers); + this->m_inputProgram->read(col, + cs * u + ss * v + this->m_center_x_pix, + cs * v - ss * u + this->m_center_y_pix, + COM_PS_NEAREST, inputBuffers); add_v4_v4(col2, col); /* double transformations */ - ltx += tx; - lty += ty; - lrot += rot; - lsc += sc; + ltx += this->m_tx; + lty += this->m_ty; + lrot += this->m_rot; + lsc += this->m_sc; } mul_v4_v4fl(color, col2, 1.0f / iterations); @@ -99,7 +102,7 @@ void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBu void DirectionalBlurOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } bool DirectionalBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h index 9cc0a4361f1..329f855871e 100644 --- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h +++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h @@ -27,12 +27,12 @@ class DirectionalBlurOperation : public NodeOperation, public QualityStepHelper { private: - SocketReader *inputProgram; - NodeDBlurData *data; + SocketReader *m_inputProgram; + NodeDBlurData *m_data; - float center_x_pix, center_y_pix; - float tx, ty; - float sc, rot; + float m_center_x_pix, m_center_y_pix; + float m_tx, m_ty; + float m_sc, m_rot; public: DirectionalBlurOperation(); @@ -54,6 +54,6 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void setData(NodeDBlurData *data) { this->data = data; } + void setData(NodeDBlurData *data) { this->m_data = data; } }; #endif diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cpp b/source/blender/compositor/operations/COM_DisplaceOperation.cpp index be50641a125..c7df53770c5 100644 --- a/source/blender/compositor/operations/COM_DisplaceOperation.cpp +++ b/source/blender/compositor/operations/COM_DisplaceOperation.cpp @@ -32,21 +32,21 @@ DisplaceOperation::DisplaceOperation() : NodeOperation() this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); - this->inputColorProgram = NULL; - this->inputVectorProgram = NULL; - this->inputScaleXProgram = NULL; - this->inputScaleYProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_inputVectorProgram = NULL; + this->m_inputScaleXProgram = NULL; + this->m_inputScaleYProgram = NULL; } void DisplaceOperation::initExecution() { - this->inputColorProgram = this->getInputSocketReader(0); - this->inputVectorProgram = this->getInputSocketReader(1); - this->inputScaleXProgram = this->getInputSocketReader(2); - this->inputScaleYProgram = this->getInputSocketReader(3); + this->m_inputColorProgram = this->getInputSocketReader(0); + this->m_inputVectorProgram = this->getInputSocketReader(1); + this->m_inputScaleXProgram = this->getInputSocketReader(2); + this->m_inputScaleYProgram = this->getInputSocketReader(3); - width_x4 = this->getWidth() * 4; - height_x4 = this->getHeight() * 4; + this->m_width_x4 = this->getWidth() * 4; + this->m_height_x4 = this->getHeight() * 4; } @@ -64,17 +64,17 @@ void DisplaceOperation::executePixel(float *color, int x, int y, MemoryBuffer *i float dxt, dyt; float u, v; - this->inputScaleXProgram->read(inScale, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputScaleXProgram->read(inScale, x, y, COM_PS_NEAREST, inputBuffers); float xs = inScale[0]; - this->inputScaleYProgram->read(inScale, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputScaleYProgram->read(inScale, x, y, COM_PS_NEAREST, inputBuffers); float ys = inScale[0]; /* clamp x and y displacement to triple image resolution - * to prevent hangs from huge values mistakenly plugged in eg. z buffers */ - CLAMP(xs, -width_x4, width_x4); - CLAMP(ys, -height_x4, height_x4); + CLAMP(xs, -this->m_width_x4, this->m_width_x4); + CLAMP(ys, -this->m_height_x4, this->m_height_x4); - this->inputVectorProgram->read(inVector, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputVectorProgram->read(inVector, x, y, COM_PS_NEAREST, inputBuffers); p_dx = inVector[0] * xs; p_dy = inVector[1] * ys; @@ -83,9 +83,9 @@ void DisplaceOperation::executePixel(float *color, int x, int y, MemoryBuffer *i v = y - p_dy + 0.5f; /* calc derivatives */ - this->inputVectorProgram->read(inVector, x + 1, y, COM_PS_NEAREST, inputBuffers); + this->m_inputVectorProgram->read(inVector, x + 1, y, COM_PS_NEAREST, inputBuffers); d_dx = inVector[0] * xs; - this->inputVectorProgram->read(inVector, x, y + 1, COM_PS_NEAREST, inputBuffers); + this->m_inputVectorProgram->read(inVector, x, y + 1, COM_PS_NEAREST, inputBuffers); d_dy = inVector[0] * ys; /* clamp derivatives to minimum displacement distance in UV space */ @@ -96,15 +96,15 @@ void DisplaceOperation::executePixel(float *color, int x, int y, MemoryBuffer *i dyt = signf(dyt) * maxf(fabsf(dyt), DISPLACE_EPSILON) / this->getHeight(); /* EWA filtering */ - this->inputColorProgram->read(color, u, v, dxt, dyt, inputBuffers); + this->m_inputColorProgram->read(color, u, v, dxt, dyt, inputBuffers); } void DisplaceOperation::deinitExecution() { - this->inputColorProgram = NULL; - this->inputVectorProgram = NULL; - this->inputScaleXProgram = NULL; - this->inputScaleYProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_inputVectorProgram = NULL; + this->m_inputScaleXProgram = NULL; + this->m_inputScaleYProgram = NULL; } bool DisplaceOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.h b/source/blender/compositor/operations/COM_DisplaceOperation.h index 82788e37e3a..e01c9190396 100644 --- a/source/blender/compositor/operations/COM_DisplaceOperation.h +++ b/source/blender/compositor/operations/COM_DisplaceOperation.h @@ -29,13 +29,13 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputColorProgram; - SocketReader *inputVectorProgram; - SocketReader *inputScaleXProgram; - SocketReader *inputScaleYProgram; + SocketReader *m_inputColorProgram; + SocketReader *m_inputVectorProgram; + SocketReader *m_inputScaleXProgram; + SocketReader *m_inputScaleYProgram; - float width_x4; - float height_x4; + float m_width_x4; + float m_height_x4; public: DisplaceOperation(); diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp index 716646e9c36..d21fc62abd7 100644 --- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp +++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp @@ -31,21 +31,21 @@ DisplaceSimpleOperation::DisplaceSimpleOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->inputColorProgram = NULL; - this->inputVectorProgram = NULL; - this->inputScaleXProgram = NULL; - this->inputScaleYProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_inputVectorProgram = NULL; + this->m_inputScaleXProgram = NULL; + this->m_inputScaleYProgram = NULL; } void DisplaceSimpleOperation::initExecution() { - this->inputColorProgram = this->getInputSocketReader(0); - this->inputVectorProgram = this->getInputSocketReader(1); - this->inputScaleXProgram = this->getInputSocketReader(2); - this->inputScaleYProgram = this->getInputSocketReader(3); + this->m_inputColorProgram = this->getInputSocketReader(0); + this->m_inputVectorProgram = this->getInputSocketReader(1); + this->m_inputScaleXProgram = this->getInputSocketReader(2); + this->m_inputScaleYProgram = this->getInputSocketReader(3); - width_x4 = this->getWidth() * 4; - height_x4 = this->getHeight() * 4; + this->m_width_x4 = this->getWidth() * 4; + this->m_height_x4 = this->getHeight() * 4; } @@ -61,17 +61,17 @@ void DisplaceSimpleOperation::executePixel(float *color, float x, float y, Pixel float p_dx, p_dy; /* main displacement in pixel space */ float u, v; - this->inputScaleXProgram->read(inScale, x, y, sampler, inputBuffers); + this->m_inputScaleXProgram->read(inScale, x, y, sampler, inputBuffers); float xs = inScale[0]; - this->inputScaleYProgram->read(inScale, x, y, sampler, inputBuffers); + this->m_inputScaleYProgram->read(inScale, x, y, sampler, inputBuffers); float ys = inScale[0]; /* clamp x and y displacement to triple image resolution - * to prevent hangs from huge values mistakenly plugged in eg. z buffers */ - CLAMP(xs, -width_x4, width_x4); - CLAMP(ys, -height_x4, height_x4); + CLAMP(xs, -this->m_width_x4, this->m_width_x4); + CLAMP(ys, -this->m_height_x4, this->m_height_x4); - this->inputVectorProgram->read(inVector, x, y, sampler, inputBuffers); + this->m_inputVectorProgram->read(inVector, x, y, sampler, inputBuffers); p_dx = inVector[0] * xs; p_dy = inVector[1] * ys; @@ -82,15 +82,15 @@ void DisplaceSimpleOperation::executePixel(float *color, float x, float y, Pixel CLAMP(u, 0.f, this->getWidth() - 1.f); CLAMP(v, 0.f, this->getHeight() - 1.f); - this->inputColorProgram->read(color, u, v, sampler, inputBuffers); + this->m_inputColorProgram->read(color, u, v, sampler, inputBuffers); } void DisplaceSimpleOperation::deinitExecution() { - this->inputColorProgram = NULL; - this->inputVectorProgram = NULL; - this->inputScaleXProgram = NULL; - this->inputScaleYProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_inputVectorProgram = NULL; + this->m_inputScaleXProgram = NULL; + this->m_inputScaleYProgram = NULL; } bool DisplaceSimpleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h index 1ebb238855b..25afbafe335 100644 --- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h +++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h @@ -29,13 +29,13 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputColorProgram; - SocketReader *inputVectorProgram; - SocketReader *inputScaleXProgram; - SocketReader *inputScaleYProgram; + SocketReader *m_inputColorProgram; + SocketReader *m_inputVectorProgram; + SocketReader *m_inputScaleXProgram; + SocketReader *m_inputScaleYProgram; - float width_x4; - float height_x4; + float m_width_x4; + float m_height_x4; public: DisplaceSimpleOperation(); diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp index ec01ba922b5..5bdc616fed7 100644 --- a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp @@ -28,20 +28,20 @@ DistanceMatteOperation::DistanceMatteOperation() : NodeOperation() addInputSocket(COM_DT_COLOR); addOutputSocket(COM_DT_VALUE); - inputImageProgram = NULL; - inputKeyProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputKeyProgram = NULL; } void DistanceMatteOperation::initExecution() { - this->inputImageProgram = this->getInputSocketReader(0); - this->inputKeyProgram = this->getInputSocketReader(1); + this->m_inputImageProgram = this->getInputSocketReader(0); + this->m_inputKeyProgram = this->getInputSocketReader(1); } void DistanceMatteOperation::deinitExecution() { - this->inputImageProgram = NULL; - this->inputKeyProgram = NULL; + this->m_inputImageProgram = NULL; + this->m_inputKeyProgram = NULL; } void DistanceMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -49,14 +49,14 @@ void DistanceMatteOperation::executePixel(float *outputValue, float x, float y, float inKey[4]; float inImage[4]; - const float tolerence = this->settings->t1; - const float falloff = this->settings->t2; + const float tolerance = this->m_settings->t1; + const float falloff = this->m_settings->t2; float distance; float alpha; - this->inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); - this->inputImageProgram->read(inImage, x, y, sampler, inputBuffers); + this->m_inputKeyProgram->read(inKey, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(inImage, x, y, sampler, inputBuffers); distance = sqrt(pow((inKey[0] - inImage[0]), 2) + pow((inKey[1] - inImage[1]), 2) + @@ -67,12 +67,12 @@ void DistanceMatteOperation::executePixel(float *outputValue, float x, float y, */ /*make 100% transparent */ - if (distance < tolerence) { + if (distance < tolerance) { outputValue[0] = 0.f; } /*in the falloff region, make partially transparent */ - else if (distance < falloff + tolerence) { - distance = distance - tolerence; + else if (distance < falloff + tolerance) { + distance = distance - tolerance; alpha = distance / falloff; /*only change if more transparent than before */ if (alpha < inImage[3]) { diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.h b/source/blender/compositor/operations/COM_DistanceMatteOperation.h index cf1172a8c11..267aa1fca7a 100644 --- a/source/blender/compositor/operations/COM_DistanceMatteOperation.h +++ b/source/blender/compositor/operations/COM_DistanceMatteOperation.h @@ -25,14 +25,14 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class DistanceMatteOperation : public NodeOperation { private: - NodeChroma *settings; - SocketReader *inputImageProgram; - SocketReader *inputKeyProgram; + NodeChroma *m_settings; + SocketReader *m_inputImageProgram; + SocketReader *m_inputKeyProgram; public: /** * Default constructor @@ -47,6 +47,6 @@ public: void initExecution(); void deinitExecution(); - void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; } + void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; } }; #endif diff --git a/source/blender/compositor/operations/COM_DotproductOperation.cpp b/source/blender/compositor/operations/COM_DotproductOperation.cpp index e225a677989..53ab5f97518 100644 --- a/source/blender/compositor/operations/COM_DotproductOperation.cpp +++ b/source/blender/compositor/operations/COM_DotproductOperation.cpp @@ -28,19 +28,19 @@ DotproductOperation::DotproductOperation() : NodeOperation() this->addInputSocket(COM_DT_VECTOR); this->addOutputSocket(COM_DT_VALUE); this->setResolutionInputSocketIndex(0); - this->input1Operation = NULL; - this->input2Operation = NULL; + this->m_input1Operation = NULL; + this->m_input2Operation = NULL; } void DotproductOperation::initExecution() { - this->input1Operation = this->getInputSocketReader(0); - this->input2Operation = this->getInputSocketReader(1); + this->m_input1Operation = this->getInputSocketReader(0); + this->m_input2Operation = this->getInputSocketReader(1); } void DotproductOperation::deinitExecution() { - this->input1Operation = NULL; - this->input2Operation = NULL; + this->m_input1Operation = NULL; + this->m_input2Operation = NULL; } /** @todo: current implementation is the inverse of a dotproduct. not 'logically' correct @@ -49,7 +49,7 @@ void DotproductOperation::executePixel(float *color, float x, float y, PixelSamp { float input1[4]; float input2[4]; - this->input1Operation->read(input1, x, y, sampler, inputBuffers); - this->input2Operation->read(input2, x, y, sampler, inputBuffers); + this->m_input1Operation->read(input1, x, y, sampler, inputBuffers); + this->m_input2Operation->read(input2, x, y, sampler, inputBuffers); color[0] = -(input1[0] * input2[0] + input1[1] * input2[1] + input1[2] * input2[2]); } diff --git a/source/blender/compositor/operations/COM_DotproductOperation.h b/source/blender/compositor/operations/COM_DotproductOperation.h index 849dc83a9cd..7ca540983d9 100644 --- a/source/blender/compositor/operations/COM_DotproductOperation.h +++ b/source/blender/compositor/operations/COM_DotproductOperation.h @@ -27,8 +27,8 @@ class DotproductOperation : public NodeOperation { private: - SocketReader *input1Operation; - SocketReader *input2Operation; + SocketReader *m_input1Operation; + SocketReader *m_input2Operation; public: DotproductOperation(); void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp index 8344a4d248b..e5a145bab2e 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp @@ -781,10 +781,10 @@ static void do_allEdgeDetection(unsigned int t, unsigned int rw, unsigned int *l if (!limask[a]) { // if the inner mask is empty if (lomask[a]) { // if the outer mask is full /* - Next we test all 4 directions around the current pixel: next/prev/up/down - The test ensures that the outer mask is empty and that the inner mask - is also empty. If both conditions are true for any one of the 4 adjacent pixels - then the current pixel is counted as being a true outer edge pixel. + * Next we test all 4 directions around the current pixel: next/prev/up/down + * The test ensures that the outer mask is empty and that the inner mask + * is also empty. If both conditions are true for any one of the 4 adjacent pixels + * then the current pixel is counted as being a true outer edge pixel. */ if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) || (!lomask[pix_prevCol] && !limask[pix_prevCol]) || @@ -843,10 +843,10 @@ static void do_adjacentEdgeDetection(unsigned int t, unsigned int rw, unsigned i if (!limask[a]) { // if the inner mask is empty if (lomask[a]) { // if the outer mask is full /* - Next we test all 4 directions around the current pixel: next/prev/up/down - The test ensures that the outer mask is empty and that the inner mask - is also empty. If both conditions are true for any one of the 4 adjacent pixels - then the current pixel is counted as being a true outer edge pixel. + * Next we test all 4 directions around the current pixel: next/prev/up/down + * The test ensures that the outer mask is empty and that the inner mask + * is also empty. If both conditions are true for any one of the 4 adjacent pixels + * then the current pixel is counted as being a true outer edge pixel. */ if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) || (!lomask[pix_prevCol] && !limask[pix_prevCol]) || @@ -902,65 +902,65 @@ static void do_createEdgeLocationBuffer(unsigned int t, unsigned int rw, unsigne unsigned int outerAccum = 0; // for looping outer edge pixel indexes, represents current position from offset unsigned int gradientAccum = 0; // for looping gradient pixel indexes, represents current position from offset /* - Here we compute the size of buffer needed to hold (row,col) coordinates - for each pixel previously determined to be either gradient, inner edge, - or outer edge. - - Allocation is done by requesting 4 bytes "sizeof(int)" per pixel, even - though gbuf[] is declared as unsigned short* (2 bytes) because we don't - store the pixel indexes, we only store x,y location of pixel in buffer. - - This does make the assumption that x and y can fit in 16 unsigned bits - so if Blender starts doing renders greater than 65536 in either direction - this will need to allocate gbuf[] as unsigned int *and allocate 8 bytes - per flagged pixel. - - In general, the buffer on-screen: - - Example: 9 by 9 pixel block - - . = pixel non-white in both outer and inner mask - o = pixel white in outer, but not inner mask, adjacent to "." pixel - g = pixel white in outer, but not inner mask, not adjacent to "." pixel - i = pixel white in inner mask, adjacent to "g" or "." pixel - F = pixel white in inner mask, only adjacent to other pixels white in the inner mask - - - ......... <----- pixel #80 - ..oooo... - .oggggo.. - .oggiggo. - .ogiFigo. - .oggiggo. - .oggggo.. - ..oooo... - pixel #00 -----> ......... - - gsz = 18 (18 "g" pixels above) - isz = 4 (4 "i" pixels above) - osz = 18 (18 "o" pixels above) - - - The memory in gbuf[] after filling will look like this: - - gradientFillOffset (0 pixels) innerEdgeOffset (18 pixels) outerEdgeOffset (22 pixels) - / / / - / / / - |X Y X Y X Y X Y > <X Y X Y > <X Y X Y X Y > <X Y X Y | <- (x,y) - +--------------------------------> <----------------> <------------------------> <----------------+ - |0 2 4 6 8 10 12 14 > ... <68 70 72 74 > ... <80 82 84 86 88 90 > ... <152 154 156 158 | <- bytes - +--------------------------------> <----------------> <------------------------> <----------------+ - |g0 g0 g1 g1 g2 g2 g3 g3 > <g17 g17 i0 i0 > <i2 i2 i3 i3 o0 o0 > <o16 o16 o17 o17 | <- pixel - / / / - / / / - / / / - +---------- gradientAccum (18) ---------+ +--- innerAccum (22) ---+ +--- outerAccum (40) ---+ - - - Ultimately we do need the pixel's memory buffer index to set the output - pixel color, but it's faster to reconstruct the memory buffer location - each iteration of the final gradient calculation than it is to deconstruct - a memory location into x,y pairs each round. + * Here we compute the size of buffer needed to hold (row,col) coordinates + * for each pixel previously determined to be either gradient, inner edge, + * or outer edge. + * + * Allocation is done by requesting 4 bytes "sizeof(int)" per pixel, even + * though gbuf[] is declared as unsigned short* (2 bytes) because we don't + * store the pixel indexes, we only store x,y location of pixel in buffer. + * + * This does make the assumption that x and y can fit in 16 unsigned bits + * so if Blender starts doing renders greater than 65536 in either direction + * this will need to allocate gbuf[] as unsigned int *and allocate 8 bytes + * per flagged pixel. + * + * In general, the buffer on-screen: + * + * Example: 9 by 9 pixel block + * + * . = pixel non-white in both outer and inner mask + * o = pixel white in outer, but not inner mask, adjacent to "." pixel + * g = pixel white in outer, but not inner mask, not adjacent to "." pixel + * i = pixel white in inner mask, adjacent to "g" or "." pixel + * F = pixel white in inner mask, only adjacent to other pixels white in the inner mask + * + * + * ......... <----- pixel #80 + * ..oooo... + * .oggggo.. + * .oggiggo. + * .ogiFigo. + * .oggiggo. + * .oggggo.. + * ..oooo... + * pixel #00 -----> ......... + * + * gsz = 18 (18 "g" pixels above) + * isz = 4 (4 "i" pixels above) + * osz = 18 (18 "o" pixels above) + * + * + * The memory in gbuf[] after filling will look like this: + * + * gradientFillOffset (0 pixels) innerEdgeOffset (18 pixels) outerEdgeOffset (22 pixels) + * / / / + * / / / + * |X Y X Y X Y X Y > <X Y X Y > <X Y X Y X Y > <X Y X Y | <- (x,y) + * +--------------------------------> <----------------> <------------------------> <----------------+ + * |0 2 4 6 8 10 12 14 > ... <68 70 72 74 > ... <80 82 84 86 88 90 > ... <152 154 156 158 | <- bytes + * +--------------------------------> <----------------> <------------------------> <----------------+ + * |g0 g0 g1 g1 g2 g2 g3 g3 > <g17 g17 i0 i0 > <i2 i2 i3 i3 o0 o0 > <o16 o16 o17 o17 | <- pixel + * / / / + * / / / + * / / / + * +---------- gradientAccum (18) ---------+ +--- innerAccum (22) ---+ +--- outerAccum (40) ---+ + * + * + * Ultimately we do need the pixel's memory buffer index to set the output + * pixel color, but it's faster to reconstruct the memory buffer location + * each iteration of the final gradient calculation than it is to deconstruct + * a memory location into x,y pairs each round. */ @@ -1184,8 +1184,8 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float * * Each version has slightly different criteria for detecting an edge pixel. */ - if (this->adjecentOnly) { // if "adjacent only" inner edge mode is turned on - if (this->keepInside) { // if "keep inside" buffer edge mode is turned on + if (this->m_adjecentOnly) { // if "adjacent only" inner edge mode is turned on + if (this->m_keepInside) { // if "keep inside" buffer edge mode is turned on do_adjacentKeepBorders(t, rw, limask, lomask, lres, res, rsize); } else { // "bleed out" buffer edge mode is turned on @@ -1198,7 +1198,7 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float do_adjacentEdgeDetection(t, rw, limask, lomask, lres, res, rsize, isz, osz, gsz); } else { // "all" inner edge mode is turned on - if (this->keepInside) { // if "keep inside" buffer edge mode is turned on + if (this->m_keepInside) { // if "keep inside" buffer edge mode is turned on do_allKeepBorders(t, rw, limask, lomask, lres, res, rsize); } else { // "bleed out" buffer edge mode is turned on @@ -1230,16 +1230,16 @@ DoubleEdgeMaskOperation::DoubleEdgeMaskOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->inputInnerMask = NULL; - this->inputOuterMask = NULL; - this->adjecentOnly = false; - this->keepInside = false; + this->m_inputInnerMask = NULL; + this->m_inputOuterMask = NULL; + this->m_adjecentOnly = false; + this->m_keepInside = false; this->setComplex(true); } bool DoubleEdgeMaskOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { - if (this->cachedInstance == NULL) { + if (this->m_cachedInstance == NULL) { rcti newInput; newInput.xmax = this->getWidth(); newInput.xmin = 0; @@ -1254,30 +1254,31 @@ bool DoubleEdgeMaskOperation::determineDependingAreaOfInterest(rcti *input, Read void DoubleEdgeMaskOperation::initExecution() { - this->inputInnerMask = this->getInputSocketReader(0); - this->inputOuterMask = this->getInputSocketReader(1); + this->m_inputInnerMask = this->getInputSocketReader(0); + this->m_inputOuterMask = this->getInputSocketReader(1); initMutex(); - this->cachedInstance = NULL; + this->m_cachedInstance = NULL; } void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->cachedInstance) return this->cachedInstance; + if (this->m_cachedInstance) + return this->m_cachedInstance; lockMutex(); - if (this->cachedInstance == NULL) { - MemoryBuffer *innerMask = (MemoryBuffer *)inputInnerMask->initializeTileData(rect, memoryBuffers); - MemoryBuffer *outerMask = (MemoryBuffer *)inputOuterMask->initializeTileData(rect, memoryBuffers); + if (this->m_cachedInstance == NULL) { + MemoryBuffer *innerMask = (MemoryBuffer *)this->m_inputInnerMask->initializeTileData(rect, memoryBuffers); + MemoryBuffer *outerMask = (MemoryBuffer *)this->m_inputOuterMask->initializeTileData(rect, memoryBuffers); float *data = new float[this->getWidth() * this->getHeight()]; float *imask = innerMask->convertToValueBuffer(); float *omask = outerMask->convertToValueBuffer(); doDoubleEdgeMask(imask, omask, data); delete imask; delete omask; - this->cachedInstance = data; + this->m_cachedInstance = data; } unlockMutex(); - return this->cachedInstance; + return this->m_cachedInstance; } void DoubleEdgeMaskOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { @@ -1291,12 +1292,12 @@ void DoubleEdgeMaskOperation::executePixel(float *color, int x, int y, MemoryBuf void DoubleEdgeMaskOperation::deinitExecution() { - this->inputInnerMask = NULL; - this->inputOuterMask = NULL; + this->m_inputInnerMask = NULL; + this->m_inputOuterMask = NULL; deinitMutex(); - if (this->cachedInstance) { - delete cachedInstance; - this->cachedInstance = NULL; + if (this->m_cachedInstance) { + delete this->m_cachedInstance; + this->m_cachedInstance = NULL; } } diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h index a18d59ae5a2..442680e320e 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h @@ -30,11 +30,11 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputOuterMask; - SocketReader *inputInnerMask; - bool adjecentOnly; - bool keepInside; - float *cachedInstance; + SocketReader *m_inputOuterMask; + SocketReader *m_inputInnerMask; + bool m_adjecentOnly; + bool m_keepInside; + float *m_cachedInstance; public: DoubleEdgeMaskOperation(); @@ -58,7 +58,7 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void setAdjecentOnly(bool adjecentOnly) { this->adjecentOnly = adjecentOnly; } - void setKeepInside(bool keepInside) { this->keepInside = keepInside; } + void setAdjecentOnly(bool adjecentOnly) { this->m_adjecentOnly = adjecentOnly; } + void setKeepInside(bool keepInside) { this->m_keepInside = keepInside; } }; #endif diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp index 0beacd02738..1aa1b89ee76 100644 --- a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp @@ -29,19 +29,19 @@ EllipseMaskOperation::EllipseMaskOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->inputMask = NULL; - this->inputValue = NULL; - this->cosine = 0.0f; - this->sine = 0.0f; + this->m_inputMask = NULL; + this->m_inputValue = NULL; + this->m_cosine = 0.0f; + this->m_sine = 0.0f; } void EllipseMaskOperation::initExecution() { - this->inputMask = this->getInputSocketReader(0); - this->inputValue = this->getInputSocketReader(1); - const double rad = DEG2RAD((double)this->data->rotation); - this->cosine = cos(rad); - this->sine = sin(rad); - this->aspectRatio = ((float)this->getWidth()) / this->getHeight(); + this->m_inputMask = this->getInputSocketReader(0); + this->m_inputValue = this->getInputSocketReader(1); + const double rad = DEG2RAD((double)this->m_data->rotation); + this->m_cosine = cos(rad); + this->m_sine = sin(rad); + this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight(); } void EllipseMaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -52,26 +52,26 @@ void EllipseMaskOperation::executePixel(float *color, float x, float y, PixelSam float rx = x / this->getWidth(); float ry = y / this->getHeight(); - const float dy = (ry - this->data->y) / this->aspectRatio; - const float dx = rx - this->data->x; - rx = this->data->x + (this->cosine * dx + this->sine * dy); - ry = this->data->y + (-this->sine * dx + this->cosine * dy); + const float dy = (ry - this->m_data->y) / this->m_aspectRatio; + const float dx = rx - this->m_data->x; + rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy); + ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy); - this->inputMask->read(inputMask, x, y, sampler, inputBuffers); - this->inputValue->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputMask->read(inputMask, x, y, sampler, inputBuffers); + this->m_inputValue->read(inputValue, x, y, sampler, inputBuffers); - const float halfHeight = (this->data->height) / 2.0f; - const float halfWidth = this->data->width / 2.0f; - float sx = rx - this->data->x; + const float halfHeight = (this->m_data->height) / 2.0f; + const float halfWidth = this->m_data->width / 2.0f; + float sx = rx - this->m_data->x; sx *= sx; const float tx = halfWidth * halfWidth; - float sy = ry - this->data->y; + float sy = ry - this->m_data->y; sy *= sy; const float ty = halfHeight * halfHeight; bool inside = ((sx / tx) + (sy / ty)) < 1.0f; - switch (this->maskType) { + switch (this->m_maskType) { case CMP_NODE_MASKTYPE_ADD: if (inside) { color[0] = max(inputMask[0], inputValue[0]); @@ -117,7 +117,7 @@ void EllipseMaskOperation::executePixel(float *color, float x, float y, PixelSam void EllipseMaskOperation::deinitExecution() { - this->inputMask = NULL; - this->inputValue = NULL; + this->m_inputMask = NULL; + this->m_inputValue = NULL; } diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.h b/source/blender/compositor/operations/COM_EllipseMaskOperation.h index 61d724c2f15..0b0ffa023cb 100644 --- a/source/blender/compositor/operations/COM_EllipseMaskOperation.h +++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.h @@ -30,15 +30,15 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputMask; - SocketReader *inputValue; + SocketReader *m_inputMask; + SocketReader *m_inputValue; - float sine; - float cosine; - float aspectRatio; - int maskType; + float m_sine; + float m_cosine; + float m_aspectRatio; + int m_maskType; - NodeEllipseMask *data; + NodeEllipseMask *m_data; public: EllipseMaskOperation(); @@ -57,9 +57,9 @@ public: */ void deinitExecution(); - void setData(NodeEllipseMask *data) { this->data = data; } + void setData(NodeEllipseMask *data) { this->m_data = data; } - void setMaskType(int maskType) { this->maskType = maskType; } + void setMaskType(int maskType) { this->m_maskType = maskType; } }; #endif diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index 7491b0f30dd..8f0ebd9b8d2 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -28,7 +28,7 @@ FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { - this->iirgaus = NULL; + this->m_iirgaus = NULL; } void FastGaussianBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) @@ -51,7 +51,7 @@ bool FastGaussianBlurOperation::determineDependingAreaOfInterest(rcti *input, Re return true; } else { - if (this->iirgaus) { + if (this->m_iirgaus) { return false; } else { @@ -72,9 +72,9 @@ void FastGaussianBlurOperation::initExecution() void FastGaussianBlurOperation::deinitExecution() { - if (this->iirgaus) { - delete this->iirgaus; - this->iirgaus = NULL; + if (this->m_iirgaus) { + delete this->m_iirgaus; + this->m_iirgaus = NULL; } BlurBaseOperation::deinitMutex(); } @@ -82,33 +82,33 @@ void FastGaussianBlurOperation::deinitExecution() void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { lockMutex(); - if (!iirgaus) { - MemoryBuffer *newBuf = (MemoryBuffer *)this->inputProgram->initializeTileData(rect, memoryBuffers); + if (!this->m_iirgaus) { + MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect, memoryBuffers); MemoryBuffer *copy = newBuf->duplicate(); updateSize(memoryBuffers); int c; - sx = data->sizex * this->size / 2.0f; - sy = data->sizey * this->size / 2.0f; + this->m_sx = this->m_data->sizex * this->m_size / 2.0f; + this->m_sy = this->m_data->sizey * this->m_size / 2.0f; - if ((sx == sy) && (sx > 0.f)) { + if ((this->m_sx == this->m_sy) && (this->m_sx > 0.f)) { for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) - IIR_gauss(copy, sx, c, 3); + IIR_gauss(copy, this->m_sx, c, 3); } else { - if (sx > 0.f) { + if (this->m_sx > 0.0f) { for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) - IIR_gauss(copy, sx, c, 1); + IIR_gauss(copy, this->m_sx, c, 1); } - if (sy > 0.f) { + if (this->m_sy > 0.0f) { for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) - IIR_gauss(copy, sy, c, 2); + IIR_gauss(copy, this->m_sy, c, 2); } } - this->iirgaus = copy; + this->m_iirgaus = copy; } unlockMutex(); - return iirgaus; + return this->m_iirgaus; } void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsigned int chan, unsigned int xy) diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h index 0f3929f052c..1e303b23869 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h @@ -28,9 +28,9 @@ class FastGaussianBlurOperation : public BlurBaseOperation { private: - float sx; - float sy; - MemoryBuffer *iirgaus; + float m_sx; + float m_sy; + MemoryBuffer *m_iirgaus; public: FastGaussianBlurOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); diff --git a/source/blender/compositor/operations/COM_FlipOperation.cpp b/source/blender/compositor/operations/COM_FlipOperation.cpp index 5023473f4aa..60dabb86bb5 100644 --- a/source/blender/compositor/operations/COM_FlipOperation.cpp +++ b/source/blender/compositor/operations/COM_FlipOperation.cpp @@ -27,34 +27,34 @@ FlipOperation::FlipOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputOperation = NULL; - this->flipX = true; - this->flipY = false; + this->m_inputOperation = NULL; + this->m_flipX = true; + this->m_flipY = false; } void FlipOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void FlipOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void FlipOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - float nx = this->flipX ? this->getWidth() - 1 - x : x; - float ny = this->flipY ? this->getHeight() - 1 - y : y; + float nx = this->m_flipX ? this->getWidth() - 1 - x : x; + float ny = this->m_flipY ? this->getHeight() - 1 - y : y; - this->inputOperation->read(color, nx, ny, sampler, inputBuffers); + this->m_inputOperation->read(color, nx, ny, sampler, inputBuffers); } bool FlipOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - if (this->flipX) { + if (this->m_flipX) { newInput.xmax = (this->getWidth() - 1 - input->xmin) + 1; newInput.xmin = (this->getWidth() - 1 - input->xmax) - 1; } @@ -62,7 +62,7 @@ bool FlipOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOper newInput.xmin = input->xmin; newInput.xmax = input->xmax; } - if (this->flipY) { + if (this->m_flipY) { newInput.ymax = (this->getHeight() - 1 - input->ymin) + 1; newInput.ymin = (this->getHeight() - 1 - input->ymax) - 1; } diff --git a/source/blender/compositor/operations/COM_FlipOperation.h b/source/blender/compositor/operations/COM_FlipOperation.h index f83fa6ac3a8..5442774c94c 100644 --- a/source/blender/compositor/operations/COM_FlipOperation.h +++ b/source/blender/compositor/operations/COM_FlipOperation.h @@ -27,9 +27,9 @@ class FlipOperation : public NodeOperation { private: - SocketReader *inputOperation; - bool flipX; - bool flipY; + SocketReader *m_inputOperation; + bool m_flipX; + bool m_flipY; public: FlipOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); @@ -37,8 +37,8 @@ public: void initExecution(); void deinitExecution(); - void setFlipX(bool flipX) { this->flipX = flipX; } - void setFlipY(bool flipY) { this->flipY = flipY; } + void setFlipX(bool flipX) { this->m_flipX = flipX; } + void setFlipY(bool flipY) { this->m_flipY = flipY; } }; #endif diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp index 3e90b643604..db8d54a2f3c 100644 --- a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp +++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp @@ -27,17 +27,17 @@ GammaCorrectOperation::GammaCorrectOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void GammaCorrectOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void GammaCorrectOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - this->inputProgram->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputColor, x, y, sampler, inputBuffers); if (inputColor[3] > 0.0f) { inputColor[0] /= inputColor[3]; inputColor[1] /= inputColor[3]; @@ -61,24 +61,24 @@ void GammaCorrectOperation::executePixel(float *color, float x, float y, PixelSa void GammaCorrectOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } GammaUncorrectOperation::GammaUncorrectOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void GammaUncorrectOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void GammaUncorrectOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; - this->inputProgram->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputColor, x, y, sampler, inputBuffers); if (inputColor[3] > 0.0f) { inputColor[0] /= inputColor[3]; @@ -102,5 +102,5 @@ void GammaUncorrectOperation::executePixel(float *color, float x, float y, Pixel void GammaUncorrectOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.h b/source/blender/compositor/operations/COM_GammaCorrectOperation.h index 4bf03eac0a1..4db911bb9b5 100644 --- a/source/blender/compositor/operations/COM_GammaCorrectOperation.h +++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.h @@ -30,7 +30,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; public: GammaCorrectOperation(); @@ -56,7 +56,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; public: GammaUncorrectOperation(); diff --git a/source/blender/compositor/operations/COM_GammaOperation.cpp b/source/blender/compositor/operations/COM_GammaOperation.cpp index 2c3e78840ee..9ccc76f4392 100644 --- a/source/blender/compositor/operations/COM_GammaOperation.cpp +++ b/source/blender/compositor/operations/COM_GammaOperation.cpp @@ -28,13 +28,13 @@ GammaOperation::GammaOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; - this->inputGammaProgram = NULL; + this->m_inputProgram = NULL; + this->m_inputGammaProgram = NULL; } void GammaOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); - this->inputGammaProgram = this->getInputSocketReader(1); + this->m_inputProgram = this->getInputSocketReader(0); + this->m_inputGammaProgram = this->getInputSocketReader(1); } void GammaOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -42,8 +42,8 @@ void GammaOperation::executePixel(float *color, float x, float y, PixelSampler s float inputValue[4]; float inputGamma[4]; - this->inputProgram->read(inputValue, x, y, sampler, inputBuffers); - this->inputGammaProgram->read(inputGamma, x, y, sampler, inputBuffers); + this->m_inputProgram->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputGammaProgram->read(inputGamma, x, y, sampler, inputBuffers); const float gamma = inputGamma[0]; /* check for negative to avoid nan's */ color[0] = inputValue[0] > 0.0f ? powf(inputValue[0], gamma) : inputValue[0]; @@ -55,6 +55,6 @@ void GammaOperation::executePixel(float *color, float x, float y, PixelSampler s void GammaOperation::deinitExecution() { - this->inputProgram = NULL; - this->inputGammaProgram = NULL; + this->m_inputProgram = NULL; + this->m_inputGammaProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_GammaOperation.h b/source/blender/compositor/operations/COM_GammaOperation.h index 8c007d27843..758f7bda04d 100644 --- a/source/blender/compositor/operations/COM_GammaOperation.h +++ b/source/blender/compositor/operations/COM_GammaOperation.h @@ -30,8 +30,8 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; - SocketReader *inputGammaProgram; + SocketReader *m_inputProgram; + SocketReader *m_inputGammaProgram; public: GammaOperation(); diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp index 1283ac48923..a138d4be1d9 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp @@ -30,16 +30,18 @@ extern "C" { GaussianAlphaXBlurOperation::GaussianAlphaXBlurOperation() : BlurBaseOperation(COM_DT_VALUE) { - this->gausstab = NULL; - this->rad = 0; + this->m_gausstab = NULL; + this->m_rad = 0; } void *GaussianAlphaXBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (!this->sizeavailable) { + lockMutex(); + if (!this->m_sizeavailable) { updateGauss(memoryBuffers); } void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + unlockMutex(); return buffer; } @@ -47,37 +49,39 @@ void GaussianAlphaXBlurOperation::initExecution() { /* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */ - if (this->sizeavailable) { - float rad = size * this->data->sizex; + initMutex(); + + if (this->m_sizeavailable) { + float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); - this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad); + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); + this->m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->m_falloff); } } void GaussianAlphaXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) { - if (this->gausstab == NULL) { + if (this->m_gausstab == NULL) { updateSize(memoryBuffers); - float rad = size * this->data->sizex; + float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); } - if (this->distbuf_inv == NULL) { + if (this->m_distbuf_inv == NULL) { updateSize(memoryBuffers); - float rad = size * this->data->sizex; + float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; - this->rad = rad; - this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad); + this->m_rad = rad; + this->m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->m_falloff); } } @@ -88,7 +92,7 @@ BLI_INLINE float finv_test(const float f, const bool test) void GaussianAlphaXBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - const bool do_invert = this->do_subtract; + const bool do_invert = this->m_do_subtract; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); @@ -97,8 +101,8 @@ void GaussianAlphaXBlurOperation::executePixel(float *color, int x, int y, Memor int miny = y; int maxy = y; - int minx = x - this->rad; - int maxx = x + this->rad; + int minx = x - this->m_rad; + int maxx = x + this->m_rad; miny = max(miny, inputBuffer->getRect()->ymin); minx = max(minx, inputBuffer->getRect()->xmin); maxy = min(maxy, inputBuffer->getRect()->ymax); @@ -118,20 +122,20 @@ void GaussianAlphaXBlurOperation::executePixel(float *color, int x, int y, Memor float distfacinv_max = 1.0f; /* 0 to 1 */ for (int nx = minx; nx < maxx; nx += step) { - const int index = (nx - x) + this->rad; + const int index = (nx - x) + this->m_rad; float value = finv_test(buffer[bufferindex], do_invert); float multiplier; /* gauss */ { - multiplier = gausstab[index]; + multiplier = this->m_gausstab[index]; alpha_accum += value * multiplier; multiplier_accum += multiplier; } /* dilate - find most extreme color */ if (value > value_max) { - multiplier = distbuf_inv[index]; + multiplier = this->m_distbuf_inv[index]; value *= multiplier; if (value > value_max) { value_max = value; @@ -150,10 +154,12 @@ void GaussianAlphaXBlurOperation::executePixel(float *color, int x, int y, Memor void GaussianAlphaXBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->gausstab; - this->gausstab = NULL; - delete [] this->distbuf_inv; - this->distbuf_inv = NULL; + delete [] this->m_gausstab; + this->m_gausstab = NULL; + delete [] this->m_distbuf_inv; + this->m_distbuf_inv = NULL; + + deinitMutex(); } bool GaussianAlphaXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -173,9 +179,9 @@ bool GaussianAlphaXBlurOperation::determineDependingAreaOfInterest(rcti *input, else #endif { - if (this->sizeavailable && this->gausstab != NULL) { - newInput.xmax = input->xmax + rad; - newInput.xmin = input->xmin - rad; + if (this->m_sizeavailable && this->m_gausstab != NULL) { + newInput.xmax = input->xmax + this->m_rad; + newInput.xmin = input->xmin - this->m_rad; newInput.ymax = input->ymax; newInput.ymin = input->ymin; } diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h index 3268e51be01..59797c27952 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h @@ -28,10 +28,11 @@ class GaussianAlphaXBlurOperation : public BlurBaseOperation { private: - float *gausstab; - float *distbuf_inv; - bool do_subtract; - int rad; + float *m_gausstab; + float *m_distbuf_inv; + int m_falloff; /* falloff for distbuf_inv */ + bool m_do_subtract; + int m_rad; void updateGauss(MemoryBuffer **memoryBuffers); public: GaussianAlphaXBlurOperation(); @@ -57,6 +58,7 @@ public: /** * Set subtract for Dilate/Erode functionality */ - void setSubtract(bool subtract) { this->do_subtract = subtract; } + void setSubtract(bool subtract) { this->m_do_subtract = subtract; } + void setFalloff(int falloff) { this->m_falloff = falloff; } }; #endif diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp index 1d67c23e41b..ab5f8d33850 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp @@ -30,16 +30,18 @@ extern "C" { GaussianAlphaYBlurOperation::GaussianAlphaYBlurOperation() : BlurBaseOperation(COM_DT_VALUE) { - this->gausstab = NULL; - this->rad = 0; + this->m_gausstab = NULL; + this->m_rad = 0; } void *GaussianAlphaYBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (!this->sizeavailable) { + lockMutex(); + if (!this->m_sizeavailable) { updateGauss(memoryBuffers); } void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + unlockMutex(); return buffer; } @@ -47,37 +49,39 @@ void GaussianAlphaYBlurOperation::initExecution() { /* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */ - if (this->sizeavailable) { - float rad = size * this->data->sizey; + initMutex(); + + if (this->m_sizeavailable) { + float rad = this->m_size * this->m_data->sizey; if (rad < 1) rad = 1; - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); - this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad); + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); + this->m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->m_falloff); } } void GaussianAlphaYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) { - if (this->gausstab == NULL) { + if (this->m_gausstab == NULL) { updateSize(memoryBuffers); - float rad = size * this->data->sizey; + float rad = this->m_size * this->m_data->sizey; if (rad < 1) rad = 1; - - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); + + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); } - if (this->distbuf_inv == NULL) { + if (this->m_distbuf_inv == NULL) { updateSize(memoryBuffers); - float rad = size * this->data->sizex; + float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; - this->rad = rad; - this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad); + this->m_rad = rad; + this->m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->m_falloff); } } @@ -88,15 +92,15 @@ BLI_INLINE float finv_test(const float f, const bool test) void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - const bool do_invert = this->do_subtract; + const bool do_invert = this->m_do_subtract; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); int bufferwidth = inputBuffer->getWidth(); int bufferstartx = inputBuffer->getRect()->xmin; int bufferstarty = inputBuffer->getRect()->ymin; - int miny = y - this->rad; - int maxy = y + this->rad; + int miny = y - this->m_rad; + int maxy = y + this->m_rad; int minx = x; int maxx = x; miny = max(miny, inputBuffer->getRect()->ymin); @@ -118,20 +122,20 @@ void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, Memor for (int ny = miny; ny < maxy; ny += step) { int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); - const int index = (ny - y) + this->rad; + const int index = (ny - y) + this->m_rad; float value = finv_test(buffer[bufferindex], do_invert); float multiplier; /* gauss */ { - multiplier = gausstab[index]; + multiplier = this->m_gausstab[index]; alpha_accum += value * multiplier; multiplier_accum += multiplier; } /* dilate - find most extreme color */ if (value > value_max) { - multiplier = distbuf_inv[index]; + multiplier = this->m_distbuf_inv[index]; value *= multiplier; if (value > value_max) { value_max = value; @@ -150,10 +154,12 @@ void GaussianAlphaYBlurOperation::executePixel(float *color, int x, int y, Memor void GaussianAlphaYBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->gausstab; - this->gausstab = NULL; - delete [] this->distbuf_inv; - this->distbuf_inv = NULL; + delete [] this->m_gausstab; + this->m_gausstab = NULL; + delete [] this->m_distbuf_inv; + this->m_distbuf_inv = NULL; + + deinitMutex(); } bool GaussianAlphaYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -173,11 +179,11 @@ bool GaussianAlphaYBlurOperation::determineDependingAreaOfInterest(rcti *input, else #endif { - if (this->sizeavailable && this->gausstab != NULL) { + if (this->m_sizeavailable && this->m_gausstab != NULL) { newInput.xmax = input->xmax; newInput.xmin = input->xmin; - newInput.ymax = input->ymax + rad; - newInput.ymin = input->ymin - rad; + newInput.ymax = input->ymax + this->m_rad; + newInput.ymin = input->ymin - this->m_rad; } else { newInput.xmax = this->getWidth(); diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h index 0ffc264ba98..e0789db7815 100644 --- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h @@ -28,10 +28,11 @@ class GaussianAlphaYBlurOperation : public BlurBaseOperation { private: - float *gausstab; - float *distbuf_inv; - bool do_subtract; - int rad; + float *m_gausstab; + float *m_distbuf_inv; + bool m_do_subtract; + int m_falloff; + int m_rad; void updateGauss(MemoryBuffer **memoryBuffers); public: GaussianAlphaYBlurOperation(); @@ -57,6 +58,7 @@ public: /** * Set subtract for Dilate/Erode functionality */ - void setSubtract(bool subtract) { this->do_subtract = subtract; } + void setSubtract(bool subtract) { this->m_do_subtract = subtract; } + void setFalloff(int falloff) { this->m_falloff = falloff; } }; #endif diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp index dc9e354b124..ac91d3336e2 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp @@ -29,15 +29,17 @@ extern "C" { GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { - this->gausstab = NULL; + this->m_gausstab = NULL; } void *GaussianBokehBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (!sizeavailable) { + lockMutex(); + if (!this->m_sizeavailable) { updateGauss(memoryBuffers); } void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + unlockMutex(); return buffer; } @@ -45,14 +47,16 @@ void GaussianBokehBlurOperation::initExecution() { BlurBaseOperation::initExecution(); - if (this->sizeavailable) { + initMutex(); + + if (this->m_sizeavailable) { updateGauss(NULL); } } void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) { - if (this->gausstab == NULL) { + if (this->m_gausstab == NULL) { float radxf; float radyf; int n; @@ -62,37 +66,37 @@ void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) int j, i; const float width = this->getWidth(); const float height = this->getHeight(); - if (!sizeavailable) { + if (!this->m_sizeavailable) { updateSize(memoryBuffers); } - radxf = size * (float)this->data->sizex; + radxf = this->m_size * (float)this->m_data->sizex; if (radxf > width / 2.0f) radxf = width / 2.0f; else if (radxf < 1.0f) radxf = 1.0f; /* vertical */ - radyf = size * (float)this->data->sizey; + radyf = this->m_size * (float)this->m_data->sizey; if (radyf > height / 2.0f) radyf = height / 2.0f; else if (radyf < 1.0f) radyf = 1.0f; - radx = ceil(radxf); - rady = ceil(radyf); + this->m_radx = ceil(radxf); + this->m_rady = ceil(radyf); - n = (2 * radx + 1) * (2 * rady + 1); + n = (2 * this->m_radx + 1) * (2 * this->m_rady + 1); /* create a full filter image */ ddgauss = new float[n]; dgauss = ddgauss; val = 0.0f; - for (j = -rady; j <= rady; j++) { - for (i = -radx; i <= radx; i++, dgauss++) { + for (j = -this->m_rady; j <= this->m_rady; j++) { + for (i = -this->m_radx; i <= this->m_radx; i++, dgauss++) { float fj = (float)j / radyf; float fi = (float)i / radxf; float dist = sqrt(fj * fj + fi * fi); - *dgauss = RE_filter_value(this->data->filtertype, dist); + *dgauss = RE_filter_value(this->m_data->filtertype, dist); val += *dgauss; } @@ -104,7 +108,7 @@ void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) } else ddgauss[4] = 1.0f; - gausstab = ddgauss; + this->m_gausstab = ddgauss; } } @@ -122,10 +126,10 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory int bufferstartx = inputBuffer->getRect()->xmin; int bufferstarty = inputBuffer->getRect()->ymin; - int miny = y - this->rady; - int maxy = y + this->rady; - int minx = x - this->radx; - int maxx = x + this->radx; + int miny = y - this->m_rady; + int maxy = y + this->m_rady; + int minx = x - this->m_radx; + int maxx = x + this->m_radx; miny = max(miny, inputBuffer->getRect()->ymin); minx = max(minx, inputBuffer->getRect()->xmin); maxy = min(maxy, inputBuffer->getRect()->ymax); @@ -135,10 +139,10 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory int step = QualityStepHelper::getStep(); int offsetadd = QualityStepHelper::getOffsetAdd(); for (int ny = miny; ny < maxy; ny += step) { - index = ((ny - y) + this->rady) * (this->radx * 2 + 1) + (minx - x + this->radx); + index = ((ny - y) + this->m_rady) * (this->m_radx * 2 + 1) + (minx - x + this->m_radx); int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); for (int nx = minx; nx < maxx; nx += step) { - const float multiplier = gausstab[index]; + const float multiplier = this->m_gausstab[index]; madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplier); multiplier_accum += multiplier; index += step; @@ -152,8 +156,10 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory void GaussianBokehBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->gausstab; - this->gausstab = NULL; + delete [] this->m_gausstab; + this->m_gausstab = NULL; + + deinitMutex(); } bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -170,15 +176,15 @@ bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, R return true; } else { - if (this->sizeavailable && this->gausstab != NULL) { + if (this->m_sizeavailable && this->m_gausstab != NULL) { newInput.xmin = 0; newInput.ymin = 0; newInput.xmax = this->getWidth(); newInput.ymax = this->getHeight(); } else { - int addx = radx; - int addy = rady; + int addx = this->m_radx; + int addy = this->m_rady; newInput.xmax = input->xmax + addx; newInput.xmin = input->xmin - addx; newInput.ymax = input->ymax + addy; diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h index 616a6539ad4..54dc8caed53 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h @@ -28,8 +28,8 @@ class GaussianBokehBlurOperation : public BlurBaseOperation { private: - float *gausstab; - int radx, rady; + float *m_gausstab; + int m_radx, m_rady; void updateGauss(MemoryBuffer **memoryBuffers); public: diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp index 7a1964a4a63..d18dd17528d 100644 --- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp @@ -29,17 +29,18 @@ extern "C" { GaussianXBlurOperation::GaussianXBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { - this->gausstab = NULL; - this->rad = 0; - + this->m_gausstab = NULL; + this->m_rad = 0; } void *GaussianXBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (!this->sizeavailable) { + lockMutex(); + if (!this->m_sizeavailable) { updateGauss(memoryBuffers); } void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + unlockMutex(); return buffer; } @@ -47,27 +48,29 @@ void GaussianXBlurOperation::initExecution() { BlurBaseOperation::initExecution(); - if (this->sizeavailable) { - float rad = size * this->data->sizex; + initMutex(); + + if (this->m_sizeavailable) { + float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); } } void GaussianXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) { - if (this->gausstab == NULL) { + if (this->m_gausstab == NULL) { updateSize(memoryBuffers); - float rad = size * this->data->sizex; + float rad = this->m_size * this->m_data->sizex; if (rad < 1) rad = 1; - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); - } + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); + } } void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) @@ -82,8 +85,8 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff int miny = y; int maxy = y; - int minx = x - this->rad; - int maxx = x + this->rad; + int minx = x - this->m_rad; + int maxx = x + this->m_rad; miny = max(miny, inputBuffer->getRect()->ymin); minx = max(minx, inputBuffer->getRect()->xmin); maxy = min(maxy, inputBuffer->getRect()->ymax); @@ -94,8 +97,8 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff int offsetadd = getOffsetAdd(); int bufferindex = ((minx - bufferstartx) * 4) + ((miny - bufferstarty) * 4 * bufferwidth); for (int nx = minx; nx < maxx; nx += step) { - index = (nx - x) + this->rad; - const float multiplier = gausstab[index]; + index = (nx - x) + this->m_rad; + const float multiplier = this->m_gausstab[index]; madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier); multiplier_accum += multiplier; bufferindex += offsetadd; @@ -106,8 +109,10 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff void GaussianXBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->gausstab; - this->gausstab = NULL; + delete [] this->m_gausstab; + this->m_gausstab = NULL; + + deinitMutex(); } bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -124,9 +129,9 @@ bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadB return true; } else { - if (this->sizeavailable && this->gausstab != NULL) { - newInput.xmax = input->xmax + rad; - newInput.xmin = input->xmin - rad; + if (this->m_sizeavailable && this->m_gausstab != NULL) { + newInput.xmax = input->xmax + this->m_rad; + newInput.xmin = input->xmin - this->m_rad; newInput.ymax = input->ymax; newInput.ymin = input->ymin; } diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h index 10a8a538391..9b5c2131b74 100644 --- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h @@ -27,8 +27,8 @@ class GaussianXBlurOperation : public BlurBaseOperation { private: - float *gausstab; - int rad; + float *m_gausstab; + int m_rad; void updateGauss(MemoryBuffer **memoryBuffers); public: GaussianXBlurOperation(); diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp index 06c1c78d85a..d2d30da8ddf 100644 --- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp @@ -29,41 +29,47 @@ extern "C" { GaussianYBlurOperation::GaussianYBlurOperation() : BlurBaseOperation(COM_DT_COLOR) { - this->gausstab = NULL; - this->rad = 0; + this->m_gausstab = NULL; + this->m_rad = 0; } void *GaussianYBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (!this->sizeavailable) { + lockMutex(); + if (!this->m_sizeavailable) { updateGauss(memoryBuffers); } void *buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers); + unlockMutex(); return buffer; } void GaussianYBlurOperation::initExecution() { - if (this->sizeavailable) { - float rad = size * this->data->sizey; + BlurBaseOperation::initExecution(); + + initMutex(); + + if (this->m_sizeavailable) { + float rad = this->m_size * this->m_data->sizey; if (rad < 1) rad = 1; - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); } } void GaussianYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) { - if (this->gausstab == NULL) { + if (this->m_gausstab == NULL) { updateSize(memoryBuffers); - float rad = size * this->data->sizey; + float rad = this->m_size * this->m_data->sizey; if (rad < 1) rad = 1; - - this->rad = rad; - this->gausstab = BlurBaseOperation::make_gausstab(rad); + + this->m_rad = rad; + this->m_gausstab = BlurBaseOperation::make_gausstab(rad); } } @@ -77,8 +83,8 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff int bufferstartx = inputBuffer->getRect()->xmin; int bufferstarty = inputBuffer->getRect()->ymin; - int miny = y - this->rad; - int maxy = y + this->rad; + int miny = y - this->m_rad; + int maxy = y + this->m_rad; int minx = x; int maxx = x; miny = max(miny, inputBuffer->getRect()->ymin); @@ -86,12 +92,12 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff maxy = min(maxy, inputBuffer->getRect()->ymax); maxx = min(maxx, inputBuffer->getRect()->xmax); - int step = getStep(); int index; + int step = getStep(); for (int ny = miny; ny < maxy; ny += step) { - index = (ny - y) + this->rad; + index = (ny - y) + this->m_rad; int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth); - const float multiplier = gausstab[index]; + const float multiplier = this->m_gausstab[index]; madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier); multiplier_accum += multiplier; } @@ -101,8 +107,10 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff void GaussianYBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete [] this->gausstab; - this->gausstab = NULL; + delete [] this->m_gausstab; + this->m_gausstab = NULL; + + deinitMutex(); } bool GaussianYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -119,11 +127,11 @@ bool GaussianYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadB return true; } else { - if (this->sizeavailable && this->gausstab != NULL) { + if (this->m_sizeavailable && this->m_gausstab != NULL) { newInput.xmax = input->xmax; newInput.xmin = input->xmin; - newInput.ymax = input->ymax + rad; - newInput.ymin = input->ymin - rad; + newInput.ymax = input->ymax + this->m_rad; + newInput.ymin = input->ymin - this->m_rad; } else { newInput.xmax = this->getWidth(); diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h index e8d362e4c32..f4d40c231dc 100644 --- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h +++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h @@ -27,8 +27,8 @@ class GaussianYBlurOperation : public BlurBaseOperation { private: - float *gausstab; - int rad; + float *m_gausstab; + int m_rad; void updateGauss(MemoryBuffer **memoryBuffers); public: GaussianYBlurOperation(); diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp index 90bdd705a7c..a6678fdecef 100644 --- a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp @@ -27,23 +27,23 @@ GlareBaseOperation::GlareBaseOperation() : SingleThreadedNodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->settings = NULL; + this->m_settings = NULL; } void GlareBaseOperation::initExecution() { SingleThreadedNodeOperation::initExecution(); - this->inputProgram = getInputSocketReader(0); + this->m_inputProgram = getInputSocketReader(0); } void GlareBaseOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; SingleThreadedNodeOperation::deinitExecution(); } MemoryBuffer *GlareBaseOperation::createMemoryBuffer(rcti *rect2, MemoryBuffer **memoryBuffers) { - MemoryBuffer *tile = (MemoryBuffer *)inputProgram->initializeTileData(rect2, memoryBuffers); + MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect2, memoryBuffers); rcti rect; rect.xmin = 0; rect.ymin = 0; @@ -51,7 +51,7 @@ MemoryBuffer *GlareBaseOperation::createMemoryBuffer(rcti *rect2, MemoryBuffer * rect.ymax = getHeight(); MemoryBuffer *result = new MemoryBuffer(NULL, &rect); float *data = result->getBuffer(); - this->generateGlare(data, tile, this->settings); + this->generateGlare(data, tile, this->m_settings); return result; } diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.h b/source/blender/compositor/operations/COM_GlareBaseOperation.h index ac67ac055e9..6104ec7a81e 100644 --- a/source/blender/compositor/operations/COM_GlareBaseOperation.h +++ b/source/blender/compositor/operations/COM_GlareBaseOperation.h @@ -41,12 +41,12 @@ private: /** * @brief Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; /** * @brief settings of the glare node. */ - NodeGlare *settings; + NodeGlare *m_settings; public: /** * Initialize the execution @@ -59,7 +59,7 @@ public: void deinitExecution(); void setGlareSettings(NodeGlare *settings) { - this->settings = settings; + this->m_settings = settings; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp index 694aa26bcde..cb4c27a4c80 100644 --- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp @@ -120,8 +120,8 @@ static void FHT(fREAL *data, unsigned int M, unsigned int inverse) } //------------------------------------------------------------------------------ /* 2D Fast Hartley Transform, Mx/My -> log2 of width/height, - nzp -> the row where zero pad data starts, - inverse -> see above */ + * nzp -> the row where zero pad data starts, + * inverse -> see above */ static void FHT2D(fREAL *data, unsigned int Mx, unsigned int My, unsigned int nzp, unsigned int inverse) { diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.h b/source/blender/compositor/operations/COM_GlareFogGlowOperation.h index 5737a6a1ff0..1231185a21a 100644 --- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.h +++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.h @@ -28,8 +28,7 @@ class GlareFogGlowOperation : public GlareBaseOperation { public: - GlareFogGlowOperation() : GlareBaseOperation() { - } + GlareFogGlowOperation() : GlareBaseOperation() {} protected: void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings); }; diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.h b/source/blender/compositor/operations/COM_GlareGhostOperation.h index 2ee85cc4543..7ce1048efe9 100644 --- a/source/blender/compositor/operations/COM_GlareGhostOperation.h +++ b/source/blender/compositor/operations/COM_GlareGhostOperation.h @@ -28,8 +28,7 @@ class GlareGhostOperation : public GlareBaseOperation { public: - GlareGhostOperation() : GlareBaseOperation() { - } + GlareGhostOperation() : GlareBaseOperation() {} protected: void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings); }; diff --git a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h index a12d1191a1a..440f3ba147a 100644 --- a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h +++ b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h @@ -28,8 +28,7 @@ class GlareSimpleStarOperation : public GlareBaseOperation { public: - GlareSimpleStarOperation() : GlareBaseOperation() { - } + GlareSimpleStarOperation() : GlareBaseOperation() {} protected: void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings); }; diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.h b/source/blender/compositor/operations/COM_GlareStreaksOperation.h index 6520a05b44f..e629ac11623 100644 --- a/source/blender/compositor/operations/COM_GlareStreaksOperation.h +++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.h @@ -28,8 +28,7 @@ class GlareStreaksOperation : public GlareBaseOperation { public: - GlareStreaksOperation() : GlareBaseOperation() { - } + GlareStreaksOperation() : GlareBaseOperation() {} protected: void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings); }; diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp index f9b2ec2b32d..6d8c567c1b5 100644 --- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp @@ -27,26 +27,26 @@ GlareThresholdOperation::GlareThresholdOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR, COM_SC_FIT); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void GlareThresholdOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { NodeOperation::determineResolution(resolution, preferredResolution); - resolution[0] = resolution[0] / (1 << settings->quality); - resolution[1] = resolution[1] / (1 << settings->quality); + resolution[0] = resolution[0] / (1 << this->m_settings->quality); + resolution[1] = resolution[1] / (1 << this->m_settings->quality); } void GlareThresholdOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void GlareThresholdOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - const float threshold = settings->threshold; + const float threshold = this->m_settings->threshold; - this->inputProgram->read(color, x, y, sampler, inputBuffers); + this->m_inputProgram->read(color, x, y, sampler, inputBuffers); if (rgb_to_luma_y(color) >= threshold) { color[0] -= threshold, color[1] -= threshold, color[2] -= threshold; color[0] = MAX2(color[0], 0.0f); @@ -60,5 +60,5 @@ void GlareThresholdOperation::executePixel(float *color, float x, float y, Pixel void GlareThresholdOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.h b/source/blender/compositor/operations/COM_GlareThresholdOperation.h index 70692565e27..d89f3a0f29d 100644 --- a/source/blender/compositor/operations/COM_GlareThresholdOperation.h +++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.h @@ -30,12 +30,12 @@ private: /** * @brief Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; /** * @brief settings of the glare node. */ - NodeGlare *settings; + NodeGlare *m_settings; public: GlareThresholdOperation(); @@ -55,7 +55,7 @@ public: void deinitExecution(); void setGlareSettings(NodeGlare *settings) { - this->settings = settings; + this->m_settings = settings; } void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp index b8e46e2d0be..02914487072 100644 --- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp +++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp @@ -37,30 +37,30 @@ HueSaturationValueCorrectOperation::HueSaturationValueCorrectOperation() : Curve this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void HueSaturationValueCorrectOperation::initExecution() { CurveBaseOperation::initExecution(); - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void HueSaturationValueCorrectOperation::executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float hsv[4], f; - this->inputProgram->read(hsv, x, y, sampler, inputBuffers); + this->m_inputProgram->read(hsv, x, y, sampler, inputBuffers); /* adjust hue, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(this->curveMapping, 0, hsv[0]); + f = curvemapping_evaluateF(this->m_curveMapping, 0, hsv[0]); hsv[0] += f - 0.5f; /* adjust saturation, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(this->curveMapping, 1, hsv[0]); + f = curvemapping_evaluateF(this->m_curveMapping, 1, hsv[0]); hsv[1] *= (f * 2.f); /* adjust value, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(this->curveMapping, 2, hsv[0]); + f = curvemapping_evaluateF(this->m_curveMapping, 2, hsv[0]); hsv[2] *= (f * 2.f); hsv[0] = hsv[0] - floorf(hsv[0]); /* mod 1.0 */ @@ -74,5 +74,5 @@ void HueSaturationValueCorrectOperation::executePixel(float *output, float x, fl void HueSaturationValueCorrectOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h index 5ede0491773..7ae5f53e370 100644 --- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h +++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h @@ -30,7 +30,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; public: HueSaturationValueCorrectOperation(); diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.cpp b/source/blender/compositor/operations/COM_IDMaskOperation.cpp index d02367088d7..c84124368be 100644 --- a/source/blender/compositor/operations/COM_IDMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_IDMaskOperation.cpp @@ -26,24 +26,24 @@ IDMaskOperation::IDMaskOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void IDMaskOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void IDMaskOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputValue[4]; - this->inputProgram->read(inputValue, x, y, sampler, inputBuffers); - const float a = (inputValue[0] == this->objectIndex) ? 1.0f : 0.0f; + this->m_inputProgram->read(inputValue, x, y, sampler, inputBuffers); + const float a = (inputValue[0] == this->m_objectIndex) ? 1.0f : 0.0f; color[0] = a; } void IDMaskOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.h b/source/blender/compositor/operations/COM_IDMaskOperation.h index 229e1b2dd82..23e8ec704e8 100644 --- a/source/blender/compositor/operations/COM_IDMaskOperation.h +++ b/source/blender/compositor/operations/COM_IDMaskOperation.h @@ -30,9 +30,9 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; - float objectIndex; + float m_objectIndex; public: IDMaskOperation(); @@ -51,7 +51,7 @@ public: */ void deinitExecution(); - void setObjectIndex(float objectIndex) { this->objectIndex = objectIndex; } + void setObjectIndex(float objectIndex) { this->m_objectIndex = objectIndex; } }; #endif diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp index 9dbe8419daa..eb2eaa8167a 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.cpp +++ b/source/blender/compositor/operations/COM_ImageOperation.cpp @@ -38,15 +38,15 @@ extern "C" { BaseImageOperation::BaseImageOperation() : NodeOperation() { - this->image = NULL; - this->buffer = NULL; - this->imageBuffer = NULL; - this->imageUser = NULL; - this->imagewidth = 0; - this->imageheight = 0; - this->framenumber = 0; - this->depthBuffer = NULL; - this->numberOfChannels = 0; + this->m_image = NULL; + this->m_buffer = NULL; + this->m_imageBuffer = NULL; + this->m_imageUser = NULL; + this->m_imagewidth = 0; + this->m_imageheight = 0; + this->m_framenumber = 0; + this->m_depthBuffer = NULL; + this->m_numberOfChannels = 0; } ImageOperation::ImageOperation() : BaseImageOperation() { @@ -65,7 +65,7 @@ ImBuf *BaseImageOperation::getImBuf() { ImBuf *ibuf; - ibuf = BKE_image_get_ibuf(this->image, this->imageUser); + ibuf = BKE_image_get_ibuf(this->m_image, this->m_imageUser); if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) { return NULL; } @@ -80,19 +80,19 @@ ImBuf *BaseImageOperation::getImBuf() void BaseImageOperation::initExecution() { ImBuf *stackbuf = getImBuf(); - this->buffer = stackbuf; + this->m_buffer = stackbuf; if (stackbuf) { - this->imageBuffer = stackbuf->rect_float; - this->depthBuffer = stackbuf->zbuf_float; - this->imagewidth = stackbuf->x; - this->imageheight = stackbuf->y; - this->numberOfChannels = stackbuf->channels; + this->m_imageBuffer = stackbuf->rect_float; + this->m_depthBuffer = stackbuf->zbuf_float; + this->m_imagewidth = stackbuf->x; + this->m_imageheight = stackbuf->y; + this->m_numberOfChannels = stackbuf->channels; } } void BaseImageOperation::deinitExecution() { - this->imageBuffer = NULL; + this->m_imageBuffer = NULL; } void BaseImageOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) @@ -110,22 +110,19 @@ void BaseImageOperation::determineResolution(unsigned int resolution[], unsigned void ImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if (this->imageBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { - color[0] = 0.0f; - color[1] = 0.0f; - color[2] = 0.0f; - color[3] = 0.0f; + if (this->m_imageBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { + zero_v4(color); } else { switch (sampler) { case COM_PS_NEAREST: - neareast_interpolation_color(this->buffer, NULL, color, x, y); + neareast_interpolation_color(this->m_buffer, NULL, color, x, y); break; case COM_PS_BILINEAR: - bilinear_interpolation_color(this->buffer, NULL, color, x, y); + bilinear_interpolation_color(this->m_buffer, NULL, color, x, y); break; case COM_PS_BICUBIC: - bicubic_interpolation_color(this->buffer, NULL, color, x, y); + bicubic_interpolation_color(this->m_buffer, NULL, color, x, y); break; } } @@ -135,20 +132,20 @@ void ImageAlphaOperation::executePixel(float *color, float x, float y, PixelSamp { float tempcolor[4]; - if (this->imageBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { + if (this->m_imageBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { color[0] = 0.0f; } else { tempcolor[3] = 1.0f; switch (sampler) { case COM_PS_NEAREST: - neareast_interpolation_color(this->buffer, NULL, tempcolor, x, y); + neareast_interpolation_color(this->m_buffer, NULL, tempcolor, x, y); break; case COM_PS_BILINEAR: - bilinear_interpolation_color(this->buffer, NULL, tempcolor, x, y); + bilinear_interpolation_color(this->m_buffer, NULL, tempcolor, x, y); break; case COM_PS_BICUBIC: - bicubic_interpolation_color(this->buffer, NULL, tempcolor, x, y); + bicubic_interpolation_color(this->m_buffer, NULL, tempcolor, x, y); break; } color[0] = tempcolor[3]; @@ -157,11 +154,11 @@ void ImageAlphaOperation::executePixel(float *color, float x, float y, PixelSamp void ImageDepthOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if (this->depthBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { + if (this->m_depthBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { color[0] = 0.0f; } else { - int offset = y * width + x; - color[0] = this->depthBuffer[offset]; + int offset = y * this->m_width + x; + color[0] = this->m_depthBuffer[offset]; } } diff --git a/source/blender/compositor/operations/COM_ImageOperation.h b/source/blender/compositor/operations/COM_ImageOperation.h index a4645c9d504..c87b06b9c4d 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.h +++ b/source/blender/compositor/operations/COM_ImageOperation.h @@ -40,15 +40,15 @@ extern "C" { */ class BaseImageOperation : public NodeOperation { protected: - ImBuf *buffer; - Image *image; - ImageUser *imageUser; - float *imageBuffer; - float *depthBuffer; - int imageheight; - int imagewidth; - int framenumber; - int numberOfChannels; + ImBuf *m_buffer; + Image *m_image; + ImageUser *m_imageUser; + float *m_imageBuffer; + float *m_depthBuffer; + int m_imageheight; + int m_imagewidth; + int m_framenumber; + int m_numberOfChannels; BaseImageOperation(); /** @@ -62,10 +62,10 @@ public: void initExecution(); void deinitExecution(); - void setImage(Image *image) { this->image = image; } - void setImageUser(ImageUser *imageuser) { this->imageUser = imageuser; } + void setImage(Image *image) { this->m_image = image; } + void setImageUser(ImageUser *imageuser) { this->m_imageUser = imageuser; } - void setFramenumber(int framenumber) { this->framenumber = framenumber; } + void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } }; class ImageOperation : public BaseImageOperation { public: diff --git a/source/blender/compositor/operations/COM_InvertOperation.cpp b/source/blender/compositor/operations/COM_InvertOperation.cpp index 6142959a12e..9e9c2522d66 100644 --- a/source/blender/compositor/operations/COM_InvertOperation.cpp +++ b/source/blender/compositor/operations/COM_InvertOperation.cpp @@ -27,29 +27,29 @@ InvertOperation::InvertOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputValueProgram = NULL; - this->inputColorProgram = NULL; - this->color = true; - this->alpha = false; + this->m_inputValueProgram = NULL; + this->m_inputColorProgram = NULL; + this->m_color = true; + this->m_alpha = false; setResolutionInputSocketIndex(1); } void InvertOperation::initExecution() { - this->inputValueProgram = this->getInputSocketReader(0); - this->inputColorProgram = this->getInputSocketReader(1); + this->m_inputValueProgram = this->getInputSocketReader(0); + this->m_inputColorProgram = this->getInputSocketReader(1); } void InvertOperation::executePixel(float *out, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputValue[4]; float inputColor[4]; - this->inputValueProgram->read(inputValue, x, y, sampler, inputBuffers); - this->inputColorProgram->read(inputColor, x, y, sampler, inputBuffers); + this->m_inputValueProgram->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColorProgram->read(inputColor, x, y, sampler, inputBuffers); const float value = inputValue[0]; const float invertedValue = 1.0f - value; - if (color) { + if (this->m_color) { out[0] = (1.0f - inputColor[0]) * value + inputColor[0] * invertedValue; out[1] = (1.0f - inputColor[1]) * value + inputColor[1] * invertedValue; out[2] = (1.0f - inputColor[2]) * value + inputColor[2] * invertedValue; @@ -58,7 +58,7 @@ void InvertOperation::executePixel(float *out, float x, float y, PixelSampler sa copy_v3_v3(out, inputColor); } - if (alpha) + if (this->m_alpha) out[3] = (1.0f - inputColor[3]) * value + inputColor[3] * invertedValue; else out[3] = inputColor[3]; @@ -67,7 +67,7 @@ void InvertOperation::executePixel(float *out, float x, float y, PixelSampler sa void InvertOperation::deinitExecution() { - this->inputValueProgram = NULL; - this->inputColorProgram = NULL; + this->m_inputValueProgram = NULL; + this->m_inputColorProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_InvertOperation.h b/source/blender/compositor/operations/COM_InvertOperation.h index 48432aecdd0..f00a3fb739d 100644 --- a/source/blender/compositor/operations/COM_InvertOperation.h +++ b/source/blender/compositor/operations/COM_InvertOperation.h @@ -30,11 +30,11 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputValueProgram; - SocketReader *inputColorProgram; + SocketReader *m_inputValueProgram; + SocketReader *m_inputColorProgram; - bool alpha; - bool color; + bool m_alpha; + bool m_color; public: InvertOperation(); @@ -54,7 +54,7 @@ public: */ void deinitExecution(); - void setColor(bool color) { this->color = color; } - void setAlpha(bool alpha) { this->alpha = alpha; } + void setColor(bool color) { this->m_color = color; } + void setAlpha(bool alpha) { this->m_alpha = alpha; } }; #endif diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp index 9c7a33c1327..3285bd32039 100644 --- a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp @@ -33,7 +33,8 @@ KeyingBlurOperation::KeyingBlurOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->size = 0.0f; + this->m_size = 0; + this->m_axis = BLUR_AXIS_X; this->setComplex(true); } @@ -53,16 +54,28 @@ void KeyingBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer int bufferWidth = inputBuffer->getWidth(); int bufferHeight = inputBuffer->getHeight(); - int i, j, count = 0; + int i, count = 0; float average = 0.0f; - for (i = -this->size + 1; i < this->size; i++) { - for (j = -this->size + 1; j < this->size; j++) { - int cx = x + j, cy = y + i; + if (this->m_axis == 0) { + for (i = -this->m_size + 1; i < this->m_size; i++) { + int cx = x + i; - if (cx >= 0 && cx < bufferWidth && cy >= 0 && cy < bufferHeight) { - int bufferIndex = (cy * bufferWidth + cx) * 4; + if (cx >= 0 && cx < bufferWidth) { + int bufferIndex = (y * bufferWidth + cx) * 4; + + average += buffer[bufferIndex]; + count++; + } + } + } + else { + for (i = -this->m_size + 1; i < this->m_size; i++) { + int cy = y + i; + + if (cy >= 0 && cy < bufferHeight) { + int bufferIndex = (cy * bufferWidth + x) * 4; average += buffer[bufferIndex]; count++; @@ -79,10 +92,18 @@ bool KeyingBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuff { rcti newInput; - newInput.xmin = 0; - newInput.ymin = 0; - newInput.xmax = this->getWidth(); - newInput.ymax = this->getHeight(); + if (this->m_axis == BLUR_AXIS_X) { + newInput.xmin = input->xmin - this->m_size; + newInput.ymin = input->ymin; + newInput.xmax = input->xmax + this->m_size; + newInput.ymax = input->ymax; + } + else { + newInput.xmin = input->xmin; + newInput.ymin = input->ymin - this->m_size; + newInput.xmax = input->xmax; + newInput.ymax = input->ymax + this->m_size; + } return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.h b/source/blender/compositor/operations/COM_KeyingBlurOperation.h index 2848f260cbd..6e08712bf39 100644 --- a/source/blender/compositor/operations/COM_KeyingBlurOperation.h +++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.h @@ -31,12 +31,19 @@ */ class KeyingBlurOperation : public NodeOperation { protected: - int size; + int m_size; + int m_axis; public: + enum BlurAxis { + BLUR_AXIS_X = 0, + BLUR_AXIS_Y = 1 + }; + KeyingBlurOperation(); - void setSize(float value) {this->size = value;} + void setSize(int value) {this->m_size = value;} + void setAxis(int value) {this->m_axis = value;} void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.cpp b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp index 2c9949f2b4b..8f7d7fbf625 100644 --- a/source/blender/compositor/operations/COM_KeyingClipOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp @@ -33,13 +33,13 @@ KeyingClipOperation::KeyingClipOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->kernelRadius = 3; - this->kernelTolerance = 0.1f; + this->m_kernelRadius = 3; + this->m_kernelTolerance = 0.1f; - this->clipBlack = 0.0f; - this->clipWhite = 1.0f; + this->m_clipBlack = 0.0f; + this->m_clipWhite = 1.0f; - this->isEdgeMatte = false; + this->m_isEdgeMatte = false; this->setComplex(true); } @@ -53,8 +53,8 @@ void *KeyingClipOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB void KeyingClipOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { - const int delta = this->kernelRadius; - const float tolerance = this->kernelTolerance; + const int delta = this->m_kernelRadius; + const float tolerance = this->m_kernelTolerance; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; float *buffer = inputBuffer->getBuffer(); @@ -90,7 +90,7 @@ void KeyingClipOperation::executePixel(float *color, int x, int y, MemoryBuffer ok = count >= (float) totalCount * 0.9f; - if (this->isEdgeMatte) { + if (this->m_isEdgeMatte) { if (ok) color[0] = 0.0f; else @@ -100,12 +100,12 @@ void KeyingClipOperation::executePixel(float *color, int x, int y, MemoryBuffer color[0] = value; if (ok) { - if (color[0] < this->clipBlack) + if (color[0] < this->m_clipBlack) color[0] = 0.0f; - else if (color[0] >= this->clipWhite) + else if (color[0] >= this->m_clipWhite) color[0] = 1.0f; else - color[0] = (color[0] - this->clipBlack) / (this->clipWhite - this->clipBlack); + color[0] = (color[0] - this->m_clipBlack) / (this->m_clipWhite - this->m_clipBlack); } } } @@ -114,10 +114,10 @@ bool KeyingClipOperation::determineDependingAreaOfInterest(rcti *input, ReadBuff { rcti newInput; - newInput.xmin = 0; - newInput.ymin = 0; - newInput.xmax = this->getWidth(); - newInput.ymax = this->getHeight(); + newInput.xmin = input->xmin - this->m_kernelRadius; + newInput.ymin = input->ymin - this->m_kernelRadius; + newInput.xmax = input->xmax + this->m_kernelRadius; + newInput.ymax = input->ymax + this->m_kernelRadius; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.h b/source/blender/compositor/operations/COM_KeyingClipOperation.h index 9c7b23b0160..1a8e71a306b 100644 --- a/source/blender/compositor/operations/COM_KeyingClipOperation.h +++ b/source/blender/compositor/operations/COM_KeyingClipOperation.h @@ -27,27 +27,27 @@ #include "COM_NodeOperation.h" /** - * Class with implementation of black/white clipping for keying node - */ + * Class with implementation of black/white clipping for keying node + */ class KeyingClipOperation : public NodeOperation { protected: - float clipBlack; - float clipWhite; + float m_clipBlack; + float m_clipWhite; - int kernelRadius; - float kernelTolerance; + int m_kernelRadius; + float m_kernelTolerance; - bool isEdgeMatte; + bool m_isEdgeMatte; public: KeyingClipOperation(); - void setClipBlack(float value) {this->clipBlack = value;} - void setClipWhite(float value) {this->clipWhite = value;} + void setClipBlack(float value) {this->m_clipBlack = value;} + void setClipWhite(float value) {this->m_clipWhite = value;} - void setKernelRadius(int value) {this->kernelRadius = value;} - void setKernelTolerance(float value) {this->kernelTolerance = value;} + void setKernelRadius(int value) {this->m_kernelRadius = value;} + void setKernelTolerance(float value) {this->m_kernelTolerance = value;} - void setIsEdgeMatte(bool value) {this->isEdgeMatte = value;} + void setIsEdgeMatte(bool value) {this->m_isEdgeMatte = value;} void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp index 04523384653..081d9f723e8 100644 --- a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp @@ -46,22 +46,22 @@ KeyingDespillOperation::KeyingDespillOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->despillFactor = 0.5f; + this->m_despillFactor = 0.5f; - this->pixelReader = NULL; - this->screenReader = NULL; + this->m_pixelReader = NULL; + this->m_screenReader = NULL; } void KeyingDespillOperation::initExecution() { - this->pixelReader = this->getInputSocketReader(0); - this->screenReader = this->getInputSocketReader(1); + this->m_pixelReader = this->getInputSocketReader(0); + this->m_screenReader = this->getInputSocketReader(1); } void KeyingDespillOperation::deinitExecution() { - this->pixelReader = NULL; - this->screenReader = NULL; + this->m_pixelReader = NULL; + this->m_screenReader = NULL; } void KeyingDespillOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -69,8 +69,8 @@ void KeyingDespillOperation::executePixel(float *color, float x, float y, PixelS float pixelColor[4]; float screenColor[4]; - this->pixelReader->read(pixelColor, x, y, sampler, inputBuffers); - this->screenReader->read(screenColor, x, y, sampler, inputBuffers); + this->m_pixelReader->read(pixelColor, x, y, sampler, inputBuffers); + this->m_screenReader->read(screenColor, x, y, sampler, inputBuffers); int screen_primary_channel = get_pixel_primary_channel(screenColor); float average_value, amount; @@ -83,7 +83,7 @@ void KeyingDespillOperation::executePixel(float *color, float x, float y, PixelS color[2] = pixelColor[2]; color[3] = pixelColor[3]; - if (this->despillFactor * amount > 0) { - color[screen_primary_channel] = pixelColor[screen_primary_channel] - this->despillFactor * amount; + if (this->m_despillFactor * amount > 0) { + color[screen_primary_channel] = pixelColor[screen_primary_channel] - this->m_despillFactor * amount; } } diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.h b/source/blender/compositor/operations/COM_KeyingDespillOperation.h index 92a1415a1f0..4fea9b578a1 100644 --- a/source/blender/compositor/operations/COM_KeyingDespillOperation.h +++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.h @@ -27,13 +27,13 @@ #include "COM_NodeOperation.h" /** - * Class with implementation of keying despill node - */ + * Class with implementation of keying despill node + */ class KeyingDespillOperation : public NodeOperation { protected: - SocketReader *pixelReader; - SocketReader *screenReader; - float despillFactor; + SocketReader *m_pixelReader; + SocketReader *m_screenReader; + float m_despillFactor; public: KeyingDespillOperation(); @@ -41,7 +41,7 @@ public: void initExecution(); void deinitExecution(); - void setDespillFactor(float value) {this->despillFactor = value;} + void setDespillFactor(float value) {this->m_despillFactor = value;} void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]); }; diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp index 0a450cc3bf8..e92e5c84c2d 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp @@ -60,28 +60,28 @@ KeyingOperation::KeyingOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->screenBalance = 0.5f; + this->m_screenBalance = 0.5f; - this->pixelReader = NULL; - this->screenReader = NULL; - this->garbageReader = NULL; - this->coreReader = NULL; + this->m_pixelReader = NULL; + this->m_screenReader = NULL; + this->m_garbageReader = NULL; + this->m_coreReader = NULL; } void KeyingOperation::initExecution() { - this->pixelReader = this->getInputSocketReader(0); - this->screenReader = this->getInputSocketReader(1); - this->garbageReader = this->getInputSocketReader(2); - this->coreReader = this->getInputSocketReader(3); + this->m_pixelReader = this->getInputSocketReader(0); + this->m_screenReader = this->getInputSocketReader(1); + this->m_garbageReader = this->getInputSocketReader(2); + this->m_coreReader = this->getInputSocketReader(3); } void KeyingOperation::deinitExecution() { - this->pixelReader = NULL; - this->screenReader = NULL; - this->garbageReader = NULL; - this->coreReader = NULL; + this->m_pixelReader = NULL; + this->m_screenReader = NULL; + this->m_garbageReader = NULL; + this->m_coreReader = NULL; } void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -91,41 +91,48 @@ void KeyingOperation::executePixel(float *color, float x, float y, PixelSampler float garbageValue[4]; float coreValue[4]; - this->pixelReader->read(pixelColor, x, y, sampler, inputBuffers); - this->screenReader->read(screenColor, x, y, sampler, inputBuffers); - this->garbageReader->read(garbageValue, x, y, sampler, inputBuffers); - this->coreReader->read(coreValue, x, y, sampler, inputBuffers); + this->m_pixelReader->read(pixelColor, x, y, sampler, inputBuffers); + this->m_screenReader->read(screenColor, x, y, sampler, inputBuffers); + this->m_garbageReader->read(garbageValue, x, y, sampler, inputBuffers); + this->m_coreReader->read(coreValue, x, y, sampler, inputBuffers); int primary_channel = get_pixel_primary_channel(screenColor); - float saturation = get_pixel_saturation(pixelColor, this->screenBalance, primary_channel); - float screen_saturation = get_pixel_saturation(screenColor, this->screenBalance, primary_channel); - - if (saturation < 0) { + if (pixelColor[primary_channel] > 1.0f) { + /* overexposure doesn't happen on screen itself and usually happens + * on light sources in the shot, this need to be checked separately + * because saturation and falloff calculation is based on the fact + * that pixels are not overexposured + */ color[0] = 1.0f; } - else if (saturation >= screen_saturation) { - color[0] = 0.0f; - } else { - float distance = 1.0f - saturation / screen_saturation; - - color[0] = distance; + float saturation = get_pixel_saturation(pixelColor, this->m_screenBalance, primary_channel); + float screen_saturation = get_pixel_saturation(screenColor, this->m_screenBalance, primary_channel); + + if (saturation < 0) { + /* means main channel of pixel is different from screen, + * assume this is completely a foreground + */ + color[0] = 1.0f; + } + else if (saturation >= screen_saturation) { + /* matched main channels and higher saturation on pixel + * is treated as completely background + */ + color[0] = 0.0f; + } + else { + /* nice alpha falloff on edges */ + float distance = 1.0f - saturation / screen_saturation; + + color[0] = distance; + } } - color[0] *= (1.0f - garbageValue[0]); + /* apply garbage matte */ + color[0] = MIN2(color[0], 1.0f - garbageValue[0]); + /* apply core matte */ color[0] = MAX2(color[0], coreValue[0]); } - -bool KeyingOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) -{ - rcti newInput; - - newInput.xmin = 0; - newInput.ymin = 0; - newInput.xmax = this->getWidth(); - newInput.ymax = this->getHeight(); - - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); -} diff --git a/source/blender/compositor/operations/COM_KeyingOperation.h b/source/blender/compositor/operations/COM_KeyingOperation.h index 8d0e7851ee5..736db54850a 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.h +++ b/source/blender/compositor/operations/COM_KeyingOperation.h @@ -32,16 +32,16 @@ #include "BLI_listbase.h" /** - * Class with implementation of keying node - */ + * Class with implementation of keying node + */ class KeyingOperation : public NodeOperation { protected: - SocketReader *pixelReader; - SocketReader *screenReader; - SocketReader *garbageReader; - SocketReader *coreReader; + SocketReader *m_pixelReader; + SocketReader *m_screenReader; + SocketReader *m_garbageReader; + SocketReader *m_coreReader; - float screenBalance; + float m_screenBalance; public: KeyingOperation(); @@ -49,11 +49,9 @@ public: void initExecution(); void deinitExecution(); - void setScreenBalance(float value) {this->screenBalance = value;} + void setScreenBalance(float value) {this->m_screenBalance = value;} void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]); - - bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); }; #endif diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp index 9f7b69636ab..53572162b9e 100644 --- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp @@ -42,22 +42,22 @@ extern "C" { KeyingScreenOperation::KeyingScreenOperation() : NodeOperation() { this->addOutputSocket(COM_DT_COLOR); - this->movieClip = NULL; - this->framenumber = 0; - this->trackingObject[0] = 0; + this->m_movieClip = NULL; + this->m_framenumber = 0; + this->m_trackingObject[0] = 0; setComplex(true); } void KeyingScreenOperation::initExecution() { initMutex(); - this->cachedTriangulation = NULL; + this->m_cachedTriangulation = NULL; } void KeyingScreenOperation::deinitExecution() { - if (this->cachedTriangulation) { - TriangulationData *triangulation = cachedTriangulation; + if (this->m_cachedTriangulation) { + TriangulationData *triangulation = this->m_cachedTriangulation; if (triangulation->triangulated_points) MEM_freeN(triangulation->triangulated_points); @@ -65,9 +65,12 @@ void KeyingScreenOperation::deinitExecution() if (triangulation->triangles) MEM_freeN(triangulation->triangles); - MEM_freeN(this->cachedTriangulation); + if (triangulation->triangles_AABB) + MEM_freeN(triangulation->triangles_AABB); - this->cachedTriangulation = NULL; + MEM_freeN(this->m_cachedTriangulation); + + this->m_cachedTriangulation = NULL; } } @@ -75,7 +78,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri { MovieClipUser user = {0}; TriangulationData *triangulation; - MovieTracking *tracking = &movieClip->tracking; + MovieTracking *tracking = &this->m_movieClip->tracking; MovieTrackingTrack *track; VoronoiSite *sites; ImBuf *ibuf; @@ -85,10 +88,10 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri int i; int width = this->getWidth(); int height = this->getHeight(); - int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->movieClip, framenumber); + int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip, this->m_framenumber); - if (this->trackingObject[0]) { - MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->trackingObject); + if (this->m_trackingObject[0]) { + MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->m_trackingObject); if (!object) return NULL; @@ -98,13 +101,20 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri else tracksbase = BKE_tracking_get_active_tracks(tracking); - sites_total = BLI_countlist(tracksbase); + /* count sites */ + for (track = (MovieTrackingTrack *) tracksbase->first, sites_total = 0; track; track = track->next) { + MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame); + + if ((marker->flag & MARKER_DISABLED) == 0) { + sites_total++; + } + } if (!sites_total) return NULL; BKE_movieclip_user_set_frame(&user, clip_frame); - ibuf = BKE_movieclip_get_ibuf(movieClip, &user); + ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, &user); if (!ibuf) return NULL; @@ -113,13 +123,19 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri sites = (VoronoiSite *) MEM_callocN(sizeof(VoronoiSite) * sites_total, "keyingscreen voronoi sites"); track = (MovieTrackingTrack *) tracksbase->first; - i = 0; - while (track) { - VoronoiSite *site = &sites[i]; + for (track = (MovieTrackingTrack *) tracksbase->first, i = 0; track; track = track->next, i++) { MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame); - ImBuf *pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE); + VoronoiSite *site; + ImBuf *pattern_ibuf; int j; + if (marker->flag & MARKER_DISABLED) + continue; + + site = &sites[i]; + + pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE); + zero_v3(site->color); for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) { if (pattern_ibuf->rect_float) { @@ -139,9 +155,6 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri site->co[0] = marker->pos[0] * width; site->co[1] = marker->pos[1] * height; - - track = track->next; - i++; } IMB_freeImBuf(ibuf); @@ -155,24 +168,100 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri MEM_freeN(sites); BLI_freelistN(&edges); + if (triangulation->triangles_total) { + rctf *rect; + rect = triangulation->triangles_AABB = + (rctf *) MEM_callocN(sizeof(rctf) * triangulation->triangles_total, "voronoi triangulation AABB"); + + for (i = 0; i < triangulation->triangles_total; i++, rect++) { + int *triangle = triangulation->triangles[i]; + VoronoiTriangulationPoint *a = &triangulation->triangulated_points[triangle[0]], + *b = &triangulation->triangulated_points[triangle[1]], + *c = &triangulation->triangulated_points[triangle[2]]; + + float min[2], max[2]; + + INIT_MINMAX2(min, max); + + DO_MINMAX2(a->co, min, max); + DO_MINMAX2(b->co, min, max); + DO_MINMAX2(c->co, min, max); + + rect->xmin = min[0]; + rect->ymin = min[1]; + + rect->xmax = max[0]; + rect->ymax = max[1]; + } + } + return triangulation; } void *KeyingScreenOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->movieClip == NULL) + TileData *tile_data; + TriangulationData *triangulation; + int triangles_allocated = 0; + int chunk_size = 20; + int i; + rctf rect_float; + + if (this->m_movieClip == NULL) return NULL; - if (this->cachedTriangulation) - return this->cachedTriangulation; + if (!this->m_cachedTriangulation) { + lockMutex(); + if (this->m_cachedTriangulation == NULL) { + this->m_cachedTriangulation = buildVoronoiTriangulation(); + } + unlockMutex(); + } + + triangulation = this->m_cachedTriangulation; + + if (!triangulation) + return NULL; + + BLI_init_rctf(&rect_float, rect->xmin, rect->xmax, rect->ymin, rect->ymax); + + tile_data = (TileData *) MEM_callocN(sizeof(TileData), "keying screen tile data"); + + for (i = 0; i < triangulation->triangles_total; i++) { + bool ok = BLI_isect_rctf(&rect_float, &triangulation->triangles_AABB[i], NULL); + + if (ok) { + tile_data->triangles_total++; + + if (tile_data->triangles_total > triangles_allocated) { + if (!tile_data->triangles) { + tile_data->triangles = (int *) MEM_mallocN(sizeof(int) * chunk_size, + "keying screen tile triangles chunk"); + } + else { + tile_data->triangles = (int *) MEM_reallocN(tile_data->triangles, + sizeof(int) * (triangles_allocated + chunk_size)); + } - lockMutex(); - if (this->cachedTriangulation == NULL) { - this->cachedTriangulation = buildVoronoiTriangulation(); + triangles_allocated += chunk_size; + } + + tile_data->triangles[tile_data->triangles_total - 1] = i; + } } - unlockMutex(); - return this->cachedTriangulation; + return tile_data; +} + +void KeyingScreenOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) +{ + TileData *tile_data = (TileData *) data; + + if (tile_data->triangles) { + MEM_freeN(tile_data->triangles); + } + + MEM_freeN(tile_data); } void KeyingScreenOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) @@ -180,13 +269,13 @@ void KeyingScreenOperation::determineResolution(unsigned int resolution[], unsig resolution[0] = 0; resolution[1] = 0; - if (this->movieClip) { + if (this->m_movieClip) { MovieClipUser user = {0}; int width, height; - int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->movieClip, framenumber); + int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip, this->m_framenumber); BKE_movieclip_user_set_frame(&user, clip_frame); - BKE_movieclip_get_size(this->movieClip, &user, &width, &height); + BKE_movieclip_get_size(this->m_movieClip, &user, &width, &height); resolution[0] = width; resolution[1] = height; @@ -200,21 +289,29 @@ void KeyingScreenOperation::executePixel(float *color, int x, int y, MemoryBuffe color[2] = 0.0f; color[3] = 1.0f; - if (this->movieClip && data) { - TriangulationData *triangulation = (TriangulationData *) data; + if (this->m_movieClip && data) { + TriangulationData *triangulation = this->m_cachedTriangulation; + TileData *tile_data = (TileData *) data; int i; - for (i = 0; i < triangulation->triangles_total; i++) { - int *triangle = triangulation->triangles[i]; - VoronoiTriangulationPoint *a = &triangulation->triangulated_points[triangle[0]], - *b = &triangulation->triangulated_points[triangle[1]], - *c = &triangulation->triangulated_points[triangle[2]]; - float co[2] = {(float) x, (float) y}, w[3]; - - if (barycentric_coords_v2(a->co, b->co, c->co, co, w)) { - if (barycentric_inside_triangle_v2(w)) { - color[0] += a->color[0] * w[0] + b->color[0] * w[1] + c->color[0] * w[2]; - color[1] += a->color[1] * w[0] + b->color[1] * w[1] + c->color[1] * w[2]; - color[2] += a->color[2] * w[0] + b->color[2] * w[1] + c->color[2] * w[2]; + float co[2] = {(float) x, (float) y}; + + for (i = 0; i < tile_data->triangles_total; i++) { + int triangle_idx = tile_data->triangles[i]; + rctf *rect = &triangulation->triangles_AABB[triangle_idx]; + + if (IN_RANGE_INCL(x, rect->xmin, rect->xmax) && IN_RANGE_INCL(y, rect->ymin, rect->ymax)) { + int *triangle = triangulation->triangles[triangle_idx]; + VoronoiTriangulationPoint *a = &triangulation->triangulated_points[triangle[0]], + *b = &triangulation->triangulated_points[triangle[1]], + *c = &triangulation->triangulated_points[triangle[2]]; + float w[3]; + + if (barycentric_coords_v2(a->co, b->co, c->co, co, w)) { + if (barycentric_inside_triangle_v2(w)) { + color[0] += a->color[0] * w[0] + b->color[0] * w[1] + c->color[0] * w[2]; + color[1] += a->color[1] * w[0] + b->color[1] * w[1] + c->color[1] * w[2]; + color[2] += a->color[2] * w[0] + b->color[2] * w[1] + c->color[2] * w[2]; + } } } } diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.h b/source/blender/compositor/operations/COM_KeyingScreenOperation.h index 9d3f44f6be2..95815cd3930 100644 --- a/source/blender/compositor/operations/COM_KeyingScreenOperation.h +++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.h @@ -39,39 +39,46 @@ extern "C" { } /** - * Class with implementation of green screen gradient rasterization - */ + * Class with implementation of green screen gradient rasterization + */ class KeyingScreenOperation : public NodeOperation { protected: typedef struct TriangulationData { VoronoiTriangulationPoint *triangulated_points; int (*triangles)[3]; int triangulated_points_total, triangles_total; + rctf *triangles_AABB; } TriangulationData; - MovieClip *movieClip; - int framenumber; - TriangulationData *cachedTriangulation; - char trackingObject[64]; + typedef struct TileData { + int *triangles; + int triangles_total; + } TileData; + + MovieClip *m_movieClip; + int m_framenumber; + TriangulationData *m_cachedTriangulation; + char m_trackingObject[64]; /** - * Determine the output resolution. The resolution is retrieved from the Renderer - */ + * Determine the output resolution. The resolution is retrieved from the Renderer + */ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); TriangulationData *buildVoronoiTriangulation(); - public: +public: KeyingScreenOperation(); void initExecution(); void deinitExecution(); void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data); - void setMovieClip(MovieClip *clip) {this->movieClip = clip;} - void setTrackingObject(char *object) {strncpy(this->trackingObject, object, sizeof(this->trackingObject));} - void setFramenumber(int framenumber) {this->framenumber = framenumber;} + void setMovieClip(MovieClip *clip) {this->m_movieClip = clip;} + void setTrackingObject(const char *object) {strncpy(this->m_trackingObject, object, sizeof(this->m_trackingObject));} + void setFramenumber(int framenumber) {this->m_framenumber = framenumber;} void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data); }; diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp index 6e8aa9461e6..233f903c3e3 100644 --- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp @@ -27,29 +27,29 @@ LuminanceMatteOperation::LuminanceMatteOperation() : NodeOperation() addInputSocket(COM_DT_COLOR); addOutputSocket(COM_DT_VALUE); - inputImageProgram = NULL; + this->m_inputImageProgram = NULL; } void LuminanceMatteOperation::initExecution() { - this->inputImageProgram = this->getInputSocketReader(0); + this->m_inputImageProgram = this->getInputSocketReader(0); } void LuminanceMatteOperation::deinitExecution() { - this->inputImageProgram = NULL; + this->m_inputImageProgram = NULL; } void LuminanceMatteOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inColor[4]; - const float high = this->settings->t1; - const float low = this->settings->t2; + const float high = this->m_settings->t1; + const float low = this->m_settings->t2; float alpha; - this->inputImageProgram->read(inColor, x, y, sampler, inputBuffers); + this->m_inputImageProgram->read(inColor, x, y, sampler, inputBuffers); /* one line thread-friend algorithm: * outputValue[0] = max(inputValue[3], min(high, max(low, ((inColor[0]-low)/(high-low)))) diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h index f44e32396a3..041fd0d7ee9 100644 --- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h +++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h @@ -25,13 +25,13 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class LuminanceMatteOperation : public NodeOperation { private: - NodeChroma *settings; - SocketReader *inputImageProgram; + NodeChroma *m_settings; + SocketReader *m_inputImageProgram; public: /** * Default constructor @@ -46,6 +46,6 @@ public: void initExecution(); void deinitExecution(); - void setSettings(NodeChroma *nodeChroma) { this->settings = nodeChroma; } + void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; } }; #endif diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cpp b/source/blender/compositor/operations/COM_MapUVOperation.cpp index b29dcfab194..dec2d0849c9 100644 --- a/source/blender/compositor/operations/COM_MapUVOperation.cpp +++ b/source/blender/compositor/operations/COM_MapUVOperation.cpp @@ -27,17 +27,17 @@ MapUVOperation::MapUVOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VECTOR); this->addOutputSocket(COM_DT_COLOR); - this->alpha = 0.f; + this->m_alpha = 0.0f; this->setComplex(true); - this->inputUVProgram = NULL; - this->inputColorProgram = NULL; + this->m_inputUVProgram = NULL; + this->m_inputColorProgram = NULL; } void MapUVOperation::initExecution() { - this->inputColorProgram = this->getInputSocketReader(0); - this->inputUVProgram = this->getInputSocketReader(1); + this->m_inputColorProgram = this->getInputSocketReader(0); + this->m_inputUVProgram = this->getInputSocketReader(1); } void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -50,30 +50,30 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s float uv_l, uv_r; float uv_u, uv_d; - this->inputUVProgram->read(inputUV, x, y, sampler, inputBuffers); + this->m_inputUVProgram->read(inputUV, x, y, sampler, inputBuffers); if (inputUV[2] == 0.f) { zero_v4(color); return; } /* adaptive sampling, red (U) channel */ - this->inputUVProgram->read(uv_a, x - 1, y, COM_PS_NEAREST, inputBuffers); - this->inputUVProgram->read(uv_b, x + 1, y, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_a, x - 1, y, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_b, x + 1, y, COM_PS_NEAREST, inputBuffers); uv_l = uv_a[2] != 0.f ? fabsf(inputUV[0] - uv_a[0]) : 0.f; uv_r = uv_b[2] != 0.f ? fabsf(inputUV[0] - uv_b[0]) : 0.f; dx = 0.5f * (uv_l + uv_r); /* adaptive sampling, green (V) channel */ - this->inputUVProgram->read(uv_a, x, y - 1, COM_PS_NEAREST, inputBuffers); - this->inputUVProgram->read(uv_b, x, y + 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_a, x, y - 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_b, x, y + 1, COM_PS_NEAREST, inputBuffers); uv_u = uv_a[2] != 0.f ? fabsf(inputUV[1] - uv_a[1]) : 0.f; uv_d = uv_b[2] != 0.f ? fabsf(inputUV[1] - uv_b[1]) : 0.f; dy = 0.5f * (uv_u + uv_d); /* more adaptive sampling, red and green (UV) channels */ - this->inputUVProgram->read(uv_a, x - 1, y - 1, COM_PS_NEAREST, inputBuffers); - this->inputUVProgram->read(uv_b, x - 1, y + 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_a, x - 1, y - 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_b, x - 1, y + 1, COM_PS_NEAREST, inputBuffers); uv_l = uv_a[2] != 0.f ? fabsf(inputUV[0] - uv_a[0]) : 0.f; uv_r = uv_b[2] != 0.f ? fabsf(inputUV[0] - uv_b[0]) : 0.f; uv_u = uv_a[2] != 0.f ? fabsf(inputUV[1] - uv_a[1]) : 0.f; @@ -82,8 +82,8 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s dx += 0.25f * (uv_l + uv_r); dy += 0.25f * (uv_u + uv_d); - this->inputUVProgram->read(uv_a, x + 1, y - 1, COM_PS_NEAREST, inputBuffers); - this->inputUVProgram->read(uv_b, x + 1, y + 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_a, x + 1, y - 1, COM_PS_NEAREST, inputBuffers); + this->m_inputUVProgram->read(uv_b, x + 1, y + 1, COM_PS_NEAREST, inputBuffers); uv_l = uv_a[2] != 0.f ? fabsf(inputUV[0] - uv_a[0]) : 0.f; uv_r = uv_b[2] != 0.f ? fabsf(inputUV[0] - uv_b[0]) : 0.f; uv_u = uv_a[2] != 0.f ? fabsf(inputUV[1] - uv_a[1]) : 0.f; @@ -93,7 +93,7 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s dy += 0.25f * (uv_u + uv_d); /* UV to alpha threshold */ - const float threshold = this->alpha * 0.05f; + const float threshold = this->m_alpha * 0.05f; float alpha = 1.0f - threshold * (dx + dy); if (alpha < 0.f) alpha = 0.f; else alpha *= inputUV[2]; @@ -104,10 +104,10 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s /* EWA filtering */ - u = inputUV[0] * inputColorProgram->getWidth(); - v = inputUV[1] * inputColorProgram->getHeight(); + u = inputUV[0] * this->m_inputColorProgram->getWidth(); + v = inputUV[1] * this->m_inputColorProgram->getHeight(); - this->inputColorProgram->read(color, u, v, dx, dy, inputBuffers); + this->m_inputColorProgram->read(color, u, v, dx, dy, inputBuffers); /* "premul" */ if (alpha < 1.0f) { @@ -117,8 +117,8 @@ void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler s void MapUVOperation::deinitExecution() { - this->inputUVProgram = NULL; - this->inputColorProgram = NULL; + this->m_inputUVProgram = NULL; + this->m_inputColorProgram = NULL; } bool MapUVOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_MapUVOperation.h b/source/blender/compositor/operations/COM_MapUVOperation.h index 22e3531e838..c14640da61c 100644 --- a/source/blender/compositor/operations/COM_MapUVOperation.h +++ b/source/blender/compositor/operations/COM_MapUVOperation.h @@ -29,10 +29,10 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputUVProgram; - SocketReader *inputColorProgram; + SocketReader *m_inputUVProgram; + SocketReader *m_inputColorProgram; - float alpha; + float m_alpha; public: MapUVOperation(); @@ -57,6 +57,6 @@ public: */ void deinitExecution(); - void setAlpha(float alpha) { this->alpha = alpha; } + void setAlpha(float alpha) { this->m_alpha = alpha; } }; #endif diff --git a/source/blender/compositor/operations/COM_MapValueOperation.cpp b/source/blender/compositor/operations/COM_MapValueOperation.cpp index 6d7804dd6e3..17d82e85723 100644 --- a/source/blender/compositor/operations/COM_MapValueOperation.cpp +++ b/source/blender/compositor/operations/COM_MapValueOperation.cpp @@ -26,19 +26,19 @@ MapValueOperation::MapValueOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void MapValueOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void MapValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float src[4]; - inputOperation->read(src, x, y, sampler, inputBuffers); - TexMapping *texmap = this->settings; + this->m_inputOperation->read(src, x, y, sampler, inputBuffers); + TexMapping *texmap = this->m_settings; float value = (src[0] + texmap->loc[0]) * texmap->size[0]; if (texmap->flag & TEXMAP_CLIP_MIN) if (value < texmap->min[0]) @@ -52,5 +52,5 @@ void MapValueOperation::executePixel(float *outputValue, float x, float y, Pixel void MapValueOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_MapValueOperation.h b/source/blender/compositor/operations/COM_MapValueOperation.h index 5fae74e0a6a..fb50d0fbe4d 100644 --- a/source/blender/compositor/operations/COM_MapValueOperation.h +++ b/source/blender/compositor/operations/COM_MapValueOperation.h @@ -26,16 +26,16 @@ #include "DNA_texture_types.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MapValueOperation : public NodeOperation { private: /** * Cached reference to the inputProgram */ - SocketReader *inputOperation; - TexMapping *settings; + SocketReader *m_inputOperation; + TexMapping *m_settings; public: /** * Default constructor @@ -60,7 +60,7 @@ public: /** * @brief set the TexMapping settings */ - void setSettings(TexMapping *settings) { this->settings = settings; } + void setSettings(TexMapping *settings) { this->m_settings = settings; } }; #endif diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp index 0493bdee12c..2b45cd53fd5 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cpp +++ b/source/blender/compositor/operations/COM_MaskOperation.cpp @@ -38,69 +38,80 @@ extern "C" { MaskOperation::MaskOperation() : NodeOperation() { this->addOutputSocket(COM_DT_VALUE); - this->mask = NULL; - this->maskWidth = 0; - this->maskHeight = 0; - this->framenumber = 0; - this->rasterizedMask = NULL; + this->m_mask = NULL; + this->m_maskWidth = 0; + this->m_maskHeight = 0; + this->m_framenumber = 0; + this->m_rasterizedMask = NULL; setComplex(true); } void MaskOperation::initExecution() { initMutex(); - this->rasterizedMask = NULL; + + this->m_rasterizedMask = NULL; + this->m_maskLayers.first = this->m_maskLayers.last = NULL; + + if (this->m_mask) { + BKE_mask_layer_copy_list(&this->m_maskLayers, &this->m_mask->masklayers); + } } void MaskOperation::deinitExecution() { - if (this->rasterizedMask) { - MEM_freeN(rasterizedMask); - this->rasterizedMask = NULL; + BKE_mask_layer_free_list(&this->m_maskLayers); + + if (this->m_rasterizedMask) { + MEM_freeN(this->m_rasterizedMask); + this->m_rasterizedMask = NULL; } } void *MaskOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->rasterizedMask) - return this->rasterizedMask; + if (this->m_rasterizedMask) + return this->m_rasterizedMask; - if (!this->mask) + if (!this->m_mask) return NULL; lockMutex(); - if (this->rasterizedMask == NULL) { + if (this->m_rasterizedMask == NULL) { int width = this->getWidth(); int height = this->getHeight(); float *buffer; buffer = (float *)MEM_callocN(sizeof(float) * width * height, "rasterized mask"); - BKE_mask_rasterize(mask, width, height, buffer, TRUE, this->smooth); - if (this->smooth) { + + BKE_mask_rasterize_layers(&this->m_maskLayers, width, height, buffer, TRUE, + this->m_do_smooth, this->m_do_feather); + + if (this->m_do_smooth) { PLX_antialias_buffer(buffer, width, height); } - this->rasterizedMask = buffer; + this->m_rasterizedMask = buffer; } unlockMutex(); - return this->rasterizedMask; + return this->m_rasterizedMask; } void MaskOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { - if (maskWidth == 0 || maskHeight == 0) { + if (this->m_maskWidth == 0 || this->m_maskHeight == 0) { NodeOperation::determineResolution(resolution, preferredResolution); } else { unsigned int nr[2]; - nr[0] = maskWidth; - nr[1] = maskHeight; + nr[0] = this->m_maskWidth; + nr[1] = this->m_maskHeight; NodeOperation::determineResolution(resolution, nr); - resolution[0] = maskWidth; - resolution[1] = maskHeight; + resolution[0] = this->m_maskWidth; + resolution[1] = this->m_maskHeight; } } diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h index 8507cb994c0..df1cad3c0f6 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.h +++ b/source/blender/compositor/operations/COM_MaskOperation.h @@ -36,12 +36,14 @@ */ class MaskOperation : public NodeOperation { protected: - Mask *mask; - int maskWidth; - int maskHeight; - int framenumber; - bool smooth; - float *rasterizedMask; + Mask *m_mask; + int m_maskWidth; + int m_maskHeight; + int m_framenumber; + bool m_do_smooth; + bool m_do_feather; + float *m_rasterizedMask; + ListBase m_maskLayers; /** * Determine the output resolution. The resolution is retrieved from the Renderer @@ -56,11 +58,12 @@ public: void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); - void setMask(Mask *mask) { this->mask = mask; } - void setMaskWidth(int width) { this->maskWidth = width; } - void setMaskHeight(int height) { this->maskHeight = height; } - void setFramenumber(int framenumber) { this->framenumber = framenumber; } - void setSmooth(bool smooth) { this->smooth = smooth; } + void setMask(Mask *mask) { this->m_mask = mask; } + void setMaskWidth(int width) { this->m_maskWidth = width; } + void setMaskHeight(int height) { this->m_maskHeight = height; } + void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } + void setSmooth(bool smooth) { this->m_do_smooth = smooth; } + void setFeather(bool feather) { this->m_do_feather = feather; } void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data); }; diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp index 5e9fb70b206..1bf89be57b5 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp @@ -30,21 +30,21 @@ MathBaseOperation::MathBaseOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->inputValue1Operation = NULL; - this->inputValue2Operation = NULL; + this->m_inputValue1Operation = NULL; + this->m_inputValue2Operation = NULL; } void MathBaseOperation::initExecution() { - this->inputValue1Operation = this->getInputSocketReader(0); - this->inputValue2Operation = this->getInputSocketReader(1); + this->m_inputValue1Operation = this->getInputSocketReader(0); + this->m_inputValue2Operation = this->getInputSocketReader(1); } void MathBaseOperation::deinitExecution() { - this->inputValue1Operation = NULL; - this->inputValue2Operation = NULL; + this->m_inputValue1Operation = NULL; + this->m_inputValue2Operation = NULL; } void MathBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) @@ -69,8 +69,8 @@ void MathAddOperation::executePixel(float *outputValue, float x, float y, PixelS float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = inputValue1[0] + inputValue2[0]; } @@ -80,8 +80,8 @@ void MathSubtractOperation::executePixel(float *outputValue, float x, float y, P float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = inputValue1[0] - inputValue2[0]; } @@ -91,8 +91,8 @@ void MathMultiplyOperation::executePixel(float *outputValue, float x, float y, P float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = inputValue1[0] * inputValue2[0]; } @@ -102,8 +102,8 @@ void MathDivideOperation::executePixel(float *outputValue, float x, float y, Pix float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); if (inputValue2[0] == 0) /* We don't want to divide by zero. */ outputValue[0] = 0.0; @@ -116,8 +116,8 @@ void MathSineOperation::executePixel(float *outputValue, float x, float y, Pixel float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = sin(inputValue1[0]); } @@ -127,8 +127,8 @@ void MathCosineOperation::executePixel(float *outputValue, float x, float y, Pix float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = cos(inputValue1[0]); } @@ -138,8 +138,8 @@ void MathTangentOperation::executePixel(float *outputValue, float x, float y, Pi float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = tan(inputValue1[0]); } @@ -149,8 +149,8 @@ void MathArcSineOperation::executePixel(float *outputValue, float x, float y, Pi float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); if (inputValue1[0] <= 1 && inputValue1[0] >= -1) outputValue[0] = asin(inputValue1[0]); @@ -163,8 +163,8 @@ void MathArcCosineOperation::executePixel(float *outputValue, float x, float y, float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); if (inputValue1[0] <= 1 && inputValue1[0] >= -1) outputValue[0] = acos(inputValue1[0]); @@ -177,8 +177,8 @@ void MathArcTangentOperation::executePixel(float *outputValue, float x, float y, float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = atan(inputValue1[0]); } @@ -188,8 +188,8 @@ void MathPowerOperation::executePixel(float *outputValue, float x, float y, Pixe float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); if (inputValue1[0] >= 0) { outputValue[0] = pow(inputValue1[0], inputValue2[0]); @@ -211,8 +211,8 @@ void MathLogarithmOperation::executePixel(float *outputValue, float x, float y, float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); if (inputValue1[0] > 0 && inputValue2[0] > 0) outputValue[0] = log(inputValue1[0]) / log(inputValue2[0]); @@ -225,8 +225,8 @@ void MathMinimumOperation::executePixel(float *outputValue, float x, float y, Pi float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = min(inputValue1[0], inputValue2[0]); } @@ -236,8 +236,8 @@ void MathMaximumOperation::executePixel(float *outputValue, float x, float y, Pi float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = max(inputValue1[0], inputValue2[0]); } @@ -247,8 +247,8 @@ void MathRoundOperation::executePixel(float *outputValue, float x, float y, Pixe float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = round(inputValue1[0]); } @@ -258,8 +258,8 @@ void MathLessThanOperation::executePixel(float *outputValue, float x, float y, P float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = inputValue1[0] < inputValue2[0] ? 1.0f : 0.0f; } @@ -269,8 +269,8 @@ void MathGreaterThanOperation::executePixel(float *outputValue, float x, float y float inputValue1[4]; float inputValue2[4]; - inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); - inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers); outputValue[0] = inputValue1[0] > inputValue2[0] ? 1.0f : 0.0f; } diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h index 12dc5fa36c7..be06537cbf0 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.h +++ b/source/blender/compositor/operations/COM_MathBaseOperation.h @@ -26,16 +26,16 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MathBaseOperation : public NodeOperation { protected: /** * Prefetched reference to the inputProgram */ - SocketReader *inputValue1Operation; - SocketReader *inputValue2Operation; + SocketReader *m_inputValue1Operation; + SocketReader *m_inputValue2Operation; protected: /** diff --git a/source/blender/compositor/operations/COM_MixAddOperation.cpp b/source/blender/compositor/operations/COM_MixAddOperation.cpp index bd9538a5600..7f7315fb3ff 100644 --- a/source/blender/compositor/operations/COM_MixAddOperation.cpp +++ b/source/blender/compositor/operations/COM_MixAddOperation.cpp @@ -33,9 +33,9 @@ void MixAddOperation::executePixel(float *outputValue, float x, float y, PixelSa float inputColor2[4]; float inputValue[4]; - inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); - inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); float value = inputValue[0]; diff --git a/source/blender/compositor/operations/COM_MixAddOperation.h b/source/blender/compositor/operations/COM_MixAddOperation.h index 7b03802cf7e..c5eaf0a4d77 100644 --- a/source/blender/compositor/operations/COM_MixAddOperation.h +++ b/source/blender/compositor/operations/COM_MixAddOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixAddOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixBaseOperation.cpp b/source/blender/compositor/operations/COM_MixBaseOperation.cpp index 0efab2942b0..fbe92f54aa8 100644 --- a/source/blender/compositor/operations/COM_MixBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_MixBaseOperation.cpp @@ -28,17 +28,17 @@ MixBaseOperation::MixBaseOperation() : NodeOperation() this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); - this->inputValueOperation = NULL; - this->inputColor1Operation = NULL; - this->inputColor2Operation = NULL; + this->m_inputValueOperation = NULL; + this->m_inputColor1Operation = NULL; + this->m_inputColor2Operation = NULL; this->setUseValueAlphaMultiply(false); } void MixBaseOperation::initExecution() { - this->inputValueOperation = this->getInputSocketReader(0); - this->inputColor1Operation = this->getInputSocketReader(1); - this->inputColor2Operation = this->getInputSocketReader(2); + this->m_inputValueOperation = this->getInputSocketReader(0); + this->m_inputColor1Operation = this->getInputSocketReader(1); + this->m_inputColor2Operation = this->getInputSocketReader(2); } void MixBaseOperation::executePixel(float *outputColor, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -47,9 +47,9 @@ void MixBaseOperation::executePixel(float *outputColor, float x, float y, PixelS float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; @@ -63,9 +63,9 @@ void MixBaseOperation::executePixel(float *outputColor, float x, float y, PixelS void MixBaseOperation::deinitExecution() { - this->inputValueOperation = NULL; - this->inputColor1Operation = NULL; - this->inputColor2Operation = NULL; + this->m_inputValueOperation = NULL; + this->m_inputColor1Operation = NULL; + this->m_inputColor2Operation = NULL; } void MixBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) diff --git a/source/blender/compositor/operations/COM_MixBaseOperation.h b/source/blender/compositor/operations/COM_MixBaseOperation.h index 3637cc9eacf..268d4832243 100644 --- a/source/blender/compositor/operations/COM_MixBaseOperation.h +++ b/source/blender/compositor/operations/COM_MixBaseOperation.h @@ -26,18 +26,18 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixBaseOperation : public NodeOperation { protected: /** * Prefetched reference to the inputProgram */ - SocketReader *inputValueOperation; - SocketReader *inputColor1Operation; - SocketReader *inputColor2Operation; - bool valueAlphaMultiply; + SocketReader *m_inputValueOperation; + SocketReader *m_inputColor1Operation; + SocketReader *m_inputColor2Operation; + bool m_valueAlphaMultiply; public: /** * Default constructor @@ -61,7 +61,7 @@ public: void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); - void setUseValueAlphaMultiply(const bool value) { this->valueAlphaMultiply = value; } - bool useValueAlphaMultiply() { return this->valueAlphaMultiply; } + void setUseValueAlphaMultiply(const bool value) { this->m_valueAlphaMultiply = value; } + bool useValueAlphaMultiply() { return this->m_valueAlphaMultiply; } }; #endif diff --git a/source/blender/compositor/operations/COM_MixBlendOperation.cpp b/source/blender/compositor/operations/COM_MixBlendOperation.cpp index f010d23ce60..341aba0e7fc 100644 --- a/source/blender/compositor/operations/COM_MixBlendOperation.cpp +++ b/source/blender/compositor/operations/COM_MixBlendOperation.cpp @@ -34,9 +34,9 @@ void MixBlendOperation::executePixel(float *outputValue, float x, float y, Pixel float inputValue[4]; float value; - inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); - inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); value = inputValue[0]; if (this->useValueAlphaMultiply()) { diff --git a/source/blender/compositor/operations/COM_MixBlendOperation.h b/source/blender/compositor/operations/COM_MixBlendOperation.h index b906134f5cb..16ad635bebd 100644 --- a/source/blender/compositor/operations/COM_MixBlendOperation.h +++ b/source/blender/compositor/operations/COM_MixBlendOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixBlendOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixBurnOperation.cpp b/source/blender/compositor/operations/COM_MixBurnOperation.cpp index e94834148e8..039915ab66a 100644 --- a/source/blender/compositor/operations/COM_MixBurnOperation.cpp +++ b/source/blender/compositor/operations/COM_MixBurnOperation.cpp @@ -34,9 +34,9 @@ void MixBurnOperation::executePixel(float *outputValue, float x, float y, PixelS float value; float tmp; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixBurnOperation.h b/source/blender/compositor/operations/COM_MixBurnOperation.h index af09772edde..7412f651ab3 100644 --- a/source/blender/compositor/operations/COM_MixBurnOperation.h +++ b/source/blender/compositor/operations/COM_MixBurnOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixBurnOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixColorOperation.cpp b/source/blender/compositor/operations/COM_MixColorOperation.cpp index f3e893bc18f..cb5791c02bb 100644 --- a/source/blender/compositor/operations/COM_MixColorOperation.cpp +++ b/source/blender/compositor/operations/COM_MixColorOperation.cpp @@ -37,9 +37,9 @@ void MixColorOperation::executePixel(float *outputValue, float x, float y, Pixel float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixColorOperation.h b/source/blender/compositor/operations/COM_MixColorOperation.h index 9b0d93f934d..028ff517132 100644 --- a/source/blender/compositor/operations/COM_MixColorOperation.h +++ b/source/blender/compositor/operations/COM_MixColorOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixColorOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixDarkenOperation.cpp b/source/blender/compositor/operations/COM_MixDarkenOperation.cpp index a36c663ddda..db243cf4a87 100644 --- a/source/blender/compositor/operations/COM_MixDarkenOperation.cpp +++ b/source/blender/compositor/operations/COM_MixDarkenOperation.cpp @@ -33,9 +33,9 @@ void MixDarkenOperation::executePixel(float *outputValue, float x, float y, Pixe float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixDarkenOperation.h b/source/blender/compositor/operations/COM_MixDarkenOperation.h index 69fb4450458..337fa1a7024 100644 --- a/source/blender/compositor/operations/COM_MixDarkenOperation.h +++ b/source/blender/compositor/operations/COM_MixDarkenOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixDarkenOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp b/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp index 69886753480..9fe1a3cb94b 100644 --- a/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp +++ b/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp @@ -34,9 +34,9 @@ void MixDifferenceOperation::executePixel(float *outputValue, float x, float y, float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixDifferenceOperation.h b/source/blender/compositor/operations/COM_MixDifferenceOperation.h index c71b22214cc..503fbb691d3 100644 --- a/source/blender/compositor/operations/COM_MixDifferenceOperation.h +++ b/source/blender/compositor/operations/COM_MixDifferenceOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixDifferenceOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixDivideOperation.cpp b/source/blender/compositor/operations/COM_MixDivideOperation.cpp index 8b6586c5336..0e1bd408b89 100644 --- a/source/blender/compositor/operations/COM_MixDivideOperation.cpp +++ b/source/blender/compositor/operations/COM_MixDivideOperation.cpp @@ -33,9 +33,9 @@ void MixDivideOperation::executePixel(float *outputValue, float x, float y, Pixe float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixDivideOperation.h b/source/blender/compositor/operations/COM_MixDivideOperation.h index 375e7129e8b..db60a39f93f 100644 --- a/source/blender/compositor/operations/COM_MixDivideOperation.h +++ b/source/blender/compositor/operations/COM_MixDivideOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixDivideOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixDodgeOperation.cpp b/source/blender/compositor/operations/COM_MixDodgeOperation.cpp index 971ddd5b736..ea01806267b 100644 --- a/source/blender/compositor/operations/COM_MixDodgeOperation.cpp +++ b/source/blender/compositor/operations/COM_MixDodgeOperation.cpp @@ -34,9 +34,9 @@ void MixDodgeOperation::executePixel(float *outputValue, float x, float y, Pixel float value; float tmp; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixDodgeOperation.h b/source/blender/compositor/operations/COM_MixDodgeOperation.h index a4adf6fde47..32aa8593657 100644 --- a/source/blender/compositor/operations/COM_MixDodgeOperation.h +++ b/source/blender/compositor/operations/COM_MixDodgeOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixDodgeOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixGlareOperation.cpp b/source/blender/compositor/operations/COM_MixGlareOperation.cpp index bfb0efe692f..7cd24b3bf06 100644 --- a/source/blender/compositor/operations/COM_MixGlareOperation.cpp +++ b/source/blender/compositor/operations/COM_MixGlareOperation.cpp @@ -34,9 +34,9 @@ void MixGlareOperation::executePixel(float *outputValue, float x, float y, Pixel float inputValue[4]; float value; - inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); - inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); value = inputValue[0]; float mf = 2.f - 2.f * fabsf(value - 0.5f); diff --git a/source/blender/compositor/operations/COM_MixGlareOperation.h b/source/blender/compositor/operations/COM_MixGlareOperation.h index 1a025eb3edd..1c715d7414b 100644 --- a/source/blender/compositor/operations/COM_MixGlareOperation.h +++ b/source/blender/compositor/operations/COM_MixGlareOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixGlareOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixHueOperation.cpp b/source/blender/compositor/operations/COM_MixHueOperation.cpp index 05d02805ebc..e7b444616f4 100644 --- a/source/blender/compositor/operations/COM_MixHueOperation.cpp +++ b/source/blender/compositor/operations/COM_MixHueOperation.cpp @@ -37,9 +37,9 @@ void MixHueOperation::executePixel(float *outputValue, float x, float y, PixelSa float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixHueOperation.h b/source/blender/compositor/operations/COM_MixHueOperation.h index 56310e253c0..ff1ef369440 100644 --- a/source/blender/compositor/operations/COM_MixHueOperation.h +++ b/source/blender/compositor/operations/COM_MixHueOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixHueOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixLightenOperation.cpp b/source/blender/compositor/operations/COM_MixLightenOperation.cpp index 6e1af7a3c44..89166637f9f 100644 --- a/source/blender/compositor/operations/COM_MixLightenOperation.cpp +++ b/source/blender/compositor/operations/COM_MixLightenOperation.cpp @@ -33,9 +33,9 @@ void MixLightenOperation::executePixel(float *outputValue, float x, float y, Pix float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixLightenOperation.h b/source/blender/compositor/operations/COM_MixLightenOperation.h index bb251a44653..dd51215b26a 100644 --- a/source/blender/compositor/operations/COM_MixLightenOperation.h +++ b/source/blender/compositor/operations/COM_MixLightenOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixLightenOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp b/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp index bf1c181b566..5406a3cbcc1 100644 --- a/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp +++ b/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp @@ -33,9 +33,9 @@ void MixLinearLightOperation::executePixel(float *outputValue, float x, float y, float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixLinearLightOperation.h b/source/blender/compositor/operations/COM_MixLinearLightOperation.h index 39d5b6495d1..e96e2b7eaf7 100644 --- a/source/blender/compositor/operations/COM_MixLinearLightOperation.h +++ b/source/blender/compositor/operations/COM_MixLinearLightOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixLinearLightOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp b/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp index 62018ed5698..978e96eb2f6 100644 --- a/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp +++ b/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp @@ -33,9 +33,9 @@ void MixMultiplyOperation::executePixel(float *outputValue, float x, float y, Pi float inputColor2[4]; float inputValue[4]; - inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); - inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); - inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(inputValue, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { diff --git a/source/blender/compositor/operations/COM_MixMultiplyOperation.h b/source/blender/compositor/operations/COM_MixMultiplyOperation.h index 2c12854bfa6..4c89a8f2957 100644 --- a/source/blender/compositor/operations/COM_MixMultiplyOperation.h +++ b/source/blender/compositor/operations/COM_MixMultiplyOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixMultiplyOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixOverlayOperation.cpp b/source/blender/compositor/operations/COM_MixOverlayOperation.cpp index a269045c598..f4f96747acd 100644 --- a/source/blender/compositor/operations/COM_MixOverlayOperation.cpp +++ b/source/blender/compositor/operations/COM_MixOverlayOperation.cpp @@ -33,9 +33,9 @@ void MixOverlayOperation::executePixel(float *outputValue, float x, float y, Pix float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixOverlayOperation.h b/source/blender/compositor/operations/COM_MixOverlayOperation.h index 48d1d10a697..7de955b9f4f 100644 --- a/source/blender/compositor/operations/COM_MixOverlayOperation.h +++ b/source/blender/compositor/operations/COM_MixOverlayOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixOverlayOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixSaturationOperation.cpp b/source/blender/compositor/operations/COM_MixSaturationOperation.cpp index 863a17a7f80..c9c6f691fdb 100644 --- a/source/blender/compositor/operations/COM_MixSaturationOperation.cpp +++ b/source/blender/compositor/operations/COM_MixSaturationOperation.cpp @@ -37,9 +37,9 @@ void MixSaturationOperation::executePixel(float *outputValue, float x, float y, float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixSaturationOperation.h b/source/blender/compositor/operations/COM_MixSaturationOperation.h index ccb95e2f00f..241009e2645 100644 --- a/source/blender/compositor/operations/COM_MixSaturationOperation.h +++ b/source/blender/compositor/operations/COM_MixSaturationOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixSaturationOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixScreenOperation.cpp b/source/blender/compositor/operations/COM_MixScreenOperation.cpp index 6fb7befeba4..9bc9144f4ff 100644 --- a/source/blender/compositor/operations/COM_MixScreenOperation.cpp +++ b/source/blender/compositor/operations/COM_MixScreenOperation.cpp @@ -33,9 +33,9 @@ void MixScreenOperation::executePixel(float *outputValue, float x, float y, Pixe float inputColor2[4]; float valuev[4]; - inputValueOperation->read(valuev, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(valuev, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); float value = valuev[0]; if (this->useValueAlphaMultiply()) { diff --git a/source/blender/compositor/operations/COM_MixScreenOperation.h b/source/blender/compositor/operations/COM_MixScreenOperation.h index 6b9fa302325..4d0c1fded3d 100644 --- a/source/blender/compositor/operations/COM_MixScreenOperation.h +++ b/source/blender/compositor/operations/COM_MixScreenOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixScreenOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp b/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp index 9f7d0823473..52c2e8829dc 100644 --- a/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp +++ b/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp @@ -33,9 +33,9 @@ void MixSoftLightOperation::executePixel(float *outputValue, float x, float y, P float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixSoftLightOperation.h b/source/blender/compositor/operations/COM_MixSoftLightOperation.h index 4189066de2c..bcb718027b2 100644 --- a/source/blender/compositor/operations/COM_MixSoftLightOperation.h +++ b/source/blender/compositor/operations/COM_MixSoftLightOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixSoftLightOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixSubtractOperation.cpp b/source/blender/compositor/operations/COM_MixSubtractOperation.cpp index 80086053872..60f54ab478d 100644 --- a/source/blender/compositor/operations/COM_MixSubtractOperation.cpp +++ b/source/blender/compositor/operations/COM_MixSubtractOperation.cpp @@ -33,9 +33,9 @@ void MixSubtractOperation::executePixel(float *outputValue, float x, float y, Pi float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixSubtractOperation.h b/source/blender/compositor/operations/COM_MixSubtractOperation.h index b820fb1e5e1..3c8112b0e36 100644 --- a/source/blender/compositor/operations/COM_MixSubtractOperation.h +++ b/source/blender/compositor/operations/COM_MixSubtractOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixSubtractOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixValueOperation.cpp b/source/blender/compositor/operations/COM_MixValueOperation.cpp index cd79c54318d..2651b0d7dee 100644 --- a/source/blender/compositor/operations/COM_MixValueOperation.cpp +++ b/source/blender/compositor/operations/COM_MixValueOperation.cpp @@ -37,9 +37,9 @@ void MixValueOperation::executePixel(float *outputValue, float x, float y, Pixel float inputColor2[4]; float value; - inputValueOperation->read(&value, x, y, sampler, inputBuffers); - inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); - inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); + this->m_inputValueOperation->read(&value, x, y, sampler, inputBuffers); + this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers); + this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; diff --git a/source/blender/compositor/operations/COM_MixValueOperation.h b/source/blender/compositor/operations/COM_MixValueOperation.h index d12a2d2b3d6..c0f3ce10f29 100644 --- a/source/blender/compositor/operations/COM_MixValueOperation.h +++ b/source/blender/compositor/operations/COM_MixValueOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixValueOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp index 662212567de..1af206920c5 100644 --- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp @@ -28,40 +28,40 @@ extern "C" { MovieClipAttributeOperation::MovieClipAttributeOperation() : NodeOperation() { this->addOutputSocket(COM_DT_VALUE); - this->valueSet = false; - this->framenumber = 0; - this->attribute = MCA_X; + this->m_valueSet = false; + this->m_framenumber = 0; + this->m_attribute = MCA_X; } void MovieClipAttributeOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if (!valueSet) { + if (!this->m_valueSet) { float loc[2], scale, angle; loc[0] = 0.0f; loc[1] = 0.0f; scale = 1.0f; angle = 0.0f; - if (clip) { - int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, framenumber); - BKE_tracking_stabilization_data_get(&clip->tracking, clip_framenr, getWidth(), getHeight(), loc, &scale, &angle); + 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->tracking, clip_framenr, getWidth(), getHeight(), loc, &scale, &angle); } - switch (this->attribute) { + switch (this->m_attribute) { case MCA_SCALE: - this->value = scale; + this->m_value = scale; break; case MCA_ANGLE: - this->value = angle; + this->m_value = angle; break; case MCA_X: - this->value = loc[0]; + this->m_value = loc[0]; break; case MCA_Y: - this->value = loc[1]; + this->m_value = loc[1]; break; } - valueSet = true; + this->m_valueSet = true; } - outputValue[0] = this->value; + outputValue[0] = this->m_value; } void MovieClipAttributeOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h index b6e89fa345c..c6422fbbfc2 100644 --- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h +++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h @@ -32,16 +32,16 @@ typedef enum MovieClipAttribute { MCA_ANGLE } MovieClipAttribute; /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MovieClipAttributeOperation : public NodeOperation { private: - MovieClip *clip; - float value; - bool valueSet; - int framenumber; - MovieClipAttribute attribute; + MovieClip *m_clip; + float m_value; + bool m_valueSet; + int m_framenumber; + MovieClipAttribute m_attribute; public: /** * Default constructor @@ -54,8 +54,8 @@ public: void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); - void setMovieClip(MovieClip *clip) { this->clip = clip; } - void setFramenumber(int framenumber) { this->framenumber = framenumber; } - void setAttribute(MovieClipAttribute attribute) { this->attribute = attribute; } + void setMovieClip(MovieClip *clip) { this->m_clip = clip; } + void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } + void setAttribute(MovieClipAttribute attribute) { this->m_attribute = attribute; } }; #endif diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.cpp b/source/blender/compositor/operations/COM_MovieClipOperation.cpp index b8bda12c626..f53bb66d478 100644 --- a/source/blender/compositor/operations/COM_MovieClipOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieClipOperation.cpp @@ -34,23 +34,23 @@ extern "C" { MovieClipOperation::MovieClipOperation() : NodeOperation() { this->addOutputSocket(COM_DT_COLOR); - this->movieClip = NULL; - this->movieClipBuffer = NULL; - this->movieClipUser = NULL; - this->movieClipwidth = 0; - this->movieClipheight = 0; - this->framenumber = 0; + this->m_movieClip = NULL; + this->m_movieClipBuffer = NULL; + this->m_movieClipUser = NULL; + this->m_movieClipwidth = 0; + this->m_movieClipheight = 0; + this->m_framenumber = 0; } void MovieClipOperation::initExecution() { - if (this->movieClip) { - BKE_movieclip_user_set_frame(this->movieClipUser, this->framenumber); + if (this->m_movieClip) { + BKE_movieclip_user_set_frame(this->m_movieClipUser, this->m_framenumber); ImBuf *ibuf; - ibuf = BKE_movieclip_get_ibuf(this->movieClip, this->movieClipUser); + ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, this->m_movieClipUser); if (ibuf) { - this->movieClipBuffer = ibuf; + this->m_movieClipBuffer = ibuf; if (ibuf->rect_float == NULL || ibuf->userflags & IB_RECT_INVALID) { IMB_float_from_rect(ibuf); ibuf->userflags &= ~IB_RECT_INVALID; @@ -61,10 +61,10 @@ void MovieClipOperation::initExecution() void MovieClipOperation::deinitExecution() { - if (this->movieClipBuffer) { - IMB_freeImBuf(this->movieClipBuffer); + if (this->m_movieClipBuffer) { + IMB_freeImBuf(this->m_movieClipBuffer); - this->movieClipBuffer = NULL; + this->m_movieClipBuffer = NULL; } } @@ -73,10 +73,10 @@ void MovieClipOperation::determineResolution(unsigned int resolution[], unsigned resolution[0] = 0; resolution[1] = 0; - if (this->movieClip) { + if (this->m_movieClip) { int width, height; - BKE_movieclip_get_size(this->movieClip, this->movieClipUser, &width, &height); + BKE_movieclip_get_size(this->m_movieClip, this->m_movieClipUser, &width, &height); resolution[0] = width; resolution[1] = height; @@ -85,22 +85,19 @@ void MovieClipOperation::determineResolution(unsigned int resolution[], unsigned void MovieClipOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if (this->movieClipBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { - color[0] = 0.0f; - color[1] = 0.0f; - color[2] = 0.0f; - color[3] = 0.0f; + if (this->m_movieClipBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) { + zero_v4(color); } else { switch (sampler) { case COM_PS_NEAREST: - neareast_interpolation_color(this->movieClipBuffer, NULL, color, x, y); + neareast_interpolation_color(this->m_movieClipBuffer, NULL, color, x, y); break; case COM_PS_BILINEAR: - bilinear_interpolation_color(this->movieClipBuffer, NULL, color, x, y); + bilinear_interpolation_color(this->m_movieClipBuffer, NULL, color, x, y); break; case COM_PS_BICUBIC: - bicubic_interpolation_color(this->movieClipBuffer, NULL, color, x, y); + bicubic_interpolation_color(this->m_movieClipBuffer, NULL, color, x, y); break; } } diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.h b/source/blender/compositor/operations/COM_MovieClipOperation.h index 454c442a167..2e824009ab6 100644 --- a/source/blender/compositor/operations/COM_MovieClipOperation.h +++ b/source/blender/compositor/operations/COM_MovieClipOperation.h @@ -37,12 +37,12 @@ */ class MovieClipOperation : public NodeOperation { protected: - MovieClip *movieClip; - MovieClipUser *movieClipUser; - ImBuf *movieClipBuffer; - int movieClipheight; - int movieClipwidth; - int framenumber; + MovieClip *m_movieClip; + MovieClipUser *m_movieClipUser; + ImBuf *m_movieClipBuffer; + int m_movieClipheight; + int m_movieClipwidth; + int m_framenumber; /** * Determine the output resolution. The resolution is retrieved from the Renderer @@ -54,10 +54,10 @@ public: void initExecution(); void deinitExecution(); - void setMovieClip(MovieClip *image) { this->movieClip = image; } - void setMovieClipUser(MovieClipUser *imageuser) { this->movieClipUser = imageuser; } + void setMovieClip(MovieClip *image) { this->m_movieClip = image; } + void setMovieClipUser(MovieClipUser *imageuser) { this->m_movieClipUser = imageuser; } - void setFramenumber(int framenumber) { this->framenumber = framenumber; } + void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); }; diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp index 5320f901747..6b423cadcc6 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp @@ -37,57 +37,57 @@ MovieDistortionOperation::MovieDistortionOperation(bool distortion) : NodeOperat this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputOperation = NULL; - this->movieClip = NULL; - this->cache = NULL; - this->distortion = distortion; + this->m_inputOperation = NULL; + this->m_movieClip = NULL; + this->m_cache = NULL; + this->m_distortion = distortion; } void MovieDistortionOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); - if (this->movieClip) { + this->m_inputOperation = this->getInputSocketReader(0); + if (this->m_movieClip) { MovieClipUser clipUser = {0}; int calibration_width, calibration_height; - BKE_movieclip_user_set_frame(&clipUser, this->framenumber); - BKE_movieclip_get_size(this->movieClip, &clipUser, &calibration_width, &calibration_height); + BKE_movieclip_user_set_frame(&clipUser, this->m_framenumber); + BKE_movieclip_get_size(this->m_movieClip, &clipUser, &calibration_width, &calibration_height); for (unsigned int i = 0; i < s_cache.size(); i++) { DistortionCache *c = (DistortionCache *)s_cache[i]; - if (c->isCacheFor(this->movieClip, this->width, this->height, - calibration_width, calibration_height, this->distortion)) + if (c->isCacheFor(this->m_movieClip, this->m_width, this->m_height, + calibration_width, calibration_height, this->m_distortion)) { - this->cache = c; + this->m_cache = c; return; } } - DistortionCache *newC = new DistortionCache(this->movieClip, this->width, this->height, - calibration_width, calibration_height, this->distortion); + DistortionCache *newC = new DistortionCache(this->m_movieClip, this->m_width, this->m_height, + calibration_width, calibration_height, this->m_distortion); s_cache.push_back(newC); - this->cache = newC; + this->m_cache = newC; } else { - this->cache = NULL; + this->m_cache = NULL; } } void MovieDistortionOperation::deinitExecution() { - this->inputOperation = NULL; - this->movieClip = NULL; + this->m_inputOperation = NULL; + this->m_movieClip = NULL; } void MovieDistortionOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if (this->cache != NULL) { + if (this->m_cache != NULL) { float u, v; - this->cache->getUV(&this->movieClip->tracking, x, y, &u, &v); - this->inputOperation->read(color, u, v, sampler, inputBuffers); + this->m_cache->getUV(&this->m_movieClip->tracking, x, y, &u, &v); + this->m_inputOperation->read(color, u, v, sampler, inputBuffers); } else { - this->inputOperation->read(color, x, y, sampler, inputBuffers); + this->m_inputOperation->read(color, x, y, sampler, inputBuffers); } } diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h index c2ce04a78e1..ab81ae44597 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.h +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h @@ -31,100 +31,101 @@ extern "C" { class DistortionCache { private: - float k1; - float k2; - float k3; - float principal_x; - float principal_y; - float pixel_aspect; - int width; - int height; - int calibration_width; - int calibration_height; - bool inverted; - float *buffer; - int *bufferCalculated; + float m_k1; + float m_k2; + float m_k3; + float m_principal_x; + float m_principal_y; + float m_pixel_aspect; + int m_width; + int m_height; + int m_calibration_width; + int m_calibration_height; + bool m_inverted; + float *m_buffer; + int *m_bufferCalculated; public: DistortionCache(MovieClip *movieclip, int width, int height, int calibration_width, int calibration_height, bool inverted) { - this->k1 = movieclip->tracking.camera.k1; - this->k2 = movieclip->tracking.camera.k2; - this->k3 = movieclip->tracking.camera.k3; - this->principal_x = movieclip->tracking.camera.principal[0]; - this->principal_y = movieclip->tracking.camera.principal[1]; - this->pixel_aspect = movieclip->tracking.camera.pixel_aspect; - this->width = width; - this->height = height; - this->calibration_width = calibration_width; - this->calibration_height = calibration_height; - this->inverted = inverted; - this->bufferCalculated = new int[this->width * this->height]; - this->buffer = new float[this->width * this->height * 2]; - for (int i = 0; i < this->width * this->height; i++) { - this->bufferCalculated[i] = 0; + this->m_k1 = movieclip->tracking.camera.k1; + this->m_k2 = movieclip->tracking.camera.k2; + this->m_k3 = movieclip->tracking.camera.k3; + this->m_principal_x = movieclip->tracking.camera.principal[0]; + this->m_principal_y = movieclip->tracking.camera.principal[1]; + this->m_pixel_aspect = movieclip->tracking.camera.pixel_aspect; + this->m_width = width; + this->m_height = height; + this->m_calibration_width = calibration_width; + this->m_calibration_height = calibration_height; + this->m_inverted = inverted; + this->m_bufferCalculated = new int[this->m_width * this->m_height]; + this->m_buffer = new float[this->m_width * this->m_height * 2]; + for (int i = 0; i < this->m_width * this->m_height; i++) { + this->m_bufferCalculated[i] = 0; } } bool isCacheFor(MovieClip *movieclip, int width, int height, int calibration_width, int claibration_height, bool inverted) { - return this->k1 == movieclip->tracking.camera.k1 && - this->k2 == movieclip->tracking.camera.k2 && - this->k3 == movieclip->tracking.camera.k3 && - this->principal_x == movieclip->tracking.camera.principal[0] && - this->principal_y == movieclip->tracking.camera.principal[1] && - this->pixel_aspect == movieclip->tracking.camera.pixel_aspect && - this->inverted == inverted && - this->width == width && - this->height == height && - this->calibration_width == calibration_width && - this->calibration_height == calibration_height; + return this->m_k1 == movieclip->tracking.camera.k1 && + this->m_k2 == movieclip->tracking.camera.k2 && + this->m_k3 == movieclip->tracking.camera.k3 && + this->m_principal_x == movieclip->tracking.camera.principal[0] && + this->m_principal_y == movieclip->tracking.camera.principal[1] && + this->m_pixel_aspect == movieclip->tracking.camera.pixel_aspect && + this->m_inverted == inverted && + this->m_width == width && + this->m_height == height && + this->m_calibration_width == this->m_calibration_width && + this->m_calibration_height == this->m_calibration_height; } - void getUV(MovieTracking *trackingData, int x, int y, float *u, float *v) { - if (x < 0 || x >= this->width || y < 0 || y >= this->height) { + void getUV(MovieTracking *trackingData, int x, int y, float *u, float *v) + { + if (x < 0 || x >= this->m_width || y < 0 || y >= this->m_height) { *u = x; *v = y; } else { - int offset = y * this->width + x; + int offset = y * this->m_width + x; int offset2 = offset * 2; - if (!bufferCalculated[offset]) { + if (!this->m_bufferCalculated[offset]) { //float overscan = 0.0f; - float w = (float)this->width /* / (1 + overscan) */; - float h = (float)this->height /* / (1 + overscan) */; - float aspx = (float)w / this->calibration_width; - float aspy = (float)h / this->calibration_height; + float w = (float)this->m_width /* / (1 + overscan) */; + float h = (float)this->m_height /* / (1 + overscan) */; + float aspx = (float)w / this->m_calibration_width; + float aspy = (float)h / this->m_calibration_height; float in[2]; float out[2]; in[0] = (x /* - 0.5 * overscan * w */) / aspx; - in[1] = (y /* - 0.5 * overscan * h */) / aspy / this->pixel_aspect; + in[1] = (y /* - 0.5 * overscan * h */) / aspy / this->m_pixel_aspect; - if (inverted) { + if (this->m_inverted) { BKE_tracking_undistort_v2(trackingData, in, out); } else { BKE_tracking_distort_v2(trackingData, in, out); } - buffer[offset2] = out[0] * aspx /* + 0.5 * overscan * w */; - buffer[offset2 + 1] = (out[1] * aspy /* + 0.5 * overscan * h */) * this->pixel_aspect; + this->m_buffer[offset2] = out[0] * aspx /* + 0.5 * overscan * w */; + this->m_buffer[offset2 + 1] = (out[1] * aspy /* + 0.5 * overscan * h */) * this->m_pixel_aspect; - bufferCalculated[offset] = 1; + this->m_bufferCalculated[offset] = 1; } - *u = buffer[offset2]; - *v = buffer[offset2 + 1]; + *u = this->m_buffer[offset2]; + *v = this->m_buffer[offset2 + 1]; } } }; class MovieDistortionOperation : public NodeOperation { private: - DistortionCache *cache; - SocketReader *inputOperation; - MovieClip *movieClip; + DistortionCache *m_cache; + SocketReader *m_inputOperation; + MovieClip *m_movieClip; protected: - bool distortion; - int framenumber; + bool m_distortion; + int m_framenumber; public: MovieDistortionOperation(bool distortion); @@ -134,8 +135,8 @@ public: void initExecution(); void deinitExecution(); - void setMovieClip(MovieClip *clip) { this->movieClip = clip; } - void setFramenumber(int framenumber) { this->framenumber = framenumber; } + void setMovieClip(MovieClip *clip) { this->m_movieClip = clip; } + void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } }; #endif diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp index 1bd21f6e712..363c0379770 100644 --- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp +++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp @@ -29,15 +29,15 @@ extern "C" { MultilayerBaseOperation::MultilayerBaseOperation(int pass) : BaseImageOperation() { - this->passId = pass; + this->m_passId = pass; } ImBuf *MultilayerBaseOperation::getImBuf() { RenderPass *rpass; - rpass = (RenderPass *)BLI_findlink(&this->renderlayer->passes, this->passId); + rpass = (RenderPass *)BLI_findlink(&this->m_renderlayer->passes, this->m_passId); if (rpass) { - this->imageUser->pass = this->passId; - BKE_image_multilayer_index(image->rr, this->imageUser); + this->m_imageUser->pass = this->m_passId; + BKE_image_multilayer_index(this->m_image->rr, this->m_imageUser); return BaseImageOperation::getImBuf(); } return NULL; @@ -47,31 +47,29 @@ void MultilayerColorOperation::executePixel(float *color, float x, float y, Pixe { int yi = y; int xi = x; - if (this->imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) { + if (this->m_imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) { color[0] = 0.0f; color[1] = 0.0f; color[2] = 0.0f; color[3] = 0.0f; } else { - if (this->numberOfChannels == 4) { + if (this->m_numberOfChannels == 4) { switch (sampler) { case COM_PS_NEAREST: - neareast_interpolation_color(this->buffer, NULL, color, x, y); + neareast_interpolation_color(this->m_buffer, NULL, color, x, y); break; case COM_PS_BILINEAR: - bilinear_interpolation_color(this->buffer, NULL, color, x, y); + bilinear_interpolation_color(this->m_buffer, NULL, color, x, y); break; case COM_PS_BICUBIC: - bicubic_interpolation_color(this->buffer, NULL, color, x, y); + bicubic_interpolation_color(this->m_buffer, NULL, color, x, y); break; } } else { int offset = (yi * this->getWidth() + xi) * 3; - color[0] = this->imageBuffer[offset]; - color[1] = this->imageBuffer[offset + 1]; - color[2] = this->imageBuffer[offset + 2]; + copy_v3_v3(color, &this->m_imageBuffer[offset]); } } } @@ -80,11 +78,11 @@ void MultilayerValueOperation::executePixel(float *color, float x, float y, Pixe { int yi = y; int xi = x; - if (this->imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) { + if (this->m_imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) { color[0] = 0.0f; } else { - float result = this->imageBuffer[yi * this->getWidth() + xi]; + float result = this->m_imageBuffer[yi * this->getWidth() + xi]; color[0] = result; } } @@ -93,13 +91,11 @@ void MultilayerVectorOperation::executePixel(float *color, float x, float y, Pix { int yi = y; int xi = x; - if (this->imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) { + if (this->m_imageBuffer == NULL || xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight() ) { color[0] = 0.0f; } else { int offset = (yi * this->getWidth() + xi) * 3; - color[0] = this->imageBuffer[offset]; - color[1] = this->imageBuffer[offset + 1]; - color[2] = this->imageBuffer[offset + 2]; + copy_v3_v3(color, &this->m_imageBuffer[offset]); } } diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.h b/source/blender/compositor/operations/COM_MultilayerImageOperation.h index c33e65fc55b..f946c44dd35 100644 --- a/source/blender/compositor/operations/COM_MultilayerImageOperation.h +++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.h @@ -29,8 +29,8 @@ class MultilayerBaseOperation : public BaseImageOperation { private: - int passId; - RenderLayer *renderlayer; + int m_passId; + RenderLayer *m_renderlayer; protected: ImBuf *getImBuf(); public: @@ -38,7 +38,7 @@ public: * Constructor */ MultilayerBaseOperation(int pass); - void setRenderLayer(RenderLayer *renderlayer) { this->renderlayer = renderlayer; } + void setRenderLayer(RenderLayer *renderlayer) { this->m_renderlayer = renderlayer; } }; class MultilayerColorOperation : public MultilayerBaseOperation { diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.cpp b/source/blender/compositor/operations/COM_NormalizeOperation.cpp index 6d12141a455..8a83ef7f3ae 100644 --- a/source/blender/compositor/operations/COM_NormalizeOperation.cpp +++ b/source/blender/compositor/operations/COM_NormalizeOperation.cpp @@ -25,13 +25,13 @@ NormalizeOperation::NormalizeOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->imageReader = NULL; - this->cachedInstance = NULL; + this->m_imageReader = NULL; + this->m_cachedInstance = NULL; this->setComplex(true); } void NormalizeOperation::initExecution() { - this->imageReader = this->getInputSocketReader(0); + this->m_imageReader = this->getInputSocketReader(0); NodeOperation::initMutex(); } @@ -41,16 +41,16 @@ void NormalizeOperation::executePixel(float *color, int x, int y, MemoryBuffer * NodeTwoFloats *minmult = (NodeTwoFloats *)data; float output[4]; - this->imageReader->read(output, x, y, inputBuffers, NULL); + this->m_imageReader->read(output, x, y, inputBuffers, NULL); color[0] = (output[0] - minmult->x) * minmult->y; } void NormalizeOperation::deinitExecution() { - this->imageReader = NULL; - if (this->cachedInstance) { - delete cachedInstance; + this->m_imageReader = NULL; + if (this->m_cachedInstance) { + delete this->m_cachedInstance; } NodeOperation::deinitMutex(); } @@ -58,7 +58,8 @@ void NormalizeOperation::deinitExecution() bool NormalizeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti imageInput; - + if (this->m_cachedInstance) return false; + NodeOperation *operation = getInputOperation(0); imageInput.xmax = operation->getWidth(); imageInput.xmin = 0; @@ -77,8 +78,8 @@ bool NormalizeOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe void *NormalizeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { lockMutex(); - if (this->cachedInstance == NULL) { - MemoryBuffer *tile = (MemoryBuffer *)imageReader->initializeTileData(rect, memoryBuffers); + if (this->m_cachedInstance == NULL) { + MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect, memoryBuffers); /* using generic two floats struct to store x: min y: mult */ NodeTwoFloats *minmult = new NodeTwoFloats(); @@ -92,8 +93,12 @@ void *NormalizeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu float value; while (p--) { value = bc[0]; - maxv = max(value, maxv); - minv = min(value, minv); + if ((value > maxv) && (value <= BLENDER_ZMAX)) { + maxv = value; + } + if ((value < minv) && (value >= -BLENDER_ZMAX)) { + minv = value; + } bc += 4; } @@ -101,11 +106,11 @@ void *NormalizeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBu /* The rare case of flat buffer would cause a divide by 0 */ minmult->y = ((maxv != minv) ? 1.0f / (maxv - minv) : 0.f); - this->cachedInstance = minmult; + this->m_cachedInstance = minmult; } unlockMutex(); - return this->cachedInstance; + return this->m_cachedInstance; } void NormalizeOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.h b/source/blender/compositor/operations/COM_NormalizeOperation.h index de1c4d67bba..1f4a403434e 100644 --- a/source/blender/compositor/operations/COM_NormalizeOperation.h +++ b/source/blender/compositor/operations/COM_NormalizeOperation.h @@ -33,13 +33,13 @@ protected: /** * @brief Cached reference to the reader */ - SocketReader *imageReader; + SocketReader *m_imageReader; /** * @brief temporarily cache of the execution storage * it stores x->min and y->mult */ - NodeTwoFloats *cachedInstance; + NodeTwoFloats *m_cachedInstance; public: NormalizeOperation(); diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp index e71178a811d..087e7a15e39 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp +++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp @@ -92,101 +92,101 @@ static void write_buffer_rect(rcti *rect, MemoryBuffer **memoryBuffers, const bN OutputSingleLayerOperation::OutputSingleLayerOperation( - const Scene *scene, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path) + const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path) { - this->scene = scene; - this->tree = tree; + this->m_rd = rd; + this->m_tree = tree; this->addInputSocket(datatype); - this->outputBuffer = NULL; - this->datatype = datatype; - this->imageInput = NULL; + this->m_outputBuffer = NULL; + this->m_datatype = datatype; + this->m_imageInput = NULL; - this->format = format; - BLI_strncpy(this->path, path, sizeof(this->path)); + this->m_format = format; + BLI_strncpy(this->m_path, path, sizeof(this->m_path)); } void OutputSingleLayerOperation::initExecution() { - this->imageInput = getInputSocketReader(0); - this->outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->datatype); + this->m_imageInput = getInputSocketReader(0); + this->m_outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->m_datatype); } void OutputSingleLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) { - write_buffer_rect(rect, memoryBuffers, this->tree, imageInput, this->outputBuffer, this->getWidth(), this->datatype); + write_buffer_rect(rect, memoryBuffers, this->m_tree, this->m_imageInput, this->m_outputBuffer, this->getWidth(), this->m_datatype); } void OutputSingleLayerOperation::deinitExecution() { if (this->getWidth() * this->getHeight() != 0) { - int size = get_datatype_size(this->datatype); + int size = get_datatype_size(this->m_datatype); ImBuf *ibuf = IMB_allocImBuf(this->getWidth(), this->getHeight(), size * 8, 0); Main *bmain = G.main; /* TODO, have this passed along */ char filename[FILE_MAX]; ibuf->channels = size; - ibuf->rect_float = this->outputBuffer; + ibuf->rect_float = this->m_outputBuffer; ibuf->mall |= IB_rectfloat; - ibuf->dither = scene->r.dither_intensity; + ibuf->dither = this->m_rd->dither_intensity; - if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) + if (this->m_rd->color_mgt_flag & R_COLOR_MANAGEMENT) ibuf->profile = IB_PROFILE_LINEAR_RGB; - BKE_makepicstring(filename, this->path, bmain->name, this->scene->r.cfra, this->format->imtype, - (this->scene->r.scemode & R_EXTENSION), true); + BKE_makepicstring(filename, this->m_path, bmain->name, this->m_rd->cfra, this->m_format->imtype, + (this->m_rd->scemode & R_EXTENSION), true); - if (0 == BKE_imbuf_write(ibuf, filename, this->format)) + if (0 == BKE_imbuf_write(ibuf, filename, this->m_format)) printf("Cannot save Node File Output to %s\n", filename); else printf("Saved: %s\n", filename); IMB_freeImBuf(ibuf); } - this->outputBuffer = NULL; - this->imageInput = NULL; + this->m_outputBuffer = NULL; + this->m_imageInput = NULL; } -OutputOpenExrLayer::OutputOpenExrLayer(const char *name, DataType datatype) +OutputOpenExrLayer::OutputOpenExrLayer(const char *name_, DataType datatype_) { - BLI_strncpy(this->name, name, sizeof(this->name)); - this->datatype = datatype; + BLI_strncpy(this->name, name_, sizeof(this->name)); + this->datatype = datatype_; /* these are created in initExecution */ this->outputBuffer = 0; this->imageInput = 0; } OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation( - const Scene *scene, const bNodeTree *tree, const char *path, char exr_codec) + const RenderData *rd, const bNodeTree *tree, const char *path, char exr_codec) { - this->scene = scene; - this->tree = tree; + this->m_rd = rd; + this->m_tree = tree; - BLI_strncpy(this->path, path, sizeof(this->path)); - this->exr_codec = exr_codec; + BLI_strncpy(this->m_path, path, sizeof(this->m_path)); + this->m_exr_codec = exr_codec; } void OutputOpenExrMultiLayerOperation::add_layer(const char *name, DataType datatype) { this->addInputSocket(datatype); - layers.push_back(OutputOpenExrLayer(name, datatype)); + this->m_layers.push_back(OutputOpenExrLayer(name, datatype)); } void OutputOpenExrMultiLayerOperation::initExecution() { - for (unsigned int i = 0; i < layers.size(); ++i) { - layers[i].imageInput = getInputSocketReader(i); - layers[i].outputBuffer = init_buffer(this->getWidth(), this->getHeight(), layers[i].datatype); + for (unsigned int i = 0; i < this->m_layers.size(); ++i) { + this->m_layers[i].imageInput = getInputSocketReader(i); + this->m_layers[i].outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->m_layers[i].datatype); } } void OutputOpenExrMultiLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) { - for (unsigned int i = 0; i < layers.size(); ++i) { - write_buffer_rect(rect, memoryBuffers, this->tree, layers[i].imageInput, layers[i].outputBuffer, this->getWidth(), layers[i].datatype); + for (unsigned int i = 0; i < this->m_layers.size(); ++i) { + write_buffer_rect(rect, memoryBuffers, this->m_tree, this->m_layers[i].imageInput, this->m_layers[i].outputBuffer, this->getWidth(), this->m_layers[i].datatype); } } @@ -199,19 +199,19 @@ void OutputOpenExrMultiLayerOperation::deinitExecution() char filename[FILE_MAX]; void *exrhandle = IMB_exr_get_handle(); - BKE_makepicstring(filename, this->path, bmain->name, this->scene->r.cfra, R_IMF_IMTYPE_MULTILAYER, - (this->scene->r.scemode & R_EXTENSION), true); + BKE_makepicstring(filename, this->m_path, bmain->name, this->m_rd->cfra, R_IMF_IMTYPE_MULTILAYER, + (this->m_rd->scemode & R_EXTENSION), true); BLI_make_existing_file(filename); - for (unsigned int i = 0; i < layers.size(); ++i) { + for (unsigned int i = 0; i < this->m_layers.size(); ++i) { char channelname[EXR_TOT_MAXNAME]; - BLI_strncpy(channelname, layers[i].name, sizeof(channelname) - 2); + BLI_strncpy(channelname, this->m_layers[i].name, sizeof(channelname) - 2); char *channelname_ext = channelname + strlen(channelname); - float *buf = layers[i].outputBuffer; + float *buf = this->m_layers[i].outputBuffer; /* create channels */ - switch (layers[i].datatype) { + switch (this->m_layers[i].datatype) { case COM_DT_VALUE: strcpy(channelname_ext, ".V"); IMB_exr_add_channel(exrhandle, 0, channelname, 1, width, buf); @@ -241,7 +241,7 @@ void OutputOpenExrMultiLayerOperation::deinitExecution() } /* when the filename has no permissions, this can fail */ - if (IMB_exr_begin_write(exrhandle, filename, width, height, this->exr_codec)) { + if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec)) { IMB_exr_write_channels(exrhandle); } else { @@ -251,13 +251,13 @@ void OutputOpenExrMultiLayerOperation::deinitExecution() } IMB_exr_close(exrhandle); - for (unsigned int i = 0; i < layers.size(); ++i) { - if (layers[i].outputBuffer) { - MEM_freeN(layers[i].outputBuffer); - layers[i].outputBuffer = NULL; + for (unsigned int i = 0; i < this->m_layers.size(); ++i) { + if (this->m_layers[i].outputBuffer) { + MEM_freeN(this->m_layers[i].outputBuffer); + this->m_layers[i].outputBuffer = NULL; } - layers[i].imageInput = NULL; + this->m_layers[i].imageInput = NULL; } } } diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h index cfc5f7e41f2..60244a8bf72 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.h +++ b/source/blender/compositor/operations/COM_OutputFileOperation.h @@ -32,18 +32,18 @@ /* Writes the image to a single-layer file. */ class OutputSingleLayerOperation : public NodeOperation { private: - const Scene *scene; - const bNodeTree *tree; + const RenderData *m_rd; + const bNodeTree *m_tree; - ImageFormatData *format; - char path[FILE_MAX]; + ImageFormatData *m_format; + char m_path[FILE_MAX]; - float *outputBuffer; - DataType datatype; - SocketReader *imageInput; + float *m_outputBuffer; + DataType m_datatype; + SocketReader *m_imageInput; public: - OutputSingleLayerOperation(const Scene *scene, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path); + OutputSingleLayerOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path); void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); bool isOutputOperation(bool rendering) const { return true; } @@ -67,15 +67,15 @@ class OutputOpenExrMultiLayerOperation : public NodeOperation { private: typedef std::vector<OutputOpenExrLayer> LayerList; - const Scene *scene; - const bNodeTree *tree; + const RenderData *m_rd; + const bNodeTree *m_tree; - char path[FILE_MAX]; - char exr_codec; - LayerList layers; + char m_path[FILE_MAX]; + char m_exr_codec; + LayerList m_layers; public: - OutputOpenExrMultiLayerOperation(const Scene *scene, const bNodeTree *tree, const char *path, char exr_codec); + OutputOpenExrMultiLayerOperation(const RenderData *rd, const bNodeTree *tree, const char *path, char exr_codec); void add_layer(const char *name, DataType datatype); diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp index 54a95af33b9..55e94568688 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.cpp +++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp @@ -42,39 +42,41 @@ extern "C" { PreviewOperation::PreviewOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); - this->outputBuffer = NULL; - this->input = NULL; - this->divider = 1.0f; - this->node = NULL; + this->m_outputBuffer = NULL; + this->m_input = NULL; + this->m_divider = 1.0f; + this->m_node = NULL; } void PreviewOperation::initExecution() { - this->input = getInputSocketReader(0); - if (!this->node->preview) { - this->node->preview = (bNodePreview *)MEM_callocN(sizeof(bNodePreview), "node preview"); + this->m_input = getInputSocketReader(0); + if (!this->m_node->preview) { + this->m_node->preview = (bNodePreview *)MEM_callocN(sizeof(bNodePreview), "node preview"); } else { - if (this->getWidth() == (unsigned int)this->node->preview->xsize && this->getHeight() == (unsigned int)this->node->preview->ysize) { - this->outputBuffer = this->node->preview->rect; + if (this->getWidth() == (unsigned int)this->m_node->preview->xsize && + this->getHeight() == (unsigned int)this->m_node->preview->ysize) + { + this->m_outputBuffer = this->m_node->preview->rect; } } - if (this->outputBuffer == NULL) { - this->outputBuffer = (unsigned char *)MEM_callocN(sizeof(unsigned char) * 4 * getWidth() * getHeight(), "PreviewOperation"); - if (this->node->preview->rect) { - MEM_freeN(this->node->preview->rect); + if (this->m_outputBuffer == NULL) { + this->m_outputBuffer = (unsigned char *)MEM_callocN(sizeof(unsigned char) * 4 * getWidth() * getHeight(), "PreviewOperation"); + if (this->m_node->preview->rect) { + MEM_freeN(this->m_node->preview->rect); } - this->node->preview->xsize = getWidth(); - this->node->preview->ysize = getHeight(); - this->node->preview->rect = outputBuffer; + this->m_node->preview->xsize = getWidth(); + this->m_node->preview->ysize = getHeight(); + this->m_node->preview->rect = this->m_outputBuffer; } } void PreviewOperation::deinitExecution() { - this->outputBuffer = NULL; - this->input = NULL; + this->m_outputBuffer = NULL; + this->m_input = NULL; } void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) @@ -84,16 +86,16 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber, Memory for (int y = rect->ymin; y < rect->ymax; y++) { offset = (y * getWidth() + rect->xmin) * 4; for (int x = rect->xmin; x < rect->xmax; x++) { - float rx = floor(x / divider); - float ry = floor(y / divider); + float rx = floor(x / this->m_divider); + float ry = floor(y / this->m_divider); color[0] = 0.0f; color[1] = 0.0f; color[2] = 0.0f; color[3] = 1.0f; - input->read(color, rx, ry, COM_PS_NEAREST, memoryBuffers); + this->m_input->read(color, rx, ry, COM_PS_NEAREST, memoryBuffers); linearrgb_to_srgb_v4(color, color); - F4TOCHAR4(color, outputBuffer + offset); + F4TOCHAR4(color, this->m_outputBuffer + offset); offset += 4; } } @@ -102,10 +104,10 @@ bool PreviewOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferO { rcti newInput; - newInput.xmin = input->xmin / divider; - newInput.xmax = input->xmax / divider; - newInput.ymin = input->ymin / divider; - newInput.ymax = input->ymax / divider; + newInput.xmin = input->xmin / this->m_divider; + newInput.xmax = input->xmax / this->m_divider; + newInput.ymin = input->ymin / this->m_divider; + newInput.ymax = input->ymax / this->m_divider; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } @@ -114,15 +116,15 @@ void PreviewOperation::determineResolution(unsigned int resolution[], unsigned i NodeOperation::determineResolution(resolution, preferredResolution); int width = resolution[0]; int height = resolution[1]; - this->divider = 0.0f; + this->m_divider = 0.0f; if (width > height) { - divider = COM_PREVIEW_SIZE / (width - 1); + this->m_divider = COM_PREVIEW_SIZE / (width - 1); } else { - divider = COM_PREVIEW_SIZE / (height - 1); + this->m_divider = COM_PREVIEW_SIZE / (height - 1); } - width = width * divider; - height = height * divider; + width = width * this->m_divider; + height = height * this->m_divider; resolution[0] = width; resolution[1] = height; diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h index f9ce0c644a1..e7b8ba55ae0 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.h +++ b/source/blender/compositor/operations/COM_PreviewOperation.h @@ -28,14 +28,14 @@ class PreviewOperation : public NodeOperation { protected: - unsigned char *outputBuffer; + unsigned char *m_outputBuffer; /** * @brief holds reference to the SDNA bNode, where this nodes will render the preview image for */ - bNode *node; - SocketReader *input; - float divider; + bNode *m_node; + SocketReader *m_input; + float m_divider; public: PreviewOperation(); @@ -46,7 +46,7 @@ public: void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); - void setbNode(bNode *node) { this->node = node; } + void setbNode(bNode *node) { this->m_node = node; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); bool isPreviewOperation() { return true; } diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp index 77f2a06b29b..74145c52a5d 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp @@ -27,20 +27,23 @@ ProjectorLensDistortionOperation::ProjectorLensDistortionOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); - this->inputProgram = NULL; + this->m_inputProgram = NULL; + this->m_dispersionAvailable = false; + this->m_dispersion = 0.0f; } void ProjectorLensDistortionOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); - kr = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f); - kr2 = kr * 20; + this->initMutex(); + this->m_inputProgram = this->getInputSocketReader(0); } void *ProjectorLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers); + updateDispersion(memoryBuffers); + void *buffer = this->m_inputProgram->initializeTileData(NULL, memoryBuffers); return buffer; } @@ -52,26 +55,49 @@ void ProjectorLensDistortionOperation::executePixel(float *color, int x, int y, const float v = (y + 0.5f) / height; const float u = (x + 0.5f) / width; MemoryBuffer *inputBuffer = (MemoryBuffer *)data; - inputBuffer->readCubic(inputValue, (u * width + kr2) - 0.5f, v * height - 0.5f); + inputBuffer->readCubic(inputValue, (u * width + this->m_kr2) - 0.5f, v * height - 0.5f); color[0] = inputValue[0]; inputBuffer->read(inputValue, x, y); color[1] = inputValue[1]; - inputBuffer->readCubic(inputValue, (u * width - kr2) - 0.5f, v * height - 0.5f); + inputBuffer->readCubic(inputValue, (u * width - this->m_kr2) - 0.5f, v * height - 0.5f); color[2] = inputValue[2]; color[3] = 1.0f; } void ProjectorLensDistortionOperation::deinitExecution() { - this->inputProgram = NULL; + this->deinitMutex(); + this->m_inputProgram = NULL; } bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { rcti newInput; - newInput.ymax = input->ymax; - newInput.ymin = input->ymin; - newInput.xmin = input->xmin - kr2 - 2; - newInput.xmax = input->xmax + kr2 + 2; + if (this->m_dispersionAvailable) { + newInput.ymax = input->ymax; + newInput.ymin = input->ymin; + newInput.xmin = input->xmin - this->m_kr2 - 2; + newInput.xmax = input->xmax + this->m_kr2 + 2; + } else { + newInput.xmin = input->xmin-7; //(0.25f*20*1)+2 == worse case dispersion + newInput.ymin = input->ymin; + newInput.ymax = input->ymax; + newInput.xmax = input->xmax+7; //(0.25f*20*1)+2 == worse case dispersion + } return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } + +void ProjectorLensDistortionOperation::updateDispersion(MemoryBuffer **inputBuffers) +{ + if (this->m_dispersionAvailable) return; + this->lockMutex(); + if (!this->m_dispersionAvailable) { + float result[4]; + this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); + this->m_dispersion = result[0]; + this->m_kr = 0.25f * MAX2(MIN2(this->m_dispersion, 1.f), 0.f); + this->m_kr2 = this->m_kr * 20; + this->m_dispersionAvailable = true; + } + this->unlockMutex(); +} diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h index 2e188617ab5..c658d66429a 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h @@ -30,12 +30,14 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; - NodeLensDist *data; + NodeLensDist *m_data; - float dispersion; - float kr, kr2; + float m_dispersion; + bool m_dispersionAvailable; + + float m_kr, m_kr2; public: ProjectorLensDistortionOperation(); @@ -55,10 +57,11 @@ public: */ void deinitExecution(); - void setData(NodeLensDist *data) { this->data = data; } - void setDispertion(float dispersion) { this->dispersion = dispersion; } + void setData(NodeLensDist *data) { this->m_data = data; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + void updateDispersion(MemoryBuffer **inputBuffers); + }; #endif diff --git a/source/blender/compositor/operations/COM_QualityStepHelper.cpp b/source/blender/compositor/operations/COM_QualityStepHelper.cpp index 18b3b106138..d99d6f28eff 100644 --- a/source/blender/compositor/operations/COM_QualityStepHelper.cpp +++ b/source/blender/compositor/operations/COM_QualityStepHelper.cpp @@ -24,45 +24,45 @@ QualityStepHelper::QualityStepHelper() { - this->quality = COM_QUALITY_HIGH; - this->step = 1; - this->offsetadd = 4; + this->m_quality = COM_QUALITY_HIGH; + this->m_step = 1; + this->m_offsetadd = 4; } void QualityStepHelper::initExecution(QualityHelper helper) { switch (helper) { case COM_QH_INCREASE: - switch (this->quality) { + switch (this->m_quality) { case COM_QUALITY_HIGH: default: - this->step = 1; - this->offsetadd = 4; + this->m_step = 1; + this->m_offsetadd = 4; break; case COM_QUALITY_MEDIUM: - this->step = 2; - this->offsetadd = 8; + this->m_step = 2; + this->m_offsetadd = 8; break; case COM_QUALITY_LOW: - this->step = 3; - this->offsetadd = 12; + this->m_step = 3; + this->m_offsetadd = 12; break; } break; case COM_QH_MULTIPLY: - switch (this->quality) { + switch (this->m_quality) { case COM_QUALITY_HIGH: default: - this->step = 1; - this->offsetadd = 4; + this->m_step = 1; + this->m_offsetadd = 4; break; case COM_QUALITY_MEDIUM: - this->step = 2; - this->offsetadd = 8; + this->m_step = 2; + this->m_offsetadd = 8; break; case COM_QUALITY_LOW: - this->step = 4; - this->offsetadd = 16; + this->m_step = 4; + this->m_offsetadd = 16; break; } break; diff --git a/source/blender/compositor/operations/COM_QualityStepHelper.h b/source/blender/compositor/operations/COM_QualityStepHelper.h index aef80e22e38..34e2ba1b47c 100644 --- a/source/blender/compositor/operations/COM_QualityStepHelper.h +++ b/source/blender/compositor/operations/COM_QualityStepHelper.h @@ -31,9 +31,9 @@ typedef enum QualityHelper { class QualityStepHelper { private: - CompositorQuality quality; - int step; - int offsetadd; + CompositorQuality m_quality; + int m_step; + int m_offsetadd; protected: /** @@ -41,13 +41,13 @@ protected: */ void initExecution(QualityHelper helper); - inline int getStep() const { return this->step; } - inline int getOffsetAdd() const { return this->offsetadd; } + inline int getStep() const { return this->m_step; } + inline int getOffsetAdd() const { return this->m_offsetadd; } public: QualityStepHelper(); - void setQuality(CompositorQuality quality) { this->quality = quality; } + void setQuality(CompositorQuality quality) { this->m_quality = quality; } }; #endif diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp index fa1f0280207..76e6921503e 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp @@ -27,7 +27,7 @@ ReadBufferOperation::ReadBufferOperation() : NodeOperation() { this->addOutputSocket(COM_DT_COLOR); - this->offset = 0; + this->m_offset = 0; } void *ReadBufferOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) @@ -37,31 +37,40 @@ void *ReadBufferOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB void ReadBufferOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { - if (this->memoryProxy != NULL) { - WriteBufferOperation *operation = memoryProxy->getWriteBufferOperation(); + if (this->m_memoryProxy != NULL) { + WriteBufferOperation *operation = this->m_memoryProxy->getWriteBufferOperation(); operation->determineResolution(resolution, preferredResolution); operation->setResolution(resolution); /// @todo: may not occur!, but does with blur node - if (memoryProxy->getExecutor()) memoryProxy->getExecutor()->setResolution(resolution); + if (this->m_memoryProxy->getExecutor()) { + this->m_memoryProxy->getExecutor()->setResolution(resolution); + } } } void ReadBufferOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - MemoryBuffer *inputBuffer = inputBuffers[this->offset]; - if (inputBuffer) { - if (sampler == COM_PS_NEAREST) { - inputBuffer->read(color, x, y); - } - else { - inputBuffer->readCubic(color, x, y); + if (inputBuffers) { + MemoryBuffer *inputBuffer = inputBuffers[this->m_offset]; + if (inputBuffer) { + if (sampler == COM_PS_NEAREST) { + inputBuffer->read(color, x, y); + } + else { + inputBuffer->readCubic(color, x, y); + } } + } else { + color[0] = 0.0f; + color[1] = 0.0f; + color[2] = 0.0f; + color[3] = 0.0f; } } void ReadBufferOperation::executePixel(float *color, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]) { - MemoryBuffer *inputBuffer = inputBuffers[this->offset]; + MemoryBuffer *inputBuffer = inputBuffers[this->m_offset]; if (inputBuffer) { inputBuffer->readEWA(color, x, y, dx, dy); } @@ -76,9 +85,10 @@ bool ReadBufferOperation::determineDependingAreaOfInterest(rcti *input, ReadBuff return false; } -void ReadBufferOperation::readResolutionFromWriteBuffer() { - if (this->memoryProxy != NULL) { - WriteBufferOperation *operation = memoryProxy->getWriteBufferOperation(); +void ReadBufferOperation::readResolutionFromWriteBuffer() +{ + if (this->m_memoryProxy != NULL) { + WriteBufferOperation *operation = this->m_memoryProxy->getWriteBufferOperation(); this->setWidth(operation->getWidth()); this->setHeight(operation->getHeight()); } diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h index 576aa194bc5..de0c69c0ecc 100644 --- a/source/blender/compositor/operations/COM_ReadBufferOperation.h +++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h @@ -28,23 +28,23 @@ class ReadBufferOperation : public NodeOperation { private: - MemoryProxy *memoryProxy; - unsigned int offset; + MemoryProxy *m_memoryProxy; + unsigned int m_offset; public: ReadBufferOperation(); int isBufferOperation() { return true; } - void setMemoryProxy(MemoryProxy *memoryProxy) { this->memoryProxy = memoryProxy; } - MemoryProxy *getMemoryProxy() { return this->memoryProxy; } + void setMemoryProxy(MemoryProxy *memoryProxy) { this->m_memoryProxy = memoryProxy; } + MemoryProxy *getMemoryProxy() { return this->m_memoryProxy; } void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); void executePixel(float *color, float x, float y, float dx, float dy, MemoryBuffer * inputBuffers[]); const bool isReadBufferOperation() const { return true; } - void setOffset(unsigned int offset) { this->offset = offset; } - unsigned int getOffset() { return this->offset; } + void setOffset(unsigned int offset) { this->m_offset = offset; } + unsigned int getOffset() { return this->m_offset; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return memoryBuffers[offset]; } + MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return memoryBuffers[this->m_offset]; } void readResolutionFromWriteBuffer(); }; diff --git a/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp b/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp index f27af3c25f5..e4543c06d9b 100644 --- a/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp +++ b/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp @@ -33,10 +33,10 @@ extern "C" { RenderLayersBaseProg::RenderLayersBaseProg(int renderpass, int elementsize) : NodeOperation() { - this->renderpass = renderpass; + this->m_renderpass = renderpass; this->setScene(NULL); - this->inputBuffer = NULL; - this->elementsize = elementsize; + this->m_inputBuffer = NULL; + this->m_elementsize = elementsize; } @@ -55,10 +55,10 @@ void RenderLayersBaseProg::initExecution() RenderLayer *rl = RE_GetRenderLayer(rr, srl->name); if (rl && rl->rectf) { - this->inputBuffer = RE_RenderLayerGetPass(rl, renderpass); + this->m_inputBuffer = RE_RenderLayerGetPass(rl, this->m_renderpass); - if (this->inputBuffer == NULL || renderpass == SCE_PASS_COMBINED) { - this->inputBuffer = rl->rectf; + if (this->m_inputBuffer == NULL || this->m_renderpass == SCE_PASS_COMBINED) { + this->m_inputBuffer = rl->rectf; } } } @@ -74,38 +74,30 @@ void RenderLayersBaseProg::executePixel(float *output, float x, float y, PixelSa int ix = x; int iy = y; - if (inputBuffer == NULL || ix < 0 || iy < 0 || ix >= (int)this->getWidth() || iy >= (int)this->getHeight() ) { - output[0] = 0.0f; - output[1] = 0.0f; - output[2] = 0.0f; - output[3] = 0.0f; + if (this->m_inputBuffer == NULL || ix < 0 || iy < 0 || ix >= (int)this->getWidth() || iy >= (int)this->getHeight() ) { + zero_v4(output); } else { - unsigned int offset = (iy * this->getWidth() + ix) * elementsize; - if (elementsize == 1) { - output[0] = inputBuffer[offset]; + unsigned int offset = (iy * this->getWidth() + ix) * this->m_elementsize; + if (this->m_elementsize == 1) { + output[0] = this->m_inputBuffer[offset]; output[1] = 0.0f; output[2] = 0.0f; output[3] = 0.0f; } - else if (elementsize == 3) { - output[0] = inputBuffer[offset]; - output[1] = inputBuffer[offset + 1]; - output[2] = inputBuffer[offset + 2]; + else if (this->m_elementsize == 3) { + copy_v3_v3(output, &this->m_inputBuffer[offset]); output[3] = 1.0f; } else { - output[0] = inputBuffer[offset]; - output[1] = inputBuffer[offset + 1]; - output[2] = inputBuffer[offset + 2]; - output[3] = inputBuffer[offset + 3]; + copy_v4_v4(output, &this->m_inputBuffer[offset]); } } } void RenderLayersBaseProg::deinitExecution() { - this->inputBuffer = NULL; + this->m_inputBuffer = NULL; } void RenderLayersBaseProg::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) diff --git a/source/blender/compositor/operations/COM_RenderLayersBaseProg.h b/source/blender/compositor/operations/COM_RenderLayersBaseProg.h index ce2b8f767b6..a18b515bd7b 100644 --- a/source/blender/compositor/operations/COM_RenderLayersBaseProg.h +++ b/source/blender/compositor/operations/COM_RenderLayersBaseProg.h @@ -45,24 +45,24 @@ private: /** * Reference to the scene object. */ - Scene *scene; + Scene *m_scene; /** * layerId of the layer where this operation needs to get its data from */ - short layerId; + short m_layerId; /** * cached instance to the float buffer inside the layer */ - float *inputBuffer; + float *m_inputBuffer; /** * renderpass where this operation needs to get its data from */ - int renderpass; + int m_renderpass; - int elementsize; + int m_elementsize; protected: /** @@ -78,7 +78,7 @@ protected: /** * retrieve the reference to the float buffer of the renderer. */ - inline float *getInputBuffer() { return this->inputBuffer; } + inline float *getInputBuffer() { return this->m_inputBuffer; } public: /** @@ -86,10 +86,10 @@ public: * @see RenderLayerNode to set the actual scene where * the data will be retrieved from. */ - void setScene(Scene *scene) { this->scene = scene; } - Scene *getScene() { return this->scene; } - void setLayerId(short layerId) { this->layerId = layerId; } - short getLayerId() { return this->layerId; } + void setScene(Scene *scene) { this->m_scene = scene; } + Scene *getScene() { return this->m_scene; } + void setLayerId(short layerId) { this->m_layerId = layerId; } + short getLayerId() { return this->m_layerId; } void initExecution(); void deinitExecution(); void executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]); diff --git a/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp b/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp index 14c3d652c42..f21585844ff 100644 --- a/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp +++ b/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp @@ -22,7 +22,7 @@ #include "COM_RenderLayersImageProg.h" -RenderLayersColourProg::RenderLayersColourProg() : RenderLayersBaseProg(SCE_PASS_COMBINED, 4) +RenderLayersColorProg::RenderLayersColorProg() : RenderLayersBaseProg(SCE_PASS_COMBINED, 4) { this->addOutputSocket(COM_DT_COLOR); } diff --git a/source/blender/compositor/operations/COM_RenderLayersImageProg.h b/source/blender/compositor/operations/COM_RenderLayersImageProg.h index b6ddac425cb..2d63bad235b 100644 --- a/source/blender/compositor/operations/COM_RenderLayersImageProg.h +++ b/source/blender/compositor/operations/COM_RenderLayersImageProg.h @@ -20,15 +20,15 @@ * Monique Dewanchand */ -#ifndef _COM_RenderLayersColourProg_h -#define _COM_RenderLayersColourProg_h +#ifndef _COM_RenderLayersColorProg_h +#define _COM_RenderLayersColorProg_h #include "COM_RenderLayersBaseProg.h" /// @TODO rename to image operation -class RenderLayersColourProg : public RenderLayersBaseProg { +class RenderLayersColorProg : public RenderLayersBaseProg { public: - RenderLayersColourProg(); + RenderLayersColorProg(); }; #endif diff --git a/source/blender/compositor/operations/COM_RenderLayersMistOperation.h b/source/blender/compositor/operations/COM_RenderLayersMistOperation.h index 8c0ee9bfcab..ad838c9e340 100644 --- a/source/blender/compositor/operations/COM_RenderLayersMistOperation.h +++ b/source/blender/compositor/operations/COM_RenderLayersMistOperation.h @@ -1,3 +1,25 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + #ifndef _COM_RenderLayersMistOperation_h #define _COM_RenderLayersMistOperation_h diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp index ac06048faf3..086ce917e7e 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.cpp +++ b/source/blender/compositor/operations/COM_RotateOperation.cpp @@ -29,40 +29,41 @@ RotateOperation::RotateOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->imageSocket = NULL; - this->degreeSocket = NULL; - this->doDegree2RadConversion = false; - this->isDegreeSet = false; + this->m_imageSocket = NULL; + this->m_degreeSocket = NULL; + this->m_doDegree2RadConversion = false; + this->m_isDegreeSet = false; } void RotateOperation::initExecution() { - this->imageSocket = this->getInputSocketReader(0); - this->degreeSocket = this->getInputSocketReader(1); - this->centerX = this->getWidth() / 2.0; - this->centerY = this->getHeight() / 2.0; + this->m_imageSocket = this->getInputSocketReader(0); + this->m_degreeSocket = this->getInputSocketReader(1); + this->m_centerX = this->getWidth() / 2.0; + this->m_centerY = this->getHeight() / 2.0; } void RotateOperation::deinitExecution() { - this->imageSocket = NULL; - this->degreeSocket = NULL; + this->m_imageSocket = NULL; + this->m_degreeSocket = NULL; } -inline void RotateOperation::ensureDegree() { - if (!isDegreeSet) { +inline void RotateOperation::ensureDegree() +{ + if (!this->m_isDegreeSet) { float degree[4]; - this->degreeSocket->read(degree, 0, 0, COM_PS_NEAREST, NULL); + this->m_degreeSocket->read(degree, 0, 0, COM_PS_NEAREST, NULL); double rad; - if (this->doDegree2RadConversion) { + if (this->m_doDegree2RadConversion) { rad = DEG2RAD((double)degree[0]); } else { rad = degree[0]; } - this->cosine = cos(rad); - this->sine = sin(rad); + this->m_cosine = cos(rad); + this->m_sine = sin(rad); - isDegreeSet = true; + this->m_isDegreeSet = true; } } @@ -70,11 +71,11 @@ inline void RotateOperation::ensureDegree() { void RotateOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { ensureDegree(); - const float dy = y - this->centerY; - const float dx = x - this->centerX; - const float nx = this->centerX + (this->cosine * dx + this->sine * dy); - const float ny = this->centerY + (-this->sine * dx + this->cosine * dy); - this->imageSocket->read(color, nx, ny, sampler, inputBuffers); + const float dy = y - this->m_centerY; + const float dx = x - this->m_centerX; + const float nx = this->m_centerX + (this->m_cosine * dx + this->m_sine * dy); + const float ny = this->m_centerY + (-this->m_sine * dx + this->m_cosine * dy); + this->m_imageSocket->read(color, nx, ny, sampler, inputBuffers); } bool RotateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -82,19 +83,19 @@ bool RotateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOp ensureDegree(); rcti newInput; - const float dxmin = input->xmin - this->centerX; - const float dymin = input->ymin - this->centerY; - const float dxmax = input->xmax - this->centerX; - const float dymax = input->ymax - this->centerY; + const float dxmin = input->xmin - this->m_centerX; + const float dymin = input->ymin - this->m_centerY; + const float dxmax = input->xmax - this->m_centerX; + const float dymax = input->ymax - this->m_centerY; - const float x1 = this->centerX + (this->cosine * dxmin + this->sine * dymin); - const float x2 = this->centerX + (this->cosine * dxmax + this->sine * dymin); - const float x3 = this->centerX + (this->cosine * dxmin + this->sine * dymax); - const float x4 = this->centerX + (this->cosine * dxmax + this->sine * dymax); - const float y1 = this->centerY + (-this->sine * dxmin + this->cosine * dymin); - const float y2 = this->centerY + (-this->sine * dxmax + this->cosine * dymin); - const float y3 = this->centerY + (-this->sine * dxmin + this->cosine * dymax); - const float y4 = this->centerY + (-this->sine * dxmax + this->cosine * dymax); + const float x1 = this->m_centerX + (this->m_cosine * dxmin + this->m_sine * dymin); + const float x2 = this->m_centerX + (this->m_cosine * dxmax + this->m_sine * dymin); + const float x3 = this->m_centerX + (this->m_cosine * dxmin + this->m_sine * dymax); + const float x4 = this->m_centerX + (this->m_cosine * dxmax + this->m_sine * dymax); + const float y1 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymin); + const float y2 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymin); + const float y3 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymax); + const float y4 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymax); const float minx = min(x1, min(x2, min(x3, x4))); const float maxx = max(x1, max(x2, max(x3, x4))); const float miny = min(y1, min(y2, min(y3, y4))); diff --git a/source/blender/compositor/operations/COM_RotateOperation.h b/source/blender/compositor/operations/COM_RotateOperation.h index bf7355da80e..9e6dd3987d1 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.h +++ b/source/blender/compositor/operations/COM_RotateOperation.h @@ -27,21 +27,21 @@ class RotateOperation : public NodeOperation { private: - SocketReader *imageSocket; - SocketReader *degreeSocket; - float centerX; - float centerY; - float cosine; - float sine; - bool doDegree2RadConversion; - bool isDegreeSet; + SocketReader *m_imageSocket; + SocketReader *m_degreeSocket; + float m_centerX; + float m_centerY; + float m_cosine; + float m_sine; + bool m_doDegree2RadConversion; + bool m_isDegreeSet; public: RotateOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); void initExecution(); void deinitExecution(); - void setDoDegree2RadConversion(bool abool) { this->doDegree2RadConversion = abool; } + void setDoDegree2RadConversion(bool abool) { this->m_doDegree2RadConversion = abool; } void ensureDegree(); }; diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp index 2e23df73b67..6a1f7b62203 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.cpp +++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp @@ -33,24 +33,24 @@ ScaleOperation::ScaleOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputOperation = NULL; - this->inputXOperation = NULL; - this->inputYOperation = NULL; + this->m_inputOperation = NULL; + this->m_inputXOperation = NULL; + this->m_inputYOperation = NULL; } void ScaleOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); - this->inputXOperation = this->getInputSocketReader(1); - this->inputYOperation = this->getInputSocketReader(2); - this->centerX = this->getWidth() / 2.0; - this->centerY = this->getHeight() / 2.0; + this->m_inputOperation = this->getInputSocketReader(0); + this->m_inputXOperation = this->getInputSocketReader(1); + this->m_inputYOperation = this->getInputSocketReader(2); + this->m_centerX = this->getWidth() / 2.0; + this->m_centerY = this->getHeight() / 2.0; } void ScaleOperation::deinitExecution() { - this->inputOperation = NULL; - this->inputXOperation = NULL; - this->inputYOperation = NULL; + this->m_inputOperation = NULL; + this->m_inputXOperation = NULL; + this->m_inputYOperation = NULL; } @@ -63,15 +63,15 @@ void ScaleOperation::executePixel(float *color, float x, float y, PixelSampler s float scaleX[4]; float scaleY[4]; - this->inputXOperation->read(scaleX, x, y, sampler, inputBuffers); - this->inputYOperation->read(scaleY, x, y, sampler, inputBuffers); + this->m_inputXOperation->read(scaleX, x, y, sampler, inputBuffers); + this->m_inputYOperation->read(scaleY, x, y, sampler, inputBuffers); const float scx = scaleX[0]; const float scy = scaleY[0]; - float nx = this->centerX + (x - this->centerX) / scx; - float ny = this->centerY + (y - this->centerY) / scy; - this->inputOperation->read(color, nx, ny, sampler, inputBuffers); + float nx = this->m_centerX + (x - this->m_centerX) / scx; + float ny = this->m_centerY + (y - this->m_centerY) / scy; + this->m_inputOperation->read(color, nx, ny, sampler, inputBuffers); } bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -80,16 +80,16 @@ bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOpe float scaleX[4]; float scaleY[4]; - this->inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST, NULL); - this->inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST, NULL); + this->m_inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST, NULL); + this->m_inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST, NULL); const float scx = scaleX[0]; const float scy = scaleY[0]; - newInput.xmax = this->centerX + (input->xmax - this->centerX) / scx; - newInput.xmin = this->centerX + (input->xmin - this->centerX) / scx; - newInput.ymax = this->centerY + (input->ymax - this->centerY) / scy; - newInput.ymin = this->centerY + (input->ymin - this->centerY) / scy; + 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; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } @@ -103,24 +103,24 @@ ScaleAbsoluteOperation::ScaleAbsoluteOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputOperation = NULL; - this->inputXOperation = NULL; - this->inputYOperation = NULL; + this->m_inputOperation = NULL; + this->m_inputXOperation = NULL; + this->m_inputYOperation = NULL; } void ScaleAbsoluteOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); - this->inputXOperation = this->getInputSocketReader(1); - this->inputYOperation = this->getInputSocketReader(2); - this->centerX = this->getWidth() / 2.0; - this->centerY = this->getHeight() / 2.0; + this->m_inputOperation = this->getInputSocketReader(0); + this->m_inputXOperation = this->getInputSocketReader(1); + this->m_inputYOperation = this->getInputSocketReader(2); + this->m_centerX = this->getWidth() / 2.0; + this->m_centerY = this->getHeight() / 2.0; } void ScaleAbsoluteOperation::deinitExecution() { - this->inputOperation = NULL; - this->inputXOperation = NULL; - this->inputYOperation = NULL; + this->m_inputOperation = NULL; + this->m_inputXOperation = NULL; + this->m_inputYOperation = NULL; } @@ -133,8 +133,8 @@ void ScaleAbsoluteOperation::executePixel(float *color, float x, float y, PixelS float scaleX[4]; float scaleY[4]; - this->inputXOperation->read(scaleX, x, y, sampler, inputBuffers); - this->inputYOperation->read(scaleY, x, y, sampler, inputBuffers); + this->m_inputXOperation->read(scaleX, x, y, sampler, inputBuffers); + this->m_inputYOperation->read(scaleY, x, y, sampler, inputBuffers); const float scx = scaleX[0]; // target absolute scale const float scy = scaleY[0]; // target absolute scale @@ -145,10 +145,10 @@ void ScaleAbsoluteOperation::executePixel(float *color, float x, float y, PixelS float relativeXScale = scx / width; float relativeYScale = scy / height; - float nx = this->centerX + (x - this->centerX) / relativeXScale; - float ny = this->centerY + (y - this->centerY) / relativeYScale; + float nx = this->m_centerX + (x - this->m_centerX) / relativeXScale; + float ny = this->m_centerY + (y - this->m_centerY) / relativeYScale; - this->inputOperation->read(color, nx, ny, sampler, inputBuffers); + this->m_inputOperation->read(color, nx, ny, sampler, inputBuffers); } bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -157,8 +157,8 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadB float scaleX[4]; float scaleY[4]; - this->inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST, NULL); - this->inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST, NULL); + this->m_inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST, NULL); + this->m_inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST, NULL); const float scx = scaleX[0]; const float scy = scaleY[0]; @@ -168,10 +168,10 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadB float relateveXScale = scx / width; float relateveYScale = scy / height; - newInput.xmax = this->centerX + (input->xmax - this->centerX) / relateveXScale; - newInput.xmin = this->centerX + (input->xmin - this->centerX) / relateveXScale; - newInput.ymax = this->centerY + (input->ymax - this->centerY) / relateveYScale; - newInput.ymin = this->centerY + (input->ymin - this->centerY) / relateveYScale; + 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; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } @@ -180,59 +180,59 @@ bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadB // Absolute fixed siez ScaleFixedSizeOperation::ScaleFixedSizeOperation() : NodeOperation() { - this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void ScaleFixedSizeOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); - this->relX = inputOperation->getWidth() / (float)this->newWidth; - this->relY = inputOperation->getHeight() / (float)this->newHeight; + this->m_inputOperation = this->getInputSocketReader(0); + this->m_relX = this->m_inputOperation->getWidth() / (float)this->m_newWidth; + this->m_relY = this->m_inputOperation->getHeight() / (float)this->m_newHeight; /* *** all the options below are for a fairly special case - camera framing *** */ - if (this->offsetX != 0.0f || this->offsetY != 0.0f) { - this->is_offset = true; + if (this->m_offsetX != 0.0f || this->m_offsetY != 0.0f) { + this->m_is_offset = true; - if (this->newWidth > this->newHeight) { - this->offsetX *= this->newWidth; - this->offsetY *= this->newWidth; + if (this->m_newWidth > this->m_newHeight) { + this->m_offsetX *= this->m_newWidth; + this->m_offsetY *= this->m_newWidth; } else { - this->offsetX *= this->newHeight; - this->offsetY *= this->newHeight; + this->m_offsetX *= this->m_newHeight; + this->m_offsetY *= this->m_newHeight; } } - if (this->is_aspect) { + if (this->m_is_aspect) { /* apply aspect from clip */ - const float w_src = inputOperation->getWidth(); - const float h_src = inputOperation->getHeight(); + const float w_src = this->m_inputOperation->getWidth(); + const float h_src = this->m_inputOperation->getHeight(); /* destination aspect is already applied from the camera frame */ - const float w_dst = this->newWidth; - const float h_dst = this->newHeight; + const float w_dst = this->m_newWidth; + const float h_dst = this->m_newHeight; const float asp_src = w_src / h_src; const float asp_dst = w_dst / h_dst; if (fabsf(asp_src - asp_dst) >= FLT_EPSILON) { - if ((asp_src > asp_dst) == (this->is_crop == true)) { + if ((asp_src > asp_dst) == (this->m_is_crop == true)) { /* fit X */ const float div = asp_src / asp_dst; - this->relX /= div; - this->offsetX += ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f; + this->m_relX /= div; + this->m_offsetX += ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f; } else { /* fit Y */ const float div = asp_dst / asp_src; - this->relY /= div; - this->offsetY += ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f; + this->m_relY /= div; + this->m_offsetY += ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f; } - this->is_offset = true; + this->m_is_offset = true; } } /* *** end framing options *** */ @@ -240,7 +240,7 @@ void ScaleFixedSizeOperation::initExecution() void ScaleFixedSizeOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } @@ -250,13 +250,13 @@ void ScaleFixedSizeOperation::executePixel(float *color, float x, float y, Pixel sampler = COM_PS_BICUBIC; #endif - if (this->is_offset) { - float nx = ((x - this->offsetX) * relX); - float ny = ((y - this->offsetY) * relY); - this->inputOperation->read(color, nx, ny, sampler, inputBuffers); + if (this->m_is_offset) { + float nx = ((x - this->m_offsetX) * this->m_relX); + float ny = ((y - this->m_offsetY) * this->m_relY); + this->m_inputOperation->read(color, nx, ny, sampler, inputBuffers); } else { - this->inputOperation->read(color, x * relX, y * relY, sampler, inputBuffers); + this->m_inputOperation->read(color, x * this->m_relX, y * this->m_relY, sampler, inputBuffers); } } @@ -264,10 +264,10 @@ bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input, Read { rcti newInput; - newInput.xmax = input->xmax * relX; - newInput.xmin = input->xmin * relX; - newInput.ymax = input->ymax * relY; - newInput.ymin = input->ymin * relY; + newInput.xmax = input->xmax * this->m_relX; + newInput.xmin = input->xmin * this->m_relX; + newInput.ymax = input->ymax * this->m_relY; + newInput.ymin = input->ymin * this->m_relY; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } @@ -275,9 +275,9 @@ bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input, Read void ScaleFixedSizeOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { unsigned int nr[2]; - nr[0] = newWidth; - nr[1] = newHeight; + nr[0] = this->m_newWidth; + nr[1] = this->m_newHeight; NodeOperation::determineResolution(resolution, nr); - resolution[0] = newWidth; - resolution[1] = newHeight; + resolution[0] = this->m_newWidth; + resolution[1] = this->m_newHeight; } diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h index 7089f6c10a4..8cd44810bbd 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.h +++ b/source/blender/compositor/operations/COM_ScaleOperation.h @@ -27,11 +27,11 @@ class ScaleOperation : public NodeOperation { private: - SocketReader *inputOperation; - SocketReader *inputXOperation; - SocketReader *inputYOperation; - float centerX; - float centerY; + SocketReader *m_inputOperation; + SocketReader *m_inputXOperation; + SocketReader *m_inputYOperation; + float m_centerX; + float m_centerY; public: ScaleOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); @@ -42,11 +42,11 @@ public: }; class ScaleAbsoluteOperation : public NodeOperation { - SocketReader *inputOperation; - SocketReader *inputXOperation; - SocketReader *inputYOperation; - float centerX; - float centerY; + SocketReader *m_inputOperation; + SocketReader *m_inputXOperation; + SocketReader *m_inputYOperation; + float m_centerX; + float m_centerY; public: ScaleAbsoluteOperation(); @@ -58,20 +58,20 @@ public: }; class ScaleFixedSizeOperation : public NodeOperation { - SocketReader *inputOperation; - int newWidth; - int newHeight; - float relX; - float relY; + SocketReader *m_inputOperation; + int m_newWidth; + int m_newHeight; + float m_relX; + float m_relY; /* center is only used for aspect correction */ - float offsetX; - float offsetY; - bool is_aspect; - bool is_crop; + float m_offsetX; + float m_offsetY; + bool m_is_aspect; + bool m_is_crop; /* set from other properties on initialization, * check if we need to apply offset */ - bool is_offset; + bool m_is_offset; public: ScaleFixedSizeOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); @@ -80,11 +80,11 @@ public: void initExecution(); void deinitExecution(); - void setNewWidth(int width) { this->newWidth = width; } - void setNewHeight(int height) { this->newHeight = height; } - void setIsAspect(bool is_aspect) { this->is_aspect = is_aspect; } - void setIsCrop(bool is_crop) { this->is_crop = is_crop; } - void setOffset(float x, float y) { this->offsetX = x; this->offsetY = y; } + void setNewWidth(int width) { this->m_newWidth = width; } + void setNewHeight(int height) { this->m_newHeight = height; } + void setIsAspect(bool is_aspect) { this->m_is_aspect = is_aspect; } + void setIsCrop(bool is_crop) { this->m_is_crop = is_crop; } + void setOffset(float x, float y) { this->m_offsetX = x; this->m_offsetY = y; } }; #endif diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp index 1e19c293314..ea8483734d3 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp @@ -30,34 +30,28 @@ extern "C" { ScreenLensDistortionOperation::ScreenLensDistortionOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); + this->addInputSocket(COM_DT_VALUE); + this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); - this->inputProgram = NULL; + this->m_inputProgram = NULL; + this->m_valuesAvailable = false; + this->m_dispersion = 0.0f; + this->m_distortion = 0.0f; } void ScreenLensDistortionOperation::initExecution() { - this->inputProgram = this->getInputSocketReader(0); - kg = MAX2(MIN2(this->distortion, 1.f), -0.999f); - // smaller dispersion range for somewhat more control - const float d = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f); - kr = MAX2(MIN2((kg + d), 1.f), -0.999f); - kb = MAX2(MIN2((kg - d), 1.f), -0.999f); - maxk = MAX3(kr, kg, kb); - sc = (this->data->fit && (maxk > 0.f)) ? (1.f / (1.f + 2.f * maxk)) : (1.f / (1.f + maxk)); - drg = 4.f * (kg - kr); - dgb = 4.f * (kb - kg); - - kr4 = kr * 4.f; - kg4 = kg * 4.f; - kb4 = kb * 4.f; - cx = 0.5f * (float)getWidth(); - cy = 0.5f * (float)getHeight(); - + this->m_inputProgram = this->getInputSocketReader(0); + this->initMutex(); + this->m_cx = 0.5f * (float)getWidth(); + this->m_cy = 0.5f * (float)getHeight(); + } void *ScreenLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers); + void *buffer = this->m_inputProgram->initializeTileData(NULL, memoryBuffers); + updateDispersionAndDistortion(memoryBuffers); return buffer; } @@ -70,28 +64,29 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int int dr = 0, dg = 0, db = 0; float d, t, ln[6] = {0, 0, 0, 0, 0, 0}; float tc[4] = {0, 0, 0, 0}; - const float v = sc * ((y + 0.5f) - cy) / cy; - const float u = sc * ((x + 0.5f) - cx) / cx; + const float v = this->m_sc * ((y + 0.5f) - this->m_cy) / this->m_cy; + const float u = this->m_sc * ((x + 0.5f) - this->m_cx) / this->m_cx; + const float uv_dot = u * u + v * v; int sta = 0, mid = 0, end = 0; - if ((t = 1.f - kr4 * (u * u + v * v)) >= 0.f) { + if ((t = 1.f - this->m_kr4 * uv_dot) >= 0.f) { d = 1.f / (1.f + sqrtf(t)); ln[0] = (u * d + 0.5f) * width - 0.5f, ln[1] = (v * d + 0.5f) * height - 0.5f; sta = 1; } - if ((t = 1.f - kg4 * (u * u + v * v)) >= 0.f) { + if ((t = 1.f - this->m_kg4 * uv_dot) >= 0.f) { d = 1.f / (1.f + sqrtf(t)); ln[2] = (u * d + 0.5f) * width - 0.5f, ln[3] = (v * d + 0.5f) * height - 0.5f; mid = 1; } - if ((t = 1.f - kb4 * (u * u + v * v)) >= 0.f) { + if ((t = 1.f - this->m_kb4 * uv_dot) >= 0.f) { d = 1.f / (1.f + sqrtf(t)); ln[4] = (u * d + 0.5f) * width - 0.5f, ln[5] = (v * d + 0.5f) * height - 0.5f; end = 1; } if (sta && mid && end) { - float jit = this->data->jit; + float jit = this->m_data->jit; float z; float color[4]; { @@ -103,10 +98,10 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int for (z = 0; z < ds; ++z) { const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd; - t = 1.f - (kr4 + tz * drg) * (u * u + v * v); - d = 1.f / (1.f + sqrtf(t)); - const float nx = (u * d + 0.5f) * getWidth() - 0.5f; - const float ny = (v * d + 0.5f) * getHeight() - 0.5f; + t = 1.0f - (this->m_kr4 + tz * this->m_drg) * uv_dot; + d = 1.0f / (1.f + sqrtf(t)); + const float nx = (u * d + 0.5f) * width - 0.5f; + const float ny = (v * d + 0.5f) * height - 0.5f; buffer->readCubic(color, nx, ny); tc[0] += (1.f - tz) * color[0], tc[1] += tz * color[1]; dr++, dg++; @@ -121,19 +116,19 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int for (z = 0; z < ds; ++z) { const float tz = ((float)z + (jit ? BLI_frand() : 0.5f)) * sd; - t = 1.f - (kg4 + tz * dgb) * (u * u + v * v); + t = 1.f - (this->m_kg4 + tz * this->m_dgb) * uv_dot; d = 1.f / (1.f + sqrtf(t)); - const float nx = (u * d + 0.5f) * getWidth() - 0.5f; - const float ny = (v * d + 0.5f) * getHeight() - 0.5f; + const float nx = (u * d + 0.5f) * width - 0.5f; + const float ny = (v * d + 0.5f) * height - 0.5f; buffer->readCubic(color, nx, ny); tc[1] += (1.f - tz) * color[1], tc[2] += tz * color[2]; dg++, db++; } } - if (dr) outputColor[0] = 2.f * tc[0] / (float)dr; - if (dg) outputColor[1] = 2.f * tc[1] / (float)dg; - if (db) outputColor[2] = 2.f * tc[2] / (float)db; + if (dr) outputColor[0] = 2.0f * tc[0] / (float)dr; + if (dg) outputColor[1] = 2.0f * tc[1] / (float)dg; + if (db) outputColor[2] = 2.0f * tc[2] / (float)db; /* set alpha */ outputColor[3] = 1.0f; @@ -148,25 +143,192 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int void ScreenLensDistortionOperation::deinitExecution() { - this->inputProgram = NULL; + this->deinitMutex(); + this->m_inputProgram = NULL; } -void ScreenLensDistortionOperation::determineUV(float result[2], float x, float y) const +void ScreenLensDistortionOperation::determineUV(float result[4], float x, float y, float distortion, float dispersion) { - const float v = sc * ((y + 0.5f) - cy) / cy; - const float u = sc * ((x + 0.5f) - cx) / cx; - const float t = ABS(MIN3(kr, kg, kb) * 4); - float d = 1.f / (1.f + sqrtf(t)); - result[0] = (u * d + 0.5f) * getWidth() - 0.5f; - result[1] = (v * d + 0.5f) * getHeight() - 0.5f; + if (!this->m_valuesAvailable) { + updateVariables(distortion, dispersion); + } + determineUV(result, x, y); +} + +void ScreenLensDistortionOperation::determineUV(float result[4], float x, float y) const +{ + const float height = this->getHeight(); + const float width = this->getWidth(); + + float d, t, ln[6] = {0, 0, 0, 0, 0, 0}; + const float v = this->m_sc * ((y + 0.5f) - this->m_cy) / this->m_cy; + const float u = this->m_sc * ((x + 0.5f) - this->m_cx) / this->m_cx; + const float uv_dot = u * u + v * v; + + if ((t = 1.f - this->m_kr4 * uv_dot) >= 0.f) { + d = 1.f / (1.f + sqrtf(t)); + ln[0] = (u * d + 0.5f) * width - 0.5f, ln[1] = (v * d + 0.5f) * height - 0.5f; + } + if ((t = 1.f - this->m_kg4 * uv_dot) >= 0.f) { + d = 1.f / (1.f + sqrtf(t)); + ln[2] = (u * d + 0.5f) * width - 0.5f, ln[3] = (v * d + 0.5f) * height - 0.5f; + } + if ((t = 1.f - this->m_kb4 * uv_dot) >= 0.f) { + d = 1.f / (1.f + sqrtf(t)); + ln[4] = (u * d + 0.5f) * width - 0.5f, ln[5] = (v * d + 0.5f) * height - 0.5f; + } + + float jit = this->m_data->jit; + float z; + { + // RG + const int dx = ln[2] - ln[0], dy = ln[3] - ln[1]; + const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.f; + const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf); + const float sd = 1.f / (float)ds; + + z = ds; + const float tz = ((float)z + (1.0f)) * sd; + t = 1.0f - (this->m_kr4 + tz * this->m_drg) * uv_dot; + d = 1.0f / (1.f + sqrtf(t)); + const float nx = (u * d + 0.5f) * width - 0.5f; + const float ny = (v * d + 0.5f) * height - 0.5f; + result[0] = nx; + result[1] = ny; + } + { + // GB + const int dx = ln[4] - ln[2], dy = ln[5] - ln[3]; + const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.f; + const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf); + const float sd = 1.f / (float)ds; + + z = ds; + const float tz = ((float)z + (1.0f)) * sd; + t = 1.f - (this->m_kg4 + tz * this->m_dgb) * uv_dot; + d = 1.f / (1.f + sqrtf(t)); + const float nx = (u * d + 0.5f) * width - 0.5f; + const float ny = (v * d + 0.5f) * height - 0.5f; + result[2] = nx; + result[3] = ny; + } } bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { + rcti newInputValue; + newInputValue.xmin = 0; + newInputValue.ymin = 0; + newInputValue.xmax = 2; + newInputValue.ymax = 2; + + NodeOperation *operation = getInputOperation(1); + if (operation->determineDependingAreaOfInterest(&newInputValue, readOperation, output) ) { + return true; + } + + operation = getInputOperation(2); + if (operation->determineDependingAreaOfInterest(&newInputValue, readOperation, output) ) { + return true; + } + +#define MARGIN 64 + +#define UPDATE_INPUT \ + newInput.xmin = MIN3(newInput.xmin, coords[0], coords[2]); \ + newInput.ymin = MIN3(newInput.ymin, coords[1], coords[3]); \ + newInput.xmax = MAX3(newInput.xmax, coords[0], coords[2]); \ + newInput.ymax = MAX3(newInput.ymax, coords[1], coords[3]); + rcti newInput; - newInput.xmin = 0; - newInput.ymin = 0; - newInput.ymax = inputProgram->getHeight(); - newInput.xmax = inputProgram->getWidth(); - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + float margin; + float coords[4]; + if (m_valuesAvailable) { + determineUV(coords, input->xmin, input->ymin); + newInput.xmin = coords[0]; + newInput.ymin = coords[1]; + newInput.xmax = coords[0]; + newInput.ymax = coords[1]; + UPDATE_INPUT; + determineUV(coords, input->xmin, input->ymax); + UPDATE_INPUT; + determineUV(coords, input->xmax, input->ymax); + UPDATE_INPUT; + determineUV(coords, input->xmax, input->ymin); + UPDATE_INPUT; + margin = (ABS(this->m_distortion)+this->m_dispersion)*MARGIN; + } + else + { + determineUV(coords, input->xmin, input->ymin, 1.0f, 1.0f); + newInput.xmin = coords[0]; + newInput.ymin = coords[1]; + newInput.xmax = coords[0]; + newInput.ymax = coords[1]; + UPDATE_INPUT; + determineUV(coords, input->xmin, input->ymin, -1.0f, 1.0f); + UPDATE_INPUT; + + determineUV(coords, input->xmin, input->ymax, -1.0f, 1.0f); + UPDATE_INPUT; + determineUV(coords, input->xmin, input->ymax, 1.0f, 1.0f); + UPDATE_INPUT; + + determineUV(coords, input->xmax, input->ymax, -1.0f, 1.0f); + UPDATE_INPUT; + determineUV(coords, input->xmax, input->ymax, 1.0f, 1.0f); + UPDATE_INPUT; + + determineUV(coords, input->xmax, input->ymin, -1.0f, 1.0f); + UPDATE_INPUT; + determineUV(coords, input->xmax, input->ymin, 1.0f, 1.0f); + UPDATE_INPUT; + margin=MARGIN; + } + +#undef UPDATE_INPUT + newInput.xmin -= margin; + newInput.ymin -= margin; + newInput.xmax += margin; + newInput.ymax += margin; + + operation = getInputOperation(0); + if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { + return true; + } + return false; +} + +void ScreenLensDistortionOperation::updateVariables(float distortion, float dispersion) +{ + this->m_kg = MAX2(MIN2(distortion, 1.f), -0.999f); + // smaller dispersion range for somewhat more control + const float d = 0.25f * MAX2(MIN2(dispersion, 1.f), 0.f); + this->m_kr = MAX2(MIN2((this->m_kg + d), 1.0f), -0.999f); + this->m_kb = MAX2(MIN2((this->m_kg - d), 1.0f), -0.999f); + this->m_maxk = MAX3(this->m_kr, this->m_kg, this->m_kb); + this->m_sc = (this->m_data->fit && (this->m_maxk > 0.f)) ? (1.f / (1.f + 2.f * this->m_maxk)) : (1.f / (1.f + this->m_maxk)); + this->m_drg = 4.f * (this->m_kg - this->m_kr); + this->m_dgb = 4.f * (this->m_kb - this->m_kg); + + this->m_kr4 = this->m_kr * 4.0f; + this->m_kg4 = this->m_kg * 4.0f; + this->m_kb4 = this->m_kb * 4.0f; +} + +void ScreenLensDistortionOperation::updateDispersionAndDistortion(MemoryBuffer **inputBuffers) +{ + if (this->m_valuesAvailable) return; + + this->lockMutex(); + if (!this->m_valuesAvailable) { + float result[4]; + this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); + this->m_distortion = result[0]; + this->getInputSocketReader(2)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); + this->m_dispersion = result[0]; + updateVariables(this->m_distortion, this->m_dispersion); + this->m_valuesAvailable = true; + } + this->unlockMutex(); } diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h index 34656f38a09..f80b938818c 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h @@ -30,18 +30,19 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; - NodeLensDist *data; + NodeLensDist *m_data; - float dispersion; - float distortion; - float kr, kg, kb; - float kr4, kg4, kb4; - float maxk; - float drg; - float dgb; - float sc, cx, cy; + float m_dispersion; + float m_distortion; + bool m_valuesAvailable; + float m_kr, m_kg, m_kb; + float m_kr4, m_kg4, m_kb4; + float m_maxk; + float m_drg; + float m_dgb; + float m_sc, m_cx, m_cy; public: ScreenLensDistortionOperation(); @@ -61,14 +62,27 @@ public: */ void deinitExecution(); - void setData(NodeLensDist *data) { this->data = data; } - void setDispertion(float dispersion) { this->dispersion = dispersion; } - void setDistortion(float distortion) { this->distortion = distortion; } + void setData(NodeLensDist *data) { this->m_data = data; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + /** + * @brief Set the distortion and dispersion and precalc some values + * @param distortion + * @param dispersion + */ + void setDistortionAndDispersion(float distortion, float dispersion) { + this->m_distortion = distortion; + this->m_dispersion = dispersion; + updateVariables(distortion, dispersion); + this->m_valuesAvailable = true; + } + private: - void determineUV(float *result, float x, float y) const; + void determineUV(float result[4], float x, float y) const; + void determineUV(float result[4], float x, float y, float distortion, float dispersion); + void updateDispersionAndDistortion(MemoryBuffer **inputBuffers); + void updateVariables(float distortion, float dispersion); }; #endif diff --git a/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp b/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp index caa1387da2a..6ae4fc4cfe5 100644 --- a/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp +++ b/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp @@ -26,22 +26,22 @@ SeparateChannelOperation::SeparateChannelOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_VALUE); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void SeparateChannelOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void SeparateChannelOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void SeparateChannelOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float input[4]; - this->inputOperation->read(input, x, y, sampler, inputBuffers); - color[0] = input[this->channel]; + this->m_inputOperation->read(input, x, y, sampler, inputBuffers); + color[0] = input[this->m_channel]; } diff --git a/source/blender/compositor/operations/COM_SeparateChannelOperation.h b/source/blender/compositor/operations/COM_SeparateChannelOperation.h index b1a38fd8294..65a54f91252 100644 --- a/source/blender/compositor/operations/COM_SeparateChannelOperation.h +++ b/source/blender/compositor/operations/COM_SeparateChannelOperation.h @@ -27,8 +27,8 @@ class SeparateChannelOperation : public NodeOperation { private: - SocketReader *inputOperation; - int channel; + SocketReader *m_inputOperation; + int m_channel; public: SeparateChannelOperation(); void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); @@ -36,7 +36,7 @@ public: void initExecution(); void deinitExecution(); - void setChannel(int channel) { this->channel = channel; } + void setChannel(int channel) { this->m_channel = channel; } }; #endif diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp index 5924108ed86..d383fb638ae 100644 --- a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp +++ b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp @@ -28,28 +28,28 @@ SetAlphaOperation::SetAlphaOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->inputColor = NULL; - this->inputAlpha = NULL; + this->m_inputColor = NULL; + this->m_inputAlpha = NULL; } void SetAlphaOperation::initExecution() { - this->inputColor = getInputSocketReader(0); - this->inputAlpha = getInputSocketReader(1); + this->m_inputColor = getInputSocketReader(0); + this->m_inputAlpha = getInputSocketReader(1); } void SetAlphaOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float alphaInput[4]; - this->inputColor->read(outputValue, x, y, sampler, inputBuffers); - this->inputAlpha->read(alphaInput, x, y, sampler, inputBuffers); + this->m_inputColor->read(outputValue, x, y, sampler, inputBuffers); + this->m_inputAlpha->read(alphaInput, x, y, sampler, inputBuffers); outputValue[3] = alphaInput[0]; } void SetAlphaOperation::deinitExecution() { - this->inputColor = NULL; - this->inputAlpha = NULL; + this->m_inputColor = NULL; + this->m_inputAlpha = NULL; } diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.h b/source/blender/compositor/operations/COM_SetAlphaOperation.h index 231b41f1697..21968c930e7 100644 --- a/source/blender/compositor/operations/COM_SetAlphaOperation.h +++ b/source/blender/compositor/operations/COM_SetAlphaOperation.h @@ -26,13 +26,13 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class SetAlphaOperation : public NodeOperation { private: - SocketReader *inputColor; - SocketReader *inputAlpha; + SocketReader *m_inputColor; + SocketReader *m_inputAlpha; public: /** diff --git a/source/blender/compositor/operations/COM_SetColorOperation.cpp b/source/blender/compositor/operations/COM_SetColorOperation.cpp index 5307d7abc24..55a6a3800ca 100644 --- a/source/blender/compositor/operations/COM_SetColorOperation.cpp +++ b/source/blender/compositor/operations/COM_SetColorOperation.cpp @@ -29,10 +29,10 @@ SetColorOperation::SetColorOperation() : NodeOperation() void SetColorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - outputValue[0] = this->channel1; - outputValue[1] = this->channel2; - outputValue[2] = this->channel3; - outputValue[3] = this->channel4; + outputValue[0] = this->m_channel1; + outputValue[1] = this->m_channel2; + outputValue[2] = this->m_channel3; + outputValue[3] = this->m_channel4; } void SetColorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) diff --git a/source/blender/compositor/operations/COM_SetColorOperation.h b/source/blender/compositor/operations/COM_SetColorOperation.h index 9d28f1757db..a51311837ee 100644 --- a/source/blender/compositor/operations/COM_SetColorOperation.h +++ b/source/blender/compositor/operations/COM_SetColorOperation.h @@ -26,15 +26,15 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class SetColorOperation : public NodeOperation { private: - float channel1; - float channel2; - float channel3; - float channel4; + float m_channel1; + float m_channel2; + float m_channel3; + float m_channel4; public: /** @@ -42,15 +42,21 @@ public: */ SetColorOperation(); - const float getChannel1() {return this->channel1;} - void setChannel1(float value) {this->channel1 = value;} - const float getChannel2() {return this->channel2;} - void setChannel2(float value) {this->channel2 = value;} - const float getChannel3() {return this->channel3;} - void setChannel3(float value) {this->channel3 = value;} - const float getChannel4() {return this->channel4;} - void setChannel4(float value) {this->channel4 = value;} - void setChannels(float value[4]) {this->channel1 = value[0];this->channel2 = value[1];this->channel3 = value[2];this->channel4 = value[3];} + const float getChannel1() { return this->m_channel1; } + void setChannel1(float value) { this->m_channel1 = value; } + const float getChannel2() { return this->m_channel2; } + void setChannel2(float value) { this->m_channel2 = value; } + const float getChannel3() { return this->m_channel3; } + void setChannel3(float value) { this->m_channel3 = value; } + const float getChannel4() { return this->m_channel4; } + void setChannel4(float value) { this->m_channel4 = value; } + void setChannels(float value[4]) + { + this->m_channel1 = value[0]; + this->m_channel2 = value[1]; + this->m_channel3 = value[2]; + this->m_channel4 = value[3]; + } /** * the inner loop of this program diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp index dfe7fe91bf8..c235bd81e58 100644 --- a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp +++ b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp @@ -30,14 +30,14 @@ SetSamplerOperation::SetSamplerOperation() : NodeOperation() void SetSamplerOperation::initExecution() { - this->reader = this->getInputSocketReader(0); + this->m_reader = this->getInputSocketReader(0); } void SetSamplerOperation::deinitExecution() { - this->reader = NULL; + this->m_reader = NULL; } void SetSamplerOperation::executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - reader->read(output, x, y, this->sampler, inputBuffers); + this->m_reader->read(output, x, y, this->m_sampler, inputBuffers); } diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.h b/source/blender/compositor/operations/COM_SetSamplerOperation.h index 5dba0b3703f..273eac159bc 100644 --- a/source/blender/compositor/operations/COM_SetSamplerOperation.h +++ b/source/blender/compositor/operations/COM_SetSamplerOperation.h @@ -26,20 +26,20 @@ /** - * this program converts an input colour to an output Sampler. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output Sampler. + * it assumes we are in sRGB color space. */ class SetSamplerOperation : public NodeOperation { private: - PixelSampler sampler; - SocketReader *reader; + PixelSampler m_sampler; + SocketReader *m_reader; public: /** * Default constructor */ SetSamplerOperation(); - void setSampler(PixelSampler sampler) { this->sampler = sampler; } + void setSampler(PixelSampler sampler) { this->m_sampler = sampler; } /** * the inner loop of this program diff --git a/source/blender/compositor/operations/COM_SetValueOperation.cpp b/source/blender/compositor/operations/COM_SetValueOperation.cpp index 483fcc97a1f..98a21112c5b 100644 --- a/source/blender/compositor/operations/COM_SetValueOperation.cpp +++ b/source/blender/compositor/operations/COM_SetValueOperation.cpp @@ -29,7 +29,7 @@ SetValueOperation::SetValueOperation() : NodeOperation() void SetValueOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - outputValue[0] = this->value; + outputValue[0] = this->m_value; } void SetValueOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) diff --git a/source/blender/compositor/operations/COM_SetValueOperation.h b/source/blender/compositor/operations/COM_SetValueOperation.h index 2f4a6ec0dc8..642940e03cd 100644 --- a/source/blender/compositor/operations/COM_SetValueOperation.h +++ b/source/blender/compositor/operations/COM_SetValueOperation.h @@ -26,12 +26,12 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class SetValueOperation : public NodeOperation { private: - float value; + float m_value; public: /** @@ -39,8 +39,8 @@ public: */ SetValueOperation(); - const float getValue() { return this->value; } - void setValue(float value) { this->value = value; } + const float getValue() { return this->m_value; } + void setValue(float value) { this->m_value = value; } /** diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.cpp b/source/blender/compositor/operations/COM_SetVectorOperation.cpp index 3d15a184c4e..f37bc489e75 100644 --- a/source/blender/compositor/operations/COM_SetVectorOperation.cpp +++ b/source/blender/compositor/operations/COM_SetVectorOperation.cpp @@ -30,10 +30,10 @@ SetVectorOperation::SetVectorOperation() : NodeOperation() void SetVectorOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - outputValue[0] = this->x; - outputValue[1] = this->y; - outputValue[2] = this->z; - outputValue[3] = this->w; + outputValue[0] = this->m_x; + outputValue[1] = this->m_y; + outputValue[2] = this->m_z; + outputValue[3] = this->m_w; } void SetVectorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.h b/source/blender/compositor/operations/COM_SetVectorOperation.h index 49088027762..d1b9fe25085 100644 --- a/source/blender/compositor/operations/COM_SetVectorOperation.h +++ b/source/blender/compositor/operations/COM_SetVectorOperation.h @@ -26,15 +26,15 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class SetVectorOperation : public NodeOperation { private: - float x; - float y; - float z; - float w; + float m_x; + float m_y; + float m_z; + float m_w; public: /** @@ -42,14 +42,14 @@ public: */ SetVectorOperation(); - const float getX() { return this->x; } - void setX(float value) { this->x = value; } - const float getY() { return this->y; } - void setY(float value) { this->y = value; } - const float getZ() { return this->z; } - void setZ(float value) { this->z = value; } - const float getW() { return this->w; } - void setW(float value) { this->w = value; } + const float getX() { return this->m_x; } + void setX(float value) { this->m_x = value; } + const float getY() { return this->m_y; } + void setY(float value) { this->m_y = value; } + const float getZ() { return this->m_z; } + void setZ(float value) { this->m_z = value; } + const float getW() { return this->m_w; } + void setW(float value) { this->m_w = value; } /** * the inner loop of this program diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp index 55c4b68ee57..8b39406fd83 100644 --- a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp +++ b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp @@ -26,22 +26,22 @@ SocketProxyOperation::SocketProxyOperation(DataType type) : NodeOperation() { this->addInputSocket(type); this->addOutputSocket(type); - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void SocketProxyOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); + this->m_inputOperation = this->getInputSocketReader(0); } void SocketProxyOperation::deinitExecution() { - this->inputOperation = NULL; + this->m_inputOperation = NULL; } void SocketProxyOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - if (this->inputOperation) { - this->inputOperation->read(color, x, y, sampler, inputBuffers); + if (this->m_inputOperation) { + this->m_inputOperation->read(color, x, y, sampler, inputBuffers); } } diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.h b/source/blender/compositor/operations/COM_SocketProxyOperation.h index 5dc8f3d6f8f..a4177efbd8e 100644 --- a/source/blender/compositor/operations/COM_SocketProxyOperation.h +++ b/source/blender/compositor/operations/COM_SocketProxyOperation.h @@ -27,7 +27,7 @@ class SocketProxyOperation : public NodeOperation { private: - SocketReader *inputOperation; + SocketReader *m_inputOperation; public: SocketProxyOperation(DataType type); void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp index 2735f182406..00f854b2ba9 100644 --- a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp @@ -40,30 +40,30 @@ SplitViewerOperation::SplitViewerOperation() : ViewerBaseOperation() { this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_COLOR); - this->image1Input = NULL; - this->image2Input = NULL; + this->m_image1Input = NULL; + this->m_image2Input = NULL; } void SplitViewerOperation::initExecution() { // When initializing the tree during initial load the width and height can be zero. - this->image1Input = getInputSocketReader(0); - this->image2Input = getInputSocketReader(1); + this->m_image1Input = getInputSocketReader(0); + this->m_image2Input = getInputSocketReader(1); ViewerBaseOperation::initExecution(); } void SplitViewerOperation::deinitExecution() { - this->image1Input = NULL; - this->image2Input = NULL; + this->m_image1Input = NULL; + this->m_image2Input = NULL; ViewerBaseOperation::deinitExecution(); } void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) { - float *buffer = this->outputBuffer; - unsigned char *bufferDisplay = this->outputBufferDisplay; + float *buffer = this->m_outputBuffer; + unsigned char *bufferDisplay = this->m_outputBufferDisplay; if (!buffer) return; int x1 = rect->xmin; @@ -73,21 +73,21 @@ void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me int offset = (y1 * this->getWidth() + x1) * 4; int x; int y; - int perc = xSplit ? this->splitPercentage *getWidth() / 100.0f : this->splitPercentage *getHeight() / 100.0f; + int perc = this->m_xSplit ? this->m_splitPercentage * this->getWidth() / 100.0f : this->m_splitPercentage * this->getHeight() / 100.0f; for (y = y1; y < y2; y++) { for (x = x1; x < x2; x++) { bool image1; float srgb[4]; - image1 = xSplit ? x > perc : y > perc; + image1 = this->m_xSplit ? x > perc : y > perc; if (image1) { - image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); } else { - image2Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_image2Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); } /// @todo: linear conversion only when scene color management is selected, also check predivide. - if (this->doColorManagement) { - if (this->doColorPredivide) { + if (this->m_doColorManagement) { + if (this->m_doColorPredivide) { linearrgb_to_srgb_predivide_v4(srgb, buffer + offset); } else { diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.h b/source/blender/compositor/operations/COM_SplitViewerOperation.h index aba63ff190b..92275606105 100644 --- a/source/blender/compositor/operations/COM_SplitViewerOperation.h +++ b/source/blender/compositor/operations/COM_SplitViewerOperation.h @@ -28,17 +28,17 @@ class SplitViewerOperation : public ViewerBaseOperation { private: - SocketReader *image1Input; - SocketReader *image2Input; + SocketReader *m_image1Input; + SocketReader *m_image2Input; - float splitPercentage; - bool xSplit; + float m_splitPercentage; + bool m_xSplit; public: SplitViewerOperation(); void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); void initExecution(); void deinitExecution(); - void setSplitPercentage(float splitPercentage) { this->splitPercentage = splitPercentage; } - void setXSplit(bool xsplit) { this->xSplit = xsplit; } + void setSplitPercentage(float splitPercentage) { this->m_splitPercentage = splitPercentage; } + void setXSplit(bool xsplit) { this->m_xSplit = xsplit; } }; #endif diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp index 072528f3fc6..6098cfc3e5c 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.cpp +++ b/source/blender/compositor/operations/COM_TextureOperation.cpp @@ -29,10 +29,10 @@ TextureBaseOperation::TextureBaseOperation() : NodeOperation() { this->addInputSocket(COM_DT_VECTOR); //offset this->addInputSocket(COM_DT_VECTOR); //size - this->texture = NULL; - this->inputSize = NULL; - this->inputOffset = NULL; - this->scene = NULL; + this->m_texture = NULL; + this->m_inputSize = NULL; + this->m_inputOffset = NULL; + this->m_rd = NULL; } TextureOperation::TextureOperation() : TextureBaseOperation() { @@ -45,20 +45,20 @@ TextureAlphaOperation::TextureAlphaOperation() : TextureBaseOperation() void TextureBaseOperation::initExecution() { - this->inputOffset = getInputSocketReader(0); - this->inputSize = getInputSocketReader(1); + this->m_inputOffset = getInputSocketReader(0); + this->m_inputSize = getInputSocketReader(1); } void TextureBaseOperation::deinitExecution() { - this->inputSize = NULL; - this->inputOffset = NULL; + this->m_inputSize = NULL; + this->m_inputOffset = NULL; } void TextureBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) { if (preferredResolution[0] == 0 || preferredResolution[1] == 0) { - int width = this->scene->r.xsch * this->scene->r.size / 100; - int height = this->scene->r.ysch * this->scene->r.size / 100; + int width = this->m_rd->xsch * this->m_rd->size / 100; + int height = this->m_rd->ysch * this->m_rd->size / 100; resolution[0] = width; resolution[1] = height; } @@ -89,14 +89,14 @@ void TextureBaseOperation::executePixel(float *color, float x, float y, PixelSam const float u = (cx - x) / this->getWidth() * 2; const float v = (cy - y) / this->getHeight() * 2; - this->inputSize->read(textureSize, x, y, sampler, inputBuffers); - this->inputOffset->read(textureOffset, x, y, sampler, inputBuffers); + this->m_inputSize->read(textureSize, x, y, sampler, inputBuffers); + this->m_inputOffset->read(textureOffset, x, y, sampler, inputBuffers); vec[0] = textureSize[0] * (u + textureOffset[0]); vec[1] = textureSize[1] * (v + textureOffset[1]); vec[2] = textureSize[2] * textureOffset[2]; - retval = multitex_ext(this->texture, vec, NULL, NULL, 0, &texres); + retval = multitex_ext(this->m_texture, vec, NULL, NULL, 0, &texres); if (texres.talpha) color[3] = texres.ta; diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h index e862a1f1910..d42da697b08 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.h +++ b/source/blender/compositor/operations/COM_TextureOperation.h @@ -42,10 +42,10 @@ extern "C" { */ class TextureBaseOperation : public NodeOperation { private: - Tex *texture; - const Scene *scene; - SocketReader *inputSize; - SocketReader *inputOffset; + Tex *m_texture; + const RenderData *m_rd; + SocketReader *m_inputSize; + SocketReader *m_inputOffset; protected: @@ -62,10 +62,10 @@ protected: public: void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); - void setTexture(Tex *texture) { this->texture = texture; } + void setTexture(Tex *texture) { this->m_texture = texture; } void initExecution(); void deinitExecution(); - void setScene(const Scene *scene) { this->scene = scene; } + void setRenderData(const RenderData *rd) { this->m_rd = rd; } }; class TextureOperation : public TextureBaseOperation { diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cpp b/source/blender/compositor/operations/COM_TonemapOperation.cpp index 7b978e0f87c..b5daf85b390 100644 --- a/source/blender/compositor/operations/COM_TonemapOperation.cpp +++ b/source/blender/compositor/operations/COM_TonemapOperation.cpp @@ -30,14 +30,14 @@ TonemapOperation::TonemapOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); this->addOutputSocket(COM_DT_COLOR); - this->imageReader = NULL; - this->data = NULL; - this->cachedInstance = NULL; + this->m_imageReader = NULL; + this->m_data = NULL; + this->m_cachedInstance = NULL; this->setComplex(true); } void TonemapOperation::initExecution() { - this->imageReader = this->getInputSocketReader(0); + this->m_imageReader = this->getInputSocketReader(0); NodeOperation::initMutex(); } @@ -46,11 +46,11 @@ void TonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *in AvgLogLum *avg = (AvgLogLum *)data; float output[4]; - this->imageReader->read(output, x, y, inputBuffers, NULL); + this->m_imageReader->read(output, x, y, inputBuffers, NULL); mul_v3_fl(output, avg->al); - float dr = output[0] + this->data->offset; - float dg = output[1] + this->data->offset; - float db = output[2] + this->data->offset; + float dr = output[0] + this->m_data->offset; + float dg = output[1] + this->m_data->offset; + float db = output[2] + this->m_data->offset; output[0] /= ((dr == 0.f) ? 1.0f : dr); output[1] /= ((dg == 0.f) ? 1.0f : dg); output[2] /= ((db == 0.f) ? 1.0f : db); @@ -66,14 +66,14 @@ void TonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *in void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) { AvgLogLum *avg = (AvgLogLum *)data; - NodeTonemap *ntm = this->data; + NodeTonemap *ntm = this->m_data; - const float f = expf(-this->data->f); + const float f = expf(-this->m_data->f); const float m = (ntm->m > 0.0f) ? ntm->m : (0.3f + 0.7f * powf(avg->auto_key, 1.4f)); const float ic = 1.0f - ntm->c, ia = 1.0f - ntm->a; float output[4]; - this->imageReader->read(output, x, y, inputBuffers, NULL); + this->m_imageReader->read(output, x, y, inputBuffers, NULL); const float L = rgb_to_luma_y(output); float I_l = output[0] + ic * (L - output[0]); @@ -94,9 +94,9 @@ void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, Mem void TonemapOperation::deinitExecution() { - this->imageReader = NULL; - if (this->cachedInstance) { - delete cachedInstance; + this->m_imageReader = NULL; + if (this->m_cachedInstance) { + delete this->m_cachedInstance; } NodeOperation::deinitMutex(); } @@ -119,8 +119,8 @@ bool TonemapOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferO void *TonemapOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { lockMutex(); - if (this->cachedInstance == NULL) { - MemoryBuffer *tile = (MemoryBuffer *)imageReader->initializeTileData(rect, memoryBuffers); + if (this->m_cachedInstance == NULL) { + MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect, memoryBuffers); AvgLogLum *data = new AvgLogLum(); float *buffer = tile->getBuffer(); @@ -146,12 +146,12 @@ void *TonemapOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuff maxl = log((double)maxl + 1e-5); minl = log((double)minl + 1e-5); avl = lsum * sc; data->auto_key = (maxl > minl) ? ((maxl - avl) / (maxl - minl)) : 1.f; float al = exp((double)avl); - data->al = (al == 0.f) ? 0.f : (this->data->key / al); - data->igm = (this->data->gamma == 0.f) ? 1 : (1.f / this->data->gamma); - this->cachedInstance = data; + data->al = (al == 0.0f) ? 0.0f : (this->m_data->key / al); + data->igm = (this->m_data->gamma == 0.f) ? 1 : (1.f / this->m_data->gamma); + this->m_cachedInstance = data; } unlockMutex(); - return this->cachedInstance; + return this->m_cachedInstance; } void TonemapOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) diff --git a/source/blender/compositor/operations/COM_TonemapOperation.h b/source/blender/compositor/operations/COM_TonemapOperation.h index 005f0862443..ed9018d0a09 100644 --- a/source/blender/compositor/operations/COM_TonemapOperation.h +++ b/source/blender/compositor/operations/COM_TonemapOperation.h @@ -46,17 +46,17 @@ protected: /** * @brief Cached reference to the reader */ - SocketReader *imageReader; + SocketReader *m_imageReader; /** * @brief settings of the Tonemap */ - NodeTonemap *data; + NodeTonemap *m_data; /** * @brief temporarily cache of the execution storage */ - AvgLogLum *cachedInstance; + AvgLogLum *m_cachedInstance; public: TonemapOperation(); @@ -79,7 +79,7 @@ public: */ void deinitExecution(); - void setData(NodeTonemap *data) { this->data = data; } + void setData(NodeTonemap *data) { this->m_data = data; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cpp b/source/blender/compositor/operations/COM_TranslateOperation.cpp index c41e2c7f156..e43a8e55130 100644 --- a/source/blender/compositor/operations/COM_TranslateOperation.cpp +++ b/source/blender/compositor/operations/COM_TranslateOperation.cpp @@ -29,31 +29,31 @@ TranslateOperation::TranslateOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->setResolutionInputSocketIndex(0); - this->inputOperation = NULL; - this->inputXOperation = NULL; - this->inputYOperation = NULL; - this->isDeltaSet = false; + this->m_inputOperation = NULL; + this->m_inputXOperation = NULL; + this->m_inputYOperation = NULL; + this->m_isDeltaSet = false; } void TranslateOperation::initExecution() { - this->inputOperation = this->getInputSocketReader(0); - this->inputXOperation = this->getInputSocketReader(1); - this->inputYOperation = this->getInputSocketReader(2); + this->m_inputOperation = this->getInputSocketReader(0); + this->m_inputXOperation = this->getInputSocketReader(1); + this->m_inputYOperation = this->getInputSocketReader(2); } void TranslateOperation::deinitExecution() { - this->inputOperation = NULL; - this->inputXOperation = NULL; - this->inputYOperation = NULL; + this->m_inputOperation = NULL; + this->m_inputXOperation = NULL; + this->m_inputYOperation = NULL; } void TranslateOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { ensureDelta(); - this->inputOperation->read(color, x - this->getDeltaX(), y - this->getDeltaY(), sampler, inputBuffers); + this->m_inputOperation->read(color, x - this->getDeltaX(), y - this->getDeltaY(), sampler, inputBuffers); } bool TranslateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) diff --git a/source/blender/compositor/operations/COM_TranslateOperation.h b/source/blender/compositor/operations/COM_TranslateOperation.h index bf3121bec11..8af4ffe8967 100644 --- a/source/blender/compositor/operations/COM_TranslateOperation.h +++ b/source/blender/compositor/operations/COM_TranslateOperation.h @@ -27,12 +27,12 @@ class TranslateOperation : public NodeOperation { private: - SocketReader *inputOperation; - SocketReader *inputXOperation; - SocketReader *inputYOperation; - float deltaX; - float deltaY; - bool isDeltaSet; + SocketReader *m_inputOperation; + SocketReader *m_inputXOperation; + SocketReader *m_inputYOperation; + float m_deltaX; + float m_deltaY; + bool m_isDeltaSet; public: TranslateOperation(); bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); @@ -41,17 +41,17 @@ public: void initExecution(); void deinitExecution(); - float getDeltaX() { return this->deltaX; } - float getDeltaY() { return this->deltaY; } + float getDeltaX() { return this->m_deltaX; } + float getDeltaY() { return this->m_deltaY; } inline void ensureDelta() { - if (!isDeltaSet) { + if (!this->m_isDeltaSet) { float tempDelta[4]; - this->inputXOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL); - this->deltaX = tempDelta[0]; - this->inputYOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL); - this->deltaY = tempDelta[0]; - this->isDeltaSet = true; + this->m_inputXOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL); + this->m_deltaX = tempDelta[0]; + this->m_inputYOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL); + this->m_deltaY = tempDelta[0]; + this->m_isDeltaSet = true; } } }; diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp index c17e51e6391..46101f6355d 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp @@ -33,24 +33,33 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // do not resize the bokeh image. this->addInputSocket(COM_DT_VALUE); // radius this->addInputSocket(COM_DT_VALUE); // depth +#ifdef COM_DEFOCUS_SEARCH + this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // inverse search radius optimization structure. +#endif this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); - this->inputProgram = NULL; - this->inputBokehProgram = NULL; - this->inputSizeProgram = NULL; - this->inputDepthProgram = NULL; - this->maxBlur = 32.0f; - this->threshold = 1.0f; + this->m_inputProgram = NULL; + this->m_inputBokehProgram = NULL; + this->m_inputSizeProgram = NULL; + this->m_inputDepthProgram = NULL; + this->m_maxBlur = 32.0f; + this->m_threshold = 1.0f; +#ifdef COM_DEFOCUS_SEARCH + this->m_inputSearchProgram = NULL; +#endif } void VariableSizeBokehBlurOperation::initExecution() { - this->inputProgram = getInputSocketReader(0); - this->inputBokehProgram = getInputSocketReader(1); - this->inputSizeProgram = getInputSocketReader(2); - this->inputDepthProgram = getInputSocketReader(3); + this->m_inputProgram = getInputSocketReader(0); + this->m_inputBokehProgram = getInputSocketReader(1); + this->m_inputSizeProgram = getInputSocketReader(2); + this->m_inputDepthProgram = getInputSocketReader(3); +#ifdef COM_DEFOCUS_SEARCH + this->m_inputSearchProgram = getInputSocketReader(4); +#endif QualityStepHelper::initExecution(COM_QH_INCREASE); } @@ -63,27 +72,36 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - int miny = y - maxBlur; - int maxy = y + maxBlur; - int minx = x - maxBlur; - int maxx = x + maxBlur; +#ifdef COM_DEFOCUS_SEARCH + float search[4]; + this->inputSearchProgram->read(search, x/InverseSearchRadiusOperation::DIVIDER, y/InverseSearchRadiusOperation::DIVIDER, inputBuffers, NULL); + int minx = search[0]; + int miny = search[1]; + int maxx = search[2]; + int maxy = search[3]; +#else + int minx = MAX2(x - this->m_maxBlur, 0.0f); + int miny = MAX2(y - this->m_maxBlur, 0.0f); + int maxx = MIN2(x + this->m_maxBlur, m_width); + int maxy = MIN2(y + this->m_maxBlur, m_height); +#endif { - inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers); - inputDepthProgram->read(tempDepth, x, y, COM_PS_NEAREST, inputBuffers); - inputProgram->read(readColor, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputDepthProgram->read(tempDepth, x, y, COM_PS_NEAREST, inputBuffers); + this->m_inputProgram->read(readColor, x, y, COM_PS_NEAREST, inputBuffers); add_v4_v4(color_accum, readColor); add_v4_fl(multiplier_accum, 1.0f); float sizeCenter = tempSize[0]; - float centerDepth = tempDepth[0]+threshold; + float centerDepth = tempDepth[0] + this->m_threshold; for (int ny = miny; ny < maxy; ny += QualityStepHelper::getStep()) { for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) { if (nx >= 0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) { - inputDepthProgram->read(tempDepth, nx, ny, COM_PS_NEAREST, inputBuffers); - inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); - float size = tempSize[0]; + this->m_inputDepthProgram->read(tempDepth, nx, ny, COM_PS_NEAREST, inputBuffers); if (tempDepth[0] < centerDepth) { - if ((sizeCenter > threshold && size > threshold) || size <= threshold) { + this->m_inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); + float size = tempSize[0]; + if ((sizeCenter > this->m_threshold && size > this->m_threshold) || size <= this->m_threshold) { float dx = nx - x; float dy = ny - y; if (nx == x && ny == y) { @@ -91,8 +109,8 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me else if (size >= fabsf(dx) && size >= fabsf(dy)) { float u = 256 + dx * 256 / size; float v = 256 + dy * 256 / size; - inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); - inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers); + this->m_inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers); + this->m_inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers); madd_v4_v4v4(color_accum, bokeh, readColor); add_v4_v4(multiplier_accum, bokeh); } @@ -112,9 +130,13 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me void VariableSizeBokehBlurOperation::deinitExecution() { - this->inputProgram = NULL; - this->inputBokehProgram = NULL; - this->inputSizeProgram = NULL; + this->m_inputProgram = NULL; + this->m_inputBokehProgram = NULL; + this->m_inputSizeProgram = NULL; + this->m_inputDepthProgram = NULL; +#ifdef COM_DEFOCUS_SEARCH + this->m_inputSearchProgram = NULL; +#endif } bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -122,14 +144,15 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu rcti newInput; rcti bokehInput; - newInput.xmax = input->xmax + maxBlur + 2; - newInput.xmin = input->xmin - maxBlur + 2; - newInput.ymax = input->ymax + maxBlur - 2; - newInput.ymin = input->ymin - maxBlur - 2; + newInput.xmax = input->xmax + this->m_maxBlur + 2; + newInput.xmin = input->xmin - this->m_maxBlur + 2; + newInput.ymax = input->ymax + this->m_maxBlur - 2; + newInput.ymin = input->ymin - this->m_maxBlur - 2; bokehInput.xmax = 512; bokehInput.xmin = 0; bokehInput.ymax = 512; bokehInput.ymin = 0; + NodeOperation *operation = getInputOperation(2); if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { @@ -143,9 +166,118 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { return true; } +#ifdef COM_DEFOCUS_SEARCH + rcti searchInput; + searchInput.xmax = (input->xmax/InverseSearchRadiusOperation::DIVIDER)+1; + searchInput.xmin = (input->xmin/InverseSearchRadiusOperation::DIVIDER)-1; + searchInput.ymax = (input->ymax/InverseSearchRadiusOperation::DIVIDER)+1; + searchInput.ymin = (input->ymin/InverseSearchRadiusOperation::DIVIDER)-1; + operation = getInputOperation(4); + if (operation->determineDependingAreaOfInterest(&searchInput, readOperation, output) ) { + return true; + } +#endif operation = getInputOperation(0); if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { return true; } return false; } + +#ifdef COM_DEFOCUS_SEARCH +// InverseSearchRadiusOperation +InverseSearchRadiusOperation::InverseSearchRadiusOperation() : NodeOperation() +{ + this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // radius + this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // depth + this->addOutputSocket(COM_DT_COLOR); + this->setComplex(true); + this->inputRadius = NULL; + this->inputDepth = NULL; +} + +void InverseSearchRadiusOperation::initExecution() +{ + this->inputRadius = this->getInputSocketReader(0); + this->inputDepth = this->getInputSocketReader(1); +} + +void* InverseSearchRadiusOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +{ + MemoryBuffer * data = new MemoryBuffer(NULL, rect); + int x, y; + float width = this->inputRadius->getWidth(); + float height = this->inputRadius->getHeight(); + + for (x = rect->xmin; x < rect->xmax ; x++) { + for (y = rect->ymin; y < rect->ymax ; y++) { + float[4] temp; + int rx = x * DIVIDER; + int ry = y * DIVIDER; + this->inputRadius->read(temp, rx, ry, memoryBuffers, NULL); + float centerRadius = temp[0]; + this->inputDepth->read(temp, rx, ry, memoryBuffers, NULL); + float centerDepth = temp[0]; + t[0] = MAX2(rx - this->maxBlur, 0.0f); + t[1] = MAX2(ry - this->maxBlur, 0.0f); + t[2] = MIN2(rx + this->maxBlur, width); + t[3] = MIN2(ry + this->maxBlur, height); + int minx = t[0]; + int miny = t[1]; + int maxx = t[2]; + int maxy = t[3]; + int sminx = rx; + int smaxx = rx; + int sminy = ry; + int smaxy = ry; + for (int nx = minx ; nx < maxx ; nx ++) { + for (int ny = miny ; ny < maxy ; ny ++) { + this->inputRadius->read(temp, nx, ny, memoryBuffers, NULL); + if (nx < rx && temp[0]) + + } + } + float t[4]; + data->writePixel(x, y, t); + } + } + return data; +} + +void InverseSearchRadiusOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +{ + MemoryBuffer *buffer = (MemoryBuffer*)data; + buffer->read(color, x, y); +} + +void InverseSearchRadiusOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) +{ + if (data) { + MemoryBuffer* mb = (MemoryBuffer*)data; + delete mb; + } +} + +void InverseSearchRadiusOperation::deinitExecution() +{ + this->inputRadius = NULL; + this->inputDepth = NULL; +} + +void InverseSearchRadiusOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) +{ + NodeOperation::determineResolution(resolution, preferredResolution); + resolution[0] = resolution[0] / DIVIDER; + resolution[1] = resolution[1] / DIVIDER; +} + +bool InverseSearchRadiusOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + rcti newRect; + newRect.ymin = input->ymin*DIVIDER; + newRect.ymax = input->ymax*DIVIDER; + newRect.xmin = input->xmin*DIVIDER; + newRect.xmax = input->xmax*DIVIDER; + return NodeOperation::determineDependingAreaOfInterest(&newRect, readOperation, output); +} +#endif diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h index d04bf08405f..4bf597ff831 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h @@ -25,14 +25,18 @@ #include "COM_NodeOperation.h" #include "COM_QualityStepHelper.h" + class VariableSizeBokehBlurOperation : public NodeOperation, public QualityStepHelper { private: - int maxBlur; - float threshold; - SocketReader *inputProgram; - SocketReader *inputBokehProgram; - SocketReader *inputSizeProgram; - SocketReader *inputDepthProgram; + int m_maxBlur; + float m_threshold; + SocketReader *m_inputProgram; + SocketReader *m_inputBokehProgram; + SocketReader *m_inputSizeProgram; + SocketReader *m_inputDepthProgram; +#ifdef COM_DEFOCUS_SEARCH + SocketReader *inputSearchProgram; +#endif public: VariableSizeBokehBlurOperation(); @@ -54,10 +58,48 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void setMaxBlur(int maxRadius) { this->maxBlur = maxRadius; } + void setMaxBlur(int maxRadius) { this->m_maxBlur = maxRadius; } - void setThreshold(float threshold) { this->threshold = threshold; } + void setThreshold(float threshold) { this->m_threshold = threshold; } }; + +#ifdef COM_DEFOCUS_SEARCH +class InverseSearchRadiusOperation : public NodeOperation { +private: + int maxBlur; + float threshold; + SocketReader *inputDepth; + SocketReader *inputRadius; +public: + static const int DIVIDER = 4; + + InverseSearchRadiusOperation(); + + /** + * the inner loop of this program + */ + void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + + /** + * Initialize the execution + */ + void initExecution(); + void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data); + + /** + * Deinitialize the execution + */ + void deinitExecution(); + + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); + + void setMaxBlur(int maxRadius) { this->maxBlur = maxRadius; } + + void setThreshold(float threshold) { this->threshold = threshold; } +}; +#endif #endif diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp index 3efae2c4e3d..48be72561ba 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp @@ -34,20 +34,20 @@ VectorBlurOperation::VectorBlurOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); // ZBUF this->addInputSocket(COM_DT_COLOR); //SPEED this->addOutputSocket(COM_DT_COLOR); - this->settings = NULL; - this->cachedInstance = NULL; - this->inputImageProgram = NULL; - this->inputSpeedProgram = NULL; - this->inputZProgram = NULL; + this->m_settings = NULL; + this->m_cachedInstance = NULL; + this->m_inputImageProgram = NULL; + this->m_inputSpeedProgram = NULL; + this->m_inputZProgram = NULL; setComplex(true); } void VectorBlurOperation::initExecution() { initMutex(); - this->inputImageProgram = getInputSocketReader(0); - this->inputZProgram = getInputSocketReader(1); - this->inputSpeedProgram = getInputSocketReader(2); - this->cachedInstance = NULL; + this->m_inputImageProgram = getInputSocketReader(0); + this->m_inputZProgram = getInputSocketReader(1); + this->m_inputSpeedProgram = getInputSocketReader(2); + this->m_cachedInstance = NULL; QualityStepHelper::initExecution(COM_QH_INCREASE); } @@ -56,44 +56,43 @@ void VectorBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer { float *buffer = (float *) data; int index = (y * this->getWidth() + x) * COM_NUMBER_OF_CHANNELS; - color[0] = buffer[index]; - color[1] = buffer[index + 1]; - color[2] = buffer[index + 2]; - color[3] = buffer[index + 3]; + copy_v4_v4(color, &buffer[index]); } void VectorBlurOperation::deinitExecution() { deinitMutex(); - this->inputImageProgram = NULL; - this->inputSpeedProgram = NULL; - this->inputZProgram = NULL; - if (this->cachedInstance) { - delete cachedInstance; - this->cachedInstance = NULL; + this->m_inputImageProgram = NULL; + this->m_inputSpeedProgram = NULL; + this->m_inputZProgram = NULL; + if (this->m_cachedInstance) { + delete this->m_cachedInstance; + this->m_cachedInstance = NULL; } } void *VectorBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) { - if (this->cachedInstance) return this->cachedInstance; + if (this->m_cachedInstance) { + return this->m_cachedInstance; + } lockMutex(); - if (this->cachedInstance == NULL) { - MemoryBuffer *tile = (MemoryBuffer *)inputImageProgram->initializeTileData(rect, memoryBuffers); - MemoryBuffer *speed = (MemoryBuffer *)inputSpeedProgram->initializeTileData(rect, memoryBuffers); - MemoryBuffer *z = (MemoryBuffer *)inputZProgram->initializeTileData(rect, memoryBuffers); + if (this->m_cachedInstance == NULL) { + MemoryBuffer *tile = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect, memoryBuffers); + MemoryBuffer *speed = (MemoryBuffer *)this->m_inputSpeedProgram->initializeTileData(rect, memoryBuffers); + MemoryBuffer *z = (MemoryBuffer *)this->m_inputZProgram->initializeTileData(rect, memoryBuffers); float *data = new float[this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS]; memcpy(data, tile->getBuffer(), this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float)); this->generateVectorBlur(data, tile, speed, z); - this->cachedInstance = data; + this->m_cachedInstance = data; } unlockMutex(); - return this->cachedInstance; + return this->m_cachedInstance; } bool VectorBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { - if (this->cachedInstance == NULL) { + if (this->m_cachedInstance == NULL) { rcti newInput; newInput.xmax = this->getWidth(); newInput.xmin = 0; @@ -110,11 +109,11 @@ void VectorBlurOperation::generateVectorBlur(float *data, MemoryBuffer *inputIma { float *zbuf = inputZ->convertToValueBuffer(); NodeBlurData blurdata; - blurdata.samples = this->settings->samples / QualityStepHelper::getStep(); - blurdata.maxspeed = this->settings->maxspeed; - blurdata.minspeed = this->settings->minspeed; - blurdata.curved = this->settings->curved; - blurdata.fac = this->settings->fac; + blurdata.samples = this->m_settings->samples / QualityStepHelper::getStep(); + blurdata.maxspeed = this->m_settings->maxspeed; + blurdata.minspeed = this->m_settings->minspeed; + blurdata.curved = this->m_settings->curved; + blurdata.fac = this->m_settings->fac; RE_zbuf_accumulate_vecblur(&blurdata, this->getWidth(), this->getHeight(), data, inputImage->getBuffer(), inputSpeed->getBuffer(), zbuf); delete zbuf; return; diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.h b/source/blender/compositor/operations/COM_VectorBlurOperation.h index 30821cdd8b2..a2e72fa3232 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.h +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.h @@ -31,16 +31,16 @@ private: /** * @brief Cached reference to the inputProgram */ - SocketReader *inputImageProgram; - SocketReader *inputSpeedProgram; - SocketReader *inputZProgram; + SocketReader *m_inputImageProgram; + SocketReader *m_inputSpeedProgram; + SocketReader *m_inputZProgram; /** * @brief settings of the glare node. */ - NodeBlurData *settings; + NodeBlurData *m_settings; - float *cachedInstance; + float *m_cachedInstance; public: VectorBlurOperation(); @@ -62,7 +62,7 @@ public: void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); - void setVectorBlurSettings(NodeBlurData *settings) { this->settings = settings; } + void setVectorBlurSettings(NodeBlurData *settings) { this->m_settings = settings; } bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); protected: diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp index 3173599ece6..ee3f44d8979 100644 --- a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp @@ -35,12 +35,12 @@ VectorCurveOperation::VectorCurveOperation() : CurveBaseOperation() this->addInputSocket(COM_DT_VECTOR); this->addOutputSocket(COM_DT_VECTOR); - this->inputProgram = NULL; + this->m_inputProgram = NULL; } void VectorCurveOperation::initExecution() { CurveBaseOperation::initExecution(); - this->inputProgram = this->getInputSocketReader(0); + this->m_inputProgram = this->getInputSocketReader(0); } void VectorCurveOperation::executePixel(float *output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -48,13 +48,13 @@ void VectorCurveOperation::executePixel(float *output, float x, float y, PixelSa float input[4]; - this->inputProgram->read(input, x, y, sampler, inputBuffers); + this->m_inputProgram->read(input, x, y, sampler, inputBuffers); - curvemapping_evaluate_premulRGBF(this->curveMapping, output, input); + curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, input); output[3] = input[3]; } void VectorCurveOperation::deinitExecution() { - this->inputProgram = NULL; + this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.h b/source/blender/compositor/operations/COM_VectorCurveOperation.h index 41faee7acf6..2fbaf170986 100644 --- a/source/blender/compositor/operations/COM_VectorCurveOperation.h +++ b/source/blender/compositor/operations/COM_VectorCurveOperation.h @@ -30,7 +30,7 @@ private: /** * Cached reference to the inputProgram */ - SocketReader *inputProgram; + SocketReader *m_inputProgram; public: VectorCurveOperation(); diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp index a8aa84e84f9..446b169763c 100644 --- a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp @@ -42,10 +42,10 @@ ViewerBaseOperation::ViewerBaseOperation() : NodeOperation() { this->setImage(NULL); this->setImageUser(NULL); - this->outputBuffer = NULL; - this->outputBufferDisplay = NULL; - this->active = false; - this->doColorManagement = true; + this->m_outputBuffer = NULL; + this->m_outputBufferDisplay = NULL; + this->m_active = false; + this->m_doColorManagement = true; } void ViewerBaseOperation::initExecution() @@ -57,8 +57,8 @@ void ViewerBaseOperation::initExecution() void ViewerBaseOperation::initImage() { - Image *anImage = this->image; - ImBuf *ibuf = BKE_image_acquire_ibuf(anImage, this->imageUser, &this->lock); + Image *anImage = this->m_image; + ImBuf *ibuf = BKE_image_acquire_ibuf(anImage, this->m_imageUser, &this->m_lock); if (!ibuf) return; if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) { @@ -73,10 +73,10 @@ void ViewerBaseOperation::initImage() } /* now we combine the input with ibuf */ - this->outputBuffer = ibuf->rect_float; - this->outputBufferDisplay = (unsigned char *)ibuf->rect; + this->m_outputBuffer = ibuf->rect_float; + this->m_outputBufferDisplay = (unsigned char *)ibuf->rect; - BKE_image_release_ibuf(this->image, this->lock); + BKE_image_release_ibuf(this->m_image, this->m_lock); } void ViewerBaseOperation:: updateImage(rcti *rect) { @@ -85,7 +85,7 @@ void ViewerBaseOperation:: updateImage(rcti *rect) void ViewerBaseOperation::deinitExecution() { - this->outputBuffer = NULL; + this->m_outputBuffer = NULL; } const CompositorPriority ViewerBaseOperation::getRenderPriority() const diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.h b/source/blender/compositor/operations/COM_ViewerBaseOperation.h index 2aaa7d20966..f3fd1e9c9df 100644 --- a/source/blender/compositor/operations/COM_ViewerBaseOperation.h +++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.h @@ -28,35 +28,35 @@ class ViewerBaseOperation : public NodeOperation { protected: - float *outputBuffer; - unsigned char *outputBufferDisplay; - Image *image; - ImageUser *imageUser; - void *lock; - bool active; - float centerX; - float centerY; - OrderOfChunks chunkOrder; - bool doColorManagement; - bool doColorPredivide; + float *m_outputBuffer; + unsigned char *m_outputBufferDisplay; + Image *m_image; + ImageUser *m_imageUser; + void *m_lock; + bool m_active; + float m_centerX; + float m_centerY; + OrderOfChunks m_chunkOrder; + bool m_doColorManagement; + bool m_doColorPredivide; public: bool isOutputOperation(bool rendering) const { return isActiveViewerOutput(); } void initExecution(); void deinitExecution(); - void setImage(Image *image) { this->image = image; } - void setImageUser(ImageUser *imageUser) { this->imageUser = imageUser; } - const bool isActiveViewerOutput() const { return active; } - void setActive(bool active) { this->active = active; } - void setCenterX(float centerX) { this->centerX = centerX;} - void setCenterY(float centerY) { this->centerY = centerY;} - void setChunkOrder(OrderOfChunks tileOrder) { this->chunkOrder = tileOrder; } - float getCenterX() { return this->centerX; } - float getCenterY() { return this->centerY; } - OrderOfChunks getChunkOrder() { return this->chunkOrder; } + void setImage(Image *image) { this->m_image = image; } + void setImageUser(ImageUser *imageUser) { this->m_imageUser = imageUser; } + const bool isActiveViewerOutput() const { return this->m_active; } + void setActive(bool active) { this->m_active = active; } + void setCenterX(float centerX) { this->m_centerX = centerX;} + void setCenterY(float centerY) { this->m_centerY = centerY;} + void setChunkOrder(OrderOfChunks tileOrder) { this->m_chunkOrder = tileOrder; } + float getCenterX() { return this->m_centerX; } + float getCenterY() { return this->m_centerY; } + OrderOfChunks getChunkOrder() { return this->m_chunkOrder; } const CompositorPriority getRenderPriority() const; - void setColorManagement(bool doColorManagement) { this->doColorManagement = doColorManagement; } - void setColorPredivide(bool doColorPredivide) { this->doColorPredivide = doColorPredivide; } + void setColorManagement(bool doColorManagement) { this->m_doColorManagement = doColorManagement; } + void setColorPredivide(bool doColorPredivide) { this->m_doColorPredivide = doColorPredivide; } bool isViewerOperation() { return true; } protected: diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp index cf7bf3fdc9d..9278ddd6ead 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp @@ -44,30 +44,30 @@ ViewerOperation::ViewerOperation() : ViewerBaseOperation() this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VALUE); - this->imageInput = NULL; - this->alphaInput = NULL; + this->m_imageInput = NULL; + this->m_alphaInput = NULL; } void ViewerOperation::initExecution() { // When initializing the tree during initial load the width and height can be zero. - this->imageInput = getInputSocketReader(0); - this->alphaInput = getInputSocketReader(1); + this->m_imageInput = getInputSocketReader(0); + this->m_alphaInput = getInputSocketReader(1); ViewerBaseOperation::initExecution(); } void ViewerOperation::deinitExecution() { - this->imageInput = NULL; - this->alphaInput = NULL; + this->m_imageInput = NULL; + this->m_alphaInput = NULL; ViewerBaseOperation::deinitExecution(); } void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) { - float *buffer = this->outputBuffer; - unsigned char *bufferDisplay = this->outputBufferDisplay; + float *buffer = this->m_outputBuffer; + unsigned char *bufferDisplay = this->m_outputBufferDisplay; if (!buffer) return; const int x1 = rect->xmin; const int y1 = rect->ymin; @@ -82,14 +82,14 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryB for (y = y1; y < y2 && (!breaked); y++) { for (x = x1; x < x2; x++) { - imageInput->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); - if (alphaInput != NULL) { - alphaInput->read(alpha, x, y, COM_PS_NEAREST, memoryBuffers); + this->m_imageInput->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers); + if (this->m_alphaInput != NULL) { + this->m_alphaInput->read(alpha, x, y, COM_PS_NEAREST, memoryBuffers); buffer[offset + 3] = alpha[0]; } /// @todo: linear conversion only when scene color management is selected, also check predivide. - if (this->doColorManagement) { - if (this->doColorPredivide) { + if (this->m_doColorManagement) { + if (this->m_doColorPredivide) { linearrgb_to_srgb_predivide_v4(srgb, buffer + offset); } else { diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h index 49ef5ad4bb7..fd83c3957f1 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.h +++ b/source/blender/compositor/operations/COM_ViewerOperation.h @@ -29,8 +29,8 @@ class ViewerOperation : public ViewerBaseOperation { private: - SocketReader *imageInput; - SocketReader *alphaInput; + SocketReader *m_imageInput; + SocketReader *m_alphaInput; public: ViewerOperation(); diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp index e1018e0d037..b8c7478b2f7 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp @@ -23,46 +23,50 @@ #include "COM_WriteBufferOperation.h" #include "COM_defines.h" #include <stdio.h> +#include "COM_OpenCLDevice.h" WriteBufferOperation::WriteBufferOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); - this->memoryProxy = new MemoryProxy(); - this->memoryProxy->setWriteBufferOperation(this); - this->memoryProxy->setExecutor(NULL); + this->m_memoryProxy = new MemoryProxy(); + this->m_memoryProxy->setWriteBufferOperation(this); + this->m_memoryProxy->setExecutor(NULL); } WriteBufferOperation::~WriteBufferOperation() { - if (this->memoryProxy) { - delete this->memoryProxy; - this->memoryProxy = NULL; + if (this->m_memoryProxy) { + delete this->m_memoryProxy; + this->m_memoryProxy = NULL; } } void WriteBufferOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { - input->read(color, x, y, sampler, inputBuffers); + this->m_input->read(color, x, y, sampler, inputBuffers); } void WriteBufferOperation::initExecution() { - this->input = this->getInputOperation(0); - this->memoryProxy->allocate(this->width, this->height); + this->m_input = this->getInputOperation(0); + this->m_memoryProxy->allocate(this->m_width, this->m_height); } void WriteBufferOperation::deinitExecution() { - this->input = NULL; - this->memoryProxy->free(); + this->m_input = NULL; + this->m_memoryProxy->free(); } void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) { //MemoryBuffer *memoryBuffer = MemoryManager::getMemoryBuffer(this->getMemoryProxy(), tileNumber); - MemoryBuffer *memoryBuffer = this->memoryProxy->getBuffer(); + MemoryBuffer *memoryBuffer = this->m_memoryProxy->getBuffer(); float *buffer = memoryBuffer->getBuffer(); - if (this->input->isComplex()) { - void *data = this->input->initializeTileData(rect, memoryBuffers); + if (this->m_input->isComplex()) { + bNode* bnode = this->m_input->getbNode(); + if (bnode&& bnode->original) bnode->original->highlight++; + + void *data = this->m_input->initializeTileData(rect, memoryBuffers); int x1 = rect->xmin; int y1 = rect->ymin; int x2 = rect->xmax; @@ -73,7 +77,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me for (y = y1; y < y2 && (!breaked); y++) { int offset4 = (y * memoryBuffer->getWidth() + x1) * COM_NUMBER_OF_CHANNELS; for (x = x1; x < x2; x++) { - input->read(&(buffer[offset4]), x, y, memoryBuffers, data); + this->m_input->read(&(buffer[offset4]), x, y, memoryBuffers, data); offset4 += COM_NUMBER_OF_CHANNELS; } @@ -83,9 +87,10 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me } if (data) { - this->input->deinitializeTileData(rect, memoryBuffers, data); + this->m_input->deinitializeTileData(rect, memoryBuffers, data); data = NULL; } + if (bnode&& bnode->original) bnode->original->highlight++; } else { int x1 = rect->xmin; @@ -99,7 +104,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me for (y = y1; y < y2 && (!breaked); y++) { int offset4 = (y * memoryBuffer->getWidth() + x1) * COM_NUMBER_OF_CHANNELS; for (x = x1; x < x2; x++) { - input->read(&(buffer[offset4]), x, y, COM_PS_NEAREST, memoryBuffers); + this->m_input->read(&(buffer[offset4]), x, y, COM_PS_NEAREST, memoryBuffers); offset4 += COM_NUMBER_OF_CHANNELS; } if (isBreaked()) { @@ -110,7 +115,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me memoryBuffer->setCreatedState(); } -void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer **inputMemoryBuffers, MemoryBuffer *outputBuffer) +void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **inputMemoryBuffers, MemoryBuffer *outputBuffer) { float *outputFloatBuffer = outputBuffer->getBuffer(); cl_int error; @@ -131,15 +136,17 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr CL_FLOAT }; - cl_mem clOutputBuffer = clCreateImage2D(context, CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, outputBufferWidth, outputBufferHeight, 0, outputFloatBuffer, &error); + cl_mem clOutputBuffer = clCreateImage2D(device->getContext(), CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, &imageFormat, outputBufferWidth, outputBufferHeight, 0, outputFloatBuffer, &error); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } // STEP 2 list<cl_mem> *clMemToCleanUp = new list<cl_mem>(); clMemToCleanUp->push_back(clOutputBuffer); list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>(); + bNode* bnode = this->m_input->getbNode(); + if (bnode&& bnode->original) bnode->original->highlight++; - this->input->executeOpenCL(context, program, queue, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp); + this->m_input->executeOpenCL(device, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp); // STEP 3 @@ -149,13 +156,14 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr // clFlush(queue); // clFinish(queue); - error = clEnqueueBarrier(queue); + error = clEnqueueBarrier(device->getQueue()); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } - error = clEnqueueReadImage(queue, clOutputBuffer, CL_TRUE, origin, region, 0, 0, outputFloatBuffer, 0, NULL, NULL); + error = clEnqueueReadImage(device->getQueue(), clOutputBuffer, CL_TRUE, origin, region, 0, 0, outputFloatBuffer, 0, NULL, NULL); if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer); - + + if (bnode&& bnode->original) bnode->original->highlight++; // STEP 4 @@ -175,7 +183,8 @@ void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program pr delete clKernelsToCleanUp; } -void WriteBufferOperation::readResolutionFromInputSocket() { +void WriteBufferOperation::readResolutionFromInputSocket() +{ NodeOperation *inputOperation = this->getInputOperation(0); this->setWidth(inputOperation->getWidth()); this->setHeight(inputOperation->getHeight()); diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h index 321eed7240a..24bfdecd124 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.h +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h @@ -31,20 +31,20 @@ * @ingroup Operation */ class WriteBufferOperation : public NodeOperation { - MemoryProxy *memoryProxy; - NodeOperation *input; + MemoryProxy *m_memoryProxy; + NodeOperation *m_input; public: WriteBufferOperation(); ~WriteBufferOperation(); int isBufferOperation() { return true; } - MemoryProxy *getMemoryProxy() { return this->memoryProxy; } + MemoryProxy *getMemoryProxy() { return this->m_memoryProxy; } void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer * inputBuffers[]); const bool isWriteBufferOperation() const { return true; } void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers); void initExecution(); void deinitExecution(); - void executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer); + void executeOpenCLRegion(OpenCLDevice* device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer); void readResolutionFromInputSocket(); }; diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.cpp b/source/blender/compositor/operations/COM_ZCombineOperation.cpp index eb02b150fa4..c1ea63432b9 100644 --- a/source/blender/compositor/operations/COM_ZCombineOperation.cpp +++ b/source/blender/compositor/operations/COM_ZCombineOperation.cpp @@ -31,19 +31,19 @@ ZCombineOperation::ZCombineOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); - this->image1Reader = NULL; - this->depth1Reader = NULL; - this->image2Reader = NULL; - this->depth2Reader = NULL; + this->m_image1Reader = NULL; + this->m_depth1Reader = NULL; + this->m_image2Reader = NULL; + this->m_depth2Reader = NULL; } void ZCombineOperation::initExecution() { - this->image1Reader = this->getInputSocketReader(0); - this->depth1Reader = this->getInputSocketReader(1); - this->image2Reader = this->getInputSocketReader(2); - this->depth2Reader = this->getInputSocketReader(3); + this->m_image1Reader = this->getInputSocketReader(0); + this->m_depth1Reader = this->getInputSocketReader(1); + this->m_image2Reader = this->getInputSocketReader(2); + this->m_depth2Reader = this->getInputSocketReader(3); } void ZCombineOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -51,13 +51,13 @@ void ZCombineOperation::executePixel(float *color, float x, float y, PixelSample float depth1[4]; float depth2[4]; - this->depth1Reader->read(depth1, x, y, sampler, inputBuffers); - this->depth2Reader->read(depth2, x, y, sampler, inputBuffers); + this->m_depth1Reader->read(depth1, x, y, sampler, inputBuffers); + this->m_depth2Reader->read(depth2, x, y, sampler, inputBuffers); if (depth1[0] < depth2[0]) { - this->image1Reader->read(color, x, y, sampler, inputBuffers); + this->m_image1Reader->read(color, x, y, sampler, inputBuffers); } else { - this->image2Reader->read(color, x, y, sampler, inputBuffers); + this->m_image2Reader->read(color, x, y, sampler, inputBuffers); } } void ZCombineAlphaOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) @@ -67,15 +67,15 @@ void ZCombineAlphaOperation::executePixel(float *color, float x, float y, PixelS float color1[4]; float color2[4]; - this->depth1Reader->read(depth1, x, y, sampler, inputBuffers); - this->depth2Reader->read(depth2, x, y, sampler, inputBuffers); + this->m_depth1Reader->read(depth1, x, y, sampler, inputBuffers); + this->m_depth2Reader->read(depth2, x, y, sampler, inputBuffers); if (depth1[0] < depth2[0]) { - this->image1Reader->read(color1, x, y, sampler, inputBuffers); - this->image2Reader->read(color2, x, y, sampler, inputBuffers); + this->m_image1Reader->read(color1, x, y, sampler, inputBuffers); + this->m_image2Reader->read(color2, x, y, sampler, inputBuffers); } else { - this->image1Reader->read(color2, x, y, sampler, inputBuffers); - this->image2Reader->read(color1, x, y, sampler, inputBuffers); + this->m_image1Reader->read(color2, x, y, sampler, inputBuffers); + this->m_image2Reader->read(color1, x, y, sampler, inputBuffers); } float fac = color1[3]; float ifac = 1.0f - fac; @@ -87,8 +87,8 @@ void ZCombineAlphaOperation::executePixel(float *color, float x, float y, PixelS void ZCombineOperation::deinitExecution() { - this->image1Reader = NULL; - this->depth1Reader = NULL; - this->image2Reader = NULL; - this->depth2Reader = NULL; + this->m_image1Reader = NULL; + this->m_depth1Reader = NULL; + this->m_image2Reader = NULL; + this->m_depth2Reader = NULL; } diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.h b/source/blender/compositor/operations/COM_ZCombineOperation.h index 56ad950a3aa..422a946b98f 100644 --- a/source/blender/compositor/operations/COM_ZCombineOperation.h +++ b/source/blender/compositor/operations/COM_ZCombineOperation.h @@ -26,15 +26,15 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ZCombineOperation : public NodeOperation { protected: - SocketReader *image1Reader; - SocketReader *depth1Reader; - SocketReader *image2Reader; - SocketReader *depth2Reader; + SocketReader *m_image1Reader; + SocketReader *m_depth1Reader; + SocketReader *m_image2Reader; + SocketReader *m_depth2Reader; public: /** * Default constructor diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 46e1eb98dae..a6d1ac64bbe 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -2397,13 +2397,15 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo case ANIMCONT_GPENCIL: { - items = animdata_filter_gpencil(anim_data, data, filter_mode); + if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) + items = animdata_filter_gpencil(anim_data, data, filter_mode); } break; case ANIMCONT_MASK: { - items = animdata_filter_mask(anim_data, data, filter_mode); + if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) + items = animdata_filter_mask(anim_data, data, filter_mode); } break; diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 4a5966948ae..672e11ac613 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -416,6 +416,7 @@ static char *get_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *pro char *basepath = RNA_path_from_ID_to_property(ptr, prop); char *path = basepath; /* in case no remapping is needed */ + /* Remapping will only be performed in the Properties Editor, as only this * restricts the subspace of options to the 'active' data (a manageable state) */ @@ -426,23 +427,6 @@ static char *get_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *pro if (ob && id) { /* only id-types which can be remapped to go through objects should be considered */ switch (GS(id->name)) { - case ID_MA: /* materials */ - { - Material *ma = give_current_material(ob, ob->actcol); - - /* assumes: material will only be shown if it is active objects's active material it's ok */ - if ((ID *)ma == id) { - /* create new path */ - // TODO: use RNA path functions to construct instead? - path = BLI_sprintfN("material_slots[\"%s\"].material.%s", - ma->id.name + 2, basepath); - - /* free old one */ - MEM_freeN(basepath); - } - } - break; - case ID_TE: /* textures */ { Material *ma = give_current_material(ob, ob->actcol); @@ -452,6 +436,7 @@ static char *get_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *pro if ((ID *)tex == id) { /* create new path */ // TODO: use RNA path functions to construct step by step instead? + // FIXME: maybe this isn't even needed anymore... path = BLI_sprintfN("material_slots[\"%s\"].material.texture_slots[\"%s\"].texture.%s", ma->id.name + 2, tex->id.name + 2, basepath); diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index ea875567705..8c1e2bedd86 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -123,7 +123,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr); /* basic settings (backdrop + mode selector + some padding) */ - /* col= uiLayoutColumn(layout, 1); */ /* UNUSED */ + /* col = uiLayoutColumn(layout, TRUE); */ /* UNUSED */ block = uiLayoutGetBlock(layout); uiBlockBeginAlign(block); but = uiDefButR(block, MENU, B_FMODIFIER_REDRAW, NULL, 0, 0, width - 30, UI_UNIT_Y, &ptr, "mode", -1, 0, 0, -1, -1, NULL); @@ -141,7 +141,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s unsigned int i; /* draw polynomial order selector */ - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 10, 0, width - 30, 19, &data->poly_order, 1, 100, 0, 0, @@ -150,7 +150,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s /* draw controls for each coefficient and a + sign at end of row */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); cp = data->coefficients; @@ -177,7 +177,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s uiDefBut(block, LABEL, 1, "+", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, ""); /* next coefficient on a new row */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); } else { @@ -194,7 +194,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s unsigned int i; /* draw polynomial order selector */ - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 0, 0, width - 30, 19, &data->poly_order, 1, 100, 0, 0, @@ -203,7 +203,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s /* draw controls for each pair of coefficients */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); cp = data->coefficients; @@ -230,7 +230,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s uiDefBut(block, LABEL, 1, ") +", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, ""); /* set up new row for the next pair of coefficients*/ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); } else @@ -253,11 +253,11 @@ static void draw_modifier__fn_generator(uiLayout *layout, ID *id, FModifier *fcm RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr); /* add the settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, &ptr, "function_type", 0, "", ICON_NONE); uiItemR(col, &ptr, "use_additive", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); // no grouping for now + col = uiLayoutColumn(layout, FALSE); // no grouping for now uiItemR(col, &ptr, "amplitude", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "phase_multiplier", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "phase_offset", 0, NULL, ICON_NONE); @@ -278,16 +278,16 @@ static void draw_modifier__cycles(uiLayout *layout, ID *id, FModifier *fcm, shor /* split into 2 columns * NOTE: the mode comboboxes shouldn't get labels, otherwise there isn't enough room */ - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); /* before range */ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemL(col, IFACE_("Before:"), ICON_NONE); uiItemR(col, &ptr, "mode_before", 0, "", ICON_NONE); uiItemR(col, &ptr, "cycles_before", 0, NULL, ICON_NONE); /* after range */ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemL(col, IFACE_("After:"), ICON_NONE); uiItemR(col, &ptr, "mode_after", 0, "", ICON_NONE); uiItemR(col, &ptr, "cycles_after", 0, NULL, ICON_NONE); @@ -308,15 +308,15 @@ static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short uiItemR(layout, &ptr, "blend_type", 0, NULL, ICON_NONE); /* split into 2 columns */ - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); /* col 1 */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemR(col, &ptr, "scale", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "strength", 0, NULL, ICON_NONE); /* col 2 */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemR(col, &ptr, "phase", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "depth", 0, NULL, ICON_NONE); } @@ -499,18 +499,18 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh RNA_pointer_create(id, &RNA_FModifierEnvelope, fcm, &ptr); /* general settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Envelope:"), ICON_NONE); uiItemR(col, &ptr, "reference_value", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "default_min", 0, IFACE_("Min"), ICON_NONE); uiItemR(row, &ptr, "default_max", 0, IFACE_("Max"), ICON_NONE); /* control points header */ // TODO: move this control-point control stuff to using the new special widgets for lists // the current way is far too cramped - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); uiDefBut(block, LABEL, 1, IFACE_("Control Points:"), 0, 0, 150, 20, NULL, 0.0, 0.0, 0, 0, ""); @@ -522,7 +522,7 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh /* control points list */ for (i = 0, fed = env->data; i < env->totvert; i++, fed++) { /* get a new row to operate on */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); uiBlockBeginAlign(block); @@ -555,36 +555,36 @@ static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, shor /* row 1: minimum */ { - /* row= uiLayoutRow(layout, 0); */ /* UNUSED */ + /* row = uiLayoutRow(layout, FALSE); */ /* UNUSED */ /* split into 2 columns */ - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); /* x-minimum */ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &ptr, "use_min_x", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "min_x", 0, NULL, ICON_NONE); /* y-minimum*/ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &ptr, "use_min_y", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "min_y", 0, NULL, ICON_NONE); } /* row 2: maximum */ { - /* row= uiLayoutRow(layout, 0); */ /* UNUSED */ + /* row = uiLayoutRow(layout, FALSE); */ /* UNUSED */ /* split into 2 columns */ - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); /* x-minimum */ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &ptr, "use_max_x", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "max_x", 0, NULL, ICON_NONE); /* y-minimum*/ - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &ptr, "use_max_y", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "max_y", 0, NULL, ICON_NONE); } @@ -602,23 +602,23 @@ static void draw_modifier__stepped(uiLayout *layout, ID *id, FModifier *fcm, sho RNA_pointer_create(id, &RNA_FModifierStepped, fcm, &ptr); /* block 1: "stepping" settings */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, &ptr, "frame_step", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "frame_offset", 0, NULL, ICON_NONE); /* block 2: start range settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, &ptr, "use_frame_start", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_start")); uiItemR(sub, &ptr, "frame_start", 0, NULL, ICON_NONE); /* block 3: end range settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, &ptr, "use_frame_end", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_end")); uiItemR(sub, &ptr, "frame_end", 0, NULL, ICON_NONE); } @@ -642,11 +642,11 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier /* get layout-row + UI-block for this */ box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); block = uiLayoutGetBlock(row); // err... /* left-align -------------------------------------------- */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); uiBlockSetEmboss(block, UI_EMBOSSN); @@ -664,7 +664,7 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier uiItemL(sub, "<Unknown Modifier>", ICON_NONE); /* right-align ------------------------------------------- */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); @@ -726,28 +726,28 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier box = uiLayoutBox(layout); /* restricted range ----------------------------------------------------- */ - col = uiLayoutColumn(box, 1); + col = uiLayoutColumn(box, TRUE); /* top row: use restricted range */ - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "use_restricted_range", 0, NULL, ICON_NONE); if (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) { /* second row: settings */ - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "frame_start", 0, IFACE_("Start"), ICON_NONE); uiItemR(row, &ptr, "frame_end", 0, IFACE_("End"), ICON_NONE); /* third row: blending influence */ - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "blend_in", 0, IFACE_("In"), ICON_NONE); uiItemR(row, &ptr, "blend_out", 0, IFACE_("Out"), ICON_NONE); } /* influence -------------------------------------------------------------- */ - col = uiLayoutColumn(box, 1); + col = uiLayoutColumn(box, TRUE); /* top row: use influence */ uiItemR(col, &ptr, "use_influence", 0, NULL, ICON_NONE); diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index e6fc4d5a168..46a89963ad9 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -847,9 +847,17 @@ void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks) ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through each F-Curve, grabbing the keyframes */ - for (ale = anim_data.first; ale; ale = ale->next) + for (ale = anim_data.first; ale; ale = ale->next) { fcurve_to_keylist(ale->adt, ale->data, keys, blocks); - + + if (ale->datatype == ALE_MASKLAY) { + mask_to_keylist(ac->ads, ale->data, keys); + } + else if (ale->datatype == ALE_GPFRAME) { + gpl_to_keylist(ac->ads, ale->data, keys); + } + } + BLI_freelistN(&anim_data); } } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 6250424d655..0c9a6ff6bf1 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -201,7 +201,7 @@ FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr, grp = (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1)); if (grp) { agrp->customCol = grp->customCol; - action_group_colors_sync(agrp); + action_group_colors_sync(agrp, grp); } } } @@ -1581,7 +1581,7 @@ void ANIM_OT_keyframe_delete_button(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* properties */ - RNA_def_boolean(ot->srna, "all", 1, "All", "Delete keyfames from all elements of the array"); + RNA_def_boolean(ot->srna, "all", 1, "All", "Delete keyframes from all elements of the array"); } /* ******************************************* */ diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 0760b384ecd..ddf66a6169b 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -183,7 +183,7 @@ LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, con void POSELIB_OT_new(struct wmOperatorType *ot); void POSELIB_OT_unlink(struct wmOperatorType *ot); -void POSELIB_OT_action_sanitise(struct wmOperatorType *ot); +void POSELIB_OT_action_sanitize(struct wmOperatorType *ot); void POSELIB_OT_pose_add(struct wmOperatorType *ot); void POSELIB_OT_pose_remove(struct wmOperatorType *ot); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index f3461f71391..59ee90c553b 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -159,7 +159,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(POSELIB_OT_new); WM_operatortype_append(POSELIB_OT_unlink); - WM_operatortype_append(POSELIB_OT_action_sanitise); + WM_operatortype_append(POSELIB_OT_action_sanitize); /* POSE SLIDING */ WM_operatortype_append(POSE_OT_push); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index ea3c8685525..6cef843d828 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -4563,7 +4563,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA); } } - /* if there are some dependencies for visualising armature state + /* if there are some dependencies for visualizing armature state * (e.g. Mask Modifier in 'Armature' mode), force update */ else if (arm->flag & ARM_HAS_VIZ_DEPS) { @@ -4828,6 +4828,9 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, if (numbones == 0) return; + if (ED_vgroup_data_create(ob->data) == FALSE) + return; + /* create an array of pointer to bones that are skinnable * and fill it with all of the skinnable bones */ bonelist = MEM_callocN(numbones * sizeof(Bone *), "bonelist"); diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index ab96656406e..6b6d2a1505f 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -667,25 +667,27 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, *err_str = NULL; /* count triangles and create mask */ - if ( (use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK) != 0) || - (use_vert_sel = ((me->editflag & ME_EDIT_VERT_SEL) != 0))) + if ((use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK) != 0) || + (use_vert_sel = ((me->editflag & ME_EDIT_VERT_SEL) != 0))) { mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask"); - } - for (a = 0, mp = me->mpoly; a < me->totpoly; mp++, a++) { /* (added selectedVerts content for vertex mask, they used to just equal 1) */ if (use_vert_sel) { - for (j = 0, ml = me->mloop + mp->loopstart; j < mp->totloop; j++, ml++) { - if (use_vert_sel) { - mask[ml->v] = (mvert[ml->v].flag & SELECT) != 0; + for (a = 0, mp = me->mpoly; a < me->totpoly; mp++, a++) { + for (j = 0, ml = me->mloop + mp->loopstart; j < mp->totloop; j++, ml++) { + if (use_vert_sel) { + mask[ml->v] = (mvert[ml->v].flag & SELECT) != 0; + } } } } else if (use_face_sel) { - if (mp->flag & ME_FACE_SEL) { - for (j = 0, ml = me->mloop + mp->loopstart; j < mp->totloop; j++, ml++) { - mask[ml->v] = 1; + for (a = 0, mp = me->mpoly; a < me->totpoly; mp++, a++) { + if (mp->flag & ME_FACE_SEL) { + for (j = 0, ml = me->mloop + mp->loopstart; j < mp->totloop; j++, ml++) { + mask[ml->v] = 1; + } } } } diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 824a39374fd..51700793791 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -220,7 +220,7 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val) else { /* - these weights are derived from the relative distance of these * poses from the current frame - * - they then get normalised so that they only sum up to 1 + * - they then get normalized so that they only sum up to 1 */ float wtot; diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 18e3d967835..ee54fc2c6fe 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -288,7 +288,7 @@ void POSELIB_OT_unlink(wmOperatorType *ot) /* This tool automagically generates/validates poselib data so that it corresponds to the data * in the action. This is for use in making existing actions usable as poselibs. */ -static int poselib_sanitise_exec(bContext *C, wmOperator *op) +static int poselib_sanitize_exec(bContext *C, wmOperator *op) { Object *ob = get_poselib_object(C); bAction *act = (ob) ? ob->poselib : NULL; @@ -353,15 +353,15 @@ static int poselib_sanitise_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void POSELIB_OT_action_sanitise(wmOperatorType *ot) +void POSELIB_OT_action_sanitize(wmOperatorType *ot) { /* identifiers */ - ot->name = "Sanitise Pose Library Action"; - ot->idname = "POSELIB_OT_action_sanitise"; + ot->name = "Sanitize Pose Library Action"; + ot->idname = "POSELIB_OT_action_sanitize"; ot->description = "Make action suitable for use as a Pose Library"; /* callbacks */ - ot->exec = poselib_sanitise_exec; + ot->exec = poselib_sanitize_exec; ot->poll = has_poselib_pose_data_poll; /* flags */ diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 2fa7b4b2126..e8a71a35576 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1199,8 +1199,6 @@ void load_editNurb(Object *obedit) if (obedit == NULL) return; - set_actNurb(obedit, NULL); - if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { Curve *cu = obedit->data; Nurb *nu, *newnu; @@ -1222,8 +1220,6 @@ void load_editNurb(Object *obedit) BKE_nurbList_free(&oldnurb); } - - set_actNurb(obedit, NULL); } /* make copy in cu->editnurb */ @@ -1234,7 +1230,6 @@ void make_editNurb(Object *obedit) Nurb *nu, *newnu, *nu_act = NULL; KeyBlock *actkey; - set_actNurb(obedit, NULL); if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { @@ -2373,7 +2368,7 @@ void CURVE_OT_smooth_radius(wmOperatorType *ot) { /* identifiers */ ot->name = "Smooth Curve Radius"; - ot->description = "Flatten radiuses of selected points"; + ot->description = "Flatten radii of selected points"; ot->idname = "CURVE_OT_smooth_radius"; /* api clastbacks */ @@ -3937,8 +3932,8 @@ static int make_segment_exec(bContext *C, wmOperator *op) ListBase *nubase = object_editcurve_get(obedit); Nurb *nu, *nu1 = NULL, *nu2 = NULL; BPoint *bp; - float *fp, offset; - int a, ok = 0; + int ok = 0; + /* int a; */ /* UNUSED */ /* first decide if this is a surface merge! */ if (obedit->type == OB_SURF) nu = nubase->first; @@ -4046,32 +4041,19 @@ static int make_segment_exec(bContext *C, wmOperator *op) MEM_freeN(nu1->bp); nu1->bp = bp; - a = nu1->pntsu + nu1->orderu; + /* a = nu1->pntsu + nu1->orderu; */ /* UNUSED */ nu1->pntsu += nu2->pntsu; BLI_remlink(nubase, nu2); /* now join the knots */ if (nu1->type == CU_NURBS) { - if (nu1->knotsu == NULL) { - BKE_nurb_knot_calc_u(nu1); - } - else { - fp = MEM_mallocN(sizeof(float) * KNOTSU(nu1), "addsegment3"); - memcpy(fp, nu1->knotsu, sizeof(float) * a); + if (nu1->knotsu != NULL) { MEM_freeN(nu1->knotsu); - nu1->knotsu = fp; - - - offset = nu1->knotsu[a - 1] + 1.0f; - fp = nu1->knotsu + a; - for (a = 0; a < nu2->pntsu; a++, fp++) { - if (nu2->knotsu) - *fp = offset + nu2->knotsu[a + 1]; - else - *fp = offset; - } + nu1->knotsu = NULL; } + + BKE_nurb_knot_calc_u(nu1); } BKE_nurb_free(nu2); nu2 = NULL; } diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index fa555b0ddb8..6d113cbb924 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -281,7 +281,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s, } /* tessellation code - draw stroke as series of connected quads with connection - * edges rotated to minimise shrinking artifacts, and rounded endcaps + * edges rotated to minimize shrinking artifacts, and rounded endcaps */ else { bGPDspoint *pt1, *pt2; diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index a7beaa74eb7..b69db0040b5 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -399,7 +399,7 @@ void paste_gpdata(Scene *scene) /* this should be the right frame... as it may be a pre-existing frame, * must make sure that only compatible stroke types get copied over * - we cannot just add a duplicate frame, as that would cause errors - * - need to check for compatible types to minimise memory usage (copying 'junk' over) + * - need to check for compatible types to minimize memory usage (copying 'junk' over) */ for (gps = gpfs->strokes.first; gps; gps = gps->next) { short stroke_ok; diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index 4c125ebe013..d90ec02b0c1 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -113,20 +113,20 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* get layout-row + UI-block for header */ box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND); block = uiLayoutGetBlock(row); /* err... */ uiBlockSetEmboss(block, UI_EMBOSSN); /* left-align ............................... */ - sub = uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); /* active */ block = uiLayoutGetBlock(sub); icon = (gpl->flag & GP_LAYER_ACTIVE) ? ICON_RADIOBUT_ON : ICON_RADIOBUT_OFF; but = uiDefIconButBitI(block, TOG, GP_LAYER_ACTIVE, 0, icon, 0, 0, UI_UNIT_X, UI_UNIT_Y, - &gpd->flag, 0.0, 0.0, 0.0, 0.0, TIP_("Set active layer")); + &gpl->flag, 0.0, 0.0, 0.0, 0.0, TIP_("Set active layer")); uiButSetFunc(but, gp_ui_activelayer_cb, gpd, gpl); /* locked */ @@ -151,7 +151,7 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* delete button (only if hidden but not locked!) */ if ((gpl->flag & GP_LAYER_HIDE) && !(gpl->flag & GP_LAYER_LOCKED)) { /* right-align ............................... */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); block = uiLayoutGetBlock(sub); /* XXX... err... */ @@ -179,7 +179,7 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* delete 'button' */ uiBlockSetEmboss(block, UI_EMBOSSN); /* right-align ............................... */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); block = uiLayoutGetBlock(sub); /* XXX... err... */ @@ -190,14 +190,14 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* new backdrop ----------------------------------- */ box = uiLayoutBox(layout); - split = uiLayoutSplit(box, 0.5f, 0); + split = uiLayoutSplit(box, 0.5f, FALSE); /* draw settings ---------------------------------- */ /* left column ..................... */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); /* color */ - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiItemR(sub, &ptr, "color", 0, "", ICON_NONE); uiItemR(sub, &ptr, "alpha", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -210,10 +210,10 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons } /* right column ................... */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); /* onion-skinning */ - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiItemR(sub, &ptr, "use_onion_skinning", 0, NULL, ICON_NONE); uiItemR(sub, &ptr, "ghost_range_max", 0, IFACE_("Frames"), ICON_NONE); @@ -236,14 +236,14 @@ static void draw_gpencil_space_specials(const bContext *C, uiLayout *layout) uiLayout *col, *row; SpaceClip *sc = CTX_wm_space_clip(C); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); if (sc) { bScreen *screen = CTX_wm_screen(C); PointerRNA sc_ptr; RNA_pointer_create(&screen->id, &RNA_SpaceClipEditor, sc, &sc_ptr); - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &sc_ptr, "grease_pencil_source", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } } @@ -262,7 +262,7 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin RNA_id_pointer_create((ID *)gpd, &gpd_ptr); /* draw gpd settings first ------------------------------------- */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); /* current Grease Pencil block */ /* TODO: show some info about who owns this? */ @@ -270,7 +270,7 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin /* add new layer button - can be used even when no data, since it can add a new block too */ uiItemO(col, IFACE_("New Layer"), ICON_NONE, "GPENCIL_OT_layer_add"); - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemO(row, IFACE_("Delete Frame"), ICON_NONE, "GPENCIL_OT_active_frame_delete"); uiItemO(row, IFACE_("Convert"), ICON_NONE, "GPENCIL_OT_convert"); @@ -280,12 +280,12 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin /* draw each layer --------------------------------------------- */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); gp_drawui_layer(col, gpd, gpl, is_v3d); } /* draw gpd drawing settings first ------------------------------------- */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); /* label */ uiItemL(col, IFACE_("Drawing Settings:"), ICON_NONE); @@ -298,17 +298,17 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin } /* drawing space options */ - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "VIEW", NULL, ICON_NONE); uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "CURSOR", NULL, ICON_NONE); if (sc == NULL) { - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiLayoutSetActive(row, v3d_stroke_opts); uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "SURFACE", NULL, ICON_NONE); uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "STROKE", NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, v3d_stroke_opts == STROKE_OPTS_V3D_ON); uiItemR(row, &gpd_ptr, "use_stroke_endpoints", 0, NULL, ICON_NONE); } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 6d90824668e..12b002ef612 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -56,6 +56,7 @@ #include "ED_gpencil.h" #include "ED_screen.h" #include "ED_view3d.h" +#include "ED_clip.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -1032,8 +1033,9 @@ static int gp_session_initdata(bContext *C, tGPsdata *p) p->custom_color[3] = 0.9f; if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) { - int framenr = sc->user.framenr; - MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking); + MovieClip *clip = ED_space_clip_get_clip(sc); + int framenr = ED_space_clip_get_clip_frame_number(sc); + MovieTrackingTrack *track = BKE_tracking_track_get_active(&clip->tracking); MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr); p->imat[3][0] -= marker->pos[0]; diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 24aa88a36bd..e1401a8ff88 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -177,7 +177,7 @@ typedef enum eAnim_KeyType { ALE_NONE = 0, /* no keyframe data */ ALE_FCURVE, /* F-Curve */ ALE_GPFRAME, /* Grease Pencil Frames */ - ALE_MASKLAY, /* Mask */ + ALE_MASKLAY, /* Mask */ ALE_NLASTRIP, /* NLA Strips */ ALE_ALL, /* All channels summary */ diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index 3a9d73ccf10..2670fb5b042 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -42,6 +42,8 @@ struct SpaceClip; struct wmEvent; /* ** clip_editor.c ** */ + +/* common poll functions */ int ED_space_clip_poll(struct bContext *C); int ED_space_clip_view_clip_poll(struct bContext *C); @@ -50,14 +52,10 @@ int ED_space_clip_tracking_poll(struct bContext *C); int ED_space_clip_maskedit_poll(struct bContext *C); int ED_space_clip_maskedit_mask_poll(bContext *C); -struct MovieClip *ED_space_clip_get_clip(struct SpaceClip *sc); -void ED_space_clip_set_clip(struct bContext *C, struct bScreen *screen, struct SpaceClip *sc, struct MovieClip *clip); - -void ED_space_clip_get_zoom(struct SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy); - -void ED_space_clip_get_clip_size(struct SpaceClip *sc, int *width, int *height); -void ED_space_clip_get_clip_aspect(struct SpaceClip *sc, float *aspx, float *aspy); -void ED_space_clip_get_clip_aspect_dimension_aware(struct SpaceClip *sc, float *aspx, float *aspy); +void ED_space_clip_get_size(const struct bContext *C, int *width, int *height); +void ED_space_clip_get_zoom(const struct bContext *C, float *zoomx, float *zoomy); +void ED_space_clip_get_aspect(struct SpaceClip *sc, float *aspx, float *aspy); +void ED_space_clip_get_aspect_dimension_aware(struct SpaceClip *sc, float *aspx, float *aspy); int ED_space_clip_get_clip_frame_number(struct SpaceClip *sc); @@ -65,18 +63,18 @@ struct ImBuf *ED_space_clip_get_buffer(struct SpaceClip *sc); struct ImBuf *ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2], float *scale, float *angle); void ED_clip_update_frame(const struct Main *mainp, int cfra); -int ED_clip_view_selection(struct SpaceClip *sc, struct ARegion *ar, int fit); +int ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, int fit); void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[2]); void ED_clip_point_stable_pos(const struct bContext *C, float x, float y, float *xr, float *yr); -void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, const float co[2], float r_co[2]); +void ED_clip_point_stable_pos__reverse(const struct bContext *C, const float co[2], float r_co[2]); void ED_clip_mouse_pos(const struct bContext *C, struct wmEvent *event, float co[2]); int ED_space_clip_check_show_trackedit(struct SpaceClip *sc); int ED_space_clip_check_show_maskedit(struct SpaceClip *sc); -void ED_space_clip_get_mask_size(struct SpaceClip *sc, int *width, int *height); -void ED_space_clip_get_mask_aspect(struct SpaceClip *sc, float *aspx, float *aspy); +struct MovieClip *ED_space_clip_get_clip(struct SpaceClip *sc); +void ED_space_clip_set_clip(struct bContext *C, struct bScreen *screen, struct SpaceClip *sc, struct MovieClip *clip); struct Mask *ED_space_clip_get_mask(struct SpaceClip *sc); void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask); diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index 66e65d114cb..6f86d01fb98 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -41,10 +41,20 @@ struct bNodeTree; struct bNode; struct bNodeTree; struct ScrArea; +struct View2D; + +typedef enum { + NODE_TOP = 1, + NODE_BOTTOM = 2, + NODE_LEFT = 4, + NODE_RIGHT = 8 +} NodeBorder; /* drawnode.c */ void ED_init_node_butfuncs(void); +void drawnodesnap(struct View2D *v2d, const float cent[2], float size, NodeBorder border); + /* node_draw.c */ void ED_node_tree_update(struct SpaceNode *snode, struct Scene *scene); void ED_node_changed_update(struct ID *id, struct bNode *node); @@ -61,6 +71,9 @@ void ED_node_link_insert(struct ScrArea *sa); void ED_node_post_apply_transform(struct bContext *C, struct bNodeTree *ntree); void ED_node_set_active(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node); + +void ED_node_sample_set(const float col[4]); + /* node ops.c */ void ED_operatormacros_node(void); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 9c10a270ef8..9209bbb2db7 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -176,6 +176,12 @@ int ED_object_modifier_apply(struct ReportList *reports, 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); +int ED_object_iter_other(struct Main *bmain, struct Object *orig_ob, int include_orig, + int (*callback)(struct Object *ob, void *callback_data), + void *callback_data); + +int ED_object_multires_update_totlevels_cb(struct Object *ob, void *totlevel_v); + #ifdef __cplusplus } #endif diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h index c53dca47da9..6b9d8385ac3 100644 --- a/source/blender/editors/include/ED_screen_types.h +++ b/source/blender/editors/include/ED_screen_types.h @@ -76,10 +76,10 @@ typedef struct ScreenFrameRateInfo { /* Enum for Action Zone Edges. Which edge of area is action zone. */ typedef enum { - AE_RIGHT_TO_TOPLEFT, /* Region located on the left, _right_ edge is action zone. Region minimised to the top left */ - AE_LEFT_TO_TOPRIGHT, /* Region located on the right, _left_ edge is action zone. Region minimised to the top right */ - AE_TOP_TO_BOTTOMRIGHT, /* Region located at the bottom, _top_ edge is action zone. Region minimised to the bottom right */ - AE_BOTTOM_TO_TOPLEFT /* Region located at the top, _bottom_edge is action zone. Region minimised to the top left */ + AE_RIGHT_TO_TOPLEFT, /* Region located on the left, _right_ edge is action zone. Region minimized to the top left */ + AE_LEFT_TO_TOPRIGHT, /* Region located on the right, _left_ edge is action zone. Region minimized to the top right */ + AE_TOP_TO_BOTTOMRIGHT, /* Region located at the bottom, _top_ edge is action zone. Region minimized to the bottom right */ + AE_BOTTOM_TO_TOPLEFT /* Region located at the top, _bottom_edge is action zone. Region minimized to the top left */ } AZEdge; /* for editing areas/regions */ diff --git a/source/blender/editors/include/ED_sequencer.h b/source/blender/editors/include/ED_sequencer.h index cea567254de..7ba26f30c39 100644 --- a/source/blender/editors/include/ED_sequencer.h +++ b/source/blender/editors/include/ED_sequencer.h @@ -33,4 +33,6 @@ struct Sequence; void ED_sequencer_select_sequence_single(struct Scene *scene, struct Sequence *seq, int deselect_all); void ED_sequencer_deselect_all(struct Scene *scene); +void ED_operatormacros_sequencer(void); + #endif /* __ED_SEQUENCER_H__ */ diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 608df8dd9b3..d7e9fc323a6 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -180,6 +180,8 @@ int peelObjectsTransForm(struct TransInfo *t, struct ListBase *depth_peels, cons int peelObjectsContext(struct bContext *C, struct ListBase *depth_peels, const float mval[2], SnapMode mode); int snapObjectsTransform(struct TransInfo *t, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode); int snapObjectsContext(struct bContext *C, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode); +int snapNodesTransform(struct TransInfo *t, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode); +int snapNodesContext(struct bContext *C, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode); #endif diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 469388219d6..5039a30b61a 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -166,6 +166,7 @@ void UI_view2d_view_restore(const struct bContext *C); View2DGrid *UI_view2d_grid_calc(struct Scene *scene, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp, int winx, int winy); void UI_view2d_grid_draw(struct View2D *v2d, View2DGrid *grid, int flag); void UI_view2d_constant_grid_draw(struct View2D *v2d); +void UI_view2d_multi_grid_draw(struct View2D *v2d, float step, int level_size, int totlevels); void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy); void UI_view2d_grid_free(View2DGrid *grid); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index d26c8cefdf0..49d56d427ba 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -498,7 +498,7 @@ static int ui_but_float_precision(uiBut *but, double value) return prec; } -static void ui_draw_linkline(uiLinkLine *line, int hilightActiveLines) +static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines) { rcti rect; @@ -511,7 +511,7 @@ static void ui_draw_linkline(uiLinkLine *line, int hilightActiveLines) if (line->flag & UI_SELECT) glColor3ub(100, 100, 100); - else if (hilightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))) + else if (highlightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))) UI_ThemeColor(TH_TEXT_HI); else glColor3ub(0, 0, 0); @@ -919,7 +919,7 @@ void uiEndBlock(const bContext *C, uiBlock *block) if (ui_but_update_from_old_block(C, block, &but)) ui_check_but(but); - /* temp? Proper check for greying out */ + /* temp? Proper check for graying out */ if (but->optype) { wmOperatorType *ot = but->optype; diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 0007facdf8f..f173e7ce630 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1310,7 +1310,7 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o fx = rect->xmin + zoomx * (-offsx); if (fx > rect->xmin) fx -= dx * (floorf(fx - rect->xmin)); while (fx < rect->xmax) { - glVertex2f(fx, rect->ymin); + glVertex2f(fx, rect->ymin); glVertex2f(fx, rect->ymax); fx += dx; } @@ -1319,7 +1319,7 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o fy = rect->ymin + zoomy * (-offsy); if (fy > rect->ymin) fy -= dy * (floorf(fy - rect->ymin)); while (fy < rect->ymax) { - glVertex2f(rect->xmin, fy); + glVertex2f(rect->xmin, fy); glVertex2f(rect->xmax, fy); fy += dy; } @@ -1346,7 +1346,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect cumap = (CurveMapping *)(but->editcumap ? but->editcumap : but->poin); cuma = cumap->cm + cumap->cur; - + /* need scissor test, curve can draw outside of boundary */ glGetIntegerv(GL_VIEWPORT, scissor); scissor_new.xmin = ar->winrct.xmin + rect->xmin; @@ -1363,53 +1363,56 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect offsy = cumap->curr.ymin - but->aspect / zoomy; /* backdrop */ - if (cumap->flag & CUMA_DO_CLIP) { - gl_shaded_color((unsigned char *)wcol->inner, -20); - glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); - glColor3ubv((unsigned char *)wcol->inner); - glRectf(rect->xmin + zoomx * (cumap->clipr.xmin - offsx), - rect->ymin + zoomy * (cumap->clipr.ymin - offsy), - rect->xmin + zoomx * (cumap->clipr.xmax - offsx), - rect->ymin + zoomy * (cumap->clipr.ymax - offsy)); + if (but->a1 == UI_GRAD_H) { + /* magic trigger for curve backgrounds */ + rcti grid; + float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */ + + grid.xmin = rect->xmin + zoomx * (-offsx); + grid.xmax = rect->xmax + zoomx * (-offsx); + grid.ymin = rect->ymin + zoomy * (-offsy); + grid.ymax = rect->ymax + zoomy * (-offsy); + + ui_draw_gradient(&grid, col, UI_GRAD_H, 1.0f); + + /* grid, hsv uses different grid */ + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor4ub(0, 0, 0, 48); + ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.1666666f); + glDisable(GL_BLEND); } else { - glColor3ubv((unsigned char *)wcol->inner); - glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); - } - - /* grid, every 0.25 step */ - gl_shaded_color((unsigned char *)wcol->inner, -16); - ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.25f); - /* grid, every 1.0 step */ - gl_shaded_color((unsigned char *)wcol->inner, -24); - ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 1.0f); - /* axes */ - gl_shaded_color((unsigned char *)wcol->inner, -50); - glBegin(GL_LINES); - glVertex2f(rect->xmin, rect->ymin + zoomy * (-offsy)); - glVertex2f(rect->xmax, rect->ymin + zoomy * (-offsy)); - glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymin); - glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymax); - glEnd(); - - /* magic trigger for curve backgrounds */ - if (but->a1 != -1) { - if (but->a1 == UI_GRAD_H) { - rcti grid; - float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */ - - grid.xmin = rect->xmin + zoomx * (-offsx); - grid.xmax = rect->xmax + zoomx * (-offsx); - grid.ymin = rect->ymin + zoomy * (-offsy); - grid.ymax = rect->ymax + zoomy * (-offsy); - - glEnable(GL_BLEND); - ui_draw_gradient(&grid, col, UI_GRAD_H, 0.5f); - glDisable(GL_BLEND); + if (cumap->flag & CUMA_DO_CLIP) { + gl_shaded_color((unsigned char *)wcol->inner, -20); + glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); + glColor3ubv((unsigned char *)wcol->inner); + glRectf(rect->xmin + zoomx * (cumap->clipr.xmin - offsx), + rect->ymin + zoomy * (cumap->clipr.ymin - offsy), + rect->xmin + zoomx * (cumap->clipr.xmax - offsx), + rect->ymin + zoomy * (cumap->clipr.ymax - offsy)); + } + else { + glColor3ubv((unsigned char *)wcol->inner); + glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); } + + /* grid, every 0.25 step */ + gl_shaded_color((unsigned char *)wcol->inner, -16); + ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.25f); + /* grid, every 1.0 step */ + gl_shaded_color((unsigned char *)wcol->inner, -24); + ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 1.0f); + /* axes */ + gl_shaded_color((unsigned char *)wcol->inner, -50); + glBegin(GL_LINES); + glVertex2f(rect->xmin, rect->ymin + zoomy * (-offsy)); + glVertex2f(rect->xmax, rect->ymin + zoomy * (-offsy)); + glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymin); + glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymax); + glEnd(); } - - + /* cfra option */ /* XXX 2.48 */ #if 0 @@ -1423,11 +1426,21 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect #endif /* sample option */ - /* XXX 2.48 */ -#if 0 if (cumap->flag & CUMA_DRAW_SAMPLE) { - if (cumap->cur == 3) { - float lum = cumap->sample[0] * 0.35f + cumap->sample[1] * 0.45f + cumap->sample[2] * 0.2f; + if (but->a1 == UI_GRAD_H) { + float tsample[3]; + float hsv[3]; + linearrgb_to_srgb_v3_v3(tsample, cumap->sample); + rgb_to_hsv_v(tsample, hsv); + glColor3ub(240, 240, 240); + + glBegin(GL_LINES); + glVertex2f(rect->xmin + zoomx * (hsv[0] - offsx), rect->ymin); + glVertex2f(rect->xmin + zoomx * (hsv[0] - offsx), rect->ymax); + glEnd(); + } + else if (cumap->cur == 3) { + float lum = rgb_to_bw(cumap->sample); glColor3ub(240, 240, 240); glBegin(GL_LINES); @@ -1449,7 +1462,6 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glEnd(); } } -#endif /* the curve */ glColor3ubv((unsigned char *)wcol->item); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index a8a7a55c653..30c5f2fbe40 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3362,7 +3362,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmND ui_get_but_vectorf(but, rgb); rgb_to_hsv_compat_v(rgb, hsv); - /* Convert current colour on hue/sat disc to circular coordinates phi, r */ + /* Convert current color on hue/sat disc to circular coordinates phi, r */ phi = fmodf(hsv[0] + 0.25f, 1.0f) * -2.0f * (float)M_PI; r = hsv[1]; /* sqr= r>0.f?sqrtf(r):1; */ /* UNUSED */ @@ -5009,7 +5009,7 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y) ui_window_to_block(ar, block, &mx, &my); for (but = block->buttons.first; but; but = but->next) { - /* note, LABEL is included for hilights, this allows drags */ + /* note, LABEL is included for highlights, this allows drags */ if (but->type == LABEL && but->dragpoin == NULL) continue; if (ELEM3(but->type, ROUNDBOX, SEPR, LISTBOX)) @@ -6244,9 +6244,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle case YKEY: case ZKEY: { - if ((event->val == KM_PRESS) && + if ((event->val == KM_PRESS) && (event->shift == FALSE) && - (event->ctrl == FALSE) && + (event->ctrl == FALSE) && (event->oskey == FALSE)) { for (but = block->buttons.first; but; but = but->next) { diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 9af3ff3bdd8..1f88db033a4 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -447,7 +447,7 @@ extern void ui_draw_aligned_panel(struct uiStyle *style, uiBlock *block, rcti *r /* interface_draw.c */ extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select); -void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha); +void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha); void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 4c2d86de502..3270015271a 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -370,7 +370,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in int colbuts = len / (2 * cols); int layer_used = 0; - uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, 0)); + uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, FALSE)); unit = UI_UNIT_X * 0.75; butw = unit; @@ -409,7 +409,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in int totdim, dim_size[3]; /* 3 == RNA_MAX_ARRAY_DIMENSION */ int row, col; - uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, 1)); + uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, TRUE)); totdim = RNA_property_array_dimension(ptr, prop, dim_size); if (totdim != 2) return; /* only 2D matrices supported in UI so far */ @@ -532,7 +532,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n PropertySubType subtype; int labelw; - sub = uiLayoutRow(layout, 0); + sub = uiLayoutRow(layout, FALSE); uiBlockSetCurLayout(block, sub); if (name[0]) { @@ -550,7 +550,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n subtype = RNA_property_subtype(prop); if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) { - uiBlockSetCurLayout(block, uiLayoutRow(sub, 1)); + uiBlockSetCurLayout(block, uiLayoutRow(sub, TRUE)); uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w - UI_UNIT_X, h); /* BUTTONS_OT_file_browse calls uiFileBrowseContextProperty */ @@ -798,8 +798,8 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname if (prop && RNA_property_type(prop) == PROP_ENUM) { EnumPropertyItem *item; int totitem, i, free; - uiLayout *split = uiLayoutSplit(layout, 0, 0); - uiLayout *column = uiLayoutColumn(split, 0); + uiLayout *split = uiLayoutSplit(layout, 0.0f, FALSE); + uiLayout *column = uiLayoutColumn(split, FALSE); RNA_property_enum_items_gettexted(block->evil_C, &ptr, prop, &item, &totitem, &free); @@ -825,7 +825,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname else { if (item[i].name) { if (i != 0) { - column = uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); /* inconsistent, but menus with labels do not look good flipped */ block->flag |= UI_BLOCK_NO_FLIP; } @@ -843,6 +843,14 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname MEM_freeN(item); } } + else if (prop && RNA_property_type(prop) != PROP_ENUM) { + RNA_warning("%s.%s, not an enum type", RNA_struct_identifier(ptr.type), propname); + return; + } + else { + RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname); + return; + } } void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname) @@ -1203,8 +1211,8 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname else { EnumPropertyItem *item; int totitem, i, free; - uiLayout *split = uiLayoutSplit(layout, 0, 0); - uiLayout *column = uiLayoutColumn(split, 0); + uiLayout *split = uiLayoutSplit(layout, 0.0f, FALSE); + uiLayout *column = uiLayoutColumn(split, FALSE); RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free); @@ -1215,7 +1223,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname else { if (item[i].name) { if (i != 0) { - column = uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); /* inconsistent, but menus with labels do not look good flipped */ block->flag |= UI_BLOCK_NO_FLIP; } @@ -2301,7 +2309,7 @@ uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout) uiBlock *block; block = uiLayoutGetBlock(layout); - uiLayoutAbsolute(layout, 0); + uiLayoutAbsolute(layout, FALSE); return block; } @@ -2893,7 +2901,7 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op, i uiBut *but; uiLayout *col; /* needed to avoid alignment errors with previous buttons */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); block = uiLayoutGetBlock(col); but = uiDefIconTextBut(block, BUT, 0, ICON_FILE_REFRESH, IFACE_("Reset"), 0, 0, 18, 20, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Reset operator defaults")); diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index dd6be9141ca..40f28de50fa 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1729,7 +1729,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a } /* create items */ - split = uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); for (a = 0; a < md->nitems; a++) { if (a == column_end) { @@ -1748,7 +1748,7 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a } } - column = uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); } if (block->flag & UI_BLOCK_NO_FLIP) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 2d9c6ee7657..e6a4c260d0f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -370,7 +370,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str if ((idfrom && idfrom->lib) || !editable) uiButSetFlag(but, UI_BUT_DISABLED); - uiLayoutRow(layout, 1); + uiLayoutRow(layout, TRUE); template->preview = 1; } else if (flag & UI_ID_BROWSE) { @@ -528,7 +528,7 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const * - template_ID makes a copy of the template data and assigns it to the relevant buttons */ if (template->idlb) { - uiLayoutRow(layout, 1); + uiLayoutRow(layout, TRUE); template_ID(C, layout, template, type, idcode, flag, newop, openop, unlinkop); } @@ -576,7 +576,7 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co } /* Start drawing UI Elements using standard defines */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); /* Label - either use the provided text, or will become "ID-Block:" */ if (text) { @@ -617,7 +617,7 @@ void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propna } /* Start drawing UI Elements using standard defines */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); /* Path (existing string) Widget */ uiItemR(row, ptr, propname, 0, text, ICON_RNA); @@ -730,14 +730,14 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, /* create RNA pointer */ RNA_pointer_create(&ob->id, &RNA_Modifier, md, &ptr); - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiLayoutSetContextPointer(column, "modifier", &ptr); /* rounded header ------------------------------------------------------------------- */ box = uiLayoutBox(column); if (isVirtual) { - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND); block = uiLayoutGetBlock(row); /* VIRTUAL MODIFIER */ @@ -751,7 +751,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, } else { /* REAL MODIFIER */ - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); block = uiLayoutGetBlock(row); uiBlockSetEmboss(block, UI_EMBOSSN); @@ -782,7 +782,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, if (modifier_couldBeCage(scene, md) && (index <= lastCageIndex)) { /* -- convert to rna ? */ but = uiDefIconButBitI(block, TOG, eModifierMode_OnCage, 0, ICON_MESH_DATA, 0, 0, UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, - TIP_("Apply modifier to editing cage during Editmode")); + TIP_("Apply modifier to editing cage during Edit mode")); if (index < cageIndex) uiButSetFlag(but, UI_BUT_DISABLED); uiButSetFunc(but, modifiers_setOnCage, ob, md); @@ -836,7 +836,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, if (!isVirtual && (md->mode & eModifierMode_Expanded)) { /* apply/convert/copy */ box = uiLayoutBox(column); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) { /* only here obdata, the rest of modifiers is ob level */ @@ -868,14 +868,14 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, } /* result is the layout block inside the box, that we return so that modifier settings can be drawn */ - result = uiLayoutColumn(box, 0); + result = uiLayoutColumn(box, FALSE); block = uiLayoutAbsoluteBlock(box); } /* error messages */ if (md->error) { box = uiLayoutBox(column); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemL(row, md->error, ICON_ERROR); } @@ -1005,11 +1005,11 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiLayoutSetContextPointer(col, "constraint", &ptr); box = uiLayoutBox(col); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); block = uiLayoutGetBlock(box); /* Draw constraint header */ @@ -1051,7 +1051,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) * as that poses problems when restoring them, so disable the "up" button where * it may cause this situation. * - * Up/Down buttons should only be shown (or not greyed - todo) if they serve some purpose. + * Up/Down buttons should only be shown (or not grayed - todo) if they serve some purpose. */ if (proxylocked_constraints_owner(ob, pchan)) { if (con->prev) { @@ -1197,8 +1197,8 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M /* layout */ block = uiLayoutGetBlock(layout); - row = uiLayoutRow(layout, 0); - col = uiLayoutColumn(row, 0); + row = uiLayoutRow(layout, FALSE); + col = uiLayoutColumn(row, FALSE); uiLayoutSetKeepAspect(col, 1); /* add preview */ @@ -1215,7 +1215,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M /* Create RNA Pointer */ RNA_pointer_create(id, &RNA_Material, ma, &material_ptr); - col = uiLayoutColumn(row, 1); + col = uiLayoutColumn(row, TRUE); uiLayoutSetScaleX(col, 1.5); uiItemR(col, &material_ptr, "preview_render_type", UI_ITEM_R_EXPAND, "", ICON_NONE); } @@ -1224,7 +1224,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M /* Create RNA Pointer */ RNA_pointer_create(id, &RNA_Texture, tex, &texture_ptr); - uiLayoutRow(layout, 1); + uiLayoutRow(layout, TRUE); uiDefButS(block, ROW, B_MATPRV, IFACE_("Texture"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_TEXTURE, 0, 0, ""); if (GS(parent->name) == ID_MA) uiDefButS(block, ROW, B_MATPRV, IFACE_("Material"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); @@ -1236,7 +1236,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M /* Alpha button for texture preview */ if (*pr_texture != TEX_PR_OTHER) { - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, &texture_ptr, "use_preview_alpha", 0, NULL, ICON_NONE); } } @@ -1364,7 +1364,7 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand /* better to use rna so we can animate them */ PointerRNA ptr; RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, &ptr, "position", 0, "Pos", ICON_NONE); bt = block->buttons.last; @@ -1775,11 +1775,11 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe block = uiLayoutGetBlock(layout); /* curve chooser */ - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); if (labeltype == 'v') { /* vector */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if (cumap->cm[0].curve) { @@ -1797,7 +1797,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe } else if (labeltype == 'c') { /* color */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if (cumap->cm[3].curve) { @@ -1819,7 +1819,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe } else if (labeltype == 'h') { /* HSV */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); if (cumap->cm[0].curve) { @@ -1842,7 +1842,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe bg = UI_GRAD_H; /* operation buttons */ - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiBlockSetEmboss(block, UI_EMBOSSN); @@ -1872,16 +1872,16 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe /* curve itself */ size = uiLayoutGetWidth(layout); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiDefBut(block, BUT_CURVE, 0, "", 0, 0, size, MIN2(size, 200), cumap, 0.0f, 1.0f, bg, 0, ""); /* black/white levels */ if (levels) { - split = uiLayoutSplit(layout, 0, 0); - uiItemR(uiLayoutColumn(split, 0), ptr, "black_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - uiItemR(uiLayoutColumn(split, 0), ptr, "white_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + split = uiLayoutSplit(layout, 0.0f, FALSE); + uiItemR(uiLayoutColumn(split, FALSE), ptr, "black_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(uiLayoutColumn(split, FALSE), ptr, "white_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - uiLayoutRow(layout, 0); + uiLayoutRow(layout, FALSE); bt = uiDefBut(block, BUT, 0, IFACE_("Reset"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, TIP_("Reset Black/White point and curves")); uiButSetNFunc(bt, curvemap_buttons_reset, MEM_dupallocN(cb), cumap); @@ -1940,8 +1940,8 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision); - col = uiLayoutColumn(layout, 0); - row = uiLayoutRow(col, 1); + col = uiLayoutColumn(layout, FALSE); + row = uiLayoutRow(col, TRUE); but = uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, 0, 0, ""); @@ -2032,13 +2032,13 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname, /* layers are laid out going across rows, with the columns being divided into groups */ for (group = 0; group < groups; group++) { - uCol = uiLayoutColumn(layout, 1); + uCol = uiLayoutColumn(layout, TRUE); for (row = 0; row < 2; row++) { uiBlock *block; uiBut *but; - uRow = uiLayoutRow(uCol, 1); + uRow = uiLayoutRow(uCol, TRUE); block = uiLayoutGetBlock(uRow); layer = groups * cols_per_group * row + cols_per_group * group; @@ -2112,12 +2112,12 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe overlap = uiLayoutOverlap(layout); /* list item behind label & other buttons */ - sub = uiLayoutRow(overlap, 0); + sub = uiLayoutRow(overlap, FALSE); but = uiDefButR_prop(block, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, activeptr, activeprop, 0, 0, i, 0, 0, ""); uiButSetFlag(but, UI_BUT_NO_TOOLTIP); - sub = uiLayoutRow(overlap, 0); + sub = uiLayoutRow(overlap, FALSE); /* retrieve icon and name */ icon = list_item_icon_get(C, itemptr, rnaicon, 0); @@ -2172,12 +2172,12 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe Key *key = (Key *)itemptr->id.data; KeyBlock *kb = (KeyBlock *)itemptr->data; - split = uiLayoutSplit(sub, 0.66f, 0); + split = uiLayoutSplit(sub, 0.66f, FALSE); uiItemL(split, name, icon); uiBlockSetEmboss(block, UI_EMBOSSN); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); if (i == 0 || (key->type != KEY_RELATIVE)) uiItemL(row, "", ICON_NONE); else uiItemR(row, itemptr, "value", 0, "", ICON_NONE); uiItemR(row, itemptr, "mute", 0, "", 0); @@ -2185,7 +2185,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe if ((kb->flag & KEYBLOCK_MUTE) || (ob->mode == OB_MODE_EDIT && !((ob->shapeflag & OB_SHAPE_EDIT_MODE) && ob->type == OB_MESH))) { - uiLayoutSetActive(row, 0); + uiLayoutSetActive(row, FALSE); } uiBlockSetEmboss(block, UI_EMBOSS); } @@ -2233,7 +2233,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe else if (itemptr->type == &RNA_MovieTrackingObject) { MovieTrackingObject *tracking_object = (MovieTrackingObject *)itemptr->data; - split = uiLayoutSplit(sub, 0.75f, 0); + split = uiLayoutSplit(sub, 0.75f, FALSE); if (tracking_object->flag & TRACKING_OBJECT_CAMERA) { uiItemL(split, name, ICON_CAMERA_DATA); } @@ -2242,12 +2242,12 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe } } else if (itemptr->type == &RNA_MaskLayer) { - split = uiLayoutSplit(sub, 0.5f, 0); + split = uiLayoutSplit(sub, 0.5f, FALSE); uiItemL(split, name, icon); uiBlockSetEmboss(block, UI_EMBOSSN); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); // uiItemR(row, itemptr, "alpha", 0, "", ICON_NONE); // enable when used uiItemR(row, itemptr, "hide", 0, "", 0); uiItemR(row, itemptr, "hide_select", 0, "", 0); @@ -2277,7 +2277,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe * for the string prop, after the name of each item of the collection. */ else if (prop_list_id) { - row = uiLayoutRow(sub, 1); + row = uiLayoutRow(sub, TRUE); uiItemL(row, name, icon); /* XXX: Check, as sometimes we get an itemptr looking like @@ -2378,8 +2378,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * if (listtype == 'i') { box = uiLayoutListBox(layout, ptr, prop, activeptr, activeprop); - col = uiLayoutColumn(box, 1); - row = uiLayoutRow(col, 0); + col = uiLayoutColumn(box, TRUE); + row = uiLayoutRow(col, FALSE); if (ptr->data && prop) { /* create list items */ @@ -2387,7 +2387,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * { /* create button */ if (!(i % 9)) - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); icon = list_item_icon_get(C, &itemptr, rnaicon, 1); but = uiDefIconButR_prop(block, LISTROW, 0, icon, 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, activeptr, activeprop, 0, 0, i, 0, 0, ""); @@ -2402,7 +2402,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * else if (listtype == 'c') { /* compact layout */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); if (ptr->data && prop) { /* create list items */ @@ -2447,8 +2447,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * /* layout */ box = uiLayoutListBox(layout, ptr, prop, activeptr, activeprop); - row = uiLayoutRow(box, 0); - col = uiLayoutColumn(row, 1); + row = uiLayoutRow(box, FALSE); + col = uiLayoutColumn(row, TRUE); /* init numbers */ RNA_property_int_range(activeptr, activeprop, &min, &max); @@ -2488,7 +2488,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * /* add scrollbar */ if (len > items) { - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiDefButI(block, SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * items, &pa->list_scroll, 0, len - items, items, 0, ""); } } @@ -2624,7 +2624,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) if (owner) { uiLayout *ui_abs; - ui_abs = uiLayoutAbsolute(layout, 0); + ui_abs = uiLayoutAbsolute(layout, FALSE); (void)ui_abs; // UNUSED uiDefIconBut(block, BUT, handle_event, ICON_PANEL_CLOSE, @@ -2632,7 +2632,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) uiDefBut(block, PROGRESSBAR, 0, WM_jobs_name(wm, owner), UI_UNIT_X, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, WM_jobs_progress(wm, owner), 0, TIP_("Progress")); - uiLayoutRow(layout, 0); + uiLayoutRow(layout, FALSE); } if (WM_jobs_test(wm, screen)) uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0, 0, 85, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, @@ -2664,7 +2664,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) if (!rti || rti->widthfac == 0.0f || !report) return; - ui_abs = uiLayoutAbsolute(layout, 0); + ui_abs = uiLayoutAbsolute(layout, FALSE); block = uiLayoutGetBlock(ui_abs); width = BLF_width(style->widget.uifont_id, report->message); @@ -2679,7 +2679,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) but->col[3] = 255; but = uiDefBut(block, ROUNDBOX, 0, "", UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); - but->col[0] = but->col[1] = but->col[2] = FTOCHAR(rti->greyscale); + but->col[0] = but->col[1] = but->col[2] = FTOCHAR(rti->grayscale); but->col[3] = 255; uiBlockEndAlign(block); @@ -2699,7 +2699,8 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) uiBlockSetEmboss(block, UI_EMBOSSN); if (reports->list.first != reports->list.last) - uiDefIconButO(block, BUT, "UI_OT_reports_to_textblock", WM_OP_INVOKE_REGION_WIN, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, TIP_("Click to see rest of reports in textblock: 'Recent Reports'")); + uiDefIconButO(block, BUT, "UI_OT_reports_to_textblock", WM_OP_INVOKE_REGION_WIN, icon, 2, 0, + UI_UNIT_X, UI_UNIT_Y, TIP_("Click to see the remaining reports in text block: 'Recent Reports'")); else uiDefIconBut(block, LABEL, 0, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); @@ -2725,7 +2726,7 @@ static void template_keymap_item_properties(uiLayout *layout, const char *title, if (title) uiItemL(layout, title, ICON_NONE); - flow = uiLayoutColumnFlow(layout, 2, 0); + flow = uiLayoutColumnFlow(layout, 2, FALSE); RNA_STRUCT_BEGIN (ptr, prop) { diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 9773918e508..8ff8e0824d6 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -158,17 +158,17 @@ int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, name = RNA_property_ui_name(prop); if (label_align == 'V') { - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); if (!is_boolean) uiItemL(col, name, ICON_NONE); } else if (label_align == 'H') { - split = uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, FALSE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemL(col, (is_boolean) ? "" : name, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); } else { col = NULL; diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 004c5306d65..5ee89bb418f 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1434,7 +1434,7 @@ static struct uiWidgetColors wcol_menu_back = { 25, -20 }; -/* tooltip colour */ +/* tooltip color */ static struct uiWidgetColors wcol_tooltip = { {0, 0, 0, 255}, {25, 25, 25, 230}, @@ -1946,8 +1946,9 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) /* ************ custom buttons, old stuff ************** */ /* draws in resolution of 20x4 colors */ -void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) +void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const float alpha) { + const float color_step = (type == UI_GRAD_H) ? 0.02 : 0.05f; int a; float h = hsv[0], s = hsv[1], v = hsv[2]; float dx, dy, sx1, sx2, sy; @@ -2004,7 +2005,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) /* old below */ - for (dx = 0.0f; dx < 1.0f; dx += 0.05f) { + for (dx = 0.0f; dx < 1.0f; dx += color_step) { // previous color copy_v3_v3(col0[0], col1[0]); copy_v3_v3(col0[1], col1[1]); @@ -2032,11 +2033,15 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) hsv_to_rgb(dx, 1.0, v, &col1[3][0], &col1[3][1], &col1[3][2]); break; case UI_GRAD_H: - hsv_to_rgb(dx, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]); + { + /* annoying but without this the color shifts - could be solved some other way + * - campbell */ + hsv_to_rgb(dx + color_step, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]); copy_v3_v3(col1[1], col1[0]); copy_v3_v3(col1[2], col1[0]); copy_v3_v3(col1[3], col1[0]); break; + } case UI_GRAD_S: hsv_to_rgb(h, dx, 1.0, &col1[1][0], &col1[1][1], &col1[1][2]); copy_v3_v3(col1[0], col1[1]); @@ -2053,7 +2058,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) // rect sx1 = rect->xmin + dx * (rect->xmax - rect->xmin); - sx2 = rect->xmin + (dx + 0.05f) * (rect->xmax - rect->xmin); + sx2 = rect->xmin + (dx + color_step) * (rect->xmax - rect->xmin); sy = rect->ymin; dy = (rect->ymax - rect->ymin) / 3.0; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index fe46a5dc9c5..407b2308af8 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1888,8 +1888,8 @@ void init_userdef_do_versions(void) rgba_char_args_set(btheme->tact.anim_active, 204, 112, 26, 102); /* NLA Colors */ - rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); /* same as dopesheet above */ - rgba_char_args_set(btheme->tnla.anim_non_active,153, 135, 97, 77); + rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); /* same as dopesheet above */ + rgba_char_args_set(btheme->tnla.anim_non_active, 153, 135, 97, 77); rgba_char_args_set(btheme->tnla.nla_tweaking, 77, 243, 26, 77); rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index b2227405d8b..392aae1632d 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -431,7 +431,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) /* curRatio = height / width; */ /* UNUSED */ winRatio = winy / winx; - /* both sizes change (area/region maximised) */ + /* both sizes change (area/region maximized) */ if (do_x == do_y) { if (do_x && do_y) { /* here is 1,1 case, so all others must be 0,0 */ @@ -1328,6 +1328,54 @@ void UI_view2d_constant_grid_draw(View2D *v2d) glEnd(); } +/* Draw a multi-level grid in given 2d-region */ +void UI_view2d_multi_grid_draw(View2D *v2d, float step, int level_size, int totlevels) +{ + int offset = -10; + float lstep = step; + int level; + + for (level = 0; level < totlevels; ++level) { + int i; + float start; + + UI_ThemeColorShade(TH_BACK, offset); + + i = (v2d->cur.xmin >= 0.0f ? -(int)(-v2d->cur.xmin / lstep) : (int)(v2d->cur.xmin / lstep)); + start = i * lstep; + + glBegin(GL_LINES); + for (; start < v2d->cur.xmax; start += lstep, ++i) { + if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) + continue; + glVertex2f(start, v2d->cur.ymin); + glVertex2f(start, v2d->cur.ymax); + } + + i = (v2d->cur.ymin >= 0.0f ? -(int)(-v2d->cur.ymin / lstep) : (int)(v2d->cur.ymin / lstep)); + start = i * lstep; + + for (; start < v2d->cur.ymax; start += lstep, ++i) { + if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) + continue; + glVertex2f(v2d->cur.xmin, start); + glVertex2f(v2d->cur.xmax, start); + } + + /* X and Y axis */ + UI_ThemeColorShade(TH_BACK, offset - 8); + glVertex2f(0.0f, v2d->cur.ymin); + glVertex2f(0.0f, v2d->cur.ymax); + glVertex2f(v2d->cur.xmin, 0.0f); + glVertex2f(v2d->cur.xmax, 0.0f); + + glEnd(); + + lstep *= level_size; + offset -= 6; + } +} + /* the price we pay for not exposting structs :( */ void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy) { @@ -2078,18 +2126,21 @@ void UI_view2d_text_cache_draw(ARegion *ar) { View2DString *v2s; int col_pack_prev = 0; + + /* investigate using BLF_ascender() */ + const float default_height = strings.first ? BLF_height_default("28") : 0.0f; // glMatrixMode(GL_PROJECTION); // glPushMatrix(); // glMatrixMode(GL_MODELVIEW); // glPushMatrix(); ED_region_pixelspace(ar); - + for (v2s = strings.first; v2s; v2s = v2s->next) { const char *str = (const char *)(v2s + 1); int xofs = 0, yofs; - yofs = ceil(0.5f * (v2s->rect.ymax - v2s->rect.ymin - BLF_height_default("28"))); + yofs = ceil(0.5f * (v2s->rect.ymax - v2s->rect.ymin - default_height)); if (yofs < 1) yofs = 1; if (col_pack_prev != v2s->col.pack) { diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt index 0c417c5dfb9..7db23041c88 100644 --- a/source/blender/editors/io/CMakeLists.txt +++ b/source/blender/editors/io/CMakeLists.txt @@ -31,6 +31,10 @@ set(INC ../../collada ) +set(INC_SYS + +) + set(SRC io_collada.c io_ops.c diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index cf649207ff3..77808d0a00d 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -24,7 +24,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/io/collada.c +/** \file blender/editors/io/io_collada.c * \ingroup collada */ #ifdef WITH_COLLADA @@ -83,6 +83,12 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) int include_children; int include_armatures; int deform_bones_only; + + int include_uv_textures; + int include_material_textures; + int use_texture_copies; + int active_uv_only; + int use_object_instantiation; int sort_by_name; int second_life; @@ -97,11 +103,17 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) /* Options panel */ apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); - export_mesh_type = RNA_enum_get(op->ptr, "export_mesh_type_selection"); + export_mesh_type = RNA_enum_get(op->ptr, "export_mesh_type_selection"); selected = RNA_boolean_get(op->ptr, "selected"); include_children = RNA_boolean_get(op->ptr, "include_children"); include_armatures = RNA_boolean_get(op->ptr, "include_armatures"); deform_bones_only = RNA_boolean_get(op->ptr, "deform_bones_only"); + + include_uv_textures = RNA_boolean_get(op->ptr, "include_uv_textures"); + include_material_textures= RNA_boolean_get(op->ptr, "include_material_textures"); + use_texture_copies = RNA_boolean_get(op->ptr, "use_texture_copies"); + active_uv_only = RNA_boolean_get(op->ptr, "active_uv_only"); + use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation"); sort_by_name = RNA_boolean_get(op->ptr, "sort_by_name"); second_life = RNA_boolean_get(op->ptr, "second_life"); @@ -118,6 +130,12 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) include_children, include_armatures, deform_bones_only, + + active_uv_only, + include_uv_textures, + include_material_textures, + use_texture_copies, + use_object_instantiation, sort_by_name, second_life)) { @@ -130,7 +148,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) { - uiLayout *box, *row, *col, *sub, *split; + uiLayout *box, *row, *col, *split; /* Export Options: */ box = uiLayoutBox(layout); @@ -138,49 +156,60 @@ void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA); row = uiLayoutRow(box, 0); - col = uiLayoutColumn(row, 0); - split = uiLayoutSplit(col, 0.5f, 0); - uiItemR(split, imfptr, "apply_modifiers", 0, NULL, ICON_NONE); - sub = uiLayoutRow(split, 0); - uiItemR(sub, imfptr, "export_mesh_type_selection", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE); - uiLayoutSetEnabled(sub, RNA_boolean_get(imfptr, "apply_modifiers")); - - row = uiLayoutRow(box, 0); + split = uiLayoutSplit(row, 0.6f, UI_LAYOUT_ALIGN_RIGHT); + col = uiLayoutColumn(split, FALSE); + uiItemR(col, imfptr, "apply_modifiers", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, FALSE); + uiItemR(col, imfptr, "export_mesh_type_selection", 0, "", ICON_NONE); + uiLayoutSetEnabled(col, RNA_boolean_get(imfptr, "apply_modifiers")); + + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE); - row = uiLayoutRow(box, 0); - col = uiLayoutColumn(row, 0); - split = uiLayoutSplit(col, 0.1f, 0); - sub = uiLayoutRow(split, 0); - uiItemR(split, imfptr, "include_children", 0, NULL, ICON_NONE); + row = uiLayoutRow(box, FALSE); + uiItemR(row, imfptr, "include_children", 0, NULL, ICON_NONE); uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); - row = uiLayoutRow(box, 0); - col = uiLayoutColumn(row, 0); - split = uiLayoutSplit(col, 0.1f, 0); - sub = uiLayoutRow(split, 0); - uiItemR(split, imfptr, "include_armatures", 0, NULL, ICON_NONE); + row = uiLayoutRow(box, FALSE); + uiItemR(row, imfptr, "include_armatures", 0, NULL, ICON_NONE); uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); + // Texture options + box = uiLayoutBox(layout); + row = uiLayoutRow(box, FALSE); + uiItemL(row, IFACE_("Texture Options:"), ICON_TEXTURE_DATA); + + row = uiLayoutRow(box, FALSE); + uiItemR(row, imfptr, "active_uv_only", 0, NULL, ICON_NONE); + + row = uiLayoutRow(box, FALSE); + uiItemR(row, imfptr, "include_uv_textures", 0, NULL, ICON_NONE); + + row = uiLayoutRow(box, FALSE); + uiItemR(row, imfptr, "include_material_textures", 0, NULL, ICON_NONE); + + row = uiLayoutRow(box, FALSE); + uiItemR(row, imfptr, "use_texture_copies", 1, NULL, ICON_NONE); + // Armature options box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemL(row, IFACE_("Armature Options:"), ICON_ARMATURE_DATA); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "deform_bones_only", 0, NULL, ICON_NONE); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "second_life", 0, NULL, ICON_NONE); /* Collada options: */ box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemL(row, IFACE_("Collada Options:"), ICON_MODIFIER); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "use_object_instantiation", 0, NULL, ICON_NONE); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE); } @@ -215,8 +244,9 @@ void WM_OT_collada_export(wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); - RNA_def_boolean(ot->srna, "apply_modifiers", 0, "Apply Modifiers", - "Apply modifiers"); + RNA_def_boolean(ot->srna, + "apply_modifiers", 0, "Apply Modifiers", + "Apply modifiers to exported mesh (non destructive))"); RNA_def_int(ot->srna, "export_mesh_type", 0, INT_MIN, INT_MAX, "Resolution", "Modifier resolution for export", INT_MIN, INT_MAX); @@ -237,6 +267,19 @@ void WM_OT_collada_export(wmOperatorType *ot) "Only export deforming bones with armatures"); + RNA_def_boolean(ot->srna, "active_uv_only", 0, "Only Active UV layer", + "Export textures assigned to the object UV maps"); + + RNA_def_boolean(ot->srna, "include_uv_textures", 0, "Include UV Textures", + "Export textures assigned to the object UV maps"); + + RNA_def_boolean(ot->srna, "include_material_textures", 0, "Include Material Textures", + "Export textures assigned to the object Materials"); + + RNA_def_boolean(ot->srna, "use_texture_copies", 1, "Copy", + "Copy textures to same folder where the .dae file is exported"); + + RNA_def_boolean(ot->srna, "use_object_instantiation", 1, "Use Object Instances", "Instantiate multiple Objects from same Data"); diff --git a/source/blender/editors/io/io_ops.h b/source/blender/editors/io/io_ops.h index 1e2c4443e43..4c04b349655 100644 --- a/source/blender/editors/io/io_ops.h +++ b/source/blender/editors/io/io_ops.h @@ -24,7 +24,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editor/io/io_collada.h +/** \file blender/editor/io/io_ops.h * \ingroup editor/io */ diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 71d3caf74c5..f080b9f96e7 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -116,7 +116,8 @@ static void draw_spline_parents(MaskLayer *UNUSED(masklay), MaskSpline *spline) #endif /* return non-zero if spline is selected */ -static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline) +static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline, + const char UNUSED(draw_flag), const char draw_type) { const int is_spline_sel = (spline->flag & SELECT) && (masklay->restrictflag & MASK_RESTRICT_SELECT) == 0; unsigned char rgb_spline[4]; @@ -188,8 +189,20 @@ static void draw_spline_points(MaskLayer *masklay, MaskSpline *spline) /* draw handle segment */ if (has_handle) { - glColor3ubv(rgb_spline); + /* this could be split into its own loop */ + if (draw_type == MASK_DT_OUTLINE) { + const unsigned char rgb_gray[4] = {0x60, 0x60, 0x60, 0xff}; + glLineWidth(3); + glColor4ubv(rgb_gray); + glBegin(GL_LINES); + glVertex3fv(vert); + glVertex3fv(handle); + glEnd(); + glLineWidth(1); + } + + glColor3ubv(rgb_spline); glBegin(GL_LINES); glVertex3fv(vert); glVertex3fv(handle); @@ -415,7 +428,7 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type if (!(masklay->restrictflag & MASK_RESTRICT_SELECT)) { /* ...and then handles over the curve so they're nicely visible */ - draw_spline_points(masklay, spline); + draw_spline_points(masklay, spline, draw_flag, draw_type); } /* show undeform for testing */ @@ -425,7 +438,7 @@ static void draw_masklays(Mask *mask, const char draw_flag, const char draw_type spline->points_deform = NULL; draw_spline_curve(masklay, spline, draw_flag, draw_type, is_active, width, height); // draw_spline_parents(masklay, spline); - draw_spline_points(masklay, spline); + draw_spline_points(masklay, spline, draw_flag, draw_type); spline->points_deform = back; } } diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index fdf72043464..6e0da5fd756 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -121,7 +121,7 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, co[0] = x; co[1] = y; BKE_mask_coord_to_movieclip(sc->clip, &sc->user, co, co); - ED_clip_point_stable_pos__reverse(sc, ar, co, co); + ED_clip_point_stable_pos__reverse(C, co, co); } else { /* possible other spaces from which mask editing is available */ @@ -137,8 +137,7 @@ void ED_mask_size(const bContext *C, int *width, int *height) ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacedata.first) { if (sa->spacetype == SPACE_CLIP) { - SpaceClip *sc = sa->spacedata.first; - ED_space_clip_get_mask_size(sc, width, height); + ED_space_clip_get_size(C, width, height); return; } else if (sa->spacetype == SPACE_SEQ) { @@ -159,7 +158,7 @@ void ED_mask_aspect(const bContext *C, float *aspx, float *aspy) SpaceClip *sc = CTX_wm_space_clip(C); if (sc) { - ED_space_clip_get_mask_aspect(sc, aspx, aspy); + ED_space_clip_get_aspect(sc, aspx, aspy); } else { /* possible other spaces from which mask editing is available */ @@ -173,13 +172,12 @@ void ED_mask_pixelspace_factor(const bContext *C, float *scalex, float *scaley) SpaceClip *sc = CTX_wm_space_clip(C); if (sc) { - ARegion *ar = CTX_wm_region(C); int width, height; float zoomx, zoomy, aspx, aspy; - ED_space_clip_get_clip_size(sc, &width, &height); - ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); - ED_space_clip_get_clip_aspect(sc, &aspx, &aspy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); *scalex = ((float)width * aspx) * zoomx; *scaley = ((float)height * aspy) * zoomy; @@ -239,6 +237,7 @@ void ED_operatortypes_mask(void) WM_operatortype_append(MASK_OT_shape_key_insert); WM_operatortype_append(MASK_OT_shape_key_clear); WM_operatortype_append(MASK_OT_shape_key_feather_reset); + WM_operatortype_append(MASK_OT_shape_key_rekey); } void ED_keymap_mask(wmKeyConfig *keyconf) diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h index 408b585bf4c..f1d72f59078 100644 --- a/source/blender/editors/mask/mask_intern.h +++ b/source/blender/editors/mask/mask_intern.h @@ -110,5 +110,6 @@ void ED_mask_point_pos__reverse(const struct bContext *C, float x, float y, floa void MASK_OT_shape_key_insert(struct wmOperatorType *ot); void MASK_OT_shape_key_clear(struct wmOperatorType *ot); void MASK_OT_shape_key_feather_reset(struct wmOperatorType *ot); +void MASK_OT_shape_key_rekey(struct wmOperatorType *ot); #endif /* __MASK_INTERN_H__ */ diff --git a/source/blender/editors/mask/mask_relationships.c b/source/blender/editors/mask/mask_relationships.c index 7ba3c27e18d..a1f2539ce7c 100644 --- a/source/blender/editors/mask/mask_relationships.c +++ b/source/blender/editors/mask/mask_relationships.c @@ -44,6 +44,7 @@ #include "WM_types.h" #include "ED_screen.h" +#include "ED_clip.h" /* frame remapping functions */ #include "ED_mask.h" /* own include */ #include "mask_intern.h" /* own include */ @@ -104,21 +105,25 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) MovieClip *clip; MovieTrackingTrack *track; MovieTrackingMarker *marker; - MovieTrackingObject *tracking; + MovieTrackingObject *tracking_object; /* done */ + int framenr; + float marker_pos_ofs[2]; float parmask_pos[2]; if ((NULL == (sc = CTX_wm_space_clip(C))) || (NULL == (clip = sc->clip)) || (NULL == (track = clip->tracking.act_track)) || - (NULL == (marker = BKE_tracking_marker_get(track, sc->user.framenr))) || - (NULL == (tracking = BKE_tracking_object_get_active(&clip->tracking)))) + (NULL == (tracking_object = BKE_tracking_object_get_active(&clip->tracking)))) { return OPERATOR_CANCELLED; } + framenr = ED_space_clip_get_clip_frame_number(sc); + marker = BKE_tracking_marker_get(track, framenr); + add_v2_v2v2(marker_pos_ofs, marker->pos, track->offset); BKE_mask_coord_from_movieclip(clip, &sc->user, parmask_pos, marker_pos_ofs); @@ -138,7 +143,7 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) if (MASKPOINT_ISSEL_ANY(point)) { point->parent.id_type = ID_MC; point->parent.id = &clip->id; - strcpy(point->parent.parent, tracking->name); + strcpy(point->parent.parent, tracking_object->name); strcpy(point->parent.sub_parent, track->name); copy_v2_v2(point->parent.parent_orig, parmask_pos); diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index e34823278cb..e619277456e 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -581,8 +581,6 @@ static int circle_select_exec(bContext *C, wmOperator *op) MaskLayer *masklay; int i; - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); int x, y, radius, width, height, mode, change = FALSE; float zoomx, zoomy, offset[2], ellipse[2]; @@ -595,8 +593,8 @@ static int circle_select_exec(bContext *C, wmOperator *op) /* TODO - make generic! - this is SpaceClip only! */ /* compute ellipse and position in unified coordinates */ - ED_space_clip_get_clip_size(sc, &width, &height); - ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); width = height = MAX2(width, height); ellipse[0] = width * zoomx / radius; diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c index 8da083ab400..c5b9fc33a9b 100644 --- a/source/blender/editors/mask/mask_shapekey.c +++ b/source/blender/editors/mask/mask_shapekey.c @@ -29,7 +29,11 @@ * \ingroup edmask */ +#include <stdlib.h> + #include "BLI_utildefines.h" +#include "BLI_listbase.h" +#include "BLI_math.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -39,6 +43,9 @@ #include "DNA_mask_types.h" #include "DNA_scene_types.h" +#include "RNA_access.h" +#include "RNA_define.h" + #include "WM_api.h" #include "WM_types.h" @@ -222,7 +229,7 @@ void MASK_OT_shape_key_feather_reset(wmOperatorType *ot) { /* identifiers */ ot->name = "Feather Reset Animation"; - ot->description = "Resets fearther weights on all selected points animation values"; + ot->description = "Reset feather weights on all selected points animation values"; ot->idname = "MASK_OT_shape_key_feather_reset"; /* api callbacks */ @@ -233,6 +240,175 @@ void MASK_OT_shape_key_feather_reset(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +/* + * - loop over selected shapekeys. + * - find firstsel/lastsel pairs. + * - move these into a temp list. + * - re-key all the original shapes. + * - copy unselected values back from the original. + * - free the original. + */ +static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) +{ + Scene *scene = CTX_data_scene(C); + const int frame = CFRA; + Mask *mask = CTX_data_edit_mask(C); + MaskLayer *masklay; + int change = FALSE; + + const short do_feather = RNA_boolean_get(op->ptr, "feather"); + const short do_location = RNA_boolean_get(op->ptr, "location"); + + for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { + + if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { + continue; + } + + /* we need at least one point selected here to bother re-interpolating */ + if (!ED_mask_layer_select_check(masklay)) { + continue; + } + + if (masklay->splines_shapes.first) { + MaskLayerShape *masklay_shape; + MaskLayerShape *masklay_shape_lastsel = NULL; + + for (masklay_shape = masklay->splines_shapes.first; + masklay_shape; + masklay_shape = masklay_shape->next) + { + MaskLayerShape *masklay_shape_a = NULL; + MaskLayerShape *masklay_shape_b = NULL; + + /* find contiguous selections */ + if (masklay_shape->flag & MASK_SHAPE_SELECT) { + if (masklay_shape_lastsel == NULL) { + masklay_shape_lastsel = masklay_shape; + } + if ((masklay_shape->next == NULL) || + (((MaskLayerShape *)masklay_shape->next)->flag & MASK_SHAPE_SELECT) == 0) + { + masklay_shape_a = masklay_shape_lastsel; + masklay_shape_b = masklay_shape; + masklay_shape_lastsel = NULL; + } + } + + /* we have a from<>to? - re-interpolate! */ + if (masklay_shape_a && masklay_shape_b) { + ListBase shapes_tmp = {NULL, NULL}; + MaskLayerShape *masklay_shape_tmp; + MaskLayerShape *masklay_shape_tmp_next; + MaskLayerShape *masklay_shape_tmp_last = masklay_shape_b->next; + MaskLayerShape *masklay_shape_tmp_rekey; + + /* move keys */ + for (masklay_shape_tmp = masklay_shape_a; + masklay_shape_tmp && (masklay_shape_tmp != masklay_shape_tmp_last); + masklay_shape_tmp = masklay_shape_tmp_next) + { + masklay_shape_tmp_next = masklay_shape_tmp->next; + BLI_remlink(&masklay->splines_shapes, masklay_shape_tmp); + BLI_addtail(&shapes_tmp, masklay_shape_tmp); + } + + /* re-key, note: cant modify the keys here since it messes uop */ + for (masklay_shape_tmp = shapes_tmp.first; + masklay_shape_tmp; + masklay_shape_tmp = masklay_shape_tmp->next) + { + BKE_mask_layer_evaluate(masklay, masklay_shape_tmp->frame, TRUE); + masklay_shape_tmp_rekey = BKE_mask_layer_shape_varify_frame(masklay, masklay_shape_tmp->frame); + BKE_mask_layer_shape_from_mask(masklay, masklay_shape_tmp_rekey); + masklay_shape_tmp_rekey->flag = masklay_shape_tmp->flag & MASK_SHAPE_SELECT; + } + + /* restore unselected points and free copies */ + for (masklay_shape_tmp = shapes_tmp.first; + masklay_shape_tmp; + masklay_shape_tmp = masklay_shape_tmp_next) + { + /* restore */ + int i_abs = 0; + int i; + MaskSpline *spline; + MaskLayerShapeElem *shape_ele_src; + MaskLayerShapeElem *shape_ele_dst; + + masklay_shape_tmp_next = masklay_shape_tmp->next; + + /* we know this exists, added above */ + masklay_shape_tmp_rekey = BKE_mask_layer_shape_find_frame(masklay, masklay_shape_tmp->frame); + + shape_ele_src = (MaskLayerShapeElem *)masklay_shape_tmp->data; + shape_ele_dst = (MaskLayerShapeElem *)masklay_shape_tmp_rekey->data; + + for (spline = masklay->splines.first; spline; spline = spline->next) { + for (i = 0; i < spline->tot_point; i++) { + MaskSplinePoint *point = &spline->points[i]; + + /* not especially efficient but makes this easier to follow */ + SWAP(MaskLayerShapeElem, *shape_ele_src, *shape_ele_dst); + + if (MASKPOINT_ISSEL_ANY(point)) { + if (do_location) { + memcpy(shape_ele_dst->value, shape_ele_src->value, sizeof(float) * 6); + } + if (do_feather) { + shape_ele_dst->value[6] = shape_ele_src->value[6]; + } + } + + shape_ele_src++; + shape_ele_dst++; + + i_abs++; + } + } + + BKE_mask_layer_shape_free(masklay_shape_tmp); + } + + change = TRUE; + } + } + + /* re-evaluate */ + BKE_mask_layer_evaluate(masklay, frame, TRUE); + } + } + + if (change) { + WM_event_add_notifier(C, NC_MASK | ND_DATA, mask); + DAG_id_tag_update(&mask->id, 0); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void MASK_OT_shape_key_rekey(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Re-Key Points of Selected Shapes"; + ot->description = "Recalculate animation data on selected points for frames selected in the dopesheet"; + ot->idname = "MASK_OT_shape_key_rekey"; + + /* api callbacks */ + ot->exec = mask_shape_key_rekey_exec; + ot->poll = ED_maskedit_mask_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_boolean(ot->srna, "location", TRUE, "Location", ""); + RNA_def_boolean(ot->srna, "feather", TRUE, "Feather", ""); +} + /* *** Shape Key Utils *** */ diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index f154aec2eb4..2ceb8aeef26 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1468,6 +1468,8 @@ static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], flo if (cure && p) { if (!kcd->ignore_edge_snapping || !(cure->e)) { + KnifeVert *edgesnap = NULL; + if (kcd->snap_midpoints) { mid_v3_v3v3(p, cure->v1->co, cure->v2->co); mid_v3_v3v3(cagep, cure->v1->cageco, cure->v2->cageco); @@ -1479,6 +1481,13 @@ static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], flo d = len_v3v3(cagep, cure->v1->cageco) / len_v3v3(cure->v1->cageco, cure->v2->cageco); interp_v3_v3v3(p, cure->v1->co, cure->v2->co, d); } + + /* update mouse coordinates to the snapped-to edge's screen coordinates + * this is important for angle snap, which uses the previous mouse position */ + edgesnap = new_knife_vert(kcd, p, cagep); + kcd->cur.mval[0] = (int)edgesnap->sco[0]; + kcd->cur.mval[1] = (int)edgesnap->sco[1]; + } else { return NULL; @@ -1557,6 +1566,11 @@ static KnifeVert *knife_find_closest_vert(KnifeTool_OpData *kcd, float p[3], flo if (curv && p) { copy_v3_v3(p, curv->co); copy_v3_v3(cagep, curv->cageco); + + /* update mouse coordinates to the snapped-to vertex's screen coordinates + * this is important for angle snap, which uses the previous mouse position */ + kcd->cur.mval[0] = (int)curv->sco[0]; + kcd->cur.mval[1] = (int)curv->sco[1]; } return curv; @@ -1617,7 +1631,11 @@ static int knife_update_active(KnifeTool_OpData *kcd) kcd->cur.mval[0] = kcd->vc.mval[0]; kcd->cur.mval[1] = kcd->vc.mval[1]; + /* XXX knife_snap_angle updates the view coordinate mouse values to constrained angles, + * which current mouse values are set to current mouse values are then used + * for vertex and edge snap detection, without regard to the exact angle constraint */ kcd->cur.vert = knife_find_closest_vert(kcd, kcd->cur.co, kcd->cur.cage, &kcd->cur.bmface, &kcd->cur.is_space); + if (!kcd->cur.vert) { kcd->cur.edge = knife_find_closest_edge(kcd, kcd->cur.co, kcd->cur.cage, &kcd->cur.bmface, &kcd->cur.is_space); } @@ -1989,9 +2007,9 @@ static void knifenet_fill_faces(KnifeTool_OpData *kcd) remerge_faces(kcd); /* delete left over faces */ - BMO_op_callf(bm, "del geom=%ff context=%i", DEL, DEL_ONLYFACES); - BMO_op_callf(bm, "del geom=%fe context=%i", DEL, DEL_EDGES); - BMO_op_callf(bm, "del geom=%fv context=%i", DEL, DEL_VERTS); + BMO_op_callf(bm, "delete geom=%ff context=%i", DEL, DEL_ONLYFACES); + BMO_op_callf(bm, "delete geom=%fe context=%i", DEL, DEL_EDGES); + BMO_op_callf(bm, "delete geom=%fv context=%i", DEL, DEL_VERTS); if (face_nets) MEM_freeN(face_nets); diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 15e3033b7eb..eb2aabd88b8 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -313,10 +313,13 @@ static void ringsel_finish(bContext *C, wmOperator *op) edgering_sel(lcd, cuts, 1); if (lcd->do_cut) { + /* Enable gridfill, so that intersecting loopcut works as one would expect. + * Note though that it will break edgeslide in this specific case. + * See [#31939]. */ BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT, 0.0f, 0.0f, 0.0f, cuts, - SUBDIV_SELECT_LOOPCUT, SUBD_PATH, 0, FALSE, 0); + SUBDIV_SELECT_LOOPCUT, SUBD_PATH, 0, TRUE, 0); /* force edge slide to edge select mode in in face select mode */ if (em->selectmode & SCE_SELECT_FACE) { @@ -336,7 +339,8 @@ static void ringsel_finish(bContext *C, wmOperator *op) DAG_id_tag_update(lcd->ob->data, 0); } else { - + /* XXX Is this piece of code ever used now? Simple loop select is now + * in editmesh_select.c (around line 1000)... */ /* sets as active, useful for other tools */ if (em->selectmode & SCE_SELECT_VERTEX) BM_select_history_store(em->bm, lcd->eed->v1); /* low priority TODO, get vertrex close to mouse */ diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index 1bcd5cee111..f71ec56ca5f 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -347,7 +347,7 @@ static int edbm_rip_call_edgesplit(BMEditMesh *em, wmOperator *op) { BMOperator bmop; - if (!EDBM_op_init(em, &bmop, op, "edgesplit edges=%he verts=%hv use_verts=%b", + if (!EDBM_op_init(em, &bmop, op, "split_edges edges=%he verts=%hv use_verts=%b", BM_ELEM_TAG, BM_ELEM_SELECT, TRUE)) { return FALSE; diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 44ec8bd6aaa..5404eb3bea6 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -710,7 +710,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) float thresh = RNA_float_get(op->ptr, "threshold"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "similarfaces faces=%hf type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); + EDBM_op_init(em, &bmop, op, "similar_faces faces=%hf type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -748,7 +748,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) float thresh = RNA_float_get(op->ptr, "threshold"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "similaredges edges=%he type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); + EDBM_op_init(em, &bmop, op, "similar_edges edges=%he type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -789,7 +789,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) float thresh = RNA_float_get(op->ptr, "threshold"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "similarverts verts=%hv type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); + EDBM_op_init(em, &bmop, op, "similar_verts verts=%hv type=%i thresh=%f", BM_ELEM_SELECT, type, thresh); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -1001,12 +1001,13 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) BMEdge *eed; int select = TRUE; int dist = 50; - + float mvalf[2]; + em_setup_viewcontext(C, &vc); - vc.mval[0] = mval[0]; - vc.mval[1] = mval[1]; + 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 */ view3d_validate_backbuf(&vc); @@ -1041,22 +1042,58 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) } EDBM_selectmode_flush(em); -// if (EM_texFaceCheck()) - + /* sets as active, useful for other tools */ if (select) { if (em->selectmode & SCE_SELECT_VERTEX) { - /* TODO: would be nice if the edge vertex chosen here - * was the one closer to the selection pointer, instead - * of arbitrarily selecting the first one */ - BM_select_history_store(em->bm, eed->v1); + /* Find nearest vert from mouse. */ + float v1_co[2], v2_co[2]; + + /* We can't be sure this has already been set... */ + ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); + project_float_noclip(vc.ar, eed->v1->co, v1_co); + project_float_noclip(vc.ar, eed->v2->co, v2_co); +#if 0 + printf("mouse to v1: %f\nmouse to v2: %f\n", len_squared_v2v2(mvalf, v1_co), + len_squared_v2v2(mvalf, v2_co)); +#endif + if (len_squared_v2v2(mvalf, v1_co) < len_squared_v2v2(mvalf, v2_co)) + BM_select_history_store(em->bm, eed->v1); + else + BM_select_history_store(em->bm, eed->v2); } else if (em->selectmode & SCE_SELECT_EDGE) { BM_select_history_store(em->bm, eed); } - /* TODO: would be nice if the nearest face that - * belongs to the selected edge could be set to - * active here in face select mode */ + else if (em->selectmode & SCE_SELECT_FACE) { + /* Select the face of eed which is the nearest of mouse. */ + BMFace *f, *efa = NULL; + BMIter iterf; + float best_dist = MAXFLOAT; + + /* We can't be sure this has already been set... */ + ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); + + BM_ITER_ELEM(f, &iterf, eed, BM_FACES_OF_EDGE) { + if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { + float cent[3]; + float co[2], tdist; + + BM_face_calc_center_mean(f, cent); + project_float_noclip(vc.ar, cent, co); + tdist = len_squared_v2v2(mvalf, co); + if (tdist < best_dist) { +/* printf("Best face: %p (%f)\n", f, tdist);*/ + best_dist = tdist; + efa = f; + } + } + } + if (efa) { + BM_active_face_set(em->bm, efa); + BM_select_history_store(em->bm, efa); + } + } } WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit); diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c index a86a274eb70..f08c229d38a 100644 --- a/source/blender/editors/mesh/editmesh_slide.c +++ b/source/blender/editors/mesh/editmesh_slide.c @@ -211,7 +211,7 @@ static void vtx_slide_confirm(bContext *C, wmOperator *op) if (other_d < vso->snap_threshold) { BM_vert_select_set(bm, other, TRUE); BM_vert_select_set(bm, vso->start_vtx, TRUE); - EDBM_op_callf(em, op, "pointmerge verts=%hv mergeco=%v", BM_ELEM_SELECT, other->co); + EDBM_op_callf(em, op, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, other->co); EDBM_flag_disable_all(em, BM_ELEM_SELECT); } else { @@ -687,7 +687,7 @@ static int edbm_vertex_slide_exec(bContext *C, wmOperator *op) /* Prepare operator */ if (!EDBM_op_init(em, &bmop, op, - "vertex_slide vert=%e edge=%hev distance_t=%f", + "slide_vert vert=%e edge=%hev distance_t=%f", start_vert, BM_ELEM_SELECT, distance_t)) { return OPERATOR_CANCELLED; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 0f7d4c5c547..0f13df4c777 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -172,7 +172,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, Object *obedit, BMEditMes /* individual face extrude */ /* will use vertex normals for extrusion directions, so *nor is unaffected */ -static short edbm_extrude_face_indiv(BMEditMesh *em, wmOperator *op, const char hflag, float *UNUSED(nor)) +static short edbm_extrude_discrete_faces(BMEditMesh *em, wmOperator *op, const char hflag, float *UNUSED(nor)) { BMOIter siter; BMIter liter; @@ -180,7 +180,7 @@ static short edbm_extrude_face_indiv(BMEditMesh *em, wmOperator *op, const char BMLoop *l; BMOperator bmop; - EDBM_op_init(em, &bmop, op, "extrude_face_indiv faces=%hf", hflag); + EDBM_op_init(em, &bmop, op, "extrude_discrete_faces faces=%hf", hflag); /* deselect original verts */ EDBM_flag_disable_all(em, BM_ELEM_SELECT); @@ -473,7 +473,7 @@ static int edbm_extrude_mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe else if (nr == 1) transmode = edbm_extrude_edge(obedit, em, BM_ELEM_SELECT, nor); else if (nr == 4) transmode = edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT, nor); else if (nr == 3) transmode = edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, nor); - else transmode = edbm_extrude_face_indiv(em, op, BM_ELEM_SELECT, nor); + else transmode = edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT, nor); if (transmode == 0) { BKE_report(op->reports, RPT_ERROR, "Not a valid selection for extrude"); @@ -614,7 +614,7 @@ static int edbm_extrude_faces_exec(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(obedit); float nor[3]; - edbm_extrude_face_indiv(em, op, BM_ELEM_SELECT, nor); + edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT, nor); EDBM_update_generic(C, em, TRUE); @@ -853,7 +853,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent invert_m4_m4(vc.obedit->imat, vc.obedit->obmat); mul_m4_v3(vc.obedit->imat, min); // back in object space - EDBM_op_init(vc.em, &bmop, op, "makevert co=%v", min); + EDBM_op_init(vc.em, &bmop, op, "create_vert co=%v", min); BMO_op_exec(vc.em->bm, &bmop); BMO_ITER (v1, &oiter, vc.em->bm, &bmop, "newvertout", BM_VERT) { @@ -912,24 +912,24 @@ static int edbm_delete_exec(bContext *C, wmOperator *op) int type = RNA_enum_get(op->ptr, "type"); if (type == 0) { - if (!EDBM_op_callf(em, op, "del geom=%hv context=%i", BM_ELEM_SELECT, DEL_VERTS)) /* Erase Vertices */ + if (!EDBM_op_callf(em, op, "delete geom=%hv context=%i", BM_ELEM_SELECT, DEL_VERTS)) /* Erase Vertices */ return OPERATOR_CANCELLED; } else if (type == 1) { - if (!EDBM_op_callf(em, op, "del geom=%he context=%i", BM_ELEM_SELECT, DEL_EDGES)) /* Erase Edges */ + if (!EDBM_op_callf(em, op, "delete geom=%he context=%i", BM_ELEM_SELECT, DEL_EDGES)) /* Erase Edges */ return OPERATOR_CANCELLED; } else if (type == 2) { - if (!EDBM_op_callf(em, op, "del geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES)) /* Erase Faces */ + if (!EDBM_op_callf(em, op, "delete geom=%hf context=%i", BM_ELEM_SELECT, DEL_FACES)) /* Erase Faces */ return OPERATOR_CANCELLED; } else if (type == 3) { - if (!EDBM_op_callf(em, op, "del geom=%hef context=%i", BM_ELEM_SELECT, DEL_EDGESFACES)) /* Edges and Faces */ + if (!EDBM_op_callf(em, op, "delete geom=%hef context=%i", BM_ELEM_SELECT, DEL_EDGESFACES)) /* Edges and Faces */ return OPERATOR_CANCELLED; } else if (type == 4) { //"Erase Only Faces"; - if (!EDBM_op_callf(em, op, "del geom=%hf context=%i", + if (!EDBM_op_callf(em, op, "delete geom=%hf context=%i", BM_ELEM_SELECT, DEL_ONLYFACES)) { return OPERATOR_CANCELLED; @@ -1197,7 +1197,7 @@ static int edbm_vert_connect(bContext *C, wmOperator *op) BMOperator bmop; int len = 0; - if (!EDBM_op_init(em, &bmop, op, "connectverts verts=%hv", BM_ELEM_SELECT)) { + if (!EDBM_op_init(em, &bmop, op, "connect_verts verts=%hv", BM_ELEM_SELECT)) { return OPERATOR_CANCELLED; } BMO_op_exec(bm, &bmop); @@ -1234,7 +1234,7 @@ static int edbm_edge_split_exec(bContext *C, wmOperator *op) BMOperator bmop; int len = 0; - if (!EDBM_op_init(em, &bmop, op, "edgesplit edges=%he", BM_ELEM_SELECT)) { + if (!EDBM_op_init(em, &bmop, op, "split_edges edges=%he", BM_ELEM_SELECT)) { return OPERATOR_CANCELLED; } BMO_op_exec(bm, &bmop); @@ -1271,7 +1271,7 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(ob); BMOperator bmop; - EDBM_op_init(em, &bmop, op, "dupe geom=%hvef", BM_ELEM_SELECT); + EDBM_op_init(em, &bmop, op, "duplicate geom=%hvef", BM_ELEM_SELECT); BMO_op_exec(em->bm, &bmop); EDBM_flag_disable_all(em, BM_ELEM_SELECT); @@ -1318,7 +1318,7 @@ static int edbm_flip_normals_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - if (!EDBM_op_callf(em, op, "reversefaces faces=%hf", BM_ELEM_SELECT)) + if (!EDBM_op_callf(em, op, "reverse_faces faces=%hf", BM_ELEM_SELECT)) return OPERATOR_CANCELLED; EDBM_update_generic(C, em, TRUE); @@ -1386,7 +1386,7 @@ static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - EDBM_op_init(em, &bmop, op, "edgerotate edges=%he ccw=%b", BM_ELEM_TAG, do_ccw); + EDBM_op_init(em, &bmop, op, "rotate_edges edges=%he ccw=%b", BM_ELEM_TAG, do_ccw); /* avoids leaving old verts selected which can be a problem running multiple times, * since this means the edges become selected around the face which then attempt to rotate */ @@ -1490,11 +1490,11 @@ static int edbm_normals_make_consistent_exec(bContext *C, wmOperator *op) /* doflip has to do with bmesh_rationalize_normals, it's an internal * thing */ - if (!EDBM_op_callf(em, op, "righthandfaces faces=%hf do_flip=%b", BM_ELEM_SELECT, TRUE)) + if (!EDBM_op_callf(em, op, "recalc_face_normals faces=%hf do_flip=%b", BM_ELEM_SELECT, TRUE)) return OPERATOR_CANCELLED; if (RNA_boolean_get(op->ptr, "inside")) - EDBM_op_callf(em, op, "reversefaces faces=%hf", BM_ELEM_SELECT); + EDBM_op_callf(em, op, "reverse_faces faces=%hf", BM_ELEM_SELECT); EDBM_update_generic(C, em, TRUE); @@ -1560,7 +1560,7 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op) for (i = 0; i < repeat; i++) { if (!EDBM_op_callf(em, op, - "vertexsmooth verts=%hv mirror_clip_x=%b mirror_clip_y=%b mirror_clip_z=%b clipdist=%f", + "smooth_vert verts=%hv mirror_clip_x=%b mirror_clip_y=%b mirror_clip_z=%b clipdist=%f", BM_ELEM_SELECT, mirrx, mirry, mirrz, clipdist)) { return OPERATOR_CANCELLED; @@ -1678,7 +1678,7 @@ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op) int dir = RNA_enum_get(op->ptr, "direction"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "face_rotateuvs faces=%hf dir=%i", BM_ELEM_SELECT, dir); + EDBM_op_init(em, &bmop, op, "rotate_uvs faces=%hf dir=%i", BM_ELEM_SELECT, dir); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -1701,7 +1701,7 @@ static int edbm_reverse_uvs_exec(bContext *C, wmOperator *op) BMOperator bmop; /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "face_reverseuvs faces=%hf", BM_ELEM_SELECT); + EDBM_op_init(em, &bmop, op, "reverse_uvs faces=%hf", BM_ELEM_SELECT); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -1727,7 +1727,7 @@ static int edbm_rotate_colors_exec(bContext *C, wmOperator *op) int dir = RNA_enum_get(op->ptr, "direction"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "face_rotatecolors faces=%hf dir=%i", BM_ELEM_SELECT, dir); + EDBM_op_init(em, &bmop, op, "rotate_colors faces=%hf dir=%i", BM_ELEM_SELECT, dir); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -1752,7 +1752,7 @@ static int edbm_reverse_colors_exec(bContext *C, wmOperator *op) BMOperator bmop; /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "face_reversecolors faces=%hf", BM_ELEM_SELECT); + EDBM_op_init(em, &bmop, op, "reverse_colors faces=%hf", BM_ELEM_SELECT); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -1865,7 +1865,7 @@ static int merge_firstlast(BMEditMesh *em, int first, int uvmerge, wmOperator *w return OPERATOR_CANCELLED; } - if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv mergeco=%v", BM_ELEM_SELECT, mergevert->co)) + if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, mergevert->co)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -1906,11 +1906,11 @@ static int merge_target(BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob, return OPERATOR_CANCELLED; if (uvmerge) { - if (!EDBM_op_callf(em, wmop, "vert_average_facedata verts=%hv", BM_ELEM_SELECT)) + if (!EDBM_op_callf(em, wmop, "average_vert_facedata verts=%hv", BM_ELEM_SELECT)) return OPERATOR_CANCELLED; } - if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv mergeco=%v", BM_ELEM_SELECT, co)) + if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, co)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -2032,12 +2032,12 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) BMOperator bmop; int count; - EDBM_op_init(em, &bmop, op, "finddoubles verts=%hv dist=%f", BM_ELEM_SELECT, RNA_float_get(op->ptr, "mergedist")); + EDBM_op_init(em, &bmop, op, "find_doubles verts=%hv dist=%f", BM_ELEM_SELECT, RNA_float_get(op->ptr, "mergedist")); BMO_op_exec(em->bm, &bmop); count = BMO_slot_map_count(em->bm, &bmop, "targetmapout"); - if (!EDBM_op_callf(em, op, "weldverts targetmap=%s", &bmop, "targetmapout")) { + if (!EDBM_op_callf(em, op, "weld_verts targetmap=%s", &bmop, "targetmapout")) { BMO_op_finish(em->bm, &bmop); return OPERATOR_CANCELLED; } @@ -2109,7 +2109,7 @@ static int edbm_select_vertex_path_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ - EDBM_op_init(em, &bmop, op, "vertexshortestpath startv=%e endv=%e type=%i", sv->ele, ev->ele, type); + EDBM_op_init(em, &bmop, op, "shortest_path startv=%e endv=%e type=%i", sv->ele, ev->ele, type); /* execute the operator */ BMO_op_exec(em->bm, &bmop); @@ -2714,7 +2714,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) BLI_ghash_insert(gh, bv, scr); } - if (!EDBM_op_init(em, &bmop, op, "esubd")) { + if (!EDBM_op_init(em, &bmop, op, "subdivide_edges")) { return OPERATOR_CANCELLED; } @@ -2819,8 +2819,8 @@ static int mesh_separate_selected(Main *bmain, Scene *scene, Base *editbase, wmO ED_base_object_select(basenew, BA_DESELECT); - EDBM_op_callf(em, wmop, "dupe geom=%hvef dest=%p", BM_ELEM_SELECT, bm_new); - EDBM_op_callf(em, wmop, "del geom=%hvef context=%i", BM_ELEM_SELECT, DEL_FACES); + EDBM_op_callf(em, wmop, "duplicate geom=%hvef dest=%p", BM_ELEM_SELECT, bm_new); + EDBM_op_callf(em, wmop, "delete geom=%hvef context=%i", BM_ELEM_SELECT, DEL_FACES); /* clean up any loose edges */ BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { @@ -2831,7 +2831,7 @@ static int mesh_separate_selected(Main *bmain, Scene *scene, Base *editbase, wmO BM_edge_select_set(em->bm, e, FALSE); } } - EDBM_op_callf(em, wmop, "del geom=%hvef context=%i", BM_ELEM_SELECT, DEL_EDGES); + EDBM_op_callf(em, wmop, "delete geom=%hvef context=%i", BM_ELEM_SELECT, DEL_EDGES); /* clean up any loose verts */ BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { @@ -2843,7 +2843,7 @@ static int mesh_separate_selected(Main *bmain, Scene *scene, Base *editbase, wmO } } - EDBM_op_callf(em, wmop, "del geom=%hvef context=%i", BM_ELEM_SELECT, DEL_VERTS); + EDBM_op_callf(em, wmop, "delete geom=%hvef context=%i", BM_ELEM_SELECT, DEL_VERTS); BM_mesh_normals_update(bm_new, TRUE); @@ -2892,11 +2892,9 @@ static int mesh_separate_material(Main *bmain, Scene *scene, Base *editbase, wmO static int mesh_separate_loose(Main *bmain, Scene *scene, Base *editbase, wmOperator *wmop) { int i; - BMVert *v; BMEdge *e; BMVert *v_seed; BMWalker walker; - BMIter iter; int result = FALSE; Object *obedit = editbase->object; BMEditMesh *em = BMEdit_FromObject(obedit); @@ -2913,11 +2911,7 @@ static int mesh_separate_loose(Main *bmain, Scene *scene, Base *editbase, wmOper * original mesh.*/ for (i = 0; i < max_iter; i++) { /* Get a seed vertex to start the walk */ - v_seed = NULL; - BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - v_seed = v; - break; - } + v_seed = BM_iter_at_index(bm, BM_VERTS_OF_MESH, NULL, 0); /* No vertices available, can't do anything */ if (v_seed == NULL) { @@ -4187,11 +4181,11 @@ void MESH_OT_sort_elements(wmOperatorType *ot) { static EnumPropertyItem type_items[] = { {SRT_VIEW_ZAXIS, "VIEW_ZAXIS", 0, "View Z Axis", - "Sort selected elements from farest to nearest one in current view"}, + "Sort selected elements from farthest to nearest one in current view"}, {SRT_VIEW_XAXIS, "VIEW_XAXIS", 0, "View X Axis", "Sort selected elements from left to right one in current view"}, {SRT_CURSOR_DISTANCE, "CURSOR_DISTANCE", 0, "Cursor Distance", - "Sort selected elements from nearest to farest from 3D cursor"}, + "Sort selected elements from nearest to farthest from 3D cursor"}, {SRT_MATERIAL, "MATERIAL", 0, "Material", "Sort selected elements from smallest to greatest material index (faces only!)"}, {SRT_SELECTED, "SELECTED", 0, "Selected", @@ -4966,7 +4960,7 @@ static int edbm_wireframe_exec(bContext *C, wmOperator *op) BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, FALSE); BMO_slot_buffer_hflag_enable(em->bm, &bmop, "faces", BM_FACE, BM_ELEM_TAG, FALSE); - BMO_op_callf(em->bm, "del geom=%hvef context=%i", BM_ELEM_TAG, DEL_FACES); + BMO_op_callf(em->bm, "delete geom=%hvef context=%i", BM_ELEM_TAG, DEL_FACES); } BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); @@ -5032,7 +5026,7 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) /* Delete unused vertices, edges, and faces */ if (RNA_boolean_get(op->ptr, "delete_unused")) { - if (!EDBM_op_callf(em, op, "del geom=%s context=%i", + if (!EDBM_op_callf(em, op, "delete geom=%s context=%i", &bmop, "unused_geom", DEL_ONLYTAGGED)) { EDBM_op_finish(em, &bmop, op, TRUE); @@ -5042,7 +5036,7 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) /* Delete hole edges/faces */ if (RNA_boolean_get(op->ptr, "make_holes")) { - if (!EDBM_op_callf(em, op, "del geom=%s context=%i", + if (!EDBM_op_callf(em, op, "delete geom=%s context=%i", &bmop, "holes_geom", DEL_ONLYTAGGED)) { EDBM_op_finish(em, &bmop, op, TRUE); diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index c3fbb2e8c16..4952dd3f09a 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -485,7 +485,7 @@ void EDBM_select_more(BMEditMesh *em) int use_faces = em->selectmode == SCE_SELECT_FACE; BMO_op_initf(em->bm, &bmop, - "regionextend geom=%hvef constrict=%b use_faces=%b", + "region_extend geom=%hvef constrict=%b use_faces=%b", BM_ELEM_SELECT, FALSE, use_faces); BMO_op_exec(em->bm, &bmop); /* don't flush selection in edge/vertex mode */ @@ -501,7 +501,7 @@ void EDBM_select_less(BMEditMesh *em) int use_faces = em->selectmode == SCE_SELECT_FACE; BMO_op_initf(em->bm, &bmop, - "regionextend geom=%hvef constrict=%b use_faces=%b", + "region_extend geom=%hvef constrict=%b use_faces=%b", BM_ELEM_SELECT, TRUE, use_faces); BMO_op_exec(em->bm, &bmop); /* don't flush selection in edge/vertex mode */ diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 59a0475ebb5..cdbf5751ea1 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -45,6 +45,7 @@ #include "DNA_key_types.h" #include "DNA_material_types.h" #include "DNA_meshdata_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -418,8 +419,17 @@ int join_mesh_exec(bContext *C, wmOperator *op) } if (me->totloop) { - if (base->object != ob) + if (base->object != ob) { + MultiresModifierData *mmd; + multiresModifier_prepare_join(scene, base->object, ob); + + if ((mmd = get_multires_modifier(scene, base->object, TRUE))) { + ED_object_iter_other(bmain, base->object, TRUE, + ED_object_multires_update_totlevels_cb, + &mmd->totlvl); + } + } CustomData_merge(&me->ldata, &ldata, CD_MASK_MESH, CD_DEFAULT, totloop); CustomData_copy_data(&me->ldata, &ldata, 0, loopofs, me->totloop); @@ -888,7 +898,7 @@ int mesh_mirrtopo_table(Object *ob, char mode) return 0; } -static int mesh_get_x_mirror_vert_spacial(Object *ob, int index) +static int mesh_get_x_mirror_vert_spatial(Object *ob, int index) { Mesh *me = ob->data; MVert *mvert; @@ -916,12 +926,12 @@ int mesh_get_x_mirror_vert(Object *ob, int index) return mesh_get_x_mirror_vert_topo(ob, index); } else { - return mesh_get_x_mirror_vert_spacial(ob, index); + return mesh_get_x_mirror_vert_spatial(ob, index); } return 0; } -static BMVert *editbmesh_get_x_mirror_vert_spacial(Object *ob, BMEditMesh *em, const float co[3]) +static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, const float co[3]) { float vec[3]; intptr_t poinval; @@ -979,7 +989,7 @@ BMVert *editbmesh_get_x_mirror_vert(Object *ob, struct BMEditMesh *em, BMVert *e return editbmesh_get_x_mirror_vert_topo(ob, em, eve, index); } else { - return editbmesh_get_x_mirror_vert_spacial(ob, em, co); + return editbmesh_get_x_mirror_vert_spatial(ob, em, co); } } diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 810fe244984..e1c715952d1 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -616,13 +616,15 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima) CLAMP(ss_lvl, 0, 6); - smd.levels = smd.renderLevels = ss_lvl; - smd.flags |= eSubsurfModifierFlag_SubsurfUv; + if (ss_lvl > 0) { + smd.levels = smd.renderLevels = ss_lvl; + smd.flags |= eSubsurfModifierFlag_SubsurfUv; - if (bkr->simple) - smd.subdivType = ME_SIMPLE_SUBSURF; + if (bkr->simple) + smd.subdivType = ME_SIMPLE_SUBSURF; - height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, NULL, 0); + height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, NULL, 0); + } } height_data->origindex = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 908c0a6f4f2..35ee641d2c1 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -106,7 +106,7 @@ /* ************* XXX **************** */ static void error(const char *UNUSED(arg)) {} static void waitcursor(int UNUSED(val)) {} -static int pupmenu(const char *UNUSED(msg)) {return 0;} +static int pupmenu(const char *UNUSED(msg)) { return 0; } /* port over here */ static void error_libdata(void) {} diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index b47591dddee..c9851c6a0db 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -160,7 +160,7 @@ void GROUP_OT_objects_remove_active(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int group_objects_remove_exec(bContext *C, wmOperator *UNUSED(op)) +static int group_objects_remove_all_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); @@ -180,21 +180,116 @@ static int group_objects_remove_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void GROUP_OT_objects_remove(wmOperatorType *ot) +void GROUP_OT_objects_remove_all(wmOperatorType *ot) { /* identifiers */ - ot->name = "Remove From Groups"; - ot->description = "Remove selected objects from all groups"; - ot->idname = "GROUP_OT_objects_remove"; + ot->name = "Remove From All Groups"; + ot->description = "Remove selected objects from all groups or a selected group"; + ot->idname = "GROUP_OT_objects_remove_all"; /* api callbacks */ - ot->exec = group_objects_remove_exec; + ot->exec = group_objects_remove_all_exec; ot->poll = ED_operator_objectmode; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +static int group_objects_remove_exec(bContext *C, wmOperator *op) +{ + Object *ob = ED_object_context(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + int group_object_index = RNA_enum_get(op->ptr, "group"); + + /* first get the group back from the enum index, quite awkward and UI spesific */ + if (ob) { + Group *group = NULL; + int i = 0; + + while ((group = find_group(ob, group))) { + if (i == group_object_index) { + break; + } + i++; + } + + /* now remove all selected objects from the group */ + if (group) { + + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) + { + rem_from_group(group, base->object, scene, base); + } + CTX_DATA_END; + + DAG_scene_sort(bmain, scene); + WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); + + return OPERATOR_FINISHED; + } + } + + return OPERATOR_CANCELLED; +} + + +/* can be called with C == NULL */ +static EnumPropertyItem *group_objects_remove_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) +{ + Object *ob; + EnumPropertyItem *item = NULL, item_tmp = {0}; + int totitem = 0; + + if (C == NULL) { + return DummyRNA_NULL_items; + } + + ob = ED_object_context(C); + + /* check that the action exists */ + if (ob) { + Group *group = NULL; + int i = 0; + + while ((group = find_group(ob, group))) { + item_tmp.identifier = item_tmp.name = group->id.name + 2; + /* item_tmp.icon = ICON_ARMATURE_DATA; */ + item_tmp.value = i; + RNA_enum_item_add(&item, &totitem, &item_tmp); + i++; + } + } + + RNA_enum_item_end(&item, &totitem); + *free = 1; + + return item; +} + +void GROUP_OT_objects_remove(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name = "Remove From Group"; + ot->description = "Remove selected objects from all groups or a selected group"; + ot->idname = "GROUP_OT_objects_remove"; + + /* api callbacks */ + ot->exec = group_objects_remove_exec; + ot->invoke = WM_menu_invoke; + ot->poll = ED_operator_objectmode; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "The group to remove this object from"); + RNA_def_enum_funcs(prop, group_objects_remove_itemf); + ot->prop = prop; +} + static int group_create_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 6f3cca442f0..917f1c67f8f 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -139,6 +139,7 @@ void LATTICE_OT_make_regular(struct wmOperatorType *ot); /* object_group.c */ void GROUP_OT_create(struct wmOperatorType *ot); +void GROUP_OT_objects_remove_all(struct wmOperatorType *ot); void GROUP_OT_objects_remove(struct wmOperatorType *ot); void GROUP_OT_objects_add_active(struct wmOperatorType *ot); void GROUP_OT_objects_remove_active(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index d6b5fb9fc10..aab3d8afb22 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -173,7 +173,100 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc return new_md; } -static int object_modifier_remove(Object *ob, ModifierData *md, int *sort_depsgraph) +/* Return TRUE if the object has a modifier of type 'type' other than + * the modifier pointed to be 'exclude', otherwise returns FALSE. */ +static int object_has_modifier(const Object *ob, const ModifierData *exclude, + ModifierType type) +{ + ModifierData *md; + + for (md = ob->modifiers.first; md; md = md->next) { + if ((md != exclude) && (md->type == type)) + return TRUE; + } + + return FALSE; +} + +/* If the object data of 'orig_ob' has other users, run 'callback' on + * each of them. + * + * If include_orig is TRUE, the callback will run on 'orig_ob' too. + * + * If the callback ever returns TRUE, iteration will stop and the + * function value will be TRUE. Otherwise the function returns FALSE. + */ +int ED_object_iter_other(Main *bmain, Object *orig_ob, int include_orig, + int (*callback)(Object *ob, void *callback_data), + void *callback_data) +{ + ID *ob_data_id = orig_ob->data; + int users = ob_data_id->us; + + if (ob_data_id->flag & LIB_FAKEUSER) + users--; + + /* First check that the object's data has multiple users */ + if (users > 1) { + Object *ob; + int totfound = include_orig ? 0 : 1; + + for (ob = bmain->object.first; ob && totfound < users; + ob = ob->id.next) + { + if (((ob != orig_ob) || include_orig) && + (ob->data == orig_ob->data)) + { + if (callback(ob, callback_data)) + return TRUE; + + totfound++; + } + } + } + else if (include_orig) { + return callback(orig_ob, callback_data); + } + + return FALSE; +} + +static int object_has_modifier_cb(Object *ob, void *data) +{ + ModifierType type = *((ModifierType*)data); + + return object_has_modifier(ob, NULL, type); +} + +/* Use with ED_object_iter_other(). Sets the total number of levels + * for any multires modifiers on the object to the int pointed to by + * callback_data. */ +int ED_object_multires_update_totlevels_cb(Object *ob, void *totlevel_v) +{ + ModifierData *md; + int totlevel = *((int*)totlevel_v); + + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Multires) { + multires_set_tot_level(ob, (MultiresModifierData *)md, totlevel); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + } + } + return FALSE; +} + +/* Return TRUE if no modifier of type 'type' other than 'exclude' */ +static int object_modifier_safe_to_delete(Main *bmain, Object *ob, + ModifierData *exclude, + ModifierType type) +{ + return (!object_has_modifier(ob, exclude, type) && + !ED_object_iter_other(bmain, ob, FALSE, + object_has_modifier_cb, &type)); +} + +static int object_modifier_remove(Main *bmain, Object *ob, ModifierData *md, + int *sort_depsgraph) { ModifierData *obmd; @@ -218,33 +311,13 @@ static int object_modifier_remove(Object *ob, ModifierData *md, int *sort_depsgr ob->dt = OB_TEXTURE; } else if (md->type == eModifierType_Multires) { - int ok = 1; - ModifierData *tmpmd; - - /* ensure MDISPS CustomData layer isn't used by another multires modifiers */ - for (tmpmd = ob->modifiers.first; tmpmd; tmpmd = tmpmd->next) - if (tmpmd != md && tmpmd->type == eModifierType_Multires) { - ok = 0; - break; - } - - if (ok) { + /* Delete MDisps layer if not used by another multires modifier */ + if (object_modifier_safe_to_delete(bmain, ob, md, eModifierType_Multires)) multires_customdata_delete(ob->data); - } } else if (md->type == eModifierType_Skin) { - int ok = 1; - ModifierData *tmpmd; - - /* ensure skin CustomData layer isn't used by another skin modifier */ - for (tmpmd = ob->modifiers.first; tmpmd; tmpmd = tmpmd->next) { - if (tmpmd != md && tmpmd->type == eModifierType_Skin) { - ok = 0; - break; - } - } - - if (ok) + /* Delete MVertSkin layer if not used by another skin modifier */ + if (object_modifier_safe_to_delete(bmain, ob, md, eModifierType_Skin)) modifier_skin_customdata_delete(ob); } @@ -265,7 +338,7 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob int sort_depsgraph = 0; int ok; - ok = object_modifier_remove(ob, md, &sort_depsgraph); + ok = object_modifier_remove(bmain, ob, md, &sort_depsgraph); if (!ok) { BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", ob->id.name, md->name); @@ -294,7 +367,7 @@ void ED_object_modifier_clear(Main *bmain, Scene *scene, Object *ob) next_md = md->next; - object_modifier_remove(ob, md, &sort_depsgraph); + object_modifier_remove(bmain, ob, md, &sort_depsgraph); md = next_md; } @@ -771,19 +844,21 @@ static void edit_modifier_properties(wmOperatorType *ot) static int edit_modifier_invoke_properties(bContext *C, wmOperator *op) { - PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier); ModifierData *md; - if (RNA_struct_property_is_set(op->ptr, "modifier")) - return 1; - - if (ptr.data) { - md = ptr.data; - RNA_string_set(op->ptr, "modifier", md->name); - return 1; + if (RNA_struct_property_is_set(op->ptr, "modifier")) { + return TRUE; } - - return 0; + else { + PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier); + if (ptr.data) { + md = ptr.data; + RNA_string_set(op->ptr, "modifier", md->name); + return TRUE; + } + } + + return FALSE; } static ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type) @@ -843,7 +918,7 @@ void OBJECT_OT_modifier_remove(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -882,7 +957,7 @@ void OBJECT_OT_modifier_move_up(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -921,7 +996,7 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -969,7 +1044,7 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; RNA_def_enum(ot->srna, "apply_as", modifier_apply_as_items, MODIFIER_APPLY_DATA, "Apply as", "How to apply the modifier to the geometry"); edit_modifier_properties(ot); @@ -1012,7 +1087,7 @@ void OBJECT_OT_modifier_convert(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1051,7 +1126,7 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1071,6 +1146,10 @@ static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; multiresModifier_del_levels(mmd, ob, 1); + + ED_object_iter_other(CTX_data_main(C), ob, TRUE, + ED_object_multires_update_totlevels_cb, + &mmd->totlvl); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); @@ -1096,7 +1175,7 @@ void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot) ot->exec = multires_higher_levels_delete_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1112,6 +1191,10 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) multiresModifier_subdivide(mmd, ob, 0, mmd->simple); + ED_object_iter_other(CTX_data_main(C), ob, TRUE, + ED_object_multires_update_totlevels_cb, + &mmd->totlvl); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); @@ -1137,7 +1220,7 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot) ot->exec = multires_subdivide_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1201,7 +1284,7 @@ void OBJECT_OT_multires_reshape(wmOperatorType *ot) ot->exec = multires_reshape_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1276,7 +1359,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot) ot->poll = multires_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; WM_operator_properties_filesel(ot, FOLDERFILE | BTXFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); edit_modifier_properties(ot); @@ -1348,7 +1431,7 @@ void OBJECT_OT_multires_base_apply(wmOperatorType *ot) ot->exec = multires_base_apply_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1673,7 +1756,7 @@ static Object *modifier_skin_armature_create(struct Scene *scene, edges_visited = BLI_BITMAP_NEW(me->totedge, "edge_visited"); /* note: we use EditBones here, easier to set them up and use - * edit-armature functions to convert back to regular bones */ + * edit-armature functions to convert back to regular bones */ for (v = 0; v < me->totvert; v++) { if (mvert_skin[v].flag & MVERT_SKIN_ROOT) { EditBone *bone = NULL; @@ -1763,7 +1846,7 @@ void OBJECT_OT_skin_armature_create(wmOperatorType *ot) ot->exec = skin_armature_create_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1858,7 +1941,7 @@ void OBJECT_OT_meshdeform_bind(wmOperatorType *ot) ot->exec = meshdeform_bind_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -1905,7 +1988,7 @@ void OBJECT_OT_explode_refresh(wmOperatorType *ot) ot->exec = explode_refresh_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } @@ -2120,7 +2203,7 @@ void OBJECT_OT_ocean_bake(wmOperatorType *ot) ot->exec = ocean_bake_exec; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); RNA_def_boolean(ot->srna, "free", FALSE, "Free", "Free the bake, rather than generating it"); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index addc6cd4277..f8f4fe9c4e5 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -105,6 +105,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_select_mirror); WM_operatortype_append(GROUP_OT_create); + WM_operatortype_append(GROUP_OT_objects_remove_all); WM_operatortype_append(GROUP_OT_objects_remove); WM_operatortype_append(GROUP_OT_objects_add_active); WM_operatortype_append(GROUP_OT_objects_remove_active); @@ -395,6 +396,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "GROUP_OT_create", GKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); + WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_all", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL | KM_ALT, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 89f018a1b76..3d3f4ef1260 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -270,7 +270,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) { if (nr == 1) { // XXX old animation system - //if (base->object->ipo==ipo) base->flag |= SELECT; + //if (base->object->ipo == ipo) base->flag |= SELECT; //changed = 1; } else if (nr == 2) { diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index b31e5c0aea3..2e58fa85a11 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -567,11 +567,14 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) if (deform) { fsmesh.channelSizeVertices = length; fsmesh.channelVertices = fobj->VertexCache; - - // remove channels + + /* remove channels */ fsmesh.channelTranslation = fsmesh.channelRotation = - fsmesh.channelScale = NULL; + fsmesh.channelScale = NULL; + + /* Override user settings, only noslip is supported here! */ + fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP; } elbeemAddMesh(&fsmesh); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index de3d2d4e871..d37a16cb1bb 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -518,7 +518,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) ibuf = BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock); if (ibuf) { - /* color -> greyscale */ + /* color -> grayscale */ /* editing directly would alter the render view */ if (scene->r.im_format.planes == R_IMF_PLANES_BW) { ImBuf *ibuf_bw = IMB_dupImBuf(ibuf); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 37ab87780b5..a638aac9423 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -862,7 +862,7 @@ static void draw_join_shape(ScrArea *sa, char dir) draw_horizontal_join_shape(sa, dir); } -/* draw screen area darker with arrow (visualisation of future joining) */ +/* draw screen area darker with arrow (visualization of future joining) */ static void scrarea_draw_shape_dark(ScrArea *sa, char dir) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1241,6 +1241,8 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event) else WM_cursor_set(win, CURSOR_X_MOVE); } + else + WM_cursor_set(win, CURSOR_STD); } } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index cacd6d01291..6be276dea14 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -458,7 +458,7 @@ int ED_operator_editmball(bContext *C) int ED_operator_mask(bContext *C) { - SpaceClip *sc= CTX_wm_space_clip(C); + SpaceClip *sc = CTX_wm_space_clip(C); return ED_space_clip_check_show_maskedit(sc); } @@ -2826,7 +2826,7 @@ static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *U uiItemS(layout); - /* file browser should be fullscreen all the time, but other regions can be maximised/restored... */ + /* file browser should be fullscreen all the time, but other regions can be maximized/restored... */ if (sa->spacetype != SPACE_FILE) { if (sa->full) uiItemO(layout, "Tile Area", ICON_NONE, "SCREEN_OT_screen_full_area"); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index b0867608840..6a8f7db5fc9 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -2344,8 +2344,8 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i /* Use tf_uv_pxoffset instead of tf->uv so we can offset the UV half a pixel * this is done so we can avoid offsetting all the pixels by 0.5 which causes * problems when wrapping negative coords */ - xhalfpx = (0.5f + (PROJ_GEOM_TOLERANCE / 3.0f) ) / ibuf_xf; - yhalfpx = (0.5f + (PROJ_GEOM_TOLERANCE / 4.0f) ) / ibuf_yf; + xhalfpx = (0.5f + (PROJ_GEOM_TOLERANCE / 3.0f)) / ibuf_xf; + yhalfpx = (0.5f + (PROJ_GEOM_TOLERANCE / 4.0f)) / ibuf_yf; /* Note about (PROJ_GEOM_TOLERANCE/x) above... * Needed to add this offset since UV coords are often quads aligned to pixels. @@ -4935,7 +4935,7 @@ static int texture_paint_init(bContext *C, wmOperator *op) if (BKE_brush_size_get(scene, brush) < 2) BKE_brush_size_set(scene, brush, 2); - /* allocate and initialize spacial data structures */ + /* allocate and initialize spatial data structures */ project_paint_begin(&pop->ps); if (pop->ps.dm == NULL) @@ -5728,7 +5728,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) undo_paint_push_begin(UNDO_PAINT_IMAGE, op->type->name, image_undo_restore, image_undo_free); - /* allocate and initialize spacial data structures */ + /* allocate and initialize spatial data structures */ project_paint_begin(&ps); if (ps.dm == NULL) { diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 3c37ad8cf2a..1b62ba8a7e0 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -3045,7 +3045,7 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op) void PAINT_OT_weight_from_bones(wmOperatorType *ot) { static EnumPropertyItem type_items[] = { - {ARM_GROUPS_AUTO, "AUTOMATIC", 0, "Automatic", "Automatic weights froms bones"}, + {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}}; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 89dbe14f62a..bfac2922c2b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -592,7 +592,7 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis, distsq = len_squared_v3v3(mirror, cache->true_location); if (distsq <= 4.0f * (cache->radius_squared)) - return (2.0f * (cache->radius) - sqrtf(distsq)) / (2.0f * (cache->radius)); + return (2.0f * (cache->radius) - sqrtf(distsq)) / (2.0f * (cache->radius)); else return 0; } @@ -3145,40 +3145,46 @@ static const char *sculpt_tool_name(Sculpt *sd) { Brush *brush = paint_brush(&sd->paint); - switch (brush->sculpt_tool) { + switch ((BrushSculptTool)brush->sculpt_tool) { case SCULPT_TOOL_DRAW: - return "Draw Brush"; break; + return "Draw Brush"; case SCULPT_TOOL_SMOOTH: - return "Smooth Brush"; break; + return "Smooth Brush"; case SCULPT_TOOL_CREASE: - return "Crease Brush"; break; + return "Crease Brush"; case SCULPT_TOOL_BLOB: - return "Blob Brush"; break; + return "Blob Brush"; case SCULPT_TOOL_PINCH: - return "Pinch Brush"; break; + return "Pinch Brush"; case SCULPT_TOOL_INFLATE: - return "Inflate Brush"; break; + return "Inflate Brush"; case SCULPT_TOOL_GRAB: - return "Grab Brush"; break; + return "Grab Brush"; case SCULPT_TOOL_NUDGE: - return "Nudge Brush"; break; + return "Nudge Brush"; case SCULPT_TOOL_THUMB: - return "Thumb Brush"; break; + return "Thumb Brush"; case SCULPT_TOOL_LAYER: - return "Layer Brush"; break; + return "Layer Brush"; case SCULPT_TOOL_FLATTEN: - return "Flatten Brush"; break; + return "Flatten Brush"; case SCULPT_TOOL_CLAY: - return "Clay Brush"; break; + return "Clay Brush"; case SCULPT_TOOL_CLAY_STRIPS: - return "Clay Strips Brush"; break; + return "Clay Strips Brush"; case SCULPT_TOOL_FILL: - return "Fill Brush"; break; + return "Fill Brush"; case SCULPT_TOOL_SCRAPE: - return "Scrape Brush"; break; - default: - return "Sculpting"; break; + return "Scrape Brush"; + case SCULPT_TOOL_SNAKE_HOOK: + return "Snake Hook Brush"; + case SCULPT_TOOL_ROTATE: + return "Rotate Brush"; + case SCULPT_TOOL_MASK: + return "Mask Brush"; } + + return "Sculpting"; } /** @@ -3639,8 +3645,8 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, } /* Returns true iff any of the smoothing modes are active (currently - one of smooth brush, autosmooth, mask smooth, or shift-key - smooth) */ + * one of smooth brush, autosmooth, mask smooth, or shift-key + * smooth) */ static int sculpt_any_smooth_mode(const Brush *brush, StrokeCache *cache, int stroke_mode) diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 539a32161e5..b42c6406362 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -930,8 +930,25 @@ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short s ED_gpencil_select_frame(ale->data, selx, select_mode); else if (ale->type == ANIMTYPE_MASKLAYER) ED_mask_select_frame(ale->data, selx, select_mode); - else - ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL); + else { + if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK) && + (ale->type == ANIMTYPE_SUMMARY) && (ale->datatype == ALE_ALL)) + { + ListBase anim_data = {NULL, NULL}; + int filter; + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + for (ale = anim_data.first; ale; ale = ale->next) { + if (ale->type == ANIMTYPE_GPLAYER) + ED_gpencil_select_frame(ale->data, selx, select_mode); + else if (ale->type == ANIMTYPE_MASKLAYER) + ED_mask_select_frame(ale->data, selx, select_mode); + } + } + else { + ANIM_animchannel_keyframes_loop(&ked, ac->ads, ale, ok_cb, select_cb, NULL); + } + } } /* Option 2) Selects all the keyframes on either side of the current frame (depends on which side the mouse is on) */ diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index d8d664eea22..2cbcbcdbc9a 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -63,6 +63,7 @@ #include "ED_logic.h" #include "ED_clip.h" #include "ED_mask.h" +#include "ED_sequencer.h" #include "io_ops.h" @@ -139,7 +140,8 @@ void ED_spacetypes_init(void) ED_operatormacros_clip(); ED_operatormacros_curve(); ED_operatormacros_mask(); - + ED_operatormacros_sequencer(); + /* register dropboxes (can use macros) */ spacetypes = BKE_spacetypes_list(); for (type = spacetypes->first; type; type = type->next) { diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index d1c2c1e092f..6154a1cc5ce 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -991,7 +991,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) if (!path) return; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT); block = uiLayoutGetBlock(row); diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index 9b3d713d040..e561b2a9e79 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -118,13 +118,13 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiTemplateID(layout, C, ptr, propname, NULL, "CLIP_OT_open", NULL); if (clip) { - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); block = uiLayoutGetBlock(row); uiDefBut(block, LABEL, 0, "File Path:", 0, 19, 145, 19, NULL, 0, 0, 0, 0, ""); - row = uiLayoutRow(layout, 0); - split = uiLayoutSplit(row, 0.0, 0); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(layout, FALSE); + split = uiLayoutSplit(row, 0.0f, FALSE); + row = uiLayoutRow(split, TRUE); uiItemR(row, &clipptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "clip.reload"); @@ -396,7 +396,7 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P BKE_movieclip_get_size(clip, user, &width, &height); if (track->flag & TRACK_LOCKED) { - uiLayoutSetActive(layout, 0); + uiLayoutSetActive(layout, FALSE); block = uiLayoutAbsoluteBlock(layout); uiDefBut(block, LABEL, 0, "Track is locked", 0, 0, 300, 19, NULL, 0, 0, 0, 0, ""); @@ -434,7 +434,7 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P uiDefButBitI(block, OPTIONN, MARKER_DISABLED, B_MARKER_FLAG, "Enabled", 10, 190, 145, 19, &cb->marker_flag, 0, 0, 0, 0, tip); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiLayoutSetActive(col, (cb->marker_flag & MARKER_DISABLED) == 0); block = uiLayoutAbsoluteBlock(col); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 9b9e2223ae6..37da40e11b3 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -1318,7 +1318,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking); if (track) { - int framenr = sc->user.framenr; + int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr); offsx = marker->pos[0]; @@ -1408,19 +1408,23 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, glPopMatrix(); } -void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) +void clip_draw_main(const bContext *C, ARegion *ar) { + SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); + Scene *scene = CTX_data_scene(C); ImBuf *ibuf; int width, height; float zoomx, zoomy; + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); + /* if no clip, nothing to do */ - if (!clip) + if (!clip) { + ED_region_grid_draw(ar, zoomx, zoomy); return; - - ED_space_clip_get_clip_size(sc, &width, &height); - ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); + } if (sc->flag & SC_SHOW_STABLE) { float smat[4][4], ismat[4][4]; @@ -1492,12 +1496,10 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d) MovieTrackingTrack *track = BKE_tracking_track_get_active(&sc->clip->tracking); if (track) { - int framenr = sc->user.framenr; - /* don't get the exact marker since it may not exist for the frame */ + int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); - if (marker) { - glTranslatef(marker->pos[0], marker->pos[1], 0.0f); - } + + glTranslatef(marker->pos[0], marker->pos[1], 0.0f); } } diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 4dd2f82df02..224a250fe4c 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -122,132 +122,73 @@ int ED_space_clip_maskedit_mask_poll(bContext *C) return FALSE; } -/* ******** editing functions ******** */ +/* ******** common editing functions ******** */ -void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *clip) +void ED_space_clip_get_size(const bContext *C, int *width, int *height) { - MovieClip *old_clip; - - if (!screen && C) - screen = CTX_wm_screen(C); - - old_clip = sc->clip; - sc->clip = clip; - - if (sc->clip && sc->clip->id.us == 0) - sc->clip->id.us = 1; - - if (screen && sc->view == SC_VIEW_CLIP) { - ScrArea *area; - SpaceLink *sl; - - for (area = screen->areabase.first; area; area = area->next) { - for (sl = area->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_CLIP) { - SpaceClip *cur_sc = (SpaceClip *) sl; + SpaceClip *sc = CTX_wm_space_clip(C); - if (cur_sc != sc && cur_sc->view != SC_VIEW_CLIP) { - if (cur_sc->clip == old_clip || cur_sc->clip == NULL) { - cur_sc->clip = clip; - } - } - } - } - } + if (!sc->clip) { + *width = *height = 0; + } + else { + BKE_movieclip_get_size(sc->clip, &sc->user, width, height); } - - if (C) - WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip); -} - -MovieClip *ED_space_clip_get_clip(SpaceClip *sc) -{ - return sc->clip; -} - -Mask *ED_space_clip_get_mask(SpaceClip *sc) -{ - return sc->mask; } -ImBuf *ED_space_clip_get_buffer(SpaceClip *sc) +void ED_space_clip_get_zoom(const bContext *C, float *zoomx, float *zoomy) { - if (sc->clip) { - ImBuf *ibuf; - - ibuf = BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag); - - if (ibuf && (ibuf->rect || ibuf->rect_float)) - return ibuf; + ARegion *ar = CTX_wm_region(C); + int width, height; - if (ibuf) - IMB_freeImBuf(ibuf); - } + ED_space_clip_get_size(C, &width, &height); - return NULL; + *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width); + *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height); } -ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale, float *angle) +void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy) { - if (sc->clip) { - ImBuf *ibuf; - - ibuf = BKE_movieclip_get_stable_ibuf(sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag); - - if (ibuf && (ibuf->rect || ibuf->rect_float)) - return ibuf; - - if (ibuf) - IMB_freeImBuf(ibuf); - } + MovieClip *clip = ED_space_clip_get_clip(sc); - return NULL; -} + if (clip) + BKE_movieclip_aspect(clip, aspx, aspy); + else + *aspx = *aspy = 1.0f; -void ED_space_clip_get_clip_size(SpaceClip *sc, int *width, int *height) -{ - if (!sc->clip) { - *width = *height = 0; + if (*aspx < *aspy) { + *aspy = *aspy / *aspx; + *aspx = 1.0f; } else { - BKE_movieclip_get_size(sc->clip, &sc->user, width, height); + *aspx = *aspx / *aspy; + *aspy = 1.0f; } } -void ED_space_clip_get_mask_size(SpaceClip *sc, int *width, int *height) +void ED_space_clip_get_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *aspy) { - /* quite the same as ED_space_clip_size, but it also runs aspect correction on output resolution - * this is needed because mask should be rasterized with exactly the same resolution as - * currently displaying frame and it doesn't have access to aspect correction currently - * used for display. (sergey) - */ + int w, h; - if (!sc->mask) { - *width = 0; - *height = 0; - } else { - float aspx, aspy; + /* most of tools does not require aspect to be returned with dimensions correction + * due to they're invariant to this stuff, but some transformation tools like rotation + * should be aware of aspect correction caused by different resolution in different + * directions. + * mainly this is sued for transformation stuff + */ - ED_space_clip_get_clip_size(sc, width, height); - ED_space_clip_get_clip_aspect(sc, &aspx, &aspy); + if (!sc->clip) { + *aspx = 1.0f; + *aspy = 1.0f; - *width *= aspx; - *height *= aspy; + return; } -} - -void ED_space_clip_get_mask_aspect(SpaceClip *sc, float *aspx, float *aspy) -{ - int w, h; - ED_space_clip_get_clip_aspect(sc, aspx, aspy); - ED_space_clip_get_clip_size(sc, &w, &h); + ED_space_clip_get_aspect(sc, aspx, aspy); + BKE_movieclip_get_size(sc->clip, &sc->user, &w, &h); - /* now this is not accounted for! */ -#if 0 - *aspx *= (float)w; - *aspy *= (float)h; -#endif + *aspx *= (float) w; + *aspy *= (float) h; if (*aspx < *aspy) { *aspy = *aspy / *aspx; @@ -259,51 +200,46 @@ void ED_space_clip_get_mask_aspect(SpaceClip *sc, float *aspx, float *aspy) } } -void ED_space_clip_get_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy) +/* return current frame number in clip space */ +int ED_space_clip_get_clip_frame_number(SpaceClip *sc) { - int width, height; - - ED_space_clip_get_clip_size(sc, &width, &height); + MovieClip *clip = ED_space_clip_get_clip(sc); - *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width); - *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height); + return BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr); } -void ED_space_clip_get_clip_aspect(SpaceClip *sc, float *aspx, float *aspy) +ImBuf *ED_space_clip_get_buffer(SpaceClip *sc) { - MovieClip *clip = ED_space_clip_get_clip(sc); + if (sc->clip) { + ImBuf *ibuf; - if (clip) - BKE_movieclip_aspect(clip, aspx, aspy); - else - *aspx = *aspy = 1.0f; + ibuf = BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag); + + if (ibuf && (ibuf->rect || ibuf->rect_float)) + return ibuf; + + if (ibuf) + IMB_freeImBuf(ibuf); + } + + return NULL; } -void ED_space_clip_get_clip_aspect_dimension_aware(SpaceClip *sc, float *aspx, float *aspy) +ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale, float *angle) { - int w, h; - - /* most of tools does not require aspect to be returned with dimensions correction - * due to they're invariant to this stuff, but some transformation tools like rotation - * should be aware of aspect correction caused by different resolution in different - * directions. - * mainly this is sued for transformation stuff - */ + if (sc->clip) { + ImBuf *ibuf; - ED_space_clip_get_clip_aspect(sc, aspx, aspy); - ED_space_clip_get_clip_size(sc, &w, &h); + ibuf = BKE_movieclip_get_stable_ibuf(sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag); - *aspx *= (float)w; - *aspy *= (float)h; + if (ibuf && (ibuf->rect || ibuf->rect_float)) + return ibuf; - if (*aspx < *aspy) { - *aspy = *aspy / *aspx; - *aspx = 1.0f; - } - else { - *aspx = *aspx / *aspy; - *aspy = 1.0f; + if (ibuf) + IMB_freeImBuf(ibuf); } + + return NULL; } void ED_clip_update_frame(const Main *mainp, int cfra) @@ -329,29 +265,23 @@ void ED_clip_update_frame(const Main *mainp, int cfra) } } -/* return current frame number in clip space */ -int ED_space_clip_get_clip_frame_number(SpaceClip *sc) -{ - MovieClip *clip = ED_space_clip_get_clip(sc); - - return BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr); -} - -static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) +static int selected_boundbox(const bContext *C, float min[2], float max[2]) { + SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); MovieTrackingTrack *track; int width, height, ok = FALSE; ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); + int framenr = ED_space_clip_get_clip_frame_number(sc); INIT_MINMAX2(min, max); - ED_space_clip_get_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track)) { - MovieTrackingMarker *marker = BKE_tracking_marker_get(track, sc->user.framenr); + MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); if (marker) { float pos[3]; @@ -383,22 +313,23 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) return ok; } -int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) +int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit) { + SpaceClip *sc = CTX_wm_space_clip(C); int w, h, frame_width, frame_height; float min[2], max[2]; - ED_space_clip_get_clip_size(sc, &frame_width, &frame_height); + ED_space_clip_get_size(C, &frame_width, &frame_height); if (frame_width == 0 || frame_height == 0) return FALSE; - if (!selected_boundbox(sc, min, max)) + if (!selected_boundbox(C, min, max)) return FALSE; /* center view */ - clip_view_center_to_point(sc, (max[0] + min[0]) / (2 * frame_width), - (max[1] + min[1]) / (2 * frame_height)); + clip_view_center_to_point(C, (max[0] + min[0]) / (2 * frame_width), + (max[1] + min[1]) / (2 * frame_height)); w = max[0] - min[0]; h = max[1] - min[1]; @@ -408,7 +339,7 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) int width, height; float zoomx, zoomy, newzoom, aspx, aspy; - ED_space_clip_get_clip_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); width = ar->winrct.xmax - ar->winrct.xmin + 1; height = ar->winrct.ymax - ar->winrct.ymin + 1; @@ -434,7 +365,7 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, const float co[2], float r_co[ float aspy = 1.0f / clip->tracking.camera.pixel_aspect; int width, height; - ED_space_clip_get_clip_size(sc, &width, &height); + BKE_movieclip_get_size(sc->clip, &sc->user, &width, &height); r_co[0] *= width; r_co[1] *= height * aspy; @@ -453,8 +384,8 @@ void ED_clip_point_stable_pos(const bContext *C, float x, float y, float *xr, fl int sx, sy, width, height; float zoomx, zoomy, pos[3], imat[4][4]; - ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); - ED_space_clip_get_clip_size(sc, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); + ED_space_clip_get_size(C, &width, &height); UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); @@ -485,16 +416,18 @@ void ED_clip_point_stable_pos(const bContext *C, float x, float y, float *xr, fl * \brief the reverse of ED_clip_point_stable_pos(), gets the marker region coords. * better name here? view_to_track / track_to_view or so? */ -void ED_clip_point_stable_pos__reverse(SpaceClip *sc, ARegion *ar, const float co[2], float r_co[2]) +void ED_clip_point_stable_pos__reverse(const bContext *C, const float co[2], float r_co[2]) { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); float zoomx, zoomy; float pos[3]; int width, height; int sx, sy; UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); - ED_space_clip_get_clip_size(sc, &width, &height); - ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); ED_clip_point_undistorted_pos(sc, co, pos); pos[2] = 0.0f; @@ -511,6 +444,87 @@ void ED_clip_mouse_pos(const bContext *C, wmEvent *event, float co[2]) ED_clip_point_stable_pos(C, event->mval[0], event->mval[1], &co[0], &co[1]); } +int ED_space_clip_check_show_trackedit(SpaceClip *sc) +{ + if (sc) { + return ELEM3(sc->mode, SC_MODE_TRACKING, SC_MODE_RECONSTRUCTION, SC_MODE_DISTORTION); + } + + return FALSE; +} + +int ED_space_clip_check_show_maskedit(SpaceClip *sc) +{ + if (sc) { + return sc->mode == SC_MODE_MASKEDIT; + } + + return FALSE; +} + +/* ******** clip editing functions ******** */ + +MovieClip *ED_space_clip_get_clip(SpaceClip *sc) +{ + return sc->clip; +} + +void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *clip) +{ + MovieClip *old_clip; + + if (!screen && C) + screen = CTX_wm_screen(C); + + old_clip = sc->clip; + sc->clip = clip; + + if (sc->clip && sc->clip->id.us == 0) + sc->clip->id.us = 1; + + if (screen && sc->view == SC_VIEW_CLIP) { + ScrArea *area; + SpaceLink *sl; + + for (area = screen->areabase.first; area; area = area->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_CLIP) { + SpaceClip *cur_sc = (SpaceClip *) sl; + + if (cur_sc != sc && cur_sc->view != SC_VIEW_CLIP) { + if (cur_sc->clip == old_clip || cur_sc->clip == NULL) { + cur_sc->clip = clip; + } + } + } + } + } + } + + if (C) + WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip); +} + +/* ******** masking editing functions ******** */ + +Mask *ED_space_clip_get_mask(SpaceClip *sc) +{ + return sc->mask; +} + +void ED_space_clip_set_mask(bContext *C, SpaceClip *sc, Mask *mask) +{ + sc->mask = mask; + + if (sc->mask && sc->mask->id.us == 0) { + sc->clip->id.us = 1; + } + + if (C) { + WM_event_add_notifier(C, NC_MASK | NA_SELECTED, mask); + } +} + /* OpenGL draw context */ typedef struct SpaceClipDrawContext { @@ -654,36 +668,3 @@ void ED_space_clip_free_texture_buffer(SpaceClip *sc) MEM_freeN(context); } } - -/* ******** masking editing related functions ******** */ - -int ED_space_clip_check_show_trackedit(SpaceClip *sc) -{ - if (sc) { - return ELEM3(sc->mode, SC_MODE_TRACKING, SC_MODE_RECONSTRUCTION, SC_MODE_DISTORTION); - } - - return FALSE; -} - -int ED_space_clip_check_show_maskedit(SpaceClip *sc) -{ - if (sc) { - return sc->mode == SC_MODE_MASKEDIT; - } - - return FALSE; -} - -void ED_space_clip_set_mask(bContext *C, SpaceClip *sc, Mask *mask) -{ - sc->mask = mask; - - if (sc->mask && sc->mask->id.us == 0) { - sc->clip->id.us = 1; - } - - if (C) { - WM_event_add_notifier(C, NC_MASK | NA_SELECTED, mask); - } -} diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 5bc195a1ae2..c61a0baa82e 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -69,7 +69,7 @@ void clip_draw_dopesheet_channels(const struct bContext *C, struct ARegion *ar); void CLIP_OT_dopesheet_select_channel(struct wmOperatorType *ot); /* clip_draw.c */ -void clip_draw_main(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); +void clip_draw_main(const struct bContext *C, struct ARegion *ar); void clip_draw_grease_pencil(struct bContext *C, int onlyv2d); void clip_draw_curfra_label(struct SpaceClip *sc, float x, float y); @@ -125,7 +125,7 @@ void clip_graph_tracking_iterate(struct SpaceClip *sc, int selected_only, int in void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track); void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker); -void clip_view_center_to_point(struct SpaceClip *sc, float x, float y); +void clip_view_center_to_point(const struct bContext *C, float x, float y); void clip_draw_cfra(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); void clip_draw_sfra_efra(struct View2D *v2d, struct Scene *scene); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index b3f7b221af0..9d1f52568b4 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -69,8 +69,10 @@ /******************** view navigation utilities *********************/ -static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float location[2]) +static void sclip_zoom_set(const bContext *C, float zoom, float location[2]) { + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); float oldzoom = sc->zoom; int width, height; @@ -78,7 +80,7 @@ static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float locatio if (sc->zoom < 0.1f || sc->zoom > 4.0f) { /* check zoom limits */ - ED_space_clip_get_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); width *= sc->zoom; height *= sc->zoom; @@ -92,22 +94,22 @@ static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float locatio } if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { - ED_space_clip_get_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); sc->xof += ((location[0] - 0.5f) * width - sc->xof) * (sc->zoom - oldzoom) / sc->zoom; sc->yof += ((location[1] - 0.5f) * height - sc->yof) * (sc->zoom - oldzoom) / sc->zoom; } } -static void sclip_zoom_set_factor(SpaceClip *sc, ARegion *ar, float zoomfac, float location[2]) +static void sclip_zoom_set_factor(const bContext *C, float zoomfac, float location[2]) { - sclip_zoom_set(sc, ar, sc->zoom*zoomfac, location); + SpaceClip *sc = CTX_wm_space_clip(C); + + sclip_zoom_set(C, sc->zoom * zoomfac, location); } static void sclip_zoom_set_factor_exec(bContext *C, wmEvent *event, float factor) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); float location[2], *mpos = NULL; if (event) { @@ -115,7 +117,7 @@ static void sclip_zoom_set_factor_exec(bContext *C, wmEvent *event, float factor mpos = location; } - sclip_zoom_set_factor(sc, ar, factor, mpos); + sclip_zoom_set_factor(C, factor, mpos); ED_region_tag_redraw(CTX_wm_region(C)); } @@ -494,10 +496,7 @@ static void view_zoom_exit(bContext *C, wmOperator *op, int cancel) static int view_zoom_exec(bContext *C, wmOperator *op) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); - - sclip_zoom_set_factor(sc, ar, RNA_float_get(op->ptr, "factor"), NULL); + sclip_zoom_set_factor(C, RNA_float_get(op->ptr, "factor"), NULL); ED_region_tag_redraw(CTX_wm_region(C)); @@ -525,8 +524,6 @@ static int view_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event) static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); ViewZoomData *vpd = op->customdata; float factor; @@ -534,7 +531,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) case MOUSEMOVE: factor = 1.0f + (vpd->x - event->x + vpd->y - event->y) / 300.0f; RNA_float_set(op->ptr, "factor", factor); - sclip_zoom_set(sc, ar, vpd->zoom * factor, vpd->location); + sclip_zoom_set(C, vpd->zoom * factor, vpd->location); ED_region_tag_redraw(CTX_wm_region(C)); break; default: @@ -582,13 +579,11 @@ void CLIP_OT_view_zoom(wmOperatorType *ot) static int view_zoom_in_exec(bContext *C, wmOperator *op) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); float location[2]; RNA_float_get_array(op->ptr, "location", location); - sclip_zoom_set_factor(sc, ar, 1.25f, location); + sclip_zoom_set_factor(C, 1.25f, location); ED_region_tag_redraw(CTX_wm_region(C)); @@ -624,13 +619,11 @@ void CLIP_OT_view_zoom_in(wmOperatorType *ot) static int view_zoom_out_exec(bContext *C, wmOperator *op) { - SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); float location[2]; RNA_float_get_array(op->ptr, "location", location); - sclip_zoom_set_factor(sc, ar, 0.8f, location); + sclip_zoom_set_factor(C, 0.8f, location); ED_region_tag_redraw(CTX_wm_region(C)); @@ -661,7 +654,7 @@ void CLIP_OT_view_zoom_out(wmOperatorType *ot) /* properties */ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", - "Cursor location in normalised (0.0-1.0) coordinates", -10.0f, 10.0f); + "Cursor location in normalized (0.0-1.0) coordinates", -10.0f, 10.0f); } /********************** view zoom ratio operator *********************/ @@ -669,9 +662,8 @@ void CLIP_OT_view_zoom_out(wmOperatorType *ot) static int view_zoom_ratio_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); - ARegion *ar = CTX_wm_region(C); - sclip_zoom_set(sc, ar, RNA_float_get(op->ptr, "ratio"), NULL); + sclip_zoom_set(C, RNA_float_get(op->ptr, "ratio"), NULL); /* ensure pixel exact locations for draw */ sc->xof = (int) sc->xof; @@ -713,8 +705,8 @@ static int view_all_exec(bContext *C, wmOperator *op) sc = CTX_wm_space_clip(C); ar = CTX_wm_region(C); - ED_space_clip_get_clip_size(sc, &w, &h); - ED_space_clip_get_clip_aspect(sc, &aspx, &aspy); + ED_space_clip_get_size(C, &w, &h); + ED_space_clip_get_aspect(sc, &aspx, &aspy); w = w * aspx; h = h * aspy; @@ -729,7 +721,7 @@ static int view_all_exec(bContext *C, wmOperator *op) zoomx = (float) width / (w + 2 * margin); zoomy = (float) height / (h + 2 * margin); - sclip_zoom_set(sc, ar, MIN2(zoomx, zoomy), NULL); + sclip_zoom_set(C, MIN2(zoomx, zoomy), NULL); } else { if ((w >= width || h >= height) && (width > 0 && height > 0)) { @@ -737,10 +729,10 @@ static int view_all_exec(bContext *C, wmOperator *op) zoomy = (float) height / h; /* find the zoom value that will fit the image in the image space */ - sclip_zoom_set(sc, ar, 1.0f / power_of_2(1.0f / MIN2(zoomx, zoomy)), NULL); + sclip_zoom_set(C, 1.0f / power_of_2(1.0f / MIN2(zoomx, zoomy)), NULL); } else - sclip_zoom_set(sc, ar, 1.0f, NULL); + sclip_zoom_set(C, 1.0f, NULL); } sc->xof = sc->yof = 0.0f; @@ -775,7 +767,7 @@ static int view_selected_exec(bContext *C, wmOperator *UNUSED(op)) sc->xlockof = 0.0f; sc->ylockof = 0.0f; - ED_clip_view_selection(sc, ar, 1); + ED_clip_view_selection(C, ar, 1); ED_region_tag_redraw(CTX_wm_region(C)); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 1c040c69fa9..d9c9f63e4a3 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -223,13 +223,14 @@ void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, } } -void clip_view_center_to_point(SpaceClip *sc, float x, float y) +void clip_view_center_to_point(const bContext *C, float x, float y) { + SpaceClip *sc = CTX_wm_space_clip(C); int width, height; float aspx, aspy; - ED_space_clip_get_clip_size(sc, &width, &height); - ED_space_clip_get_clip_aspect(sc, &aspx, &aspy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_aspect(sc, &aspx, &aspy); sc->xof = (x - 0.5f) * width * aspx; sc->yof = (y - 0.5f) * height * aspy; diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 49ee6b65256..0a6a4af6960 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1008,13 +1008,14 @@ static void clip_refresh(const bContext *C, ScrArea *sa) /********************* main region ********************/ /* sets up the fields of the View2D from zoom and offset */ -static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar) +static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar) { + SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); float x1, y1, w, h; int width, height, winx, winy; - ED_space_clip_get_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); w = width; h = height; @@ -1074,11 +1075,54 @@ static void clip_main_area_init(wmWindowManager *wm, ARegion *ar) WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } +static void clip_main_area_draw_mask(const bContext *C, ARegion *ar) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + int x, y; + int width, height; + float zoomx, zoomy; + + /* frame image */ + float maxdim; + float xofs, yofs; + + /* find window pixel coordinates of origin */ + UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); + + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); + + /* frame the image */ + maxdim = maxf(width, height); + if (width == height) { + xofs = yofs = 0; + } + else if (width < height) { + xofs = ((height - width) / -2.0f) * zoomx; + yofs = 0.0f; + } + else { /* (width > height) */ + xofs = 0.0f; + yofs = ((width - height) / -2.0f) * zoomy; + } + + /* apply transformation so mask editing tools will assume drawing from the origin in normalized space */ + glPushMatrix(); + glTranslatef(x + xofs, y + yofs, 0); + glScalef(maxdim * zoomx, maxdim * zoomy, 0); + glMultMatrixf(sc->stabmat); + + ED_mask_draw(C, sc->mask_draw_flag, sc->mask_draw_type); + + ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); + + glPopMatrix(); +} + static void clip_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ SpaceClip *sc = CTX_wm_space_clip(C); - Scene *scene = CTX_data_scene(C); MovieClip *clip = ED_space_clip_get_clip(sc); /* if tracking is in progress, we should synchronize framenr from clipuser @@ -1093,7 +1137,7 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) tmpibuf = ED_space_clip_get_stable_buffer(sc, NULL, NULL, NULL); } - if (ED_clip_view_selection(sc, ar, 0)) { + if (ED_clip_view_selection(C, ar, 0)) { sc->xof += sc->xlockof; sc->yof += sc->ylockof; } @@ -1107,51 +1151,12 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) glClear(GL_COLOR_BUFFER_BIT); /* data... */ - movieclip_main_area_set_view2d(sc, ar); + movieclip_main_area_set_view2d(C, ar); - clip_draw_main(sc, ar, scene); + clip_draw_main(C, ar); if (sc->mode == SC_MODE_MASKEDIT) { - int x, y; - int width, height; - float zoomx, zoomy, aspx, aspy; - - /* frame image */ - float maxdim; - float xofs, yofs; - - /* find window pixel coordinates of origin */ - UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); - - ED_space_clip_get_clip_size(sc, &width, &height); - ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); - ED_space_clip_get_clip_aspect(sc, &aspx, &aspy); - - /* frame the image */ - maxdim = maxf(width, height); - if (width == height) { - xofs = yofs = 0; - } - else if (width < height) { - xofs = ((height - width) / -2.0f) * zoomx; - yofs = 0.0f; - } - else { /* (width > height) */ - xofs = 0.0f; - yofs = ((width - height) / -2.0f) * zoomy; - } - - /* apply transformation so mask editing tools will assume drawing from the origin in normalized space */ - glPushMatrix(); - glTranslatef(x + xofs, y + yofs, 0); - glScalef(maxdim * zoomx, maxdim * zoomy, 0); - glMultMatrixf(sc->stabmat); - - ED_mask_draw(C, sc->mask_draw_flag, sc->mask_draw_type); - - ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); - - glPopMatrix(); + clip_main_area_draw_mask(C, ar); } /* Grease Pencil */ diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 8f58df1cb2c..2e4ba844646 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -81,8 +81,9 @@ /********************** add marker operator *********************/ -static void add_marker(SpaceClip *sc, float x, float y) +static void add_marker(const bContext *C, float x, float y) { + SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); @@ -90,7 +91,7 @@ static void add_marker(SpaceClip *sc, float x, float y) int width, height; int framenr = ED_space_clip_get_clip_frame_number(sc); - ED_space_clip_get_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); track = BKE_tracking_track_add(tracking, tracksbase, x, y, framenr, width, height); @@ -106,14 +107,14 @@ static int add_marker_exec(bContext *C, wmOperator *op) float pos[2]; int width, height; - ED_space_clip_get_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); if (!width || !height) return OPERATOR_CANCELLED; RNA_float_get_array(op->ptr, "location", pos); - add_marker(sc, pos[0], pos[1]); + add_marker(C, pos[0], pos[1]); /* reset offset from locked position, so frame jumping wouldn't be so confusing */ sc->xlockof = 0; @@ -532,7 +533,7 @@ MovieTrackingTrack *tracking_marker_check_slide(bContext *C, wmEvent *event, int int framenr = ED_space_clip_get_clip_frame_number(sc); int action = -1, area = 0, corner = -1; - ED_space_clip_get_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); if (width == 0 || height == 0) return NULL; @@ -628,7 +629,7 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event) int framenr = ED_space_clip_get_clip_frame_number(sc); int area, action, corner; - ED_space_clip_get_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); if (width == 0 || height == 0) return NULL; @@ -1585,14 +1586,15 @@ static int clear_track_path_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); + MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; - ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); + ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); int action = RNA_enum_get(op->ptr, "action"); int clear_active = RNA_boolean_get(op->ptr, "clear_active"); int framenr = ED_space_clip_get_clip_frame_number(sc); if (clear_active) { - track = BKE_tracking_track_get_active(&clip->tracking); + track = BKE_tracking_track_get_active(tracking); BKE_tracking_track_path_clear(track, framenr, action); } else { @@ -1605,6 +1607,7 @@ static int clear_track_path_exec(bContext *C, wmOperator *op) } } + BKE_tracking_dopesheet_tag_update(tracking); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); return OPERATOR_FINISHED; @@ -2605,6 +2608,7 @@ static int detect_features_exec(bContext *C, wmOperator *op) IMB_freeImBuf(ibuf); + BKE_tracking_dopesheet_tag_update(tracking); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -3328,7 +3332,7 @@ static int tracking_object_remove_exec(bContext *C, wmOperator *op) void CLIP_OT_tracking_object_remove(wmOperatorType *ot) { /* identifiers */ - ot->name = "Movie Tracking Object"; + ot->name = "Remove Tracking Object"; ot->description = "Remove object for tracking"; ot->idname = "CLIP_OT_tracking_object_remove"; diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index f8f786e549c..0ebb84b3953 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -110,15 +110,16 @@ static int mouse_on_crns(float co[2], float pos[2], float crns[4][2], float epsx return dist < MAX2(epsx, epsy); } -static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *track) +static int track_mouse_area(const bContext *C, float co[2], MovieTrackingTrack *track) { + SpaceClip *sc = CTX_wm_space_clip(C); int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); float pat_min[2], pat_max[2]; float epsx, epsy; int width, height; - ED_space_clip_get_clip_size(sc, &width, &height); + ED_space_clip_get_size(C, &width, &height); BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max); @@ -235,7 +236,7 @@ static int mouse_select(bContext *C, float co[2], int extend) track = find_nearest_track(sc, tracksbase, co); if (track) { - int area = track_mouse_area(sc, co, track); + int area = track_mouse_area(C, co, track); if (!extend || !TRACK_VIEW_SELECTED(sc, track)) area = TRACK_AREA_ALL; @@ -412,7 +413,6 @@ void CLIP_OT_select_border(wmOperatorType *ot) static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, short select) { - ARegion *ar = CTX_wm_region(C); SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; @@ -435,7 +435,7 @@ static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, sho float screen_co[2]; /* marker in screen coords */ - ED_clip_point_stable_pos__reverse(sc, ar, marker->pos, screen_co); + ED_clip_point_stable_pos__reverse(C, marker->pos, screen_co); if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) && BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], V2D_IS_CLIPPED)) @@ -520,7 +520,6 @@ static int circle_select_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); - ARegion *ar = CTX_wm_region(C); MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); @@ -536,8 +535,8 @@ static int circle_select_exec(bContext *C, wmOperator *op) mode = RNA_int_get(op->ptr, "gesture_mode"); /* compute ellipse and position in unified coordinates */ - ED_space_clip_get_clip_size(sc, &width, &height); - ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); + ED_space_clip_get_size(C, &width, &height); + ED_space_clip_get_zoom(C, &zoomx, &zoomy); ellipse[0] = width * zoomx / radius; ellipse[1] = height * zoomy / radius; diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index 3ad6614d356..a07a560328c 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -91,7 +91,7 @@ int file_directory_exec(bContext *C, struct wmOperator *unused); int file_directory_new_exec(bContext *C, struct wmOperator *unused); int file_delete_exec(bContext *C, struct wmOperator *unused); -int file_hilight_set(struct SpaceFile *sfile, struct ARegion *ar, int mx, int my); +int file_highlight_set(struct SpaceFile *sfile, struct ARegion *ar, int mx, int my); void file_sfile_to_operator(struct wmOperator *op, struct SpaceFile *sfile, char *filepath); void file_operator_to_sfile(struct SpaceFile *sfile, struct wmOperator *op); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index e2fc1b64223..2d778b94216 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -515,7 +515,7 @@ void FILE_OT_delete_bookmark(wmOperatorType *ot) RNA_def_int(ot->srna, "index", -1, -1, 20000, "Index", "", -1, 20000); } -int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) +int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) { View2D *v2d = &ar->v2d; FileSelectParams *params; @@ -555,7 +555,7 @@ static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *e ARegion *ar = CTX_wm_region(C); SpaceFile *sfile = CTX_wm_space_file(C); - if (!file_hilight_set(sfile, ar, event->x, event->y)) + if (!file_highlight_set(sfile, ar, event->x, event->y)) return OPERATOR_CANCELLED; ED_area_tag_redraw(CTX_wm_area(C)); @@ -1277,7 +1277,8 @@ void FILE_OT_hidedot(struct wmOperatorType *ot) ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ } -struct ARegion *file_buttons_region(struct ScrArea *sa){ +struct ARegion *file_buttons_region(struct ScrArea *sa) +{ ARegion *ar, *arnew; for (ar = sa->regionbase.first; ar; ar = ar->next) diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index 77e99a61b10..51bd660e126 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -87,12 +87,12 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat uiLayoutSetAlignment(pa->layout, UI_LAYOUT_ALIGN_LEFT); block = uiLayoutGetBlock(pa->layout); box = uiLayoutBox(pa->layout); - col = uiLayoutColumn(box, 1); + col = uiLayoutColumn(box, TRUE); for (i_iter = 0; i_iter < nentries; ++i_iter) { char dir[FILE_MAX]; char temp[FILE_MAX]; - uiLayout *layout = uiLayoutRow(col, 0); + uiLayout *layout = uiLayoutRow(col, FALSE); char *entry; i = reverse ? nentries - (i_iter + 1) : i_iter; @@ -143,7 +143,7 @@ static void file_panel_bookmarks(const bContext *C, Panel *pa) uiLayout *row; if (sfile) { - row = uiLayoutRow(pa->layout, 0); + row = uiLayoutRow(pa->layout, FALSE); uiItemO(row, IFACE_("Add"), ICON_ZOOMIN, "file.bookmark_add"); uiItemL(row, NULL, ICON_NONE); diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index a4cf447686c..fb12ea8417a 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -805,19 +805,19 @@ int ED_file_extension_icon(const char *relname) if (type == BLENDERFILE || type == BLENDERFILE_BACKUP) return ICON_FILE_BLEND; - else if (type == IMAGEFILE) + else if (type == IMAGEFILE) return ICON_FILE_IMAGE; - else if (type == MOVIEFILE) + else if (type == MOVIEFILE) return ICON_FILE_MOVIE; - else if (type == PYSCRIPTFILE) + else if (type == PYSCRIPTFILE) return ICON_FILE_SCRIPT; - else if (type == SOUNDFILE) + else if (type == SOUNDFILE) return ICON_FILE_SOUND; - else if (type == FTFONTFILE) + else if (type == FTFONTFILE) return ICON_FILE_FONT; - else if (type == BTXFILE) + else if (type == BTXFILE) return ICON_FILE_BLANK; - else if (type == COLLADAFILE) + else if (type == COLLADAFILE) return ICON_FILE_BLANK; return ICON_FILE_BLANK; @@ -831,7 +831,7 @@ static void filelist_setfiletypes(struct FileList *filelist) file = filelist->filelist; for (num = 0; num < filelist->numfiles; num++, file++) { - file->type = file->s.st_mode; /* restore the mess below */ + file->type = file->s.st_mode; /* restore the mess below */ /* Don't check extensions for directories */ if (file->type & S_IFDIR) { @@ -856,7 +856,7 @@ static void filelist_read_dir(struct FileList *filelist) filelist->fidx = NULL; filelist->filelist = NULL; - BLI_current_working_dir(wdir, sizeof(wdir)); /* backup cwd to restore after */ + BLI_current_working_dir(wdir, sizeof(wdir)); /* backup cwd to restore after */ BLI_cleanup_dir(G.main->name, filelist->dir); filelist->numfiles = BLI_dir_contents(filelist->dir, &(filelist->filelist)); @@ -1108,7 +1108,7 @@ void filelist_from_library(struct FileList *filelist) filelist_sort(filelist, FILE_SORT_ALPHA); - BLI_strncpy(G.main->name, filename, sizeof(filename)); // prevent G.main->name to change + BLI_strncpy(G.main->name, filename, sizeof(filename)); /* prevent G.main->name to change */ filelist->filter = 0; filelist_filter(filelist); diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 79979603f54..95d5483b42c 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -356,7 +356,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) /* on first read, find active file */ if (params->active_file == -1) { wmEvent *event = CTX_wm_window(C)->eventstate; - file_hilight_set(sfile, ar, event->x, event->y); + file_highlight_set(sfile, ar, event->x, event->y); } file_draw_list(C, ar); diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index ddcd46ba817..efe62eaf495 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -142,19 +142,19 @@ static void graph_panel_view(const bContext *C, Panel *pa) RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr); /* 2D-Cursor */ - col = uiLayoutColumn(pa->layout, 0); + col = uiLayoutColumn(pa->layout, FALSE); uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump"); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); - row = uiLayoutSplit(sub, 0.7, 1); + row = uiLayoutSplit(sub, 0.7f, TRUE); uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE); uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA); - row = uiLayoutSplit(sub, 0.7, 1); + row = uiLayoutSplit(sub, 0.7f, TRUE); uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE); uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE); } @@ -183,24 +183,24 @@ static void graph_panel_properties(const bContext *C, Panel *pa) /* user-friendly 'name' for F-Curve */ /* TODO: only show the path if this is invalid? */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); icon = getname_anim_fcurve(name, ale->id, fcu); uiItemL(col, name, icon); /* RNA-Path Editing - only really should be enabled when things aren't working */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED) != 0); uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA); uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE); /* color settings */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Display Color:"), ICON_NONE); - row = uiLayoutRow(col, 1); + row = uiLayoutRow(col, TRUE); uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE); - sub = uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiLayoutSetEnabled(sub, (fcu->color_mode == FCURVE_COLOR_CUSTOM)); uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE); @@ -307,7 +307,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) } /* interpolation */ - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE); /* numerical coordinate editing @@ -315,7 +315,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) * and unit conversion magic that cannot be achieved using a purely RNA-approach */ // XXX: - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); /* keyframe itself */ { uiItemL(col, IFACE_("Key:"), ICON_NONE); @@ -469,7 +469,7 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); /* Target ID */ - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:")); /* Target Property */ @@ -480,7 +480,7 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa /* get pointer for resolving the property selected */ RNA_id_pointer_create(dtar->id, &root_ptr); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); /* rna path */ uiTemplatePathBuilder(col, &dtar_ptr, "data_path", &root_ptr, IFACE_("Path")); } @@ -501,7 +501,7 @@ static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar * RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr); /* Bone 1 */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Bone 1:")); if (dtar->id && ob1->pose) { @@ -511,7 +511,7 @@ static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar * uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); } - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Bone 2:")); if (dtar2->id && ob2->pose) { @@ -537,7 +537,7 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar * RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr); /* Bone 1 */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone 1:")); if (dtar->id && ob1->pose) { @@ -549,7 +549,7 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar * uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Ob/Bone 2:")); if (dtar2->id && ob2->pose) { @@ -574,7 +574,7 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); /* properties */ - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone:")); if (dtar->id && ob->pose) { @@ -584,7 +584,7 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); } - sub = uiLayoutColumn(layout, 1); + sub = uiLayoutColumn(layout, TRUE); uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE); uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE); } @@ -612,7 +612,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL); /* general actions - management */ - col = uiLayoutColumn(pa->layout, 0); + col = uiLayoutColumn(pa->layout, FALSE); block = uiLayoutGetBlock(col); but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10 * UI_UNIT_X, 22, NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies")); @@ -625,7 +625,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) /* driver-level settings - type, expressions, and errors */ RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr); - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); block = uiLayoutGetBlock(col); uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE); @@ -644,13 +644,13 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR); } - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); /* debug setting */ uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE); /* value of driver */ if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { - uiLayout *row = uiLayoutRow(col, 1); + uiLayout *row = uiLayoutRow(col, TRUE); char valBuf[32]; uiItemL(row, IFACE_("Driver Value:"), ICON_NONE); @@ -660,7 +660,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) } /* add driver variables */ - col = uiLayoutColumn(pa->layout, 0); + col = uiLayoutColumn(pa->layout, FALSE); block = uiLayoutGetBlock(col); but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver")); @@ -672,14 +672,14 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) uiLayout *box, *row; /* sub-layout column for this variable's settings */ - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); /* header panel */ box = uiLayoutBox(col); /* first row context info for driver */ RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); block = uiLayoutGetBlock(row); /* variable name */ uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE); @@ -692,7 +692,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) uiBlockSetEmboss(block, UI_EMBOSS); /* variable type */ - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE); /* variable type settings */ @@ -718,7 +718,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) char valBuf[32]; box = uiLayoutBox(col); - row = uiLayoutRow(box, 1); + row = uiLayoutRow(box, TRUE); uiItemL(row, IFACE_("Value:"), ICON_NONE); BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval); @@ -760,7 +760,7 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) /* 'add modifier' button at top of panel */ { - row = uiLayoutRow(pa->layout, 0); + row = uiLayoutRow(pa->layout, FALSE); block = uiLayoutGetBlock(row); // XXX for now, this will be a operator button which calls a 'add modifier' operator @@ -768,14 +768,14 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) 10, 0, 150, 20, TIP_("Adds a new F-Curve Modifier for the active F-Curve")); /* copy/paste (as sub-row)*/ - row = uiLayoutRow(row, 1); + row = uiLayoutRow(row, TRUE); uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy"); uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste"); } /* draw each modifier */ for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) { - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm); } diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index ddca0030cf5..870e9bb8168 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -276,7 +276,7 @@ static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short View2D *v2d = &ar->v2d; /* only draw points if curve is visible - * - draw unselected points before selected points as separate passes to minimise color-changing overhead + * - draw unselected points before selected points as separate passes to minimize color-changing overhead * (XXX dunno if this is faster than drawing all in one pass though) * and also to make sure in the case of overlapping points that the selected is always visible * - draw handles before keyframes, so that keyframes will overlap handles (keyframes are more important for users) @@ -851,7 +851,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid setlinestyle(2); } if ( ((fcu->grp) && (fcu->grp->flag & AGRP_MUTED)) || (fcu->flag & FCURVE_MUTED) ) { - /* muted curves are drawn in a greyish hue */ + /* muted curves are drawn in a grayish hue */ // XXX should we have some variations? UI_ThemeColorShade(TH_HEADER, 50); } diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 756e6997fc8..f4cb4ec3d05 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -189,6 +189,8 @@ static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) sipo->ads->source = (ID *)(G.main->scene.first); // FIXME: this is a really nasty hack here for now... } + /* force immediate init of any invalid F-Curve colors */ + sipo->flag |= SIPO_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); } @@ -477,7 +479,13 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn) if (wmn->data == ND_SPACE_GRAPH) ED_area_tag_redraw(sa); break; - + case NC_WINDOW: + if (sipo->flag & SIPO_TEMP_NEEDCHANSYNC) { + /* force redraw/refresh after undo/redo - prevents "black curve" problem */ + ED_area_tag_refresh(sa); + } + break; + // XXX: restore the case below if not enough updates occur... //default: // if (wmn->data==ND_KEYS) diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 332a2ecada4..92c339d7672 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -148,7 +148,7 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, /* the frame number, even if we cant */ if (ima->source == IMA_SRC_SEQUENCE) { /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */ - const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0); + const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0, NULL); ofs += sprintf(str + ofs, IFACE_(", Frame: %d"), framenr); } @@ -512,7 +512,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image int wmenu1, wmenu2, wmenu3, layer; char *strp; - uiLayoutRow(layout, 1); + uiLayoutRow(layout, TRUE); /* layer menu is 1/3 larger than pass */ wmenu1 = (2 * w) / 5; @@ -552,7 +552,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, uiBut *but; const float dpi_fac = UI_DPI_FAC; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); if (rr == NULL || iuser == NULL) return; @@ -693,13 +693,13 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE); if (ima->source != IMA_SRC_GENERATED) { - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); if (ima->packedfile) uiItemO(row, "", ICON_PACKAGE, "image.unpack"); else uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack"); - row = uiLayoutRow(row, 0); + row = uiLayoutRow(row, FALSE); uiLayoutSetEnabled(row, ima->packedfile == NULL); uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "image.reload"); @@ -733,26 +733,26 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char if (compact == 0) { /* background image view doesnt need these */ uiItemS(layout); - split = uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); /* XXX Why only display fields_per_frame only for video image types? * And why allow fields for non-video image types at all??? */ if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { - uiLayout *subsplit = uiLayoutSplit(col, 0, 0); - uiLayout *subcol = uiLayoutColumn(subsplit, 0); + uiLayout *subsplit = uiLayoutSplit(col, 0.0f, FALSE); + uiLayout *subcol = uiLayoutColumn(subsplit, FALSE); uiItemR(subcol, &imaptr, "use_fields", 0, NULL, ICON_NONE); - subcol = uiLayoutColumn(subsplit, 0); + subcol = uiLayoutColumn(subsplit, FALSE); uiLayoutSetActive(subcol, RNA_boolean_get(&imaptr, "use_fields")); uiItemR(subcol, userptr, "fields_per_frame", 0, IFACE_("Fields"), ICON_NONE); } else uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields")); uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, &imaptr, "use_premultiply", 0, NULL, ICON_NONE); uiItemR(row, &imaptr, "use_color_unpremultiply", 0, NULL, ICON_NONE); } @@ -761,24 +761,24 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { uiItemS(layout); - split = uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); BLI_snprintf(str, sizeof(str), IFACE_("(%d) Frames"), iuser->framenr); uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE); uiItemR(col, userptr, "frame_start", 0, IFACE_("Start"), ICON_NONE); uiItemR(col, userptr, "frame_offset", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemO(col, NULL, ICON_NONE, "IMAGE_OT_match_movie_length"); uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE); uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE); } else if (ima->source == IMA_SRC_GENERATED) { - split = uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE); uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE); uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE); @@ -804,12 +804,12 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) uiLayout *col, *row, *split, *sub; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); - split = uiLayoutSplit(col, 0.5f, 0); + split = uiLayoutSplit(col, 0.5f, FALSE); uiItemR(split, imfptr, "file_format", 0, "", ICON_NONE); - sub = uiLayoutRow(split, 0); + sub = uiLayoutRow(split, FALSE); uiItemR(sub, imfptr, "color_mode", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE); /* only display depth setting if multiple depths can be used */ @@ -821,7 +821,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) R_IMF_CHAN_DEPTH_24, R_IMF_CHAN_DEPTH_32)) == 0) { - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, imfptr, "color_depth", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } @@ -837,7 +837,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE); } - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); if (BKE_imtype_supports_zbuf(imf->imtype)) { uiItemR(row, imfptr, "use_zbuffer", 0, NULL, ICON_NONE); } @@ -847,7 +847,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) } if (imf->imtype == R_IMF_IMTYPE_JP2) { - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, imfptr, "use_jpeg2k_cinema_preset", 0, NULL, ICON_NONE); uiItemR(row, imfptr, "use_jpeg2k_cinema_48", 0, NULL, ICON_NONE); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 7e67e737cc2..3dc1fbd738f 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1926,6 +1926,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) if (ibuf == NULL) { ED_space_image_release_buffer(sima, lock); + info->draw = 0; return; } @@ -2018,8 +2019,9 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) } #endif } - else + else { info->draw = 0; + } ED_space_image_release_buffer(sima, lock); ED_area_tag_redraw(CTX_wm_area(C)); diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 080f12bf35b..33a2d5c18c5 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -340,7 +340,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm ReportTimerInfo *rti; float progress = 0.0, color_progress = 0.0; float neutral_col[3] = {0.35, 0.35, 0.35}; - float neutral_grey = 0.6; + float neutral_gray = 0.6; float timeout = 0.0, color_timeout = 0.0; int send_note = 0; @@ -385,7 +385,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm rti->col[1] = 0.45; rti->col[2] = 0.7; } - rti->greyscale = 0.75; + rti->grayscale = 0.75; rti->widthfac = 1.0; } @@ -398,7 +398,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm /* fade colors out sharply according to progress through fade-out duration */ interp_v3_v3v3(rti->col, rti->col, neutral_col, color_progress); - rti->greyscale = interpf(neutral_grey, rti->greyscale, color_progress); + rti->grayscale = interpf(neutral_gray, rti->grayscale, color_progress); } /* collapse report at end of timeout */ diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 0eec61f599e..08842698214 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3197,8 +3197,8 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *lo uiLayout *box, *row, *sub; bSensor *sens= (bSensor *)ptr->data; - box= uiLayoutBox(layout); - row= uiLayoutRow(box, 0); + box = uiLayoutBox(layout); + row = uiLayoutRow(box, FALSE); uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")) { @@ -3210,13 +3210,13 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *lo uiItemL(row, sens->name, ICON_NONE); } - sub= uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); uiLayoutSetActive(sub, ((RNA_boolean_get(logic_ptr, "show_sensors_active_states") && RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin"))); uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")==0) { - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_UP, "direction", 1); // up uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_DOWN, "direction", 2); // down } @@ -3228,19 +3228,19 @@ static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr) { uiLayout *box, *split, *sub, *row; - box= uiLayoutBox(layout); - split = uiLayoutSplit(box, 0.45, 0); + box = uiLayoutBox(layout); + split = uiLayoutSplit(box, 0.45f, FALSE); - row= uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_pulse_true_level", 0, "", ICON_DOTSUP); uiItemR(row, ptr, "use_pulse_false_level", 0, "", ICON_DOTSDOWN); - sub=uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); uiLayoutSetActive(sub, (RNA_boolean_get(ptr, "use_pulse_true_level") || RNA_boolean_get(ptr, "use_pulse_false_level"))); uiItemR(sub, ptr, "frequency", 0, "Freq", ICON_NONE); - row= uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_level", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_tap", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); @@ -3282,7 +3282,7 @@ static void draw_sensor_armature(uiLayout *layout, PointerRNA *ptr) if (RNA_property_collection_lookup_string(&pose_ptr, bones_prop, as->posechannel, &pchan_ptr)) uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE); } - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "test_type", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "test_type") != SENS_ARM_STATE_CHANGED) uiItemR(row, ptr, "value", 0, NULL, ICON_NONE); @@ -3295,8 +3295,8 @@ static void draw_sensor_collision(uiLayout *layout, PointerRNA *ptr, bContext *C RNA_main_pointer_create(CTX_data_main(C), &main_ptr); - split = uiLayoutSplit(layout, 0.3, 0); - row = uiLayoutRow(split, 1); + split = uiLayoutSplit(layout, 0.3f, FALSE); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_pulse", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_material", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); @@ -3314,7 +3314,7 @@ static void draw_sensor_delay(uiLayout *layout, PointerRNA *ptr) { uiLayout *row; - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "delay", 0, NULL, ICON_NONE); uiItemR(row, ptr, "duration", 0, NULL, ICON_NONE); @@ -3332,17 +3332,17 @@ static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr) case SENS_JOY_BUTTON: uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events") == FALSE); uiItemR(col, ptr, "button_number", 0, NULL, ICON_NONE); break; case SENS_JOY_AXIS: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "axis_number", 0, NULL, ICON_NONE); uiItemR(row, ptr, "axis_threshold", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events") == FALSE); uiItemR(col, ptr, "axis_direction", 0, NULL, ICON_NONE); break; @@ -3350,12 +3350,12 @@ static void draw_sensor_joystick(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "hat_number", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_all_events", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_events") == FALSE); uiItemR(col, ptr, "hat_direction", 0, NULL, ICON_NONE); break; case SENS_JOY_AXIS_SINGLE: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "single_axis_number", 0, NULL, ICON_NONE); uiItemR(row, ptr, "axis_threshold", 0, NULL, ICON_NONE); break; @@ -3368,21 +3368,21 @@ static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr) PointerRNA settings_ptr; uiLayout *row, *col; - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, "Key:", ICON_NONE); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys") == FALSE); uiItemR(col, ptr, "key", UI_ITEM_R_EVENT, "", ICON_NONE); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "use_all_keys", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys") == FALSE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemL(row, "First Modifier:", ICON_NONE); uiItemR(row, ptr, "modifier_key_1", UI_ITEM_R_EVENT, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemL(row, "Second Modifier:", ICON_NONE); uiItemR(row, ptr, "modifier_key_2", UI_ITEM_R_EVENT, "", ICON_NONE); @@ -3407,7 +3407,7 @@ static void draw_sensor_near(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "property", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "distance", 0, NULL, ICON_NONE); uiItemR(row, ptr, "reset_distance", 0, NULL, ICON_NONE); } @@ -3425,7 +3425,7 @@ static void draw_sensor_property(uiLayout *layout, PointerRNA *ptr) switch (RNA_enum_get(ptr, "evaluation_type")) { case SENS_PROP_INTERVAL: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "value_min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "value_max", 0, NULL, ICON_NONE); break; @@ -3447,7 +3447,7 @@ static void draw_sensor_radar(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "property", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "axis", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "angle", 0, NULL, ICON_NONE); uiItemR(row, ptr, "distance", 0, NULL, ICON_NONE); } @@ -3463,7 +3463,7 @@ static void draw_sensor_ray(uiLayout *layout, PointerRNA *ptr, bContext *C) PointerRNA main_ptr; RNA_main_pointer_create(CTX_data_main(C), &main_ptr); - split= uiLayoutSplit(layout, 0.3, 0); + split = uiLayoutSplit(layout, 0.3f, FALSE); uiItemR(split, ptr, "ray_type", 0, "", ICON_NONE); switch (RNA_enum_get(ptr, "ray_type")) { case SENS_RAY_PROPERTY: @@ -3474,9 +3474,9 @@ static void draw_sensor_ray(uiLayout *layout, PointerRNA *ptr, bContext *C) break; } - split= uiLayoutSplit(layout, 0.3, 0); + split = uiLayoutSplit(layout, 0.3, FALSE); uiItemR(split, ptr, "axis", 0, "", ICON_NONE); - row= uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "range", 0, NULL, ICON_NONE); uiItemR(row, ptr, "use_x_ray", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); } @@ -3555,8 +3555,8 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i char state[3]; BLI_snprintf(state, sizeof(state), "%d", RNA_int_get(ptr, "states")); - box= uiLayoutBox(layout); - row= uiLayoutRow(box, 0); + box = uiLayoutBox(layout); + row = uiLayoutRow(box, FALSE); uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")) { @@ -3574,7 +3574,7 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i uiItemR(row, ptr, "use_priority", 0, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")==0) { - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_UP, "direction", 1); // up uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_DOWN, "direction", 2); // down } @@ -3590,13 +3590,13 @@ static void draw_controller_python(uiLayout *layout, PointerRNA *ptr) { uiLayout *split, *sub; - split = uiLayoutSplit(layout, 0.3, 1); + split = uiLayoutSplit(layout, 0.3, TRUE); uiItemR(split, ptr, "mode", 0, "", ICON_NONE); if (RNA_enum_get(ptr, "mode") == CONT_PY_SCRIPT) { uiItemR(split, ptr, "text", 0, "", ICON_NONE); } else { - sub = uiLayoutSplit(split, 0.8, 0); + sub = uiLayoutSplit(split, 0.8f, FALSE); uiItemR(sub, ptr, "module", 0, "", ICON_NONE); uiItemR(sub, ptr, "use_debug", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); } @@ -3646,8 +3646,8 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA * uiLayout *box, *row, *sub; bActuator *act= (bActuator *)ptr->data; - box= uiLayoutBox(layout); - row= uiLayoutRow(box, 0); + box = uiLayoutBox(layout); + row = uiLayoutRow(box, FALSE); uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")) { @@ -3659,13 +3659,13 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA * uiItemL(row, act->name, ICON_NONE); } - sub= uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); uiLayoutSetActive(sub, ((RNA_boolean_get(logic_ptr, "show_actuators_active_states") && RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin"))); uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE); if (RNA_boolean_get(ptr, "show_expanded")==0) { - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_UP, "direction", 1); // up uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_DOWN, "direction", 2); // down } @@ -3680,22 +3680,22 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "play_mode", 0, "", ICON_NONE); - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, TRUE); uiItemR(sub, ptr, "use_force", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(sub, ptr, "use_additive", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutColumn(sub, 0); + row = uiLayoutColumn(sub, FALSE); uiLayoutSetActive(row, (RNA_boolean_get(ptr, "use_additive") || RNA_boolean_get(ptr, "use_force"))); uiItemR(row, ptr, "use_local", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "action", 0, "", ICON_NONE); uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); if ((RNA_enum_get(ptr, "play_mode") == ACT_ACTION_FROM_PROP)) uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE); @@ -3706,11 +3706,11 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "apply_to_children", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "frame_blend_in", 0, NULL, ICON_NONE); uiItemR(row, ptr, "priority", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "layer", 0, NULL, ICON_NONE); uiItemR(row, ptr, "layer_weight", 0, NULL, ICON_NONE); @@ -3798,11 +3798,11 @@ static void draw_actuator_camera(uiLayout *layout, PointerRNA *ptr) uiLayout *row; uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "height", 0, NULL, ICON_NONE); uiItemR(row, ptr, "axis", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "max", 0, NULL, ICON_NONE); @@ -3821,7 +3821,7 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext case ACT_CONST_TYPE_LOC: uiItemR(layout, ptr, "limit", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "limit_min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "limit_max", 0, NULL, ICON_NONE); @@ -3829,36 +3829,36 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext break; case ACT_CONST_TYPE_DIST: - split = uiLayoutSplit(layout, 0.8, 0); + split = uiLayoutSplit(layout, 0.8, FALSE); uiItemR(split, ptr, "direction", 0, NULL, ICON_NONE); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_local", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_normal", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); - col = uiLayoutColumn(row, 1); + row = uiLayoutRow(layout, FALSE); + col = uiLayoutColumn(row, TRUE); uiItemL(col, "Range:", ICON_NONE); uiItemR(col, ptr, "range", 0, "", ICON_NONE); - col = uiLayoutColumn(row, 1); + col = uiLayoutColumn(row, TRUE); uiItemR(col, ptr, "use_force_distance", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 0); + sub = uiLayoutColumn(col, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_force_distance") == TRUE); uiItemR(sub, ptr, "distance", 0, "", ICON_NONE); uiItemR(layout, ptr, "damping", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.15, 0); + split = uiLayoutSplit(layout, 0.15f, FALSE); uiItemR(split, ptr, "use_material_detect", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); if (RNA_boolean_get(ptr, "use_material_detect")) uiItemPointerR(split, ptr, "material", &main_ptr, "materials", NULL, ICON_MATERIAL_DATA); else uiItemR(split, ptr, "property", 0, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.15, 0); + split = uiLayoutSplit(layout, 0.15, FALSE); uiItemR(split, ptr, "use_persistent", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "time", 0, NULL, ICON_NONE); uiItemR(row, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); break; @@ -3866,43 +3866,43 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext case ACT_CONST_TYPE_ORI: uiItemR(layout, ptr, "direction_axis_pos", 0, NULL, ICON_NONE); - row=uiLayoutRow(layout, 1); + row=uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "damping", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "time", 0, NULL, ICON_NONE); - row=uiLayoutRow(layout, 0); + row=uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "rotation_max", 0, NULL, ICON_NONE); - row=uiLayoutRow(layout, 1); + row=uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "angle_min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "angle_max", 0, NULL, ICON_NONE); break; case ACT_CONST_TYPE_FH: - split=uiLayoutSplit(layout, 0.75, 0); - row= uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.75, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "fh_damping", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "fh_height", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_fh_paralel_axis", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "direction_axis", 0, NULL, ICON_NONE); - split = uiLayoutSplit(row, 0.9, 0); + split = uiLayoutSplit(row, 0.9f, FALSE); uiItemR(split, ptr, "fh_force", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_fh_normal", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.15, 0); + split = uiLayoutSplit(layout, 0.15, FALSE); uiItemR(split, ptr, "use_material_detect", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); if (RNA_boolean_get(ptr, "use_material_detect")) uiItemPointerR(split, ptr, "material", &main_ptr, "materials", NULL, ICON_MATERIAL_DATA); else uiItemR(split, ptr, "property", 0, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.15, 0); + split = uiLayoutSplit(layout, 0.15, FALSE); uiItemR(split, ptr, "use_persistent", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "time", 0, NULL, ICON_NONE); uiItemR(row, ptr, "damping_rotation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); break; @@ -3917,17 +3917,17 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) switch (RNA_enum_get(ptr, "mode")) { case ACT_EDOB_ADD_OBJECT: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "object", 0, NULL, ICON_NONE); uiItemR(row, ptr, "time", 0, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "linear_velocity", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "angular_velocity", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_angular_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); break; @@ -3938,16 +3938,16 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) uiItemL(layout, "Mode only available for mesh objects", ICON_NONE); break; } - split = uiLayoutSplit(layout, 0.6, 0); + split = uiLayoutSplit(layout, 0.6, FALSE); uiItemR(split, ptr, "mesh", 0, NULL, ICON_NONE); - row = uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "use_replace_display_mesh", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_replace_physics_mesh", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); break; case ACT_EDOB_TRACK_TO: - split = uiLayoutSplit(layout, 0.5, 0); + split = uiLayoutSplit(layout, 0.5, FALSE); uiItemR(split, ptr, "track_object", 0, NULL, ICON_NONE); - sub = uiLayoutSplit(split, 0.7, 0); + sub = uiLayoutSplit(split, 0.7f, FALSE); uiItemR(sub, ptr, "time", 0, NULL, ICON_NONE); uiItemR(sub, ptr, "use_3d_tracking", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); break; @@ -3974,8 +3974,8 @@ static void draw_actuator_filter_2d(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "glsl_shader", 0, NULL, ICON_NONE); break; case ACT_2DFILTER_MOTIONBLUR: - split=uiLayoutSplit(layout, 0.75, 1); - row= uiLayoutRow(split, 0); + split=uiLayoutSplit(layout, 0.75f, TRUE); + row = uiLayoutRow(split, FALSE); uiLayoutSetActive(row, RNA_boolean_get(ptr, "use_motion_blur") == TRUE); uiItemR(row, ptr, "motion_blur_factor", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_motion_blur", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); @@ -4007,7 +4007,7 @@ static void draw_actuator_message(uiLayout *layout, PointerRNA *ptr, bContext *C uiItemPointerR(layout, ptr, "to_property", &main_ptr, "objects", NULL, ICON_OBJECT_DATA); uiItemR(layout, ptr, "subject", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "body_type", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "body_type") == ACT_MESG_MESG) @@ -4031,37 +4031,37 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) switch (RNA_enum_get(ptr, "mode")) { case ACT_OBJECT_NORMAL: - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "offset_location", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_location", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "offset_rotation", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_rotation", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); if (ELEM3(physics_type, OB_BODY_TYPE_DYNAMIC, OB_BODY_TYPE_RIGID, OB_BODY_TYPE_SOFT)) { uiItemL(layout, "Dynamic Object Settings:", ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "force", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_force", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "torque", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_torque", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "linear_velocity", 0, NULL, ICON_NONE); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_add_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "angular_velocity", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_angular_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); @@ -4071,29 +4071,29 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) case ACT_OBJECT_SERVO: uiItemR(layout, ptr, "reference_object", 0, NULL, ICON_NONE); - split = uiLayoutSplit(layout, 0.9, 0); - row = uiLayoutRow(split, 0); + split = uiLayoutSplit(layout, 0.9, FALSE); + row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "linear_velocity", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_linear_velocity", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); - col = uiLayoutColumn(row, 0); + row = uiLayoutRow(layout, FALSE); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "use_servo_limit_x", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_x") == TRUE); uiItemR(sub, ptr, "force_max_x", 0, NULL, ICON_NONE); uiItemR(sub, ptr, "force_min_x", 0, NULL, ICON_NONE); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "use_servo_limit_y", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_y") == TRUE); uiItemR(sub, ptr, "force_max_y", 0, NULL, ICON_NONE); uiItemR(sub, ptr, "force_min_y", 0, NULL, ICON_NONE); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "use_servo_limit_z", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_servo_limit_z") == TRUE); uiItemR(sub, ptr, "force_max_z", 0, NULL, ICON_NONE); uiItemR(sub, ptr, "force_min_z", 0, NULL, ICON_NONE); @@ -4102,7 +4102,7 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) //Layout designers willing to help on that, please compare with 2.49 ui // (since the old code is going to be deleted ... soon) - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "proportional_coefficient", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "integral_coefficient", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "derivate_coefficient", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -4119,9 +4119,9 @@ static void draw_actuator_parent(uiLayout *layout, PointerRNA *ptr) if (RNA_enum_get(ptr, "mode") == ACT_PARENT_SET) { uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "use_compound", 0, NULL, ICON_NONE); - sub= uiLayoutRow(row, 0); + sub = uiLayoutRow(row, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_compound") == TRUE); uiItemR(sub, ptr, "use_ghost", 0, NULL, ICON_NONE); } @@ -4152,15 +4152,15 @@ static void draw_actuator_property(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "value", 0, NULL, ICON_NONE); break; case ACT_PROP_COPY: - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "object", 0, NULL, ICON_NONE); if (ob_from) { RNA_pointer_create((ID *)ob_from, &RNA_GameObjectSettings, ob_from, &obj_settings_ptr); uiItemPointerR(row, ptr, "object_property", &obj_settings_ptr, "properties", NULL, ICON_NONE); } else { - sub= uiLayoutRow(row, 0); - uiLayoutSetActive(sub, 0); + sub = uiLayoutRow(row, FALSE); + uiLayoutSetActive(sub, FALSE); uiItemR(sub, ptr, "object_property", 0, NULL, ICON_NONE); } break; @@ -4176,15 +4176,15 @@ static void draw_actuator_random(uiLayout *layout, PointerRNA *ptr) ob = (Object *)ptr->id.data; RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "seed", 0, NULL, ICON_NONE); uiItemR(row, ptr, "distribution", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); switch (RNA_enum_get(ptr, "distribution")) { case ACT_RANDOM_BOOL_CONST: @@ -4261,12 +4261,12 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "mode", 0, "", ICON_NONE); uiItemR(row, ptr, "action", 0, "", ICON_NONE); uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); if ((RNA_enum_get(ptr, "mode") == ACT_ACTION_FROM_PROP)) uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE); @@ -4275,11 +4275,11 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "frame_end", 0, NULL, ICON_NONE); } - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "frame_blend_in", 0, NULL, ICON_NONE); uiItemR(row, ptr, "priority", 0, NULL, ICON_NONE); - row= uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemPointerR(row, ptr, "frame_property", &settings_ptr, "properties", NULL, ICON_NONE); #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR @@ -4298,28 +4298,28 @@ static void draw_actuator_sound(uiLayout *layout, PointerRNA *ptr, bContext *C) } uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "volume", 0, NULL, ICON_NONE); uiItemR(row, ptr, "pitch", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_sound_3d", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_sound_3d") == TRUE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "gain_3d_min", 0, NULL, ICON_NONE); uiItemR(row, ptr, "gain_3d_max", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "distance_3d_reference", 0, NULL, ICON_NONE); uiItemR(row, ptr, "distance_3d_max", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "rolloff_factor_3d", 0, NULL, ICON_NONE); uiItemR(row, ptr, "cone_outer_gain_3d", 0, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "cone_outer_angle_3d", 0, NULL, ICON_NONE); uiItemR(row, ptr, "cone_inner_angle_3d", 0, NULL, ICON_NONE); } @@ -4331,7 +4331,7 @@ static void draw_actuator_state(uiLayout *layout, PointerRNA *ptr) PointerRNA settings_ptr; RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - split = uiLayoutSplit(layout, 0.35, 0); + split = uiLayoutSplit(layout, 0.35, FALSE); uiItemR(split, ptr, "operation", 0, NULL, ICON_NONE); uiTemplateLayers(split, ptr, "states", &settings_ptr, "used_states", 0); @@ -4340,7 +4340,7 @@ static void draw_actuator_state(uiLayout *layout, PointerRNA *ptr) static void draw_actuator_visibility(uiLayout *layout, PointerRNA *ptr) { uiLayout *row; - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "use_visible", 0, NULL, ICON_NONE); uiItemR(row, ptr, "use_occlusion", 0, NULL, ICON_NONE); @@ -4356,32 +4356,32 @@ static void draw_actuator_steering(uiLayout *layout, PointerRNA *ptr) uiItemR(layout, ptr, "target", 0, NULL, 0); uiItemR(layout, ptr, "navmesh", 0, NULL, 0); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "distance", 0, NULL, 0); uiItemR(row, ptr, "velocity", 0, NULL, 0); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "acceleration", 0, NULL, 0); uiItemR(row, ptr, "turn_speed", 0, NULL, 0); - row = uiLayoutRow(layout, 0); - col = uiLayoutColumn(row, 0); + row = uiLayoutRow(layout, FALSE); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "facing", 0, NULL, 0); - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "facing_axis", 0, NULL, 0); if (!RNA_boolean_get(ptr, "facing")) { - uiLayoutSetActive(col, 0); + uiLayoutSetActive(col, FALSE); } - col = uiLayoutColumn(row, 0); + col = uiLayoutColumn(row, FALSE); uiItemR(col, ptr, "normal_up", 0, NULL, 0); if (!RNA_pointer_get(ptr, "navmesh").data) { - uiLayoutSetActive(col, 0); + uiLayoutSetActive(col, FALSE); } - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "self_terminated", 0, NULL, 0); if (RNA_enum_get(ptr, "mode")==ACT_STEERING_PATHFOLLOWING) { uiItemR(row, ptr, "update_period", 0, NULL, 0); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); } uiItemR(row, ptr, "show_visualization", 0, NULL, 0); } @@ -4522,7 +4522,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) xco= 420; yco= 170; width= 300; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ @@ -4545,32 +4545,32 @@ static void logic_buttons_new(bContext *C, ARegion *ar) RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); - split= uiLayoutSplit(layout, 0.05, 0); + split = uiLayoutSplit(layout, 0.05f, FALSE); uiItemR(split, &settings_ptr, "show_state_panel", UI_ITEM_R_NO_BG, "", ICON_DISCLOSURE_TRI_RIGHT); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide controllers"); if (ob == act_ob) uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", ICON_NONE); if (RNA_boolean_get(&settings_ptr, "show_state_panel")) { - box= uiLayoutBox(layout); - split= uiLayoutSplit(box, 0.2, 0); + box = uiLayoutBox(layout); + split = uiLayoutSplit(box, 0.2f, FALSE); - col= uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiItemL(col, "Visible", ICON_NONE); uiItemL(col, "Initial", ICON_NONE); - subsplit= uiLayoutSplit(split, 0.85, 0); - col= uiLayoutColumn(subsplit, 0); - row= uiLayoutRow(col, 0); + subsplit = uiLayoutSplit(split, 0.85f, FALSE); + col = uiLayoutColumn(subsplit, FALSE); + row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, RNA_boolean_get(&settings_ptr, "use_all_states") == FALSE); uiTemplateLayers(row, &settings_ptr, "states_visible", &settings_ptr, "used_states", 0); - row= uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiTemplateLayers(row, &settings_ptr, "states_initial", &settings_ptr, "used_states", 0); - col= uiLayoutColumn(subsplit, 0); + col = uiLayoutColumn(subsplit, FALSE); uiItemR(col, &settings_ptr, "use_all_states", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(col, &settings_ptr, "show_debug_state", 0, "", ICON_NONE); } @@ -4589,18 +4589,18 @@ static void logic_buttons_new(bContext *C, ARegion *ar) continue; /* use two nested splits to align inlinks/links properly */ - split = uiLayoutSplit(layout, 0.05, 0); + split = uiLayoutSplit(layout, 0.05f, FALSE); /* put inlink button to the left */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT); uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, cont, LINK_CONTROLLER, 0, 0, 0, ""); - //col = uiLayoutColumn(split, 1); + //col = uiLayoutColumn(split, TRUE); /* nested split for middle and right columns */ - subsplit = uiLayoutSplit(split, 0.95, 0); + subsplit = uiLayoutSplit(split, 0.95f, FALSE); - col = uiLayoutColumn(subsplit, 1); + col = uiLayoutColumn(subsplit, TRUE); uiLayoutSetContextPointer(col, "controller", &ptr); /* should make UI template for controller header.. function will do for now */ @@ -4612,7 +4612,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* put link button to the right */ - col = uiLayoutColumn(subsplit, 0); + col = uiLayoutColumn(subsplit, FALSE); uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_LEFT); but = uiDefIconBut(block, LINK, 0, ICON_LINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR); @@ -4625,7 +4625,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) xco= 10; yco= 170; width= 340; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ @@ -4643,7 +4643,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* only draw the sensor common header if "use_visible" */ if ((ob->scavisflag & OB_VIS_SENS) == 0) continue; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors"); if (ob == act_ob) uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", "Add Sensor", ICON_NONE); @@ -4667,8 +4667,8 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* make as visible, for move operator */ sens->flag |= SENS_VISIBLE; - split = uiLayoutSplit(layout, 0.95, 0); - col = uiLayoutColumn(split, 1); + split = uiLayoutSplit(layout, 0.95f, FALSE); + col = uiLayoutColumn(split, TRUE); uiLayoutSetContextPointer(col, "sensor", &ptr); /* should make UI template for sensor header.. function will do for now */ @@ -4678,7 +4678,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) draw_brick_sensor(col, &ptr, C); /* put link button to the right */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); /* use old-school uiButtons for links for now */ but = uiDefIconBut(block, LINK, 0, ICON_LINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); uiSetButLink(but, NULL, (void ***)&(sens->links), &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER); @@ -4691,7 +4691,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) xco= 800; yco= 170; width= 340; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefBlockBut(block, actuator_menu, NULL, "Actuators", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ @@ -4709,7 +4709,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* only draw the actuator common header if "use_visible" */ if ( (ob->scavisflag & OB_VIS_ACT) == 0) continue; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide actuators"); if (ob == act_ob) uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", "Add Actuator", ICON_NONE); @@ -4734,13 +4734,13 @@ static void logic_buttons_new(bContext *C, ARegion *ar) /* make as visible, for move operator */ act->flag |= ACT_VISIBLE; - split = uiLayoutSplit(layout, 0.05, 0); + split = uiLayoutSplit(layout, 0.05f, FALSE); /* put inlink button to the left */ - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiDefIconBut(block, INLINK, 0, ICON_INLINK, 0, 0, UI_UNIT_X, UI_UNIT_Y, act, LINK_ACTUATOR, 0, 0, 0, ""); - col = uiLayoutColumn(split, 1); + col = uiLayoutColumn(split, TRUE); uiLayoutSetContextPointer(col, "actuator", &ptr); /* should make UI template for actuator header.. function will do for now */ diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 63e518e5aaa..804d44ba720 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -252,19 +252,19 @@ static void nla_panel_animdata(const bContext *C, Panel *pa) /* Active Action Properties ------------------------------------- */ /* action */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiTemplateID(row, (bContext *)C, &adt_ptr, "action", "ACTION_OT_new", NULL, NULL /*"ACTION_OT_unlink"*/); // XXX: need to make these operators /* extrapolation */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &adt_ptr, "action_extrapolation", 0, NULL, ICON_NONE); /* blending */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &adt_ptr, "action_blend_type", 0, NULL, ICON_NONE); /* influence */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &adt_ptr, "action_influence", 0, NULL, ICON_NONE); } @@ -284,7 +284,7 @@ static void nla_panel_track(const bContext *C, Panel *pa) uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); /* Info - Active NLA-Context:Track ---------------------- */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &nlt_ptr, "name", 0, NULL, ICON_NLA); } @@ -305,12 +305,12 @@ static void nla_panel_properties(const bContext *C, Panel *pa) /* Strip Properties ------------------------------------- */ /* strip type */ - row = uiLayoutColumn(layout, 1); + row = uiLayoutColumn(layout, TRUE); uiItemR(row, &strip_ptr, "name", 0, NULL, ICON_NLA); // XXX icon? uiItemR(row, &strip_ptr, "type", 0, NULL, ICON_NONE); /* strip extents */ - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiItemL(column, "Strip Extents:", ICON_NONE); uiItemR(column, &strip_ptr, "frame_start", 0, NULL, ICON_NONE); uiItemR(column, &strip_ptr, "frame_end", 0, NULL, ICON_NONE); @@ -324,27 +324,27 @@ static void nla_panel_properties(const bContext *C, Panel *pa) /* only show if allowed to... */ if (showEvalProps) { /* extrapolation */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE); /* blending */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE); /* blend in/out + autoblending * - blend in/out can only be set when autoblending is off */ - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence") == FALSE); uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle? - sub = uiLayoutColumn(column, 1); + sub = uiLayoutColumn(column, TRUE); uiLayoutSetActive(sub, RNA_boolean_get(&strip_ptr, "use_auto_blend") == FALSE); uiItemR(sub, &strip_ptr, "blend_in", 0, NULL, ICON_NONE); uiItemR(sub, &strip_ptr, "blend_out", 0, NULL, ICON_NONE); /* settings */ - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); uiItemL(column, "Playback Settings:", ICON_NONE); uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE); @@ -370,19 +370,19 @@ static void nla_panel_actclip(const bContext *C, Panel *pa) /* Strip Properties ------------------------------------- */ /* action pointer */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &strip_ptr, "action", 0, NULL, ICON_ACTION); /* action extents */ // XXX custom names were used here (to avoid the prefixes)... probably not necessary in future? - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiItemL(column, "Action Extents:", ICON_NONE); uiItemR(column, &strip_ptr, "action_frame_start", 0, "Start Frame", ICON_NONE); uiItemR(column, &strip_ptr, "action_frame_end", 0, "End Frame", ICON_NONE); uiItemO(column, NULL, ICON_NONE, "NLA_OT_action_sync_length"); /* action usage */ - column = uiLayoutColumn(layout, 1); + column = uiLayoutColumn(layout, TRUE); uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_time") == FALSE); uiItemL(column, "Playback Settings:", ICON_NONE); uiItemR(column, &strip_ptr, "scale", 0, NULL, ICON_NONE); @@ -404,19 +404,19 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa) block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, TRUE); uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_influence")); uiItemR(sub, &strip_ptr, "influence", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); - sub = uiLayoutRow(col, 0); + col = uiLayoutColumn(layout, TRUE); + sub = uiLayoutRow(col, FALSE); uiItemR(sub, &strip_ptr, "use_animated_time", 0, NULL, ICON_NONE); uiItemR(sub, &strip_ptr, "use_animated_time_cyclic", 0, NULL, ICON_NONE); - sub = uiLayoutRow(col, 0); + sub = uiLayoutRow(col, FALSE); uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_time")); uiItemR(sub, &strip_ptr, "strip_time", 0, NULL, ICON_NONE); } @@ -440,7 +440,7 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa) /* 'add modifier' button at top of panel */ { - row = uiLayoutRow(pa->layout, 0); + row = uiLayoutRow(pa->layout, FALSE); block = uiLayoutGetBlock(row); // XXX for now, this will be a operator button which calls a temporary 'add modifier' operator @@ -449,14 +449,14 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa) TIP_("Adds a new F-Modifier for the active NLA Strip")); /* copy/paste (as sub-row)*/ - row = uiLayoutRow(row, 1); + row = uiLayoutRow(row, TRUE); uiItemO(row, "", ICON_COPYDOWN, "NLA_OT_fmodifier_copy"); uiItemO(row, "", ICON_PASTEDOWN, "NLA_OT_fmodifier_paste"); } /* draw each modifier */ for (fcm = strip->modifiers.first; fcm; fcm = fcm->next) { - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.id.data, &strip->modifiers, fcm); } diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 7eb0f676707..92f014fd804 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -89,7 +89,7 @@ static void nla_action_get_color(AnimData *adt, bAction *act, float color[4]) UI_GetThemeColor4fv(TH_ANIM_ACTIVE, color); } else { - /* greyish-red color */ + /* grayish-red color */ UI_GetThemeColor4fv(TH_ANIM_INACTIVE, color); } } @@ -217,7 +217,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc) { const float yheight = ymaxc - yminc; - /* drawing color is simply a light-grey */ + /* drawing color is simply a light-gray */ // TODO: is this color suitable? // XXX nasty hacked color for now... which looks quite bad too... glColor3f(0.7f, 0.7f, 0.7f); @@ -480,7 +480,7 @@ static void nla_draw_strip_text(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, i static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, View2D *v2d, float UNUSED(yminc), float ymaxc) { const float ytol = 1.0f; /* small offset to vertical positioning of text, for legibility */ - const char col[4] = {220, 220, 220, 255}; /* light grey */ + const char col[4] = {220, 220, 220, 255}; /* light gray */ char numstr[32] = ""; @@ -551,7 +551,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* draw each strip in the track (if visible) */ for (strip = nlt->strips.first, index = 1; strip; strip = strip->next, index++) { if (BKE_nlastrip_within_bounds(strip, v2d->cur.xmin, v2d->cur.xmax)) { - /* draw the visualisation of the strip */ + /* draw the visualization of the strip */ nla_draw_strip(snla, adt, nlt, strip, v2d, yminc, ymaxc); /* add the text for this strip to the cache */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 1ac069c772e..daab0ce0f5f 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -140,7 +140,7 @@ static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v) block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); - layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y + 2, args->width, NODE_DY, UI_GetStyle()), 0); + layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y + 2, args->width, NODE_DY, UI_GetStyle()), FALSE); uiItemR(layout, &args->ptr, "default_value", UI_ITEM_R_EXPAND, "", ICON_NONE); @@ -291,7 +291,7 @@ static void node_buts_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr prop = RNA_struct_find_property(ptr, "outputs"); RNA_property_collection_lookup_int(ptr, prop, 0, &sockptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiTemplateColorWheel(col, &sockptr, "default_value", 1, 0, 0, 0); uiItemR(col, &sockptr, "default_value", 0, "", ICON_NONE); } @@ -302,7 +302,7 @@ static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA bNodeTree *ntree = (bNodeTree *)ptr->id.data; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE); if (ntree->type == NTREE_COMPOSIT) uiItemR(row, ptr, "use_alpha", 0, "", ICON_IMAGE_RGB_ALPHA); @@ -325,7 +325,7 @@ static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt uiTemplateCurveMapping(layout, ptr, "curve", 's', 0, 0); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "frame_start", 0, IFACE_("Sta"), ICON_NONE); uiItemR(row, ptr, "frame_end", 0, IFACE_("End"), ICON_NONE); } @@ -340,25 +340,30 @@ static void node_buts_curvevec(uiLayout *layout, bContext *UNUSED(C), PointerRNA uiTemplateCurveMapping(layout, ptr, "mapping", 'v', 0, 0); } -static float *_sample_col = NULL; // bad bad, 2.5 will do better? -#if 0 -static void node_curvemap_sample(float *col) +static float _sample_col[4]; // bad bad, 2.5 will do better? +#define SAMPLE_FLT_ISNONE FLT_MAX +void ED_node_sample_set(const float col[4]) { - _sample_col = col; + if (col) { + copy_v4_v4(_sample_col, col); + } + else { + copy_v4_fl(_sample_col, SAMPLE_FLT_ISNONE); + } } -#endif static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { bNode *node = ptr->data; CurveMapping *cumap = node->storage; - if (_sample_col) { + if (_sample_col[0] != SAMPLE_FLT_ISNONE) { cumap->flag |= CUMA_DRAW_SAMPLE; copy_v3_v3(cumap->sample, _sample_col); } - else + else { cumap->flag &= ~CUMA_DRAW_SAMPLE; + } uiTemplateCurveMapping(layout, ptr, "mapping", 'c', 0, 0); } @@ -1189,7 +1194,7 @@ static void node_common_set_butfunc(bNodeType *ntype) /* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */ -static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imaptr, PointerRNA *iuserptr) +static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr, PointerRNA *imaptr, PointerRNA *iuserptr) { uiLayout *col; int source; @@ -1197,7 +1202,7 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imap if (!imaptr->data) return; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, imaptr, "source", 0, "", ICON_NONE); @@ -1208,25 +1213,24 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *imap Scene *scene = CTX_data_scene(C); ImageUser *iuser = iuserptr->data; char numstr[32]; - const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0); + const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0, NULL); BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr); uiItemL(layout, numstr, ICON_NONE); } if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { - col = uiLayoutColumn(layout, 1); - uiItemR(col, iuserptr, "frame_duration", 0, NULL, ICON_NONE); - uiItemR(col, iuserptr, "frame_start", 0, NULL, ICON_NONE); - uiItemR(col, iuserptr, "frame_offset", 0, NULL, ICON_NONE); - uiItemR(col, iuserptr, "use_cyclic", 0, NULL, ICON_NONE); - uiItemR(col, iuserptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); + col = uiLayoutColumn(layout, TRUE); + uiItemR(col, ptr, "frame_duration", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "frame_start", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "frame_offset", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "use_cyclic", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); } - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); if (RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER) - uiItemR(col, iuserptr, "layer", 0, NULL, ICON_NONE); - + uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE); } static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -1238,7 +1242,7 @@ static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA if (!node->id) return; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "use_diffuse", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_specular", 0, NULL, ICON_NONE); uiItemR(col, ptr, "invert_normal", 0, NULL, ICON_NONE); @@ -1249,22 +1253,22 @@ static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), Poin uiLayout *row; uiItemL(layout, IFACE_("Location:"), ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "translation", 0, "", ICON_NONE); uiItemL(layout, IFACE_("Rotation:"), ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "rotation", 0, "", ICON_NONE); uiItemL(layout, IFACE_("Scale:"), ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "scale", 0, "", ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "use_min", 0, "Min", ICON_NONE); uiItemR(row, ptr, "min", 0, "", ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "use_max", 0, "Max", ICON_NONE); uiItemR(row, ptr, "max", 0, "", ICON_NONE); } @@ -1279,7 +1283,7 @@ static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA PointerRNA obptr = CTX_data_pointer_get(C, "active_object"); uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) { PointerRNA dataptr = RNA_pointer_get(&obptr, "data"); @@ -1306,7 +1310,10 @@ static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL); uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE); - node_buts_image_user(layout, C, &imaptr, &iuserptr); + /* note: image user properties used directly here, unlike compositor image node, + * which redefines them in the node struct RNA to get proper updates. + */ + node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr); } static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -1318,7 +1325,7 @@ static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, Poin uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE); uiItemR(layout, ptr, "projection", 0, "", ICON_NONE); - node_buts_image_user(layout, C, &imaptr, &iuserptr); + node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr); } static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -1451,7 +1458,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * imaptr = RNA_pointer_get(ptr, "image"); RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr); - node_buts_image_user(layout, C, &imaptr, &iuserptr); + node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr); } static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -1471,8 +1478,8 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point if (!node->id) return; - col = uiLayoutColumn(layout, 0); - row = uiLayoutRow(col, 0); + col = uiLayoutColumn(layout, FALSE); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "layer", 0, "", ICON_NONE); prop = RNA_struct_find_property(ptr, "layer"); @@ -1494,7 +1501,7 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point { uiLayout *col, *row; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "filter_type", 0, "", ICON_NONE); if (RNA_enum_get(ptr, "filter_type") != R_FILTER_FAST_GAUSS) { @@ -1506,15 +1513,15 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point if (RNA_boolean_get(ptr, "use_relative")) { uiItemL(col, IFACE_("Aspect Correction"), 0); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "aspect_correction", UI_ITEM_R_EXPAND, NULL, 0); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "factor_x", 0, IFACE_("X"), ICON_NONE); uiItemR(col, ptr, "factor_y", 0, IFACE_("Y"), ICON_NONE); } else { - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "size_x", 0, IFACE_("X"), ICON_NONE); uiItemR(col, ptr, "size_y", 0, IFACE_("Y"), ICON_NONE); } @@ -1527,14 +1534,14 @@ static void node_composit_buts_dblur(uiLayout *layout, bContext *UNUSED(C), Poin uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_wrap", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Center:"), ICON_NONE); uiItemR(col, ptr, "center_x", 0, IFACE_("X"), ICON_NONE); uiItemR(col, ptr, "center_y", 0, IFACE_("Y"), ICON_NONE); uiItemS(layout); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "distance", 0, NULL, ICON_NONE); uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE); @@ -1548,7 +1555,7 @@ static void node_composit_buts_bilateralblur(uiLayout *layout, bContext *UNUSED( { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "iterations", 0, NULL, ICON_NONE); uiItemR(col, ptr, "sigma_color", 0, NULL, ICON_NONE); uiItemR(col, ptr, "sigma_space", 0, NULL, ICON_NONE); @@ -1558,26 +1565,26 @@ static void node_composit_buts_defocus(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *sub, *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemL(col, IFACE_("Bokeh Type:"), ICON_NONE); uiItemR(col, ptr, "bokeh", 0, "", ICON_NONE); uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_gamma_correction", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_zbuffer") == TRUE); uiItemR(col, ptr, "f_stop", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "use_preview", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "use_zbuffer", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 0); + sub = uiLayoutColumn(col, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_zbuffer") == FALSE); uiItemR(sub, ptr, "z_scale", 0, NULL, ICON_NONE); } @@ -1617,7 +1624,7 @@ static void node_composit_buts_tonemap(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "tonemap_type", 0, "", ICON_NONE); if (RNA_enum_get(ptr, "tonemap_type") == 0) { uiItemR(col, ptr, "key", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1636,10 +1643,10 @@ static void node_composit_buts_lensdist(uiLayout *layout, bContext *UNUSED(C), P { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "use_projector", 0, NULL, ICON_NONE); - col = uiLayoutColumn(col, 0); + col = uiLayoutColumn(col, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_projector") == FALSE); uiItemR(col, ptr, "use_jitter", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_fit", 0, NULL, ICON_NONE); @@ -1649,11 +1656,11 @@ static void node_composit_buts_vecblur(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "samples", 0, NULL, ICON_NONE); uiItemR(col, ptr, "factor", 0, IFACE_("Blur"), ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Speed:"), ICON_NONE); uiItemR(col, ptr, "speed_min", 0, IFACE_("Min"), ICON_NONE); uiItemR(col, ptr, "speed_max", 0, IFACE_("Max"), ICON_NONE); @@ -1678,7 +1685,7 @@ static void node_composit_buts_crop(uiLayout *layout, bContext *UNUSED(C), Point uiItemR(layout, ptr, "use_crop_size", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "relative", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); if (RNA_boolean_get(ptr, "relative")) { uiItemR(col, ptr, "rel_min_x", 0, IFACE_("Left"), ICON_NONE); uiItemR(col, ptr, "rel_max_x", 0, IFACE_("Right"), ICON_NONE); @@ -1697,8 +1704,8 @@ static void node_composit_buts_splitviewer(uiLayout *layout, bContext *UNUSED(C) { uiLayout *row, *col; - col = uiLayoutColumn(layout, 0); - row = uiLayoutRow(col, 0); + col = uiLayoutColumn(layout, FALSE); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(col, ptr, "factor", 0, NULL, ICON_NONE); } @@ -1707,7 +1714,7 @@ static void node_composit_buts_double_edge_mask(uiLayout *layout, bContext *UNUS { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemL(col, IFACE_("Inner Edge:"), ICON_NONE); uiItemR(col, ptr, "inner_mode", 0, "", ICON_NONE); @@ -1719,19 +1726,19 @@ static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), { uiLayout *sub, *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE); uiItemR(col, ptr, "size", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "use_min", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 0); + sub = uiLayoutColumn(col, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_min")); uiItemR(sub, ptr, "min", 0, "", ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "use_max", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 0); + sub = uiLayoutColumn(col, FALSE); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_max")); uiItemR(sub, ptr, "max", 0, "", ICON_NONE); } @@ -1740,7 +1747,7 @@ static void node_composit_buts_alphaover(uiLayout *layout, bContext *UNUSED(C), { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "use_premultiply", 0, NULL, ICON_NONE); uiItemR(col, ptr, "premul", 0, NULL, ICON_NONE); } @@ -1749,7 +1756,7 @@ static void node_composit_buts_zcombine(uiLayout *layout, bContext *UNUSED(C), P { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "use_alpha", 0, NULL, ICON_NONE); } @@ -1758,7 +1765,7 @@ static void node_composit_buts_hue_sat(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1768,8 +1775,13 @@ static void node_composit_buts_dilateerode(uiLayout *layout, bContext *UNUSED(C) { uiItemR(layout, ptr, "type", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE); - if (RNA_enum_get(ptr, "type") == CMP_NODE_DILATEERODE_DISTANCE_THRESH) { - uiItemR(layout, ptr, "edge", 0, NULL, ICON_NONE); + switch (RNA_enum_get(ptr, "type")) { + case CMP_NODE_DILATEERODE_DISTANCE_THRESH: + uiItemR(layout, ptr, "edge", 0, NULL, ICON_NONE); + break; + case CMP_NODE_DILATEERODE_DISTANCE_FEATHER: + uiItemR(layout, ptr, "falloff", 0, NULL, ICON_NONE); + break; } } @@ -1777,7 +1789,7 @@ static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } @@ -1786,10 +1798,10 @@ static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED { uiLayout *col, *row; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(layout, IFACE_("Color Space:"), ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1801,15 +1813,15 @@ static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C) uiLayout *row, *col; uiItemL(layout, IFACE_("Despill Channel:"), ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "limit_method") == 0) { uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } @@ -1826,11 +1838,11 @@ static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "tolerance", 0, NULL, ICON_NONE); uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); /*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now */ uiItemR(col, ptr, "gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); /*uiItemR(col, ptr, "shadow_adjust", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now*/ @@ -1840,7 +1852,7 @@ static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C) { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1851,20 +1863,20 @@ static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED( uiLayout *col, *row; uiItemL(layout, IFACE_("Color Space:"), ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "color_space", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemL(col, IFACE_("Key Channel:"), ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "matte_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "limit_method") == 0) { uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } @@ -1876,7 +1888,7 @@ static void node_composit_buts_luma_matte(uiLayout *layout, bContext *UNUSED(C), { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } @@ -1889,7 +1901,7 @@ static void node_composit_buts_map_uv(uiLayout *layout, bContext *UNUSED(C), Poi static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "index", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "use_smooth_mask", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE); } /* draw function for file output node sockets, displays only sub-path and format, no value button */ @@ -1904,7 +1916,7 @@ static void node_draw_input_file_output(const bContext *C, uiBlock *block, RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr); layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y + NODE_DY, width, 20, UI_GetStyle()); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); imfptr = RNA_pointer_get(&nodeptr, "format"); imtype = RNA_enum_get(&imfptr, "file_format"); @@ -1973,7 +1985,7 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C /* XXX collection lookup does not return the ID part of the pointer, setting this manually here */ active_input_ptr.id.data = ptr->id.data; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); op_ptr = uiItemFullO(row, "NODE_OT_output_file_move_active_socket", "", ICON_TRIA_UP, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&op_ptr, "direction", 1); op_ptr = uiItemFullO(row, "NODE_OT_output_file_move_active_socket", "", ICON_TRIA_DOWN, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); @@ -1982,30 +1994,30 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C if (active_input_ptr.data) { if (multilayer) { uiLayout *row, *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Layer:"), 0); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &active_input_ptr, "name", 0, "", 0); uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); } else { uiLayout *row, *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("File Path:"), 0); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &active_input_ptr, "path", 0, "", 0); uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); /* format details for individual files */ imfptr = RNA_pointer_get(&active_input_ptr, "format"); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemL(col, IFACE_("Format:"), 0); uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, 0); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == FALSE); uiTemplateImageSettings(col, &imfptr); } @@ -2034,7 +2046,7 @@ static void node_composit_buts_invert(uiLayout *layout, bContext *UNUSED(C), Poi { uiLayout *col; - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, ptr, "invert_rgb", 0, NULL, ICON_NONE); uiItemR(col, ptr, "invert_alpha", 0, NULL, ICON_NONE); } @@ -2057,39 +2069,39 @@ static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C if (RNA_enum_get(ptr, "correction_method") == 0) { - split = uiLayoutSplit(layout, 0, 0); - col = uiLayoutColumn(split, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "lift", 1, 1, 0, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "lift", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "gamma", 1, 1, 1, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "gamma", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "gain", 1, 1, 1, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "gain", 0, NULL, ICON_NONE); } else { - split = uiLayoutSplit(layout, 0, 0); - col = uiLayoutColumn(split, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "offset", 1, 1, 0, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "offset", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "power", 1, 1, 0, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "power", 0, NULL, ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); uiTemplateColorWheel(col, ptr, "slope", 1, 1, 0, 1); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, ptr, "slope", 0, NULL, ICON_NONE); } @@ -2124,6 +2136,17 @@ static void node_composit_buts_colorbalance_but(uiLayout *layout, bContext *UNUS static void node_composit_buts_huecorrect(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { + bNode *node = ptr->data; + CurveMapping *cumap = node->storage; + + if (_sample_col[0] != SAMPLE_FLT_ISNONE) { + cumap->flag |= CUMA_DRAW_SAMPLE; + copy_v3_v3(cumap->sample, _sample_col); + } + else { + cumap->flag &= ~CUMA_DRAW_SAMPLE; + } + uiTemplateCurveMapping(layout, ptr, "mapping", 'h', 0, 0); } @@ -2170,12 +2193,12 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE { uiLayout *row; - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "red", 0, NULL, ICON_NONE); uiItemR(row, ptr, "green", 0, NULL, ICON_NONE); uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, "", 0); uiItemL(row, IFACE_("Saturation"), 0); uiItemL(row, IFACE_("Contrast"), 0); @@ -2183,7 +2206,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemL(row, IFACE_("Gain"), 0); uiItemL(row, IFACE_("Lift"), 0); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, IFACE_("Master"), 0); uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2191,7 +2214,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "master_gain", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, IFACE_("Highlights"), 0); uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2199,7 +2222,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, IFACE_("Midtones"), 0); uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2207,7 +2230,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemL(row, IFACE_("Shadows"), 0); uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2215,7 +2238,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "midtones_start", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "midtones_end", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } @@ -2224,7 +2247,7 @@ static void node_composit_buts_colorcorrection_but(uiLayout *layout, bContext *U { uiLayout *row; - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "red", 0, NULL, ICON_NONE); uiItemR(row, ptr, "green", 0, NULL, ICON_NONE); uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE); @@ -2259,7 +2282,7 @@ static void node_composit_buts_colorcorrection_but(uiLayout *layout, bContext *U uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); uiItemR(row, ptr, "midtones_start", 0, NULL, ICON_NONE); uiItemR(row, ptr, "midtones_end", 0, NULL, ICON_NONE); } @@ -2273,11 +2296,11 @@ static void node_composit_buts_boxmask(uiLayout *layout, bContext *UNUSED(C), Po { uiLayout *row; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "x", 0, NULL, ICON_NONE); uiItemR(row, ptr, "y", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -2400,10 +2423,10 @@ void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode static void node_composit_buts_ellipsemask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "x", 0, NULL, ICON_NONE); uiItemR(row, ptr, "y", 0, NULL, ICON_NONE); - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -2417,7 +2440,7 @@ static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), uiItemR(layout, ptr, "tile_order", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "tile_order") == 0) { - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "center_x", 0, NULL, ICON_NONE); uiItemR(col, ptr, "center_y", 0, NULL, ICON_NONE); } @@ -2426,7 +2449,8 @@ static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *ptr) { uiTemplateID(layout, C, ptr, "mask", NULL, NULL, NULL); - uiItemR(layout, ptr, "smooth_mask", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_feather", 0, NULL, ICON_NONE); } @@ -2443,7 +2467,7 @@ static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, Point RNA_pointer_create(&clip->id, &RNA_MovieTracking, &clip->tracking, &tracking_ptr); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA); } } @@ -2460,6 +2484,8 @@ static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), Poi uiItemR(layout, ptr, "clip_black", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "clip_white", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "dilate_distance", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "feather_falloff", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "feather_distance", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "blur_post", 0, NULL, ICON_NONE); } @@ -2672,11 +2698,11 @@ static void node_texture_buts_bricks(uiLayout *layout, bContext *UNUSED(C), Poin { uiLayout *col; - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "offset", 0, IFACE_("Offset"), ICON_NONE); uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE); uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE); } @@ -2691,23 +2717,23 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe RNA_pointer_create(id, &RNA_Texture, tex, &tex_ptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); switch (tex->type) { case TEX_BLEND: uiItemR(col, &tex_ptr, "progression", 0, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "use_flip_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); break; case TEX_MARBLE: - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "marble_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_basis", 0, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE); break; @@ -2716,9 +2742,9 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe break; case TEX_STUCCI: - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "stucci_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); break; @@ -2726,18 +2752,18 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe case TEX_WOOD: uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); uiItemR(col, &tex_ptr, "wood_type", 0, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, !(RNA_enum_get(&tex_ptr, "wood_type") == TEX_BAND || RNA_enum_get(&tex_ptr, "wood_type") == TEX_RING)); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); break; case TEX_CLOUDS: uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "cloud_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, 0); + row = uiLayoutRow(col, FALSE); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(col, &tex_ptr, "noise_depth", UI_ITEM_R_EXPAND, IFACE_("Depth"), ICON_NONE); break; @@ -3294,40 +3320,62 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) do_triple = TRUE; } else { + int cycle = 0; + /* going to give issues once... */ if (link->tosock->flag & SOCK_UNAVAIL) return; if (link->fromsock->flag & SOCK_UNAVAIL) return; - /* a bit ugly... but thats how we detect the internal group links */ - if (!link->fromnode || !link->tonode) { - UI_ThemeColorBlend(TH_BACK, TH_WIRE, 0.5f); - do_shaded = FALSE; - } - else { - /* check cyclic */ - if ((link->fromnode->level >= link->tonode->level && link->tonode->level != 0xFFF) && (link->flag & NODE_LINK_VALID)) { - /* special indicated link, on drop-node */ - if (link->flag & NODE_LINKFLAG_HILITE) { - th_col1 = th_col2 = TH_ACTIVE; - } - else { - /* regular link */ - if (link->fromnode->flag & SELECT) - th_col1 = TH_EDGE_SELECT; - if (link->tonode->flag & SELECT) - th_col2 = TH_EDGE_SELECT; - } - do_shaded = TRUE; - do_triple = TRUE; - } + /* check cyclic */ + if (link->fromnode && link->tonode) + cycle = (link->fromnode->level < link->tonode->level || link->tonode->level == 0xFFF); + if (!cycle && (link->flag & NODE_LINK_VALID)) { + /* special indicated link, on drop-node */ + if (link->flag & NODE_LINKFLAG_HILITE) { + th_col1 = th_col2 = TH_ACTIVE; + } else { - th_col1 = TH_REDALERT; + /* regular link */ + if (link->fromnode && link->fromnode->flag & SELECT) + th_col1 = TH_EDGE_SELECT; + if (link->tonode && link->tonode->flag & SELECT) + th_col2 = TH_EDGE_SELECT; } + do_shaded = TRUE; + do_triple = TRUE; + } + else { + th_col1 = TH_REDALERT; } } node_draw_link_bezier(v2d, snode, link, th_col1, do_shaded, th_col2, do_triple, th_col3); // node_draw_link_straight(v2d, snode, link, th_col1, do_shaded, th_col2, do_triple, th_col3); } + +void drawnodesnap(View2D *v2d, const float cent[2], float size, NodeBorder border) +{ + glBegin(GL_LINES); + + if (border & (NODE_LEFT | NODE_RIGHT)) { + glVertex2f(cent[0], v2d->cur.ymin); + glVertex2f(cent[0], v2d->cur.ymax); + } + else { + glVertex2f(cent[0], cent[1] - size); + glVertex2f(cent[0], cent[1] + size); + } + + if (border & (NODE_TOP | NODE_BOTTOM)) { + glVertex2f(v2d->cur.xmin, cent[1]); + glVertex2f(v2d->cur.xmax, cent[1]); + } + else { + glVertex2f(cent[0] - size, cent[1]); + glVertex2f(cent[0] + size, cent[1]); + } + + glEnd(); +} diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c index f2ec2289ad1..bc4c391720a 100644 --- a/source/blender/editors/space_node/node_buttons.c +++ b/source/blender/editors/space_node/node_buttons.c @@ -100,7 +100,7 @@ static void active_node_panel(const bContext *C, Panel *pa) //else RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); - layout = uiLayoutColumn(pa->layout, 0); + layout = uiLayoutColumn(pa->layout, FALSE); uiLayoutSetContextPointer(layout, "node", &ptr); /* draw this node's name, etc. */ @@ -113,17 +113,17 @@ static void active_node_panel(const bContext *C, Panel *pa) uiItemS(layout); uiItemS(layout); - row = uiLayoutRow(layout, 0); + row = uiLayoutRow(layout, FALSE); - col = uiLayoutColumn(row, 1); + col = uiLayoutColumn(row, TRUE); uiItemM(col, (bContext *)C, "NODE_MT_node_color_presets", NULL, 0); uiItemR(col, &ptr, "use_custom_color", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); - sub = uiLayoutRow(col, 0); + sub = uiLayoutRow(col, FALSE); if (!(node->flag & NODE_CUSTOM_COLOR)) uiLayoutSetEnabled(sub, 0); uiItemR(sub, &ptr, "color", 0, "", 0); - col = uiLayoutColumn(row, 1); + col = uiLayoutColumn(row, TRUE); uiItemO(col, "", ICON_ZOOMIN, "node.node_color_preset_add"); opptr = uiItemFullO(col, "node.node_color_preset_add", "", ICON_ZOOMOUT, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_boolean_set(&opptr, "remove_active", 1); @@ -164,7 +164,7 @@ static void node_sockets_panel(const bContext *C, Panel *pa) for (sock=node->inputs.first; sock; sock=sock->next) { BLI_snprintf(name, sizeof(name), "%s:", sock->name); - split = uiLayoutSplit(layout, 0.35f, 0); + split = uiLayoutSplit(layout, 0.35f, FALSE); uiItemL(split, name, ICON_NONE); uiTemplateNodeLink(split, ntree, node, sock); } diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index c65bbd6e15f..65646c855b7 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -65,6 +65,7 @@ #include "ED_node.h" #include "ED_gpencil.h" +#include "ED_space_api.h" #include "UI_interface.h" #include "UI_interface_icons.h" @@ -723,6 +724,12 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN if (node->flag & NODE_MUTED) UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); + if (ntree->type == NTREE_COMPOSIT && (snode->flag&SNODE_SHOW_HIGHLIGHT)) { + if (node->highlight) { + UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f); + node->highlight = 0; + } + } uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); uiRoundBox(rct->xmin, rct->ymax-NODE_DY, rct->xmax, rct->ymax, BASIS_RAD); @@ -804,7 +811,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN glDisable(GL_BLEND); /* outline active and selected emphasis */ - if ( node->flag & (NODE_ACTIVE|SELECT) ) { + if ( node->flag & (NODE_ACTIVE|SELECT)) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -861,7 +868,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN node->block= NULL; } -static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, bNode *node) +static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node) { bNodeSocket *sock; rctf *rct= &node->totr; @@ -878,10 +885,18 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b UI_ThemeColor(color_id); if (node->flag & NODE_MUTED) UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); + + if (ntree->type == NTREE_COMPOSIT && (snode->flag&SNODE_SHOW_HIGHLIGHT)) { + if (node->highlight) { + UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f); + node->highlight = 0; + } + } + uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); /* outline active and selected emphasis */ - if ( node->flag & (NODE_ACTIVE|SELECT) ) { + if ( node->flag & (NODE_ACTIVE|SELECT)) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -1004,7 +1019,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode) void node_draw_default(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node) { if (node->flag & NODE_HIDDEN) - node_draw_hidden(C, ar, snode, node); + node_draw_hidden(C, ar, snode, ntree, node); else node_draw_basis(C, ar, snode, ntree, node); } @@ -1087,6 +1102,8 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) //uiFreeBlocksWin(&sa->uiblocks, sa->win); + ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); + /* only set once */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_MAP1_VERTEX_3); @@ -1095,7 +1112,9 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) snode->aspect= (v2d->cur.xmax - v2d->cur.xmin)/((float)ar->winx); // XXX snode->curfont= uiSetCurFont_ext(snode->aspect); - UI_view2d_constant_grid_draw(v2d); + /* grid */ + UI_view2d_multi_grid_draw(v2d, 25.0f, 5, 2); + /* backdrop */ draw_nodespace_back_pix(ar, snode, color_manage); @@ -1137,6 +1156,8 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); + ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); + /* draw grease-pencil ('canvas' strokes) */ if (snode->nodetree) draw_gpencil_view2d(C, 1); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 81e375f26bc..9a6906c43bc 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -120,7 +120,7 @@ typedef struct CompoJob { /* called by compo, only to check job 'stop' value */ static int compo_breakjob(void *cjv) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; return *(cj->stop); } @@ -128,14 +128,14 @@ static int compo_breakjob(void *cjv) /* called by compo, wmJob sends notifier */ static void compo_redrawjob(void *cjv, char *UNUSED(str)) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; *(cj->do_update) = TRUE; } static void compo_freejob(void *cjv) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; if (cj->localtree) { ntreeLocalMerge(cj->localtree, cj->ntree); @@ -147,22 +147,22 @@ static void compo_freejob(void *cjv) * sliding buttons doesn't frustrate */ static void compo_initjob(void *cjv) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; - cj->localtree= ntreeLocalize(cj->ntree); + cj->localtree = ntreeLocalize(cj->ntree); } /* called before redraw notifiers, it moves finished previews over */ static void compo_updatejob(void *cjv) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; ntreeLocalSync(cj->localtree, cj->ntree); } static void compo_progressjob(void *cjv, float progress) { - CompoJob *cj= cjv; + CompoJob *cj = cjv; *(cj->progress) = progress; } @@ -171,49 +171,49 @@ static void compo_progressjob(void *cjv, float progress) /* only this runs inside thread */ static void compo_startjob(void *cjv, short *stop, short *do_update, float *progress) { - CompoJob *cj= cjv; - bNodeTree *ntree= cj->localtree; + CompoJob *cj = cjv; + bNodeTree *ntree = cj->localtree; if (cj->scene->use_nodes == FALSE) return; - cj->stop= stop; - cj->do_update= do_update; - cj->progress= progress; - - ntree->test_break= compo_breakjob; - ntree->tbh= cj; - ntree->stats_draw= compo_redrawjob; - ntree->sdh= cj; - ntree->progress= compo_progressjob; - ntree->prh= cj; + cj->stop = stop; + cj->do_update = do_update; + cj->progress = progress; + + ntree->test_break = compo_breakjob; + ntree->tbh = cj; + ntree->stats_draw = compo_redrawjob; + ntree->sdh = cj; + ntree->progress = compo_progressjob; + ntree->prh = cj; // XXX BIF_store_spare(); - ntreeCompositExecTree(ntree, &cj->scene->r, 0, 1); /* 1 is do_previews */ + ntreeCompositExecTree(ntree, &cj->scene->r, 0, 1); /* 1 is do_previews */ - ntree->test_break= NULL; - ntree->stats_draw= NULL; - ntree->progress= NULL; + ntree->test_break = NULL; + ntree->stats_draw = NULL; + ntree->progress = NULL; } void snode_composite_job(const bContext *C, ScrArea *sa) { - SpaceNode *snode= sa->spacedata.first; + SpaceNode *snode = sa->spacedata.first; wmJob *steve; CompoJob *cj; - steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Compositing", WM_JOB_EXCL_RENDER|WM_JOB_PROGRESS); - cj= MEM_callocN(sizeof(CompoJob), "compo job"); + steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Compositing", WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS); + cj = MEM_callocN(sizeof(CompoJob), "compo job"); /* customdata for preview thread */ - cj->scene= CTX_data_scene(C); - cj->ntree= snode->nodetree; + cj->scene = CTX_data_scene(C); + cj->ntree = snode->nodetree; /* setup job */ WM_jobs_customdata(steve, cj, compo_freejob); - WM_jobs_timer(steve, 0.1, NC_SCENE, NC_SCENE|ND_COMPO_RESULT); + WM_jobs_timer(steve, 0.1, NC_SCENE, NC_SCENE | ND_COMPO_RESULT); WM_jobs_callbacks(steve, compo_startjob, compo_initjob, compo_updatejob, NULL); WM_jobs_start(CTX_wm_manager(C), steve); @@ -225,9 +225,9 @@ void snode_composite_job(const bContext *C, ScrArea *sa) /* operator poll callback */ static int composite_node_active(bContext *C) { - if ( ED_operator_node_active(C)) { - SpaceNode *snode= CTX_wm_space_node(C); - if (snode->treetype==NTREE_COMPOSIT) + if (ED_operator_node_active(C)) { + SpaceNode *snode = CTX_wm_space_node(C); + if (snode->treetype == NTREE_COMPOSIT) return 1; } return 0; @@ -239,7 +239,7 @@ static bNode *editnode_get_active(bNodeTree *ntree) bNode *node; /* check for edited group */ - for (node= ntree->nodes.first; node; node= node->next) + for (node = ntree->nodes.first; node; node = node->next) if (nodeGroupEditGet(node)) break; if (node) @@ -255,9 +255,9 @@ static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup) if (ntree == lookup) return 1; - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) if (node->type == NODE_GROUP && node->id) - if (has_nodetree((bNodeTree*)node->id, lookup)) + if (has_nodetree((bNodeTree *)node->id, lookup)) return 1; return 0; @@ -274,8 +274,8 @@ void snode_dag_update(bContext *C, SpaceNode *snode) Main *bmain = CTX_data_main(C); /* for groups, update all ID's using this */ - if (snode->edittree!=snode->nodetree) { - bNodeTreeType *tti= ntreeGetType(snode->edittree->type); + if (snode->edittree != snode->nodetree) { + bNodeTreeType *tti = ntreeGetType(snode->edittree->type); tti->foreach_nodetree(bmain, snode->edittree, snode_dag_update_group); } @@ -284,14 +284,14 @@ void snode_dag_update(bContext *C, SpaceNode *snode) void snode_notify(bContext *C, SpaceNode *snode) { - WM_event_add_notifier(C, NC_NODE|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_NODE | NA_EDITED, NULL); - if (snode->treetype==NTREE_SHADER) - WM_event_add_notifier(C, NC_MATERIAL|ND_NODES, snode->id); - else if (snode->treetype==NTREE_COMPOSIT) - WM_event_add_notifier(C, NC_SCENE|ND_NODES, snode->id); - else if (snode->treetype==NTREE_TEXTURE) - WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id); + if (snode->treetype == NTREE_SHADER) + WM_event_add_notifier(C, NC_MATERIAL | ND_NODES, snode->id); + else if (snode->treetype == NTREE_COMPOSIT) + WM_event_add_notifier(C, NC_SCENE | ND_NODES, snode->id); + else if (snode->treetype == NTREE_TEXTURE) + WM_event_add_notifier(C, NC_TEXTURE | ND_NODES, snode->id); } bNode *node_tree_get_editgroup(bNodeTree *nodetree) @@ -299,7 +299,7 @@ bNode *node_tree_get_editgroup(bNodeTree *nodetree) bNode *gnode; /* get the groupnode */ - for (gnode= nodetree->nodes.first; gnode; gnode= gnode->next) + for (gnode = nodetree->nodes.first; gnode; gnode = gnode->next) if (nodeGroupEditGet(gnode)) break; return gnode; @@ -316,11 +316,11 @@ void ED_node_shader_default(Scene *scene, ID *id) int output_type, shader_type; float color[3], strength = 1.0f; - ntree= ntreeAddTree("Shader Nodetree", NTREE_SHADER, 0); + ntree = ntreeAddTree("Shader Nodetree", NTREE_SHADER, 0); switch (GS(id->name)) { case ID_MA: { - Material *ma= (Material*)id; + Material *ma = (Material *)id; ma->nodetree = ntree; if (BKE_scene_use_new_shading_nodes(scene)) { @@ -333,22 +333,22 @@ void ED_node_shader_default(Scene *scene, ID *id) } copy_v3_v3(color, &ma->r); - strength= 0.0f; + strength = 0.0f; break; } case ID_WO: { - World *wo= (World*)id; + World *wo = (World *)id; wo->nodetree = ntree; output_type = SH_NODE_OUTPUT_WORLD; shader_type = SH_NODE_BACKGROUND; copy_v3_v3(color, &wo->horr); - strength= 1.0f; + strength = 1.0f; break; } case ID_LA: { - Lamp *la= (Lamp*)id; + Lamp *la = (Lamp *)id; la->nodetree = ntree; output_type = SH_NODE_OUTPUT_LAMP; @@ -356,9 +356,9 @@ void ED_node_shader_default(Scene *scene, ID *id) copy_v3_v3(color, &la->r); if (la->type == LA_LOCAL || la->type == LA_SPOT || la->type == LA_AREA) - strength= 100.0f; + strength = 100.0f; else - strength= 1.0f; + strength = 1.0f; break; } default: @@ -367,27 +367,27 @@ void ED_node_shader_default(Scene *scene, ID *id) } ntemp.type = output_type; - out= nodeAddNode(ntree, &ntemp); - out->locx= 300.0f; out->locy= 300.0f; + out = nodeAddNode(ntree, &ntemp); + out->locx = 300.0f; out->locy = 300.0f; ntemp.type = shader_type; - in= nodeAddNode(ntree, &ntemp); - in->locx= 10.0f; in->locy= 300.0f; + in = nodeAddNode(ntree, &ntemp); + in->locx = 10.0f; in->locy = 300.0f; nodeSetActive(ntree, in); /* only a link from color to color */ - fromsock= in->outputs.first; - tosock= out->inputs.first; + fromsock = in->outputs.first; + tosock = out->inputs.first; nodeAddLink(ntree, in, fromsock, out, tosock); /* default values */ if (BKE_scene_use_new_shading_nodes(scene)) { - sock= in->inputs.first; - copy_v3_v3(((bNodeSocketValueRGBA*)sock->default_value)->value, color); + sock = in->inputs.first; + copy_v3_v3(((bNodeSocketValueRGBA *)sock->default_value)->value, color); if (strength != 0.0f) { - sock= in->inputs.last; - ((bNodeSocketValueFloat*)sock->default_value)->value= strength; + sock = in->inputs.last; + ((bNodeSocketValueFloat *)sock->default_value)->value = strength; } } @@ -409,28 +409,28 @@ void ED_node_composit_default(Scene *sce) return; } - sce->nodetree= ntreeAddTree("Compositing Nodetree", NTREE_COMPOSIT, 0); + sce->nodetree = ntreeAddTree("Compositing Nodetree", NTREE_COMPOSIT, 0); sce->nodetree->chunksize = 256; sce->nodetree->edit_quality = NTREE_QUALITY_HIGH; sce->nodetree->render_quality = NTREE_QUALITY_HIGH; ntemp.type = CMP_NODE_COMPOSITE; - out= nodeAddNode(sce->nodetree, &ntemp); - out->locx= 300.0f; out->locy= 400.0f; - out->id= &sce->id; + out = nodeAddNode(sce->nodetree, &ntemp); + out->locx = 300.0f; out->locy = 400.0f; + out->id = &sce->id; id_us_plus(out->id); ntemp.type = CMP_NODE_R_LAYERS; - in= nodeAddNode(sce->nodetree, &ntemp); - in->locx= 10.0f; in->locy= 400.0f; - in->id= &sce->id; + in = nodeAddNode(sce->nodetree, &ntemp); + in->locx = 10.0f; in->locy = 400.0f; + in->id = &sce->id; id_us_plus(in->id); nodeSetActive(sce->nodetree, in); /* links from color to color */ - fromsock= in->outputs.first; - tosock= out->inputs.first; + fromsock = in->outputs.first; + tosock = out->inputs.first; nodeAddLink(sce->nodetree, in, fromsock, out, tosock); ntreeUpdateTree(sce->nodetree); @@ -453,19 +453,19 @@ void ED_node_texture_default(Tex *tx) return; } - tx->nodetree= ntreeAddTree("Texture Nodetree", NTREE_TEXTURE, 0); + tx->nodetree = ntreeAddTree("Texture Nodetree", NTREE_TEXTURE, 0); ntemp.type = TEX_NODE_OUTPUT; - out= nodeAddNode(tx->nodetree, &ntemp); - out->locx= 300.0f; out->locy= 300.0f; + out = nodeAddNode(tx->nodetree, &ntemp); + out->locx = 300.0f; out->locy = 300.0f; ntemp.type = TEX_NODE_CHECKER; - in= nodeAddNode(tx->nodetree, &ntemp); - in->locx= 10.0f; in->locy= 300.0f; + in = nodeAddNode(tx->nodetree, &ntemp); + in->locx = 10.0f; in->locy = 300.0f; nodeSetActive(tx->nodetree, in); - fromsock= in->outputs.first; - tosock= out->inputs.first; + fromsock = in->outputs.first; + tosock = out->inputs.first; nodeAddLink(tx->nodetree, in, fromsock, out, tosock); ntreeUpdateTree(tx->nodetree); @@ -475,128 +475,128 @@ void ED_node_texture_default(Tex *tx) void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *treetype) { if (id) { - bNode *node= NULL; - short idtype= GS(id->name); + bNode *node = NULL; + short idtype = GS(id->name); if (idtype == ID_NT) { - *ntree= (bNodeTree*)id; - if (treetype) *treetype= (*ntree)->type; + *ntree = (bNodeTree *)id; + if (treetype) *treetype = (*ntree)->type; } else if (idtype == ID_MA) { - *ntree= ((Material*)id)->nodetree; - if (treetype) *treetype= NTREE_SHADER; + *ntree = ((Material *)id)->nodetree; + if (treetype) *treetype = NTREE_SHADER; } else if (idtype == ID_LA) { - *ntree= ((Lamp*)id)->nodetree; - if (treetype) *treetype= NTREE_SHADER; + *ntree = ((Lamp *)id)->nodetree; + if (treetype) *treetype = NTREE_SHADER; } else if (idtype == ID_WO) { - *ntree= ((World*)id)->nodetree; - if (treetype) *treetype= NTREE_SHADER; + *ntree = ((World *)id)->nodetree; + if (treetype) *treetype = NTREE_SHADER; } else if (idtype == ID_SCE) { - *ntree= ((Scene*)id)->nodetree; - if (treetype) *treetype= NTREE_COMPOSIT; + *ntree = ((Scene *)id)->nodetree; + if (treetype) *treetype = NTREE_COMPOSIT; } else if (idtype == ID_TE) { - *ntree= ((Tex*)id)->nodetree; - if (treetype) *treetype= NTREE_TEXTURE; + *ntree = ((Tex *)id)->nodetree; + if (treetype) *treetype = NTREE_TEXTURE; } else { - if (treetype) *treetype= 0; + if (treetype) *treetype = 0; return; } /* find editable group */ if (edittree) { if (*ntree) - for (node= (*ntree)->nodes.first; node; node= node->next) + for (node = (*ntree)->nodes.first; node; node = node->next) if (nodeGroupEditGet(node)) break; if (node && node->id) - *edittree= (bNodeTree *)node->id; + *edittree = (bNodeTree *)node->id; else - *edittree= *ntree; + *edittree = *ntree; } } else { - *ntree= NULL; - *edittree= NULL; - if (treetype) *treetype= 0; + *ntree = NULL; + *edittree = NULL; + if (treetype) *treetype = 0; } } /* Here we set the active tree(s), even called for each redraw now, so keep it fast :) */ void snode_set_context(SpaceNode *snode, Scene *scene) { - Object *ob= OBACT; + Object *ob = OBACT; - snode->id= snode->from= NULL; + snode->id = snode->from = NULL; - if (snode->treetype==NTREE_SHADER) { + if (snode->treetype == NTREE_SHADER) { /* need active object, or we allow pinning... */ if (snode->shaderfrom == SNODE_SHADER_OBJECT) { if (ob) { if (ob->type == OB_LAMP) { - snode->from= &ob->id; - snode->id= ob->data; + snode->from = &ob->id; + snode->id = ob->data; } else { - Material *ma= give_current_material(ob, ob->actcol); + Material *ma = give_current_material(ob, ob->actcol); if (ma) { - snode->from= &ob->id; - snode->id= &ma->id; + snode->from = &ob->id; + snode->id = &ma->id; } } } } else { /* SNODE_SHADER_WORLD */ if (scene->world) { - snode->from= NULL; - snode->id= &scene->world->id; + snode->from = NULL; + snode->id = &scene->world->id; } } } - else if (snode->treetype==NTREE_COMPOSIT) { - snode->id= &scene->id; + else if (snode->treetype == NTREE_COMPOSIT) { + snode->id = &scene->id; /* update output sockets based on available layers */ ntreeCompositForceHidden(scene->nodetree, scene); } - else if (snode->treetype==NTREE_TEXTURE) { - Tex *tx= NULL; + else if (snode->treetype == NTREE_TEXTURE) { + Tex *tx = NULL; - if (snode->texfrom==SNODE_TEX_OBJECT) { + if (snode->texfrom == SNODE_TEX_OBJECT) { if (ob) { - tx= give_current_object_texture(ob); + tx = give_current_object_texture(ob); if (ob->type == OB_LAMP) - snode->from= (ID*)ob->data; + snode->from = (ID *)ob->data; else - snode->from= (ID*)give_current_material(ob, ob->actcol); + snode->from = (ID *)give_current_material(ob, ob->actcol); /* from is not set fully for material nodes, should be ID + Node then */ - snode->id= &tx->id; + snode->id = &tx->id; } } - else if (snode->texfrom==SNODE_TEX_WORLD) { - tx= give_current_world_texture(scene->world); - snode->from= (ID *)scene->world; - snode->id= &tx->id; + else if (snode->texfrom == SNODE_TEX_WORLD) { + tx = give_current_world_texture(scene->world); + snode->from = (ID *)scene->world; + snode->id = &tx->id; } else { - struct Brush *brush= NULL; + struct Brush *brush = NULL; if (ob && (ob->mode & OB_MODE_SCULPT)) - brush= paint_brush(&scene->toolsettings->sculpt->paint); + brush = paint_brush(&scene->toolsettings->sculpt->paint); else - brush= paint_brush(&scene->toolsettings->imapaint.paint); + brush = paint_brush(&scene->toolsettings->imapaint.paint); if (brush) { - snode->from= (ID *)brush; - tx= give_current_brush_texture(brush); - snode->id= &tx->id; + snode->from = (ID *)brush; + tx = give_current_brush_texture(brush); + snode->id = &tx->id; } } } @@ -618,7 +618,7 @@ static void snode_update(SpaceNode *snode, bNode *node) nodeUpdate(snode->edittree, node); /* if inside group, tag entire group */ - gnode= node_tree_get_editgroup(snode->nodetree); + gnode = node_tree_get_editgroup(snode->nodetree); if (gnode) nodeUpdateID(snode->nodetree, gnode->id); } @@ -629,24 +629,24 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) nodeSetActive(ntree, node); - if (node->type!=NODE_GROUP) { - int was_output= (node->flag & NODE_DO_OUTPUT); + if (node->type != NODE_GROUP) { + int was_output = (node->flag & NODE_DO_OUTPUT); /* tree specific activate calls */ - if (ntree->type==NTREE_SHADER) { + if (ntree->type == NTREE_SHADER) { /* when we select a material, active texture is cleared, for buttons */ if (node->id && ELEM3(GS(node->id->name), ID_MA, ID_LA, ID_WO)) nodeClearActiveID(ntree, ID_TE); - if (node->type==SH_NODE_OUTPUT) { + if (node->type == SH_NODE_OUTPUT) { bNode *tnode; - for (tnode= ntree->nodes.first; tnode; tnode= tnode->next) - if ( tnode->type==SH_NODE_OUTPUT) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) + if (tnode->type == SH_NODE_OUTPUT) tnode->flag &= ~NODE_DO_OUTPUT; node->flag |= NODE_DO_OUTPUT; - if (was_output==0) + if (was_output == 0) ED_node_generic_update(bmain, ntree, node); } @@ -654,49 +654,49 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) if ((node->flag & NODE_ACTIVE_TEXTURE) && !was_active_texture) { Material *ma; - for (ma=bmain->mat.first; ma; ma=ma->id.next) + for (ma = bmain->mat.first; ma; ma = ma->id.next) if (ma->nodetree && ma->use_nodes && has_nodetree(ma->nodetree, ntree)) GPU_material_free(ma); WM_main_add_notifier(NC_IMAGE, NULL); } - WM_main_add_notifier(NC_MATERIAL|ND_NODES, node->id); + WM_main_add_notifier(NC_MATERIAL | ND_NODES, node->id); } - else if (ntree->type==NTREE_COMPOSIT) { + else if (ntree->type == NTREE_COMPOSIT) { /* make active viewer, currently only 1 supported... */ - if ( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { bNode *tnode; - for (tnode= ntree->nodes.first; tnode; tnode= tnode->next) - if ( ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) + if (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) tnode->flag &= ~NODE_DO_OUTPUT; node->flag |= NODE_DO_OUTPUT; - if (was_output==0) + if (was_output == 0) ED_node_generic_update(bmain, ntree, node); /* addnode() doesnt link this yet... */ - node->id= (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); } - else if (node->type==CMP_NODE_R_LAYERS) { + else if (node->type == CMP_NODE_R_LAYERS) { Scene *scene; - for (scene=bmain->scene.first; scene; scene=scene->id.next) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { if (scene->nodetree && scene->use_nodes && has_nodetree(scene->nodetree, ntree)) { - if (node->id==NULL || node->id==(ID *)scene) { - scene->r.actlay= node->custom1; + if (node->id == NULL || node->id == (ID *)scene) { + scene->r.actlay = node->custom1; } } } } - else if (node->type==CMP_NODE_COMPOSITE) { - if (was_output==0) { + else if (node->type == CMP_NODE_COMPOSITE) { + if (was_output == 0) { bNode *tnode; - for (tnode= ntree->nodes.first; tnode; tnode= tnode->next) - if ( tnode->type==CMP_NODE_COMPOSITE) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) + if (tnode->type == CMP_NODE_COMPOSITE) tnode->flag &= ~NODE_DO_OUTPUT; node->flag |= NODE_DO_OUTPUT; @@ -704,11 +704,11 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) } } } - else if (ntree->type==NTREE_TEXTURE) { + else if (ntree->type == NTREE_TEXTURE) { // XXX #if 0 if (node->id) - ; // XXX BIF_preview_changed(-1); + ; // XXX BIF_preview_changed(-1); // allqueue(REDRAWBUTSSHADING, 1); // allqueue(REDRAWIPO, 0); #endif @@ -745,7 +745,7 @@ static void edit_node_properties(wmOperatorType *ot) static int edit_node_invoke_properties(bContext *C, wmOperator *op) { if (!RNA_struct_property_is_set(op->ptr, "node")) { - bNode *node= CTX_data_pointer_get_type(C, "node", &RNA_Node).data; + bNode *node = CTX_data_pointer_get_type(C, "node", &RNA_Node).data; if (!node) return 0; else @@ -764,7 +764,7 @@ static int edit_node_invoke_properties(bContext *C, wmOperator *op) static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **rnode, bNodeSocket **rsock, int *rin_out) { bNode *node; - bNodeSocket *sock=NULL; + bNodeSocket *sock = NULL; char nodename[MAX_NAME]; int sockindex; int in_out; @@ -776,8 +776,8 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r sockindex = RNA_int_get(op->ptr, "socket"); switch (in_out) { - case SOCK_IN: sock = BLI_findlink(&node->inputs, sockindex); break; - case SOCK_OUT: sock = BLI_findlink(&node->outputs, sockindex); break; + case SOCK_IN: sock = BLI_findlink(&node->inputs, sockindex); break; + case SOCK_OUT: sock = BLI_findlink(&node->outputs, sockindex); break; } if (rnode) @@ -796,25 +796,25 @@ void snode_make_group_editable(SpaceNode *snode, bNode *gnode) bNode *node; /* make sure nothing has group editing on */ - for (node=snode->nodetree->nodes.first; node; node=node->next) + for (node = snode->nodetree->nodes.first; node; node = node->next) nodeGroupEditClear(node); - if (gnode==NULL) { + if (gnode == NULL) { /* with NULL argument we do a toggle */ - if (snode->edittree==snode->nodetree) - gnode= nodeGetActive(snode->nodetree); + if (snode->edittree == snode->nodetree) + gnode = nodeGetActive(snode->nodetree); } if (gnode) { snode->edittree = nodeGroupEditSet(gnode, 1); /* deselect all other nodes, so we can also do grabbing of entire subtree */ - for (node= snode->nodetree->nodes.first; node; node= node->next) + for (node = snode->nodetree->nodes.first; node; node = node->next) node_deselect(node); node_select(gnode); } else - snode->edittree= snode->nodetree; + snode->edittree = snode->nodetree; } static int node_group_edit_exec(bContext *C, wmOperator *UNUSED(op)) @@ -823,14 +823,14 @@ static int node_group_edit_exec(bContext *C, wmOperator *UNUSED(op)) ED_preview_kill_jobs(C); - if (snode->nodetree==snode->edittree) { + if (snode->nodetree == snode->edittree) { bNode *gnode = nodeGetActive(snode->edittree); snode_make_group_editable(snode, gnode); } else snode_make_group_editable(snode, NULL); - WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL); return OPERATOR_FINISHED; } @@ -841,9 +841,9 @@ static int node_group_edit_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e bNode *gnode; /* XXX callback? */ - if (snode->nodetree==snode->edittree) { + if (snode->nodetree == snode->edittree) { gnode = nodeGetActive(snode->edittree); - if (gnode && gnode->id && GS(gnode->id->name)==ID_NT && gnode->id->lib) { + if (gnode && gnode->id && GS(gnode->id->name) == ID_NT && gnode->id->lib) { uiPupMenuOkee(C, op->type->idname, "Make group local?"); return OPERATOR_CANCELLED; } @@ -865,7 +865,7 @@ void NODE_OT_group_edit(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ***************** Add Group Socket operator ************* */ @@ -873,10 +873,10 @@ void NODE_OT_group_edit(wmOperatorType *ot) static int node_group_socket_add_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); - int in_out= -1; - char name[MAX_NAME]= ""; - int type= SOCK_FLOAT; - bNodeTree *ngroup= snode->edittree; + int in_out = -1; + char name[MAX_NAME] = ""; + int type = SOCK_FLOAT; + bNodeTree *ngroup = snode->edittree; /* bNodeSocket *sock; */ /* UNUSED */ ED_preview_kill_jobs(C); @@ -914,7 +914,7 @@ void NODE_OT_group_socket_add(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output"); RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Group socket name"); @@ -926,9 +926,9 @@ void NODE_OT_group_socket_add(wmOperatorType *ot) static int node_group_socket_remove_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); - int index= -1; - int in_out= -1; - bNodeTree *ngroup= snode->edittree; + int index = -1; + int in_out = -1; + bNodeTree *ngroup = snode->edittree; bNodeSocket *sock; ED_preview_kill_jobs(C); @@ -943,7 +943,7 @@ static int node_group_socket_remove_exec(bContext *C, wmOperator *op) else return OPERATOR_CANCELLED; - sock = (bNodeSocket*)BLI_findlink(in_out==SOCK_IN ? &ngroup->inputs : &ngroup->outputs, index); + sock = (bNodeSocket *)BLI_findlink(in_out == SOCK_IN ? &ngroup->inputs : &ngroup->outputs, index); if (sock) { node_group_remove_socket(ngroup, sock, in_out); ntreeUpdateTree(ngroup); @@ -966,7 +966,7 @@ void NODE_OT_group_socket_remove(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output"); @@ -977,9 +977,9 @@ void NODE_OT_group_socket_remove(wmOperatorType *ot) static int node_group_socket_move_up_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); - int index= -1; - int in_out= -1; - bNodeTree *ngroup= snode->edittree; + int index = -1; + int in_out = -1; + bNodeTree *ngroup = snode->edittree; bNodeSocket *sock, *prev; ED_preview_kill_jobs(C); @@ -995,8 +995,8 @@ static int node_group_socket_move_up_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* swap */ - if (in_out==SOCK_IN) { - sock = (bNodeSocket*)BLI_findlink(&ngroup->inputs, index); + if (in_out == SOCK_IN) { + sock = (bNodeSocket *)BLI_findlink(&ngroup->inputs, index); prev = sock->prev; /* can't move up the first socket */ if (!prev) @@ -1006,8 +1006,8 @@ static int node_group_socket_move_up_exec(bContext *C, wmOperator *op) ngroup->update |= NTREE_UPDATE_GROUP_IN; } - else if (in_out==SOCK_OUT) { - sock = (bNodeSocket*)BLI_findlink(&ngroup->outputs, index); + else if (in_out == SOCK_OUT) { + sock = (bNodeSocket *)BLI_findlink(&ngroup->outputs, index); prev = sock->prev; /* can't move up the first socket */ if (!prev) @@ -1036,7 +1036,7 @@ void NODE_OT_group_socket_move_up(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output"); @@ -1047,9 +1047,9 @@ void NODE_OT_group_socket_move_up(wmOperatorType *ot) static int node_group_socket_move_down_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); - int index= -1; - int in_out= -1; - bNodeTree *ngroup= snode->edittree; + int index = -1; + int in_out = -1; + bNodeTree *ngroup = snode->edittree; bNodeSocket *sock, *next; ED_preview_kill_jobs(C); @@ -1065,8 +1065,8 @@ static int node_group_socket_move_down_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* swap */ - if (in_out==SOCK_IN) { - sock = (bNodeSocket*)BLI_findlink(&ngroup->inputs, index); + if (in_out == SOCK_IN) { + sock = (bNodeSocket *)BLI_findlink(&ngroup->inputs, index); next = sock->next; /* can't move down the last socket */ if (!next) @@ -1076,8 +1076,8 @@ static int node_group_socket_move_down_exec(bContext *C, wmOperator *op) ngroup->update |= NTREE_UPDATE_GROUP_IN; } - else if (in_out==SOCK_OUT) { - sock = (bNodeSocket*)BLI_findlink(&ngroup->outputs, index); + else if (in_out == SOCK_OUT) { + sock = (bNodeSocket *)BLI_findlink(&ngroup->outputs, index); next = sock->next; /* can't move down the last socket */ if (!next) @@ -1106,7 +1106,7 @@ void NODE_OT_group_socket_move_down(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, INT_MAX); RNA_def_enum(ot->srna, "in_out", socket_in_out_items, SOCK_IN, "Socket Type", "Input or Output"); @@ -1122,22 +1122,22 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) bNodeTree *ngroup, *wgroup; ListBase anim_basepaths = {NULL, NULL}; - ngroup= (bNodeTree *)gnode->id; - if (ngroup==NULL) return 0; + ngroup = (bNodeTree *)gnode->id; + if (ngroup == NULL) return 0; /* clear new pointers, set in copytree */ - for (node= ntree->nodes.first; node; node= node->next) - node->new_node= NULL; + for (node = ntree->nodes.first; node; node = node->next) + node->new_node = NULL; /* wgroup is a temporary copy of the NodeTree we're merging in * - all of wgroup's nodes are transferred across to their new home * - ngroup (i.e. the source NodeTree) is left unscathed */ - wgroup= ntreeCopyTree(ngroup); + wgroup = ntreeCopyTree(ngroup); /* add the nodes into the ntree */ - for (node= wgroup->nodes.first; node; node= nextn) { - nextn= node->next; + for (node = wgroup->nodes.first; node; node = nextn) { + nextn = node->next; /* keep track of this node's RNA "base" path (the part of the path identifying the node) * if the old nodetree has animation data which potentially covers this node @@ -1164,10 +1164,10 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } /* restore external links to and from the gnode */ - for (link= ntree->links.first; link; link= link->next) { - if (link->fromnode==gnode) { + for (link = ntree->links.first; link; link = link->next) { + if (link->fromnode == gnode) { if (link->fromsock->groupsock) { - bNodeSocket *gsock= link->fromsock->groupsock; + bNodeSocket *gsock = link->fromsock->groupsock; if (gsock->link) { if (gsock->link->fromnode) { /* NB: using the new internal copies here! the groupsock pointer still maps to the old tree */ @@ -1176,7 +1176,7 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } else { /* group output directly maps to group input */ - bNodeSocket *insock= node_group_find_input(gnode, gsock->link->fromsock); + bNodeSocket *insock = node_group_find_input(gnode, gsock->link->fromsock); if (insock->link) { link->fromnode = insock->link->fromnode; link->fromsock = insock->link->fromsock; @@ -1191,20 +1191,20 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } } /* remove internal output links, these are not used anymore */ - for (link=wgroup->links.first; link; link= linkn) { + for (link = wgroup->links.first; link; link = linkn) { linkn = link->next; if (!link->tonode) nodeRemLink(wgroup, link); } /* restore links from internal nodes */ - for (link= wgroup->links.first; link; link= link->next) { + for (link = wgroup->links.first; link; link = link->next) { /* indicates link to group input */ if (!link->fromnode) { /* NB: can't use find_group_node_input here, * because gnode sockets still point to the old tree! */ bNodeSocket *insock; - for (insock= gnode->inputs.first; insock; insock= insock->next) + for (insock = gnode->inputs.first; insock; insock = insock->next) if (insock->groupsock->new_sock == link->fromsock) break; if (insock->link) { @@ -1220,8 +1220,8 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } /* add internal links to the ntree */ - for (link= wgroup->links.first; link; link= linkn) { - linkn= link->next; + for (link = wgroup->links.first; link; link = linkn) { + linkn = link->next; BLI_remlink(&wgroup->links, link); BLI_addtail(&ntree->links, link); } @@ -1229,7 +1229,7 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) /* and copy across the animation, * note that the animation data's action can be NULL here */ if (wgroup->adt) { - LinkData *ld, *ldn=NULL; + LinkData *ld, *ldn = NULL; bAction *waction; /* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */ @@ -1271,15 +1271,15 @@ static int node_group_ungroup_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); /* are we inside of a group? */ - gnode= node_tree_get_editgroup(snode->nodetree); + gnode = node_tree_get_editgroup(snode->nodetree); if (gnode) snode_make_group_editable(snode, NULL); - gnode= nodeGetActive(snode->edittree); - if (gnode==NULL) + gnode = nodeGetActive(snode->edittree); + if (gnode == NULL) return OPERATOR_CANCELLED; - if (gnode->type!=NODE_GROUP) { + if (gnode->type != NODE_GROUP) { BKE_report(op->reports, RPT_WARNING, "Not a group"); return OPERATOR_CANCELLED; } @@ -1309,7 +1309,7 @@ void NODE_OT_group_ungroup(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Separate operator ********************** */ @@ -1322,19 +1322,19 @@ static int node_group_separate_selected(bNodeTree *ntree, bNode *gnode, int make bNodeTree *ngroup; ListBase anim_basepaths = {NULL, NULL}; - ngroup= (bNodeTree *)gnode->id; - if (ngroup==NULL) return 0; + ngroup = (bNodeTree *)gnode->id; + if (ngroup == NULL) return 0; /* deselect all nodes in the target tree */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) node_deselect(node); /* clear new pointers, set in nodeCopyNode */ - for (node= ngroup->nodes.first; node; node= node->next) - node->new_node= NULL; + for (node = ngroup->nodes.first; node; node = node->next) + node->new_node = NULL; /* add selected nodes into the ntree */ - for (node= ngroup->nodes.first; node; node= node_next) { + for (node = ngroup->nodes.first; node; node = node_next) { node_next = node->next; if (!(node->flag & NODE_SELECT)) continue; @@ -1375,7 +1375,7 @@ static int node_group_separate_selected(bNodeTree *ntree, bNode *gnode, int make } /* add internal links to the ntree */ - for (link= ngroup->links.first; link; link= link_next) { + for (link = ngroup->links.first; link; link = link_next) { int fromselect = (link->fromnode && (link->fromnode->flag & NODE_SELECT)); int toselect = (link->tonode && (link->tonode->flag & NODE_SELECT)); link_next = link->next; @@ -1400,7 +1400,7 @@ static int node_group_separate_selected(bNodeTree *ntree, bNode *gnode, int make /* and copy across the animation, * note that the animation data's action can be NULL here */ if (ngroup->adt) { - LinkData *ld, *ldn=NULL; + LinkData *ld, *ldn = NULL; /* now perform the moving */ BKE_animdata_separate_by_basepath(&ngroup->id, &ntree->id, &anim_basepaths); @@ -1428,7 +1428,7 @@ typedef enum eNodeGroupSeparateType { /* Operator Property */ EnumPropertyItem node_group_separate_types[] = { - {NODE_GS_COPY, "COPY", 0, "Copy", "Copy to parent node tree, keep group intact"}, + {NODE_GS_COPY, "COPY", 0, "Copy", "Copy to parent node tree, keep group intact"}, {NODE_GS_MOVE, "MOVE", 0, "Move", "Move to parent node tree, remove from group"}, {0, NULL, 0, NULL, NULL} }; @@ -1442,25 +1442,25 @@ static int node_group_separate_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); /* are we inside of a group? */ - gnode= node_tree_get_editgroup(snode->nodetree); + gnode = node_tree_get_editgroup(snode->nodetree); if (!gnode) { BKE_report(op->reports, RPT_WARNING, "Not inside node group"); return OPERATOR_CANCELLED; } switch (type) { - case NODE_GS_COPY: - if (!node_group_separate_selected(snode->nodetree, gnode, 1)) { - BKE_report(op->reports, RPT_WARNING, "Can't separate nodes"); - return OPERATOR_CANCELLED; - } - break; - case NODE_GS_MOVE: - if (!node_group_separate_selected(snode->nodetree, gnode, 0)) { - BKE_report(op->reports, RPT_WARNING, "Can't separate nodes"); - return OPERATOR_CANCELLED; - } - break; + case NODE_GS_COPY: + if (!node_group_separate_selected(snode->nodetree, gnode, 1)) { + BKE_report(op->reports, RPT_WARNING, "Can't separate nodes"); + return OPERATOR_CANCELLED; + } + break; + case NODE_GS_MOVE: + if (!node_group_separate_selected(snode->nodetree, gnode, 0)) { + BKE_report(op->reports, RPT_WARNING, "Can't separate nodes"); + return OPERATOR_CANCELLED; + } + break; } /* switch to parent tree */ @@ -1501,7 +1501,7 @@ void NODE_OT_group_separate(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", node_group_separate_types, NODE_GS_COPY, "Type", ""); } @@ -1513,7 +1513,7 @@ static bNode *visible_node(SpaceNode *snode, rctf *rct) { bNode *node; - for (node=snode->edittree->nodes.last; node; node=node->prev) { + for (node = snode->edittree->nodes.last; node; node = node->prev) { if (BLI_isect_rctf(&node->totr, rct, NULL)) break; } @@ -1529,17 +1529,17 @@ typedef struct NodeViewMove { static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - NodeViewMove *nvm= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + NodeViewMove *nvm = op->customdata; switch (event->type) { case MOUSEMOVE: - snode->xof -= (nvm->mvalo[0]-event->mval[0]); - snode->yof -= (nvm->mvalo[1]-event->mval[1]); - nvm->mvalo[0]= event->mval[0]; - nvm->mvalo[1]= event->mval[1]; + snode->xof -= (nvm->mvalo[0] - event->mval[0]); + snode->yof -= (nvm->mvalo[1] - event->mval[1]); + nvm->mvalo[0] = event->mval[0]; + nvm->mvalo[1] = event->mval[1]; /* prevent dragging image outside of the window and losing it! */ CLAMP(snode->xof, nvm->xmin, nvm->xmax); @@ -1554,9 +1554,9 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, wmEvent *event) case RIGHTMOUSE: MEM_freeN(nvm); - op->customdata= NULL; + op->customdata = NULL; - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_NODE, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_NODE, NULL); return OPERATOR_FINISHED; } @@ -1566,30 +1566,30 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, wmEvent *event) static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); NodeViewMove *nvm; Image *ima; ImBuf *ibuf; - int pad= 10; + int pad = 10; void *lock; - ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); - ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); + ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (ibuf == NULL) { BKE_image_release_ibuf(ima, lock); return OPERATOR_CANCELLED; } - nvm= MEM_callocN(sizeof(NodeViewMove), "NodeViewMove struct"); - op->customdata= nvm; - nvm->mvalo[0]= event->mval[0]; - nvm->mvalo[1]= event->mval[1]; + nvm = MEM_callocN(sizeof(NodeViewMove), "NodeViewMove struct"); + op->customdata = nvm; + nvm->mvalo[0] = event->mval[0]; + nvm->mvalo[1] = event->mval[1]; - nvm->xmin = -(ar->winx/2) - ibuf->x/2 + pad; - nvm->xmax = ar->winx/2 + ibuf->x/2 - pad; - nvm->ymin = -(ar->winy/2) - ibuf->y/2 + pad; - nvm->ymax = ar->winy/2 + ibuf->y/2 - pad; + nvm->xmin = -(ar->winx / 2) - ibuf->x / 2 + pad; + nvm->xmax = ar->winx / 2 + ibuf->x / 2 - pad; + nvm->ymin = -(ar->winy / 2) - ibuf->y / 2 + pad; + nvm->ymax = ar->winy / 2 + ibuf->y / 2 - pad; BKE_image_release_ibuf(ima, lock); @@ -1602,7 +1602,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) static int snode_bg_viewmove_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; return OPERATOR_CANCELLED; } @@ -1621,14 +1621,14 @@ void NODE_OT_backimage_move(wmOperatorType *ot) ot->cancel = snode_bg_viewmove_cancel; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; } static int backimage_zoom(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - float fac= RNA_float_get(op->ptr, "factor"); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + float fac = RNA_float_get(op->ptr, "factor"); snode->zoom *= fac; ED_region_tag_redraw(ar); @@ -1643,7 +1643,7 @@ void NODE_OT_backimage_zoom(wmOperatorType *ot) /* identifiers */ ot->name = "Background Image Zoom"; ot->idname = "NODE_OT_backimage_zoom"; - ot->description = "Zoom in/out the brackground image"; + ot->description = "Zoom in/out the background image"; /* api callbacks */ ot->exec = backimage_zoom; @@ -1674,28 +1674,32 @@ typedef struct ImageSampleInfo { static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) { Scene *scene = CTX_data_scene(C); - ImageSampleInfo *info= arg_info; + ImageSampleInfo *info = arg_info; - ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels, - info->x, info->y, info->col, info->colf, - NULL, NULL /* zbuf - unused for nodes */ - ); + if (info->draw) { + ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels, + info->x, info->y, info->col, info->colf, + NULL, NULL /* zbuf - unused for nodes */ + ); + } } static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - ImageSampleInfo *info= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + ImageSampleInfo *info = op->customdata; void *lock; Image *ima; ImBuf *ibuf; float fx, fy, bufx, bufy; - ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); - ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); - if (!ibuf) + ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); + ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); + if (!ibuf) { + info->draw = 0; return; + } if (!ibuf->rect) { if (info->color_manage) @@ -1708,46 +1712,50 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) /* map the mouse coords to the backdrop image space */ bufx = ibuf->x * snode->zoom; bufy = ibuf->y * snode->zoom; - fx = (bufx > 0.0f ? ((float)event->mval[0] - 0.5f*ar->winx - snode->xof) / bufx + 0.5f : 0.0f); - fy = (bufy > 0.0f ? ((float)event->mval[1] - 0.5f*ar->winy - snode->yof) / bufy + 0.5f : 0.0f); + fx = (bufx > 0.0f ? ((float)event->mval[0] - 0.5f * ar->winx - snode->xof) / bufx + 0.5f : 0.0f); + fy = (bufy > 0.0f ? ((float)event->mval[1] - 0.5f * ar->winy - snode->yof) / bufy + 0.5f : 0.0f); - if (fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) { + if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { float *fp; char *cp; - int x= (int)(fx*ibuf->x), y= (int)(fy*ibuf->y); + int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); - CLAMP(x, 0, ibuf->x-1); - CLAMP(y, 0, ibuf->y-1); + CLAMP(x, 0, ibuf->x - 1); + CLAMP(y, 0, ibuf->y - 1); - info->x= x; - info->y= y; - info->draw= 1; - info->channels= ibuf->channels; + info->x = x; + info->y = y; + info->draw = 1; + info->channels = ibuf->channels; if (ibuf->rect) { - cp= (char *)(ibuf->rect + y*ibuf->x + x); + cp = (char *)(ibuf->rect + y * ibuf->x + x); - info->col[0]= cp[0]; - info->col[1]= cp[1]; - info->col[2]= cp[2]; - info->col[3]= cp[3]; + info->col[0] = cp[0]; + info->col[1] = cp[1]; + info->col[2] = cp[2]; + info->col[3] = cp[3]; - info->colf[0]= (float)cp[0]/255.0f; - info->colf[1]= (float)cp[1]/255.0f; - info->colf[2]= (float)cp[2]/255.0f; - info->colf[3]= (float)cp[3]/255.0f; + info->colf[0] = (float)cp[0] / 255.0f; + info->colf[1] = (float)cp[1] / 255.0f; + info->colf[2] = (float)cp[2] / 255.0f; + info->colf[3] = (float)cp[3] / 255.0f; } if (ibuf->rect_float) { - fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x)); + fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); - info->colf[0]= fp[0]; - info->colf[1]= fp[1]; - info->colf[2]= fp[2]; - info->colf[3]= fp[3]; + info->colf[0] = fp[0]; + info->colf[1] = fp[1]; + info->colf[2] = fp[2]; + info->colf[3] = fp[3]; } + + ED_node_sample_set(info->colf); + } + else { + info->draw = 0; + ED_node_sample_set(NULL); } - else - info->draw= 0; BKE_image_release_ibuf(ima, lock); @@ -1756,8 +1764,9 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) static void sample_exit(bContext *C, wmOperator *op) { - ImageSampleInfo *info= op->customdata; + ImageSampleInfo *info = op->customdata; + ED_node_sample_set(NULL); ED_region_draw_cb_exit(info->art, info->draw_handle); ED_area_tag_redraw(CTX_wm_area(C)); MEM_freeN(info); @@ -1765,17 +1774,17 @@ static void sample_exit(bContext *C, wmOperator *op) static int sample_invoke(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); ImageSampleInfo *info; - if (snode->treetype!=NTREE_COMPOSIT || !(snode->flag & SNODE_BACKDRAW)) + if (snode->treetype != NTREE_COMPOSIT || !(snode->flag & SNODE_BACKDRAW)) return OPERATOR_CANCELLED; - info= MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); - info->art= ar->type; + info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); + info->art = ar->type; info->draw_handle = ED_region_draw_cb_activate(ar->type, sample_draw, info, REGION_DRAW_POST_PIXEL); - op->customdata= info; + op->customdata = info; sample_apply(C, op, event); @@ -1837,20 +1846,20 @@ static void node_resize_init(bContext *C, wmOperator *op, wmEvent *UNUSED(event) { SpaceNode *snode = CTX_wm_space_node(C); - NodeSizeWidget *nsw= MEM_callocN(sizeof(NodeSizeWidget), "size widget op data"); + NodeSizeWidget *nsw = MEM_callocN(sizeof(NodeSizeWidget), "size widget op data"); - op->customdata= nsw; - nsw->mxstart= snode->mx; - nsw->mystart= snode->my; + op->customdata = nsw; + nsw->mxstart = snode->mx; + nsw->mystart = snode->my; /* store old */ - nsw->oldlocx= node->locx; - nsw->oldlocy= node->locy; - nsw->oldoffsetx= node->offsetx; - nsw->oldoffsety= node->offsety; - nsw->oldwidth= node->width; - nsw->oldheight= node->height; - nsw->oldminiwidth= node->miniwidth; + nsw->oldlocx = node->locx; + nsw->oldlocy = node->locy; + nsw->oldoffsetx = node->offsetx; + nsw->oldoffsety = node->offsety; + nsw->oldwidth = node->width; + nsw->oldheight = node->height; + nsw->oldminiwidth = node->miniwidth; nsw->directions = dir; WM_cursor_modal(CTX_wm_window(C), node_get_resize_cursor(dir)); @@ -1863,15 +1872,15 @@ static void node_resize_exit(bContext *C, wmOperator *op, int UNUSED(cancel)) WM_cursor_restore(CTX_wm_window(C)); MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; } static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - bNode *node= editnode_get_active(snode->edittree); - NodeSizeWidget *nsw= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + bNode *node = editnode_get_active(snode->edittree); + NodeSizeWidget *nsw = op->customdata; float mx, my, dx, dy; switch (event->type) { @@ -1886,46 +1895,46 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) float widthmin = 0.0f; float widthmax = 100.0f; if (nsw->directions & NODE_RESIZE_RIGHT) { - node->miniwidth= nsw->oldminiwidth + dx; + node->miniwidth = nsw->oldminiwidth + dx; CLAMP(node->miniwidth, widthmin, widthmax); } if (nsw->directions & NODE_RESIZE_LEFT) { float locmax = nsw->oldlocx + nsw->oldminiwidth; - node->locx= nsw->oldlocx + dx; + node->locx = nsw->oldlocx + dx; CLAMP(node->locx, locmax - widthmax, locmax - widthmin); - node->miniwidth= locmax - node->locx; + node->miniwidth = locmax - node->locx; } } else { - float widthmin = UI_DPI_FAC*node->typeinfo->minwidth; - float widthmax = UI_DPI_FAC*node->typeinfo->maxwidth; + float widthmin = UI_DPI_FAC * node->typeinfo->minwidth; + float widthmax = UI_DPI_FAC * node->typeinfo->maxwidth; if (nsw->directions & NODE_RESIZE_RIGHT) { - node->width= nsw->oldwidth + dx; + node->width = nsw->oldwidth + dx; CLAMP(node->width, widthmin, widthmax); } if (nsw->directions & NODE_RESIZE_LEFT) { float locmax = nsw->oldlocx + nsw->oldwidth; - node->locx= nsw->oldlocx + dx; + node->locx = nsw->oldlocx + dx; CLAMP(node->locx, locmax - widthmax, locmax - widthmin); - node->width= locmax - node->locx; + node->width = locmax - node->locx; } } /* height works the other way round ... */ { - float heightmin = UI_DPI_FAC*node->typeinfo->minheight; - float heightmax = UI_DPI_FAC*node->typeinfo->maxheight; + float heightmin = UI_DPI_FAC * node->typeinfo->minheight; + float heightmax = UI_DPI_FAC * node->typeinfo->maxheight; if (nsw->directions & NODE_RESIZE_TOP) { float locmin = nsw->oldlocy - nsw->oldheight; - node->locy= nsw->oldlocy + dy; + node->locy = nsw->oldlocy + dy; CLAMP(node->locy, locmin + heightmin, locmin + heightmax); - node->height= node->locy - locmin; + node->height = node->locy - locmin; } if (nsw->directions & NODE_RESIZE_BOTTOM) { - node->height= nsw->oldheight - dy; + node->height = nsw->oldheight - dy; CLAMP(node->height, heightmin, heightmax); } } @@ -1934,20 +1943,20 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) if (node->type == NODE_FRAME) { /* keep the offset symmetric around center point */ if (nsw->directions & NODE_RESIZE_LEFT) { - node->locx = nsw->oldlocx + 0.5f*dx; - node->offsetx = nsw->oldoffsetx + 0.5f*dx; + node->locx = nsw->oldlocx + 0.5f * dx; + node->offsetx = nsw->oldoffsetx + 0.5f * dx; } if (nsw->directions & NODE_RESIZE_RIGHT) { - node->locx = nsw->oldlocx + 0.5f*dx; - node->offsetx = nsw->oldoffsetx - 0.5f*dx; + node->locx = nsw->oldlocx + 0.5f * dx; + node->offsetx = nsw->oldoffsetx - 0.5f * dx; } if (nsw->directions & NODE_RESIZE_TOP) { - node->locy = nsw->oldlocy + 0.5f*dy; - node->offsety = nsw->oldoffsety + 0.5f*dy; + node->locy = nsw->oldlocy + 0.5f * dy; + node->offsety = nsw->oldoffsety + 0.5f * dy; } if (nsw->directions & NODE_RESIZE_BOTTOM) { - node->locy = nsw->oldlocy + 0.5f*dy; - node->offsety = nsw->oldoffsety - 0.5f*dy; + node->locy = nsw->oldlocy + 0.5f * dy; + node->offsety = nsw->oldoffsety - 0.5f * dy; } } } @@ -1971,9 +1980,9 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - bNode *node= editnode_get_active(snode->edittree); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + bNode *node = editnode_get_active(snode->edittree); int dir; if (node) { @@ -1986,7 +1995,7 @@ static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; } } - return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } static int node_resize_cancel(bContext *C, wmOperator *op) @@ -2020,10 +2029,10 @@ int node_has_hidden_sockets(bNode *node) { bNodeSocket *sock; - for (sock= node->inputs.first; sock; sock= sock->next) + for (sock = node->inputs.first; sock; sock = sock->next) if (sock->flag & SOCK_HIDDEN) return 1; - for (sock= node->outputs.first; sock; sock= sock->next) + for (sock = node->outputs.first; sock; sock = sock->next) if (sock->flag & SOCK_HIDDEN) return 1; return 0; @@ -2033,20 +2042,20 @@ void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set) { bNodeSocket *sock; - if (set==0) { - for (sock= node->inputs.first; sock; sock= sock->next) + if (set == 0) { + for (sock = node->inputs.first; sock; sock = sock->next) sock->flag &= ~SOCK_HIDDEN; - for (sock= node->outputs.first; sock; sock= sock->next) + for (sock = node->outputs.first; sock; sock = sock->next) sock->flag &= ~SOCK_HIDDEN; } else { /* hide unused sockets */ - for (sock= node->inputs.first; sock; sock= sock->next) { - if (sock->link==NULL) + for (sock = node->inputs.first; sock; sock = sock->next) { + if (sock->link == NULL) sock->flag |= SOCK_HIDDEN; } - for (sock= node->outputs.first; sock; sock= sock->next) { - if (nodeCountSocketLinks(snode->edittree, sock)==0) + for (sock = node->outputs.first; sock; sock = sock->next) { + if (nodeCountSocketLinks(snode->edittree, sock) == 0) sock->flag |= SOCK_HIDDEN; } } @@ -2060,20 +2069,20 @@ static int node_link_viewer(const bContext *C, bNode *tonode) bNodeSocket *sock; /* context check */ - if (tonode==NULL || tonode->outputs.first==NULL) + if (tonode == NULL || tonode->outputs.first == NULL) return OPERATOR_CANCELLED; - if ( ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) + if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) return OPERATOR_CANCELLED; /* get viewer */ - for (node= snode->edittree->nodes.first; node; node= node->next) - if ( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) + for (node = snode->edittree->nodes.first; node; node = node->next) + if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) if (node->flag & NODE_DO_OUTPUT) break; /* no viewer, we make one active */ - if (node==NULL) { - for (node= snode->edittree->nodes.first; node; node= node->next) { - if ( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if (node == NULL) { + for (node = snode->edittree->nodes.first; node; node = node->next) { + if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { node->flag |= NODE_DO_OUTPUT; break; } @@ -2085,17 +2094,17 @@ static int node_link_viewer(const bContext *C, bNode *tonode) /* try to find an already connected socket to cycle to the next */ if (node) { link = NULL; - for (link= snode->edittree->links.first; link; link= link->next) - if (link->tonode==node && link->fromnode==tonode) - if (link->tosock==node->inputs.first) + for (link = snode->edittree->links.first; link; link = link->next) + if (link->tonode == node && link->fromnode == tonode) + if (link->tosock == node->inputs.first) break; if (link) { /* unlink existing connection */ - sock= link->fromsock; + sock = link->fromsock; nodeRemLink(snode->edittree, link); /* find a socket after the previously connected socket */ - for (sock=sock->next; sock; sock= sock->next) + for (sock = sock->next; sock; sock = sock->next) if (!nodeSocketIsHidden(sock)) break; } @@ -2103,7 +2112,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode) /* find a socket starting from the first socket */ if (!sock) { - for (sock= tonode->outputs.first; sock; sock= sock->next) + for (sock = tonode->outputs.first; sock; sock = sock->next) if (!nodeSocketIsHidden(sock)) break; } @@ -2125,17 +2134,17 @@ static int node_link_viewer(const bContext *C, bNode *tonode) } else { /* get link to viewer */ - for (link= snode->edittree->links.first; link; link= link->next) - if (link->tonode==node && link->tosock==node->inputs.first) + for (link = snode->edittree->links.first; link; link = link->next) + if (link->tonode == node && link->tosock == node->inputs.first) break; } - if (link==NULL) { + if (link == NULL) { nodeAddLink(snode->edittree, tonode, sock, node, node->inputs.first); } else { - link->fromnode= tonode; - link->fromsock= sock; + link->fromnode = tonode; + link->fromsock = sock; /* make sure the dependency sorting is updated */ snode->edittree->update |= NTREE_UPDATE_LINKS; } @@ -2149,10 +2158,10 @@ static int node_link_viewer(const bContext *C, bNode *tonode) static int node_active_link_viewer(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node; - node= editnode_get_active(snode->edittree); + node = editnode_get_active(snode->edittree); if (!node) return OPERATOR_CANCELLED; @@ -2181,31 +2190,31 @@ void NODE_OT_link_viewer(wmOperatorType *ot) ot->poll = composite_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* return 0, nothing done */ -static int UNUSED_FUNCTION(node_mouse_groupheader)(SpaceNode *snode) +static int UNUSED_FUNCTION(node_mouse_groupheader) (SpaceNode * snode) { bNode *gnode; - float mx=0, my=0; + float mx = 0, my = 0; // XXX int mval[2]; - gnode= node_tree_get_editgroup(snode->nodetree); - if (gnode==NULL) return 0; + gnode = node_tree_get_editgroup(snode->nodetree); + if (gnode == NULL) return 0; // XXX getmouseco_areawin(mval); // XXX areamouseco_to_ipoco(G.v2d, mval, &mx, &my); /* click in header or outside? */ - if (BLI_in_rctf(&gnode->totr, mx, my)==0) { - rctf rect= gnode->totr; + if (BLI_in_rctf(&gnode->totr, mx, my) == 0) { + rctf rect = gnode->totr; rect.ymax += NODE_DY; - if (BLI_in_rctf(&rect, mx, my)==0) - snode_make_group_editable(snode, NULL); /* toggles, so exits editmode */ + if (BLI_in_rctf(&rect, mx, my) == 0) + snode_make_group_editable(snode, NULL); /* toggles, so exits editmode */ // else // XXX transform_nodes(snode->nodetree, 'g', "Move group"); @@ -2222,36 +2231,36 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so bNodeSocket *sock; rctf rect; - *nodep= NULL; - *sockp= NULL; + *nodep = NULL; + *sockp = NULL; /* check if we click in a socket */ - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { - rect.xmin = snode->mx - (NODE_SOCKSIZE+4); - rect.ymin = snode->my - (NODE_SOCKSIZE+4); - rect.xmax = snode->mx + (NODE_SOCKSIZE+4); - rect.ymax = snode->my + (NODE_SOCKSIZE+4); + rect.xmin = snode->mx - (NODE_SOCKSIZE + 4); + rect.ymin = snode->my - (NODE_SOCKSIZE + 4); + rect.xmax = snode->mx + (NODE_SOCKSIZE + 4); + rect.ymax = snode->my + (NODE_SOCKSIZE + 4); if (!(node->flag & NODE_HIDDEN)) { /* extra padding inside and out - allow dragging on the text areas too */ if (in_out == SOCK_IN) { rect.xmax += NODE_SOCKSIZE; - rect.xmin -= NODE_SOCKSIZE*4; + rect.xmin -= NODE_SOCKSIZE * 4; } else if (in_out == SOCK_OUT) { - rect.xmax += NODE_SOCKSIZE*4; + rect.xmax += NODE_SOCKSIZE * 4; rect.xmin -= NODE_SOCKSIZE; } } if (in_out & SOCK_IN) { - for (sock= node->inputs.first; sock; sock= sock->next) { + for (sock = node->inputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { if (node == visible_node(snode, &rect)) { - *nodep= node; - *sockp= sock; + *nodep = node; + *sockp = sock; return 1; } } @@ -2259,12 +2268,12 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so } } if (in_out & SOCK_OUT) { - for (sock= node->outputs.first; sock; sock= sock->next) { + for (sock = node->outputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { if (node == visible_node(snode, &rect)) { - *nodep= node; - *sockp= sock; + *nodep = node; + *sockp = sock; return 1; } } @@ -2277,22 +2286,22 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so * NB: using ngroup->outputs as input sockets and vice versa here! */ if (in_out & SOCK_IN) { - for (sock= snode->edittree->outputs.first; sock; sock= sock->next) { + for (sock = snode->edittree->outputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { - *nodep= NULL; /* NULL node pointer indicates group socket */ - *sockp= sock; + *nodep = NULL; /* NULL node pointer indicates group socket */ + *sockp = sock; return 1; } } } } if (in_out & SOCK_OUT) { - for (sock= snode->edittree->inputs.first; sock; sock= sock->next) { + for (sock = snode->edittree->inputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { - *nodep= NULL; /* NULL node pointer indicates group socket */ - *sockp= sock; + *nodep = NULL; /* NULL node pointer indicates group socket */ + *sockp = sock; return 1; } } @@ -2304,7 +2313,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so static int outside_group_rect(SpaceNode *snode) { - bNode *gnode= node_tree_get_editgroup(snode->nodetree); + bNode *gnode = node_tree_get_editgroup(snode->nodetree); if (gnode) { return (snode->mx < gnode->totr.xmin || snode->mx >= gnode->totr.xmax || @@ -2351,7 +2360,7 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree, bNode *node, bNodeSocke bNodeSocket *sock; /* first look for selected output */ - for (sock=node->outputs.first; sock; sock=sock->next) { + for (sock = node->outputs.first; sock; sock = sock->next) { if (!socket_is_available(ntree, sock, allow_multiple)) continue; @@ -2360,19 +2369,19 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree, bNode *node, bNodeSocke } /* try to find a socket with a matching name */ - for (sock=node->outputs.first; sock; sock=sock->next) { + for (sock = node->outputs.first; sock; sock = sock->next) { if (!socket_is_available(ntree, sock, allow_multiple)) continue; /* check for same types */ if (sock->type == sock_target->type) { - if (strcmp(sock->name, sock_target->name)==0) + if (strcmp(sock->name, sock_target->name) == 0) return sock; } } /* otherwise settle for the first available socket of the right type */ - for (sock=node->outputs.first; sock; sock=sock->next) { + for (sock = node->outputs.first; sock; sock = sock->next) { if (!socket_is_available(ntree, sock, allow_multiple)) continue; @@ -2391,16 +2400,16 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree, bNode *node, bNodeSocke static bNodeSocket *best_socket_input(bNodeTree *ntree, bNode *node, int num, int replace) { bNodeSocket *sock; - int socktype, maxtype=0; + int socktype, maxtype = 0; int a = 0; - for (sock=node->inputs.first; sock; sock=sock->next) { + for (sock = node->inputs.first; sock; sock = sock->next) { maxtype = MAX2(sock->type, maxtype); } /* find sockets of higher 'types' first (i.e. image) */ - for (socktype=maxtype; socktype >= 0; socktype--) { - for (sock=node->inputs.first; sock; sock=sock->next) { + for (socktype = maxtype; socktype >= 0; socktype--) { + for (sock = node->inputs.first; sock; sock = sock->next) { if (!socket_is_available(ntree, sock, replace)) { a++; @@ -2447,9 +2456,9 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) ListBase *nodelist = MEM_callocN(sizeof(ListBase), "items_list"); bNodeListItem *nli; bNode *node; - int i, numlinks=0; + int i, numlinks = 0; - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & NODE_SELECT) { nli = MEM_mallocN(sizeof(bNodeListItem), "temporary node list item"); nli->node = node; @@ -2460,7 +2469,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) /* sort nodes left to right */ BLI_sortlist(nodelist, sort_nodes_locx); - for (nli=nodelist->first; nli; nli=nli->next) { + for (nli = nodelist->first; nli; nli = nli->next) { bNode *node_fr, *node_to; bNodeSocket *sock_fr, *sock_to; int has_selected_inputs = 0; @@ -2471,7 +2480,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) node_to = nli->next->node; /* if there are selected sockets, connect those */ - for (sock_to = node_to->inputs.first; sock_to; sock_to=sock_to->next) { + for (sock_to = node_to->inputs.first; sock_to; sock_to = sock_to->next) { if (sock_to->flag & SELECT) { has_selected_inputs = 1; @@ -2492,7 +2501,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) /* no selected inputs, connect by finding suitable match */ int num_inputs = BLI_countlist(&node_to->inputs); - for (i=0; i<num_inputs; i++) { + for (i = 0; i < num_inputs; i++) { /* find the best guess input socket */ sock_to = best_socket_input(ntree, node_to, i, replace); @@ -2523,7 +2532,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) /* can be called from menus too, but they should do own undopush and redraws */ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate *ntemp, float locx, float locy) { - bNode *node= NULL, *gnode; + bNode *node = NULL, *gnode; node_deselect_all(snode); @@ -2531,11 +2540,11 @@ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate /* generics */ if (node) { - node->locx= locx; - node->locy= locy + 60.0f; // arbitrary.. so its visible, (0,0) is top of node + node->locx = locx; + node->locy = locy + 60.0f; // arbitrary.. so its visible, (0,0) is top of node node_select(node); - gnode= node_tree_get_editgroup(snode->nodetree); + gnode = node_tree_get_editgroup(snode->nodetree); if (gnode) { node->locx -= gnode->locx; node->locy -= gnode->locy; @@ -2544,7 +2553,7 @@ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate ntreeUpdateTree(snode->edittree); ED_node_set_active(bmain, snode->edittree, node); - if (snode->nodetree->type==NTREE_COMPOSIT) { + if (snode->nodetree->type == NTREE_COMPOSIT) { if (ELEM4(node->type, CMP_NODE_R_LAYERS, CMP_NODE_COMPOSITE, CMP_NODE_DEFOCUS, CMP_NODE_OUTPUT_FILE)) { node->id = &scene->id; } @@ -2561,7 +2570,7 @@ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate snode_update(snode, node); } - if (snode->nodetree->type==NTREE_TEXTURE) { + if (snode->nodetree->type == NTREE_TEXTURE) { ntreeTexCheckCyclics(snode->edittree); } @@ -2577,7 +2586,7 @@ static void node_duplicate_reparent_recursive(bNode *node) node->flag |= NODE_TEST; /* find first selected parent */ - for (parent=node->parent; parent; parent=parent->parent) { + for (parent = node->parent; parent; parent = parent->parent) { if (parent->flag & SELECT) { if (!(parent->flag & NODE_TEST)) node_duplicate_reparent_recursive(parent); @@ -2593,8 +2602,8 @@ static void node_duplicate_reparent_recursive(bNode *node) static int node_duplicate_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - bNodeTree *ntree= snode->edittree; + SpaceNode *snode = CTX_wm_space_node(C); + bNodeTree *ntree = snode->edittree; bNode *node, *newnode, *lastnode; bNodeLink *link, *newlink, *lastlink; int keep_inputs = RNA_boolean_get(op->ptr, "keep_inputs"); @@ -2602,7 +2611,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); lastnode = ntree->nodes.last; - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { newnode = nodeCopyNode(ntree, node); @@ -2616,7 +2625,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } /* make sure we don't copy new nodes again! */ - if (node==lastnode) + if (node == lastnode) break; } @@ -2624,7 +2633,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) * NB: this depends on correct node->new_node and sock->new_sock pointers from above copy! */ lastlink = ntree->links.last; - for (link=ntree->links.first; link; link=link->next) { + for (link = ntree->links.first; link; link = link->next) { /* This creates new links between copied nodes. * If keep_inputs is set, also copies input links from unselected (when fromnode==NULL)! */ @@ -2649,25 +2658,25 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } /* make sure we don't copy new links again! */ - if (link==lastlink) + if (link == lastlink) break; } /* clear flags for recursive depth-first iteration */ - for (node= ntree->nodes.first; node; node= node->next) + for (node = ntree->nodes.first; node; node = node->next) node->flag &= ~NODE_TEST; /* reparent copied nodes */ - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if ((node->flag & SELECT) && !(node->flag & NODE_TEST)) node_duplicate_reparent_recursive(node); /* only has to check old nodes */ - if (node==lastnode) + if (node == lastnode) break; } /* deselect old nodes, select the copies instead */ - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { /* has been set during copy above */ newnode = node->new_node; @@ -2678,7 +2687,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } /* make sure we don't copy new nodes again! */ - if (node==lastnode) + if (node == lastnode) break; } @@ -2702,7 +2711,7 @@ void NODE_OT_duplicate(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "keep_inputs", 0, "Keep Inputs", "Keep the input links to duplicated nodes"); } @@ -2716,21 +2725,21 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeL if (tsock && nodeCountSocketLinks(snode->edittree, link->tosock) > tsock->limit) { - for (tlink= snode->edittree->links.first; tlink; tlink= tlink->next) { - if (link!=tlink && tlink->tosock==link->tosock) + for (tlink = snode->edittree->links.first; tlink; tlink = tlink->next) { + if (link != tlink && tlink->tosock == link->tosock) break; } if (tlink) { /* try to move the existing link to the next available socket */ if (tlink->tonode) { /* is there a free input socket with the target type? */ - for (sock= tlink->tonode->inputs.first; sock; sock= sock->next) { - if (sock->type==tlink->tosock->type) + for (sock = tlink->tonode->inputs.first; sock; sock = sock->next) { + if (sock->type == tlink->tosock->type) if (nodeCountSocketLinks(snode->edittree, sock) < sock->limit) break; } if (sock) { - tlink->tosock= sock; + tlink->tosock = sock; sock->flag &= ~SOCK_HIDDEN; } else { @@ -2749,12 +2758,12 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeL /* in_out = starting socket */ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); - bNodeLinkDrag *nldrag= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + bNodeLinkDrag *nldrag = op->customdata; bNodeTree *ntree = snode->edittree; bNode *tnode; - bNodeSocket *tsock= NULL; + bNodeSocket *tsock = NULL; bNodeLink *link; LinkData *linkdata; int in_out; @@ -2762,14 +2771,14 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) in_out = nldrag->in_out; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], - &snode->mx, &snode->my); + &snode->mx, &snode->my); switch (event->type) { case MOUSEMOVE: - if (in_out==SOCK_OUT) { + if (in_out == SOCK_OUT) { if (node_find_indicated_socket(snode, &tnode, &tsock, SOCK_IN)) { - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; /* skip if this is already the target socket */ @@ -2792,14 +2801,14 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) } else { int do_update = FALSE; - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; if (link->tonode || link->tosock) { BLI_remlink(&ntree->links, link); link->prev = link->next = NULL; - link->tonode= NULL; - link->tosock= NULL; + link->tonode = NULL; + link->tosock = NULL; ntree->update |= NTREE_UPDATE_LINKS; do_update = TRUE; @@ -2812,7 +2821,7 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) } else { if (node_find_indicated_socket(snode, &tnode, &tsock, SOCK_OUT)) { - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; /* skip if this is already the target socket */ @@ -2835,14 +2844,14 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) } else { int do_update = FALSE; - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; if (link->fromnode || link->fromsock) { BLI_remlink(&ntree->links, link); link->prev = link->next = NULL; - link->fromnode= NULL; - link->fromsock= NULL; + link->fromnode = NULL; + link->fromsock = NULL; ntree->update |= NTREE_UPDATE_LINKS; do_update = TRUE; @@ -2860,7 +2869,7 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: { - for (linkdata=nldrag->links.first; linkdata; linkdata=linkdata->next) { + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { link = linkdata->data; if (link->tosock && link->fromsock) { @@ -2869,7 +2878,7 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) snode_update(snode, link->tonode); /* we might need to remove a link */ - if (in_out==SOCK_OUT) + if (in_out == SOCK_OUT) node_remove_extra_links(snode, link->tosock, link); /* when linking to group outputs, update the socket type */ @@ -2930,16 +2939,16 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, int detach) /* output indicated? */ if (node_find_indicated_socket(snode, &node, &sock, SOCK_OUT)) { - nldrag= MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata"); + nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata"); num_links = nodeCountSocketLinks(snode->edittree, sock); if (num_links > 0 && (num_links >= sock->limit || detach)) { /* dragged links are fixed on input side */ nldrag->in_out = SOCK_IN; /* detach current links and store them in the operator data */ - for (link= snode->edittree->links.first; link; link= link_next) { + for (link = snode->edittree->links.first; link; link = link_next) { link_next = link->next; - if (link->fromsock==sock) { + if (link->fromsock == sock) { linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data"); linkdata->data = oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link"); *oplink = *link; @@ -2962,16 +2971,16 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, int detach) } /* or an input? */ else if (node_find_indicated_socket(snode, &node, &sock, SOCK_IN)) { - nldrag= MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata"); + nldrag = MEM_callocN(sizeof(bNodeLinkDrag), "drag link op customdata"); num_links = nodeCountSocketLinks(snode->edittree, sock); if (num_links > 0 && (num_links >= sock->limit || detach)) { /* dragged links are fixed on output side */ nldrag->in_out = SOCK_OUT; /* detach current links and store them in the operator data */ - for (link= snode->edittree->links.first; link; link= link_next) { + for (link = snode->edittree->links.first; link; link = link_next) { link_next = link->next; - if (link->tosock==sock) { + if (link->tosock == sock) { linkdata = MEM_callocN(sizeof(LinkData), "drag link op link data"); linkdata->data = oplink = MEM_callocN(sizeof(bNodeLink), "drag link op link"); *oplink = *link; @@ -3002,20 +3011,20 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, int detach) static int node_link_invoke(bContext *C, wmOperator *op, wmEvent *event) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); bNodeLinkDrag *nldrag; int detach = RNA_boolean_get(op->ptr, "detach"); UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], - &snode->mx, &snode->my); + &snode->mx, &snode->my); ED_preview_kill_jobs(C); nldrag = node_link_init(snode, detach); if (nldrag) { - op->customdata= nldrag; + op->customdata = nldrag; BLI_addtail(&snode->linkdrag, nldrag); /* add modal handler */ @@ -3024,13 +3033,13 @@ static int node_link_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; } else - return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } static int node_link_cancel(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - bNodeLinkDrag *nldrag= op->customdata; + SpaceNode *snode = CTX_wm_space_node(C); + bNodeLinkDrag *nldrag = op->customdata; BLI_remlink(&snode->linkdrag, nldrag); @@ -3055,7 +3064,7 @@ void NODE_OT_link(wmOperatorType *ot) ot->cancel = node_link_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; RNA_def_boolean(ot->srna, "detach", FALSE, "Detach", "Detach and redirect existing links"); } @@ -3065,7 +3074,7 @@ void NODE_OT_link(wmOperatorType *ot) /* makes a link between selected output and input sockets */ static int node_make_link_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); int replace = RNA_boolean_get(op->ptr, "replace"); ED_preview_kill_jobs(C); @@ -3095,7 +3104,7 @@ void NODE_OT_link_make(wmOperatorType *ot) ot->poll = ED_operator_node_active; // XXX we need a special poll which checks that there are selected input/output sockets /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "replace", 0, "Replace", "Replace socket connections with the new links"); } @@ -3104,16 +3113,16 @@ void NODE_OT_link_make(wmOperatorType *ot) #define LINK_RESOL 12 static int add_reroute_intersect_check(bNodeLink *link, float mcoords[][2], int tot, float result[2]) { - float coord_array[LINK_RESOL+1][2]; + float coord_array[LINK_RESOL + 1][2]; int i, b; if (node_link_bezier_points(NULL, NULL, link, coord_array, LINK_RESOL)) { - for (i=0; i<tot-1; i++) - for (b=0; b<LINK_RESOL; b++) - if (isect_line_line_v2(mcoords[i], mcoords[i+1], coord_array[b], coord_array[b+1]) > 0) { - result[0] = (mcoords[i][0]+mcoords[i+1][0])/2.0f; - result[1] = (mcoords[i][1]+mcoords[i+1][1])/2.0f; + for (i = 0; i < tot - 1; i++) + for (b = 0; b < LINK_RESOL; b++) + if (isect_line_line_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) { + result[0] = (mcoords[i][0] + mcoords[i + 1][0]) / 2.0f; + result[1] = (mcoords[i][1] + mcoords[i + 1][1]) / 2.0f; return 1; } } @@ -3122,29 +3131,30 @@ static int add_reroute_intersect_check(bNodeLink *link, float mcoords[][2], int static int add_reroute_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); float mcoords[256][2]; - int i= 0; + int i = 0; - RNA_BEGIN(op->ptr, itemptr, "path") { + RNA_BEGIN(op->ptr, itemptr, "path") + { float loc[2]; RNA_float_get_array(&itemptr, "loc", loc); UI_view2d_region_to_view(&ar->v2d, (short)loc[0], (short)loc[1], - &mcoords[i][0], &mcoords[i][1]); + &mcoords[i][0], &mcoords[i][1]); i++; - if (i>= 256) break; + if (i >= 256) break; } RNA_END; - if (i>1) { + if (i > 1) { bNodeLink *link; float insertPoint[2]; ED_preview_kill_jobs(C); - for (link= snode->edittree->links.first; link; link=link->next) { + for (link = snode->edittree->links.first; link; link = link->next) { if (add_reroute_intersect_check(link, mcoords, i, insertPoint)) { bNodeTemplate ntemp; bNode *rerouteNode; @@ -3171,27 +3181,27 @@ static int add_reroute_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } void NODE_OT_add_reroute(wmOperatorType *ot) { PropertyRNA *prop; - ot->name= "Add reroute"; - ot->idname= "NODE_OT_add_reroute"; + ot->name = "Add reroute"; + ot->idname = "NODE_OT_add_reroute"; - ot->invoke= WM_gesture_lines_invoke; - ot->modal= WM_gesture_lines_modal; - ot->exec= add_reroute_exec; - ot->cancel= WM_gesture_lines_cancel; + ot->invoke = WM_gesture_lines_invoke; + ot->modal = WM_gesture_lines_modal; + ot->exec = add_reroute_exec; + ot->cancel = WM_gesture_lines_cancel; - ot->poll= ED_operator_node_active; + ot->poll = ED_operator_node_active; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); + prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath); /* internal */ RNA_def_int(ot->srna, "cursor", BC_CROSSCURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX); @@ -3201,14 +3211,14 @@ void NODE_OT_add_reroute(wmOperatorType *ot) /* ********************** Cut Link operator ***************** */ static int cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot) { - float coord_array[LINK_RESOL+1][2]; + float coord_array[LINK_RESOL + 1][2]; int i, b; if (node_link_bezier_points(NULL, NULL, link, coord_array, LINK_RESOL)) { - for (i=0; i<tot-1; i++) - for (b=0; b<LINK_RESOL; b++) - if (isect_line_line_v2(mcoords[i], mcoords[i+1], coord_array[b], coord_array[b+1]) > 0) + for (i = 0; i < tot - 1; i++) + for (b = 0; b < LINK_RESOL; b++) + if (isect_line_line_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) return 1; } return 0; @@ -3216,30 +3226,30 @@ static int cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot) static int cut_links_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); - ARegion *ar= CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); float mcoords[256][2]; - int i= 0; + int i = 0; - RNA_BEGIN (op->ptr, itemptr, "path") + RNA_BEGIN(op->ptr, itemptr, "path") { float loc[2]; RNA_float_get_array(&itemptr, "loc", loc); UI_view2d_region_to_view(&ar->v2d, (int)loc[0], (int)loc[1], - &mcoords[i][0], &mcoords[i][1]); + &mcoords[i][0], &mcoords[i][1]); i++; - if (i>= 256) break; + if (i >= 256) break; } RNA_END; - if (i>1) { + if (i > 1) { bNodeLink *link, *next; ED_preview_kill_jobs(C); - for (link= snode->edittree->links.first; link; link= next) { - next= link->next; + for (link = snode->edittree->links.first; link; link = next) { + next = link->next; if (cut_links_intersect(link, mcoords, i)) { snode_update(snode, link->tonode); @@ -3254,7 +3264,7 @@ static int cut_links_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } void NODE_OT_links_cut(wmOperatorType *ot) @@ -3273,9 +3283,9 @@ void NODE_OT_links_cut(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); + prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath); /* internal */ RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX); @@ -3285,13 +3295,13 @@ void NODE_OT_links_cut(wmOperatorType *ot) static int detach_links_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); - bNodeTree *ntree= snode->edittree; + SpaceNode *snode = CTX_wm_space_node(C); + bNodeTree *ntree = snode->edittree; bNode *node; ED_preview_kill_jobs(C); - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { nodeInternalRelink(ntree, node); } @@ -3315,7 +3325,7 @@ void NODE_OT_links_detach(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************* automatic node insert on dragging ******************* */ @@ -3324,25 +3334,25 @@ void NODE_OT_links_detach(wmOperatorType *ot) static bNodeSocket *socket_best_match(ListBase *sockets) { bNodeSocket *sock; - int type, maxtype=0; + int type, maxtype = 0; /* find type range */ - for (sock=sockets->first; sock; sock=sock->next) + for (sock = sockets->first; sock; sock = sock->next) maxtype = MAX2(sock->type, maxtype); /* try all types, starting from 'highest' (i.e. colors, vectors, values) */ - for (type=maxtype; type >= 0; --type) { - for (sock= sockets->first; sock; sock= sock->next) { - if (!nodeSocketIsHidden(sock) && type==sock->type) { + for (type = maxtype; type >= 0; --type) { + for (sock = sockets->first; sock; sock = sock->next) { + if (!nodeSocketIsHidden(sock) && type == sock->type) { return sock; } } } /* no visible sockets, unhide first of highest type */ - for (type=maxtype; type >= 0; --type) { - for (sock= sockets->first; sock; sock= sock->next) { - if (type==sock->type) { + for (type = maxtype; type >= 0; --type) { + for (sock = sockets->first; sock; sock = sock->next) { + if (type == sock->type) { sock->flag &= ~SOCK_HIDDEN; return sock; } @@ -3355,31 +3365,31 @@ static bNodeSocket *socket_best_match(ListBase *sockets) /* prevent duplicate testing code below */ static SpaceNode *ed_node_link_conditions(ScrArea *sa, bNode **select) { - SpaceNode *snode= sa?sa->spacedata.first:NULL; + SpaceNode *snode = sa ? sa->spacedata.first : NULL; bNode *node; bNodeLink *link; /* no unlucky accidents */ - if (sa==NULL || sa->spacetype!=SPACE_NODE) return NULL; + if (sa == NULL || sa->spacetype != SPACE_NODE) return NULL; - *select= NULL; + *select = NULL; - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { if (*select) break; else - *select= node; + *select = node; } } /* only one selected */ - if (node || *select==NULL) return NULL; + if (node || *select == NULL) return NULL; /* correct node */ - if ((*select)->inputs.first==NULL || (*select)->outputs.first==NULL) return NULL; + if ((*select)->inputs.first == NULL || (*select)->outputs.first == NULL) return NULL; /* test node for links */ - for (link= snode->edittree->links.first; link; link=link->next) { + for (link = snode->edittree->links.first; link; link = link->next) { if (link->tonode == *select || link->fromnode == *select) return NULL; } @@ -3391,27 +3401,27 @@ static SpaceNode *ed_node_link_conditions(ScrArea *sa, bNode **select) void ED_node_link_insert(ScrArea *sa) { bNode *node, *select; - SpaceNode *snode= ed_node_link_conditions(sa, &select); + SpaceNode *snode = ed_node_link_conditions(sa, &select); bNodeLink *link; bNodeSocket *sockto; - if (snode==NULL) return; + if (snode == NULL) return; /* get the link */ - for (link= snode->edittree->links.first; link; link=link->next) + for (link = snode->edittree->links.first; link; link = link->next) if (link->flag & NODE_LINKFLAG_HILITE) break; if (link) { - node= link->tonode; - sockto= link->tosock; + node = link->tonode; + sockto = link->tosock; - link->tonode= select; - link->tosock= socket_best_match(&select->inputs); + link->tonode = select; + link->tosock = socket_best_match(&select->inputs); link->flag &= ~NODE_LINKFLAG_HILITE; nodeAddLink(snode->edittree, select, socket_best_match(&select->outputs), node, sockto); - ntreeUpdateTree(snode->edittree); /* needed for pointers */ + ntreeUpdateTree(snode->edittree); /* needed for pointers */ snode_update(snode, select); ED_node_changed_update(snode->id, select); } @@ -3422,44 +3432,44 @@ void ED_node_link_insert(ScrArea *sa) void ED_node_link_intersect_test(ScrArea *sa, int test) { bNode *select; - SpaceNode *snode= ed_node_link_conditions(sa, &select); - bNodeLink *link, *selink=NULL; + SpaceNode *snode = ed_node_link_conditions(sa, &select); + bNodeLink *link, *selink = NULL; float mcoords[6][2]; - if (snode==NULL) return; + if (snode == NULL) return; /* clear flags */ - for (link= snode->edittree->links.first; link; link=link->next) + for (link = snode->edittree->links.first; link; link = link->next) link->flag &= ~NODE_LINKFLAG_HILITE; - if (test==0) return; + if (test == 0) return; /* okay, there's 1 node, without links, now intersect */ - mcoords[0][0]= select->totr.xmin; - mcoords[0][1]= select->totr.ymin; - mcoords[1][0]= select->totr.xmax; - mcoords[1][1]= select->totr.ymin; - mcoords[2][0]= select->totr.xmax; - mcoords[2][1]= select->totr.ymax; - mcoords[3][0]= select->totr.xmin; - mcoords[3][1]= select->totr.ymax; - mcoords[4][0]= select->totr.xmin; - mcoords[4][1]= select->totr.ymin; - mcoords[5][0]= select->totr.xmax; - mcoords[5][1]= select->totr.ymax; + mcoords[0][0] = select->totr.xmin; + mcoords[0][1] = select->totr.ymin; + mcoords[1][0] = select->totr.xmax; + mcoords[1][1] = select->totr.ymin; + mcoords[2][0] = select->totr.xmax; + mcoords[2][1] = select->totr.ymax; + mcoords[3][0] = select->totr.xmin; + mcoords[3][1] = select->totr.ymax; + mcoords[4][0] = select->totr.xmin; + mcoords[4][1] = select->totr.ymin; + mcoords[5][0] = select->totr.xmax; + mcoords[5][1] = select->totr.ymax; /* we only tag a single link for intersect now */ /* idea; use header dist when more? */ - for (link= snode->edittree->links.first; link; link=link->next) { + for (link = snode->edittree->links.first; link; link = link->next) { if (cut_links_intersect(link, mcoords, 5)) { /* intersect code wants edges */ if (selink) break; - selink= link; + selink = link; } } - if (link==NULL && selink) + if (link == NULL && selink) selink->flag |= NODE_LINKFLAG_HILITE; } @@ -3471,20 +3481,20 @@ void ED_node_link_intersect_test(ScrArea *sa, int test) /* goes over all scenes, reads render layers */ static int node_read_renderlayers_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), *scene; + Main *bmain = CTX_data_main(C); + SpaceNode *snode = CTX_wm_space_node(C); + Scene *curscene = CTX_data_scene(C), *scene; bNode *node; ED_preview_kill_jobs(C); /* first tag scenes unread */ - for (scene= bmain->scene.first; scene; scene= scene->id.next) + for (scene = bmain->scene.first; scene; scene = scene->id.next) scene->id.flag |= LIB_DOIT; - for (node= snode->edittree->nodes.first; node; node= node->next) { - if (node->type==CMP_NODE_R_LAYERS) { - ID *id= node->id; + for (node = snode->edittree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_R_LAYERS) { + ID *id = node->id; if (id->flag & LIB_DOIT) { RE_ReadRenderResult(curscene, (Scene *)id); ntreeCompositTagRender((Scene *)id); @@ -3516,10 +3526,10 @@ void NODE_OT_read_renderlayers(wmOperatorType *ot) 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); + 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); WM_cursor_wait(1); RE_MergeFullSample(re, bmain, curscene, snode->nodetree); @@ -3527,7 +3537,7 @@ static int node_read_fullsamplelayers_exec(bContext *C, wmOperator *UNUSED(op)) /* note we are careful to send the right notifier, as otherwise the * compositor would reexecute and overwrite the full sample result */ - WM_event_add_notifier(C, NC_SCENE|ND_COMPO_RESULT, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_COMPO_RESULT, NULL); return OPERATOR_FINISHED; } @@ -3550,23 +3560,23 @@ void NODE_OT_read_fullsamplelayers(wmOperatorType *ot) int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *sce= CTX_data_scene(C); + Scene *sce = CTX_data_scene(C); bNode *node; - for (node= sce->nodetree->nodes.first; node; node= node->next) { - if (node->id==(ID *)sce && node->need_exec) { + for (node = sce->nodetree->nodes.first; node; node = node->next) { + if (node->id == (ID *)sce && node->need_exec) { break; } } if (node) { - SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1); + SceneRenderLayer *srl = BLI_findlink(&sce->r.layers, node->custom1); if (srl) { PointerRNA op_ptr; WM_operator_properties_create(&op_ptr, "RENDER_OT_render"); RNA_string_set(&op_ptr, "layer", srl->name); - RNA_string_set(&op_ptr, "scene", sce->id.name+2); + RNA_string_set(&op_ptr, "scene", sce->id.name + 2); /* to keep keypositions */ sce->r.scemode |= R_NO_FRAME_UPDATE; @@ -3607,35 +3617,35 @@ static int node_group_make_test(bNodeTree *ntree, bNode *gnode) int totnode = 0; /* is there something to group? also do some clearing */ - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node == gnode) continue; if (node->flag & NODE_SELECT) { /* no groups in groups */ - if (node->type==NODE_GROUP) + if (node->type == NODE_GROUP) return 0; totnode++; } node->done = 0; } - if (totnode==0) return 0; + if (totnode == 0) return 0; /* check if all connections are OK, no unselected node has both * inputs and outputs to a selection */ - for (link= ntree->links.first; link; link= link->next) { + for (link = ntree->links.first; link; link = link->next) { if (link->fromnode && link->tonode && link->fromnode->flag & NODE_SELECT && link->fromnode != gnode) link->tonode->done |= 1; if (link->fromnode && link->tonode && link->tonode->flag & NODE_SELECT && link->tonode != gnode) link->fromnode->done |= 2; } - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node == gnode) continue; - if ((node->flag & NODE_SELECT)==0) - if (node->done==3) + if ((node->flag & NODE_SELECT) == 0) + if (node->done == 3) break; } if (node) @@ -3648,7 +3658,7 @@ static void node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min, { bNode *node; INIT_MINMAX2(min, max); - for (node= ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node == gnode) continue; if (node->flag & NODE_SELECT) { @@ -3667,14 +3677,14 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) float min[2], max[2]; /* deselect all nodes in the target tree */ - for (node = ngroup->nodes.first; node; node=node->next) + for (node = ngroup->nodes.first; node; node = node->next) node_deselect(node); node_get_selected_minmax(ntree, gnode, min, max); /* move nodes over */ - for (node= ntree->nodes.first; node; node= nextn) { - nextn= node->next; + for (node = ntree->nodes.first; node; node = nextn) { + nextn = node->next; if (node == gnode) continue; if (node->flag & NODE_SELECT) { @@ -3700,14 +3710,14 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) BLI_remlink(&ntree->nodes, node); BLI_addtail(&ngroup->nodes, node); - node->locx-= 0.5f*(min[0]+max[0]); - node->locy-= 0.5f*(min[1]+max[1]); + node->locx -= 0.5f * (min[0] + max[0]); + node->locy -= 0.5f * (min[1] + max[1]); } } /* move animation data over */ if (ntree->adt) { - LinkData *ld, *ldn=NULL; + LinkData *ld, *ldn = NULL; BKE_animdata_separate_by_basepath(&ntree->id, &ngroup->id, &anim_basepaths); @@ -3724,10 +3734,10 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) ntreeFreeCache(ngroup); /* relink external sockets */ - for (link= ntree->links.first; link; link= linkn) { + for (link = ntree->links.first; link; link = linkn) { int fromselect = (link->fromnode && (link->fromnode->flag & NODE_SELECT) && link->fromnode != gnode); int toselect = (link->tonode && (link->tonode->flag & NODE_SELECT) && link->tonode != gnode); - linkn= link->next; + linkn = link->next; if (gnode && ((fromselect && link->tonode == gnode) || (toselect && link->fromnode == gnode))) { /* remove all links to/from the gnode. @@ -3747,8 +3757,8 @@ static int node_group_make_insert_selected(bNodeTree *ntree, bNode *gnode) } else if (fromselect) { /* search for existing group node socket */ - for (gsock=ngroup->outputs.first; gsock; gsock=gsock->next) - if (gsock->link && gsock->link->fromsock==link->fromsock) + for (gsock = ngroup->outputs.first; gsock; gsock = gsock->next) + if (gsock->link && gsock->link->fromsock == link->fromsock) break; if (!gsock) { gsock = node_group_expose_socket(ngroup, link->fromsock, SOCK_OUT); @@ -3779,14 +3789,14 @@ static bNode *node_group_make_from_selected(bNodeTree *ntree) node_get_selected_minmax(ntree, NULL, min, max); /* new nodetree */ - ngroup= ntreeAddTree("NodeGroup", ntree->type, NODE_GROUP); + ngroup = ntreeAddTree("NodeGroup", ntree->type, NODE_GROUP); /* make group node */ ntemp.type = NODE_GROUP; ntemp.ngroup = ngroup; - gnode= nodeAddNode(ntree, &ntemp); - gnode->locx= 0.5f*(min[0]+max[0]); - gnode->locy= 0.5f*(min[1]+max[1]); + gnode = nodeAddNode(ntree, &ntemp); + gnode->locx = 0.5f * (min[0] + max[0]); + gnode->locy = 0.5f * (min[1] + max[1]); node_group_make_insert_selected(ntree, gnode); @@ -3814,16 +3824,16 @@ static int node_group_make_exec(bContext *C, wmOperator *op) bNode *gnode; int type = RNA_enum_get(op->ptr, "type"); - if (snode->edittree!=snode->nodetree) { + if (snode->edittree != snode->nodetree) { BKE_report(op->reports, RPT_WARNING, "Can not add a new Group in a Group"); return OPERATOR_CANCELLED; } /* for time being... is too complex to handle */ - if (snode->treetype==NTREE_COMPOSIT) { - for (gnode=snode->nodetree->nodes.first; gnode; gnode= gnode->next) { + if (snode->treetype == NTREE_COMPOSIT) { + for (gnode = snode->nodetree->nodes.first; gnode; gnode = gnode->next) { if (gnode->flag & SELECT) - if (gnode->type==CMP_NODE_R_LAYERS) + if (gnode->type == CMP_NODE_R_LAYERS) break; } @@ -3836,29 +3846,29 @@ static int node_group_make_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); switch (type) { - case NODE_GM_NEW: - if (node_group_make_test(snode->nodetree, NULL)) { - gnode = node_group_make_from_selected(snode->nodetree); - } - else { - BKE_report(op->reports, RPT_WARNING, "Can not make Group"); - return OPERATOR_CANCELLED; - } - break; - case NODE_GM_INSERT: - gnode = nodeGetActive(snode->nodetree); - if (!gnode || gnode->type != NODE_GROUP) { - BKE_report(op->reports, RPT_WARNING, "No active Group node"); - return OPERATOR_CANCELLED; - } - if (node_group_make_test(snode->nodetree, gnode)) { - node_group_make_insert_selected(snode->nodetree, gnode); - } - else { - BKE_report(op->reports, RPT_WARNING, "Can not insert into Group"); - return OPERATOR_CANCELLED; - } - break; + case NODE_GM_NEW: + if (node_group_make_test(snode->nodetree, NULL)) { + gnode = node_group_make_from_selected(snode->nodetree); + } + else { + BKE_report(op->reports, RPT_WARNING, "Can not make Group"); + return OPERATOR_CANCELLED; + } + break; + case NODE_GM_INSERT: + gnode = nodeGetActive(snode->nodetree); + if (!gnode || gnode->type != NODE_GROUP) { + BKE_report(op->reports, RPT_WARNING, "No active Group node"); + return OPERATOR_CANCELLED; + } + if (node_group_make_test(snode->nodetree, gnode)) { + node_group_make_insert_selected(snode->nodetree, gnode); + } + else { + BKE_report(op->reports, RPT_WARNING, "Can not insert into Group"); + return OPERATOR_CANCELLED; + } + break; } if (gnode) { @@ -3909,7 +3919,7 @@ void NODE_OT_group_make(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", node_group_make_types, NODE_GM_NEW, "Type", ""); } @@ -3919,18 +3929,18 @@ void NODE_OT_group_make(wmOperatorType *ot) static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) { bNode *node; - int tot_eq= 0, tot_neq= 0; + int tot_eq = 0, tot_neq = 0; /* Toggles the flag on all selected nodes. * If the flag is set on all nodes it is unset. * If the flag is not set on all nodes, it is set. */ - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - if (toggle_flag== NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW)==0) + if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) continue; - if (toggle_flag== NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS)==0) + if (toggle_flag == NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS) == 0) continue; if (node->flag & toggle_flag) @@ -3939,15 +3949,15 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) tot_neq++; } } - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - if (toggle_flag== NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW)==0) + if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) continue; - if (toggle_flag== NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS)==0) + if (toggle_flag == NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS) == 0) continue; - if ( (tot_eq && tot_neq) || tot_eq==0) + if ( (tot_eq && tot_neq) || tot_eq == 0) node->flag |= toggle_flag; else node->flag &= ~toggle_flag; @@ -3957,7 +3967,7 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) static int node_hide_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); /* sanity checking (poll callback checks this already) */ if ((snode == NULL) || (snode->edittree == NULL)) @@ -3982,12 +3992,12 @@ void NODE_OT_hide_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int node_preview_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); /* sanity checking (poll callback checks this already) */ if ((snode == NULL) || (snode->edittree == NULL)) @@ -4014,12 +4024,12 @@ void NODE_OT_preview_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int node_options_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); /* sanity checking (poll callback checks this already) */ if ((snode == NULL) || (snode->edittree == NULL)) @@ -4044,12 +4054,12 @@ void NODE_OT_options_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node; int hidden; @@ -4061,16 +4071,16 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op)) /* Toggle for all selected nodes */ hidden = 0; - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { if (node_has_hidden_sockets(node)) { - hidden= 1; + hidden = 1; break; } } } - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { node_set_hidden_sockets(snode, node, !hidden); } @@ -4095,19 +4105,19 @@ void NODE_OT_hide_socket_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Mute operator *********************** */ static int node_mute_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node; ED_preview_kill_jobs(C); - for (node= snode->edittree->nodes.first; node; node= node->next) { + for (node = snode->edittree->nodes.first; node; node = node->next) { /* Only allow muting of nodes having a mute func! */ if ((node->flag & SELECT) && node->typeinfo->internal_connect) { node->flag ^= NODE_MUTED; @@ -4133,20 +4143,20 @@ void NODE_OT_mute_toggle(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Delete operator ******************* */ static int node_delete_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node, *next; ED_preview_kill_jobs(C); - for (node= snode->edittree->nodes.first; node; node= next) { - next= node->next; + for (node = snode->edittree->nodes.first; node; node = next) { + next = node->next; if (node->flag & SELECT) { /* check id user here, nodeFreeNode is called for free dbase too */ if (node->id) @@ -4175,19 +4185,19 @@ void NODE_OT_delete(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Delete with reconnect ******************* */ static int node_delete_reconnect_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node, *next; ED_preview_kill_jobs(C); - for (node= snode->edittree->nodes.first; node; node= next) { - next= node->next; + for (node = snode->edittree->nodes.first; node; node = next) { + next = node->next; if (node->flag & SELECT) { nodeInternalRelink(snode->edittree, node); @@ -4218,14 +4228,14 @@ void NODE_OT_delete_reconnect(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Show Cyclic Dependencies Operator ******************* */ static int node_show_cycles_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); /* this is just a wrapper around this call... */ ntreeUpdateTree(snode->nodetree); @@ -4246,18 +4256,18 @@ void NODE_OT_show_cyclic_dependencies(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Add File Node Operator ******************* */ static int node_add_file_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - SpaceNode *snode= CTX_wm_space_node(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + SpaceNode *snode = CTX_wm_space_node(C); bNode *node; - Image *ima= NULL; + Image *ima = NULL; bNodeTemplate ntemp; /* check input variables */ @@ -4265,9 +4275,9 @@ static int node_add_file_exec(bContext *C, wmOperator *op) char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - errno= 0; + errno = 0; - ima= BKE_image_load_exists(path); + ima = BKE_image_load_exists(path); if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s", path, errno ? strerror(errno) : "Unsupported image format"); @@ -4275,9 +4285,9 @@ static int node_add_file_exec(bContext *C, wmOperator *op) } } else if (RNA_struct_property_is_set(op->ptr, "name")) { - char name[MAX_ID_NAME-2]; + char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); - ima= (Image *)BKE_libblock_find_name(ID_IM, name); + ima = (Image *)BKE_libblock_find_name(ID_IM, name); if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Image named \"%s\", not found", name); @@ -4320,12 +4330,12 @@ static int node_add_file_exec(bContext *C, wmOperator *op) static int node_add_file_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceNode *snode= CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], - &snode->mx, &snode->my); + &snode->mx, &snode->my); if (RNA_struct_property_is_set(op->ptr, "filepath") || RNA_struct_property_is_set(op->ptr, "name")) return node_add_file_exec(C, op); @@ -4346,10 +4356,10 @@ void NODE_OT_add_file(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); //XXX TODO, relative_path - RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME-2, "Name", "Datablock name to assign"); + WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); //XXX TODO, relative_path + RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Datablock name to assign"); } /********************** New node tree operator *********************/ @@ -4361,10 +4371,10 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) PointerRNA ptr, idptr; PropertyRNA *prop; int treetype; - char treename[MAX_ID_NAME-2] = "NodeTree"; + char treename[MAX_ID_NAME - 2] = "NodeTree"; /* retrieve state */ - snode= CTX_wm_space_node(C); + snode = CTX_wm_space_node(C); if (RNA_struct_property_is_set(op->ptr, "type")) treetype = RNA_enum_get(op->ptr, "type"); @@ -4391,7 +4401,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) RNA_property_update(C, &ptr, prop); } else if (snode) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); snode->nodetree = ntree; ED_node_tree_update(snode, scene); @@ -4412,18 +4422,18 @@ void NODE_OT_new_node_tree(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", nodetree_type_items, NTREE_COMPOSIT, "Tree Type", ""); - RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME-2, "Name", ""); + RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME - 2, "Name", ""); } /* ****************** File Output Add Socket ******************* */ static int node_output_file_add_socket_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - SpaceNode *snode= CTX_wm_space_node(C); + Scene *scene = CTX_data_scene(C); + SpaceNode *snode = CTX_wm_space_node(C); PointerRNA ptr; bNodeTree *ntree; bNode *node; @@ -4455,7 +4465,7 @@ void NODE_OT_output_file_add_socket(wmOperatorType *ot) ot->poll = composite_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_string(ot->srna, "file_path", "Image", MAX_NAME, "File Path", "Sub-path of the output file"); } @@ -4464,7 +4474,7 @@ void NODE_OT_output_file_add_socket(wmOperatorType *ot) static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); PointerRNA ptr = CTX_data_pointer_get(C, "node"); bNodeTree *ntree; bNode *node; @@ -4494,14 +4504,14 @@ void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot) ot->poll = composite_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Multi File Output Move Socket ******************* */ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); PointerRNA ptr = CTX_data_pointer_get(C, "node"); bNode *node; NodeImageMultiFile *nimf; @@ -4519,7 +4529,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) direction = RNA_enum_get(op->ptr, "direction"); - if (direction==1) { + if (direction == 1) { bNodeSocket *before = sock->prev; if (!before) return OPERATOR_CANCELLED; @@ -4546,7 +4556,8 @@ void NODE_OT_output_file_move_active_socket(wmOperatorType *ot) static EnumPropertyItem direction_items[] = { {1, "UP", 0, "Up", ""}, {2, "DOWN", 0, "Down", ""}, - { 0, NULL, 0, NULL, NULL }}; + { 0, NULL, 0, NULL, NULL } + }; /* identifiers */ ot->name = "Move File Node Socket"; @@ -4558,7 +4569,7 @@ void NODE_OT_output_file_move_active_socket(wmOperatorType *ot) ot->poll = composite_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "direction", direction_items, 2, "Direction", ""); } @@ -4577,7 +4588,7 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) if (!node) return OPERATOR_CANCELLED; - for (tnode=ntree->nodes.first; tnode; tnode=tnode->next) { + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { if (tnode->flag & NODE_SELECT && tnode != node) { if (node->flag & NODE_CUSTOM_COLOR) { tnode->flag |= NODE_CUSTOM_COLOR; @@ -4589,7 +4600,7 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4606,7 +4617,7 @@ void NODE_OT_node_copy_color(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Set Parent ******************* */ @@ -4619,7 +4630,7 @@ static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) if (!frame || frame->type != NODE_FRAME) return OPERATOR_CANCELLED; - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node == frame) continue; if (node->flag & NODE_SELECT) { @@ -4629,7 +4640,7 @@ static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4646,7 +4657,7 @@ void NODE_OT_parent_set(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Clear Parent ******************* */ @@ -4657,13 +4668,13 @@ static int node_parent_clear_exec(bContext *C, wmOperator *UNUSED(op)) bNodeTree *ntree = snode->edittree; bNode *node; - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & NODE_SELECT) { nodeDetachNode(node); } } - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4680,14 +4691,14 @@ void NODE_OT_parent_clear(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Join Nodes ******************* */ /* tags for depth-first search */ -#define NODE_JOIN_DONE 1 -#define NODE_JOIN_IS_DESCENDANT 2 +#define NODE_JOIN_DONE 1 +#define NODE_JOIN_IS_DESCENDANT 2 static void node_join_attach_recursive(bNode *node, bNode *frame) { @@ -4727,7 +4738,7 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op)) bNodeTemplate ntemp; /* XXX save selection: node_add_node call below sets the new frame as single active+selected node */ - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & NODE_SELECT) node->flag |= NODE_TEST; else @@ -4740,22 +4751,22 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op)) frame = node_add_node(snode, bmain, scene, &ntemp, 0.0f, 0.0f); /* reset tags */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) node->done = 0; - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (!(node->done & NODE_JOIN_DONE)) node_join_attach_recursive(node, frame); } /* restore selection */ - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & NODE_TEST) node->flag |= NODE_SELECT; } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4772,7 +4783,7 @@ void NODE_OT_join(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Attach ******************* */ @@ -4784,7 +4795,7 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op)) bNode *frame; /* check nodes front to back */ - for (frame=ntree->nodes.last; frame; frame=frame->prev) { + for (frame = ntree->nodes.last; frame; frame = frame->prev) { /* skip selected, those are the nodes we want to attach */ if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) continue; @@ -4793,7 +4804,7 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op)) } if (frame) { bNode *node, *parent; - for (node=ntree->nodes.last; node; node=node->prev) { + for (node = ntree->nodes.last; node; node = node->prev) { if (node->flag & NODE_SELECT) { if (node->parent == NULL) { /* attach all unparented nodes */ @@ -4801,7 +4812,7 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op)) } else { /* attach nodes which share parent with the frame */ - for (parent=frame->parent; parent; parent=parent->parent) + for (parent = frame->parent; parent; parent = parent->parent) if (parent == node->parent) break; if (parent) { @@ -4814,15 +4825,15 @@ static int node_attach_exec(bContext *C, wmOperator *UNUSED(op)) } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } static int node_attach_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceNode *snode= CTX_wm_space_node(C); + ARegion *ar = CTX_wm_region(C); + SpaceNode *snode = CTX_wm_space_node(C); /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->mx, &snode->my); @@ -4843,14 +4854,14 @@ void NODE_OT_attach(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** Detach ******************* */ /* tags for depth-first search */ -#define NODE_DETACH_DONE 1 -#define NODE_DETACH_IS_DESCENDANT 2 +#define NODE_DETACH_DONE 1 +#define NODE_DETACH_IS_DESCENDANT 2 static void node_detach_recursive(bNode *node) { @@ -4883,18 +4894,18 @@ static int node_detach_exec(bContext *C, wmOperator *UNUSED(op)) bNode *node; /* reset tags */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) node->done = 0; /* detach nodes recursively * relative order is preserved here! */ - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (!(node->done & NODE_DETACH_DONE)) node_detach_recursive(node); } ED_node_sort(ntree); - WM_event_add_notifier(C, NC_NODE|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -4911,5 +4922,5 @@ void NODE_OT_detach(wmOperatorType *ot) ot->poll = ED_operator_node_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 0d03df2298f..d4cfa2a3ba2 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -239,7 +239,7 @@ static void node_menu_add(const bContext *C, Menu *menu) bNodeTreeType *ntreetype= ntreeGetType(snode->treetype); if (!snode->nodetree) - uiLayoutSetActive(layout, 0); + uiLayoutSetActive(layout, FALSE); if (ntreetype && ntreetype->foreach_nodeclass) ntreetype->foreach_nodeclass(scene, layout, node_menu_add_foreach_cb); diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 97e64c4acdf..f12c7941e1d 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -68,11 +68,11 @@ static void node_tag_recursive(bNode *node) bNodeSocket *input; if (!node || (node->flag & NODE_TEST)) - return; /* in case of cycles */ - + return; /* in case of cycles */ + node->flag |= NODE_TEST; - for (input=node->inputs.first; input; input=input->next) + for (input = node->inputs.first; input; input = input->next) if (input->link) node_tag_recursive(input->link->fromnode); } @@ -82,11 +82,11 @@ static void node_clear_recursive(bNode *node) bNodeSocket *input; if (!node || !(node->flag & NODE_TEST)) - return; /* in case of cycles */ - + return; /* in case of cycles */ + node->flag &= ~NODE_TEST; - for (input=node->inputs.first; input; input=input->next) + for (input = node->inputs.first; input; input = input->next) if (input->link) node_clear_recursive(input->link->fromnode); } @@ -100,20 +100,20 @@ static void node_remove_linked(bNodeTree *ntree, bNode *rem_node) return; /* tag linked nodes to be removed */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) node->flag &= ~NODE_TEST; - + node_tag_recursive(rem_node); /* clear tags on nodes that are still used by other nodes */ - for (node=ntree->nodes.first; node; node=node->next) + for (node = ntree->nodes.first; node; node = node->next) if (!(node->flag & NODE_TEST)) - for (sock=node->inputs.first; sock; sock=sock->next) + for (sock = node->inputs.first; sock; sock = sock->next) if (sock->link && sock->link->fromnode != rem_node) node_clear_recursive(sock->link->fromnode); /* remove nodes */ - for (node=ntree->nodes.first; node; node=next) { + for (node = ntree->nodes.first; node; node = next) { next = node->next; if (node->flag & NODE_TEST) { @@ -166,7 +166,7 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t } /* find existing node that we can use */ - for (node_from=ntree->nodes.first; node_from; node_from=node_from->next) + for (node_from = ntree->nodes.first; node_from; node_from = node_from->next) if (node_from->type == ntemp->type) break; @@ -181,7 +181,7 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t node_from = node_prev; } else if (!node_from) { - node_from= nodeAddNode(ntree, ntemp); + node_from = nodeAddNode(ntree, ntemp); node_from->locx = node_to->locx - (node_from->typeinfo->width + 50); node_from->locy = node_to->locy; @@ -199,11 +199,11 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t if (node_prev && node_from != node_prev) { bNodeSocket *sock_prev, *sock_from; - for (sock_prev=node_prev->inputs.first; sock_prev; sock_prev=sock_prev->next) { - for (sock_from=node_from->inputs.first; sock_from; sock_from=sock_from->next) { + for (sock_prev = node_prev->inputs.first; sock_prev; sock_prev = sock_prev->next) { + for (sock_from = node_from->inputs.first; sock_from; sock_from = sock_from->next) { if (nodeCountSocketLinks(ntree, sock_from) >= sock_from->limit) continue; - + if (strcmp(sock_prev->name, sock_from->name) == 0 && sock_prev->type == sock_from->type) { bNodeLink *link = sock_prev->link; @@ -239,9 +239,9 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t /****************************** Node Link Menu *******************************/ -#define UI_NODE_LINK_ADD 0 -#define UI_NODE_LINK_DISCONNECT -1 -#define UI_NODE_LINK_REMOVE -2 +#define UI_NODE_LINK_ADD 0 +#define UI_NODE_LINK_DISCONNECT -1 +#define UI_NODE_LINK_REMOVE -2 typedef struct NodeLinkArg { Main *bmain; @@ -259,7 +259,7 @@ typedef struct NodeLinkArg { static void ui_node_link(bContext *C, void *arg_p, void *event_p) { - NodeLinkArg *arg = (NodeLinkArg*)arg_p; + NodeLinkArg *arg = (NodeLinkArg *)arg_p; Main *bmain = arg->bmain; bNode *node_to = arg->node; bNodeSocket *sock_to = arg->sock; @@ -278,7 +278,7 @@ static void ui_node_link(bContext *C, void *arg_p, void *event_p) node_socket_remove(bmain, ntree, node_to, sock_to); else node_socket_add_replace(bmain, ntree, node_to, sock_to, &ntemp, arg->output); - + ED_undo_push(C, "Node input modify"); } @@ -290,7 +290,7 @@ static void ui_node_sock_name(bNodeSocket *sock, char name[UI_MAX_NAME_STR]) if (node->type == NODE_GROUP) { if (node->id) - BLI_strncpy(node_name, node->id->name+2, UI_MAX_NAME_STR); + BLI_strncpy(node_name, node->id->name + 2, UI_MAX_NAME_STR); else BLI_strncpy(node_name, N_("Group"), UI_MAX_NAME_STR); } @@ -331,17 +331,17 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) bNodeTree *ngroup; NodeLinkArg *argN; int first = 1; - int compatibility= 0; + int compatibility = 0; if (ntree->type == NTREE_SHADER) { if (BKE_scene_use_new_shading_nodes(arg->scene)) - compatibility= NODE_NEW_SHADING; + compatibility = NODE_NEW_SHADING; else - compatibility= NODE_OLD_SHADING; + compatibility = NODE_OLD_SHADING; } if (nclass == NODE_CLASS_GROUP) { - for (ngroup=bmain->nodetree.first; ngroup; ngroup=ngroup->id.next) { + for (ngroup = bmain->nodetree.first; ngroup; ngroup = ngroup->id.next) { bNodeSocket *gsock; char name[UI_MAX_NAME_STR]; int i, j, num = 0; @@ -349,40 +349,40 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) if (ngroup->type != ntree->type) continue; - for (gsock=ngroup->inputs.first; gsock; gsock=gsock->next) + for (gsock = ngroup->inputs.first; gsock; gsock = gsock->next) if (ui_compatible_sockets(gsock->type, sock->type)) num++; - for (i=0, j=0, gsock=ngroup->outputs.first; gsock; gsock=gsock->next, i++) { + for (i = 0, j = 0, gsock = ngroup->outputs.first; gsock; gsock = gsock->next, i++) { if (!ui_compatible_sockets(gsock->type, sock->type)) continue; if (first) { - column= uiLayoutColumn(layout, 0); + column = uiLayoutColumn(layout, FALSE); uiBlockSetCurLayout(block, column); uiItemL(column, IFACE_(cname), ICON_NODE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; first = 0; } if (num > 1) { if (j == 0) { - uiItemL(column, ngroup->id.name+2, ICON_NODE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + uiItemL(column, ngroup->id.name + 2, ICON_NODE); + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; } BLI_snprintf(name, UI_MAX_NAME_STR, " %s", gsock->name); j++; } else - BLI_strncpy(name, ngroup->id.name+2, UI_MAX_NAME_STR); + BLI_strncpy(name, ngroup->id.name + 2, UI_MAX_NAME_STR); - but = uiDefBut(block, BUT, 0, ngroup->id.name+2, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); + but = uiDefBut(block, BUT, 0, ngroup->id.name + 2, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); argN = MEM_dupallocN(arg); argN->type = NODE_GROUP; @@ -393,9 +393,9 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) } } else { - bNodeTreeType *ttype= ntreeGetType(ntree->type); + bNodeTreeType *ttype = ntreeGetType(ntree->type); - for (ntype=ttype->node_types.first; ntype; ntype=ntype->next) { + for (ntype = ttype->node_types.first; ntype; ntype = ntype->next) { bNodeSocketTemplate *stemp; char name[UI_MAX_NAME_STR]; int i, j, num = 0; @@ -406,21 +406,21 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) if (ntype->nclass != nclass) continue; - for (i=0, stemp=ntype->outputs; stemp && stemp->type != -1; stemp++, i++) + for (i = 0, stemp = ntype->outputs; stemp && stemp->type != -1; stemp++, i++) if (ui_compatible_sockets(stemp->type, sock->type)) num++; - for (i=0, j=0, stemp=ntype->outputs; stemp && stemp->type != -1; stemp++, i++) { + for (i = 0, j = 0, stemp = ntype->outputs; stemp && stemp->type != -1; stemp++, i++) { if (!ui_compatible_sockets(stemp->type, sock->type)) continue; if (first) { - column= uiLayoutColumn(layout, 0); + column = uiLayoutColumn(layout, FALSE); uiBlockSetCurLayout(block, column); uiItemL(column, IFACE_(cname), ICON_NODE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; first = 0; } @@ -428,8 +428,8 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) if (num > 1) { if (j == 0) { uiItemL(column, IFACE_(ntype->name), ICON_NODE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; } BLI_snprintf(name, UI_MAX_NAME_STR, " %s", IFACE_(stemp->name)); @@ -438,8 +438,8 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) else BLI_strncpy(name, IFACE_(ntype->name), UI_MAX_NAME_STR); - but = uiDefBut(block, BUT, 0, name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); + but = uiDefBut(block, BUT, 0, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); argN = MEM_dupallocN(arg); argN->type = ntype->type; @@ -452,7 +452,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) static void node_menu_column_foreach_cb(void *calldata, int nclass, const char *name) { - NodeLinkArg *arg = (NodeLinkArg*)calldata; + NodeLinkArg *arg = (NodeLinkArg *)calldata; if (!ELEM(nclass, NODE_CLASS_GROUP, NODE_CLASS_LAYOUT)) ui_node_menu_column(arg, nclass, name); @@ -460,39 +460,39 @@ static void node_menu_column_foreach_cb(void *calldata, int nclass, const char * static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_p) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); uiBlock *block = uiLayoutGetBlock(layout); - uiBut *but = (uiBut*)but_p; + uiBut *but = (uiBut *)but_p; uiLayout *split, *column; - NodeLinkArg *arg = (NodeLinkArg*)but->func_argN; + NodeLinkArg *arg = (NodeLinkArg *)but->func_argN; bNodeSocket *sock = arg->sock; - bNodeTreeType *ntreetype= ntreeGetType(arg->ntree->type); + bNodeTreeType *ntreetype = ntreeGetType(arg->ntree->type); uiBlockSetCurLayout(block, layout); - split= uiLayoutSplit(layout, 0, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); + + arg->bmain = bmain; + arg->scene = scene; + arg->layout = split; - arg->bmain= bmain; - arg->scene= scene; - arg->layout= split; - if (ntreetype && ntreetype->foreach_nodeclass) ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb); - column= uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); uiBlockSetCurLayout(block, column); if (sock->link) { uiItemL(column, IFACE_("Link"), ICON_NONE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; - but = uiDefBut(block, BUT, 0, IFACE_("Remove"), 0, 0, UI_UNIT_X*4, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Remove nodes connected to the input")); + but = uiDefBut(block, BUT, 0, IFACE_("Remove"), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Remove nodes connected to the input")); uiButSetNFunc(but, ui_node_link, MEM_dupallocN(arg), SET_INT_IN_POINTER(UI_NODE_LINK_REMOVE)); - but = uiDefBut(block, BUT, 0, IFACE_("Disconnect"), 0, 0, UI_UNIT_X*4, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Disconnect nodes connected to the input")); + but = uiDefBut(block, BUT, 0, IFACE_("Disconnect"), 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Disconnect nodes connected to the input")); uiButSetNFunc(but, ui_node_link, MEM_dupallocN(arg), SET_INT_IN_POINTER(UI_NODE_LINK_DISCONNECT)); } @@ -517,14 +517,14 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo if (sock->link || sock->type == SOCK_SHADER || (sock->flag & SOCK_HIDE_VALUE)) { char name[UI_MAX_NAME_STR]; ui_node_sock_name(sock, name); - but = uiDefMenuBut(block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, ""); + but = uiDefMenuBut(block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, ""); } else but = uiDefIconMenuBut(block, ui_template_node_link_menu, NULL, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, ""); - but->type= MENU; - but->flag |= UI_TEXT_LEFT|UI_BUT_NODE_LINK; - but->poin= (char*)but; + but->type = MENU; + but->flag |= UI_TEXT_LEFT | UI_BUT_NODE_LINK; + but->poin = (char *)but; but->func_argN = arg; if (sock->link && sock->link->fromnode) @@ -535,7 +535,7 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo /**************************** Node Tree Layout *******************************/ static void ui_node_draw_input(uiLayout *layout, bContext *C, - bNodeTree *ntree, bNode *node, bNodeSocket *input, int depth); + bNodeTree *ntree, bNode *node, bNodeSocket *input, int depth); static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, int depth) { @@ -547,16 +547,16 @@ static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, b if (node->typeinfo->uifunc) { if (node->type != NODE_GROUP) { - split = uiLayoutSplit(layout, 0.35f, 0); - col = uiLayoutColumn(split, 0); - col = uiLayoutColumn(split, 0); + split = uiLayoutSplit(layout, 0.35f, FALSE); + col = uiLayoutColumn(split, FALSE); + col = uiLayoutColumn(split, FALSE); node->typeinfo->uifunc(col, C, &nodeptr); } } - for (input=node->inputs.first; input; input=input->next) - ui_node_draw_input(layout, C, ntree, node, input, depth+1); + for (input = node->inputs.first; input; input = input->next) + ui_node_draw_input(layout, C, ntree, node, input, depth + 1); } static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input, int depth) @@ -567,7 +567,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, uiLayout *split, *row, *col; bNode *lnode; char label[UI_MAX_NAME_STR]; - int indent = (depth > 1)? 2*(depth - 1): 0; + int indent = (depth > 1) ? 2 * (depth - 1) : 0; int dependency_loop; if (input->flag & SOCK_UNAVAIL) @@ -575,7 +575,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, /* to avoid eternal loops on cyclic dependencies */ node->flag |= NODE_TEST; - lnode = (input->link)? input->link->fromnode: NULL; + lnode = (input->link) ? input->link->fromnode : NULL; dependency_loop = (lnode && (lnode->flag & NODE_TEST)); if (dependency_loop) @@ -590,32 +590,32 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, BLI_snprintf(label, UI_MAX_NAME_STR, "%s%s:", label, IFACE_(input->name)); /* split in label and value */ - split = uiLayoutSplit(layout, 0.35f, 0); + split = uiLayoutSplit(layout, 0.35f, FALSE); - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); if (depth > 0) { uiBlockSetEmboss(block, UI_EMBOSSN); if (lnode && (lnode->inputs.first || (lnode->typeinfo->uifunc && lnode->type != NODE_GROUP))) { - int icon = (input->flag & SOCK_COLLAPSED)? ICON_DISCLOSURE_TRI_RIGHT: ICON_DISCLOSURE_TRI_DOWN; + int icon = (input->flag & SOCK_COLLAPSED) ? ICON_DISCLOSURE_TRI_RIGHT : ICON_DISCLOSURE_TRI_DOWN; uiItemR(row, &inputptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", icon); } else uiItemL(row, "", ICON_BLANK1); bt = block->buttons.last; - bt->x2 = UI_UNIT_X/2; + bt->x2 = UI_UNIT_X / 2; uiBlockSetEmboss(block, UI_EMBOSS); } uiItemL(row, label, ICON_NONE); - bt= block->buttons.last; - bt->flag= UI_TEXT_LEFT; + bt = block->buttons.last; + bt->flag = UI_TEXT_LEFT; if (dependency_loop) { - row = uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiItemL(row, IFACE_("Dependency Loop"), ICON_ERROR); } else if (lnode) { @@ -633,18 +633,18 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, /* input not linked, show value */ if (input->type != SOCK_SHADER && !(input->flag & SOCK_HIDE_VALUE)) { if (input->type == SOCK_VECTOR) { - row = uiLayoutRow(split, 0); - col = uiLayoutColumn(row, 0); + row = uiLayoutRow(split, FALSE); + col = uiLayoutColumn(row, FALSE); uiItemR(col, &inputptr, "default_value", 0, "", 0); } else { - row = uiLayoutRow(split, 1); + row = uiLayoutRow(split, TRUE); uiItemR(row, &inputptr, "default_value", 0, "", 0); } } else - row = uiLayoutRow(split, 0); + row = uiLayoutRow(split, FALSE); uiTemplateNodeLink(row, ntree, node, input); } @@ -661,7 +661,7 @@ void uiTemplateNodeView(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode * return; /* clear for cycle check */ - for (tnode=ntree->nodes.first; tnode; tnode=tnode->next) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) tnode->flag &= ~NODE_TEST; if (input) diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index e069ba2a5fc..349259ad71b 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -4,7 +4,7 @@ * 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. + * 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 @@ -18,7 +18,7 @@ * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. * - * + * * Contributor(s): Blender Foundation * * ***** END GPL LICENSE BLOCK ***** @@ -63,7 +63,7 @@ #include "RNA_access.h" -#include "node_intern.h" // own include +#include "node_intern.h" // own include /* ******************** manage regions ********************* */ @@ -71,23 +71,23 @@ ARegion *node_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; - + /* add subdiv level; after header */ - ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ - if (ar==NULL) return NULL; - - arnew= MEM_callocN(sizeof(ARegion), "buttons for node"); - + if (ar == NULL) return NULL; + + arnew = MEM_callocN(sizeof(ARegion), "buttons for node"); + BLI_insertlinkafter(&sa->regionbase, ar, arnew); - arnew->regiontype= RGN_TYPE_UI; - arnew->alignment= RGN_ALIGN_RIGHT; - + arnew->regiontype = RGN_TYPE_UI; + arnew->alignment = RGN_ALIGN_RIGHT; + arnew->flag = RGN_FLAG_HIDDEN; - + return arnew; } @@ -97,64 +97,64 @@ static SpaceLink *node_new(const bContext *UNUSED(C)) { ARegion *ar; SpaceNode *snode; - - snode= MEM_callocN(sizeof(SpaceNode), "initnode"); - snode->spacetype= SPACE_NODE; - + + snode = MEM_callocN(sizeof(SpaceNode), "initnode"); + snode->spacetype = SPACE_NODE; + /* backdrop */ snode->zoom = 1.0f; - + /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for node"); - + ar = MEM_callocN(sizeof(ARegion), "header for node"); + BLI_addtail(&snode->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; - + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; + /* buttons/list view */ - ar= MEM_callocN(sizeof(ARegion), "buttons for node"); - + ar = MEM_callocN(sizeof(ARegion), "buttons for node"); + BLI_addtail(&snode->regionbase, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; - + /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for node"); - + ar = MEM_callocN(sizeof(ARegion), "main area for node"); + BLI_addtail(&snode->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; - + ar->regiontype = RGN_TYPE_WINDOW; + ar->v2d.tot.xmin = -256.0f; ar->v2d.tot.ymin = -256.0f; ar->v2d.tot.xmax = 768.0f; ar->v2d.tot.ymax = 768.0f; - + ar->v2d.cur.xmin = -256.0f; ar->v2d.cur.ymin = -256.0f; ar->v2d.cur.xmax = 768.0f; ar->v2d.cur.ymax = 768.0f; - - ar->v2d.min[0]= 1.0f; - ar->v2d.min[1]= 1.0f; - - ar->v2d.max[0]= 32000.0f; - ar->v2d.max[1]= 32000.0f; - - ar->v2d.minzoom= 0.09f; - ar->v2d.maxzoom= 2.31f; - - ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); - ar->v2d.keepzoom= V2D_LIMITZOOM|V2D_KEEPASPECT; - ar->v2d.keeptot= 0; - + + ar->v2d.min[0] = 1.0f; + ar->v2d.min[1] = 1.0f; + + ar->v2d.max[0] = 32000.0f; + ar->v2d.max[1] = 32000.0f; + + ar->v2d.minzoom = 0.09f; + ar->v2d.maxzoom = 2.31f; + + ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); + ar->v2d.keepzoom = V2D_LIMITZOOM | V2D_KEEPASPECT; + ar->v2d.keeptot = 0; + return (SpaceLink *)snode; } /* not spacelink itself */ static void node_free(SpaceLink *UNUSED(sl)) -{ - +{ + } @@ -167,10 +167,10 @@ static void node_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) static void node_area_listener(ScrArea *sa, wmNotifier *wmn) { /* note, ED_area_tag_refresh will re-execute compositor */ - SpaceNode *snode= sa->spacedata.first; - int type= snode->treetype; + SpaceNode *snode = sa->spacedata.first; + int type = snode->treetype; short shader_type = snode->shaderfrom; - + /* preview renders */ switch (wmn->category) { case NC_SCENE: @@ -183,9 +183,9 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); break; case ND_TRANSFORM_DONE: - if (type==NTREE_COMPOSIT) { + if (type == NTREE_COMPOSIT) { if (snode->flag & SNODE_AUTO_RENDER) { - snode->recalc= 1; + snode->recalc = 1; ED_area_tag_refresh(sa); } } @@ -193,43 +193,43 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_WM: - if (wmn->data==ND_FILEREAD) + if (wmn->data == ND_FILEREAD) ED_area_tag_refresh(sa); break; - + /* future: add ID checks? */ case NC_MATERIAL: - if (type==NTREE_SHADER) { - if (wmn->data==ND_SHADING) + if (type == NTREE_SHADER) { + if (wmn->data == ND_SHADING) ED_area_tag_refresh(sa); - else if (wmn->data==ND_SHADING_DRAW) + else if (wmn->data == ND_SHADING_DRAW) ED_area_tag_refresh(sa); - else if (wmn->action==NA_ADDED && snode->edittree) + else if (wmn->action == NA_ADDED && snode->edittree) nodeSetActiveID(snode->edittree, ID_MA, wmn->reference); - + } break; case NC_TEXTURE: - if (type==NTREE_SHADER || type==NTREE_TEXTURE) { - if (wmn->data==ND_NODES) + if (type == NTREE_SHADER || type == NTREE_TEXTURE) { + if (wmn->data == ND_NODES) ED_area_tag_refresh(sa); } break; case NC_WORLD: - if (type==NTREE_SHADER && shader_type==SNODE_SHADER_WORLD) { - ED_area_tag_refresh(sa); + if (type == NTREE_SHADER && shader_type == SNODE_SHADER_WORLD) { + ED_area_tag_refresh(sa); } break; case NC_OBJECT: - if (type==NTREE_SHADER) { - if (wmn->data==ND_OB_SHADING) + if (type == NTREE_SHADER) { + if (wmn->data == ND_OB_SHADING) ED_area_tag_refresh(sa); } break; case NC_SPACE: - if (wmn->data==ND_SPACE_NODE) + if (wmn->data == ND_SPACE_NODE) ED_area_tag_refresh(sa); - else if (wmn->data==ND_SPACE_NODE_VIEW) + else if (wmn->data == ND_SPACE_NODE_VIEW) ED_area_tag_redraw(sa); break; case NC_NODE: @@ -247,7 +247,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_MASK: if (wmn->action == NA_EDITED) { - if (type==NTREE_COMPOSIT) { + if (type == NTREE_COMPOSIT) { ED_area_tag_refresh(sa); } } @@ -255,7 +255,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) case NC_IMAGE: if (wmn->action == NA_EDITED) { - if (type==NTREE_COMPOSIT) { + if (type == NTREE_COMPOSIT) { /* note that nodeUpdateID is already called by BKE_image_signal() on all * scenes so really this is just to know if the images is used in the compo else * painting on images could become very slow when the compositor is open. */ @@ -270,42 +270,42 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) static void node_area_refresh(const struct bContext *C, struct ScrArea *sa) { /* default now: refresh node is starting preview */ - SpaceNode *snode= sa->spacedata.first; + SpaceNode *snode = sa->spacedata.first; snode_set_context(snode, CTX_data_scene(C)); - + if (snode->nodetree) { - if (snode->treetype==NTREE_SHADER) { + if (snode->treetype == NTREE_SHADER) { if (GS(snode->id->name) == ID_MA) { - Material *ma= (Material *)snode->id; + Material *ma = (Material *)snode->id; if (ma->use_nodes) ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } else if (GS(snode->id->name) == ID_LA) { - Lamp *la= (Lamp *)snode->id; + Lamp *la = (Lamp *)snode->id; if (la->use_nodes) ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } else if (GS(snode->id->name) == ID_WO) { - World *wo= (World *)snode->id; + World *wo = (World *)snode->id; if (wo->use_nodes) ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } } - else if (snode->treetype==NTREE_COMPOSIT) { - Scene *scene= (Scene *)snode->id; + else if (snode->treetype == NTREE_COMPOSIT) { + Scene *scene = (Scene *)snode->id; if (scene->use_nodes) { /* recalc is set on 3d view changes for auto compo */ if (snode->recalc) { - snode->recalc= 0; - node_render_changed_exec((struct bContext*)C, NULL); + snode->recalc = 0; + node_render_changed_exec((struct bContext *)C, NULL); } - else + else snode_composite_job(C, sa); } } - else if (snode->treetype==NTREE_TEXTURE) { - Tex *tex= (Tex *)snode->id; + else if (snode->treetype == NTREE_TEXTURE) { + Tex *tex = (Tex *)snode->id; if (tex->use_nodes) { ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } @@ -315,12 +315,12 @@ static void node_area_refresh(const struct bContext *C, struct ScrArea *sa) static SpaceLink *node_duplicate(SpaceLink *sl) { - SpaceNode *snoden= MEM_dupallocN(sl); - + SpaceNode *snoden = MEM_dupallocN(sl); + /* clear or remove stuff from old */ - snoden->nodetree= NULL; - snoden->linkdrag.first= snoden->linkdrag.last= NULL; - + snoden->nodetree = NULL; + snoden->linkdrag.first = snoden->linkdrag.last = NULL; + return (SpaceLink *)snoden; } @@ -331,7 +331,7 @@ static void node_buttons_area_init(wmWindowManager *wm, ARegion *ar) wmKeyMap *keymap; ED_region_panels_init(wm, ar); - + keymap = WM_keymap_find(wm->defaultconf, "Node Generic", SPACE_NODE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -343,12 +343,12 @@ static void node_buttons_area_draw(const bContext *C, ARegion *ar) static void node_cursor(wmWindow *win, ScrArea *sa, ARegion *ar) { - SpaceNode *snode= sa->spacedata.first; - + SpaceNode *snode = sa->spacedata.first; + /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin, &snode->mx, &snode->my); - + node_set_cursor(win, snode); } @@ -357,26 +357,26 @@ static void node_main_area_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; ListBase *lb; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); - + /* own keymaps */ keymap = WM_keymap_find(wm->defaultconf, "Node Generic", SPACE_NODE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - + keymap = WM_keymap_find(wm->defaultconf, "Node Editor", SPACE_NODE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - + /* add drop boxes */ lb = WM_dropboxmap_find("Node Editor", SPACE_NODE, RGN_TYPE_WINDOW); - + WM_event_add_dropbox_handler(&ar->handlers, lb); } static void node_main_area_draw(const bContext *C, ARegion *ar) { - View2D *v2d= &ar->v2d; - + View2D *v2d = &ar->v2d; + drawnodespace(C, ar, v2d); } @@ -385,13 +385,13 @@ static void node_main_area_draw(const bContext *C, ARegion *ar) static int node_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if (drag->type==WM_DRAG_ID) { - ID *id= (ID *)drag->poin; - if ( GS(id->name)==ID_IM ) + if (drag->type == WM_DRAG_ID) { + ID *id = (ID *)drag->poin; + if (GS(id->name) == ID_IM) return 1; } - else if (drag->type==WM_DRAG_PATH) { - if (ELEM(drag->icon, 0, ICON_FILE_IMAGE)) /* rule might not work? */ + else if (drag->type == WM_DRAG_PATH) { + if (ELEM(drag->icon, 0, ICON_FILE_IMAGE)) /* rule might not work? */ return 1; } return 0; @@ -399,10 +399,10 @@ static int node_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(eve static void node_id_path_drop_copy(wmDrag *drag, wmDropBox *drop) { - ID *id= (ID *)drag->poin; - + ID *id = (ID *)drag->poin; + if (id) { - RNA_string_set(drop->ptr, "name", id->name+2); + RNA_string_set(drop->ptr, "name", id->name + 2); } if (drag->path[0]) { RNA_string_set(drop->ptr, "filepath", drag->path); @@ -412,10 +412,10 @@ static void node_id_path_drop_copy(wmDrag *drag, wmDropBox *drop) /* this region dropbox definition */ static void node_dropboxes(void) { - ListBase *lb= WM_dropboxmap_find("Node Editor", SPACE_NODE, RGN_TYPE_WINDOW); - + ListBase *lb = WM_dropboxmap_find("Node Editor", SPACE_NODE, RGN_TYPE_WINDOW); + WM_dropbox_add(lb, "NODE_OT_add_file", node_drop_poll, node_id_path_drop_copy); - + } /* ************* end drop *********** */ @@ -429,8 +429,8 @@ static void node_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar) static void node_header_area_draw(const bContext *C, ARegion *ar) { - SpaceNode *snode= CTX_wm_space_node(C); - Scene *scene= CTX_data_scene(C); + SpaceNode *snode = CTX_wm_space_node(C); + Scene *scene = CTX_data_scene(C); /* find and set the context */ snode_set_context(snode, scene); @@ -444,12 +444,19 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch (wmn->category) { case NC_SPACE: - if (wmn->data==ND_SPACE_NODE) + if (wmn->data == ND_SPACE_NODE) ED_region_tag_redraw(ar); break; case NC_SCREEN: - if (wmn->data == ND_GPENCIL) - ED_region_tag_redraw(ar); + switch (wmn->data) { + case ND_GPENCIL: + ED_region_tag_redraw(ar); + break; + case ND_SCREENCAST: + case ND_ANIMPLAY: + ED_region_tag_redraw(ar); + break; + } break; case NC_SCENE: case NC_MATERIAL: @@ -458,7 +465,7 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case NC_OBJECT: - if (wmn->data==ND_OB_SHADING) + if (wmn->data == ND_OB_SHADING) ED_region_tag_redraw(ar); break; case NC_ID: @@ -472,17 +479,17 @@ const char *node_context_dir[] = {"selected_nodes", "active_node", NULL}; static int node_context(const bContext *C, const char *member, bContextDataResult *result) { - SpaceNode *snode= CTX_wm_space_node(C); - + SpaceNode *snode = CTX_wm_space_node(C); + if (CTX_data_dir(member)) { CTX_data_dir_set(result, node_context_dir); return 1; } else if (CTX_data_equals(member, "selected_nodes")) { bNode *node; - + if (snode->edittree) { - for (node=snode->edittree->nodes.last; node; node=node->prev) { + for (node = snode->edittree->nodes.last; node; node = node->prev) { if (node->flag & NODE_SELECT) { CTX_data_list_add(result, &snode->edittree->id, &RNA_Node, node); } @@ -500,67 +507,67 @@ static int node_context(const bContext *C, const char *member, bContextDataResul CTX_data_type_set(result, CTX_DATA_TYPE_POINTER); return 1; } - + return 0; } /* only called once, from space/spacetypes.c */ void ED_spacetype_node(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype node"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype node"); ARegionType *art; - - st->spaceid= SPACE_NODE; + + st->spaceid = SPACE_NODE; strncpy(st->name, "Node", BKE_ST_MAXNAME); - - st->new= node_new; - st->free= node_free; - st->init= node_init; - st->duplicate= node_duplicate; - st->operatortypes= node_operatortypes; - st->keymap= node_keymap; - st->listener= node_area_listener; - st->refresh= node_area_refresh; - st->context= node_context; + + st->new = node_new; + st->free = node_free; + st->init = node_init; + st->duplicate = node_duplicate; + st->operatortypes = node_operatortypes; + st->keymap = node_keymap; + st->listener = node_area_listener; + st->refresh = node_area_refresh; + st->context = node_context; st->dropboxes = node_dropboxes; - + /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype node region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype node region"); art->regionid = RGN_TYPE_WINDOW; - art->init= node_main_area_init; - art->draw= node_main_area_draw; - art->listener= node_region_listener; + art->init = node_main_area_init; + art->draw = node_main_area_draw; + art->listener = node_region_listener; art->cursor = node_cursor; art->event_cursor = TRUE; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_GPENCIL; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_GPENCIL; BLI_addhead(&st->regiontypes, art); - + /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype node region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype node region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; - art->listener= node_region_listener; - art->init= node_header_area_init; - art->draw= node_header_area_draw; - + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; + art->listener = node_region_listener; + art->init = node_header_area_init; + art->draw = node_header_area_draw; + BLI_addhead(&st->regiontypes, art); node_menus_register(); - + /* regions: listview/buttons */ - art= MEM_callocN(sizeof(ARegionType), "spacetype node region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype node region"); art->regionid = RGN_TYPE_UI; - art->prefsizex= 180; // XXX - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; - art->listener= node_region_listener; - art->init= node_buttons_area_init; - art->draw= node_buttons_area_draw; + art->prefsizex = 180; // XXX + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; + art->listener = node_region_listener; + art->init = node_buttons_area_init; + art->draw = node_buttons_area_draw; BLI_addhead(&st->regiontypes, art); - + node_buttons_register(art); - + BKE_spacetype_register(st); } diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index f0ecaf3ab2c..42fdd5173d4 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -202,26 +202,39 @@ static int group_restrict_flag(Group *gr, int flag) { GroupObject *gob; +#ifdef USE_GROUP_SELECT for (gob = gr->gobject.first; gob; gob = gob->next) { if ((gob->ob->restrictflag & flag) == 0) return 0; } - return 1; +#else + /* weak but fast */ + if ((gob = gr->gobject.first)) + if ((gob->ob->restrictflag & flag) == 0) + return 0; + return 1; +#endif } -#ifdef USE_GROUP_SELECT static int group_select_flag(Group *gr) { GroupObject *gob; +#ifdef USE_GROUP_SELECT for (gob = gr->gobject.first; gob; gob = gob->next) if ((gob->ob->flag & SELECT)) return 1; return 0; -} +#else + /* weak but fast */ + if ((gob = gr->gobject.first)) + if (gob->ob->flag & SELECT) + return 1; + return 0; #endif +} void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) { @@ -428,25 +441,15 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSSN); -#ifndef USE_GROUP_SELECT - restrict_bool = FALSE; -#endif - -#ifdef USE_GROUP_SELECT restrict_bool = group_restrict_flag(gr, OB_RESTRICT_VIEW); -#endif bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr); -#ifdef USE_GROUP_SELECT restrict_bool = group_restrict_flag(gr, OB_RESTRICT_SELECT); -#endif bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr); -#ifdef USE_GROUP_SELECT restrict_bool = group_restrict_flag(gr, OB_RESTRICT_RENDER); -#endif bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr); @@ -1289,7 +1292,6 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene } } else if (te->idcode == ID_GR) { -#ifdef USE_GROUP_SELECT Group *gr = (Group *)tselem->id; if (group_select_flag(gr)) { char col[4]; @@ -1299,7 +1301,6 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene active = 2; } -#endif } else if (te->idcode == ID_OB) { Object *ob = (Object *)tselem->id; @@ -1540,7 +1541,7 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; outliner_draw_selection(ar, soops, &soops->tree, &starty); - // grey hierarchy lines + // gray hierarchy lines UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.4f); starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y / 2 - OL_Y_OFFSET; startx = 6; diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index eb740e441b7..449914feae4 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1360,7 +1360,7 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot) /* identifiers */ ot->idname = "OUTLINER_OT_keyingset_add_selected"; ot->name = "Keying Set Add Selected"; - ot->description = "Add selected items (blue-grey rows) to active Keying Set"; + ot->description = "Add selected items (blue-gray rows) to active Keying Set"; /* api callbacks */ ot->exec = outliner_keyingset_additems_exec; @@ -1397,7 +1397,7 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) /* identifiers */ ot->idname = "OUTLINER_OT_keyingset_remove_selected"; ot->name = "Keying Set Remove Selected"; - ot->description = "Remove selected items (blue-grey rows) from active Keying Set"; + ot->description = "Remove selected items (blue-gray rows) from active Keying Set"; /* api callbacks */ ot->exec = outliner_keyingset_removeitems_exec; diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 812fba50295..096713f9cd3 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -69,7 +69,7 @@ #include "outliner_intern.h" /* ****************************************************** */ -/* Outliner Selection (grey-blue highlight for rows) */ +/* Outliner Selection (gray-blue highlight for rows) */ static int outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *selecting) { diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c index 1e452f2052d..7dbcabedccc 100644 --- a/source/blender/editors/space_sequencer/sequencer_buttons.c +++ b/source/blender/editors/space_sequencer/sequencer_buttons.c @@ -58,7 +58,7 @@ void sequencer_buttons_register(ARegionType *art) pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel gpencil"); strcpy(pt->idname, "SEQUENCER_PT_gpencil"); strcpy(pt->label, N_("Grease Pencil")); - pt->draw= gpencil_panel_standard; + pt->draw = gpencil_panel_standard; BLI_addtail(&art->paneltypes, pt); } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index e48450e93bd..38f29e8816e 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -72,8 +72,11 @@ #include "sequencer_intern.h" -#define SEQ_LEFTHANDLE 1 -#define SEQ_RIGHTHANDLE 2 +#define SEQ_LEFTHANDLE 1 +#define SEQ_RIGHTHANDLE 2 + +#define SEQ_HANDLE_SIZE_MIN 7.0f +#define SEQ_HANDLE_SIZE_MAX 40.0f /* Note, Don't use SEQ_BEGIN/SEQ_END while drawing! @@ -325,13 +328,19 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, glDisable(GL_BLEND); } +/* clamp handles to defined size in pixel space */ +static float draw_seq_handle_size_get_clamped(Sequence *seq, const float pixelx) +{ + const float minhandle = pixelx * SEQ_HANDLE_SIZE_MIN; + const float maxhandle = pixelx * SEQ_HANDLE_SIZE_MAX; + return CLAMPIS(seq->handsize, minhandle, maxhandle); +} + /* draw a handle, for each end of a sequence strip */ -static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short direction) +static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_clamped, const short direction) { float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; //for triangles and rect float x1, x2, y1, y2; - float handsize; - float minhandle, maxhandle; char numstr[32]; unsigned int whichsel = 0; @@ -340,31 +349,25 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; y2 = seq->machine + SEQ_STRIP_OFSTOP; - - /* clamp handles to defined size in pixel space */ - handsize = seq->handsize; - minhandle = 7; - maxhandle = 40; - CLAMP(handsize, minhandle * pixelx, maxhandle * pixelx); - + /* set up co-ordinates/dimensions for either left or right handle */ if (direction == SEQ_LEFTHANDLE) { rx1 = x1; - rx2 = x1 + handsize * 0.75f; + rx2 = x1 + handsize_clamped * 0.75f; - v1[0] = x1 + handsize / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2); - v2[0] = x1 + handsize / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2); - v3[0] = v2[0] + handsize / 4; v3[1] = (y1 + y2) / 2.0f; + v1[0] = x1 + handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2); + v2[0] = x1 + handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2); + v3[0] = v2[0] + handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f; whichsel = SEQ_LEFTSEL; } else if (direction == SEQ_RIGHTHANDLE) { - rx1 = x2 - handsize * 0.75f; + rx1 = x2 - handsize_clamped * 0.75f; rx2 = x2; - v1[0] = x2 - handsize / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2); - v2[0] = x2 - handsize / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2); - v3[0] = v2[0] - handsize / 4; v3[1] = (y1 + y2) / 2.0f; + v1[0] = x2 - handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2); + v2[0] = x2 - handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2); + v3[0] = v2[0] - handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f; whichsel = SEQ_RIGHTSEL; } @@ -404,7 +407,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire } else { BLI_snprintf(numstr, sizeof(numstr), "%d", seq->enddisp - 1); - x1 = x2 - handsize * 0.75f; + x1 = x2 - handsize_clamped * 0.75f; y1 = y2 + 0.05f; } UI_view2d_text_cache_add(v2d, x1, y1, numstr, col); @@ -530,67 +533,67 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float name = give_seqname(seq); if (seq->type == SEQ_TYPE_META || seq->type == SEQ_TYPE_ADJUSTMENT) { - BLI_snprintf(str, sizeof(str), "%d | %s", seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } else if (seq->type == SEQ_TYPE_SCENE) { if (seq->scene) { if (seq->scene_camera) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s (%s)", - seq->len, name, seq->scene->id.name + 2, ((ID *)seq->scene_camera)->name + 2); + BLI_snprintf(str, sizeof(str), "%s: %s (%s) | %d", + name, seq->scene->id.name + 2, ((ID *)seq->scene_camera)->name + 2, seq->len); } else { - BLI_snprintf(str, sizeof(str), "%d | %s: %s", - seq->len, name, seq->scene->id.name + 2); + BLI_snprintf(str, sizeof(str), "%s: %s | %d", + name, seq->scene->id.name + 2, seq->len); } } else { - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } } else if (seq->type == SEQ_TYPE_MOVIECLIP) { if (seq->clip && strcmp(name, seq->clip->id.name + 2) != 0) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s", - seq->len, name, seq->clip->id.name + 2); + BLI_snprintf(str, sizeof(str), "%s: %s | %d", + name, seq->clip->id.name + 2, seq->len); } else { - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } } else if (seq->type == SEQ_TYPE_MASK) { if (seq->mask && strcmp(name, seq->mask->id.name + 2) != 0) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s", - seq->len, name, seq->mask->id.name + 2); + BLI_snprintf(str, sizeof(str), "%s: %s | %d", + name, seq->mask->id.name + 2, seq->len); } else { - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } } else if (seq->type == SEQ_TYPE_MULTICAM) { - BLI_snprintf(str, sizeof(str), "Cam | %s: %d", + BLI_snprintf(str, sizeof(str), "Cam %s: %d", name, seq->multicam_source); } else if (seq->type == SEQ_TYPE_IMAGE) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s%s", - seq->len, name, seq->strip->dir, seq->strip->stripdata->name); + BLI_snprintf(str, sizeof(str), "%s: %s%s | %d", + name, seq->strip->dir, seq->strip->stripdata->name, seq->len); } else if (seq->type & SEQ_TYPE_EFFECT) { - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } else if (seq->type == SEQ_TYPE_SOUND_RAM) { if (seq->sound) - BLI_snprintf(str, sizeof(str), "%d | %s: %s", - seq->len, name, seq->sound->name); + BLI_snprintf(str, sizeof(str), "%s: %s | %d", + name, seq->sound->name, seq->len); else - BLI_snprintf(str, sizeof(str), "%d | %s", - seq->len, name); + BLI_snprintf(str, sizeof(str), "%s | %d", + name, seq->len); } else if (seq->type == SEQ_TYPE_MOVIE) { - BLI_snprintf(str, sizeof(str), "%d | %s: %s%s", - seq->len, name, seq->strip->dir, seq->strip->stripdata->name); + BLI_snprintf(str, sizeof(str), "%s: %s%s | %d", + name, seq->strip->dir, seq->strip->stripdata->name, seq->len); } if (seq->flag & SELECT) { @@ -679,6 +682,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline View2D *v2d = &ar->v2d; float x1, x2, y1, y2; unsigned char col[3], background_col[3], is_single_image; + const float handsize_clamped = draw_seq_handle_size_get_clamped(seq, pixelx); /* we need to know if this is a single image/color or not for drawing */ is_single_image = (char)seq_single_check(seq); @@ -706,8 +710,8 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline if (!is_single_image) draw_seq_extensions(scene, ar, seq); - draw_seq_handle(v2d, seq, pixelx, SEQ_LEFTHANDLE); - draw_seq_handle(v2d, seq, pixelx, SEQ_RIGHTHANDLE); + draw_seq_handle(v2d, seq, handsize_clamped, SEQ_LEFTHANDLE); + draw_seq_handle(v2d, seq, handsize_clamped, SEQ_RIGHTHANDLE); /* draw the strip outline */ x1 = seq->startdisp; @@ -766,8 +770,8 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline } /* calculate if seq is long enough to print a name */ - x1 = seq->startdisp + seq->handsize; - x2 = seq->enddisp - seq->handsize; + x1 = seq->startdisp + handsize_clamped; + x2 = seq->enddisp - handsize_clamped; /* info text on the strip */ if (x1 < v2d->cur.xmin) x1 = v2d->cur.xmin; @@ -1072,7 +1076,7 @@ static void draw_seq_backdrop(View2D *v2d) { int i; - /* darker grey overlay over the view backdrop */ + /* darker gray overlay over the view backdrop */ UI_ThemeColorShade(TH_BACK, -20); glRectf(v2d->cur.xmin, -1.0, v2d->cur.xmax, 1.0); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index c686f8440a9..7ed5c77ed1f 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1570,16 +1570,6 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } -static int sequencer_add_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) -{ - sequencer_add_duplicate_exec(C, op); - - RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION); - WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); - - return OPERATOR_FINISHED; -} - void SEQUENCER_OT_duplicate(wmOperatorType *ot) { /* identifiers */ @@ -1588,7 +1578,6 @@ void SEQUENCER_OT_duplicate(wmOperatorType *ot) ot->description = "Duplicate the selected strips"; /* api callbacks */ - ot->invoke = sequencer_add_duplicate_invoke; ot->exec = sequencer_add_duplicate_exec; ot->poll = ED_operator_sequencer_active; @@ -2705,8 +2694,11 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - sound_remove_scene_sound(scene, seq_act->scene_sound); - sound_remove_scene_sound(scene, seq_other->scene_sound); + if (seq_act->scene_sound) + sound_remove_scene_sound(scene, seq_act->scene_sound); + + if (seq_other->scene_sound) + sound_remove_scene_sound(scene, seq_other->scene_sound); seq_act->scene_sound = NULL; seq_other->scene_sound = NULL; diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 79ecd9f7481..4a1c8f0c006 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -167,7 +167,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_offset_clear", OKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "SEQUENCER_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "SEQUENCER_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", DELKEY, KM_PRESS, 0, 0); @@ -321,3 +321,13 @@ void sequencer_keymap(wmKeyConfig *keyconf) #endif } +void ED_operatormacros_sequencer(void) +{ + wmOperatorType *ot; + + ot = WM_operatortype_append_macro("SEQUENCER_OT_duplicate_move", "Duplicate Strips", + "Duplicate selected strips and move them", OPTYPE_UNDO | OPTYPE_REGISTER); + + WM_operatortype_macro_define(ot, "SEQUENCER_OT_duplicate"); + WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); +} diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index b03edfc61b9..a55f0edc06c 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -587,14 +587,14 @@ static int select_more_less_seq__internal(Scene *scene, int sel, int linked) /* only get unselected nabours */ neighbor = find_neighboring_sequence(scene, seq, SEQ_SIDE_LEFT, isel); if (neighbor) { - if (sel) {neighbor->flag |= SELECT; recurs_sel_seq(neighbor); } + if (sel) { neighbor->flag |= SELECT; recurs_sel_seq(neighbor); } else neighbor->flag &= ~SELECT; if (linked == 0) neighbor->tmp = (Sequence *)1; change = 1; } neighbor = find_neighboring_sequence(scene, seq, SEQ_SIDE_RIGHT, isel); if (neighbor) { - if (sel) {neighbor->flag |= SELECT; recurs_sel_seq(neighbor); } + if (sel) { neighbor->flag |= SELECT; recurs_sel_seq(neighbor); } else neighbor->flag &= ~SELECT; if (linked == 0) neighbor->tmp = (void *)1; change = 1; diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index b8bf764fabc..cabc761161e 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -454,6 +454,10 @@ static void sequencer_main_area_listener(ARegion *ar, wmNotifier *wmn) if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; + case NC_SCREEN: + if (ELEM(wmn->data, ND_SCREENCAST, ND_ANIMPLAY)) + ED_region_tag_redraw(ar); + break; } } diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 3ebc4eb974c..f0275fb6584 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -830,7 +830,7 @@ void TEXT_OT_paste(wmOperatorType *ot) static int text_duplicate_line_exec(bContext *C, wmOperator *UNUSED(op)) { - Text *text= CTX_data_edit_text(C); + Text *text = CTX_data_edit_text(C); txt_duplicate_line(text); @@ -1341,7 +1341,7 @@ static int move_lines_exec(bContext *C, wmOperator *op) txt_move_lines(text, direction); text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); + WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); /* run the script while editing, evil but useful */ if (CTX_wm_space_text(C)->live_edit) @@ -1352,7 +1352,7 @@ static int move_lines_exec(bContext *C, wmOperator *op) void TEXT_OT_move_lines(wmOperatorType *ot) { - static EnumPropertyItem direction_items[]= { + static EnumPropertyItem direction_items[] = { {TXT_MOVE_LINE_UP, "UP", 0, "Up", ""}, {TXT_MOVE_LINE_DOWN, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c index 248f73b9ab6..5376b82f24c 100644 --- a/source/blender/editors/space_userpref/space_userpref.c +++ b/source/blender/editors/space_userpref/space_userpref.c @@ -57,23 +57,23 @@ static SpaceLink *userpref_new(const bContext *UNUSED(C)) { ARegion *ar; SpaceUserPref *spref; - - spref= MEM_callocN(sizeof(SpaceUserPref), "inituserpref"); - spref->spacetype= SPACE_USERPREF; - + + spref = MEM_callocN(sizeof(SpaceUserPref), "inituserpref"); + spref->spacetype = SPACE_USERPREF; + /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for userpref"); - + ar = MEM_callocN(sizeof(ARegion), "header for userpref"); + BLI_addtail(&spref->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; - + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; + /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for userpref"); - + ar = MEM_callocN(sizeof(ARegion), "main area for userpref"); + BLI_addtail(&spref->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; - + ar->regiontype = RGN_TYPE_WINDOW; + return (SpaceLink *)spref; } @@ -93,10 +93,10 @@ static void userpref_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa static SpaceLink *userpref_duplicate(SpaceLink *sl) { - SpaceUserPref *sprefn= MEM_dupallocN(sl); - + SpaceUserPref *sprefn = MEM_dupallocN(sl); + /* clear or remove stuff from old */ - + return (SpaceLink *)sprefn; } @@ -155,41 +155,41 @@ static void userpref_header_listener(ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn /* only called once, from space/spacetypes.c */ void ED_spacetype_userpref(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype userpref"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype userpref"); ARegionType *art; - - st->spaceid= SPACE_USERPREF; + + st->spaceid = SPACE_USERPREF; strncpy(st->name, "Userpref", BKE_ST_MAXNAME); - - st->new= userpref_new; - st->free= userpref_free; - st->init= userpref_init; - st->duplicate= userpref_duplicate; - st->operatortypes= userpref_operatortypes; - st->keymap= userpref_keymap; - + + st->new = userpref_new; + st->free = userpref_free; + st->init = userpref_init; + st->duplicate = userpref_duplicate; + st->operatortypes = userpref_operatortypes; + st->keymap = userpref_keymap; + /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); art->regionid = RGN_TYPE_WINDOW; - art->init= userpref_main_area_init; - art->draw= userpref_main_area_draw; - art->listener= userpref_main_area_listener; - art->keymapflag= ED_KEYMAP_UI; + art->init = userpref_main_area_init; + art->draw = userpref_main_area_draw; + art->listener = userpref_main_area_listener; + art->keymapflag = ED_KEYMAP_UI; BLI_addhead(&st->regiontypes, art); - + /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype userpref region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER; - art->listener= userpref_header_listener; - art->init= userpref_header_area_init; - art->draw= userpref_header_area_draw; - + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; + art->listener = userpref_header_listener; + art->init = userpref_header_area_init; + art->draw = userpref_header_area_draw; + BLI_addhead(&st->regiontypes, art); - - + + BKE_spacetype_register(st); } diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index e51f7a312eb..33aada7b811 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -2269,7 +2269,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) } } -/* ****************************** Armature Visualisation ******************************** */ +/* ****************************** Armature Visualization ******************************** */ /* ---------- Paths --------- */ diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index b92d3d9d24c..339b5560711 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -6442,7 +6442,7 @@ static void draw_hooks(Object *ob) } } -static void drawRBpivot(bRigidBodyJointConstraint *data, const unsigned char ob_wire_col[4]) +static void draw_rigid_body_pivot(bRigidBodyJointConstraint *data, const unsigned char ob_wire_col[4]) { const char *axis_str[3] = {"px", "py", "pz"}; int axis; @@ -7068,12 +7068,13 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short if (con->type == CONSTRAINT_TYPE_RIGIDBODYJOINT) { bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)con->data; if (data->flag & CONSTRAINT_DRAW_PIVOT) - drawRBpivot(data, ob_wire_col); + draw_rigid_body_pivot(data, ob_wire_col); } } if (ob->gameflag & OB_BOUNDS) { if (ob->boundtype != ob->collision_boundtype || (dtx & OB_BOUNDBOX) == 0) { + setlinestyle(2); draw_bounding_volume(scene, ob, ob->collision_boundtype); setlinestyle(0); @@ -7108,8 +7109,11 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short } if (dt <= OB_SOLID && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { - if ((ob->gameflag & OB_DYNAMIC) || - ((ob->gameflag & OB_BOUNDS) && (ob->boundtype == OB_BOUND_SPHERE))) + if (((ob->gameflag & OB_DYNAMIC) && + !ELEM(ob->collision_boundtype, OB_BOUND_TRIANGLE_MESH, OB_BOUND_CONVEX_HULL)) || + + ((ob->gameflag & OB_BOUNDS) && + (ob->boundtype == OB_BOUND_SPHERE))) { float imat[4][4], vec[3] = {0.0f, 0.0f, 0.0f}; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 4a135f91d91..6cfa828024d 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -834,7 +834,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) uiBlockSetHandleFunc(block, do_view3d_vgroup_buttons, NULL); - col = uiLayoutColumn(pa->layout, 0); + col = uiLayoutColumn(pa->layout, FALSE); block = uiLayoutAbsoluteBlock(col); uiBlockBeginAlign(block); @@ -856,7 +856,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) uiDefBut(block, BUT, B_VGRP_PNL_NORMALIZE, IFACE_("Normalize"), 0, yco, 100, 20, NULL, 0, 0, 0, 0, TIP_("Normalize active vertex weights")); uiDefBut(block, BUT, B_VGRP_PNL_COPY, IFACE_("Copy"), 100, yco, 100, 20, - NULL, 0, 0, 0, 0, TIP_("Copy active vertex to other seleted verts")); + NULL, 0, 0, 0, 0, TIP_("Copy active vertex to other selected verts")); uiBlockEndAlign(block); } } @@ -865,7 +865,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) { uiLayout *split, *colsub; - split = uiLayoutSplit(layout, 0.8, 0); + split = uiLayoutSplit(layout, 0.8f, FALSE); if (ptr->type == &RNA_PoseBone) { PointerRNA boneptr; @@ -875,19 +875,19 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) bone = boneptr.data; uiLayoutSetActive(split, !(bone->parent && bone->flag & BONE_CONNECTED)); } - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "location", 0, NULL, ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemL(colsub, "", ICON_NONE); uiItemR(colsub, ptr, "lock_location", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); - split = uiLayoutSplit(layout, 0.8, 0); + split = uiLayoutSplit(layout, 0.8f, FALSE); switch (RNA_enum_get(ptr, "rotation_mode")) { case ROT_MODE_QUAT: /* quaternion */ - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "rotation_quaternion", 0, IFACE_("Rotation"), ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE); if (RNA_boolean_get(ptr, "lock_rotations_4d")) uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE + UI_ITEM_R_ICON_ONLY, "", ICON_NONE); @@ -896,9 +896,9 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); break; case ROT_MODE_AXISANGLE: /* axis angle */ - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "rotation_axis_angle", 0, IFACE_("Rotation"), ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE); if (RNA_boolean_get(ptr, "lock_rotations_4d")) uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); @@ -907,19 +907,19 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); break; default: /* euler rotations */ - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "rotation_euler", 0, IFACE_("Rotation"), ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemL(colsub, "", ICON_NONE); uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); break; } uiItemR(layout, ptr, "rotation_mode", 0, "", ICON_NONE); - split = uiLayoutSplit(layout, 0.8, 0); - colsub = uiLayoutColumn(split, 1); + split = uiLayoutSplit(layout, 0.8f, FALSE); + colsub = uiLayoutColumn(split, TRUE); uiItemR(colsub, ptr, "scale", 0, NULL, ICON_NONE); - colsub = uiLayoutColumn(split, 1); + colsub = uiLayoutColumn(split, TRUE); uiItemL(colsub, "", ICON_NONE); uiItemR(colsub, ptr, "lock_scale", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_NONE); @@ -948,7 +948,7 @@ static void v3d_posearmature_buts(uiLayout *layout, Object *ob) RNA_pointer_create(&ob->id, &RNA_PoseBone, pchan, &pchanptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); /* XXX: RNA buts show data in native types (i.e. quats, 4-component axis/angle, etc.) * but old-school UI shows in eulers always. Do we want to be able to still display in Eulers? @@ -972,7 +972,7 @@ static void v3d_editarmature_buts(uiLayout *layout, Object *ob) RNA_pointer_create(&arm->id, &RNA_EditBone, ebone, &eboneptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, &eboneptr, "head", 0, NULL, ICON_NONE); if (ebone->parent && ebone->flag & BONE_CONNECTED) { PointerRNA parptr = RNA_pointer_get(&eboneptr, "parent"); @@ -1002,7 +1002,7 @@ static void v3d_editmetaball_buts(uiLayout *layout, Object *ob) RNA_pointer_create(&mball->id, &RNA_MetaElement, mball->lastelem, &ptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemR(col, &ptr, "co", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "radius", 0, NULL, ICON_NONE); @@ -1010,7 +1010,7 @@ static void v3d_editmetaball_buts(uiLayout *layout, Object *ob) uiItemR(col, &ptr, "type", 0, NULL, ICON_NONE); - col = uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, TRUE); switch (RNA_enum_get(&ptr, "type")) { case MB_BALL: break; @@ -1081,8 +1081,8 @@ static void view3d_panel_object(const bContext *C, Panel *pa) block = uiLayoutGetBlock(pa->layout); uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL); - col = uiLayoutColumn(pa->layout, 0); - /* row = uiLayoutRow(col, 0); */ /* UNUSED */ + col = uiLayoutColumn(pa->layout, FALSE); + /* row = uiLayoutRow(col, FALSE); */ /* UNUSED */ RNA_id_pointer_create(&ob->id, &obptr); if (ob == obedit) { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 709a73178aa..e6ea42aa5ba 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1561,7 +1561,12 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, if (ima == NULL) continue; BKE_image_user_frame_calc(&bgpic->iuser, CFRA, 0); - ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser); + if (ima->source == IMA_SRC_SEQUENCE && !(bgpic->iuser.flag & IMA_USER_FRAME_IN_RANGE)) { + ibuf = NULL; /* frame is out of range, dont show */ + } + else { + ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser); + } image_aspect[0] = ima->aspx; image_aspect[1] = ima->aspx; @@ -1589,6 +1594,11 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, * be dereferenced after usage. */ freeibuf = ibuf; } + else { + /* perhaps when loading future files... */ + BLI_assert(0); + copy_v2_fl(image_aspect, 1.0f); + } if (ibuf == NULL) continue; @@ -2790,6 +2800,14 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar) static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const char **grid_unit); +static int view3d_main_area_do_render_draw(const bContext *C) +{ + Scene *scene = CTX_data_scene(C); + RenderEngineType *type = RE_engines_find(scene->r.engine); + + return (type && type->view_update && type->view_draw); +} + static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw_border) { Scene *scene = CTX_data_scene(C); @@ -3126,7 +3144,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) int draw_border = (rv3d->persp == RV3D_CAMOB && (scene->r.mode & R_BORDER)); /* draw viewport using opengl */ - if (v3d->drawtype != OB_RENDER || draw_border) { + if (v3d->drawtype != OB_RENDER || !view3d_main_area_do_render_draw(C) || draw_border) { view3d_main_area_draw_objects(C, ar, &grid_unit); ED_region_pixelspace(ar); } diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index a68caeb0719..eb202497260 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -451,7 +451,7 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C) BMEditMesh *em = BMEdit_FromObject(obedit); uiLayout *row; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); block = uiLayoutGetBlock(row); uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, 0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Vertex select - Shift-Click for multiple modes"); uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, 0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Edge select - Shift-Click for multiple modes"); @@ -494,7 +494,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) v3d->modeselect = OB_MODE_OBJECT; } - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene), 0, 0, 126 * dpi_fac, UI_UNIT_Y, &(v3d->modeselect), 0, 0, 0, 0, TIP_("Mode")); @@ -512,7 +512,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); } else { - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); uiItemR(row, &meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); } @@ -521,7 +521,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) else { const char *str_menu; - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* pose/object only however we want to allow in weight paint mode too @@ -531,7 +531,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) } /* Transform widget / manipulators */ - row = uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, TRUE); uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); block = uiLayoutGetBlock(row); diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index ff896a95941..ee1ead76f7c 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -211,12 +211,12 @@ static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) for (ct = st->toolshelf.first; ct; ct = ct->next) { if (0 == strncmp(context, ct->context, OP_MAX_TYPENAME)) { - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); uiItemFullO(col, ct->opname, NULL, ICON_NONE, NULL, WM_OP_INVOKE_REGION_WIN, 0); } } } - col = uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, TRUE); uiDefBlockBut(uiLayoutGetBlock(pa->layout), tool_search_menu, &st->toolshelf, "Add Tool", 0, 0, UI_UNIT_X, UI_UNIT_Y, "Add Tool in shelf, gets saved in files"); } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 8fb012a18d6..4782b95ba1c 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1564,13 +1564,15 @@ static void endlocalview(Main *bmain, Scene *scene, ScrArea *sa) static int localview_exec(bContext *C, wmOperator *UNUSED(unused)) { + Main *bmain = CTX_data_main(C); View3D *v3d = CTX_wm_view3d(C); if (v3d->localvd) endlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C)); else initlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C)); - + + DAG_id_type_tag(bmain, ID_OB); ED_area_tag_redraw(CTX_wm_area(C)); return OPERATOR_FINISHED; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 67e87afc5c3..164c1dd7c12 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -183,11 +183,11 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy) r_vec[2] = 0.0f; if (t->options & CTX_MOVIECLIP) { - ED_space_clip_get_clip_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy); } else if (t->options & CTX_MASK) { /* TODO - NOT WORKING, this isnt so bad since its only display aspect */ - ED_space_clip_get_mask_aspect(t->sa->spacedata.first, &aspx, &aspy); + ED_space_clip_get_aspect(t->sa->spacedata.first, &aspx, &aspy); } r_vec[0] *= aspx; @@ -254,9 +254,9 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) copy_v2_v2(v, vec); if (t->options & CTX_MOVIECLIP) - ED_space_clip_get_clip_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(t->sa->spacedata.first, &aspx, &aspy); else if (t->options & CTX_MASK) - ED_space_clip_get_mask_aspect(t->sa->spacedata.first, &aspx, &aspy); + ED_space_clip_get_aspect(t->sa->spacedata.first, &aspx, &aspy); v[0] /= aspx; v[1] /= aspy; @@ -317,13 +317,13 @@ void applyAspectRatio(TransInfo *t, float vec[2]) if (t->options & CTX_MOVIECLIP) { - ED_space_clip_get_clip_aspect_dimension_aware(sc, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(sc, &aspx, &aspy); vec[0] /= aspx; vec[1] /= aspy; } else if (t->options & CTX_MASK) { - ED_space_clip_get_mask_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); vec[0] /= aspx; vec[1] /= aspy; @@ -356,10 +356,10 @@ void removeAspectRatio(TransInfo *t, float vec[2]) float aspx = 1.0f, aspy = 1.0f; if (t->options & CTX_MOVIECLIP) { - ED_space_clip_get_clip_aspect_dimension_aware(sc, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(sc, &aspx, &aspy); } else if (t->options & CTX_MASK) { - ED_space_clip_get_mask_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); } vec[0] *= aspx; @@ -1655,6 +1655,12 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int unit_m3(t->spacemtx); t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); } + else if (t->spacetype == SPACE_NODE) { + unit_m3(t->spacemtx); + /*t->draw_handle_apply = ED_region_draw_cb_activate(t->ar->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW);*/ + t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); + /*t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);*/ + } else unit_m3(t->spacemtx); @@ -2170,8 +2176,8 @@ static void constraintob_from_transdata(bConstraintOb *cob, TransData *td) if (td->ext->rotOrder == ROT_MODE_QUAT) { /* quats */ /* objects and bones do normalization first too, otherwise - * we don't necessarily end up with a rotation matrix, and - * then conversion back to quat gives a different result */ + * we don't necessarily end up with a rotation matrix, and + * then conversion back to quat gives a different result */ float quat[4]; normalize_qt_qt(quat, td->ext->quat); quat_to_mat4(cob->matrix, quat); @@ -3542,6 +3548,11 @@ void initTranslation(TransInfo *t) t->snap[1] = 0.125f; t->snap[2] = 0.0625f; } + else if (t->spacetype == SPACE_NODE) { + t->snap[0] = 0.0f; + t->snap[1] = 125.0f; + t->snap[2] = 25.0f; + } else { t->snap[0] = 0.0f; t->snap[1] = t->snap[2] = 1.0f; @@ -5004,7 +5015,6 @@ void projectSVData(TransInfo *t, int final) for (i = 0, sv = sld->sv; i < sld->totsv; sv++, i++) { BMIter fiter; BMFace *f; - /* BMESH_TODO, this interpolates between vertex/loops which are not moved * (are only apart of a face attached to a slide vert), couldn't we iterate BM_LOOPS_OF_VERT @@ -5034,6 +5044,8 @@ void projectSVData(TransInfo *t, int final) /* project onto copied projection face */ BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { + /* only affected verts will get interpolated */ + char affected = FALSE; f_copy_flip = f_copy; if (BM_elem_flag_test(l->e, BM_ELEM_SELECT) || BM_elem_flag_test(l->prev->e, BM_ELEM_SELECT)) { @@ -5058,6 +5070,8 @@ void projectSVData(TransInfo *t, int final) if (!f_copy_flip) { continue; /* shouldn't happen, but protection */ } + + affected = TRUE; } else { /* the loop is attached to only one vertex and not a selected edge, @@ -5094,10 +5108,15 @@ void projectSVData(TransInfo *t, int final) f_copy_flip = BLI_smallhash_lookup(&sld->origfaces, (uintptr_t)e_sel->l->radial_next->f); } } + + affected = TRUE; } } + if(!affected) + continue; + /* only loop data, no vertex data since that contains shape keys, * and we do not want to mess up other shape keys */ BM_loop_interp_from_face(em->bm, l, f_copy_flip, FALSE, FALSE); @@ -5122,7 +5141,7 @@ void projectSVData(TransInfo *t, int final) } } } - + BLI_smallhash_release(&visit); } diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index fdc09c1bed0..3ab5bf7bbfb 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -86,6 +86,7 @@ typedef struct TransSnap { float snapTarget[3]; /* to this point */ float snapNormal[3]; float snapTangent[3]; + char snapNodeBorder; ListBase points; TransSnapPoint *selectedPoint; float dist; // Distance from snapPoint to snapTarget diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index d2910c5b602..034ea3eb704 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -276,7 +276,7 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 sub_v3_v3v3(out, i1, t_con_center); /* possible some values become nan when - * viewpoint and object are both zero */ + * viewpoint and object are both zero */ if (!finite(out[0])) out[0] = 0.0f; if (!finite(out[1])) out[1] = 0.0f; if (!finite(out[2])) out[2] = 0.0f; @@ -306,7 +306,7 @@ static void planeProjection(TransInfo *t, float in[3], float out[3]) } /* - * Generic callback for constant spacial constraints applied to linear motion + * Generic callback for constant spatial constraints applied to linear motion * * The IN vector in projected into the constrained space and then further * projected along the view vector. @@ -404,9 +404,7 @@ static void applyObjectConstraintVec(TransInfo *t, TransData *td, float in[3], f } /* - * Generic callback for constant spacial constraints applied to resize motion - * - * + * Generic callback for constant spatial constraints applied to resize motion */ static void applyAxisConstraintSize(TransInfo *t, TransData *td, float smat[3][3]) @@ -430,9 +428,7 @@ static void applyAxisConstraintSize(TransInfo *t, TransData *td, float smat[3][3 } /* - * Callback for object based spacial constraints applied to resize motion - * - * + * Callback for object based spatial constraints applied to resize motion */ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3][3]) @@ -459,7 +455,7 @@ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3] } /* - * Generic callback for constant spacial constraints applied to rotations + * Generic callback for constant spatial constraints applied to rotations * * The rotation axis is copied into VEC. * @@ -501,7 +497,7 @@ static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], fl } /* - * Callback for object based spacial constraints applied to rotations + * Callback for object based spatial constraints applied to rotations * * The rotation axis is copied into VEC. * @@ -644,7 +640,7 @@ void drawConstraint(TransInfo *t) { TransCon *tc = &(t->con); - if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) + if (!ELEM3(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE)) return; if (!(tc->mode & CON_APPLY)) return; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index a9716483db7..af0b33d58ae 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2819,7 +2819,7 @@ static void posttrans_mask_clean(Mask *mask) short added = 0; masklay_shape_new = masklay_shape->next; - if (masklay_shape->flag & GP_FRAME_SELECT) { + if (masklay_shape->flag & MASK_SHAPE_SELECT) { BLI_remlink(&masklay->splines_shapes, masklay_shape); /* find place to add them in buffer @@ -5516,8 +5516,11 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node) } td->loc = td2d->loc; - copy_v3_v3(td->center, td->loc); copy_v3_v3(td->iloc, td->loc); + /* use node center instead of origin (top-left corner) */ + td->center[0] = node->locx + 0.5f * (node->totr.xmax - node->totr.xmin); + td->center[1] = node->locy - 0.5f * (node->totr.ymax - node->totr.ymin); /* node height is used negative */ + td->center[2] = 0.0f; memset(td->axismtx, 0, sizeof(td->axismtx)); td->axismtx[2][2] = 1.0f; @@ -5529,6 +5532,8 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node) unit_m3(td->mtx); unit_m3(td->smtx); + + td->extra = node; } static void createTransNodeData(bContext *C, TransInfo *t) @@ -5736,7 +5741,7 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) if (t->total == 0) return; - ED_space_clip_get_clip_aspect_dimension_aware(sc, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(sc, &aspx, &aspy); td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransTracking TransData"); td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransTracking TransData2D"); @@ -5913,9 +5918,12 @@ static void createTransTrackingData(bContext *C, TransInfo *t) t->total = 0; + if (!clip) + return; + BKE_movieclip_get_size(clip, &sc->user, &width, &height); - if (!clip || width == 0 || height == 0) + if (width == 0 || height == 0) return; if (ar->regiontype == RGN_TYPE_PREVIEW) { @@ -5992,7 +6000,7 @@ void flushTransTracking(TransInfo *t) int a; float aspx, aspy; - ED_space_clip_get_clip_aspect_dimension_aware(sc, &aspx, &aspy); + ED_space_clip_get_aspect_dimension_aware(sc, &aspx, &aspy); if (t->state == TRANS_CANCEL) cancelTransTracking(t); @@ -6072,7 +6080,7 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point, tdm->point = point; copy_m3_m3(tdm->vec, bezt->vec); - ED_space_clip_get_mask_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); if (propmode || is_sel_point) { int i; @@ -6250,7 +6258,7 @@ void flushTransMasking(TransInfo *t) int a; float aspx, aspy, invx, invy; - ED_space_clip_get_mask_aspect(sc, &aspx, &aspy); + ED_space_clip_get_aspect(sc, &aspx, &aspy); invx = 1.0f / aspx; invy = 1.0f / aspy; @@ -6321,7 +6329,7 @@ void createTransData(bContext *C, TransInfo *t) #endif } else if (t->spacetype == SPACE_NODE) { - t->flag |= T_2D_EDIT | T_POINTS; + t->flag |= T_POINTS | T_2D_EDIT; createTransNodeData(C, t); if (t->data && (t->flag & T_PROP_EDIT)) { sort_trans_data(t); // makes selected become first in array diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 0ecfa2695e0..9f335b4afe7 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -643,7 +643,7 @@ static void recalcData_spaceclip(TransInfo *t) MovieClip *clip = ED_space_clip_get_clip(sc); ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking); MovieTrackingTrack *track; - int framenr = sc->user.framenr; + int framenr = ED_space_clip_get_clip_frame_number(sc); flushTransTracking(t); diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index b3ccf004810..1507dbfddda 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -745,7 +745,7 @@ static char axisBlendAngle(float angle) } /* three colors can be set; - * grey for ghosting + * gray for ghosting * moving: in transform theme color * else the red/green/blue */ diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 90b67951614..c49e1715f34 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -42,6 +42,7 @@ #include "DNA_object_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" // Temporary, for snapping to other unselected meshes +#include "DNA_node_types.h" #include "DNA_space_types.h" #include "DNA_screen_types.h" #include "DNA_view3d_types.h" @@ -74,6 +75,7 @@ #include "ED_armature.h" #include "ED_image.h" #include "ED_mesh.h" +#include "ED_node.h" #include "ED_uvedit.h" #include "ED_view3d.h" @@ -113,6 +115,9 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3]); /****************** IMPLEMENTATIONS *********************/ +static int snapNodeTest(View2D *v2d, bNode *node, SnapMode mode); +static NodeBorder snapNodeBorder(int snap_node_mode); + #if 0 int BIF_snappingSupported(Object *obedit) { @@ -140,19 +145,22 @@ int activeSnap(TransInfo *t) void drawSnapping(const struct bContext *C, TransInfo *t) { - if (validSnap(t) && activeSnap(t)) { - - unsigned char col[4], selectedCol[4], activeCol[4]; - UI_GetThemeColor3ubv(TH_TRANSFORM, col); - col[3] = 128; - - UI_GetThemeColor3ubv(TH_SELECT, selectedCol); - selectedCol[3] = 128; - - UI_GetThemeColor3ubv(TH_ACTIVE, activeCol); - activeCol[3] = 192; - - if (t->spacetype == SPACE_VIEW3D) { + unsigned char col[4], selectedCol[4], activeCol[4]; + + if (!activeSnap(t)) + return; + + UI_GetThemeColor3ubv(TH_TRANSFORM, col); + col[3] = 128; + + UI_GetThemeColor3ubv(TH_SELECT, selectedCol); + selectedCol[3] = 128; + + UI_GetThemeColor3ubv(TH_ACTIVE, activeCol); + activeCol[3] = 192; + + if (t->spacetype == SPACE_VIEW3D) { + if (validSnap(t)) { TransSnapPoint *p; View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); @@ -160,11 +168,11 @@ void drawSnapping(const struct bContext *C, TransInfo *t) float size; glDisable(GL_DEPTH_TEST); - + size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); - + invert_m4_m4(imat, rv3d->viewmat); - + for (p = t->tsnap.points.first; p; p = p->next) { if (p == t->tsnap.selectedPoint) { glColor4ubv(selectedCol); @@ -172,20 +180,20 @@ void drawSnapping(const struct bContext *C, TransInfo *t) else { glColor4ubv(col); } - + drawcircball(GL_LINE_LOOP, p->co, ED_view3d_pixel_size(rv3d, p->co) * size * 0.75f, imat); } - + if (t->tsnap.status & POINT_INIT) { glColor4ubv(activeCol); - + drawcircball(GL_LINE_LOOP, t->tsnap.snapPoint, ED_view3d_pixel_size(rv3d, t->tsnap.snapPoint) * size, imat); } /* draw normal if needed */ if (usingSnappingNormal(t) && validSnappingNormal(t)) { glColor4ubv(activeCol); - + glBegin(GL_LINES); glVertex3f(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]); glVertex3f(t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0], @@ -197,7 +205,9 @@ void drawSnapping(const struct bContext *C, TransInfo *t) if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } - else if (t->spacetype == SPACE_IMAGE) { + } + else if (t->spacetype == SPACE_IMAGE) { + if (validSnap(t)) { /* This will not draw, and Im nor sure why - campbell */ #if 0 float xuser_asp, yuser_asp; @@ -228,7 +238,36 @@ void drawSnapping(const struct bContext *C, TransInfo *t) glTranslatef(-t->tsnap.snapPoint[0], -t->tsnap.snapPoint[1], 0.0f); setlinestyle(0); #endif + } + } + else if (t->spacetype == SPACE_NODE) { + if (validSnap(t)) { + ARegion *ar = CTX_wm_region(C); + TransSnapPoint *p; + float size; + + size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); + + glEnable(GL_BLEND); + for (p = t->tsnap.points.first; p; p = p->next) { + if (p == t->tsnap.selectedPoint) { + glColor4ubv(selectedCol); + } + else { + glColor4ubv(col); + } + + drawnodesnap(&ar->v2d, p->co, size, 0); + } + + if (t->tsnap.status & POINT_INIT) { + glColor4ubv(activeCol); + + drawnodesnap(&ar->v2d, t->tsnap.snapPoint, size, t->tsnap.snapNodeBorder); + } + + glDisable(GL_BLEND); } } } @@ -349,6 +388,8 @@ void resetSnapping(TransInfo *t) t->tsnap.snapNormal[0] = 0; t->tsnap.snapNormal[1] = 0; t->tsnap.snapNormal[2] = 0; + + t->tsnap.snapNodeBorder = 0; } int usingSnappingNormal(TransInfo *t) @@ -373,12 +414,20 @@ static void initSnappingMode(TransInfo *t) Object *obedit = t->obedit; Scene *scene = t->scene; - /* force project off when not supported */ - if (ts->snap_mode != SCE_SNAP_MODE_FACE) { + if (t->spacetype == SPACE_NODE) { + /* force project off when not supported */ t->tsnap.project = 0; + + t->tsnap.mode = ts->snap_node_mode; + } + else { + /* force project off when not supported */ + if (ts->snap_mode != SCE_SNAP_MODE_FACE) { + t->tsnap.project = 0; + } + + t->tsnap.mode = ts->snap_mode; } - - t->tsnap.mode = ts->snap_mode; if ((t->spacetype == SPACE_VIEW3D || t->spacetype == SPACE_IMAGE) && /* Only 3D view or UV */ (t->flag & T_CAMERA) == 0) /* Not with camera selected in camera view */ @@ -414,6 +463,19 @@ static void initSnappingMode(TransInfo *t) t->tsnap.mode = SCE_SNAP_MODE_INCREMENT; } } + else if (t->spacetype == SPACE_NODE) + { + setSnappingCallback(t); + + if (t->tsnap.applySnap != NULL) + { + t->tsnap.modeSelect = SNAP_NOT_SELECTED; + } + else { + /* Grid if snap is not possible */ + t->tsnap.mode = SCE_SNAP_MODE_INCREMENT; + } + } else { /* Always grid outside of 3D view */ t->tsnap.mode = SCE_SNAP_MODE_INCREMENT; @@ -459,7 +521,7 @@ void initSnapping(TransInfo *t, wmOperator *op) } /* use scene defaults only when transform is modal */ else if (t->flag & T_MODAL) { - if (ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) { + if (ELEM3(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE)) { if (ts->snap_flag & SCE_SNAP) { t->modifiers |= MOD_SNAP; } @@ -624,7 +686,17 @@ static void ApplySnapTranslation(TransInfo *t, float vec[3]) { float point[3]; getSnapPoint(t, point); - sub_v3_v3v3(vec, point, t->tsnap.snapTarget); + + if (t->spacetype == SPACE_NODE) { + char border = t->tsnap.snapNodeBorder; + if (border & (NODE_LEFT | NODE_RIGHT)) + vec[0] = point[0] - t->tsnap.snapTarget[0]; + if (border & (NODE_BOTTOM | NODE_TOP)) + vec[1] = point[1] - t->tsnap.snapTarget[1]; + } + else { + sub_v3_v3v3(vec, point, t->tsnap.snapTarget); + } } static void ApplySnapRotation(TransInfo *t, float *value) @@ -879,20 +951,57 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) t->tsnap.status &= ~POINT_INIT; } } + else if (t->spacetype == SPACE_NODE) { + float loc[2]; + int dist = SNAP_MIN_DISTANCE; // Use a user defined value here + char node_border; + + if (snapNodesTransform(t, t->mval, &dist, loc, &node_border, t->tsnap.modeSelect)) { + copy_v2_v2(t->tsnap.snapPoint, loc); + t->tsnap.snapNodeBorder = node_border; + + t->tsnap.status |= POINT_INIT; + } + else { + t->tsnap.status &= ~POINT_INIT; + } + } } /********************** TARGET **************************/ +static void TargetSnapOffset(TransInfo *t, TransData *td) +{ + if (t->spacetype == SPACE_NODE && td != NULL) { + bNode *node = td->extra; + char border = t->tsnap.snapNodeBorder; + float width = node->totr.xmax - node->totr.xmin; + float height = node->totr.ymax - node->totr.ymin; + + if (border & NODE_LEFT) + t->tsnap.snapTarget[0] -= 0.5f * width; + if (border & NODE_RIGHT) + t->tsnap.snapTarget[0] += 0.5f * width; + if (border & NODE_BOTTOM) + t->tsnap.snapTarget[1] -= 0.5f * height; + if (border & NODE_TOP) + t->tsnap.snapTarget[1] += 0.5f * height; + } +} + static void TargetSnapCenter(TransInfo *t) { /* Only need to calculate once */ if ((t->tsnap.status & TARGET_INIT) == 0) { copy_v3_v3(t->tsnap.snapTarget, t->center); + if (t->flag & (T_EDIT | T_POSE)) { Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } + TargetSnapOffset(t, NULL); + t->tsnap.status |= TARGET_INIT; } } @@ -914,12 +1023,14 @@ static void TargetSnapActive(TransInfo *t) if (active_td) { copy_v3_v3(t->tsnap.snapTarget, active_td->center); - + if (t->flag & (T_EDIT | T_POSE)) { Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } + TargetSnapOffset(t, active_td); + t->tsnap.status |= TARGET_INIT; } /* No active, default to median */ @@ -953,6 +1064,8 @@ static void TargetSnapMedian(TransInfo *t) mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } + TargetSnapOffset(t, NULL); + t->tsnap.status |= TARGET_INIT; } } @@ -1029,6 +1142,8 @@ static void TargetSnapClosest(TransInfo *t) } } + TargetSnapOffset(t, closest); + t->tsnap.status |= TARGET_INIT; } } @@ -1876,6 +1991,113 @@ int peelObjectsContext(bContext *C, ListBase *depth_peels, const float mval[2], return peelObjects(CTX_data_scene(C), v3d, CTX_wm_region(C), CTX_data_edit_object(C), depth_peels, mval, mode); } +/******************** NODES ***********************************/ + +static int snapNodeTest(View2D *v2d, bNode *node, SnapMode mode) +{ + /* node is use for snapping only if a) snap mode matches and b) node is inside the view */ + return ((mode == SNAP_NOT_SELECTED && !(node->flag & NODE_SELECT)) || + (mode == SNAP_ALL && !(node->flag & NODE_ACTIVE))) && + (node->totr.xmin < v2d->cur.xmax && node->totr.xmax > v2d->cur.xmin && + node->totr.ymin < v2d->cur.ymax && node->totr.ymax > v2d->cur.ymin); +} + +static NodeBorder snapNodeBorder(int snap_node_mode) +{ + switch (snap_node_mode) { + case SCE_SNAP_MODE_NODE_X: + return NODE_LEFT | NODE_RIGHT; + case SCE_SNAP_MODE_NODE_Y: + return NODE_TOP | NODE_BOTTOM; + case SCE_SNAP_MODE_NODE_XY: + return NODE_LEFT | NODE_RIGHT | NODE_TOP | NODE_BOTTOM; + } + return 0; +} + +static int snapNode(ToolSettings *ts, SpaceNode *UNUSED(snode), ARegion *ar, bNode *node, const int mval[2], + float r_loc[2], int *r_dist, char *r_node_border) +{ + View2D *v2d = &ar->v2d; + NodeBorder border = snapNodeBorder(ts->snap_node_mode); + int retval = 0; + rcti totr; + int new_dist; + + UI_view2d_to_region_no_clip(v2d, node->totr.xmin, node->totr.ymin, &totr.xmin, &totr.ymin); + UI_view2d_to_region_no_clip(v2d, node->totr.xmax, node->totr.ymax, &totr.xmax, &totr.ymax); + + if (border & NODE_LEFT) { + new_dist = abs(totr.xmin - mval[0]); + if (new_dist < *r_dist) { + UI_view2d_region_to_view(v2d, totr.xmin, mval[1], &r_loc[0], &r_loc[1]); + *r_dist = new_dist; + *r_node_border = NODE_LEFT; + retval = 1; + } + } + + if (border & NODE_RIGHT) { + new_dist = abs(totr.xmax - mval[0]); + if (new_dist < *r_dist) { + UI_view2d_region_to_view(v2d, totr.xmax, mval[1], &r_loc[0], &r_loc[1]); + *r_dist = new_dist; + *r_node_border = NODE_RIGHT; + retval = 1; + } + } + + if (border & NODE_BOTTOM) { + new_dist = abs(totr.ymin - mval[1]); + if (new_dist < *r_dist) { + UI_view2d_region_to_view(v2d, mval[0], totr.ymin, &r_loc[0], &r_loc[1]); + *r_dist = new_dist; + *r_node_border = NODE_BOTTOM; + retval = 1; + } + } + + if (border & NODE_TOP) { + new_dist = abs(totr.ymax - mval[1]); + if (new_dist < *r_dist) { + UI_view2d_region_to_view(v2d, mval[0], totr.ymax, &r_loc[0], &r_loc[1]); + *r_dist = new_dist; + *r_node_border = NODE_TOP; + retval = 1; + } + } + + return retval; +} + +static int snapNodes(ToolSettings *ts, SpaceNode *snode, ARegion *ar, const int mval[2], + int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode) +{ + bNodeTree *ntree = snode->edittree; + bNode *node; + int retval = 0; + + *r_node_border = 0; + + for (node = ntree->nodes.first; node; node = node->next) { + if (snapNodeTest(&ar->v2d, node, mode)) + retval |= snapNode(ts, snode, ar, node, mval, r_loc, r_dist, r_node_border); + } + + return retval; +} + +int snapNodesTransform(TransInfo *t, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode) +{ + return snapNodes(t->settings, t->sa->spacedata.first, t->ar, mval, r_dist, r_loc, r_node_border, mode); +} + +int snapNodesContext(bContext *C, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode) +{ + Scene *scene = CTX_data_scene(C); + return snapNodes(scene->toolsettings, CTX_wm_space_node(C), CTX_wm_region(C), mval, r_dist, r_loc, r_node_border, mode); +} + /*================================================================*/ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], GearsType action); diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 65d23641ab5..0c2bfff3b57 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -493,12 +493,13 @@ static int undo_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even if (totitem > 0) { uiPopupMenu *pup = uiPupMenuBegin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); uiLayout *layout = uiPupMenuLayout(pup); - uiLayout *split = uiLayoutSplit(layout, 0, 0), *column = NULL; + uiLayout *split = uiLayoutSplit(layout, 0.0f, FALSE); + uiLayout *column = NULL; int i, c; for (c = 0, i = totitem - 1; i >= 0; i--, c++) { if ( (c % 20) == 0) - column = uiLayoutColumn(split, 0); + column = uiLayoutColumn(split, FALSE); if (item[i].identifier) uiItemIntO(column, item[i].name, item[i].icon, op->type->idname, "item", item[i].value); diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index a90f8253654..17c57b1f6e4 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -133,7 +133,7 @@ static void draw_uvs_shadow(Object *obedit) BMIter iter, liter; MLoopUV *luv; - /* draws the grey mesh when painting */ + /* draws the gray mesh when painting */ glColor3ub(112, 112, 112); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { @@ -467,7 +467,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) /* draw other uvs */ if (sima->flag & SI_DRAW_OTHER) { - Image *curimage = (activetf) ? activetf->tpage : NULL; + Image *curimage = (activetf) ? activetf->tpage : ima; draw_uvs_other(scene, obedit, curimage); } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index b15df9c3e89..216ac61b628 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -3402,7 +3402,8 @@ static void UV_OT_cursor_set(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in normalised (0.0-1.0) coordinates", -10.0f, 10.0f); + RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", + "Cursor location in normalized (0.0-1.0) coordinates", -10.0f, 10.0f); } /********************** set tile operator **********************/ diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 59e384cbd4b..d80e756f0b6 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -71,5 +71,10 @@ endif() add_definitions(-DGLEW_STATIC) +if(WITH_IMAGE_DDS) + add_definitions(-DWITH_DDS) +endif() + + blender_add_lib(bf_gpu "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 438cfd6b741..59140b2be80 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -122,6 +122,9 @@ void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h, int m void GPU_update_images_framechange(void); int GPU_update_image_time(struct Image *ima, double time); int GPU_verify_image(struct Image *ima, struct ImageUser *iuser, int tftile, int compare, int mipmap); +void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float *frect, int rectw, int recth, int mipmap, int use_hight_bit_depth, struct Image *ima); +void GPU_create_gl_tex_compressed(unsigned int *bind, unsigned int *pix, int x, int y, int mipmap, struct Image *ima, struct ImBuf *ibuf); +int GPU_upload_dxt_texture(struct ImBuf *ibuf); void GPU_free_image(struct Image *ima); void GPU_free_images(void); void GPU_free_images_anim(void); diff --git a/source/blender/gpu/SConscript b/source/blender/gpu/SConscript index cf1c91f25fe..7ab0c6cce46 100644 --- a/source/blender/gpu/SConscript +++ b/source/blender/gpu/SConscript @@ -17,4 +17,7 @@ incs += ' ' + env['BF_OPENGL_INC'] if env['WITH_BF_SMOKE']: defs.append('WITH_SMOKE') +if env['WITH_BF_DDS']: + defs.append('WITH_DDS') + env.BlenderLib ( 'bf_gpu', sources, Split(incs), defines = defs, libtype=['core','player'], priority=[160,110] ) diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index e718a486561..8a31a454633 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -240,7 +240,8 @@ static struct GPUTextureState { /* Mipmap settings */ -void GPU_set_gpu_mipmapping(int gpu_mipmap){ +void GPU_set_gpu_mipmapping(int gpu_mipmap) +{ int old_value = GTS.gpu_mipmap; /* only actually enable if it's supported */ @@ -426,8 +427,8 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int ImBuf *ibuf = NULL; unsigned int *bind = NULL; int rectw, recth, tpx=0, tpy=0, y; - unsigned int *tilerect= NULL, *scalerect= NULL, *rect= NULL; - float *ftilerect= NULL, *fscalerect = NULL, *frect = NULL; + unsigned int *tilerect= NULL, *rect= NULL; + float *ftilerect= NULL, *frect = NULL; float *srgb_frect = NULL; short texwindx, texwindy, texwinsx, texwinsy; /* flag to determine whether high resolution format is used */ @@ -536,7 +537,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int IMB_buffer_float_from_float(srgb_frect, ibuf->rect_float, ibuf->channels, IB_PROFILE_SRGB, ibuf->profile, 0, ibuf->x, ibuf->y, ibuf->x, ibuf->x); - /* clamp buffer colours to 1.0 to avoid artifacts due to glu for hdr images */ + /* clamp buffer colors to 1.0 to avoid artifacts due to glu for hdr images */ IMB_buffer_float_clamp(srgb_frect, ibuf->x, ibuf->y); frect= srgb_frect + texwinsy*ibuf->x + texwinsx; } @@ -561,7 +562,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int IMB_buffer_float_from_float(srgb_frect, ibuf->rect_float, ibuf->channels, IB_PROFILE_SRGB, ibuf->profile, 0, ibuf->x, ibuf->y, ibuf->x, ibuf->x); - /* clamp buffer colours to 1.0 to avoid artifacts due to glu for hdr images */ + /* clamp buffer colors to 1.0 to avoid artifacts due to glu for hdr images */ IMB_buffer_float_clamp(srgb_frect, ibuf->x, ibuf->y); } else @@ -610,8 +611,33 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int rect= tilerect; } } +#ifdef WITH_DDS + if (ibuf->ftype & DDS) + GPU_create_gl_tex_compressed(bind, rect, rectw, recth, mipmap, ima, ibuf); + else +#endif + GPU_create_gl_tex(bind, rect, frect, rectw, recth, mipmap, use_high_bit_depth, ima); + + /* clean up */ + if (tilerect) + MEM_freeN(tilerect); + if (ftilerect) + MEM_freeN(ftilerect); + if (srgb_frect) + MEM_freeN(srgb_frect); + + return *bind; +} - /* scale if not a power of two. this is not strictly necessary for newer +void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float * frect, int rectw, int recth, int mipmap, int use_high_bit_depth, Image *ima) +{ + unsigned int *scalerect = NULL; + float *fscalerect = NULL; + + int tpx = rectw; + int tpy = recth; + + /* scale if not a power of two. this is not strictly necessary for newer * GPUs (OpenGL version >= 2.0) since they support non-power-of-two-textures */ if (!is_pow2_limit(rectw) || !is_pow2_limit(recth)) { rectw= smaller_pow2_limit(rectw); @@ -625,9 +651,9 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int } else { scalerect= MEM_mallocN(rectw*recth*sizeof(*scalerect), "scalerect"); - gluScaleImage(GL_RGBA, tpx, tpy, GL_UNSIGNED_BYTE, rect, rectw, recth, GL_UNSIGNED_BYTE, scalerect); + gluScaleImage(GL_RGBA, tpx, tpy, GL_UNSIGNED_BYTE, pix, rectw, recth, GL_UNSIGNED_BYTE, scalerect); - rect= scalerect; + pix= scalerect; } } @@ -639,7 +665,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int if (use_high_bit_depth) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect); else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); } @@ -648,14 +674,14 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int if (use_high_bit_depth) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect); else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix); glGenerateMipmapEXT(GL_TEXTURE_2D); } else { if (use_high_bit_depth) gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA16, rectw, recth, GL_RGBA, GL_FLOAT, frect); else - gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect); + gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, pix); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); @@ -667,21 +693,88 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic()); /* set to modulate with vertex color */ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - /* clean up */ - if (tilerect) - MEM_freeN(tilerect); - if (ftilerect) - MEM_freeN(ftilerect); + if (scalerect) MEM_freeN(scalerect); if (fscalerect) MEM_freeN(fscalerect); - if (srgb_frect) - MEM_freeN(srgb_frect); - return *bind; } +/** + * GPU_upload_dxt_texture() assumes that the texture is already bound and ready to go. + * This is so the viewport and the BGE can share some code. + * Returns FALSE if the provided ImBuf doesn't have a supported DXT compression format + */ +int GPU_upload_dxt_texture(ImBuf *ibuf) +{ +#if WITH_DDS + GLint format = 0; + int blocksize, height, width, i, size, offset = 0; + + height = ibuf->x; + width = ibuf->y; + + if (GLEW_EXT_texture_compression_s3tc) { + if (ibuf->dds_data.fourcc == FOURCC_DXT1) + format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + else if (ibuf->dds_data.fourcc == FOURCC_DXT3) + format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + else if (ibuf->dds_data.fourcc == FOURCC_DXT5) + format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + } + + if (format == 0) { + printf("Unable to find a suitable DXT compression, falling back to uncompressed\n"); + return FALSE; + } + + blocksize = (format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) ? 8 : 16; + for (i=0; i<ibuf->dds_data.nummipmaps && (width||height); ++i) { + if (width == 0) + width = 1; + if (height == 0) + height = 1; + + size = ((width+3)/4)*((height+3)/4)*blocksize; + + glCompressedTexImage2D(GL_TEXTURE_2D, i, format, width, height, + 0, size, ibuf->dds_data.data + offset); + + offset += size; + width >>= 1; + height >>= 1; + } + + return TRUE; +#else + (void)ibuf; + return FALSE; +#endif +} + +void GPU_create_gl_tex_compressed(unsigned int *bind, unsigned int *pix, int x, int y, int mipmap, Image *ima, ImBuf *ibuf) +{ +#ifndef WITH_DDS + (void)ibuf; + /* Fall back to uncompressed if DDS isn't enabled */ + GPU_create_gl_tex(bind, pix, NULL, x, y, mipmap, 0, ima); +#else + + + glGenTextures(1, (GLuint *)bind); + glBindTexture(GL_TEXTURE_2D, *bind); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + if (GPU_upload_dxt_texture(ibuf) == 0) { + glDeleteTextures(1, (GLuint*)bind); + GPU_create_gl_tex(bind, pix, NULL, x, y, mipmap, 0, ima); + } +#endif +} static void gpu_verify_repeat(Image *ima) { /* set either clamp or repeat in X/Y */ diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index b9980b1401d..d544e6501fc 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -21,7 +21,7 @@ * The Original Code is: all of this file. * * Original author: Benoit Bolsee - * Contributor(s): + * Contributor(s): * * ***** END GPL LICENSE BLOCK ***** */ @@ -30,7 +30,6 @@ * \ingroup ikplugin */ - #include "MEM_guardedalloc.h" #include "BIK_api.h" @@ -75,25 +74,25 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t } } if (con == NULL) return; - + /* exclude tip from chain? */ if (!(data->flag & CONSTRAINT_IK_TIP)) pchan_tip = pchan_tip->parent; - + /* Find the chain's root & count the segments needed */ for (curchan = pchan_tip; curchan; curchan = curchan->parent) { pchan_root = curchan; - + curchan->flag |= POSE_CHAIN; // don't forget to clear this chanlist[segcount] = curchan; segcount++; - + if (segcount == data->rootbone || segcount > 255) break; // 255 is weak } if (!segcount) return; /* setup the chain data */ - + /* we make tree-IK, unless all existing targets are in this chain */ for (tree = pchan_root->iktree.first; tree; tree = tree->next) { for (target = tree->targets.first; target; target = target->next) { @@ -116,11 +115,11 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t tree = MEM_callocN(sizeof(PoseTree), "posetree"); tree->type = CONSTRAINT_TYPE_KINEMATIC; - + tree->iterations = data->iterations; tree->totchannel = segcount; tree->stretch = (data->flag & CONSTRAINT_IK_STRETCH); - + tree->pchan = MEM_callocN(segcount * sizeof(void *), "ik tree pchan"); tree->parent = MEM_callocN(segcount * sizeof(int), "ik tree parent"); for (a = 0; a < segcount; a++) { @@ -128,7 +127,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t tree->parent[a] = a - 1; } target->tip = segcount - 1; - + /* AND! link the tree to the root */ BLI_addtail(&pchan_root->iktree, tree); } @@ -154,7 +153,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t for (parent = a - 1; parent < tree->totchannel; parent++) if (tree->pchan[parent] == chanlist[segcount - 1]->parent) break; - + /* shouldn't happen, but could with dependency cycles */ if (parent == tree->totchannel) parent = a - 1; @@ -177,7 +176,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t tree->parent[tree->totchannel + a] = tree->totchannel + a - 1; } tree->parent[tree->totchannel] = parent; - + tree->totchannel = newsize; } @@ -210,12 +209,12 @@ static void make_dmats(bPoseChannel *pchan) static void where_is_ik_bone(bPoseChannel *pchan, float ik_mat[][3]) // nr = to detect if this is first bone { float vec[3], ikmat[4][4]; - + copy_m4_m3(ikmat, ik_mat); - + if (pchan->parent) mul_serie_m4(pchan->pose_mat, pchan->parent->pose_mat, pchan->chan_mat, ikmat, NULL, NULL, NULL, NULL, NULL); - else + else mult_m4_m4m4(pchan->pose_mat, pchan->chan_mat, ikmat); /* calculate head */ @@ -253,13 +252,13 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) if (tree->totchannel == 0) return; - + iktree = MEM_mallocN(sizeof(void *) * tree->totchannel, "ik tree"); for (a = 0; a < tree->totchannel; a++) { pchan = tree->pchan[a]; bone = pchan->bone; - + /* set DoF flag */ flag = 0; if (!(pchan->ikflag & BONE_IK_NO_XDOF) && !(pchan->ikflag & BONE_IK_NO_XDOF_TEMP)) @@ -268,72 +267,72 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) flag |= IK_YDOF; if (!(pchan->ikflag & BONE_IK_NO_ZDOF) && !(pchan->ikflag & BONE_IK_NO_ZDOF_TEMP)) flag |= IK_ZDOF; - + if (tree->stretch && (pchan->ikstretch > 0.0f)) { flag |= IK_TRANS_YDOF; hasstretch = 1; } - + seg = iktree[a] = IK_CreateSegment(flag); - + /* find parent */ if (a == 0) parent = NULL; else parent = iktree[tree->parent[a]]; - + IK_SetParent(seg, parent); - + /* get the matrix that transforms from prevbone into this bone */ copy_m3_m4(R_bonemat, pchan->pose_mat); - + /* gather transformations for this IK segment */ - + if (pchan->parent) copy_m3_m4(R_parmat, pchan->parent->pose_mat); else unit_m3(R_parmat); - + /* bone offset */ if (pchan->parent && (a > 0)) sub_v3_v3v3(start, pchan->pose_head, pchan->parent->pose_tail); else /* only root bone (a = 0) has no parent */ start[0] = start[1] = start[2] = 0.0f; - + /* change length based on bone size */ length = bone->length * len_v3(R_bonemat[1]); - + /* compute rest basis and its inverse */ copy_m3_m3(rest_basis, bone->bone_mat); copy_m3_m3(irest_basis, bone->bone_mat); transpose_m3(irest_basis); - + /* compute basis with rest_basis removed */ invert_m3_m3(iR_parmat, R_parmat); 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); - + if (pchan->ikflag & BONE_IK_XLIMIT) IK_SetLimit(seg, IK_X, pchan->limitmin[0], pchan->limitmax[0]); if (pchan->ikflag & BONE_IK_YLIMIT) IK_SetLimit(seg, IK_Y, pchan->limitmin[1], pchan->limitmax[1]); if (pchan->ikflag & BONE_IK_ZLIMIT) IK_SetLimit(seg, IK_Z, pchan->limitmin[2], pchan->limitmax[2]); - + IK_SetStiffness(seg, IK_X, pchan->stiffness[0]); IK_SetStiffness(seg, IK_Y, pchan->stiffness[1]); IK_SetStiffness(seg, IK_Z, pchan->stiffness[2]); - + if (tree->stretch && (pchan->ikstretch > 0.0f)) { float ikstretch = pchan->ikstretch * pchan->ikstretch; IK_SetStiffness(seg, IK_TRANS_Y, MIN2(1.0f - ikstretch, 0.99f)); @@ -359,31 +358,31 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) else unit_m4(rootmat); copy_v3_v3(rootmat[3], pchan->pose_head); - + mult_m4_m4m4(imat, ob->obmat, rootmat); invert_m4_m4(goalinv, imat); - + for (target = tree->targets.first; target; target = target->next) { float polepos[3]; int poleconstrain = 0; - + data = (bKinematicConstraint *)target->con->data; - + /* 1.0=ctime, we pass on object for auto-ik (owner-type here is object, even though * strictly speaking, it is a posechannel) */ get_constraint_target_matrix(scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0); - + /* and set and transform goal */ mult_m4_m4m4(goal, goalinv, rootmat); - + copy_v3_v3(goalpos, goal[3]); copy_m3_m4(goalrot, goal); - + /* same for pole vector target */ if (data->poletar) { get_constraint_target_matrix(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 */ break; @@ -398,7 +397,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) * a smooth transition */ resultblend = 1; resultinf = target->con->enforce; - + if (data->flag & CONSTRAINT_IK_GETANGLE) { poleangledata = data; data->flag &= ~CONSTRAINT_IK_GETANGLE; @@ -411,28 +410,28 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) float q1[4], q2[4], q[4]; float fac = target->con->enforce; float mfac = 1.0f - fac; - + pchan = tree->pchan[target->tip]; - + /* end effector in world space */ copy_m4_m4(end_pose, pchan->pose_mat); copy_v3_v3(end_pose[3], pchan->pose_tail); mul_serie_m4(world_pose, goalinv, ob->obmat, end_pose, NULL, NULL, NULL, NULL, NULL); - + /* blend position */ goalpos[0] = fac * goalpos[0] + mfac * world_pose[3][0]; goalpos[1] = fac * goalpos[1] + mfac * world_pose[3][1]; goalpos[2] = fac * goalpos[2] + mfac * world_pose[3][2]; - + /* blend rotation */ mat3_to_quat(q1, goalrot); mat4_to_quat(q2, world_pose); interp_qt_qtqt(q, q1, q2, mfac); quat_to_mat3(goalrot, q); } - + iktarget = iktree[target->tip]; - + if (data->weight != 0.0f) { if (poleconstrain) IK_SolverSetPoleVectorConstraint(solver, iktarget, goalpos, @@ -457,30 +456,30 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) tree->basis_change = MEM_mallocN(sizeof(float[3][3]) * tree->totchannel, "ik basis change"); if (hasstretch) ikstretch = MEM_mallocN(sizeof(float) * tree->totchannel, "ik stretch"); - + for (a = 0; a < tree->totchannel; a++) { IK_GetBasisChange(iktree[a], tree->basis_change[a]); - + if (hasstretch) { /* have to compensate for scaling received from parent */ float parentstretch, stretch; - + pchan = tree->pchan[a]; parentstretch = (tree->parent[a] >= 0) ? ikstretch[tree->parent[a]] : 1.0f; - + if (tree->stretch && (pchan->ikstretch > 0.0f)) { float trans[3], length; - + IK_GetTranslationChange(iktree[a], trans); length = pchan->bone->length * len_v3(pchan->pose_mat[1]); - + ikstretch[a] = (length == 0.0f) ? 1.0f : (trans[1] + length) / length; } else ikstretch[a] = 1.0; - + stretch = (parentstretch == 0.0f) ? 1.0f : ikstretch[a] / parentstretch; - + mul_v3_fl(tree->basis_change[a][0], stretch); mul_v3_fl(tree->basis_change[a][1], stretch); mul_v3_fl(tree->basis_change[a][2], stretch); @@ -491,10 +490,10 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) blend_m3_m3m3(tree->basis_change[a], identity, tree->basis_change[a], resultinf); } - + IK_FreeSegment(iktree[a]); } - + MEM_freeN(iktree); if (ikstretch) MEM_freeN(ikstretch); } @@ -514,7 +513,7 @@ static void free_posetree(PoseTree *tree) void iksolver_initialize_tree(struct Scene *UNUSED(scene), struct Object *ob, float UNUSED(ctime)) { bPoseChannel *pchan; - + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->constflag & PCHAN_HAS_IK) // flag is set on editing constraints initialize_posetree(ob, pchan); // will attach it to root! @@ -527,11 +526,11 @@ void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPose while (pchan->iktree.first) { PoseTree *tree = pchan->iktree.first; int a; - + /* stop on the first tree that isn't a standard IK chain */ if (tree->type != CONSTRAINT_TYPE_KINEMATIC) return; - + /* 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 @@ -541,18 +540,18 @@ void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPose } /* 5. execute the IK solver */ execute_posetree(scene, ob, tree); - - /* 6. apply the differences to the channels, + + /* 6. apply the differences to the channels, * we need to calculate the original differences first */ for (a = 0; a < tree->totchannel; a++) { make_dmats(tree->pchan[a]); } - + for (a = 0; a < tree->totchannel; a++) { /* sets POSE_DONE */ where_is_ik_bone(tree->pchan[a], tree->basis_change[a]); } - + /* 7. and free */ BLI_remlink(&pchan->iktree, tree); free_posetree(tree); diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index 048dd955726..a0d7bfbaaf6 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -21,7 +21,7 @@ * The Original Code is: all of this file. * * Original author: Benoit Bolsee - * Contributor(s): + * Contributor(s): * * ***** END GPL LICENSE BLOCK ***** */ @@ -30,7 +30,6 @@ * \ingroup ikplugin */ - #include <stdlib.h> #include <string.h> #include <vector> @@ -73,23 +72,22 @@ extern "C" { bItasc DefIKParam; // in case of animation mode, feedback and timestep is fixed -#define ANIM_TIMESTEP 1.0 -#define ANIM_FEEDBACK 0.8 -#define ANIM_QMAX 0.52 +#define ANIM_TIMESTEP 1.0 +#define ANIM_FEEDBACK 0.8 +#define ANIM_QMAX 0.52 // Structure pointed by bPose.ikdata // It contains everything needed to simulate the armatures // There can be several simulation islands independent to each other -struct IK_Data -{ - struct IK_Scene* first; +struct IK_Data { + struct IK_Scene *first; }; typedef float Vector3[3]; typedef float Vector4[4]; struct IK_Target; -typedef void (*ErrorCallback)(const iTaSC::ConstraintValues* values, unsigned int nvalues, IK_Target* iktarget); +typedef void (*ErrorCallback)(const iTaSC::ConstraintValues *values, unsigned int nvalues, IK_Target *iktarget); // one structure for each target in the scene struct IK_Target @@ -160,8 +158,7 @@ struct IK_Channel { } }; -struct IK_Scene -{ +struct IK_Scene { struct Scene *blscene; IK_Scene* next; int numchan; // number of channel in pchan @@ -201,11 +198,11 @@ struct IK_Scene // delete scene first if (scene) delete scene; - for (std::vector<IK_Target*>::iterator it = targets.begin(); it != targets.end(); ++it) + for (std::vector<IK_Target *>::iterator it = targets.begin(); it != targets.end(); ++it) delete (*it); targets.clear(); if (channels) - delete [] channels; + delete[] channels; if (solver) delete solver; if (armature) @@ -239,38 +236,38 @@ enum IK_SegmentAxis { static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *con) { - bPoseChannel *curchan, *pchan_root=NULL, *chanlist[256], **oldchan; + bPoseChannel *curchan, *pchan_root = NULL, *chanlist[256], **oldchan; PoseTree *tree; PoseTarget *target; bKinematicConstraint *data; - int a, t, segcount= 0, size, newsize, *oldparent, parent, rootbone, treecount; + int a, t, segcount = 0, size, newsize, *oldparent, parent, rootbone, treecount; + + data = (bKinematicConstraint *)con->data; - data=(bKinematicConstraint*)con->data; - /* exclude tip from chain? */ if (!(data->flag & CONSTRAINT_IK_TIP)) - pchan_tip= pchan_tip->parent; - + pchan_tip = pchan_tip->parent; + rootbone = data->rootbone; /* Find the chain's root & count the segments needed */ - for (curchan = pchan_tip; curchan; curchan=curchan->parent) { + for (curchan = pchan_tip; curchan; curchan = curchan->parent) { pchan_root = curchan; - - if (++segcount > 255) // 255 is weak + + if (++segcount > 255) // 255 is weak break; - if (segcount==rootbone) { - // reached this end of the chain but if the chain is overlapping with a + if (segcount == rootbone) { + // reached this end of the chain but if the chain is overlapping with a // previous one, we must go back up to the root of the other chain if ((curchan->flag & POSE_CHAIN) && curchan->iktree.first == NULL) { rootbone++; continue; } - break; + break; } if (curchan->iktree.first != NULL) - // Oh oh, there is already a chain starting from this channel and our chain is longer... + // Oh oh, there is already a chain starting from this channel and our chain is longer... // Should handle this by moving the previous chain up to the beginning of our chain // For now we just stop here break; @@ -280,86 +277,86 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co if ((pchan_root->flag & POSE_CHAIN) && pchan_root->iktree.first == NULL) return 0; // now that we know how many segment we have, set the flag - for (rootbone = segcount, segcount = 0, curchan = pchan_tip; segcount < rootbone; segcount++, curchan=curchan->parent) { - chanlist[segcount]=curchan; + for (rootbone = segcount, segcount = 0, curchan = pchan_tip; segcount < rootbone; segcount++, curchan = curchan->parent) { + chanlist[segcount] = curchan; curchan->flag |= POSE_CHAIN; } /* setup the chain data */ /* create a target */ - target= (PoseTarget*)MEM_callocN(sizeof(PoseTarget), "posetarget"); - target->con= con; + target = (PoseTarget *)MEM_callocN(sizeof(PoseTarget), "posetarget"); + target->con = con; // by contruction there can be only one tree per channel and each channel can be part of at most one tree. - tree = (PoseTree*)pchan_root->iktree.first; + tree = (PoseTree *)pchan_root->iktree.first; - if (tree==NULL) { + if (tree == NULL) { /* make new tree */ - tree= (PoseTree*)MEM_callocN(sizeof(PoseTree), "posetree"); + tree = (PoseTree *)MEM_callocN(sizeof(PoseTree), "posetree"); - tree->iterations= data->iterations; - tree->totchannel= segcount; + tree->iterations = data->iterations; + tree->totchannel = segcount; tree->stretch = (data->flag & CONSTRAINT_IK_STRETCH); - - tree->pchan= (bPoseChannel**)MEM_callocN(segcount*sizeof(void*), "ik tree pchan"); - tree->parent= (int*)MEM_callocN(segcount*sizeof(int), "ik tree parent"); - for (a=0; a<segcount; a++) { - tree->pchan[a]= chanlist[segcount-a-1]; - tree->parent[a]= a-1; + + tree->pchan = (bPoseChannel **)MEM_callocN(segcount * sizeof(void *), "ik tree pchan"); + tree->parent = (int *)MEM_callocN(segcount * sizeof(int), "ik tree parent"); + for (a = 0; a < segcount; a++) { + tree->pchan[a] = chanlist[segcount - a - 1]; + tree->parent[a] = a - 1; } - target->tip= segcount-1; - + target->tip = segcount - 1; + /* AND! link the tree to the root */ BLI_addtail(&pchan_root->iktree, tree); // new tree treecount = 1; } else { - tree->iterations= MAX2(data->iterations, tree->iterations); - tree->stretch= tree->stretch && !(data->flag & CONSTRAINT_IK_STRETCH); + tree->iterations = MAX2(data->iterations, tree->iterations); + tree->stretch = tree->stretch && !(data->flag & CONSTRAINT_IK_STRETCH); /* skip common pose channels and add remaining*/ - size= MIN2(segcount, tree->totchannel); + size = MIN2(segcount, tree->totchannel); a = t = 0; - while (a<size && t<tree->totchannel) { + while (a < size && t < tree->totchannel) { // locate first matching channel - for (;t<tree->totchannel && tree->pchan[t]!=chanlist[segcount-a-1];t++); - if (t>=tree->totchannel) + for (; t < tree->totchannel && tree->pchan[t] != chanlist[segcount - a - 1]; t++) ; + if (t >= tree->totchannel) break; - for (; a<size && t<tree->totchannel && tree->pchan[t]==chanlist[segcount-a-1]; a++, t++); + for (; a < size && t < tree->totchannel && tree->pchan[t] == chanlist[segcount - a - 1]; a++, t++) ; } - segcount= segcount-a; - target->tip= tree->totchannel + segcount - 1; + segcount = segcount - a; + target->tip = tree->totchannel + segcount - 1; if (segcount > 0) { for (parent = a - 1; parent < tree->totchannel; parent++) - if (tree->pchan[parent] == chanlist[segcount-1]->parent) + if (tree->pchan[parent] == chanlist[segcount - 1]->parent) break; - + /* shouldn't happen, but could with dependency cycles */ if (parent == tree->totchannel) parent = a - 1; /* resize array */ - newsize= tree->totchannel + segcount; - oldchan= tree->pchan; - oldparent= tree->parent; - - tree->pchan= (bPoseChannel**)MEM_callocN(newsize*sizeof(void*), "ik tree pchan"); - tree->parent= (int*)MEM_callocN(newsize*sizeof(int), "ik tree parent"); - memcpy(tree->pchan, oldchan, sizeof(void*)*tree->totchannel); - memcpy(tree->parent, oldparent, sizeof(int)*tree->totchannel); + newsize = tree->totchannel + segcount; + oldchan = tree->pchan; + oldparent = tree->parent; + + tree->pchan = (bPoseChannel **)MEM_callocN(newsize * sizeof(void *), "ik tree pchan"); + tree->parent = (int *)MEM_callocN(newsize * sizeof(int), "ik tree parent"); + memcpy(tree->pchan, oldchan, sizeof(void *) * tree->totchannel); + memcpy(tree->parent, oldparent, sizeof(int) * tree->totchannel); MEM_freeN(oldchan); MEM_freeN(oldparent); /* add new pose channels at the end, in reverse order */ - for (a=0; a<segcount; a++) { - tree->pchan[tree->totchannel+a]= chanlist[segcount-a-1]; - tree->parent[tree->totchannel+a]= tree->totchannel+a-1; + for (a = 0; a < segcount; a++) { + tree->pchan[tree->totchannel + a] = chanlist[segcount - a - 1]; + tree->parent[tree->totchannel + a] = tree->totchannel + a - 1; } - tree->parent[tree->totchannel]= parent; - - tree->totchannel= newsize; + tree->parent[tree->totchannel] = parent; + + tree->totchannel = newsize; } // reusing tree treecount = 0; @@ -381,7 +378,7 @@ static bool is_cartesian_constraint(bConstraint *con) static bool constraint_valid(bConstraint *con) { - bKinematicConstraint* data=(bKinematicConstraint*)con->data; + bKinematicConstraint *data = (bKinematicConstraint *)con->data; if (data->flag & CONSTRAINT_IK_AUTO) return true; @@ -389,9 +386,9 @@ static bool constraint_valid(bConstraint *con) return false; if (is_cartesian_constraint(con)) { /* cartesian space constraint */ - if (data->tar==NULL) + if (data->tar == NULL) return false; - if (data->tar->type==OB_ARMATURE && data->subtarget[0]==0) + if (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0) return false; } return true; @@ -404,8 +401,8 @@ int initialize_scene(Object *ob, bPoseChannel *pchan_tip) /* find all IK constraints and validate them */ treecount = 0; - for (con= (bConstraint *)pchan_tip->constraints.first; con; con= (bConstraint *)con->next) { - if (con->type==CONSTRAINT_TYPE_KINEMATIC) { + for (con = (bConstraint *)pchan_tip->constraints.first; con; con = (bConstraint *)con->next) { + if (con->type == CONSTRAINT_TYPE_KINEMATIC) { if (constraint_valid(con)) treecount += initialize_chain(ob, pchan_tip, con); } @@ -413,23 +410,23 @@ int initialize_scene(Object *ob, bPoseChannel *pchan_tip) return treecount; } -static IK_Data* get_ikdata(bPose *pose) +static IK_Data *get_ikdata(bPose *pose) { if (pose->ikdata) - return (IK_Data*)pose->ikdata; + return (IK_Data *)pose->ikdata; pose->ikdata = MEM_callocN(sizeof(IK_Data), "iTaSC ikdata"); // here init ikdata if needed // now that we have scene, make sure the default param are initialized if (!DefIKParam.iksolver) BKE_pose_itasc_init(&DefIKParam); - return (IK_Data*)pose->ikdata; + return (IK_Data *)pose->ikdata; } static double EulerAngleFromMatrix(const KDL::Rotation& R, int axis) { - double t = KDL::sqrt(R(0, 0)*R(0, 0) + R(0, 1)*R(0, 1)); + double t = KDL::sqrt(R(0, 0) * R(0, 0) + R(0, 1) * R(0, 1)); - if (t > 16.0*KDL::epsilon) { + if (t > 16.0 * KDL::epsilon) { if (axis == 0) return -KDL::atan2(R(1, 2), R(2, 2)); else if (axis == 1) return KDL::atan2(-R(0, 2), t); else return -KDL::atan2(R(0, 1), R(0, 0)); @@ -447,7 +444,7 @@ static double ComputeTwist(const KDL::Rotation& R) double qy = R(0, 2) - R(2, 0); double qw = R(0, 0) + R(1, 1) + R(2, 2) + 1; - double tau = 2*KDL::atan2(qy, qw); + double tau = 2 * KDL::atan2(qy, qw); return tau; } @@ -457,102 +454,102 @@ static void RemoveEulerAngleFromMatrix(KDL::Rotation& R, double angle, int axis) // compute twist parameter KDL::Rotation T; switch (axis) { - case 0: - T = KDL::Rotation::RotX(-angle); - break; - case 1: - T = KDL::Rotation::RotY(-angle); - break; - case 2: - T = KDL::Rotation::RotZ(-angle); - break; - default: - return; + case 0: + T = KDL::Rotation::RotX(-angle); + break; + case 1: + T = KDL::Rotation::RotY(-angle); + break; + case 2: + T = KDL::Rotation::RotZ(-angle); + break; + default: + return; } // remove angle - R = R*T; + R = R * T; } #if 0 static void GetEulerXZY(const KDL::Rotation& R, double& X, double& Z, double& Y) { - if (fabs(R(0, 1)) > 1.0 - KDL::epsilon ) { + if (fabs(R(0, 1)) > 1.0 - KDL::epsilon) { X = -KDL::sign(R(0, 1)) * KDL::atan2(R(1, 2), R(1, 0)); Z = -KDL::sign(R(0, 1)) * KDL::PI / 2; Y = 0.0; } else { X = KDL::atan2(R(2, 1), R(1, 1)); - Z = KDL::atan2(-R(0, 1), KDL::sqrt( KDL::sqr(R(0, 0)) + KDL::sqr(R(0, 2)))); + Z = KDL::atan2(-R(0, 1), KDL::sqrt(KDL::sqr(R(0, 0)) + KDL::sqr(R(0, 2)))); Y = KDL::atan2(R(0, 2), R(0, 0)); } } static void GetEulerXYZ(const KDL::Rotation& R, double& X, double& Y, double& Z) { - if (fabs(R(0, 2)) > 1.0 - KDL::epsilon ) { + if (fabs(R(0, 2)) > 1.0 - KDL::epsilon) { X = KDL::sign(R(0, 2)) * KDL::atan2(-R(1, 0), R(1, 1)); Y = KDL::sign(R(0, 2)) * KDL::PI / 2; Z = 0.0; } else { X = KDL::atan2(-R(1, 2), R(2, 2)); - Y = KDL::atan2(R(0, 2), KDL::sqrt( KDL::sqr(R(0, 0)) + KDL::sqr(R(0, 1)))); + Y = KDL::atan2(R(0, 2), KDL::sqrt(KDL::sqr(R(0, 0)) + KDL::sqr(R(0, 1)))); Z = KDL::atan2(-R(0, 1), R(0, 0)); } } #endif -static void GetJointRotation(KDL::Rotation& boneRot, int type, double* rot) +static void GetJointRotation(KDL::Rotation& boneRot, int type, double *rot) { switch (type & ~IK_TRANSY) { - default: - // fixed bone, no joint - break; - case IK_XDOF: - // RX only, get the X rotation - rot[0] = EulerAngleFromMatrix(boneRot, 0); - break; - case IK_YDOF: - // RY only, get the Y rotation - rot[0] = ComputeTwist(boneRot); - break; - case IK_ZDOF: - // RZ only, get the Z rotation - rot[0] = EulerAngleFromMatrix(boneRot, 2); - break; - case IK_XDOF|IK_YDOF: - rot[1] = ComputeTwist(boneRot); - RemoveEulerAngleFromMatrix(boneRot, rot[1], 1); - rot[0] = EulerAngleFromMatrix(boneRot, 0); - break; - case IK_SWING: - // RX+RZ - boneRot.GetXZRot().GetValue(rot); - break; - case IK_YDOF|IK_ZDOF: - // RZ+RY - rot[1] = ComputeTwist(boneRot); - RemoveEulerAngleFromMatrix(boneRot, rot[1], 1); - rot[0] = EulerAngleFromMatrix(boneRot, 2); - break; - case IK_SWING|IK_YDOF: - rot[2] = ComputeTwist(boneRot); - RemoveEulerAngleFromMatrix(boneRot, rot[2], 1); - boneRot.GetXZRot().GetValue(rot); - break; - case IK_REVOLUTE: - boneRot.GetRot().GetValue(rot); - break; + default: + // fixed bone, no joint + break; + case IK_XDOF: + // RX only, get the X rotation + rot[0] = EulerAngleFromMatrix(boneRot, 0); + break; + case IK_YDOF: + // RY only, get the Y rotation + rot[0] = ComputeTwist(boneRot); + break; + case IK_ZDOF: + // RZ only, get the Z rotation + rot[0] = EulerAngleFromMatrix(boneRot, 2); + break; + case IK_XDOF | IK_YDOF: + rot[1] = ComputeTwist(boneRot); + RemoveEulerAngleFromMatrix(boneRot, rot[1], 1); + rot[0] = EulerAngleFromMatrix(boneRot, 0); + break; + case IK_SWING: + // RX+RZ + boneRot.GetXZRot().GetValue(rot); + break; + case IK_YDOF | IK_ZDOF: + // RZ+RY + rot[1] = ComputeTwist(boneRot); + RemoveEulerAngleFromMatrix(boneRot, rot[1], 1); + rot[0] = EulerAngleFromMatrix(boneRot, 2); + break; + case IK_SWING | IK_YDOF: + rot[2] = ComputeTwist(boneRot); + RemoveEulerAngleFromMatrix(boneRot, rot[2], 1); + boneRot.GetXZRot().GetValue(rot); + break; + case IK_REVOLUTE: + boneRot.GetRot().GetValue(rot); + break; } } static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& current, iTaSC::Frame& next, void *param) { - IK_Target* target = (IK_Target*)param; + IK_Target *target = (IK_Target *)param; // compute next target position // get target matrix from constraint. - bConstraint* constraint = (bConstraint*)target->blenderConstraint; + bConstraint *constraint = (bConstraint *)target->blenderConstraint; float tarmat[4][4]; get_constraint_target_matrix(target->blscene, constraint, 0, CONSTRAINT_OBTYPE_OBJECT, target->owner, tarmat, 1.0); @@ -564,14 +561,14 @@ static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Fram // eeRest is relative to the reference frame of the IK root // get this frame in world reference float restmat[4][4]; - bPoseChannel* pchan = target->rootChannel; + bPoseChannel *pchan = target->rootChannel; if (pchan->parent) { pchan = pchan->parent; float chanmat[4][4]; copy_m4_m4(chanmat, pchan->pose_mat); copy_v3_v3(chanmat[3], pchan->pose_tail); mul_serie_m4(restmat, target->owner->obmat, chanmat, target->eeRest, NULL, NULL, NULL, NULL, NULL); - } + } else { mult_m4_m4m4(restmat, target->owner->obmat, target->eeRest); } @@ -584,13 +581,13 @@ static bool target_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Fram static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& current, iTaSC::Frame& next, void *param) { - IK_Scene* ikscene = (IK_Scene*)param; + IK_Scene *ikscene = (IK_Scene *)param; // compute next armature base pose - // algorithm: + // algorithm: // ikscene->pchan[0] is the root channel of the tree // if it has a parent, get the pose matrix from it and replace [3] by parent pchan->tail // then multiply by the armature matrix to get ikscene->armature base position - bPoseChannel* pchan = ikscene->channels[0].pchan; + bPoseChannel *pchan = ikscene->channels[0].pchan; float rootmat[4][4]; if (pchan->parent) { pchan = pchan->parent; @@ -602,7 +599,7 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& // iTaSC armature is scaled to object scale, scale the base frame too ikscene->baseFrame.p *= ikscene->blScale; mult_m4_m4m4(rootmat, ikscene->blArmature->obmat, chanmat); - } + } else { copy_m4_m4(rootmat, ikscene->blArmature->obmat); ikscene->baseFrame = iTaSC::F_identity; @@ -611,11 +608,11 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& // if there is a polar target (only during solving otherwise we don't have end efffector) if (ikscene->polarConstraint && timestamp.update) { // compute additional rotation of base frame so that armature follows the polar target - float imat[4][4]; // IK tree base inverse matrix - float polemat[4][4]; // polar target in IK tree base frame - float goalmat[4][4]; // target in IK tree base frame - float mat[4][4]; // temp matrix - bKinematicConstraint* poledata = (bKinematicConstraint*)ikscene->polarConstraint->data; + float imat[4][4]; // IK tree base inverse matrix + float polemat[4][4]; // polar target in IK tree base frame + float goalmat[4][4]; // target in IK tree base frame + float mat[4][4]; // temp matrix + bKinematicConstraint *poledata = (bKinematicConstraint *)ikscene->polarConstraint->data; invert_m4_m4(imat, rootmat); // polar constraint imply only one target @@ -642,48 +639,48 @@ static bool base_callback(const iTaSC::Timestamp& timestamp, const iTaSC::Frame& KDL::Vector rootz = rootframe.M.UnitZ(); // and compute root bone head double q_rest[3], q[3], length; - const KDL::Joint* joint; - const KDL::Frame* tip; + const KDL::Joint *joint; + const KDL::Frame *tip; ikscene->armature->getSegment(rootchan.tail, 3, joint, q_rest[0], q[0], tip); length = (joint->getType() == KDL::Joint::TransY) ? q[0] : tip->p(1); - KDL::Vector rootpos = rootframe.p - length*rootframe.M.UnitY(); + KDL::Vector rootpos = rootframe.p - length *rootframe.M.UnitY(); - // compute main directions + // compute main directions KDL::Vector dir = KDL::Normalize(endpos - rootpos); - KDL::Vector poledir = KDL::Normalize(goalpos-rootpos); + KDL::Vector poledir = KDL::Normalize(goalpos - rootpos); // compute up directions - KDL::Vector poleup = KDL::Normalize(polepos-rootpos); - KDL::Vector up = rootx*KDL::cos(poledata->poleangle) + rootz*KDL::sin(poledata->poleangle); + KDL::Vector poleup = KDL::Normalize(polepos - rootpos); + KDL::Vector up = rootx * KDL::cos(poledata->poleangle) + rootz *KDL::sin(poledata->poleangle); // from which we build rotation matrix KDL::Rotation endrot, polerot; // for the armature, using the root bone orientation - KDL::Vector x = KDL::Normalize(dir*up); + KDL::Vector x = KDL::Normalize(dir * up); endrot.UnitX(x); - endrot.UnitY(KDL::Normalize(x*dir)); + endrot.UnitY(KDL::Normalize(x * dir)); endrot.UnitZ(-dir); - // for the polar target - x = KDL::Normalize(poledir*poleup); + // for the polar target + x = KDL::Normalize(poledir * poleup); polerot.UnitX(x); - polerot.UnitY(KDL::Normalize(x*poledir)); + polerot.UnitY(KDL::Normalize(x * poledir)); polerot.UnitZ(-poledir); // the difference between the two is the rotation we want to apply - KDL::Rotation result(polerot*endrot.Inverse()); + KDL::Rotation result(polerot * endrot.Inverse()); // apply on base frame as this is an artificial additional rotation - next.M = next.M*result; - ikscene->baseFrame.M = ikscene->baseFrame.M*result; + next.M = next.M * result; + ikscene->baseFrame.M = ikscene->baseFrame.M * result; } return true; } -static bool copypose_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintValues* const _values, unsigned int _nvalues, void* _param) +static bool copypose_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintValues *const _values, unsigned int _nvalues, void *_param) { - IK_Target* iktarget =(IK_Target*)_param; + IK_Target *iktarget = (IK_Target *)_param; bKinematicConstraint *condata = (bKinematicConstraint *)iktarget->blenderConstraint->data; - iTaSC::ConstraintValues* values = _values; - bItasc* ikparam = (bItasc*) iktarget->owner->pose->ikparam; + iTaSC::ConstraintValues *values = _values; + bItasc *ikparam = (bItasc *) iktarget->owner->pose->ikparam; // we need default parameters - if (!ikparam) + if (!ikparam) ikparam = &DefIKParam; if (iktarget->blenderConstraint->flag & CONSTRAINT_OFF) { @@ -702,14 +699,14 @@ static bool copypose_callback(const iTaSC::Timestamp& timestamp, iTaSC::Constrai if (iktarget->controlType & iTaSC::CopyPose::CTL_POSITION) { // update error values->alpha = condata->weight; - values->action = iTaSC::ACT_ALPHA|iTaSC::ACT_FEEDBACK; + values->action = iTaSC::ACT_ALPHA | iTaSC::ACT_FEEDBACK; values->feedback = (iktarget->simulation) ? ikparam->feedback : ANIM_FEEDBACK; values++; } if (iktarget->controlType & iTaSC::CopyPose::CTL_ROTATION) { // update error values->alpha = condata->orientweight; - values->action = iTaSC::ACT_ALPHA|iTaSC::ACT_FEEDBACK; + values->action = iTaSC::ACT_ALPHA | iTaSC::ACT_FEEDBACK; values->feedback = (iktarget->simulation) ? ikparam->feedback : ANIM_FEEDBACK; values++; } @@ -717,36 +714,36 @@ static bool copypose_callback(const iTaSC::Timestamp& timestamp, iTaSC::Constrai return true; } -static void copypose_error(const iTaSC::ConstraintValues* values, unsigned int nvalues, IK_Target* iktarget) +static void copypose_error(const iTaSC::ConstraintValues *values, unsigned int nvalues, IK_Target *iktarget) { - iTaSC::ConstraintSingleValue* value; + iTaSC::ConstraintSingleValue *value; double error; int i; if (iktarget->controlType & iTaSC::CopyPose::CTL_POSITION) { // update error - for (i=0, error=0.0, value=values->values; i<values->number; ++i, ++value) + for (i = 0, error = 0.0, value = values->values; i < values->number; ++i, ++value) error += KDL::sqr(value->y - value->yd); iktarget->blenderConstraint->lin_error = (float)KDL::sqrt(error); values++; } if (iktarget->controlType & iTaSC::CopyPose::CTL_ROTATION) { // update error - for (i=0, error=0.0, value=values->values; i<values->number; ++i, ++value) + for (i = 0, error = 0.0, value = values->values; i < values->number; ++i, ++value) error += KDL::sqr(value->y - value->yd); iktarget->blenderConstraint->rot_error = (float)KDL::sqrt(error); values++; } } -static bool distance_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintValues* const _values, unsigned int _nvalues, void* _param) +static bool distance_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintValues *const _values, unsigned int _nvalues, void *_param) { - IK_Target* iktarget =(IK_Target*)_param; + IK_Target *iktarget = (IK_Target *)_param; bKinematicConstraint *condata = (bKinematicConstraint *)iktarget->blenderConstraint->data; - iTaSC::ConstraintValues* values = _values; - bItasc* ikparam = (bItasc*) iktarget->owner->pose->ikparam; + iTaSC::ConstraintValues *values = _values; + bItasc *ikparam = (bItasc *) iktarget->owner->pose->ikparam; // we need default parameters - if (!ikparam) + if (!ikparam) ikparam = &DefIKParam; // update weight according to mode @@ -755,30 +752,30 @@ static bool distance_callback(const iTaSC::Timestamp& timestamp, iTaSC::Constrai } else { switch (condata->mode) { - case LIMITDIST_INSIDE: - values->alpha = (values->values[0].y > condata->dist) ? condata->weight : 0.0; - break; - case LIMITDIST_OUTSIDE: - values->alpha = (values->values[0].y < condata->dist) ? condata->weight : 0.0; - break; - default: - values->alpha = condata->weight; - break; - } - if (!timestamp.substep) { - // only update value on first timestep - switch (condata->mode) { case LIMITDIST_INSIDE: - values->values[0].yd = condata->dist*0.95; + values->alpha = (values->values[0].y > condata->dist) ? condata->weight : 0.0; break; case LIMITDIST_OUTSIDE: - values->values[0].yd = condata->dist*1.05; + values->alpha = (values->values[0].y < condata->dist) ? condata->weight : 0.0; break; default: - values->values[0].yd = condata->dist; + values->alpha = condata->weight; break; + } + if (!timestamp.substep) { + // only update value on first timestep + switch (condata->mode) { + case LIMITDIST_INSIDE: + values->values[0].yd = condata->dist * 0.95; + break; + case LIMITDIST_OUTSIDE: + values->values[0].yd = condata->dist * 1.05; + break; + default: + values->values[0].yd = condata->dist; + break; } - values->values[0].action = iTaSC::ACT_VALUE|iTaSC::ACT_FEEDBACK; + values->values[0].action = iTaSC::ACT_VALUE | iTaSC::ACT_FEEDBACK; values->feedback = (iktarget->simulation) ? ikparam->feedback : ANIM_FEEDBACK; } } @@ -786,16 +783,16 @@ static bool distance_callback(const iTaSC::Timestamp& timestamp, iTaSC::Constrai return true; } -static void distance_error(const iTaSC::ConstraintValues* values, unsigned int _nvalues, IK_Target* iktarget) +static void distance_error(const iTaSC::ConstraintValues *values, unsigned int _nvalues, IK_Target *iktarget) { iktarget->blenderConstraint->lin_error = (float)(values->values[0].y - values->values[0].yd); } -static bool joint_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintValues* const _values, unsigned int _nvalues, void* _param) +static bool joint_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintValues *const _values, unsigned int _nvalues, void *_param) { - IK_Channel* ikchan = (IK_Channel*)_param; - bItasc* ikparam = (bItasc*)ikchan->owner->pose->ikparam; - bPoseChannel* chan = ikchan->pchan; + IK_Channel *ikchan = (IK_Channel *)_param; + bItasc *ikparam = (bItasc *)ikchan->owner->pose->ikparam; + bPoseChannel *chan = ikchan->pchan; int dof; // a channel can be splitted into multiple joints, so we get called multiple @@ -808,57 +805,57 @@ static bool joint_callback(const iTaSC::Timestamp& timestamp, iTaSC::ConstraintV if (chan->rotmode > 0) { /* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */ - eulO_to_mat3( rmat, chan->eul, chan->rotmode); + eulO_to_mat3(rmat, chan->eul, chan->rotmode); } else if (chan->rotmode == ROT_MODE_AXISANGLE) { /* axis-angle - stored in quaternion data, but not really that great for 3D-changing orientations */ - axis_angle_to_mat3( rmat, &chan->quat[1], chan->quat[0]); + axis_angle_to_mat3(rmat, &chan->quat[1], chan->quat[0]); } else { - /* quats are normalised before use to eliminate scaling issues */ + /* quats are normalized before use to eliminate scaling issues */ normalize_qt(chan->quat); quat_to_mat3(rmat, chan->quat); } KDL::Rotation jointRot( - rmat[0][0], rmat[1][0], rmat[2][0], - rmat[0][1], rmat[1][1], rmat[2][1], - rmat[0][2], rmat[1][2], rmat[2][2]); + rmat[0][0], rmat[1][0], rmat[2][0], + rmat[0][1], rmat[1][1], rmat[2][1], + rmat[0][2], rmat[1][2], rmat[2][2]); GetJointRotation(jointRot, ikchan->jointType, ikchan->jointValue); ikchan->jointValid = 1; } // determine which part of jointValue is used for this joint // closely related to the way the joints are defined switch (ikchan->jointType & ~IK_TRANSY) { - case IK_XDOF: - case IK_YDOF: - case IK_ZDOF: - dof = 0; - break; - case IK_XDOF|IK_YDOF: - // X + Y - dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RX) ? 0 : 1; - break; - case IK_SWING: - // XZ - dof = 0; - break; - case IK_YDOF|IK_ZDOF: - // Z + Y - dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RZ) ? 0 : 1; - break; - case IK_SWING|IK_YDOF: - // XZ + Y - dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RY) ? 2 : 0; - break; - case IK_REVOLUTE: - dof = 0; - break; - default: - dof = -1; - break; + case IK_XDOF: + case IK_YDOF: + case IK_ZDOF: + dof = 0; + break; + case IK_XDOF | IK_YDOF: + // X + Y + dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RX) ? 0 : 1; + break; + case IK_SWING: + // XZ + dof = 0; + break; + case IK_YDOF | IK_ZDOF: + // Z + Y + dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RZ) ? 0 : 1; + break; + case IK_SWING | IK_YDOF: + // XZ + Y + dof = (_values[0].id == iTaSC::Armature::ID_JOINT_RY) ? 2 : 0; + break; + case IK_REVOLUTE: + dof = 0; + break; + default: + dof = -1; + break; } if (dof >= 0) { - for (unsigned int i=0; i<_nvalues; i++, dof++) { + for (unsigned int i = 0; i < _nvalues; i++, dof++) { _values[i].values[0].yd = ikchan->jointValue[dof]; _values[i].alpha = chan->ikrotweight; _values[i].feedback = ikparam->feedback; @@ -875,30 +872,30 @@ static int convert_channels(IK_Scene *ikscene, PoseTree *tree) int a, flag, njoint; njoint = 0; - for (a=0, ikchan = ikscene->channels; a<ikscene->numchan; ++a, ++ikchan) { - pchan= tree->pchan[a]; + for (a = 0, ikchan = ikscene->channels; a < ikscene->numchan; ++a, ++ikchan) { + pchan = tree->pchan[a]; ikchan->pchan = pchan; - ikchan->parent = (a>0) ? tree->parent[a] : -1; + ikchan->parent = (a > 0) ? tree->parent[a] : -1; ikchan->owner = ikscene->blArmature; - + /* set DoF flag */ flag = 0; if (!(pchan->ikflag & BONE_IK_NO_XDOF) && !(pchan->ikflag & BONE_IK_NO_XDOF_TEMP) && - (!(pchan->ikflag & BONE_IK_XLIMIT) || pchan->limitmin[0]<0.f || pchan->limitmax[0]>0.f)) + (!(pchan->ikflag & BONE_IK_XLIMIT) || pchan->limitmin[0] < 0.f || pchan->limitmax[0] > 0.f)) { flag |= IK_XDOF; } if (!(pchan->ikflag & BONE_IK_NO_YDOF) && !(pchan->ikflag & BONE_IK_NO_YDOF_TEMP) && - (!(pchan->ikflag & BONE_IK_YLIMIT) || pchan->limitmin[1]<0.f || pchan->limitmax[1]>0.f)) + (!(pchan->ikflag & BONE_IK_YLIMIT) || pchan->limitmin[1] < 0.f || pchan->limitmax[1] > 0.f)) { flag |= IK_YDOF; } if (!(pchan->ikflag & BONE_IK_NO_ZDOF) && !(pchan->ikflag & BONE_IK_NO_ZDOF_TEMP) && - (!(pchan->ikflag & BONE_IK_ZLIMIT) || pchan->limitmin[2]<0.f || pchan->limitmax[2]>0.f)) + (!(pchan->ikflag & BONE_IK_ZLIMIT) || pchan->limitmin[2] < 0.f || pchan->limitmax[2] > 0.f)) { flag |= IK_ZDOF; } - + if (tree->stretch && (pchan->ikstretch > 0.0)) { flag |= IK_TRANSY; } @@ -929,49 +926,49 @@ static int convert_channels(IK_Scene *ikscene, PoseTree *tree) * bone length is computed from bone->length multiplied by the scaling factor of * the armature. Non-uniform scaling will give bad result! */ - switch (flag & (IK_XDOF|IK_YDOF|IK_ZDOF)) { - default: - ikchan->jointType = 0; - ikchan->ndof = 0; - break; - case IK_XDOF: - // RX only, get the X rotation - ikchan->jointType = IK_XDOF; - ikchan->ndof = 1; - break; - case IK_YDOF: - // RY only, get the Y rotation - ikchan->jointType = IK_YDOF; - ikchan->ndof = 1; - break; - case IK_ZDOF: - // RZ only, get the Zz rotation - ikchan->jointType = IK_ZDOF; - ikchan->ndof = 1; - break; - case IK_XDOF|IK_YDOF: - ikchan->jointType = IK_XDOF|IK_YDOF; - ikchan->ndof = 2; - break; - case IK_XDOF|IK_ZDOF: - // RX+RZ - ikchan->jointType = IK_SWING; - ikchan->ndof = 2; - break; - case IK_YDOF|IK_ZDOF: - // RZ+RY - ikchan->jointType = IK_ZDOF|IK_YDOF; - ikchan->ndof = 2; - break; - case IK_XDOF|IK_YDOF|IK_ZDOF: - // spherical joint - if (pchan->ikflag & (BONE_IK_XLIMIT|BONE_IK_YLIMIT|BONE_IK_ZLIMIT)) - // decompose in a Swing+RotY joint - ikchan->jointType = IK_SWING|IK_YDOF; - else - ikchan->jointType = IK_REVOLUTE; - ikchan->ndof = 3; - break; + switch (flag & (IK_XDOF | IK_YDOF | IK_ZDOF)) { + default: + ikchan->jointType = 0; + ikchan->ndof = 0; + break; + case IK_XDOF: + // RX only, get the X rotation + ikchan->jointType = IK_XDOF; + ikchan->ndof = 1; + break; + case IK_YDOF: + // RY only, get the Y rotation + ikchan->jointType = IK_YDOF; + ikchan->ndof = 1; + break; + case IK_ZDOF: + // RZ only, get the Zz rotation + ikchan->jointType = IK_ZDOF; + ikchan->ndof = 1; + break; + case IK_XDOF | IK_YDOF: + ikchan->jointType = IK_XDOF | IK_YDOF; + ikchan->ndof = 2; + break; + case IK_XDOF | IK_ZDOF: + // RX+RZ + ikchan->jointType = IK_SWING; + ikchan->ndof = 2; + break; + case IK_YDOF | IK_ZDOF: + // RZ+RY + ikchan->jointType = IK_ZDOF | IK_YDOF; + ikchan->ndof = 2; + break; + case IK_XDOF | IK_YDOF | IK_ZDOF: + // spherical joint + if (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_YLIMIT | BONE_IK_ZLIMIT)) + // decompose in a Swing+RotY joint + ikchan->jointType = IK_SWING | IK_YDOF; + else + ikchan->jointType = IK_REVOLUTE; + ikchan->ndof = 3; + break; } if (flag & IK_TRANSY) { ikchan->jointType |= IK_TRANSY; @@ -992,8 +989,8 @@ static void convert_pose(IK_Scene *ikscene) bPoseChannel *pchan; IK_Channel *ikchan; Bone *bone; - float rmat[4][4]; // rest pose of bone with parent taken into account - float bmat[4][4]; // difference + float rmat[4][4]; // rest pose of bone with parent taken into account + float bmat[4][4]; // difference float scale; double *rot; int a, joint; @@ -1001,10 +998,10 @@ static void convert_pose(IK_Scene *ikscene) // assume uniform scaling and take Y scale as general scale for the armature scale = len_v3(ikscene->blArmature->obmat[1]); rot = ikscene->jointArray(0); - for (joint=a=0, ikchan = ikscene->channels; a<ikscene->numchan && joint<ikscene->numjoint; ++a, ++ikchan) { - pchan= ikchan->pchan; - bone= pchan->bone; - + for (joint = a = 0, ikchan = ikscene->channels; a < ikscene->numchan && joint < ikscene->numjoint; ++a, ++ikchan) { + pchan = ikchan->pchan; + bone = pchan->bone; + if (pchan->parent) { unit_m4(bmat); mul_m4_m4m3(bmat, pchan->parent->pose_mat, bone->bone_mat); @@ -1018,9 +1015,9 @@ static void convert_pose(IK_Scene *ikscene) boneRot.setValue(bmat[0]); GetJointRotation(boneRot, ikchan->jointType, rot); if (ikchan->jointType & IK_TRANSY) { - // compute actual length - rot[ikchan->ndof-1] = len_v3v3(pchan->pose_tail, pchan->pose_head) * scale; - } + // compute actual length + rot[ikchan->ndof - 1] = len_v3v3(pchan->pose_tail, pchan->pose_head) * scale; + } rot += ikchan->ndof; joint += ikchan->ndof; } @@ -1038,32 +1035,32 @@ static void BKE_pose_rest(IK_Scene *ikscene) // assume uniform scaling and take Y scale as general scale for the armature scale = len_v3(ikscene->blArmature->obmat[1]); - // rest pose is 0 + // rest pose is 0 SetToZero(ikscene->jointArray); // except for transY joints rot = ikscene->jointArray(0); - for (joint=a=0, ikchan = ikscene->channels; a<ikscene->numchan && joint<ikscene->numjoint; ++a, ++ikchan) { - pchan= ikchan->pchan; - bone= pchan->bone; + for (joint = a = 0, ikchan = ikscene->channels; a < ikscene->numchan && joint < ikscene->numjoint; ++a, ++ikchan) { + pchan = ikchan->pchan; + bone = pchan->bone; if (ikchan->jointType & IK_TRANSY) - rot[ikchan->ndof-1] = bone->length*scale; + rot[ikchan->ndof - 1] = bone->length * scale; rot += ikchan->ndof; joint += ikchan->ndof; } } -static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) +static IK_Scene *convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) { - PoseTree *tree = (PoseTree*)pchan->iktree.first; + PoseTree *tree = (PoseTree *)pchan->iktree.first; PoseTarget *target; bKinematicConstraint *condata; bConstraint *polarcon; bItasc *ikparam; - iTaSC::Armature* arm; - iTaSC::Scene* scene; - IK_Scene* ikscene; - IK_Channel* ikchan; + iTaSC::Armature *arm; + iTaSC::Scene *scene; + IK_Scene *ikscene; + IK_Channel *ikchan; KDL::Frame initPose; KDL::Rotation boneRot; Bone *bone; @@ -1084,7 +1081,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) ikscene->numchan = tree->totchannel; ikscene->armature = arm; ikscene->scene = scene; - ikparam = (bItasc*)ob->pose->ikparam; + ikparam = (bItasc *)ob->pose->ikparam; ingame = (ob->pose->flag & POSE_GAME_ENGINE); if (!ikparam) { // you must have our own copy @@ -1096,7 +1093,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) // shorter than in animation => move to auto step automatically and set // the target substep duration via min/max if (!(ikparam->flag & ITASC_AUTO_STEP)) { - float timestep = blscene->r.frs_sec_base/blscene->r.frs_sec; + float timestep = blscene->r.frs_sec_base / blscene->r.frs_sec; if (ikparam->numstep > 0) timestep /= ikparam->numstep; // with equal min and max, the algorythm will take this step and the indicative substep most of the time @@ -1109,24 +1106,24 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) ikscene->cache = new iTaSC::Cache(); switch (ikparam->solver) { - case ITASC_SOLVER_SDLS: - ikscene->solver = new iTaSC::WSDLSSolver(); - break; - case ITASC_SOLVER_DLS: - ikscene->solver = new iTaSC::WDLSSolver(); - break; - default: - delete ikscene; - return NULL; + case ITASC_SOLVER_SDLS: + ikscene->solver = new iTaSC::WSDLSSolver(); + break; + case ITASC_SOLVER_DLS: + ikscene->solver = new iTaSC::WDLSSolver(); + break; + default: + delete ikscene; + return NULL; } ikscene->blArmature = ob; // assume uniform scaling and take Y scale as general scale for the armature ikscene->blScale = len_v3(ob->obmat[1]); - ikscene->blInvScale = (ikscene->blScale < KDL::epsilon) ? 0.0f : 1.0f/ikscene->blScale; + ikscene->blInvScale = (ikscene->blScale < KDL::epsilon) ? 0.0f : 1.0f / ikscene->blScale; - std::string joint; - std::string root("root"); - std::string parent; + std::string joint; + std::string root("root"); + std::string parent; std::vector<double> weights; double weight[3]; // build the array of joints corresponding to the IK chain @@ -1141,22 +1138,22 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) BKE_pose_rest(ikscene); } rot = ikscene->jointArray(0); - for (a=0, ikchan = ikscene->channels; a<tree->totchannel; ++a, ++ikchan) { - pchan= ikchan->pchan; - bone= pchan->bone; + for (a = 0, ikchan = ikscene->channels; a < tree->totchannel; ++a, ++ikchan) { + pchan = ikchan->pchan; + bone = pchan->bone; KDL::Frame tip(iTaSC::F_identity); Vector3 *fl = bone->bone_mat; KDL::Rotation brot( - fl[0][0], fl[1][0], fl[2][0], - fl[0][1], fl[1][1], fl[2][1], - fl[0][2], fl[1][2], fl[2][2]); + fl[0][0], fl[1][0], fl[2][0], + fl[0][1], fl[1][1], fl[2][1], + fl[0][2], fl[1][2], fl[2][2]); KDL::Vector bpos(bone->head[0], bone->head[1], bone->head[2]); bpos *= ikscene->blScale; KDL::Frame head(brot, bpos); - + // rest pose length of the bone taking scaling into account - length= bone->length*ikscene->blScale; + length = bone->length * ikscene->blScale; parent = (a > 0) ? ikscene->channels[tree->parent[a]].tail : root; // first the fixed segment to the bone head if (head.p.Norm() > KDL::epsilon || head.M.GetRot().Norm() > KDL::epsilon) { @@ -1170,95 +1167,95 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) tip.p[1] = length; } joint = bone->name; - weight[0] = (1.0-pchan->stiffness[0]); - weight[1] = (1.0-pchan->stiffness[1]); - weight[2] = (1.0-pchan->stiffness[2]); + weight[0] = (1.0 - pchan->stiffness[0]); + weight[1] = (1.0 - pchan->stiffness[1]); + weight[2] = (1.0 - pchan->stiffness[2]); switch (ikchan->jointType & ~IK_TRANSY) { - case 0: - // fixed bone - if (!(ikchan->jointType & IK_TRANSY)) { - joint += ":F"; - ret = arm->addSegment(joint, parent, KDL::Joint::None, 0.0, tip); - } - break; - case IK_XDOF: - // RX only, get the X rotation - joint += ":RX"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotX, rot[0], tip); - weights.push_back(weight[0]); - break; - case IK_YDOF: - // RY only, get the Y rotation - joint += ":RY"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[0], tip); - weights.push_back(weight[1]); - break; - case IK_ZDOF: - // RZ only, get the Zz rotation - joint += ":RZ"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotZ, rot[0], tip); - weights.push_back(weight[2]); - break; - case IK_XDOF|IK_YDOF: - joint += ":RX"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotX, rot[0]); - weights.push_back(weight[0]); - if (ret) { - parent = joint; - joint = bone->name; - joint += ":RY"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[1], tip); - weights.push_back(weight[1]); - } - break; - case IK_SWING: - joint += ":SW"; - ret = arm->addSegment(joint, parent, KDL::Joint::Swing, rot[0], tip); - weights.push_back(weight[0]); - weights.push_back(weight[2]); - break; - case IK_YDOF|IK_ZDOF: - // RZ+RY - joint += ":RZ"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotZ, rot[0]); - weights.push_back(weight[2]); - if (ret) { - parent = joint; - joint = bone->name; + case 0: + // fixed bone + if (!(ikchan->jointType & IK_TRANSY)) { + joint += ":F"; + ret = arm->addSegment(joint, parent, KDL::Joint::None, 0.0, tip); + } + break; + case IK_XDOF: + // RX only, get the X rotation + joint += ":RX"; + ret = arm->addSegment(joint, parent, KDL::Joint::RotX, rot[0], tip); + weights.push_back(weight[0]); + break; + case IK_YDOF: + // RY only, get the Y rotation joint += ":RY"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[1], tip); + ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[0], tip); weights.push_back(weight[1]); - } - break; - case IK_SWING|IK_YDOF: - // decompose in a Swing+RotY joint - joint += ":SW"; - ret = arm->addSegment(joint, parent, KDL::Joint::Swing, rot[0]); - weights.push_back(weight[0]); - weights.push_back(weight[2]); - if (ret) { - parent = joint; - joint = bone->name; - joint += ":RY"; - ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[2], tip); + break; + case IK_ZDOF: + // RZ only, get the Zz rotation + joint += ":RZ"; + ret = arm->addSegment(joint, parent, KDL::Joint::RotZ, rot[0], tip); + weights.push_back(weight[2]); + break; + case IK_XDOF | IK_YDOF: + joint += ":RX"; + ret = arm->addSegment(joint, parent, KDL::Joint::RotX, rot[0]); + weights.push_back(weight[0]); + if (ret) { + parent = joint; + joint = bone->name; + joint += ":RY"; + ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[1], tip); + weights.push_back(weight[1]); + } + break; + case IK_SWING: + joint += ":SW"; + ret = arm->addSegment(joint, parent, KDL::Joint::Swing, rot[0], tip); + weights.push_back(weight[0]); + weights.push_back(weight[2]); + break; + case IK_YDOF | IK_ZDOF: + // RZ+RY + joint += ":RZ"; + ret = arm->addSegment(joint, parent, KDL::Joint::RotZ, rot[0]); + weights.push_back(weight[2]); + if (ret) { + parent = joint; + joint = bone->name; + joint += ":RY"; + ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[1], tip); + weights.push_back(weight[1]); + } + break; + case IK_SWING | IK_YDOF: + // decompose in a Swing+RotY joint + joint += ":SW"; + ret = arm->addSegment(joint, parent, KDL::Joint::Swing, rot[0]); + weights.push_back(weight[0]); + weights.push_back(weight[2]); + if (ret) { + parent = joint; + joint = bone->name; + joint += ":RY"; + ret = arm->addSegment(joint, parent, KDL::Joint::RotY, rot[2], tip); + weights.push_back(weight[1]); + } + break; + case IK_REVOLUTE: + joint += ":SJ"; + ret = arm->addSegment(joint, parent, KDL::Joint::Sphere, rot[0], tip); + weights.push_back(weight[0]); weights.push_back(weight[1]); - } - break; - case IK_REVOLUTE: - joint += ":SJ"; - ret = arm->addSegment(joint, parent, KDL::Joint::Sphere, rot[0], tip); - weights.push_back(weight[0]); - weights.push_back(weight[1]); - weights.push_back(weight[2]); - break; + weights.push_back(weight[2]); + break; } if (ret && (ikchan->jointType & IK_TRANSY)) { parent = joint; joint = bone->name; joint += ":TY"; - ret = arm->addSegment(joint, parent, KDL::Joint::TransY, rot[ikchan->ndof-1]); - float ikstretch = pchan->ikstretch*pchan->ikstretch; - weight[1] = (1.0-MIN2(1.0-ikstretch, 0.99)); + ret = arm->addSegment(joint, parent, KDL::Joint::TransY, rot[ikchan->ndof - 1]); + float ikstretch = pchan->ikstretch * pchan->ikstretch; + weight[1] = (1.0 - MIN2(1.0 - ikstretch, 0.99)); weights.push_back(weight[1]); } if (!ret) @@ -1269,7 +1266,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) ikchan->head = parent; // in case of error ret = false; - if ((ikchan->jointType & IK_XDOF) && (pchan->ikflag & (BONE_IK_XLIMIT|BONE_IK_ROTCTL))) { + if ((ikchan->jointType & IK_XDOF) && (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_ROTCTL))) { joint = bone->name; joint += ":RX"; if (pchan->ikflag & BONE_IK_XLIMIT) { @@ -1281,7 +1278,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) break; } } - if ((ikchan->jointType & IK_YDOF) && (pchan->ikflag & (BONE_IK_YLIMIT|BONE_IK_ROTCTL))) { + if ((ikchan->jointType & IK_YDOF) && (pchan->ikflag & (BONE_IK_YLIMIT | BONE_IK_ROTCTL))) { joint = bone->name; joint += ":RY"; if (pchan->ikflag & BONE_IK_YLIMIT) { @@ -1293,7 +1290,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) break; } } - if ((ikchan->jointType & IK_ZDOF) && (pchan->ikflag & (BONE_IK_ZLIMIT|BONE_IK_ROTCTL))) { + if ((ikchan->jointType & IK_ZDOF) && (pchan->ikflag & (BONE_IK_ZLIMIT | BONE_IK_ROTCTL))) { joint = bone->name; joint += ":RZ"; if (pchan->ikflag & BONE_IK_ZLIMIT) { @@ -1305,7 +1302,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) break; } } - if ((ikchan->jointType & IK_SWING) && (pchan->ikflag & (BONE_IK_XLIMIT|BONE_IK_ZLIMIT|BONE_IK_ROTCTL))) { + if ((ikchan->jointType & IK_SWING) && (pchan->ikflag & (BONE_IK_XLIMIT | BONE_IK_ZLIMIT | BONE_IK_ROTCTL))) { joint = bone->name; joint += ":SW"; if (pchan->ikflag & BONE_IK_XLIMIT) { @@ -1336,13 +1333,13 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) return NULL; } // for each target, we need to add an end effector in the armature - for (numtarget=0, polarcon=NULL, ret = true, target=(PoseTarget*)tree->targets.first; target; target=(PoseTarget*)target->next) { - condata= (bKinematicConstraint*)target->con->data; + for (numtarget = 0, polarcon = NULL, ret = true, target = (PoseTarget *)tree->targets.first; target; target = (PoseTarget *)target->next) { + condata = (bKinematicConstraint *)target->con->data; pchan = tree->pchan[target->tip]; if (is_cartesian_constraint(target->con)) { // add the end effector - IK_Target* iktarget = new IK_Target(); + IK_Target *iktarget = new IK_Target(); ikscene->targets.push_back(iktarget); iktarget->ee = arm->addEndEffector(ikscene->channels[target->tip].tail); if (iktarget->ee == -1) { @@ -1372,7 +1369,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) ikscene->polarConstraint = polarcon; } // we can now add the armature - // the armature is based on a moving frame. + // 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); ikscene->base = new iTaSC::MovingFrame(initPose); @@ -1392,8 +1389,8 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) // set the weight e_matrix& Wq = arm->getWq(); assert(Wq.cols() == (int)weights.size()); - for (int q=0; q<Wq.cols(); q++) - Wq(q, q)=weights[q]; + for (int q = 0; q < Wq.cols(); q++) + Wq(q, q) = weights[q]; // get the inverse rest pose frame of the base to compute relative rest pose of end effectors // this is needed to handle the enforce parameter // ikscene->pchan[0] is the root channel of the tree @@ -1401,9 +1398,9 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) float invBaseFrame[4][4]; pchan = ikscene->channels[0].pchan; if (pchan->parent) { - // it has a parent, get the pose matrix from it + // it has a parent, get the pose matrix from it float baseFrame[4][4]; - pchan = pchan->parent; + pchan = pchan->parent; copy_m4_m4(baseFrame, pchan->bone->arm_mat); // move to the tail and scale to get rest pose of armature base copy_v3_v3(baseFrame[3], pchan->bone->arm_tail); @@ -1413,10 +1410,10 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) unit_m4(invBaseFrame); } // finally add the constraint - for (t=0; t<ikscene->targets.size(); t++) { - IK_Target* iktarget = ikscene->targets[t]; + for (t = 0; t < ikscene->targets.size(); t++) { + IK_Target *iktarget = ikscene->targets[t]; iktarget->blscene = blscene; - condata= (bKinematicConstraint*)iktarget->blenderConstraint->data; + condata = (bKinematicConstraint *)iktarget->blenderConstraint->data; pchan = tree->pchan[iktarget->channel]; unsigned int controltype, bonecnt; double bonelen; @@ -1424,16 +1421,16 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) // add the end effector // estimate the average bone length, used to clamp feedback error - for (bonecnt=0, bonelen=0.f, a=iktarget->channel; a>=0; a=tree->parent[a], bonecnt++) - bonelen += ikscene->blScale*tree->pchan[a]->bone->length; - bonelen /= bonecnt; + for (bonecnt = 0, bonelen = 0.f, a = iktarget->channel; a >= 0; a = tree->parent[a], bonecnt++) + bonelen += ikscene->blScale * tree->pchan[a]->bone->length; + bonelen /= bonecnt; // store the rest pose of the end effector to compute enforce target copy_m4_m4(mat, pchan->bone->arm_mat); copy_v3_v3(mat[3], pchan->bone->arm_tail); // get the rest pose relative to the armature base mult_m4_m4m4(iktarget->eeRest, invBaseFrame, mat); - iktarget->eeBlend = (!ikscene->polarConstraint && condata->type==CONSTRAINT_IK_COPYPOSE) ? true : false; + 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); iktarget->target = new iTaSC::MovingFrame(initPose); @@ -1443,59 +1440,59 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) break; switch (condata->type) { - case CONSTRAINT_IK_COPYPOSE: - controltype = 0; - if (condata->flag & CONSTRAINT_IK_ROT) { - if (!(condata->flag & CONSTRAINT_IK_NO_ROT_X)) - controltype |= iTaSC::CopyPose::CTL_ROTATIONX; - if (!(condata->flag & CONSTRAINT_IK_NO_ROT_Y)) - controltype |= iTaSC::CopyPose::CTL_ROTATIONY; - if (!(condata->flag & CONSTRAINT_IK_NO_ROT_Z)) - controltype |= iTaSC::CopyPose::CTL_ROTATIONZ; - } - if (condata->flag & CONSTRAINT_IK_POS) { - if (!(condata->flag & CONSTRAINT_IK_NO_POS_X)) - controltype |= iTaSC::CopyPose::CTL_POSITIONX; - if (!(condata->flag & CONSTRAINT_IK_NO_POS_Y)) - controltype |= iTaSC::CopyPose::CTL_POSITIONY; - if (!(condata->flag & CONSTRAINT_IK_NO_POS_Z)) - controltype |= iTaSC::CopyPose::CTL_POSITIONZ; - } - if (controltype) { - iktarget->constraint = new iTaSC::CopyPose(controltype, controltype, bonelen); - // set the gain - if (controltype & iTaSC::CopyPose::CTL_POSITION) - iktarget->constraint->setControlParameter(iTaSC::CopyPose::ID_POSITION, iTaSC::ACT_ALPHA, condata->weight); - if (controltype & iTaSC::CopyPose::CTL_ROTATION) - iktarget->constraint->setControlParameter(iTaSC::CopyPose::ID_ROTATION, iTaSC::ACT_ALPHA, condata->orientweight); - iktarget->constraint->registerCallback(copypose_callback, iktarget); - iktarget->errorCallback = copypose_error; - iktarget->controlType = controltype; + case CONSTRAINT_IK_COPYPOSE: + controltype = 0; + if (condata->flag & CONSTRAINT_IK_ROT) { + if (!(condata->flag & CONSTRAINT_IK_NO_ROT_X)) + controltype |= iTaSC::CopyPose::CTL_ROTATIONX; + if (!(condata->flag & CONSTRAINT_IK_NO_ROT_Y)) + controltype |= iTaSC::CopyPose::CTL_ROTATIONY; + if (!(condata->flag & CONSTRAINT_IK_NO_ROT_Z)) + controltype |= iTaSC::CopyPose::CTL_ROTATIONZ; + } + if (condata->flag & CONSTRAINT_IK_POS) { + if (!(condata->flag & CONSTRAINT_IK_NO_POS_X)) + controltype |= iTaSC::CopyPose::CTL_POSITIONX; + if (!(condata->flag & CONSTRAINT_IK_NO_POS_Y)) + controltype |= iTaSC::CopyPose::CTL_POSITIONY; + if (!(condata->flag & CONSTRAINT_IK_NO_POS_Z)) + controltype |= iTaSC::CopyPose::CTL_POSITIONZ; + } + if (controltype) { + iktarget->constraint = new iTaSC::CopyPose(controltype, controltype, bonelen); + // set the gain + if (controltype & iTaSC::CopyPose::CTL_POSITION) + iktarget->constraint->setControlParameter(iTaSC::CopyPose::ID_POSITION, iTaSC::ACT_ALPHA, condata->weight); + if (controltype & iTaSC::CopyPose::CTL_ROTATION) + iktarget->constraint->setControlParameter(iTaSC::CopyPose::ID_ROTATION, iTaSC::ACT_ALPHA, condata->orientweight); + iktarget->constraint->registerCallback(copypose_callback, iktarget); + iktarget->errorCallback = copypose_error; + iktarget->controlType = controltype; + // add the constraint + if (condata->flag & CONSTRAINT_IK_TARGETAXIS) + ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, iktarget->targetName, armname, "", ikscene->channels[iktarget->channel].tail); + else + ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, armname, iktarget->targetName, ikscene->channels[iktarget->channel].tail); + } + break; + case CONSTRAINT_IK_DISTANCE: + iktarget->constraint = new iTaSC::Distance(bonelen); + iktarget->constraint->setControlParameter(iTaSC::Distance::ID_DISTANCE, iTaSC::ACT_VALUE, condata->dist); + iktarget->constraint->registerCallback(distance_callback, iktarget); + iktarget->errorCallback = distance_error; + // we can update the weight on each substep + iktarget->constraint->substep(true); // add the constraint - if (condata->flag & CONSTRAINT_IK_TARGETAXIS) - ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, iktarget->targetName, armname, "", ikscene->channels[iktarget->channel].tail); - else - ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, armname, iktarget->targetName, ikscene->channels[iktarget->channel].tail); - } - break; - case CONSTRAINT_IK_DISTANCE: - iktarget->constraint = new iTaSC::Distance(bonelen); - iktarget->constraint->setControlParameter(iTaSC::Distance::ID_DISTANCE, iTaSC::ACT_VALUE, condata->dist); - iktarget->constraint->registerCallback(distance_callback, iktarget); - iktarget->errorCallback = distance_error; - // we can update the weight on each substep - iktarget->constraint->substep(true); - // add the constraint - ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, armname, iktarget->targetName, ikscene->channels[iktarget->channel].tail); - break; + ret = scene->addConstraintSet(iktarget->constraintName, iktarget->constraint, armname, iktarget->targetName, ikscene->channels[iktarget->channel].tail); + break; } if (!ret) break; } if (!ret || - !scene->addCache(ikscene->cache) || - !scene->addSolver(ikscene->solver) || - !scene->initialize()) { + !scene->addCache(ikscene->cache) || + !scene->addSolver(ikscene->solver) || + !scene->initialize()) { delete ikscene; ikscene = NULL; } @@ -1507,13 +1504,13 @@ static void create_scene(Scene *scene, Object *ob) bPoseChannel *pchan; // create the IK scene - for (pchan= (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan= (bPoseChannel *)pchan->next) { + for (pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = (bPoseChannel *)pchan->next) { // by construction there is only one tree - PoseTree *tree = (PoseTree*)pchan->iktree.first; + PoseTree *tree = (PoseTree *)pchan->iktree.first; if (tree) { - IK_Data* ikdata = get_ikdata(ob->pose); + IK_Data *ikdata = get_ikdata(ob->pose); // convert tree in iTaSC::Scene - IK_Scene* ikscene = convert_tree(scene, ob, pchan); + IK_Scene *ikscene = convert_tree(scene, ob, pchan); if (ikscene) { ikscene->next = ikdata->first; ikdata->first = ikscene; @@ -1526,7 +1523,7 @@ static void create_scene(Scene *scene, Object *ob) if (tree->parent) MEM_freeN(tree->parent); if (tree->basis_change) MEM_freeN(tree->basis_change); MEM_freeN(tree); - tree = (PoseTree*)pchan->iktree.first; + tree = (PoseTree *)pchan->iktree.first; } } } @@ -1537,12 +1534,12 @@ static int init_scene(Object *ob) { // check also if scaling has changed float scale = len_v3(ob->obmat[1]); - IK_Scene* scene; + IK_Scene *scene; if (ob->pose->ikdata) { - for (scene = ((IK_Data*)ob->pose->ikdata)->first; - scene != NULL; - scene = scene->next) { + for (scene = ((IK_Data *)ob->pose->ikdata)->first; + scene != NULL; + scene = scene->next) { if (fabs(scene->blScale - scale) > KDL::epsilon) return 1; scene->channels[0].pchan->flag |= POSE_IKTREE; @@ -1551,31 +1548,31 @@ 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(Scene *blscene, IK_Scene *ikscene, bItasc *ikparam, float ctime, float frtime) { int i; - IK_Channel* ikchan; + IK_Channel *ikchan; if (ikparam->flag & ITASC_SIMULATION) { - for (i=0, ikchan=ikscene->channels; i<ikscene->numchan; i++, ++ikchan) { + for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; i++, ++ikchan) { // In simulation mode we don't allow external contraint to change our bones, mark the channel done // also tell Blender that this channel is part of IK tree (cleared on each BKE_pose_where_is() - ikchan->pchan->flag |= (POSE_DONE|POSE_CHAIN); + ikchan->pchan->flag |= (POSE_DONE | POSE_CHAIN); ikchan->jointValid = 0; } } else { // in animation mode, we must get the bone position from action and constraints - for (i=0, ikchan=ikscene->channels; i<ikscene->numchan; i++, ++ikchan) { + 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); // 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->pchan->flag |= (POSE_DONE | POSE_CHAIN); ikchan->jointValid = 0; } } // only run execute the scene if at least one of our target is enabled - for (i=ikscene->targets.size(); i > 0; --i) { - IK_Target* iktarget = ikscene->targets[i-1]; + for (i = ikscene->targets.size(); i > 0; --i) { + IK_Target *iktarget = ikscene->targets[i - 1]; if (!(iktarget->blenderConstraint->flag & CONSTRAINT_OFF)) break; } @@ -1592,7 +1589,7 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl if (ikparam->flag & ITASC_SIMULATION) { ikscene->solver->setParam(iTaSC::Solver::DLS_QMAX, ikparam->maxvel); - } + } else { // in animation mode we start from the pose after action and constraint convert_pose(ikscene); @@ -1601,15 +1598,15 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl reiterate = true; simulation = false; // time is virtual, so take fixed value for velocity parameters (see itasc_update_param) - // and choose 1s timestep to allow having velocity parameters in radiant + // and choose 1s timestep to allow having velocity parameters in radiant timestep = 1.0; // use auto setup to let the solver test the variation of the joints numstep = 0; } - + if (ikscene->cache && !reiterate && simulation) { iTaSC::CacheTS sts, cts; - sts = cts = (iTaSC::CacheTS)(timestamp*1000.0+0.5); + sts = cts = (iTaSC::CacheTS)(timestamp * 1000.0 + 0.5); if (ikscene->cache->getPreviousCacheItem(ikscene->armature, 0, &cts) == NULL || cts == 0) { // the cache is empty before this time, reiterate if (ikparam->flag & ITASC_INITIAL_REITERATION) @@ -1618,14 +1615,14 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl else { // can take the cache as a start point. sts -= cts; - timestep = sts/1000.0; + timestep = sts / 1000.0; } } // don't cache if we are reiterating because we don't want to distroy the cache unnecessarily ikscene->scene->update(timestamp, timestep, numstep, false, !reiterate, simulation); if (reiterate) { // how many times do we reiterate? - for (i = 0; i<ikparam->numiter; i++) { + for (i = 0; i < ikparam->numiter; i++) { if (ikscene->armature->getMaxJointChange() < ikparam->precision || ikscene->armature->getMaxEndEffectorChange() < ikparam->precision) { @@ -1639,11 +1636,11 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl } } // compute constraint error - for (i=ikscene->targets.size(); i > 0; --i) { - IK_Target* iktarget = ikscene->targets[i-1]; + for (i = ikscene->targets.size(); i > 0; --i) { + IK_Target *iktarget = ikscene->targets[i - 1]; if (!(iktarget->blenderConstraint->flag & CONSTRAINT_OFF)) { unsigned int nvalues; - const iTaSC::ConstraintValues* values; + const iTaSC::ConstraintValues *values; values = iktarget->constraint->getControlParameters(&nvalues); iktarget->errorCallback(values, nvalues, iktarget); } @@ -1654,22 +1651,22 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl // combine the parent and the joint frame to get the frame relative to armature // a backward translation of the bone length gives the head // if TY, compute the scale as the ratio of the joint length with rest pose length - iTaSC::Armature* arm = ikscene->armature; + iTaSC::Armature *arm = ikscene->armature; KDL::Frame frame; double q_rest[3], q[3]; - const KDL::Joint* joint; - const KDL::Frame* tip; - bPoseChannel* pchan; + const KDL::Joint *joint; + const KDL::Frame *tip; + bPoseChannel *pchan; float scale; float length; float yaxis[3]; - for (i=0, ikchan=ikscene->channels; i<ikscene->numchan; ++i, ++ikchan) { + for (i = 0, ikchan = ikscene->channels; i < ikscene->numchan; ++i, ++ikchan) { if (i == 0) { if (!arm->getRelativeFrame(frame, ikchan->tail)) break; // this frame is relative to base, make it relative to object ikchan->frame = ikscene->baseFrame * frame; - } + } else { if (!arm->getRelativeFrame(frame, ikchan->tail, ikscene->channels[ikchan->parent].tail)) break; @@ -1682,10 +1679,10 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl break; if (joint->getType() == KDL::Joint::TransY) { // stretch bones have a TY joint, compute the scale - scale = (float)(q[0]/q_rest[0]); + scale = (float)(q[0] / q_rest[0]); // the length is the joint itself length = (float)q[0]; - } + } else { scale = 1.0f; // for fixed bone, the length is in the tip (always along Y axis) @@ -1710,7 +1707,7 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl mul_v3_fl(pchan->pose_mat[1], scale); mul_v3_fl(pchan->pose_mat[2], scale); } - if (i<ikscene->numchan) { + if (i < ikscene->numchan) { // big problem ; } @@ -1732,11 +1729,11 @@ void itasc_initialize_tree(struct Scene *scene, Object *ob, float ctime) itasc_clear_data(ob->pose); // we should handle all the constraint and mark them all disabled // for blender but we'll start with the IK constraint alone - for (pchan= (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan= (bPoseChannel *)pchan->next) { + for (pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = (bPoseChannel *)pchan->next) { if (pchan->constflag & PCHAN_HAS_IK) count += initialize_scene(ob, pchan); } - // if at least one tree, create the scenes from the PoseTree stored in the channels + // if at least one tree, create the scenes from the PoseTree stored in the channels if (count) create_scene(scene, ob); itasc_update_param(ob->pose); @@ -1747,14 +1744,14 @@ void itasc_initialize_tree(struct Scene *scene, Object *ob, float ctime) void itasc_execute_tree(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime) { if (ob->pose->ikdata) { - IK_Data* ikdata = (IK_Data*)ob->pose->ikdata; - bItasc* ikparam = (bItasc*) ob->pose->ikparam; + IK_Data *ikdata = (IK_Data *)ob->pose->ikdata; + bItasc *ikparam = (bItasc *) ob->pose->ikparam; // we need default parameters if (!ikparam) ikparam = &DefIKParam; - for (IK_Scene* ikscene = ikdata->first; ikscene; ikscene = ikscene->next) { + for (IK_Scene *ikscene = ikdata->first; ikscene; ikscene = ikscene->next) { if (ikscene->channels[0].pchan == pchan) { - float timestep = scene->r.frs_sec_base/scene->r.frs_sec; + float timestep = scene->r.frs_sec_base / scene->r.frs_sec; if (ob->pose->flag & POSE_GAME_ENGINE) { timestep = ob->pose->ctime; // limit the timestep to avoid excessive number of iteration @@ -1776,8 +1773,8 @@ void itasc_release_tree(struct Scene *scene, struct Object *ob, float ctime) void itasc_clear_data(struct bPose *pose) { if (pose->ikdata) { - IK_Data* ikdata = (IK_Data*)pose->ikdata; - for (IK_Scene* scene = ikdata->first; scene; scene = ikdata->first) { + IK_Data *ikdata = (IK_Data *)pose->ikdata; + for (IK_Scene *scene = ikdata->first; scene; scene = ikdata->first) { ikdata->first = scene->next; delete scene; } @@ -1789,8 +1786,8 @@ void itasc_clear_data(struct bPose *pose) void itasc_clear_cache(struct bPose *pose) { if (pose->ikdata) { - IK_Data* ikdata = (IK_Data*)pose->ikdata; - for (IK_Scene* scene = ikdata->first; scene; scene = scene->next) { + IK_Data *ikdata = (IK_Data *)pose->ikdata; + for (IK_Scene *scene = ikdata->first; scene; scene = scene->next) { if (scene->cache) // clear all cache but leaving the timestamp 0 (=rest pose) scene->cache->clearCacheFrom(NULL, 1); @@ -1801,12 +1798,12 @@ void itasc_clear_cache(struct bPose *pose) void itasc_update_param(struct bPose *pose) { if (pose->ikdata && pose->ikparam) { - IK_Data* ikdata = (IK_Data*)pose->ikdata; - bItasc* ikparam = (bItasc*)pose->ikparam; - for (IK_Scene* ikscene = ikdata->first; ikscene; ikscene = ikscene->next) { + IK_Data *ikdata = (IK_Data *)pose->ikdata; + bItasc *ikparam = (bItasc *)pose->ikparam; + for (IK_Scene *ikscene = ikdata->first; ikscene; ikscene = ikscene->next) { double armlength = ikscene->armature->getArmLength(); - ikscene->solver->setParam(iTaSC::Solver::DLS_LAMBDA_MAX, ikparam->dampmax*armlength); - ikscene->solver->setParam(iTaSC::Solver::DLS_EPSILON, ikparam->dampeps*armlength); + ikscene->solver->setParam(iTaSC::Solver::DLS_LAMBDA_MAX, ikparam->dampmax * armlength); + ikscene->solver->setParam(iTaSC::Solver::DLS_EPSILON, ikparam->dampeps * armlength); if (ikparam->flag & ITASC_SIMULATION) { ikscene->scene->setParam(iTaSC::Scene::MIN_TIMESTEP, ikparam->minstep); ikscene->scene->setParam(iTaSC::Scene::MAX_TIMESTEP, ikparam->maxstep); @@ -1814,7 +1811,7 @@ void itasc_update_param(struct bPose *pose) ikscene->armature->setControlParameter(CONSTRAINT_ID_ALL, iTaSC::Armature::ID_JOINT, iTaSC::ACT_FEEDBACK, ikparam->feedback); } else { - // in animation mode timestep is 1s by convention => + // in animation mode timestep is 1s by convention => // qmax becomes radiant and feedback becomes fraction of error gap corrected in one iteration ikscene->scene->setParam(iTaSC::Scene::MIN_TIMESTEP, 1.0); ikscene->scene->setParam(iTaSC::Scene::MAX_TIMESTEP, 1.0); @@ -1834,10 +1831,10 @@ void itasc_test_constraint(struct Object *ob, struct bConstraint *cons) return; switch (data->type) { - case CONSTRAINT_IK_COPYPOSE: - case CONSTRAINT_IK_DISTANCE: - /* cartesian space constraint */ - break; + case CONSTRAINT_IK_COPYPOSE: + case CONSTRAINT_IK_DISTANCE: + /* cartesian space constraint */ + break; } } diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 2cb1dfe149a..dcb5cdd7d32 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -50,6 +50,13 @@ struct ImMetaData; #define IB_MIPMAP_LEVELS 20 #define IB_FILENAME_SIZE 1024 +typedef struct DDSData { + unsigned int fourcc; /* DDS fourcc info */ + unsigned int nummipmaps; /* The number of mipmaps in the dds file */ + unsigned char *data; /* The compressed image data */ + unsigned int size; /* The size of the compressed data */ +} DDSData; + /** * \ingroup imbuf * This is the abstraction of an image. ImBuf is the basic type used for all @@ -119,6 +126,9 @@ typedef struct ImBuf { unsigned char *encodedbuffer; /* Compressed image only used with png currently */ unsigned int encodedsize; /* Size of data written to encodedbuffer */ unsigned int encodedbuffersize; /* Size of encodedbuffer */ + + /* information for compressed textures */ + struct DDSData dds_data; } ImBuf; /* Moved from BKE_bmfont_types.h because it is a userflag bit mask. */ @@ -215,6 +225,28 @@ typedef struct ImBuf { #define IB_PROFILE_SRGB 2 #define IB_PROFILE_CUSTOM 3 +/* dds */ +#ifdef WITH_DDS +#ifndef MAKEFOURCC +#define MAKEFOURCC(ch0, ch1, ch2, ch3)\ + ((unsigned long)(unsigned char)(ch0) | \ + ((unsigned long)(unsigned char)(ch1) << 8) | \ + ((unsigned long)(unsigned char)(ch2) << 16) | \ + ((unsigned long)(unsigned char)(ch3) << 24)) +#endif //MAKEFOURCC + +/* + * FOURCC codes for DX compressed-texture pixel formats + */ + +#define FOURCC_DDS (MAKEFOURCC('D','D','S',' ')) +#define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1')) +#define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2')) +#define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3')) +#define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4')) +#define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5')) + +#endif // DDS extern const char *imb_ext_image[]; extern const char *imb_ext_image_qt[]; extern const char *imb_ext_movie[]; diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 319e3f27bd8..68a094c26d0 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -162,6 +162,8 @@ void IMB_freeImBuf(ImBuf *ibuf) IMB_freezbuffloatImBuf(ibuf); freeencodedbufferImBuf(ibuf); IMB_metadata_free(ibuf); + if (ibuf->dds_data.data != NULL) + free(ibuf->dds_data.data); /* dds_data.data is allocated by DirectDrawSurface::readData(), so don't use MEM_freeN! */ MEM_freeN(ibuf); } } @@ -351,7 +353,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int ibuf->planes = planes; ibuf->ftype = TGA; ibuf->channels = 4; /* float option, is set to other values when buffers get assigned */ - ibuf->ppm[0] = ibuf->ppm[1] = 150.0 / 0.0254; /* 150dpi -> pixels-per-meter */ + ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254; /* IMB_DPI_DEFAULT -> pixels-per-meter */ if (flags & IB_rect) { if (imb_addrectImBuf(ibuf) == FALSE) { diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index f777d40dca9..f0c2d754333 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -64,7 +64,7 @@ #include <io.h> #endif -#include "BLI_blenlib.h" /* BLI_remlink BLI_filesize BLI_addtail +#include "BLI_blenlib.h" /* BLI_remlink BLI_file_descriptor_size BLI_addtail * BLI_countlist BLI_stringdec */ #include "BLI_utildefines.h" #include "BLI_math_base.h" @@ -551,8 +551,8 @@ static int startffmpeg(struct anim *anim) anim->pFrameDeinterlaced = avcodec_alloc_frame(); anim->pFrameRGB = avcodec_alloc_frame(); - if (avpicture_get_size(PIX_FMT_RGBA, anim->x, anim->y) - != anim->x * anim->y * 4) + if (avpicture_get_size(PIX_FMT_RGBA, anim->x, anim->y) != + anim->x * anim->y * 4) { fprintf(stderr, "ffmpeg has changed alloc scheme ... ARGHHH!\n"); diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c index 8e996b97622..182e0a7e29d 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c @@ -83,7 +83,7 @@ static ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int size, logImageGetSize(image, &width, &height, &depth); - if (depth != 3) { /*need to do greyscale loading eventually.*/ + if (depth != 3) { /*need to do grayscale loading eventually.*/ logImageClose(image); return NULL; } diff --git a/source/blender/imbuf/intern/cineon/dpxfile.h b/source/blender/imbuf/intern/cineon/dpxfile.h index 8846c7418d5..e1d95268a80 100644 --- a/source/blender/imbuf/intern/cineon/dpxfile.h +++ b/source/blender/imbuf/intern/cineon/dpxfile.h @@ -62,7 +62,7 @@ typedef struct { R32 ref_high_quantity;/* reference high quantity represented */ U8 designator1; U8 transfer_characteristics; - U8 colourimetry; + U8 colorimetry; U8 bits_per_pixel; U16 packing; U16 encoding; diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c index a4b8c9d3f36..c1138225e93 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.c +++ b/source/blender/imbuf/intern/cineon/dpxlib.c @@ -53,7 +53,7 @@ fillDpxChannelInfo(DpxFile* dpx, DpxChannelInformation* chan, int des) { chan->ref_high_quantity = htonf(2.046); chan->designator1 = des; chan->transfer_characteristics = 0; - chan->colourimetry = 0; + chan->colorimetry = 0; chan->bits_per_pixel = 10; chan->packing = htons(1); chan->encoding = 0; diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp index 438988fbe48..82f355e1bb2 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp @@ -1016,6 +1016,10 @@ uint DirectDrawSurface::mipmapCount() const else return 1; } +uint DirectDrawSurface::fourCC() const +{ + return header.pf.fourcc; +} uint DirectDrawSurface::width() const { @@ -1131,6 +1135,29 @@ void DirectDrawSurface::mipmap(Image * img, uint face, uint mipmap) } } +// It was easier to copy this function from upstream than to resync. +// This should be removed if a resync ever occurs. +void* DirectDrawSurface::readData(uint &rsize) +{ + uint header_size = 128; // sizeof(DDSHeader); + if (header.hasDX10Header()) + { + header_size += 20; // sizeof(DDSHeader10); + } + + uint size = stream.size - header_size; + rsize = size; + + unsigned char *data = new unsigned char[size]; + + stream.seek(header_size); + mem_read(stream, data, size); + + // Maybe check if size == rsize? assert() isn't in this scope... + + return data; +} + void DirectDrawSurface::readLinearImage(Image * img) { diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.h b/source/blender/imbuf/intern/dds/DirectDrawSurface.h index ddae8826620..a851533b1f3 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.h +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.h @@ -158,6 +158,7 @@ public: bool hasAlpha() const; uint mipmapCount() const; + uint fourCC() const; uint width() const; uint height() const; uint depth() const; @@ -171,6 +172,7 @@ public: void setUserVersion(int version); void mipmap(Image * img, uint f, uint m); + void* readData(uint &size); // void mipmap(FloatImage * img, uint f, uint m); void printInfo() const; diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp index 071d94c2076..fba326f7865 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -123,6 +123,8 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags) ibuf->ftype = DDS; ibuf->profile = IB_PROFILE_SRGB; + ibuf->dds_data.fourcc = dds.fourCC(); + ibuf->dds_data.nummipmaps = dds.mipmapCount(); if ((flags & IB_test) == 0) { if (!imb_addrectImBuf(ibuf)) return(ibuf); @@ -136,10 +138,18 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags) cp[0] = pixel.r; /* set R component of col */ cp[1] = pixel.g; /* set G component of col */ cp[2] = pixel.b; /* set B component of col */ - if (bits_per_pixel == 32) + if (dds.hasAlpha()) cp[3] = pixel.a; /* set A component of col */ rect[i] = col; } + + if (ibuf->dds_data.fourcc != FOURCC_DDS) + ibuf->dds_data.data = (unsigned char*)dds.readData(ibuf->dds_data.size); + else { + ibuf->dds_data.data = NULL; + ibuf->dds_data.size = 0; + } + IMB_flipy(ibuf); } diff --git a/source/blender/imbuf/intern/imbuf.h b/source/blender/imbuf/intern/imbuf.h index 47b4b7b6a58..999aae81cb7 100644 --- a/source/blender/imbuf/intern/imbuf.h +++ b/source/blender/imbuf/intern/imbuf.h @@ -72,5 +72,7 @@ typedef unsigned char uchar; #define TRUE 1 #define FALSE 0 +#define IMB_DPI_DEFAULT 72.0f + #endif /* __IMBUF_H__ */ diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 0ccd2680461..8b2e27ae1f3 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -313,7 +313,7 @@ int IMB_proxy_size_to_array_index(IMB_Proxy_Size pr_size) { switch (pr_size) { case IMB_PROXY_NONE: /* if we got here, something is broken anyways, - so sane defaults... */ + * so sane defaults... */ return 0; case IMB_PROXY_25: return 0; @@ -333,7 +333,7 @@ int IMB_timecode_to_array_index(IMB_Timecode_Type tc) { switch (tc) { case IMB_TC_NONE: /* if we got here, something is broken anyways, - so sane defaults... */ + * so sane defaults... */ return 0; case IMB_TC_RECORD_RUN: return 0; @@ -906,11 +906,11 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context, pts_time_base * frame_rate + 0.5f); /* decoding starts *always* on I-Frames, - so: P-Frames won't work, even if all the - information is in place, when we seek - to the I-Frame presented *after* the P-Frame, - but located before the P-Frame within - the stream */ + * so: P-Frames won't work, even if all the + * information is in place, when we seek + * to the I-Frame presented *after* the P-Frame, + * but located before the P-Frame within + * the stream */ if (pts < seek_pos_pts) { s_pos = last_seek_pos; @@ -966,7 +966,7 @@ static AviMovie *alloc_proxy_output_avi( double framerate; AviMovie *avi; short frs_sec = 25; /* it doesn't really matter for proxies, - but sane defaults help anyways...*/ + * but sane defaults help anyways...*/ float frs_sec_base = 1.0; IMB_anim_get_fps(anim, &frs_sec, &frs_sec_base); diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index a5826634724..3008c233718 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -175,13 +175,13 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) h = image->comps[0].h; switch (image->numcomps) { - case 1: /* Greyscale */ + case 1: /* Grayscale */ case 3: /* Color */ planes = 24; use_alpha = FALSE; break; - default: /* 2 or 4 - Greyscale or Color + alpha */ - planes = 32; /* greyscale + alpha */ + default: /* 2 or 4 - Grayscale or Color + alpha */ + planes = 32; /* grayscale + alpha */ use_alpha = TRUE; break; } @@ -220,7 +220,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) r = image->comps[0].data; a = (use_alpha) ? image->comps[1].data : NULL; - /* greyscale 12bits+ */ + /* grayscale 12bits+ */ if (use_alpha) { a = image->comps[1].data; PIXEL_LOOPER_BEGIN(rect_float) { @@ -272,7 +272,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) r = image->comps[0].data; a = (use_alpha) ? image->comps[1].data : NULL; - /* greyscale */ + /* grayscale */ if (use_alpha) { a = image->comps[3].data; PIXEL_LOOPER_BEGIN(rect_uchar) { @@ -332,7 +332,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) return(ibuf); } -//static opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp) { +//static opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp) /* prec can be 8, 12, 16 */ /* use inline because the float passed can be a function call that would end up being called many times */ diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 556ec64e59a..615b420429a 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -36,7 +36,7 @@ * high-level routine that loads all images as 32-bit RGBA, handling all the * required conversions between many different TIFF types internally. * - * Saving supports RGB, RGBA and BW (greyscale) images correctly, with + * Saving supports RGB, RGBA and BW (grayscale) images correctly, with * 8 bits per channel in all cases. The "deflate" compression algorithm is * used to compress images. */ @@ -765,7 +765,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) PHOTOMETRIC_RGB); } else if (samplesperpixel == 1) { - /* greyscale images, 1 channel */ + /* grayscale images, 1 channel */ TIFFSetField(image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); } @@ -811,7 +811,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) yres = (float)(ibuf->ppm[1] * 0.0254); } else { - xres = yres = 150.0f; + xres = yres = IMB_DPI_DEFAULT; } TIFFSetField(image, TIFFTAG_XRESOLUTION, xres); diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index ea012090bbd..a8292d02463 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -43,7 +43,7 @@ struct Group; struct GHash; /* ************************************************ */ -/* Visualisation */ +/* Visualization */ /* Motion Paths ------------------------------------ */ /* (used for Pose Channels and Objects) */ @@ -83,10 +83,10 @@ typedef enum eMotionPath_Flag { MOTIONPATH_FLAG_EDIT = (1 << 1) } eMotionPath_Flag; -/* Visualisation General --------------------------- */ +/* Visualization General --------------------------- */ /* for Objects or Poses (but NOT PoseChannels) */ -/* Animation Visualisation Settings (avs) */ +/* Animation Visualization Settings (avs) */ typedef struct bAnimVizSettings { /* Onion-Skinning Settings ----------------- */ int ghost_sf, ghost_ef; /* start and end frames of ghost-drawing range (only used for GHOST_TYPE_RANGE) */ @@ -254,7 +254,7 @@ typedef enum ePchan_Flag { /* IK/Pose solving*/ POSE_CHAIN = (1 << 9), POSE_DONE = (1 << 10), - /* visualisation */ + /* visualization */ POSE_KEY = (1 << 11), POSE_STRIDE = (1 << 12), /* standard IK solving */ @@ -679,7 +679,7 @@ typedef struct bActionChannel { /* Action Channel flags (ONLY USED FOR DO_VERSIONS...) */ typedef enum ACHAN_FLAG { ACHAN_SELECTED = (1 << 0), - ACHAN_HILIGHTED = (1 << 1), + ACHAN_HIGHLIGHTED = (1 << 1), ACHAN_HIDDEN = (1 << 2), ACHAN_PROTECTED = (1 << 3), ACHAN_EXPANDED = (1 << 4), diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index 55fb3322806..17ee8723e53 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -891,7 +891,7 @@ typedef enum eAnimData_Flag { typedef enum eAnimData_Recalc { ADT_RECALC_DRIVERS = (1<<0), ADT_RECALC_ANIM = (1<<1), - ADT_RECALC_ALL = (ADT_RECALC_DRIVERS|ADT_RECALC_ANIM) + ADT_RECALC_ALL = (ADT_RECALC_DRIVERS | ADT_RECALC_ANIM) } eAnimData_Recalc; /* Base Struct for Anim ------------------------------------- */ diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h index cc08d0e92bd..0afe3773c94 100644 --- a/source/blender/makesdna/DNA_armature_types.h +++ b/source/blender/makesdna/DNA_armature_types.h @@ -127,9 +127,9 @@ typedef enum eArmature_Flag { ARM_AUTO_IK = (1<<9), ARM_NO_CUSTOM = (1<<10), /* made option negative, for backwards compat */ ARM_COL_CUSTOM = (1<<11), /* draw custom colors */ - ARM_GHOST_ONLYSEL = (1<<12), /* when ghosting, only show selected bones (this should belong to ghostflag instead) */ // XXX depreceated + ARM_GHOST_ONLYSEL = (1<<12), /* when ghosting, only show selected bones (this should belong to ghostflag instead) */ /* XXX depreceated */ ARM_DS_EXPAND = (1<<13), /* dopesheet channel is expanded */ - ARM_HAS_VIZ_DEPS = (1<<14), /* other objects are used for visualising various states (hack for efficient updates) */ + ARM_HAS_VIZ_DEPS = (1<<14), /* other objects are used for visualizing various states (hack for efficient updates) */ } eArmature_Flag; /* armature->drawtype */ diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index 40362424532..b6036840401 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -464,7 +464,7 @@ typedef enum eBConstraint_Types { CONSTRAINT_TYPE_CLAMPTO = 18, /* clampto constraint */ CONSTRAINT_TYPE_TRANSFORM = 19, /* transformation (loc/rot/size -> loc/rot/size) constraint */ CONSTRAINT_TYPE_SHRINKWRAP = 20, /* shrinkwrap (loc/rot) constraint */ - CONSTRAINT_TYPE_DAMPTRACK = 21, /* New Tracking constraint that minimises twisting */ + CONSTRAINT_TYPE_DAMPTRACK = 21, /* New Tracking constraint that minimizes twisting */ CONSTRAINT_TYPE_SPLINEIK = 22, /* Spline-IK - Align 'n' bones to a curve */ CONSTRAINT_TYPE_TRANSLIKE = 23, /* Copy transform matrix */ CONSTRAINT_TYPE_SAMEVOL = 24, /* Maintain volume during scaling */ diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index f5c0148d9d0..56cf90d3d9d 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -116,7 +116,7 @@ typedef struct BPoint { float vec[4]; float alfa, weight; /* alfa: tilt in 3D View, weight: used for softbody goal weight */ short f1, hide; /* f1: selection status, hide: is point hidden or not */ - float radius, pad; /* user-set radius per point for bevelling etc */ + float radius, pad; /* user-set radius per point for beveling etc */ } BPoint; typedef struct Nurb { diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index f6c4822bb55..4a4b21017db 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -122,6 +122,7 @@ typedef struct Image { #define IMA_OLD_PREMUL 128 #define IMA_CM_PREDIVIDE 256 #define IMA_USED_FOR_RENDER 512 +#define IMA_USER_FRAME_IN_RANGE 1024 /* for image user, but these flags are mixed */ /* Image.tpageflag */ #define IMA_TILES 1 diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index 0bd83e73271..5806d9a3947 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -259,19 +259,19 @@ typedef struct GridPaintMask { typedef enum MVertSkinFlag { /* Marks a vertex as the edge-graph root, used for calculating - rotations for all connected edges (recursively.) Also used to - choose a root when generating an armature. */ + * rotations for all connected edges (recursively.) Also used to + * choose a root when generating an armature. */ MVERT_SKIN_ROOT = 1, /* Marks a branch vertex (vertex with more than two connected - edges) so that it's neighbors are directly hulled together, - rather than the default of generating intermediate frames. */ + * edges) so that it's neighbors are directly hulled together, + * rather than the default of generating intermediate frames. */ MVERT_SKIN_LOOSE = 2 } MVertSkinFlag; typedef struct MVertSkin { /* Radii of the skin, define how big the generated frames - are. Currently only the first two elements are used. */ + * are. Currently only the first two elements are used. */ float radius[3]; /* MVertSkinFlag */ diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 9bc002b7bbe..e4b5a264ba3 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -166,6 +166,7 @@ typedef struct bNode { struct bNode *parent; /* parent node */ struct ID *id; /* optional link to libdata */ void *storage; /* custom data, must be struct, for storage in file */ + struct bNode *original; /* the original node in the tree (for localized tree) */ float locx, locy; /* root offset for drawing */ float width, height; /* node custom width and height */ @@ -177,10 +178,11 @@ typedef struct bNode { char label[64]; /* custom user-defined label, MAX_NAME */ short custom1, custom2; /* to be abused for buttons */ float custom3, custom4; + int highlight; /* 0 = not highlighted, 1-N = highlighted*/ + int pad; short need_exec, exec; /* need_exec is set as UI execution event, exec is flag during exec */ void *threaddata; /* optional extra storage for use in thread (read only then!) */ - rctf totr; /* entire boundbox */ rctf butr; /* optional buttons area */ rctf prvr; /* optional preview area */ @@ -302,6 +304,7 @@ typedef struct bNodeTree { /* ntree->flag */ #define NTREE_DS_EXPAND 1 /* for animation editors */ #define NTREE_COM_OPENCL 2 /* use opencl */ +#define NTREE_TWO_PASS 4 /* two pass */ /* XXX not nice, but needed as a temporary flags * for group updates after library linking. */ @@ -347,21 +350,31 @@ typedef struct bNodeSocketValueRGBA { /* data structs, for node->storage */ - -#define CMP_NODE_MASKTYPE_ADD 0 -#define CMP_NODE_MASKTYPE_SUBTRACT 1 -#define CMP_NODE_MASKTYPE_MULTIPLY 2 -#define CMP_NODE_MASKTYPE_NOT 3 - -#define CMP_NODE_LENSFLARE_GHOST 1 -#define CMP_NODE_LENSFLARE_GLOW 2 -#define CMP_NODE_LENSFLARE_CIRCLE 4 -#define CMP_NODE_LENSFLARE_STREAKS 8 - -#define CMP_NODE_DILATEERODE_STEP 0 -#define CMP_NODE_DILATEERODE_DISTANCE_THRESH 1 -#define CMP_NODE_DILATEERODE_DISTANCE 2 -#define CMP_NODE_DILATEERODE_DISTANCE_FEATHER 3 +enum { + CMP_NODE_MASKTYPE_ADD = 0, + CMP_NODE_MASKTYPE_SUBTRACT = 1, + CMP_NODE_MASKTYPE_MULTIPLY = 2, + CMP_NODE_MASKTYPE_NOT = 3 +}; + +enum { + CMP_NODE_LENSFLARE_GHOST = 1, + CMP_NODE_LENSFLARE_GLOW = 2, + CMP_NODE_LENSFLARE_CIRCLE = 4, + CMP_NODE_LENSFLARE_STREAKS = 8 +}; + +enum { + CMP_NODE_DILATEERODE_STEP = 0, + CMP_NODE_DILATEERODE_DISTANCE_THRESH = 1, + CMP_NODE_DILATEERODE_DISTANCE = 2, + CMP_NODE_DILATEERODE_DISTANCE_FEATHER = 3 +}; + +enum { + CMP_NODEFLAG_MASK_AA = (1 << 0), + CMP_NODEFLAG_MASK_NO_FEATHER = (1 << 1) +}; typedef struct NodeFrame { short flag; @@ -559,6 +572,11 @@ typedef struct NodeColorspill { float uspillr, uspillg, uspillb; } NodeColorspill; +typedef struct NodeDilateErode { + char falloff; + char pad[7]; +} NodeDilateErode; + typedef struct NodeTexBase { TexMapping tex_mapping; ColorMapping color_mapping; @@ -640,6 +658,8 @@ typedef struct NodeKeyingData { float edge_kernel_tolerance; float clip_black, clip_white; int dilate_distance; + int feather_distance; + int feather_falloff; int blur_pre, blur_post; } NodeKeyingData; diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index 854087b3b5b..1dd2aa6c59b 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -89,7 +89,7 @@ typedef struct PartDeflect { float pdef_perm; /* Chance of particle passing through mesh */ float pdef_frict; /* Friction factor for particle deflection */ float pdef_rfrict; /* Random element of friction for deflection */ - float pdef_stickness;/* surface particle stickness */ + float pdef_stickness;/* surface particle stickiness */ float absorption; /* used for forces */ diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 83bfec3cc52..3da6d0fc99d 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -122,7 +122,7 @@ typedef struct Object { struct bGPdata *gpd; /* Grease Pencil data */ - bAnimVizSettings avs; /* settings for visualisation of object-transform animation */ + bAnimVizSettings avs; /* settings for visualization of object-transform animation */ bMotionPath *mpath; /* motion path cache for this object */ ListBase constraintChannels DNA_DEPRECATED; // XXX depreceated... old animation system @@ -258,6 +258,7 @@ typedef struct Object { struct FluidsimSettings *fluidsimSettings; /* if fluidsim enabled, store additional settings */ struct DerivedMesh *derivedDeform, *derivedFinal; + int *pad; 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 */ @@ -336,7 +337,7 @@ typedef struct DupliObject { /* check if the object type supports materials */ #define OB_TYPE_SUPPORT_MATERIAL(_type) \ - ((_type) >= OB_MESH && (_type) <= OB_MBALL) + ((_type) >= OB_MESH && (_type) <= OB_MBALL) #define OB_TYPE_SUPPORT_VGROUP(_type) \ (ELEM(_type, OB_MESH, OB_LATTICE)) #define OB_TYPE_SUPPORT_EDITMODE(_type) \ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 3bceb0277d5..02a7d0da325 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -625,7 +625,7 @@ typedef struct GameData { short ticrate, maxlogicstep, physubstep, maxphystep; short obstacleSimulation, pad1; float levelHeight; - float deactivationtime, lineardeactthreshold, angulardeactthreshold,pad2; + float deactivationtime, lineardeactthreshold, angulardeactthreshold, pad2; } GameData; #define STEREO_NOSTEREO 1 @@ -899,7 +899,7 @@ typedef struct ToolSettings { /* Subdivide Settings */ short cornertype; - short pad3; + short pad1; /*Triangle to Quad conversion threshold*/ float jointrilimit; /* Editmode Tools */ @@ -995,12 +995,13 @@ typedef struct ToolSettings { char edge_mode_live_unwrap; /* Transform */ - char snap_mode; + char snap_mode, snap_node_mode; + char pad3; short snap_flag, snap_target; short proportional, prop_mode; char proportional_objects; /* proportional edit, object mode */ char proportional_mask; /* proportional edit, object mode */ - char pad[4]; + char pad4[2]; char auto_normalize; /*auto normalizing mode in wpaint*/ char multipaint; /* paint multiple bones in wpaint */ @@ -1012,7 +1013,7 @@ typedef struct ToolSettings { int uv_relax_method; /* XXX: these sculpt_paint_* fields are deprecated, use the * unified_paint_settings field instead! */ - short sculpt_paint_settings DNA_DEPRECATED; short pad1; + short sculpt_paint_settings DNA_DEPRECATED; short pad5; int sculpt_paint_unified_size DNA_DEPRECATED; float sculpt_paint_unified_unprojected_radius DNA_DEPRECATED; float sculpt_paint_unified_alpha DNA_DEPRECATED; @@ -1370,6 +1371,9 @@ typedef struct Scene { #define SCE_SNAP_MODE_EDGE 2 #define SCE_SNAP_MODE_FACE 3 #define SCE_SNAP_MODE_VOLUME 4 +#define SCE_SNAP_MODE_NODE_X 5 +#define SCE_SNAP_MODE_NODE_Y 6 +#define SCE_SNAP_MODE_NODE_XY 7 /* toolsettings->selectmode */ #define SCE_SELECT_VERTEX 1 /* for mesh */ diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 2f6ea861cba..28c386241a7 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -875,11 +875,12 @@ typedef struct SpaceNode { /* snode->flag */ typedef enum eSpaceNode_Flag { - SNODE_BACKDRAW = (1 << 1), -/* SNODE_DISPGP = (1 << 2), */ /* XXX: Grease Pencil - deprecated? */ - SNODE_USE_ALPHA = (1 << 3), - SNODE_SHOW_ALPHA = (1 << 4), - SNODE_AUTO_RENDER = (1 << 5), + SNODE_BACKDRAW = (1 << 1), +/* SNODE_DISPGP = (1 << 2), */ /* XXX: Grease Pencil - deprecated? */ + SNODE_USE_ALPHA = (1 << 3), + SNODE_SHOW_ALPHA = (1 << 4), + SNODE_AUTO_RENDER = (1 << 5), + SNODE_SHOW_HIGHLIGHT = (1 << 6), } eSpaceNode_Flag; /* snode->texfrom */ diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 5a49e45cf5e..780ca0b5878 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -112,7 +112,7 @@ typedef struct ReportList { # typedef struct ReportTimerInfo { float col[3]; - float greyscale; + float grayscale; float widthfac; } ReportTimerInfo; diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 2498cba42ef..8be743335cc 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -659,10 +659,10 @@ static eSDNA_Type sdna_type_nr(const char *dna_type) if ((strcmp(dna_type, "char") == 0) || (strcmp(dna_type, "const char") == 0)) return SDNA_TYPE_CHAR; else if ((strcmp(dna_type, "uchar") == 0) || (strcmp(dna_type, "unsigned char") == 0)) return SDNA_TYPE_UCHAR; else if ( strcmp(dna_type, "short") == 0) return SDNA_TYPE_SHORT; - else if ((strcmp(dna_type, "ushort") == 0)||(strcmp(dna_type, "unsigned short") == 0)) return SDNA_TYPE_USHORT; + else if ((strcmp(dna_type, "ushort") == 0) || (strcmp(dna_type, "unsigned short") == 0)) return SDNA_TYPE_USHORT; else if ( strcmp(dna_type, "int") == 0) return SDNA_TYPE_INT; else if ( strcmp(dna_type, "long") == 0) return SDNA_TYPE_LONG; - else if ((strcmp(dna_type, "ulong") == 0)||(strcmp(dna_type, "unsigned long") == 0)) return SDNA_TYPE_ULONG; + else if ((strcmp(dna_type, "ulong") == 0) || (strcmp(dna_type, "unsigned long") == 0)) return SDNA_TYPE_ULONG; else if ( strcmp(dna_type, "float") == 0) return SDNA_TYPE_FLOAT; else if ( strcmp(dna_type, "double") == 0) return SDNA_TYPE_DOUBLE; else if ( strcmp(dna_type, "int64_t") == 0) return SDNA_TYPE_INT64; diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index b0f8f02ae9f..09cb22683a7 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -798,7 +798,11 @@ static int calculate_structlens(int firststruct) } } - /* 2-4 aligned/ */ + /* 2-4-8 aligned/ */ + if (type < firststruct && typelens[type] > 4 && (len % 8)) { + printf("Align 8 error in struct: %s %s (add %d padding bytes)\n", types[structtype], cp, len % 8); + dna_error = 1; + } if (typelens[type] > 3 && (len % 4) ) { printf("Align 4 error in struct: %s %s (add %d padding bytes)\n", types[structtype], cp, len % 4); dna_error = 1; diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 473ab7485b0..a0614a9d82a 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -41,9 +41,11 @@ extern EnumPropertyItem object_mode_items[]; extern EnumPropertyItem metaelem_type_items[]; extern EnumPropertyItem proportional_falloff_items[]; +extern EnumPropertyItem proportional_falloff_curve_only_items[]; extern EnumPropertyItem proportional_editing_items[]; extern EnumPropertyItem snap_target_items[]; extern EnumPropertyItem snap_element_items[]; +extern EnumPropertyItem snap_node_element_items[]; extern EnumPropertyItem mesh_select_mode_items[]; extern EnumPropertyItem space_type_items[]; extern EnumPropertyItem region_type_items[]; diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 9cab08cbc34..32ca1bca107 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -51,6 +51,13 @@ # define __func__ __FUNCTION__ #endif +/* copied from BKE_utildefines.h ugh */ +#ifdef __GNUC__ +# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__)) +#else +# define UNUSED(x) x +#endif + /* Replace if different */ #define TMP_EXT ".tmp" @@ -310,7 +317,7 @@ static void rna_print_data_get(FILE *f, PropertyDefRNA *dp) fprintf(f, " %s *data= (%s*)(ptr->data);\n", dp->dnastructname, dp->dnastructname); } -static void rna_print_id_get(FILE *f, PropertyDefRNA *dp) +static void rna_print_id_get(FILE *f, PropertyDefRNA *UNUSED(dp)) { fprintf(f, " ID *id= ptr->id.data;\n"); } @@ -1179,7 +1186,7 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property return func; } -static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, +static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *UNUSED(dp), const char *manualfunc) { char *func, *getfunc; @@ -1206,7 +1213,7 @@ static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *p return func; } -static char *rna_def_property_end_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *dp, +static char *rna_def_property_end_func(FILE *f, StructRNA *srna, PropertyRNA *prop, PropertyDefRNA *UNUSED(dp), const char *manualfunc) { char *func; @@ -2006,7 +2013,7 @@ static void rna_generate_blender(BlenderRNA *brna, FILE *f) fprintf(f, "};\n\n"); } -static void rna_generate_property_prototypes(BlenderRNA *brna, StructRNA *srna, FILE *f) +static void rna_generate_property_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f) { PropertyRNA *prop; StructRNA *base; @@ -2029,7 +2036,7 @@ static void rna_generate_property_prototypes(BlenderRNA *brna, StructRNA *srna, fprintf(f, "\n"); } -static void rna_generate_parameter_prototypes(BlenderRNA *brna, StructRNA *srna, FunctionRNA *func, FILE *f) +static void rna_generate_parameter_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FunctionRNA *func, FILE *f) { PropertyRNA *parm; @@ -2068,7 +2075,7 @@ static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna, fprintf(f, "\n"); } -static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA *srna, FunctionDefRNA *dfunc, FILE *f) +static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FunctionDefRNA *dfunc, FILE *f) { FunctionRNA *func; PropertyDefRNA *dparm; @@ -2483,7 +2490,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr } } -static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) +static void rna_generate_struct(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f) { FunctionRNA *func; FunctionDefRNA *dfunc; @@ -2761,7 +2768,7 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const } } -static void rna_generate_header(BlenderRNA *brna, FILE *f) +static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f) { StructDefRNA *ds; PropertyDefRNA *dp; @@ -2929,7 +2936,7 @@ static const char *cpp_classes = "" "};\n" "\n"; -static void rna_generate_header_cpp(BlenderRNA *brna, FILE *f) +static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f) { StructDefRNA *ds; PropertyDefRNA *dp; diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 459482063b1..69f785c32de 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -24,7 +24,6 @@ * \ingroup RNA */ - #include <stdlib.h> #include "RNA_access.h" @@ -37,6 +36,8 @@ #include "DNA_action_types.h" #include "DNA_scene_types.h" +#include "BLI_utildefines.h" + #include "MEM_guardedalloc.h" #include "ED_keyframing.h" @@ -463,7 +464,8 @@ static FCurve *rna_Driver_from_existing(AnimData *adt, bContext *C, FCurve *src_ #else /* helper function for Keying Set -> keying settings */ -static void rna_def_common_keying_flags(StructRNA *srna, short reg) +/* TODO: use reg option! */ +static void rna_def_common_keying_flags(StructRNA *srna, short UNUSED(reg)) { PropertyRNA *prop; diff --git a/source/blender/makesrna/intern/rna_animviz.c b/source/blender/makesrna/intern/rna_animviz.c index 990d7c43309..68075823a86 100644 --- a/source/blender/makesrna/intern/rna_animviz.c +++ b/source/blender/makesrna/intern/rna_animviz.c @@ -183,7 +183,7 @@ static void rna_def_animviz_ghosts(BlenderRNA *brna) srna = RNA_def_struct(brna, "AnimVizOnionSkinning", NULL); RNA_def_struct_sdna(srna, "bAnimVizSettings"); RNA_def_struct_nested(brna, srna, "AnimViz"); - RNA_def_struct_ui_text(srna, "Onion Skinning Settings", "Onion Skinning settings for animation visualisation"); + RNA_def_struct_ui_text(srna, "Onion Skinning Settings", "Onion Skinning settings for animation visualization"); /* Enums */ prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); @@ -256,7 +256,7 @@ static void rna_def_animviz_paths(BlenderRNA *brna) srna = RNA_def_struct(brna, "AnimVizMotionPaths", NULL); RNA_def_struct_sdna(srna, "bAnimVizSettings"); RNA_def_struct_nested(brna, srna, "AnimViz"); - RNA_def_struct_ui_text(srna, "Motion Path Settings", "Motion Path settings for animation visualisation"); + RNA_def_struct_ui_text(srna, "Motion Path Settings", "Motion Path settings for animation visualization"); /* Enums */ prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); @@ -343,10 +343,10 @@ void rna_def_animviz_common(StructRNA *srna) { PropertyRNA *prop; - prop = RNA_def_property(srna, "animation_visualisation", PROP_POINTER, PROP_NONE); + prop = RNA_def_property(srna, "animation_visualization", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "avs"); - RNA_def_property_ui_text(prop, "Animation Visualisation", "Animation data for this datablock"); + RNA_def_property_ui_text(prop, "Animation Visualization", "Animation data for this datablock"); } static void rna_def_animviz(BlenderRNA *brna) @@ -356,21 +356,21 @@ static void rna_def_animviz(BlenderRNA *brna) srna = RNA_def_struct(brna, "AnimViz", NULL); RNA_def_struct_sdna(srna, "bAnimVizSettings"); - RNA_def_struct_ui_text(srna, "Animation Visualisation", "Settings for the visualisation of motion"); + RNA_def_struct_ui_text(srna, "Animation Visualization", "Settings for the visualization of motion"); /* onion-skinning settings (nested struct) */ prop = RNA_def_property(srna, "onion_skin_frames", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "AnimVizOnionSkinning"); RNA_def_property_pointer_funcs(prop, "rna_AnimViz_onion_skinning_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Onion Skinning", "Onion Skinning (ghosting) settings for visualisation"); + RNA_def_property_ui_text(prop, "Onion Skinning", "Onion Skinning (ghosting) settings for visualization"); /* motion path settings (nested struct) */ prop = RNA_def_property(srna, "motion_path", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "AnimVizMotionPaths"); RNA_def_property_pointer_funcs(prop, "rna_AnimViz_motion_paths_get", NULL, NULL, NULL); - RNA_def_property_ui_text(prop, "Motion Paths", "Motion Path settings for visualisation"); + RNA_def_property_ui_text(prop, "Motion Paths", "Motion Path settings for visualization"); } /* --- */ diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index ecdfe1505c8..15fdce09d83 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -135,6 +135,8 @@ static void rna_CurveMapping_clipmaxy_range(PointerRNA *ptr, float *min, float * static char *rna_ColorRamp_path(PointerRNA *ptr) { + char *path = NULL; + /* handle the cases where a single datablock may have 2 ramp types */ if (ptr->id.data) { ID *id = ptr->id.data; @@ -145,16 +147,47 @@ static char *rna_ColorRamp_path(PointerRNA *ptr) Material *ma = (Material *)id; if (ptr->data == ma->ramp_col) - return BLI_strdup("diffuse_ramp"); + path = BLI_strdup("diffuse_ramp"); else if (ptr->data == ma->ramp_spec) - return BLI_strdup("specular_ramp"); + path = BLI_strdup("specular_ramp"); + break; } - break; + + case ID_NT: + { + bNodeTree *ntree = (bNodeTree *)id; + bNode *node; + PointerRNA node_ptr; + char *node_path; + + for (node = ntree->nodes.first; node; node = node->next) { + if (ELEM3(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) { + if (node->storage == ptr->data) { + /* all node color ramp properties called 'color_ramp' + * prepend path from ID to the node + */ + RNA_pointer_create(id, &RNA_Node, node, &node_ptr); + node_path = RNA_path_from_ID_to_struct(&node_ptr); + path = BLI_sprintfN("%s.color_ramp", node_path); + MEM_freeN(node_path); + } + } + } + break; + } + + default: + /* everything else just uses 'color_ramp' */ + path = BLI_strdup("color_ramp"); + break; } } + else { + /* everything else just uses 'color_ramp' */ + path = BLI_strdup("color_ramp"); + } - /* everything else just uses 'color_ramp' */ - return BLI_strdup("color_ramp"); + return path; } static char *rna_ColorRampElement_path(PointerRNA *ptr) @@ -204,7 +237,6 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr) } break; - /* TODO: node trees need special attention */ case ID_NT: { bNodeTree *ntree = (bNodeTree *)id; diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index ae8b0c51544..8d718715e5b 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -109,7 +109,7 @@ static EnumPropertyItem owner_space_pchan_items[] = { "The constraint is applied relative to the local coordinate system of the object, " "with the parent transformation added"}, {CONSTRAINT_SPACE_LOCAL, "LOCAL", 0, "Local Space", - "The constraint is applied relative to the local coordinate sytem of the object"}, + "The constraint is applied relative to the local coordinate system of the object"}, {0, NULL, 0, NULL, NULL} }; @@ -1116,7 +1116,7 @@ static void rna_def_constraint_action(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Object Action", "Bones only: apply the object's transformation channels of the action " "to the constrained bone, instead of bone's channels"); - RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); + RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "start"); diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index f70fe9082af..c333c56a6b8 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -24,7 +24,6 @@ * \ingroup RNA */ - #include <stdlib.h> #include "RNA_define.h" @@ -36,6 +35,8 @@ #include "DNA_material_types.h" #include "DNA_scene_types.h" +#include "BLI_utildefines.h" + #include "BKE_font.h" #include "WM_types.h" @@ -753,7 +754,7 @@ static void rna_def_bpoint(BlenderRNA *brna) prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "radius"); RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling"); + RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for beveling"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); RNA_def_struct_path_func(srna, "rna_Curve_spline_point_path"); @@ -839,13 +840,13 @@ static void rna_def_beztriple(BlenderRNA *brna) prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "radius"); RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling"); + RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for beveling"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); RNA_def_struct_path_func(srna, "rna_Curve_spline_point_path"); } -static void rna_def_path(BlenderRNA *brna, StructRNA *srna) +static void rna_def_path(BlenderRNA *UNUSED(brna), StructRNA *srna) { PropertyRNA *prop; @@ -894,7 +895,7 @@ static void rna_def_path(BlenderRNA *brna, StructRNA *srna) RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } -static void rna_def_nurbs(BlenderRNA *brna, StructRNA *srna) +static void rna_def_nurbs(BlenderRNA *UNUSED(brna), StructRNA *srna) { PropertyRNA *prop; @@ -905,7 +906,7 @@ static void rna_def_nurbs(BlenderRNA *brna, StructRNA *srna) RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } -static void rna_def_font(BlenderRNA *brna, StructRNA *srna) +static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna) { PropertyRNA *prop; @@ -1002,7 +1003,7 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna) RNA_def_property_string_maxlength(prop, MAX_ID_NAME - 2); RNA_def_property_ui_text(prop, "Object Font", "Use Blender Objects as font characters (give font objects a common name " - "followed by the character they represent, eg. familya, familyb, etc, " + "followed by the character they represent, eg. family_a, family_b, etc, " "and turn on Verts Duplication)"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); @@ -1187,7 +1188,7 @@ static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a spline from a curve"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); #endif } @@ -1435,7 +1436,7 @@ static void rna_def_curve(BlenderRNA *brna) prop = RNA_def_property(srna, "use_fill_caps", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FILL_CAPS); - RNA_def_property_ui_text(prop, "Fill Caps", "Fill caps for bevelled curves"); + RNA_def_property_ui_text(prop, "Fill Caps", "Fill caps for beveled curves"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* texture space */ @@ -1639,7 +1640,7 @@ static void rna_def_curve_nurb(BlenderRNA *brna) prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "hide", 1); - RNA_def_property_ui_text(prop, "Hide", "Hide this curve in editmode"); + RNA_def_property_ui_text(prop, "Hide", "Hide this curve in Edit mode"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 02d8cbef4a3..0320c0d7142 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -497,6 +497,9 @@ void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext) ext->free(ext->data); /* decref's the PyObject that the srna owns */ RNA_struct_blender_type_set(srna, NULL); /* this gets accessed again - XXX fixme */ RNA_struct_py_type_set(srna, NULL); /* NULL the srna's value so RNA_struct_free wont complain of a leak */ +#else + (void)srna; + (void)ext; #endif } @@ -546,7 +549,8 @@ void RNA_struct_free(BlenderRNA *brna, StructRNA *srna) if (srna->flag & STRUCT_RUNTIME) rna_freelinkN(&brna->structs, srna); - +#else + (void)brna, (void)srna; #endif } diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.c b/source/blender/makesrna/intern/rna_dynamicpaint.c index 4bfcabc935b..6739e5b71fa 100644 --- a/source/blender/makesrna/intern/rna_dynamicpaint.c +++ b/source/blender/makesrna/intern/rna_dynamicpaint.c @@ -469,7 +469,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna) prop = RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DPAINT_ANTIALIAS); - RNA_def_property_ui_text(prop, "Anti-aliasing", "Use 5x multisampling to smoothen paint edges"); + RNA_def_property_ui_text(prop, "Anti-aliasing", "Use 5x multisampling to smooth paint edges"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_DynamicPaintSurface_reset"); prop = RNA_def_property(srna, "brush_influence_scale", PROP_FLOAT, PROP_FACTOR); @@ -677,7 +677,7 @@ static void rna_def_canvas_surface(BlenderRNA *brna) prop = RNA_def_property(srna, "wave_speed", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01, 5.0); RNA_def_property_ui_range(prop, 0.20, 4.0, 1, 2); - RNA_def_property_ui_text(prop, "Speed", "Wave propogation speed"); + RNA_def_property_ui_text(prop, "Speed", "Wave propagation speed"); prop = RNA_def_property(srna, "wave_timescale", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01, 3.0); diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 333f6878413..5eb15cf31b6 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -688,7 +688,7 @@ static void rna_def_fmodifier_function_generator(BlenderRNA *brna) {2, "TAN", 0, "Tangent", ""}, {3, "SQRT", 0, "Square Root", ""}, {4, "LN", 0, "Natural Logarithm", ""}, - {5, "SINC", 0, "Normalised Sine", "sin(x) / x"}, + {5, "SINC", 0, "Normalized Sine", "sin(x) / x"}, {0, NULL, 0, NULL, NULL} }; @@ -1136,9 +1136,9 @@ static void rna_def_drivertarget(BlenderRNA *brna) {0, "WORLD_SPACE", 0, "World Space", "Transforms include effects of parenting/restpose and constraints"}, {DTAR_FLAG_LOCALSPACE, "TRANSFORM_SPACE", 0, "Transform Space", "Transforms don't include parenting/restpose or constraints"}, - {DTAR_FLAG_LOCALSPACE|DTAR_FLAG_LOCAL_CONSTS, "LOCAL_SPACE", 0, "Local Space", - "Transforms include effects of constraints but not " - "parenting/restpose"}, + {DTAR_FLAG_LOCALSPACE | DTAR_FLAG_LOCAL_CONSTS, "LOCAL_SPACE", 0, "Local Space", + "Transforms include effects of constraints but not " + "parenting/restpose"}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 8dd1bc86ca1..e84a290acb8 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -349,7 +349,7 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) prop = RNA_def_property(srna, "simulation_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "realsize"); RNA_def_property_range(prop, 0.001, 10); - RNA_def_property_ui_text(prop, "Real World Size", "Size of the simulation domain in metres"); + RNA_def_property_ui_text(prop, "Real World Size", "Size of the simulation domain in meters"); prop = RNA_def_property(srna, "simulation_rate", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "animRate"); @@ -461,8 +461,9 @@ static void rna_def_fluidsim_volume(StructRNA *srna) RNA_def_property_boolean_sdna(prop, NULL, "domainNovecgen", 0); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Export Animated Mesh", - "Export this mesh as an animated one (slower, only use if really necessary [e.g. " - "armatures or parented objects], animated pos/rot/scale F-Curves do not require it)"); + "Export this mesh as an animated one (slower and enforces No Slip, only use if really " + "necessary [e.g. armatures or parented objects], animated pos/rot/scale F-Curves " + "do not require it)"); } static void rna_def_fluidsim_active(StructRNA *srna) diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 14d01444681..fa3f8d69c47 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -178,9 +178,11 @@ static void rna_Image_update(Image *image, ReportList *reports) IMB_rect_from_float(ibuf); } -static void rna_Image_scale(Image *image, int width, int height) +static void rna_Image_scale(Image *image, ReportList *reports, int width, int height) { - BKE_image_scale(image, width, height); + if (!BKE_image_scale(image, width, height)) { + BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name + 2); + } } static int rna_Image_gl_load(Image *image, ReportList *reports, int filter, int mag) @@ -285,6 +287,7 @@ void RNA_api_image(StructRNA *srna) func = RNA_def_function(srna, "scale", "rna_Image_scale"); RNA_def_function_ui_description(func, "Scale the image in pixels"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_int(func, "width", 0, 1, 10000, "", "Width", 1, 10000); RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_int(func, "height", 0, 1, 10000, "", "Height", 1, 10000); diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index c2d730f5ed9..5334c10c4c6 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -639,7 +639,7 @@ static void rna_def_key(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "slurph"); RNA_def_property_range(prop, -500, 500); RNA_def_property_ui_text(prop, "Slurph", - "Create a delay (in frames) in applying keypositions, first vertex goes first"); + "Create a delay (in frames) in applying key positions, first vertex goes first"); RNA_def_property_update(prop, 0, "rna_Key_update_data"); } diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 6ac032e5d99..c98e1f3312b 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -255,7 +255,7 @@ static void rna_Main_movieclips_begin(CollectionPropertyIterator *iter, PointerR static void rna_Main_masks_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { - Main *bmain= (Main*)ptr->data; + Main *bmain = (Main*)ptr->data; rna_iterator_listbase_begin(iter, &bmain->mask, NULL); } diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 98b3c0ab9f4..c702972b3b7 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -1548,12 +1548,12 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop) PropertyRNA *parm; RNA_def_property_srna(cprop, "BlendDataMasks"); - srna= RNA_def_struct(brna, "BlendDataMasks", NULL); + srna = RNA_def_struct(brna, "BlendDataMasks", NULL); RNA_def_struct_sdna(srna, "Main"); RNA_def_struct_ui_text(srna, "Main Masks", "Collection of masks"); - func= RNA_def_function(srna, "tag", "rna_Main_masks_tag"); - parm= RNA_def_boolean(func, "value", 0, "Value", ""); + func = RNA_def_function(srna, "tag", "rna_Main_masks_tag"); + parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); /* new func */ @@ -1565,10 +1565,10 @@ void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); /* remove func */ - func= RNA_def_function(srna, "remove", "rna_Main_masks_remove"); + func = RNA_def_function(srna, "remove", "rna_Main_masks_remove"); RNA_def_function_ui_description(func, "Remove a masks from the current blendfile."); - parm= RNA_def_pointer(func, "mask", "Mask", "", "Mask to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + parm = RNA_def_pointer(func, "mask", "Mask", "", "Mask to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); } #endif diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index dfcbbe0653b..b879d2b19f7 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -50,9 +50,13 @@ #ifdef RNA_RUNTIME #include "DNA_mask_types.h" +#include "DNA_movieclip_types.h" #include "BKE_depsgraph.h" #include "BKE_mask.h" +#include "BKE_tracking.h" + +#include "BLI_math.h" #include "RNA_access.h" @@ -62,10 +66,44 @@ static void rna_Mask_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin { Mask *mask = ptr->id.data; - WM_main_add_notifier(NC_MASK|ND_DATA, mask); + WM_main_add_notifier(NC_MASK | ND_DATA, mask); DAG_id_tag_update( &mask->id, 0); } +static void rna_Mask_update_parent(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + MaskParent *parent = ptr->data; + + if (parent->id) { + if (GS(parent->id->name) == ID_MC) { + MovieClip *clip = (MovieClip *) parent->id; + MovieTracking *tracking = &clip->tracking; + MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, parent->parent); + + if (object) { + MovieTrackingTrack *track = BKE_tracking_track_get_named(tracking, object, parent->sub_parent); + + if (track) { + int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, scene->r.cfra); + MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_framenr); + float marker_pos_ofs[2], parmask_pos[2]; + MovieClipUser user = {0}; + + BKE_movieclip_user_set_frame(&user, scene->r.cfra); + + add_v2_v2v2(marker_pos_ofs, marker->pos, track->offset); + + BKE_mask_coord_from_movieclip(clip, &user, parmask_pos, marker_pos_ofs); + + copy_v2_v2(parent->parent_orig, parmask_pos); + } + } + } + } + + rna_Mask_update_data(bmain, scene, ptr); +} + /* note: this function exists only to avoid id refcounting */ static void rna_MaskParent_id_set(PointerRNA *ptr, PointerRNA value) { @@ -289,7 +327,7 @@ static MaskLayer *rna_Mask_layer_new(Mask *mask, const char *name) { MaskLayer *masklay = BKE_mask_layer_new(mask, name); - WM_main_add_notifier(NC_MASK|NA_EDITED, mask); + WM_main_add_notifier(NC_MASK | NA_EDITED, mask); return masklay; } @@ -298,7 +336,7 @@ void rna_Mask_layer_remove(Mask *mask, MaskLayer *masklay) { BKE_mask_layer_remove(mask, masklay); - WM_main_add_notifier(NC_MASK|NA_EDITED, mask); + WM_main_add_notifier(NC_MASK | NA_EDITED, mask); } static void rna_MaskLayer_spline_add(ID *id, MaskLayer *masklay, int number) @@ -309,7 +347,7 @@ static void rna_MaskLayer_spline_add(ID *id, MaskLayer *masklay, int number) for (i = 0; i < number; i++) BKE_mask_spline_add(masklay); - WM_main_add_notifier(NC_MASK|NA_EDITED, mask); + WM_main_add_notifier(NC_MASK | NA_EDITED, mask); } static void rna_Mask_start_frame_set(PointerRNA *ptr, int value) @@ -357,7 +395,7 @@ static void rna_def_maskParent(BlenderRNA *brna) /* note: custom set function is ONLY to avoid rna setting a user for this. */ RNA_def_property_pointer_funcs(prop, NULL, "rna_MaskParent_id_set", "rna_MaskParent_id_typef", NULL); RNA_def_property_ui_text(prop, "ID", "ID-block to which masking element would be parented to or to it's property"); - RNA_def_property_update(prop, 0, "rna_Mask_update_data"); + RNA_def_property_update(prop, 0, "rna_Mask_update_parent"); prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "id_type"); @@ -366,19 +404,19 @@ static void rna_def_maskParent(BlenderRNA *brna) RNA_def_property_enum_funcs(prop, NULL, "rna_MaskParent_id_type_set", NULL); //RNA_def_property_editable_func(prop, "rna_MaskParent_id_type_editable"); RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used"); - RNA_def_property_update(prop, 0, "rna_Mask_update_data"); + RNA_def_property_update(prop, 0, "rna_Mask_update_parent"); /* parent */ prop = RNA_def_property(srna, "parent", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Parent", "Name of parent object in specified data block to which parenting happens"); RNA_def_property_string_maxlength(prop, MAX_ID_NAME - 2); - RNA_def_property_update(prop, 0, "rna_Mask_update_data"); + RNA_def_property_update(prop, 0, "rna_Mask_update_parent"); /* sub_parent */ prop = RNA_def_property(srna, "sub_parent", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Sub Parent", "Name of parent sub-object in specified data block to which parenting happens"); RNA_def_property_string_maxlength(prop, MAX_ID_NAME - 2); - RNA_def_property_update(prop, 0, "rna_Mask_update_data"); + RNA_def_property_update(prop, 0, "rna_Mask_update_parent"); } static void rna_def_maskSplinePointUW(BlenderRNA *brna) @@ -488,14 +526,14 @@ static void rna_def_mask_splines(BlenderRNA *brna) prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "MaskSpline"); RNA_def_property_pointer_funcs(prop, "rna_MaskLayer_active_spline_get", "rna_MaskLayer_active_spline_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Active Spline", "Active spline of masking layer"); /* active point */ prop = RNA_def_property(srna, "active_point", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "MaskSplinePoint"); RNA_def_property_pointer_funcs(prop, "rna_MaskLayer_active_spline_point_get", "rna_MaskLayer_active_spline_point_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Active Spline", "Active spline of masking layer"); } @@ -637,7 +675,7 @@ static void rna_def_masklayers(BlenderRNA *brna, PropertyRNA *cprop) prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "MaskLayer"); RNA_def_property_pointer_funcs(prop, "rna_Mask_layer_active_get", "rna_Mask_layer_active_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Active Shape", "Active layer in this mask"); } diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 3cee8ca271c..4523858d639 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -776,7 +776,7 @@ static void rna_def_material_gamesettings(BlenderRNA *brna) }; static EnumPropertyItem prop_face_orientation_items[] = { - {GEMAT_NORMAL, "NORMAL", 0, "Normal", "No tranformation"}, + {GEMAT_NORMAL, "NORMAL", 0, "Normal", "No transformation"}, {GEMAT_HALO, "HALO", 0, "Halo", "Screen aligned billboard"}, {GEMAT_BILLBOARD, "BILLBOARD", 0, "Billboard", "Billboard with Z-axis constraint"}, {GEMAT_SHADOW, "SHADOW", 0, "Shadow", "Faces are used for shadow"}, diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 7daa0d97834..d904fdffa61 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -2374,7 +2374,7 @@ static void rna_def_loop_colors(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a vertex color layer"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); #endif prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED); @@ -2551,7 +2551,7 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a vertex color layer"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "layer", "Layer", "", "The layer to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); #endif prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED); @@ -2859,7 +2859,8 @@ static void rna_def_mesh(BlenderRNA *brna) prop = RNA_def_property(srna, "show_edges", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEDGES); - RNA_def_property_ui_text(prop, "Draw Edges", "Display selected edges using hilights in the 3D view and UV editor"); + RNA_def_property_ui_text(prop, "Draw Edges", + "Display selected edges using highlights in the 3D view and UV editor"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); prop = RNA_def_property(srna, "show_all_edges", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index e9b3faa2c86..084cda87507 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -2811,8 +2811,8 @@ static void rna_def_modifier_weightvgmix(BlenderRNA *brna) {MOD_WVG_MIX_SUB, "SUB", 0, "Subtract", "Subtract VGroup B's weights from VGroup A's ones"}, {MOD_WVG_MIX_MUL, "MUL", 0, "Multiply", "Multiply VGroup A's weights by VGroup B's ones"}, {MOD_WVG_MIX_DIV, "DIV", 0, "Divide", "Divide VGroup A's weights by VGroup B's ones"}, - {MOD_WVG_MIX_DIF, "DIF", 0, "Difference", "Difference between VGroup A's and VGroup B's weigths"}, - {MOD_WVG_MIX_AVG, "AVG", 0, "Average", "Average value of VGroup A's and VGroup B's weigths"}, + {MOD_WVG_MIX_DIF, "DIF", 0, "Difference", "Difference between VGroup A's and VGroup B's weights"}, + {MOD_WVG_MIX_AVG, "AVG", 0, "Average", "Average value of VGroup A's and VGroup B's weights"}, {0, NULL, 0, NULL, NULL} }; @@ -3236,17 +3236,17 @@ static void rna_def_modifier_skin(BlenderRNA *brna) prop = RNA_def_property(srna, "use_x_symmetry", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_X); - RNA_def_property_ui_text(prop, "X", "Avoid making unsymmetric quads across the X axis"); + RNA_def_property_ui_text(prop, "X", "Avoid making unsymmetrical quads across the X axis"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "use_y_symmetry", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_Y); - RNA_def_property_ui_text(prop, "Y", "Avoid making unsymmetric quads across the Y axis"); + RNA_def_property_ui_text(prop, "Y", "Avoid making unsymmetrical quads across the Y axis"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); prop = RNA_def_property(srna, "use_z_symmetry", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_Z); - RNA_def_property_ui_text(prop, "Z", "Avoid making unsymmetric quads across the Z axis"); + RNA_def_property_ui_text(prop, "Z", "Avoid making unsymmetrical quads across the Z axis"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); } @@ -3292,7 +3292,7 @@ void RNA_def_modifier(BlenderRNA *brna) prop = RNA_def_property(srna, "show_in_editmode", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Editmode); - RNA_def_property_ui_text(prop, "Editmode", "Use modifier while in the edit mode"); + RNA_def_property_ui_text(prop, "Edit Mode", "Use modifier while in the Edit mode"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index ef3dac5a221..a39c168c594 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1944,6 +1944,10 @@ static void def_cmp_image(StructRNA *srna) RNA_def_property_ui_text(prop, "Image", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + /* NB: image user properties used in the UI are redefined in def_node_image_user, + * to trigger correct updates of the node editor. RNA design problem that prevents + * updates from nested structs ... + */ RNA_def_struct_sdna_from(srna, "ImageUser", "storage"); def_node_image_user(srna); } @@ -2049,10 +2053,10 @@ static void def_cmp_dilate_erode(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem type_items[] = { - {CMP_NODE_DILATEERODE_STEP, "STEP", 0, "Step", ""}, - {CMP_NODE_DILATEERODE_DISTANCE_THRESH, "THRESHOLD", 0, "Threshold", ""}, - {CMP_NODE_DILATEERODE_DISTANCE, "DISTANCE", 0, "Distance", ""}, - {CMP_NODE_DILATEERODE_DISTANCE_FEATHER,"FEATHER", 0, "Feather", ""}, + {CMP_NODE_DILATEERODE_STEP, "STEP", 0, "Step", ""}, + {CMP_NODE_DILATEERODE_DISTANCE_THRESH, "THRESHOLD", 0, "Threshold", ""}, + {CMP_NODE_DILATEERODE_DISTANCE, "DISTANCE", 0, "Distance", ""}, + {CMP_NODE_DILATEERODE_DISTANCE_FEATHER, "FEATHER", 0, "Feather", ""}, {0, NULL, 0, NULL, NULL} }; @@ -2068,11 +2072,21 @@ static void def_cmp_dilate_erode(StructRNA *srna) RNA_def_property_ui_text(prop, "Distance", "Distance to grow/shrink (number of iterations)"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + /* CMP_NODE_DILATEERODE_DISTANCE_THRESH only */ prop = RNA_def_property(srna, "edge", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "custom3"); RNA_def_property_range(prop, -100, 100); RNA_def_property_ui_text(prop, "Edge", "Edge to inset"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + RNA_def_struct_sdna_from(srna, "NodeDilateErode", "storage"); + + /* CMP_NODE_DILATEERODE_DISTANCE_FEATHER only */ + prop = RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "falloff"); + RNA_def_property_enum_items(prop, proportional_falloff_curve_only_items); + RNA_def_property_ui_text(prop, "Falloff", "Falloff type the feather"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } static void def_cmp_scale(StructRNA *srna) @@ -2456,9 +2470,9 @@ static void def_cmp_id_mask(StructRNA *srna) RNA_def_property_ui_text(prop, "Index", "Pass index number to convert to alpha"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - prop = RNA_def_property(srna, "use_smooth_mask", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "custom2", 0); - RNA_def_property_ui_text(prop, "Smooth Mask", "Apply an anti-aliasing filter to the mask"); + RNA_def_property_ui_text(prop, "Anti-Aliasing", "Apply an anti-aliasing filter to the mask"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -3109,16 +3123,21 @@ static void def_cmp_mask(StructRNA *srna) { PropertyRNA *prop; - prop = RNA_def_property(srna, "smooth_mask", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "custom1", 0); - RNA_def_property_ui_text(prop, "Anti-Alias", "Apply an anti-aliasing filter to the mask"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - prop = RNA_def_property(srna, "mask", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "Mask"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Mask", ""); + + prop = RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom1", CMP_NODEFLAG_MASK_AA); + RNA_def_property_ui_text(prop, "Anti-Alias", "Apply an anti-aliasing filter to the mask"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "use_feather", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "custom1", CMP_NODEFLAG_MASK_NO_FEATHER); + RNA_def_property_ui_text(prop, "Feather", "Use feather information from the mask"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } static void dev_cmd_transform(StructRNA *srna) @@ -3240,7 +3259,7 @@ static void def_cmp_ellipsemask(StructRNA *srna) RNA_def_property_float_sdna(prop, NULL, "rotation"); RNA_def_property_float_default(prop, 0.0f); RNA_def_property_range(prop, -1000.0f, 1000.0f); - RNA_def_property_ui_text(prop, "Rotation", "Rotationangle of the box"); + RNA_def_property_ui_text(prop, "Rotation", "Rotation angle of the box"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -3536,14 +3555,14 @@ static void def_cmp_keyingscreen(StructRNA *srna) RNA_def_property_struct_type(prop, "MovieClip"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Movie Clip", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); RNA_def_struct_sdna_from(srna, "NodeKeyingScreenData", "storage"); prop = RNA_def_property(srna, "tracking_object", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "tracking_object"); RNA_def_property_ui_text(prop, "Tracking Object", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } static void def_cmp_keying(StructRNA *srna) @@ -3556,55 +3575,67 @@ static void def_cmp_keying(StructRNA *srna) RNA_def_property_float_sdna(prop, NULL, "screen_balance"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Screen Balance", "Balance between two non-primary channels primary channel is comparing against"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "despill_factor", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "despill_factor"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Despill", "Factor of despilling screen color from image"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "clip_black", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "clip_black"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Clip Black", "Value of on-scaled matte pixel which considers as fully background pixel"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_ui_text(prop, "Clip Black", "Value of non-scaled matte pixel which considers as fully background pixel"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "clip_white", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "clip_white"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Clip White", "Value of on-scaled matte pixel which considers as fully foreground pixel"); + RNA_def_property_ui_text(prop, "Clip White", "Value of non-scaled matte pixel which considers as fully foreground pixel"); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "blur_pre", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "blur_pre"); RNA_def_property_range(prop, 0, 2048); RNA_def_property_ui_text(prop, "Pre Blur", "Chroma pre-blur size which applies before running keyer"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "blur_post", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "blur_post"); RNA_def_property_range(prop, 0, 2048); RNA_def_property_ui_text(prop, "Post Blur", "Matte blur size which applies after clipping and dilate/eroding"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "dilate_distance", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "dilate_distance"); RNA_def_property_range(prop, -100, 100); RNA_def_property_ui_text(prop, "Dilate/Erode", "Matte dilate/erode side"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "edge_kernel_radius", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "edge_kernel_radius"); - RNA_def_property_range(prop, -100, 100); + RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "Edge Kernel Radius", "Radius of kernel used to detect whether pixel belongs to edge"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "edge_kernel_tolerance", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "edge_kernel_tolerance"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Edge Kernel Tolerance", "Tolerance to pixels inside kernel which are treating as belonging to the same plane"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "feather_falloff", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "feather_falloff"); + RNA_def_property_enum_items(prop, proportional_falloff_curve_only_items); + RNA_def_property_ui_text(prop, "Feather Falloff", "Falloff type the feather"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "feather_distance", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "feather_distance"); + RNA_def_property_range(prop, -100, 100); + RNA_def_property_ui_text(prop, "Feather Distance", "Distance to grow/shrink the feather"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } /* -- Texture Nodes --------------------------------------------------------- */ @@ -4236,6 +4267,11 @@ static void rna_def_composite_nodetree(BlenderRNA *brna) prop = RNA_def_property(srna, "use_opencl", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", NTREE_COM_OPENCL); RNA_def_property_ui_text(prop, "OpenCL", "Enable GPU calculations"); + + prop = RNA_def_property(srna, "two_pass", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", NTREE_TWO_PASS); + RNA_def_property_ui_text(prop, "Two Pass", "Use two pass execution during editing: first calculate fast nodes, " + "second pass calculate all nodes"); } static void rna_def_shader_nodetree(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 20f58f4d16e..5ebaddda043 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -37,7 +37,7 @@ DefNode( ShaderNode, SH_NODE_MATERIAL, def_sh_material, "MATER DefNode( ShaderNode, SH_NODE_RGB, 0, "RGB", RGB, "RGB", "" ) DefNode( ShaderNode, SH_NODE_VALUE, 0, "VALUE", Value, "Value", "" ) DefNode( ShaderNode, SH_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "MixRGB", "" ) -DefNode( ShaderNode, SH_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) +DefNode( ShaderNode, SH_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) DefNode( ShaderNode, SH_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" ) DefNode( ShaderNode, SH_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" ) DefNode( ShaderNode, SH_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" ) @@ -91,13 +91,13 @@ DefNode( ShaderNode, SH_NODE_TEX_WAVE, def_sh_tex_wave, "TE DefNode( ShaderNode, SH_NODE_TEX_MUSGRAVE, def_sh_tex_musgrave, "TEX_MUSGRAVE", TexMusgrave, "Musgrave Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_VORONOI, def_sh_tex_voronoi, "TEX_VORONOI", TexVoronoi, "Voronoi Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_CHECKER, def_sh_tex_checker, "TEX_CHECKER", TexChecker, "Checker Texture", "" ) -DefNode( ShaderNode, SH_NODE_TEX_COORD, 0, "TEX_COORD", TexCoord, "Texture Coordinate","") +DefNode( ShaderNode, SH_NODE_TEX_COORD, 0, "TEX_COORD", TexCoord, "Texture Coordinate","" ) DefNode( CompositorNode, CMP_NODE_VIEWER, def_cmp_viewer, "VIEWER", Viewer, "Viewer", "" ) DefNode( CompositorNode, CMP_NODE_RGB, 0, "RGB", RGB, "RGB", "" ) DefNode( CompositorNode, CMP_NODE_VALUE, 0, "VALUE", Value, "Value", "" ) DefNode( CompositorNode, CMP_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "Mix RGB", "" ) -DefNode( CompositorNode, CMP_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) +DefNode( CompositorNode, CMP_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) DefNode( CompositorNode, CMP_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" ) DefNode( CompositorNode, CMP_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" ) DefNode( CompositorNode, CMP_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", CurveVec, "Vector Curve", "" ) @@ -118,7 +118,7 @@ DefNode( CompositorNode, CMP_NODE_COMPOSITE, 0, "COMPO DefNode( CompositorNode, CMP_NODE_OUTPUT_FILE, def_cmp_output_file, "OUTPUT_FILE", OutputFile, "Output File", "" ) DefNode( CompositorNode, CMP_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" ) DefNode( CompositorNode, CMP_NODE_TRANSLATE, 0, "TRANSLATE", Translate, "Translate", "" ) -DefNode( CompositorNode, CMP_NODE_ZCOMBINE, def_cmp_zcombine, "ZCOMBINE", Zcombine, "Z Combine", "" ) +DefNode( CompositorNode, CMP_NODE_ZCOMBINE, def_cmp_zcombine, "ZCOMBINE", Zcombine, "Z Combine", "" ) DefNode( CompositorNode, CMP_NODE_COMBRGBA, 0, "COMBRGBA", CombRGBA, "Combine RGBA", "" ) DefNode( CompositorNode, CMP_NODE_DILATEERODE, def_cmp_dilate_erode, "DILATEERODE", DilateErode, "Dilate/Erode", "" ) DefNode( CompositorNode, CMP_NODE_ROTATE, def_cmp_rotate, "ROTATE", Rotate, "Rotate", "" ) @@ -178,7 +178,7 @@ DefNode( TextureNode, TEX_NODE_BRICKS, def_tex_bricks, "BRICK DefNode( TextureNode, TEX_NODE_MATH, def_math, "MATH", Math, "Math", "" ) DefNode( TextureNode, TEX_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "Mix RGB", "" ) DefNode( TextureNode, TEX_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" ) -DefNode( TextureNode, TEX_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) +DefNode( TextureNode, TEX_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) DefNode( TextureNode, TEX_NODE_IMAGE, def_tex_image, "IMAGE", Image, "Image", "" ) DefNode( TextureNode, TEX_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", CurveRGB, "RGB Curve", "" ) DefNode( TextureNode, TEX_NODE_INVERT, 0, "INVERT", Invert, "Invert", "" ) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 0399a8ee60d..ce6b028beb5 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -174,6 +174,11 @@ static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA rna_Object_internal_update(bmain, scene, ptr); } +static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +{ + DAG_id_type_tag(bmain, ID_OB); +} + static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) { Object *ob = ptr->id.data; @@ -947,8 +952,8 @@ static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value) break; case OB_BODY_TYPE_CHARACTER: ob->gameflag |= OB_COLLISION | OB_GHOST | OB_CHARACTER; - ob->gameflag &= ~(OB_SENSOR | OB_OCCLUDER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR - | OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH); + ob->gameflag &= ~(OB_SENSOR | OB_OCCLUDER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR | + OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH); break; case OB_BODY_TYPE_STATIC: ob->gameflag |= OB_COLLISION; @@ -1444,7 +1449,8 @@ static void rna_def_object_game_settings(BlenderRNA *brna) "Collision Sensor, detects static and dynamic objects but not the other " "collision sensor objects"}, {OB_BODY_TYPE_NAVMESH, "NAVMESH", 0, "Navigation Mesh", "Navigation mesh"}, - {OB_BODY_TYPE_CHARACTER, "CHARACTER", 0, "Character", "Simple kinematic physics appropiate for game characters"}, + {OB_BODY_TYPE_CHARACTER, "CHARACTER", 0, "Character", + "Simple kinematic physics appropriate for game characters"}, {0, NULL, 0, NULL, NULL} }; @@ -1502,7 +1508,7 @@ static void rna_def_object_game_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "use_ghost", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_GHOST); - RNA_def_property_ui_text(prop, "Ghost", "Object does not restitute collisions, like a ghost"); + RNA_def_property_ui_text(prop, "Ghost", "Object does not react to collisions, like a ghost"); prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01, 10000.0); @@ -1539,17 +1545,17 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_range(prop, 0.0, 1000.0); RNA_def_property_ui_text(prop, "Velocity Max", "Clamp velocity to this maximum speed"); - prop= RNA_def_property(srna, "step_height", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "step_height", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "step_height"); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_ui_text(prop, "Step Height", "Maximum height of steps the character can run over"); - prop= RNA_def_property(srna, "jump_speed", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "jump_speed", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "jump_speed"); RNA_def_property_range(prop, 0.0, 1000.0); RNA_def_property_ui_text(prop, "Jump Force", "Upward velocity applied to the character when jumping (with the Motion actuator)"); - prop= RNA_def_property(srna, "fall_speed", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "fall_speed", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fall_speed"); RNA_def_property_range(prop, 0.0, 1000.0); RNA_def_property_ui_text(prop, "Fall Speed Max", "Maximum speed at which the character will fall"); @@ -1971,6 +1977,12 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_layer_update"); + prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER); + RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000); + RNA_def_property_array(prop, 8); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object is on"); + 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", "Object selection state"); @@ -2308,7 +2320,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEW); RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, 1); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update"); prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_SELECT); @@ -2320,7 +2332,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER); RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update"); /* anim */ rna_def_animdata_common(srna); @@ -2579,6 +2591,12 @@ static void rna_def_object_base(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Layers", "Layers the object base is on"); RNA_def_property_boolean_funcs(prop, NULL, "rna_Base_layer_set"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Base_layer_update"); + + prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER); + RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000); + RNA_def_property_array(prop, 8); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Local View Layers", "3D local view layers the object base is on"); prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BA_SELECT); diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 25866dd996f..1c896133408 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -901,10 +901,10 @@ static void rna_def_collision(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Kill Particles", "Kill collided particles"); RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); - prop = RNA_def_property(srna, "stickness", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "stickiness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pdef_stickness"); RNA_def_property_range(prop, 0.0f, 10.0f); - RNA_def_property_ui_text(prop, "Stickness", "Amount of stickness to surface collision"); + RNA_def_property_ui_text(prop, "Stickiness", "Amount of stickiness to surface collision"); RNA_def_property_update(prop, 0, "rna_CollisionSettings_update"); /* Soft Body and Cloth Interaction */ diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index eaf1ae09524..35c85f0f40e 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -142,9 +142,9 @@ void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value) /* ensure only valid values get set */ if ((value >= -1) && (value < 21)) { grp->customCol = value; - + /* sync colors stored with theme colors based on the index specified */ - action_group_colors_sync(grp); + action_group_colors_sync(grp, NULL); } } @@ -1118,8 +1118,8 @@ static void rna_def_pose_itasc(BlenderRNA *brna) {ITASC_INITIAL_REITERATION, "INITIAL", 0, "Initial", "The solver reiterates (converges) on the first frame but not on " "subsequent frame"}, - {ITASC_INITIAL_REITERATION|ITASC_REITERATION, "ALWAYS", 0, "Always", - "The solver reiterates (converges) on all frames"}, + {ITASC_INITIAL_REITERATION | ITASC_REITERATION, "ALWAYS", 0, "Always", + "The solver reiterates (converges) on all frames"}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 85c7b5679c1..ec09682d8b0 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -101,6 +101,16 @@ EnumPropertyItem proportional_falloff_items[] = { {0, NULL, 0, NULL, NULL} }; +/* subset of the enum - only curves, missing random and const */ +EnumPropertyItem proportional_falloff_curve_only_items[] = { + {PROP_SMOOTH, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", "Smooth falloff"}, + {PROP_SPHERE, "SPHERE", ICON_SPHERECURVE, "Sphere", "Spherical falloff"}, + {PROP_ROOT, "ROOT", ICON_ROOTCURVE, "Root", "Root falloff"}, + {PROP_SHARP, "SHARP", ICON_SHARPCURVE, "Sharp", "Sharp falloff"}, + {PROP_LIN, "LINEAR", ICON_LINCURVE, "Linear", "Linear falloff"}, + {0, NULL, 0, NULL, NULL} +}; + EnumPropertyItem proportional_editing_items[] = { {PROP_EDIT_OFF, "DISABLED", ICON_PROP_OFF, "Disable", "Proportional Editing disabled"}, @@ -126,6 +136,14 @@ EnumPropertyItem snap_element_items[] = { {0, NULL, 0, NULL, NULL} }; +EnumPropertyItem snap_node_element_items[] = { + {SCE_SNAP_MODE_INCREMENT, "INCREMENT", ICON_SNAP_INCREMENT, "Increment", "Snap to increments of grid"}, + {SCE_SNAP_MODE_NODE_X, "NODE_X", ICON_SNAP_EDGE, "Node X", "Snap to left/right node border"}, + {SCE_SNAP_MODE_NODE_Y, "NODE_Y", ICON_SNAP_EDGE, "Node Y", "Snap to top/bottom node border"}, + {SCE_SNAP_MODE_NODE_XY, "NODE_XY", ICON_SNAP_EDGE, "Node X / Y", "Snap to any node border"}, + {0, NULL, 0, NULL, NULL} +}; + /* workaround for duplice enums, * have each enum line as a defne then conditionally set it or not @@ -726,7 +744,7 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value) } static EnumPropertyItem *rna_ImageFormatSettings_file_format_itemf(bContext *C, PointerRNA *ptr, - PropertyRNA *UNUSED(prop), int *free) + PropertyRNA *UNUSED(prop), int *UNUSED(free)) { ID *id = ptr->id.data; if (id && GS(id->name) == ID_SCE) { @@ -745,7 +763,7 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_mode_itemf(bContext *C, P const char is_render = (id && GS(id->name) == ID_SCE); /* note, we need to act differently for render - * where 'BW' will force greyscale even if the output format writes + * where 'BW' will force grayscale even if the output format writes * as RGBA, this is age old blender convention and not sure how useful * it really is but keep it for now - campbell */ char chan_flag = BKE_imtype_valid_channels(imf->imtype) | (is_render ? IMA_CHAN_FLAG_BW : 0); @@ -1616,6 +1634,13 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, snap_element_items); RNA_def_property_ui_text(prop, "Snap Element", "Type of element to snap to"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ + + /* node editor uses own set of snap modes */ + prop = RNA_def_property(srna, "snap_node_element", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "snap_node_mode"); + RNA_def_property_enum_items(prop, snap_node_element_items); + RNA_def_property_ui_text(prop, "Snap Node Element", "Type of element to snap to"); + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "snap_target", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "snap_target"); @@ -1641,7 +1666,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Project to Self", "Snap onto itself (editmode)"); RNA_def_property_ui_icon(prop, ICON_ORTHO, 0); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ - + /* Grease Pencil */ prop = RNA_def_property(srna, "use_grease_pencil_sessions", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_PAINTSESSIONS_ON); @@ -2844,7 +2869,7 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) RNA_def_property_enum_items(prop, image_color_mode_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_ImageFormatSettings_color_mode_itemf"); RNA_def_property_ui_text(prop, "Color Mode", - "Choose BW for saving greyscale images, RGB for saving red, green and blue channels, " + "Choose BW for saving grayscale images, RGB for saving red, green and blue channels, " "and RGBA for saving red, green, blue and alpha channels"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index d4611f4a268..13b60498900 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -91,17 +91,25 @@ static void rna_Scene_collada_export( const char *filepath, int apply_modifiers, int export_mesh_type, - int selected, + + int selected, int include_children, int include_armatures, int deform_bones_only, + + int active_uv_only, + int include_uv_textures, + int include_material_textures, + int use_texture_copies, + int use_object_instantiation, int sort_by_name, int second_life) { collada_export(scene, filepath, apply_modifiers, export_mesh_type, selected, - include_children, include_armatures, deform_bones_only, - use_object_instantiation, sort_by_name, second_life); + include_children, include_armatures, deform_bones_only, + active_uv_only, include_uv_textures, include_material_textures, + use_texture_copies, use_object_instantiation, sort_by_name, second_life); } #endif @@ -136,6 +144,12 @@ void RNA_api_scene(StructRNA *srna) parm = RNA_def_boolean(func, "include_children", 0, "Include Children", "Export all children of selected objects (even if not selected)"); parm = RNA_def_boolean(func, "include_armatures", 0, "Include Armatures", "Export related armatures (even if not selected)"); parm = RNA_def_boolean(func, "deform_bones_only", 0, "Deform Bones only", "Only export deforming bones with armatures"); + + parm = RNA_def_boolean(func, "active_uv_only", 0, "Active UV Layer only", "Export only the active UV Layer"); + parm = RNA_def_boolean(func, "include_uv_textures", 0, "Include UV Textures", "Export textures assigned to the object UV maps"); + parm = RNA_def_boolean(func, "include_material_textures", 0, "Include Material Textures", "Export textures assigned to the object Materials"); + parm = RNA_def_boolean(func, "use_texture_copies", 0, "copy", "Copy textures to same folder where the .dae file is exported"); + parm = RNA_def_boolean(func, "use_object_instantiation", 1, "Use Object Instances", "Instantiate multiple Objects from same Data"); parm = RNA_def_boolean(func, "sort_by_name", 0, "Sort by Object name", "Sort exported data by Object name"); parm = RNA_def_boolean(func, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life"); diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index 6e5aa78b8bd..d405cba6607 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -296,7 +296,7 @@ static void rna_def_screen(BlenderRNA *brna) prop = RNA_def_property(srna, "show_fullscreen", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Screen_fullscreen_get", NULL); - RNA_def_property_ui_text(prop, "Fullscreen", "An area is maximised, filling this screen"); + RNA_def_property_ui_text(prop, "Fullscreen", "An area is maximized, filling this screen"); /* Define Anim Playback Areas */ prop = RNA_def_property(srna, "use_play_top_left_3d_editor", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index cce0612bd68..00e8ed5289f 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -231,7 +231,7 @@ static void rna_Sensor_level_set(struct PointerRNA *ptr, int value) sens->tap = 0; } -static void rna_Sensor_Armature_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Sensor_Armature_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { bSensor *sens = (bSensor *)ptr->data; bArmatureSensor *as = sens->data; diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index 3a534cd22b4..6c54b7c2cf3 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -99,7 +99,7 @@ static Sequence *alloc_generic_sequence(Editing *ed, const char *name, int start return seq; } -static Sequence *rna_Sequences_new_clip(ID *id, Editing *ed, ReportList *reports, +static Sequence *rna_Sequences_new_clip(ID *id, Editing *ed, const char *name, MovieClip *clip, int channel, int start_frame) { @@ -118,7 +118,7 @@ static Sequence *rna_Sequences_new_clip(ID *id, Editing *ed, ReportList *reports return seq; } -static Sequence *rna_Sequences_new_mask(ID *id, Editing *ed, ReportList *reports, +static Sequence *rna_Sequences_new_mask(ID *id, Editing *ed, const char *name, Mask *mask, int channel, int start_frame) { @@ -137,7 +137,7 @@ static Sequence *rna_Sequences_new_mask(ID *id, Editing *ed, ReportList *reports return seq; } -static Sequence *rna_Sequences_new_scene(ID *id, Editing *ed, ReportList *reports, +static Sequence *rna_Sequences_new_scene(ID *id, Editing *ed, const char *name, Scene *sce_seq, int channel, int start_frame) { @@ -455,7 +455,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_ui_text(srna, "Sequences", "Collection of Sequences"); func = RNA_def_function(srna, "new_clip", "rna_Sequences_new_clip"); - RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Add a new movie clip sequence"); parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -472,7 +472,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func = RNA_def_function(srna, "new_mask", "rna_Sequences_new_mask"); - RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Add a new movie clip sequence"); parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -489,7 +489,7 @@ void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func = RNA_def_function(srna, "new_scene", "rna_Sequences_new_scene"); - RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); RNA_def_function_ui_description(func, "Add a new scene sequence"); parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); RNA_def_property_flag(parm, PROP_REQUIRED); diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index 4224b3936c6..e8818248609 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -296,7 +296,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "smooth_emitter", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_HIGH_SMOOTH); - RNA_def_property_ui_text(prop, "Smooth Emitter", "Smoothen emitted smoke to avoid blockiness"); + RNA_def_property_ui_text(prop, "Smooth Emitter", "Smooth emitted smoke to avoid blockiness"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); prop = RNA_def_property(srna, "time_scale", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 661c7ba878c..f6286333111 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1699,6 +1699,12 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceView3D_layer_set"); RNA_def_property_ui_text(prop, "Visible Layers", "Layers visible in this 3D View"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_layer_update"); + + prop = RNA_def_property(srna, "layers_local_view", PROP_BOOLEAN, PROP_LAYER_MEMBER); + RNA_def_property_boolean_sdna(prop, NULL, "lay", 0x01000000); + RNA_def_property_array(prop, 8); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Local View Layers", "Local view layers visible in this 3D View"); prop = RNA_def_property(srna, "layers_used", PROP_BOOLEAN, PROP_LAYER_MEMBER); RNA_def_property_boolean_sdna(prop, NULL, "lay_used", 1); @@ -2297,7 +2303,7 @@ static void rna_def_space_dopesheet(BlenderRNA *brna) prop = RNA_def_property(srna, "show_group_colors", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SACTION_NODRAWGCOLORS); RNA_def_property_ui_text(prop, "Show Group Colors", - "Draw groups and channels with colours matching their corresponding groups"); + "Draw groups and channels with colors matching their corresponding groups"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_DOPESHEET, NULL); /* editing */ @@ -2408,7 +2414,7 @@ static void rna_def_space_graph(BlenderRNA *brna) prop = RNA_def_property(srna, "show_group_colors", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NODRAWGCOLORS); RNA_def_property_ui_text(prop, "Show Group Colors", - "Draw groups and channels with colours matching their corresponding groups"); + "Draw groups and channels with colors matching their corresponding groups"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); /* editing */ @@ -2920,6 +2926,11 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_def_property_enum_items(prop, backdrop_channels_items); RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the image to draw"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); + + prop = RNA_def_property(srna, "show_highlight", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SNODE_SHOW_HIGHLIGHT); + RNA_def_property_ui_text(prop, "Highlight", "Highlight nodes that are being calculated"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); } static void rna_def_space_logic(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 9b709e9ace1..0270a7643a6 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -841,7 +841,7 @@ static void rna_def_texture_clouds(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_clouds_stype[] = { - {TEX_DEFAULT, "GREYSCALE", 0, "Greyscale", ""}, + {TEX_DEFAULT, "GRAYSCALE", 0, "Grayscale", ""}, {TEX_COLOR, "COLOR", 0, "Color", ""}, {0, NULL, 0, NULL, NULL} }; @@ -1783,7 +1783,7 @@ static void rna_def_texture_voxeldata(BlenderRNA *brna) static EnumPropertyItem file_format_items[] = { {TEX_VD_BLENDERVOXEL, "BLENDER_VOXEL", 0, "Blender Voxel", "Default binary voxel file format"}, - {TEX_VD_RAW_8BIT, "RAW_8BIT", 0, "8 bit RAW", "8 bit greyscale binary data"}, + {TEX_VD_RAW_8BIT, "RAW_8BIT", 0, "8 bit RAW", "8 bit grayscale binary data"}, /*{TEX_VD_RAW_16BIT, "RAW_16BIT", 0, "16 bit RAW", ""}, */ {TEX_VD_IMAGE_SEQUENCE, "IMAGE_SEQUENCE", 0, "Image Sequence", "Generate voxels from a sequence of image slices"}, diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 801bec30ecf..e8e00d42d2f 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -636,7 +636,7 @@ static void rna_def_trackingSettings(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_int_sdna(prop, NULL, "default_margin"); RNA_def_property_range(prop, 0, 300); - RNA_def_property_ui_text(prop, "Margin", "Default distance from image boudary at which marker stops tracking"); + RNA_def_property_ui_text(prop, "Margin", "Default distance from image boundary at which marker stops tracking"); /* default_tracking_motion_model */ prop = RNA_def_property(srna, "default_motion_model", PROP_ENUM, PROP_NONE); @@ -952,7 +952,7 @@ static void rna_def_trackingTrack(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "margin"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0, 300); - RNA_def_property_ui_text(prop, "Margin", "Distance from image boudary at which marker stops tracking"); + RNA_def_property_ui_text(prop, "Margin", "Distance from image boundary at which marker stops tracking"); /* tracking motion model */ prop = RNA_def_property(srna, "motion_model", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 7c9cb04b66a..70d94bfc7ed 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -617,7 +617,7 @@ static void rna_def_ui_layout(BlenderRNA *brna) prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_UILayout_enabled_get", "rna_UILayout_enabled_set"); - RNA_def_property_ui_text(prop, "Enabled", "When false, this (sub)layout is greyed out"); + RNA_def_property_ui_text(prop, "Enabled", "When false, this (sub)layout is grayed out"); prop = RNA_def_property(srna, "alert", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_UILayout_alert_get", "rna_UILayout_alert_set"); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 42eb06b137a..54178516d50 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -144,7 +144,8 @@ static void rna_userdef_anisotropic_update(Main *bmain, Scene *scene, PointerRNA rna_userdef_update(bmain, scene, ptr); } -static void rna_userdef_gl_gpu_mipmaps(Main *bmain, Scene *scene, PointerRNA *ptr) { +static void rna_userdef_gl_gpu_mipmaps(Main *bmain, Scene *scene, PointerRNA *ptr) +{ GPU_set_gpu_mipmapping(U.use_gpu_mipmap); rna_userdef_update(bmain, scene, ptr); } @@ -462,7 +463,7 @@ static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) prop = RNA_def_property(srna, "shadowcolor", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Shadow Brightness", "Shadow color in grey value"); + RNA_def_property_ui_text(prop, "Shadow Brightness", "Shadow color in gray value"); RNA_def_property_update(prop, 0, "rna_userdef_update"); } @@ -2092,7 +2093,7 @@ static void rna_def_userdef_theme_space_clip(BlenderRNA *brna) prop = RNA_def_property(srna, "marker_outline", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "marker_outline"); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Marker Outline Color", "Color of marker's outile"); + RNA_def_property_ui_text(prop, "Marker Outline Color", "Color of marker's outline"); RNA_def_property_update(prop, 0, "rna_userdef_update"); prop = RNA_def_property(srna, "marker", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -2755,7 +2756,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "ipo_new"); RNA_def_property_ui_text(prop, "New Interpolation Type", "Interpolation mode used for first keyframe on newly added F-Curves " - "(subsequent keyframes take interpolation from preceeding keyframe)"); + "(subsequent keyframes take interpolation from preceding keyframe)"); prop = RNA_def_property(srna, "keyframe_new_handle_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, keyframe_handle_type_items); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 8c6a2809ef8..61c75e306cb 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -183,7 +183,7 @@ EnumPropertyItem event_type_items[] = { {SELECTMOUSE, "SELECTMOUSE", 0, "Select Mouse", ""}, {0, "", 0, NULL, NULL}, {MOUSEMOVE, "MOUSEMOVE", 0, "Mouse Move", ""}, - {INBETWEEN_MOUSEMOVE, "INBETWEEN_MOUSEMOVE", 0, "Inbetween Move", ""}, + {INBETWEEN_MOUSEMOVE, "INBETWEEN_MOUSEMOVE", 0, "In-between Move", ""}, {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", ""}, {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", ""}, {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", ""}, diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 41057234d9b..a4ba9ba35bb 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -173,7 +173,7 @@ static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op, int *index_map, i; BMO_op_initf(bm, &find_op, - "finddoubles verts=%av dist=%f keepverts=%s", + "find_doubles verts=%av dist=%f keep_verts=%s", amd->merge_dist, dupe_op, "geom"); BMO_op_exec(bm, &find_op); @@ -224,8 +224,8 @@ static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4], BMIter iter; /* Add the DerivedMesh's elements to the BMesh. The pre-existing - elements were already tagged, so the new elements can be - identified by not having the BM_ELEM_TAG flag set. */ + * elements were already tagged, so the new elements can be + * identified by not having the BM_ELEM_TAG flag set. */ DM_to_bmesh_ex(dm, bm); if (amd->flags & MOD_ARR_MERGE) { @@ -235,7 +235,7 @@ static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4], BMOperator find_op; BMO_op_initf(bm, &find_op, - "finddoubles verts=%Hv dist=%f keepverts=%s", + "find_doubles verts=%Hv dist=%f keep_verts=%s", BM_ELEM_TAG, amd->merge_dist, dupe_op, dupe_slot_name); @@ -287,7 +287,7 @@ static void merge_first_last(BMesh *bm, BMVert *v, *v2; BMO_op_initf(bm, &find_op, - "finddoubles verts=%s dist=%f keepverts=%s", + "find_doubles verts=%s dist=%f keep_verts=%s", dupe_first, "geom", amd->merge_dist, dupe_first, "geom"); @@ -410,9 +410,9 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, bmesh_edit_begin(em->bm, 0); if (amd->flags & MOD_ARR_MERGE) - BMO_op_init(em->bm, &weld_op, "weldverts"); + BMO_op_init(em->bm, &weld_op, "weld_verts"); - BMO_op_initf(em->bm, &dupe_op, "dupe geom=%avef"); + BMO_op_initf(em->bm, &dupe_op, "duplicate geom=%avef"); first_dupe_op = dupe_op; for (j = 0; j < count - 1; j++) { @@ -422,7 +422,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, BMOIter oiter; if (j != 0) - BMO_op_initf(em->bm, &dupe_op, "dupe geom=%s", &old_dupe_op, "newout"); + BMO_op_initf(em->bm, &dupe_op, "duplicate geom=%s", &old_dupe_op, "newout"); BMO_op_exec(em->bm, &dupe_op); geom_slot = BMO_slot_get(&dupe_op, "geom"); diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index 1b3e3c16486..39d78f777a0 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -103,7 +103,7 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj } } - BMO_op_callf(bm, "edgesplit edges=%fe", EDGE_MARK); + BMO_op_callf(bm, "split_edges edges=%fe", EDGE_MARK); BMO_pop(bm); diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index 5039ffef382..ab7263a1b53 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -178,7 +178,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, return derivedData; } - /* verthash gives mapping from original vertex indicies to the new indices (including selected matches only) + /* verthash gives mapping from original vertex indices to the new indices (including selected matches only) * key=oldindex, value=newindex */ vertHash = BLI_ghash_int_new("mask vert gh"); diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index ce95f9bec6e..aed8a70a805 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -282,10 +282,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, step_tot--; if (step_tot < 3) step_tot = 3; - maxVerts = totvert * step_tot; /* -1 because we're joining back up */ - maxEdges = (totvert * step_tot) + /* these are the edges between new verts */ - (totedge * step_tot); /* -1 because vert edges join */ - maxPolys = totedge * step_tot; + maxVerts = totvert * step_tot; /* -1 because we're joining back up */ + maxEdges = (totvert * step_tot) + /* these are the edges between new verts */ + (totedge * step_tot); /* -1 because vert edges join */ + maxPolys = totedge * step_tot; screw_ofs = 0.0f; } diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index d3ea3fd4ebd..46987f30205 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -318,7 +318,7 @@ static int build_hull(SkinOutput *so, Frame **frames, int totframe) BMO_op_finish(bm, &op); - BMO_op_callf(bm, "del geom=%hef context=%i", BM_ELEM_TAG, DEL_ONLYTAGGED); + BMO_op_callf(bm, "delete geom=%hef context=%i", BM_ELEM_TAG, DEL_ONLYTAGGED); return TRUE; } @@ -1035,7 +1035,7 @@ static BMFace *collapse_face_corners(BMesh *bm, BMFace *f, int n, int i; shortest_edge = BM_face_find_shortest_loop(f)->e; - BMO_op_initf(bm, &op, "weldverts"); + BMO_op_initf(bm, &op, "weld_verts"); /* Note: could probably calculate merges in one go to be * faster */ @@ -1175,7 +1175,7 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f /* Extrude the split face */ BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE); BM_elem_flag_enable(split_face, BM_ELEM_TAG); - BMO_op_initf(bm, &op, "extrude_face_indiv faces=%hf", BM_ELEM_TAG); + BMO_op_initf(bm, &op, "extrude_discrete_faces faces=%hf", BM_ELEM_TAG); BMO_op_exec(bm, &op); /* Update split face (should only be one new face created @@ -1198,7 +1198,7 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f BM_mesh_elem_hflag_disable_all(bm, BM_EDGE, BM_ELEM_TAG, FALSE); BM_elem_flag_enable(longest_edge, BM_ELEM_TAG); - BMO_op_callf(bm, "esubd edges=%he numcuts=%i quadcornertype=%i", + BMO_op_callf(bm, "subdivide_edges edges=%he numcuts=%i quadcornertype=%i", BM_ELEM_TAG, 1, SUBD_STRAIGHT_CUT); } else if (split_face->len > 4) { @@ -1230,7 +1230,7 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f /* Delete split face and merge */ BM_face_kill(bm, split_face); - BMO_op_init(bm, &op, "weldverts"); + BMO_op_init(bm, &op, "weld_verts"); for (i = 0; i < 4; i++) { BMO_slot_map_ptr_insert(bm, &op, "targetmap", verts[i], frame->verts[best_order[i]]); @@ -1395,7 +1395,7 @@ static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd) } } - BMO_op_callf(so->bm, "del geom=%hef context=%i", BM_ELEM_TAG, DEL_ONLYTAGGED); + BMO_op_callf(so->bm, "delete geom=%hef context=%i", BM_ELEM_TAG, DEL_ONLYTAGGED); BLI_heap_free(heap, NULL); } diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 2415c7842a7..ce5ce1d87c1 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -35,7 +35,6 @@ set(INC ../makesrna ../render/extern/include ../../../intern/guardedalloc - ../compositor ) set(INC_SYS @@ -243,4 +242,11 @@ if(WITH_IMAGE_OPENEXR) add_definitions(-DWITH_OPENEXR) endif() +if(WITH_COMPOSITOR) + list(APPEND INC + ../compositor + ) + add_definitions(-DWITH_COMPOSITOR) +endif() + blender_add_lib(bf_nodes "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/nodes/SConscript b/source/blender/nodes/SConscript index 86178b31688..bf70b5a6ed5 100644 --- a/source/blender/nodes/SConscript +++ b/source/blender/nodes/SConscript @@ -13,7 +13,6 @@ incs += ' ../imbuf ../avi ' incs += ' ../blenloader' incs += ' ../blenfont ../blenkernel ../renderconverter ' incs += ' ../gpu #/extern/glew/include ' -incs += ' ../compositor ' incs += ' ' + env['BF_OPENGL_INC'] incs += ' ' + env['BF_ZLIB_INC'] @@ -36,6 +35,10 @@ if env['OURPLATFORM'] == 'linux': if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): incs += ' ' + env['BF_PTHREADS_INC'] + +if env['WITH_BF_COMPOSITOR']: + incs += ' ../compositor ' + defs.append("WITH_COMPOSITOR") env.BlenderLib ( libname = 'bf_nodes', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [190,105] ) env.BlenderLib ( libname = 'bf_cmpnodes', sources = cmpsources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [175,101] ) diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 5813f4d479f..b9acf821efe 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -59,7 +59,10 @@ #include "NOD_composite.h" #include "node_composite_util.h" -#include "COM_compositor.h" + +#ifdef WITH_COMPOSITOR +# include "COM_compositor.h" +#endif static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func) { @@ -115,7 +118,6 @@ static void update_node(bNodeTree *ntree, bNode *node) } } node->need_exec= 1; - /* individual node update call */ if (node->typeinfo->updatefunc) node->typeinfo->updatefunc(ntree, node); @@ -130,6 +132,7 @@ static void localize(bNodeTree *localtree, bNodeTree *ntree) for (node= ntree->nodes.first; node; node= node->next) { /* ensure new user input gets handled ok */ node->need_exec= 0; + node->new_node->original = node; /* move over the compbufs */ /* right after ntreeCopyTree() oldsock pointers are valid */ @@ -197,6 +200,7 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree) lnode->new_node->preview= lnode->preview; lnode->preview= NULL; } + } } } @@ -218,8 +222,8 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree) } else if (lnode->type==CMP_NODE_MOVIEDISTORTION) { /* special case for distortion node: distortion context is allocating in exec function - and to achive much better performance on further calls this context should be - copied back to original node */ + * and to achive much better performance on further calls this context should be + * copied back to original node */ if (lnode->storage) { if (lnode->new_node->storage) BKE_tracking_distortion_free(lnode->new_node->storage); @@ -351,6 +355,8 @@ void ntreeCompositEndExecTree(bNodeTreeExec *exec, int use_tree_data) } } +#ifdef WITH_COMPOSITOR + /* ***************************** threaded version for execute composite nodes ************* */ /* these are nodes without input, only giving values */ /* or nodes with only value inputs */ @@ -586,7 +592,6 @@ static void ntree_composite_texnode(bNodeTree *ntree, int init) } /* optimized tree execute test for compositing */ -/* optimized tree execute test for compositing */ static void ntreeCompositExecTreeOld(bNodeTree *ntree, RenderData *rd, int do_preview) { bNodeExec *nodeexec; @@ -677,13 +682,18 @@ static void ntreeCompositExecTreeOld(bNodeTree *ntree, RenderData *rd, int do_pr /* XXX top-level tree uses the ntree->execdata pointer */ ntreeCompositEndExecTree(exec, 1); } +#endif void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int do_preview) { +#ifdef WITH_COMPOSITOR if (G.rt == 200) ntreeCompositExecTreeOld(ntree, rd, do_preview); else - COM_execute(ntree, rendering); + COM_execute(rd, ntree, rendering); +#else + (void)ntree, (void)rd, (void)rendering, (void)do_preview; +#endif } /* *********************************************** */ diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index 70788dfe0c8..98ded3ea3b3 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -207,7 +207,7 @@ void typecheck_compbuf_color(float *out, float *in, int outtype, int intype) *out= 0.333333f*(in[0]+in[1]+in[2]); } else if (intype==CB_RGBA) { - *out= in[0]*0.35f + in[1]*0.45f + in[2]*0.2f; + *out = rgb_to_bw(in); } } else if (outtype==CB_VEC2) { @@ -300,7 +300,7 @@ CompBuf *typecheck_compbuf(CompBuf *inbuf, int type) } else if (inbuf->type==CB_RGBA) { for (; x>0; x--, outrf+= 1, inrf+= 4) - *outrf= inrf[0]*0.35f + inrf[1]*0.45f + inrf[2]*0.2f; + *outrf = rgb_to_bw(inrf); } } else if (type==CB_VEC2) { @@ -872,8 +872,8 @@ static void FHT(fREAL* data, unsigned int M, unsigned int inverse) } //------------------------------------------------------------------------------ /* 2D Fast Hartley Transform, Mx/My -> log2 of width/height, - nzp -> the row where zero pad data starts, - inverse -> see above */ + * nzp -> the row where zero pad data starts, + * inverse -> see above */ static void FHT2D(fREAL *data, unsigned int Mx, unsigned int My, unsigned int nzp, unsigned int inverse) { diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c index 62e8138f5e1..0137093658c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c +++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c @@ -59,7 +59,7 @@ static bNodeSocketTemplate cmp_node_bilateralblur_out[] = { (c1[3] - c2[3]) * (c1[3] - c2[3])) /* this is the main kernel function for comparing color distances - and adding them weighted to the final color */ + * and adding them weighted to the final color */ #define KERNEL_ELEMENT_C3(k) \ temp_color = src + deltas[k]; \ ref_color = ref + deltas[k]; \ diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.c b/source/blender/nodes/composite/nodes/node_composite_blur.c index 046623f5b26..fb163222781 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.c +++ b/source/blender/nodes/composite/nodes/node_composite_blur.c @@ -384,7 +384,7 @@ static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fa float fi = (float)i / radxf; float dist = sqrt(fj * fj + fi * fi); - //*dgauss= hexagon_filter(fi, fj); + // *dgauss= hexagon_filter(fi, fj); *dgauss = RE_filter_value(nbd->filtertype, dist); val += *dgauss; diff --git a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c index 7c6b4ad1f95..0c6ce79c51f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c @@ -26,8 +26,8 @@ */ /** \file blender/nodes/composite/nodes/node_composite_chromaMatte.c -* \ingroup cmpnodes -*/ + * \ingroup cmpnodes + */ #include "node_composite_util.h" diff --git a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c index 0569f5c68ef..53061366b8b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c @@ -26,8 +26,8 @@ */ /** \file blender/nodes/composite/nodes/node_composite_diffMatte.c -* \ingroup cmpnodes -*/ + * \ingroup cmpnodes + */ #include "node_composite_util.h" @@ -48,10 +48,10 @@ static bNodeSocketTemplate cmp_node_diff_matte_out[]={ static void do_diff_matte(bNode *node, float *outColor, float *inColor1, float *inColor2) { NodeChroma *c= (NodeChroma *)node->storage; - float tolerence=c->t1; + float tolerance=c->t1; float fper=c->t2; - /* get falloff amount over tolerence size */ - float falloff=(1.0f-fper) * tolerence; + /* get falloff amount over tolerance size */ + float falloff=(1.0f-fper) * tolerance; float difference; float alpha; float maxInputAlpha; @@ -64,13 +64,13 @@ static void do_diff_matte(bNode *node, float *outColor, float *inColor1, float * copy_v3_v3(outColor, inColor1); - if (difference <= tolerence) { + if (difference <= tolerance) { if (difference <= falloff) { alpha = 0.0f; } else { /* alpha as percent (distance / tolerance), each modified by falloff amount (in pixels)*/ - alpha=(difference-falloff)/(tolerence-falloff); + alpha=(difference-falloff)/(tolerance-falloff); } /*only change if more transparent than either image */ diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.c b/source/blender/nodes/composite/nodes/node_composite_dilate.c index 2f139831cc9..5977d291388 100644 --- a/source/blender/nodes/composite/nodes/node_composite_dilate.c +++ b/source/blender/nodes/composite/nodes/node_composite_dilate.c @@ -146,6 +146,13 @@ static void node_composit_exec_dilateerode(void *UNUSED(data), bNode *node, bNod } } +static void node_composit_init_dilateerode(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +{ + NodeDilateErode *data = MEM_callocN(sizeof(NodeDilateErode), "NodeDilateErode"); + data->falloff = PROP_SMOOTH; + node->storage = data; +} + void register_node_type_cmp_dilateerode(bNodeTreeType *ttype) { static bNodeType ntype; @@ -153,7 +160,10 @@ void register_node_type_cmp_dilateerode(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_DILATEERODE, "Dilate/Erode", NODE_CLASS_OP_FILTER, NODE_OPTIONS); node_type_socket_templates(&ntype, cmp_node_dilateerode_in, cmp_node_dilateerode_out); node_type_size(&ntype, 130, 100, 320); + node_type_init(&ntype, node_composit_init_dilateerode); node_type_exec(&ntype, node_composit_exec_dilateerode); + node_type_storage(&ntype, "NodeDilateErode", node_free_standard_storage, node_copy_standard_storage); + nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_displace.c b/source/blender/nodes/composite/nodes/node_composite_displace.c index c1a85a0071b..49cba801d5a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_displace.c +++ b/source/blender/nodes/composite/nodes/node_composite_displace.c @@ -126,7 +126,7 @@ static void do_displace(bNode *node, CompBuf *stackbuf, CompBuf *cbuf, CompBuf * /* simple method for reference, linear interpolation */ -/* +#if 0 int x, y; float dx, dy; float u, v; @@ -147,7 +147,7 @@ static void do_displace(bNode *node, CompBuf *stackbuf, CompBuf *cbuf, CompBuf * qd_setPixel(stackbuf, x, y, col); } } -*/ +#endif } diff --git a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c index a456f45c57e..86634487776 100644 --- a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c @@ -26,8 +26,8 @@ */ /** \file blender/nodes/composite/nodes/node_composite_distanceMatte.c -* \ingroup cmpnodes -*/ + * \ingroup cmpnodes + */ #include "node_composite_util.h" @@ -50,10 +50,10 @@ static bNodeSocketTemplate cmp_node_distance_matte_out[]={ static void do_distance_matte(bNode *node, float *out, float *in) { NodeChroma *c= (NodeChroma *)node->storage; - float tolerence=c->t1; + float tolerance=c->t1; float fper=c->t2; - /* get falloff amount over tolerence size */ - float falloff=(1.0f-fper) * tolerence; + /* get falloff amount over tolerance size */ + float falloff=(1.0f-fper) * tolerance; float distance; float alpha; @@ -63,13 +63,13 @@ static void do_distance_matte(bNode *node, float *out, float *in) copy_v3_v3(out, in); - if (distance <= tolerence) { + if (distance <= tolerance) { if (distance <= falloff) { alpha = 0.0f; } else { /* alpha as percent (distance / tolerance), each modified by falloff amount (in pixels)*/ - alpha=(distance-falloff)/(tolerence-falloff); + alpha=(distance-falloff)/(tolerance-falloff); } /*only change if more transparent than before */ @@ -88,10 +88,10 @@ static void do_distance_matte(bNode *node, float *out, float *in) static void do_chroma_distance_matte(bNode *node, float *out, float *in) { NodeChroma *c= (NodeChroma *)node->storage; - float tolerence=c->t1; + float tolerance=c->t1; float fper=c->t2; - /* get falloff amount over tolerence size */ - float falloff=(1.0f-fper) * tolerence; + /* get falloff amount over tolerance size */ + float falloff=(1.0f-fper) * tolerance; float y_key, cb_key, cr_key; float y_pix, cb_pix, cr_pix; float distance; @@ -114,13 +114,13 @@ static void do_chroma_distance_matte(bNode *node, float *out, float *in) copy_v3_v3(out, in); - if (distance <= tolerence) { + if (distance <= tolerance) { if (distance <= falloff) { alpha = 0.0f; } else { /* alpha as percent (distance / tolerance), each modified by falloff amount (in pixels)*/ - alpha=(distance-falloff)/(tolerence-falloff); + alpha=(distance-falloff)/(tolerance-falloff); } /*only change if more transparent than before */ @@ -139,9 +139,9 @@ static void do_chroma_distance_matte(bNode *node, float *out, float *in) static void node_composit_exec_distance_matte(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { /* - Loosely based on the Sequencer chroma key plug-in, but enhanced to work in other color spaces and - uses a different difference function (suggested in forums of vfxtalk.com). - */ + * Loosely based on the Sequencer chroma key plug-in, but enhanced to work in other color spaces and + * uses a different difference function (suggested in forums of vfxtalk.com). + */ CompBuf *workbuf; CompBuf *inbuf; NodeChroma *c; diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index ba03a2697be..3060496bb9e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -368,9 +368,11 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i stackbuf->malloc= alloc; } - /*code to respect the premul flag of images; I'm - not sure if this is a good idea for multilayer images, - since it never worked before for them. + /* code to respect the premul flag of images; I'm + * not sure if this is a good idea for multilayer images, + * since it never worked before for them. + */ +#if 0 if (type==CB_RGBA && ima->flag & IMA_DO_PREMUL) { //premul the image int i; @@ -382,7 +384,7 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i pixel[2] *= pixel[3]; } } - */ +#endif return stackbuf; } @@ -481,8 +483,8 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE int i; float *pixel; - /*first duplicate stackbuf->rect, since it's just a pointer - to the source imbuf, and we don't want to change that.*/ + /* first duplicate stackbuf->rect, since it's just a pointer + * to the source imbuf, and we don't want to change that.*/ stackbuf->rect = MEM_dupallocN(stackbuf->rect); /* since stackbuf now has allocated memory, rather than just a pointer, diff --git a/source/blender/nodes/composite/nodes/node_composite_lensdist.c b/source/blender/nodes/composite/nodes/node_composite_lensdist.c index 9b19ca6f5cf..7635a391441 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lensdist.c +++ b/source/blender/nodes/composite/nodes/node_composite_lensdist.c @@ -98,19 +98,20 @@ static void lensDistort(CompBuf *dst, CompBuf *src, float kr, float kg, float kb float d, t, ln[6] = {0, 0, 0, 0, 0, 0}; fRGB c1, tc = {0, 0, 0, 0}; const float u = sc*((x + 0.5f) - cx)/cx; + const float uv_dot = u * u + v * v; int sta = 0, mid = 0, end = 0; - if ((t = 1.f - kr*(u*u + v*v)) >= 0.f) { + if ((t = 1.f - kr*uv_dot) >= 0.f) { d = 1.f/(1.f + sqrtf(t)); ln[0] = (u*d + 0.5f)*dst->x - 0.5f, ln[1] = (v*d + 0.5f)*dst->y - 0.5f; sta = 1; } - if ((t = 1.f - kg*(u*u + v*v)) >= 0.f) { + if ((t = 1.f - kg*uv_dot) >= 0.f) { d = 1.f/(1.f + sqrtf(t)); ln[2] = (u*d + 0.5f)*dst->x - 0.5f, ln[3] = (v*d + 0.5f)*dst->y - 0.5f; mid = 1; } - if ((t = 1.f - kb*(u*u + v*v)) >= 0.f) { + if ((t = 1.f - kb*uv_dot) >= 0.f) { d = 1.f/(1.f + sqrtf(t)); ln[4] = (u*d + 0.5f)*dst->x - 0.5f, ln[5] = (v*d + 0.5f)*dst->y - 0.5f; end = 1; @@ -125,7 +126,7 @@ static void lensDistort(CompBuf *dst, CompBuf *src, float kr, float kg, float kb for (z=0; z<ds; ++z) { const float tz = ((float)z + (jit ? BLI_frand() : 0.5f))*sd; - t = 1.f - (kr + tz*drg)*(u*u + v*v); + t = 1.f - (kr + tz*drg)*uv_dot; d = 1.f / (1.f + sqrtf(t)); qd_getPixelLerp(src, (u*d + 0.5f)*dst->x - 0.5f, (v*d + 0.5f)*dst->y - 0.5f, c1); if (src->type == CB_VAL) c1[1] = c1[2] = c1[0]; @@ -141,7 +142,7 @@ static void lensDistort(CompBuf *dst, CompBuf *src, float kr, float kg, float kb for (z=0; z<ds; ++z) { const float tz = ((float)z + (jit ? BLI_frand() : 0.5f))*sd; - t = 1.f - (kg + tz*dgb)*(u*u + v*v); + t = 1.f - (kg + tz*dgb)*uv_dot; d = 1.f / (1.f + sqrtf(t)); qd_getPixelLerp(src, (u*d + 0.5f)*dst->x - 0.5f, (v*d + 0.5f)*dst->y - 0.5f, c1); if (src->type == CB_VAL) c1[1] = c1[2] = c1[0]; diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.c b/source/blender/nodes/composite/nodes/node_composite_levels.c index 5594c20a9df..1952756d397 100644 --- a/source/blender/nodes/composite/nodes/node_composite_levels.c +++ b/source/blender/nodes/composite/nodes/node_composite_levels.c @@ -45,11 +45,6 @@ static bNodeSocketTemplate cmp_node_view_levels_out[]={ {-1, 0, ""} }; -static void rgb_tobw(float r, float g, float b, float* out) -{ - *out= r*0.35f + g*0.45f + b*0.2f; -} - static void fill_bins(bNode* node, CompBuf* in, int* bins) { float value[4]; @@ -66,7 +61,7 @@ static void fill_bins(bNode* node, CompBuf* in, int* bins) if (value[3] > 0.0f) { /* don't count transparent pixels */ switch (node->custom1) { case 1: { /* all colors */ - rgb_tobw(value[0], value[1], value[2], &value[0]); + value[0] = rgb_to_bw(value); value[0]=value[0]*255; /* scale to 0-255 range */ ivalue=(int)value[0]; break; @@ -125,7 +120,7 @@ static float brightness_mean(bNode* node, CompBuf* in) switch (node->custom1) { case 1: { - rgb_tobw(value[0], value[1], value[2], &value[0]); + value[0] = rgb_to_bw(value); sum+=value[0]; break; } @@ -176,7 +171,7 @@ static float brightness_standard_deviation(bNode* node, CompBuf* in, float mean) switch (node->custom1) { case 1: { - rgb_tobw(value[0], value[1], value[2], &value[0]); + value[0] = rgb_to_bw(value); sum+=(value[0]-mean)*(value[0]-mean); break; } @@ -296,10 +291,11 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack * mean=brightness_mean(node, in[0]->data); std_dev=brightness_standard_deviation(node, in[0]->data, mean); - /* Printf debuging ;) + /* Printf debuging ;) */ +#if 0 printf("Mean: %f\n", mean); printf("Std Dev: %f\n", std_dev); - */ +#endif if (out[0]->hasoutput) out[0]->vec[0]= mean; diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.c b/source/blender/nodes/composite/nodes/node_composite_mask.c index 91c3e9fbaf7..3cd3a732829 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mask.c +++ b/source/blender/nodes/composite/nodes/node_composite_mask.c @@ -70,7 +70,9 @@ static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack ** stackbuf = alloc_compbuf(sx, sy, CB_VAL, TRUE); res = stackbuf->rect; - BKE_mask_rasterize(mask, sx, sy, res, TRUE, node->custom1); + BKE_mask_rasterize(mask, sx, sy, res, TRUE, + (node->custom1 & CMP_NODEFLAG_MASK_AA) != 0, + (node->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); if (node->custom1) { PLX_antialias_buffer(res,sx,sy); diff --git a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c index bdf6b4f1635..429ba262164 100644 --- a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c @@ -111,7 +111,7 @@ static bNodeSocketTemplate cmp_node_rgbtobw_out[]= { static void do_rgbtobw(bNode *UNUSED(node), float *out, float *in) { - out[0]= in[0]*0.35f + in[1]*0.45f + in[2]*0.2f; + out[0] = rgb_to_bw(in); } static void node_composit_exec_rgbtobw(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c index b5400244efe..8b393dd740a 100644 --- a/source/blender/nodes/intern/node_socket.c +++ b/source/blender/nodes/intern/node_socket.c @@ -319,7 +319,7 @@ void node_socket_copy_default_value(int type, void *to_default_value, void *from * In the interface this could be implemented by a pseudo-script textbox on linked inputs, * with quick selection from a predefined list of conversion options. Some Examples: * - vector component 'z' (vector->float): "z" - * - greyscale color (float->color): "grey" + * - grayscale color (float->color): "gray" * - color luminance (color->float): "lum" * - matrix column 2 length (matrix->vector->float): "col[1].len" * - mesh vertex coordinate 'y' (mesh->vertex->vector->float): "vertex.co.y" diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c index 1738606082f..fb3316c2036 100644 --- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c @@ -104,7 +104,7 @@ static void node_shader_exec_rgbtobw(void *UNUSED(data), bNode *UNUSED(node), bN /* stack order out: bw */ /* stack order in: col */ - out[0]->vec[0]= in[0]->vec[0]*0.35f + in[0]->vec[1]*0.45f + in[0]->vec[2]*0.2f; + out[0]->vec[0] = rgb_to_bw(in[0]->vec); } static int gpu_shader_rgbtobw(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c index c84436a84b7..1a11a7075b8 100644 --- a/source/blender/nodes/texture/node_texture_tree.c +++ b/source/blender/nodes/texture/node_texture_tree.c @@ -282,7 +282,7 @@ int ntreeTexExecTree( if (texres->nor) retval |= TEX_NOR; retval |= TEX_RGB; /* confusing stuff; the texture output node sets this to NULL to indicate no normal socket was set - however, the texture code checks this for other reasons (namely, a normal is required for material) */ + * however, the texture code checks this for other reasons (namely, a normal is required for material) */ texres->nor= nor; return retval; diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c index 28d03db1687..53f1aa82f60 100644 --- a/source/blender/nodes/texture/node_texture_util.c +++ b/source/blender/nodes/texture/node_texture_util.c @@ -31,20 +31,20 @@ /* - HOW TEXTURE NODES WORK - - In contrast to Shader nodes, which place a color into the output - stack when executed, Texture nodes place a TexDelegate* there. To - obtain a color value from this, a node further up the chain reads - the TexDelegate* from its input stack, and uses tex_call_delegate to - retrieve the color from the delegate. - - comments: (ton) - - This system needs recode, a node system should rely on the stack, and - callbacks for nodes only should evaluate own node, not recursively go - over other previous ones. -*/ + * HOW TEXTURE NODES WORK + * + * In contrast to Shader nodes, which place a color into the output + * stack when executed, Texture nodes place a TexDelegate* there. To + * obtain a color value from this, a node further up the chain reads + * the TexDelegate* from its input stack, and uses tex_call_delegate to + * retrieve the color from the delegate. + * + * comments: (ton) + * + * This system needs recode, a node system should rely on the stack, and + * callbacks for nodes only should evaluate own node, not recursively go + * over other previous ones. + */ #include <assert.h> #include "node_texture_util.h" diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h index 0fe685996b1..7d8c4ce232c 100644 --- a/source/blender/nodes/texture/node_texture_util.h +++ b/source/blender/nodes/texture/node_texture_util.h @@ -97,7 +97,7 @@ typedef struct TexParams { int osatex; /* optional. we don't really want these here, but image - textures need to do mapping & color correction */ + * textures need to do mapping & color correction */ ShadeInput *shi; MTex *mtex; } TexParams; diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c index fe2082d1442..3b33383c73b 100644 --- a/source/blender/nodes/texture/nodes/node_texture_proc.c +++ b/source/blender/nodes/texture/nodes/node_texture_proc.c @@ -36,8 +36,8 @@ #include "RE_shader_ext.h" /* - In this file: wrappers to use procedural textures as nodes -*/ + * In this file: wrappers to use procedural textures as nodes + */ static bNodeSocketTemplate outputs_both[]= { diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c index d1a02210038..10db0debd5b 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c +++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c @@ -91,8 +91,7 @@ static void rgbtobw_valuefn(float *out, TexParams *p, bNode *UNUSED(node), bNode { float cin[4]; tex_input_rgba(cin, in[0], p, thread); - - *out = cin[0] * 0.35f + cin[1] * 0.45f + cin[2] * 0.2f; + *out = rgb_to_bw(cin); } static void rgbtobw_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/opencl/CMakeLists.txt b/source/blender/opencl/CMakeLists.txt index 9c8ce830316..20dcf33d363 100644 --- a/source/blender/opencl/CMakeLists.txt +++ b/source/blender/opencl/CMakeLists.txt @@ -28,11 +28,15 @@ set(INC . ) +set(INC_SYS + +) + set(SRC - OCL_opencl.h - intern/clew.h - intern/clew.c - intern/OCL_opencl.c + OCL_opencl.h + intern/clew.h + intern/clew.c + intern/OCL_opencl.c ) diff --git a/source/blender/python/bmesh/CMakeLists.txt b/source/blender/python/bmesh/CMakeLists.txt index 40bde7161b6..032a914fb70 100644 --- a/source/blender/python/bmesh/CMakeLists.txt +++ b/source/blender/python/bmesh/CMakeLists.txt @@ -33,6 +33,7 @@ set(INC_SYS set(SRC bmesh_py_api.c + bmesh_py_ops.c bmesh_py_types.c bmesh_py_types_customdata.c bmesh_py_types_meshdata.c @@ -40,6 +41,7 @@ set(SRC bmesh_py_utils.c bmesh_py_api.h + bmesh_py_ops.h bmesh_py_types.h bmesh_py_types_customdata.h bmesh_py_types_meshdata.h diff --git a/source/blender/python/bmesh/bmesh_py_api.c b/source/blender/python/bmesh/bmesh_py_api.c index 4d8d4e3bc23..f3e5b300ced 100644 --- a/source/blender/python/bmesh/bmesh_py_api.c +++ b/source/blender/python/bmesh/bmesh_py_api.c @@ -40,6 +40,7 @@ #include "bmesh_py_types_customdata.h" #include "bmesh_py_types_meshdata.h" +#include "bmesh_py_ops.h" #include "bmesh_py_utils.h" #include "BKE_tessmesh.h" @@ -72,7 +73,7 @@ PyDoc_STRVAR(bpy_bm_from_edit_mesh_doc, "\n" " Return a BMesh from this mesh, currently the mesh must already be in editmode.\n" "\n" -" :return: the BMesh assosiated with this mesh.\n" +" :return: the BMesh associated with this mesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n" ); static PyObject *bpy_bm_from_edit_mesh(PyObject *UNUSED(self), PyObject *value) @@ -143,6 +144,11 @@ PyObject *BPyInit_bmesh(void) PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule); Py_INCREF(submodule); + PyModule_AddObject(mod, "ops", (submodule = BPyInit_bmesh_ops())); + /* PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule); */ + PyDict_SetItemString(sys_modules, "bmesh.ops", submodule); /* fake module */ + Py_INCREF(submodule); + PyModule_AddObject(mod, "utils", (submodule = BPyInit_bmesh_utils())); PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule); Py_INCREF(submodule); diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c new file mode 100644 index 00000000000..53ddcecd7a8 --- /dev/null +++ b/source/blender/python/bmesh/bmesh_py_ops.c @@ -0,0 +1,543 @@ +/* + * ***** 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) 2012 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/bmesh/bmesh_py_ops.c + * \ingroup pybmesh + * + * This file defines the 'bmesh.ops' module. + * Operators from 'opdefines' are wrapped. + */ + +#include <Python.h> + +#include "BLI_utildefines.h" + +#include "MEM_guardedalloc.h" + +#include "../generic/py_capi_utils.h" + +#include "../mathutils/mathutils.h" + +#include "bmesh.h" + +#include "bmesh_py_types.h" + +#include "bmesh_py_utils.h" /* own include */ + +static int bpy_bm_op_as_py_error(BMesh *bm) +{ + if (BMO_error_occurred(bm)) { + const char *errmsg; + if (BMO_error_get(bm, &errmsg, NULL)) { + PyErr_Format(PyExc_RuntimeError, + "bmesh operator: %.200s", + errmsg); + return -1; + } + } + return 0; +} + +/* bmesh operator 'bmesh.ops.*' callable types + * ******************************************* */ +PyTypeObject bmesh_op_Type; + +typedef struct { + PyObject_HEAD /* required python macro */ + const char *opname; +} BPy_BMeshOpFunc; + +PyObject *bpy_bmesh_op_CreatePyObject(const char *opname) +{ + BPy_BMeshOpFunc *self = PyObject_New(BPy_BMeshOpFunc, &bmesh_op_Type); + + self->opname = opname; + + return (PyObject *)self; +} + +static PyObject *bpy_bmesh_op_repr(BPy_BMeshOpFunc *self) +{ + return PyUnicode_FromFormat("<%.200s bmesh.ops.%.200s()>", + Py_TYPE(self)->tp_name, + self->opname); +} + + +static PyObject *pyrna_op_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw) +{ + BPy_BMesh *py_bm; + BMesh *bm; + + BMOperator bmop; + + if ((PyTuple_GET_SIZE(args) == 1) && + (py_bm = (BPy_BMesh *)PyTuple_GET_ITEM(args, 0)) && + (BPy_BMesh_Check(py_bm)) + ) + { + BPY_BM_CHECK_OBJ(py_bm); + bm = py_bm->bm; + } + else { + PyErr_SetString(PyExc_TypeError, + "calling a bmesh operator expects a single BMesh (non keyword) " + "as the first argument"); + return NULL; + } + + /* TODO - error check this!, though we do the error check on attribute access */ + BMO_op_init(bm, &bmop, self->opname); + + if (kw && PyDict_Size(kw) > 0) { + /* setup properties, see bpy_rna.c: pyrna_py_to_prop() + * which shares this logic for parsing properties */ + + PyObject *key, *value; + Py_ssize_t pos = 0; + while (PyDict_Next(kw, &pos, &key, &value)) { + const char *slot_name = _PyUnicode_AsString(key); + BMOpSlot *slot = BMO_slot_get(&bmop, slot_name); + + if (slot == NULL) { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" is invalid for this operator", + self->opname, slot_name); + return NULL; + } + + /* now assign the value */ + switch (slot->slot_type) { + case BMO_OP_SLOT_BOOL: + { + int param; + + param = PyLong_AsLong(value); + + if (param < 0) { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" expected True/False or 0/1, not %.200s", + self->opname, slot_name, Py_TYPE(value)->tp_name); + return NULL; + } + else { + slot->data.i = param; + } + + break; + } + 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) ")", + self->opname, slot_name, Py_TYPE(value)->tp_name); + return NULL; + } + else if (param == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" expected an int, not %.200s", + self->opname, slot_name, Py_TYPE(value)->tp_name); + return NULL; + } + else { + slot->data.i = (int)param; + } + break; + } + case BMO_OP_SLOT_FLT: + { + float param = PyFloat_AsDouble(value); + if (param == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" expected a float, not %.200s", + self->opname, slot_name, Py_TYPE(value)->tp_name); + return NULL; + } + else { + slot->data.f = param; + } + break; + } + case BMO_OP_SLOT_MAT: + { + /* 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", + self->opname, slot_name, Py_TYPE(value)->tp_name); + return NULL; + } + else if (BaseMath_ReadCallback((MatrixObject *)value) == -1) { + return NULL; + } + else if (((size = ((MatrixObject *)value)->num_col) != ((MatrixObject *)value)->num_row) || + (ELEM(size, 3, 4) == FALSE)) + { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" expected a 3x3 or 4x4 matrix Matrix", + self->opname, slot_name); + return NULL; + } + + BMO_slot_mat_set(&bmop, slot_name, ((MatrixObject *)value)->matrix, size); + break; + } + case BMO_OP_SLOT_VEC: + { + /* passing slot name here is a bit non-descriptive */ + if (mathutils_array_parse(slot->data.vec, 3, 3, value, slot_name) == -1) { + return NULL; + } + break; + } + case BMO_OP_SLOT_ELEMENT_BUF: + { + /* there are many ways we could interpret arguments, for now... + * - verts/edges/faces from the mesh direct, + * this way the operator takes every item. + * - `TODO` a plain python sequence (list) of elements. + * - `TODO` an iterator. eg. + * face.verts + * - `TODO` (type, flag) pair, eg. + * ('VERT', {'TAG'}) + */ + +#define BPY_BM_GENERIC_MESH_TEST(type_string) \ + if (((BPy_BMGeneric *)value)->bm != bm) { \ + PyErr_Format(PyExc_NotImplementedError, \ + "%.200s: keyword \"%.200s\" " type_string " are from another bmesh", \ + self->opname, slot_name, slot->slot_type); \ + return NULL; \ + } (void)0 + + if (BPy_BMVertSeq_Check(value)) { + BPY_BM_GENERIC_MESH_TEST("verts"); + BMO_slot_buffer_from_all(bm, &bmop, slot_name, BM_VERT); + } + else if (BPy_BMEdgeSeq_Check(value)) { + BPY_BM_GENERIC_MESH_TEST("edges"); + BMO_slot_buffer_from_all(bm, &bmop, slot_name, BM_EDGE); + } + else if (BPy_BMFaceSeq_Check(value)) { + BPY_BM_GENERIC_MESH_TEST("faces"); + BMO_slot_buffer_from_all(bm, &bmop, slot_name, BM_FACE); + } + else if (BPy_BMElemSeq_Check(value)) { + BMIter iter; + BMHeader *ele; + int tot; + unsigned int i; + + BPY_BM_GENERIC_MESH_TEST("elements"); + + /* this will loop over all elements which is a shame but + * we need to know this before alloc */ + /* calls bpy_bmelemseq_length() */ + tot = Py_TYPE(value)->tp_as_sequence->sq_length((PyObject *)self); + + BMO_slot_buffer_alloc(&bmop, slot_name, tot); + + i = 0; + BM_ITER_BPY_BM_SEQ (ele, &iter, ((BPy_BMElemSeq *)value)) { + ((void **)slot->data.buf)[i] = (void *)ele; + i++; + } + } + /* keep this last */ + else if (PySequence_Check(value)) { + BMElem **elem_array = NULL; + Py_ssize_t elem_array_len; + + elem_array = BPy_BMElem_PySeq_As_Array(&bm, value, 0, PY_SSIZE_T_MAX, + &elem_array_len, BM_VERT | BM_EDGE | BM_FACE, + TRUE, TRUE, slot_name); + + /* error is set above */ + if (elem_array == NULL) { + return NULL; + } + + BMO_slot_buffer_alloc(&bmop, slot_name, elem_array_len); + memcpy(slot->data.buf, elem_array, sizeof(void *) * elem_array_len); + PyMem_FREE(elem_array); + } + else { + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" expected " + "a bmesh sequence, list, (htype, flag) pair, not %.200s", + self->opname, slot_name, Py_TYPE(value)->tp_name); + return NULL; + } + +#undef BPY_BM_GENERIC_MESH_TEST + + break; + } + default: + /* TODO --- many others */ + PyErr_Format(PyExc_NotImplementedError, + "%.200s: keyword \"%.200s\" type %d not working yet!", + self->opname, slot_name, slot->slot_type); + return NULL; + break; + } + } + } + + BMO_op_exec(bm, &bmop); + BMO_op_finish(bm, &bmop); + + if (bpy_bm_op_as_py_error(bm) == -1) { + return NULL; + } + + Py_RETURN_NONE; +} + + +PyTypeObject bmesh_op_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "BMeshOpFunc", /* tp_name */ + sizeof(BPy_BMeshOpFunc), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + NULL, /* tp_dealloc */ + NULL, /* printfunc tp_print; */ + NULL, /* getattrfunc tp_getattr; */ + NULL, /* setattrfunc tp_setattr; */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + (reprfunc) bpy_bmesh_op_repr, /* tp_repr */ + + /* Method suites for standard classes */ + + NULL, /* PyNumberMethods *tp_as_number; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ + + /* More standard operations (here for binary compatibility) */ + + NULL, /* hashfunc tp_hash; */ + (ternaryfunc)pyrna_op_call, /* ternaryfunc tp_call; */ + NULL, /* reprfunc tp_str; */ + + /* will only use these if this is a subtype of a py class */ + NULL, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ + + /* Functions to access object as input/output buffer */ + NULL, /* PyBufferProcs *tp_as_buffer; */ + + /*** Flags to define presence of optional/expanded features ***/ + Py_TPFLAGS_DEFAULT, /* long tp_flags; */ + + NULL, /* char *tp_doc; Documentation string */ + /*** Assigned meaning in release 2.0 ***/ + /* call function for all accessible objects */ + NULL, /* traverseproc tp_traverse; */ + + /* delete references to contained objects */ + NULL, /* inquiry tp_clear; */ + + /*** Assigned meaning in release 2.1 ***/ + /*** rich comparisons ***/ + NULL, /* richcmpfunc tp_richcompare; */ + + /*** weak reference enabler ***/ + 0, + /*** Added in release 2.2 ***/ + /* Iterators */ + NULL, /* getiterfunc tp_iter; */ + NULL, /* iternextfunc tp_iternext; */ + + /*** Attribute descriptor and subclassing stuff ***/ + NULL, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMemberDef *tp_members; */ + NULL, /* struct PyGetSetDef *tp_getset; */ + NULL, /* struct _typeobject *tp_base; */ + NULL, /* PyObject *tp_dict; */ + NULL, /* descrgetfunc tp_descr_get; */ + NULL, /* descrsetfunc tp_descr_set; */ + 0, /* long tp_dictoffset; */ + NULL, /* initproc tp_init; */ + NULL, /* allocfunc tp_alloc; */ + NULL, /* newfunc tp_new; */ + /* Low-level free-memory routine */ + NULL, /* freefunc tp_free; */ + /* For PyObject_IS_GC */ + NULL, /* inquiry tp_is_gc; */ + NULL, /* PyObject *tp_bases; */ + /* method resolution order */ + NULL, /* PyObject *tp_mro; */ + NULL, /* PyObject *tp_cache; */ + NULL, /* PyObject *tp_subclasses; */ + NULL, /* PyObject *tp_weaklist; */ + NULL +}; + + +/* bmesh fake module 'bmesh.ops' + * ***************************** */ + +static PyObject *bpy_bmesh_fmod_getattro(PyObject *UNUSED(self), PyObject *pyname) +{ + const unsigned int tot = bmesh_total_ops; + unsigned int i; + const char *name = _PyUnicode_AsString(pyname); + + for (i = 0; i < tot; i++) { + if (strcmp(opdefines[i]->name, name) == 0) { + return bpy_bmesh_op_CreatePyObject(opdefines[i]->name); + } + } + + PyErr_Format(PyExc_AttributeError, + "BMeshOpsModule: , operator \"%.200s\" doesn't exist", + name); + return NULL; +} + +static PyObject *bpy_bmesh_fmod_dir(PyObject *UNUSED(self)) +{ + const unsigned int tot = bmesh_total_ops; + unsigned int i; + PyObject *ret; + + ret = PyList_New(bmesh_total_ops); + + for (i = 0; i < tot; i++) { + PyList_SET_ITEM(ret, i, PyUnicode_FromString(opdefines[i]->name)); + } + + return ret; +} + +static struct PyMethodDef bpy_bmesh_fmod_methods[] = { + {"__dir__", (PyCFunction)bpy_bmesh_fmod_dir, METH_NOARGS, NULL}, + {NULL, NULL, 0, NULL} +}; + +static PyTypeObject bmesh_ops_fakemod_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "BMeshOpsModule", /* tp_name */ + 0, /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + NULL, /* tp_dealloc */ + NULL, /* printfunc tp_print; */ + NULL, /* getattrfunc tp_getattr; */ + NULL, /* setattrfunc tp_setattr; */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + NULL, /* tp_repr */ + + /* Method suites for standard classes */ + + NULL, /* PyNumberMethods *tp_as_number; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ + + /* More standard operations (here for binary compatibility) */ + + NULL, /* hashfunc tp_hash; */ + NULL, /* ternaryfunc tp_call; */ + NULL, /* reprfunc tp_str; */ + + /* will only use these if this is a subtype of a py class */ + bpy_bmesh_fmod_getattro, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ + + /* Functions to access object as input/output buffer */ + NULL, /* PyBufferProcs *tp_as_buffer; */ + + /*** Flags to define presence of optional/expanded features ***/ + Py_TPFLAGS_DEFAULT, /* long tp_flags; */ + + NULL, /* char *tp_doc; Documentation string */ + /*** Assigned meaning in release 2.0 ***/ + /* call function for all accessible objects */ + NULL, /* traverseproc tp_traverse; */ + + /* delete references to contained objects */ + NULL, /* inquiry tp_clear; */ + + /*** Assigned meaning in release 2.1 ***/ + /*** rich comparisons ***/ + NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */ + + /*** weak reference enabler ***/ + 0, + /*** Added in release 2.2 ***/ + /* Iterators */ + NULL, /* getiterfunc tp_iter; */ + NULL, /* iternextfunc tp_iternext; */ + + /*** Attribute descriptor and subclassing stuff ***/ + bpy_bmesh_fmod_methods, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMemberDef *tp_members; */ + NULL, /* struct PyGetSetDef *tp_getset; */ + NULL, /* struct _typeobject *tp_base; */ + NULL, /* PyObject *tp_dict; */ + NULL, /* descrgetfunc tp_descr_get; */ + NULL, /* descrsetfunc tp_descr_set; */ + 0, /* long tp_dictoffset; */ + NULL, /* initproc tp_init; */ + NULL, /* allocfunc tp_alloc; */ + NULL, /* newfunc tp_new; */ + /* Low-level free-memory routine */ + NULL, /* freefunc tp_free; */ + /* For PyObject_IS_GC */ + NULL, /* inquiry tp_is_gc; */ + NULL, /* PyObject *tp_bases; */ + /* method resolution order */ + NULL, /* PyObject *tp_mro; */ + NULL, /* PyObject *tp_cache; */ + NULL, /* PyObject *tp_subclasses; */ + NULL, /* PyObject *tp_weaklist; */ + NULL +}; + +PyObject *BPyInit_bmesh_ops(void) +{ + PyObject *submodule; + + if (PyType_Ready(&bmesh_ops_fakemod_Type) < 0) + return NULL; + + if (PyType_Ready(&bmesh_op_Type) < 0) + return NULL; + + submodule = PyObject_New(PyObject, &bmesh_ops_fakemod_Type); + + /* prevent further creation of instances */ + bmesh_ops_fakemod_Type.tp_init = NULL; + bmesh_ops_fakemod_Type.tp_new = NULL; + + return submodule; +} diff --git a/source/blender/python/bmesh/bmesh_py_ops.h b/source/blender/python/bmesh/bmesh_py_ops.h new file mode 100644 index 00000000000..56c980b57ea --- /dev/null +++ b/source/blender/python/bmesh/bmesh_py_ops.h @@ -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. + * + * The Original Code is Copyright (C) 2012 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/python/bmesh/bmesh_py_ops.h + * \ingroup pybmesh + */ + +#ifndef __BMESH_PY_OPS_H__ +#define __BMESH_PY_OPS_H__ + +PyObject *BPyInit_bmesh_ops(void); + +#endif /* __BMESH_PY_OPS_H__ */ diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index 053dac71fe6..f7a7d379ba4 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -1024,7 +1024,7 @@ PyDoc_STRVAR(bpy_bm_elem_select_set_doc, ".. method:: select_set(select)\n" "\n" " Set the selection.\n" -" This is different from the *select* attribute because it updates the selection state of assosiated geometry.\n" +" This is different from the *select* attribute because it updates the selection state of associated geometry.\n" "\n" " :arg select: Select or de-select.\n" " :type select: boolean\n" @@ -1057,7 +1057,7 @@ PyDoc_STRVAR(bpy_bm_elem_hide_set_doc, ".. method:: hide_set(hide)\n" "\n" " Set the hide state.\n" -" This is different from the *hide* attribute because it updates the selection and hide state of assosiated geometry.\n" +" This is different from the *hide* attribute because it updates the selection and hide state of associated geometry.\n" "\n" " :arg hide: Hidden or visible.\n" " :type hide: boolean\n" diff --git a/source/blender/python/bmesh/bmesh_py_types.h b/source/blender/python/bmesh/bmesh_py_types.h index 85bbd5d7b09..947e66bf24e 100644 --- a/source/blender/python/bmesh/bmesh_py_types.h +++ b/source/blender/python/bmesh/bmesh_py_types.h @@ -186,4 +186,13 @@ char *BPy_BMElem_StringFromHType(const char htype); ele; \ ele = BM_iter_step(iter)) + +#ifdef __PY_CAPI_UTILS_H__ +struct PyC_FlagSet; +extern struct PyC_FlagSet bpy_bm_scene_vert_edge_face_flags[]; +extern struct PyC_FlagSet bpy_bm_htype_vert_edge_face_flags[]; +extern struct PyC_FlagSet bpy_bm_htype_all_flags[]; +extern struct PyC_FlagSet bpy_bm_hflag_all_flags[]; +#endif + #endif /* __BMESH_TYPES_H__ */ diff --git a/source/blender/python/bmesh/bmesh_py_utils.c b/source/blender/python/bmesh/bmesh_py_utils.c index 374a01c51f8..4417bc2ce8d 100644 --- a/source/blender/python/bmesh/bmesh_py_utils.c +++ b/source/blender/python/bmesh/bmesh_py_utils.c @@ -370,7 +370,7 @@ static PyObject *bpy_bm_utils_edge_rotate(PyObject *UNUSED(self), PyObject *args PyDoc_STRVAR(bpy_bm_utils_face_split_doc, ".. method:: face_split(face, vert_a, vert_b, coords=(), use_exist=True, example=None)\n" "\n" -" Split an edge, return the newly created data.\n" +" Face split with optional intermediate points.\n" "\n" " :arg face: The face to cut.\n" " :type face: :class:`bmesh.types.BMFace`\n" @@ -457,6 +457,7 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args, py_vert_a->v, py_vert_b->v, (float (*)[3])coords, ncoords, &l_new, py_edge_example ? py_edge_example->e : NULL); + PyMem_Free(coords); } else { f_new = BM_face_split(bm, py_face->f, @@ -667,13 +668,13 @@ static struct PyMethodDef BPy_BM_utils_methods[] = { }; -PyDoc_STRVAR(BPy_BM_doc, +PyDoc_STRVAR(BPy_BM_utils_doc, "This module provides access to blenders bmesh data structures." ); -static struct PyModuleDef BPy_BM_types_module_def = { +static struct PyModuleDef BPy_BM_utils_module_def = { PyModuleDef_HEAD_INIT, "bmesh.utils", /* m_name */ - BPy_BM_doc, /* m_doc */ + BPy_BM_utils_doc, /* m_doc */ 0, /* m_size */ BPy_BM_utils_methods, /* m_methods */ NULL, /* m_reload */ @@ -687,7 +688,7 @@ PyObject *BPyInit_bmesh_utils(void) { PyObject *submodule; - submodule = PyModule_Create(&BPy_BM_types_module_def); + submodule = PyModule_Create(&BPy_BM_utils_module_def); return submodule; } diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index 5999040a2ab..3a46c6971cf 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -52,6 +52,7 @@ #include "BKE_main.h" static Main *bpy_import_main = NULL; +static ListBase bpy_import_main_list; /* 'builtins' is most likely PyEval_GetBuiltins() */ void bpy_import_init(PyObject *builtins) @@ -92,6 +93,16 @@ void bpy_import_main_set(struct Main *maggie) bpy_import_main = maggie; } +void bpy_import_main_extra_add(struct Main *maggie) +{ + BLI_addhead(&bpy_import_main_list, maggie); +} + +void bpy_import_main_extra_remove(struct Main *maggie) +{ + BLI_remlink_safe(&bpy_import_main_list, maggie); +} + /* returns a dummy filename for a textblock so we can tell what file a text block comes from */ void bpy_text_filename_get(char *fn, size_t fn_len, Text *text) { @@ -150,6 +161,18 @@ PyObject *bpy_text_import_name(const char *name, int *found) text = BLI_findstring(&maggie->text, txtname, offsetof(ID, name) + 2); + if (text) { + *found = 1; + return bpy_text_import(text); + } + + /* If we still haven't found the module try additional modules form bpy_import_main_list */ + maggie = bpy_import_main_list.first; + while (maggie && !text) { + text = BLI_findstring(&maggie->text, txtname, offsetof(ID, name) + 2); + maggie = maggie->next; + } + if (!text) return NULL; else diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h index 8b41a575d96..980e6edca03 100644 --- a/source/blender/python/generic/bpy_internal_import.h +++ b/source/blender/python/generic/bpy_internal_import.h @@ -62,4 +62,8 @@ extern PyMethodDef bpy_reload_meth; struct Main *bpy_import_main_get(void); void bpy_import_main_set(struct Main *maggie); +/* This is used for importing text from dynamically loaded libraries in the game engine */ +void bpy_import_main_extra_add(struct Main *maggie); +void bpy_import_main_extra_remove(struct Main *maggie); + #endif /* __BPY_INTERNAL_IMPORT_H__ */ diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 10562271941..7375ad454a0 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -147,6 +147,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) /* note that context is an int, python does the conversion in this case */ int context = WM_OP_EXEC_DEFAULT; + int is_undo = FALSE; /* XXX Todo, work out a better solution for passing on context, * could make a tuple from self and pack the name and Context into it... */ @@ -157,7 +158,8 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) return NULL; } - if (!PyArg_ParseTuple(args, "sO|O!s:_bpy.ops.call", &opname, &context_dict, &PyDict_Type, &kw, &context_str)) + if (!PyArg_ParseTuple(args, "sO|O!si:_bpy.ops.call", + &opname, &context_dict, &PyDict_Type, &kw, &context_str, &is_undo)) return NULL; ot = WM_operatortype_find(opname, TRUE); @@ -236,7 +238,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) PyThreadState *ts = PyEval_SaveThread(); #endif - operator_ret = WM_operator_call_py(C, ot, context, &ptr, reports); + operator_ret = WM_operator_call_py(C, ot, context, &ptr, reports, is_undo); #ifdef BPY_RELEASE_GIL /* regain GIL */ diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 04f9a90f0d2..4bba7ba6838 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -873,7 +873,7 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self) if (path) { if (GS(id->name) == ID_NT) { /* nodetree paths are not accurate */ ret = PyUnicode_FromFormat("bpy.data...%s", - path); + path); } else { ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s", @@ -980,7 +980,7 @@ static PyObject *pyrna_prop_repr(BPy_PropertyRNA *self) if (path) { if (GS(id->name) == ID_NT) { /* nodetree paths are not accurate */ ret = PyUnicode_FromFormat("bpy.data...%s", - path); + path); } else { ret = PyUnicode_FromFormat("bpy.data.%s[%R].%s", @@ -2040,12 +2040,12 @@ static int pyrna_prop_collection_bool(BPy_PropertyRNA *self) * This is done for faster lookups. */ #define PYRNA_PROP_COLLECTION_ABS_INDEX(ret_err) \ if (keynum < 0) { \ - keynum_abs += RNA_property_collection_length(&self->ptr, self->prop); \ - if (keynum_abs < 0) { \ - PyErr_Format(PyExc_IndexError, \ - "bpy_prop_collection[%d]: out of range.", keynum); \ - return ret_err; \ - } \ + keynum_abs += RNA_property_collection_length(&self->ptr, self->prop); \ + if (keynum_abs < 0) { \ + PyErr_Format(PyExc_IndexError, \ + "bpy_prop_collection[%d]: out of range.", keynum); \ + return ret_err; \ + } \ } (void)0 @@ -3508,8 +3508,8 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) PyList_Append(ret, linkptr); Py_DECREF(linkptr); } + break; } - break; default: /* should never happen */ BLI_assert(!"Invalid context type"); diff --git a/source/blender/python/intern/stubs.c b/source/blender/python/intern/stubs.c index ab43b518085..50d2e88f210 100644 --- a/source/blender/python/intern/stubs.c +++ b/source/blender/python/intern/stubs.c @@ -35,5 +35,5 @@ //void BPY_text_free_code(void) {} void BPY_pyconstraint_exec(void) {} void BPY_pyconstraint_target(void) {} -int BPY_is_pyconstraint(void) {return 0;} +int BPY_is_pyconstraint(void) { return 0;} void BPY_pyconstraint_update(void) {} diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index 8b79301f264..c08165f9850 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -133,6 +133,7 @@ int mathutils_array_parse(float *array, int array_min, int array_max, PyObject * } } +/* on error, -1 is returned and no allocation is made */ int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, const char *error_prefix) { int size; @@ -164,6 +165,7 @@ int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, c { PyObject *value_fast = NULL; // *array = NULL; + int ret; /* non list/tuple cases */ if (!(value_fast = PySequence_Fast(value, error_prefix))) { @@ -182,7 +184,13 @@ int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, c *array = PyMem_Malloc(size * sizeof(float)); - return mathutils_array_parse_fast(*array, size, value_fast, error_prefix); + ret = mathutils_array_parse_fast(*array, size, value_fast, error_prefix); + + if (ret == -1) { + PyMem_Free(*array); + } + + return ret; } } diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 5c4c6414f39..5f372abcc69 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -1640,7 +1640,7 @@ static PyObject *Matrix_richcmpr(PyObject *a, PyObject *b, int op) * sequence length */ static int Matrix_len(MatrixObject *self) { - return (self->num_row); + return self->num_row; } /*----------------------------object[]--------------------------- * sequence accessor (get) diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index 8fb3a3f74d6..79285b7778d 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -54,11 +54,18 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v /* 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 *UNUSED(kwds)) +static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { float *vec = NULL; int size = 3; /* default to a 3D vector */ + if (kwds && PyDict_Size(kwds)) { + PyErr_SetString(PyExc_TypeError, + "Vector(): " + "takes no keyword args"); + return NULL; + } + switch (PyTuple_GET_SIZE(args)) { case 0: vec = PyMem_Malloc(size * sizeof(float)); @@ -74,9 +81,6 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED break; case 1: if ((size = mathutils_array_parse_alloc(&vec, 2, PyTuple_GET_ITEM(args, 0), "mathutils.Vector()")) == -1) { - if (vec) { - PyMem_Free(vec); - } return NULL; } break; @@ -86,7 +90,7 @@ static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *UNUSED "more then a single arg given"); return NULL; } - return Vector_CreatePyObject(vec, size, Py_NEW, type); + return Vector_CreatePyObject_alloc(vec, size, type); } static PyObject *vec__apply_to_copy(PyNoArgsFunction vec_func, VectorObject *self) @@ -294,7 +298,6 @@ static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) if ((value_size = mathutils_array_parse_alloc(&iter_vec, 2, value, "Vector.Repeat(vector, size), invalid 'vector' arg")) == -1) { - PyMem_Free(iter_vec); return NULL; } @@ -308,6 +311,7 @@ static PyObject *C_Vector_Repeat(PyObject *cls, PyObject *args) vec = PyMem_Malloc(size * sizeof(float)); if (vec == NULL) { + PyMem_Free(iter_vec); PyErr_SetString(PyExc_MemoryError, "Vector.Repeat(): " "problem allocating pointer space"); @@ -891,19 +895,18 @@ PyDoc_STRVAR(Vector_dot_doc, static PyObject *Vector_dot(VectorObject *self, PyObject *value) { float *tvec; + PyObject *ret; if (BaseMath_ReadCallback(self) == -1) return NULL; if (mathutils_array_parse_alloc(&tvec, self->size, value, "Vector.dot(other), invalid 'other' arg") == -1) { - goto cleanup; + return NULL; } - return PyFloat_FromDouble(dot_vn_vn(self->vec, tvec, self->size)); - -cleanup: + ret = PyFloat_FromDouble(dot_vn_vn(self->vec, tvec, self->size)); PyMem_Free(tvec); - return NULL; + return ret; } PyDoc_STRVAR(Vector_angle_doc, @@ -1133,12 +1136,12 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "Of:lerp", &value, &fac)) return NULL; - if (mathutils_array_parse_alloc(&tvec, size, value, "Vector.lerp(other), invalid 'other' arg") == -1) { - goto cleanup; + if (BaseMath_ReadCallback(self) == -1) { + return NULL; } - if (BaseMath_ReadCallback(self) == -1) { - goto cleanup; + if (mathutils_array_parse_alloc(&tvec, size, value, "Vector.lerp(other), invalid 'other' arg") == -1) { + return NULL; } vec = PyMem_Malloc(size * sizeof(float)); @@ -1158,10 +1161,6 @@ static PyObject *Vector_lerp(VectorObject *self, PyObject *args) PyMem_Free(tvec); return Vector_CreatePyObject_alloc(vec, size, Py_TYPE(self)); - -cleanup: - PyMem_Free(tvec); - return NULL; } PyDoc_STRVAR(Vector_rotate_doc, @@ -1363,7 +1362,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se size = (end - begin); if (mathutils_array_parse_alloc(&vec, size, seq, "vector[begin:end] = [...]") == -1) { - goto cleanup; + return -1; } if (vec == NULL) { @@ -1376,16 +1375,12 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se /*parsed well - now set in vector*/ memcpy(self->vec + begin, vec, size * sizeof(float)); + PyMem_Free(vec); + if (BaseMath_WriteCallback(self) == -1) return -1; - PyMem_Free(vec); - return 0; - -cleanup: - PyMem_Free(vec); - return -1; } /* Numeric Protocols */ diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 4d05b837952..524515ac460 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -944,6 +944,109 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje return Vector_CreatePyObject(vec, 3, Py_NEW, NULL); } +PyDoc_STRVAR(M_Geometry_points_in_planes_doc, +".. function:: points_in_planes(planes)\n" +"\n" +" Returns a list of points inside all planes given and a list of index values for the planes used.\n" +"\n" +" :arg planes: List of planes (4D vectors).\n" +" :type planes: list of :class:`mathutils.Vector`\n" +" :return: two lists, once containing the vertices inside the planes, another containing the plane indicies used\n" +" :rtype: pair of lists\n" +); +/* note: this function could be optimized by some spatial structure */ +static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *args) +{ + PyObject *py_planes; + float (*planes)[4]; + unsigned int planes_len; + + if (!PyArg_ParseTuple(args, "O:points_in_planes", + &py_planes)) + { + return NULL; + } + + if ((planes_len = mathutils_array_parse_alloc_v((float **)&planes, 4, py_planes, "points_in_planes")) == -1) { + return NULL; + } + else { + /* note, this could be refactored into plain C easy - py bits are noted */ + const float eps = 0.0001f; + const unsigned int len = (unsigned int)planes_len; + unsigned int i, j, k, l; + + float n1n2[3], n2n3[3], n3n1[3]; + float potentialVertex[3]; + char *planes_used = MEM_callocN(sizeof(char) * len, __func__); + + /* python */ + PyObject *py_verts = PyList_New(0); + PyObject *py_plene_index = PyList_New(0); + + for (i = 0; i < len; i++) { + const float *N1 = planes[i]; + for (j = i + 1; j < len; j++) { + const float *N2 = planes[j]; + cross_v3_v3v3(n1n2, N1, N2); + if (len_squared_v3(n1n2) > eps) { + for (k = j + 1; k < len; k++) { + const float *N3 = planes[k]; + cross_v3_v3v3(n2n3, N2, N3); + if (len_squared_v3(n2n3) > eps) { + cross_v3_v3v3(n3n1, N3, N1); + if (len_squared_v3(n3n1) > eps) { + const float quotient = dot_v3v3(N1, n2n3); + if (fabsf(quotient) > eps) { + /* potentialVertex = (n2n3 * N1[3] + n3n1 * N2[3] + n1n2 * N3[3]) * (-1.0 / quotient); */ + const float quotient_ninv = -1.0f / quotient; + potentialVertex[0] = ((n2n3[0] * N1[3]) + (n3n1[0] * N2[3]) + (n1n2[0] * N3[3])) * quotient_ninv; + potentialVertex[1] = ((n2n3[1] * N1[3]) + (n3n1[1] * N2[3]) + (n1n2[1] * N3[3])) * quotient_ninv; + potentialVertex[2] = ((n2n3[2] * N1[3]) + (n3n1[2] * N2[3]) + (n1n2[2] * N3[3])) * quotient_ninv; + for (l = 0; l < len; l++) { + const float *NP = planes[l]; + if ((dot_v3v3(NP, potentialVertex) + NP[3]) > 0.000001f) { + break; + } + } + + if (l == len) { /* ok */ + /* python */ + PyObject *item = Vector_CreatePyObject(potentialVertex, 3, Py_NEW, NULL); + PyList_Append(py_verts, item); + Py_DECREF(item); + + planes_used[i] = planes_used[j] = planes_used[k] = TRUE; + } + } + } + } + } + } + } + } + + PyMem_Free(planes); + + /* now make a list of used planes */ + for (i = 0; i < len; i++) { + if (planes_used[i]) { + PyObject *item = PyLong_FromLong(i); + PyList_Append(py_plene_index, item); + Py_DECREF(item); + } + } + MEM_freeN(planes_used); + + { + PyObject *ret = PyTuple_New(2); + PyTuple_SET_ITEM(ret, 0, py_verts); + PyTuple_SET_ITEM(ret, 1, py_plene_index); + return ret; + } + } +} + #ifndef MATH_STANDALONE PyDoc_STRVAR(M_Geometry_interpolate_bezier_doc, @@ -1279,6 +1382,7 @@ static PyMethodDef M_Geometry_methods[] = { {"area_tri", (PyCFunction) M_Geometry_area_tri, METH_VARARGS, M_Geometry_area_tri_doc}, {"normal", (PyCFunction) M_Geometry_normal, METH_VARARGS, M_Geometry_normal_doc}, {"barycentric_transform", (PyCFunction) M_Geometry_barycentric_transform, METH_VARARGS, M_Geometry_barycentric_transform_doc}, + {"points_in_planes", (PyCFunction) M_Geometry_points_in_planes, METH_VARARGS, M_Geometry_points_in_planes_doc}, #ifndef MATH_STANDALONE {"interpolate_bezier", (PyCFunction) M_Geometry_interpolate_bezier, METH_VARARGS, M_Geometry_interpolate_bezier_doc}, {"tessellate_polygon", (PyCFunction) M_Geometry_tessellate_polygon, METH_O, M_Geometry_tessellate_polygon_doc}, diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 2a3c8e60638..4e33e4d7e2d 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -154,6 +154,7 @@ typedef struct RenderStats { /* calling a new render with same name, frees automatic existing render */ struct Render *RE_NewRender (const char *name); struct Render *RE_GetRender(const char *name); +struct Render *RE_GetRender_FromData(const struct RenderData *rd); /* returns 1 while render is working (or renders called from within render) */ int RE_RenderInProgress(struct Render *re); diff --git a/source/blender/render/intern/raytrace/bvh.h b/source/blender/render/intern/raytrace/bvh.h index fab0bb94618..9318e1758a6 100644 --- a/source/blender/render/intern/raytrace/bvh.h +++ b/source/blender/render/intern/raytrace/bvh.h @@ -75,7 +75,7 @@ inline int test_bb_group4(__m128 *bb_group, const Isect *isec) * Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe * [http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9] */ -static int rayobject_bb_intersect_test(const Isect *isec, const float *_bb) +static inline int rayobject_bb_intersect_test(const Isect *isec, const float *_bb) { const float *bb = _bb; diff --git a/source/blender/render/intern/raytrace/rayobject_instance.cpp b/source/blender/render/intern/raytrace/rayobject_instance.cpp index 92a412103ba..bfbc1c64133 100644 --- a/source/blender/render/intern/raytrace/rayobject_instance.cpp +++ b/source/blender/render/intern/raytrace/rayobject_instance.cpp @@ -77,32 +77,32 @@ typedef struct InstanceRayObject { RayObject *RE_rayobject_instance_create(RayObject *target, float transform[][4], void *ob, void *target_ob) { - InstanceRayObject *obj= (InstanceRayObject*)MEM_callocN(sizeof(InstanceRayObject), "InstanceRayObject"); - assert( RE_rayobject_isAligned(obj) ); /* RayObject API assumes real data to be 4-byte aligned */ - + InstanceRayObject *obj = (InstanceRayObject *)MEM_callocN(sizeof(InstanceRayObject), "InstanceRayObject"); + assert(RE_rayobject_isAligned(obj) ); /* RayObject API assumes real data to be 4-byte aligned */ + obj->rayobj.api = &instance_api; obj->target = target; obj->ob = ob; obj->target_ob = target_ob; - + copy_m4_m4(obj->target2global, transform); invert_m4_m4(obj->global2target, obj->target2global); - - return RE_rayobject_unalignRayAPI((RayObject*) obj); + + return RE_rayobject_unalignRayAPI((RayObject *) obj); } static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec) { - InstanceRayObject *obj = (InstanceRayObject*)o; + InstanceRayObject *obj = (InstanceRayObject *)o; float start[3], dir[3], idot_axis[3], dist; int changed = 0, i, res; - + // TODO - this is disabling self intersection on instances if (isec->orig.ob == obj->ob && obj->ob) { changed = 1; isec->orig.ob = obj->target_ob; } - + // backup old values copy_v3_v3(start, isec->start); copy_v3_v3(dir, isec->dir); @@ -113,16 +113,16 @@ static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec) mul_m4_v3(obj->global2target, isec->start); mul_mat3_m4_v3(obj->global2target, isec->dir); isec->dist *= normalize_v3(isec->dir); - + // update idot_axis and bv_index - for (i=0; i<3; i++) { - isec->idot_axis[i] = 1.0f / isec->dir[i]; - - isec->bv_index[2*i] = isec->idot_axis[i] < 0.0 ? 1 : 0; - isec->bv_index[2*i+1] = 1 - isec->bv_index[2*i]; - - isec->bv_index[2*i] = i+3*isec->bv_index[2*i]; - isec->bv_index[2*i+1] = i+3*isec->bv_index[2*i+1]; + for (i = 0; i < 3; i++) { + isec->idot_axis[i] = 1.0f / isec->dir[i]; + + isec->bv_index[2 * i] = isec->idot_axis[i] < 0.0 ? 1 : 0; + isec->bv_index[2 * i + 1] = 1 - isec->bv_index[2 * i]; + + isec->bv_index[2 * i] = i + 3 * isec->bv_index[2 * i]; + isec->bv_index[2 * i + 1] = i + 3 * isec->bv_index[2 * i + 1]; } // raycast @@ -143,11 +143,11 @@ static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec) isec->dist = len_v3(vec); isec->hit.ob = obj->ob; -#ifdef RT_USE_LAST_HIT +#ifdef RT_USE_LAST_HIT // TODO support for last hit optimization in instances that can jump // directly to the last hit face. // For now it jumps directly to the last-hit instance root node. - isec->last_hit = RE_rayobject_unalignRayAPI((RayObject*) obj); + isec->last_hit = RE_rayobject_unalignRayAPI((RayObject *) obj); #endif } @@ -155,19 +155,19 @@ static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec) copy_v3_v3(isec->start, start); copy_v3_v3(isec->dir, dir); copy_v3_v3(isec->idot_axis, idot_axis); - + if (changed) isec->orig.ob = obj->ob; // restore bv_index - for (i=0; i<3; i++) { - isec->bv_index[2*i] = isec->idot_axis[i] < 0.0 ? 1 : 0; - isec->bv_index[2*i+1] = 1 - isec->bv_index[2*i]; - - isec->bv_index[2*i] = i+3*isec->bv_index[2*i]; - isec->bv_index[2*i+1] = i+3*isec->bv_index[2*i+1]; + for (i = 0; i < 3; i++) { + isec->bv_index[2 * i] = isec->idot_axis[i] < 0.0 ? 1 : 0; + isec->bv_index[2 * i + 1] = 1 - isec->bv_index[2 * i]; + + isec->bv_index[2 * i] = i + 3 * isec->bv_index[2 * i]; + isec->bv_index[2 * i + 1] = i + 3 * isec->bv_index[2 * i + 1]; } - + return res; } @@ -188,7 +188,7 @@ static void RE_rayobject_instance_bb(RayObject *o, float *min, float *max) //TODO: // *better bb.. calculated without rotations of bb // *maybe cache that better-fitted-BB at the InstanceRayObject - InstanceRayObject *obj = (InstanceRayObject*)o; + InstanceRayObject *obj = (InstanceRayObject *)o; float m[3], M[3], t[3]; int i, j; @@ -196,8 +196,8 @@ static void RE_rayobject_instance_bb(RayObject *o, float *min, float *max) RE_rayobject_merge_bb(obj->target, m, M); //There must be a faster way than rotating all the 8 vertexs of the BB - for (i=0; i<8; i++) { - for (j=0; j<3; j++) t[j] = i&(1<<j) ? M[j] : m[j]; + for (i = 0; i < 8; i++) { + for (j = 0; j < 3; j++) t[j] = i & (1 << j) ? M[j] : m[j]; mul_m4_v3(obj->target2global, t); DO_MINMAX(t, min, max); } diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 4eebc967823..d21a22f553b 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -327,16 +327,16 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), #define UVTOINDEX(u,v) (startvlak + (u) * sizev + (v)) /* - -NOTE THAT U/V COORDINATES ARE SOMETIMES SWAPPED !! - -^ ()----p4----p3----() -| | | | | -u | | F1 | F2 | - | | | | - ()----p1----p2----() - v -> -*/ + * + * NOTE THAT U/V COORDINATES ARE SOMETIMES SWAPPED !! + * + * ^ ()----p4----p3----() + * | | | | | + * u | | F1 | F2 | + * | | | | + * ()----p1----p2----() + * v -> + */ /* ------------------------------------------------------------------------- */ @@ -3226,12 +3226,15 @@ static void init_camera_inside_volumes(Render *re) } } - /* debug { - MatInside *m; - for (m=re->render_volumes_inside.first; m; m=m->next) { - printf("matinside: ma: %s\n", m->ma->id.name+2); + +#if 0 /* debug */ + { + MatInside *m; + for (m = re->render_volumes_inside.first; m; m = m->next) { + printf("matinside: ma: %s\n", m->ma->id.name + 2); + } } - }*/ +#endif } static void add_volume(Render *re, ObjectRen *obr, Material *ma) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index eab152262f8..3de64996311 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -245,6 +245,18 @@ Render *RE_GetRender(const char *name) return re; } +Render *RE_GetRender_FromData(const RenderData *rd) +{ + Render *re; + + /* search for existing renders */ + for (re = RenderGlobal.renderlist.first; re; re = re->next) + if (&re->r == rd) + break; + + return re; +} + /* if you want to know exactly what has been done */ RenderResult *RE_AcquireResultRead(Render *re) { diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 6f572b43a15..8e8483839b1 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -1041,7 +1041,7 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd) } } - /* color -> greyscale */ + /* color -> grayscale */ /* editing directly would alter the render view */ if (rd->im_format.planes == R_IMF_PLANES_BW) { ImBuf *ibuf_bw = IMB_dupImBuf(ibuf); diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index f6fe8e8974d..39577bf8da8 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -2852,7 +2852,7 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) /* texture output */ if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { - texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); + texres.tin = rgb_to_bw(&texres.tr); rgb= 0; } if (mtex->texflag & MTEX_NEGATIVE) { @@ -2919,7 +2919,7 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) if (mtex->mapto & MAP_ALPHA) { if (rgb) { if (texres.talpha) texres.tin= texres.ta; - else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); + else texres.tin = rgb_to_bw(&texres.tr); } col_r[3]*= texres.tin; @@ -3051,7 +3051,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h /* texture output */ if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { - texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); + texres.tin = rgb_to_bw(&texres.tr); rgb= 0; } if (mtex->texflag & MTEX_NEGATIVE) { @@ -3124,7 +3124,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h } } if (mtex->mapto & WOMAP_BLEND) { - if (rgb) texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); + if (rgb) texres.tin = rgb_to_bw(&texres.tr); *blend= texture_value_blend(mtex->def_var, *blend, texres.tin, mtex->blendfac, mtex->blendtype); } @@ -3264,7 +3264,7 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r /* texture output */ if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { - texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); + texres.tin = rgb_to_bw(&texres.tr); rgb= 0; } if (mtex->texflag & MTEX_NEGATIVE) { @@ -3358,7 +3358,7 @@ int externtex(MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, rgb= multitex(tex, texvec, dxt, dyt, 0, &texr, thread, mtex->which_output); if (rgb) { - texr.tin= (0.35f*texr.tr+0.45f*texr.tg+0.2f*texr.tb); + texr.tin = rgb_to_bw(&texr.tr); } else { texr.tr= mtex->r; @@ -3591,7 +3591,7 @@ void RE_sample_material_color(Material *mat, float color[3], float *alpha, const if (!mvert || !mface || !mat) return; v1=mface[face_index].v1, v2=mface[face_index].v2, v3=mface[face_index].v3; - if (hit_quad) {v2=mface[face_index].v3; v3=mface[face_index].v4;} + if (hit_quad) { v2 = mface[face_index].v3; v3 = mface[face_index].v4; } normal_tri_v3(normal, mvert[v1].co, mvert[v2].co, mvert[v3].co); /* generate shadeinput with data required */ diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 931a81f2543..03bea0122cf 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1866,7 +1866,7 @@ static void renderflare(RenderResult *rr, float *rectf, HaloRen *har) alfa= har->alfa; visifac= R.ycor*(har->pixels); - /* all radials added / r^3 == 1.0f! */ + /* all radials added / r^3 == 1.0f! */ visifac /= (har->rad*har->rad*har->rad); visifac*= visifac; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index bfea3f3c40b..5011c785e90 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -193,13 +193,13 @@ struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType * int WM_operator_poll (struct bContext *C, struct wmOperatorType *ot); -int WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, int context); +int WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, short context); int WM_operator_call (struct bContext *C, struct wmOperator *op); int WM_operator_call_notest(struct bContext *C, struct wmOperator *op); int WM_operator_repeat (struct bContext *C, struct wmOperator *op); int WM_operator_repeat_check(const struct bContext *C, struct wmOperator *op); -int WM_operator_name_call (struct bContext *C, const char *opstring, int context, struct PointerRNA *properties); -int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, int context, struct PointerRNA *properties, struct ReportList *reports); +int WM_operator_name_call (struct bContext *C, const char *opstring, short context, struct PointerRNA *properties); +int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, short context, struct PointerRNA *properties, struct ReportList *reports, short is_undo); void WM_operator_properties_alloc(struct PointerRNA **ptr, struct IDProperty **properties, const char *opstring); /* used for keymap and macro items */ void WM_operator_properties_sanitize(struct PointerRNA *ptr, const short no_context); /* make props context sensitive or not */ diff --git a/source/blender/windowmanager/intern/wm_apple.c b/source/blender/windowmanager/intern/wm_apple.c index 161725386c5..71d074e340f 100644 --- a/source/blender/windowmanager/intern/wm_apple.c +++ b/source/blender/windowmanager/intern/wm_apple.c @@ -41,7 +41,7 @@ #include <Carbon/Carbon.h> /* To avoid killing small end comps, we want to allow - * blender to start maximised if all the followings are true : + * blender to start maximized if all the followings are true : * - Renderer is OpenGL capable * - Hardware acceleration * - VRAM > 16 Mo diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index e55f7404798..9795c482af2 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -417,7 +417,7 @@ int WM_operator_poll(bContext *C, wmOperatorType *ot) } /* sets up the new context and calls 'wm_operator_invoke()' with poll_only */ -int WM_operator_poll_context(bContext *C, wmOperatorType *ot, int context) +int WM_operator_poll_context(bContext *C, wmOperatorType *ot, short context) { return wm_operator_call_internal(C, ot, NULL, NULL, context, TRUE); } @@ -1068,7 +1068,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA /* invokes operator in context */ -int WM_operator_name_call(bContext *C, const char *opstring, int context, PointerRNA *properties) +int WM_operator_name_call(bContext *C, const char *opstring, short context, PointerRNA *properties) { wmOperatorType *ot = WM_operatortype_find(opstring, 0); if (ot) @@ -1082,7 +1082,7 @@ int WM_operator_name_call(bContext *C, const char *opstring, int context, Pointe * - poll() must be called by python before this runs. * - reports can be passed to this function (so python can report them as exceptions) */ -int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA *properties, ReportList *reports) +int WM_operator_call_py(bContext *C, wmOperatorType *ot, short context, PointerRNA *properties, ReportList *reports, short is_undo) { int retval = OPERATOR_CANCELLED; @@ -1091,13 +1091,13 @@ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA op = wm_operator_create(wm, ot, properties, reports); if (op->type->exec) { - if (op->type->flag & OPTYPE_UNDO) + if (is_undo && op->type->flag & OPTYPE_UNDO) wm->op_undo_depth++; retval = op->type->exec(C, op); OPERATOR_RETVAL_CHECK(retval); - if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) + if (is_undo && op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) wm->op_undo_depth--; } else @@ -1110,11 +1110,11 @@ int WM_operator_call_py(bContext *C, wmOperatorType *ot, int context, PointerRNA * we could have some more obvious way of doing this like passing a flag. */ wmWindowManager *wm = CTX_wm_manager(C); - if (wm) wm->op_undo_depth++; + if (!is_undo && wm) wm->op_undo_depth++; retval = wm_operator_call_internal(C, ot, properties, reports, context, FALSE); - if (wm && (wm == CTX_wm_manager(C))) wm->op_undo_depth--; + if (!is_undo && wm && (wm == CTX_wm_manager(C))) wm->op_undo_depth--; /* keep the reports around if needed later */ if ((retval & OPERATOR_RUNNING_MODAL) || diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 73f59a5fbae..bd7b4694471 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -54,7 +54,7 @@ #include "wm_event_types.h" #include "wm.h" - +#include "PIL_time.h" /* ********************** Threaded Jobs Manager ****************************** */ @@ -127,6 +127,7 @@ struct wmJob { /* we use BLI_threads api, but per job only 1 thread runs */ ListBase threads; + double start_time; }; /* finds: @@ -343,6 +344,9 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve) /* restarted job has timer already */ if (steve->wt == NULL) steve->wt = WM_event_add_timer(wm, steve->win, TIMERJOBS, steve->timestep); + + if (G.debug & G_DEBUG_JOBS) + steve->start_time = PIL_check_seconds_timer(); } else printf("job fails, not initialized\n"); } @@ -465,6 +469,11 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) // if (steve->stop) printf("job ready but stopped %s\n", steve->name); // else printf("job finished %s\n", steve->name); + if (G.debug & G_DEBUG_JOBS) { + printf("Job '%s' finished in %f seconds\n", steve->name, + PIL_check_seconds_timer() - steve->start_time); + } + steve->running = 0; BLI_end_threads(&steve->threads); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 639039baaa7..2aa010f012e 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1052,7 +1052,10 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData) block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); - uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT); + + /* intentionally don't use 'UI_BLOCK_MOVEMOUSE_QUIT', some dialogs have many items + * where quitting by accident is very annoying */ + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1); layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style); @@ -1328,8 +1331,8 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiBlockSetEmboss(block, UI_EMBOSSP); uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN); - split = uiLayoutSplit(layout, 0, 0); - col = uiLayoutColumn(split, 0); + split = uiLayoutSplit(layout, 0.0f, FALSE); + col = uiLayoutColumn(split, FALSE); uiItemL(col, "Links", ICON_NONE); uiItemStringO(col, IFACE_("Donations"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment"); uiItemStringO(col, IFACE_("Credits"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/credits"); @@ -1346,7 +1349,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiItemStringO(col, IFACE_("Python API Reference"), ICON_URL, "WM_OT_url_open", "url", url); uiItemL(col, "", ICON_NONE); - col = uiLayoutColumn(split, 0); + col = uiLayoutColumn(split, FALSE); if (wm_resource_check_prev()) { uiItemO(col, NULL, ICON_NEW, "WM_OT_copy_prev_settings"); @@ -2062,12 +2065,17 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot) ot->check = blend_save_check; /* ommit window poll so this can work in background mode */ - WM_operator_properties_filesel(ot, FOLDERFILE | BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, + FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file"); - RNA_def_boolean(ot->srna, "relative_remap", 1, "Remap Relative", "Remap relative paths when saving in a different directory"); - RNA_def_boolean(ot->srna, "copy", 0, "Save Copy", "Save a copy of the actual working state but does not make saved file active"); + RNA_def_boolean(ot->srna, "relative_remap", 1, "Remap Relative", + "Remap relative paths when saving in a different directory"); + RNA_def_boolean(ot->srna, "copy", 0, "Save Copy", + "Save a copy of the actual working state but does not make saved file active"); #ifdef USE_BMESH_SAVE_AS_COMPAT - RNA_def_boolean(ot->srna, "use_mesh_compat", 0, "Legacy Mesh Format", "Save using legacy mesh format (no ngons)"); + RNA_def_boolean(ot->srna, "use_mesh_compat", 0, "Legacy Mesh Format", + "Save using legacy mesh format (no ngons) - WARNING: only saves tris and quads, other ngons will " + "be lost (no implicit triangulation)"); #endif } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index dd501e6d880..28e50f1655e 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -368,7 +368,7 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) if (win->eventstate == NULL) win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state"); - /* until screens get drawn, make it nice grey */ + /* until screens get drawn, make it nice gray */ glClearColor(0.55, 0.55, 0.55, 0.0); /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */ if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index 6fd4ced9c23..6360cfd4802 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -56,7 +56,7 @@ void wm_window_raise (wmWindow *win); void wm_window_lower (wmWindow *win); void wm_window_set_size (wmWindow *win, int width, int height); void wm_window_get_size (wmWindow *win, int *width_r, int *height_r); -void wm_window_get_size_ghost (wmWindow *win, int *width_r, int *height_r); +void wm_window_get_size_ghost(wmWindow *win, int *width_r, int *height_r); void wm_window_get_position (wmWindow *win, int *posx_r, int *posy_r); void wm_window_swap_buffers (wmWindow *win); diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index 99db5576fa0..720d68ef00d 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -153,7 +153,7 @@ endif() list(APPEND BLENDER_SORTED_LIBS extern_eltopo) endif() - if(WITH_BUILTIN_GLEW) + if(NOT WITH_SYSTEM_GLEW) list(APPEND BLENDER_SORTED_LIBS extern_glew) endif() diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index cbe34538bcd..53f3dacbffa 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -228,7 +228,7 @@ void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct ToolSett void ED_screen_set_scene(struct bContext *C, struct Scene *scene) {} void ED_space_clip_set_clip(struct bContext *C, struct SpaceClip *sc, struct MovieClip *clip) {} -void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask){} +void ED_space_clip_set_mask(struct bContext *C, struct SpaceClip *sc, struct Mask *mask) {} void ED_area_tag_redraw_regiontype(struct ScrArea *sa, int regiontype) {} void ED_render_engine_changed(struct Main *bmain) {} @@ -449,7 +449,7 @@ struct wmOperatorType *WM_operatortype_find(const char *idname, int quiet) {retu struct GHashIterator *WM_operatortype_iter() {return (struct GHashIterator *) NULL;} struct wmOperatorType *WM_operatortype_exists(const char *idname) {return (struct wmOperatorType *) NULL;} struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname) {return (struct wmOperatorTypeMacro *) NULL;} -int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, int context, struct PointerRNA *properties, struct ReportList *reports) {return 0;} +int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, short context, short is_undo, struct PointerRNA *properties, struct ReportList *reports) {return 0;} int WM_operatortype_remove(const char *idname) {return 0;} int WM_operator_poll(struct bContext *C, struct wmOperatorType *ot) {return 0;} int WM_operator_poll_context(struct bContext *C, struct wmOperatorType *ot, int context) {return 0;} @@ -506,7 +506,7 @@ struct DualConMesh *dualcon(const struct DualConMesh *input_mesh, float threshold, float hermite_num, float scale, - int depth) {return 0;} + int depth) { return 0; } /* intern/cycles */ struct CCLDeviceInfo; diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index e8b951f3680..d9ac43d7622 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -894,11 +894,15 @@ endif() cycles_kernel cycles_util cycles_subd - bf_compositor #added for opencl compositor - bf_opencl #added for opencl compositor bf_intern_raskter ) + if(WITH_COMPOSITOR) + #added for opencl compositor + list(APPEND BLENDER_SORTED_LIBS bf_compositor) + list(APPEND BLENDER_SORTED_LIBS bf_opencl) + endif() + if(WITH_LIBMV) list(APPEND BLENDER_SORTED_LIBS extern_libmv) list(APPEND BLENDER_SORTED_LIBS extern_ceres) @@ -908,7 +912,7 @@ endif() list(APPEND BLENDER_SORTED_LIBS extern_eltopo) endif() - if(WITH_BUILTIN_GLEW) + if(NOT WITH_SYSTEM_GLEW) list(APPEND BLENDER_SORTED_LIBS extern_glew) endif() diff --git a/source/creator/SConscript b/source/creator/SConscript deleted file mode 100644 index 80428ba7bb6..00000000000 --- a/source/creator/SConscript +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/python - -# dummy, code has been moved to Blender.creator() diff --git a/source/creator/creator.c b/source/creator/creator.c index 8b6d92414c8..8c9cc45a050 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -387,6 +387,19 @@ static int debug_mode_libmv(int UNUSED(argc), const char **UNUSED(argv), void *U } #endif +static int set_debug_value(int argc, const char **argv, void *UNUSED(data)) +{ + if (argc > 1) { + G.rt = atoi(argv[1]); + + return 1; + } + else { + printf("\nError: you must specify debug value to set.\n"); + return 0; + } +} + static int set_fpe(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data)) { #if defined(__linux__) || defined(_WIN32) || defined(OSX_SSE_FPE) @@ -1115,6 +1128,7 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 1, "-a", NULL, playback_doc, playback_mode, NULL); BLI_argsAdd(ba, 1, "-d", "--debug", debug_doc, debug_mode, ba); + #ifdef WITH_FFMPEG BLI_argsAdd(ba, 1, NULL, "--debug-ffmpeg", "\n\tEnable debug messages from FFmpeg library", debug_mode_generic, (void *)G_DEBUG_FFMPEG); #endif @@ -1129,6 +1143,9 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 1, NULL, "--debug-libmv", "\n\tEnable debug messages from libmv library", debug_mode_libmv, NULL); #endif + BLI_argsAdd(ba, 1, NULL, "--debug-value", "<value>\n\tSet debug value of <value> on startup\n", set_debug_value, NULL); + BLI_argsAdd(ba, 1, NULL, "--debug-jobs", "\n\tEnable time profiling for background jobs.", debug_mode_generic, (void *)G_DEBUG_JOBS); + BLI_argsAdd(ba, 1, NULL, "--verbose", "<verbose>\n\tSet logging verbosity level.", set_verbosity, NULL); BLI_argsAdd(ba, 1, NULL, "--factory-startup", "\n\tSkip reading the "STRINGIFY (BLENDER_STARTUP_FILE)" in the users home directory", set_factory_startup, NULL); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h index a9a12f5a9e0..ee7997abb39 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h @@ -194,9 +194,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderCanvas"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderCanvas") #endif }; diff --git a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h index 18f163d7274..43870d9030d 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h @@ -72,9 +72,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_BlenderInputDevice"); } - void operator delete(void *mem) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_BlenderInputDevice") #endif }; #endif //__KX_BLENDERINPUTDEVICE_H__ diff --git a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h index 43296fc9760..e9140efce01 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h @@ -55,9 +55,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderKeyboardDevice"); } - void operator delete(void *mem) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderKeyboardDevice") #endif }; diff --git a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h index 1c54b2fc000..0571cafd7a1 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h @@ -51,9 +51,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderMouseDevice"); } - void operator delete(void *mem) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderMouseDevice") #endif }; diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index a470e029758..a229c9f34e6 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -108,9 +108,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderRenderTools"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderRenderTools") #endif }; diff --git a/source/gameengine/BlenderRoutines/KX_BlenderSystem.h b/source/gameengine/BlenderRoutines/KX_BlenderSystem.h index 2674c9a7aa1..a8e033ed47b 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderSystem.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderSystem.h @@ -49,9 +49,7 @@ public: virtual double GetTimeInSeconds(); #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderSystem"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderSystem") #endif }; diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 9869dfb9424..b580fc31585 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -350,6 +350,9 @@ bool BL_ActionActuator::Update(double curtime, bool frame) PyObject* BL_ActionActuator::PyGetChannel(PyObject* value) { + PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.getChannel() no longer works, please use BL_ArmatureObject.channels instead"); + return NULL; +#if 0 // XXX To be removed in a later version (first removed in 2.64) const char *string= _PyUnicode_AsString(value); if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE) @@ -407,6 +410,7 @@ PyObject* BL_ActionActuator::PyGetChannel(PyObject* value) pchan->size[0], pchan->size[1], pchan->size[2], pchan->quat[0], pchan->quat[1], pchan->quat[2], pchan->quat[3] ); #endif +#endif } /* setChannel */ @@ -416,6 +420,10 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, "\t - matrix : A 4x4 matrix specifying the overriding transformation\n" "\t as an offset from the bone's rest position.\n") { + PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.setChannel() no longer works, please use BL_ArmatureObject.channels instead"); + return NULL; + +#if 0 // XXX To be removed in a later version (first removed in 2.64) BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent(); char *string; PyObject *pymat= NULL; @@ -497,6 +505,7 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, } Py_RETURN_NONE; +#endif } /* ------------------------------------------------------------------------- */ @@ -583,6 +592,10 @@ int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { + PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.channelNames no longer works, please use BL_ArmatureObject.channels instead"); + return NULL; + +#if 0 // XXX To be removed in a later version (first removed in 2.64) BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); PyObject *ret= PyList_New(0); PyObject *item; @@ -605,6 +618,7 @@ PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYA } return ret; +#endif } PyObject* BL_ActionActuator::pyattr_get_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h index d0fe741672d..61477fb1cac 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.h +++ b/source/gameengine/Converter/BL_DeformableGameObject.h @@ -100,9 +100,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_DeformableGameObject"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_DeformableGameObject") #endif }; diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h index b7d527d83eb..c73e4efd245 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.h +++ b/source/gameengine/Converter/BL_MeshDeformer.h @@ -90,9 +90,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_MeshDeformer"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_MeshDeformer") #endif }; diff --git a/source/gameengine/Converter/BL_ModifierDeformer.h b/source/gameengine/Converter/BL_ModifierDeformer.h index 163b2dd108f..b4827b1bee4 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.h +++ b/source/gameengine/Converter/BL_ModifierDeformer.h @@ -107,9 +107,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ModifierDeformer"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_ModifierDeformer") #endif }; diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h index 6b55d5b26f9..efc1b546666 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.h +++ b/source/gameengine/Converter/BL_ShapeDeformer.h @@ -79,9 +79,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ShapeDeformer"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_ShapeDeformer") #endif }; diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index 8e3d5851573..48c3c3e6186 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -116,9 +116,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_SkinDeformer"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_SkinDeformer") #endif }; diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h index e6f274b777e..e00eb99e73f 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.h +++ b/source/gameengine/Converter/BlenderWorldInfo.h @@ -100,9 +100,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BlenderWorldInfo"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BlenderWorldInfo") #endif }; diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h index cd18bd8c1d6..bc5a6eeef85 100644 --- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h +++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h @@ -55,9 +55,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ScalarInterpolator"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_ScalarInterpolator") #endif }; @@ -71,9 +69,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_InterpolatorList"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_InterpolatorList") #endif }; diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 78e5d7b32c2..3961e6554a7 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -42,6 +42,7 @@ #include "KX_PhysicsEngineEnums.h" #include "PHY_IPhysicsEnvironment.h" #include "KX_KetsjiEngine.h" +#include "KX_PythonInit.h" // So we can handle adding new text datablocks for Python to import #include "KX_IPhysicsController.h" #include "BL_Material.h" #include "BL_ActionActuator.h" @@ -173,9 +174,9 @@ KX_BlenderSceneConverter::~KX_BlenderSceneConverter() #endif /* free any data that was dynamically loaded */ - for (vector<Main*>::iterator it=m_DynamicMaggie.begin(); !(it==m_DynamicMaggie.end()); it++) { - Main *main= *it; - free_main(main); + while (m_DynamicMaggie.size() != 0) + { + FreeBlendFile(m_DynamicMaggie[0]); } m_DynamicMaggie.clear(); @@ -987,6 +988,11 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha load_datablocks(main_newlib, bpy_openlib, path, idcode); + if (idcode==ID_SCE) { + /* assume we want text blocks too */ + load_datablocks(main_newlib, bpy_openlib, path, ID_TXT); + } + /* now do another round of linking for Scenes so all actions are properly loaded */ if (idcode==ID_SCE && options & LIB_LOAD_LOAD_ACTIONS) { load_datablocks(main_newlib, bpy_openlib, path, ID_AC); @@ -1038,6 +1044,10 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha delete other; } + /* Handle any text datablocks */ + + addImportMain(main_newlib); + /* Now handle all the actions */ if (options & LIB_LOAD_LOAD_ACTIONS) { ID *action; @@ -1330,6 +1340,9 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie) } } + /* make sure this maggie is removed from the import list if it's there (this operation is safe if it isn't in the list) */ + removeImportMain(maggie); + free_main(maggie); return true; diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index 258fb1ebdcc..906e3fed111 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -191,9 +191,7 @@ public: #endif #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderSceneConverter"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BlenderSceneConverter") #endif }; diff --git a/source/gameengine/Converter/KX_SoftBodyDeformer.h b/source/gameengine/Converter/KX_SoftBodyDeformer.h index 5235c91ce89..d692d45eb18 100644 --- a/source/gameengine/Converter/KX_SoftBodyDeformer.h +++ b/source/gameengine/Converter/KX_SoftBodyDeformer.h @@ -93,9 +93,7 @@ protected: //class RAS_MeshObject *m_pMesh; #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ShapeDeformer"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_ShapeDeformer") #endif }; diff --git a/source/gameengine/Expressions/BoolValue.h b/source/gameengine/Expressions/BoolValue.h index 48238264f1b..09e931ea661 100644 --- a/source/gameengine/Expressions/BoolValue.h +++ b/source/gameengine/Expressions/BoolValue.h @@ -56,11 +56,8 @@ public: private: bool m_bool; - #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CBoolValue"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CBoolValue") #endif }; diff --git a/source/gameengine/Expressions/ConstExpr.h b/source/gameengine/Expressions/ConstExpr.h index 30b830cb92c..86d411cef26 100644 --- a/source/gameengine/Expressions/ConstExpr.h +++ b/source/gameengine/Expressions/ConstExpr.h @@ -47,9 +47,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CConstExpr"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CConstExpr") #endif }; diff --git a/source/gameengine/Expressions/EmptyValue.h b/source/gameengine/Expressions/EmptyValue.h index 73946da6705..54920359f3f 100644 --- a/source/gameengine/Expressions/EmptyValue.h +++ b/source/gameengine/Expressions/EmptyValue.h @@ -41,9 +41,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CEmptyValue"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CEmptyValue") #endif }; diff --git a/source/gameengine/Expressions/ErrorValue.h b/source/gameengine/Expressions/ErrorValue.h index 484d135f406..12bc7c7ffcb 100644 --- a/source/gameengine/Expressions/ErrorValue.h +++ b/source/gameengine/Expressions/ErrorValue.h @@ -39,9 +39,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CErrorValue"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CErrorValue") #endif }; diff --git a/source/gameengine/Expressions/Expression.h b/source/gameengine/Expressions/Expression.h index 8a4ba8bb7e2..5f5db505331 100644 --- a/source/gameengine/Expressions/Expression.h +++ b/source/gameengine/Expressions/Expression.h @@ -74,9 +74,7 @@ class CBrokenLinkInfo #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CBrokenLinkInfo"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CBrokenLinkInfo") #endif }; @@ -144,9 +142,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CExpression"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CExpression") #endif }; diff --git a/source/gameengine/Expressions/FloatValue.h b/source/gameengine/Expressions/FloatValue.h index 75b2202eb7e..59311e5d373 100644 --- a/source/gameengine/Expressions/FloatValue.h +++ b/source/gameengine/Expressions/FloatValue.h @@ -50,9 +50,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CFloatValue"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CFloatValue") #endif }; diff --git a/source/gameengine/Expressions/IdentifierExpr.h b/source/gameengine/Expressions/IdentifierExpr.h index 632a1e0a6d9..58e75c4b02e 100644 --- a/source/gameengine/Expressions/IdentifierExpr.h +++ b/source/gameengine/Expressions/IdentifierExpr.h @@ -52,9 +52,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CIdentifierExpr"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CIdentifierExpr") #endif }; diff --git a/source/gameengine/Expressions/IfExpr.h b/source/gameengine/Expressions/IfExpr.h index c0caa7f3e17..f8ed81168d0 100644 --- a/source/gameengine/Expressions/IfExpr.h +++ b/source/gameengine/Expressions/IfExpr.h @@ -51,9 +51,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CIfExpr"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CIfExpr") #endif }; diff --git a/source/gameengine/Expressions/InputParser.h b/source/gameengine/Expressions/InputParser.h index 085e6870429..6dfeff55105 100644 --- a/source/gameengine/Expressions/InputParser.h +++ b/source/gameengine/Expressions/InputParser.h @@ -110,9 +110,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CParser"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CParser") #endif }; diff --git a/source/gameengine/Expressions/IntValue.h b/source/gameengine/Expressions/IntValue.h index 733ee8bfa4e..e728467cc4e 100644 --- a/source/gameengine/Expressions/IntValue.h +++ b/source/gameengine/Expressions/IntValue.h @@ -65,9 +65,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CIntValue"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CIntValue") #endif }; diff --git a/source/gameengine/Expressions/KX_HashedPtr.h b/source/gameengine/Expressions/KX_HashedPtr.h index edb68f2861d..ffc6ff647d5 100644 --- a/source/gameengine/Expressions/KX_HashedPtr.h +++ b/source/gameengine/Expressions/KX_HashedPtr.h @@ -54,9 +54,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CHashedPtr"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CHashedPtr") #endif }; diff --git a/source/gameengine/Expressions/Operator1Expr.h b/source/gameengine/Expressions/Operator1Expr.h index 9815ce16e95..13a1b16500a 100644 --- a/source/gameengine/Expressions/Operator1Expr.h +++ b/source/gameengine/Expressions/Operator1Expr.h @@ -52,9 +52,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:COperator1Expr"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:") #endif }; diff --git a/source/gameengine/Expressions/Operator2Expr.h b/source/gameengine/Expressions/Operator2Expr.h index 8b1c5523a2f..23272930131 100644 --- a/source/gameengine/Expressions/Operator2Expr.h +++ b/source/gameengine/Expressions/Operator2Expr.h @@ -58,9 +58,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:COperator2Expr"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:COperator2Expr") #endif }; diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 124a8e28f57..2fee6aaab92 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -166,7 +166,7 @@ public: \ void *operator new(size_t num_bytes) { \ return MEM_mallocN(num_bytes, Type.tp_name); \ } \ - void operator delete( void *mem ) { \ + void operator delete(void *mem) { \ MEM_freeN(mem); \ } \ @@ -534,21 +534,11 @@ typedef PyTypeObject *PyParentObject; /* Define the PyParent Object */ #ifdef WITH_CXX_GUARDEDALLOC #define Py_Header \ public: \ - void *operator new(size_t num_bytes) { \ - return MEM_mallocN(num_bytes, "GE:PyObjectPlus"); \ - } \ - void operator delete( void *mem ) { \ - MEM_freeN(mem); \ - } \ + MEM_CXX_CLASS_ALLOC_FUNCS("GE:PyObjectPlus") \ + #define Py_HeaderPtr \ -public: \ - void *operator new(size_t num_bytes) { \ - return MEM_mallocN(num_bytes, "GE:PyObjectPlusPtr"); \ - } \ - void operator delete( void *mem ) { \ - MEM_freeN(mem); \ - } \ + MEM_CXX_CLASS_ALLOC_FUNCS("GE:PyObjectPlusPtr") \ #else // WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Expressions/StringValue.h b/source/gameengine/Expressions/StringValue.h index 931858b7eed..aa4a1a0bb00 100644 --- a/source/gameengine/Expressions/StringValue.h +++ b/source/gameengine/Expressions/StringValue.h @@ -53,9 +53,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CStringValue"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CStringValue") #endif }; diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index 30bc33adddd..6507cc32cf1 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -406,7 +406,7 @@ CValue* CValue::GetProperty(int inIndex) std::map<STR_String,CValue*>::iterator it; for (it= m_pNamedPropertyArray->begin(); (it != m_pNamedPropertyArray->end()); it++) { - if (count++==inIndex) + if (count++ == inIndex) { result = (*it).second; break; diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h index 261f5244f21..e3b52e80ba6 100644 --- a/source/gameengine/Expressions/Value.h +++ b/source/gameengine/Expressions/Value.h @@ -164,9 +164,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CAction"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CAction") #endif }; @@ -436,11 +434,8 @@ public: protected: STR_String m_strNewName; // Identification - #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CPropValue"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CPropValue") #endif }; diff --git a/source/gameengine/Expressions/VectorValue.h b/source/gameengine/Expressions/VectorValue.h index 5d0e0c0ddb2..b7afa61d4dd 100644 --- a/source/gameengine/Expressions/VectorValue.h +++ b/source/gameengine/Expressions/VectorValue.h @@ -86,9 +86,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CVectorValue"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CVectorValue") #endif }; diff --git a/source/gameengine/Expressions/VoidValue.h b/source/gameengine/Expressions/VoidValue.h index 8e2545b309d..5599b226a60 100644 --- a/source/gameengine/Expressions/VoidValue.h +++ b/source/gameengine/Expressions/VoidValue.h @@ -66,9 +66,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CVoidValue"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CVoidValue") #endif }; diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt index 64f198f72a0..e511704c7f4 100644 --- a/source/gameengine/GameLogic/CMakeLists.txt +++ b/source/gameengine/GameLogic/CMakeLists.txt @@ -32,6 +32,7 @@ set(INC ../../../intern/container ../../../intern/moto/include ../../../intern/string + ../../../intern/ghost ) set(INC_SYS diff --git a/source/gameengine/GameLogic/SCA_ActuatorEventManager.h b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h index b91e6f872a2..dee9ea4e8ba 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorEventManager.h +++ b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h @@ -49,9 +49,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_ActuatorEventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_ActuatorEventManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h index 21ac55d36a4..cf4063fba1f 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h +++ b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h @@ -43,9 +43,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_AlwaysEventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_AlwaysEventManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_BasicEventManager.h b/source/gameengine/GameLogic/SCA_BasicEventManager.h index 9d08a7785e2..24206e46a61 100644 --- a/source/gameengine/GameLogic/SCA_BasicEventManager.h +++ b/source/gameengine/GameLogic/SCA_BasicEventManager.h @@ -50,9 +50,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_BasicEventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_BasicEventManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_EventManager.h b/source/gameengine/GameLogic/SCA_EventManager.h index 933fdc5190a..83322fe8243 100644 --- a/source/gameengine/GameLogic/SCA_EventManager.h +++ b/source/gameengine/GameLogic/SCA_EventManager.h @@ -84,9 +84,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_EventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_EventManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.h b/source/gameengine/GameLogic/SCA_ExpressionController.h index 47401ea5807..06edc83ab96 100644 --- a/source/gameengine/GameLogic/SCA_ExpressionController.h +++ b/source/gameengine/GameLogic/SCA_ExpressionController.h @@ -59,9 +59,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_ExpressionController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_ExpressionController") #endif }; diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h index 211a25b84c8..801483bb882 100644 --- a/source/gameengine/GameLogic/SCA_IActuator.h +++ b/source/gameengine/GameLogic/SCA_IActuator.h @@ -160,9 +160,7 @@ public: bool IsType(KX_ACTUATOR_TYPE type) { return m_type == type; } #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_IActuator"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_IActuator") #endif }; diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.h b/source/gameengine/GameLogic/SCA_IInputDevice.h index 443faef6338..0382a2efd21 100644 --- a/source/gameengine/GameLogic/SCA_IInputDevice.h +++ b/source/gameengine/GameLogic/SCA_IInputDevice.h @@ -274,14 +274,14 @@ public: protected: /** - m_eventStatusTables are two tables that contain current and previous - status of all events - */ + * m_eventStatusTables are two tables that contain current and previous + * status of all events + */ SCA_InputEvent m_eventStatusTables[2][SCA_IInputDevice::KX_MAX_KEYS]; /** - m_currentTable is index for m_keyStatusTable that toggle between 0 or 1 - */ + * m_currentTable is index for m_keyStatusTable that toggle between 0 or 1 + */ int m_currentTable; void ClearStatusTable(int tableid); @@ -316,9 +316,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_InputEvent"); } - void operator delete(void *mem) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_InputEvent") #endif }; diff --git a/source/gameengine/GameLogic/SCA_IScene.h b/source/gameengine/GameLogic/SCA_IScene.h index e7806ea0746..a399e313082 100644 --- a/source/gameengine/GameLogic/SCA_IScene.h +++ b/source/gameengine/GameLogic/SCA_IScene.h @@ -74,9 +74,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_IScene"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_IScene") #endif }; diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.h b/source/gameengine/GameLogic/SCA_JoystickManager.h index dcdd667cb1a..60dcaea4ef2 100644 --- a/source/gameengine/GameLogic/SCA_JoystickManager.h +++ b/source/gameengine/GameLogic/SCA_JoystickManager.h @@ -51,9 +51,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_JoystickManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_JoystickManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.h b/source/gameengine/GameLogic/SCA_KeyboardManager.h index 5706d16ae19..2d9ad45833f 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardManager.h +++ b/source/gameengine/GameLogic/SCA_KeyboardManager.h @@ -59,9 +59,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_KeyboardManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_KeyboardManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index 6543d16d469..1263514d475 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -56,7 +56,7 @@ SCA_LogicManager::~SCA_LogicManager() assert(m_activeActuators.Empty()); } -/* +#if 0 // this kind of fixes bug 398 but breakes games, so better leave it out for now. // a removed object's gameobject (and logicbricks and stuff) didn't get released // because it was still in the m_mapStringToGameObjects map. @@ -77,7 +77,7 @@ void SCA_LogicManager::RemoveGameObject(const STR_String& gameobjname) m_mapStringToGameObjects.remove(gameobjname); } -*/ +#endif void SCA_LogicManager::RegisterEventManager(SCA_EventManager* eventmgr) diff --git a/source/gameengine/GameLogic/SCA_LogicManager.h b/source/gameengine/GameLogic/SCA_LogicManager.h index 751c03bc712..817f3a1c22a 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.h +++ b/source/gameengine/GameLogic/SCA_LogicManager.h @@ -147,9 +147,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_LogicManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_LogicManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_MouseManager.h b/source/gameengine/GameLogic/SCA_MouseManager.h index 4b40ab8a197..60edb2816cb 100644 --- a/source/gameengine/GameLogic/SCA_MouseManager.h +++ b/source/gameengine/GameLogic/SCA_MouseManager.h @@ -68,9 +68,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_MouseManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_MouseManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.h b/source/gameengine/GameLogic/SCA_PropertyEventManager.h index 7d5e13f0ae1..7a4ec750484 100644 --- a/source/gameengine/GameLogic/SCA_PropertyEventManager.h +++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.h @@ -48,9 +48,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_PropertyEventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_PropertyEventManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index ce183b37498..a92ffac4129 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -318,9 +318,9 @@ CValue* SCA_PropertySensor::FindIdentifier(const STR_String& identifiername) int SCA_PropertySensor::validValueForProperty(void *self, const PyAttributeDef*) { - /* If someone actually do type checking please make sure the 'max' and 'min' - are checked as well (currently they are calling the PrecalculateRangeExpression - function directly */ + /* If someone actually do type checking please make sure the 'max' and 'min' + * are checked as well (currently they are calling the PrecalculateRangeExpression + * function directly */ /* There is no type checking at this moment, unfortunately... */ return 0; diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 9c8e6fe99b4..ab7f57a5454 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -71,21 +71,19 @@ SCA_PythonController::SCA_PythonController(SCA_IObject* gameobj, int mode) } -/* +#if 0 //debugging -CValue* SCA_PythonController::AddRef() +CValue *SCA_PythonController::AddRef() { //printf("AddRef refcount = %i\n",GetRefCount()); return CValue::AddRef(); } -int SCA_PythonController::Release() +int SCA_PythonController::Release() { //printf("Release refcount = %i\n",GetRefCount()); return CValue::Release(); } -*/ - - +#endif SCA_PythonController::~SCA_PythonController() { @@ -122,13 +120,14 @@ CValue* SCA_PythonController::GetReplica() if (m_pythondictionary) replica->m_pythondictionary = PyDict_Copy(m_pythondictionary); - /* +#if 0 // The other option is to incref the replica->m_pythondictionary - // the replica objects can then share data. if (m_pythondictionary) Py_INCREF(replica->m_pythondictionary); - */ #endif + +#endif /* WITH_PYTHON */ // this will copy properties and so on... replica->ProcessReplica(); @@ -209,7 +208,7 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value) else if (PyObject_TypeCheck(value, &SCA_IActuator::Type)) { PyObjectPlus *value_plus= BGE_PROXY_REF(value); for (it = lacts.begin(); it!= lacts.end(); ++it) { - if ( static_cast<SCA_IActuator*>(value_plus) == (*it) ) { + if (static_cast<SCA_IActuator*>(value_plus) == (*it)) { return *it; } } diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp index 46c43b5e339..f83b23f510c 100644 --- a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp +++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp @@ -28,6 +28,8 @@ #include "SCA_PythonKeyboard.h" #include "SCA_IInputDevice.h" +#include "GHOST_C-api.h" + /* ------------------------------------------------------------------------- */ /* Native functions */ /* ------------------------------------------------------------------------- */ @@ -55,6 +57,23 @@ SCA_PythonKeyboard::~SCA_PythonKeyboard() /* Python functions */ /* ------------------------------------------------------------------------- */ +/* clipboard */ +static PyObject* gPyGetClipboard(PyObject* args, PyObject* kwds) +{ + char *buf = (char *)GHOST_getClipboard(0); + return PyUnicode_FromString(buf?buf:""); +} + +static PyObject* gPySetClipboard(PyObject* args, PyObject* value) +{ + char* buf; + if (!PyArg_ParseTuple(value,"s:setClipboard",&buf)) + Py_RETURN_NONE; + + GHOST_putClipboard((GHOST_TInt8 *)buf, 0); + Py_RETURN_NONE; +} + /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_PythonKeyboard::Type = { PyVarObject_HEAD_INIT(NULL, 0) @@ -79,6 +98,8 @@ PyTypeObject SCA_PythonKeyboard::Type = { }; PyMethodDef SCA_PythonKeyboard::Methods[] = { + {"getClipboard", (PyCFunction) gPyGetClipboard, METH_VARARGS, "getCliboard doc"}, + {"setClipboard", (PyCFunction) gPySetClipboard, METH_VARARGS, "setCliboard doc"}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.h b/source/gameengine/GameLogic/SCA_RandomEventManager.h index 7205363a3ee..b46899b1355 100644 --- a/source/gameengine/GameLogic/SCA_RandomEventManager.h +++ b/source/gameengine/GameLogic/SCA_RandomEventManager.h @@ -47,9 +47,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_RandomEventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_RandomEventManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h index 8f546b37ec8..10818cb4e8f 100644 --- a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h +++ b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h @@ -77,9 +77,7 @@ class SCA_RandomNumberGenerator { #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_RandomNumberGenerator"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_RandomNumberGenerator") #endif }; diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.h b/source/gameengine/GameLogic/SCA_TimeEventManager.h index 7c813785b9c..092cf016370 100644 --- a/source/gameengine/GameLogic/SCA_TimeEventManager.h +++ b/source/gameengine/GameLogic/SCA_TimeEventManager.h @@ -55,9 +55,7 @@ public: vector<CValue*> GetTimeValues(); #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_TimeEventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_TimeEventManager") #endif }; diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript index e33169bada7..da3c0fadb51 100644 --- a/source/gameengine/GameLogic/SConscript +++ b/source/gameengine/GameLogic/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('*.cpp') + env.Glob('Joystick/*.cpp') -incs = '. #/intern/string #intern/container' +incs = '. #/intern/string #intern/container #intern/ghost' incs += ' #/source/gameengine/Expressions #/intern/moto/include' incs += ' #/source/gameengine/Rasterizer #/source/gameengine/SceneGraph' incs += ' #/source/blender/blenlib' diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h index cd2bc7e374e..0e26c5ad729 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.h +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h @@ -87,7 +87,7 @@ protected: /** Height of the context. */ int m_height; /** Rect that defines the area used for rendering, - relative to the context */ + * relative to the context */ RAS_Rect m_displayarea; /** Storage for the banners to display. */ diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index 15be4c46894..fbeb34b70b4 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -141,6 +141,16 @@ bool BL_Action::Play(const char* name, return false; } + // If we have the same settings, don't play again + // This is to resolve potential issues with pulses on sensors such as the ones + // reported in bug #29412. The fix is here so it works for both logic bricks and Python. + // However, this may eventually lead to issues where a user wants to override an already + // playing action with the same action and settings. If this becomes an issue, + // then this fix may have to be re-evaluated. + if (!IsDone() && m_action == prev_action && m_startframe == start && m_endframe == end + && m_priority == priority && m_speed == playback_speed) + return false; + if (prev_action != m_action) { // First get rid of any old controllers diff --git a/source/gameengine/Ketsji/BL_Action.h b/source/gameengine/Ketsji/BL_Action.h index e5e325a2ba0..ab2adf7fe34 100644 --- a/source/gameengine/Ketsji/BL_Action.h +++ b/source/gameengine/Ketsji/BL_Action.h @@ -132,9 +132,7 @@ public: }; #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_Action"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_Action") #endif }; diff --git a/source/gameengine/Ketsji/BL_ActionManager.h b/source/gameengine/Ketsji/BL_ActionManager.h index d4351e3c704..dbdaa6652ad 100644 --- a/source/gameengine/Ketsji/BL_ActionManager.h +++ b/source/gameengine/Ketsji/BL_ActionManager.h @@ -94,9 +94,7 @@ public: void Update(float); #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_ActionManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_ActionManager") #endif }; diff --git a/source/gameengine/Ketsji/BL_BlenderShader.h b/source/gameengine/Ketsji/BL_BlenderShader.h index d309b1236fc..f23dbfdf3a5 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.h +++ b/source/gameengine/Ketsji/BL_BlenderShader.h @@ -97,9 +97,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_BlenderShader"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_BlenderShader") #endif }; diff --git a/source/gameengine/Ketsji/BL_Material.h b/source/gameengine/Ketsji/BL_Material.h index 70fd640a07e..b67bd95f878 100644 --- a/source/gameengine/Ketsji/BL_Material.h +++ b/source/gameengine/Ketsji/BL_Material.h @@ -110,9 +110,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_Material"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_Material") #endif }; diff --git a/source/gameengine/Ketsji/BL_Shader.h b/source/gameengine/Ketsji/BL_Shader.h index 47221365816..2bb094f12ee 100644 --- a/source/gameengine/Ketsji/BL_Shader.h +++ b/source/gameengine/Ketsji/BL_Shader.h @@ -32,9 +32,7 @@ public: int mLoc; // Sampler location #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_Sampler"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_Sampler") #endif }; @@ -79,9 +77,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_Uniform"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_Uniform") #endif }; @@ -104,9 +100,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_DefUniform"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_DefUniform") #endif }; diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index 576da0d3f40..19247664dfa 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -144,7 +144,15 @@ bool BL_Texture::InitFromImage(int unit, Image *img, bool mipmap) mNeedsDeleted = 1; glGenTextures(1, (GLuint*)&mTexture); + +#ifdef WITH_DDS + if (ibuf->ftype & DDS) + InitGLCompressedTex(ibuf, mipmap); + else + InitGLTex(ibuf->rect, ibuf->x, ibuf->y, mipmap); +#else InitGLTex(ibuf->rect, ibuf->x, ibuf->y, mipmap); +#endif // track created units BL_TextureObject obj; @@ -183,6 +191,26 @@ void BL_Texture::InitGLTex(unsigned int *pix,int x,int y,bool mipmap) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } +void BL_Texture::InitGLCompressedTex(ImBuf* ibuf, bool mipmap) +{ +#ifndef WITH_DDS + // Fall back to uncompressed if DDS isn't enabled + InitGLTex(ibuf->rect, ibuf->x, ibuf->y, mipmap); + return; +#else + glBindTexture(GL_TEXTURE_2D, mTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + + if (GPU_upload_dxt_texture(ibuf) == 0) { + InitGLTex(ibuf->rect, ibuf->x, ibuf->y, mipmap); + return; + } +#endif +} void BL_Texture::InitNonPow2Tex(unsigned int *pix,int x,int y,bool mipmap) { diff --git a/source/gameengine/Ketsji/BL_Texture.h b/source/gameengine/Ketsji/BL_Texture.h index 3c60cad4fbf..a6bd354d260 100644 --- a/source/gameengine/Ketsji/BL_Texture.h +++ b/source/gameengine/Ketsji/BL_Texture.h @@ -35,6 +35,7 @@ private: void InitNonPow2Tex(unsigned int *p,int x,int y,bool mipmap ); void InitGLTex(unsigned int *p,int x,int y,bool mipmap ); + void InitGLCompressedTex(struct ImBuf *p, bool mipmap); public: BL_Texture(); ~BL_Texture( ); @@ -74,9 +75,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_Texture"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_Texture") #endif }; diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index c7f54838c10..4b3426e0784 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -221,6 +221,10 @@ set(SRC add_definitions(-DGLEW_STATIC) +if(WITH_IMAGE_DDS) + add_definitions(-DWITH_DDS) +endif() + if(WITH_SDL) list(APPEND INC_SYS ${SDL_INCLUDE_DIR} diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h index 5fcd591d822..71e806686ca 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h @@ -92,9 +92,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BulletPhysicsController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BulletPhysicsController") #endif }; diff --git a/source/gameengine/Ketsji/KX_CameraIpoSGController.h b/source/gameengine/Ketsji/KX_CameraIpoSGController.h index f24d0942290..06058760332 100644 --- a/source/gameengine/Ketsji/KX_CameraIpoSGController.h +++ b/source/gameengine/Ketsji/KX_CameraIpoSGController.h @@ -90,9 +90,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_CameraIpoSGController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_CameraIpoSGController") #endif }; diff --git a/source/gameengine/Ketsji/KX_ClientObjectInfo.h b/source/gameengine/Ketsji/KX_ClientObjectInfo.h index 1a94c39441f..6fd1271160a 100644 --- a/source/gameengine/Ketsji/KX_ClientObjectInfo.h +++ b/source/gameengine/Ketsji/KX_ClientObjectInfo.h @@ -80,9 +80,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_ClientObjectInfo"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ClientObjectInfo") #endif }; diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index f149b676aa5..d87bb937b41 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -469,7 +469,7 @@ bool KX_Dome::ParseWarpMesh(STR_String text) * First line is the image type the mesh is support to be applied to: 2 = fisheye, 1=radial * Tthe next line has the mesh dimensions * Rest of the lines are the nodes of the mesh. Each line has x y u v i - * (x,y) are the normalised screen coordinates + * (x,y) are the normalized screen coordinates * (u,v) texture coordinates * i a multiplicative intensity factor * diff --git a/source/gameengine/Ketsji/KX_Dome.h b/source/gameengine/Ketsji/KX_Dome.h index 125df573893..24177af5d60 100644 --- a/source/gameengine/Ketsji/KX_Dome.h +++ b/source/gameengine/Ketsji/KX_Dome.h @@ -191,9 +191,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_Dome"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_Dome") #endif }; diff --git a/source/gameengine/Ketsji/KX_EmptyObject.h b/source/gameengine/Ketsji/KX_EmptyObject.h index 7ad9984888d..b99f44c38c5 100644 --- a/source/gameengine/Ketsji/KX_EmptyObject.h +++ b/source/gameengine/Ketsji/KX_EmptyObject.h @@ -43,9 +43,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_EmptyObject"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_EmptyObject") #endif }; diff --git a/source/gameengine/Ketsji/KX_FontObject.h b/source/gameengine/Ketsji/KX_FontObject.h index 30fe89162c0..ae8b4166238 100644 --- a/source/gameengine/Ketsji/KX_FontObject.h +++ b/source/gameengine/Ketsji/KX_FontObject.h @@ -69,14 +69,6 @@ protected: class RAS_IRenderTools* m_rendertools; //needed for drawing routine -#if 0 // WHY COMMENTED? - campbell -#ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_FontObject"); } - void operator delete( void *mem ) { MEM_freeN(mem); } -#endif -#endif - #ifdef WITH_PYTHON static PyObject* pyattr_get_text(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); diff --git a/source/gameengine/Ketsji/KX_IInterpolator.h b/source/gameengine/Ketsji/KX_IInterpolator.h index 2e30d77f8e5..6ca44e1f6e5 100644 --- a/source/gameengine/Ketsji/KX_IInterpolator.h +++ b/source/gameengine/Ketsji/KX_IInterpolator.h @@ -46,9 +46,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_IInterpolator"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_IInterpolator") #endif }; diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.h b/source/gameengine/Ketsji/KX_IPO_SGController.h index 3abcaa3a39e..266b89ff969 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.h +++ b/source/gameengine/Ketsji/KX_IPO_SGController.h @@ -119,11 +119,10 @@ public: m_ipotime = time; m_modified = true; } - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_IpoSGController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_IpoSGController") #endif }; diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h index 528bf00d574..dd34549c1fb 100644 --- a/source/gameengine/Ketsji/KX_IPhysicsController.h +++ b/source/gameengine/Ketsji/KX_IPhysicsController.h @@ -141,9 +141,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_IPhysicsController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_IPhysicsController") #endif }; diff --git a/source/gameengine/Ketsji/KX_IScalarInterpolator.h b/source/gameengine/Ketsji/KX_IScalarInterpolator.h index 72842f311c9..2b5aefccfe7 100644 --- a/source/gameengine/Ketsji/KX_IScalarInterpolator.h +++ b/source/gameengine/Ketsji/KX_IScalarInterpolator.h @@ -44,9 +44,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_IScalarInterpolator"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_IScalarInterpolator") #endif }; diff --git a/source/gameengine/Ketsji/KX_ISceneConverter.h b/source/gameengine/Ketsji/KX_ISceneConverter.h index 50390005f2b..919ae1d6de5 100644 --- a/source/gameengine/Ketsji/KX_ISceneConverter.h +++ b/source/gameengine/Ketsji/KX_ISceneConverter.h @@ -89,9 +89,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_ISceneConverter"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ISceneConverter") #endif }; diff --git a/source/gameengine/Ketsji/KX_ISystem.h b/source/gameengine/Ketsji/KX_ISystem.h index 4a6f7223d0a..4ba71f8d239 100644 --- a/source/gameengine/Ketsji/KX_ISystem.h +++ b/source/gameengine/Ketsji/KX_ISystem.h @@ -55,9 +55,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_ISystem"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ISystem") #endif }; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 04113607531..21c3198b8f9 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -603,7 +603,7 @@ else /* Suspension holds the physics and logic processing for an * entire scene. Objects can be suspended individually, and - * the settings for that preceed the logic and physics + * the settings for that precede the logic and physics * update. */ m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index f9c6d59b668..b3bef016b0f 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -443,9 +443,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_KetsjiEngine"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_KetsjiEngine") #endif }; diff --git a/source/gameengine/Ketsji/KX_LightIpoSGController.h b/source/gameengine/Ketsji/KX_LightIpoSGController.h index 15591bfa981..3a3a9677b04 100644 --- a/source/gameengine/Ketsji/KX_LightIpoSGController.h +++ b/source/gameengine/Ketsji/KX_LightIpoSGController.h @@ -98,9 +98,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_LightIpoSGController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_LightIpoSGController") #endif }; diff --git a/source/gameengine/Ketsji/KX_MaterialIpoController.h b/source/gameengine/Ketsji/KX_MaterialIpoController.h index 11d92925a02..ee5546641c2 100644 --- a/source/gameengine/Ketsji/KX_MaterialIpoController.h +++ b/source/gameengine/Ketsji/KX_MaterialIpoController.h @@ -58,9 +58,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_MaterialIpoController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_MaterialIpoController") #endif }; diff --git a/source/gameengine/Ketsji/KX_MotionState.h b/source/gameengine/Ketsji/KX_MotionState.h index 02470f88c5e..3bead93cbda 100644 --- a/source/gameengine/Ketsji/KX_MotionState.h +++ b/source/gameengine/Ketsji/KX_MotionState.h @@ -58,8 +58,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_MotionState"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_MotionState") #endif }; diff --git a/source/gameengine/Ketsji/KX_ObColorIpoSGController.h b/source/gameengine/Ketsji/KX_ObColorIpoSGController.h index d2f4c69bf47..9a9b3dac098 100644 --- a/source/gameengine/Ketsji/KX_ObColorIpoSGController.h +++ b/source/gameengine/Ketsji/KX_ObColorIpoSGController.h @@ -73,9 +73,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_ObColorIpoSGController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ObColorIpoSGController") #endif }; diff --git a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp index b8169899c78..fd47587e2c8 100644 --- a/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp +++ b/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp @@ -40,7 +40,7 @@ namespace inline float vdist(const float* a, const float* b) { return sqrtf(vdistsqr(a,b)); } inline void vcpy(float* a, const float* b) { a[0]=b[0]; a[1]=b[1]; } inline float vdot(const float* a, const float* b) { return a[0]*b[0] + a[1]*b[1]; } - inline float vperp(const float* a, const float* b) { return a[0]*b[1] - a[1]*b[0]; } +/* inline float vperp(const float* a, const float* b) { return a[0]*b[1] - a[1]*b[0]; } */ /* UNUSED */ inline void vsub(float* v, const float* a, const float* b) { v[0] = a[0]-b[0]; v[1] = a[1]-b[1]; } inline void vadd(float* v, const float* a, const float* b) { v[0] = a[0]+b[0]; v[1] = a[1]+b[1]; } inline void vscale(float* v, const float* a, const float s) { v[0] = a[0]*s; v[1] = a[1]*s; } @@ -48,7 +48,7 @@ namespace inline float vlensqr(const float* v) { return vdot(v,v); } inline float vlen(const float* v) { return sqrtf(vlensqr(v)); } inline void vlerp(float* v, const float* a, const float* b, float t) { v[0] = lerp(a[0], b[0], t); v[1] = lerp(a[1], b[1], t); } - inline void vmad(float* v, const float* a, const float* b, float s) { v[0] = a[0] + b[0]*s; v[1] = a[1] + b[1]*s; } +/* inline void vmad(float* v, const float* a, const float* b, float s) { v[0] = a[0] + b[0]*s; v[1] = a[1] + b[1]*s; } */ /* UNUSED */ inline void vnorm(float* v) { float d = vlen(v); @@ -549,6 +549,9 @@ void KX_ObstacleSimulationTOI_rays::sampleRVO(KX_Obstacle* activeObst, KX_NavMes p1, p2, ob->m_rad, htmin, htmax)) continue; } + else { + continue; + } if (htmin > 0.0f) { @@ -743,6 +746,9 @@ static void processSamples(KX_Obstacle* activeObst, KX_NavMeshObject* activeNavM // Avoid less when facing walls. htmin *= 2.0f; } + else { + continue; + } if (htmin >= 0.0f) { diff --git a/source/gameengine/Ketsji/KX_OrientationInterpolator.h b/source/gameengine/Ketsji/KX_OrientationInterpolator.h index 1a4ed534d16..59014b70174 100644 --- a/source/gameengine/Ketsji/KX_OrientationInterpolator.h +++ b/source/gameengine/Ketsji/KX_OrientationInterpolator.h @@ -56,9 +56,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -private: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_OrientationInterpolator"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_OrientationInterpolator") #endif }; diff --git a/source/gameengine/Ketsji/KX_PositionInterpolator.h b/source/gameengine/Ketsji/KX_PositionInterpolator.h index ef5dfc8ac6b..b5ab053bb0e 100644 --- a/source/gameengine/Ketsji/KX_PositionInterpolator.h +++ b/source/gameengine/Ketsji/KX_PositionInterpolator.h @@ -56,9 +56,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -private: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_PositionInterpolator"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_PositionInterpolator") #endif }; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 28c4630c43e..823363dfd11 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1130,8 +1130,8 @@ static int getGLSLSettingFlag(const char *setting) } static PyObject* gPySetGLSLMaterialSetting(PyObject*, - PyObject* args, - PyObject*) + PyObject* args, + PyObject*) { GlobalSettings *gs= gp_KetsjiEngine->GetGlobalSettings(); char *setting; @@ -1142,7 +1142,7 @@ static PyObject* gPySetGLSLMaterialSetting(PyObject*, flag = getGLSLSettingFlag(setting); - if (flag==-1) { + if (flag == -1) { PyErr_SetString(PyExc_ValueError, "Rasterizer.setGLSLMaterialSetting(string): glsl setting is not known"); return NULL; } @@ -1173,8 +1173,8 @@ static PyObject* gPySetGLSLMaterialSetting(PyObject*, } static PyObject* gPyGetGLSLMaterialSetting(PyObject*, - PyObject* args, - PyObject*) + PyObject* args, + PyObject*) { GlobalSettings *gs= gp_KetsjiEngine->GetGlobalSettings(); char *setting; @@ -1185,7 +1185,7 @@ static PyObject* gPyGetGLSLMaterialSetting(PyObject*, flag = getGLSLSettingFlag(setting); - if (flag==-1) { + if (flag == -1) { PyErr_SetString(PyExc_ValueError, "Rasterizer.getGLSLMaterialSetting(string): glsl setting is not known"); return NULL; } @@ -1821,6 +1821,16 @@ static void restorePySysObjects(void) // PyObject_Print(sys_path, stderr, 0); } +void addImportMain(struct Main *maggie) +{ + bpy_import_main_extra_add(maggie); +} + +void removeImportMain(struct Main *maggie) +{ + bpy_import_main_extra_remove(maggie); +} + // Copied from bpy_interface.c static struct _inittab bge_internal_modules[]= { {(char *)"mathutils", PyInit_mathutils}, diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index d8346018b55..866681b9da7 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -61,6 +61,9 @@ int saveGamePythonConfig( char **marshal_buffer); int loadGamePythonConfig(char *marshal_buffer, int marshal_length); #endif +void addImportMain(struct Main *maggie); +void removeImportMain(struct Main *maggie); + class KX_KetsjiEngine; class KX_Scene; diff --git a/source/gameengine/Ketsji/KX_RayCast.h b/source/gameengine/Ketsji/KX_RayCast.h index 814443f5c64..544080f31d0 100644 --- a/source/gameengine/Ketsji/KX_RayCast.h +++ b/source/gameengine/Ketsji/KX_RayCast.h @@ -96,9 +96,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_RayCast"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_RayCast") #endif }; @@ -135,9 +133,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_RayCast::Callback"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_RayCast::Callback") #endif }; diff --git a/source/gameengine/Ketsji/KX_RayEventManager.h b/source/gameengine/Ketsji/KX_RayEventManager.h index fee2fe53227..f795495d1c9 100644 --- a/source/gameengine/Ketsji/KX_RayEventManager.h +++ b/source/gameengine/Ketsji/KX_RayEventManager.h @@ -46,9 +46,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_RayEventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_RayEventManager") #endif }; diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h index 734f82731b8..76fefdebe08 100644 --- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h +++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h @@ -89,9 +89,7 @@ private : #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BoneParentRelation"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_BoneParentRelation") #endif }; diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h index 44864c87cd7..b5ab5302910 100644 --- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h +++ b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h @@ -88,9 +88,7 @@ private : #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_NormalParentRelation"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_NormalParentRelation") #endif }; @@ -145,9 +143,7 @@ private : #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_VertexParentRelation"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_VertexParentRelation") #endif }; @@ -228,9 +224,7 @@ private : #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_SlowParentRelation"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_SlowParentRelation") #endif }; diff --git a/source/gameengine/Ketsji/KX_ScalarInterpolator.h b/source/gameengine/Ketsji/KX_ScalarInterpolator.h index d08a32ce0aa..5d8c3163376 100644 --- a/source/gameengine/Ketsji/KX_ScalarInterpolator.h +++ b/source/gameengine/Ketsji/KX_ScalarInterpolator.h @@ -61,9 +61,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_ScalarInterpolator"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ScalarInterpolator") #endif }; diff --git a/source/gameengine/Ketsji/KX_ScalingInterpolator.h b/source/gameengine/Ketsji/KX_ScalingInterpolator.h index ae8b25f9185..52b6d0cf8cc 100644 --- a/source/gameengine/Ketsji/KX_ScalingInterpolator.h +++ b/source/gameengine/Ketsji/KX_ScalingInterpolator.h @@ -56,9 +56,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_ScalingInterpolator"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_ScalingInterpolator") #endif }; diff --git a/source/gameengine/Ketsji/KX_TimeCategoryLogger.h b/source/gameengine/Ketsji/KX_TimeCategoryLogger.h index 62b74871603..ea780739695 100644 --- a/source/gameengine/Ketsji/KX_TimeCategoryLogger.h +++ b/source/gameengine/Ketsji/KX_TimeCategoryLogger.h @@ -129,9 +129,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_TimeCategoryLogger"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_TimeCategoryLogger") #endif }; diff --git a/source/gameengine/Ketsji/KX_TimeLogger.h b/source/gameengine/Ketsji/KX_TimeLogger.h index b2336c2c512..83c934ea81b 100644 --- a/source/gameengine/Ketsji/KX_TimeLogger.h +++ b/source/gameengine/Ketsji/KX_TimeLogger.h @@ -107,9 +107,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_TimeLogger"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_TimeLogger") #endif }; diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.h b/source/gameengine/Ketsji/KX_TouchEventManager.h index 38286cba9aa..d9a0164fd05 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.h +++ b/source/gameengine/Ketsji/KX_TouchEventManager.h @@ -81,9 +81,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_TouchEventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_TouchEventManager") #endif }; diff --git a/source/gameengine/Ketsji/KX_WorldInfo.h b/source/gameengine/Ketsji/KX_WorldInfo.h index cb4e9de50c2..e4a73873fa1 100644 --- a/source/gameengine/Ketsji/KX_WorldInfo.h +++ b/source/gameengine/Ketsji/KX_WorldInfo.h @@ -70,9 +70,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_WorldInfo"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_WorldInfo") #endif }; diff --git a/source/gameengine/Ketsji/KX_WorldIpoController.h b/source/gameengine/Ketsji/KX_WorldIpoController.h index 9578130b51e..409b1fec321 100644 --- a/source/gameengine/Ketsji/KX_WorldIpoController.h +++ b/source/gameengine/Ketsji/KX_WorldIpoController.h @@ -96,9 +96,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_WorldIpoController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_WorldIpoController") #endif }; diff --git a/source/gameengine/Network/NG_NetworkDeviceInterface.h b/source/gameengine/Network/NG_NetworkDeviceInterface.h index d4a3d12057e..8f903cc64fa 100644 --- a/source/gameengine/Network/NG_NetworkDeviceInterface.h +++ b/source/gameengine/Network/NG_NetworkDeviceInterface.h @@ -75,9 +75,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:NG_NetworkDeviceInterface"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:NG_NetworkDeviceInterface") #endif }; diff --git a/source/gameengine/Network/NG_NetworkMessage.h b/source/gameengine/Network/NG_NetworkMessage.h index 7a55891552f..25e7fd97596 100644 --- a/source/gameengine/Network/NG_NetworkMessage.h +++ b/source/gameengine/Network/NG_NetworkMessage.h @@ -131,9 +131,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:NG_NetworkMessage"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:NG_NetworkMessage") #endif }; diff --git a/source/gameengine/Network/NG_NetworkObject.h b/source/gameengine/Network/NG_NetworkObject.h index b7b01bdad06..b9858cd8d43 100644 --- a/source/gameengine/Network/NG_NetworkObject.h +++ b/source/gameengine/Network/NG_NetworkObject.h @@ -48,9 +48,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:NG_NetworkObject"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:NG_NetworkObject") #endif }; diff --git a/source/gameengine/Network/NG_NetworkScene.h b/source/gameengine/Network/NG_NetworkScene.h index b3ca4df9d50..41ac8ead5e4 100644 --- a/source/gameengine/Network/NG_NetworkScene.h +++ b/source/gameengine/Network/NG_NetworkScene.h @@ -111,9 +111,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:NG_NetworkScene"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:NG_NetworkScene") #endif }; diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.h b/source/gameengine/Physics/Bullet/CcdGraphicController.h index 07878b7162e..60ff475832b 100644 --- a/source/gameengine/Physics/Bullet/CcdGraphicController.h +++ b/source/gameengine/Physics/Bullet/CcdGraphicController.h @@ -83,9 +83,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CcdGraphicController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CcdGraphicController") #endif }; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 63c267443aa..09afafbe0a7 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -203,9 +203,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CcdShapeConstructionInfo"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CcdShapeConstructionInfo") #endif }; @@ -625,9 +623,7 @@ protected: } #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CcdPhysicsController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CcdPhysicsController") #endif }; @@ -659,9 +655,7 @@ class DefaultMotionState : public PHY_IMotionState #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:DefaultMotionState"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:DefaultMotionState") #endif }; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 552cca801de..ef1c0873005 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -288,9 +288,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CcdPhysicsEnvironment"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:CcdPhysicsEnvironment") #endif }; diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h index 8e55c4a0c0f..9c109168b18 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h @@ -35,13 +35,13 @@ #include "PHY_IPhysicsEnvironment.h" /** -* DummyPhysicsEnvironment is an empty placeholder -* Alternatives are ODE,Sumo and Dynamo PhysicsEnvironments -* Use DummyPhysicsEnvironment as a base to integrate your own physics engine -* Physics Environment takes care of stepping the simulation and is a container for physics entities (rigidbodies,constraints, materials etc.) -* -* A derived class may be able to 'construct' entities by loading and/or converting -*/ + * DummyPhysicsEnvironment is an empty placeholder + * Alternatives are ODE,Sumo and Dynamo PhysicsEnvironments + * Use DummyPhysicsEnvironment as a base to integrate your own physics engine + * Physics Environment takes care of stepping the simulation and is a container for physics entities (rigidbodies,constraints, materials etc.) + * + * A derived class may be able to 'construct' entities by loading and/or converting + */ class DummyPhysicsEnvironment : public PHY_IPhysicsEnvironment { @@ -98,9 +98,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:DummyPhysicsEnvironment"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:DummyPhysicsEnvironment") #endif }; diff --git a/source/gameengine/Physics/common/PHY_IController.h b/source/gameengine/Physics/common/PHY_IController.h index d25af9f898c..239ac3366e1 100644 --- a/source/gameengine/Physics/common/PHY_IController.h +++ b/source/gameengine/Physics/common/PHY_IController.h @@ -56,9 +56,7 @@ class PHY_IController #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IController") #endif }; diff --git a/source/gameengine/Physics/common/PHY_IGraphicController.h b/source/gameengine/Physics/common/PHY_IGraphicController.h index 6a94b3d6ea9..af337188818 100644 --- a/source/gameengine/Physics/common/PHY_IGraphicController.h +++ b/source/gameengine/Physics/common/PHY_IGraphicController.h @@ -54,8 +54,7 @@ class PHY_IGraphicController : public PHY_IController virtual PHY_IGraphicController* GetReplica(class PHY_IMotionState* motionstate) {return 0;} #ifdef WITH_CXX_GUARDEDALLOC - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IController") #endif }; diff --git a/source/gameengine/Physics/common/PHY_IMotionState.h b/source/gameengine/Physics/common/PHY_IMotionState.h index 77c51ebdb79..2eb2a9f39cf 100644 --- a/source/gameengine/Physics/common/PHY_IMotionState.h +++ b/source/gameengine/Physics/common/PHY_IMotionState.h @@ -61,9 +61,7 @@ class PHY_IMotionState #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IMotionState"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IMotionState") #endif }; diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h index 727cbda931d..7eea2a183a1 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsController.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h @@ -102,10 +102,9 @@ class PHY_IPhysicsController : public PHY_IController PHY__Vector3 GetWorldPosition(PHY__Vector3& localpos); + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IPhysicsController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IPhysicsController") #endif }; diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h index a2597f917e3..8fde9e289dc 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h @@ -87,11 +87,10 @@ public: m_faceUV(faceUV) { } - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IRayCastFilterCallback"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IRayCastFilterCallback") #endif }; @@ -179,11 +178,10 @@ class PHY_IPhysicsEnvironment virtual float getConstraintParam(int constraintId,int param) = 0; virtual void exportFile(const char* filename) {}; - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IPhysicsEnvironment"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IPhysicsEnvironment") #endif }; diff --git a/source/gameengine/Physics/common/PHY_IVehicle.h b/source/gameengine/Physics/common/PHY_IVehicle.h index 735ce5a8791..731e22d9f0f 100644 --- a/source/gameengine/Physics/common/PHY_IVehicle.h +++ b/source/gameengine/Physics/common/PHY_IVehicle.h @@ -62,9 +62,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:PHY_IVehicle"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_IVehicle") #endif }; diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 0a1958e509a..43acb9e5f8a 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -323,23 +323,24 @@ void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance) void RAS_2DFilterManager::UpdateOffsetMatrix(RAS_ICanvas* canvas) { - RAS_Rect canvas_rect = canvas->GetWindowArea(); - canvaswidth = canvas->GetWidth(); - canvasheight = canvas->GetHeight(); - - texturewidth = canvaswidth + canvas_rect.GetLeft(); - textureheight = canvasheight + canvas_rect.GetBottom(); + /* RAS_Rect canvas_rect = canvas->GetWindowArea(); */ /* UNUSED */ + texturewidth = canvas->GetWidth(); + textureheight = canvas->GetHeight(); GLint i,j; - i = 0; - while ((1 << i) <= texturewidth) - i++; - texturewidth = (1 << (i)); - // Now for height - i = 0; - while ((1 << i) <= textureheight) - i++; - textureheight = (1 << (i)); + if (!GL_ARB_texture_non_power_of_two) + { + i = 0; + while ((1 << i) <= texturewidth) + i++; + texturewidth = (1 << (i)); + + // Now for height + i = 0; + while ((1 << i) <= textureheight) + i++; + textureheight = (1 << (i)); + } GLfloat xInc = 1.0f / (GLfloat)texturewidth; GLfloat yInc = 1.0f / (GLfloat)textureheight; @@ -400,6 +401,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) GLuint viewport[4]={0}; glGetIntegerv(GL_VIEWPORT,(GLint *)viewport); + RAS_Rect rect = canvas->GetWindowArea(); if (canvaswidth != canvas->GetWidth() || canvasheight != canvas->GetHeight()) { @@ -417,19 +419,19 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) if (need_depth) { glActiveTextureARB(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, texname[1]); - glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, 0, 0, texturewidth,textureheight, 0); + glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, rect.GetLeft(), rect.GetBottom(), rect.GetWidth(), rect.GetHeight(), 0); } if (need_luminance) { glActiveTextureARB(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, texname[2]); - glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, 0, 0, texturewidth,textureheight, 0); + glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, rect.GetLeft(), rect.GetBottom(), rect.GetWidth(), rect.GetHeight(), 0); } // reverting to texunit 0, without this we get bug [#28462] glActiveTextureARB(GL_TEXTURE0); - glViewport(0,0, texturewidth, textureheight); + glViewport(rect.GetLeft(), rect.GetBottom(), texturewidth, textureheight); glDisable(GL_DEPTH_TEST); // in case the previous material was wire @@ -452,7 +454,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) glActiveTextureARB(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texname[0]); - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, texturewidth, textureheight, 0); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, rect.GetLeft(), rect.GetBottom(), rect.GetWidth(), rect.GetHeight(), 0); // Don't use texturewidth and textureheight in case we don't have NPOT support glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_QUADS); diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h index c9af48fe516..93d143dd3ce 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h @@ -106,12 +106,10 @@ public: void RenderFilters(RAS_ICanvas* canvas); void EnableFilter(std::vector<STR_String>& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text); - - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_2DFilterManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_2DFilterManager") #endif }; #endif diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h index dade2ad7c11..2650bc9f722 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.h +++ b/source/gameengine/Rasterizer/RAS_BucketManager.h @@ -84,10 +84,9 @@ private: void RenderAlphaBuckets(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools); + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_BucketManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_BucketManager") #endif }; diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h index 1e9a792634a..627db2b63fb 100644 --- a/source/gameengine/Rasterizer/RAS_Deformer.h +++ b/source/gameengine/Rasterizer/RAS_Deformer.h @@ -93,10 +93,9 @@ protected: class RAS_MeshObject *m_pMesh; bool m_bDynamic; + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_Deformer"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_Deformer") #endif }; diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.h b/source/gameengine/Rasterizer/RAS_FramingManager.h index fc5adc97657..6312f83737e 100644 --- a/source/gameengine/Rasterizer/RAS_FramingManager.h +++ b/source/gameengine/Rasterizer/RAS_FramingManager.h @@ -163,9 +163,7 @@ private : #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_FrameSettings"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_FrameSettings") #endif }; @@ -300,14 +298,11 @@ private : RAS_FramingManager( const RAS_FramingManager & ); - + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_FramingManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_FramingManager") #endif }; #endif - diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h index dae70c5c343..713a06845ac 100644 --- a/source/gameengine/Rasterizer/RAS_ICanvas.h +++ b/source/gameengine/Rasterizer/RAS_ICanvas.h @@ -217,11 +217,10 @@ public: protected: RAS_MouseState m_mousestate; - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_ICanvas"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_ICanvas") #endif }; diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h index 527114b300f..0f89af490d8 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h @@ -185,12 +185,10 @@ public: * PreCalculate texture gen */ virtual void OnConstruction(int layer){} - - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_IPolyMaterial"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IPolyMaterial") #endif }; diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 828ee01d150..d4c19410eb1 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -416,12 +416,10 @@ public: virtual void SetAnisotropicFiltering(short level)=0; virtual short GetAnisotropicFiltering()=0; - - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_IRasterizer"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IRasterizer") #endif }; diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h index 1d9f7052975..5d3efb8c38a 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.h +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h @@ -201,12 +201,10 @@ public: virtual void MotionBlur(RAS_IRasterizer* rasterizer)=0; - - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_IRenderTools"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IRenderTools") #endif }; diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h index cff4d67d44b..7cf7fee7845 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h @@ -175,12 +175,10 @@ public: bool IsCulled() { return m_bCulled; } #endif void SetCulled(bool culled) { m_bCulled = culled; } - - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_MeshSlot"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_MeshSlot") #endif }; @@ -195,9 +193,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_MeshMaterial"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_MeshMaterial") #endif }; @@ -254,11 +250,8 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_MaterialBucket"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_MaterialBucket") #endif }; #endif //__RAS_MATERIAL_BUCKET - diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index ffe2964c058..326110bea57 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -170,12 +170,10 @@ public: }; vector<vector<SharedVertex> > m_sharedvertex_map; - - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_MeshObject"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_MeshObject") #endif }; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h index 0b36bbf3876..808c4f11dd8 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h @@ -73,12 +73,10 @@ public: virtual void SetDrawingMode(int drawingmode); virtual bool QueryLists(){return true;} - - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_ListRasterizer"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_ListRasterizer") #endif }; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 3b4a6c4900c..36f768f6474 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -315,12 +315,10 @@ public: virtual void SetAnisotropicFiltering(short level); virtual short GetAnisotropicFiltering(); - - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_OpenGLRasterizer"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_OpenGLRasterizer") #endif }; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp index ff24bd639ba..a36229c35d1 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp @@ -42,7 +42,7 @@ RAS_VAOpenGLRasterizer::RAS_VAOpenGLRasterizer(RAS_ICanvas* canvas, bool lock) : RAS_OpenGLRasterizer(canvas), - m_Lock(lock && GLEW_EXT_compiled_vertex_array), + /* m_Lock(lock && GLEW_EXT_compiled_vertex_array), */ /* UNUSED */ m_last_texco_num(0), m_last_attrib_num(0) { diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h index d96f390ad74..deda1c4603a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h @@ -37,7 +37,7 @@ class RAS_VAOpenGLRasterizer : public RAS_OpenGLRasterizer { void TexCoordPtr(const RAS_TexVert *tv); - bool m_Lock; + /* bool m_Lock; */ /* UNUSED */ TexCoGen m_last_texco[RAS_MAX_TEXCO]; TexCoGen m_last_attrib[RAS_MAX_ATTRIB]; @@ -63,9 +63,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_VAOpenGLRasterizer"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_VAOpenGLRasterizer") #endif }; diff --git a/source/gameengine/Rasterizer/RAS_Polygon.h b/source/gameengine/Rasterizer/RAS_Polygon.h index a3bd6b600c9..bc70b43286c 100644 --- a/source/gameengine/Rasterizer/RAS_Polygon.h +++ b/source/gameengine/Rasterizer/RAS_Polygon.h @@ -93,11 +93,10 @@ public: RAS_MaterialBucket* GetMaterial(); RAS_DisplayArray* GetDisplayArray(); - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_Polygon"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_Polygon") #endif }; diff --git a/source/gameengine/Rasterizer/RAS_Rect.h b/source/gameengine/Rasterizer/RAS_Rect.h index c845c2c21bd..cb5f7d47457 100644 --- a/source/gameengine/Rasterizer/RAS_Rect.h +++ b/source/gameengine/Rasterizer/RAS_Rect.h @@ -94,11 +94,10 @@ public: { m_y2 = y2; } - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_Rect"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_Rect") #endif }; diff --git a/source/gameengine/Rasterizer/RAS_TexVert.h b/source/gameengine/Rasterizer/RAS_TexVert.h index f76c6a66c86..15059a9cf12 100644 --- a/source/gameengine/Rasterizer/RAS_TexVert.h +++ b/source/gameengine/Rasterizer/RAS_TexVert.h @@ -141,11 +141,10 @@ public: // compare two vertices, to test if they can be shared, used for // splitting up based on uv's, colors, etc bool closeTo(const RAS_TexVert* other); - + + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_TexVert"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_TexVert") #endif }; diff --git a/source/gameengine/SceneGraph/SG_BBox.h b/source/gameengine/SceneGraph/SG_BBox.h index 33e29b85a5f..cd1c523ff40 100644 --- a/source/gameengine/SceneGraph/SG_BBox.h +++ b/source/gameengine/SceneGraph/SG_BBox.h @@ -136,9 +136,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_BBox"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_BBox") #endif }; diff --git a/source/gameengine/SceneGraph/SG_Controller.h b/source/gameengine/SceneGraph/SG_Controller.h index 7100debe632..d82738dbb86 100644 --- a/source/gameengine/SceneGraph/SG_Controller.h +++ b/source/gameengine/SceneGraph/SG_Controller.h @@ -43,12 +43,6 @@ class SG_Controller { public: - -#ifdef WITH_CXX_GUARDEDALLOC - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "SG_Controller"); } - void operator delete( void *mem ) { MEM_freeN(mem); } -#endif - SG_Controller( ) : m_pObject(NULL) { @@ -122,6 +116,9 @@ public: protected: SG_IObject* m_pObject; +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_Controller") +#endif }; #endif //__SG_CONTROLLER_H__ diff --git a/source/gameengine/SceneGraph/SG_DList.h b/source/gameengine/SceneGraph/SG_DList.h index 90e3226f227..be1c1fda2f2 100644 --- a/source/gameengine/SceneGraph/SG_DList.h +++ b/source/gameengine/SceneGraph/SG_DList.h @@ -217,9 +217,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_DList"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_DList") #endif }; diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h index a1d4207e508..c36c984f3d3 100644 --- a/source/gameengine/SceneGraph/SG_IObject.h +++ b/source/gameengine/SceneGraph/SG_IObject.h @@ -367,9 +367,7 @@ protected : #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_IObject"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_IObject") #endif }; diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h index 41133495f2e..1d0c0e592e6 100644 --- a/source/gameengine/SceneGraph/SG_Node.h +++ b/source/gameengine/SceneGraph/SG_Node.h @@ -271,9 +271,7 @@ private: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_Node"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_Node") #endif }; diff --git a/source/gameengine/SceneGraph/SG_ParentRelation.h b/source/gameengine/SceneGraph/SG_ParentRelation.h index 4140563828f..925c0ed2766 100644 --- a/source/gameengine/SceneGraph/SG_ParentRelation.h +++ b/source/gameengine/SceneGraph/SG_ParentRelation.h @@ -131,9 +131,7 @@ protected : #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_ParentRelation"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_ParentRelation") #endif }; diff --git a/source/gameengine/SceneGraph/SG_QList.h b/source/gameengine/SceneGraph/SG_QList.h index e1288877b1d..bcc56f05615 100644 --- a/source/gameengine/SceneGraph/SG_QList.h +++ b/source/gameengine/SceneGraph/SG_QList.h @@ -157,9 +157,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_QList"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_QList") #endif }; diff --git a/source/gameengine/SceneGraph/SG_Spatial.h b/source/gameengine/SceneGraph/SG_Spatial.h index 32f91103369..e456851d183 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.h +++ b/source/gameengine/SceneGraph/SG_Spatial.h @@ -287,9 +287,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_Spatial"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_Spatial") #endif }; diff --git a/source/gameengine/SceneGraph/SG_Tree.h b/source/gameengine/SceneGraph/SG_Tree.h index b2cbb227f77..339862c652f 100644 --- a/source/gameengine/SceneGraph/SG_Tree.h +++ b/source/gameengine/SceneGraph/SG_Tree.h @@ -115,16 +115,14 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_Tree"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_Tree") #endif }; /** * SG_TreeFactory generates an SG_Tree from a list of SG_Nodes. - * It joins pairs of SG_Nodes to minimise the size of the resultant + * It joins pairs of SG_Nodes to minimize the size of the resultant * bounding box. * cf building an optimized Huffman tree. * \warning O(n^3)!!! @@ -158,9 +156,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_TreeFactory"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_TreeFactory") #endif }; |