diff options
author | OmarSquircleArt <omar.squircleart@gmail.com> | 2019-08-10 16:18:12 +0300 |
---|---|---|
committer | OmarSquircleArt <omar.squircleart@gmail.com> | 2019-08-10 16:18:12 +0300 |
commit | 67474a7e622957044bc708119a7cfa49a82790fd (patch) | |
tree | 1689263da79f08b1c3c9725ac56c3da8b5d91fbb | |
parent | b091542fe91353c15dd7240ba7ce8ecf72d4011b (diff) | |
parent | 553b581f25c1782c4231816965cd3f6ce58a449a (diff) |
Merge master to soc-2019-cycles-procedural.soc-2019-cycles-procedural
209 files changed, 4003 insertions, 2344 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 88295979fa7..6ced6e1d76d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -413,6 +413,8 @@ unset(PLATFORM_DEFAULT) option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON) option(WITH_CYCLES_DEBUG "Build Cycles with extra debug capabilities" OFF) option(WITH_CYCLES_NATIVE_ONLY "Build Cycles with native kernel only (which fits current CPU, use for development only)" OFF) +option(WITH_CYCLES_KERNEL_ASAN "Build Cycles kernels with address sanitizer when WITH_COMPILER_ASAN is on, even if it's very slow" OFF) +mark_as_advanced(WITH_CYCLES_KERNEL_ASAN) mark_as_advanced(WITH_CYCLES_CUBIN_COMPILER) mark_as_advanced(WITH_CYCLES_LOGGING) mark_as_advanced(WITH_CYCLES_DEBUG) @@ -822,12 +824,6 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "Release") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMPILER_ASAN_CXXFLAGS}") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMPILER_ASAN_CXXFLAGS}") - if(WITH_CYCLES_OSL) - # With OSL, Cycles disables rtti in some modules, which then breaks at linking - # when trying to use vptr sanitizer (included into 'undefined' general option). - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-sanitize=vptr") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-sanitize=vptr") - endif() if(MSVC) set(COMPILER_ASAN_LINKER_FLAGS "/FUNCTIONPADMIN:6") endif() diff --git a/GNUmakefile b/GNUmakefile index 69a2689cea1..1ad7cc4fc27 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -37,7 +37,9 @@ Convenience Targets * bpy: Build as a python module which can be loaded from python directly. * deps: Build library dependencies (intended only for platform maintainers). + * developer: Enable faster builds, error checking and tests, recommended for developers. * config: Run cmake configuration tool to set build options. + * ninja: Use ninja build tool for faster builds. Note: passing the argument 'BUILD_DIR=path' when calling make will override the default build dir. Note: passing the argument 'BUILD_CMAKE_ARGS=args' lets you add cmake arguments. @@ -221,6 +223,19 @@ ifneq "$(findstring bpy, $(MAKECMDGOALS))" "" BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/bpy_module.cmake" endif +ifneq "$(findstring developer, $(MAKECMDGOALS))" "" + BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -C"$(BLENDER_DIR)/build_files/cmake/config/blender_developer.cmake" +endif + +# ----------------------------------------------------------------------------- +# build tool + +ifneq "$(findstring ninja, $(MAKECMDGOALS))" "" + BUILD_COMMAND:=ninja + BUILD_CMAKE_ARGS:=$(BUILD_CMAKE_ARGS) -G Ninja +else + BUILD_COMMAND:=make -s +endif # ----------------------------------------------------------------------------- # Blender binary path @@ -282,7 +297,7 @@ all: .FORCE @echo @echo Building Blender ... - $(MAKE) -C "$(BUILD_DIR)" -s -j $(NPROCS) install + $(BUILD_COMMAND) -C "$(BUILD_DIR)" -j $(NPROCS) install @echo @echo edit build configuration with: "$(BUILD_DIR)/CMakeCache.txt" run make again to rebuild. @echo Blender successfully built, run from: $(BLENDER_BIN) @@ -294,6 +309,8 @@ lite: all cycles: all headless: all bpy: all +developer: all +ninja: all # ----------------------------------------------------------------------------- # Build dependencies @@ -312,7 +329,7 @@ deps: .FORCE @echo @echo Building dependencies ... - $(MAKE) -C "$(DEPS_BUILD_DIR)" -s -j $(NPROCS) $(DEPS_TARGET) + $(BUILD_COMMAND) -C "$(DEPS_BUILD_DIR)" -j $(NPROCS) $(DEPS_TARGET) @echo @echo Dependencies successfully built and installed to $(DEPS_INSTALL_DIR). @echo @@ -548,7 +565,7 @@ help_features: .FORCE @$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_print_build_options.py" $(BLENDER_DIR)"/CMakeLists.txt" clean: .FORCE - $(MAKE) -C "$(BUILD_DIR)" clean + $(BUILD_COMMAND) -C "$(BUILD_DIR)" clean .PHONY: all diff --git a/build_files/cmake/config/blender_developer.cmake b/build_files/cmake/config/blender_developer.cmake new file mode 100644 index 00000000000..5209ce4ed25 --- /dev/null +++ b/build_files/cmake/config/blender_developer.cmake @@ -0,0 +1,19 @@ +# Configuration for developers, with faster builds, error checking and tests. +# +# Example usage: +# cmake -C../blender/build_files/cmake/config/blender_developer.cmake ../blender +# + +set(WITH_ASSERT_ABORT ON CACHE BOOL "" FORCE) +set(WITH_BUILDINFO OFF CACHE BOOL "" FORCE) +set(WITH_COMPILER_ASAN ON CACHE BOOL "" FORCE) +set(WITH_CYCLES_DEBUG ON CACHE BOOL "" FORCE) +set(WITH_CYCLES_NATIVE_ONLY ON CACHE BOOL "" FORCE) +set(WITH_GTESTS ON CACHE BOOL "" FORCE) +set(WITH_LIBMV_SCHUR_SPECIALIZATIONS OFF CACHE BOOL "" FORCE) +set(WITH_PYTHON_SAFETY ON CACHE BOOL "" FORCE) +set(WITH_DOC_MANPAGE OFF CACHE BOOL "" FORCE) + +# This may have issues with C++ initialization order, needs to be tested +# on all platforms to be sure this is safe to enable. +# set(WITH_CXX_GUARDEDALLOC ON CACHE BOOL "" FORCE) diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index fa757b2a1c5..8286f5d80a9 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -171,8 +171,7 @@ if(NOT DEFINED LIBDIR) message(STATUS "64 bit compiler detected.") set(LIBDIR_BASE "win64") else() - message(STATUS "32 bit compiler detected.") - set(LIBDIR_BASE "windows") + message(FATAL_ERROR "32 bit compiler detected, blender no longer provides pre-build libraries for 32 bit windows, please set the LIBDIR cmake variable to your own library folder") endif() # Can be 1910..1912 if(MSVC_VERSION GREATER 1919) @@ -386,9 +385,6 @@ if(WITH_BOOST) if(CMAKE_CL_64) set(BOOST_POSTFIX "vc140-mt-s-x64-1_68.lib") set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-x64-1_68.lib") - else() - set(BOOST_POSTFIX "vc140-mt-s-x32-1_68.lib") - set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-x32-1_68.lib") endif() set(BOOST_LIBRARIES optimized ${BOOST_LIBPATH}/libboost_date_time-${BOOST_POSTFIX} diff --git a/build_files/windows/check_libraries.cmd b/build_files/windows/check_libraries.cmd index 8c5f7ec7e17..fcae2c90657 100644 --- a/build_files/windows/check_libraries.cmd +++ b/build_files/windows/check_libraries.cmd @@ -2,11 +2,7 @@ if "%BUILD_VS_YEAR%"=="2015" set BUILD_VS_LIBDIRPOST=vc14 if "%BUILD_VS_YEAR%"=="2017" set BUILD_VS_LIBDIRPOST=vc14 if "%BUILD_VS_YEAR%"=="2019" set BUILD_VS_LIBDIRPOST=vc14 -if "%BUILD_ARCH%"=="x64" ( - set BUILD_VS_SVNDIR=win64_%BUILD_VS_LIBDIRPOST% -) else if "%BUILD_ARCH%"=="x86" ( - set BUILD_VS_SVNDIR=windows_%BUILD_VS_LIBDIRPOST% -) +set BUILD_VS_SVNDIR=win64_%BUILD_VS_LIBDIRPOST% set BUILD_VS_LIBDIR="%BLENDER_DIR%..\lib\%BUILD_VS_SVNDIR%" if NOT "%verbose%" == "" ( diff --git a/build_files/windows/configure_msbuild.cmd b/build_files/windows/configure_msbuild.cmd index c316e2286e5..7cb0a4df689 100644 --- a/build_files/windows/configure_msbuild.cmd +++ b/build_files/windows/configure_msbuild.cmd @@ -1,14 +1,6 @@ set BUILD_GENERATOR_POST= set BUILD_PLATFORM_SELECT= -if "%BUILD_ARCH%"=="x64" ( - set MSBUILD_PLATFORM=x64 -) else if "%BUILD_ARCH%"=="x86" ( - set MSBUILD_PLATFORM=win32 - if "%WITH_CLANG%"=="1" ( - echo Clang not supported for X86 - exit /b 1 - ) -) +set MSBUILD_PLATFORM=x64 if "%WITH_CLANG%"=="1" ( set CLANG_CMAKE_ARGS=-T"llvm" diff --git a/build_files/windows/detect_architecture.cmd b/build_files/windows/detect_architecture.cmd index cd211668b7f..42663ef2d29 100644 --- a/build_files/windows/detect_architecture.cmd +++ b/build_files/windows/detect_architecture.cmd @@ -6,11 +6,13 @@ if "%BUILD_ARCH%"=="" ( set WINDOWS_ARCH= Win64 set BUILD_ARCH=x64 ) else ( - set WINDOWS_ARCH= - set BUILD_ARCH=x86 + echo Error: 32 bit builds of blender are no longer supported. + goto ERR ) ) else if "%BUILD_ARCH%"=="x64" ( set WINDOWS_ARCH= Win64 -) else if "%BUILD_ARCH%"=="x86" ( - set WINDOWS_ARCH= ) +:EOF +exit /b 0 +:ERR +exit /b 1
\ No newline at end of file diff --git a/build_files/windows/format.cmd b/build_files/windows/format.cmd index 9dd6f1fc83b..c291dc581ae 100644 --- a/build_files/windows/format.cmd +++ b/build_files/windows/format.cmd @@ -2,10 +2,6 @@ if EXIST %BLENDER_DIR%\..\lib\win64_vc14\llvm\bin\clang-format.exe ( set CF_PATH=..\lib\win64_vc14\llvm\bin goto detect_done ) -if EXIST %BLENDER_DIR%\..\lib\windows_vc14\llvm\bin\clang-format.exe ( - set CF_PATH=..\lib\windows_vc14\llvm\bin - goto detect_done -) echo clang-format not found exit /b 1 diff --git a/build_files/windows/parse_arguments.cmd b/build_files/windows/parse_arguments.cmd index 8c8b473dbcf..3f40ef1f5ef 100644 --- a/build_files/windows/parse_arguments.cmd +++ b/build_files/windows/parse_arguments.cmd @@ -41,10 +41,13 @@ if NOT "%1" == "" ( ) else if "%1" == "release" ( set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\blender_release.cmake" set TARGET=Release + ) else if "%1" == "developer" ( + set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -C"%BLENDER_DIR%\build_files\cmake\config\blender_developer.cmake" ) else if "%1" == "asan" ( set WITH_ASAN=1 - ) else if "%1" == "x86" ( - set BUILD_ARCH=x86 + ) else if "%1" == "x86" ( + echo Error: 32 bit builds of blender are no longer supported. + goto ERR ) else if "%1" == "x64" ( set BUILD_ARCH=x64 ) else if "%1" == "2017" ( @@ -97,10 +100,12 @@ if NOT "%1" == "" ( goto EOF ) else ( echo Command "%1" unknown, aborting! - exit /b 1 + goto ERR ) shift /1 goto argv_loop ) :EOF -exit /b 0
\ No newline at end of file +exit /b 0 +:ERR +exit /b 1
\ No newline at end of file diff --git a/build_files/windows/show_help.cmd b/build_files/windows/show_help.cmd index 08a6c40731c..d0469688b5a 100644 --- a/build_files/windows/show_help.cmd +++ b/build_files/windows/show_help.cmd @@ -17,13 +17,12 @@ echo - format [path] ^(Format the source using clang-format, path is optional, r echo. echo Configuration options echo - verbose ^(enable diagnostic output during configuration^) +echo - developer ^(enable faster builds, error checking and tests, recommended for developers^) echo - with_tests ^(enable building unit tests^) echo - nobuildinfo ^(disable buildinfo^) echo - debug ^(Build an unoptimized debuggable build^) echo - packagename [newname] ^(override default cpack package name^) echo - buildir [newdir] ^(override default build folder^) -echo - x86 ^(override host auto-detect and build 32 bit code^) -echo - x64 ^(override host auto-detect and build 64 bit code^) echo - 2017 ^(build with visual studio 2017^) echo - 2017pre ^(build with visual studio 2017 pre-release^) echo - 2017b ^(build with visual studio 2017 Build Tools^) diff --git a/doc/python_api/rst/info_quickstart.rst b/doc/python_api/rst/info_quickstart.rst index aa3a38974c4..75aeb765f53 100644 --- a/doc/python_api/rst/info_quickstart.rst +++ b/doc/python_api/rst/info_quickstart.rst @@ -317,7 +317,9 @@ To run the script: #. Click the button labeled ``New`` and the confirmation pop up in order to create a new text block. #. Press :kbd:`Ctrl-V` to paste the code into the text panel (the upper left frame). #. Click on the button **Run Script**. -#. Move your cursor into the 3D view, press spacebar for the operator search menu, and type "Simple". +#. Move your cursor into the 3D Viewport, + open the :ref:`operator search menu <blender_manual:bpy.ops.wm.search_menu>`, + and type "Simple". #. Click on the "Simple Operator" item found in search. diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index 3fc92525821..8daa845f830 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -491,6 +491,17 @@ endif() include_directories(${INC}) include_directories(SYSTEM ${INC_SYS}) +if(CMAKE_COMPILER_IS_GNUCC AND (NOT WITH_CYCLES_KERNEL_ASAN)) + # GCC hangs compiling the big kernel files with asan and release, so disable by default. + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-sanitize=all") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-sanitize=vptr") +elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") + # With OSL, Cycles disables rtti in some modules, wich then breaks at linking + # when trying to use vptr sanitizer (included into 'undefined' general option). + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-sanitize=vptr") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-sanitize=vptr") +endif() + set_source_files_properties(kernels/cpu/kernel.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_KERNEL_FLAGS}") set_source_files_properties(kernels/cpu/kernel_split.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_KERNEL_FLAGS}") set_source_files_properties(kernels/cpu/filter.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_KERNEL_FLAGS}") diff --git a/intern/cycles/util/util_simd.h b/intern/cycles/util/util_simd.h index 8fcaadc5f53..f49cfb4184d 100644 --- a/intern/cycles/util/util_simd.h +++ b/intern/cycles/util/util_simd.h @@ -45,7 +45,7 @@ # endif -# if defined(__x86_64__) || defined(__i386__) || defined(_M_X64) || defined(_M_IX86) +# if defined(__x86_64__) || defined(_M_X64) # define SIMD_SET_FLUSH_TO_ZERO \ _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); \ _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); diff --git a/intern/elbeem/CMakeLists.txt b/intern/elbeem/CMakeLists.txt index 926329be61b..383cfa66c15 100644 --- a/intern/elbeem/CMakeLists.txt +++ b/intern/elbeem/CMakeLists.txt @@ -119,4 +119,10 @@ else() add_definitions(-DPARALLEL=0) endif() +# Work around hang with GCC and ASAN. +if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-sanitize=vptr") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-sanitize=vptr") +endif() + blender_add_lib_nolist(bf_intern_elbeem "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/intern/numaapi/source/numaapi_win32.c b/intern/numaapi/source/numaapi_win32.c index bd370707656..f205968b6b4 100644 --- a/intern/numaapi/source/numaapi_win32.c +++ b/intern/numaapi/source/numaapi_win32.c @@ -193,22 +193,22 @@ bool numaAPI_IsNodeAvailable(int node) { // // This is needed because numaApiGetNumNodes() is not guaranteed to // give total amount of nodes and some nodes might be unavailable. - ULONGLONG processor_mask; - if (!_GetNumaNodeProcessorMask(node, &processor_mask)) { + GROUP_AFFINITY processor_mask = { 0 }; + if (!_GetNumaNodeProcessorMaskEx(node, &processor_mask)) { return false; } - if (processor_mask == 0) { + if (processor_mask.Mask == 0) { return false; } return true; } int numaAPI_GetNumNodeProcessors(int node) { - ULONGLONG processor_mask; - if (!_GetNumaNodeProcessorMask(node, &processor_mask)) { + GROUP_AFFINITY processor_mask = { 0 }; + if (!_GetNumaNodeProcessorMaskEx(node, &processor_mask)) { return 0; } - return countNumSetBits(processor_mask); + return countNumSetBits(processor_mask.Mask); } //////////////////////////////////////////////////////////////////////////////// @@ -239,11 +239,12 @@ bool numaAPI_RunProcessOnNode(int node) { // TODO(sergey): Make sure requested node is within active CPU group. // Change affinity of the proces to make it to run on a given node. HANDLE process_handle = GetCurrentProcess(); - ULONGLONG processor_mask; - if (_GetNumaNodeProcessorMask(node, &processor_mask) == 0) { + GROUP_AFFINITY processor_mask = { 0 }; + if (_GetNumaNodeProcessorMaskEx(node, &processor_mask) == 0) { return false; } - if (_SetProcessAffinityMask(process_handle, processor_mask) == 0) { + // TODO: Affinity should respect processor group. + if (_SetProcessAffinityMask(process_handle, processor_mask.Mask) == 0) { return false; } return true; @@ -38,6 +38,7 @@ if "%FORMAT%" == "1" ( ) call "%BLENDER_DIR%\build_files\windows\detect_architecture.cmd" +if errorlevel 1 goto EOF if "%BUILD_VS_YEAR%" == "" ( call "%BLENDER_DIR%\build_files\windows\autodetect_msvc.cmd" diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 8a35a937928..e8e78a86b6a 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -1736,6 +1736,7 @@ def km_info(params): ("info.report_delete", {"type": 'X', "value": 'PRESS'}, None), ("info.report_delete", {"type": 'DEL', "value": 'PRESS'}, None), ("info.report_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + op_menu("INFO_MT_context_menu", params.context_menu_event), ]) return keymap @@ -2128,7 +2129,7 @@ def km_text_generic(_params): ), ("text.start_find", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), ("text.jump", {"type": 'J', "value": 'PRESS', "ctrl": True}, None), - ("text.find", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), + ("text.find_set_selected", {"type": 'G', "value": 'PRESS', "ctrl": True}, None), ("text.replace", {"type": 'H', "value": 'PRESS', "ctrl": True}, None), ]) @@ -2144,10 +2145,6 @@ def km_text(params): ) items.extend([ - ("text.move", {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, - {"properties": [("type", 'PREVIOUS_WORD')]}), - ("text.move", {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, - {"properties": [("type", 'NEXT_WORD')]}), ("wm.context_cycle_int", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "ctrl": True}, {"properties": [("data_path", 'space_data.font_size'), ("reverse", False)]}), ("wm.context_cycle_int", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True}, @@ -2165,6 +2162,11 @@ def km_text(params): else: items.extend([ ("text.new", {"type": 'N', "value": 'PRESS', "ctrl": True}, None), + + ("text.move", {"type": 'LEFT_ARROW', "value": 'PRESS', "alt": True}, + {"properties": [("type", 'PREVIOUS_WORD')]}), + ("text.move", {"type": 'RIGHT_ARROW', "value": 'PRESS', "alt": True}, + {"properties": [("type", 'NEXT_WORD')]}), ]) items.extend([ @@ -2267,7 +2269,7 @@ def km_text(params): {"properties": [("lines", 1)]}), ("text.line_break", {"type": 'RET', "value": 'PRESS'}, None), ("text.line_break", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None), - op_menu("TEXT_MT_toolbox", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}), + op_menu("TEXT_MT_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}), ("text.autocomplete", {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, None), ("text.line_number", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), ("text.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), @@ -2407,6 +2409,10 @@ def km_sequencer(params): {"properties": [("mode", 'TIME_EXTEND')]}), ("marker.add", {"type": 'M', "value": 'PRESS'}, None), ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), + ("sequencer.select",{"type": 'LEFT_BRACKET', "value": 'PRESS'}, + {"properties": [("left_right", 'LEFT'), ("linked_time", True)]}), + ("sequencer.select",{"type": 'RIGHT_BRACKET', "value": 'PRESS'}, + {"properties": [("left_right", 'RIGHT'), ("linked_time", True)]}), ]) return keymap @@ -2444,7 +2450,7 @@ def km_sequencerpreview(params): return keymap -def km_console(_params): +def km_console(params): items = [] keymap = ( "Console", @@ -2504,6 +2510,7 @@ def km_console(_params): ("console.indent", {"type": 'TAB', "value": 'PRESS'}, None), ("console.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None), ("console.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), + op_menu("CONSOLE_MT_context_menu", params.context_menu_event), ]) return keymap diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py index d96a1d335fa..a8fe45c8b15 100644 --- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py +++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py @@ -1136,6 +1136,7 @@ def km_info(params): ("info.report_delete", {"type": 'BACK_SPACE', "value": 'PRESS'}, None), ("info.report_delete", {"type": 'DEL', "value": 'PRESS'}, None), ("info.report_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None), + op_menu("INFO_MT_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}), ]) return keymap @@ -1637,7 +1638,7 @@ def km_text(params): {"properties": [("lines", 1)]}), ("text.line_break", {"type": 'RET', "value": 'PRESS'}, None), ("text.line_break", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None), - op_menu("TEXT_MT_toolbox", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}), + op_menu("TEXT_MT_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS', "any": True}), ("text.autocomplete", {"type": 'SPACE', "value": 'PRESS', "ctrl": True}, None), ("text.line_number", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), ("text.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), @@ -1859,6 +1860,7 @@ def km_console(params): ("console.indent", {"type": 'TAB', "value": 'PRESS'}, None), ("console.unindent", {"type": 'TAB', "value": 'PRESS', "shift": True}, None), ("console.insert", {"type": 'TEXTINPUT', "value": 'ANY', "any": True}, None), + op_menu("CONSOLE_MT_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}), ]) return keymap diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index e4f8daa9c4b..8463277e28c 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -914,7 +914,8 @@ class LoadImageAsEmpty: align=('VIEW' if self.view_align else 'WORLD'), ) - obj = context.active_object + view_layer = context.view_layer + obj = view_layer.objects.active obj.data = image obj.empty_display_size = 5.0 self.set_settings(context, obj) diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 66e96199b08..316ce818530 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -1785,13 +1785,15 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel): col = split.column() col.label(text="Settings:") - row = col.row(align=True) - row.enabled = md.mode == 'FIXED' - row.prop(md, "step") - row = col.row(align=True) - row.enabled = not md.mode == 'FIXED' - row.prop(md, "factor") + if md.mode == 'FIXED': + col.prop(md, "step") + elif md.mode == 'ADAPTIVE': + col.prop(md, "factor") + elif md.mode == 'SAMPLE': + col.prop(md, "length") + elif md.mode == 'MERGE': + col.prop(md, "length", text="Threshold") col = layout.column() col.separator() diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py index 1e5aac4cc0d..6f089f93f00 100644 --- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -606,7 +606,8 @@ class GPENCIL_MT_cleanup(Menu): def draw(self, _context): layout = self.layout - layout.operator("gpencil.frame_clean_loose", text="Loose Points") + layout.operator("gpencil.frame_clean_loose", text="Delete Loose Points") + layout.operator("gpencil.stroke_merge_by_distance", text="Merge by Distance") layout.separator() layout.operator("gpencil.frame_clean_fill", text="Boundary Strokes").mode = 'ACTIVE' diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py index 8db0f8182ab..a9e68ecc502 100644 --- a/release/scripts/startup/bl_ui/properties_material_gpencil.py +++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py @@ -162,6 +162,8 @@ class MATERIAL_PT_gpencil_strokecolor(GPMaterialButtonsPanel, Panel): if gpcolor.mode in {'DOTS', 'BOX'}: col.prop(gpcolor, "alignment_mode") + if gpcolor.mode == 'LINE': + col.prop(gpcolor, "use_overlap_strokes") class MATERIAL_PT_gpencil_fillcolor(GPMaterialButtonsPanel, Panel): bl_label = "Fill" diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 02b809cdfb4..ebbf278c5e7 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -272,7 +272,9 @@ class PARTICLE_PT_emission(ParticleButtonsPanel, Panel): col = layout.column() col.active = part.emit_from == 'VERT' or part.distribution != 'GRID' col.prop(part, "count") - col.prop(psys, "seed") + + if psys is not None: + col.prop(psys, "seed") if part.type == 'HAIR': col.prop(part, "hair_length") diff --git a/release/scripts/startup/bl_ui/space_console.py b/release/scripts/startup/bl_ui/space_console.py index 2e1d0fd2eba..2db1b06c902 100644 --- a/release/scripts/startup/bl_ui/space_console.py +++ b/release/scripts/startup/bl_ui/space_console.py @@ -31,8 +31,6 @@ class CONSOLE_HT_header(Header): CONSOLE_MT_editor_menus.draw_collapsible(context, layout) - layout.operator("console.autocomplete", text="Autocomplete") - class CONSOLE_MT_editor_menus(Menu): bl_idname = "CONSOLE_MT_editor_menus" @@ -40,28 +38,32 @@ class CONSOLE_MT_editor_menus(Menu): def draw(self, _context): layout = self.layout + layout.menu("CONSOLE_MT_view") layout.menu("CONSOLE_MT_console") -class CONSOLE_MT_console(Menu): - bl_label = "Console" +class CONSOLE_MT_view(Menu): + bl_label = "View" def draw(self, _context): layout = self.layout - layout.operator("console.indent") - layout.operator("console.unindent") + props = layout.operator("wm.context_cycle_int", text="Zoom In") + props.data_path = 'space_data.font_size' + props.reverse = False + props = layout.operator("wm.context_cycle_int", text="Zoom Out") + props.data_path = 'space_data.font_size' + props.reverse = True layout.separator() - layout.operator("console.clear") - layout.operator("console.clear_line") + layout.operator("console.move", text="Move to Previous Word").type = 'PREVIOUS_WORD' + layout.operator("console.move", text="Move to Next Word").type = 'NEXT_WORD' + layout.operator("console.move", text="Move to Line Begin").type = 'LINE_BEGIN' + layout.operator("console.move", text="Move to Line End").type = 'LINE_END' layout.separator() - layout.operator("console.copy_as_script") - layout.operator("console.copy") - layout.operator("console.paste") layout.menu("CONSOLE_MT_language") layout.separator() @@ -92,17 +94,81 @@ class CONSOLE_MT_language(Menu): translate=False).language = language +class CONSOLE_MT_console(Menu): + bl_label = "Console" + + def draw(self, _context): + layout = self.layout + + layout.operator("console.clear") + layout.operator("console.clear_line") + layout.operator("console.delete", text="Delete Previous Word").type = 'PREVIOUS_WORD' + layout.operator("console.delete", text="Delete Next Word").type = 'NEXT_WORD' + + layout.separator() + + layout.operator("console.copy_as_script", text="Copy as Script") + layout.operator("console.copy", text="Copy") + layout.operator("console.paste", text="Paste") + + layout.separator() + + layout.operator("console.indent") + layout.operator("console.unindent") + + layout.separator() + + layout.operator("console.history_cycle", text="Backward in History").reverse = True + layout.operator("console.history_cycle", text="Forward in History").reverse = False + + layout.separator() + + layout.operator("console.autocomplete", text="Autocomplete") + +class CONSOLE_MT_context_menu(Menu): + bl_label = "Console Context Menu" + + def draw(self, context): + layout = self.layout + + layout.operator("console.clear") + layout.operator("console.clear_line") + layout.operator("console.delete", text="Delete Previous Word").type = 'PREVIOUS_WORD' + layout.operator("console.delete", text="Delete Next Word").type = 'NEXT_WORD' + + layout.separator() + + layout.operator("console.copy_as_script", text="Copy as Script") + layout.operator("console.copy", text="Copy") + layout.operator("console.paste", text="Paste") + + layout.separator() + + layout.operator("console.indent") + layout.operator("console.unindent") + + layout.separator() + + layout.operator("console.history_cycle", text="Backward in History").reverse = True + layout.operator("console.history_cycle", text="Forward in History").reverse = False + + layout.separator() + + layout.operator("console.autocomplete", text="Autocomplete") + + def add_scrollback(text, text_type): for l in text.split("\n"): - bpy.ops.console.scrollback_append(text=l.expandtabs(4), - type=text_type) + bpy.ops.console.scrollback_append(text=l.expandtabs(4), type=text_type) classes = ( CONSOLE_HT_header, CONSOLE_MT_editor_menus, - CONSOLE_MT_console, + CONSOLE_MT_view, CONSOLE_MT_language, + CONSOLE_MT_console, + CONSOLE_MT_context_menu, ) if __name__ == "__main__": # only for live edit. diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py index b02a17e7270..3b1b33b26e9 100644 --- a/release/scripts/startup/bl_ui/space_dopesheet.py +++ b/release/scripts/startup/bl_ui/space_dopesheet.py @@ -361,7 +361,7 @@ class DOPESHEET_MT_select(Menu): layout.separator() layout.operator("action.select_box").axis_range = False - layout.operator("action.select_box", text="Border Axis Range").axis_range = True + layout.operator("action.select_box", text="Box Select (Axis Range)").axis_range = True layout.operator("action.select_circle") diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py index 7af2e8cd0a6..b6195d1626a 100644 --- a/release/scripts/startup/bl_ui/space_graph.py +++ b/release/scripts/startup/bl_ui/space_graph.py @@ -169,10 +169,10 @@ class GRAPH_MT_select(Menu): props = layout.operator("graph.select_box") props.axis_range = False props.include_handles = False - props = layout.operator("graph.select_box", text="Border Axis Range") + props = layout.operator("graph.select_box", text="Box Select (Axis Range)") props.axis_range = True props.include_handles = False - props = layout.operator("graph.select_box", text="Border (Include Handles)") + props = layout.operator("graph.select_box", text="Box Select (Include Handles)") props.axis_range = False props.include_handles = True @@ -336,7 +336,6 @@ class GRAPH_MT_context_menu(Menu): layout.separator() - layout.operator_menu_enum("graph.keyframe_type", "type", text="Keyframe Type") layout.operator_menu_enum("graph.handle_type", "type", text="Handle Type") layout.operator_menu_enum("graph.interpolation_type", "type", text="Interpolation Mode") layout.operator_menu_enum("graph.easing_type", "type", text="Easing Type") diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index eea34beaad1..06505c54c9c 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -176,6 +176,7 @@ class IMAGE_MT_select(Menu): layout.separator() layout.operator("uv.select_split") + layout.operator("uv.select_overlap") class IMAGE_MT_brush(Menu): diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index a8aa0d9d0b6..eabf71365d5 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -23,14 +23,60 @@ from bpy.types import Header, Menu class INFO_HT_header(Header): bl_space_type = 'INFO' - def draw(self, _context): + def draw(self, context): layout = self.layout layout.template_header() - # Empty for now until info editor gets turned into log editor + INFO_MT_editor_menus.draw_collapsible(context, layout) + + +class INFO_MT_editor_menus(Menu): + bl_idname = "INFO_MT_editor_menus" + bl_label = "" + + def draw(self, context): + layout = self.layout + layout.menu("INFO_MT_view") + layout.menu("INFO_MT_info") + + +class INFO_MT_view(Menu): + bl_label = "View" + + def draw(self, context): + layout = self.layout + + layout.menu("INFO_MT_area") + + +class INFO_MT_info(Menu): + bl_label = "Info" + + def draw(self, context): + layout = self.layout + + layout.operator("info.select_all", text="Select All").action = 'SELECT' + layout.operator("info.select_all", text="Deselect All").action = 'DESELECT' + layout.operator("info.select_all", text="Invert Selection").action = 'INVERT' + layout.operator("info.select_all", text="Toggle Selection").action = 'TOGGLE' + + layout.separator() + + layout.operator("info.select_box") + + layout.separator() + + # Disabled because users will likely try this and find + # it doesn't work all that well in practice. + # Mainly because operators needs to run in the right context. + + # layout.operator("info.report_replay") + # layout.separator() + + layout.operator("info.report_delete", text="Delete") + layout.operator("info.report_copy", text="Copy") -# Not really info, just add to re-usable location. class INFO_MT_area(Menu): bl_label = "Area" @@ -58,9 +104,22 @@ class INFO_MT_area(Menu): ).use_hide_panels = True +class INFO_MT_context_menu(Menu): + bl_label = "Info Context Menu" + + def draw(self, context): + layout = self.layout + + layout.operator("info.report_copy", text="Copy") + layout.operator("info.report_delete", text="Delete") + classes = ( INFO_HT_header, + INFO_MT_editor_menus, INFO_MT_area, + INFO_MT_view, + INFO_MT_info, + INFO_MT_context_menu, ) if __name__ == "__main__": # only for live edit. diff --git a/release/scripts/startup/bl_ui/space_nla.py b/release/scripts/startup/bl_ui/space_nla.py index 06bd69928d8..aaa971cfa55 100644 --- a/release/scripts/startup/bl_ui/space_nla.py +++ b/release/scripts/startup/bl_ui/space_nla.py @@ -126,7 +126,7 @@ class NLA_MT_select(Menu): layout.separator() layout.operator("nla.select_box").axis_range = False - layout.operator("nla.select_box", text="Border Axis Range").axis_range = True + layout.operator("nla.select_box", text="Box Select (Axis Range)").axis_range = True layout.separator() props = layout.operator("nla.select_leftright", text="Before Current Frame") diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index d5ef24d7ff3..f12dff248ed 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -185,6 +185,27 @@ class SEQUENCER_MT_range(Menu): layout.operator("anim.end_frame_set", text="Set End Frame") +class SEQUENCER_MT_preview_zoom(Menu): + bl_label = "Fractional Zoom" + + def draw(self, context): + layout = self.layout + layout.operator_context = 'INVOKE_REGION_PREVIEW' + + ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1)) + + for i, (a, b) in enumerate(ratios): + if i in {3, 4}: # Draw separators around Zoom 1:1. + layout.separator() + + layout.operator( + "sequencer.view_zoom_ratio", + text=iface_(f"Zoom {a:d}:{b:d}"), + translate=False, + ).ratio = a / b + layout.operator_context = 'INVOKE_DEFAULT' + + class SEQUENCER_MT_view(Menu): bl_label = "View" @@ -194,6 +215,8 @@ class SEQUENCER_MT_view(Menu): st = context.space_data is_preview = st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'} is_sequencer_view = st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'} + scene = context.scene + ed = scene.sequence_editor if st.view_type == 'PREVIEW': # Specifying the REGION_PREVIEW context is needed in preview-only @@ -214,6 +237,21 @@ class SEQUENCER_MT_view(Menu): layout.operator("sequencer.view_all", text="Frame All") layout.operator("view2d.zoom_border", text="Zoom") + if is_preview: + layout.operator_context = 'INVOKE_REGION_PREVIEW' + layout.separator() + + layout.operator("sequencer.view_all_preview", text="Fit Preview in Window") + + if is_sequencer_view: + layout.menu("SEQUENCER_MT_preview_zoom", text="Fractional Preview Zoom") + else: + layout.operator("view2d.zoom_border", text="Zoom") + layout.menu("SEQUENCER_MT_preview_zoom") + + layout.operator_context = 'INVOKE_DEFAULT' + + if is_sequencer_view: layout.separator() layout.operator_context = 'INVOKE_DEFAULT' @@ -227,47 +265,26 @@ class SEQUENCER_MT_view(Menu): layout.separator() layout.operator_context = 'INVOKE_DEFAULT' - if is_preview: - layout.operator_context = 'INVOKE_REGION_PREVIEW' - layout.operator("sequencer.view_all_preview", text="Fit Preview in window") - layout.operator("view2d.zoom_border", text="Zoom") - - layout.separator() - - ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1)) - - for a, b in ratios: - layout.operator( - "sequencer.view_zoom_ratio", - text=iface_("Zoom %d:%d") % (a, b), - translate=False, - ).ratio = a / b +# layout.prop(st, "show_frame_indicator") #Do not have any function and do not work. + layout.prop(st, "show_strip_offset") + layout.prop(st, "show_marker_lines") + if is_preview: layout.separator() - - layout.operator_context = 'INVOKE_DEFAULT' - - # # XXX, invokes in the header view - # layout.operator("sequencer.view_ghost_border", text="Overlay Border") + if st.display_mode == 'IMAGE': + layout.prop(ed, "show_overlay", text="Show Frame Overlay") + layout.prop(st, "show_safe_areas", text="Show Safe Areas") + layout.prop(st, "show_metadata", text="Show Metadata") + layout.prop(st, "show_annotation", text="Show Annotations") + elif st.display_mode == 'WAVEFORM': + layout.prop(st, "show_separate_color", text="Show Separate Color Channels") if is_sequencer_view: - layout.prop(st, "show_seconds") - layout.prop(st, "show_frame_indicator") - layout.prop(st, "show_strip_offset") - layout.prop(st, "show_marker_lines") - layout.separator() layout.menu("SEQUENCER_MT_view_cache") layout.prop_menu_enum(st, "waveform_display_type") - if is_preview: - if st.display_mode == 'IMAGE': - layout.prop(st, "show_safe_areas") - layout.prop(st, "show_metadata") - elif st.display_mode == 'WAVEFORM': - layout.prop(st, "show_separate_color") - layout.separator() layout.operator("render.opengl", text="Sequence Render Image", icon='RENDER_STILL').sequencer = True @@ -276,6 +293,9 @@ class SEQUENCER_MT_view(Menu): props.sequencer = True layout.separator() + layout.operator("sequencer.export_subtitles", text="Export Subtitles", icon="EXPORT") + + layout.separator() layout.menu("INFO_MT_area") @@ -670,7 +690,7 @@ class SEQUENCER_MT_strip(Menu): 'CROSS', 'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP', 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED', 'MULTICAM', 'ADJUSTMENT', - 'GAUSSIAN_BLUR', 'TEXT', + 'GAUSSIAN_BLUR', }: layout.separator() layout.menu("SEQUENCER_MT_strip_effect") @@ -681,6 +701,9 @@ class SEQUENCER_MT_strip(Menu): layout.separator() layout.operator("sequencer.rendersize") layout.operator("sequencer.images_separate") + elif strip_type == 'TEXT': + layout.separator() + layout.menu("SEQUENCER_MT_strip_effect") elif strip_type == 'META': layout.separator() layout.operator("sequencer.meta_make") @@ -752,7 +775,7 @@ class SEQUENCER_MT_context_menu(Menu): 'CROSS', 'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP', 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED', 'MULTICAM', 'ADJUSTMENT', - 'GAUSSIAN_BLUR', 'TEXT', + 'GAUSSIAN_BLUR', }: layout.separator() layout.menu("SEQUENCER_MT_strip_effect") @@ -763,6 +786,9 @@ class SEQUENCER_MT_context_menu(Menu): layout.separator() layout.operator("sequencer.rendersize") layout.operator("sequencer.images_separate") + elif strip_type == 'TEXT': + layout.separator() + layout.menu("SEQUENCER_MT_strip_effect") elif strip_type == 'META': layout.separator() layout.operator("sequencer.meta_make") @@ -1038,26 +1064,10 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): col.label(text="Two or more channels are needed below this strip", icon='INFO') elif strip_type == 'TEXT': - col = layout.column() - col.prop(strip, "text") - col.template_ID(strip, "font", open="font.open", unlink="font.unlink") - col.prop(strip, "font_size") - - row = col.row() - row.prop(strip, "color") - row = col.row() - row.prop(strip, "use_shadow") - rowsub = row.row() - rowsub.active = strip.use_shadow - rowsub.prop(strip, "shadow_color", text="") - - col.prop(strip, "align_x", text="Horizontal") - col.prop(strip, "align_y", text="Vertical") - row = col.row(align=True) - row.prop(strip, "location", text="Location", slider=True) - col.prop(strip, "wrap_width") - - layout.operator("sequencer.export_subtitles", text="Export Subtitles", icon='EXPORT') + layout = self.layout + layout.use_property_split = False + layout.prop(strip, "text", text="") + layout.use_property_split = True col = layout.column(align=True) if strip_type == 'SPEED': @@ -1076,6 +1086,73 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): row.prop(strip, "factor", slider=True) +class SEQUENCER_PT_effect_text_layout(SequencerButtonsPanel, Panel): + bl_label = "Layout" + bl_parent_id = "SEQUENCER_PT_effect" + bl_category = "Strip" + + @classmethod + def poll(cls, context): + strip = act_strip(context) + return strip.type == 'TEXT' + + def draw(self, context): + strip = act_strip(context) + layout = self.layout + layout.use_property_split = True + col = layout.column() + col.prop(strip, "location", text="Location") + col.prop(strip, "align_x", text="Alignment X") + col.prop(strip, "align_y", text="Y") + col.prop(strip, "wrap_width", text="Wrap Width") + + +class SEQUENCER_PT_effect_text_style(SequencerButtonsPanel, Panel): + bl_label = "Style" + bl_parent_id = "SEQUENCER_PT_effect" + bl_category = "Strip" + + @classmethod + def poll(cls, context): + strip = act_strip(context) + return strip.type == 'TEXT' + + def draw(self, context): + strip = act_strip(context) + layout = self.layout + layout.use_property_split = True + col = layout.column() + col.template_ID(strip, "font", open="font.open", unlink="font.unlink") + col.prop(strip, "font_size") + col.prop(strip, "color") + + +class SEQUENCER_PT_effect_text_style_shadow(SequencerButtonsPanel, Panel): + bl_label = "Shadow" + bl_parent_id = "SEQUENCER_PT_effect_text_style" + bl_options = {'DEFAULT_CLOSED'} + bl_category = "Strip" + + @classmethod + def poll(cls, context): + strip = act_strip(context) + return strip.type != 'SOUND' + + def draw_header(self, context): + strip = act_strip(context) + self.layout.prop(strip, "use_shadow", text="") + + def draw(self, context): + strip = act_strip(context) + layout = self.layout + layout.use_property_split = True + + layout.active = strip.use_shadow and (not strip.mute) + + col = layout.column(align=True) + col.prop(strip, "shadow_color", text="Color") + + class SEQUENCER_PT_source(SequencerButtonsPanel, Panel): bl_label = "Source" bl_options = {'DEFAULT_CLOSED'} @@ -1843,6 +1920,11 @@ class SEQUENCER_PT_frame_overlay(SequencerButtonsPanel_Output, Panel): def draw(self, context): layout = self.layout + + layout.operator_context = 'INVOKE_REGION_PREVIEW' + layout.operator("sequencer.view_ghost_border", text="Set Overlay Region") + layout.operator_context = 'INVOKE_DEFAULT' + layout.use_property_split = True layout.use_property_decorate = False @@ -2024,6 +2106,7 @@ classes = ( SEQUENCER_MT_view, SEQUENCER_MT_view_cache, SEQUENCER_MT_view_toggle, + SEQUENCER_MT_preview_zoom, SEQUENCER_MT_select_playhead, SEQUENCER_MT_select_handle, SEQUENCER_MT_select_channel, @@ -2057,6 +2140,9 @@ classes = ( SEQUENCER_PT_effect, SEQUENCER_PT_scene, SEQUENCER_PT_mask, + SEQUENCER_PT_effect_text_style, + SEQUENCER_PT_effect_text_layout, + SEQUENCER_PT_effect_text_style_shadow, SEQUENCER_PT_time, SEQUENCER_PT_source, diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py index 91984131464..1ffb181b219 100644 --- a/release/scripts/startup/bl_ui/space_text.py +++ b/release/scripts/startup/bl_ui/space_text.py @@ -47,6 +47,11 @@ class TEXT_HT_header(Header): layout.separator_spacer() + row = layout.row(align=True) + row.prop(st, "show_line_numbers", text="") + row.prop(st, "show_word_wrap", text="") + row.prop(st, "show_syntax_highlight", text="") + if text: is_osl = text.name.endswith((".osl", ".osl")) @@ -107,6 +112,7 @@ class TEXT_MT_editor_menus(Menu): if text: layout.menu("TEXT_MT_edit") + layout.menu("TEXT_MT_select") layout.menu("TEXT_MT_format") layout.menu("TEXT_MT_templates") @@ -179,6 +185,33 @@ class TEXT_PT_find(Panel): row.prop(st, "use_find_all", text="All", toggle=True) +class TEXT_MT_view_navigation(Menu): + bl_label = "Navigation" + + def draw(self, context): + layout = self.layout + + st = context.space_data + + layout.operator("text.move", text="Top").type = 'FILE_TOP' + layout.operator("text.move", text="Bottom").type = 'FILE_BOTTOM' + + layout.separator() + + layout.operator("text.move", text="Line Begin").type = 'LINE_BEGIN' + layout.operator("text.move", text="Line End").type = 'LINE_END' + + layout.separator() + + layout.operator("text.move", text="Previous Line").type = 'PREVIOUS_LINE' + layout.operator("text.move", text="Next Line").type = 'NEXT_LINE' + + layout.separator() + + layout.operator("text.move", text="Previous Word").type = 'PREVIOUS_WORD' + layout.operator("text.move", text="Next Word").type = 'NEXT_WORD' + + class TEXT_MT_view(Menu): bl_label = "View" @@ -198,12 +231,7 @@ class TEXT_MT_view(Menu): layout.separator() - layout.operator("text.move", - text="Top of File", - ).type = 'FILE_TOP' - layout.operator("text.move", - text="Bottom of File", - ).type = 'FILE_BOTTOM' + layout.menu("TEXT_MT_view_navigation") layout.separator() @@ -219,7 +247,7 @@ class TEXT_MT_text(Menu): st = context.space_data text = st.text - layout.operator("text.new", text="New") + layout.operator("text.new", text="New", icon='FILE_NEW') layout.operator("text.open", text="Open...", icon='FILE_FOLDER') if text: @@ -231,9 +259,18 @@ class TEXT_MT_text(Menu): layout.operator("text.save_as", text="Save As...") if text.filepath: + layout.separator() layout.operator("text.make_internal") layout.separator() + row = layout.row() + row.active = text.name.endswith(".py") + row.prop(text, "use_module") + row = layout.row() + + layout.prop(st, "use_live_edit") + + layout.separator() layout.operator("text.run_script") @@ -270,14 +307,35 @@ class TEXT_MT_templates(Menu): layout.menu("TEXT_MT_templates_osl") -class TEXT_MT_edit_select(Menu): +class TEXT_MT_select(Menu): bl_label = "Select" def draw(self, _context): layout = self.layout - layout.operator("text.select_all") - layout.operator("text.select_line") + layout.operator("text.select_all", text="All") + layout.operator("text.select_line", text="Line") + layout.operator("text.select_word", text="Word") + + layout.separator() + + layout.operator("text.move_select", text="Top").type = 'FILE_TOP' + layout.operator("text.move_select", text="Bottom").type = 'FILE_BOTTOM' + + layout.separator() + + layout.operator("text.move_select", text="Line Begin").type = 'LINE_BEGIN' + layout.operator("text.move_select", text="Line End").type = 'LINE_END' + + layout.separator() + + layout.operator("text.move_select", text="Previous Line").type = 'PREVIOUS_LINE' + layout.operator("text.move_select", text="Next Line").type = 'NEXT_LINE' + + layout.separator() + + layout.operator("text.move_select", text="Previous Word").type = 'PREVIOUS_WORD' + layout.operator("text.move_select", text="Next Word").type = 'NEXT_WORD' class TEXT_MT_format(Menu): @@ -335,23 +393,17 @@ class TEXT_MT_edit(Menu): layout.separator() - layout.prop(st, "use_live_edit") - - layout.separator() - - layout.operator("text.move_lines", - text="Move line(s) up").direction = 'UP' - layout.operator("text.move_lines", - text="Move line(s) down").direction = 'DOWN' + layout.operator("text.move_lines", text="Move Line(s) Up").direction = 'UP' + layout.operator("text.move_lines", text="Move Line(s) Down").direction = 'DOWN' layout.separator() - layout.menu("TEXT_MT_edit_select") + layout.operator("text.start_find", text="Find & Replace...") + layout.operator("text.find_set_selected", text="Find Next") + layout.operator("text.jump", text="Jump To...") layout.separator() - layout.operator("text.jump") - layout.operator("text.start_find", text="Find...") layout.operator("text.autocomplete") layout.separator() @@ -359,7 +411,7 @@ class TEXT_MT_edit(Menu): layout.menu("TEXT_MT_edit_to3d") -class TEXT_MT_toolbox(Menu): +class TEXT_MT_context_menu(Menu): bl_label = "" def draw(self, _context): @@ -370,14 +422,12 @@ class TEXT_MT_toolbox(Menu): layout.operator("text.cut") layout.operator("text.copy", icon='COPYDOWN') layout.operator("text.paste", icon='PASTEDOWN') + layout.operator("text.duplicate_line") layout.separator() - layout.operator("text.duplicate_line") - layout.operator("text.move_lines", - text="Move Lines Up").direction = 'UP' - layout.operator("text.move_lines", - text="Move Lines Down").direction = 'DOWN' + layout.operator("text.move_lines", text="Move Line(s) Up").direction = 'UP' + layout.operator("text.move_lines", text="Move Line(s) Down").direction = 'DOWN' layout.separator() @@ -386,8 +436,7 @@ class TEXT_MT_toolbox(Menu): layout.separator() - layout.operator("text.comment", text="Comment") - layout.operator("text.uncomment", text="Uncomment") + layout.operator("text.comment_toggle") layout.separator() @@ -402,14 +451,15 @@ classes = ( TEXT_PT_find, TEXT_PT_properties, TEXT_MT_view, + TEXT_MT_view_navigation, TEXT_MT_text, TEXT_MT_templates, TEXT_MT_templates_py, TEXT_MT_templates_osl, - TEXT_MT_edit_select, + TEXT_MT_select, TEXT_MT_format, TEXT_MT_edit_to3d, - TEXT_MT_toolbox, + TEXT_MT_context_menu, ) if __name__ == "__main__": # only for live edit. diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 08f36bb15bb..128d6100a27 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -44,9 +44,11 @@ class USERPREF_HT_header(Header): if prefs.use_preferences_save and (not bpy.app.use_userpref_skip_save_on_exit): pass else: - sub = row.row(align=True) - sub.active = prefs.is_dirty - sub.operator("wm.save_userpref") + # Show '*' to let users know the preferences have been modified. + row.operator( + "wm.save_userpref", + text="Save Preferences{:s}".format(" *" if prefs.is_dirty else ""), + ) def draw(self, context): layout = self.layout @@ -427,7 +429,6 @@ class USERPREF_PT_edit_annotations(PreferencePanel, Panel): flow.prop(edit, "grease_pencil_default_color", text="Default Color") flow.prop(edit, "grease_pencil_eraser_radius", text="Eraser Radius") - flow.prop(edit, "use_grease_pencil_simplify_stroke", text="Simplify Stroke") class USERPREF_PT_edit_weight_paint(PreferencePanel, Panel): diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 582d4fe1258..65619ffd285 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -761,6 +761,8 @@ class VIEW3D_MT_editor_menus(Menu): layout.menu("VIEW3D_MT_paint_gpencil") elif obj and obj.mode == 'EDIT_GPENCIL': layout.menu("VIEW3D_MT_edit_gpencil") + layout.menu("VIEW3D_MT_edit_gpencil_stroke") + layout.menu("VIEW3D_MT_edit_gpencil_point") elif obj and obj.mode == 'WEIGHT_GPENCIL': layout.menu("VIEW3D_MT_weight_gpencil") @@ -779,10 +781,7 @@ class VIEW3D_MT_editor_menus(Menu): elif obj: if mode_string != 'PAINT_TEXTURE': layout.menu("VIEW3D_MT_%s" % mode_string.lower()) - if mode_string in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT', 'PAINT_TEXTURE'}: - layout.menu("VIEW3D_MT_brush") - if mode_string == 'SCULPT': - layout.menu("VIEW3D_MT_hide_mask") + else: layout.menu("VIEW3D_MT_object") @@ -2643,63 +2642,6 @@ class VIEW3D_MT_make_links(Menu): layout.operator("object.join_uvs") # stupid place to add this! -class VIEW3D_MT_brush(Menu): - bl_label = "Brush" - - def draw(self, context): - layout = self.layout - - tool_settings = context.tool_settings - settings = UnifiedPaintPanel.paint_settings(context) - brush = getattr(settings, "brush", None) - - ups = tool_settings.unified_paint_settings - layout.prop(ups, "use_unified_size", text="Unified Size") - layout.prop(ups, "use_unified_strength", text="Unified Strength") - if context.image_paint_object or context.vertex_paint_object: - layout.prop(ups, "use_unified_color", text="Unified Color") - layout.separator() - - # skip if no active brush - if not brush: - layout.label(text="No Brushes currently available", icon='INFO') - return - - # brush paint modes - layout.menu("VIEW3D_MT_brush_paint_modes") - - # brush tool - if context.sculpt_object: - layout.operator("brush.reset") - layout.prop_menu_enum(brush, "sculpt_tool") - elif context.image_paint_object: - layout.prop_menu_enum(brush, "image_tool") - elif context.vertex_paint_object: - layout.prop_menu_enum(brush, "vertex_tool") - elif context.weight_paint_object: - layout.prop_menu_enum(brush, "weight_tool") - - # TODO: still missing a lot of brush options here - - # sculpt options - if context.sculpt_object: - - sculpt_tool = brush.sculpt_tool - - layout.separator() - layout.prop_menu_enum(brush, "curve_preset") - layout.separator() - - if sculpt_tool != 'GRAB': - layout.prop_menu_enum(brush, "stroke_method") - - if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}: - layout.prop_menu_enum(brush, "direction") - - if sculpt_tool == 'LAYER': - layout.prop(brush, "use_persistent") - layout.operator("sculpt.set_persistent_base") - class VIEW3D_MT_brush_paint_modes(Menu): bl_label = "Enabled Modes" @@ -2788,6 +2730,27 @@ class VIEW3D_MT_vertex_group(Menu): layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True +class VIEW3D_MT_gpencil_vertex_group(Menu): + bl_label = "Vertex Groups" + + def draw(self, context): + layout = self.layout + + layout.operator_context = 'EXEC_AREA' + ob = context.active_object + + layout.operator("object.vertex_group_add", text="Add New Group") + ob = context.active_object + if ob.vertex_groups.active: + layout.separator() + + layout.operator("gpencil.vertex_group_assign", text="Assign") + layout.operator("gpencil.vertex_group_remove_from", text="Remove") + + layout.operator("gpencil.vertex_group_select", text="Select") + layout.operator("gpencil.vertex_group_deselect", text="Deselect") + + class VIEW3D_MT_paint_weight(Menu): bl_label = "Weights" @@ -2839,38 +2802,6 @@ class VIEW3D_MT_sculpt(Menu): def draw(self, context): layout = self.layout - tool_settings = context.tool_settings - sculpt = tool_settings.sculpt - - layout.operator("sculpt.dynamic_topology_toggle", text="Toggle Dynamic Topology") - - layout.separator() - - layout.prop(sculpt, "use_symmetry_x") - layout.prop(sculpt, "use_symmetry_y") - layout.prop(sculpt, "use_symmetry_z") - - layout.separator() - - layout.prop(sculpt, "lock_x") - layout.prop(sculpt, "lock_y") - layout.prop(sculpt, "lock_z") - - layout.separator() - - layout.prop(sculpt, "use_threaded", text="Threaded Sculpt") - layout.prop(sculpt, "show_low_resolution") - layout.prop(sculpt, "show_brush") - layout.prop(sculpt, "use_deform_only") - layout.prop(sculpt, "show_mask") - - -class VIEW3D_MT_hide_mask(Menu): - bl_label = "Hide/Mask" - - def draw(self, _context): - layout = self.layout - props = layout.operator("paint.hide_show", text="Show All") props.action = 'SHOW' props.area = 'ALL' @@ -2885,7 +2816,6 @@ class VIEW3D_MT_hide_mask(Menu): props = layout.operator("paint.hide_show", text="Hide Masked") props.area = 'MASKED' - props.action = 'HIDE' layout.separator() @@ -4447,6 +4377,7 @@ class VIEW3D_MT_gpencil_simplify(Menu): layout = self.layout layout.operator("gpencil.stroke_simplify_fixed", text="Fixed") layout.operator("gpencil.stroke_simplify", text="Adaptive") + layout.operator("gpencil.stroke_sample", text="Sample") class VIEW3D_MT_paint_gpencil(Menu): @@ -4457,7 +4388,6 @@ class VIEW3D_MT_paint_gpencil(Menu): layout = self.layout layout.menu("VIEW3D_MT_gpencil_animation") - layout.menu("VIEW3D_MT_edit_gpencil_interpolate") layout.separator() @@ -4501,46 +4431,58 @@ class VIEW3D_MT_gpencil_copy_layer(Menu): class VIEW3D_MT_edit_gpencil(Menu): - bl_label = "Strokes" + bl_label = "Grease Pencil" def draw(self, _context): layout = self.layout layout.menu("VIEW3D_MT_edit_gpencil_transform") - - layout.separator() + layout.menu("VIEW3D_MT_mirror") layout.menu("GPENCIL_MT_snap") layout.separator() layout.menu("VIEW3D_MT_gpencil_animation") - layout.menu("VIEW3D_MT_edit_gpencil_interpolate") layout.separator() # Cut, Copy, Paste layout.operator("gpencil.duplicate_move", text="Duplicate") + layout.operator("gpencil.stroke_split", text="Split") layout.operator("gpencil.copy", text="Copy", icon='COPYDOWN') layout.operator("gpencil.paste", text="Paste", icon='PASTEDOWN').type = 'COPY' layout.operator("gpencil.paste", text="Paste & Merge").type = 'MERGE' layout.separator() - layout.operator("gpencil.stroke_smooth", text="Smooth") - layout.operator("gpencil.stroke_subdivide", text="Subdivide") + layout.menu("VIEW3D_MT_weight_gpencil") + + layout.separator() + + layout.menu("VIEW3D_MT_edit_gpencil_showhide") + + layout.operator_menu_enum("gpencil.stroke_separate", "mode") + layout.menu("GPENCIL_MT_cleanup") + + layout.separator() + + # Remove + layout.menu("VIEW3D_MT_edit_gpencil_delete") + + +class VIEW3D_MT_edit_gpencil_stroke(Menu): + bl_label = "Stroke" + + def draw(self, _context): + layout = self.layout + + layout.operator("gpencil.stroke_subdivide", text="Subdivide").only_selected = False layout.menu("VIEW3D_MT_gpencil_simplify") layout.operator("gpencil.stroke_trim", text="Trim") layout.separator() - layout.operator_menu_enum("gpencil.stroke_separate", "mode", text="Separate...") - layout.operator("gpencil.stroke_split", text="Split") - layout.operator("gpencil.stroke_merge", text="Merge") - op = layout.operator("gpencil.stroke_cyclical_set", text="Close") - op.type = 'CLOSE' - op.geometry = True layout.operator_menu_enum("gpencil.stroke_join", "type", text="Join...") - layout.operator("gpencil.stroke_flip", text="Flip Direction") layout.separator() @@ -4551,14 +4493,35 @@ class VIEW3D_MT_edit_gpencil(Menu): layout.separator() # Convert + op = layout.operator("gpencil.stroke_cyclical_set", text="Close") + op.type = 'CLOSE' + op.geometry = True layout.operator("gpencil.stroke_cyclical_set", text="Toggle Cyclic").type = 'TOGGLE' layout.operator_menu_enum("gpencil.stroke_caps_set", text="Toggle Caps...", property="type") + layout.operator("gpencil.stroke_flip", text="Switch Direction") + + +class VIEW3D_MT_edit_gpencil_point(Menu): + bl_label = "Point" + + def draw(self, _context): + layout = self.layout + + layout.operator("gpencil.extrude_move", text="Extrude Points") layout.separator() - # Remove - layout.menu("GPENCIL_MT_cleanup") - layout.menu("VIEW3D_MT_edit_gpencil_delete") + layout.operator("gpencil.stroke_smooth", text="Smooth Points").only_selected = True + + layout.separator() + + layout.operator("gpencil.stroke_merge", text="Merge Points") + + # TODO: add new RIP operator + + layout.separator() + + layout.menu("VIEW3D_MT_gpencil_vertex_group") class VIEW3D_MT_weight_gpencil(Menu): @@ -4571,10 +4534,12 @@ class VIEW3D_MT_weight_gpencil(Menu): layout.operator("gpencil.vertex_group_normalize", text="Normalize") layout.separator() + layout.operator("gpencil.vertex_group_invert", text="Invert") layout.operator("gpencil.vertex_group_smooth", text="Smooth") layout.separator() + layout.menu("VIEW3D_MT_gpencil_autoweights") @@ -4590,12 +4555,17 @@ class VIEW3D_MT_gpencil_animation(Menu): layout = self.layout layout.operator("gpencil.blank_frame_add") - layout.operator("gpencil.active_frames_delete_all", text="Delete Frame(s)") layout.separator() + layout.operator("gpencil.frame_duplicate", text="Duplicate Active Frame") layout.operator("gpencil.frame_duplicate", text="Duplicate All Layers").mode = 'ALL' + layout.separator() + + layout.operator("gpencil.delete", text="Delete Active Frame").type = 'FRAME' + layout.operator("gpencil.active_frames_delete_all", text="Delete All Active Frames") + class VIEW3D_MT_edit_gpencil_transform(Menu): bl_label = "Transform" @@ -4615,14 +4585,17 @@ class VIEW3D_MT_edit_gpencil_transform(Menu): layout.operator("transform.transform", text="Shrink Fatten").mode = 'GPENCIL_SHRINKFATTEN' -class VIEW3D_MT_edit_gpencil_interpolate(Menu): - bl_label = "Interpolate" + layout.operator("gpencil.interpolate", text="Interpolate") + layout.operator("gpencil.interpolate_sequence", text="Sequence") + +class VIEW3D_MT_edit_gpencil_showhide(Menu): + bl_label = "Show/hide" def draw(self, _context): layout = self.layout - layout.operator("gpencil.interpolate", text="Interpolate") - layout.operator("gpencil.interpolate_sequence", text="Sequence") + layout.operator("gpencil.hide", text="Hide Active Layer") + layout.operator("gpencil.reveal", text="Show All Layers") class VIEW3D_MT_object_mode_pie(Menu): @@ -5801,23 +5774,36 @@ class VIEW3D_PT_overlay_pose(Panel): row.prop(overlay, "show_xray_bone") -class VIEW3D_PT_overlay_paint(Panel): +class VIEW3D_PT_overlay_texture_paint(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' bl_parent_id = 'VIEW3D_PT_overlay' - bl_label = "" + bl_label = "Texture Paint" @classmethod def poll(cls, context): - return context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'} + return context.mode == 'PAINT_TEXTURE' - def draw_header(self, context): + def draw(self, context): layout = self.layout - layout.label(text={ - 'PAINT_TEXTURE': "Texture Paint", - 'PAINT_VERTEX': "Vertex Paint", - 'PAINT_WEIGHT': "Weight Paint", - }[context.mode]) + view = context.space_data + overlay = view.overlay + display_all = overlay.show_overlays + + col = layout.column() + col.active = display_all + col.prop(overlay, "texture_paint_mode_opacity") + + +class VIEW3D_PT_overlay_vertex_paint(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_parent_id = 'VIEW3D_PT_overlay' + bl_label = "Vertex Paint" + + @classmethod + def poll(cls, context): + return context.mode == 'PAINT_VERTEX' def draw(self, context): layout = self.layout @@ -5828,22 +5814,37 @@ class VIEW3D_PT_overlay_paint(Panel): col = layout.column() col.active = display_all - col.prop(overlay, { - 'PAINT_TEXTURE': "texture_paint_mode_opacity", - 'PAINT_VERTEX': "vertex_paint_mode_opacity", - 'PAINT_WEIGHT': "weight_paint_mode_opacity", - }[context.mode], text="Opacity") + col.prop(overlay, "vertex_paint_mode_opacity", text="Opacity") + col.prop(overlay, "show_paint_wire") - if context.mode == 'PAINT_WEIGHT': - row = col.split(factor=0.33) - row.label(text="Zero Weights") - sub = row.row() - sub.prop(context.tool_settings, "vertex_group_user", expand=True) - col.prop(overlay, "show_wpaint_contours") +class VIEW3D_PT_overlay_weight_paint(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_parent_id = 'VIEW3D_PT_overlay' + bl_label = "Weight Paint" - if context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX'}: - col.prop(overlay, "show_paint_wire") + @classmethod + def poll(cls, context): + return context.mode == 'PAINT_WEIGHT' + + def draw(self, context): + layout = self.layout + view = context.space_data + overlay = view.overlay + display_all = overlay.show_overlays + + col = layout.column() + col.active = display_all + + col.prop(overlay, "weight_paint_mode_opacity", text="Opacity") + row = col.split(factor=0.33) + row.label(text="Zero Weights") + sub = row.row() + sub.prop(context.tool_settings, "vertex_group_user", expand=True) + + col.prop(overlay, "show_wpaint_contours") + col.prop(overlay, "show_paint_wire") class VIEW3D_PT_pivot_point(Panel): @@ -6306,8 +6307,7 @@ class VIEW3D_MT_gpencil_edit_context_menu(Menu): if is_3d_view: layout.menu("GPENCIL_MT_cleanup") - layout.operator("gpencil.stroke_simplify_fixed", text="Simplify") - layout.operator("gpencil.stroke_simplify", text="Simplify Adaptive") + layout.menu("VIEW3D_MT_gpencil_simplify") layout.operator("gpencil.stroke_merge", text="Merge") layout.menu("VIEW3D_MT_edit_gpencil_delete") @@ -6552,14 +6552,13 @@ classes = ( VIEW3D_MT_object_showhide, VIEW3D_MT_make_single_user, VIEW3D_MT_make_links, - VIEW3D_MT_brush, VIEW3D_MT_brush_paint_modes, VIEW3D_MT_paint_vertex, VIEW3D_MT_hook, VIEW3D_MT_vertex_group, + VIEW3D_MT_gpencil_vertex_group, VIEW3D_MT_paint_weight, VIEW3D_MT_sculpt, - VIEW3D_MT_hide_mask, VIEW3D_MT_particle, VIEW3D_MT_particle_context_menu, VIEW3D_MT_particle_showhide, @@ -6601,7 +6600,10 @@ classes = ( VIEW3D_MT_paint_gpencil, VIEW3D_MT_assign_material, VIEW3D_MT_edit_gpencil, + VIEW3D_MT_edit_gpencil_stroke, + VIEW3D_MT_edit_gpencil_point, VIEW3D_MT_edit_gpencil_delete, + VIEW3D_MT_edit_gpencil_showhide, VIEW3D_MT_weight_gpencil, VIEW3D_MT_gpencil_animation, VIEW3D_MT_gpencil_simplify, @@ -6628,7 +6630,6 @@ classes = ( VIEW3D_MT_edit_armature_names, VIEW3D_MT_edit_armature_delete, VIEW3D_MT_edit_gpencil_transform, - VIEW3D_MT_edit_gpencil_interpolate, VIEW3D_MT_object_mode_pie, VIEW3D_MT_view_pie, VIEW3D_MT_transform_gizmo_pie, @@ -6668,7 +6669,9 @@ classes = ( VIEW3D_PT_overlay_edit_mesh_normals, VIEW3D_PT_overlay_edit_mesh_freestyle, VIEW3D_PT_overlay_edit_curve, - VIEW3D_PT_overlay_paint, + VIEW3D_PT_overlay_texture_paint, + VIEW3D_PT_overlay_vertex_paint, + VIEW3D_PT_overlay_weight_paint, VIEW3D_PT_overlay_pose, VIEW3D_PT_overlay_sculpt, VIEW3D_PT_pivot_point, diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index c4f69e18c43..13172a07cb2 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -37,6 +37,53 @@ from bl_ui.properties_paint_common import ( from bl_ui.utils import PresetPanel +class VIEW3D_MT_brush_context_menu(Menu): + bl_label = "Material Specials" + + def draw(self, context): + layout = self.layout + + tool_settings = context.tool_settings + settings = UnifiedPaintPanel.paint_settings(context) + brush = getattr(settings, "brush", None) + + # skip if no active brush + if not brush: + layout.label(text="No Brushes currently available", icon='INFO') + return + + # brush paint modes + layout.menu("VIEW3D_MT_brush_paint_modes") + + # brush tool + + if context.image_paint_object: + layout.prop_menu_enum(brush, "image_tool") + elif context.vertex_paint_object: + layout.prop_menu_enum(brush, "vertex_tool") + elif context.weight_paint_object: + layout.prop_menu_enum(brush, "weight_tool") + elif context.sculpt_object: + layout.prop_menu_enum(brush, "sculpt_tool") + layout.operator("brush.reset") + + +class VIEW3D_MT_brush_context_menu_paint_modes(Menu): + bl_label = "Enabled Modes" + + def draw(self, context): + layout = self.layout + + settings = UnifiedPaintPanel.paint_settings(context) + brush = settings.brush + + layout.prop(brush, "use_paint_sculpt", text="Sculpt") + layout.prop(brush, "use_paint_uv_sculpt", text="UV Sculpt") + layout.prop(brush, "use_paint_vertex", text="Vertex Paint") + layout.prop(brush, "use_paint_weight", text="Weight Paint") + layout.prop(brush, "use_paint_image", text="Texture Paint") + + class View3DPanel: bl_space_type = 'VIEW_3D' bl_region_type = 'UI' @@ -299,8 +346,9 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): brush = settings.brush if not self.is_popover: - col = layout.split().column() - col.template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8) + row = layout.row() + row.column().template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8) + row.menu("VIEW3D_MT_brush_context_menu", icon='DOWNARROW_HLT', text="") # Sculpt Mode # if context.sculpt_object and brush: @@ -1117,8 +1165,6 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel): col.prop(sculpt, "show_low_resolution") col = flow.column() col.prop(sculpt, "use_deform_only") - col = flow.column() - col.prop(sculpt, "show_mask") class VIEW3D_PT_sculpt_options_unified(Panel, View3DPaintPanel): @@ -2071,6 +2117,8 @@ class VIEW3D_PT_gpencil_brush_presets(PresetPanel, Panel): classes = ( + VIEW3D_MT_brush_context_menu, + VIEW3D_MT_brush_context_menu_paint_modes, VIEW3D_PT_tools_meshedit_options, VIEW3D_PT_tools_meshedit_options_automerge, VIEW3D_PT_tools_curveedit_options_stroke, diff --git a/release/scripts/startup/keyingsets_builtins.py b/release/scripts/startup/keyingsets_builtins.py index 1132a09420e..e24cbcfd18e 100644 --- a/release/scripts/startup/keyingsets_builtins.py +++ b/release/scripts/startup/keyingsets_builtins.py @@ -199,8 +199,8 @@ class BUILTIN_KSI_BendyBones(KeyingSetInfo): # VisualLocation class BUILTIN_KSI_VisualLoc(KeyingSetInfo): - ("Insert a keyframe on each of the location channels, taking into account effects of constraints " - "and relationships") + """Insert a keyframe on each of the location channels, """ \ + """taking into account effects of constraints and relationships""" bl_label = "Visual Location" bl_options = {'INSERTKEY_VISUAL'} @@ -217,8 +217,8 @@ class BUILTIN_KSI_VisualLoc(KeyingSetInfo): # VisualRotation class BUILTIN_KSI_VisualRot(KeyingSetInfo): - ("Insert a keyframe on each of the rotation channels, taking into account effects of constraints " - "and relationships") + """Insert a keyframe on each of the rotation channels, """ \ + """taking into account effects of constraints and relationships""" bl_label = "Visual Rotation" bl_options = {'INSERTKEY_VISUAL'} @@ -235,8 +235,8 @@ class BUILTIN_KSI_VisualRot(KeyingSetInfo): # VisualScaling class BUILTIN_KSI_VisualScaling(KeyingSetInfo): - ("Insert a keyframe on each of the scale channels, taking into account effects of constraints " - "and relationships") + """Insert a keyframe on each of the scale channels, """ \ + """taking into account effects of constraints and relationships""" bl_label = "Visual Scaling" bl_options = {'INSERTKEY_VISUAL'} @@ -253,8 +253,8 @@ class BUILTIN_KSI_VisualScaling(KeyingSetInfo): # VisualLocRot class BUILTIN_KSI_VisualLocRot(KeyingSetInfo): - ("Insert a keyframe on each of the location and rotation channels, taking into account effects of constraints " - "and relationships") + """Insert a keyframe on each of the location and rotation channels, """ \ + """taking into account effects of constraints and relationships""" bl_label = "Visual LocRot" bl_options = {'INSERTKEY_VISUAL'} @@ -275,8 +275,8 @@ class BUILTIN_KSI_VisualLocRot(KeyingSetInfo): # VisualLocScale class BUILTIN_KSI_VisualLocScale(KeyingSetInfo): - ("Insert a keyframe on each of the location and scaling channels, taking into account effects of constraints " - "and relationships") + """Insert a keyframe on each of the location and scaling channels, """ \ + """taking into account effects of constraints and relationships""" bl_label = "Visual LocScale" bl_options = {'INSERTKEY_VISUAL'} @@ -297,8 +297,8 @@ class BUILTIN_KSI_VisualLocScale(KeyingSetInfo): # VisualLocRotScale class BUILTIN_KSI_VisualLocRotScale(KeyingSetInfo): - ("Insert a keyframe on each of the location, rotation and scaling channels, taking into account effects " - "of constraints and relationships") + """Insert a keyframe on each of the location, """ \ + """rotation and scaling channels, taking into account effects of constraints and relationships""" bl_label = "Visual LocRotScale" bl_options = {'INSERTKEY_VISUAL'} @@ -321,8 +321,8 @@ class BUILTIN_KSI_VisualLocRotScale(KeyingSetInfo): # VisualRotScale class BUILTIN_KSI_VisualRotScale(KeyingSetInfo): - ("Insert a keyframe on each of the rotation and scaling channels, taking into account effects of constraints " - "and relationships") + """Insert a keyframe on each of the rotation and scaling channels, """ \ + """taking into account effects of constraints and relationships""" bl_label = "Visual RotScale" bl_options = {'INSERTKEY_VISUAL'} @@ -369,8 +369,8 @@ class BUILTIN_KSI_Available(KeyingSetInfo): # All properties that are likely to get animated in a character rig class BUILTIN_KSI_WholeCharacter(KeyingSetInfo): - ("Insert a keyframe for all properties that are likely to get animated in a character rig " - "(useful when blocking out a shot)") + """Insert a keyframe for all properties that are likely to get animated in a character rig """ \ + """(useful when blocking out a shot)""" bl_idname = ANIM_KS_WHOLE_CHARACTER_ID bl_label = "Whole Character" @@ -530,8 +530,8 @@ class BUILTIN_KSI_WholeCharacter(KeyingSetInfo): class BUILTIN_KSI_WholeCharacterSelected(KeyingSetInfo): - ("Insert a keyframe for all properties that are likely to get animated in a character rig " - "(only selected bones)") + """Insert a keyframe for all properties that are likely to get animated in a character rig """ \ + """(only selected bones)""" bl_idname = ANIM_KS_WHOLE_CHARACTER_SELECTED_ID bl_label = "Whole Character (Selected bones only)" diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index a6eb12c3708..643073b3470 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -34,17 +34,19 @@ struct ImBuf; struct Scopes; struct rctf; -void curvemapping_set_defaults( +void BKE_curvemapping_set_defaults( struct CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy); -struct CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, float maxy); -void curvemapping_free_data(struct CurveMapping *cumap); -void curvemapping_free(struct CurveMapping *cumap); -void curvemapping_copy_data(struct CurveMapping *target, const struct CurveMapping *cumap); -struct CurveMapping *curvemapping_copy(const struct CurveMapping *cumap); -void curvemapping_set_black_white_ex(const float black[3], const float white[3], float r_bwmul[3]); -void curvemapping_set_black_white(struct CurveMapping *cumap, - const float black[3], - const float white[3]); +struct CurveMapping *BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy); +void BKE_curvemapping_free_data(struct CurveMapping *cumap); +void BKE_curvemapping_free(struct CurveMapping *cumap); +void BKE_curvemapping_copy_data(struct CurveMapping *target, const struct CurveMapping *cumap); +struct CurveMapping *BKE_curvemapping_copy(const struct CurveMapping *cumap); +void BKE_curvemapping_set_black_white_ex(const float black[3], + const float white[3], + float r_bwmul[3]); +void BKE_curvemapping_set_black_white(struct CurveMapping *cumap, + const float black[3], + const float white[3]); enum { CURVEMAP_SLOPE_NEGATIVE = 0, @@ -52,56 +54,56 @@ enum { CURVEMAP_SLOPE_POS_NEG = 2, }; -void curvemap_reset(struct CurveMap *cuma, const struct rctf *clipr, int preset, int slope); -void curvemap_remove(struct CurveMap *cuma, const short flag); -bool curvemap_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp); -struct CurveMapPoint *curvemap_insert(struct CurveMap *cuma, float x, float y); -void curvemap_handle_set(struct CurveMap *cuma, int type); +void BKE_curvemap_reset(struct CurveMap *cuma, const struct rctf *clipr, int preset, int slope); +void BKE_curvemap_remove(struct CurveMap *cuma, const short flag); +bool BKE_curvemap_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp); +struct CurveMapPoint *BKE_curvemap_insert(struct CurveMap *cuma, float x, float y); +void BKE_curvemap_handle_set(struct CurveMap *cuma, int type); -void curvemapping_changed(struct CurveMapping *cumap, const bool rem_doubles); -void curvemapping_changed_all(struct CurveMapping *cumap); +void BKE_curvemapping_changed(struct CurveMapping *cumap, const bool rem_doubles); +void BKE_curvemapping_changed_all(struct CurveMapping *cumap); /* call before _all_ evaluation functions */ -void curvemapping_initialize(struct CurveMapping *cumap); +void BKE_curvemapping_initialize(struct CurveMapping *cumap); /* keep these (const CurveMap) - to help with thread safety */ /* single curve, no table check */ -float curvemap_evaluateF(const struct CurveMap *cuma, float value); +float BKE_curvemap_evaluateF(const struct CurveMap *cuma, float value); /* single curve, with table check */ -float curvemapping_evaluateF(const struct CurveMapping *cumap, int cur, float value); -void curvemapping_evaluate3F(const struct CurveMapping *cumap, - float vecout[3], - const float vecin[3]); -void curvemapping_evaluateRGBF(const struct CurveMapping *cumap, - float vecout[3], - const float vecin[3]); -void curvemapping_evaluate_premulRGB(const struct CurveMapping *cumap, - unsigned char vecout_byte[3], - const unsigned char vecin_byte[3]); -void curvemapping_evaluate_premulRGBF_ex(const struct CurveMapping *cumap, - float vecout[3], - const float vecin[3], - const float black[3], - const float bwmul[3]); -void curvemapping_evaluate_premulRGBF(const struct CurveMapping *cumap, - float vecout[3], - const float vecin[3]); -int curvemapping_RGBA_does_something(const struct CurveMapping *cumap); -void curvemapping_table_RGBA(const struct CurveMapping *cumap, float **array, int *size); +float BKE_curvemapping_evaluateF(const struct CurveMapping *cumap, int cur, float value); +void BKE_curvemapping_evaluate3F(const struct CurveMapping *cumap, + float vecout[3], + const float vecin[3]); +void BKE_curvemapping_evaluateRGBF(const struct CurveMapping *cumap, + float vecout[3], + const float vecin[3]); +void BKE_curvemapping_evaluate_premulRGB(const struct CurveMapping *cumap, + unsigned char vecout_byte[3], + const unsigned char vecin_byte[3]); +void BKE_curvemapping_evaluate_premulRGBF_ex(const struct CurveMapping *cumap, + float vecout[3], + const float vecin[3], + const float black[3], + const float bwmul[3]); +void BKE_curvemapping_evaluate_premulRGBF(const struct CurveMapping *cumap, + float vecout[3], + const float vecin[3]); +int BKE_curvemapping_RGBA_does_something(const struct CurveMapping *cumap); +void BKE_curvemapping_table_RGBA(const struct CurveMapping *cumap, float **array, int *size); /* non-const, these modify the curve */ -void curvemapping_premultiply(struct CurveMapping *cumap, int restore); +void BKE_curvemapping_premultiply(struct CurveMapping *cumap, int restore); void BKE_histogram_update_sample_line(struct Histogram *hist, struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings); -void scopes_update(struct Scopes *scopes, - struct ImBuf *ibuf, - const struct ColorManagedViewSettings *view_settings, - const struct ColorManagedDisplaySettings *display_settings); -void scopes_free(struct Scopes *scopes); -void scopes_new(struct Scopes *scopes); +void BKE_scopes_update(struct Scopes *scopes, + struct ImBuf *ibuf, + const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings); +void BKE_scopes_free(struct Scopes *scopes); +void BKE_scopes_new(struct Scopes *scopes); void BKE_color_managed_display_settings_init(struct ColorManagedDisplaySettings *settings); void BKE_color_managed_display_settings_copy(struct ColorManagedDisplaySettings *new_settings, diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index 9ec872f3676..997f1fc82e1 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -197,6 +197,10 @@ void BKE_gpencil_simplify_stroke(struct bGPDstroke *gps, float factor); void BKE_gpencil_simplify_fixed(struct bGPDstroke *gps); void BKE_gpencil_subdivide(struct bGPDstroke *gps, int level, int flag); bool BKE_gpencil_trim_stroke(struct bGPDstroke *gps); +void BKE_gpencil_merge_distance_stroke(struct bGPDframe *gpf, + struct bGPDstroke *gps, + const float threshold, + const bool use_unselected); void BKE_gpencil_stroke_2d_flat(const struct bGPDspoint *points, int totpoints, @@ -212,6 +216,7 @@ void BKE_gpencil_stroke_2d_flat_ref(const struct bGPDspoint *ref_points, void BKE_gpencil_transform(struct bGPdata *gpd, float mat[4][4]); +bool BKE_gpencil_sample_stroke(struct bGPDstroke *gps, const float dist, const bool select); bool BKE_gpencil_smooth_stroke(struct bGPDstroke *gps, int i, float inf); bool BKE_gpencil_smooth_stroke_strength(struct bGPDstroke *gps, int point_index, float influence); bool BKE_gpencil_smooth_stroke_thickness(struct bGPDstroke *gps, int point_index, float influence); diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 28769ba7de9..c0ac71f9c96 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -223,7 +223,7 @@ void BKE_main_id_flag_all(struct Main *bmain, const int flag, const bool value); void BKE_main_id_clear_newpoins(struct Main *bmain); -void BLE_main_id_refcount_recompute(struct Main *bmain, const bool do_linked_only); +void BKE_main_id_refcount_recompute(struct Main *bmain, const bool do_linked_only); void BKE_main_lib_objects_recalc_all(struct Main *bmain); diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index f018e912945..65aa43ced7c 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -59,10 +59,6 @@ void txt_order_cursors(struct Text *text, const bool reverse); int txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case); bool txt_has_sel(struct Text *text); int txt_get_span(struct TextLine *from, struct TextLine *to); -int txt_utf8_offset_to_index(const char *str, int offset); -int txt_utf8_index_to_offset(const char *str, int index); -int txt_utf8_offset_to_column(const char *str, int offset); -int txt_utf8_column_to_offset(const char *str, int column); void txt_move_up(struct Text *text, const bool sel); void txt_move_down(struct Text *text, const bool sel); void txt_move_left(struct Text *text, const bool sel); diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 49855de0591..d91296e0c01 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -960,13 +960,13 @@ void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces, int * } } -void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, - CCGFace **faces, - int numFaces, - CCGVert ***verts, - int *numVerts, - CCGEdge ***edges, - int *numEdges) +void ccgSubSurf__effectedFaceNeighbors(CCGSubSurf *ss, + CCGFace **faces, + int numFaces, + CCGVert ***verts, + int *numVerts, + CCGEdge ***edges, + int *numEdges) { CCGVert **arrayV; CCGEdge **arrayE; @@ -1134,7 +1134,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in cornerIdx = gridSize - 1; ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF); - ccgSubSurf__effectedFaceNeighbours( + ccgSubSurf__effectedFaceNeighbors( ss, effectedF, numEffectedF, &effectedV, &numEffectedV, &effectedE, &numEffectedE); /* zero */ diff --git a/source/blender/blenkernel/intern/CCGSubSurf_intern.h b/source/blender/blenkernel/intern/CCGSubSurf_intern.h index 41a34b65381..51486db1bdc 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf_intern.h +++ b/source/blender/blenkernel/intern/CCGSubSurf_intern.h @@ -306,13 +306,13 @@ struct CCGSubSurf { /* * CCGSubSurf.c * */ void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces, int *freeFaces); -void ccgSubSurf__effectedFaceNeighbours(CCGSubSurf *ss, - CCGFace **faces, - int numFaces, - CCGVert ***verts, - int *numVerts, - CCGEdge ***edges, - int *numEdges); +void ccgSubSurf__effectedFaceNeighbors(CCGSubSurf *ss, + CCGFace **faces, + int numFaces, + CCGVert ***verts, + int *numVerts, + CCGEdge ***edges, + int *numEdges); /* * CCGSubSurf_legacy.c * */ diff --git a/source/blender/blenkernel/intern/CCGSubSurf_legacy.c b/source/blender/blenkernel/intern/CCGSubSurf_legacy.c index d8b30c9d4ef..01735b34e5e 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf_legacy.c +++ b/source/blender/blenkernel/intern/CCGSubSurf_legacy.c @@ -1323,7 +1323,7 @@ CCGError ccgSubSurf_updateNormals(CCGSubSurf *ss, CCGFace **effectedF, int numEf int i, numEffectedV, numEffectedE, freeF; ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF); - ccgSubSurf__effectedFaceNeighbours( + ccgSubSurf__effectedFaceNeighbors( ss, effectedF, numEffectedF, &effectedV, &numEffectedV, &effectedE, &numEffectedE); if (ss->calcVertNormals) { @@ -1361,7 +1361,7 @@ CCGError ccgSubSurf_updateLevels(CCGSubSurf *ss, int lvl, CCGFace **effectedF, i int curLvl, subdivLevels = ss->subdivLevels; ccgSubSurf__allFaces(ss, &effectedF, &numEffectedF, &freeF); - ccgSubSurf__effectedFaceNeighbours( + ccgSubSurf__effectedFaceNeighbors( ss, effectedF, numEffectedF, &effectedV, &numEffectedV, &effectedE, &numEffectedE); for (curLvl = lvl; curLvl < subdivLevels; curLvl++) { diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 7f1a0e6a744..6267c095618 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1046,24 +1046,25 @@ static void mesh_calc_modifier_final_normals(const Mesh *mesh_input, * since they are needed by drawing code. */ const bool do_poly_normals = ((final_datamask->pmask & CD_MASK_NORMAL) != 0); - if (do_loop_normals) { - /* In case we also need poly normals, add the layer and compute them here - * (BKE_mesh_calc_normals_split() assumes that if that data exists, it is always valid). */ - if (do_poly_normals) { - if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) { - float(*polynors)[3] = CustomData_add_layer( - &mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly); - BKE_mesh_calc_normals_poly(mesh_final->mvert, - NULL, - mesh_final->totvert, - mesh_final->mloop, - mesh_final->mpoly, - mesh_final->totloop, - mesh_final->totpoly, - polynors, - false); - } + /* In case we also need poly normals, add the layer and compute them here + * (BKE_mesh_calc_normals_split() assumes that if that data exists, it is always valid). */ + if (do_poly_normals) { + if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) { + float(*polynors)[3] = CustomData_add_layer( + &mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly); + BKE_mesh_calc_normals_poly(mesh_final->mvert, + NULL, + mesh_final->totvert, + mesh_final->mloop, + mesh_final->mpoly, + mesh_final->totloop, + mesh_final->totpoly, + polynors, + false); } + } + + if (do_loop_normals) { /* Compute loop normals (note: will compute poly and vert normals as well, if needed!) */ BKE_mesh_calc_normals_split(mesh_final); BKE_mesh_tessface_clear(mesh_final); @@ -1536,11 +1537,16 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph, modifier_freeTemporaryData(md); } - /* Yay, we are done. If we have a Mesh and deformed vertices - * need to apply these back onto the Mesh. If we have no + /* Yay, we are done. If we have a Mesh and deformed vertices, + * we need to apply these back onto the Mesh. If we have no * Mesh then we need to build one. */ if (mesh_final == NULL) { - if (deformed_verts == NULL && allow_shared_mesh) { + /* Note: this check on cdmask is a bit dodgy, it handles the issue at stake here (see T68211), + * but other cases might require similar handling? + * Could be a good idea to define a proper CustomData_MeshMask for that then. */ + if (deformed_verts == NULL && allow_shared_mesh && + (final_datamask.lmask & CD_MASK_NORMAL) == 0 && + (final_datamask.pmask & CD_MASK_NORMAL) == 0) { mesh_final = mesh_input; } else { @@ -1653,14 +1659,25 @@ static void editbmesh_calc_modifier_final_normals(const Mesh *mesh_input, * simpler to generate it here as well. */ const bool do_poly_normals = ((final_datamask->pmask & CD_MASK_NORMAL) != 0); - if (do_loop_normals) { - /* In case we also need poly normals, add the layer here, - * then BKE_mesh_calc_normals_split() will fill it. */ - if (do_poly_normals) { - if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) { - CustomData_add_layer(&mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly); - } + /* In case we also need poly normals, add the layer and compute them here + * (BKE_mesh_calc_normals_split() assumes that if that data exists, it is always valid). */ + if (do_poly_normals) { + if (!CustomData_has_layer(&mesh_final->pdata, CD_NORMAL)) { + float(*polynors)[3] = CustomData_add_layer( + &mesh_final->pdata, CD_NORMAL, CD_CALLOC, NULL, mesh_final->totpoly); + BKE_mesh_calc_normals_poly(mesh_final->mvert, + NULL, + mesh_final->totvert, + mesh_final->mloop, + mesh_final->mpoly, + mesh_final->totloop, + mesh_final->totpoly, + polynors, + false); } + } + + if (do_loop_normals) { /* Compute loop normals */ BKE_mesh_calc_normals_split(mesh_final); BKE_mesh_tessface_clear(mesh_final); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 984de700ce7..57a7379eeae 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -236,9 +236,9 @@ void action_group_colors_sync(bActionGroup *grp, const bActionGroup *ref_grp) */ 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); - rgba_char_args_set(grp->cs.active, 0x18, 0xb6, 0xe0, 255); + rgba_uchar_args_set(grp->cs.solid, 0xff, 0x00, 0x00, 255); + rgba_uchar_args_set(grp->cs.select, 0x81, 0xe6, 0x14, 255); + rgba_uchar_args_set(grp->cs.active, 0x18, 0xb6, 0xe0, 255); } } } diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 4ceae89dfbb..0d94fbe648f 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -372,7 +372,7 @@ static void setup_app_data(bContext *C, * lib_link on local IDs using linked ones. * There is no real way to predict amount of changes here, so we have to fully redo * refcounting . */ - BLE_main_id_refcount_recompute(bmain, true); + BKE_main_id_refcount_recompute(bmain, true); } } diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 709f74808a3..b2d3ccfebc3 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -184,9 +184,9 @@ void BKE_brush_init_gpencil_settings(Brush *brush) brush->gpencil_settings->flag |= GP_BRUSH_ENABLE_CURSOR; /* curves */ - brush->gpencil_settings->curve_sensitivity = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); - brush->gpencil_settings->curve_strength = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); - brush->gpencil_settings->curve_jitter = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + brush->gpencil_settings->curve_sensitivity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + brush->gpencil_settings->curve_strength = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + brush->gpencil_settings->curve_jitter = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } /* add a new gp-brush */ @@ -386,8 +386,8 @@ void BKE_brush_gpencil_presets(bContext *C) /* Curve */ custom_curve = brush->gpencil_settings->curve_sensitivity; - curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); - curvemapping_initialize(custom_curve); + BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_initialize(custom_curve); brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_INK); /* Ink Noise brush */ @@ -423,8 +423,8 @@ void BKE_brush_gpencil_presets(bContext *C) /* Curve */ custom_curve = brush->gpencil_settings->curve_sensitivity; - curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); - curvemapping_initialize(custom_curve); + BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_initialize(custom_curve); brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_INKNOISE); brush->gpencil_settings->gradient_f = 1.0f; @@ -495,8 +495,8 @@ void BKE_brush_gpencil_presets(bContext *C) brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR; /* Curve */ custom_curve = brush->gpencil_settings->curve_sensitivity; - curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); - curvemapping_initialize(custom_curve); + BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_initialize(custom_curve); brush_gpencil_curvemap_reset(custom_curve->cm, 4, GPCURVE_PRESET_MARKER); brush->gpencil_settings->gradient_f = 1.0f; @@ -649,14 +649,14 @@ void BKE_brush_copy_data(Main *UNUSED(bmain), brush_dst->preview = NULL; } - brush_dst->curve = curvemapping_copy(brush_src->curve); + brush_dst->curve = BKE_curvemapping_copy(brush_src->curve); if (brush_src->gpencil_settings != NULL) { brush_dst->gpencil_settings = MEM_dupallocN(brush_src->gpencil_settings); - brush_dst->gpencil_settings->curve_sensitivity = curvemapping_copy( + brush_dst->gpencil_settings->curve_sensitivity = BKE_curvemapping_copy( brush_src->gpencil_settings->curve_sensitivity); - brush_dst->gpencil_settings->curve_strength = curvemapping_copy( + brush_dst->gpencil_settings->curve_strength = BKE_curvemapping_copy( brush_src->gpencil_settings->curve_strength); - brush_dst->gpencil_settings->curve_jitter = curvemapping_copy( + brush_dst->gpencil_settings->curve_jitter = BKE_curvemapping_copy( brush_src->gpencil_settings->curve_jitter); } @@ -677,12 +677,12 @@ void BKE_brush_free(Brush *brush) if (brush->icon_imbuf) { IMB_freeImBuf(brush->icon_imbuf); } - curvemapping_free(brush->curve); + BKE_curvemapping_free(brush->curve); if (brush->gpencil_settings != NULL) { - curvemapping_free(brush->gpencil_settings->curve_sensitivity); - curvemapping_free(brush->gpencil_settings->curve_strength); - curvemapping_free(brush->gpencil_settings->curve_jitter); + BKE_curvemapping_free(brush->gpencil_settings->curve_sensitivity); + BKE_curvemapping_free(brush->gpencil_settings->curve_strength); + BKE_curvemapping_free(brush->gpencil_settings->curve_jitter); MEM_SAFE_FREE(brush->gpencil_settings); } @@ -917,15 +917,15 @@ void BKE_brush_curve_preset(Brush *b, eCurveMappingPreset preset) CurveMap *cm = NULL; if (!b->curve) { - b->curve = curvemapping_add(1, 0, 0, 1, 1); + b->curve = BKE_curvemapping_add(1, 0, 0, 1, 1); } cm = b->curve->cm; cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; b->curve->preset = preset; - curvemap_reset(cm, &b->curve->clipr, b->curve->preset, CURVEMAP_SLOPE_NEGATIVE); - curvemapping_changed(b->curve, false); + BKE_curvemap_reset(cm, &b->curve->clipr, b->curve->preset, CURVEMAP_SLOPE_NEGATIVE); + BKE_curvemapping_changed(b->curve, false); } /* Generic texture sampler for 3D painting systems. point has to be either in @@ -1412,7 +1412,7 @@ float BKE_brush_curve_strength(const Brush *br, float p, const float len) switch (br->curve_preset) { case BRUSH_CURVE_CUSTOM: - strength = curvemapping_evaluateF(br->curve, 0, 1.0f - p); + strength = BKE_curvemapping_evaluateF(br->curve, 0, 1.0f - p); break; case BRUSH_CURVE_SHARP: strength = p * p; @@ -1498,7 +1498,7 @@ struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary) int half = side / 2; int i, j; - curvemapping_initialize(br->curve); + BKE_curvemapping_initialize(br->curve); texcache = BKE_brush_gen_texture_cache(br, half, secondary); im->rect_float = MEM_callocN(sizeof(float) * side * side, "radial control rect"); im->x = im->y = side; diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index e51d15ee152..8c125d1609b 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -553,6 +553,7 @@ BVHTree *bvhtree_from_editmesh_verts(BVHTreeFromEditMesh *data, /* Save on cache for later use */ /* printf("BVHTree built and saved on cache\n"); */ bvhcache_insert(bvh_cache, data->tree, BVHTREE_FROM_EM_VERTS); + data->cached = true; } BLI_rw_mutex_unlock(&cache_rwlock); } @@ -743,6 +744,7 @@ BVHTree *bvhtree_from_editmesh_edges(BVHTreeFromEditMesh *data, /* Save on cache for later use */ /* printf("BVHTree built and saved on cache\n"); */ bvhcache_insert(bvh_cache, data->tree, BVHTREE_FROM_EM_EDGES); + data->cached = true; } BLI_rw_mutex_unlock(&cache_rwlock); } diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index aa5f74c6297..b129bf14bb8 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -48,7 +48,7 @@ /* ***************** operations on full struct ************* */ -void curvemapping_set_defaults( +void BKE_curvemapping_set_defaults( CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy) { int a; @@ -84,18 +84,18 @@ void curvemapping_set_defaults( cumap->changed_timestamp = 0; } -CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, float maxy) +CurveMapping *BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy) { CurveMapping *cumap; cumap = MEM_callocN(sizeof(CurveMapping), "new curvemap"); - curvemapping_set_defaults(cumap, tot, minx, miny, maxx, maxy); + BKE_curvemapping_set_defaults(cumap, tot, minx, miny, maxx, maxy); return cumap; } -void curvemapping_free_data(CurveMapping *cumap) +void BKE_curvemapping_free_data(CurveMapping *cumap) { int a; @@ -115,15 +115,15 @@ void curvemapping_free_data(CurveMapping *cumap) } } -void curvemapping_free(CurveMapping *cumap) +void BKE_curvemapping_free(CurveMapping *cumap) { if (cumap) { - curvemapping_free_data(cumap); + BKE_curvemapping_free_data(cumap); MEM_freeN(cumap); } } -void curvemapping_copy_data(CurveMapping *target, const CurveMapping *cumap) +void BKE_curvemapping_copy_data(CurveMapping *target, const CurveMapping *cumap) { int a; @@ -142,17 +142,19 @@ void curvemapping_copy_data(CurveMapping *target, const CurveMapping *cumap) } } -CurveMapping *curvemapping_copy(const CurveMapping *cumap) +CurveMapping *BKE_curvemapping_copy(const CurveMapping *cumap) { if (cumap) { CurveMapping *cumapn = MEM_dupallocN(cumap); - curvemapping_copy_data(cumapn, cumap); + BKE_curvemapping_copy_data(cumapn, cumap); return cumapn; } return NULL; } -void curvemapping_set_black_white_ex(const float black[3], const float white[3], float r_bwmul[3]) +void BKE_curvemapping_set_black_white_ex(const float black[3], + const float white[3], + float r_bwmul[3]) { int a; @@ -162,7 +164,9 @@ void curvemapping_set_black_white_ex(const float black[3], const float white[3], } } -void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], const float white[3]) +void BKE_curvemapping_set_black_white(CurveMapping *cumap, + const float black[3], + const float white[3]) { if (white) { copy_v3_v3(cumap->white, white); @@ -171,15 +175,15 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con copy_v3_v3(cumap->black, black); } - curvemapping_set_black_white_ex(cumap->black, cumap->white, cumap->bwmul); + BKE_curvemapping_set_black_white_ex(cumap->black, cumap->white, cumap->bwmul); cumap->changed_timestamp++; } /* ***************** operations on single curve ************* */ -/* ********** NOTE: requires curvemapping_changed() call after ******** */ +/* ********** NOTE: requires BKE_curvemapping_changed() call after ******** */ /* remove specified point */ -bool curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point) +bool BKE_curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point) { CurveMapPoint *cmp; int a, b, removed = 0; @@ -209,7 +213,7 @@ bool curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point) } /* removes with flag set */ -void curvemap_remove(CurveMap *cuma, const short flag) +void BKE_curvemap_remove(CurveMap *cuma, const short flag) { CurveMapPoint *cmp = MEM_mallocN((cuma->totpoint) * sizeof(CurveMapPoint), "curve points"); int a, b, removed = 0; @@ -232,7 +236,7 @@ void curvemap_remove(CurveMap *cuma, const short flag) cuma->totpoint -= removed; } -CurveMapPoint *curvemap_insert(CurveMap *cuma, float x, float y) +CurveMapPoint *BKE_curvemap_insert(CurveMap *cuma, float x, float y) { CurveMapPoint *cmp = MEM_callocN((cuma->totpoint + 1) * sizeof(CurveMapPoint), "curve points"); CurveMapPoint *newcmp = NULL; @@ -266,7 +270,7 @@ CurveMapPoint *curvemap_insert(CurveMap *cuma, float x, float y) return newcmp; } -void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope) +void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope) { if (cuma->curve) { MEM_freeN(cuma->curve); @@ -439,7 +443,7 @@ void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope) /** * \param type: eBezTriple_Handle */ -void curvemap_handle_set(CurveMap *cuma, int type) +void BKE_curvemap_handle_set(CurveMap *cuma, int type) { int a; @@ -800,7 +804,7 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr) /* call when you do images etc, needs restore too. also verifies tables */ /* it uses a flag to prevent premul or free to happen twice */ -void curvemapping_premultiply(CurveMapping *cumap, int restore) +void BKE_curvemapping_premultiply(CurveMapping *cumap, int restore) { int a; @@ -841,7 +845,7 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore) for (a = 0; a < 3; a++) { int b; for (b = 0; b <= CM_TABLE; b++) { - cumap->cm[a].table[b].y = curvemap_evaluateF(cumap->cm + 3, cumap->cm[a].table[b].y); + cumap->cm[a].table[b].y = BKE_curvemap_evaluateF(cumap->cm + 3, cumap->cm[a].table[b].y); } copy_v2_v2(cumap->cm[a].premul_ext_in, cumap->cm[a].ext_in); @@ -871,7 +875,7 @@ static int sort_curvepoints(const void *a1, const void *a2) /* ************************ more CurveMapping calls *************** */ /* note; only does current curvemap! */ -void curvemapping_changed(CurveMapping *cumap, const bool rem_doubles) +void BKE_curvemapping_changed(CurveMapping *cumap, const bool rem_doubles) { CurveMap *cuma = cumap->cm + cumap->cur; CurveMapPoint *cmp = cuma->curve; @@ -942,20 +946,20 @@ void curvemapping_changed(CurveMapping *cumap, const bool rem_doubles) } } if (a != cuma->totpoint - 1) { - curvemap_remove(cuma, 2); + BKE_curvemap_remove(cuma, 2); } } curvemap_make_table(cuma, clipr); } -void curvemapping_changed_all(CurveMapping *cumap) +void BKE_curvemapping_changed_all(CurveMapping *cumap) { int a, cur = cumap->cur; for (a = 0; a < CM_TOT; a++) { if (cumap->cm[a].curve) { cumap->cur = a; - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); } } @@ -963,7 +967,7 @@ void curvemapping_changed_all(CurveMapping *cumap) } /* table should be verified */ -float curvemap_evaluateF(const CurveMap *cuma, float value) +float BKE_curvemap_evaluateF(const CurveMap *cuma, float value) { float fi; int i; @@ -990,10 +994,10 @@ float curvemap_evaluateF(const CurveMap *cuma, float value) } /* works with curve 'cur' */ -float curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value) +float BKE_curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value) { const CurveMap *cuma = cumap->cm + cur; - float val = curvemap_evaluateF(cuma, value); + float val = BKE_curvemap_evaluateF(cuma, value); /* account for clipping */ if (cumap->flag & CUMA_DO_CLIP) { @@ -1009,19 +1013,24 @@ float curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value) } /* vector case */ -void curvemapping_evaluate3F(const CurveMapping *cumap, float vecout[3], const float vecin[3]) +void BKE_curvemapping_evaluate3F(const CurveMapping *cumap, float vecout[3], const float vecin[3]) { - vecout[0] = curvemap_evaluateF(&cumap->cm[0], vecin[0]); - vecout[1] = curvemap_evaluateF(&cumap->cm[1], vecin[1]); - vecout[2] = curvemap_evaluateF(&cumap->cm[2], vecin[2]); + vecout[0] = BKE_curvemap_evaluateF(&cumap->cm[0], vecin[0]); + vecout[1] = BKE_curvemap_evaluateF(&cumap->cm[1], vecin[1]); + vecout[2] = BKE_curvemap_evaluateF(&cumap->cm[2], vecin[2]); } /* RGB case, no black/white points, no premult */ -void curvemapping_evaluateRGBF(const CurveMapping *cumap, float vecout[3], const float vecin[3]) +void BKE_curvemapping_evaluateRGBF(const CurveMapping *cumap, + float vecout[3], + const float vecin[3]) { - vecout[0] = curvemap_evaluateF(&cumap->cm[0], curvemap_evaluateF(&cumap->cm[3], vecin[0])); - vecout[1] = curvemap_evaluateF(&cumap->cm[1], curvemap_evaluateF(&cumap->cm[3], vecin[1])); - vecout[2] = curvemap_evaluateF(&cumap->cm[2], curvemap_evaluateF(&cumap->cm[3], vecin[2])); + vecout[0] = BKE_curvemap_evaluateF(&cumap->cm[0], + BKE_curvemap_evaluateF(&cumap->cm[3], vecin[0])); + vecout[1] = BKE_curvemap_evaluateF(&cumap->cm[1], + BKE_curvemap_evaluateF(&cumap->cm[3], vecin[1])); + vecout[2] = BKE_curvemap_evaluateF(&cumap->cm[2], + BKE_curvemap_evaluateF(&cumap->cm[3], vecin[2])); } static void curvemapping_evaluateRGBF_filmlike(const CurveMapping *cumap, @@ -1033,8 +1042,8 @@ static void curvemapping_evaluateRGBF_filmlike(const CurveMapping *cumap, const float v1in = vecin[channel_offset[1]]; const float v2in = vecin[channel_offset[2]]; - const float v0 = curvemap_evaluateF(&cumap->cm[channel_offset[0]], v0in); - const float v2 = curvemap_evaluateF(&cumap->cm[channel_offset[2]], v2in); + const float v0 = BKE_curvemap_evaluateF(&cumap->cm[channel_offset[0]], v0in); + const float v2 = BKE_curvemap_evaluateF(&cumap->cm[channel_offset[2]], v2in); const float v1 = v2 + ((v0 - v2) * (v1in - v2in) / (v0in - v2in)); vecout[channel_offset[0]] = v0; @@ -1042,20 +1051,20 @@ static void curvemapping_evaluateRGBF_filmlike(const CurveMapping *cumap, vecout[channel_offset[2]] = v2; } -/** same as #curvemapping_evaluate_premulRGBF +/** same as #BKE_curvemapping_evaluate_premulRGBF * but black/bwmul are passed as args for the compositor * where they can change per pixel. * - * Use in conjunction with #curvemapping_set_black_white_ex + * Use in conjunction with #BKE_curvemapping_set_black_white_ex * * \param black: Use instead of cumap->black * \param bwmul: Use instead of cumap->bwmul */ -void curvemapping_evaluate_premulRGBF_ex(const CurveMapping *cumap, - float vecout[3], - const float vecin[3], - const float black[3], - const float bwmul[3]) +void BKE_curvemapping_evaluate_premulRGBF_ex(const CurveMapping *cumap, + float vecout[3], + const float vecin[3], + const float black[3], + const float bwmul[3]) { const float r = (vecin[0] - black[0]) * bwmul[0]; const float g = (vecin[1] - black[1]) * bwmul[1]; @@ -1064,9 +1073,9 @@ void curvemapping_evaluate_premulRGBF_ex(const CurveMapping *cumap, switch (cumap->tone) { default: case CURVE_TONE_STANDARD: { - vecout[0] = curvemap_evaluateF(&cumap->cm[0], r); - vecout[1] = curvemap_evaluateF(&cumap->cm[1], g); - vecout[2] = curvemap_evaluateF(&cumap->cm[2], b); + vecout[0] = BKE_curvemap_evaluateF(&cumap->cm[0], r); + vecout[1] = BKE_curvemap_evaluateF(&cumap->cm[1], g); + vecout[2] = BKE_curvemap_evaluateF(&cumap->cm[2], b); break; } case CURVE_TONE_FILMLIKE: { @@ -1088,8 +1097,9 @@ void curvemapping_evaluate_premulRGBF_ex(const CurveMapping *cumap, } else { /* Case 4: r >= g == b */ - copy_v2_fl2( - vecout, curvemap_evaluateF(&cumap->cm[0], r), curvemap_evaluateF(&cumap->cm[1], g)); + copy_v2_fl2(vecout, + BKE_curvemap_evaluateF(&cumap->cm[0], r), + BKE_curvemap_evaluateF(&cumap->cm[1], g)); vecout[2] = vecout[1]; } } @@ -1116,17 +1126,17 @@ void curvemapping_evaluate_premulRGBF_ex(const CurveMapping *cumap, } /* RGB with black/white points and premult. tables are checked */ -void curvemapping_evaluate_premulRGBF(const CurveMapping *cumap, - float vecout[3], - const float vecin[3]) +void BKE_curvemapping_evaluate_premulRGBF(const CurveMapping *cumap, + float vecout[3], + const float vecin[3]) { - curvemapping_evaluate_premulRGBF_ex(cumap, vecout, vecin, cumap->black, cumap->bwmul); + BKE_curvemapping_evaluate_premulRGBF_ex(cumap, vecout, vecin, cumap->black, cumap->bwmul); } /* same as above, byte version */ -void curvemapping_evaluate_premulRGB(const CurveMapping *cumap, - unsigned char vecout_byte[3], - const unsigned char vecin_byte[3]) +void BKE_curvemapping_evaluate_premulRGB(const CurveMapping *cumap, + unsigned char vecout_byte[3], + const unsigned char vecin_byte[3]) { float vecin[3], vecout[3]; @@ -1134,14 +1144,14 @@ void curvemapping_evaluate_premulRGB(const CurveMapping *cumap, vecin[1] = (float)vecin_byte[1] / 255.0f; vecin[2] = (float)vecin_byte[2] / 255.0f; - curvemapping_evaluate_premulRGBF(cumap, vecout, vecin); + BKE_curvemapping_evaluate_premulRGBF(cumap, vecout, vecin); vecout_byte[0] = unit_float_to_uchar_clamp(vecout[0]); vecout_byte[1] = unit_float_to_uchar_clamp(vecout[1]); vecout_byte[2] = unit_float_to_uchar_clamp(vecout[2]); } -int curvemapping_RGBA_does_something(const CurveMapping *cumap) +int BKE_curvemapping_RGBA_does_something(const CurveMapping *cumap) { int a; @@ -1187,7 +1197,7 @@ int curvemapping_RGBA_does_something(const CurveMapping *cumap) return 0; } -void curvemapping_initialize(CurveMapping *cumap) +void BKE_curvemapping_initialize(CurveMapping *cumap) { int a; @@ -1202,7 +1212,7 @@ void curvemapping_initialize(CurveMapping *cumap) } } -void curvemapping_table_RGBA(const CurveMapping *cumap, float **array, int *size) +void BKE_curvemapping_table_RGBA(const CurveMapping *cumap, float **array, int *size) { int a; @@ -1520,10 +1530,10 @@ static void scopes_update_finalize(void *__restrict userdata, void *__restrict u } } -void scopes_update(Scopes *scopes, - ImBuf *ibuf, - const ColorManagedViewSettings *view_settings, - const ColorManagedDisplaySettings *display_settings) +void BKE_scopes_update(Scopes *scopes, + ImBuf *ibuf, + const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings) { int a; unsigned int nl, na, nr, ng, nb; @@ -1685,7 +1695,7 @@ void scopes_update(Scopes *scopes, scopes->ok = 1; } -void scopes_free(Scopes *scopes) +void BKE_scopes_free(Scopes *scopes) { if (scopes->waveform_1) { MEM_freeN(scopes->waveform_1); @@ -1705,7 +1715,7 @@ void scopes_free(Scopes *scopes) } } -void scopes_new(Scopes *scopes) +void BKE_scopes_new(Scopes *scopes) { scopes->accuracy = 30.0; scopes->hist.mode = HISTO_MODE_RGB; @@ -1781,7 +1791,7 @@ void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings new_settings->gamma = settings->gamma; if (settings->curve_mapping) { - new_settings->curve_mapping = curvemapping_copy(settings->curve_mapping); + new_settings->curve_mapping = BKE_curvemapping_copy(settings->curve_mapping); } else { new_settings->curve_mapping = NULL; @@ -1791,7 +1801,7 @@ void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings void BKE_color_managed_view_settings_free(ColorManagedViewSettings *settings) { if (settings->curve_mapping) { - curvemapping_free(settings->curve_mapping); + BKE_curvemapping_free(settings->curve_mapping); } } diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 03530fc76b6..1fb25375159 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -117,7 +117,7 @@ static int neighStraightY[8] = {0, 1, 0, -1, 1, 1, -1, -1}; /* brush mesh raycast status */ #define HIT_VOLUME 1 #define HIT_PROXIMITY 2 -/* dynamicPaint_findNeighbourPixel() return codes */ +/* dynamicPaint_findNeighborPixel() return codes */ #define NOT_FOUND -1 #define ON_MESH_EDGE -2 #define OUT_OF_TEXTURE -3 @@ -233,7 +233,7 @@ typedef struct PaintUVPoint { unsigned int v1, v2, v3; /** If this pixel isn't uv mapped to any face, but it's neighboring pixel is. */ - unsigned int neighbour_pixel; + unsigned int neighbor_pixel; } PaintUVPoint; typedef struct ImgSeqFormatData { @@ -2263,7 +2263,7 @@ static void dynamic_paint_create_uv_surface_direct_cb( /* Init per pixel settings */ tPoint->tri_index = -1; - tPoint->neighbour_pixel = -1; + tPoint->neighbor_pixel = -1; tPoint->pixel_index = index; /* Actual pixel center, used when collision is found */ @@ -2377,7 +2377,7 @@ static void dynamic_paint_create_uv_surface_neighbor_cb( const int ind = (tx + u) + w * (ty + v); /* if neighbor has index */ - if (tempPoints[ind].neighbour_pixel == -1 && tempPoints[ind].tri_index != -1) { + if (tempPoints[ind].neighbor_pixel == -1 && tempPoints[ind].tri_index != -1) { float uv[2]; const int i = tempPoints[ind].tri_index; const float *uv1 = mloopuv[mlooptri[i].tri[0]].uv; @@ -2387,13 +2387,13 @@ static void dynamic_paint_create_uv_surface_neighbor_cb( /* tri index */ /* There is a low possibility of actually having a neighbor point which tri is * already set from another neighbor in a separate thread here. - * Checking for both tri_index and neighbour_pixel above reduces that probability + * Checking for both tri_index and neighbor_pixel above reduces that probability * but it remains possible. - * That atomic op (and its memory fence) ensures tPoint->neighbour_pixel is set - * to non--1 *before* its tri_index is set (i.e. that it cannot be used a neighbour). + * That atomic op (and its memory fence) ensures tPoint->neighbor_pixel is set + * to non--1 *before* its tri_index is set (i.e. that it cannot be used a neighbor). */ - tPoint->neighbour_pixel = ind - 1; - atomic_add_and_fetch_uint32(&tPoint->neighbour_pixel, 1); + tPoint->neighbor_pixel = ind - 1; + atomic_add_and_fetch_uint32(&tPoint->neighbor_pixel, 1); tPoint->tri_index = i; /* Now calculate pixel data for this pixel as it was on polygon surface */ @@ -2467,13 +2467,13 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa * px, py : origin pixel x and y * n_index : lookup direction index (use neighX, neighY to get final index) */ -static int dynamic_paint_find_neighbour_pixel(const DynamicPaintCreateUVSurfaceData *data, - const MeshElemMap *vert_to_looptri_map, - const int w, - const int h, - const int px, - const int py, - const int n_index) +static int dynamic_paint_find_neighbor_pixel(const DynamicPaintCreateUVSurfaceData *data, + const MeshElemMap *vert_to_looptri_map, + const int w, + const int h, + const int px, + const int py, + const int n_index) { /* Note: Current method only uses polygon edges to detect neighboring pixels. * -> It doesn't always lead to the optimum pixel but is accurate enough @@ -2494,7 +2494,7 @@ static int dynamic_paint_find_neighbour_pixel(const DynamicPaintCreateUVSurfaceD /* Check if shifted point is on same face -> it's a correct neighbor * (and if it isn't marked as an "edge pixel") */ - if ((tPoint->tri_index == cPoint->tri_index) && (tPoint->neighbour_pixel == -1)) { + if ((tPoint->tri_index == cPoint->tri_index) && (tPoint->neighbor_pixel == -1)) { return (x + w * y); } @@ -2504,7 +2504,7 @@ static int dynamic_paint_find_neighbour_pixel(const DynamicPaintCreateUVSurfaceD * !! Replace with "is uv faces linked" check !! * This should work fine as long as uv island margin is > 1 pixel. */ - if ((tPoint->tri_index != -1) && (tPoint->neighbour_pixel == -1)) { + if ((tPoint->tri_index != -1) && (tPoint->neighbor_pixel == -1)) { return (x + w * y); } @@ -2691,8 +2691,8 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa } /* If final point is an "edge pixel", use it's "real" neighbor instead */ - if (tempPoints[final_index].neighbour_pixel != -1) { - final_index = tempPoints[final_index].neighbour_pixel; + if (tempPoints[final_index].neighbor_pixel != -1) { + final_index = tempPoints[final_index].neighbor_pixel; /* If we ended up to our origin point */ if (final_index == (px + w * py)) { @@ -3016,7 +3016,7 @@ int dynamicPaint_createUVSurface(Scene *scene, ed->n_index[final_index[index]] = n_pos; ed->n_num[final_index[index]] = 0; - if (tempPoints[index].neighbour_pixel != -1) { + if (tempPoints[index].neighbor_pixel != -1) { ed->flags[final_index[index]] |= ADJ_BORDER_PIXEL; total_border++; } @@ -3024,7 +3024,7 @@ int dynamicPaint_createUVSurface(Scene *scene, for (int i = 0; i < 8; i++) { /* Try to find a neighboring pixel in defined direction. * If not found, -1 is returned */ - const int n_target = dynamic_paint_find_neighbour_pixel( + const int n_target = dynamic_paint_find_neighbor_pixel( &data, vert_to_looptri_map, w, h, tx, ty, i); if (n_target >= 0 && n_target != index) { @@ -3084,7 +3084,7 @@ int dynamicPaint_createUVSurface(Scene *scene, const int fidx = final_index[index]; if (tempPoints[index].tri_index != -1) { - int nidx = tempPoints[index].neighbour_pixel; + int nidx = tempPoints[index].neighbor_pixel; fprintf(dump_file, "%d\t%d,%d\t%u\t%d,%d\t%d\t", fidx, @@ -3186,7 +3186,7 @@ int dynamicPaint_createUVSurface(Scene *scene, pPoint->alpha = 1.0f; /* Every pixel that is assigned as "edge pixel" gets blue color */ - if (uvPoint->neighbour_pixel != -1) { + if (uvPoint->neighbor_pixel != -1) { pPoint->color[2] = 1.0f; } /* and every pixel that finally got an polygon gets red color */ diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 731e9aff926..ed4c6848751 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1404,6 +1404,313 @@ void BKE_gpencil_dvert_ensure(bGPDstroke *gps) /* ************************************************** */ +static void stroke_defvert_create_nr_list(MDeformVert *dv_list, + int count, + ListBase *result, + int *totweight) +{ + LinkData *ld; + MDeformVert *dv; + MDeformWeight *dw; + int i, j; + int tw = 0; + for (i = 0; i < count; i++) { + dv = &dv_list[i]; + + /* find def_nr in list, if not exist, then create one */ + for (j = 0; j < dv->totweight; j++) { + int found = 0; + dw = &dv->dw[j]; + for (ld = result->first; ld; ld = ld->next) { + if (ld->data == POINTER_FROM_INT(dw->def_nr)) { + found = 1; + break; + } + } + if (!found) { + ld = MEM_callocN(sizeof(LinkData), "def_nr_item"); + ld->data = POINTER_FROM_INT(dw->def_nr); + BLI_addtail(result, ld); + tw++; + } + } + } + + *totweight = tw; +} + +static MDeformVert *stroke_defvert_new_count(int count, int totweight, ListBase *def_nr_list) +{ + int i, j; + LinkData *ld; + MDeformVert *dst = MEM_mallocN(count * sizeof(MDeformVert), "new_deformVert"); + + dst->totweight = totweight; + + for (i = 0; i < count; i++) { + dst[i].dw = MEM_mallocN(sizeof(MDeformWeight) * totweight, "new_deformWeight"); + j = 0; + /* re-assign deform groups */ + for (ld = def_nr_list->first; ld; ld = ld->next) { + dst[i].dw[j].def_nr = POINTER_AS_INT(ld->data); + j++; + } + } + + return dst; +} + +static void stroke_interpolate_deform_weights( + bGPDstroke *gps, int index_from, int index_to, float ratio, MDeformVert *vert) +{ + const MDeformVert *vl = &gps->dvert[index_from]; + const MDeformVert *vr = &gps->dvert[index_to]; + int i; + + for (i = 0; i < vert->totweight; i++) { + float wl = defvert_find_weight(vl, vert->dw[i].def_nr); + float wr = defvert_find_weight(vr, vert->dw[i].def_nr); + vert->dw[i].weight = interpf(wr, wl, ratio); + } +} + +static int stroke_march_next_point(const bGPDstroke *gps, + const int index_next_pt, + const float *current, + const float dist, + float *result, + float *pressure, + float *strength, + float *ratio_result, + int *index_from, + int *index_to) +{ + float remaining_till_next = 0.0f; + float remaining_march = dist; + float step_start[3]; + float point[3]; + int next_point_index = index_next_pt; + bGPDspoint *pt = NULL; + + if (!(next_point_index < gps->totpoints)) { + return -1; + } + + copy_v3_v3(step_start, current); + pt = &gps->points[next_point_index]; + copy_v3_v3(point, &pt->x); + remaining_till_next = len_v3v3(point, step_start); + + while (remaining_till_next < remaining_march) { + remaining_march -= remaining_till_next; + pt = &gps->points[next_point_index]; + copy_v3_v3(point, &pt->x); + copy_v3_v3(step_start, point); + next_point_index++; + if (!(next_point_index < gps->totpoints)) { + next_point_index = gps->totpoints - 1; + break; + } + pt = &gps->points[next_point_index]; + copy_v3_v3(point, &pt->x); + remaining_till_next = len_v3v3(point, step_start); + } + if (remaining_till_next < remaining_march) { + pt = &gps->points[next_point_index]; + copy_v3_v3(result, &pt->x); + *pressure = gps->points[next_point_index].pressure; + *strength = gps->points[next_point_index].strength; + + *index_from = next_point_index - 1; + *index_to = next_point_index; + *ratio_result = 1.0f; + + return 0; + } + else { + float ratio = remaining_march / remaining_till_next; + interp_v3_v3v3(result, step_start, point, ratio); + *pressure = interpf( + gps->points[next_point_index].pressure, gps->points[next_point_index - 1].pressure, ratio); + *strength = interpf( + gps->points[next_point_index].strength, gps->points[next_point_index - 1].strength, ratio); + + *index_from = next_point_index - 1; + *index_to = next_point_index; + *ratio_result = ratio; + + return next_point_index; + } +} + +static int stroke_march_next_point_no_interp(const bGPDstroke *gps, + const int index_next_pt, + const float *current, + const float dist, + float *result) +{ + float remaining_till_next = 0.0f; + float remaining_march = dist; + float step_start[3]; + float point[3]; + int next_point_index = index_next_pt; + bGPDspoint *pt = NULL; + + if (!(next_point_index < gps->totpoints)) { + return -1; + } + + copy_v3_v3(step_start, current); + pt = &gps->points[next_point_index]; + copy_v3_v3(point, &pt->x); + remaining_till_next = len_v3v3(point, step_start); + + while (remaining_till_next < remaining_march) { + remaining_march -= remaining_till_next; + pt = &gps->points[next_point_index]; + copy_v3_v3(point, &pt->x); + copy_v3_v3(step_start, point); + next_point_index++; + if (!(next_point_index < gps->totpoints)) { + next_point_index = gps->totpoints - 1; + break; + } + pt = &gps->points[next_point_index]; + copy_v3_v3(point, &pt->x); + remaining_till_next = len_v3v3(point, step_start); + } + if (remaining_till_next < remaining_march) { + pt = &gps->points[next_point_index]; + copy_v3_v3(result, &pt->x); + return 0; + } + else { + float ratio = remaining_march / remaining_till_next; + interp_v3_v3v3(result, step_start, point, ratio); + return next_point_index; + } +} + +static int stroke_march_count(const bGPDstroke *gps, const float dist) +{ + int point_count = 0; + float point[3]; + int next_point_index = 1; + bGPDspoint *pt = NULL; + + pt = &gps->points[0]; + copy_v3_v3(point, &pt->x); + point_count++; + + while ((next_point_index = stroke_march_next_point_no_interp( + gps, next_point_index, point, dist, point)) > -1) { + point_count++; + if (next_point_index == 0) { + break; /* last point finished */ + } + } + return point_count; +} + +/** + * Resample a stroke + * \param gps: Stroke to sample + * \param dist: Distance of one segment + */ +bool BKE_gpencil_sample_stroke(bGPDstroke *gps, const float dist, const bool select) +{ + bGPDspoint *pt = gps->points; + bGPDspoint *pt1 = NULL; + bGPDspoint *pt2 = NULL; + int i; + LinkData *ld; + ListBase def_nr_list = {0}; + + if (gps->totpoints < 2 || dist < FLT_EPSILON) { + return false; + } + /* TODO: Implement feature point preservation. */ + int count = stroke_march_count(gps, dist); + + bGPDspoint *new_pt = MEM_callocN(sizeof(bGPDspoint) * count, "gp_stroke_points_sampled"); + MDeformVert *new_dv = NULL; + + int result_totweight; + + if (gps->dvert != NULL) { + stroke_defvert_create_nr_list(gps->dvert, count, &def_nr_list, &result_totweight); + new_dv = stroke_defvert_new_count(count, result_totweight, &def_nr_list); + } + + int next_point_index = 1; + i = 0; + float pressure, strength, ratio_result; + int index_from, index_to; + float last_coord[3]; + + /* 1st point is always at the start */ + pt1 = &gps->points[0]; + copy_v3_v3(last_coord, &pt1->x); + pt2 = &new_pt[i]; + copy_v3_v3(&pt2->x, last_coord); + new_pt[i].pressure = pt[0].pressure; + new_pt[i].strength = pt[0].strength; + if (select) { + new_pt[i].flag |= GP_SPOINT_SELECT; + } + i++; + + if (new_dv) { + stroke_interpolate_deform_weights(gps, 0, 0, 0, &new_dv[0]); + } + + /* the rest */ + while ((next_point_index = stroke_march_next_point(gps, + next_point_index, + last_coord, + dist, + last_coord, + &pressure, + &strength, + &ratio_result, + &index_from, + &index_to)) > -1) { + pt2 = &new_pt[i]; + copy_v3_v3(&pt2->x, last_coord); + new_pt[i].pressure = pressure; + new_pt[i].strength = strength; + if (select) { + new_pt[i].flag |= GP_SPOINT_SELECT; + } + + if (new_dv) { + stroke_interpolate_deform_weights(gps, index_from, index_to, ratio_result, &new_dv[i]); + } + + i++; + if (next_point_index == 0) { + break; /* last point finished */ + } + } + + gps->points = new_pt; + gps->totpoints = i; + MEM_freeN(pt); /* original */ + + if (new_dv) { + BKE_gpencil_free_stroke_weights(gps); + while ((ld = BLI_pophead(&def_nr_list))) { + MEM_freeN(ld); + } + gps->dvert = new_dv; + } + + gps->flag |= GP_STROKE_RECALC_GEOMETRY; + gps->tot_triangles = 0; + + return true; +} + /** * Apply smooth to stroke point * \param gps: Stroke to smooth @@ -1632,13 +1939,13 @@ float BKE_gpencil_multiframe_falloff_calc( if (gpf->framenum < actnum) { fnum = (float)(gpf->framenum - f_init) / (actnum - f_init); fnum *= 0.5f; - value = curvemapping_evaluateF(cur_falloff, 0, fnum); + value = BKE_curvemapping_evaluateF(cur_falloff, 0, fnum); } /* frames to the left of the active frame */ else if (gpf->framenum > actnum) { fnum = (float)(gpf->framenum - actnum) / (f_end - actnum); fnum *= 0.5f; - value = curvemapping_evaluateF(cur_falloff, 0, fnum + 0.5f); + value = BKE_curvemapping_evaluateF(cur_falloff, 0, fnum + 0.5f); } else { value = 1.0f; @@ -2006,6 +2313,12 @@ bool BKE_gpencil_close_stroke(bGPDstroke *gps) pt2 = &gps->points[0]; float dist_close = len_v3v3(&pt1->x, &pt2->x); + /* if the distance to close is very small, don't need add points and just enable cyclic. */ + if (dist_close <= dist_avg) { + gps->flag |= GP_STROKE_CYCLIC; + return true; + } + /* Calc number of points required using the average distance. */ int tot_newpoints = MAX2(dist_close / dist_avg, 1); @@ -2022,9 +2335,11 @@ bool BKE_gpencil_close_stroke(bGPDstroke *gps) pt2 = &gps->points[0]; bGPDspoint *pt = &gps->points[old_tot]; for (int i = 1; i < tot_newpoints + 1; i++, pt++) { - float step = ((float)i / (float)tot_newpoints); + float step = (tot_newpoints > 1) ? ((float)i / (float)tot_newpoints) : 0.99f; /* Clamp last point to be near, but not on top of first point. */ - CLAMP(step, 0.0f, 0.99f); + if ((tot_newpoints > 1) && (i == tot_newpoints)) { + step *= 0.99f; + } /* Average point. */ interp_v3_v3v3(&pt->x, &pt1->x, &pt2->x, step); @@ -2056,7 +2371,6 @@ bool BKE_gpencil_close_stroke(bGPDstroke *gps) return true; } - /* Dissolve points in stroke */ void BKE_gpencil_dissolve_points(bGPDframe *gpf, bGPDstroke *gps, const short tag) { @@ -2138,3 +2452,81 @@ void BKE_gpencil_dissolve_points(bGPDframe *gpf, bGPDstroke *gps, const short ta gps->tot_triangles = 0; } } + +/* Merge by distance ------------------------------------- */ +/* Reduce a series of points when the distance is below a threshold. + * Special case for first and last points (both are keeped) for other points, + * the merge point always is at first point. + * \param gpf: Grease Pencil frame + * \param gps: Grease Pencil stroke + * \param threshold: Distance between points + * \param use_unselected: Set to true to analyze all stroke and not only selected points + */ +void BKE_gpencil_merge_distance_stroke(bGPDframe *gpf, + bGPDstroke *gps, + const float threshold, + const bool use_unselected) +{ + bGPDspoint *pt = NULL; + bGPDspoint *pt_next = NULL; + float tagged = false; + /* Use square distance to speed up loop */ + const float th_square = threshold * threshold; + /* Need to have something to merge. */ + if (gps->totpoints < 2) { + return; + } + int i = 0; + int step = 1; + while ((i < gps->totpoints - 1) && (i + step < gps->totpoints)) { + pt = &gps->points[i]; + if (pt->flag & GP_SPOINT_TAG) { + i++; + step = 1; + continue; + } + pt_next = &gps->points[i + step]; + /* Do not recalc tagged points. */ + if (pt_next->flag & GP_SPOINT_TAG) { + step++; + continue; + } + /* Check if contiguous points are selected. */ + if (!use_unselected) { + if (((pt->flag & GP_SPOINT_SELECT) == 0) || ((pt_next->flag & GP_SPOINT_SELECT) == 0)) { + i++; + step = 1; + continue; + } + } + float len_square = len_squared_v3v3(&pt->x, &pt_next->x); + if (len_square <= th_square) { + tagged = true; + if (i != gps->totpoints - 1) { + /* Tag second point for delete. */ + pt_next->flag |= GP_SPOINT_TAG; + } + else { + pt->flag |= GP_SPOINT_TAG; + } + /* Jump to next pair of points, keeping first point segment equals.*/ + step++; + } + else { + /* Analyze next point. */ + i++; + step = 1; + } + } + + /* Always untag extremes. */ + pt = &gps->points[0]; + pt->flag &= ~GP_SPOINT_TAG; + pt = &gps->points[gps->totpoints - 1]; + pt->flag &= ~GP_SPOINT_TAG; + + /* Dissolve tagged points */ + if (tagged) { + BKE_gpencil_dissolve_points(gpf, gps, GP_SPOINT_TAG); + } +} diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 3f095d923b1..de6f5142a19 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1815,7 +1815,7 @@ static int id_refcount_recompute_callback(void *user_data, return IDWALK_RET_NOP; } -void BLE_main_id_refcount_recompute(struct Main *bmain, const bool do_linked_only) +void BKE_main_id_refcount_recompute(struct Main *bmain, const bool do_linked_only) { ID *id; diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c index 271bf58fcc6..75c9e0e42a5 100644 --- a/source/blender/blenkernel/intern/light.c +++ b/source/blender/blenkernel/intern/light.c @@ -69,7 +69,7 @@ void BKE_light_init(Light *la) la->coeff_const = 1.0f; la->coeff_lin = 0.0f; la->coeff_quad = 0.0f; - la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); + la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); la->cascade_max_dist = 200.0f; la->cascade_count = 4; la->cascade_exponent = 0.8f; @@ -82,7 +82,7 @@ void BKE_light_init(Light *la) la->att_dist = 40.0f; la->sun_angle = DEG2RADF(0.526f); - curvemapping_initialize(la->curfalloff); + BKE_curvemapping_initialize(la->curfalloff); } Light *BKE_light_add(Main *bmain, const char *name) @@ -108,7 +108,7 @@ Light *BKE_light_add(Main *bmain, const char *name) */ void BKE_light_copy_data(Main *bmain, Light *la_dst, const Light *la_src, const int flag) { - la_dst->curfalloff = curvemapping_copy(la_src->curfalloff); + la_dst->curfalloff = BKE_curvemapping_copy(la_src->curfalloff); if (la_src->nodetree) { /* Note: nodetree is *not* in bmain, however this specific case is handled at lower level @@ -145,7 +145,7 @@ Light *BKE_light_localize(Light *la) Light *lan = BKE_libblock_copy_for_localize(&la->id); - lan->curfalloff = curvemapping_copy(la->curfalloff); + lan->curfalloff = BKE_curvemapping_copy(la->curfalloff); if (la->nodetree) { lan->nodetree = ntreeLocalize(la->nodetree); @@ -167,7 +167,7 @@ void BKE_light_free(Light *la) { BKE_animdata_free((ID *)la, false); - curvemapping_free(la->curfalloff); + BKE_curvemapping_free(la->curfalloff); /* is no lib link block, but light extension */ if (la->nodetree) { diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c index 31e6d2e89e5..7bfe5a7c8ff 100644 --- a/source/blender/blenkernel/intern/linestyle.c +++ b/source/blender/blenkernel/intern/linestyle.c @@ -512,13 +512,13 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_add(FreestyleLineStyle *linestyl switch (type) { case LS_MODIFIER_ALONG_STROKE: { LineStyleAlphaModifier_AlongStroke *p = (LineStyleAlphaModifier_AlongStroke *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); break; } case LS_MODIFIER_DISTANCE_FROM_CAMERA: { LineStyleAlphaModifier_DistanceFromCamera *p = (LineStyleAlphaModifier_DistanceFromCamera *) m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->range_min = 0.0f; p->range_max = 10000.0f; break; @@ -527,25 +527,25 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_add(FreestyleLineStyle *linestyl LineStyleAlphaModifier_DistanceFromObject *p = (LineStyleAlphaModifier_DistanceFromObject *) m; p->target = NULL; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->range_min = 0.0f; p->range_max = 10000.0f; break; } case LS_MODIFIER_MATERIAL: { LineStyleAlphaModifier_Material *p = (LineStyleAlphaModifier_Material *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->mat_attr = LS_MODIFIER_MATERIAL_LINE_A; break; } case LS_MODIFIER_TANGENT: { LineStyleAlphaModifier_Tangent *p = (LineStyleAlphaModifier_Tangent *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); break; } case LS_MODIFIER_NOISE: { LineStyleAlphaModifier_Noise *p = (LineStyleAlphaModifier_Noise *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); ((LineStyleAlphaModifier_Noise *)m)->amplitude = 10.0f; ((LineStyleAlphaModifier_Noise *)m)->period = 10.0f; ((LineStyleAlphaModifier_Noise *)m)->seed = 512; @@ -553,14 +553,14 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_add(FreestyleLineStyle *linestyl } case LS_MODIFIER_CREASE_ANGLE: { LineStyleAlphaModifier_CreaseAngle *p = (LineStyleAlphaModifier_CreaseAngle *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); ((LineStyleAlphaModifier_CreaseAngle *)m)->min_angle = 0.0f; ((LineStyleAlphaModifier_CreaseAngle *)m)->max_angle = DEG2RADF(180.0f); break; } case LS_MODIFIER_CURVATURE_3D: { LineStyleAlphaModifier_Curvature_3D *p = (LineStyleAlphaModifier_Curvature_3D *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); ((LineStyleAlphaModifier_Curvature_3D *)m)->min_curvature = 0.0f; ((LineStyleAlphaModifier_Curvature_3D *)m)->max_curvature = 0.5f; break; @@ -588,7 +588,7 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty case LS_MODIFIER_ALONG_STROKE: { LineStyleAlphaModifier_AlongStroke *p = (LineStyleAlphaModifier_AlongStroke *)m; LineStyleAlphaModifier_AlongStroke *q = (LineStyleAlphaModifier_AlongStroke *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; break; } @@ -597,7 +597,7 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty m; LineStyleAlphaModifier_DistanceFromCamera *q = (LineStyleAlphaModifier_DistanceFromCamera *) new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->range_min = p->range_min; q->range_max = p->range_max; @@ -612,7 +612,7 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty id_us_plus(&p->target->id); } q->target = p->target; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->range_min = p->range_min; q->range_max = p->range_max; @@ -621,7 +621,7 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty case LS_MODIFIER_MATERIAL: { LineStyleAlphaModifier_Material *p = (LineStyleAlphaModifier_Material *)m; LineStyleAlphaModifier_Material *q = (LineStyleAlphaModifier_Material *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->mat_attr = p->mat_attr; break; @@ -629,14 +629,14 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty case LS_MODIFIER_TANGENT: { LineStyleAlphaModifier_Tangent *p = (LineStyleAlphaModifier_Tangent *)m; LineStyleAlphaModifier_Tangent *q = (LineStyleAlphaModifier_Tangent *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; break; } case LS_MODIFIER_NOISE: { LineStyleAlphaModifier_Noise *p = (LineStyleAlphaModifier_Noise *)m; LineStyleAlphaModifier_Noise *q = (LineStyleAlphaModifier_Noise *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->amplitude = p->amplitude; q->period = p->period; @@ -646,7 +646,7 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty case LS_MODIFIER_CREASE_ANGLE: { LineStyleAlphaModifier_CreaseAngle *p = (LineStyleAlphaModifier_CreaseAngle *)m; LineStyleAlphaModifier_CreaseAngle *q = (LineStyleAlphaModifier_CreaseAngle *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->min_angle = p->min_angle; q->max_angle = p->max_angle; @@ -655,7 +655,7 @@ LineStyleModifier *BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linesty case LS_MODIFIER_CURVATURE_3D: { LineStyleAlphaModifier_Curvature_3D *p = (LineStyleAlphaModifier_Curvature_3D *)m; LineStyleAlphaModifier_Curvature_3D *q = (LineStyleAlphaModifier_Curvature_3D *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->min_curvature = p->min_curvature; q->max_curvature = p->max_curvature; @@ -676,28 +676,28 @@ int BKE_linestyle_alpha_modifier_remove(FreestyleLineStyle *linestyle, LineStyle } switch (m->type) { case LS_MODIFIER_ALONG_STROKE: - curvemapping_free(((LineStyleAlphaModifier_AlongStroke *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_AlongStroke *)m)->curve); break; case LS_MODIFIER_DISTANCE_FROM_CAMERA: - curvemapping_free(((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve); break; case LS_MODIFIER_DISTANCE_FROM_OBJECT: - curvemapping_free(((LineStyleAlphaModifier_DistanceFromObject *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_DistanceFromObject *)m)->curve); break; case LS_MODIFIER_MATERIAL: - curvemapping_free(((LineStyleAlphaModifier_Material *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_Material *)m)->curve); break; case LS_MODIFIER_TANGENT: - curvemapping_free(((LineStyleAlphaModifier_Tangent *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_Tangent *)m)->curve); break; case LS_MODIFIER_NOISE: - curvemapping_free(((LineStyleAlphaModifier_Noise *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_Noise *)m)->curve); break; case LS_MODIFIER_CREASE_ANGLE: - curvemapping_free(((LineStyleAlphaModifier_CreaseAngle *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_CreaseAngle *)m)->curve); break; case LS_MODIFIER_CURVATURE_3D: - curvemapping_free(((LineStyleAlphaModifier_Curvature_3D *)m)->curve); + BKE_curvemapping_free(((LineStyleAlphaModifier_Curvature_3D *)m)->curve); break; } BLI_freelinkN(&linestyle->alpha_modifiers, m); @@ -755,7 +755,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line switch (type) { case LS_MODIFIER_ALONG_STROKE: { LineStyleThicknessModifier_AlongStroke *p = (LineStyleThicknessModifier_AlongStroke *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->value_min = 0.0f; p->value_max = 1.0f; break; @@ -763,7 +763,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line case LS_MODIFIER_DISTANCE_FROM_CAMERA: { LineStyleThicknessModifier_DistanceFromCamera *p = (LineStyleThicknessModifier_DistanceFromCamera *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->range_min = 0.0f; p->range_max = 1000.0f; p->value_min = 0.0f; @@ -774,7 +774,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line LineStyleThicknessModifier_DistanceFromObject *p = (LineStyleThicknessModifier_DistanceFromObject *)m; p->target = NULL; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->range_min = 0.0f; p->range_max = 1000.0f; p->value_min = 0.0f; @@ -783,7 +783,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line } case LS_MODIFIER_MATERIAL: { LineStyleThicknessModifier_Material *p = (LineStyleThicknessModifier_Material *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->mat_attr = LS_MODIFIER_MATERIAL_LINE; p->value_min = 0.0f; p->value_max = 1.0f; @@ -798,7 +798,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line } case LS_MODIFIER_TANGENT: { LineStyleThicknessModifier_Tangent *p = (LineStyleThicknessModifier_Tangent *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->min_thickness = 1.0f; p->max_thickness = 10.0f; break; @@ -813,7 +813,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line } case LS_MODIFIER_CREASE_ANGLE: { LineStyleThicknessModifier_CreaseAngle *p = (LineStyleThicknessModifier_CreaseAngle *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->min_angle = 0.0f; p->max_angle = DEG2RADF(180.0f); p->min_thickness = 1.0f; @@ -822,7 +822,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *line } case LS_MODIFIER_CURVATURE_3D: { LineStyleThicknessModifier_Curvature_3D *p = (LineStyleThicknessModifier_Curvature_3D *)m; - p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + p->curve = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); p->min_curvature = 0.0f; p->max_curvature = 0.5f; p->min_thickness = 1.0f; @@ -855,7 +855,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin case LS_MODIFIER_ALONG_STROKE: { LineStyleThicknessModifier_AlongStroke *p = (LineStyleThicknessModifier_AlongStroke *)m; LineStyleThicknessModifier_AlongStroke *q = (LineStyleThicknessModifier_AlongStroke *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->value_min = p->value_min; q->value_max = p->value_max; @@ -866,7 +866,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin (LineStyleThicknessModifier_DistanceFromCamera *)m; LineStyleThicknessModifier_DistanceFromCamera *q = (LineStyleThicknessModifier_DistanceFromCamera *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->range_min = p->range_min; q->range_max = p->range_max; @@ -883,7 +883,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) { id_us_plus((ID *)q->target); } - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->range_min = p->range_min; q->range_max = p->range_max; @@ -894,7 +894,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin case LS_MODIFIER_MATERIAL: { LineStyleThicknessModifier_Material *p = (LineStyleThicknessModifier_Material *)m; LineStyleThicknessModifier_Material *q = (LineStyleThicknessModifier_Material *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->mat_attr = p->mat_attr; q->value_min = p->value_min; @@ -912,7 +912,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin case LS_MODIFIER_TANGENT: { LineStyleThicknessModifier_Tangent *p = (LineStyleThicknessModifier_Tangent *)m; LineStyleThicknessModifier_Tangent *q = (LineStyleThicknessModifier_Tangent *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->min_thickness = p->min_thickness; q->max_thickness = p->max_thickness; @@ -931,7 +931,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin LineStyleThicknessModifier_Curvature_3D *p = (LineStyleThicknessModifier_Curvature_3D *)m; LineStyleThicknessModifier_Curvature_3D *q = (LineStyleThicknessModifier_Curvature_3D *) new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->min_curvature = p->min_curvature; q->max_curvature = p->max_curvature; @@ -942,7 +942,7 @@ LineStyleModifier *BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *lin case LS_MODIFIER_CREASE_ANGLE: { LineStyleThicknessModifier_CreaseAngle *p = (LineStyleThicknessModifier_CreaseAngle *)m; LineStyleThicknessModifier_CreaseAngle *q = (LineStyleThicknessModifier_CreaseAngle *)new_m; - q->curve = curvemapping_copy(p->curve); + q->curve = BKE_curvemapping_copy(p->curve); q->flags = p->flags; q->min_angle = p->min_angle; q->max_angle = p->max_angle; @@ -965,21 +965,21 @@ int BKE_linestyle_thickness_modifier_remove(FreestyleLineStyle *linestyle, LineS } switch (m->type) { case LS_MODIFIER_ALONG_STROKE: - curvemapping_free(((LineStyleThicknessModifier_AlongStroke *)m)->curve); + BKE_curvemapping_free(((LineStyleThicknessModifier_AlongStroke *)m)->curve); break; case LS_MODIFIER_DISTANCE_FROM_CAMERA: - curvemapping_free(((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve); + BKE_curvemapping_free(((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve); break; case LS_MODIFIER_DISTANCE_FROM_OBJECT: - curvemapping_free(((LineStyleThicknessModifier_DistanceFromObject *)m)->curve); + BKE_curvemapping_free(((LineStyleThicknessModifier_DistanceFromObject *)m)->curve); break; case LS_MODIFIER_MATERIAL: - curvemapping_free(((LineStyleThicknessModifier_Material *)m)->curve); + BKE_curvemapping_free(((LineStyleThicknessModifier_Material *)m)->curve); break; case LS_MODIFIER_CALLIGRAPHY: break; case LS_MODIFIER_TANGENT: - curvemapping_free(((LineStyleThicknessModifier_Tangent *)m)->curve); + BKE_curvemapping_free(((LineStyleThicknessModifier_Tangent *)m)->curve); break; case LS_MODIFIER_NOISE: break; diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 0e93c80ecb5..4a41ffbfa8c 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -658,15 +658,16 @@ void BKE_paint_cavity_curve_preset(Paint *p, int preset) CurveMap *cm = NULL; if (!p->cavity_curve) { - p->cavity_curve = curvemapping_add(1, 0, 0, 1, 1); + p->cavity_curve = BKE_curvemapping_add(1, 0, 0, 1, 1); } cm = p->cavity_curve->cm; cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; p->cavity_curve->preset = preset; - curvemap_reset(cm, &p->cavity_curve->clipr, p->cavity_curve->preset, CURVEMAP_SLOPE_POSITIVE); - curvemapping_changed(p->cavity_curve, false); + BKE_curvemap_reset( + cm, &p->cavity_curve->clipr, p->cavity_curve->preset, CURVEMAP_SLOPE_POSITIVE); + BKE_curvemapping_changed(p->cavity_curve, false); } eObjectMode BKE_paint_object_mode_from_paintmode(ePaintMode mode) @@ -778,7 +779,7 @@ void BKE_paint_init(Main *bmain, Scene *sce, ePaintMode mode, const char col[3]) void BKE_paint_free(Paint *paint) { - curvemapping_free(paint->cavity_curve); + BKE_curvemapping_free(paint->cavity_curve); MEM_SAFE_FREE(paint->tool_slots); } @@ -789,7 +790,7 @@ void BKE_paint_free(Paint *paint) void BKE_paint_copy(Paint *src, Paint *tar, const int flag) { tar->brush = src->brush; - tar->cavity_curve = curvemapping_copy(src->cavity_curve); + tar->cavity_curve = BKE_curvemapping_copy(src->cavity_curve); tar->tool_slots = MEM_dupallocN(src->tool_slots); if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) { diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 9cc49e39231..da00a044009 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -494,13 +494,13 @@ void BKE_particlesettings_free(ParticleSettings *part) } if (part->clumpcurve) { - curvemapping_free(part->clumpcurve); + BKE_curvemapping_free(part->clumpcurve); } if (part->roughcurve) { - curvemapping_free(part->roughcurve); + BKE_curvemapping_free(part->roughcurve); } if (part->twistcurve) { - curvemapping_free(part->twistcurve); + BKE_curvemapping_free(part->twistcurve); } BKE_partdeflect_free(part->pd); @@ -2060,10 +2060,10 @@ int do_guides(Depsgraph *depsgraph, } if (clumpcurve) { - curvemapping_changed_all(clumpcurve); + BKE_curvemapping_changed_all(clumpcurve); } if (roughcurve) { - curvemapping_changed_all(roughcurve); + BKE_curvemapping_changed_all(roughcurve); } { @@ -2368,22 +2368,22 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx, /* prepare curvemapping tables */ if ((part->child_flag & PART_CHILD_USE_CLUMP_CURVE) && part->clumpcurve) { - ctx->clumpcurve = curvemapping_copy(part->clumpcurve); - curvemapping_changed_all(ctx->clumpcurve); + ctx->clumpcurve = BKE_curvemapping_copy(part->clumpcurve); + BKE_curvemapping_changed_all(ctx->clumpcurve); } else { ctx->clumpcurve = NULL; } if ((part->child_flag & PART_CHILD_USE_ROUGH_CURVE) && part->roughcurve) { - ctx->roughcurve = curvemapping_copy(part->roughcurve); - curvemapping_changed_all(ctx->roughcurve); + ctx->roughcurve = BKE_curvemapping_copy(part->roughcurve); + BKE_curvemapping_changed_all(ctx->roughcurve); } else { ctx->roughcurve = NULL; } if ((part->child_flag & PART_CHILD_USE_TWIST_CURVE) && part->twistcurve) { - ctx->twistcurve = curvemapping_copy(part->twistcurve); - curvemapping_changed_all(ctx->twistcurve); + ctx->twistcurve = BKE_curvemapping_copy(part->twistcurve); + BKE_curvemapping_changed_all(ctx->twistcurve); } else { ctx->twistcurve = NULL; @@ -3719,42 +3719,42 @@ ParticleSettings *BKE_particlesettings_add(Main *bmain, const char *name) void BKE_particlesettings_clump_curve_init(ParticleSettings *part) { - CurveMapping *cumap = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + CurveMapping *cumap = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); cumap->cm[0].curve[0].x = 0.0f; cumap->cm[0].curve[0].y = 1.0f; cumap->cm[0].curve[1].x = 1.0f; cumap->cm[0].curve[1].y = 1.0f; - curvemapping_initialize(cumap); + BKE_curvemapping_initialize(cumap); part->clumpcurve = cumap; } void BKE_particlesettings_rough_curve_init(ParticleSettings *part) { - CurveMapping *cumap = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + CurveMapping *cumap = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); cumap->cm[0].curve[0].x = 0.0f; cumap->cm[0].curve[0].y = 1.0f; cumap->cm[0].curve[1].x = 1.0f; cumap->cm[0].curve[1].y = 1.0f; - curvemapping_initialize(cumap); + BKE_curvemapping_initialize(cumap); part->roughcurve = cumap; } void BKE_particlesettings_twist_curve_init(ParticleSettings *part) { - CurveMapping *cumap = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + CurveMapping *cumap = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); cumap->cm[0].curve[0].x = 0.0f; cumap->cm[0].curve[0].y = 1.0f; cumap->cm[0].curve[1].x = 1.0f; cumap->cm[0].curve[1].y = 1.0f; - curvemapping_initialize(cumap); + BKE_curvemapping_initialize(cumap); part->twistcurve = cumap; } @@ -3780,13 +3780,13 @@ void BKE_particlesettings_copy_data(Main *UNUSED(bmain), part_dst->fluid = MEM_dupallocN(part_src->fluid); if (part_src->clumpcurve) { - part_dst->clumpcurve = curvemapping_copy(part_src->clumpcurve); + part_dst->clumpcurve = BKE_curvemapping_copy(part_src->clumpcurve); } if (part_src->roughcurve) { - part_dst->roughcurve = curvemapping_copy(part_src->roughcurve); + part_dst->roughcurve = BKE_curvemapping_copy(part_src->roughcurve); } if (part_src->twistcurve) { - part_dst->twistcurve = curvemapping_copy(part_src->twistcurve); + part_dst->twistcurve = BKE_curvemapping_copy(part_src->twistcurve); } part_dst->boids = boid_copy_settings(part_src->boids); diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c index b74fd3ff684..3b02e010e7f 100644 --- a/source/blender/blenkernel/intern/particle_child.c +++ b/source/blender/blenkernel/intern/particle_child.c @@ -597,7 +597,8 @@ static float do_clump_level(float result[3], float clump = 0.0f; if (clumpcurve) { - clump = pa_clump * (1.0f - clamp_f(curvemapping_evaluateF(clumpcurve, 0, time), 0.0f, 1.0f)); + clump = pa_clump * + (1.0f - clamp_f(BKE_curvemapping_evaluateF(clumpcurve, 0, time), 0.0f, 1.0f)); interp_v3_v3v3(result, co, par_co, clump); } @@ -714,7 +715,7 @@ static void do_rough_curve(const float loc[3], return; } - fac *= clamp_f(curvemapping_evaluateF(roughcurve, 0, time), 0.0f, 1.0f); + fac *= clamp_f(BKE_curvemapping_evaluateF(roughcurve, 0, time), 0.0f, 1.0f); copy_v3_v3(rco, loc); mul_v3_fl(rco, time); @@ -749,15 +750,15 @@ static void twist_get_axis(const ParticleChildModifierContext *modifier_ctx, } } -static float curvemapping_integrate_clamped(CurveMapping *curve, - float start, - float end, - float step) +static float BKE_curvemapping_integrate_clamped(CurveMapping *curve, + float start, + float end, + float step) { float integral = 0.0f; float x = start; while (x < end) { - float y = curvemapping_evaluateF(curve, 0, x); + float y = BKE_curvemapping_evaluateF(curve, 0, x); y = clamp_f(y, 0.0f, 1.0f); /* TODO(sergey): Clamp last step to end. */ integral += y * step; @@ -804,7 +805,7 @@ static void do_twist(const ParticleChildModifierContext *modifier_ctx, } if (twist_curve != NULL) { const int num_segments = twist_num_segments(modifier_ctx); - angle *= curvemapping_integrate_clamped(twist_curve, 0.0f, time, 1.0f / num_segments); + angle *= BKE_curvemapping_integrate_clamped(twist_curve, 0.0f, time, 1.0f / num_segments); } else { angle *= time; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 5685e5cd05e..31484b59127 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -563,13 +563,13 @@ void psys_thread_context_free(ParticleThreadContext *ctx) BLI_kdtree_3d_free(ctx->tree); if (ctx->clumpcurve != NULL) { - curvemapping_free(ctx->clumpcurve); + BKE_curvemapping_free(ctx->clumpcurve); } if (ctx->roughcurve != NULL) { - curvemapping_free(ctx->roughcurve); + BKE_curvemapping_free(ctx->roughcurve); } if (ctx->twistcurve != NULL) { - curvemapping_free(ctx->twistcurve); + BKE_curvemapping_free(ctx->twistcurve); } } @@ -1958,10 +1958,10 @@ static void sphclassical_density_accum_cb(void *userdata, pfr->data[1] += q / npa->sphdensity; } -static void sphclassical_neighbour_accum_cb(void *userdata, - int index, - const float co[3], - float UNUSED(squared_dist)) +static void sphclassical_neighbor_accum_cb(void *userdata, + int index, + const float co[3], + float UNUSED(squared_dist)) { SPHRangeData *pfr = (SPHRangeData *)userdata; ParticleData *npa = pfr->npsys->particles + index; @@ -2031,7 +2031,7 @@ static void sphclassical_force_cb(void *sphdata_v, pfr.pa = pa; sph_evaluate_func( - NULL, psys, state->co, &pfr, interaction_radius, sphclassical_neighbour_accum_cb); + NULL, psys, state->co, &pfr, interaction_radius, sphclassical_neighbor_accum_cb); pressure = stiffness * (pow7f(pa->sphdensity / rest_density) - 1.0f); /* multiply by mass so that we return a force, not accel */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index b582b4f54bd..1ef93427253 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -176,10 +176,10 @@ ToolSettings *BKE_toolsettings_copy(ToolSettings *toolsettings, const int flag) ts->particle.object = NULL; /* duplicate Grease Pencil interpolation curve */ - ts->gp_interpolate.custom_ipo = curvemapping_copy(ts->gp_interpolate.custom_ipo); + ts->gp_interpolate.custom_ipo = BKE_curvemapping_copy(ts->gp_interpolate.custom_ipo); /* duplicate Grease Pencil multiframe fallof */ - ts->gp_sculpt.cur_falloff = curvemapping_copy(ts->gp_sculpt.cur_falloff); - ts->gp_sculpt.cur_primitive = curvemapping_copy(ts->gp_sculpt.cur_primitive); + ts->gp_sculpt.cur_falloff = BKE_curvemapping_copy(ts->gp_sculpt.cur_falloff); + ts->gp_sculpt.cur_primitive = BKE_curvemapping_copy(ts->gp_sculpt.cur_primitive); return ts; } @@ -212,14 +212,14 @@ void BKE_toolsettings_free(ToolSettings *toolsettings) /* free Grease Pencil interpolation curve */ if (toolsettings->gp_interpolate.custom_ipo) { - curvemapping_free(toolsettings->gp_interpolate.custom_ipo); + BKE_curvemapping_free(toolsettings->gp_interpolate.custom_ipo); } /* free Grease Pencil multiframe falloff curve */ if (toolsettings->gp_sculpt.cur_falloff) { - curvemapping_free(toolsettings->gp_sculpt.cur_falloff); + BKE_curvemapping_free(toolsettings->gp_sculpt.cur_falloff); } if (toolsettings->gp_sculpt.cur_primitive) { - curvemapping_free(toolsettings->gp_sculpt.cur_primitive); + BKE_curvemapping_free(toolsettings->gp_sculpt.cur_primitive); } MEM_freeN(toolsettings); @@ -291,7 +291,7 @@ void BKE_scene_copy_data(Main *bmain, Scene *sce_dst, const Scene *sce_src, cons BKE_color_managed_view_settings_copy(&sce_dst->r.bake.im_format.view_settings, &sce_src->r.bake.im_format.view_settings); - curvemapping_copy_data(&sce_dst->r.mblur_shutter_curve, &sce_src->r.mblur_shutter_curve); + BKE_curvemapping_copy_data(&sce_dst->r.mblur_shutter_curve, &sce_src->r.mblur_shutter_curve); /* tool settings */ sce_dst->toolsettings = BKE_toolsettings_copy(sce_dst->toolsettings, flag_subdata); @@ -347,7 +347,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) sce_copy = BKE_scene_add(bmain, sce->id.name + 2); rv = sce_copy->r.views; - curvemapping_free_data(&sce_copy->r.mblur_shutter_curve); + BKE_curvemapping_free_data(&sce_copy->r.mblur_shutter_curve); sce_copy->r = sce->r; sce_copy->r.views = rv; sce_copy->unit = sce->unit; @@ -380,7 +380,7 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type) BKE_color_managed_view_settings_copy(&sce_copy->r.bake.im_format.view_settings, &sce->r.bake.im_format.view_settings); - curvemapping_copy_data(&sce_copy->r.mblur_shutter_curve, &sce->r.mblur_shutter_curve); + BKE_curvemapping_copy_data(&sce_copy->r.mblur_shutter_curve, &sce->r.mblur_shutter_curve); /* viewport display settings */ sce_copy->display = sce->display; @@ -515,7 +515,7 @@ void BKE_scene_free_ex(Scene *sce, const bool do_id_user) BKE_color_managed_view_settings_free(&sce->view_settings); BKE_previewimg_free(&sce->preview); - curvemapping_free_data(&sce->r.mblur_shutter_curve); + BKE_curvemapping_free_data(&sce->r.mblur_shutter_curve); for (ViewLayer *view_layer = sce->view_layers.first, *view_layer_next; view_layer; view_layer = view_layer_next) { @@ -653,12 +653,12 @@ void BKE_scene_init(Scene *sce) sce->r.unit_line_thickness = 1.0f; mblur_shutter_curve = &sce->r.mblur_shutter_curve; - curvemapping_set_defaults(mblur_shutter_curve, 1, 0.0f, 0.0f, 1.0f, 1.0f); - curvemapping_initialize(mblur_shutter_curve); - curvemap_reset(mblur_shutter_curve->cm, - &mblur_shutter_curve->clipr, - CURVE_PRESET_MAX, - CURVEMAP_SLOPE_POS_NEG); + BKE_curvemapping_set_defaults(mblur_shutter_curve, 1, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_initialize(mblur_shutter_curve); + BKE_curvemap_reset(mblur_shutter_curve->cm, + &mblur_shutter_curve->clipr, + CURVE_PRESET_MAX, + CURVEMAP_SLOPE_POS_NEG); sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct"); @@ -704,19 +704,19 @@ void BKE_scene_init(Scene *sce) sce->toolsettings->imapaint.seam_bleed = 2; /* grease pencil multiframe falloff curve */ - sce->toolsettings->gp_sculpt.cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + sce->toolsettings->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_falloff_curve = sce->toolsettings->gp_sculpt.cur_falloff; - curvemapping_initialize(gp_falloff_curve); - curvemap_reset( + BKE_curvemapping_initialize(gp_falloff_curve); + BKE_curvemap_reset( gp_falloff_curve->cm, &gp_falloff_curve->clipr, CURVE_PRESET_GAUSS, CURVEMAP_SLOPE_POSITIVE); - sce->toolsettings->gp_sculpt.cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + sce->toolsettings->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_primitive_curve = sce->toolsettings->gp_sculpt.cur_primitive; - curvemapping_initialize(gp_primitive_curve); - curvemap_reset(gp_primitive_curve->cm, - &gp_primitive_curve->clipr, - CURVE_PRESET_BELL, - CURVEMAP_SLOPE_POSITIVE); + BKE_curvemapping_initialize(gp_primitive_curve); + BKE_curvemap_reset(gp_primitive_curve->cm, + &gp_primitive_curve->clipr, + CURVE_PRESET_BELL, + CURVEMAP_SLOPE_POSITIVE); sce->toolsettings->gp_sculpt.guide.spacing = 20.0f; diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c index aceb8b7e4ad..a7543881dad 100644 --- a/source/blender/blenkernel/intern/seqmodifier.c +++ b/source/blender/blenkernel/intern/seqmodifier.c @@ -293,14 +293,14 @@ static void curves_init_data(SequenceModifierData *smd) { CurvesModifierData *cmd = (CurvesModifierData *)smd; - curvemapping_set_defaults(&cmd->curve_mapping, 4, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_set_defaults(&cmd->curve_mapping, 4, 0.0f, 0.0f, 1.0f, 1.0f); } static void curves_free_data(SequenceModifierData *smd) { CurvesModifierData *cmd = (CurvesModifierData *)smd; - curvemapping_free_data(&cmd->curve_mapping); + BKE_curvemapping_free_data(&cmd->curve_mapping); } static void curves_copy_data(SequenceModifierData *target, SequenceModifierData *smd) @@ -308,7 +308,7 @@ static void curves_copy_data(SequenceModifierData *target, SequenceModifierData CurvesModifierData *cmd = (CurvesModifierData *)smd; CurvesModifierData *cmd_target = (CurvesModifierData *)target; - curvemapping_copy_data(&cmd_target->curve_mapping, &cmd->curve_mapping); + BKE_curvemapping_copy_data(&cmd_target->curve_mapping, &cmd->curve_mapping); } static void curves_apply_threaded(int width, @@ -330,7 +330,7 @@ static void curves_apply_threaded(int width, float *pixel = rect_float + pixel_index; float result[3]; - curvemapping_evaluate_premulRGBF(curve_mapping, result, pixel); + BKE_curvemapping_evaluate_premulRGBF(curve_mapping, result, pixel); if (mask_rect_float) { const float *m = mask_rect_float + pixel_index; @@ -351,7 +351,7 @@ static void curves_apply_threaded(int width, straight_uchar_to_premul_float(tempc, pixel); - curvemapping_evaluate_premulRGBF(curve_mapping, result, tempc); + BKE_curvemapping_evaluate_premulRGBF(curve_mapping, result, tempc); if (mask_rect) { float t[3]; @@ -381,14 +381,14 @@ static void curves_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *m float black[3] = {0.0f, 0.0f, 0.0f}; float white[3] = {1.0f, 1.0f, 1.0f}; - curvemapping_initialize(&cmd->curve_mapping); + BKE_curvemapping_initialize(&cmd->curve_mapping); - curvemapping_premultiply(&cmd->curve_mapping, 0); - curvemapping_set_black_white(&cmd->curve_mapping, black, white); + BKE_curvemapping_premultiply(&cmd->curve_mapping, 0); + BKE_curvemapping_set_black_white(&cmd->curve_mapping, black, white); modifier_apply_threaded(ibuf, mask, curves_apply_threaded, &cmd->curve_mapping); - curvemapping_premultiply(&cmd->curve_mapping, 1); + BKE_curvemapping_premultiply(&cmd->curve_mapping, 1); } static SequenceModifierTypeInfo seqModifier_Curves = { @@ -408,13 +408,13 @@ static void hue_correct_init_data(SequenceModifierData *smd) HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; int c; - curvemapping_set_defaults(&hcmd->curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_set_defaults(&hcmd->curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f); hcmd->curve_mapping.preset = CURVE_PRESET_MID9; for (c = 0; c < 3; c++) { CurveMap *cuma = &hcmd->curve_mapping.cm[c]; - curvemap_reset( + BKE_curvemap_reset( cuma, &hcmd->curve_mapping.clipr, hcmd->curve_mapping.preset, CURVEMAP_SLOPE_POSITIVE); } @@ -426,7 +426,7 @@ static void hue_correct_free_data(SequenceModifierData *smd) { HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; - curvemapping_free_data(&hcmd->curve_mapping); + BKE_curvemapping_free_data(&hcmd->curve_mapping); } static void hue_correct_copy_data(SequenceModifierData *target, SequenceModifierData *smd) @@ -434,7 +434,7 @@ static void hue_correct_copy_data(SequenceModifierData *target, SequenceModifier HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; HueCorrectModifierData *hcmd_target = (HueCorrectModifierData *)target; - curvemapping_copy_data(&hcmd_target->curve_mapping, &hcmd->curve_mapping); + BKE_curvemapping_copy_data(&hcmd_target->curve_mapping, &hcmd->curve_mapping); } static void hue_correct_apply_threaded(int width, @@ -464,15 +464,15 @@ static void hue_correct_apply_threaded(int width, rgb_to_hsv(pixel[0], pixel[1], pixel[2], hsv, hsv + 1, hsv + 2); /* adjust hue, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(curve_mapping, 0, hsv[0]); + f = BKE_curvemapping_evaluateF(curve_mapping, 0, hsv[0]); hsv[0] += f - 0.5f; /* adjust saturation, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(curve_mapping, 1, hsv[0]); + f = BKE_curvemapping_evaluateF(curve_mapping, 1, hsv[0]); hsv[1] *= (f * 2.0f); /* adjust value, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(curve_mapping, 2, hsv[0]); + f = BKE_curvemapping_evaluateF(curve_mapping, 2, hsv[0]); hsv[2] *= (f * 2.f); hsv[0] = hsv[0] - floorf(hsv[0]); /* mod 1.0 */ @@ -506,7 +506,7 @@ static void hue_correct_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImB { HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd; - curvemapping_initialize(&hcmd->curve_mapping); + BKE_curvemapping_initialize(&hcmd->curve_mapping); modifier_apply_threaded(ibuf, mask, hue_correct_apply_threaded, &hcmd->curve_mapping); } diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 688af539bbb..74873db179d 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1428,13 +1428,13 @@ static void emit_from_particles(Object *flow_ob, /* prepare curvemapping tables */ if ((psys->part->child_flag & PART_CHILD_USE_CLUMP_CURVE) && psys->part->clumpcurve) { - curvemapping_changed_all(psys->part->clumpcurve); + BKE_curvemapping_changed_all(psys->part->clumpcurve); } if ((psys->part->child_flag & PART_CHILD_USE_ROUGH_CURVE) && psys->part->roughcurve) { - curvemapping_changed_all(psys->part->roughcurve); + BKE_curvemapping_changed_all(psys->part->roughcurve); } if ((psys->part->child_flag & PART_CHILD_USE_TWIST_CURVE) && psys->part->twistcurve) { - curvemapping_changed_all(psys->part->twistcurve); + BKE_curvemapping_changed_all(psys->part->twistcurve); } /* initialize particle cache */ diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index b2ea5b12603..1a3e42a7da2 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -703,50 +703,6 @@ bool txt_cursor_is_line_end(Text *text) /* Cursor movement functions */ /*****************************/ -int txt_utf8_offset_to_index(const char *str, int offset) -{ - int index = 0, pos = 0; - while (pos != offset) { - pos += BLI_str_utf8_size(str + pos); - index++; - } - return index; -} - -int txt_utf8_index_to_offset(const char *str, int index) -{ - int offset = 0, pos = 0; - while (pos != index) { - offset += BLI_str_utf8_size(str + offset); - pos++; - } - return offset; -} - -int txt_utf8_offset_to_column(const char *str, int offset) -{ - int column = 0, pos = 0; - while (pos < offset) { - column += BLI_str_utf8_char_width_safe(str + pos); - pos += BLI_str_utf8_size_safe(str + pos); - } - return column; -} - -int txt_utf8_column_to_offset(const char *str, int column) -{ - int offset = 0, pos = 0, col; - while (*(str + offset) && pos < column) { - col = BLI_str_utf8_char_width_safe(str + offset); - if (pos + col > column) { - break; - } - offset += BLI_str_utf8_size_safe(str + offset); - pos += col; - } - return offset; -} - void txt_move_up(Text *text, const bool sel) { TextLine **linep; @@ -764,9 +720,9 @@ void txt_move_up(Text *text, const bool sel) } if ((*linep)->prev) { - int column = txt_utf8_offset_to_column((*linep)->line, *charp); + int column = BLI_str_utf8_offset_to_column((*linep)->line, *charp); *linep = (*linep)->prev; - *charp = txt_utf8_column_to_offset((*linep)->line, column); + *charp = BLI_str_utf8_offset_from_column((*linep)->line, column); } else { txt_move_bol(text, sel); @@ -794,9 +750,9 @@ void txt_move_down(Text *text, const bool sel) } if ((*linep)->next) { - int column = txt_utf8_offset_to_column((*linep)->line, *charp); + int column = BLI_str_utf8_offset_to_column((*linep)->line, *charp); *linep = (*linep)->next; - *charp = txt_utf8_column_to_offset((*linep)->line, column); + *charp = BLI_str_utf8_offset_from_column((*linep)->line, column); } else { txt_move_eol(text, sel); @@ -1977,7 +1933,7 @@ bool txt_replace_char(Text *text, unsigned int add) */ static void txt_select_prefix(Text *text, const char *add) { - int len, num, curc_old; + int len, num, curc_old, selc_old; char *tmp; const int indentlen = strlen(add); @@ -1985,6 +1941,7 @@ static void txt_select_prefix(Text *text, const char *add) BLI_assert(!ELEM(NULL, text->curl, text->sell)); curc_old = text->curc; + selc_old = text->selc; num = 0; while (true) { @@ -2022,19 +1979,24 @@ static void txt_select_prefix(Text *text, const char *add) num++; } } - if (!curc_old) { - text->curc = 0; - } - else { - text->curc = curc_old + indentlen; - } while (num > 0) { text->curl = text->curl->prev; num--; } - /* caller must handle undo */ + /* Keep the cursor left aligned if we don't have a selection. */ + if (curc_old == 0 && !(text->curl == text->sell && curc_old == selc_old)) { + if (text->curl == text->sell) { + if (text->curc == text->selc) { + text->selc = 0; + } + } + text->curc = 0; + } + else { + text->curc = curc_old + indentlen; + } } /** diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 9baa8bd20e1..ad7c5e3f660 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -659,15 +659,15 @@ void BKE_texture_pointdensity_init_data(PointDensity *pd) pd->object = NULL; pd->psys = 0; pd->psys_cache_space = TEX_PD_WORLDSPACE; - pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1); + pd->falloff_curve = BKE_curvemapping_add(1, 0, 0, 1, 1); pd->falloff_curve->preset = CURVE_PRESET_LINE; pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; - curvemap_reset(pd->falloff_curve->cm, - &pd->falloff_curve->clipr, - pd->falloff_curve->preset, - CURVEMAP_SLOPE_POSITIVE); - curvemapping_changed(pd->falloff_curve, false); + BKE_curvemap_reset(pd->falloff_curve->cm, + &pd->falloff_curve->clipr, + pd->falloff_curve->preset, + CURVEMAP_SLOPE_POSITIVE); + BKE_curvemapping_changed(pd->falloff_curve, false); } PointDensity *BKE_texture_pointdensity_add(void) @@ -687,7 +687,7 @@ PointDensity *BKE_texture_pointdensity_copy(const PointDensity *pd, const int UN if (pdn->coba) { pdn->coba = MEM_dupallocN(pdn->coba); } - pdn->falloff_curve = curvemapping_copy(pdn->falloff_curve); /* can be NULL */ + pdn->falloff_curve = BKE_curvemapping_copy(pdn->falloff_curve); /* can be NULL */ return pdn; } @@ -706,7 +706,7 @@ void BKE_texture_pointdensity_free_data(PointDensity *pd) pd->coba = NULL; } - curvemapping_free(pd->falloff_curve); /* can be NULL */ + BKE_curvemapping_free(pd->falloff_curve); /* can be NULL */ } void BKE_texture_pointdensity_free(PointDensity *pd) diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index 03eb2b890cf..3bc3be8b022 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -140,12 +140,18 @@ MINLINE void float_to_byte_dither_v3( #define rgba_float_args_set_ch(col, r, g, b, a) \ rgba_float_args_set(col, (r) / 255.0f, (g) / 255.0f, (b) / 255.0f, (a) / 255.0f) -MINLINE void rgba_char_args_set( - char col[4], const char r, const char g, const char b, const char a); +MINLINE void rgba_uchar_args_set(unsigned char col[4], + const unsigned char r, + const unsigned char g, + const unsigned char b, + const unsigned char a); MINLINE void rgba_float_args_set( float col[4], const float r, const float g, const float b, const float a); -MINLINE void rgba_char_args_test_set( - char col[4], const char r, const char g, const char b, const char a); +MINLINE void rgba_uchar_args_test_set(unsigned char col[4], + const unsigned char r, + const unsigned char g, + const unsigned char b, + const unsigned char a); MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack); void blackbody_temperature_to_rgb_table(float *r_table, int width, float min, float max); diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index d5485765844..5ac4ce8be0b 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -635,6 +635,14 @@ void projmat_dimensions(const float projmat[4][4], float *r_near, float *r_far); +void projmat_from_subregion(const float projmat[4][4], + const int win_size[2], + const int x_min, + const int x_max, + const int y_min, + const int y_max, + float r_projmat[4][4]); + int box_clip_bounds_m4(float boundbox[2][3], const float bounds[4], float winmat[4][4]); void box_minmax_bounds_m4(float min[3], float max[3], float boundbox[2][3], float mat[4][4]); diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h index 70586b671b4..0cdd6e94610 100644 --- a/source/blender/blenlib/BLI_string_utf8.h +++ b/source/blender/blenlib/BLI_string_utf8.h @@ -89,6 +89,11 @@ size_t BLI_str_partition_ex_utf8(const char *str, const char **suf, const bool from_right) ATTR_NONNULL(1, 3, 4, 5); +int BLI_str_utf8_offset_to_index(const char *str, int offset); +int BLI_str_utf8_offset_from_index(const char *str, int index); +int BLI_str_utf8_offset_to_column(const char *str, int offset); +int BLI_str_utf8_offset_from_column(const char *str, int column); + #define BLI_UTF8_MAX 6 /* mem */ #define BLI_UTF8_WIDTH_MAX 2 /* columns */ #define BLI_UTF8_ERR ((unsigned int)-1) diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index d7a2d681f33..f5aaddc0ea3 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -225,8 +225,8 @@ MINLINE void srgb_to_linearrgb_uchar4_predivide(float linear[4], const unsigned srgb_to_linearrgb_predivide_v4(linear, fsrgb); } -MINLINE void rgba_char_args_set( - char col[4], const char r, const char g, const char b, const char a) +MINLINE void rgba_uchar_args_set( + uchar col[4], const uchar r, const uchar g, const uchar b, const uchar a) { col[0] = r; col[1] = g; @@ -243,8 +243,8 @@ MINLINE void rgba_float_args_set( col[3] = a; } -MINLINE void rgba_char_args_test_set( - char col[4], const char r, const char g, const char b, const char a) +MINLINE void rgba_uchar_args_test_set( + uchar col[4], const uchar r, const uchar g, const uchar b, const uchar a) { if (col[3] == 0) { col[0] = r; diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 7cdac6b1497..b4a96ff316a 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -4481,6 +4481,50 @@ void projmat_dimensions(const float projmat[4][4], } } +/** + * Creates a projection matrix for a small region of the viewport. + * + * \param projmat: Projection Matrix. + * \param win_size: Viewport Size. + * \param x_min, x_max, y_min, y_max: Coordinates of the subregion. + * \return r_projmat: Resulting Projection Matrix. + */ +void projmat_from_subregion(const float projmat[4][4], + const int win_size[2], + const int x_min, + const int x_max, + const int y_min, + const int y_max, + float r_projmat[4][4]) +{ + float rect_width = (float)(x_max - x_min); + float rect_height = (float)(y_max - y_min); + + float x_fac = (float)((x_min + x_max) - win_size[0]) / rect_width; + float y_fac = (float)((y_min + y_max) - win_size[1]) / rect_height; + + copy_m4_m4(r_projmat, projmat); + r_projmat[0][0] *= (float)win_size[0] / rect_width; + r_projmat[1][1] *= (float)win_size[1] / rect_height; + +#if 0 /* TODO: check if this is more efficient. */ + r_projmat[2][0] -= x_fac * r_projmat[2][3]; + r_projmat[2][1] -= y_fac * r_projmat[2][3]; + + r_projmat[3][0] -= x_fac * r_projmat[3][3]; + r_projmat[3][1] -= y_fac * r_projmat[3][3]; +#else + if (projmat[3][3] == 0.0f) { + r_projmat[2][0] += x_fac; + r_projmat[2][1] += y_fac; + } + else { + r_projmat[3][0] -= x_fac; + r_projmat[3][1] -= y_fac; + } +#endif +} + static void i_multmatrix(float icand[4][4], float Vm[4][4]) { int row, col; diff --git a/source/blender/blenlib/intern/polyfill_2d.c b/source/blender/blenlib/intern/polyfill_2d.c index 575a4a06d6a..31b18079c73 100644 --- a/source/blender/blenlib/intern/polyfill_2d.c +++ b/source/blender/blenlib/intern/polyfill_2d.c @@ -193,7 +193,10 @@ BLI_INLINE eSign signum_enum(float a) */ BLI_INLINE float area_tri_signed_v2_alt_2x(const float v1[2], const float v2[2], const float v3[2]) { - return ((v1[0] * (v2[1] - v3[1])) + (v2[0] * (v3[1] - v1[1])) + (v3[0] * (v1[1] - v2[1]))); + float d2[2], d3[2]; + sub_v2_v2v2(d2, v2, v1); + sub_v2_v2v2(d3, v3, v1); + return (d2[0] * d3[1]) - (d3[0] * d2[1]); } static eSign span_tri_v2_sign(const float v1[2], const float v2[2], const float v3[2]) diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 01412416854..22c23727d76 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -868,3 +868,53 @@ size_t BLI_str_partition_ex_utf8(const char *str, *suf = *sep = NULL; return str_len; } + +/* -------------------------------------------------------------------- */ +/** \name Offset Conversion in Strings + * \{ */ + +int BLI_str_utf8_offset_to_index(const char *str, int offset) +{ + int index = 0, pos = 0; + while (pos != offset) { + pos += BLI_str_utf8_size(str + pos); + index++; + } + return index; +} + +int BLI_str_utf8_offset_from_index(const char *str, int index) +{ + int offset = 0, pos = 0; + while (pos != index) { + offset += BLI_str_utf8_size(str + offset); + pos++; + } + return offset; +} + +int BLI_str_utf8_offset_to_column(const char *str, int offset) +{ + int column = 0, pos = 0; + while (pos < offset) { + column += BLI_str_utf8_char_width_safe(str + pos); + pos += BLI_str_utf8_size_safe(str + pos); + } + return column; +} + +int BLI_str_utf8_offset_from_column(const char *str, int column) +{ + int offset = 0, pos = 0, col; + while (*(str + offset) && pos < column) { + col = BLI_str_utf8_char_width_safe(str + offset); + if (pos + col > column) { + break; + } + offset += BLI_str_utf8_size_safe(str + offset); + pos += col; + } + return offset; +} + +/** \} */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 44bb07d87f8..737a70615ae 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5841,7 +5841,7 @@ static void direct_link_gpencil_modifiers(FileData *fd, ListBase *lb) if (gpmd->curve_thickness) { direct_link_curvemapping(fd, gpmd->curve_thickness); /* initialize the curve. Maybe this could be moved to modififer logic */ - curvemapping_initialize(gpmd->curve_thickness); + BKE_curvemapping_initialize(gpmd->curve_thickness); } } } @@ -9395,8 +9395,8 @@ static void do_versions_userdef(FileData *fd, BlendFileData *bfd) /* Themes for Node and Sequence editor were not using grid color, * but back. we copy this over then. */ for (btheme = user->themes.first; btheme; btheme = btheme->next) { - copy_v4_v4_char(btheme->space_node.grid, btheme->space_node.back); - copy_v4_v4_char(btheme->space_sequencer.grid, btheme->space_sequencer.back); + copy_v4_v4_uchar(btheme->space_node.grid, btheme->space_node.back); + copy_v4_v4_uchar(btheme->space_sequencer.grid, btheme->space_sequencer.back); } } diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 81751a6ed07..6a5cfc45628 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -1555,7 +1555,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) for (sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; - scopes_new(&sima->scopes); + BKE_scopes_new(&sima->scopes); } } } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 3dc79308f64..b61692799ed 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -1103,9 +1103,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) Scene *scene; for (scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) { CurveMapping *curve_mapping = &scene->r.mblur_shutter_curve; - curvemapping_set_defaults(curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f); - curvemapping_initialize(curve_mapping); - curvemap_reset( + BKE_curvemapping_set_defaults(curve_mapping, 1, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_initialize(curve_mapping); + BKE_curvemap_reset( curve_mapping->cm, &curve_mapping->clipr, CURVE_PRESET_MAX, CURVEMAP_SLOPE_POS_NEG); } } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 1573f4ed02f..15b4f513050 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1347,12 +1347,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* sculpt brushes */ GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt; if ((gset) && (gset->cur_falloff == NULL)) { - gset->cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); - curvemapping_initialize(gset->cur_falloff); - curvemap_reset(gset->cur_falloff->cm, - &gset->cur_falloff->clipr, - CURVE_PRESET_GAUSS, - CURVEMAP_SLOPE_POSITIVE); + gset->cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_initialize(gset->cur_falloff); + BKE_curvemap_reset(gset->cur_falloff->cm, + &gset->cur_falloff->clipr, + CURVE_PRESET_GAUSS, + CURVEMAP_SLOPE_POSITIVE); } } } @@ -2748,12 +2748,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { GP_Sculpt_Settings *gset = &scene->toolsettings->gp_sculpt; if ((gset) && (gset->cur_primitive == NULL)) { - gset->cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); - curvemapping_initialize(gset->cur_primitive); - curvemap_reset(gset->cur_primitive->cm, - &gset->cur_primitive->clipr, - CURVE_PRESET_BELL, - CURVEMAP_SLOPE_POSITIVE); + gset->cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + BKE_curvemapping_initialize(gset->cur_primitive); + BKE_curvemap_reset(gset->cur_primitive->cm, + &gset->cur_primitive->clipr, + CURVE_PRESET_BELL, + CURVEMAP_SLOPE_POSITIVE); } } } @@ -3407,11 +3407,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) ARegion *ar = NULL; if (sl->spacetype == SPACE_CLIP) { if (((SpaceClip *)sl)->view == SC_VIEW_GRAPH) { - ar = do_versions_find_region(regionbase, RGN_TYPE_PREVIEW); + ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_PREVIEW); } } else { - ar = do_versions_find_region(regionbase, RGN_TYPE_WINDOW); + ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_WINDOW); } if (ar != NULL) { @@ -3560,7 +3560,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_TEXT) { ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; - ARegion *ar = do_versions_find_region(regionbase, RGN_TYPE_UI); + ARegion *ar = do_versions_find_region_or_null(regionbase, RGN_TYPE_UI); if (ar) { ar->alignment = RGN_ALIGN_RIGHT; } diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c index 46d84f86fd0..a6803e6164b 100644 --- a/source/blender/blenloader/intern/versioning_cycles.c +++ b/source/blender/blenloader/intern/versioning_cycles.c @@ -244,7 +244,7 @@ static void vector_curve_node_remap(bNode *node) } } - curvemapping_changed_all(mapping); + BKE_curvemapping_changed_all(mapping); } } diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 14230752d1f..fa69892584a 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -268,22 +268,22 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene) /* Be sure curfalloff and primitive are initializated */ ToolSettings *ts = scene->toolsettings; if (ts->gp_sculpt.cur_falloff == NULL) { - ts->gp_sculpt.cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + ts->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff; - curvemapping_initialize(gp_falloff_curve); - curvemap_reset(gp_falloff_curve->cm, - &gp_falloff_curve->clipr, - CURVE_PRESET_GAUSS, - CURVEMAP_SLOPE_POSITIVE); + BKE_curvemapping_initialize(gp_falloff_curve); + BKE_curvemap_reset(gp_falloff_curve->cm, + &gp_falloff_curve->clipr, + CURVE_PRESET_GAUSS, + CURVEMAP_SLOPE_POSITIVE); } if (ts->gp_sculpt.cur_primitive == NULL) { - ts->gp_sculpt.cur_primitive = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + ts->gp_sculpt.cur_primitive = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_primitive_curve = ts->gp_sculpt.cur_primitive; - curvemapping_initialize(gp_primitive_curve); - curvemap_reset(gp_primitive_curve->cm, - &gp_primitive_curve->clipr, - CURVE_PRESET_BELL, - CURVEMAP_SLOPE_POSITIVE); + BKE_curvemapping_initialize(gp_primitive_curve); + BKE_curvemap_reset(gp_primitive_curve->cm, + &gp_primitive_curve->clipr, + CURVE_PRESET_BELL, + CURVEMAP_SLOPE_POSITIVE); } /* Correct default startup UV's. */ diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 0f1d7cbf70f..9b6f252f62d 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -2094,8 +2094,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) la->falloff_type = LA_FALLOFF_INVLINEAR; if (la->curfalloff == NULL) { - la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); - curvemapping_initialize(la->curfalloff); + la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); + BKE_curvemapping_initialize(la->curfalloff); } } } diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index e42a9bc9f95..e987a623d0b 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -51,12 +51,12 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) memcpy(btheme, &U_theme_default, sizeof(*btheme)); } -#define FROM_DEFAULT_V4_UCHAR(member) copy_v4_v4_char(btheme->member, U_theme_default.member) +#define FROM_DEFAULT_V4_UCHAR(member) copy_v4_v4_uchar(btheme->member, U_theme_default.member) if (!USER_VERSION_ATLEAST(280, 25)) { - copy_v4_v4_char(btheme->space_action.anim_preview_range, btheme->space_action.anim_active); - copy_v4_v4_char(btheme->space_nla.anim_preview_range, btheme->space_nla.anim_active); - copy_v4_v4_char(btheme->space_graph.anim_preview_range, btheme->space_action.anim_active); + copy_v4_v4_uchar(btheme->space_action.anim_preview_range, btheme->space_action.anim_active); + copy_v4_v4_uchar(btheme->space_nla.anim_preview_range, btheme->space_nla.anim_active); + copy_v4_v4_uchar(btheme->space_graph.anim_preview_range, btheme->space_action.anim_active); } if (!USER_VERSION_ATLEAST(280, 26)) { @@ -102,8 +102,8 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) if (!USER_VERSION_ATLEAST(280, 40)) { FROM_DEFAULT_V4_UCHAR(space_preferences.navigation_bar); - copy_v4_v4_char(btheme->space_preferences.execution_buts, - btheme->space_preferences.navigation_bar); + copy_v4_v4_uchar(btheme->space_preferences.execution_buts, + btheme->space_preferences.navigation_bar); } if (!USER_VERSION_ATLEAST(280, 41)) { diff --git a/source/blender/blentranslation/msgfmt/msgfmt.c b/source/blender/blentranslation/msgfmt/msgfmt.c index 86d55e203d9..215c92f87de 100644 --- a/source/blender/blentranslation/msgfmt/msgfmt.c +++ b/source/blender/blentranslation/msgfmt/msgfmt.c @@ -82,12 +82,12 @@ static char *trim(char *str) return str; } - for (i = 0; i < len && ELEM(str[0], ' ', '\t', '\r','\n'); str++, i++) { + for (i = 0; i < len && ELEM(str[0], ' ', '\t', '\r', '\n'); str++, i++) { /* pass */ } char *end = &str[len - 1 - i]; - for (i = len; i > 0 && ELEM(end[0], ' ', '\t', '\r','\n'); end--, i--) { + for (i = len; i > 0 && ELEM(end[0], ' ', '\t', '\r', '\n'); end--, i--) { /* pass */ } diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 760b0aa00ae..c8eab9c4b8c 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -390,79 +390,13 @@ void BM_verts_sort_radial_plane(BMVert **vert_arr, int len) struct SortIntByFloat *vang = BLI_array_alloca(vang, len); BMVert **vert_arr_map = BLI_array_alloca(vert_arr_map, len); - float totv_inv = 1.0f / (float)len; - int i = 0; + float nor[3], cent[3]; + int index_tangent = 0; + BM_verts_calc_normal_from_cloud_ex(vert_arr, len, nor, cent, &index_tangent); + const float *far = vert_arr[index_tangent]->co; - float cent[3], nor[3]; - - const float *far = NULL, *far_cross = NULL; - - float far_vec[3]; - float far_cross_vec[3]; - float sign_vec[3]; /* work out if we are pos/neg angle */ - - float far_dist_sq, far_dist_max_sq; - float far_cross_dist, far_cross_best = 0.0f; - - /* get the center point and collect vector array since we loop over these a lot */ - zero_v3(cent); - for (i = 0; i < len; i++) { - madd_v3_v3fl(cent, vert_arr[i]->co, totv_inv); - } - - /* find the far point from cent */ - far_dist_max_sq = 0.0f; - for (i = 0; i < len; i++) { - far_dist_sq = len_squared_v3v3(vert_arr[i]->co, cent); - if (far_dist_sq > far_dist_max_sq || far == NULL) { - far = vert_arr[i]->co; - far_dist_max_sq = far_dist_sq; - } - } - - sub_v3_v3v3(far_vec, far, cent); - // far_dist = len_v3(far_vec); /* real dist */ /* UNUSED */ - - /* --- */ - - /* find a point 90deg about to compare with */ - far_cross_best = 0.0f; - for (i = 0; i < len; i++) { - - if (far == vert_arr[i]->co) { - continue; - } - - sub_v3_v3v3(far_cross_vec, vert_arr[i]->co, cent); - far_cross_dist = normalize_v3(far_cross_vec); - - /* more of a weight then a distance */ - far_cross_dist = ( - /* First we want to have a value close to zero mapped to 1. */ - 1.0f - fabsf(dot_v3v3(far_vec, far_cross_vec)) * - /* Second we multiply by the distance - * so points close to the center are not preferred. */ - far_cross_dist); - - if (far_cross_dist > far_cross_best || far_cross == NULL) { - far_cross = vert_arr[i]->co; - far_cross_best = far_cross_dist; - } - } - - sub_v3_v3v3(far_cross_vec, far_cross, cent); - - /* --- */ - - /* now we have 2 vectors we can have a cross product */ - cross_v3_v3v3(nor, far_vec, far_cross_vec); - normalize_v3(nor); - cross_v3_v3v3(sign_vec, far_vec, nor); /* this vector should match 'far_cross_vec' closely */ - - /* --- */ - - /* now calculate every points angle around the normal (signed) */ - for (i = 0; i < len; i++) { + /* Now calculate every points angle around the normal (signed). */ + for (int i = 0; i < len; i++) { vang[i].sort_value = angle_signed_on_axis_v3v3v3_v3(far, cent, vert_arr[i]->co, nor); vang[i].data = i; vert_arr_map[i] = vert_arr[i]; @@ -473,7 +407,7 @@ void BM_verts_sort_radial_plane(BMVert **vert_arr, int len) /* --- */ - for (i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { vert_arr[i] = vert_arr_map[vang[i].data]; } } diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 172f7050aa0..dc839054987 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -865,6 +865,113 @@ float BM_face_calc_normal_vcos(const BMesh *bm, } /** + * Calculate a normal from a vertex cloud. + * + * \note We could make a higher quality version that takes all vertices into account. + * Currently it finds 4 outer most points returning it's normal. + */ +void BM_verts_calc_normal_from_cloud_ex( + BMVert **varr, int varr_len, float r_normal[3], float r_center[3], int *r_index_tangent) +{ + const float varr_len_inv = 1.0f / (float)varr_len; + + /* Get the center point and collect vector array since we loop over these a lot. */ + float center[3] = {0.0f, 0.0f, 0.0f}; + for (int i = 0; i < varr_len; i++) { + madd_v3_v3fl(center, varr[i]->co, varr_len_inv); + } + + /* Find the 'co_a' point from center. */ + int co_a_index = 0; + const float *co_a = NULL; + { + float dist_sq_max = -1.0f; + for (int i = 0; i < varr_len; i++) { + const float dist_sq_test = len_squared_v3v3(varr[i]->co, center); + if (!(dist_sq_test <= dist_sq_max)) { + co_a = varr[i]->co; + co_a_index = i; + dist_sq_max = dist_sq_test; + } + } + } + + float dir_a[3]; + sub_v3_v3v3(dir_a, co_a, center); + normalize_v3(dir_a); + + const float *co_b = NULL; + float dir_b[3] = {0.0f, 0.0f, 0.0f}; + { + float dist_sq_max = -1.0f; + for (int i = 0; i < varr_len; i++) { + if (varr[i]->co == co_a) { + continue; + } + float dir_test[3]; + sub_v3_v3v3(dir_test, varr[i]->co, center); + project_plane_normalized_v3_v3v3(dir_test, dir_test, dir_a); + const float dist_sq_test = len_squared_v3(dir_test); + if (!(dist_sq_test <= dist_sq_max)) { + co_b = varr[i]->co; + dist_sq_max = dist_sq_test; + copy_v3_v3(dir_b, dir_test); + } + } + } + + if (varr_len <= 3) { + normal_tri_v3(r_normal, center, co_a, co_b); + goto finally; + } + + normalize_v3(dir_b); + + const float *co_a_opposite = NULL; + const float *co_b_opposite = NULL; + + { + float dot_a_min = FLT_MAX; + float dot_b_min = FLT_MAX; + for (int i = 0; i < varr_len; i++) { + const float *co_test = varr[i]->co; + float dot_test; + + if (co_test != co_a) { + dot_test = dot_v3v3(dir_a, co_test); + if (dot_test < dot_a_min) { + dot_a_min = dot_test; + co_a_opposite = co_test; + } + } + + if (co_test != co_b) { + dot_test = dot_v3v3(dir_b, co_test); + if (dot_test < dot_b_min) { + dot_b_min = dot_test; + co_b_opposite = co_test; + } + } + } + } + + normal_quad_v3(r_normal, co_a, co_b, co_a_opposite, co_b_opposite); + +finally: + if (r_center != NULL) { + copy_v3_v3(r_center, center); + } + if (r_index_tangent != NULL) { + *r_index_tangent = co_a_index; + } +} + +void BM_verts_calc_normal_from_cloud(BMVert **varr, int varr_len, float r_normal[3]) +{ + BM_verts_calc_normal_from_cloud_ex(varr, varr_len, r_normal, NULL, NULL); +} + +/** * Calculates the face subset normal. */ float BM_face_calc_normal_subset(const BMLoop *l_first, const BMLoop *l_last, float r_no[3]) diff --git a/source/blender/bmesh/intern/bmesh_polygon.h b/source/blender/bmesh/intern/bmesh_polygon.h index 191ebd86f4a..2ae32777a7d 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.h +++ b/source/blender/bmesh/intern/bmesh_polygon.h @@ -38,6 +38,11 @@ float BM_face_calc_normal_vcos(const BMesh *bm, const BMFace *f, float r_no[3], float const (*vertexCos)[3]) ATTR_NONNULL(); + +void BM_verts_calc_normal_from_cloud_ex( + BMVert **varr, int varr_len, float r_normal[3], float r_center[3], int *r_index_tangent); +void BM_verts_calc_normal_from_cloud(BMVert **varr, int varr_len, float r_normal[3]); + float BM_face_calc_normal_subset(const BMLoop *l_first, const BMLoop *l_last, float r_no[3]) ATTR_NONNULL(); float BM_face_calc_area(const BMFace *f) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); diff --git a/source/blender/compositor/nodes/COM_TimeNode.cpp b/source/blender/compositor/nodes/COM_TimeNode.cpp index 45604882992..2a30ee9c574 100644 --- a/source/blender/compositor/nodes/COM_TimeNode.cpp +++ b/source/blender/compositor/nodes/COM_TimeNode.cpp @@ -49,8 +49,8 @@ void TimeNode::convertToOperations(NodeConverter &converter, fac = (context.getFramenumber() - node->custom1) / (float)(node->custom2 - node->custom1); } - curvemapping_initialize((CurveMapping *)node->storage); - fac = curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac); + BKE_curvemapping_initialize((CurveMapping *)node->storage); + fac = BKE_curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac); operation->setValue(clamp_f(fac, 0.0f, 1.0f)); converter.addOperation(operation); diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp index e25ef49cf28..90d3a60abd0 100644 --- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp @@ -50,7 +50,7 @@ void ColorCurveOperation::initExecution() this->m_inputBlackProgram = this->getInputSocketReader(2); this->m_inputWhiteProgram = this->getInputSocketReader(3); - curvemapping_premultiply(this->m_curveMapping, 0); + BKE_curvemapping_premultiply(this->m_curveMapping, 0); } void ColorCurveOperation::executePixelSampled(float output[4], @@ -73,20 +73,20 @@ void ColorCurveOperation::executePixelSampled(float output[4], /* get our own local bwmul value, * since we can't be threadsafe and use cumap->bwmul & friends */ - curvemapping_set_black_white_ex(black, white, bwmul); + BKE_curvemapping_set_black_white_ex(black, white, bwmul); this->m_inputFacProgram->readSampled(fac, x, y, sampler); this->m_inputImageProgram->readSampled(image, x, y, sampler); if (*fac >= 1.0f) { - curvemapping_evaluate_premulRGBF_ex(cumap, output, image, black, bwmul); + BKE_curvemapping_evaluate_premulRGBF_ex(cumap, output, image, black, bwmul); } else if (*fac <= 0.0f) { copy_v3_v3(output, image); } else { float col[4]; - curvemapping_evaluate_premulRGBF_ex(cumap, col, image, black, bwmul); + BKE_curvemapping_evaluate_premulRGBF_ex(cumap, col, image, black, bwmul); interp_v3_v3v3(output, image, col, *fac); } output[3] = image[3]; @@ -120,9 +120,9 @@ void ConstantLevelColorCurveOperation::initExecution() this->m_inputFacProgram = this->getInputSocketReader(0); this->m_inputImageProgram = this->getInputSocketReader(1); - curvemapping_premultiply(this->m_curveMapping, 0); + BKE_curvemapping_premultiply(this->m_curveMapping, 0); - curvemapping_set_black_white(this->m_curveMapping, this->m_black, this->m_white); + BKE_curvemapping_set_black_white(this->m_curveMapping, this->m_black, this->m_white); } void ConstantLevelColorCurveOperation::executePixelSampled(float output[4], @@ -137,14 +137,14 @@ void ConstantLevelColorCurveOperation::executePixelSampled(float output[4], this->m_inputImageProgram->readSampled(image, x, y, sampler); if (*fac >= 1.0f) { - curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, image); + BKE_curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, image); } else if (*fac <= 0.0f) { copy_v3_v3(output, image); } else { float col[4]; - curvemapping_evaluate_premulRGBF(this->m_curveMapping, col, image); + BKE_curvemapping_evaluate_premulRGBF(this->m_curveMapping, col, image); interp_v3_v3v3(output, image, col, *fac); } output[3] = image[3]; diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp index d84af71d8d8..858931ad46d 100644 --- a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp @@ -34,19 +34,19 @@ CurveBaseOperation::CurveBaseOperation() : NodeOperation() CurveBaseOperation::~CurveBaseOperation() { if (this->m_curveMapping) { - curvemapping_free(this->m_curveMapping); + BKE_curvemapping_free(this->m_curveMapping); this->m_curveMapping = NULL; } } void CurveBaseOperation::initExecution() { - curvemapping_initialize(this->m_curveMapping); + BKE_curvemapping_initialize(this->m_curveMapping); } void CurveBaseOperation::deinitExecution() { if (this->m_curveMapping) { - curvemapping_free(this->m_curveMapping); + BKE_curvemapping_free(this->m_curveMapping); this->m_curveMapping = NULL; } } @@ -55,7 +55,7 @@ void CurveBaseOperation::setCurveMapping(CurveMapping *mapping) { /* duplicate the curve to avoid glitches while drawing, see bug [#32374] */ if (this->m_curveMapping) { - curvemapping_free(this->m_curveMapping); + BKE_curvemapping_free(this->m_curveMapping); } - this->m_curveMapping = curvemapping_copy(mapping); + this->m_curveMapping = BKE_curvemapping_copy(mapping); } diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp index 61ad4248fb0..fae280249de 100644 --- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp +++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp @@ -51,15 +51,15 @@ void HueSaturationValueCorrectOperation::executePixelSampled(float output[4], this->m_inputProgram->readSampled(hsv, x, y, sampler); /* adjust hue, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(this->m_curveMapping, 0, hsv[0]); + f = BKE_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->m_curveMapping, 1, hsv[0]); + f = BKE_curvemapping_evaluateF(this->m_curveMapping, 1, hsv[0]); hsv[1] *= (f * 2.0f); /* adjust value, scaling returned default 0.5 up to 1 */ - f = curvemapping_evaluateF(this->m_curveMapping, 2, hsv[0]); + f = BKE_curvemapping_evaluateF(this->m_curveMapping, 2, hsv[0]); hsv[2] *= (f * 2.0f); hsv[0] = hsv[0] - floorf(hsv[0]); /* mod 1.0 */ diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp index 850aef122f4..6996c7ecb71 100644 --- a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp @@ -48,7 +48,7 @@ void VectorCurveOperation::executePixelSampled(float output[4], this->m_inputProgram->readSampled(input, x, y, sampler); - curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, input); + BKE_curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, input); } void VectorCurveOperation::deinitExecution() diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 8dc4972bcc1..27328084f31 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -129,8 +129,10 @@ set(SRC engines/gpencil/gpencil_shader_fx.c engines/select/select_engine.c engines/select/select_draw_utils.c + engines/select/select_buffer.c DRW_engine.h + DRW_select_buffer.h intern/DRW_render.h intern/draw_cache.h intern/draw_cache_impl.h diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index be04452f079..53cec599b82 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -176,17 +176,4 @@ void DRW_deferred_shader_remove(struct GPUMaterial *mat); struct DrawDataList *DRW_drawdatalist_from_id(struct ID *id); void DRW_drawdata_free(struct ID *id); -/* select_engine.c */ -void DRW_select_context_create(struct Base **bases, const uint bases_len, short select_mode); -bool DRW_select_elem_get(const uint sel_id, uint *r_elem, uint *r_base_index, char *r_elem_type); -uint DRW_select_context_offset_for_object_elem(const uint base_index, char elem_type); -uint DRW_select_context_elem_len(void); -void DRW_framebuffer_select_id_read(const struct rcti *rect, uint *r_buf); -void DRW_draw_select_id_object(struct Depsgraph *depsgraph, - struct ViewLayer *view_layer, - struct ARegion *ar, - struct View3D *v3d, - struct Object *ob, - short select_mode); - #endif /* __DRW_ENGINE_H__ */ diff --git a/source/blender/draw/DRW_select_buffer.h b/source/blender/draw/DRW_select_buffer.h new file mode 100644 index 00000000000..cc3cb94175a --- /dev/null +++ b/source/blender/draw/DRW_select_buffer.h @@ -0,0 +1,65 @@ +/* + * 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. + * + * Copyright 2016, Blender Foundation. + */ + +/** \file + * \ingroup draw + */ + +#ifndef __DRW_SELECT_BUFFER_H__ +#define __DRW_SELECT_BUFFER_H__ + +#include "BLI_sys_types.h" /* for bool and uint */ + +struct ARegion; +struct Base; +struct Depsgraph; +struct Object; +struct View3D; +struct ViewLayer; +struct rcti; + +/* select_buffer.c */ +void DRW_select_buffer_context_create(struct Base **bases, + const uint bases_len, + short select_mode); +bool DRW_select_buffer_elem_get(const uint sel_id, + uint *r_elem, + uint *r_base_index, + char *r_elem_type); +uint DRW_select_buffer_context_offset_for_object_elem(const uint base_index, char elem_type); +uint *DRW_select_buffer_read(const struct rcti *rect, uint *r_buf_len); +void DRW_draw_select_id_object(struct Depsgraph *depsgraph, + struct ViewLayer *view_layer, + struct ARegion *ar, + struct View3D *v3d, + struct Object *ob, + short select_mode); +uint *DRW_select_buffer_bitmap_from_rect(const struct rcti *rect, uint *r_bitmap_len); +uint *DRW_select_buffer_bitmap_from_circle(const int center[2], + const int radius, + uint *r_bitmap_len); +uint *DRW_select_buffer_bitmap_from_poly(const int poly[][2], + const int poly_len, + const struct rcti *rect); +uint DRW_select_buffer_sample_point(const int center[2]); +uint DRW_select_buffer_find_nearest_to_point(const int center[2], + const uint id_min, + const uint id_max, + uint *dist); + +#endif /* __DRW_SELECT_BUFFER_H__ */ diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c index dd7f4683ce0..f548bd15bf4 100644 --- a/source/blender/draw/engines/basic/basic_engine.c +++ b/source/blender/draw/engines/basic/basic_engine.c @@ -25,6 +25,7 @@ #include "DRW_render.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "DNA_particle_types.h" @@ -161,13 +162,19 @@ static void basic_cache_populate(void *vedata, Object *ob) } } - struct GPUBatch *geom = DRW_cache_object_surface_get(ob); - if (geom) { - const bool do_cull = (draw_ctx->v3d && - (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING)); - /* Depth Prepass */ - DRW_shgroup_call( - (do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob); + const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d); + const bool do_cull = (draw_ctx->v3d && + (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING)); + DRWShadingGroup *shgrp = (do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp; + + if (use_sculpt_pbvh) { + DRW_shgroup_call_sculpt(shgrp, ob, false, false, false); + } + else { + struct GPUBatch *geom = DRW_cache_object_surface_get(ob); + if (geom) { + DRW_shgroup_call(shgrp, geom, ob); + } } } diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c index 9b755217946..2892d0dbbaa 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c @@ -1456,7 +1456,8 @@ void gpencil_triangulate_stroke_fill(Object *ob, bGPDstroke *gps) /* Check if stencil is required */ static bool gpencil_is_stencil_required(MaterialGPencilStyle *gp_style) { - return (bool)(gp_style->stroke_style == GP_STYLE_STROKE_STYLE_SOLID); + return (bool)((gp_style->stroke_style == GP_STYLE_STROKE_STYLE_SOLID) && + ((gp_style->flag & GP_STYLE_DISABLE_STENCIL) == 0)); } /* draw stroke in drawing buffer */ diff --git a/source/blender/draw/engines/select/select_buffer.c b/source/blender/draw/engines/select/select_buffer.c new file mode 100644 index 00000000000..b184992cb56 --- /dev/null +++ b/source/blender/draw/engines/select/select_buffer.c @@ -0,0 +1,500 @@ +/* + * 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. + * + * Copyright 2019, Blender Foundation. + */ + +/** \file + * \ingroup draw_engine + * + * Utilities to read id buffer created in select_engine. + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_bitmap.h" +#include "BLI_bitmap_draw_2d.h" +#include "BLI_rect.h" + +#include "DNA_screen_types.h" + +#include "GPU_select.h" + +#include "DRW_engine.h" +#include "DRW_select_buffer.h" + +#include "select_private.h" +#include "select_engine.h" + +/* -------------------------------------------------------------------- */ +/** \name Buffer of select ID's + * \{ */ + +/* Read a block of pixels from the select frame buffer. */ +uint *DRW_select_buffer_read(const rcti *rect, uint *r_buf_len) +{ + struct SELECTID_Context *select_ctx = select_context_get(); + + /* clamp rect by texture */ + rcti r = { + .xmin = 0, + .xmax = GPU_texture_width(select_ctx->texture_u32), + .ymin = 0, + .ymax = GPU_texture_height(select_ctx->texture_u32), + }; + + rcti rect_clamp = *rect; + if (BLI_rcti_isect(&r, &rect_clamp, &rect_clamp)) { + uint buf_len = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect); + uint *r_buf = MEM_mallocN(buf_len * sizeof(*r_buf), __func__); + + DRW_opengl_context_enable(); + GPU_framebuffer_bind(select_ctx->framebuffer_select_id); + glReadBuffer(GL_COLOR_ATTACHMENT0); + glReadPixels(rect_clamp.xmin, + rect_clamp.ymin, + BLI_rcti_size_x(&rect_clamp), + BLI_rcti_size_y(&rect_clamp), + GL_RED_INTEGER, + GL_UNSIGNED_INT, + r_buf); + + GPU_framebuffer_restore(); + DRW_opengl_context_disable(); + + if (!BLI_rcti_compare(rect, &rect_clamp)) { + GPU_select_buffer_stride_realign(rect, &rect_clamp, r_buf); + } + + if (r_buf_len) { + *r_buf_len = buf_len; + } + + return r_buf; + } + return NULL; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Bitmap from ID's + * + * Given a buffer of select ID's, fill in a booleans (true/false) per index. + * #BLI_bitmap is used for memory efficiency. + * + * \{ */ + +/** + * \param rect: The rectangle to sample indices from (min/max inclusive). + * \param mask: Specifies the rect pixels (optional). + * \returns a #BLI_bitmap the length of \a bitmap_len or NULL on failure. + */ +uint *DRW_select_buffer_bitmap_from_rect(const rcti *rect, uint *r_bitmap_len) +{ + struct SELECTID_Context *select_ctx = select_context_get(); + + const uint bitmap_len = select_ctx->last_index_drawn; + if (bitmap_len == 0) { + return NULL; + } + + rcti rect_px = *rect; + rect_px.xmax += 1; + rect_px.ymax += 1; + + uint buf_len; + uint *buf = DRW_select_buffer_read(&rect_px, &buf_len); + if (buf == NULL) { + return NULL; + } + + BLI_bitmap *bitmap_buf = BLI_BITMAP_NEW(bitmap_len, __func__); + const uint *buf_iter = buf; + while (buf_len--) { + const uint index = *buf_iter - 1; + if (index < bitmap_len) { + BLI_BITMAP_ENABLE(bitmap_buf, index); + } + buf_iter++; + } + MEM_freeN((void *)buf); + + if (r_bitmap_len) { + *r_bitmap_len = bitmap_len; + } + + return bitmap_buf; +} + +/** + * \param bitmap_len: Number of indices in the selection id buffer. + * \param center: Circle center. + * \param radius: Circle radius. + * \returns a #BLI_bitmap the length of \a bitmap_len or NULL on failure. + */ +uint *DRW_select_buffer_bitmap_from_circle(const int center[2], + const int radius, + uint *r_bitmap_len) +{ + struct SELECTID_Context *select_ctx = select_context_get(); + + const uint bitmap_len = select_ctx->last_index_drawn; + if (bitmap_len == 0) { + return NULL; + } + + const rcti rect = { + .xmin = center[0] - radius, + .xmax = center[0] + radius + 1, + .ymin = center[1] - radius, + .ymax = center[1] + radius + 1, + }; + + const uint *buf = DRW_select_buffer_read(&rect, NULL); + + if (buf == NULL) { + return NULL; + } + + const uint *buf_iter = buf; + + BLI_bitmap *bitmap_buf = BLI_BITMAP_NEW(bitmap_len, __func__); + const int radius_sq = radius * radius; + for (int yc = -radius; yc <= radius; yc++) { + for (int xc = -radius; xc <= radius; xc++, buf_iter++) { + if (xc * xc + yc * yc < radius_sq) { + /* Intentionally wrap to max value if this is zero. */ + const uint index = *buf_iter - 1; + if (index < bitmap_len) { + BLI_BITMAP_ENABLE(bitmap_buf, index); + } + } + } + } + MEM_freeN((void *)buf); + + if (r_bitmap_len) { + *r_bitmap_len = bitmap_len; + } + + return bitmap_buf; +} + +struct PolyMaskData { + BLI_bitmap *px; + int width; +}; + +static void drw_select_mask_px_cb(int x, int x_end, int y, void *user_data) +{ + struct PolyMaskData *data = user_data; + BLI_bitmap *px = data->px; + int i = (y * data->width) + x; + do { + BLI_BITMAP_ENABLE(px, i); + i++; + } while (++x != x_end); +} + +/** + * \param poly: The polygon coordinates. + * \param poly_len: Length of the polygon. + * \param rect: Polygon boundaries. + * \returns a #BLI_bitmap. + */ +uint *DRW_select_buffer_bitmap_from_poly(const int poly[][2], const int poly_len, const rcti *rect) +{ + struct SELECTID_Context *select_ctx = select_context_get(); + + const uint bitmap_len = select_ctx->last_index_drawn; + if (bitmap_len == 0) { + return NULL; + } + + rcti rect_px = *rect; + rect_px.xmax += 1; + rect_px.ymax += 1; + + uint buf_len; + uint *buf = DRW_select_buffer_read(&rect_px, &buf_len); + if (buf == NULL) { + return NULL; + } + + BLI_bitmap *buf_mask = BLI_BITMAP_NEW(buf_len, __func__); + + struct PolyMaskData poly_mask_data; + poly_mask_data.px = buf_mask; + poly_mask_data.width = (rect->xmax - rect->xmin) + 1; + + BLI_bitmap_draw_2d_poly_v2i_n(rect_px.xmin, + rect_px.ymin, + rect_px.xmax, + rect_px.ymax, + poly, + poly_len, + drw_select_mask_px_cb, + &poly_mask_data); + + BLI_bitmap *bitmap_buf = BLI_BITMAP_NEW(bitmap_len, __func__); + const uint *buf_iter = buf; + int i = 0; + while (buf_len--) { + const uint index = *buf_iter - 1; + if (index < bitmap_len && BLI_BITMAP_TEST(buf_mask, i)) { + BLI_BITMAP_ENABLE(bitmap_buf, index); + } + buf_iter++; + i++; + } + MEM_freeN((void *)buf); + MEM_freeN(buf_mask); + + return bitmap_buf; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Find Single Select ID's + * + * Given a buffer of select ID's, find the a single select id. + * + * \{ */ + +/** + * Samples a single pixel. + */ +uint DRW_select_buffer_sample_point(const int center[2]) +{ + const rcti rect = { + .xmin = center[0], + .xmax = center[0] + 1, + .ymin = center[1], + .ymax = center[1] + 1, + }; + + uint buf_len; + uint *buf = DRW_select_buffer_read(&rect, &buf_len); + BLI_assert(0 != buf_len); + uint ret = buf[0]; + MEM_freeN(buf); + return ret; +} + +/** + * Find the selection id closest to \a center. + * \param dist[in,out]: Use to initialize the distance, + * when found, this value is set to the distance of the selection that's returned. + */ +uint DRW_select_buffer_find_nearest_to_point(const int center[2], + const uint id_min, + const uint id_max, + uint *dist) +{ + /* Smart function to sample a rect spiraling outside, nice for selection ID. */ + + /* Create region around center (typically the mouse cursor). + * This must be square and have an odd width, + * the spiraling algorithm does not work with arbitrary rectangles. */ + + uint index = 0; + + rcti rect; + BLI_rcti_init_pt_radius(&rect, center, *dist); + rect.xmax += 1; + rect.ymax += 1; + + int width = BLI_rcti_size_x(&rect); + int height = width; + BLI_assert(width == height); + + /* Read from selection framebuffer. */ + + uint buf_len; + const uint *buf = DRW_select_buffer_read(&rect, &buf_len); + + if (buf == NULL) { + return index; + } + + BLI_assert(width * height == buf_len); + + /* Spiral, starting from center of buffer. */ + int spiral_offset = height * (int)(width / 2) + (height / 2); + int spiral_direction = 0; + + for (int nr = 1; nr <= height; nr++) { + for (int a = 0; a < 2; a++) { + for (int b = 0; b < nr; b++) { + /* Find hit within the specified range. */ + uint hit_id = buf[spiral_offset]; + + if (hit_id && hit_id >= id_min && hit_id < id_max) { + /* Get x/y from spiral offset. */ + int hit_x = spiral_offset % width; + int hit_y = spiral_offset / width; + + int center_x = width / 2; + int center_y = height / 2; + + /* Manhatten distance in keeping with other screen-based selection. */ + *dist = (uint)(abs(hit_x - center_x) + abs(hit_y - center_y)); + + /* Indices start at 1 here. */ + index = (hit_id - id_min) + 1; + goto exit; + } + + /* Next spiral step. */ + if (spiral_direction == 0) { + spiral_offset += 1; /* right */ + } + else if (spiral_direction == 1) { + spiral_offset -= width; /* down */ + } + else if (spiral_direction == 2) { + spiral_offset -= 1; /* left */ + } + else { + spiral_offset += width; /* up */ + } + + /* Stop if we are outside the buffer. */ + if (spiral_offset < 0 || spiral_offset >= buf_len) { + goto exit; + } + } + + spiral_direction = (spiral_direction + 1) % 4; + } + } + +exit: + MEM_freeN((void *)buf); + return index; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Object Utils + * \{ */ + +bool DRW_select_buffer_elem_get(const uint sel_id, + uint *r_elem, + uint *r_base_index, + char *r_elem_type) +{ + struct SELECTID_Context *select_ctx = select_context_get(); + + char elem_type = 0; + uint elem_id; + uint base_index = 0; + + for (; base_index < select_ctx->objects_len; base_index++) { + struct BaseOffset *base_ofs = &select_ctx->index_offsets[base_index]; + + if (base_ofs->face > sel_id) { + elem_id = sel_id - base_ofs->face_start; + elem_type = SCE_SELECT_FACE; + break; + } + if (base_ofs->edge > sel_id) { + elem_id = sel_id - base_ofs->edge_start; + elem_type = SCE_SELECT_EDGE; + break; + } + if (base_ofs->vert > sel_id) { + elem_id = sel_id - base_ofs->vert_start; + elem_type = SCE_SELECT_VERTEX; + break; + } + } + + if (base_index == select_ctx->objects_len) { + return false; + } + + *r_elem = elem_id; + + if (r_base_index) { + *r_base_index = base_index; + } + + if (r_elem_type) { + *r_elem_type = elem_type; + } + + return true; +} + +uint DRW_select_buffer_context_offset_for_object_elem(const uint base_index, char elem_type) +{ + struct SELECTID_Context *select_ctx = select_context_get(); + struct BaseOffset *base_ofs = &select_ctx->index_offsets[base_index]; + + if (elem_type == SCE_SELECT_VERTEX) { + return base_ofs->vert_start - 1; + } + if (elem_type == SCE_SELECT_EDGE) { + return base_ofs->edge_start - 1; + } + if (elem_type == SCE_SELECT_FACE) { + return base_ofs->face_start - 1; + } + BLI_assert(0); + return 0; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Context + * \{ */ + +void DRW_select_buffer_context_create(Base **UNUSED(bases), + const uint bases_len, + short select_mode) +{ + struct SELECTID_Context *select_ctx = select_context_get(); + + select_ctx->select_mode = select_mode; + select_ctx->objects_len = bases_len; + + MEM_SAFE_FREE(select_ctx->index_offsets); + select_ctx->index_offsets = MEM_mallocN(sizeof(*select_ctx->index_offsets) * bases_len, + __func__); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Legacy + * \{ */ + +void DRW_draw_select_id_object(Depsgraph *depsgraph, + ViewLayer *view_layer, + ARegion *ar, + View3D *v3d, + Object *ob, + short select_mode) +{ + Base *base = BKE_view_layer_base_find(view_layer, ob); + DRW_draw_select_id(depsgraph, ar, v3d, &base, 1, select_mode); +} + +/** \} */ diff --git a/source/blender/draw/engines/select/select_draw_utils.c b/source/blender/draw/engines/select/select_draw_utils.c index c3615cb5a81..c3ee7f962a1 100644 --- a/source/blender/draw/engines/select/select_draw_utils.c +++ b/source/blender/draw/engines/select/select_draw_utils.c @@ -40,6 +40,37 @@ /** \name Draw Utilities * \{ */ +void draw_select_framebuffer_select_id_setup(struct SELECTID_Context *select_ctx) +{ + DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); + int size[2]; + size[0] = GPU_texture_width(dtxl->depth); + size[1] = GPU_texture_height(dtxl->depth); + + if (select_ctx->framebuffer_select_id == NULL) { + select_ctx->framebuffer_select_id = GPU_framebuffer_create(); + } + + if ((select_ctx->texture_u32 != NULL) && + ((GPU_texture_width(select_ctx->texture_u32) != size[0]) || + (GPU_texture_height(select_ctx->texture_u32) != size[1]))) { + GPU_texture_free(select_ctx->texture_u32); + select_ctx->texture_u32 = NULL; + } + + /* Make sure the depth texture is attached. + * It may disappear when loading another Blender session. */ + GPU_framebuffer_texture_attach(select_ctx->framebuffer_select_id, dtxl->depth, 0, 0); + + if (select_ctx->texture_u32 == NULL) { + select_ctx->texture_u32 = GPU_texture_create_2d(size[0], size[1], GPU_R32UI, NULL, NULL); + GPU_framebuffer_texture_attach( + select_ctx->framebuffer_select_id, select_ctx->texture_u32, 0, 0); + + GPU_framebuffer_check_valid(select_ctx->framebuffer_select_id, NULL); + } +} + short select_id_get_object_select_mode(Scene *scene, Object *ob) { short r_select_mode = 0; @@ -179,6 +210,9 @@ static void draw_select_id_mesh(SELECTID_StorageList *stl, DRW_shgroup_call(vert_shgrp, geom_verts, ob); *r_vert_offset = *r_edge_offset + me->totvert; } + else { + *r_vert_offset = *r_edge_offset; + } } void select_id_draw_object(void *vedata, diff --git a/source/blender/draw/engines/select/select_engine.c b/source/blender/draw/engines/select/select_engine.c index 1f00a116499..3e4e4861f50 100644 --- a/source/blender/draw/engines/select/select_engine.c +++ b/source/blender/draw/engines/select/select_engine.c @@ -22,12 +22,9 @@ * Engine for drawing a selection map where the pixels indicate the selection indices. */ -#include "BLI_rect.h" - #include "DNA_screen_types.h" #include "GPU_shader.h" -#include "GPU_select.h" #include "UI_resources.h" @@ -42,19 +39,7 @@ static struct { SELECTID_Shaders sh_data[GPU_SHADER_CFG_LEN]; - - struct GPUFrameBuffer *framebuffer_select_id; - struct GPUTexture *texture_u32; - - struct { - struct BaseOffset *base_array_index_offsets; - uint bases_len; - uint last_base_drawn; - /** Total number of items `base_array_index_offsets[bases_len - 1].vert`. */ - uint last_index_drawn; - - short select_mode; - } context; + struct SELECTID_Context context; } e_data = {{{NULL}}}; /* Engine data */ /* Shaders */ @@ -63,41 +48,6 @@ extern char datatoc_selection_id_3D_vert_glsl[]; extern char datatoc_selection_id_frag_glsl[]; /* -------------------------------------------------------------------- */ -/** \name Selection Utilities - * \{ */ - -static void draw_select_framebuffer_select_id_setup(void) -{ - DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - int size[2]; - size[0] = GPU_texture_width(dtxl->depth); - size[1] = GPU_texture_height(dtxl->depth); - - if (e_data.framebuffer_select_id == NULL) { - e_data.framebuffer_select_id = GPU_framebuffer_create(); - } - - if ((e_data.texture_u32 != NULL) && ((GPU_texture_width(e_data.texture_u32) != size[0]) || - (GPU_texture_height(e_data.texture_u32) != size[1]))) { - - GPU_texture_free(e_data.texture_u32); - e_data.texture_u32 = NULL; - } - - /* Make sure the depth texture is attached. - * It may disappear when loading another Blender session. */ - GPU_framebuffer_texture_attach(e_data.framebuffer_select_id, dtxl->depth, 0, 0); - - if (e_data.texture_u32 == NULL) { - e_data.texture_u32 = GPU_texture_create_2d(size[0], size[1], GPU_R32UI, NULL, NULL); - GPU_framebuffer_texture_attach(e_data.framebuffer_select_id, e_data.texture_u32, 0, 0); - GPU_framebuffer_check_valid(e_data.framebuffer_select_id, NULL); - } -} - -/** \} */ - -/* -------------------------------------------------------------------- */ /** \name Engine Functions * \{ */ @@ -206,15 +156,14 @@ static void select_cache_init(void *vedata) } } - e_data.context.last_base_drawn = 0; + e_data.context.last_object_drawn = 0; e_data.context.last_index_drawn = 1; } static void select_cache_populate(void *vedata, Object *ob) { const DRWContextState *draw_ctx = DRW_context_state_get(); - struct BaseOffset *base_ofs = - &e_data.context.base_array_index_offsets[e_data.context.last_base_drawn++]; + struct BaseOffset *base_ofs = &e_data.context.index_offsets[e_data.context.last_object_drawn++]; uint offset = e_data.context.last_index_drawn; @@ -237,13 +186,14 @@ static void select_draw_scene(void *vedata) SELECTID_PassList *psl = ((SELECTID_Data *)vedata)->psl; /* Setup framebuffer */ - draw_select_framebuffer_select_id_setup(); - GPU_framebuffer_bind(e_data.framebuffer_select_id); + draw_select_framebuffer_select_id_setup(&e_data.context); + GPU_framebuffer_bind(e_data.context.framebuffer_select_id); /* dithering and AA break color coding, so disable */ glDisable(GL_DITHER); - GPU_framebuffer_clear_color_depth(e_data.framebuffer_select_id, (const float[4]){0.0f}, 1.0f); + GPU_framebuffer_clear_color_depth( + e_data.context.framebuffer_select_id, (const float[4]){0.0f}, 1.0f); DRW_view_set_active(stl->g_data->view_faces); DRW_draw_pass(psl->select_id_face_pass); @@ -267,145 +217,9 @@ static void select_engine_free(void) DRW_SHADER_FREE_SAFE(sh_data->select_id_uniform); } - DRW_TEXTURE_FREE_SAFE(e_data.texture_u32); - GPU_FRAMEBUFFER_FREE_SAFE(e_data.framebuffer_select_id); - MEM_SAFE_FREE(e_data.context.base_array_index_offsets); -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Exposed `DRW_engine.h` functions - * \{ */ - -bool DRW_select_elem_get(const uint sel_id, uint *r_elem, uint *r_base_index, char *r_elem_type) -{ - char elem_type = 0; - uint elem_id; - uint base_index = 0; - - for (; base_index < e_data.context.bases_len; base_index++) { - struct BaseOffset *base_ofs = &e_data.context.base_array_index_offsets[base_index]; - - if (base_ofs->face > sel_id) { - elem_id = sel_id - base_ofs->face_start; - elem_type = SCE_SELECT_FACE; - break; - } - if (base_ofs->edge > sel_id) { - elem_id = sel_id - base_ofs->edge_start; - elem_type = SCE_SELECT_EDGE; - break; - } - if (base_ofs->vert > sel_id) { - elem_id = sel_id - base_ofs->vert_start; - elem_type = SCE_SELECT_VERTEX; - break; - } - } - - if (base_index == e_data.context.bases_len) { - return false; - } - - *r_elem = elem_id; - - if (r_base_index) { - *r_base_index = base_index; - } - - if (r_elem_type) { - *r_elem_type = elem_type; - } - - return true; -} - -uint DRW_select_context_offset_for_object_elem(const uint base_index, char elem_type) -{ - struct BaseOffset *base_ofs = &e_data.context.base_array_index_offsets[base_index]; - - if (elem_type == SCE_SELECT_VERTEX) { - return base_ofs->vert_start - 1; - } - if (elem_type == SCE_SELECT_EDGE) { - return base_ofs->edge_start - 1; - } - if (elem_type == SCE_SELECT_FACE) { - return base_ofs->face_start - 1; - } - BLI_assert(0); - return 0; -} - -uint DRW_select_context_elem_len(void) -{ - return e_data.context.last_index_drawn; -} - -/* Read a block of pixels from the select frame buffer. */ -void DRW_framebuffer_select_id_read(const rcti *rect, uint *r_buf) -{ - /* clamp rect by texture */ - rcti r = { - .xmin = 0, - .xmax = GPU_texture_width(e_data.texture_u32), - .ymin = 0, - .ymax = GPU_texture_height(e_data.texture_u32), - }; - - rcti rect_clamp = *rect; - if (BLI_rcti_isect(&r, &rect_clamp, &rect_clamp)) { - DRW_opengl_context_enable(); - GPU_framebuffer_bind(e_data.framebuffer_select_id); - glReadBuffer(GL_COLOR_ATTACHMENT0); - glReadPixels(rect_clamp.xmin, - rect_clamp.ymin, - BLI_rcti_size_x(&rect_clamp), - BLI_rcti_size_y(&rect_clamp), - GL_RED_INTEGER, - GL_UNSIGNED_INT, - r_buf); - - GPU_framebuffer_restore(); - DRW_opengl_context_disable(); - - if (!BLI_rcti_compare(rect, &rect_clamp)) { - GPU_select_buffer_stride_realign(rect, &rect_clamp, r_buf); - } - } - else { - size_t buf_size = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect) * sizeof(*r_buf); - - memset(r_buf, 0, buf_size); - } -} - -void DRW_select_context_create(Base **UNUSED(bases), const uint bases_len, short select_mode) -{ - e_data.context.select_mode = select_mode; - e_data.context.bases_len = bases_len; - - MEM_SAFE_FREE(e_data.context.base_array_index_offsets); - e_data.context.base_array_index_offsets = MEM_mallocN( - sizeof(*e_data.context.base_array_index_offsets) * bases_len, __func__); -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Legacy - * \{ */ - -void DRW_draw_select_id_object(Depsgraph *depsgraph, - ViewLayer *view_layer, - ARegion *ar, - View3D *v3d, - Object *ob, - short select_mode) -{ - Base *base = BKE_view_layer_base_find(view_layer, ob); - DRW_draw_select_id(depsgraph, ar, v3d, &base, 1, select_mode); + DRW_TEXTURE_FREE_SAFE(e_data.context.texture_u32); + GPU_FRAMEBUFFER_FREE_SAFE(e_data.context.framebuffer_select_id); + MEM_SAFE_FREE(e_data.context.index_offsets); } /** \} */ @@ -454,4 +268,15 @@ RenderEngineType DRW_engine_viewport_select_type = { /** \} */ +/* -------------------------------------------------------------------- */ +/** \name Exposed `select_private.h` functions + * \{ */ + +struct SELECTID_Context *select_context_get(void) +{ + return &e_data.context; +} + +/** \} */ + #undef SELECT_ENGINE diff --git a/source/blender/draw/engines/select/select_private.h b/source/blender/draw/engines/select/select_private.h index e2b5163c88a..2104f1485e7 100644 --- a/source/blender/draw/engines/select/select_private.h +++ b/source/blender/draw/engines/select/select_private.h @@ -79,8 +79,25 @@ struct BaseOffset { uint vert; }; -short select_id_get_object_select_mode(Scene *scene, Object *ob); +struct SELECTID_Context { + struct GPUFrameBuffer *framebuffer_select_id; + struct GPUTexture *texture_u32; + + struct BaseOffset *index_offsets; + uint objects_len; + uint last_object_drawn; + /** Total number of items `base_array_index_offsets[bases_len - 1].vert`. */ + uint last_index_drawn; + + short select_mode; +}; + +/* select_engine.c */ +struct SELECTID_Context *select_context_get(void); +/* select_draw_utils.c */ +void draw_select_framebuffer_select_id_setup(struct SELECTID_Context *r_select_ctx); +short select_id_get_object_select_mode(Scene *scene, Object *ob); void select_id_draw_object(void *vedata, View3D *v3d, Object *ob, diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 735a0dcf7a0..add49462de1 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -475,7 +475,7 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) const eGPUTextureFormat nor_tex_format = NORMAL_ENCODING_ENABLED() ? GPU_RG16 : GPU_RGBA32F; const eGPUTextureFormat comp_tex_format = DRW_state_is_image_render() ? GPU_RGBA16F : GPU_R11F_G11F_B10F; - const eGPUTextureFormat col_tex_format = DRW_state_is_image_render() ? GPU_RGBA16F : GPU_RGBA8; + const eGPUTextureFormat col_tex_format = workbench_color_texture_format(wpd); const eGPUTextureFormat id_tex_format = OBJECT_ID_PASS_ENABLED(wpd) ? GPU_R32UI : GPU_R8; e_data.object_id_tx = NULL; diff --git a/source/blender/draw/engines/workbench/workbench_effect_taa.c b/source/blender/draw/engines/workbench/workbench_effect_taa.c index 88f1f30941a..06442060623 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_taa.c +++ b/source/blender/draw/engines/workbench/workbench_effect_taa.c @@ -170,10 +170,10 @@ DRWPass *workbench_taa_create_pass(WORKBENCH_Data *vedata, GPUTexture **color_bu WORKBENCH_TextureList *txl = vedata->txl; WORKBENCH_EffectInfo *effect_info = stl->effects; WORKBENCH_FramebufferList *fbl = vedata->fbl; + const WORKBENCH_PrivateData *wpd = stl->g_data; { - const eGPUTextureFormat hist_buffer_format = DRW_state_is_image_render() ? GPU_RGBA16F : - GPU_RGBA8; + const eGPUTextureFormat hist_buffer_format = workbench_color_texture_format(wpd); DRW_texture_ensure_fullscreen_2d(&txl->history_buffer_tx, hist_buffer_format, 0); DRW_texture_ensure_fullscreen_2d(&txl->depth_buffer_tx, GPU_DEPTH24_STENCIL8, 0); } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 17144c4dc10..255b036eebb 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -381,6 +381,30 @@ BLI_INLINE bool workbench_is_matdata_pass_enabled(WORKBENCH_PrivateData *wpd) workbench_is_in_texture_paint_mode(); } +/** + * Get the default texture format to be used by the color and history buffers. + * + * Use GPU_RGBA16F for final renderings and for drawing textures. This + * allows displaying HDRI textures. Vertex Colors uses GPU_RGBA16 to resolve + * color banding issues (T66100). All other modes use GPU_RGBA8 to reduce + * bandwidth and gpu memory. + */ +BLI_INLINE eGPUTextureFormat workbench_color_texture_format(const WORKBENCH_PrivateData *wpd) +{ + eGPUTextureFormat result; + if (DRW_state_is_image_render() || workbench_is_in_texture_paint_mode() || + TEXTURE_DRAWING_ENABLED(wpd)) { + result = GPU_RGBA16F; + } + else if (VERTEX_COLORS_ENABLED(wpd)) { + result = GPU_RGBA16; + } + else { + result = GPU_RGBA8; + } + return result; +} + /* workbench_deferred.c */ void workbench_deferred_engine_init(WORKBENCH_Data *vedata); void workbench_deferred_engine_free(void); diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c index 30e51333f0f..865cfea14e3 100644 --- a/source/blender/draw/intern/draw_armature.c +++ b/source/blender/draw/intern/draw_armature.c @@ -694,17 +694,17 @@ static bool set_pchan_color(short colCode, uchar cp[4] = {255}; if (boneflag & BONE_DRAW_ACTIVE) { - copy_v3_v3_char((char *)cp, bcolor->active); + copy_v3_v3_uchar(cp, bcolor->active); if (!(boneflag & BONE_SELECTED)) { cp_shade_color3ub(cp, -80); } } else if (boneflag & BONE_SELECTED) { - copy_v3_v3_char((char *)cp, bcolor->select); + copy_v3_v3_uchar(cp, bcolor->select); } else { /* a bit darker than solid */ - copy_v3_v3_char((char *)cp, bcolor->solid); + copy_v3_v3_uchar(cp, bcolor->solid); cp_shade_color3ub(cp, -50); } @@ -742,16 +742,16 @@ static bool set_pchan_color(short colCode, if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) { uchar cp[4]; if (constflag & PCHAN_HAS_TARGET) { - rgba_char_args_set((char *)cp, 255, 150, 0, 80); + rgba_uchar_args_set(cp, 255, 150, 0, 80); } else if (constflag & PCHAN_HAS_IK) { - rgba_char_args_set((char *)cp, 255, 255, 0, 80); + rgba_uchar_args_set(cp, 255, 255, 0, 80); } else if (constflag & PCHAN_HAS_SPLINEIK) { - rgba_char_args_set((char *)cp, 200, 255, 0, 80); + rgba_uchar_args_set(cp, 200, 255, 0, 80); } else if (constflag & PCHAN_HAS_CONST) { - rgba_char_args_set((char *)cp, 0, 255, 120, 80); + rgba_uchar_args_set(cp, 0, 255, 120, 80); } else { return false; @@ -768,13 +768,13 @@ static bool set_pchan_color(short colCode, uchar cp[4] = {255}; if (boneflag & BONE_DRAW_ACTIVE) { - copy_v3_v3_char((char *)cp, bcolor->active); + copy_v3_v3_uchar(cp, bcolor->active); } else if (boneflag & BONE_SELECTED) { - copy_v3_v3_char((char *)cp, bcolor->select); + copy_v3_v3_uchar(cp, bcolor->select); } else { - copy_v3_v3_char((char *)cp, bcolor->solid); + copy_v3_v3_uchar(cp, bcolor->solid); } rgb_uchar_to_float(fcolor, cp); @@ -798,15 +798,15 @@ static bool set_pchan_color(short colCode, uchar cp[4] = {255}; if (boneflag & BONE_DRAW_ACTIVE) { - copy_v3_v3_char((char *)cp, bcolor->active); + copy_v3_v3_uchar(cp, bcolor->active); cp_shade_color3ub(cp, 10); } else if (boneflag & BONE_SELECTED) { - copy_v3_v3_char((char *)cp, bcolor->select); + copy_v3_v3_uchar(cp, bcolor->select); cp_shade_color3ub(cp, -30); } else { - copy_v3_v3_char((char *)cp, bcolor->solid); + copy_v3_v3_uchar(cp, bcolor->solid); cp_shade_color3ub(cp, -30); } @@ -830,16 +830,16 @@ static bool set_pchan_color(short colCode, if ((constflag) && ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS))) { uchar cp[4]; if (constflag & PCHAN_HAS_TARGET) { - rgba_char_args_set((char *)cp, 255, 150, 0, 255); + rgba_uchar_args_set(cp, 255, 150, 0, 255); } else if (constflag & PCHAN_HAS_IK) { - rgba_char_args_set((char *)cp, 255, 255, 0, 255); + rgba_uchar_args_set(cp, 255, 255, 0, 255); } else if (constflag & PCHAN_HAS_SPLINEIK) { - rgba_char_args_set((char *)cp, 200, 255, 0, 255); + rgba_uchar_args_set(cp, 200, 255, 0, 255); } else if (constflag & PCHAN_HAS_CONST) { - rgba_char_args_set((char *)cp, 0, 255, 120, 255); + rgba_uchar_args_set(cp, 0, 255, 120, 255); } else if (constflag) { UI_GetThemeColor4ubv(TH_BONE_POSE, cp); @@ -849,7 +849,7 @@ static bool set_pchan_color(short colCode, } else { if (bcolor) { - const char *cp = bcolor->solid; + const uchar *cp = bcolor->solid; rgb_uchar_to_float(fcolor, (uchar *)cp); fcolor[3] = 204.f / 255.f; } diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index de00bc6f577..b3df5db32e6 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -96,6 +96,8 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" +#include "DRW_select_buffer.h" + #ifdef USE_GPU_SELECT # include "GPU_select.h" #endif @@ -2564,7 +2566,7 @@ void DRW_draw_select_id(Depsgraph *depsgraph, Scene *scene = DEG_get_evaluated_scene(depsgraph); ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph); - DRW_select_context_create(bases, bases_len, select_mode); + DRW_select_buffer_context_create(bases, bases_len, select_mode); DRW_opengl_context_enable(); diff --git a/source/blender/draw/intern/draw_manager_texture.c b/source/blender/draw/intern/draw_manager_texture.c index 4750a35d784..373810b2f7f 100644 --- a/source/blender/draw/intern/draw_manager_texture.c +++ b/source/blender/draw/intern/draw_manager_texture.c @@ -45,6 +45,7 @@ static bool drw_texture_format_supports_framebuffer(eGPUTextureFormat format) case GPU_RG32F: case GPU_R11F_G11F_B10F: case GPU_RGBA8: + case GPU_RGBA16: case GPU_RGBA16F: case GPU_RGBA32F: case GPU_DEPTH_COMPONENT16: diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 148a4951dc6..87fc74f1f72 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -1115,6 +1115,10 @@ static void DRW_shgroup_camera_background_images(OBJECT_Shaders *sh_data, Object *ob, RegionView3D *rv3d) { + if (DRW_state_is_select()) { + return; + } + if (!BKE_object_empty_image_frame_is_visible_in_view3d(ob, rv3d)) { return; } @@ -1250,9 +1254,9 @@ static void DRW_shgroup_camera_background_images(OBJECT_Shaders *sh_data, float camera_aspect_y = 1.0; float camera_offset_x = 0.0; float camera_offset_y = 0.0; - float camera_aspect = 1.0; float camera_width = size[0]; float camera_height = size[1]; + float camera_aspect = camera_width / camera_height; if (!DRW_state_is_image_render()) { rctf render_border; @@ -1280,48 +1284,52 @@ static void DRW_shgroup_camera_background_images(OBJECT_Shaders *sh_data, uv2img_space[0][0] = image_width; uv2img_space[1][1] = image_height; - img2cam_space[0][0] = (1.0 / image_width); - img2cam_space[1][1] = (1.0 / image_height); + const float fit_scale = image_aspect / camera_aspect; + img2cam_space[0][0] = 1.0 / image_width; + img2cam_space[1][1] = 1.0 / fit_scale / image_height; /* Update scaling based on image and camera framing */ float scale_x = bgpic->scale; float scale_y = bgpic->scale; if (bgpic->flag & CAM_BGIMG_FLAG_CAMERA_ASPECT) { - float fit_scale = image_aspect / camera_aspect; if (bgpic->flag & CAM_BGIMG_FLAG_CAMERA_CROP) { if (image_aspect > camera_aspect) { scale_x *= fit_scale; - } - else { - scale_y /= fit_scale; + scale_y *= fit_scale; } } else { if (image_aspect > camera_aspect) { + scale_x /= fit_scale; scale_y /= fit_scale; } else { scale_x *= fit_scale; + scale_y *= fit_scale; } } } + else { + /* Stretch image to camera aspect */ + scale_y /= 1.0 / fit_scale; + } // scale image to match the desired aspect ratio scale_m4[0][0] = scale_x; scale_m4[1][1] = scale_y; - /* Translate, using coordinates that aren't squashed by the aspect. */ - translate_m4[3][0] = bgpic->offset[0] * 2.0f * max_ff(1.0f, 1.0f / camera_aspect); - translate_m4[3][1] = bgpic->offset[1] * 2.0f * max_ff(1.0f, camera_aspect); + /* Translate */ + translate_m4[3][0] = image_width * bgpic->offset[0] * 2.0f; + translate_m4[3][1] = image_height * bgpic->offset[1] * 2.0f; mul_m4_series(bg_data->transform_mat, win_m4_translate, win_m4_scale, - translate_m4, img2cam_space, - scale_m4, + translate_m4, rot_m4, + scale_m4, uv2img_space); DRWPass *pass = (bgpic->flag & CAM_BGIMG_FLAG_FOREGROUND) ? psl->camera_images_front : diff --git a/source/blender/draw/modes/paint_vertex_mode.c b/source/blender/draw/modes/paint_vertex_mode.c index bfd189189b4..5d14b3ba414 100644 --- a/source/blender/draw/modes/paint_vertex_mode.c +++ b/source/blender/draw/modes/paint_vertex_mode.c @@ -78,7 +78,8 @@ typedef struct PAINT_VERTEX_Data { typedef struct PAINT_VERTEX_Shaders { struct { - struct GPUShader *color_face; + struct GPUShader *color_face_mul_blending; + struct GPUShader *color_face_alpha_blending; struct GPUShader *wire_overlay; struct GPUShader *wire_select_overlay; } by_mode[MODE_LEN]; @@ -114,7 +115,7 @@ static void PAINT_VERTEX_engine_init(void *vedata) const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[draw_ctx->sh_cfg]; if (!sh_data->face_select_overlay) { - sh_data->by_mode[VERTEX_MODE].color_face = GPU_shader_create_from_arrays({ + sh_data->by_mode[VERTEX_MODE].color_face_mul_blending = GPU_shader_create_from_arrays({ .vert = (const char *[]){sh_cfg_data->lib, datatoc_common_view_lib_glsl, datatoc_paint_vertex_vert_glsl, @@ -122,7 +123,15 @@ static void PAINT_VERTEX_engine_init(void *vedata) .frag = (const char *[]){datatoc_paint_vertex_frag_glsl, NULL}, .defs = (const char *[]){sh_cfg_data->def, NULL}, }); - sh_data->by_mode[WEIGHT_MODE].color_face = GPU_shader_create_from_arrays({ + sh_data->by_mode[VERTEX_MODE].color_face_alpha_blending = GPU_shader_create_from_arrays({ + .vert = (const char *[]){sh_cfg_data->lib, + datatoc_common_view_lib_glsl, + datatoc_paint_vertex_vert_glsl, + NULL}, + .frag = (const char *[]){datatoc_paint_vertex_frag_glsl, NULL}, + .defs = (const char *[]){sh_cfg_data->def, "#define DRW_STATE_BLEND_ALPHA\n", NULL}, + }); + sh_data->by_mode[WEIGHT_MODE].color_face_mul_blending = GPU_shader_create_from_arrays({ .vert = (const char *[]){sh_cfg_data->lib, datatoc_common_view_lib_glsl, datatoc_common_globals_lib_glsl, @@ -131,7 +140,18 @@ static void PAINT_VERTEX_engine_init(void *vedata) .frag = (const char *[]){datatoc_common_globals_lib_glsl, datatoc_paint_weight_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg_data->def, NULL}, + .defs = (const char *[]){sh_cfg_data->def, "#define DRW_STATE_BLEND_MUL\n", NULL}, + }); + sh_data->by_mode[WEIGHT_MODE].color_face_alpha_blending = GPU_shader_create_from_arrays({ + .vert = (const char *[]){sh_cfg_data->lib, + datatoc_common_view_lib_glsl, + datatoc_common_globals_lib_glsl, + datatoc_paint_weight_vert_glsl, + NULL}, + .frag = (const char *[]){datatoc_common_globals_lib_glsl, + datatoc_paint_weight_frag_glsl, + NULL}, + .defs = (const char *[]){sh_cfg_data->def, "#define DRW_STATE_BLEND_ALPHA\n", NULL}, }); sh_data->face_select_overlay = GPU_shader_create_from_arrays({ @@ -140,7 +160,7 @@ static void PAINT_VERTEX_engine_init(void *vedata) datatoc_paint_face_selection_vert_glsl, NULL}, .frag = (const char *[]){datatoc_gpu_shader_uniform_color_frag_glsl, NULL}, - .defs = (const char *[]){sh_cfg_data->def, NULL}, + .defs = (const char *[]){sh_cfg_data->def, "#define DRW_STATE_BLEND_MUL\n", NULL}, }); sh_data->vert_select_overlay = GPU_shader_create_from_arrays({ .vert = (const char *[]){sh_cfg_data->lib, @@ -195,13 +215,17 @@ static void PAINT_VERTEX_cache_init(void *vedata) const RegionView3D *rv3d = draw_ctx->rv3d; PAINT_VERTEX_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; + const bool use_alpha_blending = draw_ctx->v3d->shading.type == OB_WIRE; + DRWState draw_state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | + (use_alpha_blending ? DRW_STATE_BLEND_ALPHA : DRW_STATE_BLEND_MUL); /* Vertex color pass */ { - DRWPass *pass = DRW_pass_create( - "Vert Color Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_MUL); - DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->by_mode[VERTEX_MODE].color_face, pass); - DRW_shgroup_uniform_float_copy( - shgrp, "white_factor", 1.0f - v3d->overlay.vertex_paint_mode_opacity); + DRWPass *pass = DRW_pass_create("Vert Color Pass", draw_state); + GPUShader *shader = use_alpha_blending ? + sh_data->by_mode[VERTEX_MODE].color_face_alpha_blending : + sh_data->by_mode[VERTEX_MODE].color_face_mul_blending; + DRWShadingGroup *shgrp = DRW_shgroup_create(shader, pass); + DRW_shgroup_uniform_float(shgrp, "opacity", &v3d->overlay.vertex_paint_mode_opacity, 1); if (rv3d->rflag & RV3D_CLIPPING) { DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES); } @@ -211,9 +235,11 @@ static void PAINT_VERTEX_cache_init(void *vedata) /* Weight color pass */ { - DRWPass *pass = DRW_pass_create( - "Weight Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_MUL); - DRWShadingGroup *shgrp = DRW_shgroup_create(sh_data->by_mode[WEIGHT_MODE].color_face, pass); + DRWPass *pass = DRW_pass_create("Weight Pass", draw_state); + GPUShader *shader = use_alpha_blending ? + sh_data->by_mode[WEIGHT_MODE].color_face_alpha_blending : + sh_data->by_mode[WEIGHT_MODE].color_face_mul_blending; + DRWShadingGroup *shgrp = DRW_shgroup_create(shader, pass); DRW_shgroup_uniform_bool_copy( shgrp, "drawContours", (v3d->overlay.wpaint_flag & V3D_OVERLAY_WPAINT_CONTOURS) != 0); DRW_shgroup_uniform_float(shgrp, "opacity", &v3d->overlay.weight_paint_mode_opacity, 1); diff --git a/source/blender/draw/modes/shaders/paint_vertex_frag.glsl b/source/blender/draw/modes/shaders/paint_vertex_frag.glsl index 426dbada812..f03e3410ec3 100644 --- a/source/blender/draw/modes/shaders/paint_vertex_frag.glsl +++ b/source/blender/draw/modes/shaders/paint_vertex_frag.glsl @@ -2,7 +2,7 @@ in vec3 finalColor; out vec4 fragColor; -uniform float white_factor = 1.0; +uniform float opacity = 1.0; vec3 linear_to_srgb_attr(vec3 c) { @@ -14,6 +14,11 @@ vec3 linear_to_srgb_attr(vec3 c) void main() { - fragColor.rgb = mix(linear_to_srgb_attr(finalColor), vec3(1.0), white_factor); + vec3 color = linear_to_srgb_attr(finalColor); +#ifdef DRW_STATE_BLEND_ALPHA + fragColor = vec4(color, opacity); +#else + fragColor.rgb = mix(vec3(1.0), color, opacity); fragColor.a = 1.0; +#endif } diff --git a/source/blender/draw/modes/shaders/paint_weight_frag.glsl b/source/blender/draw/modes/shaders/paint_weight_frag.glsl index 8b0e03ac31c..76b7719be64 100644 --- a/source/blender/draw/modes/shaders/paint_weight_frag.glsl +++ b/source/blender/draw/modes/shaders/paint_weight_frag.glsl @@ -95,6 +95,11 @@ void main() color = mix(weight_color, colorVertexUnreferenced, alert * alert); } +#ifdef DRW_STATE_BLEND_ALPHA + /* alpha blending mix */ + fragColor = vec4(color.rgb, opacity); +#else /* mix with 1.0 -> is like opacity when using multiply blend mode */ fragColor = vec4(mix(vec3(1.0), color.rgb, opacity), 1.0); +#endif } diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 3d7178a4114..1649744ba8d 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -206,16 +206,16 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa * - only use group colors if allowed to, and if actually feasible */ if (showGroupColors && (grp) && (grp->customCol)) { - unsigned char cp[3]; + uchar cp[3]; if (indent == 2) { - copy_v3_v3_char((char *)cp, grp->cs.solid); + copy_v3_v3_uchar(cp, grp->cs.solid); } else if (indent == 1) { - copy_v3_v3_char((char *)cp, grp->cs.select); + copy_v3_v3_uchar(cp, grp->cs.select); } else { - copy_v3_v3_char((char *)cp, grp->cs.active); + copy_v3_v3_uchar(cp, grp->cs.active); } /* copy the colors over, transforming from bytes to floats */ @@ -850,10 +850,10 @@ static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[ /* highlight only for active */ if (ale->flag & AGRP_ACTIVE) { - copy_v3_v3_char((char *)cp, agrp->cs.select); + copy_v3_v3_uchar(cp, agrp->cs.select); } else { - copy_v3_v3_char((char *)cp, agrp->cs.solid); + copy_v3_v3_uchar(cp, agrp->cs.solid); } /* copy the colors over, transforming from bytes to floats */ diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 047b78af7b1..c4bb5eec723 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4784,7 +4784,7 @@ static int make_segment_exec(bContext *C, wmOperator *op) BKE_nurb_handles_calc(nu1); ok = true; } - else if (nu1->type == CU_NURBS && nu1->bp->f1 & SELECT && + else if (ELEM(nu1->type, CU_NURBS, CU_POLY) && nu1->bp->f1 & SELECT && (nu1->bp[nu1->pntsu - 1].f1 & SELECT)) { nu1->flagu |= CU_NURB_CYCLIC; BKE_nurb_knot_calc_u(nu1); diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index e59e5d6a878..c9c4a67644e 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -561,87 +561,6 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure return GP_STROKEADD_INVALID; } -/* simplify a stroke (in buffer) before storing it - * - applies a reverse Chaikin filter - * - code adapted from etch-a-ton branch - */ -static void gp_stroke_simplify(tGPsdata *p) -{ - bGPdata *gpd = p->gpd; - tGPspoint *old_points = (tGPspoint *)gpd->runtime.sbuffer; - short num_points = gpd->runtime.sbuffer_used; - short flag = gpd->runtime.sbuffer_sflag; - short i, j; - - /* only simplify if simplification is enabled, and we're not doing a straight line */ - if (!(U.gp_settings & GP_PAINT_DOSIMPLIFY) || (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT)) { - return; - } - - /* don't simplify if less than 4 points in buffer */ - if ((num_points <= 4) || (old_points == NULL)) { - return; - } - - /* clear buffer (but don't free mem yet) so that we can write to it - * - firstly set sbuffer to NULL, so a new one is allocated - * - secondly, reset flag after, as it gets cleared auto - */ - gpd->runtime.sbuffer = NULL; - gp_session_validatebuffer(p); - gpd->runtime.sbuffer_sflag = flag; - -/* macro used in loop to get position of new point - * - used due to the mixture of datatypes in use here - */ -#define GP_SIMPLIFY_AVPOINT(offs, sfac) \ - { \ - co[0] += (float)(old_points[offs].x * sfac); \ - co[1] += (float)(old_points[offs].y * sfac); \ - pressure += old_points[offs].pressure * sfac; \ - time += old_points[offs].time * sfac; \ - } \ - (void)0 - - /* XXX Here too, do not lose start and end points! */ - gp_stroke_addpoint( - p, &old_points->x, old_points->pressure, p->inittime + (double)old_points->time); - for (i = 0, j = 0; i < num_points; i++) { - if (i - j == 3) { - float co[2], pressure, time; - float mco[2]; - - /* initialize values */ - co[0] = 0.0f; - co[1] = 0.0f; - pressure = 0.0f; - time = 0.0f; - - /* using macro, calculate new point */ - GP_SIMPLIFY_AVPOINT(j, -0.25f); - GP_SIMPLIFY_AVPOINT(j + 1, 0.75f); - GP_SIMPLIFY_AVPOINT(j + 2, 0.75f); - GP_SIMPLIFY_AVPOINT(j + 3, -0.25f); - - /* set values for adding */ - mco[0] = co[0]; - mco[1] = co[1]; - - /* ignore return values on this... assume to be ok for now */ - gp_stroke_addpoint(p, mco, pressure, p->inittime + (double)time); - - j += 2; - } - } - gp_stroke_addpoint(p, - &old_points[num_points - 1].x, - old_points[num_points - 1].pressure, - p->inittime + (double)old_points[num_points - 1].time); - - /* free old buffer */ - MEM_freeN(old_points); -} - /* make a new stroke from the buffer data */ static void gp_stroke_newfrombuffer(tGPsdata *p) { @@ -1466,9 +1385,6 @@ static void gp_paint_strokeend(tGPsdata *p) /* check if doing eraser or not */ if ((p->gpd->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0) { - /* simplify stroke before transferring? */ - gp_stroke_simplify(p); - /* transfer stroke to frame */ gp_stroke_newfrombuffer(p); } diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 0c2af982279..2b31af5ff1f 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -866,6 +866,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw) float tfill[4]; short sthickness; float ink[4]; + const bool is_unique = (tgpw->gps != NULL); GPU_program_point_size(true); @@ -1099,7 +1100,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw) } } /* if only one stroke, exit from loop */ - if (tgpw->gps) { + if (is_unique) { break; } } diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index 1a7422cd174..8e4d2655ef0 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -1283,7 +1283,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) /* Init multi-edit falloff curve data before doing anything, * so we won't have to do it again later. */ if (gso->is_multiframe) { - curvemapping_initialize(ts->gp_sculpt.cur_falloff); + BKE_curvemapping_initialize(ts->gp_sculpt.cur_falloff); } /* initialise custom data for brushes */ diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 277628f4363..f3ab0b45122 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -3847,6 +3847,54 @@ void GPENCIL_OT_stroke_simplify_fixed(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } +/* ** Resample stroke *** */ +static int gp_stroke_sample_exec(bContext *C, wmOperator *op) +{ + bGPdata *gpd = ED_gpencil_data_get_active(C); + const float length = RNA_float_get(op->ptr, "length"); + + /* sanity checks */ + if (ELEM(NULL, gpd)) { + return OPERATOR_CANCELLED; + } + + /* Go through each editable + selected stroke */ + GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) { + if (gps->flag & GP_STROKE_SELECT) { + BKE_gpencil_sample_stroke(gps, length, true); + } + } + GP_EDITABLE_STROKES_END(gpstroke_iter); + + /* notifiers */ + DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + + return OPERATOR_FINISHED; +} + +void GPENCIL_OT_stroke_sample(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name = "Sample Stroke"; + ot->idname = "GPENCIL_OT_stroke_sample"; + ot->description = "Sample stroke points to predefined segment length"; + + /* api callbacks */ + ot->exec = gp_stroke_sample_exec; + ot->poll = gp_active_layer_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + prop = RNA_def_float(ot->srna, "length", 0.1f, 0.0f, 100.0f, "Length", "", 0.0f, 100.0f); + /* avoid re-using last var */ + RNA_def_property_flag(prop, PROP_SKIP_SAVE); +} + /* ******************* Stroke trim ************************** */ static int gp_stroke_trim_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -4522,3 +4570,73 @@ bool ED_object_gpencil_exit(struct Main *bmain, Object *ob) } return ok; } + +/* ** merge by distance *** */ +static bool gp_merge_by_distance_poll(bContext *C) +{ + Object *ob = CTX_data_active_object(C); + if ((ob == NULL) || (ob->type != OB_GPENCIL)) { + return false; + } + bGPdata *gpd = (bGPdata *)ob->data; + if (gpd == NULL) { + return false; + } + + bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); + + return ((gpl != NULL) && (ob->mode == OB_MODE_EDIT_GPENCIL)); +} + +static int gp_merge_by_distance_exec(bContext *C, wmOperator *op) +{ + Object *ob = CTX_data_active_object(C); + bGPdata *gpd = (bGPdata *)ob->data; + const float threshold = RNA_float_get(op->ptr, "threshold"); + const bool unselected = RNA_boolean_get(op->ptr, "use_unselected"); + + /* sanity checks */ + if (ELEM(NULL, gpd)) { + return OPERATOR_CANCELLED; + } + + /* Go through each editable selected stroke */ + GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) { + if (gps->flag & GP_STROKE_SELECT) { + BKE_gpencil_merge_distance_stroke(gpf_, gps, threshold, unselected); + } + } + GP_EDITABLE_STROKES_END(gpstroke_iter); + + /* notifiers */ + DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + + return OPERATOR_FINISHED; +} + +void GPENCIL_OT_stroke_merge_by_distance(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name = "Merge by Distance"; + ot->idname = "GPENCIL_OT_stroke_merge_by_distance"; + ot->description = "Merge points by distance"; + + /* api callbacks */ + ot->exec = gp_merge_by_distance_exec; + ot->poll = gp_merge_by_distance_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + prop = RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, 100.0f, "Threshold", "", 0.0f, 100.0f); + /* avoid re-using last var */ + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + + prop = RNA_def_boolean( + ot->srna, "use_unselected", 0, "Unselected", "Use whole stroke, not only selected points"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); +} diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index 1c20da4bed3..2a608d44a0b 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -486,9 +486,11 @@ void GPENCIL_OT_stroke_simplify_fixed(struct wmOperatorType *ot); void GPENCIL_OT_stroke_separate(struct wmOperatorType *ot); void GPENCIL_OT_stroke_split(struct wmOperatorType *ot); void GPENCIL_OT_stroke_smooth(struct wmOperatorType *ot); +void GPENCIL_OT_stroke_sample(struct wmOperatorType *ot); void GPENCIL_OT_stroke_merge(struct wmOperatorType *ot); void GPENCIL_OT_stroke_cutter(struct wmOperatorType *ot); void GPENCIL_OT_stroke_trim(struct wmOperatorType *ot); +void GPENCIL_OT_stroke_merge_by_distance(struct wmOperatorType *ot); void GPENCIL_OT_brush_presets_create(struct wmOperatorType *ot); diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c index 698e508a2a5..86de9a75a56 100644 --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil/gpencil_interpolate.c @@ -1003,7 +1003,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op) if (ipo_settings->type == GP_IPO_CURVEMAP) { /* custom curvemap */ if (ipo_settings->custom_ipo) { - factor = curvemapping_evaluateF(ipo_settings->custom_ipo, 0, factor); + factor = BKE_curvemapping_evaluateF(ipo_settings->custom_ipo, 0, factor); } else { BKE_report(op->reports, RPT_ERROR, "Custom interpolation curve does not exist"); diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index a1645a5c67d..acdf5c2be4f 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -314,9 +314,11 @@ void ED_operatortypes_gpencil(void) WM_operatortype_append(GPENCIL_OT_stroke_separate); WM_operatortype_append(GPENCIL_OT_stroke_split); WM_operatortype_append(GPENCIL_OT_stroke_smooth); + WM_operatortype_append(GPENCIL_OT_stroke_sample); WM_operatortype_append(GPENCIL_OT_stroke_merge); WM_operatortype_append(GPENCIL_OT_stroke_cutter); WM_operatortype_append(GPENCIL_OT_stroke_trim); + WM_operatortype_append(GPENCIL_OT_stroke_merge_by_distance); WM_operatortype_append(GPENCIL_OT_brush_presets_create); diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index a271274fa71..06ff0e744b9 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -476,7 +476,7 @@ static void gp_brush_jitter(bGPdata *gpd, { float tmp_pressure = pressure; if (brush->gpencil_settings->draw_jitter > 0.0f) { - float curvef = curvemapping_evaluateF(brush->gpencil_settings->curve_jitter, 0, pressure); + float curvef = BKE_curvemapping_evaluateF(brush->gpencil_settings->curve_jitter, 0, pressure); tmp_pressure = curvef * brush->gpencil_settings->draw_sensitivity; } /* exponential value */ @@ -671,7 +671,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure /* store settings */ /* pressure */ if (brush->gpencil_settings->flag & GP_BRUSH_USE_PRESSURE) { - float curvef = curvemapping_evaluateF( + float curvef = BKE_curvemapping_evaluateF( brush->gpencil_settings->curve_sensitivity, 0, pressure); pt->pressure = curvef * brush->gpencil_settings->draw_sensitivity; } @@ -695,7 +695,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure /* apply randomness to pressure */ if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_RANDOM) && (brush->gpencil_settings->draw_random_press > 0.0f)) { - float curvef = curvemapping_evaluateF( + float curvef = BKE_curvemapping_evaluateF( brush->gpencil_settings->curve_sensitivity, 0, pressure); float tmp_pressure = curvef * brush->gpencil_settings->draw_sensitivity; if (BLI_rng_get_float(p->rng) > 0.5f) { @@ -731,7 +731,8 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure /* color strength */ if (brush->gpencil_settings->flag & GP_BRUSH_USE_STENGTH_PRESSURE) { - float curvef = curvemapping_evaluateF(brush->gpencil_settings->curve_strength, 0, pressure); + float curvef = BKE_curvemapping_evaluateF( + brush->gpencil_settings->curve_strength, 0, pressure); float tmp_pressure = curvef * brush->gpencil_settings->draw_sensitivity; pt->strength = tmp_pressure * brush->gpencil_settings->draw_strength; @@ -1809,9 +1810,9 @@ static void gp_init_drawing_brush(bContext *C, tGPsdata *p) changed = true; } /* be sure curves are initializated */ - curvemapping_initialize(paint->brush->gpencil_settings->curve_sensitivity); - curvemapping_initialize(paint->brush->gpencil_settings->curve_strength); - curvemapping_initialize(paint->brush->gpencil_settings->curve_jitter); + BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_sensitivity); + BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_strength); + BKE_curvemapping_initialize(paint->brush->gpencil_settings->curve_jitter); /* assign to temp tGPsdata */ p->brush = paint->brush; diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index 816517d6ef9..25913fe821a 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -704,13 +704,13 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) gp_session_validatebuffer(tgpi); gp_init_colors(tgpi); if (gset->flag & GP_SCULPT_SETT_FLAG_PRIMITIVE_CURVE) { - curvemapping_initialize(ts->gp_sculpt.cur_primitive); + BKE_curvemapping_initialize(ts->gp_sculpt.cur_primitive); } if (tgpi->brush->gpencil_settings->flag & GP_BRUSH_USE_JITTER_PRESSURE) { - curvemapping_initialize(tgpi->brush->gpencil_settings->curve_jitter); + BKE_curvemapping_initialize(tgpi->brush->gpencil_settings->curve_jitter); } if (tgpi->brush->gpencil_settings->flag & GP_BRUSH_USE_STENGTH_PRESSURE) { - curvemapping_initialize(tgpi->brush->gpencil_settings->curve_strength); + BKE_curvemapping_initialize(tgpi->brush->gpencil_settings->curve_strength); } /* get an array of depths, far depths are blended */ @@ -834,7 +834,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) /* normalize value to evaluate curve */ if (gset->flag & GP_SCULPT_SETT_FLAG_PRIMITIVE_CURVE) { float value = (float)i / (gps->totpoints - 1); - curve_pressure = curvemapping_evaluateF(gset->cur_primitive, 0, value); + curve_pressure = BKE_curvemapping_evaluateF(gset->cur_primitive, 0, value); pressure = curve_pressure; } @@ -844,7 +844,8 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) float jitter; if (brush->gpencil_settings->flag & GP_BRUSH_USE_JITTER_PRESSURE) { - jitter = curvemapping_evaluateF(brush->gpencil_settings->curve_jitter, 0, curve_pressure); + jitter = BKE_curvemapping_evaluateF( + brush->gpencil_settings->curve_jitter, 0, curve_pressure); jitter *= brush->gpencil_settings->draw_sensitivity; } else { @@ -890,7 +891,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) /* color strength */ if (brush->gpencil_settings->flag & GP_BRUSH_USE_STENGTH_PRESSURE) { - float curvef = curvemapping_evaluateF( + float curvef = BKE_curvemapping_evaluateF( brush->gpencil_settings->curve_strength, 0, curve_pressure); strength *= curvef * brush->gpencil_settings->draw_sensitivity; strength *= brush->gpencil_settings->draw_strength; diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index a475e43755c..2a0f16a4bbf 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -1396,13 +1396,13 @@ void ED_gpencil_add_defaults(bContext *C, Object *ob) /* ensure multiframe falloff curve */ if (ts->gp_sculpt.cur_falloff == NULL) { - ts->gp_sculpt.cur_falloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + ts->gp_sculpt.cur_falloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); CurveMapping *gp_falloff_curve = ts->gp_sculpt.cur_falloff; - curvemapping_initialize(gp_falloff_curve); - curvemap_reset(gp_falloff_curve->cm, - &gp_falloff_curve->clipr, - CURVE_PRESET_GAUSS, - CURVEMAP_SLOPE_POSITIVE); + BKE_curvemapping_initialize(gp_falloff_curve); + BKE_curvemap_reset(gp_falloff_curve->cm, + &gp_falloff_curve->clipr, + CURVE_PRESET_GAUSS, + CURVEMAP_SLOPE_POSITIVE); } } diff --git a/source/blender/editors/include/ED_select_buffer_utils.h b/source/blender/editors/include/ED_select_buffer_utils.h deleted file mode 100644 index af745cee676..00000000000 --- a/source/blender/editors/include/ED_select_buffer_utils.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - */ - -/** \file - * \ingroup editors - */ - -#ifndef __ED_SELECT_BUFFER_UTILS_H__ -#define __ED_SELECT_BUFFER_UTILS_H__ - -struct rcti; - -/* Boolean array from selection ID's. */ -uint *ED_select_buffer_bitmap_from_rect(const uint bitmap_len, const struct rcti *rect); -uint *ED_select_buffer_bitmap_from_circle(const uint bitmap_len, - const int center[2], - const int radius); -uint *ED_select_buffer_bitmap_from_poly(const uint bitmap_len, - const int poly[][2], - const int poly_len, - const rcti *rect); - -/* Single result from selection ID's. */ -uint ED_select_buffer_sample_point(const int center[2]); -uint ED_select_buffer_find_nearest_to_point(const int center[2], - const uint id_min, - const uint id_max, - uint *dist); - -#endif /* __ED_SELECT_BUFFER_UTILS_H__ */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index afdbbeedff4..67dfb184d19 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -465,9 +465,6 @@ int ED_view3d_backbuf_sample_size_clamp(struct ARegion *ar, const float dist); void ED_view3d_select_id_validate(struct ViewContext *vc); -uint *ED_view3d_select_id_read(int xmin, int ymin, int xmax, int ymax, uint *r_buf_len); -uint *ED_view3d_select_id_read_rect(const struct rcti *rect, uint *r_buf_len); - bool ED_view3d_autodist(struct Depsgraph *depsgraph, struct ARegion *ar, struct View3D *v3d, @@ -687,6 +684,9 @@ void ED_view3d_lock_clear(struct View3D *v3d); float ED_view3d_offset_distance(float mat[4][4], const float ofs[3], const float dist_fallback); void ED_view3d_distance_set(struct RegionView3D *rv3d, const float dist); +bool ED_view3d_distance_set_from_location(struct RegionView3D *rv3d, + const float dist_co[3], + const float dist_min); float ED_scene_grid_scale(struct Scene *scene, const char **grid_unit); float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char **grid_unit); diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h index 1f15fa3bd4d..db8afccbe2d 100644 --- a/source/blender/editors/include/UI_interface_icons.h +++ b/source/blender/editors/include/UI_interface_icons.h @@ -75,7 +75,7 @@ void UI_icon_draw_ex(float x, float aspect, float alpha, float desaturate, - const char mono_color[4], + const uchar mono_color[4], const bool mono_border); void UI_icon_draw_desaturate(float x, diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 6a36bf364a3..76630de96db 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1736,7 +1736,7 @@ void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rec /* backdrop */ UI_draw_roundbox_corner_set(UI_CNR_ALL); UI_draw_roundbox_3ubAlpha( - true, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f, (uchar *)wcol->inner, 255); + true, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f, wcol->inner, 255); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); @@ -1771,7 +1771,7 @@ void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rec GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor3ubv((uchar *)wcol->inner); + immUniformColor3ubv(wcol->inner); GPU_blend(true); GPU_line_smooth(true); @@ -1831,7 +1831,7 @@ static void gl_shaded_color_get_fl(const uchar *color, int shade, float r_color[ rgb_uchar_to_float(r_color, color_shaded); } -static void gl_shaded_color(uchar *color, int shade) +static void gl_shaded_color(const uchar *color, int shade) { uchar color_shaded[3]; gl_shaded_color_get(color, shade, color_shaded); @@ -1914,10 +1914,10 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons } else { if (cumap->flag & CUMA_DO_CLIP) { - gl_shaded_color_get_fl((uchar *)wcol->inner, -20, color_backdrop); + gl_shaded_color_get_fl(wcol->inner, -20, color_backdrop); immUniformColor3fv(color_backdrop); immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); - immUniformColor3ubv((uchar *)wcol->inner); + immUniformColor3ubv(wcol->inner); immRectf(pos, rect->xmin + zoomx * (cumap->clipr.xmin - offsx), rect->ymin + zoomy * (cumap->clipr.ymin - offsy), @@ -1925,19 +1925,19 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons rect->ymin + zoomy * (cumap->clipr.ymax - offsy)); } else { - rgb_uchar_to_float(color_backdrop, (const uchar *)wcol->inner); + rgb_uchar_to_float(color_backdrop, wcol->inner); immUniformColor3fv(color_backdrop); immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); } /* grid, every 0.25 step */ - gl_shaded_color((uchar *)wcol->inner, -16); + gl_shaded_color(wcol->inner, -16); ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 0.25f); /* grid, every 1.0 step */ - gl_shaded_color((uchar *)wcol->inner, -24); + gl_shaded_color(wcol->inner, -24); ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 1.0f); /* axes */ - gl_shaded_color((uchar *)wcol->inner, -50); + gl_shaded_color(wcol->inner, -50); immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, rect->xmin, rect->ymin + zoomy * (-offsy)); immVertex2f(pos, rect->xmax, rect->ymin + zoomy * (-offsy)); @@ -1997,7 +1997,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons immUnbindProgram(); if (cuma->table == NULL) { - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); } CurveMapPoint *cmp = cuma->table; @@ -2026,7 +2026,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons GPU_blend(true); /* Curve filled. */ - immUniformColor3ubvAlpha((uchar *)wcol->item, 128); + immUniformColor3ubvAlpha(wcol->item, 128); GPU_polygon_smooth(true); immBegin(GPU_PRIM_TRI_STRIP, (CM_TABLE * 2 + 2) + 4); immVertex2f(pos, line_range.xmin, rect->ymin); @@ -2044,7 +2044,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons /* Curve line. */ GPU_line_width(1.0f); - immUniformColor3ubvAlpha((uchar *)wcol->item, 255); + immUniformColor3ubvAlpha(wcol->item, 255); GPU_line_smooth(true); immBegin(GPU_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2); immVertex2f(pos, line_range.xmin, line_range.ymin); @@ -2099,7 +2099,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor3ubv((uchar *)wcol->outline); + immUniformColor3ubv(wcol->outline); imm_draw_box_wire_2d(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); immUnbindProgram(); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 245277c8d22..52933a89045 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2386,8 +2386,8 @@ static void ui_but_copy_curvemapping(uiBut *but) { if (but->poin != NULL) { but_copypaste_curve_alive = true; - curvemapping_free_data(&but_copypaste_curve); - curvemapping_copy_data(&but_copypaste_curve, (CurveMapping *)but->poin); + BKE_curvemapping_free_data(&but_copypaste_curve); + BKE_curvemapping_copy_data(&but_copypaste_curve, (CurveMapping *)but->poin); } } @@ -2399,8 +2399,8 @@ static void ui_but_paste_curvemapping(bContext *C, uiBut *but) } button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); - curvemapping_free_data((CurveMapping *)but->poin); - curvemapping_copy_data((CurveMapping *)but->poin, &but_copypaste_curve); + BKE_curvemapping_free_data((CurveMapping *)but->poin); + BKE_curvemapping_copy_data((CurveMapping *)but->poin, &but_copypaste_curve); button_activate_state(C, but, BUTTON_STATE_EXIT); } } @@ -2588,7 +2588,7 @@ static void ui_but_paste(bContext *C, uiBut *but, uiHandleButtonData *data, cons void ui_but_clipboard_free(void) { - curvemapping_free_data(&but_copypaste_curve); + BKE_curvemapping_free_data(&but_copypaste_curve); } /** \} */ @@ -6479,7 +6479,7 @@ static bool ui_numedit_but_CURVE(uiBlock *block, } } - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); if (moved_point) { data->draglastx = evtx; @@ -6559,8 +6559,8 @@ static int ui_do_but_CURVE( float f_xy[2]; BLI_rctf_transform_pt_v(&cumap->curr, &but->rect, f_xy, m_xy); - curvemap_insert(cuma, f_xy[0], f_xy[1]); - curvemapping_changed(cumap, false); + BKE_curvemap_insert(cuma, f_xy[0], f_xy[1]); + BKE_curvemapping_changed(cumap, false); changed = true; } @@ -6597,8 +6597,8 @@ static int ui_do_but_CURVE( if (dist_squared_to_line_segment_v2(m_xy, f_xy_prev, f_xy) < dist_min_sq) { BLI_rctf_transform_pt_v(&cumap->curr, &but->rect, f_xy, m_xy); - curvemap_insert(cuma, f_xy[0], f_xy[1]); - curvemapping_changed(cumap, false); + BKE_curvemap_insert(cuma, f_xy[0], f_xy[1]); + BKE_curvemapping_changed(cumap, false); changed = true; @@ -6672,7 +6672,7 @@ static int ui_do_but_CURVE( } } else { - curvemapping_changed(cumap, true); /* remove doubles */ + BKE_curvemapping_changed(cumap, true); /* remove doubles */ BKE_paint_invalidate_cursor_overlay(scene, view_layer, cumap); } } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 7584a43a790..e9aa18394fa 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -403,7 +403,7 @@ static void vicon_handletype_auto_clamp_draw(int x, int y, int w, int h, float a static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNUSED(alpha)) { bTheme *btheme = UI_GetTheme(); - ThemeWireColor *cs = &btheme->tarm[index]; + const ThemeWireColor *cs = &btheme->tarm[index]; /* Draw three bands of color: One per color * x-----a-----b-----c @@ -420,15 +420,15 @@ static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNU /* XXX: Include alpha into this... */ /* normal */ - immUniformColor3ubv((uchar *)cs->solid); + immUniformColor3ubv(cs->solid); immRecti(pos, x, y, a, y + h); /* selected */ - immUniformColor3ubv((uchar *)cs->select); + immUniformColor3ubv(cs->select); immRecti(pos, a, y, b, y + h); /* active */ - immUniformColor3ubv((uchar *)cs->active); + immUniformColor3ubv(cs->active); immRecti(pos, b, y, c, y + h); immUnbindProgram(); @@ -1782,7 +1782,7 @@ static void icon_draw_size(float x, enum eIconSizes size, int draw_size, const float desaturate, - const char mono_rgba[4], + const uchar mono_rgba[4], const bool mono_border) { bTheme *btheme = UI_GetTheme(); @@ -2270,7 +2270,7 @@ void UI_icon_draw_ex(float x, float aspect, float alpha, float desaturate, - const char mono_color[4], + const uchar mono_color[4], const bool mono_border) { int draw_size = get_draw_size(ICON_SIZE_ICON); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 215b0c3c410..8adb82a22c8 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -721,7 +721,7 @@ void ui_draw_aligned_panel(uiStyle *style, (block->aspect * U.inv_dpi_fac), 1.0f, 0.0f, - (const char *)col_title, + col_title, false); GPU_blend(false); } diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index f10702f3f3b..6aad9e41e7d 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -174,10 +174,10 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar) ui_draw_tooltip_background(UI_style_get(), NULL, &bbox); /* set background_color */ - rgb_uchar_to_float(background_color, (const uchar *)theme->inner); + rgb_uchar_to_float(background_color, theme->inner); /* calculate normal_color */ - rgb_uchar_to_float(main_color, (const uchar *)theme->text); + rgb_uchar_to_float(main_color, theme->text); copy_v3_v3(active_color, main_color); copy_v3_v3(normal_color, main_color); copy_v3_v3(python_color, main_color); @@ -396,11 +396,23 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is else { /* Note, this is an exceptional case, we could even remove it * however there have been reports of tooltips failing, so keep it for now. */ - expr_result = BLI_strdup("Internal error!"); + expr_result = BLI_strdup(IFACE_("Internal error!")); is_error = true; } if (expr_result != NULL) { + /* NOTE: This is a very weak hack to get a valid translation most of the time... + * Proper way to do would be to get i18n context from the item, somehow. */ + const char *label_str = CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, expr_result); + if (label_str == expr_result) { + label_str = IFACE_(expr_result); + } + + if (label_str != expr_result) { + MEM_freeN(expr_result); + expr_result = BLI_strdup(label_str); + } + uiTooltipField *field = text_field_add(data, &(uiTooltipFormat){ .style = UI_TIP_STYLE_NORMAL, @@ -437,7 +449,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is else { /* Note, this is an exceptional case, we could even remove it * however there have been reports of tooltips failing, so keep it for now. */ - expr_result = BLI_strdup("Internal error!"); + expr_result = BLI_strdup(TIP_("Internal error!")); is_error = true; } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index fb8c2f59748..37eb1770f68 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -3723,15 +3723,15 @@ static void curvemap_buttons_setclip(bContext *UNUSED(C), void *cumap_v, void *U { CurveMapping *cumap = cumap_v; - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); } static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v) { CurveMapping *cumap = cumap_v; - curvemap_remove(cumap->cm + cumap->cur, SELECT); - curvemapping_changed(cumap, false); + BKE_curvemap_remove(cumap->cm + cumap->cur, SELECT); + BKE_curvemapping_changed(cumap, false); rna_update_cb(C, cb_v, NULL); } @@ -3829,7 +3829,7 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *ar, void *cumap_v) return block; } -/* only for curvemap_tools_dofunc */ +/* only for BKE_curvemap_tools_dofunc */ enum { UICURVE_FUNC_RESET_NEG, UICURVE_FUNC_RESET_POS, @@ -3849,35 +3849,35 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) switch (event) { case UICURVE_FUNC_RESET_NEG: case UICURVE_FUNC_RESET_POS: /* reset */ - curvemap_reset(cuma, - &cumap->clipr, - cumap->preset, - (event == UICURVE_FUNC_RESET_NEG) ? CURVEMAP_SLOPE_NEGATIVE : - CURVEMAP_SLOPE_POSITIVE); - curvemapping_changed(cumap, false); + BKE_curvemap_reset(cuma, + &cumap->clipr, + cumap->preset, + (event == UICURVE_FUNC_RESET_NEG) ? CURVEMAP_SLOPE_NEGATIVE : + CURVEMAP_SLOPE_POSITIVE); + BKE_curvemapping_changed(cumap, false); break; case UICURVE_FUNC_RESET_VIEW: cumap->curr = cumap->clipr; break; case UICURVE_FUNC_HANDLE_VECTOR: /* set vector */ - curvemap_handle_set(cuma, HD_VECT); - curvemapping_changed(cumap, false); + BKE_curvemap_handle_set(cuma, HD_VECT); + BKE_curvemapping_changed(cumap, false); break; case UICURVE_FUNC_HANDLE_AUTO: /* set auto */ - curvemap_handle_set(cuma, HD_AUTO); - curvemapping_changed(cumap, false); + BKE_curvemap_handle_set(cuma, HD_AUTO); + BKE_curvemapping_changed(cumap, false); break; case UICURVE_FUNC_HANDLE_AUTO_ANIM: /* set auto-clamped */ - curvemap_handle_set(cuma, HD_AUTO_ANIM); - curvemapping_changed(cumap, false); + BKE_curvemap_handle_set(cuma, HD_AUTO_ANIM); + BKE_curvemapping_changed(cumap, false); break; case UICURVE_FUNC_EXTEND_HOZ: /* extend horiz */ cuma->flag &= ~CUMA_EXTEND_EXTRAPOLATE; - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); break; case UICURVE_FUNC_EXTEND_EXP: /* extend extrapolate */ cuma->flag |= CUMA_EXTEND_EXTRAPOLATE; - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); break; } ED_undo_push(C, "CurveMap tools"); @@ -4041,7 +4041,7 @@ static void curvemap_buttons_redraw(bContext *C, void *UNUSED(arg1), void *UNUSE static void curvemap_buttons_update(bContext *C, void *arg1_v, void *cumap_v) { CurveMapping *cumap = cumap_v; - curvemapping_changed(cumap, true); + BKE_curvemapping_changed(cumap, true); rna_update_cb(C, arg1_v, NULL); } @@ -4052,14 +4052,14 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v) cumap->preset = CURVE_PRESET_LINE; for (a = 0; a < CM_TOT; a++) { - curvemap_reset(cumap->cm + a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); + BKE_curvemap_reset(cumap->cm + a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); } cumap->black[0] = cumap->black[1] = cumap->black[2] = 0.0f; cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f; - curvemapping_set_black_white(cumap, NULL, NULL); + BKE_curvemapping_set_black_white(cumap, NULL, NULL); - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); rna_update_cb(C, cb_v, NULL); } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 55ec10b03dc..9c4d628cec5 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1135,7 +1135,7 @@ static void shape_preset_trias_from_rect_checkmark(uiWidgetTrias *tria, const rc /* prepares shade colors */ static void shadecolors4( - char coltop[4], char coldown[4], const char *color, short shadetop, short shadedown) + uchar coltop[4], uchar coldown[4], const uchar *color, short shadetop, short shadedown) { coltop[0] = CLAMPIS(color[0] + shadetop, 0, 255); coltop[1] = CLAMPIS(color[1] + shadetop, 0, 255); @@ -1149,8 +1149,8 @@ static void shadecolors4( } static void round_box_shade_col4_r(uchar r_col[4], - const char col1[4], - const char col2[4], + const uchar col1[4], + const uchar col2[4], const float fac) { const int faci = unit_float_to_uchar_clamp(fac); @@ -1352,15 +1352,14 @@ static void widgetbase_draw_ex(uiWidgetBase *wtb, if (wtb->draw_inner) { if (wcol->shaded == 0) { /* simple fill */ - inner_col1[0] = inner_col2[0] = (uchar)wcol->inner[0]; - inner_col1[1] = inner_col2[1] = (uchar)wcol->inner[1]; - inner_col1[2] = inner_col2[2] = (uchar)wcol->inner[2]; - inner_col1[3] = inner_col2[3] = (uchar)wcol->inner[3]; + inner_col1[0] = inner_col2[0] = wcol->inner[0]; + inner_col1[1] = inner_col2[1] = wcol->inner[1]; + inner_col1[2] = inner_col2[2] = wcol->inner[2]; + inner_col1[3] = inner_col2[3] = wcol->inner[3]; } else { /* gradient fill */ - shadecolors4( - (char *)inner_col1, (char *)inner_col2, wcol->inner, wcol->shadetop, wcol->shadedown); + shadecolors4(inner_col1, inner_col2, wcol->inner, wcol->shadetop, wcol->shadedown); } } @@ -1436,7 +1435,7 @@ static int ui_but_draw_menu_icon(const uiBut *but) /* icons have been standardized... and this call draws in untransformed coordinates */ static void widget_draw_icon( - const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, const char mono_color[4]) + const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, const uchar mono_color[4]) { float xs = 0.0f, ys = 0.0f; float aspect, height; @@ -1510,8 +1509,8 @@ static void widget_draw_icon( } /* Get theme color. */ - char color[4] = {mono_color[0], mono_color[1], mono_color[2], mono_color[3]}; - bool has_theme = UI_icon_get_theme_color(icon, (uchar *)color); + uchar color[4] = {mono_color[0], mono_color[1], mono_color[2], mono_color[3]}; + bool has_theme = UI_icon_get_theme_color(icon, color); /* to indicate draggable */ if (but->dragpoin && (but->flag & UI_ACTIVE)) { @@ -1548,7 +1547,7 @@ static void widget_draw_submenu_tria(const uiBut *but, float col[4]; rctf tria_rect; - rgba_uchar_to_float(col, (const uchar *)wcol->text); + rgba_uchar_to_float(col, wcol->text); col[3] *= 0.8f; BLI_rctf_init(&tria_rect, xs, xs + tria_width, ys, ys + tria_height); @@ -2099,7 +2098,7 @@ static void widget_draw_text(const uiFontStyle *fstyle, immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor4ubv((uchar *)wcol->item); + immUniformColor4ubv(wcol->item); immRecti(pos, rect->xmin + selsta_draw, rect->ymin + 2, @@ -2214,7 +2213,7 @@ static void widget_draw_text(const uiFontStyle *fstyle, UI_fontstyle_draw_ex(fstyle, rect, drawstr + but->ofs, - (uchar *)wcol->text, + wcol->text, &(struct uiFontStyleDraw_Params){ .align = align, }, @@ -2250,7 +2249,7 @@ static void widget_draw_text(const uiFontStyle *fstyle, rect->xmin + font_xofs + ul_advance, rect->ymin + font_yofs, 0.0f); - BLF_color4ubv(fstyle->uifont_id, (uchar *)wcol->text); + BLF_color4ubv(fstyle->uifont_id, wcol->text); BLF_draw(fstyle->uifont_id, "_", 2); if (fstyle->kerning == 1) { @@ -2263,8 +2262,8 @@ static void widget_draw_text(const uiFontStyle *fstyle, /* part text right aligned */ if (drawstr_right) { - char col[4]; - copy_v4_v4_char(col, wcol->text); + uchar col[4]; + copy_v4_v4_uchar(col, wcol->text); if (but->drawflag & UI_BUT_HAS_SHORTCUT) { col[3] *= 0.5f; } @@ -2273,7 +2272,7 @@ static void widget_draw_text(const uiFontStyle *fstyle, UI_fontstyle_draw(fstyle, rect, drawstr_right, - (const uchar *)col, + col, &(struct uiFontStyleDraw_Params){ .align = UI_STYLE_TEXT_RIGHT, }); @@ -2476,7 +2475,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, /* ************ button callbacks, state ***************** */ -static void widget_state_blend(char cp[3], const char cpstate[3], const float fac) +static void widget_state_blend(uchar cp[3], const uchar cpstate[3], const float fac) { if (fac != 0.0f) { cp[0] = (int)((1.0f - fac) * cp[0] + fac * cpstate[0]); @@ -2502,18 +2501,18 @@ static void ui_widget_color_disabled(uiWidgetType *wt) wt->wcol_theme = &wcol_theme_s; } -static void rgb_tint(char cp[3], int tint) +static void rgb_tint(uchar cp[3], int tint) { cp[0] = clamp_i(cp[0] + tint, 0, 255); cp[1] = clamp_i(cp[1] + tint, 0, 255); cp[2] = clamp_i(cp[2] + tint, 0, 255); } -static void rgb_ensure_contrast(char cp[3], const char cp_other[3], int contrast) +static void rgb_ensure_contrast(uchar cp[3], const uchar cp_other[3], int contrast) { BLI_assert(contrast > 0); - const int item_value = rgb_to_grayscale_byte((const uchar *)cp); - const int inner_value = rgb_to_grayscale_byte((const uchar *)cp_other); + const int item_value = rgb_to_grayscale_byte(cp); + const int inner_value = rgb_to_grayscale_byte(cp_other); const int delta = item_value - inner_value; if (delta >= 0) { if (contrast > delta) { @@ -2527,16 +2526,16 @@ static void rgb_ensure_contrast(char cp[3], const char cp_other[3], int contrast } } -static void widget_active_color(char cp[3]) +static void widget_active_color(uchar cp[3]) { cp[0] = cp[0] >= 240 ? 255 : cp[0] + 15; cp[1] = cp[1] >= 240 ? 255 : cp[1] + 15; cp[2] = cp[2] >= 240 ? 255 : cp[2] + 15; } -static const char *widget_color_blend_from_flags(const uiWidgetStateColors *wcol_state, - int state, - int drawflag) +static const uchar *widget_color_blend_from_flags(const uiWidgetStateColors *wcol_state, + int state, + int drawflag) { if (drawflag & UI_BUT_ANIMATED_CHANGED) { return wcol_state->inner_changed_sel; @@ -2573,15 +2572,15 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag) wt->wcol = *(wt->wcol_theme); - const char *color_blend = widget_color_blend_from_flags(wcol_state, state, drawflag); + const uchar *color_blend = widget_color_blend_from_flags(wcol_state, state, drawflag); if (state & UI_SELECT) { - copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); if (color_blend != NULL) { widget_state_blend(wt->wcol.inner, color_blend, wcol_state->blend); } - copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); + copy_v3_v3_uchar(wt->wcol.text, wt->wcol.text_sel); if (state & UI_SELECT) { SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown); @@ -2598,7 +2597,7 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag) } if (state & UI_BUT_REDALERT) { - char red[4] = {255, 0, 0}; + uchar red[4] = {255, 0, 0}; if (wt->draw) { widget_state_blend(wt->wcol.inner, red, 0.4f); } @@ -2609,13 +2608,13 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag) if (state & UI_BUT_DRAG_MULTI) { /* the button isn't SELECT but we're editing this so draw with sel color */ - copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown); widget_state_blend(wt->wcol.text, wt->wcol.text_sel, 0.85f); } if (state & UI_BUT_NODE_ACTIVE) { - char blue[4] = {86, 128, 194}; + uchar blue[4] = {86, 128, 194}; widget_state_blend(wt->wcol.inner, blue, 0.3f); } } @@ -2628,13 +2627,12 @@ static void widget_state_numslider(uiWidgetType *wt, int state, int drawflag) /* call this for option button */ widget_state(wt, state, drawflag); - const char *color_blend = widget_color_blend_from_flags(wcol_state, state, drawflag); + const uchar *color_blend = widget_color_blend_from_flags(wcol_state, state, drawflag); if (color_blend != NULL) { /* Set the slider 'item' so that it reflects state settings too. * De-saturate so the color of the slider doesn't conflict with the blend color, * which can make the color hard to see when the slider is set to full (see T66102). */ - wt->wcol.item[0] = wt->wcol.item[1] = wt->wcol.item[2] = rgb_to_grayscale_byte( - (const uchar *)wt->wcol.item); + wt->wcol.item[0] = wt->wcol.item[1] = wt->wcol.item[2] = rgb_to_grayscale_byte(wt->wcol.item); widget_state_blend(wt->wcol.item, color_blend, wcol_state->blend); rgb_ensure_contrast(wt->wcol.item, wt->wcol.inner, 30); } @@ -2654,10 +2652,10 @@ static void widget_state_option_menu(uiWidgetType *wt, int state, int drawflag) /* if not selected we get theme from menu back */ if (state & UI_SELECT) { - copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text_sel); + copy_v3_v3_uchar(wt->wcol.text, btheme->tui.wcol_menu_back.text_sel); } else { - copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text); + copy_v3_v3_uchar(wt->wcol.text, btheme->tui.wcol_menu_back.text); } } @@ -2682,13 +2680,13 @@ static void widget_state_pie_menu_item(uiWidgetType *wt, int state, int UNUSED(d widget_state_blend(wt->wcol.text, wt->wcol.text_sel, 0.5f); /* draw the backdrop at low alpha, helps navigating with keys * when disabled items are active */ - copy_v4_v4_char(wt->wcol.inner, wt->wcol.item); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.item); wt->wcol.inner[3] = 64; } else { /* regular active */ if (state & (UI_SELECT | UI_ACTIVE)) { - copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); + copy_v3_v3_uchar(wt->wcol.text, wt->wcol.text_sel); } else if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { /* regular disabled */ @@ -2696,10 +2694,10 @@ static void widget_state_pie_menu_item(uiWidgetType *wt, int state, int UNUSED(d } if (state & UI_SELECT) { - copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); } else if (state & UI_ACTIVE) { - copy_v4_v4_char(wt->wcol.inner, wt->wcol.item); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.item); } } } @@ -2714,13 +2712,13 @@ static void widget_state_menu_item(uiWidgetType *wt, int state, int UNUSED(drawf widget_state_blend(wt->wcol.text, wt->wcol.text_sel, 0.5f); /* draw the backdrop at low alpha, helps navigating with keys * when disabled items are active */ - copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); wt->wcol.inner[3] = 64; } else { /* regular active */ if (state & UI_ACTIVE) { - copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); + copy_v3_v3_uchar(wt->wcol.text, wt->wcol.text_sel); } else if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { /* regular disabled */ @@ -2728,7 +2726,7 @@ static void widget_state_menu_item(uiWidgetType *wt, int state, int UNUSED(drawf } if (state & UI_ACTIVE) { - copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); } } } @@ -2965,7 +2963,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const GPU_blend(true); GPU_line_smooth(true); - immUniformColor3ubv((uchar *)wcol->outline); + immUniformColor3ubv(wcol->outline); imm_draw_circle_wire_2d(pos, centx, centy, radius, tot); immUnbindProgram(); @@ -3347,7 +3345,7 @@ static void widget_numbut_draw( wtb_zone.draw_emboss = false; wcol_zone = *wcol; - copy_v3_v3_char(wcol_zone.item, wcol->text); + copy_v3_v3_uchar(wcol_zone.item, wcol->text); if (state & UI_STATE_ACTIVE_LEFT) { widget_active_color(wcol_zone.inner); } @@ -3367,7 +3365,7 @@ static void widget_numbut_draw( wtb_zone.tria1.type = ROUNDBOX_TRIA_ARROWS; wcol_zone = *wcol; - copy_v3_v3_char(wcol_zone.item, wcol->text); + copy_v3_v3_uchar(wcol_zone.item, wcol->text); if (state & UI_STATE_ACTIVE_RIGHT) { widget_active_color(wcol_zone.inner); } @@ -3386,7 +3384,7 @@ static void widget_numbut_draw( wtb_zone.draw_emboss = false; wcol_zone = *wcol; - copy_v3_v3_char(wcol_zone.item, wcol->text); + copy_v3_v3_uchar(wcol_zone.item, wcol->text); if (!(state & (UI_STATE_ACTIVE_LEFT | UI_STATE_ACTIVE_RIGHT))) { widget_active_color(wcol_zone.inner); } @@ -3466,7 +3464,7 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s else { SWAP(short, wcol->shadetop, wcol->shadedown); - copy_v4_v4_char(wcol->inner, wcol->item); + copy_v4_v4_uchar(wcol->inner, wcol->item); if (wcol->shadetop > wcol->shadedown) { wcol->shadetop += 20; /* XXX violates themes... */ @@ -3613,7 +3611,7 @@ static void widget_progressbar( widgetbase_draw(&wtb, wcol); /* "slider" bar color */ - copy_v3_v3_char(wcol->inner, wcol->item); + copy_v3_v3_uchar(wcol->inner, wcol->item); widgetbase_draw(&wtb_bar, wcol); /* raise text a bit */ @@ -3626,12 +3624,12 @@ static void widget_nodesocket( { uiWidgetBase wtb; int radi = 5; - char old_inner[3], old_outline[3]; + uchar old_inner[3], old_outline[3]; widget_init(&wtb); - copy_v3_v3_char(old_inner, wcol->inner); - copy_v3_v3_char(old_outline, wcol->outline); + copy_v3_v3_uchar(old_inner, wcol->inner); + copy_v3_v3_uchar(old_outline, wcol->outline); wcol->inner[0] = but->col[0]; wcol->inner[1] = but->col[1]; @@ -3652,8 +3650,8 @@ static void widget_nodesocket( round_box_edges(&wtb, UI_CNR_ALL, rect, (float)radi); widgetbase_draw(&wtb, wcol); - copy_v3_v3_char(wcol->inner, old_inner); - copy_v3_v3_char(wcol->outline, old_outline); + copy_v3_v3_uchar(wcol->inner, old_inner); + copy_v3_v3_uchar(wcol->outline, old_outline); } static void widget_numslider( @@ -3662,7 +3660,7 @@ static void widget_numslider( uiWidgetBase wtb, wtb1; rcti rect1; float offs, toffs; - char outline[3]; + uchar outline[3]; widget_init(&wtb); widget_init(&wtb1); @@ -3679,9 +3677,9 @@ static void widget_numslider( if (!(state & UI_STATE_TEXT_INPUT)) { int roundboxalign_slider = roundboxalign; - copy_v3_v3_char(outline, wcol->outline); - copy_v3_v3_char(wcol->outline, wcol->item); - copy_v3_v3_char(wcol->inner, wcol->item); + copy_v3_v3_uchar(outline, wcol->outline); + copy_v3_v3_uchar(wcol->outline, wcol->item); + copy_v3_v3_uchar(wcol->inner, wcol->item); if (!(state & UI_SELECT)) { SWAP(short, wcol->shadetop, wcol->shadedown); @@ -3723,7 +3721,7 @@ static void widget_numslider( widgetbase_set_uniform_discard_factor(&wtb1, factor_discard); widgetbase_draw(&wtb1, wcol); - copy_v3_v3_char(wcol->outline, outline); + copy_v3_v3_uchar(wcol->outline, outline); if (!(state & UI_SELECT)) { SWAP(short, wcol->shadetop, wcol->shadedown); @@ -3788,7 +3786,7 @@ static void widget_swatch( ui_block_cm_to_display_space_v3(but->block, col); } - rgba_float_to_uchar((uchar *)wcol->inner, col); + rgba_float_to_uchar(wcol->inner, col); const bool show_alpha_checkers = (wcol->inner[3] < 255); wcol->shaded = 0; @@ -3923,9 +3921,9 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int const float rad = wcol->roundness * U.widget_unit; if (state & UI_ACTIVE) { - copy_v4_v4_char(wcol->inner, wcol->inner_sel); - copy_v3_v3_char(wcol->text, wcol->text_sel); - copy_v3_v3_char(wcol->outline, wcol->inner); + copy_v4_v4_uchar(wcol->inner, wcol->inner_sel); + copy_v3_v3_uchar(wcol->text, wcol->text_sel); + copy_v3_v3_uchar(wcol->outline, wcol->inner); } else { wcol->inner[3] *= 1.0f - back[3]; @@ -4061,15 +4059,15 @@ static void widget_state_label(uiWidgetType *wt, int state, int drawflag) /* call this for option button */ widget_state(wt, state, drawflag); if (state & UI_SELECT) { - UI_GetThemeColor3ubv(TH_TEXT_HI, (uchar *)wt->wcol.text); + UI_GetThemeColor3ubv(TH_TEXT_HI, wt->wcol.text); } else { - UI_GetThemeColor3ubv(TH_TEXT, (uchar *)wt->wcol.text); + UI_GetThemeColor3ubv(TH_TEXT, wt->wcol.text); } } if (state & UI_BUT_REDALERT) { - char red[4] = {255, 0, 0}; + uchar red[4] = {255, 0, 0}; widget_state_blend(wt->wcol.text, red, 0.4f); } } @@ -4092,11 +4090,11 @@ static void widget_box( { uiWidgetBase wtb; float rad; - char old_col[3]; + uchar old_col[3]; widget_init(&wtb); - copy_v3_v3_char(old_col, wcol->inner); + copy_v3_v3_uchar(old_col, wcol->inner); /* abuse but->hsv - if it's non-zero, use this color as the box's background */ if (but->col[3]) { @@ -4111,7 +4109,7 @@ static void widget_box( widgetbase_draw(&wtb, wcol); - copy_v3_v3_char(wcol->inner, old_col); + copy_v3_v3_uchar(wcol->inner, old_col); } static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) @@ -4175,12 +4173,10 @@ static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundbox #ifdef USE_TAB_SHADED_HIGHLIGHT /* create outline highlight colors */ if (is_active) { - interp_v3_v3v3_uchar( - theme_col_tab_highlight, (uchar *)wcol->inner_sel, (uchar *)wcol->outline, 0.2f); + interp_v3_v3v3_uchar(theme_col_tab_highlight, wcol->inner_sel, wcol->outline, 0.2f); } else { - interp_v3_v3v3_uchar( - theme_col_tab_highlight, (uchar *)wcol->inner, (uchar *)wcol->outline, 0.12f); + interp_v3_v3v3_uchar(theme_col_tab_highlight, wcol->inner, wcol->outline, 0.12f); } #endif @@ -4202,7 +4198,7 @@ static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundbox #ifdef USE_TAB_SHADED_HIGHLIGHT /* draw outline (3d look) */ - ui_draw_but_TAB_outline(rect, rad, theme_col_tab_highlight, (uchar *)wcol->inner); + ui_draw_but_TAB_outline(rect, rad, theme_col_tab_highlight, wcol->inner); #endif #ifndef USE_TAB_SHADED_HIGHLIGHT @@ -4819,7 +4815,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct uiWidgetType wt_back = *wt; uiWidgetType *wt_temp = widget_type(UI_WTYPE_MENU_ITEM); wt_temp->state(wt_temp, state, drawflag); - copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); wt->wcol.inner[3] = 128; wt->wcol.roundness = 0.5f; ui_draw_roundbox(&rect_orig, @@ -4845,7 +4841,7 @@ static void ui_draw_clip_tri(uiBlock *block, rcti *rect, uiWidgetType *wt) { if (block) { float draw_color[4]; - uchar *color = (uchar *)wt->wcol.text; + const uchar *color = wt->wcol.text; draw_color[0] = ((float)color[0]) / 255.0f; draw_color[1] = ((float)color[1]) / 255.0f; @@ -4913,7 +4909,7 @@ static void ui_draw_popover_back_impl(const uiWidgetColors *wcol, if (ELEM(direction, UI_DIR_UP, UI_DIR_DOWN)) { uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor4ubv((uchar *)wcol->inner); + immUniformColor4ubv(wcol->inner); GPU_blend(true); immBegin(GPU_PRIM_TRIS, 3); if (direction == UI_DIR_DOWN) { @@ -4958,8 +4954,8 @@ static void draw_disk_shaded(float start, float radius_int, float radius_ext, int subd, - const char col1[4], - const char col2[4], + const uchar col1[4], + const uchar col2[4], bool shaded) { const float radius_ext_scale = (0.5f / radius_ext); /* 1 / (2 * radius_ext) */ @@ -4979,7 +4975,7 @@ static void draw_disk_shaded(float start, } else { immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor4ubv((uchar *)col1); + immUniformColor4ubv(col1); } immBegin(GPU_PRIM_TRI_STRIP, subd * 2); @@ -5032,7 +5028,7 @@ void ui_draw_pie_center(uiBlock *block) GPU_blend(true); if (btheme->tui.wcol_pie_menu.shaded) { - char col1[4], col2[4]; + uchar col1[4], col2[4]; shadecolors4(col1, col2, btheme->tui.wcol_pie_menu.inner, @@ -5060,7 +5056,7 @@ void ui_draw_pie_center(uiBlock *block) if (!(block->pie_data.flags & UI_PIE_INVALID_DIR)) { if (btheme->tui.wcol_pie_menu.shaded) { - char col1[4], col2[4]; + uchar col1[4], col2[4]; shadecolors4(col1, col2, btheme->tui.wcol_pie_menu.inner_sel, @@ -5090,7 +5086,7 @@ void ui_draw_pie_center(uiBlock *block) GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - immUniformColor4ubv((uchar *)btheme->tui.wcol_pie_menu.outline); + immUniformColor4ubv(btheme->tui.wcol_pie_menu.outline); imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, pie_radius_internal, subd); imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, pie_radius_external, subd); @@ -5102,7 +5098,7 @@ void ui_draw_pie_center(uiBlock *block) float pie_confirm_radius = U.dpi_fac * (pie_radius_internal + U.pie_menu_confirm); float pie_confirm_external = U.dpi_fac * (pie_radius_internal + U.pie_menu_confirm + 7.0f); - const char col[4] = {UNPACK3(btheme->tui.wcol_pie_menu.text_sel), 64}; + const uchar col[4] = {UNPACK3(btheme->tui.wcol_pie_menu.text_sel), 64}; draw_disk_shaded(angle - range / 2.0f, range, pie_confirm_radius, @@ -5144,7 +5140,7 @@ static void ui_draw_widget_back_color(uiWidgetTypeEnum type, rcti rect_copy = *rect; wt->state(wt, 0, 0); if (color) { - rgba_float_to_uchar((uchar *)wt->wcol.inner, color); + rgba_float_to_uchar(wt->wcol.inner, color); } wt->draw(&wt->wcol, &rect_copy, 0, UI_CNR_ALL); } @@ -5222,7 +5218,7 @@ void ui_draw_menu_item( UI_fontstyle_draw(fstyle, rect, drawstr, - (uchar *)wt->wcol.text, + wt->wcol.text, &(struct uiFontStyleDraw_Params){ .align = UI_STYLE_TEXT_LEFT, }); @@ -5235,7 +5231,7 @@ void ui_draw_menu_item( UI_fontstyle_draw(fstyle, rect, cpoin + 1, - (uchar *)wt->wcol.text, + wt->wcol.text, &(struct uiFontStyleDraw_Params){ .align = UI_STYLE_TEXT_RIGHT, }); @@ -5303,7 +5299,7 @@ void ui_draw_preview_item( UI_fontstyle_draw(fstyle, &trect, drawstr, - (uchar *)wt->wcol.text, + wt->wcol.text, &(struct uiFontStyleDraw_Params){ .align = UI_STYLE_TEXT_CENTER, }); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 25116934b06..c31de60c7ed 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -83,12 +83,12 @@ void ui_resources_free(void) const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) { ThemeSpace *ts = NULL; - static char error[4] = {240, 0, 240, 255}; - static char alert[4] = {240, 60, 60, 255}; - static char headerdesel[4] = {0, 0, 0, 255}; - static char back[4] = {0, 0, 0, 255}; - static char setting = 0; - const char *cp = error; + static uchar error[4] = {240, 0, 240, 255}; + static uchar alert[4] = {240, 60, 60, 255}; + static uchar headerdesel[4] = {0, 0, 0, 255}; + static uchar back[4] = {0, 0, 0, 255}; + static uchar setting = 0; + const uchar *cp = error; /* ensure we're not getting a color after running BKE_blender_userdef_free */ BLI_assert(BLI_findindex(&U.themes, theme_active) != -1); @@ -186,7 +186,7 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) cp = ts->button; } - copy_v4_v4_char(back, cp); + copy_v4_v4_uchar(back, cp); if (!ED_region_is_overlap(spacetype, theme_regionid)) { back[3] = 255; } @@ -903,7 +903,7 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) break; case TH_ICON_FUND: { /* Development fund icon color is not part of theme. */ - static const char red[4] = {204, 48, 72, 255}; + static const uchar red[4] = {204, 48, 72, 255}; cp = red; break; } diff --git a/source/blender/editors/interface/view2d_gizmo_navigate.c b/source/blender/editors/interface/view2d_gizmo_navigate.c index 1558d0d835f..883f16c63f2 100644 --- a/source/blender/editors/interface/view2d_gizmo_navigate.c +++ b/source/blender/editors/interface/view2d_gizmo_navigate.c @@ -179,9 +179,6 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmGizmoGroup * gz->ptr, "draw_options", ED_GIZMO_BUTTON_SHOW_OUTLINE | ED_GIZMO_BUTTON_SHOW_BACKDROP); } - /* Not needed, just match 3D view where it is needed. */ - WM_gizmo_set_flag(gz, WM_GIZMO_EVENT_HANDLE_ALL, true); - wmOperatorType *ot = WM_operatortype_find(info->opname, true); WM_gizmo_operator_set(gz, 0, ot, NULL); } diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index b57d100127e..f32fcffabd4 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -940,8 +940,8 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) const bool zoom_to_pos = use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS); /* get amount to move view by */ - dx = RNA_float_get(op->ptr, "deltax"); - dy = RNA_float_get(op->ptr, "deltay"); + dx = RNA_float_get(op->ptr, "deltax") / U.pixelsize; + dy = RNA_float_get(op->ptr, "deltay") / U.pixelsize; if (U.uiflag & USER_ZOOM_INVERT) { dx *= -1; diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 844811390ea..2f4688e2de7 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -53,7 +53,6 @@ #include "ED_mesh.h" #include "ED_screen.h" #include "ED_transform.h" -#include "ED_select_buffer_utils.h" #include "ED_select_utils.h" #include "ED_view3d.h" @@ -69,6 +68,7 @@ #include "DEG_depsgraph_query.h" #include "DRW_engine.h" +#include "DRW_select_buffer.h" #include "mesh_intern.h" /* own include */ @@ -203,7 +203,7 @@ static BMElem *edbm_select_id_bm_elem_get(Base **bases, const uint sel_id, uint { uint elem_id; char elem_type = 0; - bool success = DRW_select_elem_get(sel_id, &elem_id, r_base_index, &elem_type); + bool success = DRW_select_buffer_elem_get(sel_id, &elem_id, r_base_index, &elem_type); if (success) { Object *obedit = bases[*r_base_index]->object; @@ -319,7 +319,7 @@ BMVert *EDBM_vert_find_nearest_ex(ViewContext *vc, { DRW_draw_select_id(vc->depsgraph, vc->ar, vc->v3d, bases, bases_len, SCE_SELECT_VERTEX); - index = ED_select_buffer_find_nearest_to_point(vc->mval, 1, UINT_MAX, &dist_px); + index = DRW_select_buffer_find_nearest_to_point(vc->mval, 1, UINT_MAX, &dist_px); if (index) { eve = (BMVert *)edbm_select_id_bm_elem_get(bases, index, &base_index); @@ -541,7 +541,7 @@ BMEdge *EDBM_edge_find_nearest_ex(ViewContext *vc, { DRW_draw_select_id(vc->depsgraph, vc->ar, vc->v3d, bases, bases_len, SCE_SELECT_EDGE); - index = ED_select_buffer_find_nearest_to_point(vc->mval, 1, UINT_MAX, &dist_px); + index = DRW_select_buffer_find_nearest_to_point(vc->mval, 1, UINT_MAX, &dist_px); if (index) { eed = (BMEdge *)edbm_select_id_bm_elem_get(bases, index, &base_index); @@ -747,7 +747,7 @@ BMFace *EDBM_face_find_nearest_ex(ViewContext *vc, { DRW_draw_select_id(vc->depsgraph, vc->ar, vc->v3d, bases, bases_len, SCE_SELECT_FACE); - index = ED_select_buffer_sample_point(vc->mval); + index = DRW_select_buffer_sample_point(vc->mval); if (index) { efa = (BMFace *)edbm_select_id_bm_elem_get(bases, index, &base_index); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index ecdf103e6eb..cb147772b6a 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -7347,6 +7347,7 @@ static int mesh_symmetry_snap_exec(bContext *C, wmOperator *op) } } } + EDBM_update_generic(em, false, false); /* No need to end cache, just free the array. */ MEM_freeN(index); @@ -7578,7 +7579,9 @@ void MESH_OT_mark_freestyle_face(wmOperatorType *ot) #endif /* WITH_FREESTYLE */ -/********************** Loop normals editing tools modal map. **********************/ +/* -------------------------------------------------------------------- */ +/** \name Loop Normals Editing Tools Modal Map + * \{ */ /* NOTE: these defines are saved in keymap files, do not change values but just add new ones */ /* NOTE: We could add more here, like e.g. a switch between local or global coordinates of target, @@ -8126,7 +8129,11 @@ void MESH_OT_point_normals(struct wmOperatorType *ot) 1.0f); } -/********************** Split/Merge Loop Normals **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Split/Merge Loop Normals + * \{ */ static void normals_merge(BMesh *bm, BMLoopNorEditDataArray *lnors_ed_arr) { @@ -8333,7 +8340,11 @@ void MESH_OT_split_normals(struct wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/********************** Average Loop Normals **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Average Loop Normals + * \{ */ enum { EDBM_CLNOR_AVERAGE_LOOP = 1, @@ -8561,7 +8572,11 @@ void MESH_OT_average_normals(struct wmOperatorType *ot) 5); } -/********************** Custom Normal Interface Tools **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Custom Normal Interface Tools + * \{ */ enum { EDBM_CLNOR_TOOLS_COPY = 1, @@ -9013,7 +9028,11 @@ void MESH_OT_smoothen_normals(struct wmOperatorType *ot) 1.0f); } -/********************** Weighted Normal Modifier Face Strength **********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Weighted Normal Modifier Face Strength + * \{ */ static int edbm_mod_weighted_strength_exec(bContext *C, wmOperator *op) { @@ -9104,3 +9123,5 @@ void MESH_OT_mod_weighted_strength(struct wmOperatorType *ot) "Face Strength", "Strength to use for assigning or selecting face influence for weighted normal modifier"); } + +/** \} */ diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index b082af352b2..0bdc59c7185 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -60,8 +60,9 @@ #include "DEG_depsgraph_build.h" #include "DEG_depsgraph_query.h" +#include "DRW_select_buffer.h" + #include "ED_mesh.h" -#include "ED_select_buffer_utils.h" #include "ED_object.h" #include "ED_view3d.h" @@ -1115,11 +1116,11 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px, if (dist_px) { /* sample rect to increase chances of selecting, so that when clicking * on an edge in the backbuf, we can still select a face */ - *r_index = ED_select_buffer_find_nearest_to_point(mval, 1, me->totpoly + 1, &dist_px); + *r_index = DRW_select_buffer_find_nearest_to_point(mval, 1, me->totpoly + 1, &dist_px); } else { /* sample only on the exact position */ - *r_index = ED_select_buffer_sample_point(mval); + *r_index = DRW_select_buffer_sample_point(mval); } if ((*r_index) == 0 || (*r_index) > (unsigned int)me->totpoly) { @@ -1296,11 +1297,11 @@ bool ED_mesh_pick_vert( if (dist_px > 0) { /* sample rect to increase chances of selecting, so that when clicking * on an face in the backbuf, we can still select a vert */ - *r_index = ED_select_buffer_find_nearest_to_point(mval, 1, me->totvert + 1, &dist_px); + *r_index = DRW_select_buffer_find_nearest_to_point(mval, 1, me->totvert + 1, &dist_px); } else { /* sample only on the exact position */ - *r_index = ED_select_buffer_sample_point(mval); + *r_index = DRW_select_buffer_sample_point(mval); } if ((*r_index) == 0 || (*r_index) > (uint)me->totvert) { diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c index 79aafc6978f..0a5db782892 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.c @@ -495,12 +495,16 @@ static int data_transfer_exec(bContext *C, wmOperator *op) NULL, false, op->reports)) { + + if (data_type == DT_TYPE_LNOR && use_create) { + ((Mesh *)ob_dst->data)->flag |= ME_AUTOSMOOTH; + } + + DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY); changed = true; } } - DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY); - if (reverse_transfer) { SWAP(Object *, ob_src, ob_dst); } diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c index 2c454448b9b..a1d76174cc8 100644 --- a/source/blender/editors/physics/rigidbody_constraint.c +++ b/source/blender/editors/physics/rigidbody_constraint.c @@ -46,6 +46,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "ED_object.h" #include "ED_physics.h" #include "ED_screen.h" @@ -56,12 +57,37 @@ static bool ED_operator_rigidbody_con_active_poll(bContext *C) { + Scene *scene = CTX_data_scene(C); + if (scene == NULL || ID_IS_LINKED(&scene->id) || + (scene->rigidbody_world != NULL && scene->rigidbody_world->constraints != NULL && + ID_IS_LINKED(&scene->rigidbody_world->constraints->id))) { + return false; + } + if (ED_operator_object_active_editable(C)) { - Object *ob = CTX_data_active_object(C); + Object *ob = ED_object_active_context(C); return (ob && ob->rigidbody_constraint); } else { - return 0; + return false; + } +} + +static bool ED_operator_rigidbody_con_add_poll(bContext *C) +{ + Scene *scene = CTX_data_scene(C); + if (scene == NULL || ID_IS_LINKED(&scene->id) || + (scene->rigidbody_world != NULL && scene->rigidbody_world->constraints != NULL && + ID_IS_LINKED(&scene->rigidbody_world->constraints->id))) { + return false; + } + + if (ED_operator_object_active_editable(C)) { + Object *ob = ED_object_active_context(C); + return (ob && ob->type == OB_MESH); + } + else { + return false; } } @@ -152,7 +178,7 @@ void RIGIDBODY_OT_constraint_add(wmOperatorType *ot) /* callbacks */ ot->exec = rigidbody_con_add_exec; - ot->poll = ED_operator_object_active_editable; + ot->poll = ED_operator_rigidbody_con_add_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index 70142b790c0..bc8a1799fa0 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -62,6 +62,13 @@ static bool ED_operator_rigidbody_active_poll(bContext *C) { + Scene *scene = CTX_data_scene(C); + if (scene == NULL || ID_IS_LINKED(&scene->id) || + (scene->rigidbody_world != NULL && scene->rigidbody_world->group != NULL && + ID_IS_LINKED(&scene->rigidbody_world->group->id))) { + return false; + } + if (ED_operator_object_active_editable(C)) { Object *ob = ED_object_active_context(C); return (ob && ob->rigidbody_object); @@ -73,12 +80,19 @@ static bool ED_operator_rigidbody_active_poll(bContext *C) static bool ED_operator_rigidbody_add_poll(bContext *C) { + Scene *scene = CTX_data_scene(C); + if (scene == NULL || ID_IS_LINKED(&scene->id) || + (scene->rigidbody_world != NULL && scene->rigidbody_world->group != NULL && + ID_IS_LINKED(&scene->rigidbody_world->group->id))) { + return false; + } + if (ED_operator_object_active_editable(C)) { Object *ob = ED_object_active_context(C); return (ob && ob->type == OB_MESH); } else { - return 0; + return false; } } @@ -286,7 +300,7 @@ void RIGIDBODY_OT_objects_remove(wmOperatorType *ot) /* callbacks */ ot->exec = rigidbody_objects_remove_exec; - ot->poll = ED_operator_scene_editable; + ot->poll = ED_operator_rigidbody_active_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -341,7 +355,7 @@ void RIGIDBODY_OT_shape_change(wmOperatorType *ot) /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = rigidbody_objects_shape_change_exec; - ot->poll = ED_operator_scene_editable; + ot->poll = ED_operator_rigidbody_active_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -534,7 +548,7 @@ void RIGIDBODY_OT_mass_calculate(wmOperatorType *ot) /* callbacks */ ot->invoke = WM_menu_invoke; // XXX ot->exec = rigidbody_objects_calc_mass_exec; - ot->poll = ED_operator_scene_editable; + ot->poll = ED_operator_rigidbody_active_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index acd7126e56a..55a71ee8989 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -1177,9 +1177,9 @@ static int render_shutter_curve_preset_exec(bContext *C, wmOperator *op) cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; mblur_shutter_curve->preset = preset; - curvemap_reset( + BKE_curvemap_reset( cm, &mblur_shutter_curve->clipr, mblur_shutter_curve->preset, CURVEMAP_SLOPE_POS_NEG); - curvemapping_changed(mblur_shutter_curve, false); + BKE_curvemapping_changed(mblur_shutter_curve, false); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 9b380ad5db1..b6601807443 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -723,35 +723,33 @@ static void shader_preview_updatejob(void *spv) { ShaderPreview *sp = spv; - if (sp->id) { - if (sp->pr_method == PR_NODE_RENDER) { - if (GS(sp->id->name) == ID_MA) { - Material *mat = (Material *)sp->id; + if (sp->pr_method == PR_NODE_RENDER) { + if (GS(sp->id->name) == ID_MA) { + Material *mat = (Material *)sp->id; - if (sp->matcopy && mat->nodetree && sp->matcopy->nodetree) { - ntreeLocalSync(sp->matcopy->nodetree, mat->nodetree); - } + if (sp->matcopy && mat->nodetree && sp->matcopy->nodetree) { + ntreeLocalSync(sp->matcopy->nodetree, mat->nodetree); } - else if (GS(sp->id->name) == ID_TE) { - Tex *tex = (Tex *)sp->id; + } + else if (GS(sp->id->name) == ID_TE) { + Tex *tex = (Tex *)sp->id; - if (sp->texcopy && tex->nodetree && sp->texcopy->nodetree) { - ntreeLocalSync(sp->texcopy->nodetree, tex->nodetree); - } + if (sp->texcopy && tex->nodetree && sp->texcopy->nodetree) { + ntreeLocalSync(sp->texcopy->nodetree, tex->nodetree); } - else if (GS(sp->id->name) == ID_WO) { - World *wrld = (World *)sp->id; + } + else if (GS(sp->id->name) == ID_WO) { + World *wrld = (World *)sp->id; - if (sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree) { - ntreeLocalSync(sp->worldcopy->nodetree, wrld->nodetree); - } + if (sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree) { + ntreeLocalSync(sp->worldcopy->nodetree, wrld->nodetree); } - else if (GS(sp->id->name) == ID_LA) { - Light *la = (Light *)sp->id; + } + else if (GS(sp->id->name) == ID_LA) { + Light *la = (Light *)sp->id; - if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree) { - ntreeLocalSync(sp->lampcopy->nodetree, la->nodetree); - } + if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree) { + ntreeLocalSync(sp->lampcopy->nodetree, la->nodetree); } } } @@ -946,57 +944,80 @@ static void shader_preview_startjob(void *customdata, short *stop, short *do_upd *do_update = true; } +static void preview_id_copy_free(ID *id) +{ + struct IDProperty *properties; + /* get rid of copied ID */ + properties = IDP_GetProperties(id, false); + if (properties) { + IDP_FreePropertyContent_ex(properties, false); + MEM_freeN(properties); + } + switch (GS(id->name)) { + case ID_MA: + BKE_material_free((Material *)id); + break; + case ID_TE: + BKE_texture_free((Tex *)id); + break; + case ID_LA: + BKE_light_free((Light *)id); + break; + case ID_WO: + BKE_world_free((World *)id); + break; + default: + BLI_assert(!"ID type preview not supported."); + break; + } + MEM_freeN(id); +} + static void shader_preview_free(void *customdata) { ShaderPreview *sp = customdata; Main *pr_main = sp->pr_main; + ID *main_id_copy = NULL; + ID *sub_id_copy = NULL; if (sp->matcopy) { - sp->id_copy = (ID *)sp->matcopy; + main_id_copy = (ID *)sp->matcopy; BLI_remlink(&pr_main->materials, sp->matcopy); } if (sp->texcopy) { - sp->id_copy = (ID *)sp->texcopy; + BLI_assert(main_id_copy == NULL); + main_id_copy = (ID *)sp->texcopy; BLI_remlink(&pr_main->textures, sp->texcopy); } if (sp->worldcopy) { - sp->id_copy = (ID *)sp->worldcopy; + /* worldcopy is also created for material with `Preview World` enabled */ + if (main_id_copy) { + sub_id_copy = (ID *)sp->worldcopy; + } + else { + main_id_copy = (ID *)sp->worldcopy; + } BLI_remlink(&pr_main->worlds, sp->worldcopy); } if (sp->lampcopy) { - sp->id_copy = (ID *)sp->lampcopy; + BLI_assert(main_id_copy == NULL); + main_id_copy = (ID *)sp->lampcopy; BLI_remlink(&pr_main->lights, sp->lampcopy); } - if (sp->id_copy) { + if (main_id_copy || sp->id_copy) { /* node previews */ shader_preview_updatejob(sp); } - if (sp->id_copy && sp->own_id_copy) { - struct IDProperty *properties; - /* get rid of copied ID */ - properties = IDP_GetProperties(sp->id_copy, false); - if (properties) { - IDP_FreePropertyContent_ex(properties, false); - MEM_freeN(properties); + if (sp->own_id_copy) { + if (sp->id_copy) { + preview_id_copy_free(sp->id_copy); + } + if (main_id_copy) { + preview_id_copy_free(main_id_copy); } - switch (GS(sp->id_copy->name)) { - case ID_MA: - BKE_material_free((Material *)sp->id_copy); - break; - case ID_TE: - BKE_texture_free((Tex *)sp->id_copy); - break; - case ID_LA: - BKE_light_free((Light *)sp->id_copy); - break; - case ID_WO: - BKE_world_free((World *)sp->id_copy); - break; - default: - BLI_assert(!"ID type preview not supported."); - break; + if (sub_id_copy) { + preview_id_copy_free(sub_id_copy); } - MEM_freeN(sp->id_copy); } MEM_freeN(sp); @@ -1301,12 +1322,7 @@ static void icon_preview_free(void *customdata) IconPreview *ip = (IconPreview *)customdata; if (ip->id_copy) { - /* Feels a bit hacky just to reuse shader_preview_free() */ - ShaderPreview *sp = MEM_callocN(sizeof(ShaderPreview), "Icon ShaderPreview"); - sp->id_copy = ip->id_copy; - sp->own_id_copy = true; - shader_preview_free(sp); - ip->id_copy = NULL; + preview_id_copy_free(ip->id_copy); } BLI_freelistN(&ip->sizes); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index eccd85ab276..4fb5e0c1af3 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -186,9 +186,9 @@ bool ED_operator_scene_editable(bContext *C) { Scene *scene = CTX_data_scene(C); if (scene && !ID_IS_LINKED(scene)) { - return 1; + return true; } - return 0; + return false; } bool ED_operator_objectmode(bContext *C) diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index 2a8ff9d4f78..752a5c36010 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -23,6 +23,7 @@ set(INC ../../blentranslation ../../bmesh ../../depsgraph + ../../draw ../../gpu ../../imbuf ../../makesdna diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 576baf5794b..65e10f98753 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -460,7 +460,7 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) } buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex"); - curvemapping_initialize(br->curve); + BKE_curvemapping_initialize(br->curve); LoadTexData data = { .br = br, diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index e5527e7210d..342d0b6e820 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -1695,7 +1695,7 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps, ca3 = ps->cavities[lt_vtri[2]]; ca_mask = w[0] * ca1 + w[1] * ca2 + w[2] * ca3; - ca_mask = curvemapping_evaluateF(ps->cavity_curve, 0, ca_mask); + ca_mask = BKE_curvemapping_evaluateF(ps->cavity_curve, 0, ca_mask); CLAMP(ca_mask, 0.0f, 1.0f); mask *= ca_mask; } @@ -5092,6 +5092,22 @@ static void image_paint_partial_redraw_expand(ImagePaintPartialRedraw *cell, cell->y2 = max_ii(cell->y2, (int)projPixel->y_px + 1); } +static void copy_original_alpha_channel(ProjPixel *pixel, bool is_floatbuf) +{ + /* Use the original alpha channel data instead of the modified one */ + if (is_floatbuf) { + /* slightly more involved case since floats are in premultiplied space we need + * to make sure alpha is consistent, see T44627 */ + float rgb_straight[4]; + premul_to_straight_v4_v4(rgb_straight, pixel->pixel.f_pt); + rgb_straight[3] = pixel->origColor.f_pt[3]; + straight_to_premul_v4_v4(pixel->pixel.f_pt, rgb_straight); + } + else { + pixel->pixel.ch_pt[3] = pixel->origColor.ch_pt[3]; + } +} + /* Run this for single and multi-threaded painting. */ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), void *ph_v, @@ -5263,17 +5279,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), } if (lock_alpha) { - if (is_floatbuf) { - /* slightly more involved case since floats are in premultiplied space we need - * to make sure alpha is consistent, see T44627 */ - float rgb_straight[4]; - premul_to_straight_v4_v4(rgb_straight, projPixel->pixel.f_pt); - rgb_straight[3] = projPixel->origColor.f_pt[3]; - straight_to_premul_v4_v4(projPixel->pixel.f_pt, rgb_straight); - } - else { - projPixel->pixel.ch_pt[3] = projPixel->origColor.ch_pt[3]; - } + copy_original_alpha_channel(projPixel, is_floatbuf); } last_partial_redraw_cell = last_projIma->partRedrawRect + projPixel->bb_cell_index; @@ -5478,17 +5484,7 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), } if (lock_alpha) { - if (is_floatbuf) { - /* slightly more involved case since floats are in premultiplied space we need - * to make sure alpha is consistent, see T44627 */ - float rgb_straight[4]; - premul_to_straight_v4_v4(rgb_straight, projPixel->pixel.f_pt); - rgb_straight[3] = projPixel->origColor.f_pt[3]; - straight_to_premul_v4_v4(projPixel->pixel.f_pt, rgb_straight); - } - else { - projPixel->pixel.ch_pt[3] = projPixel->origColor.ch_pt[3]; - } + copy_original_alpha_channel(projPixel, is_floatbuf); } } @@ -5504,11 +5500,17 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), for (node = smearPixels; node; node = node->next) { /* this wont run for a float image */ projPixel = node->link; *projPixel->pixel.uint_pt = ((ProjPixelClone *)projPixel)->clonepx.uint; + if (lock_alpha) { + copy_original_alpha_channel(projPixel, false); + } } for (node = smearPixels_f; node; node = node->next) { projPixel = node->link; copy_v4_v4(projPixel->pixel.f_pt, ((ProjPixelClone *)projPixel)->clonepx.f); + if (lock_alpha) { + copy_original_alpha_channel(projPixel, true); + } } BLI_memarena_free(smearArena); @@ -5518,11 +5520,17 @@ static void do_projectpaint_thread(TaskPool *__restrict UNUSED(pool), for (node = softenPixels; node; node = node->next) { /* this wont run for a float image */ projPixel = node->link; *projPixel->pixel.uint_pt = projPixel->newColor.uint; + if (lock_alpha) { + copy_original_alpha_channel(projPixel, false); + } } for (node = softenPixels_f; node; node = node->next) { projPixel = node->link; copy_v4_v4(projPixel->pixel.f_pt, projPixel->newColor.f); + if (lock_alpha) { + copy_original_alpha_channel(projPixel, true); + } } BLI_memarena_free(softenArena); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index f073877ebcf..6144f5751f2 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -784,9 +784,9 @@ PaintStroke *paint_stroke_new(bContext *C, ups->average_stroke_counter = 0; /* initialize here to avoid initialization conflict with threaded strokes */ - curvemapping_initialize(br->curve); + BKE_curvemapping_initialize(br->curve); if (p->flags & PAINT_USE_CAVITY_MASK) { - curvemapping_initialize(p->cavity_curve); + BKE_curvemapping_initialize(p->cavity_curve); } BKE_paint_set_overlay_override(br->overlay_flags); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 0f37968f599..806b7c471c6 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -71,7 +71,8 @@ #include "BLI_sys_types.h" #include "ED_mesh.h" /* for face mask functions */ -#include "ED_select_buffer_utils.h" + +#include "DRW_select_buffer.h" #include "WM_api.h" #include "WM_types.h" @@ -391,7 +392,7 @@ static int imapaint_pick_face(ViewContext *vc, /* sample only on the exact position */ ED_view3d_select_id_validate(vc); - *r_index = ED_select_buffer_sample_point(mval); + *r_index = DRW_select_buffer_sample_point(mval); if ((*r_index) == 0 || (*r_index) > (unsigned int)totpoly) { return 0; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 32b89f5676f..12da8790b91 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1299,6 +1299,9 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) } else { Depsgraph *depsgraph = CTX_data_depsgraph_on_load(C); + if (depsgraph) { + depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + } wmWindowManager *wm = CTX_wm_manager(C); ED_object_wpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob); BKE_paint_toolslots_brush_validate(bmain, &ts->wpaint->paint); diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index 1dc28328244..72fc08cc38d 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -796,7 +796,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) VPaint *wp = ts->wpaint; struct Brush *brush = BKE_paint_brush(&wp->paint); - curvemapping_initialize(brush->curve); + BKE_curvemapping_initialize(brush->curve); data.brush = brush; data.weightpaint = BKE_brush_weight_get(scene, brush); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index eeda7a7aeaf..285e6aff7d0 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2308,7 +2308,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) /* XXX - this shouldn't be necessary, but sculpting crashes in blender2.8 otherwise * initialize before threads so they can do curve mapping */ - curvemapping_initialize(brush->curve); + BKE_curvemapping_initialize(brush->curve); /* threaded loop over nodes */ SculptThreadedTaskData data = { @@ -4604,7 +4604,7 @@ static void sculpt_update_cache_invariants( brush = br; cache->saved_smooth_size = BKE_brush_size_get(scene, brush); BKE_brush_size_set(scene, brush, size); - curvemapping_initialize(brush->curve); + BKE_curvemapping_initialize(brush->curve); } } } @@ -6238,6 +6238,9 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op) ED_object_sculptmode_exit_ex(bmain, depsgraph, scene, ob); } else { + if (depsgraph) { + depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + } ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, false, op->reports); BKE_paint_toolslots_brush_validate(bmain, &ts->sculpt->paint); } diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 36cc3605273..91ed9057667 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -497,7 +497,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm op->customdata = data; - curvemapping_initialize(ts->uvsculpt->paint.brush->curve); + BKE_curvemapping_initialize(ts->uvsculpt->paint.brush->curve); if (data) { int counter = 0, i; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index af998fda6f9..cf899773822 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -640,6 +640,8 @@ static void view_zoom_apply( delta = event->x - vpd->x + event->y - vpd->y; } + delta /= U.pixelsize; + if (U.uiflag & USER_ZOOM_INVERT) { delta = -delta; } diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index fc0adb655b7..faf613482a3 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -742,7 +742,7 @@ static int console_clear_exec(bContext *C, wmOperator *op) void CONSOLE_OT_clear(wmOperatorType *ot) { /* identifiers */ - ot->name = "Clear"; + ot->name = "Clear All"; ot->description = "Clear text by type"; ot->idname = "CONSOLE_OT_clear"; diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 829a78b2bfa..ccd0a2bfd79 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -385,10 +385,10 @@ void ED_space_image_scopes_update(const struct bContext *C, } } - scopes_update(&sima->scopes, - ibuf, - use_view_settings ? &scene->view_settings : NULL, - &scene->display_settings); + BKE_scopes_update(&sima->scopes, + ibuf, + use_view_settings ? &scene->view_settings : NULL, + &scene->display_settings); } bool ED_space_image_show_render(SpaceImage *sima) diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 374a58d1808..05ba82b8bde 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -570,6 +570,8 @@ static void image_zoom_apply(ViewZoomData *vpd, delta = x - vpd->origx + y - vpd->origy; } + delta /= U.pixelsize; + if (zoom_invert) { delta = -delta; } @@ -3217,10 +3219,10 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event int point = RNA_enum_get(op->ptr, "point"); if (point == 1) { - curvemapping_set_black_white(curve_mapping, NULL, info->linearcol); + BKE_curvemapping_set_black_white(curve_mapping, NULL, info->linearcol); } else if (point == 0) { - curvemapping_set_black_white(curve_mapping, info->linearcol, NULL); + BKE_curvemapping_set_black_white(curve_mapping, info->linearcol, NULL); } WM_event_add_notifier(C, NC_WINDOW, NULL); } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 7ff075bf819..17f808f727d 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -131,7 +131,7 @@ static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sce BKE_imageuser_default(&simage->iuser); simage->iuser.flag = IMA_SHOW_STEREO | IMA_ANIM_ALWAYS; - scopes_new(&simage->scopes); + BKE_scopes_new(&simage->scopes); simage->sample_line_hist.height = 100; /* tool header */ @@ -179,7 +179,7 @@ static void image_free(SpaceLink *sl) { SpaceImage *simage = (SpaceImage *)sl; - scopes_free(&simage->scopes); + BKE_scopes_free(&simage->scopes); } /* spacetype; init callback, add handlers */ @@ -197,7 +197,7 @@ static SpaceLink *image_duplicate(SpaceLink *sl) /* clear or remove stuff from old */ - scopes_new(&simagen->scopes); + BKE_scopes_new(&simagen->scopes); return (SpaceLink *)simagen; } diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index 108803a865f..24d3008b1e7 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -35,8 +35,6 @@ #include "GPU_immediate.h" #include "GPU_state.h" -#include "BKE_text.h" - #include "textview.h" static void console_font_begin(const int font_id, const int lheight) @@ -78,8 +76,8 @@ static void console_draw_sel(const char *str, const unsigned char bg_sel[4]) { if (sel[0] <= str_len_draw && sel[1] >= 0) { - const int sta = txt_utf8_offset_to_column(str, max_ii(sel[0], 0)); - const int end = txt_utf8_offset_to_column(str, min_ii(sel[1], str_len_draw)); + const int sta = BLI_str_utf8_offset_to_column(str, max_ii(sel[0], 0)); + const int end = BLI_str_utf8_offset_to_column(str, min_ii(sel[1], str_len_draw)); GPU_blend(true); GPU_blend_set_func_separate( @@ -156,7 +154,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, } /* last part */ - ofs += txt_utf8_column_to_offset(str + ofs, (int)floor((float)cdc->mval[0] / cdc->cwidth)); + ofs += BLI_str_utf8_offset_from_column(str + ofs, + (int)floor((float)cdc->mval[0] / cdc->cwidth)); CLAMP(ofs, 0, str_len); *cdc->pos_pick += str_len - ofs; diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 8c36d4ae2bd..e4881a6f13d 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -2407,9 +2407,9 @@ static void tselem_draw_layer_collection_enable_icon( /* restrict column clip... it has been coded by simply overdrawing, * doesn't work for buttons */ - char color[4]; + uchar color[4]; int icon = RNA_property_ui_icon(exclude_prop); - if (UI_icon_get_theme_color(icon, (uchar *)color)) { + if (UI_icon_get_theme_color(icon, color)) { UI_icon_draw_ex(x, y, icon, U.inv_dpi_fac, alpha, 0.0f, color, true); } else { @@ -2467,8 +2467,8 @@ static void tselem_draw_icon(uiBlock *block, /* restrict column clip... it has been coded by simply overdrawing, * doesn't work for buttons */ - char color[4]; - if (UI_icon_get_theme_color(data.icon, (uchar *)color)) { + uchar color[4]; + if (UI_icon_get_theme_color(data.icon, color)) { UI_icon_draw_ex(x, y, data.icon, U.inv_dpi_fac, alpha, 0.0f, color, true); } else { diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index ea815bd5456..07350b5269e 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -2076,9 +2076,11 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) scene->r.cfra + scene->ed->over_ofs; uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR); - immUniformColor3f(0.2f, 0.2f, 0.2f); + immUniform1f("dash_width", 20.0f * U.pixelsize); + immUniform1f("dash_factor", 0.5f); + immUniformThemeColor(TH_CFRAME); immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, cfra_over, v2d->cur.ymin); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index c03b804aa2c..9dc8dfa93b6 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -240,7 +240,7 @@ void wrap_offset( } max = wrap_width(st, ar); - cursin = txt_utf8_offset_to_column(linein->line, cursin); + cursin = BLI_str_utf8_offset_to_column(linein->line, cursin); while (linep) { start = 0; @@ -323,7 +323,7 @@ void wrap_offset_in_line( end = max; chop = 1; *offc = 0; - cursin = txt_utf8_offset_to_column(linein->line, cursin); + cursin = BLI_str_utf8_offset_to_column(linein->line, cursin); for (i = 0, j = 0; linein->line[j]; j += BLI_str_utf8_size_safe(linein->line + j)) { int columns = BLI_str_utf8_char_width_safe(linein->line + j); /* = 1 for tab */ @@ -1400,7 +1400,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi linep = startl; c = startc; - fc = txt_utf8_offset_to_index(linep->line, startc); + fc = BLI_str_utf8_offset_to_index(linep->line, startc); endl = NULL; endc = -1; find = -b; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 7c4a403d43d..a8af9c73bf2 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1827,7 +1827,7 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, const bool sel) if (j >= oldc) { if (ch == '\0') { - *charp = txt_utf8_column_to_offset((*linep)->line, start); + *charp = BLI_str_utf8_offset_from_column((*linep)->line, start); } loop = 0; break; @@ -1843,7 +1843,7 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, const bool sel) } else if (ch == ' ' || ch == '-' || ch == '\0') { if (j >= oldc) { - *charp = txt_utf8_column_to_offset((*linep)->line, start); + *charp = BLI_str_utf8_offset_from_column((*linep)->line, start); loop = 0; break; } diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index 39cbc67f996..040b257bb90 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -102,6 +102,7 @@ #include "RE_engine.h" #include "DRW_engine.h" +#include "DRW_select_buffer.h" #include "view3d_intern.h" /* own include */ @@ -238,22 +239,6 @@ void ED_view3d_backbuf_depth_validate(ViewContext *vc) } } -uint *ED_view3d_select_id_read_rect(const rcti *clip, uint *r_buf_len) -{ - uint width = BLI_rcti_size_x(clip); - uint height = BLI_rcti_size_y(clip); - uint buf_len = width * height; - uint *buf = MEM_mallocN(buf_len * sizeof(*buf), __func__); - - DRW_framebuffer_select_id_read(clip, buf); - - if (r_buf_len) { - *r_buf_len = buf_len; - } - - return buf; -} - /** * allow for small values [0.5 - 2.5], * and large values, FLT_MAX by clamping by the area size @@ -263,30 +248,6 @@ int ED_view3d_backbuf_sample_size_clamp(ARegion *ar, const float dist) return (int)min_ff(ceilf(dist), (float)max_ii(ar->winx, ar->winx)); } -/* reads full rect, converts indices */ -uint *ED_view3d_select_id_read(int xmin, int ymin, int xmax, int ymax, uint *r_buf_len) -{ - if (UNLIKELY((xmin > xmax) || (ymin > ymax))) { - return NULL; - } - - const rcti rect = { - .xmin = xmin, - .xmax = xmax + 1, - .ymin = ymin, - .ymax = ymax + 1, - }; - - uint buf_len; - uint *buf = ED_view3d_select_id_read_rect(&rect, &buf_len); - - if (r_buf_len) { - *r_buf_len = buf_len; - } - - return buf; -} - /* *********************** */ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index ff0052c1fd1..ec7c1c0b3b9 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -201,7 +201,7 @@ static void calctrackballvec(const rcti *rect, const int event_xy[2], float r_di /* Normalize x and y. */ r_dir[0] = (event_xy[0] - BLI_rcti_cent_x(rect)) / ((size[0] * aspect[0]) / 2.0); - r_dir[1] = (event_xy[1] - BLI_rcti_cent_x(rect)) / ((size[1] * aspect[1]) / 2.0); + r_dir[1] = (event_xy[1] - BLI_rcti_cent_y(rect)) / ((size[1] * aspect[1]) / 2.0); const float d = len_v2(r_dir); if (d < t) { /* Inside sphere. */ @@ -1959,6 +1959,8 @@ static float viewzoom_scale_value(const rcti *winrct, fac = (float)(xy_init[1] - xy_curr[1]); } + fac /= U.pixelsize; + if (zoom_invert != zoom_invert_force) { fac = -fac; } @@ -1974,8 +1976,8 @@ static float viewzoom_scale_value(const rcti *winrct, BLI_rcti_cent_x(winrct), BLI_rcti_cent_y(winrct), }; - float len_new = 5 + len_v2v2_int(ctr, xy_curr); - float len_old = 5 + len_v2v2_int(ctr, xy_init); + float len_new = (5 * U.pixelsize) + ((float)len_v2v2_int(ctr, xy_curr) / U.pixelsize); + float len_old = (5 * U.pixelsize) + ((float)len_v2v2_int(ctr, xy_init) / U.pixelsize); /* intentionally ignore 'zoom_invert' for scale */ if (zoom_invert_force) { @@ -1985,16 +1987,16 @@ static float viewzoom_scale_value(const rcti *winrct, zfac = val_orig * (len_old / max_ff(len_new, 1.0f)) / val; } else { /* USER_ZOOM_DOLLY */ - float len_new = 5; - float len_old = 5; + float len_new = 5 * U.pixelsize; + float len_old = 5 * U.pixelsize; if (U.uiflag & USER_ZOOM_HORIZ) { - len_new += (winrct->xmax - (xy_curr[0])); - len_old += (winrct->xmax - (xy_init[0])); + len_new += (winrct->xmax - (xy_curr[0])) / U.pixelsize; + len_old += (winrct->xmax - (xy_init[0])) / U.pixelsize; } else { - len_new += (winrct->ymax - (xy_curr[1])); - len_old += (winrct->ymax - (xy_init[1])); + len_new += (winrct->ymax - (xy_curr[1])) / U.pixelsize; + len_old += (winrct->ymax - (xy_init[1])) / U.pixelsize; } if (zoom_invert != zoom_invert_force) { diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 961ac4c26fb..3e2e113be3e 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -155,6 +155,8 @@ typedef struct FlyInfo { * without moving the direction there looking */ bool use_freelook; + bool anim_playing; /* needed for autokeyframing */ + int mval[2]; /* latest 2D mouse values */ int center_mval[2]; /* center mouse values */ float width, height; /* camera viewport dimensions */ @@ -185,6 +187,12 @@ typedef struct FlyInfo { } FlyInfo; +/* prototypes */ +#ifdef WITH_INPUT_NDOF +static void flyApply_ndof(bContext *C, FlyInfo *fly, bool is_confirm); +#endif /* WITH_INPUT_NDOF */ +static int flyApply(bContext *C, struct FlyInfo *fly, bool force_autokey); + static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg) { FlyInfo *fly = arg; @@ -261,6 +269,7 @@ enum { static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent *event) { + wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); rctf viewborder; @@ -308,6 +317,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent fly->grid = 1.0f; fly->use_precision = false; fly->use_freelook = false; + fly->anim_playing = ED_screen_animation_playing(wm); #ifdef NDOF_FLY_DRAW_TOOMUCH fly->redraw = 1; @@ -374,6 +384,18 @@ static int flyEnd(bContext *C, FlyInfo *fly) if (fly->state == FLY_RUNNING) { return OPERATOR_RUNNING_MODAL; } + else if (fly->state == FLY_CONFIRM) { + /* Needed for auto_keyframe. */ +#ifdef WITH_INPUT_NDOF + if (fly->ndof) { + flyApply_ndof(C, fly, true); + } + else +#endif /* WITH_INPUT_NDOF */ + { + flyApply(C, fly, true); + } + } #ifdef NDOF_FLY_DEBUG puts("\n-- fly end --"); @@ -672,12 +694,19 @@ static void flyEvent(FlyInfo *fly, const wmEvent *event) } } -static void flyMoveCamera(bContext *C, FlyInfo *fly, const bool do_rotate, const bool do_translate) +static void flyMoveCamera(bContext *C, + FlyInfo *fly, + const bool do_rotate, + const bool do_translate, + const bool is_confirm) { - ED_view3d_cameracontrol_update(fly->v3d_camera_control, true, C, do_rotate, do_translate); + /* we only consider autokeying on playback or if user confirmed fly on the same frame + * otherwise we get a keyframe even if the user cancels. */ + const bool use_autokey = is_confirm || fly->anim_playing; + ED_view3d_cameracontrol_update(fly->v3d_camera_control, use_autokey, C, do_rotate, do_translate); } -static int flyApply(bContext *C, FlyInfo *fly) +static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm) { #define FLY_ROTATE_FAC 10.0f /* more is faster */ #define FLY_ZUP_CORRECT_FAC 0.1f /* amount to correct per step */ @@ -948,7 +977,7 @@ static int flyApply(bContext *C, FlyInfo *fly) (fly->zlock != FLY_AXISLOCK_STATE_OFF) || ((moffset[0] || moffset[1]) && !fly->pan_view)); const bool do_translate = (fly->speed != 0.0f || fly->pan_view); - flyMoveCamera(C, fly, do_rotate, do_translate); + flyMoveCamera(C, fly, do_rotate, do_translate, is_confirm); } } else { @@ -963,7 +992,7 @@ static int flyApply(bContext *C, FlyInfo *fly) } #ifdef WITH_INPUT_NDOF -static void flyApply_ndof(bContext *C, FlyInfo *fly) +static void flyApply_ndof(bContext *C, FlyInfo *fly, bool is_confirm) { Object *lock_ob = ED_view3d_cameracontrol_object_get(fly->v3d_camera_control); bool has_translate, has_rotate; @@ -980,7 +1009,7 @@ static void flyApply_ndof(bContext *C, FlyInfo *fly) fly->redraw = true; if (fly->rv3d->persp == RV3D_CAMOB) { - flyMoveCamera(C, fly, has_rotate, has_translate); + flyMoveCamera(C, fly, has_rotate, has_translate, is_confirm); } } } @@ -1035,13 +1064,13 @@ static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event) #ifdef WITH_INPUT_NDOF if (fly->ndof) { /* 3D mouse overrules [2D mouse + timer] */ if (event->type == NDOF_MOTION) { - flyApply_ndof(C, fly); + flyApply_ndof(C, fly, false); } } else #endif /* WITH_INPUT_NDOF */ if (event->type == TIMER && event->customdata == fly->timer) { - flyApply(C, fly); + flyApply(C, fly, false); } do_draw |= fly->redraw; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c index 1724a8bd86d..ad1a57eb71f 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c @@ -184,10 +184,6 @@ static void WIDGETGROUP_navigate_setup(const bContext *C, wmGizmoGroup *gzgroup) wmOperatorType *ot = WM_operatortype_find(info->opname, true); WM_gizmo_operator_set(gz, 0, ot, NULL); - - /* We only need this for rotation so click/drag events aren't stolen - * by paint mode press events, however it's strange if only rotation has this behavior. */ - WM_gizmo_set_flag(gz, WM_GIZMO_EVENT_HANDLE_ALL, true); } { diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index b4bc2748de5..d20a854c022 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -89,7 +89,6 @@ #include "ED_mesh.h" #include "ED_object.h" #include "ED_screen.h" -#include "ED_select_buffer_utils.h" #include "ED_select_utils.h" #include "ED_sculpt.h" #include "ED_mball.h" @@ -105,6 +104,7 @@ #include "DEG_depsgraph_query.h" #include "DRW_engine.h" +#include "DRW_select_buffer.h" #include "view3d_intern.h" /* own include */ @@ -269,7 +269,8 @@ static bool edbm_backbuf_check_and_select_verts(struct EditSelectBuf_Cache *esel bool changed = false; const BLI_bitmap *select_bitmap = esel->select_bitmap; - uint index = DRW_select_context_offset_for_object_elem(ob->runtime.select_id, SCE_SELECT_VERTEX); + uint index = DRW_select_buffer_context_offset_for_object_elem(ob->runtime.select_id, + SCE_SELECT_VERTEX); BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { @@ -296,7 +297,8 @@ static bool edbm_backbuf_check_and_select_edges(struct EditSelectBuf_Cache *esel bool changed = false; const BLI_bitmap *select_bitmap = esel->select_bitmap; - uint index = DRW_select_context_offset_for_object_elem(ob->runtime.select_id, SCE_SELECT_EDGE); + uint index = DRW_select_buffer_context_offset_for_object_elem(ob->runtime.select_id, + SCE_SELECT_EDGE); BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { @@ -323,7 +325,8 @@ static bool edbm_backbuf_check_and_select_faces(struct EditSelectBuf_Cache *esel bool changed = false; const BLI_bitmap *select_bitmap = esel->select_bitmap; - uint index = DRW_select_context_offset_for_object_elem(ob->runtime.select_id, SCE_SELECT_FACE); + uint index = DRW_select_buffer_context_offset_for_object_elem(ob->runtime.select_id, + SCE_SELECT_FACE); BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { @@ -828,8 +831,7 @@ static bool do_lasso_select_mesh(ViewContext *vc, if (wm_userdata->data == NULL) { editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc, ts->selectmode); esel = wm_userdata->data; - const uint buffer_len = DRW_select_context_elem_len(); - esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect); + esel->select_bitmap = DRW_select_buffer_bitmap_from_poly(mcords, moves, &rect); } } @@ -847,7 +849,7 @@ static bool do_lasso_select_mesh(ViewContext *vc, struct LassoSelectUserData_ForMeshEdge data_for_edge = { .data = &data, .esel = use_zbuf ? esel : NULL, - .backbuf_offset = use_zbuf ? DRW_select_context_offset_for_object_elem( + .backbuf_offset = use_zbuf ? DRW_select_buffer_context_offset_for_object_elem( vc->obedit->runtime.select_id, SCE_SELECT_EDGE) : 0, }; @@ -1139,8 +1141,7 @@ static bool do_lasso_select_paintvert(ViewContext *vc, if (wm_userdata->data == NULL) { editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc, SCE_SELECT_VERTEX); esel = wm_userdata->data; - const uint buffer_len = DRW_select_context_elem_len(); - esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect); + esel->select_bitmap = DRW_select_buffer_bitmap_from_poly(mcords, moves, &rect); } } @@ -1198,8 +1199,7 @@ static bool do_lasso_select_paintface(ViewContext *vc, if (esel == NULL) { editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc, SCE_SELECT_FACE); esel = wm_userdata->data; - const uint buffer_len = DRW_select_context_elem_len(); - esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect); + esel->select_bitmap = DRW_select_buffer_bitmap_from_poly(mcords, moves, &rect); } if (esel->select_bitmap) { @@ -2554,8 +2554,7 @@ static bool do_paintvert_box_select(ViewContext *vc, if (wm_userdata->data == NULL) { editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc, SCE_SELECT_VERTEX); esel = wm_userdata->data; - const uint buffer_len = DRW_select_context_elem_len(); - esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect); + esel->select_bitmap = DRW_select_buffer_bitmap_from_rect(rect, NULL); } if (esel->select_bitmap != NULL) { changed |= edbm_backbuf_check_and_select_verts_obmode(me, esel, sel_op); @@ -2609,8 +2608,7 @@ static bool do_paintface_box_select(ViewContext *vc, if (wm_userdata->data == NULL) { editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc, SCE_SELECT_FACE); esel = wm_userdata->data; - const uint buffer_len = DRW_select_context_elem_len(); - esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect); + esel->select_bitmap = DRW_select_buffer_bitmap_from_rect(rect, NULL); } if (esel->select_bitmap != NULL) { changed |= edbm_backbuf_check_and_select_faces_obmode(me, esel, sel_op); @@ -2807,8 +2805,7 @@ static bool do_mesh_box_select(ViewContext *vc, if (wm_userdata->data == NULL) { editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc, ts->selectmode); esel = wm_userdata->data; - const uint buffer_len = DRW_select_context_elem_len(); - esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect); + esel->select_bitmap = DRW_select_buffer_bitmap_from_rect(rect, NULL); } } @@ -2826,7 +2823,7 @@ static bool do_mesh_box_select(ViewContext *vc, struct BoxSelectUserData_ForMeshEdge cb_data = { .data = &data, .esel = use_zbuf ? esel : NULL, - .backbuf_offset = use_zbuf ? DRW_select_context_offset_for_object_elem( + .backbuf_offset = use_zbuf ? DRW_select_buffer_context_offset_for_object_elem( vc->obedit->runtime.select_id, SCE_SELECT_EDGE) : 0, }; @@ -3395,8 +3392,7 @@ static bool mesh_circle_select(ViewContext *vc, struct EditSelectBuf_Cache *esel = wm_userdata->data; if (use_zbuf) { - const uint buffer_len = DRW_select_context_elem_len(); - esel->select_bitmap = ED_select_buffer_bitmap_from_circle(buffer_len, mval, (int)(rad + 1.0f)); + esel->select_bitmap = DRW_select_buffer_bitmap_from_circle(mval, (int)(rad + 1.0f), NULL); } if (ts->selectmode & SCE_SELECT_VERTEX) { @@ -3473,8 +3469,7 @@ static bool paint_facesel_circle_select(ViewContext *vc, { struct EditSelectBuf_Cache *esel = wm_userdata->data; - const uint buffer_len = DRW_select_context_elem_len(); - esel->select_bitmap = ED_select_buffer_bitmap_from_circle(buffer_len, mval, (int)(rad + 1.0f)); + esel->select_bitmap = DRW_select_buffer_bitmap_from_circle(mval, (int)(rad + 1.0f), NULL); if (esel->select_bitmap != NULL) { changed |= edbm_backbuf_check_and_select_faces_obmode(me, esel, sel_op); MEM_freeN(esel->select_bitmap); @@ -3528,8 +3523,7 @@ static bool paint_vertsel_circle_select(ViewContext *vc, if (use_zbuf) { struct EditSelectBuf_Cache *esel = wm_userdata->data; - const uint buffer_len = DRW_select_context_elem_len(); - esel->select_bitmap = ED_select_buffer_bitmap_from_circle(buffer_len, mval, (int)(rad + 1.0f)); + esel->select_bitmap = DRW_select_buffer_bitmap_from_circle(mval, (int)(rad + 1.0f), NULL); if (esel->select_bitmap != NULL) { changed |= edbm_backbuf_check_and_select_verts_obmode(me, esel, sel_op); MEM_freeN(esel->select_bitmap); diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index bb8c1a40a05..7f930f1d876 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -1212,9 +1212,17 @@ float ED_view3d_radius_to_dist(const View3D *v3d, /** \name View Distance Utilities * \{ */ -/* problem - ofs[3] can be on same location as camera itself. - * Blender needs proper dist value for zoom. - * use fallback_dist to override small values +/** + * This function solves the problem of having to switch between camera and non-camera views. + * + * When viewing from the perspective of \a mat, and having the view center \a ofs, + * this calculates a distance from \a ofs to the matrix \a mat. + * Using \a fallback_dist when the distance would be too small. + * + * \param mat: A matrix use for the view-point (typically the camera objects matrix). + * \param ofs: Orbit center (negated), matching #RegionView3D.ofs, which is typically passed in. + * \param fallback_dist: The distance to use if the object is too near or in front of \a ofs. + * \returns A newly calculated distance or the fallback. */ float ED_view3d_offset_distance(float mat[4][4], const float ofs[3], const float fallback_dist) { @@ -1261,6 +1269,36 @@ void ED_view3d_distance_set(RegionView3D *rv3d, const float dist) rv3d->dist = dist; } +/** + * Change the distance & offset to match the depth of \a dist_co along the view axis. + * + * \param dist_co: A world-space location to use for the new depth. + * \param dist_min: Resulting distances below this will be ignored. + * \return Success if the distance was set. + */ +bool ED_view3d_distance_set_from_location(RegionView3D *rv3d, + const float dist_co[3], + const float dist_min) +{ + float viewinv[4]; + invert_qt_qt_normalized(viewinv, rv3d->viewquat); + + float tvec[3] = {0.0f, 0.0f, -1.0f}; + mul_qt_v3(viewinv, tvec); + + float dist_co_local[3]; + negate_v3_v3(dist_co_local, rv3d->ofs); + sub_v3_v3v3(dist_co_local, dist_co, dist_co_local); + const float delta = dot_v3v3(tvec, dist_co_local); + const float dist_new = rv3d->dist + delta; + if (dist_new >= dist_min) { + madd_v3_v3fl(rv3d->ofs, tvec, -delta); + rv3d->dist = dist_new; + return true; + } + return false; +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index c5585857b55..22c1aafd7c4 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -65,9 +65,6 @@ /* ensure the target position is one we can reach, see: T45771 */ #define USE_PIXELSIZE_NATIVE_SUPPORT -/* prototypes */ -static float getVelocityZeroTime(const float gravity, const float velocity); - /* NOTE: these defines are saved in keymap files, * do not change values but just add new ones */ enum { @@ -199,6 +196,8 @@ typedef struct WalkInfo { short state; bool redraw; + bool anim_playing; /* needed for autokeyframing */ + int prev_mval[2]; /* previous 2D mouse values */ int center_mval[2]; /* center mouse values */ int moffset[2]; @@ -264,6 +263,13 @@ typedef struct WalkInfo { } WalkInfo; +/* prototypes */ +#ifdef WITH_INPUT_NDOF +static void walkApply_ndof(bContext *C, WalkInfo *walk, bool is_confirm); +#endif /* WITH_INPUT_NDOF */ +static int walkApply(bContext *C, struct WalkInfo *walk, bool force_autokey); +static float getVelocityZeroTime(const float gravity, const float velocity); + static void drawWalkPixel(const struct bContext *UNUSED(C), ARegion *ar, void *arg) { /* draws an aim/cross in the center */ @@ -420,6 +426,7 @@ static float userdef_speed = -1.f; static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) { + wmWindowManager *wm = CTX_wm_manager(C); Main *bmain = CTX_data_main(C); wmWindow *win = CTX_wm_window(C); @@ -512,6 +519,8 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->ndof = NULL; #endif + walk->anim_playing = ED_screen_animation_playing(wm); + walk->time_lastdraw = PIL_check_seconds_timer(); walk->draw_handle_pixel = ED_region_draw_cb_activate( @@ -563,6 +572,18 @@ static int walkEnd(bContext *C, WalkInfo *walk) if (walk->state == WALK_RUNNING) { return OPERATOR_RUNNING_MODAL; } + else if (walk->state == WALK_CONFIRM) { + /* Needed for auto_keyframe. */ +#ifdef WITH_INPUT_NDOF + if (walk->ndof) { + walkApply_ndof(C, walk, true); + } + else +#endif /* WITH_INPUT_NDOF */ + { + walkApply(C, walk, true); + } + } #ifdef NDOF_WALK_DEBUG puts("\n-- walk end --"); @@ -885,9 +906,15 @@ static void walkEvent(bContext *C, WalkInfo *walk, const wmEvent *event) static void walkMoveCamera(bContext *C, WalkInfo *walk, const bool do_rotate, - const bool do_translate) + const bool do_translate, + const bool is_confirm) { - ED_view3d_cameracontrol_update(walk->v3d_camera_control, true, C, do_rotate, do_translate); + /* we only consider autokeying on playback or if user confirmed walk on the same frame + * otherwise we get a keyframe even if the user cancels. */ + const bool use_autokey = is_confirm || walk->anim_playing; + + ED_view3d_cameracontrol_update( + walk->v3d_camera_control, use_autokey, C, do_rotate, do_translate); } static float getFreeFallDistance(const float gravity, const float time) @@ -900,7 +927,7 @@ static float getVelocityZeroTime(const float gravity, const float velocity) return velocity / gravity; } -static int walkApply(bContext *C, WalkInfo *walk) +static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm) { #define WALK_ROTATE_FAC 2.2f /* more is faster */ #define WALK_TOP_LIMIT DEG2RADF(85.0f) @@ -945,7 +972,7 @@ static int walkApply(bContext *C, WalkInfo *walk) /* Should we redraw? */ if ((walk->active_directions) || moffset[0] || moffset[1] || walk->teleport.state == WALK_TELEPORT_STATE_ON || - walk->gravity_state != WALK_GRAVITY_STATE_OFF) { + walk->gravity_state != WALK_GRAVITY_STATE_OFF || is_confirm) { float dvec_tmp[3]; /* time how fast it takes for us to redraw, @@ -1237,7 +1264,7 @@ static int walkApply(bContext *C, WalkInfo *walk) if (rv3d->persp == RV3D_CAMOB) { const bool do_rotate = (moffset[0] || moffset[1]); const bool do_translate = (walk->speed != 0.0f); - walkMoveCamera(C, walk, do_rotate, do_translate); + walkMoveCamera(C, walk, do_rotate, do_translate, is_confirm); } } else { @@ -1260,7 +1287,7 @@ static int walkApply(bContext *C, WalkInfo *walk) } #ifdef WITH_INPUT_NDOF -static void walkApply_ndof(bContext *C, WalkInfo *walk) +static void walkApply_ndof(bContext *C, WalkInfo *walk, bool is_confirm) { Object *lock_ob = ED_view3d_cameracontrol_object_get(walk->v3d_camera_control); bool has_translate, has_rotate; @@ -1277,7 +1304,7 @@ static void walkApply_ndof(bContext *C, WalkInfo *walk) walk->redraw = true; if (walk->rv3d->persp == RV3D_CAMOB) { - walkMoveCamera(C, walk, has_rotate, has_translate); + walkMoveCamera(C, walk, has_rotate, has_translate, is_confirm); } } } @@ -1333,13 +1360,13 @@ static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event) #ifdef WITH_INPUT_NDOF if (walk->ndof) { /* 3D mouse overrules [2D mouse + timer] */ if (event->type == NDOF_MOTION) { - walkApply_ndof(C, walk); + walkApply_ndof(C, walk, false); } } else #endif /* WITH_INPUT_NDOF */ if (event->type == TIMER && event->customdata == walk->timer) { - walkApply(C, walk); + walkApply(C, walk, false); } do_draw |= walk->redraw; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 973c1c0b7f7..98203a7e316 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4607,6 +4607,10 @@ static void applyRotationValue(TransInfo *t, } axis_angle_normalized_to_mat3(mat, axis, angle); + /* Counter for needed updates (when we need to update to non-default matrix, + * we also need another update on next iteration to go back to default matrix, + * hence the '2' value used here, instead of a mere boolean). */ + short do_update_matrix = 0; FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; @@ -4623,6 +4627,9 @@ static void applyRotationValue(TransInfo *t, if (t->con.applyRot) { t->con.applyRot(t, tc, td, axis, NULL); angle_final = angle * td->factor; + /* Even though final angle might be identical to orig value, + * we have to update the rotation matrix in that case... */ + do_update_matrix = 2; } else if (t->flag & T_PROP_EDIT) { angle_final = angle * td->factor; @@ -4645,11 +4652,17 @@ static void applyRotationValue(TransInfo *t, axis_angle_normalized_to_mat3(mat, axis, angle_progress); ElementRotation(t, tc, td, mat, t->around); } - axis_angle_normalized_to_mat3(mat, axis, angle_final); + do_update_matrix = 2; } else if (angle_final != angle) { + do_update_matrix = 2; + } + + if (do_update_matrix > 0) { axis_angle_normalized_to_mat3(mat, axis, angle_final); + do_update_matrix--; } + ElementRotation(t, tc, td, mat, t->around); } } @@ -9449,7 +9462,7 @@ static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR]) } } -static void applyTimeTranslateValue(TransInfo *t) +static void applyTimeTranslateValue(TransInfo *t, float value) { Scene *scene = t->scene; int i; @@ -9458,7 +9471,6 @@ static void applyTimeTranslateValue(TransInfo *t) const double secf = FPS; float deltax, val /* , valprev */; - t->values_final[0] = t->values[0]; FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; @@ -9476,7 +9488,7 @@ static void applyTimeTranslateValue(TransInfo *t) /* check if any need to apply nla-mapping */ if (adt && (t->spacetype != SPACE_SEQ)) { - deltax = t->values_final[0]; + deltax = value; if (autosnap == SACTSNAP_TSTEP) { deltax = (float)(floor(((double)deltax / secf) + 0.5) * secf); @@ -9529,7 +9541,7 @@ static void applyTimeTranslate(TransInfo *t, const int mval[2]) t->values_final[0] = t->vec[0]; headerTimeTranslate(t, str); - applyTimeTranslateValue(t); + applyTimeTranslateValue(t, t->values_final[0]); recalcData(t); @@ -9637,20 +9649,17 @@ static void headerTimeSlide(TransInfo *t, const float sval, char str[UI_MAX_DRAW BLI_snprintf(str, UI_MAX_DRAW_STR, TIP_("TimeSlide: %s"), &tvec[0]); } -static void applyTimeSlideValue(TransInfo *t, float sval) +static void applyTimeSlideValue(TransInfo *t, float sval, float cval) { int i; const float *range = t->custom.mode.data; float minx = range[0]; float maxx = range[1]; - t->values_final[0] = t->values[0]; /* set value for drawing black line */ if (t->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; - float cvalf = t->values_final[0]; - - saction->timeslide = cvalf; + saction->timeslide = cval; } /* It doesn't matter whether we apply to t->data or @@ -9663,7 +9672,6 @@ static void applyTimeSlideValue(TransInfo *t, float sval) * (this is only valid when not in NLA) */ AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL; - float cval = t->values_final[0]; /* only apply to data if in range */ if ((sval > minx) && (sval < maxx)) { @@ -9724,7 +9732,7 @@ static void applyTimeSlide(TransInfo *t, const int mval[2]) t->values_final[0] = (maxx - minx) * t->vec[0] / 2.0f + sval[0]; headerTimeSlide(t, sval[0], str); - applyTimeSlideValue(t, sval[0]); + applyTimeSlideValue(t, sval[0], t->values_final[0]); recalcData(t); @@ -9796,14 +9804,13 @@ static void headerTimeScale(TransInfo *t, char str[UI_MAX_DRAW_STR]) BLI_snprintf(str, UI_MAX_DRAW_STR, TIP_("ScaleX: %s"), &tvec[0]); } -static void applyTimeScaleValue(TransInfo *t) +static void applyTimeScaleValue(TransInfo *t, float value) { Scene *scene = t->scene; int i; const short autosnap = getAnimEdit_SnapMode(t); const double secf = FPS; - t->values_final[0] = t->values[0]; FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; @@ -9815,7 +9822,7 @@ static void applyTimeScaleValue(TransInfo *t) */ AnimData *adt = (t->spacetype != SPACE_NLA) ? td->extra : NULL; float startx = CFRA; - float fac = t->values_final[0]; + float fac = value; if (autosnap == SACTSNAP_TSTEP) { fac = (float)(floor((double)fac / secf + 0.5) * secf); @@ -9851,7 +9858,7 @@ static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2])) t->values_final[0] = t->vec[0]; headerTimeScale(t, str); - applyTimeScaleValue(t); + applyTimeScaleValue(t, t->values_final[0]); recalcData(t); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 4eccf4c5071..ef9d23d1db8 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -9049,7 +9049,7 @@ static void createTransGPencil(bContext *C, TransInfo *t) /* initialize falloff curve */ if (is_multiedit) { - curvemapping_initialize(ts->gp_sculpt.cur_falloff); + BKE_curvemapping_initialize(ts->gp_sculpt.cur_falloff); } /* First Pass: Count the number of data-points required for the strokes, diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 5e9add74b42..f8e33fe70ad 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -883,6 +883,16 @@ static void TRANSFORM_OT_bend(struct wmOperatorType *ot) Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER); } +static bool transform_shear_poll(bContext *C) +{ + if (!ED_operator_screenactive(C)) { + return false; + } + + ScrArea *sa = CTX_wm_area(C); + return sa && !ELEM(sa->spacetype, SPACE_ACTION); +} + static void TRANSFORM_OT_shear(struct wmOperatorType *ot) { /* identifiers */ @@ -896,7 +906,7 @@ static void TRANSFORM_OT_shear(struct wmOperatorType *ot) ot->exec = transform_exec; ot->modal = transform_modal; ot->cancel = transform_cancel; - ot->poll = ED_operator_screenactive; + ot->poll = transform_shear_poll; ot->poll_property = transform_poll_property; RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX); diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 6f06f8639bd..67bd107ab49 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -573,11 +573,11 @@ static bool raycastEditMesh(SnapObjectContext *sctx, BVHTreeFromEditMesh *treedata = sod->bvh_trees[2]; - BVHCache *em_bvh_cache = ((Mesh *)em->ob->data)->runtime.bvh_cache; + BVHCache **em_bvh_cache = &((Mesh *)em->ob->data)->runtime.bvh_cache; if (sctx->callbacks.edit_mesh.test_face_fn == NULL) { /* The tree is owned by the Mesh and may have been freed since we last used! */ - if (!bvhcache_has_tree(em_bvh_cache, treedata->tree)) { + if (treedata->tree && !bvhcache_has_tree(*em_bvh_cache, treedata->tree)) { free_bvhtree_from_editmesh(treedata); } } @@ -605,7 +605,7 @@ static bool raycastEditMesh(SnapObjectContext *sctx, else { /* Only cache if bvhtree is created without a mask. * This helps keep a standardized bvhtree in cache. */ - bvh_cache = &em_bvh_cache; + bvh_cache = em_bvh_cache; } bvhtree_from_editmesh_looptri_ex( @@ -1382,6 +1382,13 @@ static short snap_mesh_edge_verts_mixed(SnapObjectContext *sctx, }; SnapObjectData *sod = BLI_ghash_lookup(sctx->cache.object_map, ob); + if (sod == NULL) { + /* The object is in edit mode, and the key used + * was the object referenced in BMEditMesh */ + BMEditMesh *em = BKE_editmesh_from_object(ob); + sod = BLI_ghash_lookup(sctx->cache.object_map, em->ob); + } + BLI_assert(sod != NULL); if (sod->type == SNAP_MESH) { @@ -2188,7 +2195,7 @@ static short snapEditMesh(SnapObjectContext *sctx, return 0; } - BVHCache *em_bvh_cache = ((Mesh *)em->ob->data)->runtime.bvh_cache; + BVHCache **em_bvh_cache = &((Mesh *)em->ob->data)->runtime.bvh_cache; if (snapdata->snap_to_flag & SCE_SNAP_MODE_VERTEX) { if (sod->bvh_trees[0] == NULL) { @@ -2198,7 +2205,7 @@ static short snapEditMesh(SnapObjectContext *sctx, if (sctx->callbacks.edit_mesh.test_vert_fn == NULL) { /* The tree is owned by the Mesh and may have been freed since we last used! */ - if (!bvhcache_has_tree(em_bvh_cache, treedata_vert->tree)) { + if (treedata_vert->tree && !bvhcache_has_tree(*em_bvh_cache, treedata_vert->tree)) { free_bvhtree_from_editmesh(treedata_vert); } } @@ -2220,7 +2227,7 @@ static short snapEditMesh(SnapObjectContext *sctx, MEM_freeN(verts_mask); } else { - bvhtree_from_editmesh_verts(treedata_vert, em, 0.0f, 2, 6, &em_bvh_cache); + bvhtree_from_editmesh_verts(treedata_vert, em, 0.0f, 2, 6, em_bvh_cache); } } } @@ -2233,7 +2240,7 @@ static short snapEditMesh(SnapObjectContext *sctx, if (sctx->callbacks.edit_mesh.test_edge_fn == NULL) { /* The tree is owned by the Mesh and may have been freed since we last used! */ - if (!bvhcache_has_tree(em_bvh_cache, treedata_edge->tree)) { + if (treedata_edge->tree && !bvhcache_has_tree(*em_bvh_cache, treedata_edge->tree)) { free_bvhtree_from_editmesh(treedata_edge); } } @@ -2255,7 +2262,7 @@ static short snapEditMesh(SnapObjectContext *sctx, MEM_freeN(edges_mask); } else { - bvhtree_from_editmesh_edges(treedata_edge, em, 0.0f, 2, 6, &em_bvh_cache); + bvhtree_from_editmesh_edges(treedata_edge, em, 0.0f, 2, 6, em_bvh_cache); } } } diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index c09237d825d..0564cb07897 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -41,7 +41,6 @@ set(SRC ed_util.c gizmo_utils.c numinput.c - select_buffer_utils.c select_utils.c # general includes @@ -80,7 +79,6 @@ set(SRC ../include/ED_screen.h ../include/ED_screen_types.h ../include/ED_sculpt.h - ../include/ED_select_buffer_utils.h ../include/ED_select_utils.h ../include/ED_sequencer.h ../include/ED_sound.h diff --git a/source/blender/editors/util/select_buffer_utils.c b/source/blender/editors/util/select_buffer_utils.c deleted file mode 100644 index 2201ee5cec2..00000000000 --- a/source/blender/editors/util/select_buffer_utils.c +++ /dev/null @@ -1,303 +0,0 @@ -/* - * 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) 2008 Blender Foundation. - * All rights reserved. - */ - -/** \file - * \ingroup edutil - * - * Generic utilities for handling buffer selection where selection ID's are drawn onto - * an off screen buffer. - * - * All coordinates are relative to the current region. - */ - -#include "MEM_guardedalloc.h" - -#include "BLI_bitmap.h" -#include "BLI_bitmap_draw_2d.h" -#include "BLI_rect.h" -#include "BLI_utildefines.h" - -#include "ED_select_buffer_utils.h" - -/* Only for #ED_view3d_select_id_read, - * note that this file shouldn't have 3D view specific logic in it, we could have a more general - * way to read from selection buffers that doesn't depend on the view3d API. */ -#include "ED_view3d.h" - -/* -------------------------------------------------------------------- */ -/** \name Select Bitmap from ID's - * - * Given a buffer of select ID's, fill in a booleans (true/false) per index. - * #BLI_bitmap is used for memory efficiency. - * - * \{ */ - -/** - * \param bitmap_len: Number of indices in the selection id buffer. - * \param rect: The rectangle to sample indices from (min/max inclusive). - * \returns a #BLI_bitmap the length of \a bitmap_len or NULL on failure. - */ -uint *ED_select_buffer_bitmap_from_rect(const uint bitmap_len, const rcti *rect) -{ - uint buf_len; - const uint *buf = ED_view3d_select_id_read( - rect->xmin, rect->ymin, rect->xmax, rect->ymax, &buf_len); - if (buf == NULL) { - return NULL; - } - - const uint *buf_iter = buf; - - BLI_bitmap *bitmap_buf = BLI_BITMAP_NEW(bitmap_len, __func__); - - while (buf_len--) { - const uint index = *buf_iter - 1; - if (index < bitmap_len) { - BLI_BITMAP_ENABLE(bitmap_buf, index); - } - buf_iter++; - } - MEM_freeN((void *)buf); - return bitmap_buf; -} - -/** - * \param bitmap_len: Number of indices in the selection id buffer. - * \param center: Circle center. - * \param radius: Circle radius. - * \returns a #BLI_bitmap the length of \a bitmap_len or NULL on failure. - */ -uint *ED_select_buffer_bitmap_from_circle(const uint bitmap_len, - const int center[2], - const int radius) -{ - if (bitmap_len == 0) { - return NULL; - } - - const int xmin = center[0] - radius; - const int xmax = center[0] + radius; - const int ymin = center[1] - radius; - const int ymax = center[1] + radius; - - const uint *buf = ED_view3d_select_id_read(xmin, ymin, xmax, ymax, NULL); - if (buf == NULL) { - return NULL; - } - - const uint *buf_iter = buf; - - BLI_bitmap *bitmap_buf = BLI_BITMAP_NEW(bitmap_len, __func__); - const int radius_sq = radius * radius; - for (int yc = -radius; yc <= radius; yc++) { - for (int xc = -radius; xc <= radius; xc++, buf_iter++) { - if (xc * xc + yc * yc < radius_sq) { - /* Intentionally wrap to max value if this is zero. */ - const uint index = *buf_iter - 1; - if (index < bitmap_len) { - BLI_BITMAP_ENABLE(bitmap_buf, index); - } - } - } - } - MEM_freeN((void *)buf); - return bitmap_buf; -} - -struct PolyMaskData { - BLI_bitmap *px; - int width; -}; - -static void ed_select_buffer_mask_px_cb(int x, int x_end, int y, void *user_data) -{ - struct PolyMaskData *data = user_data; - BLI_bitmap *px = data->px; - int i = (y * data->width) + x; - do { - BLI_BITMAP_ENABLE(px, i); - i++; - } while (++x != x_end); -} - -/** - * \param bitmap_len: Number of indices in the selection id buffer. - * \param center: Circle center. - * \param radius: Circle radius. - * \returns a #BLI_bitmap the length of \a bitmap_len or NULL on failure. - */ -uint *ED_select_buffer_bitmap_from_poly(const uint bitmap_len, - const int poly[][2], - const int poly_len, - const rcti *rect) - -{ - if (bitmap_len == 0) { - return NULL; - } - - struct PolyMaskData poly_mask_data; - uint buf_len; - const uint *buf = ED_view3d_select_id_read( - rect->xmin, rect->ymin, rect->xmax, rect->ymax, &buf_len); - if (buf == NULL) { - return NULL; - } - - BLI_bitmap *buf_mask = BLI_BITMAP_NEW(buf_len, __func__); - poly_mask_data.px = buf_mask; - poly_mask_data.width = (rect->xmax - rect->xmin) + 1; - - BLI_bitmap_draw_2d_poly_v2i_n(rect->xmin, - rect->ymin, - rect->xmax + 1, - rect->ymax + 1, - poly, - poly_len, - ed_select_buffer_mask_px_cb, - &poly_mask_data); - - /* Build selection lookup. */ - const uint *buf_iter = buf; - BLI_bitmap *bitmap_buf = BLI_BITMAP_NEW(bitmap_len, __func__); - int i = 0; - while (buf_len--) { - const uint index = *buf_iter - 1; - if (index < bitmap_len && BLI_BITMAP_TEST(buf_mask, i)) { - BLI_BITMAP_ENABLE(bitmap_buf, index); - } - buf_iter++; - i++; - } - MEM_freeN((void *)buf); - MEM_freeN(buf_mask); - - return bitmap_buf; -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Find Single Select ID's - * - * Given a buffer of select ID's, find the a single select id. - * - * \{ */ - -/** - * Samples a single pixel. - */ -uint ED_select_buffer_sample_point(const int center[2]) -{ - uint buf_len; - uint *buf = ED_view3d_select_id_read(center[0], center[1], center[0], center[1], &buf_len); - BLI_assert(0 != buf_len); - uint ret = buf[0]; - MEM_freeN(buf); - return ret; -} - -/** - * Find the selection id closest to \a center. - * \param dist[in,out]: Use to initialize the distance, - * when found, this value is set to the distance of the selection that's returned. - */ -uint ED_select_buffer_find_nearest_to_point(const int center[2], - const uint id_min, - const uint id_max, - uint *dist) -{ - /* Smart function to sample a rect spiraling outside, nice for selection ID. */ - - /* Create region around center (typically the mouse cursor). - * This must be square and have an odd width, - * the spiraling algorithm does not work with arbitrary rectangles. */ - rcti rect; - BLI_rcti_init_pt_radius(&rect, center, *dist); - rect.xmax += 1; - rect.ymax += 1; - - int width = BLI_rcti_size_x(&rect); - int height = width; - BLI_assert(width == height); - - /* Read from selection framebuffer. */ - - uint buf_len; - const uint *buf = ED_view3d_select_id_read_rect(&rect, &buf_len); - BLI_assert(width * height == buf_len); - - /* Spiral, starting from center of buffer. */ - int spiral_offset = height * (int)(width / 2) + (height / 2); - int spiral_direction = 0; - - uint index = 0; - - for (int nr = 1; nr <= height; nr++) { - for (int a = 0; a < 2; a++) { - for (int b = 0; b < nr; b++) { - /* Find hit within the specified range. */ - uint hit_id = buf[spiral_offset]; - - if (hit_id && hit_id >= id_min && hit_id < id_max) { - /* Get x/y from spiral offset. */ - int hit_x = spiral_offset % width; - int hit_y = spiral_offset / width; - - int center_x = width / 2; - int center_y = height / 2; - - /* Manhatten distance in keeping with other screen-based selection. */ - *dist = (uint)(abs(hit_x - center_x) + abs(hit_y - center_y)); - - /* Indices start at 1 here. */ - index = (hit_id - id_min) + 1; - goto exit; - } - - /* Next spiral step. */ - if (spiral_direction == 0) { - spiral_offset += 1; /* right */ - } - else if (spiral_direction == 1) { - spiral_offset -= width; /* down */ - } - else if (spiral_direction == 2) { - spiral_offset -= 1; /* left */ - } - else { - spiral_offset += width; /* up */ - } - - /* Stop if we are outside the buffer. */ - if (spiral_offset < 0 || spiral_offset >= buf_len) { - goto exit; - } - } - - spiral_direction = (spiral_direction + 1) % 4; - } - } - -exit: - MEM_freeN((void *)buf); - return index; -} - -/** \} */ diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 6a2f740ba51..883671949c8 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -43,7 +43,10 @@ #include "BLI_lasso_2d.h" #include "BLI_blenlib.h" #include "BLI_array.h" +#include "BLI_hash.h" #include "BLI_kdtree.h" +#include "BLI_kdopbvh.h" +#include "BLI_polyfill_2d.h" #include "BLT_translation.h" @@ -4339,6 +4342,246 @@ static void UV_OT_select_pinned(wmOperatorType *ot) /** \} */ /* -------------------------------------------------------------------- */ +/** \name Select Overlap Operator + * \{ */ + +BLI_INLINE uint overlap_hash(const void *overlap_v) +{ + const BVHTreeOverlap *overlap = overlap_v; + + /* Designed to treat (A,B) and (B,A) as the same. */ + int x = overlap->indexA; + int y = overlap->indexB; + if (x > y) { + SWAP(int, x, y); + } + return BLI_hash_int_2d(x, y); +} + +BLI_INLINE bool overlap_cmp(const void *a_v, const void *b_v) +{ + const BVHTreeOverlap *a = a_v; + const BVHTreeOverlap *b = b_v; + return !((a->indexA == b->indexA && a->indexB == b->indexB) || + (a->indexA == b->indexB && a->indexB == b->indexA)); +} + +struct UVOverlapData { + int ob_index; + int face_index; + float tri[3][2]; +}; + +static int uv_select_overlap(bContext *C, const bool extend) +{ + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Image *ima = CTX_data_edit_image(C); + + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs( + view_layer, ((View3D *)NULL), &objects_len); + + /* Calculate maximum number of tree nodes and prepare initial selection. */ + uint uv_tri_len = 0; + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + BMEditMesh *em = BKE_editmesh_from_object(obedit); + + BM_mesh_elem_table_ensure(em->bm, BM_FACE); + BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_FACE); + BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, false); + if (!extend) { + uv_select_all_perform(scene, ima, obedit, SEL_DESELECT); + } + + BMIter iter; + BMFace *efa; + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + if (!uvedit_face_visible_test_ex(scene->toolsettings, obedit, ima, efa)) { + continue; + } + uv_tri_len += efa->len - 2; + } + } + + struct UVOverlapData *overlap_data = MEM_mallocN(sizeof(struct UVOverlapData) * uv_tri_len, + "UvOverlapData"); + BVHTree *uv_tree = BLI_bvhtree_new(uv_tri_len, 0.0f, 4, 6); + + /* Use a global data index when inserting into the BVH. */ + int data_index = 0; + + int face_len_alloc = 3; + float(*uv_verts)[2] = MEM_mallocN(sizeof(*uv_verts) * face_len_alloc, "UvOverlapCoords"); + uint(*indices)[3] = MEM_mallocN(sizeof(*indices) * (face_len_alloc - 2), "UvOverlapTris"); + + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + BMEditMesh *em = BKE_editmesh_from_object(obedit); + BMIter iter, liter; + BMFace *efa; + BMLoop *l; + + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); + + /* Triangulate each UV face and store it inside the BVH. */ + int face_index; + BM_ITER_MESH_INDEX (efa, &iter, em->bm, BM_FACES_OF_MESH, face_index) { + + if (!uvedit_face_visible_test_ex(scene->toolsettings, obedit, ima, efa)) { + continue; + } + + const uint face_len = efa->len; + const uint tri_len = face_len - 2; + + if (face_len_alloc < face_len) { + MEM_freeN(uv_verts); + MEM_freeN(indices); + uv_verts = MEM_mallocN(sizeof(*uv_verts) * face_len, "UvOverlapCoords"); + indices = MEM_mallocN(sizeof(*indices) * tri_len, "UvOverlapTris"); + face_len_alloc = face_len; + } + + int vert_index; + BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, vert_index) { + MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + copy_v2_v2(uv_verts[vert_index], luv->uv); + } + + BLI_polyfill_calc(uv_verts, face_len, 0, indices); + + for (int t = 0; t < tri_len; t++) { + overlap_data[data_index].ob_index = ob_index; + overlap_data[data_index].face_index = face_index; + + /* BVH needs 3D, overlap data uses 2D. */ + float tri[3][3] = { + {UNPACK2(uv_verts[indices[t][0]]), 0.0f}, + {UNPACK2(uv_verts[indices[t][1]]), 0.0f}, + {UNPACK2(uv_verts[indices[t][2]]), 0.0f}, + }; + + copy_v2_v2(overlap_data[data_index].tri[0], tri[0]); + copy_v2_v2(overlap_data[data_index].tri[1], tri[1]); + copy_v2_v2(overlap_data[data_index].tri[2], tri[2]); + + BLI_bvhtree_insert(uv_tree, data_index, &tri[0][0], 3); + data_index++; + } + } + } + BLI_assert(data_index == uv_tri_len); + + MEM_freeN(uv_verts); + MEM_freeN(indices); + + BLI_bvhtree_balance(uv_tree); + + uint tree_overlap_len; + BVHTreeOverlap *overlap = BLI_bvhtree_overlap(uv_tree, uv_tree, &tree_overlap_len, NULL, NULL); + + if (overlap != NULL) { + GSet *overlap_set = BLI_gset_new_ex(overlap_hash, overlap_cmp, __func__, tree_overlap_len); + + for (int i = 0; i < tree_overlap_len; i++) { + /* Skip overlaps against yourself. */ + if (overlap[i].indexA == overlap[i].indexB) { + continue; + } + + /* Skip overlaps that have already been tested. */ + if (!BLI_gset_add(overlap_set, &overlap[i])) { + continue; + } + + const struct UVOverlapData *o_a = &overlap_data[overlap[i].indexA]; + const struct UVOverlapData *o_b = &overlap_data[overlap[i].indexB]; + Object *obedit_a = objects[o_a->ob_index]; + Object *obedit_b = objects[o_b->ob_index]; + BMEditMesh *em_a = BKE_editmesh_from_object(obedit_a); + BMEditMesh *em_b = BKE_editmesh_from_object(obedit_b); + BMFace *face_a = em_a->bm->ftable[o_a->face_index]; + BMFace *face_b = em_b->bm->ftable[o_b->face_index]; + const int cd_loop_uv_offset_a = CustomData_get_offset(&em_a->bm->ldata, CD_MLOOPUV); + const int cd_loop_uv_offset_b = CustomData_get_offset(&em_b->bm->ldata, CD_MLOOPUV); + + /* Skip if both faces are already selected. */ + if (uvedit_face_select_test(scene, face_a, cd_loop_uv_offset_a) && + uvedit_face_select_test(scene, face_b, cd_loop_uv_offset_b)) { + continue; + } + + /* Main tri-tri overlap test. */ + const float endpoint_bias = -1e-4f; + const float(*t1)[2] = o_a->tri; + const float(*t2)[2] = o_b->tri; + float vi[2]; + bool result = + isect_seg_seg_v2_point_ex(t1[0], t1[1], t2[0], t2[1], endpoint_bias, vi) == 1 || + isect_seg_seg_v2_point_ex(t1[0], t1[1], t2[1], t2[2], endpoint_bias, vi) == 1 || + isect_seg_seg_v2_point_ex(t1[0], t1[1], t2[2], t2[0], endpoint_bias, vi) == 1 || + isect_seg_seg_v2_point_ex(t1[1], t1[2], t2[0], t2[1], endpoint_bias, vi) == 1 || + isect_seg_seg_v2_point_ex(t1[1], t1[2], t2[1], t2[2], endpoint_bias, vi) == 1 || + isect_seg_seg_v2_point_ex(t1[1], t1[2], t2[2], t2[0], endpoint_bias, vi) == 1 || + isect_seg_seg_v2_point_ex(t1[2], t1[0], t2[0], t2[1], endpoint_bias, vi) == 1 || + isect_seg_seg_v2_point_ex(t1[2], t1[0], t2[1], t2[2], endpoint_bias, vi) == 1 || + isect_point_tri_v2(t1[0], t2[0], t2[1], t2[2]) != 0 || + isect_point_tri_v2(t2[0], t1[0], t1[1], t1[2]) != 0; + + if (result) { + uvedit_face_select_enable(scene, em_a, face_a, false, cd_loop_uv_offset_a); + uvedit_face_select_enable(scene, em_b, face_b, false, cd_loop_uv_offset_b); + } + } + + BLI_gset_free(overlap_set, NULL); + MEM_freeN(overlap); + } + + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + uv_select_tag_update_for_object(depsgraph, scene->toolsettings, objects[ob_index]); + } + + BLI_bvhtree_free(uv_tree); + + MEM_freeN(overlap_data); + MEM_freeN(objects); + + return OPERATOR_FINISHED; +} + +static int uv_select_overlap_exec(bContext *C, wmOperator *op) +{ + bool extend = RNA_boolean_get(op->ptr, "extend"); + return uv_select_overlap(C, extend); +} + +static void UV_OT_select_overlap(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Overlap"; + ot->description = "Select all UV faces which overlap each other"; + ot->idname = "UV_OT_select_overlap"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* api callbacks */ + ot->exec = uv_select_overlap_exec; + ot->poll = ED_operator_uvedit; + + /* properties */ + RNA_def_boolean(ot->srna, + "extend", + 0, + "Extend", + "Extend selection rather than clearing the existing selection"); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name Hide Operator * \{ */ @@ -4971,6 +5214,7 @@ void ED_operatortypes_uvedit(void) WM_operatortype_append(UV_OT_select_circle); WM_operatortype_append(UV_OT_select_more); WM_operatortype_append(UV_OT_select_less); + WM_operatortype_append(UV_OT_select_overlap); WM_operatortype_append(UV_OT_snap_cursor); WM_operatortype_append(UV_OT_snap_selected); diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp index 71cdbafba45..367ad556d02 100644 --- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp +++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp @@ -229,7 +229,7 @@ static PyObject *Freestyle_evaluateColorRamp(PyObject * /*self*/, PyObject *args } #include "DNA_color_types.h" -#include "BKE_colortools.h" /* curvemapping_evaluateF() */ +#include "BKE_colortools.h" /* BKE_curvemapping_evaluateF() */ static char Freestyle_evaluateCurveMappingF___doc__[] = ".. function:: evaluateCurveMappingF(cumap, cur, value)\n" @@ -264,13 +264,13 @@ static PyObject *Freestyle_evaluateCurveMappingF(PyObject * /*self*/, PyObject * return NULL; } cumap = (CurveMapping *)py_srna->ptr.data; - curvemapping_initialize(cumap); + BKE_curvemapping_initialize(cumap); /* disable extrapolation if enabled */ if ((cumap->cm[cur].flag & CUMA_EXTEND_EXTRAPOLATE)) { cumap->cm[cur].flag &= ~(CUMA_EXTEND_EXTRAPOLATE); - curvemapping_changed(cumap, 0); + BKE_curvemapping_changed(cumap, 0); } - return PyFloat_FromDouble(curvemapping_evaluateF(cumap, cur, value)); + return PyFloat_FromDouble(BKE_curvemapping_evaluateF(cumap, cur, value)); } /*-----------------------Freestyle module docstring----------------------------*/ diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c index d56b3217c9f..a3dbcdf23de 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c @@ -81,9 +81,9 @@ static void initData(GpencilModifierData *md) gpmd->object = NULL; gpmd->force = 0.5f; gpmd->falloff_type = eGPHook_Falloff_Smooth; - gpmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + gpmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (gpmd->curfalloff) { - curvemapping_initialize(gpmd->curfalloff); + BKE_curvemapping_initialize(gpmd->curfalloff); } } @@ -93,13 +93,13 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target) HookGpencilModifierData *tgmd = (HookGpencilModifierData *)target; if (tgmd->curfalloff != NULL) { - curvemapping_free(tgmd->curfalloff); + BKE_curvemapping_free(tgmd->curfalloff); tgmd->curfalloff = NULL; } BKE_gpencil_modifier_copyData_generic(md, target); - tgmd->curfalloff = curvemapping_copy(gmd->curfalloff); + tgmd->curfalloff = BKE_curvemapping_copy(gmd->curfalloff); } /* calculate factor of fallof */ @@ -126,7 +126,7 @@ static float gp_hook_falloff(const struct GPHookData_cb *tData, const float len_ switch (tData->falloff_type) { case eGPHook_Falloff_Curve: - fac = curvemapping_evaluateF(tData->curfalloff, 0, fac); + fac = BKE_curvemapping_evaluateF(tData->curfalloff, 0, fac); break; case eGPHook_Falloff_Sharp: fac = fac * fac; @@ -301,7 +301,7 @@ static void freeData(GpencilModifierData *md) HookGpencilModifierData *mmd = (HookGpencilModifierData *)md; if (mmd->curfalloff) { - curvemapping_free(mmd->curfalloff); + BKE_curvemapping_free(mmd->curfalloff); } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c index 746a689c08e..a27fb27d518 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c @@ -45,6 +45,7 @@ static void initData(GpencilModifierData *md) gpmd->pass_index = 0; gpmd->step = 1; gpmd->factor = 0.0f; + gpmd->length = 0.1f; gpmd->layername[0] = '\0'; } @@ -57,7 +58,7 @@ static void deformStroke(GpencilModifierData *md, Depsgraph *UNUSED(depsgraph), Object *ob, bGPDlayer *gpl, - bGPDframe *UNUSED(gpf), + bGPDframe *gpf, bGPDstroke *gps) { SimplifyGpencilModifierData *mmd = (SimplifyGpencilModifierData *)md; @@ -66,7 +67,7 @@ static void deformStroke(GpencilModifierData *md, mmd->layername, mmd->pass_index, mmd->layer_pass, - 4, + mmd->mode == GP_SIMPLIFY_SAMPLE ? 3 : 4, gpl, gps, mmd->flag & GP_SIMPLIFY_INVERT_LAYER, @@ -75,14 +76,29 @@ static void deformStroke(GpencilModifierData *md, return; } - if (mmd->mode == GP_SIMPLIFY_FIXED) { - for (int i = 0; i < mmd->step; i++) { - BKE_gpencil_simplify_fixed(gps); + /* Select simplification mode. */ + switch (mmd->mode) { + case GP_SIMPLIFY_FIXED: { + for (int i = 0; i < mmd->step; i++) { + BKE_gpencil_simplify_fixed(gps); + } + break; } - } - else { - /* simplify stroke using Ramer-Douglas-Peucker algorithm */ - BKE_gpencil_simplify_stroke(gps, mmd->factor); + case GP_SIMPLIFY_ADAPTIVE: { + /* simplify stroke using Ramer-Douglas-Peucker algorithm */ + BKE_gpencil_simplify_stroke(gps, mmd->factor); + break; + } + case GP_SIMPLIFY_SAMPLE: { + BKE_gpencil_sample_stroke(gps, mmd->length, false); + break; + } + case GP_SIMPLIFY_MERGE: { + BKE_gpencil_merge_distance_stroke(gpf, gps, mmd->length, true); + break; + } + default: + break; } } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c index bf4f45b10af..357e36a06b2 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c @@ -48,9 +48,9 @@ static void initData(GpencilModifierData *md) gpmd->thickness = 2; gpmd->layername[0] = '\0'; gpmd->vgname[0] = '\0'; - gpmd->curve_thickness = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + gpmd->curve_thickness = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); if (gpmd->curve_thickness) { - curvemapping_initialize(gpmd->curve_thickness); + BKE_curvemapping_initialize(gpmd->curve_thickness); } } @@ -59,7 +59,7 @@ static void freeData(GpencilModifierData *md) ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md; if (gpmd->curve_thickness) { - curvemapping_free(gpmd->curve_thickness); + BKE_curvemapping_free(gpmd->curve_thickness); } } @@ -69,13 +69,13 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target) ThickGpencilModifierData *tgmd = (ThickGpencilModifierData *)target; if (tgmd->curve_thickness != NULL) { - curvemapping_free(tgmd->curve_thickness); + BKE_curvemapping_free(tgmd->curve_thickness); tgmd->curve_thickness = NULL; } BKE_gpencil_modifier_copyData_generic(md, target); - tgmd->curve_thickness = curvemapping_copy(gmd->curve_thickness); + tgmd->curve_thickness = BKE_curvemapping_copy(gmd->curve_thickness); } /* change stroke thickness */ @@ -125,7 +125,7 @@ static void deformStroke(GpencilModifierData *md, if ((mmd->flag & GP_THICK_CUSTOM_CURVE) && (mmd->curve_thickness)) { /* normalize value to evaluate curve */ float value = (float)i / (gps->totpoints - 1); - curvef = curvemapping_evaluateF(mmd->curve_thickness, 0, value); + curvef = BKE_curvemapping_evaluateF(mmd->curve_thickness, 0, value); } pt->pressure += mmd->thickness * weight * curvef; diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 59b0857c177..6eb8c80c58e 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -136,7 +136,7 @@ static bool gpu_pbvh_vert_buf_data_set(GPU_PBVH_Buffers *buffers, uint vert_len) /* TODO: Do not allocate these `.msk` and `.col` when they are not used. */ g_vbo_id.msk = GPU_vertformat_attr_add(&format, "msk", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); g_vbo_id.col = GPU_vertformat_attr_add( - &format, "c", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); + &format, "ac", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); } buffers->vert_buf = GPU_vertbuf_create_with_format_ex(&format, GPU_USAGE_STATIC); } diff --git a/source/blender/gpu/intern/gpu_context.cpp b/source/blender/gpu/intern/gpu_context.cpp index a0e03e61d5d..97f9e52f944 100644 --- a/source/blender/gpu/intern/gpu_context.cpp +++ b/source/blender/gpu/intern/gpu_context.cpp @@ -88,12 +88,7 @@ struct GPUContext { } }; -#if defined(_MSC_VER) && (_MSC_VER == 1800) -# define thread_local __declspec(thread) -thread_local GPUContext *active_ctx = NULL; -#else static thread_local GPUContext *active_ctx = NULL; -#endif static void orphans_add(GPUContext *ctx, std::vector<GLuint> *orphan_list, GLuint id) { diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 806bffea806..69e01882d50 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -420,12 +420,10 @@ void math_fraction(float a, float b, out float result) void math_modulo(float a, float b, out float result) { - result = (b != 0.0) ? mod(a, b) : 0.0; - /* Change sign to match C convention, mod in GLSL will take absolute for negative numbers. * See https://www.opengl.org/sdk/docs/man/html/mod.xhtml */ - result = (a > 0.0) ? result : result - b; + result = (b != 0.0) ? sign(a) * mod(abs(a), b) : 0.0; } void math_sine(float a, float b, out float result) diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index 4509daac81f..36af7ab2571 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -716,7 +716,7 @@ void colormanagement_exit(void) } if (global_glsl_state.curve_mapping) { - curvemapping_free(global_glsl_state.curve_mapping); + BKE_curvemapping_free(global_glsl_state.curve_mapping); } if (global_glsl_state.curve_mapping_settings.lut) { @@ -1029,14 +1029,14 @@ void IMB_colormanagement_init_default_view_settings( static void curve_mapping_apply_pixel(CurveMapping *curve_mapping, float *pixel, int channels) { if (channels == 1) { - pixel[0] = curvemap_evaluateF(curve_mapping->cm, pixel[0]); + pixel[0] = BKE_curvemap_evaluateF(curve_mapping->cm, pixel[0]); } else if (channels == 2) { - pixel[0] = curvemap_evaluateF(curve_mapping->cm, pixel[0]); - pixel[1] = curvemap_evaluateF(curve_mapping->cm, pixel[1]); + pixel[0] = BKE_curvemap_evaluateF(curve_mapping->cm, pixel[0]); + pixel[1] = BKE_curvemap_evaluateF(curve_mapping->cm, pixel[1]); } else { - curvemapping_evaluate_premulRGBF(curve_mapping, pixel, pixel); + BKE_curvemapping_evaluate_premulRGBF(curve_mapping, pixel, pixel); } } @@ -3728,8 +3728,8 @@ ColormanageProcessor *IMB_colormanagement_display_processor_new( global_role_scene_linear); if (applied_view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) { - cm_processor->curve_mapping = curvemapping_copy(applied_view_settings->curve_mapping); - curvemapping_premultiply(cm_processor->curve_mapping, false); + cm_processor->curve_mapping = BKE_curvemapping_copy(applied_view_settings->curve_mapping); + BKE_curvemapping_premultiply(cm_processor->curve_mapping, false); } return cm_processor; @@ -3754,7 +3754,7 @@ ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const char *f void IMB_colormanagement_processor_apply_v4(ColormanageProcessor *cm_processor, float pixel[4]) { if (cm_processor->curve_mapping) { - curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel); + BKE_curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel); } if (cm_processor->processor) { @@ -3766,7 +3766,7 @@ void IMB_colormanagement_processor_apply_v4_predivide(ColormanageProcessor *cm_p float pixel[4]) { if (cm_processor->curve_mapping) { - curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel); + BKE_curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel); } if (cm_processor->processor) { @@ -3777,7 +3777,7 @@ void IMB_colormanagement_processor_apply_v4_predivide(ColormanageProcessor *cm_p void IMB_colormanagement_processor_apply_v3(ColormanageProcessor *cm_processor, float pixel[3]) { if (cm_processor->curve_mapping) { - curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel); + BKE_curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel); } if (cm_processor->processor) { @@ -3870,7 +3870,7 @@ void IMB_colormanagement_processor_apply_byte( void IMB_colormanagement_processor_free(ColormanageProcessor *cm_processor) { if (cm_processor->curve_mapping) { - curvemapping_free(cm_processor->curve_mapping); + BKE_curvemapping_free(cm_processor->curve_mapping); } if (cm_processor->processor) { OCIO_processorRelease(cm_processor->processor); @@ -3899,9 +3899,9 @@ static void curve_mapping_to_ocio_settings(CurveMapping *curve_mapping, { int i; - curvemapping_initialize(curve_mapping); - curvemapping_premultiply(curve_mapping, false); - curvemapping_table_RGBA( + BKE_curvemapping_initialize(curve_mapping); + BKE_curvemapping_premultiply(curve_mapping, false); + BKE_curvemapping_table_RGBA( curve_mapping, &curve_mapping_settings->lut, &curve_mapping_settings->lut_size); for (i = 0; i < 4; i++) { @@ -3964,11 +3964,11 @@ static void update_glsl_display_processor(const ColorManagedViewSettings *view_s * We do this by allocating new curve mapping before freeing ol one. */ if (use_curve_mapping) { - new_curve_mapping = curvemapping_copy(view_settings->curve_mapping); + new_curve_mapping = BKE_curvemapping_copy(view_settings->curve_mapping); } if (global_glsl_state.curve_mapping) { - curvemapping_free(global_glsl_state.curve_mapping); + BKE_curvemapping_free(global_glsl_state.curve_mapping); MEM_freeN(curve_mapping_settings->lut); global_glsl_state.curve_mapping = NULL; curve_mapping_settings->lut = NULL; diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h index 47347753f42..82628065014 100644 --- a/source/blender/makesdna/DNA_gpencil_modifier_types.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h @@ -502,7 +502,8 @@ typedef struct SimplifyGpencilModifierData { short step; /** Custom index for passes. */ int layer_pass; - char _pad[4]; + /* Sample length */ + float length; } SimplifyGpencilModifierData; typedef enum eSimplifyGpencil_Flag { @@ -516,6 +517,10 @@ typedef enum eSimplifyGpencil_Mode { GP_SIMPLIFY_FIXED = 0, /* Use RDP algorithm */ GP_SIMPLIFY_ADAPTIVE = 1, + /* Sample the stroke using a fixed length */ + GP_SIMPLIFY_SAMPLE = 2, + /* Sample the stroke doing vertex merge */ + GP_SIMPLIFY_MERGE = 3, } eSimplifyGpencil_Mode; typedef struct OffsetGpencilModifierData { diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 42308f54d7a..152ecb85991 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -128,6 +128,8 @@ typedef enum eMaterialGPencilStyle_Flag { GP_STYLE_FILL_SHOW = (1 << 9), /* mix stroke texture */ GP_STYLE_STROKE_TEX_MIX = (1 << 11), + /* disable stencil clipping (overlap) */ + GP_STYLE_DISABLE_STENCIL = (1 << 12), } eMaterialGPencilStyle_Flag; typedef enum eMaterialGPencilStyle_Mode { diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 20d4f7d96e4..505042432ed 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -1628,16 +1628,20 @@ typedef enum eSpace_Type { SPACE_SEQ = 8, SPACE_TEXT = 9, #ifdef DNA_DEPRECATED - SPACE_IMASEL = 10, /* deprecated */ + SPACE_IMASEL = 10, /* Deprecated */ SPACE_SOUND = 11, /* Deprecated */ #endif SPACE_ACTION = 12, SPACE_NLA = 13, /* TODO: fully deprecate */ SPACE_SCRIPT = 14, /* Deprecated */ - SPACE_TIME = 15, /* Deprecated */ +#ifdef DNA_DEPRECATED + SPACE_TIME = 15, /* Deprecated */ +#endif SPACE_NODE = 16, - SPACE_LOGIC = 17, /* deprecated */ +#ifdef DNA_DEPRECATED + SPACE_LOGIC = 17, /* Deprecated */ +#endif SPACE_CONSOLE = 18, SPACE_USERPREF = 19, SPACE_CLIP = 20, diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index b90f1fd16df..b8914c7a74f 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -116,37 +116,37 @@ typedef struct uiStyle { } uiStyle; typedef struct uiWidgetColors { - char outline[4]; - char inner[4]; - char inner_sel[4]; - char item[4]; - char text[4]; - char text_sel[4]; - char shaded; + unsigned char outline[4]; + unsigned char inner[4]; + unsigned char inner_sel[4]; + unsigned char item[4]; + unsigned char text[4]; + unsigned char text_sel[4]; + unsigned char shaded; char _pad0[7]; short shadetop, shadedown; float roundness; } uiWidgetColors; typedef struct uiWidgetStateColors { - char inner_anim[4]; - char inner_anim_sel[4]; - char inner_key[4]; - char inner_key_sel[4]; - char inner_driven[4]; - char inner_driven_sel[4]; - char inner_overridden[4]; - char inner_overridden_sel[4]; - char inner_changed[4]; - char inner_changed_sel[4]; + unsigned char inner_anim[4]; + unsigned char inner_anim_sel[4]; + unsigned char inner_key[4]; + unsigned char inner_key_sel[4]; + unsigned char inner_driven[4]; + unsigned char inner_driven_sel[4]; + unsigned char inner_overridden[4]; + unsigned char inner_overridden_sel[4]; + unsigned char inner_changed[4]; + unsigned char inner_changed_sel[4]; float blend; char _pad0[4]; } uiWidgetStateColors; typedef struct uiPanelColors { - char header[4]; - char back[4]; - char sub_back[4]; + unsigned char header[4]; + unsigned char back[4]; + unsigned char sub_back[4]; char _pad0[4]; } uiPanelColors; @@ -160,13 +160,13 @@ typedef struct ThemeUI { uiWidgetStateColors wcol_state; - char widget_emboss[4]; + unsigned char widget_emboss[4]; /* fac: 0 - 1 for blend factor, width in pixels */ float menu_shadow_fac; short menu_shadow_width; - char editor_outline[4]; + unsigned char editor_outline[4]; char _pad0[2]; float icon_alpha; @@ -174,28 +174,28 @@ typedef struct ThemeUI { char _pad[4]; /* Axis Colors */ - char xaxis[4], yaxis[4], zaxis[4]; + unsigned char xaxis[4], yaxis[4], zaxis[4]; /* Gizmo Colors. */ - char gizmo_hi[4]; - char gizmo_primary[4]; - char gizmo_secondary[4]; - char gizmo_a[4]; - char gizmo_b[4]; + unsigned char gizmo_hi[4]; + unsigned char gizmo_primary[4]; + unsigned char gizmo_secondary[4]; + unsigned char gizmo_a[4]; + unsigned char gizmo_b[4]; /* Icon Colors. */ /** Scene items. */ - char icon_scene[4]; + unsigned char icon_scene[4]; /** Collection items. */ - char icon_collection[4]; + unsigned char icon_collection[4]; /** Object items. */ - char icon_object[4]; + unsigned char icon_object[4]; /** Object data items. */ - char icon_object_data[4]; + unsigned char icon_object_data[4]; /** Modifier and constraint items. */ - char icon_modifier[4]; + unsigned char icon_modifier[4]; /** Shading related items. */ - char icon_shading[4]; + unsigned char icon_shading[4]; /** Intensity of the border icons. >0 will render an border around themed * icons. */ float icon_border_intensity; @@ -206,216 +206,218 @@ typedef struct ThemeUI { */ typedef struct ThemeSpace { /* main window colors */ - char back[4]; - char back_grad[4]; + unsigned char back[4]; + unsigned char back_grad[4]; char show_back_grad; char _pad0[3]; /** Panel title. */ - char title[4]; - char text[4]; - char text_hi[4]; + unsigned char title[4]; + unsigned char text[4]; + unsigned char text_hi[4]; /* header colors */ /** Region background. */ - char header[4]; + unsigned char header[4]; /** Unused. */ - char header_title[4]; - char header_text[4]; - char header_text_hi[4]; + unsigned char header_title[4]; + unsigned char header_text[4]; + unsigned char header_text_hi[4]; /* region tabs */ - char tab_active[4]; - char tab_inactive[4]; - char tab_back[4]; - char tab_outline[4]; + unsigned char tab_active[4]; + unsigned char tab_inactive[4]; + unsigned char tab_back[4]; + unsigned char tab_outline[4]; /* button/tool regions */ /** Region background. */ - char button[4]; + unsigned char button[4]; /** Panel title. */ - char button_title[4]; - char button_text[4]; - char button_text_hi[4]; + unsigned char button_title[4]; + unsigned char button_text[4]; + unsigned char button_text_hi[4]; /* listview regions */ /** Region background. */ - char list[4]; + unsigned char list[4]; /** Panel title. */ - char list_title[4]; - char list_text[4]; - char list_text_hi[4]; + unsigned char list_title[4]; + unsigned char list_text[4]; + unsigned char list_text_hi[4]; /* navigation bar regions */ /** Region background. */ - char navigation_bar[4]; + unsigned char navigation_bar[4]; /** Region background. */ - char execution_buts[4]; + unsigned char execution_buts[4]; /* note, cannot use name 'panel' because of DNA mapping old files */ uiPanelColors panelcolors; - char shade1[4]; - char shade2[4]; + unsigned char shade1[4]; + unsigned char shade2[4]; - char hilite[4]; - char grid[4]; + unsigned char hilite[4]; + unsigned char grid[4]; - char view_overlay[4]; + unsigned char view_overlay[4]; - char wire[4], wire_edit[4], select[4]; - char lamp[4], speaker[4], empty[4], camera[4]; - char active[4], group[4], group_active[4], transform[4]; - char vertex[4], vertex_select[4], vertex_bevel[4], vertex_unreferenced[4]; - char edge[4], edge_select[4]; - char edge_seam[4], edge_sharp[4], edge_facesel[4], edge_crease[4], edge_bevel[4]; + unsigned char wire[4], wire_edit[4], select[4]; + unsigned char lamp[4], speaker[4], empty[4], camera[4]; + unsigned char active[4], group[4], group_active[4], transform[4]; + unsigned char vertex[4], vertex_select[4], vertex_bevel[4], vertex_unreferenced[4]; + unsigned char edge[4], edge_select[4]; + unsigned char edge_seam[4], edge_sharp[4], edge_facesel[4], edge_crease[4], edge_bevel[4]; /** Solid faces. */ - char face[4], face_select[4]; + unsigned char face[4], face_select[4]; /** selected color. */ - char face_dot[4]; - char extra_edge_len[4], extra_edge_angle[4], extra_face_angle[4], extra_face_area[4]; - char normal[4]; - char vertex_normal[4]; - char loop_normal[4]; - char bone_solid[4], bone_pose[4], bone_pose_active[4]; - char strip[4], strip_select[4]; - char cframe[4]; - char time_keyframe[4], time_gp_keyframe[4]; - char freestyle_edge_mark[4], freestyle_face_mark[4]; - char time_scrub_background[4]; + unsigned char face_dot[4]; + unsigned char extra_edge_len[4], extra_edge_angle[4], extra_face_angle[4], extra_face_area[4]; + unsigned char normal[4]; + unsigned char vertex_normal[4]; + unsigned char loop_normal[4]; + unsigned char bone_solid[4], bone_pose[4], bone_pose_active[4]; + unsigned char strip[4], strip_select[4]; + unsigned char cframe[4]; + unsigned char time_keyframe[4], time_gp_keyframe[4]; + unsigned char freestyle_edge_mark[4], freestyle_face_mark[4]; + unsigned char time_scrub_background[4]; char _pad5[4]; - char nurb_uline[4], nurb_vline[4]; - char act_spline[4], nurb_sel_uline[4], nurb_sel_vline[4], lastsel_point[4]; + unsigned char nurb_uline[4], nurb_vline[4]; + unsigned char act_spline[4], nurb_sel_uline[4], nurb_sel_vline[4], lastsel_point[4]; - char handle_free[4], handle_auto[4], handle_vect[4], handle_align[4], handle_auto_clamped[4]; - char handle_sel_free[4], handle_sel_auto[4], handle_sel_vect[4], handle_sel_align[4], + unsigned char handle_free[4], handle_auto[4], handle_vect[4], handle_align[4], + handle_auto_clamped[4]; + unsigned char handle_sel_free[4], handle_sel_auto[4], handle_sel_vect[4], handle_sel_align[4], handle_sel_auto_clamped[4]; /** Dopesheet. */ - char ds_channel[4], ds_subchannel[4], ds_ipoline[4]; + unsigned char ds_channel[4], ds_subchannel[4], ds_ipoline[4]; /** Keytypes. */ - char keytype_keyframe[4], keytype_extreme[4], keytype_breakdown[4], keytype_jitter[4], + unsigned char keytype_keyframe[4], keytype_extreme[4], keytype_breakdown[4], keytype_jitter[4], keytype_movehold[4]; /** Keytypes. */ - char keytype_keyframe_select[4], keytype_extreme_select[4], keytype_breakdown_select[4], + unsigned char keytype_keyframe_select[4], keytype_extreme_select[4], keytype_breakdown_select[4], keytype_jitter_select[4], keytype_movehold_select[4]; - char keyborder[4], keyborder_select[4]; + unsigned char keyborder[4], keyborder_select[4]; char _pad4[3]; - char console_output[4], console_input[4], console_info[4], console_error[4]; - char console_cursor[4], console_select[4]; + unsigned char console_output[4], console_input[4], console_info[4], console_error[4]; + unsigned char console_cursor[4], console_select[4]; - char vertex_size, outline_width, obcenter_dia, facedot_size; - char noodle_curving; + unsigned char vertex_size, outline_width, obcenter_dia, facedot_size; + unsigned char noodle_curving; /* syntax for textwindow and nodes */ - char syntaxl[4], syntaxs[4]; // in nodespace used for backdrop matte - char syntaxb[4], syntaxn[4]; // in nodespace used for color input - char syntaxv[4], syntaxc[4]; // in nodespace used for converter group - char syntaxd[4], syntaxr[4]; // in nodespace used for distort + unsigned char syntaxl[4], syntaxs[4]; // in nodespace used for backdrop matte + unsigned char syntaxb[4], syntaxn[4]; // in nodespace used for color input + unsigned char syntaxv[4], syntaxc[4]; // in nodespace used for converter group + unsigned char syntaxd[4], syntaxr[4]; // in nodespace used for distort - char nodeclass_output[4], nodeclass_filter[4]; - char nodeclass_vector[4], nodeclass_texture[4]; - char nodeclass_shader[4], nodeclass_script[4]; - char nodeclass_pattern[4], nodeclass_layout[4]; + unsigned char nodeclass_output[4], nodeclass_filter[4]; + unsigned char nodeclass_vector[4], nodeclass_texture[4]; + unsigned char nodeclass_shader[4], nodeclass_script[4]; + unsigned char nodeclass_pattern[4], nodeclass_layout[4]; /** For sequence editor. */ - char movie[4], movieclip[4], mask[4], image[4], scene[4], audio[4]; - char effect[4], transition[4], meta[4], text_strip[4]; + unsigned char movie[4], movieclip[4], mask[4], image[4], scene[4], audio[4]; + unsigned char effect[4], transition[4], meta[4], text_strip[4]; /** For dopesheet - scale factor for size of keyframes (i.e. height of channels). */ float keyframe_scale_fac; - char editmesh_active[4]; + unsigned char editmesh_active[4]; - char handle_vertex[4]; - char handle_vertex_select[4]; + unsigned char handle_vertex[4]; + unsigned char handle_vertex_select[4]; - char handle_vertex_size; + unsigned char handle_vertex_size; - char clipping_border_3d[4]; + unsigned char clipping_border_3d[4]; - char marker_outline[4], marker[4], act_marker[4], sel_marker[4], dis_marker[4], lock_marker[4]; - char bundle_solid[4]; - char path_before[4], path_after[4]; - char camera_path[4]; - char _pad1[2]; + unsigned char marker_outline[4], marker[4], act_marker[4], sel_marker[4], dis_marker[4], + lock_marker[4]; + unsigned char bundle_solid[4]; + unsigned char path_before[4], path_after[4]; + unsigned char camera_path[4]; + unsigned char _pad1[2]; - char gp_vertex_size; - char gp_vertex[4], gp_vertex_select[4]; + unsigned char gp_vertex_size; + unsigned char gp_vertex[4], gp_vertex_select[4]; - char preview_back[4]; - char preview_stitch_face[4]; - char preview_stitch_edge[4]; - char preview_stitch_vert[4]; - char preview_stitch_stitchable[4]; - char preview_stitch_unstitchable[4]; - char preview_stitch_active[4]; + unsigned char preview_back[4]; + unsigned char preview_stitch_face[4]; + unsigned char preview_stitch_edge[4]; + unsigned char preview_stitch_vert[4]; + unsigned char preview_stitch_stitchable[4]; + unsigned char preview_stitch_unstitchable[4]; + unsigned char preview_stitch_active[4]; /** Two uses, for uvs with modifier applied on mesh and uvs during painting. */ - char uv_shadow[4]; + unsigned char uv_shadow[4]; /** Uvs of other objects. */ - char uv_others[4]; + unsigned char uv_others[4]; /** Outliner - filter match. */ - char match[4]; + unsigned char match[4]; /** Outliner - selected item. */ - char selected_highlight[4]; + unsigned char selected_highlight[4]; /** Outliner - selected object. */ - char selected_object[4]; + unsigned char selected_object[4]; /** Outliner - active object. */ - char active_object[4]; + unsigned char active_object[4]; /** Outliner - edited object. */ - char edited_object[4]; + unsigned char edited_object[4]; /** Outliner - row color difference. */ - char row_alternate[4]; + unsigned char row_alternate[4]; /** Skin modifier root color. */ - char skin_root[4]; + unsigned char skin_root[4]; /* NLA */ /** Active Action + Summary Channel. */ - char anim_active[4]; + unsigned char anim_active[4]; /** Active Action = NULL. */ - char anim_non_active[4]; + unsigned char anim_non_active[4]; /** Preview range overlay. */ - char anim_preview_range[4]; + unsigned char anim_preview_range[4]; /** NLA 'Tweaking' action/strip. */ - char nla_tweaking[4]; + unsigned char nla_tweaking[4]; /** NLA - warning color for duplicate instances of tweaking strip. */ - char nla_tweakdupli[4]; + unsigned char nla_tweakdupli[4]; /** NLA "Transition" strips. */ - char nla_transition[4], nla_transition_sel[4]; + unsigned char nla_transition[4], nla_transition_sel[4]; /** NLA "Meta" strips. */ - char nla_meta[4], nla_meta_sel[4]; + unsigned char nla_meta[4], nla_meta_sel[4]; /** NLA "Sound" strips. */ - char nla_sound[4], nla_sound_sel[4]; + unsigned char nla_sound[4], nla_sound_sel[4]; /* info */ - char info_selected[4], info_selected_text[4]; - char info_error[4], info_error_text[4]; - char info_warning[4], info_warning_text[4]; - char info_info[4], info_info_text[4]; - char info_debug[4], info_debug_text[4]; + unsigned char info_selected[4], info_selected_text[4]; + unsigned char info_error[4], info_error_text[4]; + unsigned char info_warning[4], info_warning_text[4]; + unsigned char info_info[4], info_info_text[4]; + unsigned char info_debug[4], info_debug_text[4]; - char paint_curve_pivot[4]; - char paint_curve_handle[4]; + unsigned char paint_curve_pivot[4]; + unsigned char paint_curve_handle[4]; - char metadatabg[4]; - char metadatatext[4]; + unsigned char metadatabg[4]; + unsigned char metadatatext[4]; char _pad2[4]; } ThemeSpace; /* set of colors for use as a custom color set for Objects/Bones wire drawing */ typedef struct ThemeWireColor { - char solid[4]; - char select[4]; - char active[4]; + unsigned char solid[4]; + unsigned char select[4]; + unsigned char active[4]; /** #eWireColor_Flags. */ short flag; @@ -958,6 +960,7 @@ typedef enum eUserpref_UI_Flag2 { USER_UIFLAG2_UNUSED_3 = (1 << 3), /* dirty */ } eUserpref_UI_Flag2; +/** #UserDef.gpu_flag */ typedef enum eUserpref_GPU_Flag { USER_GPU_FLAG_NO_DEPT_PICK = (1 << 0), USER_GPU_FLAG_NO_EDIT_MODE_SMOOTH_WIRE = (1 << 1), @@ -1066,7 +1069,6 @@ typedef enum eText_Draw_Options { * #UserDef.gp_settings */ typedef enum eGP_UserdefSettings { GP_PAINT_UNUSED_0 = (1 << 0), - GP_PAINT_DOSIMPLIFY = (1 << 1), } eGP_UserdefSettings; enum { diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index e7a4f9cbd4e..3ba33cfe3d4 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -144,7 +144,7 @@ typedef struct View3DCursor { /** 3D Viewport Shading settings. */ typedef struct View3DShading { - /** Shading type (VIEW3D_SHADE_SOLID, ..). */ + /** Shading type (OB_SOLID, ..). */ char type; /** Runtime, for toggle between rendered viewport. */ char prev_type; diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 2484e432795..713ddfa0067 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -1565,7 +1565,7 @@ static void rna_def_brush(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}, }; -static const EnumPropertyItem color_gradient_items[] = { + static const EnumPropertyItem color_gradient_items[] = { {0, "COLOR", 0, "Color", "Paint with a single color"}, {BRUSH_USE_GRADIENT, "GRADIENT", 0, "Gradient", "Paint with a gradient"}, {0, NULL, 0, NULL, NULL}, diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index d221b7005f6..6bfd2b9f63b 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -94,7 +94,7 @@ static void rna_CurveMapping_clip_set(PointerRNA *ptr, bool value) cumap->flag &= ~CUMA_DO_CLIP; } - curvemapping_changed(cumap, false); + BKE_curvemapping_changed(cumap, false); } static void rna_CurveMapping_black_level_set(PointerRNA *ptr, const float *values) @@ -103,7 +103,7 @@ static void rna_CurveMapping_black_level_set(PointerRNA *ptr, const float *value cumap->black[0] = values[0]; cumap->black[1] = values[1]; cumap->black[2] = values[2]; - curvemapping_set_black_white(cumap, NULL, NULL); + BKE_curvemapping_set_black_white(cumap, NULL, NULL); } static void rna_CurveMapping_white_level_set(PointerRNA *ptr, const float *values) @@ -112,7 +112,7 @@ static void rna_CurveMapping_white_level_set(PointerRNA *ptr, const float *value cumap->white[0] = values[0]; cumap->white[1] = values[1]; cumap->white[2] = values[2]; - curvemapping_set_black_white(cumap, NULL, NULL); + BKE_curvemapping_set_black_white(cumap, NULL, NULL); } static void rna_CurveMapping_tone_update(Main *UNUSED(bmain), @@ -368,7 +368,7 @@ static void rna_ColorRampElement_remove(struct ColorBand *coba, static void rna_CurveMap_remove_point(CurveMap *cuma, ReportList *reports, PointerRNA *point_ptr) { CurveMapPoint *point = point_ptr->data; - if (curvemap_remove_point(cuma, point) == false) { + if (BKE_curvemap_remove_point(cuma, point) == false) { BKE_report(reports, RPT_ERROR, "Unable to remove curve point"); return; } @@ -518,7 +518,7 @@ static void rna_ColorManagedViewSettings_use_curves_set(PointerRNA *ptr, bool va view_settings->flag |= COLORMANAGE_VIEW_USE_CURVES; if (view_settings->curve_mapping == NULL) { - view_settings->curve_mapping = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); + view_settings->curve_mapping = BKE_curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); } } else { @@ -669,7 +669,7 @@ static void rna_ColorManagement_update(Main *UNUSED(bmain), Scene *UNUSED(scene) } } -/* this function only exists because #curvemap_evaluateF uses a 'const' qualifier */ +/* this function only exists because #BKE_curvemap_evaluateF uses a 'const' qualifier */ static float rna_CurveMap_evaluateF(struct CurveMap *cuma, ReportList *reports, float value) { if (!cuma->table) { @@ -679,12 +679,12 @@ static float rna_CurveMap_evaluateF(struct CurveMap *cuma, ReportList *reports, "CurveMap table not initialized, call initialize() on CurveMapping owner of the CurveMap"); return 0.0f; } - return curvemap_evaluateF(cuma, value); + return BKE_curvemap_evaluateF(cuma, value); } static void rna_CurveMap_initialize(struct CurveMapping *cumap) { - curvemapping_initialize(cumap); + BKE_curvemapping_initialize(cumap); } #else @@ -729,7 +729,7 @@ static void rna_def_curvemap_points_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_sdna(srna, "CurveMap"); RNA_def_struct_ui_text(srna, "Curve Map Point", "Collection of Curve Map Points"); - func = RNA_def_function(srna, "new", "curvemap_insert"); + func = RNA_def_function(srna, "new", "BKE_curvemap_insert"); RNA_def_function_ui_description(func, "Add point to CurveMap"); parm = RNA_def_float(func, "position", @@ -889,7 +889,7 @@ static void rna_def_curvemapping(BlenderRNA *brna) prop, "White Level", "For RGB curves, the color that white is mapped to"); RNA_def_property_float_funcs(prop, NULL, "rna_CurveMapping_white_level_set", NULL); - func = RNA_def_function(srna, "update", "curvemapping_changed_all"); + func = RNA_def_function(srna, "update", "BKE_curvemapping_changed_all"); RNA_def_function_ui_description(func, "Update curve mapping after making changes"); func = RNA_def_function(srna, "initialize", "rna_CurveMap_initialize"); diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 754c443e7e6..dfe9e018e94 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -617,6 +617,16 @@ static void rna_def_modifier_gpencilsimplify(BlenderRNA *brna) ICON_IPO_EASE_IN_OUT, "Adaptive", "Use a RDP algorithm to simplify"}, + {GP_SIMPLIFY_SAMPLE, + "SAMPLE", + ICON_IPO_EASE_IN_OUT, + "Sample", + "Sample a curve using a fixed length"}, + {GP_SIMPLIFY_MERGE, + "MERGE", + ICON_IPO_EASE_IN_OUT, + "Merge", + "Sample a curve using doing merge of vertex"}, {0, NULL, 0, NULL, NULL}, }; @@ -675,6 +685,13 @@ static void rna_def_modifier_gpencilsimplify(BlenderRNA *brna) RNA_def_property_range(prop, 1, 50); RNA_def_property_ui_text(prop, "Iterations", "Number of times to apply simplify"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + /* Sample */ + prop = RNA_def_property(srna, "length", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "length"); + RNA_def_property_range(prop, 0, 10); + RNA_def_property_ui_text(prop, "Length", "Length of each segment"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); } static void rna_def_modifier_gpencilthick(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 162ba6be834..6378ee15279 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -612,6 +612,12 @@ static void rna_def_material_greasepencil(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Pattern", "Use Fill Texture as a pattern to apply color"); RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + prop = RNA_def_property(srna, "use_overlap_strokes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_DISABLE_STENCIL); + RNA_def_property_ui_text( + prop, "Self Overlap", "Disable stencil and overlap self intersections with alpha materials"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update"); + prop = RNA_def_property(srna, "show_stroke", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_STROKE_SHOW); RNA_def_property_ui_text(prop, "Show Stroke", "Show stroke lines of this material"); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index a96e85473a2..4c50e0c19ae 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -3050,7 +3050,8 @@ static void rna_def_particle_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "child_radius", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "childrad"); - RNA_def_property_range(prop, 0.0f, 10.0f); + RNA_def_property_range(prop, 0.0f, 100000.0f); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 3); RNA_def_property_ui_text(prop, "Child Radius", "Radius of children around parent"); RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index ef8b671116a..531ff27798d 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -735,7 +735,7 @@ static void rna_GPencilInterpolateSettings_type_set(PointerRNA *ptr, int value) /* init custom interpolation curve here now the first time it's used */ if ((settings->type == GP_IPO_CURVEMAP) && (settings->custom_ipo == NULL)) { - settings->custom_ipo = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + settings->custom_ipo = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } } diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index c1ef31a80cd..80a4defba00 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -1853,7 +1853,8 @@ static void rna_def_editor(BlenderRNA *brna) prop = RNA_def_property(srna, "show_overlay", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "over_flag", SEQ_EDIT_OVERLAY_SHOW); - RNA_def_property_ui_text(prop, "Draw Axes", "Partial overlay on top of the sequencer"); + RNA_def_property_ui_text( + prop, "Show Overlay", "Partial overlay on top of the sequencer with a frame offset"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); prop = RNA_def_property(srna, "use_overlay_lock", PROP_BOOLEAN, PROP_NONE); @@ -1864,7 +1865,7 @@ static void rna_def_editor(BlenderRNA *brna) /* access to fixed and relative frame */ prop = RNA_def_property(srna, "overlay_frame", PROP_INT, PROP_NONE); - RNA_def_property_ui_text(prop, "Overlay Offset", ""); + RNA_def_property_ui_text(prop, "Overlay Offset", "Number of frames to offset"); RNA_def_property_int_funcs( prop, "rna_SequenceEditor_overlay_frame_get", "rna_SequenceEditor_overlay_frame_set", NULL); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index bed06171cbf..48eee713fc9 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -4590,10 +4590,6 @@ static void rna_def_userdef_edit(BlenderRNA *brna) "Grease Pencil Euclidean Distance", "Distance moved by mouse when drawing stroke to include"); - prop = RNA_def_property(srna, "use_grease_pencil_simplify_stroke", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "gp_settings", GP_PAINT_DOSIMPLIFY); - RNA_def_property_ui_text(prop, "Grease Pencil Simplify Stroke", "Simplify the final stroke"); - prop = RNA_def_property(srna, "grease_pencil_eraser_radius", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "gp_eraser"); RNA_def_property_range(prop, 1, 500); @@ -5824,7 +5820,7 @@ void RNA_def_userdef(BlenderRNA *brna) /* Preferences Flags */ prop = RNA_def_property(srna, "use_preferences_save", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pref_flag", USER_PREF_FLAG_SAVE); - RNA_def_property_ui_text(prop, "Save on Exit", "Save modified preferences on exit"); + RNA_def_property_ui_text(prop, "Save on Exit", "Save preferences on exit when modified"); prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "runtime.is_dirty", 0); diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 72215659915..7ae5fda7111 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -79,7 +79,12 @@ static bool isDisabled(const struct Scene *UNUSED(scene), { ArmatureModifierData *amd = (ArmatureModifierData *)md; - return !amd->object; + /* The object type check is only needed here in case we have a placeholder + * object assigned (because the library containing the armature is missing). + * + * In other cases it should be impossible. + */ + return !amd->object || amd->object->type != OB_ARMATURE; } static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, void *userData) diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index c12fb9c1bd8..2f902db9340 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -49,7 +49,7 @@ static void initData(ModifierData *md) HookModifierData *hmd = (HookModifierData *)md; hmd->force = 1.0; - hmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + hmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); hmd->falloff_type = eHook_Falloff_Smooth; hmd->flag = 0; } @@ -61,7 +61,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla modifier_copyData_generic(md, target, flag); - thmd->curfalloff = curvemapping_copy(hmd->curfalloff); + thmd->curfalloff = BKE_curvemapping_copy(hmd->curfalloff); thmd->indexar = MEM_dupallocN(hmd->indexar); } @@ -88,7 +88,7 @@ static void freeData(ModifierData *md) { HookModifierData *hmd = (HookModifierData *)md; - curvemapping_free(hmd->curfalloff); + BKE_curvemapping_free(hmd->curfalloff); MEM_SAFE_FREE(hmd->indexar); } @@ -174,7 +174,7 @@ static float hook_falloff(const struct HookData_cb *hd, const float len_sq) break; #endif case eHook_Falloff_Curve: - fac = curvemapping_evaluateF(hd->curfalloff, 0, fac); + fac = BKE_curvemapping_evaluateF(hd->curfalloff, 0, fac); break; case eHook_Falloff_Sharp: fac = fac * fac; @@ -262,11 +262,11 @@ static void deformVerts_do(HookModifierData *hmd, if (hmd->curfalloff == NULL) { /* should never happen, but bad lib linking could cause it */ - hmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + hmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } if (hmd->curfalloff) { - curvemapping_initialize(hmd->curfalloff); + BKE_curvemapping_initialize(hmd->curfalloff); } /* Generic data needed for applying per-vertex calculations (initialize all members) */ diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 6441ab69391..7155498c942 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -50,7 +50,7 @@ static void initData(ModifierData *md) { WarpModifierData *wmd = (WarpModifierData *)md; - wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + wmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); wmd->texture = NULL; wmd->strength = 1.0f; wmd->falloff_radius = 1.0f; @@ -65,7 +65,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla modifier_copyData_generic(md, target, flag); - twmd->curfalloff = curvemapping_copy(wmd->curfalloff); + twmd->curfalloff = BKE_curvemapping_copy(wmd->curfalloff); } static void requiredDataMask(Object *UNUSED(ob), @@ -100,7 +100,7 @@ static bool dependsOnTime(ModifierData *md) static void freeData(ModifierData *md) { WarpModifierData *wmd = (WarpModifierData *)md; - curvemapping_free(wmd->curfalloff); + BKE_curvemapping_free(wmd->curfalloff); } static bool isDisabled(const struct Scene *UNUSED(scene), @@ -188,11 +188,11 @@ static void warpModifier_do(WarpModifierData *wmd, } if (wmd->curfalloff == NULL) { /* should never happen, but bad lib linking could cause it */ - wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + wmd->curfalloff = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } if (wmd->curfalloff) { - curvemapping_initialize(wmd->curfalloff); + BKE_curvemapping_initialize(wmd->curfalloff); } invert_m4_m4(obinv, ob->obmat); @@ -247,7 +247,7 @@ static void warpModifier_do(WarpModifierData *wmd, fac = 1.0f; break; case eWarp_Falloff_Curve: - fac = curvemapping_evaluateF(wmd->curfalloff, 0, fac); + fac = BKE_curvemapping_evaluateF(wmd->curfalloff, 0, fac); break; case eWarp_Falloff_Sharp: fac = fac * fac; diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index 61872cbe464..486d5c90bef 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -72,7 +72,7 @@ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cm } if (cmap && falloff_type == MOD_WVG_MAPPING_CURVE) { - curvemapping_initialize(cmap); + BKE_curvemapping_initialize(cmap); } /* Map each weight (vertex) to its new value, accordingly to the chosen mode. */ @@ -83,7 +83,7 @@ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cm /* Closely matches PROP_SMOOTH and similar. */ switch (falloff_type) { case MOD_WVG_MAPPING_CURVE: - fac = curvemapping_evaluateF(cmap, 0, fac); + fac = BKE_curvemapping_evaluateF(cmap, 0, fac); break; case MOD_WVG_MAPPING_SHARP: fac = fac * fac; diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index 207c5851602..045ba78fab5 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -57,8 +57,8 @@ static void initData(ModifierData *md) wmd->falloff_type = MOD_WVG_MAPPING_NONE; wmd->default_weight = 0.0f; - wmd->cmap_curve = curvemapping_add(1, 0.0, 0.0, 1.0, 1.0); - curvemapping_initialize(wmd->cmap_curve); + wmd->cmap_curve = BKE_curvemapping_add(1, 0.0, 0.0, 1.0, 1.0); + BKE_curvemapping_initialize(wmd->cmap_curve); wmd->rem_threshold = 0.01f; wmd->add_threshold = 0.01f; @@ -71,7 +71,7 @@ static void initData(ModifierData *md) static void freeData(ModifierData *md) { WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md; - curvemapping_free(wmd->cmap_curve); + BKE_curvemapping_free(wmd->cmap_curve); } static void copyData(const ModifierData *md, ModifierData *target, const int flag) @@ -81,7 +81,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla modifier_copyData_generic(md, target, flag); - twmd->cmap_curve = curvemapping_copy(wmd->cmap_curve); + twmd->cmap_curve = BKE_curvemapping_copy(wmd->cmap_curve); } static void requiredDataMask(Object *UNUSED(ob), diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.c b/source/blender/nodes/composite/nodes/node_composite_curves.c index 7b2e7329432..8d338ba5750 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.c +++ b/source/blender/nodes/composite/nodes/node_composite_curves.c @@ -35,7 +35,7 @@ static void node_composit_init_curves_time(bNodeTree *UNUSED(ntree), bNode *node { node->custom1 = 1; node->custom2 = 250; - node->storage = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + node->storage = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } void register_node_type_cmp_curve_time(void) @@ -64,7 +64,7 @@ static bNodeSocketTemplate cmp_node_curve_vec_out[] = { static void node_composit_init_curve_vec(bNodeTree *UNUSED(ntree), bNode *node) { - node->storage = curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); + node->storage = BKE_curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); } void register_node_type_cmp_curve_vec(void) @@ -96,7 +96,7 @@ static bNodeSocketTemplate cmp_node_curve_rgb_out[] = { static void node_composit_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode *node) { - node->storage = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); + node->storage = BKE_curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); } void register_node_type_cmp_curve_rgb(void) diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c index 7fcaae0bd9c..29cdf28fb2d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c +++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c @@ -36,14 +36,14 @@ static bNodeSocketTemplate cmp_node_huecorrect_out[] = { static void node_composit_init_huecorrect(bNodeTree *UNUSED(ntree), bNode *node) { - CurveMapping *cumapping = node->storage = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + CurveMapping *cumapping = node->storage = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); int c; cumapping->preset = CURVE_PRESET_MID9; for (c = 0; c < 3; c++) { CurveMap *cuma = &cumapping->cm[c]; - curvemap_reset(cuma, &cumapping->clipr, cumapping->preset, CURVEMAP_SLOPE_POSITIVE); + BKE_curvemap_reset(cuma, &cumapping->clipr, cumapping->preset, CURVEMAP_SLOPE_POSITIVE); } /* default to showing Saturation */ diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c index 2ab68e2f7cf..e9a825b5b3f 100644 --- a/source/blender/nodes/intern/node_util.c +++ b/source/blender/nodes/intern/node_util.c @@ -47,7 +47,7 @@ void node_free_curves(bNode *node) { - curvemapping_free(node->storage); + BKE_curvemapping_free(node->storage); } void node_free_standard_storage(bNode *node) @@ -59,7 +59,7 @@ void node_free_standard_storage(bNode *node) void node_copy_curves(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node) { - dest_node->storage = curvemapping_copy(src_node->storage); + dest_node->storage = BKE_curvemapping_copy(src_node->storage); } void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), @@ -73,7 +73,7 @@ void *node_initexec_curves(bNodeExecContext *UNUSED(context), bNode *node, bNodeInstanceKey UNUSED(key)) { - curvemapping_initialize(node->storage); + BKE_curvemapping_initialize(node->storage); return NULL; /* unused return */ } diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c index 1b96dabac77..baf86951fe0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.c +++ b/source/blender/nodes/shader/nodes/node_shader_curves.c @@ -47,12 +47,12 @@ static void node_shader_exec_curve_vec(void *UNUSED(data), /* stack order input: vec */ /* stack order output: vec */ nodestack_get_vec(vec, SOCK_VECTOR, in[1]); - curvemapping_evaluate3F(node->storage, out[0]->vec, vec); + BKE_curvemapping_evaluate3F(node->storage, out[0]->vec, vec); } static void node_shader_init_curve_vec(bNodeTree *UNUSED(ntree), bNode *node) { - node->storage = curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); + node->storage = BKE_curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); } static int gpu_shader_curve_vec(GPUMaterial *mat, @@ -64,7 +64,7 @@ static int gpu_shader_curve_vec(GPUMaterial *mat, float *array, layer; int size; - curvemapping_table_RGBA(node->storage, &array, &size); + BKE_curvemapping_table_RGBA(node->storage, &array, &size); GPUNodeLink *tex = GPU_color_band(mat, size, array, &layer); return GPU_stack_link(mat, node, "curves_vec", in, out, tex, GPU_constant(&layer)); @@ -111,7 +111,7 @@ static void node_shader_exec_curve_rgb(void *UNUSED(data), /* stack order output: vec */ nodestack_get_vec(&fac, SOCK_FLOAT, in[0]); nodestack_get_vec(vec, SOCK_VECTOR, in[1]); - curvemapping_evaluateRGBF(node->storage, out[0]->vec, vec); + BKE_curvemapping_evaluateRGBF(node->storage, out[0]->vec, vec); if (fac != 1.0f) { interp_v3_v3v3(out[0]->vec, vec, out[0]->vec, fac); } @@ -119,7 +119,7 @@ static void node_shader_exec_curve_rgb(void *UNUSED(data), static void node_shader_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode *node) { - node->storage = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); + node->storage = BKE_curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); } static int gpu_shader_curve_rgb(GPUMaterial *mat, @@ -134,8 +134,8 @@ static int gpu_shader_curve_rgb(GPUMaterial *mat, CurveMapping *cumap = node->storage; - curvemapping_initialize(cumap); - curvemapping_table_RGBA(cumap, &array, &size); + BKE_curvemapping_initialize(cumap); + BKE_curvemapping_table_RGBA(cumap, &array, &size); GPUNodeLink *tex = GPU_color_band(mat, size, array, &layer); float ext_rgba[4][4]; diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c index 1087d05d040..2e2687bd50e 100644 --- a/source/blender/nodes/texture/nodes/node_texture_curves.c +++ b/source/blender/nodes/texture/nodes/node_texture_curves.c @@ -39,8 +39,8 @@ static void time_colorfn( fac = (p->cfra - node->custom1) / (float)(node->custom2 - node->custom1); } - curvemapping_initialize(node->storage); - fac = curvemapping_evaluateF(node->storage, 0, fac); + BKE_curvemapping_initialize(node->storage); + fac = BKE_curvemapping_evaluateF(node->storage, 0, fac); out[0] = CLAMPIS(fac, 0.0f, 1.0f); } @@ -58,7 +58,7 @@ static void time_init(bNodeTree *UNUSED(ntree), bNode *node) { node->custom1 = 1; node->custom2 = 250; - node->storage = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + node->storage = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } void register_node_type_tex_curve_time(void) @@ -91,7 +91,7 @@ static void rgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, float cin[4]; tex_input_rgba(cin, in[0], p, thread); - curvemapping_evaluateRGBF(node->storage, out, cin); + BKE_curvemapping_evaluateRGBF(node->storage, out, cin); out[3] = cin[3]; } @@ -107,7 +107,7 @@ static void rgb_exec(void *data, static void rgb_init(bNodeTree *UNUSED(ntree), bNode *node) { - node->storage = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); + node->storage = BKE_curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); } void register_node_type_tex_curve_rgb(void) diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 50c61dd0061..70bfa76e344 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -1505,6 +1505,10 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, /* calculate combine string length */ totbuf += id_str_size + name_str_size + desc_str_size + 3; /* 3 is for '\0's */ } + else if (item == Py_None) { + /* Only set since the rest is cleared. */ + items[i].identifier = ""; + } else { MEM_freeN(items); PyErr_SetString(PyExc_TypeError, @@ -2979,6 +2983,8 @@ PyDoc_STRVAR( " When an item only contains 4 items they define ``(identifier, name, description, " "number)``.\n" "\n" + " Separators may be added using None instead of a tuple." + "\n" " For dynamic values a callback can be passed which returns a list in\n" " the same format as the static list.\n" " This function must take 2 arguments ``(self, context)``, **context may be None**.\n" diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 8764671ae04..d620cd38b76 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -642,7 +642,7 @@ void RE_FreeRender(Render *re) BLI_freelistN(&re->view_layers); BLI_freelistN(&re->r.views); - curvemapping_free_data(&re->r.mblur_shutter_curve); + BKE_curvemapping_free_data(&re->r.mblur_shutter_curve); /* main dbase can already be invalid now, some database-free code checks it */ re->main = NULL; @@ -772,12 +772,12 @@ static void re_init_resolution(Render *re, Render *source, int winx, int winy, r void render_copy_renderdata(RenderData *to, RenderData *from) { BLI_freelistN(&to->views); - curvemapping_free_data(&to->mblur_shutter_curve); + BKE_curvemapping_free_data(&to->mblur_shutter_curve); *to = *from; BLI_duplicatelist(&to->views, &from->views); - curvemapping_copy_data(&to->mblur_shutter_curve, &from->mblur_shutter_curve); + BKE_curvemapping_copy_data(&to->mblur_shutter_curve, &from->mblur_shutter_curve); } /* what doesn't change during entire render sequence */ diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 75ddf7e0b22..3ede55434b9 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -557,8 +557,8 @@ static float density_falloff(PointDensityRangeData *pdr, int index, float square } if (pdr->density_curve && dist != 0.0f) { - curvemapping_initialize(pdr->density_curve); - density = curvemapping_evaluateF(pdr->density_curve, 0, density / dist) * dist; + BKE_curvemapping_initialize(pdr->density_curve); + density = BKE_curvemapping_evaluateF(pdr->density_curve, 0, density / dist) * dist; } return density; diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 6b3bd1ea24e..ba6a0c4ebe1 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -403,7 +403,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) /* XXX todo, multiline drag draws... but maybe not, more types mixed wont work well */ GPU_blend(true); for (drag = wm->drags.first; drag; drag = drag->next) { - const char text_col[] = {255, 255, 255, 255}; + const uchar text_col[] = {255, 255, 255, 255}; int iconsize = UI_DPI_ICON_SIZE; int padding = 4 * UI_DPI_FAC; @@ -461,7 +461,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect) drag_rect_minmax(rect, x, y, x + w, y + iconsize); } else { - UI_fontstyle_draw_simple(fstyle, x, y, wm_drag_name(drag), (uchar *)text_col); + UI_fontstyle_draw_simple(fstyle, x, y, wm_drag_name(drag), text_col); } /* operator name with roundbox */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index cea2f127b3e..88a4c13c4ca 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2691,6 +2691,12 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers wmKeyMap *keymap = WM_event_get_keymap_from_handler(wm, handler); action |= wm_handlers_do_keymap_with_keymap_handler( C, event, handlers, handler, keymap, do_debug_handler); + + /* Clear the tool-tip whenever a key binding is handled, without this tool-tips + * are kept when a modal operators starts (annoying but otherwise harmless). */ + if (action & WM_HANDLER_BREAK) { + WM_tooltip_clear(C, CTX_wm_window(C)); + } } else if (handler_base->type == WM_HANDLER_TYPE_UI) { wmEventHandler_UI *handler = (wmEventHandler_UI *)handler_base; diff --git a/tests/gtests/blenlib/BLI_polyfill_2d_test.cc b/tests/gtests/blenlib/BLI_polyfill_2d_test.cc index 9b908bf4cad..5566dced798 100644 --- a/tests/gtests/blenlib/BLI_polyfill_2d_test.cc +++ b/tests/gtests/blenlib/BLI_polyfill_2d_test.cc @@ -697,3 +697,58 @@ TEST(polyfill2d, IssueT52834_axis_align_co_linear) TEST_POLYFILL_TEMPLATE_STATIC(poly, false); } + +/* Blender bug T67109 (version a). */ +/* Multiple versions are offset & rotated, this fails in cases where others works. */ +TEST(polyfill2d, IssueT67109_axis_align_co_linear_a) +{ + const float poly[][2] = { + {3.2060661, -11.438997}, + {2.8720665, -5.796999}, + {-2.8659325, -5.796999}, + {-2.8659325, -8.307999}, + {-3.2549324, -11.438997}, + {-2.8659325, -5.4869995}, + {2.8720665, -5.4869995}, + {2.8720665, -2.9759989}, + {2.8720665, -2.6659985}, + {2.8720665, -0.15499878}, + }; + TEST_POLYFILL_TEMPLATE_STATIC(poly, false); +} + +/* Blender bug T67109, (version b). */ +TEST(polyfill2d, IssueT67109_axis_align_co_linear_b) +{ + const float poly[][2] = { + {32.41416, -12.122593}, + {28.094929, -8.477332}, + {24.141455, -12.636018}, + {25.96133, -14.366093}, + {27.96254, -16.805279}, + {23.916779, -12.422427}, + {27.870255, -8.263744}, + {26.050375, -6.533667}, + {25.825695, -6.320076}, + {24.00582, -4.5899982}, + }; + TEST_POLYFILL_TEMPLATE_STATIC(poly, false); +} + +/* Blender bug T67109 (version c). */ +TEST(polyfill2d, IssueT67109_axis_align_co_linear_c) +{ + const float poly[][2] = { + {-67.10034, 43.677097}, + {-63.253956, 61.399143}, + {-80.98382, 66.36057}, + {-83.15499, 58.601795}, + {-87.06422, 49.263668}, + {-80.71576, 67.31843}, + {-62.985912, 62.35701}, + {-60.81475, 70.11576}, + {-60.546703, 71.07365}, + {-58.37554, 78.83239}, + }; + TEST_POLYFILL_TEMPLATE_STATIC(poly, false); +} |