diff --git a/CMakeLists.txt b/CMakeLists.txt index 20170f75b9ad..ae37029dd5a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -583,13 +583,6 @@ Try to link with static libraries, as much as possible, \ to make blender more portable across distributions" OFF ) - if(WITH_STATIC_LIBS) - option(WITH_BOOST_ICU "\ -Boost uses ICU library (required for linking with static Boost built with libicu)." - OFF - ) - mark_as_advanced(WITH_BOOST_ICU) - endif() endif() # Misc @@ -1315,9 +1308,7 @@ set_and_warn_dependency(WITH_PYTHON WITH_FREESTYLE OFF) #UPBGE # enable boost for cycles, audaspace or i18n # otherwise if the user disabled -set_and_warn_dependency(WITH_BOOST WITH_INTERNATIONAL OFF) set_and_warn_dependency(WITH_BOOST WITH_OPENVDB OFF) -set_and_warn_dependency(WITH_BOOST WITH_QUADRIFLOW OFF) set_and_warn_dependency(WITH_BOOST WITH_USD OFF) if(WITH_CYCLES) set_and_warn_dependency(WITH_BOOST WITH_CYCLES_OSL OFF) @@ -1553,16 +1544,6 @@ endif() # ----------------------------------------------------------------------------- # Common Checks for Compatible Options -if(WITH_INTERNATIONAL) - if(NOT WITH_BOOST) - message( - FATAL_ERROR - "Internationalization requires WITH_BOOST, the library may not have been found. " - "Configure BOOST or disable WITH_INTERNATIONAL" - ) - endif() -endif() - # Enable SIMD support if detected by `test_sse_support()` or `test_neon_support()`. # if(WITH_CPU_SIMD) @@ -1667,19 +1648,9 @@ if(WITH_OPENVDB) ${OPENEXR_INCLUDE_DIRS} ) - list(APPEND OPENVDB_LIBRARIES ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES}) - if(WITH_OPENVDB_BLOSC) list(APPEND OPENVDB_DEFINITIONS -DWITH_OPENVDB_BLOSC) - # Even when `WITH_OPENVDB_BLOSC` is set, `FindBlosc.cmake` isn't running. - # As this might be used at some point, check the libraries are defined. - if(DEFINED BLOSC_LIBRARIES) - list(APPEND OPENVDB_LIBRARIES ${BLOSC_LIBRARIES}) - endif() - list(APPEND OPENVDB_LIBRARIES ${ZLIB_LIBRARIES}) endif() - - list(APPEND OPENVDB_LIBRARIES ${BOOST_LIBRARIES} ${TBB_LIBRARIES}) endif() # ----------------------------------------------------------------------------- @@ -2818,6 +2789,7 @@ if(FIRST_RUN) info_cfg_option(WITH_OPENCOLLADA) info_cfg_option(WITH_OPENCOLORIO) info_cfg_option(WITH_OPENIMAGEDENOISE) + info_cfg_option(WITH_OPENSUBDIV) info_cfg_option(WITH_OPENVDB) info_cfg_option(WITH_POTRACE) info_cfg_option(WITH_PUGIXML) @@ -2861,6 +2833,7 @@ if(FIRST_RUN) info_cfg_option(WITH_IMAGE_OPENJPEG) info_cfg_text("Audio:") + info_cfg_option(WITH_AUDASPACE) info_cfg_option(WITH_CODEC_FFMPEG) info_cfg_option(WITH_CODEC_SNDFILE) info_cfg_option(WITH_COREAUDIO) diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 814f0abb7059..c83f6370174f 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -256,20 +256,15 @@ if(WITH_BOOST) set(Boost_ROOT ${LIBDIR}/boost) set(Boost_NO_SYSTEM_PATHS ON) set(_boost_FIND_COMPONENTS) - if(WITH_INTERNATIONAL) - list(APPEND _boost_FIND_COMPONENTS locale) - endif() if(WITH_USD AND USD_PYTHON_SUPPORT) list(APPEND _boost_FIND_COMPONENTS python${PYTHON_VERSION_NO_DOTS}) endif() set(Boost_NO_WARN_NEW_VERSIONS ON) find_package(Boost COMPONENTS ${_boost_FIND_COMPONENTS}) - # Boost Python is separate to avoid linking Python into tests that don't need it. - set(BOOST_LIBRARIES ${Boost_LIBRARIES}) + # Boost Python is the only library Blender directly depends on, though USD headers. if(WITH_USD AND USD_PYTHON_SUPPORT) set(BOOST_PYTHON_LIBRARIES ${Boost_PYTHON${PYTHON_VERSION_NO_DOTS}_LIBRARY}) - list(REMOVE_ITEM BOOST_LIBRARIES ${BOOST_PYTHON_LIBRARIES}) endif() set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) set(BOOST_DEFINITIONS) @@ -280,8 +275,8 @@ if(WITH_BOOST) endif() add_bundled_libraries(boost/lib) -if(WITH_INTERNATIONAL OR WITH_CODEC_FFMPEG) - string(APPEND PLATFORM_LINKFLAGS " -liconv") # boost_locale and ffmpeg needs it ! +if(WITH_CODEC_FFMPEG) + string(APPEND PLATFORM_LINKFLAGS " -liconv") # ffmpeg needs it ! endif() if(WITH_PUGIXML) diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 25bd6c3a6313..8112ce0e4c83 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -472,13 +472,9 @@ if(WITH_BOOST) endif() set(Boost_USE_MULTITHREADED ON) set(__boost_packages) - if(WITH_INTERNATIONAL) - list(APPEND __boost_packages locale) - endif() if(WITH_USD AND USD_PYTHON_SUPPORT) list(APPEND __boost_packages python${PYTHON_VERSION_NO_DOTS}) endif() - list(APPEND __boost_packages system) set(Boost_NO_WARN_NEW_VERSIONS ON) find_package(Boost 1.48 COMPONENTS ${__boost_packages}) if(NOT Boost_FOUND) @@ -489,27 +485,17 @@ if(WITH_BOOST) find_package(Boost 1.48 COMPONENTS ${__boost_packages}) endif() unset(__boost_packages) - if(Boost_USE_STATIC_LIBS AND WITH_BOOST_ICU) - find_package(IcuLinux) - endif() mark_as_advanced(Boost_DIR) # why doesn't boost do this? mark_as_advanced(Boost_INCLUDE_DIR) # why doesn't boost do this? endif() - # Boost Python is separate to avoid linking Python into tests that don't need it. - set(BOOST_LIBRARIES ${Boost_LIBRARIES}) + # Boost Python is the only library Blender directly depends on, though USD headers. if(WITH_USD AND USD_PYTHON_SUPPORT) set(BOOST_PYTHON_LIBRARIES ${Boost_PYTHON${PYTHON_VERSION_NO_DOTS}_LIBRARY}) - list(REMOVE_ITEM BOOST_LIBRARIES ${BOOST_PYTHON_LIBRARIES}) endif() set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS}) set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB") - - if(Boost_USE_STATIC_LIBS AND WITH_BOOST_ICU) - find_package(IcuLinux) - list(APPEND BOOST_LIBRARIES ${ICU_LIBRARIES}) - endif() endif() add_bundled_libraries(boost/lib) diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index c96470c2a02f..3a8f7b7b84bd 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -680,9 +680,7 @@ if(NOT WITH_WINDOWS_FIND_MODULES) endif() if(WITH_BOOST) - if(WITH_INTERNATIONAL) - list(APPEND boost_extra_libs locale) - endif() + set(boost_extra_libs) set(Boost_USE_STATIC_RUNTIME ON) # prefix lib set(Boost_USE_MULTITHREADED ON) # suffix -mt set(Boost_USE_STATIC_LIBS ON) # suffix -s @@ -698,8 +696,8 @@ if(WITH_BOOST) set(BOOST_DEBUG_POSTFIX "vc142-mt-gd-x64-${BOOST_VERSION}") set(BOOST_PREFIX "lib") endif() - set(BOOST_LIBRARIES) if(EXISTS ${BOOST_34_TRIGGER_FILE}) + # Boost Python is the only library Blender directly depends on, though USD headers. if(WITH_USD) set(BOOST_PYTHON_LIBRARIES debug ${BOOST_LIBPATH}/${BOOST_PREFIX}boost_python${_PYTHON_VERSION_NO_DOTS}-${BOOST_DEBUG_POSTFIX}.lib @@ -707,15 +705,8 @@ if(WITH_BOOST) ) endif() endif() - if(WITH_INTERNATIONAL) - set(BOOST_LIBRARIES ${BOOST_LIBRARIES} - optimized ${BOOST_LIBPATH}/${BOOST_PREFIX}boost_locale-${BOOST_POSTFIX}.lib - debug ${BOOST_LIBPATH}/${BOOST_PREFIX}boost_locale-${BOOST_DEBUG_POSTFIX}.lib - ) - endif() else() # we found boost using find_package set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) - set(BOOST_LIBRARIES ${Boost_LIBRARIES}) set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS}) endif() diff --git a/build_files/windows/parse_arguments.cmd b/build_files/windows/parse_arguments.cmd index 2b5ee28ab77d..d0f6d232d0f1 100644 --- a/build_files/windows/parse_arguments.cmd +++ b/build_files/windows/parse_arguments.cmd @@ -54,9 +54,6 @@ if NOT "%1" == "" ( set BUILD_ARCH=arm64 ) else if "%1" == "2019" ( set BUILD_VS_YEAR=2019 - ) else if "%1" == "2019pre" ( - set BUILD_VS_YEAR=2019 - set VSWHERE_ARGS=-prerelease ) else if "%1" == "2019b" ( set BUILD_VS_YEAR=2019 set VSWHERE_ARGS=-products Microsoft.VisualStudio.Product.BuildTools diff --git a/build_files/windows/show_help.cmd b/build_files/windows/show_help.cmd index 8178c9162b00..6ad1adb8c1b4 100644 --- a/build_files/windows/show_help.cmd +++ b/build_files/windows/show_help.cmd @@ -25,7 +25,6 @@ echo - debug ^(Build an unoptimized debuggable build^) echo - packagename [newname] ^(override default cpack package name^) echo - builddir [newdir] ^(override default build folder^) echo - 2019 ^(build with visual studio 2019^) -echo - 2019pre ^(build with visual studio 2019 pre-release^) echo - 2019b ^(build with visual studio 2019 Build Tools^) echo - 2022 ^(build with visual studio 2022^) echo - 2022pre ^(build with visual studio 2022 pre-release^) @@ -39,6 +38,6 @@ echo. echo Experimental options echo - with_gpu_tests ^(enable both the render and draw gpu test suites including EEVEE, Workbench, Grease Pencil, draw manager and GPU backends^) echo - clang ^(enable building with clang^) -echo - asan ^(enable asan when building with clang^) +echo - asan ^(enable asan^) echo - ninja ^(enable building with ninja instead of msbuild^) echo. diff --git a/doc/license/Boost-license.txt b/doc/license/Boost-license.txt new file mode 100644 index 000000000000..36b7cd93cdfb --- /dev/null +++ b/doc/license/Boost-license.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/doc/license/SPDX-license-identifiers.txt b/doc/license/SPDX-license-identifiers.txt index 62aa0bbb4cde..c63ed010b446 100644 --- a/doc/license/SPDX-license-identifiers.txt +++ b/doc/license/SPDX-license-identifiers.txt @@ -3,6 +3,7 @@ Corresponding SPDX license identifiers in the source code: Apache-2.0 Apache-2-license.txt https://spdx.org/licenses/Apache-2.0.html BSD-2-Clause BSD-2-Clause-license.txt https://spdx.org/licenses/BSD-2-Clause.html BSD-3-Clause BSD-3-Clause-license.txt https://spdx.org/licenses/BSD-3-Clause.html +BSL-1.0 Boost-license.txt https://spdx.org/licenses/BSL-1.0.html GPL-2.0-or-later GPL-license.txt https://spdx.org/licenses/GPL-2.0-or-later.html GPL-3.0-or-later GPL3-license.txt https://spdx.org/licenses/GPL-3.0-or-later.html LGPL-2.1-or-later LGPL2.1-license.txt https://spdx.org/licenses/LGPL-2.1-or-later.html diff --git a/extern/quadriflow/CMakeLists.txt b/extern/quadriflow/CMakeLists.txt index 8c0938ca7309..f42a68ab2467 100644 --- a/extern/quadriflow/CMakeLists.txt +++ b/extern/quadriflow/CMakeLists.txt @@ -51,11 +51,11 @@ set(INC ) set(INC_SYS - ${BOOST_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIRS} ) set(SRC + patches/boykov_kolmogorov_max_flow.hpp src/adjacent-matrix.cpp src/adjacent-matrix.hpp src/compare-key.hpp @@ -91,7 +91,6 @@ set(SRC ) set(LIB - ${BOOST_LIBRARIES} ) blender_add_lib(extern_quadriflow "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/extern/quadriflow/patches/blender.patch b/extern/quadriflow/patches/blender.patch index 42e0cd4d2359..d74bd09f22ff 100644 --- a/extern/quadriflow/patches/blender.patch +++ b/extern/quadriflow/patches/blender.patch @@ -1,33 +1,5 @@ -diff --git a/extern/quadriflow/src/loader.cpp b/extern/quadriflow/src/loader.cpp ---- a/extern/quadriflow/src/loader.cpp -+++ b/extern/quadriflow/src/loader.cpp -@@ -69,7 +69,7 @@ - }; - - /// Hash function for obj_vertex -- struct obj_vertexHash : std::unary_function { -+ struct obj_vertexHash { - std::size_t operator()(const obj_vertex &v) const { - size_t hash = std::hash()(v.p); - hash = hash * 37 + std::hash()(v.uv); -diff --git a/extern/quadriflow/src/config.hpp b/extern/quadriflow/src/config.hpp -index 842b885..bf597ad 100644 ---- a/extern/quadriflow/src/config.hpp -+++ b/extern/quadriflow/src/config.hpp -@@ -1,6 +1,11 @@ - #ifndef CONFIG_H_ - #define CONFIG_H_ - -+/* Workaround a bug in boost 1.68, until we upgrade to a newer version. */ -+#if defined(__clang__) && defined(WIN32) -+ #include -+ using namespace boost; -+#endif - // Move settings to cmake to make CMake happy :) - - // #define WITH_SCALE diff --git a/extern/quadriflow/3rd/lemon-1.3.1/lemon/arg_parser.cc b/extern/quadriflow/3rd/lemon-1.3.1/lemon/arg_parser.cc -index 35a73d9..0eeba8a 100644 +index 35a73d9f308..0eeba8ab6c2 100644 --- a/extern/quadriflow/3rd/lemon-1.3.1/lemon/arg_parser.cc +++ b/extern/quadriflow/3rd/lemon-1.3.1/lemon/arg_parser.cc @@ -221,9 +221,8 @@ namespace lemon { @@ -41,108 +13,6 @@ index 35a73d9..0eeba8a 100644 ParData p; p.help=opt; p.mandatory=false; -diff --git a/extern/quadriflow/3rd/lemon-1.3.1/lemon/network_simplex.h b/extern/quadriflow/3rd/lemon-1.3.1/lemon/network_simplex.h -index 6ccad33..388e990 100644 ---- a/extern/quadriflow/3rd/lemon-1.3.1/lemon/network_simplex.h -+++ b/extern/quadriflow/3rd/lemon-1.3.1/lemon/network_simplex.h -@@ -234,7 +234,7 @@ namespace lemon { - int in_arc, join, u_in, v_in, u_out, v_out; - Value delta; - -- const Value MAX; -+ const Value MAX_VALUE; - - public: - -@@ -649,9 +649,9 @@ namespace lemon { - NetworkSimplex(const GR& graph, bool arc_mixing = true) : - _graph(graph), _node_id(graph), _arc_id(graph), - _arc_mixing(arc_mixing), -- MAX(std::numeric_limits::max()), -+ MAX_VALUE(std::numeric_limits::max()), - INF(std::numeric_limits::has_infinity ? -- std::numeric_limits::infinity() : MAX) -+ std::numeric_limits::infinity() : MAX_VALUE) - { - // Check the number types - LEMON_ASSERT(std::numeric_limits::is_signed, -@@ -1076,9 +1076,9 @@ namespace lemon { - for (int i = 0; i != _arc_num; ++i) { - Value c = _lower[i]; - if (c >= 0) { -- _cap[i] = _upper[i] < MAX ? _upper[i] - c : INF; -+ _cap[i] = _upper[i] < MAX_VALUE ? _upper[i] - c : INF; - } else { -- _cap[i] = _upper[i] < MAX + c ? _upper[i] - c : INF; -+ _cap[i] = _upper[i] < MAX_VALUE + c ? _upper[i] - c : INF; - } - _supply[_source[i]] -= c; - _supply[_target[i]] += c; -@@ -1282,7 +1282,7 @@ namespace lemon { - d = _flow[e]; - if (_pred_dir[u] == DIR_DOWN) { - c = _cap[e]; -- d = c >= MAX ? INF : c - d; -+ d = c >= MAX_VALUE ? INF : c - d; - } - if (d < delta) { - delta = d; -@@ -1297,7 +1297,7 @@ namespace lemon { - d = _flow[e]; - if (_pred_dir[u] == DIR_UP) { - c = _cap[e]; -- d = c >= MAX ? INF : c - d; -+ d = c >= MAX_VALUE ? INF : c - d; - } - if (d <= delta) { - delta = d; -@@ -1559,7 +1559,7 @@ namespace lemon { - _pi[_target[in_arc]]) >= 0) continue; - findJoinNode(); - bool change = findLeavingArc(); -- if (delta >= MAX) return false; -+ if (delta >= MAX_VALUE) return false; - changeFlow(change); - if (change) { - updateTreeStructure(); -@@ -1598,7 +1598,7 @@ namespace lemon { - while (pivot.findEnteringArc()) { - findJoinNode(); - bool change = findLeavingArc(); -- if (delta >= MAX) return UNBOUNDED; -+ if (delta >= MAX_VALUE) return UNBOUNDED; - changeFlow(change); - if (change) { - updateTreeStructure(); -diff --git a/extern/quadriflow/src/hierarchy.cpp b/extern/quadriflow/src/hierarchy.cpp -index c333256..8cc41da 100644 ---- a/extern/quadriflow/src/hierarchy.cpp -+++ b/extern/quadriflow/src/hierarchy.cpp -@@ -1133,7 +1133,8 @@ void Hierarchy::propagateConstraints() { - auto& COw = mCOw[l]; - auto& COw_next = mCOw[l + 1]; - auto& toUpper = mToUpper[l]; -- MatrixXd& S = mS[l]; -+ // FIXME -+ // MatrixXd& S = mS[l]; - - for (uint32_t i = 0; i != mV[l + 1].cols(); ++i) { - Vector2i upper = toUpper.col(i); -diff --git a/extern/quadriflow/3rd/lemon-1.3.1/lemon/random.h b/extern/quadriflow/3rd/lemon-1.3.1/lemon/random.h -index 8de74ede8a9..f9861f39169 100644 ---- a/extern/quadriflow/3rd/lemon-1.3.1/lemon/random.h -+++ b/extern/quadriflow/3rd/lemon-1.3.1/lemon/random.h -@@ -249,8 +249,8 @@ namespace lemon { - - current = state + length; - -- register Word *curr = state + length - 1; -- register long num; -+ Word *curr = state + length - 1; -+ long num; - - num = length - shift; - while (num--) { diff --git a/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h b/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h index 355ee008246..a770bbee60c 100644 --- a/extern/quadriflow/3rd/lemon-1.3.1/lemon/bits/array_map.h @@ -231,8 +101,96 @@ index 355ee008246..a770bbee60c 100644 } allocator.deallocate(values, capacity); capacity = 0; +diff --git a/extern/quadriflow/3rd/lemon-1.3.1/lemon/network_simplex.h b/extern/quadriflow/3rd/lemon-1.3.1/lemon/network_simplex.h +index 6ccad33e68e..388e990ec3b 100644 +--- a/extern/quadriflow/3rd/lemon-1.3.1/lemon/network_simplex.h ++++ b/extern/quadriflow/3rd/lemon-1.3.1/lemon/network_simplex.h +@@ -234,7 +234,7 @@ namespace lemon { + int in_arc, join, u_in, v_in, u_out, v_out; + Value delta; + +- const Value MAX; ++ const Value MAX_VALUE; + + public: + +@@ -649,9 +649,9 @@ namespace lemon { + NetworkSimplex(const GR& graph, bool arc_mixing = true) : + _graph(graph), _node_id(graph), _arc_id(graph), + _arc_mixing(arc_mixing), +- MAX(std::numeric_limits::max()), ++ MAX_VALUE(std::numeric_limits::max()), + INF(std::numeric_limits::has_infinity ? +- std::numeric_limits::infinity() : MAX) ++ std::numeric_limits::infinity() : MAX_VALUE) + { + // Check the number types + LEMON_ASSERT(std::numeric_limits::is_signed, +@@ -1076,9 +1076,9 @@ namespace lemon { + for (int i = 0; i != _arc_num; ++i) { + Value c = _lower[i]; + if (c >= 0) { +- _cap[i] = _upper[i] < MAX ? _upper[i] - c : INF; ++ _cap[i] = _upper[i] < MAX_VALUE ? _upper[i] - c : INF; + } else { +- _cap[i] = _upper[i] < MAX + c ? _upper[i] - c : INF; ++ _cap[i] = _upper[i] < MAX_VALUE + c ? _upper[i] - c : INF; + } + _supply[_source[i]] -= c; + _supply[_target[i]] += c; +@@ -1282,7 +1282,7 @@ namespace lemon { + d = _flow[e]; + if (_pred_dir[u] == DIR_DOWN) { + c = _cap[e]; +- d = c >= MAX ? INF : c - d; ++ d = c >= MAX_VALUE ? INF : c - d; + } + if (d < delta) { + delta = d; +@@ -1297,7 +1297,7 @@ namespace lemon { + d = _flow[e]; + if (_pred_dir[u] == DIR_UP) { + c = _cap[e]; +- d = c >= MAX ? INF : c - d; ++ d = c >= MAX_VALUE ? INF : c - d; + } + if (d <= delta) { + delta = d; +@@ -1559,7 +1559,7 @@ namespace lemon { + _pi[_target[in_arc]]) >= 0) continue; + findJoinNode(); + bool change = findLeavingArc(); +- if (delta >= MAX) return false; ++ if (delta >= MAX_VALUE) return false; + changeFlow(change); + if (change) { + updateTreeStructure(); +@@ -1598,7 +1598,7 @@ namespace lemon { + while (pivot.findEnteringArc()) { + findJoinNode(); + bool change = findLeavingArc(); +- if (delta >= MAX) return UNBOUNDED; ++ if (delta >= MAX_VALUE) return UNBOUNDED; + changeFlow(change); + if (change) { + updateTreeStructure(); +diff --git a/extern/quadriflow/3rd/lemon-1.3.1/lemon/random.h b/extern/quadriflow/3rd/lemon-1.3.1/lemon/random.h +index 8de74ede8a9..f9861f39169 100644 +--- a/extern/quadriflow/3rd/lemon-1.3.1/lemon/random.h ++++ b/extern/quadriflow/3rd/lemon-1.3.1/lemon/random.h +@@ -249,8 +249,8 @@ namespace lemon { + + current = state + length; + +- register Word *curr = state + length - 1; +- register long num; ++ Word *curr = state + length - 1; ++ long num; + + num = length - shift; + while (num--) { diff --git a/extern/quadriflow/src/hierarchy.cpp b/extern/quadriflow/src/hierarchy.cpp -index 8cc41da23d0..70a9628320f 100644 +index c333256a139..70a9628320f 100644 --- a/extern/quadriflow/src/hierarchy.cpp +++ b/extern/quadriflow/src/hierarchy.cpp @@ -269,7 +269,13 @@ void Hierarchy::DownsampleGraph(const AdjacentMatrix adj, const MatrixXd& V, con @@ -249,4 +207,335 @@ index 8cc41da23d0..70a9628320f 100644 + } *entry_it = Entry(i, k, dp * ratio); } - } \ No newline at end of file + } +@@ -1133,7 +1139,8 @@ void Hierarchy::propagateConstraints() { + auto& COw = mCOw[l]; + auto& COw_next = mCOw[l + 1]; + auto& toUpper = mToUpper[l]; +- MatrixXd& S = mS[l]; ++ // FIXME ++ // MatrixXd& S = mS[l]; + + for (uint32_t i = 0; i != mV[l + 1].cols(); ++i) { + Vector2i upper = toUpper.col(i); +diff --git a/extern/quadriflow/src/loader.cpp b/extern/quadriflow/src/loader.cpp +index aa27066e6e4..5b9d717db71 100644 +--- a/extern/quadriflow/src/loader.cpp ++++ b/extern/quadriflow/src/loader.cpp +@@ -8,6 +8,7 @@ + + #include "loader.hpp" + ++#include + #include + #include + +@@ -69,7 +70,7 @@ void load(const char* filename, MatrixXd& V, MatrixXi& F) + }; + + /// Hash function for obj_vertex +- struct obj_vertexHash : std::unary_function { ++ struct obj_vertexHash { + std::size_t operator()(const obj_vertex &v) const { + size_t hash = std::hash()(v.p); + hash = hash * 37 + std::hash()(v.uv); +diff --git a/extern/quadriflow/src/flow.hpp b/extern/quadriflow/src/flow.hpp +index ab4a01c..a77f7ae 100644 +--- a/extern/quadriflow/src/flow.hpp ++++ b/extern/quadriflow/src/flow.hpp +@@ -7,17 +7,12 @@ + #include + + #include "config.hpp" +- +-#include +-#include +-#include +-#include ++#include "../patches/boykov_kolmogorov_max_flow.hpp" + + #include + #include + #include + +-using namespace boost; + using namespace Eigen; + + namespace qflow { +@@ -34,78 +29,52 @@ class MaxFlowHelper { + + class BoykovMaxFlowHelper : public MaxFlowHelper { + public: +- typedef int EdgeWeightType; +- typedef adjacency_list_traits Traits; +- // clang-format off +- typedef adjacency_list < vecS, vecS, directedS, +- property < vertex_name_t, std::string, +- property < vertex_index_t, long, +- property < vertex_color_t, boost::default_color_type, +- property < vertex_distance_t, long, +- property < vertex_predecessor_t, Traits::edge_descriptor > > > > >, +- +- property < edge_capacity_t, EdgeWeightType, +- property < edge_residual_capacity_t, EdgeWeightType, +- property < edge_reverse_t, Traits::edge_descriptor > > > > Graph; +- // clang-format on +- +- public: +- BoykovMaxFlowHelper() { rev = get(edge_reverse, g); } +- void resize(int n, int m) { +- vertex_descriptors.resize(n); +- for (int i = 0; i < n; ++i) vertex_descriptors[i] = add_vertex(g); +- } +- int compute() { +- EdgeWeightType flow = +- boykov_kolmogorov_max_flow(g, vertex_descriptors.front(), vertex_descriptors.back()); +- return flow; ++ BoykovMaxFlowHelper() = default; ++ void resize(int n, int m) override { ++ num_verts = n; ++ num_edges = 0; ++ flow.resize(num_verts, m * 2); + } +- void addDirectEdge(Traits::vertex_descriptor& v1, Traits::vertex_descriptor& v2, +- property_map::type& rev, const int capacity, +- const int inv_capacity, Graph& g, Traits::edge_descriptor& e1, +- Traits::edge_descriptor& e2) { +- e1 = add_edge(v1, v2, g).first; +- e2 = add_edge(v2, v1, g).first; +- put(edge_capacity, g, e1, capacity); +- put(edge_capacity, g, e2, inv_capacity); +- +- rev[e1] = e2; +- rev[e2] = e1; ++ int compute() override { ++ return flow.max_flow(0, num_verts - 1); + } +- void addEdge(int x, int y, int c, int rc, int v, int cost = 1) { +- Traits::edge_descriptor e1, e2; +- addDirectEdge(vertex_descriptors[x], vertex_descriptors[y], rev, c, rc, g, e1, e2); ++ void addEdge(int x, int y, int c, int rc, int v, int cost = 1) override { ++ const int e1 = num_edges++; ++ const int e2 = num_edges++; ++ flow.set_edge(e1, e2, x, y, c); ++ flow.set_edge(e2, e1, y, x, rc); + if (v != -1) { +- edge_to_variables[e1] = std::make_pair(v, -1); +- edge_to_variables[e2] = std::make_pair(v, 1); ++ edge_to_variables.emplace_back(v, -1); ++ edge_to_variables.emplace_back(v, 1); ++ } ++ else { ++ edge_to_variables.emplace_back(-1, -1); ++ edge_to_variables.emplace_back(-1, -1); + } + } +- void applyTo(std::vector& edge_diff) { +- property_map::type capacity = get(edge_capacity, g); +- property_map::type residual_capacity = +- get(edge_residual_capacity, g); +- +- graph_traits::vertex_iterator u_iter, u_end; +- graph_traits::out_edge_iterator ei, e_end; +- for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) +- for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) +- if (capacity[*ei] > 0) { +- int flow = (capacity[*ei] - residual_capacity[*ei]); ++ void applyTo(std::vector& edge_diff) override { ++ for (int vert = 0; vert < num_verts; vert++) { ++ for (int edge : flow.vertex_out_edges(vert)) { ++ const int capacity = flow.edge_capacity(edge); ++ const int residual_capacity = flow.edge_residual_capacity(edge); ++ if (capacity > 0) { ++ int flow = (capacity - residual_capacity); + if (flow > 0) { +- auto it = edge_to_variables.find(*ei); +- if (it != edge_to_variables.end()) { +- edge_diff[it->second.first / 2][it->second.first % 2] += +- it->second.second * flow; ++ std::pair e2v = edge_to_variables[edge]; ++ if (e2v.first != -1) { ++ edge_diff[e2v.first / 2][e2v.first % 2] += e2v.second * flow; + } + } + } ++ } ++ } + } + + private: +- Graph g; +- property_map::type rev; +- std::vector vertex_descriptors; +- std::map> edge_to_variables; ++ BoykovKolmogorovMaxFlow flow; ++ std::vector> edge_to_variables; ++ int num_verts = 0; ++ int num_edges = 0; + }; + + class NetworkSimplexFlowHelper : public MaxFlowHelper { +diff --git a/extern/quadriflow/src/main.cpp b/extern/quadriflow/src/main.cpp +index 18bc4063c42..63c9e61b8c9 100644 +--- a/extern/quadriflow/src/main.cpp ++++ b/extern/quadriflow/src/main.cpp +@@ -110,7 +110,10 @@ int main(int argc, char** argv) { + printf("Use %lf seconds\n", (t2 - t1) * 1e-3); + t1 = GetCurrentTime64(); + printf("Solve index map...\n"); +- field.ComputeIndexMap(); ++ if (!field.ComputeIndexMap()) { ++ fprintf(stderr, "Failed to solve result, exiting!\n"); ++ return 1; ++ } + t2 = GetCurrentTime64(); + printf("Indexmap Use %lf seconds\n", (t2 - t1) * 1e-3); + printf("Writing the file...\n"); +diff --git a/extern/quadriflow/src/parametrizer.cpp b/extern/quadriflow/src/parametrizer.cpp +index b85383566c9..3dbdc386eca 100644 +--- a/extern/quadriflow/src/parametrizer.cpp ++++ b/extern/quadriflow/src/parametrizer.cpp +@@ -18,7 +18,7 @@ + + namespace qflow { + +-void Parametrizer::ComputeIndexMap(int with_scale) { ++bool Parametrizer::ComputeIndexMap(int with_scale) { + // build edge info + auto& V = hierarchy.mV[0]; + auto& F = hierarchy.mF; +@@ -80,9 +80,12 @@ void Parametrizer::ComputeIndexMap(int with_scale) { + #ifdef LOG_OUTPUT + printf("subdivide...\n"); + #endif +- subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, +- edge_diff, edge_values, face_edgeOrients, face_edgeIds, sharp_edges, +- singularities, 1); ++ if (!subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, ++ edge_diff, edge_values, face_edgeOrients, face_edgeIds, sharp_edges, ++ singularities, 1)) ++ { ++ return false; ++ } + + allow_changes.clear(); + allow_changes.resize(edge_diff.size() * 2, 1); +@@ -99,9 +102,12 @@ void Parametrizer::ComputeIndexMap(int with_scale) { + int t1 = GetCurrentTime64(); + #endif + FixFlipHierarchy(); +- subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, ++ if (!subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, + edge_diff, edge_values, face_edgeOrients, face_edgeIds, sharp_edges, +- singularities, 1); ++ singularities, 1)) ++ { ++ return false; ++ } + FixFlipSat(); + + #ifdef LOG_OUTPUT +@@ -242,6 +248,7 @@ void Parametrizer::ComputeIndexMap(int with_scale) { + // E2E_compact, + // V, N, Q, O, F, V2E, hierarchy.mE2E, disajoint_tree, + // hierarchy.mScale, false); ++ return true; + } + + } // namespace qflow +diff --git a/extern/quadriflow/src/parametrizer.hpp b/extern/quadriflow/src/parametrizer.hpp +index 1f4a02be6c2..9703ebbfff6 100644 +--- a/extern/quadriflow/src/parametrizer.hpp ++++ b/extern/quadriflow/src/parametrizer.hpp +@@ -54,7 +54,8 @@ class Parametrizer { + void ComputePositionSingularities(); + + // Integer Grid Map Pipeline +- void ComputeIndexMap(int with_scale = 0); ++ // Return false when the solver fails. ++ bool ComputeIndexMap(int with_scale = 0); + void BuildEdgeInfo(); + void ComputeMaxFlow(); + void MarkInteger(); +diff --git a/extern/quadriflow/src/post-solver.cpp b/extern/quadriflow/src/post-solver.cpp +index 6027ddd..ccefd15 100644 +--- a/extern/quadriflow/src/post-solver.cpp ++++ b/extern/quadriflow/src/post-solver.cpp +@@ -5,7 +5,9 @@ + // Created by Jingwei on 2/5/18. + // + #include ++#ifdef POST_SOLVER + #include ++#endif + #include + #include + #include +diff --git a/extern/quadriflow/src/subdivide.cpp b/extern/quadriflow/src/subdivide.cpp +index c408bbc6394..babff96ccb4 100644 +--- a/extern/quadriflow/src/subdivide.cpp ++++ b/extern/quadriflow/src/subdivide.cpp +@@ -145,7 +145,7 @@ void subdivide(MatrixXi &F, MatrixXd &V, VectorXd& rho, VectorXi &V2E, VectorXi + E2E.conservativeResize(nF * 3); + } + +-void subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, ++bool subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, + VectorXi &V2E, VectorXi &E2E, VectorXi &boundary, VectorXi &nonmanifold, + std::vector &edge_diff, std::vector &edge_values, + std::vector &face_edgeOrients, std::vector &face_edgeIds, +@@ -500,17 +500,18 @@ void subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, Matr + for (int j = 0; j < 3; ++j) { + auto diff = edge_diff[face_edgeIds[i][j]]; + if (abs(diff[0]) > 1 || abs(diff[1]) > 1) { +- printf("wrong init %d %d!\n", face_edgeIds[i][j], i * 3 + j); +- exit(0); ++ fprintf(stderr, "wrong init %d %d!\n", face_edgeIds[i][j], i * 3 + j); ++ return false; + } + } + } + for (int i = 0; i < edge_diff.size(); ++i) { + if (abs(edge_diff[i][0]) > 1 || abs(edge_diff[i][1]) > 1) { +- printf("wrong...\n"); +- exit(0); ++ fprintf(stderr, "wrong...\n"); ++ return false; + } + } ++ return true; + } + + } // namespace qflow +diff --git a/extern/quadriflow/src/subdivide.hpp b/extern/quadriflow/src/subdivide.hpp +index a93c58ac2a7..8c682b6d9f2 100644 +--- a/extern/quadriflow/src/subdivide.hpp ++++ b/extern/quadriflow/src/subdivide.hpp +@@ -9,7 +9,8 @@ namespace qflow { + void subdivide(MatrixXi &F, MatrixXd &V, VectorXd& rho, VectorXi &V2E, VectorXi &E2E, VectorXi &boundary, + VectorXi &nonmanifold, double maxLength); + +-void subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, ++// Return false when solving fails. ++bool subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, + VectorXi &V2E, VectorXi &E2E, VectorXi &boundary, VectorXi &nonmanifold, + std::vector &edge_diff, std::vector &edge_values, + std::vector &face_edgeOrients, std::vector &face_edgeIds, +diff --git a/intern/quadriflow/quadriflow_capi.cpp b/intern/quadriflow/quadriflow_capi.cpp +index fad604f679a..014ac2a5613 100644 +--- a/intern/quadriflow/quadriflow_capi.cpp ++++ b/intern/quadriflow/quadriflow_capi.cpp +@@ -190,8 +190,11 @@ void QFLOW_quadriflow_remesh(QuadriflowRemeshData *qrd, + return; + } + +- /* Compute the final quad geomtry using a maxflow solver */ +- field.ComputeIndexMap(); ++ /* Compute the final quad geometry using a maxflow solver */ ++ if (!field.ComputeIndexMap()) { ++ /* Error computing the result. */ ++ return; ++ } + + if (check_if_canceled(0.9f, update_cb, update_cb_data)) { + return; diff --git a/extern/quadriflow/patches/boykov_kolmogorov_max_flow.hpp b/extern/quadriflow/patches/boykov_kolmogorov_max_flow.hpp new file mode 100644 index 000000000000..96df563f0c48 --- /dev/null +++ b/extern/quadriflow/patches/boykov_kolmogorov_max_flow.hpp @@ -0,0 +1,691 @@ +// SPDX-FileCopyrightText: 2006 Stephan Diederich +// SPDX-FileCopyrightText: 2024 Blender Authors +// SPDX-License-Identifier: MIT +// +// Adapted from boost::graph + +#include +#include +#include +#include +#include +#include + +namespace qflow { + +class BoykovKolmogorovMaxFlow { + // Types + enum class Color { white, black, gray }; + + struct Edge { + int source; + int target; + }; + + const int NULL_VERTEX = -1; + const int NULL_EDGE = -1; + + public: + BoykovKolmogorovMaxFlow() = default; + + void resize(int num_verts, int num_edges) + { + m_graph_edges.resize(num_edges); + m_graph_out_edges.resize(num_verts); + m_cap_map.resize(num_edges); + m_res_cap_map.resize(num_edges); + m_rev_edge_map.resize(num_edges); + m_pre_map.resize(num_verts, 0); + m_tree_map.resize(num_verts, Color::gray); + m_dist_map.resize(num_verts, 0); + m_in_active_list_map.resize(num_verts, false); + m_has_parent_map.resize(num_verts, false); + m_time_map.resize(num_verts, 0); + } + + void set_edge(const int edge, + const int reverse_edge, + const int source, + const int target, + const int capacity) + { + m_graph_edges[edge] = Edge{source, target}; + m_graph_out_edges[source].push_back(edge); + m_rev_edge_map[edge] = reverse_edge; + + // Initialize flow to zero which means initializing + // the residual capacity equal to the capacity + m_cap_map[edge] = capacity; + m_res_cap_map[edge] = capacity; + } + + int edge_capacity(const int edge) + { + return m_cap_map[edge]; + } + + int edge_residual_capacity(const int edge) + { + return m_res_cap_map[edge]; + } + + const std::vector &vertex_out_edges(const int vertex) + { + return m_graph_out_edges[vertex]; + } + + int max_flow(int src, int sink) + { + m_source = src; + m_sink = sink; + + // init the search trees with the two terminals + m_tree_map[m_source] = Color::black; + m_tree_map[m_sink] = Color::white; + m_time_map[m_source] = 1; + m_time_map[m_sink] = 1; + + // augment direct paths from SOURCE->SINK and SOURCE->VERTEX->SINK + augment_direct_paths(); + // start the main-loop + while (true) { + bool path_found; + int connecting_edge; + std::tie(connecting_edge, path_found) = grow(); // find a path from source to sink + if (!path_found) { + // we're finished, no more paths were found + break; + } + ++m_time; + augment(connecting_edge); // augment that path + adopt(); // rebuild search tree structure + } + return m_flow; + } + + protected: + int lookup_edge(int source, int target) + { + for (const int e : m_graph_out_edges[source]) { + if (m_graph_edges[e].target == target) { + return e; + } + } + return NULL_EDGE; + } + + void augment_direct_paths() + { + // in a first step, we augment all direct paths from + // source->NODE->sink and additionally paths from source->sink. This + // improves especially graphcuts for segmentation, as most of the + // nodes have source/sink connects but shouldn't have an impact on + // other maxflow problems (this is done in grow() anyway) + for (const int ei : m_graph_out_edges[m_source]) { + int from_source = ei; + int current_node = m_graph_edges[from_source].target; + if (current_node == m_sink) { + int cap = m_res_cap_map[from_source]; + m_res_cap_map[from_source] = 0; + m_flow += cap; + continue; + } + const int to_sink = lookup_edge(current_node, m_sink); + if (to_sink != NULL_EDGE) { + int cap_from_source = m_res_cap_map[from_source]; + int cap_to_sink = m_res_cap_map[to_sink]; + if (cap_from_source > cap_to_sink) { + m_tree_map[current_node] = Color::black; + add_active_node(current_node); + set_edge_to_parent(current_node, from_source); + m_dist_map[current_node] = 1; + m_time_map[current_node] = 1; + // add stuff to flow and update residuals. we dont need + // to update reverse_edges, as incoming/outgoing edges + // to/from source/sink don't count for max-flow + m_res_cap_map[from_source] = m_res_cap_map[from_source] - cap_to_sink; + m_res_cap_map[to_sink] = 0; + m_flow += cap_to_sink; + } + else if (cap_to_sink > 0) { + m_tree_map[current_node] = Color::white; + add_active_node(current_node); + set_edge_to_parent(current_node, to_sink); + m_dist_map[current_node] = 1; + m_time_map[current_node] = 1; + // add stuff to flow and update residuals. we dont need + // to update reverse_edges, as incoming/outgoing edges + // to/from source/sink don't count for max-flow + m_res_cap_map[to_sink] = m_res_cap_map[to_sink] - cap_from_source; + m_res_cap_map[from_source] = 0; + m_flow += cap_from_source; + } + } + else if (m_res_cap_map[from_source]) { + // there is no sink connect, so we can't augment this path, + // but to avoid adding m_source to the active nodes, we just + // activate this node and set the approciate things + m_tree_map[current_node] = Color::black; + set_edge_to_parent(current_node, from_source); + m_dist_map[current_node] = 1; + m_time_map[current_node] = 1; + add_active_node(current_node); + } + } + for (const int ei : m_graph_out_edges[m_sink]) { + int to_sink = m_rev_edge_map[ei]; + int current_node = m_graph_edges[to_sink].source; + if (m_res_cap_map[to_sink]) { + m_tree_map[current_node] = Color::white; + set_edge_to_parent(current_node, to_sink); + m_dist_map[current_node] = 1; + m_time_map[current_node] = 1; + add_active_node(current_node); + } + } + } + + /** + * Returns a pair of an edge and a boolean. if the bool is true, the + * edge is a connection of a found path from s->t , read "the link" and + * m_graph_edges[returnVal].source is the end of the path found in the + * source-tree m_graph_edges[returnVal].target is the beginning of the path found + * in the sink-tree + */ + std::pair grow() + { + assert(m_orphans.empty()); + int current_node; + while ((current_node = get_next_active_node()) != NULL_VERTEX) { // if there is one + assert(m_tree_map[current_node] != Color::gray && + (has_parent(current_node) || current_node == m_source || current_node == m_sink)); + + if (m_tree_map[current_node] == Color::black) { + // source tree growing + if (current_node != m_last_grow_vertex) { + m_last_grow_vertex = current_node; + m_last_grow_out_edge = 0; + } + const std::vector &out_edges = m_graph_out_edges[m_last_grow_vertex]; + for (; m_last_grow_out_edge < out_edges.size(); m_last_grow_out_edge++) { + int out_edge = out_edges[m_last_grow_out_edge]; + if (m_res_cap_map[out_edge] > 0) { // check if we have capacity left on this edge + int other_node = m_graph_edges[out_edge].target; + if (m_tree_map[other_node] == Color::gray) { // it's a free node + // aquire other node to our search tree + m_tree_map[other_node] = Color::black; + set_edge_to_parent(other_node, out_edge); // set us as parent + m_dist_map[other_node] = m_dist_map[current_node] + 1; // and update the + // distance-heuristic + m_time_map[other_node] = m_time_map[current_node]; + add_active_node(other_node); + } + else if (m_tree_map[other_node] == Color::black) { + // we do this to get shorter paths. check if we + // are nearer to the source as its parent is + if (is_closer_to_terminal(current_node, other_node)) { + set_edge_to_parent(other_node, out_edge); + m_dist_map[other_node] = m_dist_map[current_node] + 1; + m_time_map[other_node] = m_time_map[current_node]; + } + } + else { + assert(m_tree_map[other_node] == Color::white); + // kewl, found a path from one to the other + // search tree, return + // the connecting edge in src->sink dir + return std::make_pair(out_edge, true); + } + } + } // for all out-edges + } // source-tree-growing + else { + assert(m_tree_map[current_node] == Color::white); + if (current_node != m_last_grow_vertex) { + m_last_grow_vertex = current_node; + m_last_grow_out_edge = 0; + } + const std::vector &out_edges = m_graph_out_edges[m_last_grow_vertex]; + for (; m_last_grow_out_edge < out_edges.size(); m_last_grow_out_edge++) { + int in_edge = m_rev_edge_map[out_edges[m_last_grow_out_edge]]; + if (m_res_cap_map[in_edge] > 0) { // check if there is capacity left + int other_node = m_graph_edges[in_edge].source; + if (m_tree_map[other_node] == Color::gray) { // it's a free node + // aquire other node to our search tree + m_tree_map[other_node] = Color::white; + set_edge_to_parent(other_node, in_edge); // set us as parent + add_active_node(other_node); // activate that node + m_dist_map[other_node] = m_dist_map[current_node] + 1; // set its distance + m_time_map[other_node] = m_time_map[current_node]; // and time + } + else if (m_tree_map[other_node] == Color::white) { + if (is_closer_to_terminal(current_node, other_node)) { + // we are closer to the sink than its parent + // is, so we "adopt" him + set_edge_to_parent(other_node, in_edge); + m_dist_map[other_node] = m_dist_map[current_node] + 1; + m_time_map[other_node] = m_time_map[current_node]; + } + } + else { + assert(m_tree_map[other_node] == Color::black); + // kewl, found a path from one to the other + // search tree, + // return the connecting edge in src->sink dir + return std::make_pair(in_edge, true); + } + } + } // for all out-edges + } // sink-tree growing + + // all edges of that node are processed, and no more paths were + // found. + // remove if from the front of the active queue + finish_node(current_node); + } // while active_nodes not empty + + // no active nodes anymore and no path found, we're done + return std::make_pair(int(), false); + } + + /** + * augments path from s->t and updates residual graph + * m_graph_edges[e].source is the end of the path found in the source-tree + * m_graph_edges[e].target is the beginning of the path found in the sink-tree + * this phase generates orphans on satured edges, if the attached verts + * are from different search-trees orphans are ordered in distance to + * sink/source. first the farest from the source are front_inserted into + * the orphans list, and after that the sink-tree-orphans are + * front_inserted. when going to adoption stage the orphans are + * popped_front, and so we process the nearest verts to the terminals + * first + */ + void augment(int e) + { + assert(m_tree_map[m_graph_edges[e].target] == Color::white); + assert(m_tree_map[m_graph_edges[e].source] == Color::black); + assert(m_orphans.empty()); + + const int bottleneck = find_bottleneck(e); + // now we push the found flow through the path + // for each edge we saturate we have to look for the verts that + // belong to that edge, one of them becomes an orphans now process + // the connecting edge + m_res_cap_map[e] = m_res_cap_map[e] - bottleneck; + assert(m_res_cap_map[e] >= 0); + m_res_cap_map[m_rev_edge_map[e]] = m_res_cap_map[m_rev_edge_map[e]] + bottleneck; + + // now we follow the path back to the source + int current_node = m_graph_edges[e].source; + while (current_node != m_source) { + int pred = get_edge_to_parent(current_node); + m_res_cap_map[pred] = m_res_cap_map[pred] - bottleneck; + assert(m_res_cap_map[pred] >= 0); + m_res_cap_map[m_rev_edge_map[pred]] = m_res_cap_map[m_rev_edge_map[pred]] + bottleneck; + if (m_res_cap_map[pred] == 0) { + set_no_parent(current_node); + m_orphans.push_front(current_node); + } + current_node = m_graph_edges[pred].source; + } + // then go forward in the sink-tree + current_node = m_graph_edges[e].target; + while (current_node != m_sink) { + int pred = get_edge_to_parent(current_node); + m_res_cap_map[pred] = m_res_cap_map[pred] - bottleneck; + assert(m_res_cap_map[pred] >= 0); + m_res_cap_map[m_rev_edge_map[pred]] = m_res_cap_map[m_rev_edge_map[pred]] + bottleneck; + if (m_res_cap_map[pred] == 0) { + set_no_parent(current_node); + m_orphans.push_front(current_node); + } + current_node = m_graph_edges[pred].target; + } + // and add it to the max-flow + m_flow += bottleneck; + } + + /** + * returns the bottleneck of a s->t path (end_of_path is last vertex in + * source-tree, begin_of_path is first vertex in sink-tree) + */ + int find_bottleneck(int e) + { + int minimum_cap = m_res_cap_map[e]; + int current_node = m_graph_edges[e].source; + // first go back in the source tree + while (current_node != m_source) { + int pred = get_edge_to_parent(current_node); + minimum_cap = std::min(minimum_cap, m_res_cap_map[pred]); + current_node = m_graph_edges[pred].source; + } + // then go forward in the sink-tree + current_node = m_graph_edges[e].target; + while (current_node != m_sink) { + int pred = get_edge_to_parent(current_node); + minimum_cap = std::min(minimum_cap, m_res_cap_map[pred]); + current_node = m_graph_edges[pred].target; + } + return minimum_cap; + } + + /** + * rebuild search trees + * empty the queue of orphans, and find new parents for them or just + * drop them from the search trees + */ + void adopt() + { + while (!m_orphans.empty() || !m_child_orphans.empty()) { + int current_node; + if (m_child_orphans.empty()) { + // get the next orphan from the main-queue and remove it + current_node = m_orphans.front(); + m_orphans.pop_front(); + } + else { + current_node = m_child_orphans.front(); + m_child_orphans.pop(); + } + if (m_tree_map[current_node] == Color::black) { + // we're in the source-tree + int min_distance = (std::numeric_limits::max)(); + int new_parent_edge; + for (const int ei : m_graph_out_edges[current_node]) { + const int in_edge = m_rev_edge_map[ei]; + assert(m_graph_edges[in_edge].target == current_node); // we should be the target of + // this edge + if (m_res_cap_map[in_edge] > 0) { + int other_node = m_graph_edges[in_edge].source; + if (m_tree_map[other_node] == Color::black && has_source_connect(other_node)) { + if (m_dist_map[other_node] < min_distance) { + min_distance = m_dist_map[other_node]; + new_parent_edge = in_edge; + } + } + } + } + if (min_distance != (std::numeric_limits::max)()) { + set_edge_to_parent(current_node, new_parent_edge); + m_dist_map[current_node] = min_distance + 1; + m_time_map[current_node] = m_time; + } + else { + m_time_map[current_node] = 0; + for (const int ei : m_graph_out_edges[current_node]) { + int in_edge = m_rev_edge_map[ei]; + int other_node = m_graph_edges[in_edge].source; + if (m_tree_map[other_node] == Color::black && other_node != m_source) { + if (m_res_cap_map[in_edge] > 0) { + add_active_node(other_node); + } + if (has_parent(other_node) && + m_graph_edges[get_edge_to_parent(other_node)].source == current_node) + { + // we are the parent of that node + // it has to find a new parent, too + set_no_parent(other_node); + m_child_orphans.push(other_node); + } + } + } + m_tree_map[current_node] = Color::gray; + } // no parent found + } // source-tree-adoption + else { + // now we should be in the sink-tree, check that... + assert(m_tree_map[current_node] == Color::white); + int new_parent_edge; + int min_distance = (std::numeric_limits::max)(); + for (const int ei : m_graph_out_edges[current_node]) { + const int out_edge = ei; + if (m_res_cap_map[out_edge] > 0) { + const int other_node = m_graph_edges[out_edge].target; + if (m_tree_map[other_node] == Color::white && has_sink_connect(other_node)) { + if (m_dist_map[other_node] < min_distance) { + min_distance = m_dist_map[other_node]; + new_parent_edge = out_edge; + } + } + } + } + if (min_distance != (std::numeric_limits::max)()) { + set_edge_to_parent(current_node, new_parent_edge); + m_dist_map[current_node] = min_distance + 1; + m_time_map[current_node] = m_time; + } + else { + m_time_map[current_node] = 0; + for (const int ei : m_graph_out_edges[current_node]) { + const int out_edge = ei; + const int other_node = m_graph_edges[out_edge].target; + if (m_tree_map[other_node] == Color::white && other_node != m_sink) { + if (m_res_cap_map[out_edge] > 0) { + add_active_node(other_node); + } + if (has_parent(other_node) && + m_graph_edges[get_edge_to_parent(other_node)].target == current_node) + { + // we were it's parent, so it has to find a + // new one, too + set_no_parent(other_node); + m_child_orphans.push(other_node); + } + } + } + m_tree_map[current_node] = Color::gray; + } // no parent found + } // sink-tree adoption + } // while !orphans.empty() + } // adopt + + /** + * return next active vertex if there is one, otherwise a null_vertex + */ + int get_next_active_node() + { + while (true) { + if (m_active_nodes.empty()) { + return NULL_VERTEX; + } + int v = m_active_nodes.front(); + + // if it has no parent, this node can't be active (if its not + // source or sink) + if (!has_parent(v) && v != m_source && v != m_sink) { + m_active_nodes.pop(); + m_in_active_list_map[v] = false; + } + else { + assert(m_tree_map[v] == Color::black || m_tree_map[v] == Color::white); + return v; + } + } + } + + /** + * adds v as an active vertex, but only if its not in the list already + */ + void add_active_node(int v) + { + assert(m_tree_map[v] != Color::gray); + if (m_in_active_list_map[v]) { + if (m_last_grow_vertex == v) { + m_last_grow_vertex = NULL_VERTEX; + } + return; + } + + m_in_active_list_map[v] = true; + m_active_nodes.push(v); + } + + /** + * finish_node removes a node from the front of the active queue (its + * called in grow phase, if no more paths can be found using this node) + */ + void finish_node(int v) + { + assert(m_active_nodes.front() == v); + m_active_nodes.pop(); + m_in_active_list_map[v] = false; + m_last_grow_vertex = NULL_VERTEX; + } + + /** + * returns edge to parent vertex of v; + */ + int get_edge_to_parent(int v) const + { + return m_pre_map[v]; + } + + /** + * returns true if the edge stored in m_pre_map[v] is a valid entry + */ + bool has_parent(int v) const + { + return m_has_parent_map[v]; + } + + /** + * sets edge to parent vertex of v; + */ + void set_edge_to_parent(int v, int f_edge_to_parent) + { + assert(m_res_cap_map[f_edge_to_parent] > 0); + m_pre_map[v] = f_edge_to_parent; + m_has_parent_map[v] = true; + } + + /** + * removes the edge to parent of v (this is done by invalidating the + * entry an additional map) + */ + void set_no_parent(int v) + { + m_has_parent_map[v] = false; + } + + /** + * checks if vertex v has a connect to the sink-vertex (@var m_sink) + * @param v the vertex which is checked + * @return true if a path to the sink was found, false if not + */ + bool has_sink_connect(int v) + { + int current_distance = 0; + int current_vertex = v; + while (true) { + if (m_time_map[current_vertex] == m_time) { + // we found a node which was already checked this round. use + // it for distance calculations + current_distance += m_dist_map[current_vertex]; + break; + } + if (current_vertex == m_sink) { + m_time_map[m_sink] = m_time; + break; + } + if (has_parent(current_vertex)) { + // it has a parent, so get it + current_vertex = m_graph_edges[get_edge_to_parent(current_vertex)].target; + ++current_distance; + } + else { + // no path found + return false; + } + } + current_vertex = v; + while (m_time_map[current_vertex] != m_time) { + m_dist_map[current_vertex] = current_distance; + --current_distance; + m_time_map[current_vertex] = m_time; + current_vertex = m_graph_edges[get_edge_to_parent(current_vertex)].target; + } + return true; + } + + /** + * checks if vertex v has a connect to the source-vertex (@var m_source) + * @param v the vertex which is checked + * @return true if a path to the source was found, false if not + */ + bool has_source_connect(int v) + { + int current_distance = 0; + int current_vertex = v; + while (true) { + if (m_time_map[current_vertex] == m_time) { + // we found a node which was already checked this round. use + // it for distance calculations + current_distance += m_dist_map[current_vertex]; + break; + } + if (current_vertex == m_source) { + m_time_map[m_source] = m_time; + break; + } + if (has_parent(current_vertex)) { + // it has a parent, so get it + current_vertex = m_graph_edges[get_edge_to_parent(current_vertex)].source; + ++current_distance; + } + else { + // no path found + return false; + } + } + current_vertex = v; + while (m_time_map[current_vertex] != m_time) { + m_dist_map[current_vertex] = current_distance; + --current_distance; + m_time_map[current_vertex] = m_time; + current_vertex = m_graph_edges[get_edge_to_parent(current_vertex)].source; + } + return true; + } + + /** + * returns true, if p is closer to a terminal than q + */ + bool is_closer_to_terminal(int p, int q) + { + // checks the timestamps first, to build no cycles, and after that + // the real distance + return (m_time_map[q] <= m_time_map[p] && m_dist_map[q] > m_dist_map[p] + 1); + } + + // Member variables + std::vector m_graph_edges; + std::vector> m_graph_out_edges; + + std::vector m_cap_map; + std::vector m_res_cap_map; + std::vector m_rev_edge_map; + std::vector m_pre_map; // stores paths found in the growth stage + std::vector m_tree_map; // maps each vertex into white, black or gray + std::vector m_dist_map; // stores distance to source/sink nodes + + int m_source; + int m_sink; + + std::queue m_active_nodes; + std::vector m_in_active_list_map; + + std::list m_orphans; + std::queue m_child_orphans; // we use a second queuqe for child orphans, as + // they are FIFO processed + std::vector m_has_parent_map; + + std::vector m_time_map; // timestamp of each node, used for + // sink/source-path calculations + int m_flow = 0; + int m_time = 1; + + int m_last_grow_vertex = NULL_VERTEX; + int m_last_grow_out_edge = 0; +}; + +} // namespace qflow diff --git a/extern/quadriflow/src/config.hpp b/extern/quadriflow/src/config.hpp index bf597ad0f397..842b885a2091 100644 --- a/extern/quadriflow/src/config.hpp +++ b/extern/quadriflow/src/config.hpp @@ -1,11 +1,6 @@ #ifndef CONFIG_H_ #define CONFIG_H_ -/* Workaround a bug in boost 1.68, until we upgrade to a newer version. */ -#if defined(__clang__) && defined(WIN32) - #include - using namespace boost; -#endif // Move settings to cmake to make CMake happy :) // #define WITH_SCALE diff --git a/extern/quadriflow/src/flow.hpp b/extern/quadriflow/src/flow.hpp index ab4a01cb4ed1..a77f7ae66393 100644 --- a/extern/quadriflow/src/flow.hpp +++ b/extern/quadriflow/src/flow.hpp @@ -7,17 +7,12 @@ #include #include "config.hpp" - -#include -#include -#include -#include +#include "../patches/boykov_kolmogorov_max_flow.hpp" #include #include #include -using namespace boost; using namespace Eigen; namespace qflow { @@ -34,78 +29,52 @@ class MaxFlowHelper { class BoykovMaxFlowHelper : public MaxFlowHelper { public: - typedef int EdgeWeightType; - typedef adjacency_list_traits Traits; - // clang-format off - typedef adjacency_list < vecS, vecS, directedS, - property < vertex_name_t, std::string, - property < vertex_index_t, long, - property < vertex_color_t, boost::default_color_type, - property < vertex_distance_t, long, - property < vertex_predecessor_t, Traits::edge_descriptor > > > > >, - - property < edge_capacity_t, EdgeWeightType, - property < edge_residual_capacity_t, EdgeWeightType, - property < edge_reverse_t, Traits::edge_descriptor > > > > Graph; - // clang-format on - - public: - BoykovMaxFlowHelper() { rev = get(edge_reverse, g); } - void resize(int n, int m) { - vertex_descriptors.resize(n); - for (int i = 0; i < n; ++i) vertex_descriptors[i] = add_vertex(g); - } - int compute() { - EdgeWeightType flow = - boykov_kolmogorov_max_flow(g, vertex_descriptors.front(), vertex_descriptors.back()); - return flow; + BoykovMaxFlowHelper() = default; + void resize(int n, int m) override { + num_verts = n; + num_edges = 0; + flow.resize(num_verts, m * 2); } - void addDirectEdge(Traits::vertex_descriptor& v1, Traits::vertex_descriptor& v2, - property_map::type& rev, const int capacity, - const int inv_capacity, Graph& g, Traits::edge_descriptor& e1, - Traits::edge_descriptor& e2) { - e1 = add_edge(v1, v2, g).first; - e2 = add_edge(v2, v1, g).first; - put(edge_capacity, g, e1, capacity); - put(edge_capacity, g, e2, inv_capacity); - - rev[e1] = e2; - rev[e2] = e1; + int compute() override { + return flow.max_flow(0, num_verts - 1); } - void addEdge(int x, int y, int c, int rc, int v, int cost = 1) { - Traits::edge_descriptor e1, e2; - addDirectEdge(vertex_descriptors[x], vertex_descriptors[y], rev, c, rc, g, e1, e2); + void addEdge(int x, int y, int c, int rc, int v, int cost = 1) override { + const int e1 = num_edges++; + const int e2 = num_edges++; + flow.set_edge(e1, e2, x, y, c); + flow.set_edge(e2, e1, y, x, rc); if (v != -1) { - edge_to_variables[e1] = std::make_pair(v, -1); - edge_to_variables[e2] = std::make_pair(v, 1); + edge_to_variables.emplace_back(v, -1); + edge_to_variables.emplace_back(v, 1); + } + else { + edge_to_variables.emplace_back(-1, -1); + edge_to_variables.emplace_back(-1, -1); } } - void applyTo(std::vector& edge_diff) { - property_map::type capacity = get(edge_capacity, g); - property_map::type residual_capacity = - get(edge_residual_capacity, g); - - graph_traits::vertex_iterator u_iter, u_end; - graph_traits::out_edge_iterator ei, e_end; - for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) - for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) - if (capacity[*ei] > 0) { - int flow = (capacity[*ei] - residual_capacity[*ei]); + void applyTo(std::vector& edge_diff) override { + for (int vert = 0; vert < num_verts; vert++) { + for (int edge : flow.vertex_out_edges(vert)) { + const int capacity = flow.edge_capacity(edge); + const int residual_capacity = flow.edge_residual_capacity(edge); + if (capacity > 0) { + int flow = (capacity - residual_capacity); if (flow > 0) { - auto it = edge_to_variables.find(*ei); - if (it != edge_to_variables.end()) { - edge_diff[it->second.first / 2][it->second.first % 2] += - it->second.second * flow; + std::pair e2v = edge_to_variables[edge]; + if (e2v.first != -1) { + edge_diff[e2v.first / 2][e2v.first % 2] += e2v.second * flow; } } } + } + } } private: - Graph g; - property_map::type rev; - std::vector vertex_descriptors; - std::map> edge_to_variables; + BoykovKolmogorovMaxFlow flow; + std::vector> edge_to_variables; + int num_verts = 0; + int num_edges = 0; }; class NetworkSimplexFlowHelper : public MaxFlowHelper { diff --git a/extern/quadriflow/src/main.cpp b/extern/quadriflow/src/main.cpp index 18bc4063c428..63c9e61b8c93 100644 --- a/extern/quadriflow/src/main.cpp +++ b/extern/quadriflow/src/main.cpp @@ -110,7 +110,10 @@ int main(int argc, char** argv) { printf("Use %lf seconds\n", (t2 - t1) * 1e-3); t1 = GetCurrentTime64(); printf("Solve index map...\n"); - field.ComputeIndexMap(); + if (!field.ComputeIndexMap()) { + fprintf(stderr, "Failed to solve result, exiting!\n"); + return 1; + } t2 = GetCurrentTime64(); printf("Indexmap Use %lf seconds\n", (t2 - t1) * 1e-3); printf("Writing the file...\n"); diff --git a/extern/quadriflow/src/parametrizer.cpp b/extern/quadriflow/src/parametrizer.cpp index b85383566c9c..3dbdc386eca5 100644 --- a/extern/quadriflow/src/parametrizer.cpp +++ b/extern/quadriflow/src/parametrizer.cpp @@ -18,7 +18,7 @@ namespace qflow { -void Parametrizer::ComputeIndexMap(int with_scale) { +bool Parametrizer::ComputeIndexMap(int with_scale) { // build edge info auto& V = hierarchy.mV[0]; auto& F = hierarchy.mF; @@ -80,9 +80,12 @@ void Parametrizer::ComputeIndexMap(int with_scale) { #ifdef LOG_OUTPUT printf("subdivide...\n"); #endif - subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, - edge_diff, edge_values, face_edgeOrients, face_edgeIds, sharp_edges, - singularities, 1); + if (!subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, + edge_diff, edge_values, face_edgeOrients, face_edgeIds, sharp_edges, + singularities, 1)) + { + return false; + } allow_changes.clear(); allow_changes.resize(edge_diff.size() * 2, 1); @@ -99,9 +102,12 @@ void Parametrizer::ComputeIndexMap(int with_scale) { int t1 = GetCurrentTime64(); #endif FixFlipHierarchy(); - subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, + if (!subdivide_edgeDiff(F, V, N, Q, O, &hierarchy.mS[0], V2E, hierarchy.mE2E, boundary, nonManifold, edge_diff, edge_values, face_edgeOrients, face_edgeIds, sharp_edges, - singularities, 1); + singularities, 1)) + { + return false; + } FixFlipSat(); #ifdef LOG_OUTPUT @@ -242,6 +248,7 @@ void Parametrizer::ComputeIndexMap(int with_scale) { // E2E_compact, // V, N, Q, O, F, V2E, hierarchy.mE2E, disajoint_tree, // hierarchy.mScale, false); + return true; } } // namespace qflow diff --git a/extern/quadriflow/src/parametrizer.hpp b/extern/quadriflow/src/parametrizer.hpp index 1f4a02be6c26..9703ebbfff69 100644 --- a/extern/quadriflow/src/parametrizer.hpp +++ b/extern/quadriflow/src/parametrizer.hpp @@ -54,7 +54,8 @@ class Parametrizer { void ComputePositionSingularities(); // Integer Grid Map Pipeline - void ComputeIndexMap(int with_scale = 0); + // Return false when the solver fails. + bool ComputeIndexMap(int with_scale = 0); void BuildEdgeInfo(); void ComputeMaxFlow(); void MarkInteger(); diff --git a/extern/quadriflow/src/post-solver.cpp b/extern/quadriflow/src/post-solver.cpp index 6027ddd2eb7d..ccefd1557d8b 100644 --- a/extern/quadriflow/src/post-solver.cpp +++ b/extern/quadriflow/src/post-solver.cpp @@ -5,7 +5,9 @@ // Created by Jingwei on 2/5/18. // #include +#ifdef POST_SOLVER #include +#endif #include #include #include diff --git a/extern/quadriflow/src/subdivide.cpp b/extern/quadriflow/src/subdivide.cpp index c408bbc6394b..babff96ccb4a 100644 --- a/extern/quadriflow/src/subdivide.cpp +++ b/extern/quadriflow/src/subdivide.cpp @@ -145,7 +145,7 @@ void subdivide(MatrixXi &F, MatrixXd &V, VectorXd& rho, VectorXi &V2E, VectorXi E2E.conservativeResize(nF * 3); } -void subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, +bool subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, VectorXi &V2E, VectorXi &E2E, VectorXi &boundary, VectorXi &nonmanifold, std::vector &edge_diff, std::vector &edge_values, std::vector &face_edgeOrients, std::vector &face_edgeIds, @@ -500,17 +500,18 @@ void subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, Matr for (int j = 0; j < 3; ++j) { auto diff = edge_diff[face_edgeIds[i][j]]; if (abs(diff[0]) > 1 || abs(diff[1]) > 1) { - printf("wrong init %d %d!\n", face_edgeIds[i][j], i * 3 + j); - exit(0); + fprintf(stderr, "wrong init %d %d!\n", face_edgeIds[i][j], i * 3 + j); + return false; } } } for (int i = 0; i < edge_diff.size(); ++i) { if (abs(edge_diff[i][0]) > 1 || abs(edge_diff[i][1]) > 1) { - printf("wrong...\n"); - exit(0); + fprintf(stderr, "wrong...\n"); + return false; } } + return true; } } // namespace qflow diff --git a/extern/quadriflow/src/subdivide.hpp b/extern/quadriflow/src/subdivide.hpp index a93c58ac2a72..8c682b6d9f2c 100644 --- a/extern/quadriflow/src/subdivide.hpp +++ b/extern/quadriflow/src/subdivide.hpp @@ -9,7 +9,8 @@ namespace qflow { void subdivide(MatrixXi &F, MatrixXd &V, VectorXd& rho, VectorXi &V2E, VectorXi &E2E, VectorXi &boundary, VectorXi &nonmanifold, double maxLength); -void subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, +// Return false when solving fails. +bool subdivide_edgeDiff(MatrixXi &F, MatrixXd &V, MatrixXd &N, MatrixXd &Q, MatrixXd &O, MatrixXd* S, VectorXi &V2E, VectorXi &E2E, VectorXi &boundary, VectorXi &nonmanifold, std::vector &edge_diff, std::vector &edge_values, std::vector &face_edgeOrients, std::vector &face_edgeIds, diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt index b7e99dfdbf71..93268d2a23e7 100644 --- a/intern/CMakeLists.txt +++ b/intern/CMakeLists.txt @@ -47,10 +47,6 @@ if(WITH_CYCLES) add_subdirectory(cycles) endif() -if(WITH_INTERNATIONAL) - add_subdirectory(locale) -endif() - if(WITH_BULLET) add_subdirectory(rigidbody) endif() diff --git a/intern/cycles/cmake/macros.cmake b/intern/cycles/cmake/macros.cmake index 1bb7283c723a..348ae3b3709a 100644 --- a/intern/cycles/cmake/macros.cmake +++ b/intern/cycles/cmake/macros.cmake @@ -146,7 +146,6 @@ macro(cycles_external_libraries_append libraries) ${OPENEXR_LIBRARIES} ${OPENEXR_LIBRARIES} # For circular dependencies between libs. ${PUGIXML_LIBRARIES} - ${BOOST_LIBRARIES} ${PYTHON_LIBRARIES} ${ZLIB_LIBRARIES} ${CMAKE_DL_LIBS} diff --git a/intern/cycles/integrator/path_trace.cpp b/intern/cycles/integrator/path_trace.cpp index 6ea925f371ef..e924220f83a3 100644 --- a/intern/cycles/integrator/path_trace.cpp +++ b/intern/cycles/integrator/path_trace.cpp @@ -1047,7 +1047,7 @@ void PathTrace::process_full_buffer_from_disk(string_view filename) render_state_.has_denoised_result = false; - if (denoise_params.use && denoiser_) { + if (denoise_params.use && denoiser_ && !progress_->get_cancel()) { progress_set_status(layer_view_name, "Denoising"); /* If GPU should be used is not based on file metadata. */ diff --git a/intern/cycles/kernel/light/background.h b/intern/cycles/kernel/light/background.h index e3bec5011bc8..559a8e8348fc 100644 --- a/intern/cycles/kernel/light/background.h +++ b/intern/cycles/kernel/light/background.h @@ -477,10 +477,15 @@ ccl_device_forceinline bool background_light_tree_parameters(const float3 centro { if (in_volume_segment) { if (t == FLT_MAX) { - /* In world volume, distant light has no contribution. */ - return false; + /* In world volumes, distant lights can contribute to the lighting of the volume with + * specific configurations of procedurally generated volumes. Use a ray length of 1.0 in this + * case to give the distant light some weight, but one that isn't too high for a typical + * world volume use case. */ + theta_d = 1.0f; + } + else { + theta_d = t; } - theta_d = t; } /* Cover the whole sphere */ diff --git a/intern/cycles/kernel/light/distant.h b/intern/cycles/kernel/light/distant.h index 6fe16cff5425..61e08946b364 100644 --- a/intern/cycles/kernel/light/distant.h +++ b/intern/cycles/kernel/light/distant.h @@ -142,10 +142,15 @@ ccl_device_forceinline bool distant_light_tree_parameters(const float3 centroid, { if (in_volume_segment) { if (t == FLT_MAX) { - /* In world volume, distant light has no contribution. */ - return false; + /* In world volumes, distant lights can contribute to the lighting of the volume with + * specific configurations of procedurally generated volumes. Use a ray length of 1.0 in this + * case to give the distant light some weight, but one that isn't too high for a typical + * world volume use case. */ + theta_d = 1.0f; + } + else { + theta_d = t; } - theta_d = t; } /* Treating it as a disk light 1 unit away */ diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index 274438e1e38d..54b2113d77f6 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -322,10 +322,15 @@ ccl_device void light_tree_node_importance(KernelGlobals kg, cos_theta_u = fast_cosf(bcone.theta_o + bcone.theta_e); distance = 1.0f; /* For distant lights, the integral in Eq. (4) gives the ray length. */ - theta_d = t; if (t == FLT_MAX) { - /* In world volume, distant light has no contribution. */ - return; + /* In world volumes, distant lights can contribute to the lighting of the volume with + * specific configurations of procedurally generated volumes. Use a ray length of 1.0 in this + * case to give the distant light some weight, but one that isn't too high for a typical + * world volume use case. */ + theta_d = 1.0f; + } + else { + theta_d = t; } } else { diff --git a/intern/cycles/kernel/osl/types.h b/intern/cycles/kernel/osl/types.h index d81833a55825..e25900701ec2 100644 --- a/intern/cycles/kernel/osl/types.h +++ b/intern/cycles/kernel/osl/types.h @@ -17,7 +17,11 @@ CCL_NAMESPACE_BEGIN /* Strings are represented by their hashes on the GPU. */ using DeviceString = size_t; #elif defined(OPENIMAGEIO_USTRING_H) +# if OSL_LIBRARY_VERSION_CODE >= 11400 +using DeviceString = ustringhash; +# else using DeviceString = ustring; +# endif #else using DeviceString = const char *; #endif diff --git a/intern/dualcon/dualcon.h b/intern/dualcon/dualcon.h index f442fc7e6476..53d7a7b313cc 100644 --- a/intern/dualcon/dualcon.h +++ b/intern/dualcon/dualcon.h @@ -15,10 +15,10 @@ typedef float (*DualConCo)[3]; typedef unsigned int (*DualConTri)[3]; -typedef unsigned int *DualConLoop; +typedef unsigned int *DualConCornerVerts; typedef struct DualConInput { - DualConLoop mloop; + DualConCornerVerts corner_verts; DualConCo co; int co_stride; @@ -28,7 +28,7 @@ typedef struct DualConInput { int tri_stride; int tottri; - int loop_stride; + int corner_verts_stride; float min[3], max[3]; } DualConInput; diff --git a/intern/dualcon/intern/dualcon_c_api.cpp b/intern/dualcon/intern/dualcon_c_api.cpp index 29c141809807..10399247bea8 100644 --- a/intern/dualcon/intern/dualcon_c_api.cpp +++ b/intern/dualcon/intern/dualcon_c_api.cpp @@ -26,8 +26,8 @@ static void veccopy(float dst[3], const float src[3]) #define GET_CO(_mesh, _n) (*(DualConCo)(((char *)(_mesh)->co) + ((_n) * (_mesh)->co_stride))) -#define GET_LOOP(_mesh, _n) \ - (*(DualConLoop)(((char *)(_mesh)->mloop) + ((_n) * (_mesh)->loop_stride))) +#define GET_CORNER_VERT(_mesh, _n) \ + (*(DualConCornerVerts)(((char *)(_mesh)->corner_verts) + ((_n) * (_mesh)->corner_verts_stride))) class DualConInputReader : public ModelReader { private: @@ -80,9 +80,9 @@ class DualConInputReader : public ModelReader { Triangle *t = new Triangle(); const unsigned int *tr = GET_TRI(input_mesh, curtri); - veccopy(t->vt[0], GET_CO(input_mesh, GET_LOOP(input_mesh, tr[0]))); - veccopy(t->vt[1], GET_CO(input_mesh, GET_LOOP(input_mesh, tr[1]))); - veccopy(t->vt[2], GET_CO(input_mesh, GET_LOOP(input_mesh, tr[2]))); + veccopy(t->vt[0], GET_CO(input_mesh, GET_CORNER_VERT(input_mesh, tr[0]))); + veccopy(t->vt[1], GET_CO(input_mesh, GET_CORNER_VERT(input_mesh, tr[1]))); + veccopy(t->vt[2], GET_CO(input_mesh, GET_CORNER_VERT(input_mesh, tr[2]))); curtri++; diff --git a/intern/locale/CMakeLists.txt b/intern/locale/CMakeLists.txt deleted file mode 100644 index 06587b362187..000000000000 --- a/intern/locale/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -# SPDX-FileCopyrightText: 2012 Blender Authors -# -# SPDX-License-Identifier: GPL-2.0-or-later - -set(INC - . -) - -set(INC_SYS -) - -set(SRC - boost_locale_wrapper.cpp - - boost_locale_wrapper.h -) - -set(LIB -) - -if(WIN32) - # This is set in platform_win32.cmake, will exist for 3.4+ library - # folders which are dynamic, but not for 3.3 which will be static. - if(EXISTS ${BOOST_34_TRIGGER_FILE}) - add_definitions(-DBOOST_ALL_DYN_LINK=1) - endif() -endif() - -if(APPLE) - # Cocoa code to read the locale on OSX - list(APPEND SRC - osx_user_locale.mm - ) -endif() - -if(WITH_HEADLESS) - add_definitions(-DWITH_HEADLESS) -endif() - -if(WITH_GHOST_SDL) - add_definitions(-DWITH_GHOST_SDL) -endif() - -if(WITH_INTERNATIONAL) - list(APPEND INC_SYS - ${BOOST_INCLUDE_DIR} - ) - list(APPEND LIB - ${BOOST_LIBRARIES} - ) - add_definitions(${BOOST_DEFINITIONS}) -endif() - -blender_add_lib(bf_intern_locale "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/intern/locale/boost_locale_wrapper.cpp b/intern/locale/boost_locale_wrapper.cpp deleted file mode 100644 index 97bef248aac4..000000000000 --- a/intern/locale/boost_locale_wrapper.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* SPDX-FileCopyrightText: 2012 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup intern_locale - */ - -#include -#include -#include - -#include "boost_locale_wrapper.h" - -static std::string messages_path; -static std::string default_domain; -static std::string locale_str; - -/* NOTE: We cannot use short stuff like `boost::locale::gettext`, because those return - * `std::basic_string` objects, which c_ptr()-returned char* is no more valid - * once deleted (which happens as soons they are out of scope of this func). */ -typedef boost::locale::message_format char_message_facet; -static std::locale locale_global; -static char_message_facet const *facet_global = NULL; - -static void bl_locale_global_cache() -{ - /* Cache facet in global variable. Not only is it better for performance, - * it also fixes crashes on macOS when doing translation from threads other - * than main. Likely because of some internal thread local variables. */ - try { - /* facet_global reference is valid as long as local_global exists, - * so we store both. */ - locale_global = std::locale(); - facet_global = &std::use_facet(locale_global); - } - /* `if std::has_facet(l) == false`, LC_ALL = "C" case. */ - catch (const std::bad_cast &e) { -#ifndef NDEBUG - std::cout << "bl_locale_global_cache:" << e.what() << " \n"; -#endif - (void)e; - facet_global = NULL; - } - catch (const std::exception &e) { -#ifndef NDEBUG - std::cout << "bl_locale_global_cache:" << e.what() << " \n"; -#endif - (void)e; - facet_global = NULL; - } -} - -void bl_locale_init(const char *_messages_path, const char *_default_domain) -{ - /* Avoid using ICU backend, we do not need its power and it's rather heavy! */ - boost::locale::localization_backend_manager lman = - boost::locale::localization_backend_manager::global(); -#if defined(_WIN32) - lman.select("winapi"); -#else - lman.select("posix"); -#endif - boost::locale::localization_backend_manager::global(lman); - - messages_path = _messages_path; - default_domain = _default_domain; -} - -void bl_locale_set(const char *locale) -{ - boost::locale::generator gen; - std::locale _locale; - /* Specify location of dictionaries. */ - gen.add_messages_path(messages_path); - gen.add_messages_domain(default_domain); - // gen.set_default_messages_domain(default_domain); - - try { - if (locale && locale[0]) { - _locale = gen(locale); - } - else { -#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) - std::string locale_osx = osx_user_locale() + std::string(".UTF-8"); - _locale = gen(locale_osx.c_str()); -#else - _locale = gen(""); -#endif - } - std::locale::global(_locale); - /* NOTE: boost always uses "C" LC_NUMERIC by default! */ - - bl_locale_global_cache(); - - /* Generate the locale string - * (useful to know which locale we are actually using in case of "default" one). */ -#define LOCALE_INFO std::use_facet(_locale) - - locale_str = LOCALE_INFO.language(); - if (LOCALE_INFO.country() != "") { - locale_str += "_" + LOCALE_INFO.country(); - } - if (LOCALE_INFO.variant() != "") { - locale_str += "@" + LOCALE_INFO.variant(); - } - -#undef LOCALE_INFO - } - /* Extra catch on `std::runtime_error` is needed for macOS/Clang as it seems that exceptions - * like `boost::locale::conv::conversion_error` (which inherit from `std::runtime_error`) are - * not caught by their ancestor `std::exception`. See #88877#1177108 */ - catch (std::runtime_error const &e) { - std::cout << "bl_locale_set(" << locale << "): " << e.what() << " \n"; - } - catch (std::exception const &e) { - std::cout << "bl_locale_set(" << locale << "): " << e.what() << " \n"; - } -} - -const char *bl_locale_get(void) -{ - return locale_str.c_str(); -} - -const char *bl_locale_pgettext(const char *msgctxt, const char *msgid) -{ - if (facet_global) { - char const *r = facet_global->get(0, msgctxt, msgid); - if (r) { - return r; - } - } - - return msgid; -} diff --git a/intern/locale/boost_locale_wrapper.h b/intern/locale/boost_locale_wrapper.h deleted file mode 100644 index 162f1eca9689..000000000000 --- a/intern/locale/boost_locale_wrapper.h +++ /dev/null @@ -1,30 +0,0 @@ -/* SPDX-FileCopyrightText: 2012 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup intern_locale - * A thin C wrapper around `boost::locale`. - */ - -#ifndef __BOOST_LOCALE_WRAPPER_H__ -#define __BOOST_LOCALE_WRAPPER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -void bl_locale_init(const char *messages_path, const char *default_domain); -void bl_locale_set(const char *locale); -const char *bl_locale_get(void); -const char *bl_locale_pgettext(const char *msgctxt, const char *msgid); - -#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) -const char *osx_user_locale(void); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __BOOST_LOCALE_WRAPPER_H__ */ diff --git a/intern/opencolorio/CMakeLists.txt b/intern/opencolorio/CMakeLists.txt index 10d2cefe8001..d3eada1ddc1c 100644 --- a/intern/opencolorio/CMakeLists.txt +++ b/intern/opencolorio/CMakeLists.txt @@ -48,15 +48,6 @@ if(WITH_OPENCOLORIO) ${OPENCOLORIO_LIBRARIES} ) - if(WIN32) - list(APPEND INC_SYS - ${BOOST_INCLUDE_DIR} - ) - list(APPEND LIB - ${BOOST_LIBRARIES} - ) - endif() - set(GLSL_SRC gpu_shader_display_transform_vert.glsl gpu_shader_display_transform_frag.glsl diff --git a/intern/quadriflow/CMakeLists.txt b/intern/quadriflow/CMakeLists.txt index b253d1feb0e3..5aef735fc7ea 100644 --- a/intern/quadriflow/CMakeLists.txt +++ b/intern/quadriflow/CMakeLists.txt @@ -8,7 +8,6 @@ set(INC set(INC_SYS ../../extern/quadriflow/src - ${BOOST_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIRS} ) @@ -20,7 +19,6 @@ set(SRC set(LIB PRIVATE bf::intern::guardedalloc extern_quadriflow - ${BOOST_LIBRARIES} ) if(WIN32) diff --git a/intern/quadriflow/quadriflow_capi.cpp b/intern/quadriflow/quadriflow_capi.cpp index fad604f679a0..014ac2a56130 100644 --- a/intern/quadriflow/quadriflow_capi.cpp +++ b/intern/quadriflow/quadriflow_capi.cpp @@ -190,8 +190,11 @@ void QFLOW_quadriflow_remesh(QuadriflowRemeshData *qrd, return; } - /* Compute the final quad geomtry using a maxflow solver */ - field.ComputeIndexMap(); + /* Compute the final quad geometry using a maxflow solver */ + if (!field.ComputeIndexMap()) { + /* Error computing the result. */ + return; + } if (check_if_canceled(0.9f, update_cb, update_cb_data)) { return; diff --git a/scripts/addons_core/io_scene_gltf2/__init__.py b/scripts/addons_core/io_scene_gltf2/__init__.py index 6b63dbae85de..4b168ad08751 100755 --- a/scripts/addons_core/io_scene_gltf2/__init__.py +++ b/scripts/addons_core/io_scene_gltf2/__init__.py @@ -5,7 +5,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', - "version": (4, 4, 34), + "version": (4, 4, 35), 'blender': (4, 4, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', @@ -1099,6 +1099,15 @@ def execute(self, context): # All custom export settings are stored in this container. export_settings = {} + # Collection Export does not handle correctly props declaration for now + # So use this tweak to manage it, waiting for a better solution + is_file_browser = context.space_data and context.space_data.type == 'FILE_BROWSER' + if not is_file_browser: + if not hasattr(context.scene, "gltf_action_filter") and self.export_action_filter: + bpy.types.Scene.gltf_action_filter = bpy.props.CollectionProperty(type=GLTF2_filter_action) + bpy.types.Scene.gltf_action_filter_active = bpy.props.IntProperty() + + # Get log level from parameters # If not set, get it from Blender app debug value export_settings['gltf_loglevel'] = self.export_loglevel diff --git a/scripts/addons_core/io_scene_gltf2/blender/com/gltf2_blender_ui.py b/scripts/addons_core/io_scene_gltf2/blender/com/gltf2_blender_ui.py index df81e064302f..7598cbe84b43 100644 --- a/scripts/addons_core/io_scene_gltf2/blender/com/gltf2_blender_ui.py +++ b/scripts/addons_core/io_scene_gltf2/blender/com/gltf2_blender_ui.py @@ -650,6 +650,13 @@ def export_panel_animation_action_filter(layout, operator): row = body.row() + # Collection Export does not handle correctly property declaration + # So use this tweak to avoid spaming the console, waiting for a better solution + is_file_browser = bpy.context.space_data.type == 'FILE_BROWSER' + if not is_file_browser and not hasattr(bpy.data.scenes[0], "gltf_action_filter"): + row.label(text="Please disable/enable 'action filter' to refresh the list") + return + if len(bpy.data.actions) > 0: row.template_list( "SCENE_UL_gltf2_filter_action", diff --git a/scripts/startup/bl_ui/properties_material_gpencil.py b/scripts/startup/bl_ui/properties_material_gpencil.py index 976823d6f232..ba0dcec463eb 100644 --- a/scripts/startup/bl_ui/properties_material_gpencil.py +++ b/scripts/startup/bl_ui/properties_material_gpencil.py @@ -46,8 +46,12 @@ class GPENCIL_UL_matslots(UIList): def draw_item(self, _context, layout, _data, item, icon, _active_data, _active_propname, _index): slot = item ma = slot.material - if (ma is not None) and (ma.grease_pencil is not None): - gpcolor = ma.grease_pencil + + if ma is None: + return + + if (gpcolor := ma.grease_pencil) is None: + return if self.layout_type in {'DEFAULT', 'COMPACT'}: row = layout.row(align=True) diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 72ef1840b71c..7f268db36ca7 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -38,7 +38,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 25 +#define BLENDER_FILE_SUBVERSION 26 /* UPBGE file format version. */ #define UPBGE_FILE_VERSION UPBGE_VERSION diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 3a509f7ac54a..aae04b5fb35c 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -7,12 +7,11 @@ * \ingroup bke */ +#include + #include "BKE_customdata.hh" // UPBGE #include "BLI_array.hh" -#include "BLI_compiler_attrs.h" -#include "BLI_compiler_compat.h" -#include "BLI_utildefines.h" #include "DNA_mesh_types.h" @@ -36,7 +35,7 @@ struct Object; struct Scene; /* TODO: Move to `BKE_mesh_types.hh` when possible. */ -enum eMeshBatchDirtyMode { +enum eMeshBatchDirtyMode : int8_t { BKE_MESH_BATCH_DIRTY_ALL = 0, BKE_MESH_BATCH_DIRTY_SELECT, BKE_MESH_BATCH_DIRTY_SELECT_PAINT, diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 5593f57aad19..6b0243151e7f 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -1155,7 +1155,6 @@ void node_tree_blend_read_data(BlendDataReader *reader, ID *owner_id, bNodeTree break; } case CMP_NODE_IMAGE: - case CMP_NODE_R_LAYERS: case CMP_NODE_VIEWER: { ImageUser *iuser = static_cast(node->storage); iuser->scene = nullptr; diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index 775bbbf377da..1dee556cfed9 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -5689,6 +5689,20 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) } } + if (!MAIN_VERSION_FILE_ATLEAST(bmain, 404, 26)) { + const Brush *default_brush = DNA_struct_default_get(Brush); + LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) { + if ((brush->mask_stencil_dimension[0] == 0) && (brush->mask_stencil_dimension[1] == 0)) { + brush->mask_stencil_dimension[0] = default_brush->mask_stencil_dimension[0]; + brush->mask_stencil_dimension[1] = default_brush->mask_stencil_dimension[1]; + } + if ((brush->mask_stencil_pos[0] == 0) && (brush->mask_stencil_pos[1] == 0)) { + brush->mask_stencil_pos[0] = default_brush->mask_stencil_pos[0]; + brush->mask_stencil_pos[1] = default_brush->mask_stencil_pos[1]; + } + } + } + /* Always run this versioning; meshes are written with the legacy format which always needs to * be converted to the new format on file load. Can be moved to a subversion check in a larger * breaking release. */ diff --git a/source/blender/blentranslation/CMakeLists.txt b/source/blender/blentranslation/CMakeLists.txt index 1fa3570bc27c..772c739b39d1 100644 --- a/source/blender/blentranslation/CMakeLists.txt +++ b/source/blender/blentranslation/CMakeLists.txt @@ -5,7 +5,6 @@ set(INC PUBLIC . ../makesrna - ../../../intern/locale ) set(INC_SYS @@ -19,19 +18,30 @@ set(SRC BLT_translation.hh ) +if(WITH_INTERNATIONAL) + list(APPEND SRC + intern/messages.cc + intern/messages.hh + ) + + if(APPLE) + list(APPEND SRC + intern/messages_apple.mm + ) + endif() +endif() + set(LIB PRIVATE bf::blenkernel PRIVATE bf::blenlib PRIVATE bf::dna PRIVATE bf::imbuf + PRIVATE bf::intern::clog PRIVATE bf::intern::guardedalloc ) if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) - list(APPEND LIB - bf_intern_locale - ) endif() if(WITH_PYTHON) diff --git a/source/blender/blentranslation/intern/blt_lang.cc b/source/blender/blentranslation/intern/blt_lang.cc index 3fe958b78c34..4bbd23975afb 100644 --- a/source/blender/blentranslation/intern/blt_lang.cc +++ b/source/blender/blentranslation/intern/blt_lang.cc @@ -11,6 +11,7 @@ #include #include #include +#include #ifndef _WIN32 # include @@ -27,18 +28,20 @@ #include "BKE_appdir.hh" -#include "IMB_thumbs.hh" - #include "DNA_userdef_types.h" #include "MEM_guardedalloc.h" +#include "CLG_log.h" + +static CLG_LogRef LOG = {"translation.language"}; + #ifdef WITH_INTERNATIONAL # include "BLI_fileops.h" # include "BLI_linklist.h" -# include "boost_locale_wrapper.h" +# include "messages.hh" /* Locale options. */ static const char **locales = nullptr; @@ -66,17 +69,19 @@ static void free_locales() static void fill_locales() { std::optional languages_path = BKE_appdir_folder_id(BLENDER_DATAFILES, "locale"); - char languages[FILE_MAX]; - LinkNode *lines = nullptr, *line = nullptr; - char *str; - int idx = 0; + if (!languages_path.has_value()) { + CLOG_WARN(&LOG, "'locale' data path for translations not found"); + return; + } free_locales(); - if (languages_path.has_value()) { - BLI_path_join(languages, FILE_MAX, languages_path->c_str(), "languages"); - line = lines = BLI_file_read_as_lines(languages); - } + char languages[FILE_MAX]; + BLI_path_join(languages, FILE_MAX, languages_path->c_str(), "languages"); + + LinkNode *lines = BLI_file_read_as_lines(languages); + LinkNode *line = lines; + int idx = 0; /* This whole "parsing" code is a bit weak, in that it expects strictly formatted input file... * Should not be a problem, though, as this file is script-generated! */ @@ -84,7 +89,7 @@ static void fill_locales() /* First loop to find highest locale ID */ while (line) { int t; - str = (char *)line->link; + char *str = (char *)line->link; if (ELEM(str[0], '#', '\0')) { line = line->next; continue; /* Comment or void... */ @@ -109,7 +114,7 @@ static void fill_locales() while (line) { const char *loc, *sep1, *sep2, *sep3; - str = (char *)line->link; + char *str = (char *)line->link; if (ELEM(str[0], '#', '\0')) { line = line->next; continue; @@ -181,10 +186,6 @@ const EnumPropertyItem *BLT_lang_RNA_enum_properties() void BLT_lang_init() { -#ifdef WITH_INTERNATIONAL - const std::optional messagepath = BKE_appdir_folder_id(BLENDER_DATAFILES, "locale"); -#endif - /* Make sure LANG is correct and wouldn't cause #std::runtime_error. */ #ifndef _WIN32 /* TODO(sergey): This code only ensures LANG is set properly, so later when @@ -205,7 +206,7 @@ void BLT_lang_init() old_locale = BLI_strdup(old_locale); if (setlocale(LC_ALL, lang) == nullptr) { setenv("LANG", "C", 1); - printf("Warning: Falling back to the standard locale (\"C\")\n"); + CLOG_WARN(&LOG, "Falling back to standard locale (\"C\")"); } setlocale(LC_ALL, old_locale); MEM_freeN(old_locale); @@ -213,22 +214,15 @@ void BLT_lang_init() #endif #ifdef WITH_INTERNATIONAL - if (messagepath.has_value()) { - bl_locale_init(messagepath->c_str(), TEXT_DOMAIN_NAME); - fill_locales(); - } - else { - printf("%s: 'locale' data path for translations not found, continuing\n", __func__); - } -#else + fill_locales(); #endif } void BLT_lang_free() { #ifdef WITH_INTERNATIONAL + blender::locale::free(); free_locales(); -#else #endif } @@ -252,27 +246,12 @@ void BLT_lang_set(const char *str) { #ifdef WITH_INTERNATIONAL int ulang = ULANGUAGE; - const char *short_locale = str ? str : LOCALE(ulang); - const char *short_locale_utf8 = nullptr; - - /* We want to avoid locales like '.UTF-8'! */ - if (short_locale[0]) { - /* Hooray! Encoding needs to be placed *before* variant! */ - const char *variant = strchr(short_locale, '@'); - if (variant) { - char *locale = BLI_strdupn(short_locale, variant - short_locale); - short_locale_utf8 = BLI_sprintfN("%s.UTF-8%s", locale, variant); - MEM_freeN(locale); - } - else { - short_locale_utf8 = BLI_sprintfN("%s.UTF-8", short_locale); - } - bl_locale_set(short_locale_utf8); - MEM_freeN((void *)short_locale_utf8); - } - else { - bl_locale_set(short_locale); - } + std::string locale_name = str ? str : LOCALE(ulang); + + /* blender::locale assumes UTF-8, no need to put it in the name. */ + const std::optional messagepath = BKE_appdir_folder_id(BLENDER_DATAFILES, "locale"); + blender::locale::init(locale_name, {TEXT_DOMAIN_NAME}, {messagepath.value_or("")}); + #else (void)str; #endif @@ -285,7 +264,7 @@ const char *BLT_lang_get() const char *locale = LOCALE(ULANGUAGE); if (locale[0] == '\0') { /* Default locale, we have to find which one we are actually using! */ - locale = bl_locale_get(); + locale = blender::locale::full_name(); } return locale; } diff --git a/source/blender/blentranslation/intern/blt_translation.cc b/source/blender/blentranslation/intern/blt_translation.cc index bfe76f7f03c7..f5f85caad79b 100644 --- a/source/blender/blentranslation/intern/blt_translation.cc +++ b/source/blender/blentranslation/intern/blt_translation.cc @@ -14,8 +14,6 @@ #include "BLT_translation.hh" -#include "MEM_guardedalloc.h" - #include "DNA_userdef_types.h" /* For user settings. */ #ifdef WITH_PYTHON @@ -24,7 +22,7 @@ #ifdef WITH_INTERNATIONAL # include "BLI_threads.h" -# include "boost_locale_wrapper.h" +# include "messages.hh" #endif /* WITH_INTERNATIONAL */ bool BLT_is_default_context(const char *msgctxt) @@ -45,15 +43,17 @@ const char *BLT_pgettext(const char *msgctxt, const char *msgid) if (BLT_is_default_context(msgctxt)) { msgctxt = BLT_I18NCONTEXT_DEFAULT; } - ret = bl_locale_pgettext(msgctxt, msgid); -/* We assume if the returned string is the same (memory level) as the msgid, - * no translation was found, and we can try py scripts' ones! - */ + + ret = blender::locale::translate(0, msgctxt, msgid); + + /* No translation found? Try py script translations. */ + if (ret == nullptr) { # ifdef WITH_PYTHON - if (ret == msgid) { ret = BPY_app_translations_py_pgettext(msgctxt, msgid); - } +# else + ret = msgid; # endif + } } return ret; diff --git a/source/blender/blentranslation/intern/messages.cc b/source/blender/blentranslation/intern/messages.cc new file mode 100644 index 000000000000..a0f00d631a2c --- /dev/null +++ b/source/blender/blentranslation/intern/messages.cc @@ -0,0 +1,596 @@ +/* SPDX-FileCopyrightText: 2009-2015 Artyom Beilis (Tonkikh) + * SPDX-FileCopyrightText: 2021-2023 Alexander Grund + * SPDX-FileCopyrightText: 2025 Blender Authors + * SPDX-License-Identifier: BSL-1.0 + * + * Adapted from boost::locale */ + +/** \file + * \ingroup blt + */ + +#include "messages.hh" + +#include +#include +#include +#include +#include +#include + +#include "BLI_assert.h" +#include "BLI_fileops.h" +#include "BLI_hash.hh" +#include "BLI_map.hh" +#include "BLI_path_utils.hh" +#include "BLI_string_ref.hh" +#include "BLI_vector.hh" + +#ifdef _WIN32 +# include "BLI_winstuff.h" +#endif + +#include "CLG_log.h" + +namespace blender::locale { + +static CLG_LogRef LOG = {"translation.messages"}; + +/* Upper/lower case, intentionally restricted to ASCII. */ + +static constexpr bool is_upper_ascii(const char c) +{ + return 'A' <= c && c <= 'Z'; +} + +static constexpr bool is_lower_ascii(const char c) +{ + return 'a' <= c && c <= 'z'; +} + +static bool make_lower_ascii(char &c) +{ + if (is_upper_ascii(c)) { + c += 'a' - 'A'; + return true; + } + return false; +} + +static bool make_upper_ascii(char &c) +{ + if (is_lower_ascii(c)) { + c += 'A' - 'a'; + return true; + } + return false; +} + +static constexpr bool is_numeric_ascii(const char c) +{ + return '0' <= c && c <= '9'; +} + +/* Info about a locale. */ + +class Info { + public: + std::string language = "C"; + std::string script; + std::string country; + std::string variant; + + Info(const StringRef locale_full_name) + { + std::string locale_name(locale_full_name); + + /* If locale name not specified, try to get the appropriate one from the system. */ +#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) + if (locale_name.empty()) { + locale_name = macos_user_locale(); + } +#endif + + if (locale_name.empty()) { + const char *lc_all = BLI_getenv("LC_ALL"); + if (lc_all) { + locale_name = lc_all; + } + } + if (locale_name.empty()) { + const char *lang = BLI_getenv("LANG"); + if (lang) { + locale_name = lang; + } + } + +#ifdef _WIN32 + if (locale_name.empty()) { + char buf[128] = {}; + if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, buf, sizeof(buf)) != 0) { + locale_name = buf; + if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, buf, sizeof(buf)) != 0) { + locale_name += "_"; + locale_name += buf; + } + } + } +#endif + + parse_from_lang(locale_name); + } + + std::string to_full_name() const + { + std::string result = language; + if (!script.empty()) { + result += '_' + script; + } + if (!country.empty()) { + result += '_' + country; + } + if (!variant.empty()) { + result += '@' + variant; + } + return result; + } + + private: + /* Locale parsing. */ + bool parse_from_variant(const std::string_view input) + { + if (language == "C" || input.empty()) { + return false; + } + variant = input; + /* No assumptions, just make it lowercase. */ + for (char &c : variant) { + make_lower_ascii(c); + } + return true; + } + + bool parse_from_encoding(const std::string_view input) + { + const int64_t end = input.find_first_of('@'); + std::string tmp(input.substr(0, end)); + if (tmp.empty()) { + return false; + } + /* tmp contains encoding, we ignore it. */ + if (end >= input.size()) { + return true; + } + BLI_assert(input[end] == '@'); + return parse_from_variant(input.substr(end + 1)); + } + + bool parse_from_country(const std::string_view input) + { + if (language == "C") { + return false; + } + + const int64_t end = input.find_first_of("@."); + std::string tmp(input.substr(0, end)); + if (tmp.empty()) { + return false; + } + + for (char &c : tmp) { + make_upper_ascii(c); + } + + /* If it's ALL uppercase ASCII, assume ISO 3166 country id. */ + if (std::find_if_not(tmp.begin(), tmp.end(), is_upper_ascii) != tmp.end()) { + /* else handle special cases: + * - en_US_POSIX is an alias for C + * - M49 country code: 3 digits */ + if (language == "en" && tmp == "US_POSIX") { + language = "C"; + tmp.clear(); + } + else if (tmp.size() != 3u || + std::find_if_not(tmp.begin(), tmp.end(), is_numeric_ascii) != tmp.end()) + { + return false; + } + } + + country = tmp; + if (end >= input.size()) { + return true; + } + if (input[end] == '.') { + return parse_from_encoding(input.substr(end + 1)); + } + BLI_assert(input[end] == '@'); + return parse_from_variant(input.substr(end + 1)); + } + + bool parse_from_script(const std::string_view input) + { + const int64_t end = input.find_first_of("-_@."); + std::string tmp(input.substr(0, end)); + /* Script is exactly 4 ASCII characters, otherwise it is not present. */ + if (tmp.length() != 4) { + return parse_from_country(input); + } + + for (char &c : tmp) { + if (!is_lower_ascii(c) && !make_lower_ascii(c)) { + return parse_from_country(input); + } + } + make_upper_ascii(tmp[0]); /* Capitalize first letter only. */ + script = tmp; + + if (end >= input.size()) { + return true; + } + if (input[end] == '-' || input[end] == '_') { + return parse_from_country(input.substr(end + 1)); + } + if (input[end] == '.') { + return parse_from_encoding(input.substr(end + 1)); + } + BLI_assert(input[end] == '@'); + return parse_from_variant(input.substr(end + 1)); + } + + bool parse_from_lang(const std::string_view input) + { + const int64_t end = input.find_first_of("-_@."); + std::string tmp(input.substr(0, end)); + if (tmp.empty()) { + return false; + } + for (char &c : tmp) { + if (!is_lower_ascii(c) && !make_lower_ascii(c)) { + return false; + } + } + if (tmp != "c" && tmp != "posix") { /* Keep default if C or POSIX. */ + language = tmp; + } + + if (end >= input.size()) { + return true; + } + if (input[end] == '-' || input[end] == '_') { + return parse_from_script(input.substr(end + 1)); + } + if (input[end] == '.') { + return parse_from_encoding(input.substr(end + 1)); + } + BLI_assert(input[end] == '@'); + return parse_from_variant(input.substr(end + 1)); + } +}; + +/* .mo file reader. */ + +class MOFile { + uint32_t keys_offset_ = 0; + uint32_t translations_offset_ = 0; + + Vector data_; + bool native_byteorder_ = false; + size_t size_ = false; + + std::string error_; + + public: + MOFile(const std::string &filepath) + { + FILE *file = BLI_fopen(filepath.c_str(), "rb"); + if (!file) { + return; + } + + fseek(file, 0, SEEK_END); + const int64_t len = BLI_ftell(file); + if (len >= 0) { + fseek(file, 0, SEEK_SET); + data_.resize(len); + if (fread(data_.data(), 1, len, file) != len) { + data_.clear(); + error_ = "Failed to read file"; + } + } + else { + error_ = "Wrong file object"; + } + + fclose(file); + + if (error_.empty()) { + read_data(); + } + } + + const char *key(int id) + { + const uint32_t off = get(keys_offset_ + id * 8 + 4); + return data_.data() + off; + } + + StringRef value(int id) + { + const uint32_t len = get(translations_offset_ + id * 8); + const uint32_t off = get(translations_offset_ + id * 8 + 4); + if (len > data_.size() || off > data_.size() - len) { + error_ = "Bad mo-file format"; + return ""; + } + return StringRef(&data_[off], len); + } + + size_t size() const + { + return size_; + } + + bool empty() const + { + return size_ == 0; + } + + const std::string &error() const + { + return error_; + } + + private: + void read_data() + { + if (data_.size() < 4) { + error_ = "Invalid 'mo' file format - the file is too short"; + return; + } + + uint32_t magic; + memcpy(&magic, data_.data(), sizeof(magic)); + if (magic == 0x950412de) { + native_byteorder_ = true; + } + else if (magic == 0xde120495) { + native_byteorder_ = false; + } + else { + error_ = "Invalid file format - invalid magic number"; + return; + } + + // Read all format sizes + size_ = get(8); + keys_offset_ = get(12); + translations_offset_ = get(16); + } + + uint32_t get(int offset) + { + if (offset > data_.size() - 4) { + error_ = "Bad mo-file format"; + return 0; + } + uint32_t v; + memcpy(&v, &data_[offset], 4); + if (!native_byteorder_) { + v = ((v & 0xFF) << 24) | ((v & 0xFF00) << 8) | ((v & 0xFF0000) >> 8) | + ((v & 0xFF000000) >> 24); + } + + return v; + } +}; + +/* Message lookup key. */ + +struct MessageKeyRef { + StringRef context_; + StringRef str_; + + uint64_t hash() const + { + return get_default_hash(context_, str_); + } +}; + +struct MessageKey { + std::string context_; + std::string str_; + + MessageKey(const StringRef c) + { + const size_t pos = c.find(char(4)); + if (pos == StringRef::not_found) { + str_ = c; + } + else { + context_ = c.substr(0, pos); + str_ = c.substr(pos + 1); + } + } + + uint64_t hash() const + { + return get_default_hash(context_, str_); + } + + static uint64_t hash_as(const MessageKeyRef &key) + { + return key.hash(); + } +}; + +inline bool operator==(const MessageKey &a, const MessageKey &b) +{ + return a.context_ == b.context_ && a.str_ == b.str_; +} + +inline bool operator==(const MessageKeyRef &a, const MessageKey &b) +{ + return a.context_ == b.context_ && a.str_ == b.str_; +} + +/* Messages translation based on .mo files. */ + +class MOMessages { + using Catalog = Map; + Vector catalogs_; + std::string error_; + + public: + MOMessages(const Info &info, + const Vector &domains, + const Vector &paths) + { + const Vector catalog_paths = get_catalog_paths(info, paths); + for (size_t i = 0; i < domains.size(); i++) { + const std::string &domain_name = domains[i]; + const std::string filename = domain_name + ".mo"; + Catalog catalog; + for (const std::string &path : catalog_paths) { + if (load_file(path + "/" + filename, catalog)) { + break; + } + } + catalogs_.append(std::move(catalog)); + } + } + + const char *translate(const int domain, const StringRef context, const StringRef str) const + { + if (domain < 0 || domain >= catalogs_.size()) { + return nullptr; + } + const MessageKeyRef key{context, str}; + const std::string *result = catalogs_[domain].lookup_ptr_as(key); + return (result) ? result->c_str() : nullptr; + } + + const std::string &error() + { + return error_; + } + + private: + Vector get_catalog_paths(const Info &info, const Vector &paths) + { + /* Find language folders. */ + Vector lang_folders; + if (!info.language.empty()) { + if (!info.variant.empty() && !info.country.empty()) { + lang_folders.append(info.language + "_" + info.country + "@" + info.variant); + } + if (!info.variant.empty()) { + lang_folders.append(info.language + "@" + info.variant); + } + if (!info.country.empty()) { + lang_folders.append(info.language + "_" + info.country); + } + lang_folders.append(info.language); + } + + /* Find catalogs in language folders. */ + Vector result; + result.reserve(lang_folders.size() * paths.size()); + for (const std::string &lang_folder : lang_folders) { + for (const std::string &search_path : paths) { + result.append(search_path + "/" + lang_folder + "/LC_MESSAGES"); + } + } + return result; + } + + bool load_file(const std::string &filepath, Catalog &catalog) + { + MOFile mo(filepath); + if (!mo.error().empty()) { + error_ = mo.error(); + return false; + } + if (mo.empty()) { + return false; + } + + /* Only support UTF-8 encoded files, as created by our msgfmt tool. */ + const std::string mo_encoding = extract(mo.value(0), "charset=", " \r\n;"); + if (mo_encoding.empty()) { + error_ = "Invalid mo-format, encoding is not specified"; + return false; + } + if (mo_encoding != "UTF-8") { + error_ = "supported mo-format, encoding must be UTF-8"; + return false; + } + + /* Create context + key to translated string mapping. */ + for (size_t i = 0; i < mo.size(); i++) { + const MessageKey key(mo.key(i)); + catalog.add(std::move(key), std::string(mo.value(i))); + } + + return true; + } + + static std::string extract(StringRef meta, const std::string &key, const StringRef separators) + { + const size_t pos = meta.find(key); + if (pos == StringRef::not_found) { + return ""; + } + meta = meta.substr(pos + key.size()); + const size_t end_pos = meta.find_first_of(separators); + return std::string(meta.substr(0, end_pos)); + } +}; + +/* Public API */ + +static std::unique_ptr global_messages; +static std::string global_full_name; + +void init(const StringRef locale_full_name, + const Vector &domains, + const Vector &paths) +{ + Info info(locale_full_name); + if (global_full_name == info.to_full_name()) { + return; + } + + global_messages = std::make_unique(info, domains, paths); + global_full_name = info.to_full_name(); + + if (global_messages->error().empty()) { + CLOG_INFO(&LOG, 2, "Locale %s used for translation", global_full_name.c_str()); + } + else { + CLOG_ERROR(&LOG, "Locale %s: %s", global_full_name.c_str(), global_messages->error().c_str()); + free(); + } +} + +void free() +{ + global_messages.reset(); + global_full_name = ""; +} + +const char *translate(const int domain, const StringRef context, const StringRef key) +{ + if (!global_messages) { + return nullptr; + } + + return global_messages->translate(domain, context, key); +} + +const char *full_name() +{ + return global_full_name.c_str(); +} + +} // namespace blender::locale diff --git a/source/blender/blentranslation/intern/messages.hh b/source/blender/blentranslation/intern/messages.hh new file mode 100644 index 000000000000..8031d903da98 --- /dev/null +++ b/source/blender/blentranslation/intern/messages.hh @@ -0,0 +1,29 @@ +/* SPDX-FileCopyrightText: 2025 Blender Authors + * SPDX-License-Identifier: BSL-1.0 + * + * Adapted from boost::locale */ + +/** \file + * \ingroup blt + */ + +#include + +#include "BLI_string_ref.hh" +#include "BLI_vector.hh" + +namespace blender::locale { + +void init(const StringRef locale_full_name, /* Local name. */ + const Vector &domains, /* Application names. */ + const Vector &paths); /* Search paths for .mo files. */ +void free(); + +const char *translate(const int domain, const StringRef context, const StringRef key); +const char *full_name(); + +#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) +std::string macos_user_locale(); +#endif + +} // namespace blender::locale diff --git a/intern/locale/osx_user_locale.mm b/source/blender/blentranslation/intern/messages_apple.mm similarity index 73% rename from intern/locale/osx_user_locale.mm rename to source/blender/blentranslation/intern/messages_apple.mm index 5d1be240f440..2d5554d03348 100644 --- a/intern/locale/osx_user_locale.mm +++ b/source/blender/blentranslation/intern/messages_apple.mm @@ -2,22 +2,24 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "boost_locale_wrapper.h" - /** \file - * \ingroup intern_locale + * \ingroup blt */ +#include "messages.hh" + #import #include +#include -static char *user_locale = nullptr; +namespace blender::locale { +#if !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) /* Get current locale. */ -const char *osx_user_locale() +std::string macos_user_locale() { - ::free(user_locale); + std::string result; @autoreleasepool { CFLocaleRef myCFLocale = CFLocaleCopyCurrent(); @@ -34,8 +36,11 @@ nsIdentifier = [NSString stringWithFormat:@"%@_%@", nsIdentifier, nsIdentifier_country]; } - user_locale = ::strdup(nsIdentifier.UTF8String); + result = nsIdentifier.UTF8String; } - return user_locale; + return result + ".UTF-8"; } +#endif + +} // namespace blender::locale diff --git a/source/blender/compositor/shaders/library/gpu_shader_compositor_type_conversion.glsl b/source/blender/compositor/shaders/library/gpu_shader_compositor_type_conversion.glsl index eaa344916e1f..a45db4dba5a4 100644 --- a/source/blender/compositor/shaders/library/gpu_shader_compositor_type_conversion.glsl +++ b/source/blender/compositor/shaders/library/gpu_shader_compositor_type_conversion.glsl @@ -84,7 +84,7 @@ vec4 color_to_vector(vec4 value) * Those should have the same interface and names as the macros in gpu_shader_codegen_lib.glsl * since the GPUMaterial compiler inserts those hard coded names. */ -float float_from_vec4(vec4 vector) +float float_from_vec4(vec4 vector, vec3 luminance_coefficients) { return dot(vector.rgb, vec3(1.0)) / 3.0; } diff --git a/source/blender/draw/DRW_engine.hh b/source/blender/draw/DRW_engine.hh index 3e2e0d8795ad..80d0d95a8f16 100644 --- a/source/blender/draw/DRW_engine.hh +++ b/source/blender/draw/DRW_engine.hh @@ -8,10 +8,6 @@ #pragma once -#include "BLI_sys_types.h" /* for bool */ - -#include "DNA_object_enums.h" - struct ARegion; struct DRWData; struct DRWInstanceDataList; diff --git a/source/blender/draw/engines/compositor/compositor_engine.cc b/source/blender/draw/engines/compositor/compositor_engine.cc index a8c2b0a702b4..8e7e8c03bf0e 100644 --- a/source/blender/draw/engines/compositor/compositor_engine.cc +++ b/source/blender/draw/engines/compositor/compositor_engine.cc @@ -34,6 +34,8 @@ #include "GPU_context.hh" #include "GPU_texture.hh" +#include "draw_view_data.hh" + #include "compositor_engine.h" /* Own include. */ namespace blender::draw::compositor_engine { diff --git a/source/blender/draw/engines/eevee_next/eevee_camera.cc b/source/blender/draw/engines/eevee_next/eevee_camera.cc index 4c5e7b15280e..d03845beea33 100644 --- a/source/blender/draw/engines/eevee_next/eevee_camera.cc +++ b/source/blender/draw/engines/eevee_next/eevee_camera.cc @@ -6,21 +6,16 @@ * \ingroup eevee */ -#include +#include "BLI_bounds.hh" #include "DRW_render.hh" -#include "BLI_bounds.hh" - #include "DNA_camera_types.h" #include "DNA_view3d_types.h" #include "BKE_camera.h" -#include "DEG_depsgraph_query.hh" - -#include "ED_view3d.hh" - +#include "RE_engine.h" #include "RE_pipeline.h" #include "render_types.h" diff --git a/source/blender/draw/engines/eevee_next/eevee_camera.hh b/source/blender/draw/engines/eevee_next/eevee_camera.hh index e7dc0053cea5..65320297c68c 100644 --- a/source/blender/draw/engines/eevee_next/eevee_camera.hh +++ b/source/blender/draw/engines/eevee_next/eevee_camera.hh @@ -8,6 +8,8 @@ * \ingroup eevee */ +#include "BLI_math_matrix.h" + #include "eevee_shader_shared.hh" namespace blender::eevee { diff --git a/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc b/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc index 196741b4224b..9c5501c84f22 100644 --- a/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc +++ b/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc @@ -24,7 +24,8 @@ #include "GPU_platform.hh" #include "GPU_texture.hh" -#include "GPU_uniform_buffer.hh" + +#include "draw_manager_profiling.hh" #include "eevee_camera.hh" #include "eevee_instance.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_engine.cc b/source/blender/draw/engines/eevee_next/eevee_engine.cc index 262dc2f20e7e..4e7277e50250 100644 --- a/source/blender/draw/engines/eevee_next/eevee_engine.cc +++ b/source/blender/draw/engines/eevee_next/eevee_engine.cc @@ -2,10 +2,8 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_global.hh" #include "BLI_rect.h" -#include "GPU_capabilities.hh" #include "GPU_framebuffer.hh" #include "ED_screen.hh" @@ -17,6 +15,8 @@ #include "eevee_engine.h" /* Own include. */ +#include "draw_view_data.hh" + #include "eevee_instance.hh" using namespace blender; diff --git a/source/blender/draw/engines/eevee_next/eevee_film.cc b/source/blender/draw/engines/eevee_next/eevee_film.cc index 834070bc4b18..74b73cd5baa9 100644 --- a/source/blender/draw/engines/eevee_next/eevee_film.cc +++ b/source/blender/draw/engines/eevee_next/eevee_film.cc @@ -17,14 +17,16 @@ #include "BLI_set.hh" #include "BKE_compositor.hh" +#include "BKE_scene.hh" -#include "GPU_debug.hh" #include "GPU_framebuffer.hh" #include "GPU_texture.hh" #include "DRW_render.hh" #include "RE_pipeline.h" +#include "draw_view_data.hh" + #include "eevee_film.hh" #include "eevee_instance.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_instance.cc b/source/blender/draw/engines/eevee_next/eevee_instance.cc index 786336f24dc0..8a568c1e8c9d 100644 --- a/source/blender/draw/engines/eevee_next/eevee_instance.cc +++ b/source/blender/draw/engines/eevee_next/eevee_instance.cc @@ -8,17 +8,22 @@ * An instance contains all structures needed to do a complete render. */ -#include - #include "BKE_global.hh" #include "BKE_object.hh" + #include "BLI_rect.h" +#include "BLI_time.h" + #include "BLT_translation.hh" + #include "DEG_depsgraph_query.hh" + #include "DNA_ID.h" #include "DNA_lightprobe_types.h" #include "DNA_modifier_types.h" + #include "IMB_imbuf_types.hh" + #include "RE_pipeline.h" #include "eevee_engine.h" @@ -27,6 +32,7 @@ #include "DNA_particle_types.h" #include "draw_common.hh" +#include "draw_view_data.hh" namespace blender::eevee { diff --git a/source/blender/draw/engines/eevee_next/eevee_instance.hh b/source/blender/draw/engines/eevee_next/eevee_instance.hh index 920baf18c7cf..4c870c74ba38 100644 --- a/source/blender/draw/engines/eevee_next/eevee_instance.hh +++ b/source/blender/draw/engines/eevee_next/eevee_instance.hh @@ -12,9 +12,16 @@ #include +#include "BLI_string.h" + +#include "BLT_translation.hh" + #include "BKE_object.hh" + #include "DEG_depsgraph.hh" + #include "DNA_lightprobe_types.h" + #include "DRW_render.hh" #include "eevee_ambient_occlusion.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_lightprobe.hh b/source/blender/draw/engines/eevee_next/eevee_lightprobe.hh index e11af602459a..8884defc94ca 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lightprobe.hh +++ b/source/blender/draw/engines/eevee_next/eevee_lightprobe.hh @@ -15,6 +15,8 @@ #include "BLI_bit_vector.hh" #include "BLI_map.hh" +#include "DNA_world_types.h" + #include "eevee_defines.hh" #include "eevee_sync.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_lightprobe_sphere.hh b/source/blender/draw/engines/eevee_next/eevee_lightprobe_sphere.hh index c34865d5d312..515877a62fba 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lightprobe_sphere.hh +++ b/source/blender/draw/engines/eevee_next/eevee_lightprobe_sphere.hh @@ -8,14 +8,11 @@ #pragma once +#include "DNA_world_types.h" + #include "eevee_lightprobe.hh" #include "eevee_shader_shared.hh" -#include "BKE_cryptomatte.hh" - -extern "C" { -} - namespace blender::eevee { class Instance; diff --git a/source/blender/draw/engines/eevee_next/eevee_lightprobe_volume.cc b/source/blender/draw/engines/eevee_next/eevee_lightprobe_volume.cc index 408da2c196f2..fa27765ed32a 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lightprobe_volume.cc +++ b/source/blender/draw/engines/eevee_next/eevee_lightprobe_volume.cc @@ -8,9 +8,8 @@ #include "BKE_lightprobe.h" #include "GPU_capabilities.hh" -#include "GPU_debug.hh" -#include "BLI_math_rotation.hh" +#include "draw_manager_profiling.hh" #include "eevee_instance.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_lookdev.cc b/source/blender/draw/engines/eevee_next/eevee_lookdev.cc index ed0958c28978..4aa40f68a950 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lookdev.cc +++ b/source/blender/draw/engines/eevee_next/eevee_lookdev.cc @@ -18,6 +18,9 @@ #include "GPU_material.hh" +#include "draw_cache.hh" +#include "draw_view_data.hh" + #include "eevee_instance.hh" namespace blender::eevee { diff --git a/source/blender/draw/engines/eevee_next/eevee_material.cc b/source/blender/draw/engines/eevee_next/eevee_material.cc index 67f842c5de35..074503fa94d6 100644 --- a/source/blender/draw/engines/eevee_next/eevee_material.cc +++ b/source/blender/draw/engines/eevee_next/eevee_material.cc @@ -15,8 +15,9 @@ #include "NOD_shader.h" -#include "eevee_instance.hh" +#include "draw_cache.hh" +#include "eevee_instance.hh" #include "eevee_material.hh" namespace blender::eevee { diff --git a/source/blender/draw/engines/eevee_next/eevee_material.hh b/source/blender/draw/engines/eevee_next/eevee_material.hh index 3e689dba5bf5..3c0d82707dbb 100644 --- a/source/blender/draw/engines/eevee_next/eevee_material.hh +++ b/source/blender/draw/engines/eevee_next/eevee_material.hh @@ -8,6 +8,8 @@ #pragma once +#include "DNA_material_types.h" + #include "DRW_render.hh" #include "BLI_map.hh" @@ -16,6 +18,9 @@ #include "eevee_sync.hh" +struct bNodeSocketValueFloat; +struct bNodeSocketValueRGBA; + namespace blender::eevee { class Instance; diff --git a/source/blender/draw/engines/eevee_next/eevee_motion_blur.cc b/source/blender/draw/engines/eevee_next/eevee_motion_blur.cc index 5875f21aa30a..d725b746fbb3 100644 --- a/source/blender/draw/engines/eevee_next/eevee_motion_blur.cc +++ b/source/blender/draw/engines/eevee_next/eevee_motion_blur.cc @@ -6,15 +6,14 @@ * \ingroup eevee */ -// #include "BLI_map.hh" #include "BKE_colortools.hh" -#include "DEG_depsgraph_query.hh" + +#include "RE_engine.h" + +#include "draw_manager_profiling.hh" #include "eevee_instance.hh" #include "eevee_motion_blur.hh" -// #include "eevee_sampling.hh" -// #include "eevee_shader_shared.hh" -// #include "eevee_velocity.hh" namespace blender::eevee { diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc index 324ea1a51577..9d2b02d0373e 100644 --- a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc +++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc @@ -17,7 +17,7 @@ #include "eevee_pipeline.hh" #include "eevee_shadow.hh" -#include +#include "draw_manager_profiling.hh" #include "draw_common.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_raytrace.cc b/source/blender/draw/engines/eevee_next/eevee_raytrace.cc index ca216c940373..1105312bbf24 100644 --- a/source/blender/draw/engines/eevee_next/eevee_raytrace.cc +++ b/source/blender/draw/engines/eevee_next/eevee_raytrace.cc @@ -8,10 +8,7 @@ * The ray-tracing module class handles ray generation, scheduling, tracing and denoising. */ -#include -#include - -#include "BKE_global.hh" +#include "draw_manager_profiling.hh" #include "eevee_instance.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_sampling.cc b/source/blender/draw/engines/eevee_next/eevee_sampling.cc index 0624c54e1ccc..a72c3455a5a8 100644 --- a/source/blender/draw/engines/eevee_next/eevee_sampling.cc +++ b/source/blender/draw/engines/eevee_next/eevee_sampling.cc @@ -9,6 +9,7 @@ */ #include "BKE_colortools.hh" +#include "BKE_scene.hh" #include "BLI_rand.h" diff --git a/source/blender/draw/engines/eevee_next/eevee_shader.cc b/source/blender/draw/engines/eevee_next/eevee_shader.cc index 563a934d94c3..1e788a3698de 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shader.cc +++ b/source/blender/draw/engines/eevee_next/eevee_shader.cc @@ -11,6 +11,8 @@ #include "GPU_capabilities.hh" +#include "BKE_material.hh" + #include "gpu_shader_create_info.hh" #include "eevee_shader.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_shadow.cc b/source/blender/draw/engines/eevee_next/eevee_shadow.cc index df74f37481e8..1d96336cb52a 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shadow.cc +++ b/source/blender/draw/engines/eevee_next/eevee_shadow.cc @@ -8,14 +8,14 @@ * The shadow module manages shadow update tagging & shadow rendering. */ -#include "BKE_global.hh" #include "BLI_math_matrix.hh" #include "GPU_compute.hh" #include "eevee_instance.hh" +#include "draw_cache.hh" #include "draw_debug.hh" -#include +#include "draw_manager_profiling.hh" namespace blender::eevee { diff --git a/source/blender/draw/engines/eevee_next/eevee_sync.cc b/source/blender/draw/engines/eevee_next/eevee_sync.cc index c37f9d2f1161..563358756eca 100644 --- a/source/blender/draw/engines/eevee_next/eevee_sync.cc +++ b/source/blender/draw/engines/eevee_next/eevee_sync.cc @@ -8,20 +8,15 @@ * Converts the different renderable object types to drawcalls. */ -#include "eevee_engine.h" - -#include "BKE_gpencil_legacy.h" -#include "BKE_object.hh" #include "BKE_paint.hh" #include "BKE_paint_bvh.hh" -#include "DEG_depsgraph_query.hh" #include "DNA_curves_types.h" -#include "DNA_gpencil_legacy_types.h" #include "DNA_modifier_types.h" #include "DNA_particle_types.h" #include "DNA_pointcloud_types.h" #include "DNA_volume_types.h" +#include "draw_cache.hh" #include "draw_common.hh" #include "draw_sculpt.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_velocity.cc b/source/blender/draw/engines/eevee_next/eevee_velocity.cc index 17fdebef400b..21cf4a0ea688 100644 --- a/source/blender/draw/engines/eevee_next/eevee_velocity.cc +++ b/source/blender/draw/engines/eevee_next/eevee_velocity.cc @@ -19,6 +19,7 @@ #include "DNA_particle_types.h" #include "DNA_rigidbody_types.h" +#include "draw_cache.hh" #include "draw_cache_impl.hh" #include "eevee_instance.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_view.cc b/source/blender/draw/engines/eevee_next/eevee_view.cc index 5d8fb5473514..8d854fddb18f 100644 --- a/source/blender/draw/engines/eevee_next/eevee_view.cc +++ b/source/blender/draw/engines/eevee_next/eevee_view.cc @@ -15,9 +15,10 @@ * its type. Passes are shared between views. */ -#include "BKE_global.hh" #include "DRW_render.hh" +#include "draw_manager_profiling.hh" + #include "eevee_instance.hh" #include "eevee_view.hh" diff --git a/source/blender/draw/engines/eevee_next/eevee_volume.cc b/source/blender/draw/engines/eevee_next/eevee_volume.cc index 3ee66bc74c07..98299a82ea82 100644 --- a/source/blender/draw/engines/eevee_next/eevee_volume.cc +++ b/source/blender/draw/engines/eevee_next/eevee_volume.cc @@ -10,10 +10,9 @@ * https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite */ -#include "DNA_volume_types.h" #include "GPU_capabilities.hh" -#include "draw_common.hh" +#include "draw_manager_profiling.hh" #include "eevee_instance.hh" #include "eevee_pipeline.hh" diff --git a/source/blender/draw/engines/external/external_engine.cc b/source/blender/draw/engines/external/external_engine.cc index 9968fc37248b..0fb18cf8a91a 100644 --- a/source/blender/draw/engines/external/external_engine.cc +++ b/source/blender/draw/engines/external/external_engine.cc @@ -12,29 +12,27 @@ #include "DRW_engine.hh" #include "DRW_render.hh" -#include "DNA_modifier_types.h" +#include "BLI_string.h" + +#include "BLT_translation.hh" + #include "DNA_screen_types.h" #include "DNA_view3d_types.h" -#include "BKE_object.hh" -#include "BKE_particle.h" -#include "BKE_screen.hh" - #include "ED_image.hh" #include "ED_screen.hh" -#include "GPU_batch.hh" #include "GPU_debug.hh" #include "GPU_matrix.hh" -#include "GPU_shader.hh" #include "GPU_state.hh" -#include "GPU_viewport.hh" #include "RE_engine.h" #include "RE_pipeline.h" #include "draw_command.hh" #include "draw_view.hh" +#include "draw_view_data.hh" + #include "external_engine.h" /* own include */ /* Shaders */ diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc b/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc index ec5f8cf12b8e..73cafeed7a8b 100644 --- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc +++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc @@ -9,28 +9,25 @@ #include "DRW_engine.hh" #include "DRW_render.hh" -#include "ED_gpencil_legacy.hh" #include "ED_view3d.hh" -#include "DNA_gpencil_legacy_types.h" -#include "DNA_view3d_types.h" +#include "DNA_material_types.h" -#include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_grease_pencil.hh" -#include "BKE_lib_id.hh" +#include "BKE_material.hh" #include "BKE_object.hh" +#include "BLI_ghash.h" #include "BLI_hash.h" #include "BLI_link_utils.h" #include "BLI_math_color.h" +#include "BLI_math_matrix.h" #include "BLI_math_vector.hh" #include "BLI_memblock.h" #include "gpencil_engine.h" -#include "draw_cache_impl.hh" - #include "DEG_depsgraph.hh" #include "UI_resources.hh" diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_data.cc b/source/blender/draw/engines/gpencil/gpencil_draw_data.cc index 73d93c6bf234..19ba43f27c98 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_data.cc +++ b/source/blender/draw/engines/gpencil/gpencil_draw_data.cc @@ -9,11 +9,12 @@ #include "DRW_render.hh" #include "DNA_light_types.h" +#include "DNA_material_types.h" #include "BKE_image.hh" +#include "BKE_material.hh" -#include "BLI_hash.h" -#include "BLI_math_color.h" +#include "BLI_math_matrix.h" #include "BLI_memblock.h" #include "GPU_uniform_buffer.hh" diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h index 0306fc03c144..b14fb68b8b98 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.h +++ b/source/blender/draw/engines/gpencil/gpencil_engine.h @@ -8,18 +8,16 @@ #pragma once -#include "DNA_gpencil_legacy_types.h" - #include "DRW_render.hh" #include "BLI_bitmap.h" -#include "BLI_bounds.hh" #include "BKE_grease_pencil.hh" #include "GPU_batch.hh" #include "draw_pass.hh" +#include "draw_view_data.hh" #define GP_LIGHT diff --git a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc index df609c1cac5a..7f8e8bf5b6cc 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc +++ b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc @@ -8,33 +8,34 @@ #include "DRW_engine.hh" #include "DRW_render.hh" +#include "BKE_context.hh" #include "BKE_curves.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" -#include "BKE_grease_pencil.h" #include "BKE_grease_pencil.hh" -#include "BKE_lib_id.hh" -#include "BKE_main.hh" +#include "BKE_material.hh" #include "BKE_object.hh" #include "BKE_paint.hh" #include "BKE_shader_fx.h" #include "BKE_camera.h" -#include "BKE_global.hh" /* for G.debug */ -#include "BLI_link_utils.h" #include "BLI_listbase.h" #include "BLI_memblock.h" #include "BLI_virtual_array.hh" +#include "BLT_translation.hh" + #include "DNA_camera_types.h" -#include "DNA_gpencil_legacy_types.h" +#include "DNA_material_types.h" #include "DNA_screen_types.h" #include "DNA_view3d_types.h" +#include "DNA_world_types.h" #include "GPU_texture.hh" #include "GPU_uniform_buffer.hh" +#include "draw_cache.hh" #include "draw_manager.hh" #include "draw_view.hh" @@ -46,7 +47,7 @@ #include "ED_screen.hh" #include "ED_view3d.hh" -#include "UI_resources.hh" +#include "draw_manager_profiling.hh" /* *********** FUNCTIONS *********** */ diff --git a/source/blender/draw/engines/gpencil/gpencil_render.cc b/source/blender/draw/engines/gpencil/gpencil_render.cc index 968b0b3c044a..dd1d5486358c 100644 --- a/source/blender/draw/engines/gpencil/gpencil_render.cc +++ b/source/blender/draw/engines/gpencil/gpencil_render.cc @@ -5,16 +5,16 @@ /** \file * \ingroup draw */ +#include "BLI_math_matrix.h" #include "BLI_rect.h" #include "DRW_render.hh" #include "BKE_object.hh" -#include "DNA_gpencil_legacy_types.h" - #include "DEG_depsgraph_query.hh" +#include "RE_engine.h" #include "RE_pipeline.h" #include "IMB_imbuf_types.hh" diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_c.cc b/source/blender/draw/engines/gpencil/gpencil_shader_c.cc index 006a870c916d..65cbe313542a 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_c.cc +++ b/source/blender/draw/engines/gpencil/gpencil_shader_c.cc @@ -7,6 +7,8 @@ */ #include "DRW_render.hh" +#include "BLI_string.h" + #include "gpencil_engine.h" extern "C" char datatoc_gpencil_common_lib_glsl[]; diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc b/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc index e4bbda4410fa..51e79fa418f8 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc +++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc @@ -13,7 +13,7 @@ #include "BKE_gpencil_legacy.h" #include "BLI_link_utils.h" -#include "BLI_memblock.h" +#include "BLI_math_matrix.h" #include "DRW_render.hh" diff --git a/source/blender/draw/engines/image/image_drawing_mode.cc b/source/blender/draw/engines/image/image_drawing_mode.cc index dd5373482e7a..d42acac93510 100644 --- a/source/blender/draw/engines/image/image_drawing_mode.cc +++ b/source/blender/draw/engines/image/image_drawing_mode.cc @@ -2,6 +2,8 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "draw_view_data.hh" + #include "image_drawing_mode.hh" #include "image_instance.hh" #include "image_shader.hh" diff --git a/source/blender/draw/engines/image/image_engine.cc b/source/blender/draw/engines/image/image_engine.cc index 8aedd0581ec8..7994a09f2820 100644 --- a/source/blender/draw/engines/image/image_engine.cc +++ b/source/blender/draw/engines/image/image_engine.cc @@ -10,30 +10,21 @@ #include "DRW_render.hh" -#include -#include +#include "BLT_translation.hh" +#include "BKE_context.hh" #include "BKE_image.hh" #include "BKE_main.hh" #include "BKE_object.hh" -#include "DNA_camera_types.h" -#include "DNA_screen_types.h" - -#include "IMB_imbuf.hh" -#include "IMB_imbuf_types.hh" - #include "ED_image.hh" -#include "GPU_batch.hh" +#include "draw_view_data.hh" #include "image_drawing_mode.hh" #include "image_engine.h" #include "image_instance.hh" -#include "image_private.hh" #include "image_shader.hh" -#include "image_space_image.hh" -#include "image_space_node.hh" namespace blender::image_engine { diff --git a/source/blender/draw/engines/overlay/overlay_armature.cc b/source/blender/draw/engines/overlay/overlay_armature.cc index 6e17d76b0a8d..eaa7d0810917 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.cc +++ b/source/blender/draw/engines/overlay/overlay_armature.cc @@ -15,12 +15,12 @@ #include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "DNA_view3d_types.h" #include "DRW_render.hh" #include "BLI_listbase_wrapper.hh" #include "BLI_math_color.h" +#include "BLI_math_matrix.h" #include "BLI_math_matrix_types.hh" #include "BLI_math_rotation.h" #include "BLI_utildefines.h" @@ -28,9 +28,7 @@ #include "BKE_action.hh" #include "BKE_armature.hh" #include "BKE_deform.hh" -#include "BKE_modifier.hh" #include "BKE_object.hh" -#include "BKE_object_types.hh" #include "DEG_depsgraph_query.hh" @@ -42,11 +40,11 @@ #include "UI_resources.hh" +#include "draw_cache.hh" #include "draw_common_c.hh" #include "draw_manager_text.hh" #include "overlay_next_armature.hh" -#include "overlay_private.hh" #include "draw_cache_impl.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_attribute_text.hh b/source/blender/draw/engines/overlay/overlay_next_attribute_text.hh index 586b59426d9f..203c4ab6fadd 100644 --- a/source/blender/draw/engines/overlay/overlay_next_attribute_text.hh +++ b/source/blender/draw/engines/overlay/overlay_next_attribute_text.hh @@ -7,16 +7,16 @@ */ #include "BLI_math_quaternion_types.hh" +#include "BLI_string.h" #include "DNA_curve_types.h" +#include "DNA_pointcloud_types.h" #include "BKE_attribute.hh" #include "BKE_curves.hh" #include "BKE_duplilist.hh" #include "BKE_geometry_set.hh" #include "BKE_instances.hh" -#include "BKE_mesh.hh" -#include "BKE_pointcloud.hh" #include "DRW_render.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_attribute_viewer.hh b/source/blender/draw/engines/overlay/overlay_next_attribute_viewer.hh index fb5883673f90..7b7b679ed41f 100644 --- a/source/blender/draw/engines/overlay/overlay_next_attribute_viewer.hh +++ b/source/blender/draw/engines/overlay/overlay_next_attribute_viewer.hh @@ -14,6 +14,7 @@ #include "DNA_curve_types.h" #include "DNA_pointcloud_types.h" +#include "draw_cache.hh" #include "draw_cache_impl.hh" #include "overlay_next_base.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_background.hh b/source/blender/draw/engines/overlay/overlay_next_background.hh index c679bf35728d..a08d25a96af7 100644 --- a/source/blender/draw/engines/overlay/overlay_next_background.hh +++ b/source/blender/draw/engines/overlay/overlay_next_background.hh @@ -8,6 +8,10 @@ #pragma once +#include "DNA_world_types.h" + +#include "draw_cache.hh" + #include "overlay_next_base.hh" namespace blender::draw::overlay { diff --git a/source/blender/draw/engines/overlay/overlay_next_engine.cc b/source/blender/draw/engines/overlay/overlay_next_engine.cc index 94d2bae7c4c6..4719f5012a78 100644 --- a/source/blender/draw/engines/overlay/overlay_next_engine.cc +++ b/source/blender/draw/engines/overlay/overlay_next_engine.cc @@ -11,19 +11,7 @@ #include "DRW_engine.hh" #include "DRW_render.hh" -#include "DEG_depsgraph_query.hh" - -#include "ED_view3d.hh" - -#include "UI_interface.hh" - -#include "BKE_duplilist.hh" -#include "BKE_object.hh" -#include "BKE_paint.hh" - -#include "GPU_capabilities.hh" - -#include "DNA_space_types.h" +#include "BLT_translation.hh" #include "draw_manager.hh" #include "overlay_next_instance.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_grease_pencil.hh b/source/blender/draw/engines/overlay/overlay_next_grease_pencil.hh index b9d0e9645590..1b91a6bb6cc4 100644 --- a/source/blender/draw/engines/overlay/overlay_next_grease_pencil.hh +++ b/source/blender/draw/engines/overlay/overlay_next_grease_pencil.hh @@ -9,14 +9,19 @@ #pragma once #include "BLI_bounds.hh" +#include "BLI_math_matrix.h" #include "BLI_math_matrix.hh" #include "BKE_curves.hh" #include "BKE_grease_pencil.hh" +#include "BKE_material.hh" #include "BKE_object.hh" +#include "DNA_material_types.h" + #include "ED_grease_pencil.hh" +#include "draw_cache.hh" #include "draw_manager_text.hh" #include "overlay_next_base.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_instance.cc b/source/blender/draw/engines/overlay/overlay_next_instance.cc index 96e36012029a..520ee3011f83 100644 --- a/source/blender/draw/engines/overlay/overlay_next_instance.cc +++ b/source/blender/draw/engines/overlay/overlay_next_instance.cc @@ -12,8 +12,6 @@ #include "BKE_paint.hh" -#include "draw_debug.hh" - #include "overlay_next_instance.hh" namespace blender::draw::overlay { diff --git a/source/blender/draw/engines/overlay/overlay_next_light.hh b/source/blender/draw/engines/overlay/overlay_next_light.hh index d882d72fbf2b..3cf5734c403d 100644 --- a/source/blender/draw/engines/overlay/overlay_next_light.hh +++ b/source/blender/draw/engines/overlay/overlay_next_light.hh @@ -8,6 +8,10 @@ #pragma once +#include "DNA_light_types.h" + +#include "BLI_math_matrix.h" + #include "overlay_next_base.hh" namespace blender::draw::overlay { diff --git a/source/blender/draw/engines/overlay/overlay_next_mode_transfer.hh b/source/blender/draw/engines/overlay/overlay_next_mode_transfer.hh index 39b2d62597d9..9002d957bba3 100644 --- a/source/blender/draw/engines/overlay/overlay_next_mode_transfer.hh +++ b/source/blender/draw/engines/overlay/overlay_next_mode_transfer.hh @@ -8,8 +8,11 @@ #pragma once +#include "BLI_time.h" + #include "BKE_paint.hh" +#include "draw_cache.hh" #include "draw_sculpt.hh" #include "overlay_next_base.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_origin.hh b/source/blender/draw/engines/overlay/overlay_next_origin.hh index d7c3d002a9a4..12db3635fb40 100644 --- a/source/blender/draw/engines/overlay/overlay_next_origin.hh +++ b/source/blender/draw/engines/overlay/overlay_next_origin.hh @@ -8,6 +8,8 @@ #pragma once +#include "BKE_layer.hh" + #include "overlay_next_base.hh" namespace blender::draw::overlay { diff --git a/source/blender/draw/engines/overlay/overlay_next_paint.hh b/source/blender/draw/engines/overlay/overlay_next_paint.hh index 025834d42d7f..0a0fbf9bca7f 100644 --- a/source/blender/draw/engines/overlay/overlay_next_paint.hh +++ b/source/blender/draw/engines/overlay/overlay_next_paint.hh @@ -10,9 +10,11 @@ #include "BKE_image.hh" #include "BKE_paint.hh" +#include "BKE_scene.hh" #include "DEG_depsgraph_query.hh" +#include "draw_cache.hh" #include "draw_cache_impl.hh" #include "overlay_next_base.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_private.hh b/source/blender/draw/engines/overlay/overlay_next_private.hh index 623d11010483..4a3deb961cd0 100644 --- a/source/blender/draw/engines/overlay/overlay_next_private.hh +++ b/source/blender/draw/engines/overlay/overlay_next_private.hh @@ -8,11 +8,14 @@ #pragma once +#include "BKE_context.hh" #include "BKE_movieclip.h" #include "BKE_object.hh" #include "BLI_function_ref.hh" +#include "DNA_world_types.h" + #include "GPU_matrix.hh" #include "DRW_gpu_wrapper.hh" @@ -20,6 +23,7 @@ #include "UI_resources.hh" #include "draw_manager.hh" #include "draw_pass.hh" +#include "draw_view_data.hh" #include "gpu_shader_create_info.hh" #include "../select/select_instance.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_shape.cc b/source/blender/draw/engines/overlay/overlay_next_shape.cc index e59a9c8fe431..2a3a887ea4fd 100644 --- a/source/blender/draw/engines/overlay/overlay_next_shape.cc +++ b/source/blender/draw/engines/overlay/overlay_next_shape.cc @@ -6,6 +6,8 @@ * \ingroup overlay */ +#include "draw_cache.hh" + #include "overlay_next_private.hh" namespace blender::draw::overlay { diff --git a/source/blender/draw/engines/overlay/shaders/overlay_antialiasing_frag.glsl b/source/blender/draw/engines/overlay/shaders/overlay_antialiasing_frag.glsl index 03b65e94d626..175e59af39d0 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_antialiasing_frag.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_antialiasing_frag.glsl @@ -100,6 +100,11 @@ void main() float dist_raw = texelFetch(lineTex, center_texel, 0).b; float dist = decode_line_dist(dist_raw); + if (!doSmoothLines && dist <= 1.0f) { + /* No expansion or AA should be applied. */ + return; + } + /* TODO: Optimization: use textureGather. */ vec4 neightbor_col0 = texelFetchOffset(colorTex, center_texel, 0, ivec2(1, 0)); vec4 neightbor_col1 = texelFetchOffset(colorTex, center_texel, 0, ivec2(-1, 0)); diff --git a/source/blender/draw/engines/select/select_engine.cc b/source/blender/draw/engines/select/select_engine.cc index 650e176cb798..7b3cefe7e4e8 100644 --- a/source/blender/draw/engines/select/select_engine.cc +++ b/source/blender/draw/engines/select/select_engine.cc @@ -8,16 +8,19 @@ * Engine for drawing a selection map where the pixels indicate the selection indices. */ -#include "DNA_screen_types.h" +#include "BLI_math_matrix.h" + +#include "BLT_translation.hh" #include "ED_view3d.hh" -#include "UI_resources.hh" +#include "RE_engine.h" #include "DRW_engine.hh" #include "DRW_select_buffer.hh" #include "draw_cache_impl.hh" +#include "draw_common_c.hh" #include "draw_manager_c.hh" #include "select_engine.hh" diff --git a/source/blender/draw/engines/select/select_instance.cc b/source/blender/draw/engines/select/select_instance.cc index 350ae7112d19..da39453ed44a 100644 --- a/source/blender/draw/engines/select/select_instance.cc +++ b/source/blender/draw/engines/select/select_instance.cc @@ -8,7 +8,7 @@ #include "DRW_render.hh" -#include "GPU_capabilities.hh" +#include "BLT_translation.hh" #include "select_engine.hh" diff --git a/source/blender/draw/engines/select/select_private.hh b/source/blender/draw/engines/select/select_private.hh index 5e74f430c907..7b2c4a0fb243 100644 --- a/source/blender/draw/engines/select/select_private.hh +++ b/source/blender/draw/engines/select/select_private.hh @@ -12,6 +12,7 @@ #include "draw_manager.hh" #include "draw_pass.hh" +#include "draw_view_data.hh" #include "DRW_render.hh" diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc b/source/blender/draw/engines/workbench/workbench_effect_dof.cc index 45a0760f9cd9..2bf66b4f7a27 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc @@ -20,7 +20,8 @@ #include "workbench_private.hh" #include "BKE_camera.h" -#include "DEG_depsgraph_query.hh" + +#include "draw_manager_profiling.hh" namespace blender::workbench { /** diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index 9d37a76219d3..56350f0909c1 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -7,24 +7,30 @@ #include "DNA_fluid_types.h" #include "BKE_editmesh.hh" +#include "BKE_material.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_paint.hh" #include "BKE_paint_bvh.hh" #include "BKE_particle.h" -#include "BKE_report.hh" #include "DEG_depsgraph_query.hh" +#include "DNA_windowmanager_types.h" #include "ED_paint.hh" #include "ED_view3d.hh" -#include "GPU_capabilities.hh" +#include "BLT_translation.hh" #include "IMB_imbuf_types.hh" +#include "RE_engine.h" +#include "RE_pipeline.h" + +#include "draw_cache.hh" #include "draw_common.hh" #include "draw_sculpt.hh" +#include "draw_view_data.hh" #include "workbench_private.hh" diff --git a/source/blender/draw/engines/workbench/workbench_materials.cc b/source/blender/draw/engines/workbench/workbench_materials.cc index bc7d0a283c7b..8909f9539bf9 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.cc +++ b/source/blender/draw/engines/workbench/workbench_materials.cc @@ -4,11 +4,12 @@ #include "workbench_private.hh" +#include "BLI_ghash.h" #include "BLI_hash.h" #include "BLI_math_color.h" /* get_image */ -#include "BKE_node.hh" #include "BKE_node_legacy_types.hh" +#include "DNA_material_types.h" #include "DNA_node_types.h" #include "ED_uvedit.hh" /* get_image */ diff --git a/source/blender/draw/engines/workbench/workbench_private.hh b/source/blender/draw/engines/workbench/workbench_private.hh index 7ad5caac8351..cdf86a0eb20e 100644 --- a/source/blender/draw/engines/workbench/workbench_private.hh +++ b/source/blender/draw/engines/workbench/workbench_private.hh @@ -2,6 +2,8 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BKE_context.hh" + #include "DNA_camera_types.h" #include "DRW_render.hh" #include "draw_manager.hh" diff --git a/source/blender/draw/engines/workbench/workbench_resources.cc b/source/blender/draw/engines/workbench/workbench_resources.cc index dc479befeca9..3170fa4056ac 100644 --- a/source/blender/draw/engines/workbench/workbench_resources.cc +++ b/source/blender/draw/engines/workbench/workbench_resources.cc @@ -3,10 +3,15 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "../eevee_next/eevee_lut.hh" /* TODO: find somewhere to share blue noise Table. */ + #include "BKE_studiolight.h" + +#include "BLI_math_matrix.h" #include "BLI_math_rotation.h" + #include "IMB_imbuf_types.hh" +#include "draw_common_c.hh" #include "workbench_private.hh" namespace blender::workbench { diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index 59a92d165dd6..2257230064dd 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -19,6 +19,8 @@ #include "DRW_render.hh" #include "GPU_compute.hh" +#include "draw_cache.hh" + #include "workbench_private.hh" namespace blender::workbench { diff --git a/source/blender/draw/engines/workbench/workbench_state.cc b/source/blender/draw/engines/workbench/workbench_state.cc index d0348c83c5fb..1b75970343b6 100644 --- a/source/blender/draw/engines/workbench/workbench_state.cc +++ b/source/blender/draw/engines/workbench/workbench_state.cc @@ -5,18 +5,19 @@ #include "workbench_private.hh" #include "BKE_camera.h" +#include "BKE_customdata.hh" #include "BKE_editmesh.hh" #include "BKE_mesh_types.hh" -#include "BKE_modifier.hh" -#include "BKE_object.hh" #include "BKE_paint.hh" #include "BKE_paint_bvh.hh" -#include "BKE_particle.h" #include "DEG_depsgraph_query.hh" -#include "DNA_fluid_types.h" + +#include "DNA_world_types.h" + #include "ED_paint.hh" #include "ED_view3d.hh" + #include "GPU_capabilities.hh" namespace blender::workbench { diff --git a/source/blender/draw/engines/workbench/workbench_volume.cc b/source/blender/draw/engines/workbench/workbench_volume.cc index b1cb909495ff..e91aa170a29a 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.cc +++ b/source/blender/draw/engines/workbench/workbench_volume.cc @@ -2,6 +2,9 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "draw_cache.hh" +#include "draw_common_c.hh" + #include "workbench_private.hh" #include "BKE_volume.hh" diff --git a/source/blender/draw/intern/DRW_gpu_wrapper.hh b/source/blender/draw/intern/DRW_gpu_wrapper.hh index 2402b6bfe643..f5a5fdefde30 100644 --- a/source/blender/draw/intern/DRW_gpu_wrapper.hh +++ b/source/blender/draw/intern/DRW_gpu_wrapper.hh @@ -57,8 +57,6 @@ * Simple wrapper to #GPUFramebuffer that can be moved. */ -#include "DRW_render.hh" - #include "MEM_guardedalloc.h" #include "draw_manager_c.hh" diff --git a/source/blender/draw/intern/DRW_render.hh b/source/blender/draw/intern/DRW_render.hh index ac08d7472fc1..db5e56c402c5 100644 --- a/source/blender/draw/intern/DRW_render.hh +++ b/source/blender/draw/intern/DRW_render.hh @@ -10,45 +10,9 @@ #pragma once -#include "BLI_listbase.h" -#include "BLI_math_matrix.h" -#include "BLI_string.h" +#include "DNA_object_enums.h" -#include "BKE_context.hh" -#include "BKE_layer.hh" -#include "BKE_material.hh" -#include "BKE_scene.hh" - -#include "BLT_translation.hh" - -#include "DNA_light_types.h" -#include "DNA_material_types.h" -#include "DNA_object_types.h" -#include "DNA_scene_types.h" -#include "DNA_world_types.h" - -#include "GPU_framebuffer.hh" #include "GPU_material.hh" -#include "GPU_primitive.hh" -#include "GPU_shader.hh" -#include "GPU_storage_buffer.hh" -#include "GPU_texture.hh" -#include "GPU_uniform_buffer.hh" - -#include "draw_cache.hh" -#include "draw_common_c.hh" -#include "draw_view_c.hh" - -#include "draw_debug_c.hh" -#include "draw_manager_profiling.hh" -#include "draw_state.hh" -#include "draw_view_data.hh" - -#include "MEM_guardedalloc.h" - -#include "RE_engine.h" - -#include "DEG_depsgraph.hh" /* Uncomment to track unused resource bindings. */ // #define DRW_UNUSED_RESOURCE_TRACKING @@ -62,16 +26,29 @@ namespace blender::gpu { class Batch; } +struct ARegion; +struct bContext; +struct Depsgraph; +struct DefaultFramebufferList; +struct DefaultTextureList; +struct DupliObject; struct GPUMaterial; struct GPUShader; struct GPUTexture; struct GPUUniformBuf; struct Object; struct ParticleSystem; -struct RenderEngineType; -struct bContext; struct rcti; +struct RegionView3D; +struct RenderEngine; +struct RenderEngineType; +struct RenderLayer; +struct RenderResult; +struct SpaceLink; struct TaskGraph; +struct View3D; +struct ViewLayer; +struct World; namespace blender::draw { class TextureFromPool; } // namespace blender::draw diff --git a/source/blender/draw/intern/draw_cache.cc b/source/blender/draw/intern/draw_cache.cc index 792cc9d5500e..cea7a7d2922f 100644 --- a/source/blender/draw/intern/draw_cache.cc +++ b/source/blender/draw/intern/draw_cache.cc @@ -11,7 +11,6 @@ #include "DNA_grease_pencil_types.h" #include "DNA_lattice_types.h" #include "DNA_mesh_types.h" -#include "DNA_meta_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_particle_types.h" @@ -21,17 +20,18 @@ #include "UI_resources.hh" +#include "BLI_ghash.h" +#include "BLI_string.h" #include "BLI_utildefines.h" +#include "BKE_context.hh" +#include "BKE_material.hh" #include "BKE_object.hh" -#include "BKE_paint.hh" #include "GPU_batch.hh" #include "GPU_batch_utils.hh" #include "GPU_capabilities.hh" -#include "MEM_guardedalloc.h" - #include "draw_cache.hh" #include "draw_cache_impl.hh" #include "draw_manager_c.hh" diff --git a/source/blender/draw/intern/draw_cache.hh b/source/blender/draw/intern/draw_cache.hh index 0f52fb4e1421..cbea353bb9ae 100644 --- a/source/blender/draw/intern/draw_cache.hh +++ b/source/blender/draw/intern/draw_cache.hh @@ -9,10 +9,12 @@ #pragma once #include "BLI_math_matrix_types.hh" +#include "BLI_span.hh" #include "BKE_volume_grid_fwd.hh" struct GPUMaterial; +struct GPUTexture; namespace blender::gpu { class Batch; class VertBuf; diff --git a/source/blender/draw/intern/draw_cache_extract.hh b/source/blender/draw/intern/draw_cache_extract.hh index 59bca0629a60..b89fe8febe06 100644 --- a/source/blender/draw/intern/draw_cache_extract.hh +++ b/source/blender/draw/intern/draw_cache_extract.hh @@ -8,9 +8,12 @@ #pragma once +#include "BLI_array.hh" #include "BLI_math_matrix_types.hh" #include "BLI_utildefines.h" +#include "DNA_view3d_enums.h" + #include "GPU_shader.hh" #include "draw_attributes.hh" @@ -19,7 +22,11 @@ namespace blender::gpu { class Batch; class IndexBuf; } // namespace blender::gpu +struct Mesh; +struct Object; +struct Scene; struct TaskGraph; +struct ToolSettings; namespace blender::draw { diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc b/source/blender/draw/intern/draw_cache_extract_mesh.cc index 7d5cf8ef2889..7e0c0abd1395 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc @@ -7,17 +7,11 @@ * * \brief Extraction of Mesh data into VBO to feed to GPU. */ -#include "MEM_guardedalloc.h" #include "DNA_mesh_types.h" #include "DNA_scene_types.h" -#include "BLI_array.hh" #include "BLI_task.h" -#include "BLI_vector.hh" - -#include "BKE_editmesh.hh" -#include "BKE_object.hh" #include "GPU_capabilities.hh" diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc index 42512da81869..78902d1c211c 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc @@ -8,13 +8,9 @@ * \brief Extraction of Mesh data into VBO to feed to GPU. */ -#include "MEM_guardedalloc.h" - #include "BLI_array.hh" #include "BLI_array_utils.hh" #include "BLI_enumerable_thread_specific.hh" -#include "BLI_index_mask.hh" -#include "BLI_math_matrix.h" #include "BLI_task.hh" #include "BLI_virtual_array.hh" @@ -23,11 +19,8 @@ #include "BKE_editmesh_cache.hh" #include "BKE_material.hh" #include "BKE_mesh.hh" -#include "BKE_mesh_runtime.hh" #include "BKE_object.hh" -#include "GPU_batch.hh" - #include "ED_mesh.hh" #include "mesh_extractors/extract_mesh.hh" diff --git a/source/blender/draw/intern/draw_cache_impl.hh b/source/blender/draw/intern/draw_cache_impl.hh index 8b26b894d6cc..b13323c6da84 100644 --- a/source/blender/draw/intern/draw_cache_impl.hh +++ b/source/blender/draw/intern/draw_cache_impl.hh @@ -8,6 +8,10 @@ #pragma once +#include + +#include "BLI_span.hh" + struct GPUMaterial; namespace blender::gpu { class Batch; @@ -23,11 +27,13 @@ struct Curve; struct Curves; struct Lattice; struct Mesh; +struct Object; +struct Scene; struct PointCloud; struct Volume; struct GreasePencil; -#include "BKE_mesh.h" +enum eMeshBatchDirtyMode : int8_t; namespace blender::draw { diff --git a/source/blender/draw/intern/draw_cache_impl_curve.cc b/source/blender/draw/intern/draw_cache_impl_curve.cc index dd38f48f1556..9c89a98f2879 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.cc +++ b/source/blender/draw/intern/draw_cache_impl_curve.cc @@ -10,27 +10,25 @@ #include "MEM_guardedalloc.h" -#include "BLI_array.hh" #include "BLI_color.hh" #include "BLI_listbase.h" #include "BLI_math_rotation.h" -#include "BLI_math_vector.h" #include "BLI_math_vector_types.hh" #include "BLI_span.hh" #include "BLI_utildefines.h" #include "DNA_curve_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BKE_curve.hh" #include "BKE_curves.hh" -#include "BKE_displist.h" #include "BKE_geometry_set.hh" #include "BKE_object_types.hh" #include "BKE_vfont.hh" #include "GPU_batch.hh" #include "GPU_capabilities.hh" -#include "GPU_material.hh" #include "GPU_texture.hh" #include "UI_resources.hh" diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 73703bbe54b6..1f2166a92a61 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -15,16 +15,15 @@ #include "BLI_array_utils.hh" #include "BLI_listbase.h" #include "BLI_math_base.h" -#include "BLI_math_matrix.hh" #include "BLI_math_vector.hh" #include "BLI_math_vector_types.hh" #include "BLI_span.hh" +#include "BLI_string.h" #include "BLI_task.hh" #include "BLI_utildefines.h" #include "DNA_curves_types.h" #include "DNA_object_types.h" -#include "DNA_scene_types.h" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc b/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc index 7e06fe4a8d05..489fe283d973 100644 --- a/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc +++ b/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc @@ -10,7 +10,6 @@ #include "BKE_attribute.hh" #include "BKE_curves.hh" -#include "BKE_deform.hh" #include "BKE_grease_pencil.h" #include "BKE_grease_pencil.hh" @@ -28,6 +27,7 @@ #include "GPU_batch.hh" +#include "draw_cache.hh" #include "draw_cache_impl.hh" #include "../engines/gpencil/gpencil_defines.h" diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.cc b/source/blender/draw/intern/draw_cache_impl_lattice.cc index 93f9578df30b..8b5b61f0adb7 100644 --- a/source/blender/draw/intern/draw_cache_impl_lattice.cc +++ b/source/blender/draw/intern/draw_cache_impl_lattice.cc @@ -10,13 +10,11 @@ #include "MEM_guardedalloc.h" -#include "BLI_math_vector.h" #include "BLI_utildefines.h" #include "DNA_curve_types.h" #include "DNA_lattice_types.h" #include "DNA_meshdata_types.h" -#include "DNA_userdef_types.h" #include "BKE_deform.hh" #include "BKE_lattice.hh" diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.cc b/source/blender/draw/intern/draw_cache_impl_mesh.cc index d8954c0a9f80..f53d69dac1ea 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.cc +++ b/source/blender/draw/intern/draw_cache_impl_mesh.cc @@ -8,23 +8,15 @@ * \brief Mesh API for render engines */ -#include #include #include "MEM_guardedalloc.h" -#include "BLI_bitmap.h" -#include "BLI_buffer.h" #include "BLI_index_range.hh" #include "BLI_listbase.h" -#include "BLI_map.hh" -#include "BLI_math_bits.h" -#include "BLI_math_vector.h" #include "BLI_span.hh" -#include "BLI_string.h" #include "BLI_string_ref.hh" #include "BLI_task.h" -#include "BLI_utildefines.h" #include "DEG_depsgraph_query.hh" // UPBGE @@ -34,14 +26,9 @@ #include "BKE_attribute.hh" #include "BKE_customdata.hh" -#include "BKE_deform.hh" #include "BKE_editmesh.hh" -#include "BKE_editmesh_cache.hh" -#include "BKE_editmesh_tangent.hh" +#include "BKE_material.hh" #include "BKE_mesh.hh" -#include "BKE_mesh_runtime.hh" -#include "BKE_mesh_tangent.hh" -#include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_deform.h" #include "BKE_paint.hh" @@ -50,16 +37,11 @@ #include "atomic_ops.h" -#include "bmesh.hh" - #include "GPU_batch.hh" #include "GPU_material.hh" #include "DRW_render.hh" -#include "ED_mesh.hh" -#include "ED_uvedit.hh" - #include "draw_cache_extract.hh" #include "draw_cache_inline.hh" #include "draw_subdivision.hh" diff --git a/source/blender/draw/intern/draw_cache_impl_particles.cc b/source/blender/draw/intern/draw_cache_impl_particles.cc index 0f988455b5b2..7f4848230279 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.cc +++ b/source/blender/draw/intern/draw_cache_impl_particles.cc @@ -13,7 +13,6 @@ #include "MEM_guardedalloc.h" #include "BLI_alloca.h" -#include "BLI_ghash.h" #include "BLI_math_color.h" #include "BLI_math_vector.h" #include "BLI_string.h" @@ -35,7 +34,6 @@ #include "GPU_batch.hh" #include "GPU_capabilities.hh" -#include "GPU_context.hh" #include "GPU_material.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/draw/intern/draw_cache_impl_pointcloud.cc b/source/blender/draw/intern/draw_cache_impl_pointcloud.cc index 7c939bca1135..e7106ce81a6f 100644 --- a/source/blender/draw/intern/draw_cache_impl_pointcloud.cc +++ b/source/blender/draw/intern/draw_cache_impl_pointcloud.cc @@ -12,10 +12,8 @@ #include "MEM_guardedalloc.h" +#include "BLI_color.hh" #include "BLI_listbase.h" -#include "BLI_math_base.h" -#include "BLI_math_color.hh" -#include "BLI_math_vector.h" #include "BLI_task.hh" #include "BLI_utildefines.h" diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 286c47cc0fec..d4557266331d 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -12,9 +12,7 @@ #include "BKE_editmesh.hh" #include "BKE_mesh.hh" #include "BKE_mesh_mapping.hh" -#include "BKE_modifier.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" #include "BKE_subdiv.hh" #include "BKE_subdiv_eval.hh" #include "BKE_subdiv_foreach.hh" @@ -22,9 +20,7 @@ #include "BKE_subdiv_modifier.hh" #include "BLI_linklist.h" -#include "BLI_string.h" -#include "BLI_string_utils.hh" -#include "BLI_time.h" +#include "BLI_threads.h" #include "BLI_virtual_array.hh" #include "DRW_engine.hh" diff --git a/source/blender/draw/intern/draw_cache_impl_volume.cc b/source/blender/draw/intern/draw_cache_impl_volume.cc index 9e9c600355e0..d0adcf23ff85 100644 --- a/source/blender/draw/intern/draw_cache_impl_volume.cc +++ b/source/blender/draw/intern/draw_cache_impl_volume.cc @@ -13,12 +13,11 @@ #include "MEM_guardedalloc.h" #include "BLI_listbase.h" -#include "BLI_math_base.h" #include "BLI_math_matrix.hh" -#include "BLI_math_vector.h" +#include "BLI_string.h" #include "BLI_utildefines.h" -#include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_volume_types.h" #include "BKE_global.hh" @@ -30,8 +29,6 @@ #include "GPU_capabilities.hh" #include "GPU_texture.hh" -#include "DEG_depsgraph_query.hh" - #include "DRW_render.hh" #include "draw_cache.hh" /* own include */ diff --git a/source/blender/draw/intern/draw_cache_inline.hh b/source/blender/draw/intern/draw_cache_inline.hh index dbe8ab283eaa..20c89953942e 100644 --- a/source/blender/draw/intern/draw_cache_inline.hh +++ b/source/blender/draw/intern/draw_cache_inline.hh @@ -9,7 +9,6 @@ #pragma once #include "GPU_batch.hh" -#include "MEM_guardedalloc.h" /* Common */ // #define DRW_DEBUG_MESH_CACHE_REQUEST diff --git a/source/blender/draw/intern/draw_color_management.cc b/source/blender/draw/intern/draw_color_management.cc index 193324e9d7b5..6f60d58cc9a7 100644 --- a/source/blender/draw/intern/draw_color_management.cc +++ b/source/blender/draw/intern/draw_color_management.cc @@ -6,20 +6,18 @@ * \ingroup draw */ -#include "draw_manager_c.hh" +#include "GPU_viewport.hh" -#include "DRW_render.hh" +#include "BLI_string.h" -#include "GPU_batch.hh" -#include "GPU_framebuffer.hh" -#include "GPU_matrix.hh" -#include "GPU_texture.hh" +#include "DRW_render.hh" #include "DNA_space_types.h" #include "DNA_view3d_types.h" #include "BKE_colortools.hh" #include "BKE_image.hh" +#include "BKE_scene.hh" #include "DEG_depsgraph_query.hh" @@ -108,13 +106,11 @@ static eDRWColorManagementType drw_color_management_type_get(Main *bmain, if (space_data) { switch (space_data->spacetype) { case SPACE_IMAGE: { - const SpaceImage *sima = static_cast( - static_cast(space_data)); + const SpaceImage *sima = reinterpret_cast(space_data); return drw_color_management_type_for_space_image(*sima); } case SPACE_NODE: { - const SpaceNode *snode = static_cast( - static_cast(space_data)); + const SpaceNode *snode = reinterpret_cast(space_data); return drw_color_management_type_for_space_node(*bmain, *snode); } } diff --git a/source/blender/draw/intern/draw_common.cc b/source/blender/draw/intern/draw_common.cc index f1743965fad1..475f8ec9c88b 100644 --- a/source/blender/draw/intern/draw_common.cc +++ b/source/blender/draw/intern/draw_common.cc @@ -6,20 +6,20 @@ * \ingroup draw */ +#include "DNA_texture_types.h" +#include "DNA_view3d_types.h" #include "DRW_render.hh" -#include "GPU_matrix.hh" -#include "GPU_shader.hh" #include "GPU_texture.hh" +#include "GPU_uniform_buffer.hh" #include "UI_resources.hh" #include "BLI_index_range.hh" #include "BLI_math_color.h" +#include "BLI_math_vector.h" #include "BKE_colorband.hh" -#include "BKE_global.hh" -#include "BKE_object.hh" #include "draw_common_c.hh" diff --git a/source/blender/draw/intern/draw_curves.cc b/source/blender/draw/intern/draw_curves.cc index d2669f571abb..5de672af2e07 100644 --- a/source/blender/draw/intern/draw_curves.cc +++ b/source/blender/draw/intern/draw_curves.cc @@ -8,7 +8,6 @@ * \brief Contains procedural GPU hair drawing methods. */ -#include "BLI_string_utils.hh" #include "BLI_utildefines.h" #include "DNA_curves_types.h" @@ -19,7 +18,6 @@ #include "GPU_batch.hh" #include "GPU_capabilities.hh" -#include "GPU_compute.hh" #include "GPU_material.hh" #include "GPU_shader.hh" #include "GPU_texture.hh" diff --git a/source/blender/draw/intern/draw_debug.cc b/source/blender/draw/intern/draw_debug.cc index f171e965f7c5..c6d6e6891487 100644 --- a/source/blender/draw/intern/draw_debug.cc +++ b/source/blender/draw/intern/draw_debug.cc @@ -9,10 +9,9 @@ */ #include "BKE_object.hh" -#include "BLI_link_utils.h" +#include "BLI_math_matrix.h" #include "BLI_math_matrix.hh" #include "GPU_batch.hh" -#include "GPU_capabilities.hh" #include "GPU_debug.hh" #include "draw_debug.hh" @@ -21,9 +20,6 @@ #include "draw_shader.hh" #include "draw_shader_shared.hh" -#include -#include - #if defined(_DEBUG) || defined(WITH_DRAW_DEBUG) # define DRAW_DEBUG #else diff --git a/source/blender/draw/intern/draw_debug.hh b/source/blender/draw/intern/draw_debug.hh index a935c0dc5beb..3ce97a2ca26e 100644 --- a/source/blender/draw/intern/draw_debug.hh +++ b/source/blender/draw/intern/draw_debug.hh @@ -17,7 +17,11 @@ #include "BLI_math_vector_types.hh" #include "BLI_vector.hh" + #include "DNA_object_types.h" + +#include "draw_shader_shared.hh" + #include "DRW_gpu_wrapper.hh" namespace blender::draw { diff --git a/source/blender/draw/intern/draw_hair.cc b/source/blender/draw/intern/draw_hair.cc index 6e675da3beac..b39680afa81a 100644 --- a/source/blender/draw/intern/draw_hair.cc +++ b/source/blender/draw/intern/draw_hair.cc @@ -10,11 +10,9 @@ #include "DRW_render.hh" -#include "BLI_string_utils.hh" -#include "BLI_utildefines.h" +#include "BLI_math_matrix.h" #include "DNA_collection_types.h" -#include "DNA_customdata_types.h" #include "DNA_modifier_types.h" #include "DNA_particle_types.h" @@ -22,8 +20,6 @@ #include "GPU_batch.hh" #include "GPU_capabilities.hh" -#include "GPU_compute.hh" -#include "GPU_context.hh" #include "GPU_material.hh" #include "GPU_shader.hh" #include "GPU_texture.hh" @@ -31,6 +27,7 @@ #include "DRW_gpu_wrapper.hh" +#include "draw_common_c.hh" #include "draw_hair_private.hh" #include "draw_manager.hh" #include "draw_shader.hh" diff --git a/source/blender/draw/intern/draw_instance_data.cc b/source/blender/draw/intern/draw_instance_data.cc index d192ad595fdb..0a188b17a92e 100644 --- a/source/blender/draw/intern/draw_instance_data.cc +++ b/source/blender/draw/intern/draw_instance_data.cc @@ -16,24 +16,13 @@ */ #include "draw_instance_data.hh" -#include "draw_manager_c.hh" #include "DRW_engine.hh" #include "DRW_render.hh" /* For DRW_shgroup_get_instance_count() */ -#include "GPU_material.hh" - -#include "DNA_particle_types.h" - -#include "BKE_duplilist.hh" - -#include "RNA_access.hh" -#include "RNA_path.hh" - -#include "BLI_bitmap.h" -#include "BLI_memblock.h" +#include "BLI_listbase.h" #include "BLI_mempool.h" -#include "BLI_utildefines.h" + #include "MEM_guardedalloc.h" struct DRWInstanceData { diff --git a/source/blender/draw/intern/draw_manager.cc b/source/blender/draw/intern/draw_manager.cc index 41b51af199dc..4eb8da24b2a2 100644 --- a/source/blender/draw/intern/draw_manager.cc +++ b/source/blender/draw/intern/draw_manager.cc @@ -6,21 +6,17 @@ * \ingroup draw */ -#include "BKE_global.hh" #include "BKE_paint.hh" #include "BKE_paint_bvh.hh" #include "BLI_math_base.h" #include "GPU_compute.hh" -#include "draw_debug.hh" #include "draw_defines.hh" #include "draw_manager.hh" #include "draw_manager_c.hh" #include "draw_pass.hh" #include "draw_shader.hh" -#include -#include namespace blender::draw { diff --git a/source/blender/draw/intern/draw_manager_c.cc b/source/blender/draw/intern/draw_manager_c.cc index cda678969b59..6c066dd0a1e6 100644 --- a/source/blender/draw/intern/draw_manager_c.cc +++ b/source/blender/draw/intern/draw_manager_c.cc @@ -10,9 +10,8 @@ #include "CLG_log.h" -#include "BLI_alloca.h" #include "BLI_listbase.h" -#include "BLI_memblock.h" +#include "BLI_math_matrix.h" #include "BLI_rect.h" #include "BLI_string.h" #include "BLI_task.h" @@ -31,6 +30,7 @@ #include "BKE_gpencil_legacy.h" #include "BKE_grease_pencil.h" #include "BKE_lattice.hh" +#include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_mball.hh" #include "BKE_mesh.hh" @@ -41,9 +41,9 @@ #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_pointcloud.hh" +#include "BKE_scene.hh" #include "BKE_screen.hh" #include "BKE_subdiv_modifier.hh" -#include "BKE_viewer_path.hh" #include "BKE_volume.hh" #include "DNA_camera_types.h" @@ -59,7 +59,6 @@ #include "GPU_capabilities.hh" #include "GPU_framebuffer.hh" -#include "GPU_immediate.hh" #include "GPU_matrix.hh" #include "GPU_platform.hh" #include "GPU_shader_shared.hh" @@ -76,14 +75,16 @@ #include "WM_api.hh" #include "wm_window.hh" +#include "draw_cache.hh" #include "draw_color_management.hh" +#include "draw_common_c.hh" #include "draw_manager_c.hh" #include "draw_manager_profiling.hh" -#include "draw_manager_testing.hh" #include "draw_manager_text.hh" #include "draw_shader.hh" #include "draw_subdivision.hh" #include "draw_texture_pool.hh" +#include "draw_view_c.hh" /* only for callbacks */ #include "draw_cache_impl.hh" @@ -102,6 +103,8 @@ #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" +#include "BLI_time.h" + #include "DRW_select_buffer.hh" static CLG_LogRef LOG = {"draw.manager"}; diff --git a/source/blender/draw/intern/draw_manager_c.hh b/source/blender/draw/intern/draw_manager_c.hh index 2f154c8e6f54..c7c9982e2edb 100644 --- a/source/blender/draw/intern/draw_manager_c.hh +++ b/source/blender/draw/intern/draw_manager_c.hh @@ -20,17 +20,18 @@ #include "GPU_context.hh" #include "GPU_framebuffer.hh" #include "GPU_shader.hh" -#include "GPU_uniform_buffer.hh" #include "GPU_viewport.hh" #include "draw_instance_data.hh" -#include "draw_shader_shared.hh" struct DRWDebugModule; struct DRWTexturePool; struct DRWUniformChunk; +struct DRWViewData; +struct DRWTextStore; struct DupliObject; struct Object; +struct Mesh; namespace blender::draw { struct CurvesUniformBufPool; struct DRW_Attributes; @@ -39,6 +40,7 @@ class CurveRefinePass; class View; } // namespace blender::draw struct GPUMaterial; +struct GSet; /** Use draw manager to call GPU_select, see: #DRW_draw_select_loop */ #define USE_GPU_SELECT @@ -57,7 +59,6 @@ struct GPUMaterial; #define USE_PROFILE #ifdef USE_PROFILE -# include "BLI_time.h" # define PROFILE_TIMER_FALLOFF 0.04 diff --git a/source/blender/draw/intern/draw_manager_profiling.cc b/source/blender/draw/intern/draw_manager_profiling.cc index 46417141f584..627ad43f0fc7 100644 --- a/source/blender/draw/intern/draw_manager_profiling.cc +++ b/source/blender/draw/intern/draw_manager_profiling.cc @@ -8,8 +8,6 @@ #include -#include "BLI_listbase.h" -#include "BLI_rect.h" #include "BLI_string.h" #include "BKE_global.hh" @@ -26,6 +24,7 @@ #include "UI_resources.hh" #include "draw_manager_profiling.hh" +#include "draw_view_data.hh" #define MAX_TIMER_NAME 32 #define MAX_NESTED_TIMER 8 diff --git a/source/blender/draw/intern/draw_manager_shader.cc b/source/blender/draw/intern/draw_manager_shader.cc index 3e42b7ea8361..fd99598f4e16 100644 --- a/source/blender/draw/intern/draw_manager_shader.cc +++ b/source/blender/draw/intern/draw_manager_shader.cc @@ -7,30 +7,17 @@ */ #include "DNA_material_types.h" -#include "DNA_object_types.h" #include "DNA_world_types.h" -#include "BLI_dynstr.h" -#include "BLI_listbase.h" -#include "BLI_map.hh" -#include "BLI_string_utils.hh" #include "BLI_threads.h" #include "BLI_time.h" -#include "BKE_context.hh" -#include "BKE_global.hh" -#include "BKE_main.hh" - #include "DEG_depsgraph_query.hh" #include "GPU_capabilities.hh" #include "GPU_material.hh" -#include "GPU_shader.hh" #include "WM_api.hh" -#include "WM_types.hh" - -#include "wm_window.hh" #include "draw_manager_c.hh" diff --git a/source/blender/draw/intern/draw_manager_text.cc b/source/blender/draw/intern/draw_manager_text.cc index 2a196c98cb3e..18e93ee9851d 100644 --- a/source/blender/draw/intern/draw_manager_text.cc +++ b/source/blender/draw/intern/draw_manager_text.cc @@ -8,6 +8,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_math_color.h" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" #include "BLI_math_matrix.hh" @@ -35,7 +36,6 @@ #include "GPU_matrix.hh" #include "GPU_state.hh" -#include "ED_screen.hh" #include "ED_view3d.hh" #include "UI_interface.hh" diff --git a/source/blender/draw/intern/draw_pointcloud.cc b/source/blender/draw/intern/draw_pointcloud.cc index 3dad271ba413..4d489d2351f6 100644 --- a/source/blender/draw/intern/draw_pointcloud.cc +++ b/source/blender/draw/intern/draw_pointcloud.cc @@ -6,23 +6,16 @@ * \ingroup draw */ -#include "BLI_string_utils.hh" -#include "BLI_utildefines.h" - #include "DNA_pointcloud_types.h" #include "GPU_batch.hh" -#include "GPU_capabilities.hh" -#include "GPU_compute.hh" #include "GPU_material.hh" #include "GPU_shader.hh" #include "GPU_texture.hh" #include "GPU_vertex_buffer.hh" -#include "DRW_gpu_wrapper.hh" #include "DRW_render.hh" -#include "draw_attributes.hh" #include "draw_cache_impl.hh" #include "draw_common.hh" #include "draw_common_c.hh" diff --git a/source/blender/draw/intern/draw_resource.cc b/source/blender/draw/intern/draw_resource.cc index 40c1e9b4261c..c983909a89ea 100644 --- a/source/blender/draw/intern/draw_resource.cc +++ b/source/blender/draw/intern/draw_resource.cc @@ -6,13 +6,10 @@ * \ingroup draw */ -#include "DNA_particle_types.h" -#include "RNA_access.hh" -#include "RNA_path.hh" -#include "RNA_types.hh" +#include "BKE_duplilist.hh" +#include "GPU_material.hh" #include "draw_handle.hh" -#include "draw_manager.hh" #include "draw_shader_shared.hh" /* -------------------------------------------------------------------- */ diff --git a/source/blender/draw/intern/draw_resource.hh b/source/blender/draw/intern/draw_resource.hh index 4ab7f1e7da5c..25ca9e916ce2 100644 --- a/source/blender/draw/intern/draw_resource.hh +++ b/source/blender/draw/intern/draw_resource.hh @@ -26,7 +26,6 @@ #include "DNA_object_types.h" #include "draw_handle.hh" -#include "draw_manager.hh" #include "draw_shader_shared.hh" /* -------------------------------------------------------------------- */ diff --git a/source/blender/draw/intern/draw_sculpt.cc b/source/blender/draw/intern/draw_sculpt.cc index 20e905fdd389..52e2d289b86b 100644 --- a/source/blender/draw/intern/draw_sculpt.cc +++ b/source/blender/draw/intern/draw_sculpt.cc @@ -8,14 +8,19 @@ #include "draw_sculpt.hh" +#include "DNA_mesh_types.h" #include "draw_attributes.hh" +#include "draw_view.hh" #include "BKE_attribute.hh" #include "BKE_customdata.hh" -#include "BKE_mesh_types.hh" +#include "BKE_object.hh" #include "BKE_paint.hh" +#include "BLI_math_matrix.hh" + #include "DRW_pbvh.hh" +#include "DRW_render.hh" namespace blender::draw { diff --git a/source/blender/draw/intern/draw_sculpt.hh b/source/blender/draw/intern/draw_sculpt.hh index 69e6d9216c6c..1ea3f391e171 100644 --- a/source/blender/draw/intern/draw_sculpt.hh +++ b/source/blender/draw/intern/draw_sculpt.hh @@ -8,7 +8,14 @@ #pragma once -#include "draw_manager.hh" +#include "BLI_math_vector_types.hh" +#include "BLI_vector.hh" + +struct GPUMaterial; +struct Object; +namespace blender::gpu { +class Batch; +} namespace blender::draw { diff --git a/source/blender/draw/intern/draw_select_buffer.cc b/source/blender/draw/intern/draw_select_buffer.cc index 3b0d311dd485..8adb01ef56d3 100644 --- a/source/blender/draw/intern/draw_select_buffer.cc +++ b/source/blender/draw/intern/draw_select_buffer.cc @@ -8,25 +8,30 @@ * Utilities to read id buffer created in select_engine. */ +#include + #include "MEM_guardedalloc.h" #include "BLI_array_utils.h" #include "BLI_bitmap.h" #include "BLI_bitmap_draw_2d.h" +#include "BLI_math_matrix.h" #include "BLI_rect.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "DNA_view3d_types.h" +#include "GPU_framebuffer.hh" #include "GPU_select.hh" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" #include "DRW_engine.hh" +#include "DRW_render.hh" #include "DRW_select_buffer.hh" -#include "draw_manager_c.hh" - #include "../engines/select/select_engine.hh" using blender::int2; diff --git a/source/blender/draw/intern/draw_shader.cc b/source/blender/draw/intern/draw_shader.cc index 22ebffdd4c16..4513d13576ae 100644 --- a/source/blender/draw/intern/draw_shader.cc +++ b/source/blender/draw/intern/draw_shader.cc @@ -8,12 +8,7 @@ #include "DRW_render.hh" -#include "BLI_dynstr.h" -#include "BLI_string_utils.hh" - #include "GPU_batch.hh" -#include "GPU_index_buffer.hh" -#include "GPU_vertex_buffer.hh" #include "draw_shader.hh" diff --git a/source/blender/draw/intern/draw_view.cc b/source/blender/draw/intern/draw_view.cc index b32e31f4188a..ab19cedf1dc1 100644 --- a/source/blender/draw/intern/draw_view.cc +++ b/source/blender/draw/intern/draw_view.cc @@ -7,7 +7,9 @@ */ #include "BLI_math_geom.h" +#include "BLI_math_matrix.h" #include "BLI_math_matrix.hh" + #include "GPU_compute.hh" #include "GPU_debug.hh" diff --git a/source/blender/draw/intern/draw_view.hh b/source/blender/draw/intern/draw_view.hh index c6a869707b9c..9632960f656f 100644 --- a/source/blender/draw/intern/draw_view.hh +++ b/source/blender/draw/intern/draw_view.hh @@ -17,7 +17,6 @@ * setting `drw_view_id` accordingly. */ -#include "DNA_view3d_types.h" #include "DRW_gpu_wrapper.hh" #include "GPU_matrix.hh" diff --git a/source/blender/draw/intern/draw_view_c.cc b/source/blender/draw/intern/draw_view_c.cc index 446bcbbf7583..27714ee33abf 100644 --- a/source/blender/draw/intern/draw_view_c.cc +++ b/source/blender/draw/intern/draw_view_c.cc @@ -14,7 +14,6 @@ #include "DNA_view3d_types.h" #include "ED_screen.hh" -#include "ED_util.hh" #include "ED_view3d.hh" #include "GPU_debug.hh" @@ -34,9 +33,13 @@ #include "BKE_paint.hh" #include "BKE_screen.hh" -#include "view3d_intern.hh" +#include "DRW_engine.hh" +#include "DRW_render.hh" + +#include "draw_cache.hh" +#include "draw_view_c.hh" -#include "draw_manager_c.hh" +#include "view3d_intern.hh" /* ******************** region info ***************** */ diff --git a/source/blender/draw/intern/draw_view_data.cc b/source/blender/draw/intern/draw_view_data.cc index 4be0028b6dd8..57d0e8b3b412 100644 --- a/source/blender/draw/intern/draw_view_data.cc +++ b/source/blender/draw/intern/draw_view_data.cc @@ -10,14 +10,11 @@ #include "BLI_vector.hh" -#include "GPU_capabilities.hh" #include "GPU_viewport.hh" #include "DRW_gpu_wrapper.hh" #include "DRW_render.hh" -#include "draw_instance_data.hh" - #include "draw_manager_text.hh" #include "draw_manager.hh" diff --git a/source/blender/draw/intern/draw_volume.cc b/source/blender/draw/intern/draw_volume.cc index b3415175b0d6..eb9300ee1a39 100644 --- a/source/blender/draw/intern/draw_volume.cc +++ b/source/blender/draw/intern/draw_volume.cc @@ -14,7 +14,8 @@ #include "DNA_fluid_types.h" #include "DNA_volume_types.h" -#include "BKE_fluid.h" +#include "BLI_string.h" + #include "BKE_global.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" @@ -23,6 +24,7 @@ #include "GPU_material.hh" +#include "draw_cache.hh" #include "draw_common_c.hh" #include "draw_manager_c.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh.cc index 8bf0b6a3ac02..833df94f3696 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh.cc @@ -8,10 +8,7 @@ * \brief Extraction of Mesh data into VBO to feed to GPU. */ -#include "MEM_guardedalloc.h" - #include "DNA_meshdata_types.h" -#include "DNA_object_types.h" #include "ED_uvedit.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc index fddc24efd8b6..e70d55adc9fe 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc @@ -8,7 +8,6 @@ #include "BLI_map.hh" #include "BLI_ordered_edge.hh" -#include "BLI_vector.hh" #include "BKE_editmesh.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc index 7cc1fe7862a2..aab6c40ae2b1 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc @@ -6,8 +6,6 @@ * \ingroup draw */ -#include "BLI_array_utils.hh" - #include "GPU_index_buffer.hh" #include "draw_subdivision.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc index 04daab3e41df..8cf3332b123d 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc @@ -6,10 +6,7 @@ * \ingroup draw */ -#include "MEM_guardedalloc.h" - #include "BLI_array_utils.hh" -#include "BLI_math_vector_types.hh" #include "BLI_string.h" #include "BKE_attribute.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc index 84f406187bcb..b3e088cac9ff 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc @@ -8,8 +8,6 @@ #include "BLI_math_vector_types.hh" -#include "MEM_guardedalloc.h" - #include "BKE_attribute.hh" #include "BKE_mesh.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc index 1919347f6738..10fb18dd69cd 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc @@ -6,10 +6,7 @@ * \ingroup draw */ -#include "MEM_guardedalloc.h" - #include "BLI_array_utils.hh" -#include "BLI_string.h" #include "BKE_attribute.hh" #include "BKE_mesh.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc index 14fd5c267cbd..bc0df880b088 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc @@ -6,11 +6,8 @@ * \ingroup draw */ -#include "MEM_guardedalloc.h" - #include "BLI_string.h" -#include "BKE_editmesh.hh" #include "BKE_editmesh_tangent.hh" #include "BKE_mesh.hh" #include "BKE_mesh_tangent.hh" diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc index a8b87bf47808..b4ca93c4d4f6 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc @@ -11,7 +11,6 @@ #include "BLI_array_utils.hh" #include "BKE_deform.hh" -#include "BKE_mesh.hh" #include "draw_subdivision.hh" #include "extract_mesh.hh" diff --git a/source/blender/editors/armature/pose_lib_2.cc b/source/blender/editors/armature/pose_lib_2.cc index 28794356888d..60f886b37456 100644 --- a/source/blender/editors/armature/pose_lib_2.cc +++ b/source/blender/editors/armature/pose_lib_2.cc @@ -535,21 +535,19 @@ static int poselib_blend_modal(bContext *C, wmOperator *op, const wmEvent *event } if (pbd->needs_redraw) { - char status_string[UI_MAX_DRAW_STR]; - char slider_string[UI_MAX_DRAW_STR]; - char tab_string[50]; - ED_slider_status_string_get(pbd->slider, slider_string, sizeof(slider_string)); + WorkspaceStatus status(C); if (pbd->state == POSE_BLEND_BLENDING) { - STRNCPY(tab_string, IFACE_("[Tab] - Show original pose")); + status.item(IFACE_("Show Original Pose"), ICON_EVENT_TAB); } else { - STRNCPY(tab_string, IFACE_("[Tab] - Show blended pose")); + status.item(IFACE_("Show Blended Pose"), ICON_EVENT_TAB); } - SNPRINTF(status_string, IFACE_("%s | %s | [Ctrl] - Flip Pose"), tab_string, slider_string); - ED_workspace_status_text(C, status_string); + ED_slider_status_get(pbd->slider, status); + + status.item_bool(IFACE_("Flip Pose"), pbd->is_flipped, ICON_EVENT_CTRL); poselib_blend_apply(C, op); } diff --git a/source/blender/editors/gpencil_legacy/annotate_paint.cc b/source/blender/editors/gpencil_legacy/annotate_paint.cc index e1615f27a0db..62b7ea83b08a 100644 --- a/source/blender/editors/gpencil_legacy/annotate_paint.cc +++ b/source/blender/editors/gpencil_legacy/annotate_paint.cc @@ -31,6 +31,7 @@ #include "DNA_scene_types.h" #include "DNA_windowmanager_types.h" +#include "UI_resources.hh" #include "UI_view2d.hh" #include "ED_clip.hh" @@ -1949,62 +1950,39 @@ static void annotation_draw_cursor_set(tGPsdata *p) /* update UI indicators of status, including cursor and header prints */ static void annotation_draw_status_indicators(bContext *C, tGPsdata *p) { + WorkspaceStatus status(C); + /* header prints */ switch (p->status) { case GP_STATUS_PAINTING: switch (p->paintmode) { case GP_PAINTMODE_DRAW_POLY: - /* Provide usage tips, since this is modal, and unintuitive without hints */ - ED_workspace_status_text( - C, - IFACE_("Annotation Create Poly: LMB click to place next stroke vertex | " - "ESC/Enter to end (or click outside this area)")); - break; - default: - /* Do nothing - the others are self explanatory, exit quickly once the mouse is - * released Showing any text would just be annoying as it would flicker. - */ + status.item(IFACE_("End"), ICON_EVENT_ESC); + status.item(IFACE_("Place Next Stroke Vertex"), ICON_MOUSE_LMB); break; - } - break; - - case GP_STATUS_IDLING: - /* print status info */ - switch (p->paintmode) { case GP_PAINTMODE_ERASER: - ED_workspace_status_text(C, - IFACE_("Annotation Eraser: Hold and drag LMB or RMB to erase | " - "ESC/Enter to end (or click outside this area)")); + status.item(IFACE_("End"), ICON_EVENT_ESC); + status.item(IFACE_("Erase"), ICON_MOUSE_LMB); break; case GP_PAINTMODE_DRAW_STRAIGHT: - ED_workspace_status_text(C, - IFACE_("Annotation Line Draw: Hold and drag LMB to draw | " - "ESC/Enter to end (or click outside this area)")); + status.item(IFACE_("End"), ICON_EVENT_ESC); + status.item(IFACE_("Draw"), ICON_MOUSE_LMB); break; case GP_PAINTMODE_DRAW: - ED_workspace_status_text(C, - IFACE_("Annotation Freehand Draw: Hold and drag LMB to draw | " - "E/ESC/Enter to end (or click outside this area)")); - break; - case GP_PAINTMODE_DRAW_POLY: - ED_workspace_status_text( - C, - IFACE_("Annotation Create Poly: LMB click to place next stroke vertex | " - "ESC/Enter to end (or click outside this area)")); + status.item(IFACE_("End"), ICON_EVENT_ESC); + status.item(IFACE_("Draw"), ICON_MOUSE_LMB); break; default: /* unhandled future cases */ - ED_workspace_status_text( - C, IFACE_("Annotation Session: ESC/Enter to end (or click outside this area)")); + status.item(IFACE_("End"), ICON_EVENT_ESC); break; } break; + case GP_STATUS_IDLING: case GP_STATUS_ERROR: case GP_STATUS_DONE: case GP_STATUS_CAPTURE: - /* clear status string */ - ED_workspace_status_text(C, nullptr); break; } } diff --git a/source/blender/editors/include/ED_screen.hh b/source/blender/editors/include/ED_screen.hh index 56abdfd1d877..cea8461a6f51 100644 --- a/source/blender/editors/include/ED_screen.hh +++ b/source/blender/editors/include/ED_screen.hh @@ -210,7 +210,7 @@ void ED_area_and_region_types_init(ScrArea *area); /** * Called in screen_refresh, or screens_init, also area size changes. */ -void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area); +void ED_area_init(bContext *C, const wmWindow *win, ScrArea *area); void ED_area_exit(bContext *C, ScrArea *area); blender::StringRefNull ED_area_name(const ScrArea *area); int ED_area_icon(const ScrArea *area); diff --git a/source/blender/editors/include/ED_util.hh b/source/blender/editors/include/ED_util.hh index da57cf1c943a..29b7bd52a862 100644 --- a/source/blender/editors/include/ED_util.hh +++ b/source/blender/editors/include/ED_util.hh @@ -12,6 +12,7 @@ struct Main; struct bContext; +class WorkspaceStatus; namespace blender::bke::id { class IDRemapper; @@ -86,6 +87,8 @@ void ED_slider_status_string_get(const tSlider *slider, char *status_string, size_t size_of_status_string); +void ED_slider_status_get(const tSlider *slider, WorkspaceStatus &status); + float ED_slider_factor_get(const tSlider *slider); void ED_slider_factor_set(tSlider *slider, float factor); diff --git a/source/blender/editors/mesh/editmesh_knife.cc b/source/blender/editors/mesh/editmesh_knife.cc index ba7ea3532b53..3af7969a2c17 100644 --- a/source/blender/editors/mesh/editmesh_knife.cc +++ b/source/blender/editors/mesh/editmesh_knife.cc @@ -3862,7 +3862,7 @@ static void knifetool_undo(KnifeTool_OpData *kcd) } } - if (kcd->mode == MODE_DRAGGING) { + if (ELEM(kcd->mode, MODE_DRAGGING, MODE_IDLE)) { /* Restore kcd->prev. */ kcd->prev = undo->pos; } @@ -3918,14 +3918,14 @@ static void knife_init_colors(KnifeColors *colors) /* Possible BMESH_TODO: add explicit themes or calculate these by * figuring out contrasting colors with grid / edges / verts * a la UI_make_axis_color. */ - UI_GetThemeColorType3ubv(TH_NURB_VLINE, SPACE_VIEW3D, colors->line); - UI_GetThemeColorType3ubv(TH_NURB_ULINE, SPACE_VIEW3D, colors->edge); - UI_GetThemeColorType3ubv(TH_NURB_SEL_ULINE, SPACE_VIEW3D, colors->edge_extra); - UI_GetThemeColorType3ubv(TH_HANDLE_SEL_VECT, SPACE_VIEW3D, colors->curpoint); - UI_GetThemeColorType3ubv(TH_HANDLE_SEL_VECT, SPACE_VIEW3D, colors->curpoint_a); + UI_GetThemeColorType3ubv(TH_GIZMO_PRIMARY, SPACE_VIEW3D, colors->line); + UI_GetThemeColorType3ubv(TH_GIZMO_A, SPACE_VIEW3D, colors->edge); + UI_GetThemeColorType3ubv(TH_GIZMO_B, SPACE_VIEW3D, colors->edge_extra); + UI_GetThemeColorType3ubv(TH_GIZMO_SECONDARY, SPACE_VIEW3D, colors->curpoint); + UI_GetThemeColorType3ubv(TH_GIZMO_SECONDARY, SPACE_VIEW3D, colors->curpoint_a); colors->curpoint_a[3] = 102; - UI_GetThemeColorType3ubv(TH_ACTIVE_SPLINE, SPACE_VIEW3D, colors->point); - UI_GetThemeColorType3ubv(TH_ACTIVE_SPLINE, SPACE_VIEW3D, colors->point_a); + UI_GetThemeColorType3ubv(TH_VERTEX, SPACE_VIEW3D, colors->point); + UI_GetThemeColorType3ubv(TH_VERTEX, SPACE_VIEW3D, colors->point_a); colors->point_a[3] = 102; UI_GetThemeColorType3ubv(TH_AXIS_X, SPACE_VIEW3D, colors->xaxis); diff --git a/source/blender/editors/mesh/editmesh_mask_extract.cc b/source/blender/editors/mesh/editmesh_mask_extract.cc index d5021a21fd59..afcd5da35c08 100644 --- a/source/blender/editors/mesh/editmesh_mask_extract.cc +++ b/source/blender/editors/mesh/editmesh_mask_extract.cc @@ -87,8 +87,6 @@ static int geometry_extract_apply(bContext *C, blender::ed::sculpt_paint::object_sculpt_mode_exit(C, depsgraph); - BKE_sculpt_mask_layers_ensure(&depsgraph, bmain, ob, nullptr); - /* Ensures that deformation from sculpt mode is taken into account before duplicating the mesh to * extract the geometry. */ CTX_data_ensure_evaluated_depsgraph(C); @@ -279,6 +277,12 @@ static void geometry_extract_tag_face_set(BMesh *bm, GeometryExtractParams *para static int paint_mask_extract_exec(bContext *C, wmOperator *op) { + Object *ob = CTX_data_active_object(C); + Mesh *mesh = static_cast(ob->data); + if (!mesh->attributes().contains(".sculpt_mask")) { + return OPERATOR_CANCELLED; + } + GeometryExtractParams params; params.mask_threshold = RNA_float_get(op->ptr, "mask_threshold"); params.num_smooth_iterations = RNA_int_get(op->ptr, "smooth_iterations"); @@ -462,14 +466,16 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op) Main &bmain = *CTX_data_main(C); Object &ob = *CTX_data_active_object(C); View3D *v3d = CTX_wm_view3d(C); + Mesh *mesh = static_cast(ob.data); - BKE_sculpt_mask_layers_ensure(nullptr, nullptr, &ob, nullptr); + if (!mesh->attributes().contains(".sculpt_mask")) { + return OPERATOR_CANCELLED; + } bool create_new_object = RNA_boolean_get(op->ptr, "new_object"); bool fill_holes = RNA_boolean_get(op->ptr, "fill_holes"); float mask_threshold = RNA_float_get(op->ptr, "mask_threshold"); - Mesh *mesh = static_cast(ob.data); Mesh *new_mesh = (Mesh *)BKE_id_copy(&bmain, &mesh->id); /* Undo crashes when new object is created in the middle of a sculpt, see #87243. */ diff --git a/source/blender/editors/object/object_bake_api.cc b/source/blender/editors/object/object_bake_api.cc index bbdb8aca8449..cd133b3d9b35 100644 --- a/source/blender/editors/object/object_bake_api.cc +++ b/source/blender/editors/object/object_bake_api.cc @@ -1405,6 +1405,10 @@ static int bake(const BakeAPIRender *bkr, /* We build a depsgraph for the baking, * so we don't need to change the original data to adjust visibility and modifiers. */ Depsgraph *depsgraph = DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_RENDER); + + /* Ensure meshes are generated even for objects with animated visibility, see: #107426. */ + DEG_disable_visibility_optimization(depsgraph); + DEG_graph_build_from_view_layer(depsgraph); int op_result = OPERATOR_CANCELLED; @@ -1573,13 +1577,23 @@ static int bake(const BakeAPIRender *bkr, continue; } - /* initialize highpoly_data */ + Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter); + ob_eval->visibility_flag &= ~OB_HIDE_RENDER; + ob_eval->base_flag |= (BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT | BASE_ENABLED_RENDER); + + Mesh *mesh_eval = BKE_mesh_new_from_object(nullptr, ob_eval, false, false); + + /* Initialize `highpoly` data. */ highpoly[i].ob = ob_iter; - highpoly[i].ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter); - highpoly[i].ob_eval->visibility_flag &= ~OB_HIDE_RENDER; - highpoly[i].ob_eval->base_flag |= (BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT | - BASE_ENABLED_RENDER); - highpoly[i].mesh = BKE_mesh_new_from_object(nullptr, highpoly[i].ob_eval, false, false); + highpoly[i].ob_eval = ob_eval; + highpoly[i].mesh = mesh_eval; + + /* Low-poly to high-poly transformation matrix. */ + copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->object_to_world().ptr()); + invert_m4_m4(highpoly[i].imat, highpoly[i].obmat); + + highpoly[i].is_flip_object = is_negative_m4(highpoly[i].ob->object_to_world().ptr()); + i++; /* NOTE(@ideasman42): While ideally this should never happen, * it's possible the `visibility_flag` assignment in this function @@ -1590,7 +1604,7 @@ static int bake(const BakeAPIRender *bkr, * Use an error here instead of a warning so users don't accidentally perform * a bake which seems to succeed with invalid results. * If visibility could be forced/overridden - it would help avoid the problem. */ - if (UNLIKELY(highpoly[i].mesh == nullptr)) { + if (UNLIKELY(mesh_eval == nullptr)) { BKE_reportf( reports, RPT_ERROR, @@ -1598,14 +1612,6 @@ static int bake(const BakeAPIRender *bkr, ob_iter->id.name + 2); goto cleanup; } - - /* Low-poly to high-poly transformation matrix. */ - copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->object_to_world().ptr()); - invert_m4_m4(highpoly[i].imat, highpoly[i].obmat); - - highpoly[i].is_flip_object = is_negative_m4(highpoly[i].ob->object_to_world().ptr()); - - i++; } BLI_assert(i == highpoly_num); diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index 12bbca98e6a2..6a0539c3c4b4 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -976,7 +976,7 @@ void ED_workspace_status_text(bContext *C, const char *str) /* ************************************************************ */ -static void area_azone_init(wmWindow *win, const bScreen *screen, ScrArea *area) +static void area_azone_init(const wmWindow *win, const bScreen *screen, ScrArea *area) { /* reinitialize entirely, regions and full-screen add azones too */ BLI_freelistN(&area->actionzones); @@ -2046,8 +2046,9 @@ void ED_area_and_region_types_init(ScrArea *area) } } -void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area) +void ED_area_init(bContext *C, const wmWindow *win, ScrArea *area) { + wmWindowManager *wm = CTX_wm_manager(C); WorkSpace *workspace = WM_window_get_active_workspace(win); const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); const Scene *scene = WM_window_get_active_scene(win); @@ -2065,6 +2066,8 @@ void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area) /* area sizes */ area_calc_totrct(area, &window_rect); + area_regions_poll(C, screen, area); + /* region rect sizes */ rcti rect = area->totrct; rcti overlap_rect = rect; @@ -2249,7 +2252,7 @@ void ED_region_visibility_change_update_ex( } if (do_init) { - ED_area_init(CTX_wm_manager(C), CTX_wm_window(C), area); + ED_area_init(C, CTX_wm_window(C), area); ED_area_tag_redraw(area); } } @@ -2577,8 +2580,8 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2) ED_area_data_copy(tmp, sa1, false); ED_area_data_copy(sa1, sa2, true); ED_area_data_copy(sa2, tmp, true); - ED_area_init(CTX_wm_manager(C), win, sa1); - ED_area_init(CTX_wm_manager(C), win, sa2); + ED_area_init(C, win, sa1); + ED_area_init(C, win, sa2); BKE_screen_area_free(tmp); MEM_delete(tmp); @@ -2694,7 +2697,7 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi region_align_info_to_area(area, region_align_info); } - ED_area_init(CTX_wm_manager(C), win, area); + ED_area_init(C, win, area); /* tell WM to refresh, cursor types etc */ WM_event_add_mousemove(win); diff --git a/source/blender/editors/screen/screen_edit.cc b/source/blender/editors/screen/screen_edit.cc index 79bc4f241f47..bba18e5f3419 100644 --- a/source/blender/editors/screen/screen_edit.cc +++ b/source/blender/editors/screen/screen_edit.cc @@ -699,40 +699,67 @@ static bool region_poll(const bContext *C, } /** - * \return true if any region polling state changed, and a screen refresh is needed. + * \return true if any region polling state changed, and an area re-init is needed. */ -static bool screen_regions_poll(bContext *C, wmWindow *win, const bScreen *screen) +bool area_regions_poll(bContext *C, const bScreen *screen, ScrArea *area) { - wmWindow *prev_win = CTX_wm_window(C); + bScreen *prev_screen = CTX_wm_screen(C); ScrArea *prev_area = CTX_wm_area(C); ARegion *prev_region = CTX_wm_region(C); - CTX_wm_window_set(C, win); + CTX_wm_screen_set(C, const_cast(screen)); + CTX_wm_area_set(C, area); bool any_changed = false; - ED_screen_areas_iter (win, screen, area) { - CTX_wm_area_set(C, area); + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { + const int old_region_flag = region->flag; - LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { - const int old_region_flag = region->flag; + region->flag &= ~RGN_FLAG_POLL_FAILED; + + CTX_wm_region_set(C, region); + if (region_poll(C, screen, area, region) == false) { + region->flag |= RGN_FLAG_POLL_FAILED; + } + else if (region->runtime->type && region->runtime->type->on_poll_success) { + region->runtime->type->on_poll_success(C, region); + } - region->flag &= ~RGN_FLAG_POLL_FAILED; + if (old_region_flag != region->flag) { + any_changed = true; - CTX_wm_region_set(C, region); - if (region_poll(C, screen, area, region) == false) { - region->flag |= RGN_FLAG_POLL_FAILED; - } - else if (region->runtime->type && region->runtime->type->on_poll_success) { - region->runtime->type->on_poll_success(C, region); - } + /* Enforce complete re-init. */ + region->v2d.flag &= ~V2D_IS_INIT; - if (old_region_flag != region->flag) { - any_changed = true; + const bool is_hidden = region->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_POLL_FAILED); + /* Don't re-init areas, caller is expected to handle that. In fact, this code might actually + * run as part of #ED_area_init(). */ + const bool do_init = false; + ED_region_visibility_change_update_ex(C, area, region, is_hidden, do_init); + } + } - /* Enforce complete re-init. */ - region->v2d.flag &= ~V2D_IS_INIT; - ED_region_visibility_change_update(C, area, region); - } + CTX_wm_screen_set(C, prev_screen); + CTX_wm_area_set(C, prev_area); + CTX_wm_region_set(C, prev_region); + + return any_changed; +} + +/** + * \return true if any region polling state changed, and a screen refresh is needed. + */ +static bool screen_regions_poll(bContext *C, wmWindow *win, const bScreen *screen) +{ + wmWindow *prev_win = CTX_wm_window(C); + ScrArea *prev_area = CTX_wm_area(C); + ARegion *prev_region = CTX_wm_region(C); + + CTX_wm_window_set(C, win); + + bool any_changed = false; + ED_screen_areas_iter (win, screen, area) { + if (area_regions_poll(C, screen, area)) { + any_changed = true; } } @@ -785,7 +812,7 @@ static void screen_refresh_if_needed(bContext *C, wmWindowManager *wm, wmWindow ED_screen_areas_iter (win, screen, area) { /* Set space-type and region callbacks, calls init() */ /* Sets sub-windows for regions, adds handlers. */ - ED_area_init(wm, win, area); + ED_area_init(C, win, area); } /* wake up animtimer */ diff --git a/source/blender/editors/screen/screen_intern.hh b/source/blender/editors/screen/screen_intern.hh index df5d0415b30f..96de9aa19240 100644 --- a/source/blender/editors/screen/screen_intern.hh +++ b/source/blender/editors/screen/screen_intern.hh @@ -143,6 +143,8 @@ bool screen_area_close(bContext *C, bScreen *screen, ScrArea *area); void screen_area_spacelink_add(const Scene *scene, ScrArea *area, eSpace_Type space_type); AZone *ED_area_actionzone_find_xy(ScrArea *area, const int xy[2]); +bool area_regions_poll(bContext *C, const bScreen *screen, ScrArea *area); + /* `screen_geometry.cc` */ int screen_geom_area_height(const ScrArea *area); diff --git a/source/blender/editors/screen/screen_ops.cc b/source/blender/editors/screen/screen_ops.cc index b7f04e01179a..6cdaadf9cef7 100644 --- a/source/blender/editors/screen/screen_ops.cc +++ b/source/blender/editors/screen/screen_ops.cc @@ -6284,7 +6284,7 @@ static void region_blend_end(bContext *C, ARegion *region, const bool is_running else { if (rgi->hidden) { rgi->region->flag |= rgi->hidden; - ED_area_init(CTX_wm_manager(C), CTX_wm_window(C), rgi->area); + ED_area_init(C, CTX_wm_window(C), rgi->area); } /* area decoration needs redraw in end */ ED_area_tag_redraw(rgi->area); @@ -6312,7 +6312,7 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *area, ARe /* blend in, reinitialize regions because it got unhidden */ if (rgi->hidden == 0) { - ED_area_init(wm, win, area); + ED_area_init(C, win, area); } else { ED_region_visibility_change_update_ex(C, area, region, true, false); diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 91654ccb29b1..e0b705d4efa0 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -3383,11 +3383,19 @@ static void outliner_draw_tree_element(uiBlock *block, /* Active items like camera or material. */ icon_bgcolor[3] = 0.2f; active = OL_DRAWSEL_ACTIVE; + if (te->idcode == ID_SCE) { + UI_GetThemeColor3ubv(TH_TEXT_HI, text_color); + text_color[3] = 255; + } } } } else { active = tree_element_type_active_state_get(tvc, te, tselem); + if (active != OL_DRAWSEL_NONE) { + UI_GetThemeColor3ubv(TH_TEXT_HI, text_color); + text_color[3] = 255; + } } /* Active circle. */ diff --git a/source/blender/editors/space_outliner/outliner_select.cc b/source/blender/editors/space_outliner/outliner_select.cc index 34dede0f2761..dc6e38f1803d 100644 --- a/source/blender/editors/space_outliner/outliner_select.cc +++ b/source/blender/editors/space_outliner/outliner_select.cc @@ -995,11 +995,6 @@ static eOLDrawState tree_element_posechannel_state_get(const Object *ob_pose, static eOLDrawState tree_element_viewlayer_state_get(const ViewLayer *view_layer, const TreeElement *te) { - /* paranoia check */ - if (te->idcode != ID_SCE) { - return OL_DRAWSEL_NONE; - } - const ViewLayer *te_view_layer = static_cast(te->directdata); if (view_layer == te_view_layer) { diff --git a/source/blender/editors/space_sequencer/sequencer_text_edit.cc b/source/blender/editors/space_sequencer/sequencer_text_edit.cc index ab8210bec279..fcf44fc84d4c 100644 --- a/source/blender/editors/space_sequencer/sequencer_text_edit.cc +++ b/source/blender/editors/space_sequencer/sequencer_text_edit.cc @@ -820,16 +820,23 @@ static int sequencer_text_edit_paste_exec(bContext *C, wmOperator * /*op*/) } const int max_str_len = sizeof(data->text) - (BLI_strnlen(data->text, sizeof(data->text)) + 1); - clipboard_len = std::min(clipboard_len, max_str_len); + + /* Maximum bytes that can be filled into `data->text`. */ + const int fillable_len = std::min(clipboard_len, max_str_len); + + /* Truncated string could contain invalid utf-8 sequence, thus ensure the length inserted is + * always valid. */ + size_t valid_str_len; + const int extra_offset = BLI_strnlen_utf8_ex(clipboard_buf, fillable_len, &valid_str_len); const seq::CharInfo cur_char = character_at_cursor_offset_get(text, data->cursor_offset); char *cursor_addr = const_cast(cur_char.str_ptr); const size_t move_str_len = BLI_strnlen(cursor_addr, sizeof(data->text)) + 1; - std::memmove(cursor_addr + clipboard_len, cursor_addr, move_str_len); - std::memcpy(cursor_addr, clipboard_buf, clipboard_len); + std::memmove(cursor_addr + valid_str_len, cursor_addr, move_str_len); + std::memcpy(cursor_addr, clipboard_buf, valid_str_len); - data->cursor_offset += BLI_strlen_utf8(clipboard_buf); + data->cursor_offset += extra_offset; MEM_freeN(clipboard_buf); text_editing_update(C); diff --git a/source/blender/editors/space_sequencer/space_sequencer.cc b/source/blender/editors/space_sequencer/space_sequencer.cc index 86c31dae5f4d..4147779bcbe0 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.cc +++ b/source/blender/editors/space_sequencer/space_sequencer.cc @@ -220,8 +220,7 @@ static void sequencer_init(wmWindowManager * /*wm*/, ScrArea *area) static void sequencer_refresh(const bContext *C, ScrArea *area) { - wmWindowManager *wm = CTX_wm_manager(C); - wmWindow *window = CTX_wm_window(C); + const wmWindow *window = CTX_wm_window(C); SpaceSeq *sseq = (SpaceSeq *)area->spacedata.first; ARegion *region_main = sequencer_find_region(area, RGN_TYPE_WINDOW); ARegion *region_preview = sequencer_find_region(area, RGN_TYPE_PREVIEW); @@ -272,7 +271,7 @@ static void sequencer_refresh(const bContext *C, ScrArea *area) } if (view_changed) { - ED_area_init(wm, window, area); + ED_area_init(const_cast(C), window, area); ED_area_tag_redraw(area); } } @@ -678,6 +677,12 @@ static void sequencer_main_cursor(wmWindow *win, ScrArea *area, ARegion *region) return; } + const View2D *v2d = ®ion->v2d; + if (UI_view2d_mouse_in_scrollers(region, v2d, win->eventstate->xy)) { + WM_cursor_set(win, wmcursor); + return; + } + float mouse_co_region[2] = {float(win->eventstate->xy[0] - region->winrct.xmin), float(win->eventstate->xy[1] - region->winrct.ymin)}; float mouse_co_view[2]; @@ -705,7 +710,6 @@ static void sequencer_main_cursor(wmWindow *win, ScrArea *area, ARegion *region) return; } - const View2D *v2d = ®ion->v2d; const float scale_y = UI_view2d_scale_get_y(v2d); if (!ED_sequencer_can_select_handle(scene, selection.seq1, v2d) || scale_y < 16 * U.pixelsize) { diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc b/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc index adb8038d7a3d..9185479b042b 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc @@ -215,7 +215,8 @@ static void ruler_item_as_string( BLI_snprintf(numstr, numstr_size, "%.*f", prec, ruler_len); } else { - BKE_unit_value_as_string(numstr, numstr_size, ruler_len, prec, B_UNIT_LENGTH, unit, false); + BKE_unit_value_as_string_scaled( + numstr, numstr_size, ruler_len, prec, B_UNIT_LENGTH, unit, false); } } } diff --git a/source/blender/editors/util/ed_draw.cc b/source/blender/editors/util/ed_draw.cc index 2a1c502e4588..d15c9ec3c408 100644 --- a/source/blender/editors/util/ed_draw.cc +++ b/source/blender/editors/util/ed_draw.cc @@ -556,6 +556,22 @@ void ED_slider_status_string_get(const tSlider *slider, increments_str); } +void ED_slider_status_get(const tSlider *slider, WorkspaceStatus &status) +{ + if (slider->allow_overshoot_lower || slider->allow_overshoot_upper) { + status.item_bool(IFACE_("Overshoot"), slider->overshoot, ICON_EVENT_E); + } + else { + status.item(IFACE_("Overshoot Disabled"), ICON_INFO); + } + + status.item_bool(IFACE_("Precision"), slider->precision, ICON_EVENT_SHIFT); + + if (slider->allow_increments) { + status.item_bool(IFACE_("Increments"), slider->increments, ICON_EVENT_CTRL); + } +} + void ED_slider_destroy(bContext *C, tSlider *slider) { /* Remove draw callback. */ diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc index 5cccf067f0e0..a6dd3ae5060e 100644 --- a/source/blender/gpu/intern/gpu_codegen.cc +++ b/source/blender/gpu/intern/gpu_codegen.cc @@ -18,6 +18,7 @@ #include "BLI_hash_mm2a.hh" #include "BLI_link_utils.h" #include "BLI_listbase.h" +#include "BLI_span.hh" #include "BLI_string.h" #include "BLI_threads.h" #include "BLI_time.h" @@ -26,6 +27,8 @@ #include "BKE_cryptomatte.hh" #include "BKE_material.hh" +#include "IMB_colormanagement.hh" + #include "GPU_capabilities.hh" #include "GPU_context.hh" #include "GPU_material.hh" @@ -232,21 +235,18 @@ static std::ostream &operator<<(std::ostream &stream, const GPUOutput *output) return stream << SRC_NAME("out", output, outputs, "tmp") << output->id; } -/* Trick type to change overload and keep a somewhat nice syntax. */ -struct GPUConstant : public GPUInput {}; - /* Print data constructor (i.e: vec2(1.0f, 1.0f)). */ -static std::ostream &operator<<(std::ostream &stream, const GPUConstant *input) +static std::ostream &operator<<(std::ostream &stream, const blender::Span &span) { - stream << input->type << "("; - for (int i = 0; i < input->type; i++) { + stream << (eGPUType)span.size() << "("; + /* Use uint representation to allow exact same bit pattern even if NaN. This is + * because we can pass UINTs as floats for constants. */ + const blender::Span uint_span = span.cast(); + for (const uint32_t &element : uint_span) { char formatted_float[32]; - /* Use uint representation to allow exact same bit pattern even if NaN. This is because we can - * pass UINTs as floats for constants. */ - const uint32_t *uint_vec = reinterpret_cast(input->vec); - SNPRINTF(formatted_float, "uintBitsToFloat(%uu)", uint_vec[i]); + SNPRINTF(formatted_float, "uintBitsToFloat(%uu)", element); stream << formatted_float; - if (i < input->type - 1) { + if (&element != &uint_span.last()) { stream << ", "; } } @@ -254,6 +254,15 @@ static std::ostream &operator<<(std::ostream &stream, const GPUConstant *input) return stream; } +/* Trick type to change overload and keep a somewhat nice syntax. */ +struct GPUConstant : public GPUInput {}; + +static std::ostream &operator<<(std::ostream &stream, const GPUConstant *input) +{ + stream << blender::Span(input->vec, input->type); + return stream; +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -532,6 +541,13 @@ void GPUCodegen::node_serialize(std::stringstream &eval_ss, const GPUNode *node) } if (from != to) { + /* Special case that needs luminance coefficients as argument. */ + if (from == GPU_VEC4 && to == GPU_FLOAT) { + float coefficients[3]; + IMB_colormanagement_get_luminance_coefficients(coefficients); + eval_ss << ", " << blender::Span(coefficients, 3); + } + eval_ss << ")"; } break; diff --git a/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl b/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl index d140521231c3..03899ee3bdb7 100644 --- a/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl +++ b/source/blender/gpu/shaders/gpu_shader_codegen_lib.glsl @@ -103,8 +103,8 @@ vec4 tangent_get(vec4 attr, mat3 normalmat) #endif -/* Assumes GPU_VEC4 is color data. So converting to luminance like cycles. */ -#define float_from_vec4(v) dot(v.rgb, vec3(0.2126, 0.7152, 0.0722)) +/* Assumes GPU_VEC4 is color data, special case that needs luminance coefficients from OCIO. */ +#define float_from_vec4(v, luminance_coefficients) dot(v.rgb, luminance_coefficients) #define float_from_vec3(v) ((v.r + v.g + v.b) * (1.0 / 3.0)) #define float_from_vec2(v) v.r diff --git a/source/blender/io/alembic/CMakeLists.txt b/source/blender/io/alembic/CMakeLists.txt index 0bfe03278a1a..441cfd8bd5da 100644 --- a/source/blender/io/alembic/CMakeLists.txt +++ b/source/blender/io/alembic/CMakeLists.txt @@ -15,12 +15,6 @@ set(INC_SYS ${OPENEXR_INCLUDE_DIRS} ) -if(WITH_BOOST) - list(APPEND INC_SYS - ${BOOST_INCLUDE_DIR} - ) -endif() - set(SRC intern/abc_axis_conversion.cc intern/abc_customdata.cc @@ -95,12 +89,6 @@ set(LIB PRIVATE bf::windowmanager ) -if(WITH_BOOST) - list(APPEND LIB - ${BOOST_LIBRARIES} - ) -endif() - blender_add_lib(bf_io_alembic "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") if(WITH_GTESTS) diff --git a/source/blender/io/grease_pencil/CMakeLists.txt b/source/blender/io/grease_pencil/CMakeLists.txt index 0d2be5e38bbb..67fdc38e3431 100644 --- a/source/blender/io/grease_pencil/CMakeLists.txt +++ b/source/blender/io/grease_pencil/CMakeLists.txt @@ -72,10 +72,4 @@ if(WITH_HARU) add_definitions(-DWITH_HARU) endif() -if(WITH_BOOST) - list(APPEND LIB - ${BOOST_LIBRARIES} - ) -endif() - blender_add_lib(bf_io_grease_pencil "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") diff --git a/source/blender/io/usd/CMakeLists.txt b/source/blender/io/usd/CMakeLists.txt index cc1a1e4052e4..abd02523c342 100644 --- a/source/blender/io/usd/CMakeLists.txt +++ b/source/blender/io/usd/CMakeLists.txt @@ -206,7 +206,6 @@ set(LIB ) list(APPEND LIB - ${BOOST_LIBRARIES} ${BOOST_PYTHON_LIBRARIES} ${PYTHON_LIBRARIES} ${USD_LIBRARIES} diff --git a/source/blender/io/usd/intern/usd_writer_material.cc b/source/blender/io/usd/intern/usd_writer_material.cc index b574d6a3d5d2..7c295409adcd 100644 --- a/source/blender/io/usd/intern/usd_writer_material.cc +++ b/source/blender/io/usd/intern/usd_writer_material.cc @@ -1323,6 +1323,7 @@ static void export_texture(const USDExporterContext &usd_export_context, bNode * usd_export_context.export_params.worker_status->reports); } +#ifdef WITH_MATERIALX static void export_texture(const USDExporterContext &usd_export_context, Image *ima) { export_texture(ima, @@ -1330,6 +1331,7 @@ static void export_texture(const USDExporterContext &usd_export_context, Image * usd_export_context.export_params.overwrite_textures, usd_export_context.export_params.worker_status->reports); } +#endif void export_texture(bNode *node, const pxr::UsdStageRefPtr stage, diff --git a/source/blender/makesrna/intern/rna_modifier.cc b/source/blender/makesrna/intern/rna_modifier.cc index fa548247728e..7f981f923b6a 100644 --- a/source/blender/makesrna/intern/rna_modifier.cc +++ b/source/blender/makesrna/intern/rna_modifier.cc @@ -6350,9 +6350,11 @@ static void rna_def_modifier_remesh(BlenderRNA *brna) "edges closer to the input"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + /* NOTE: allow zero (which skips computation), to avoid zero clamping + * to a small value which is likely to run out of memory, see: #130526. */ prop = RNA_def_property(srna, "voxel_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, nullptr, "voxel_size"); - RNA_def_property_range(prop, 0.0001f, FLT_MAX); + RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_range(prop, 0.0001, 2, 0.1, 3); RNA_def_property_ui_scale_type(prop, PROP_SCALE_LOG); RNA_def_property_ui_text(prop, @@ -8172,6 +8174,8 @@ static void rna_def_modifier_mesh_to_volume(BlenderRNA *brna) prop, "Resolution Mode", "Mode for how the desired voxel size is specified"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + /* NOTE: allow zero (which skips computation), to avoid zero clamping + * to a small value which is likely to run out of memory, see: #130526. */ prop = RNA_def_property(srna, "voxel_size", PROP_FLOAT, PROP_NONE); RNA_def_property_ui_text( prop, "Voxel Size", "Smaller values result in a higher resolution output"); @@ -8336,6 +8340,8 @@ static void rna_def_modifier_volume_to_mesh(BlenderRNA *brna) prop, "Resolution Mode", "Mode for how the desired voxel size is specified"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + /* NOTE: allow zero (which skips computation), to avoid zero clamping + * to a small value which is likely to run out of memory, see: #130526. */ prop = RNA_def_property(srna, "voxel_size", PROP_FLOAT, PROP_NONE); RNA_def_property_ui_text( prop, "Voxel Size", "Smaller values result in a higher resolution output"); diff --git a/source/blender/modifiers/intern/MOD_bevel.cc b/source/blender/modifiers/intern/MOD_bevel.cc index 2c67b309f196..4a8463d2d46d 100644 --- a/source/blender/modifiers/intern/MOD_bevel.cc +++ b/source/blender/modifiers/intern/MOD_bevel.cc @@ -110,6 +110,9 @@ static std::string ensure_weight_attribute_meta_data(Mesh &mesh, static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh) { using namespace blender; + if (mesh->verts_num == 0) { + return mesh; + } Mesh *result; BMesh *bm; BMIter iter; diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_opacity.cc b/source/blender/modifiers/intern/MOD_grease_pencil_opacity.cc index 2caf50d6deb3..494ea9d9dcc1 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_opacity.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_opacity.cc @@ -89,7 +89,8 @@ static void modify_stroke_color(const GreasePencilOpacityModifierData &omd, curves_mask.foreach_index(GrainSize(512), [&](const int64_t curve_i) { const IndexRange points = points_by_curve[curve_i]; for (const int64_t point_i : points) { - const float vgroup_weight = vgroup_weights[point_i]; + const float vgroup_weight = invert_vertex_group ? 1.0f - vgroup_weights[point_i] : + vgroup_weights[point_i]; if (vgroup_weight <= 0.0f) { continue; } @@ -110,9 +111,8 @@ static void modify_stroke_color(const GreasePencilOpacityModifierData &omd, } else { /* Use vertex group weights as influence factors. */ - const float vgroup_influence = invert_vertex_group ? 1.0f - vgroup_weight : vgroup_weight; opacities.span[point_i] = std::clamp( - opacities.span[point_i] + (omd.color_factor * curve_factor - 1.0f) * vgroup_influence, + opacities.span[point_i] + (omd.color_factor * curve_factor - 1.0f) * vgroup_weight, 0.0f, 1.0f); } @@ -144,17 +144,15 @@ static void modify_fill_color(const GreasePencilOpacityModifierData &omd, /* Use the first stroke point as vertex weight. */ const IndexRange points = points_by_curve[curve_i]; const float vgroup_weight_first = vgroup_weights[points.first()]; - float stroke_weight = vgroup_weight_first; + float stroke_weight = invert_vertex_group ? 1.0f - vgroup_weight_first : vgroup_weight_first; if (use_vgroup_opacity) { - if (points.is_empty() || (vgroup_weight_first <= 0.0f)) { + if (points.is_empty() || (stroke_weight <= 0.0f)) { stroke_weight = 1.0f; } - const float stroke_influence = invert_vertex_group ? 1.0f - stroke_weight : stroke_weight; - - fill_opacities.span[curve_i] = std::clamp(stroke_influence, 0.0f, 1.0f); + fill_opacities.span[curve_i] = std::clamp(stroke_weight, 0.0f, 1.0f); } else { - if (!points.is_empty() && (vgroup_weight_first > 0.0f)) { + if (!points.is_empty() && (stroke_weight > 0.0f)) { fill_opacities.span[curve_i] = std::clamp(omd.color_factor * stroke_weight, 0.0f, 1.0f); } } diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc b/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc index dad006eaa640..366f7c72dbbf 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc @@ -187,9 +187,10 @@ static void modify_stroke_color(Object &ob, }; auto get_point_factor = [&](const int64_t point_i) { - const float weight = vgroup_weights[point_i]; + const float weight = invert_vertex_group ? 1.0f - vgroup_weights[point_i] : + vgroup_weights[point_i]; if (use_weight_as_factor) { - return invert_vertex_group ? 1.0f - weight : weight; + return weight; } return tmd.factor * weight; }; @@ -275,12 +276,12 @@ static void modify_fill_color(Object &ob, /* Use the first stroke point as vertex weight. */ const IndexRange points = points_by_curve[curve_i]; const float vgroup_weight_first = vgroup_weights[points.first()]; - float stroke_weight = vgroup_weight_first; - if (points.is_empty() || (vgroup_weight_first <= 0.0f)) { + float stroke_weight = invert_vertex_group ? 1.0f - vgroup_weight_first : vgroup_weight_first; + if (points.is_empty() || (stroke_weight <= 0.0f)) { return 0.0f; } else if (use_weight_as_factor) { - return invert_vertex_group ? 1.0f - stroke_weight : stroke_weight; + return stroke_weight; } return tmd.factor * stroke_weight; }; diff --git a/source/blender/modifiers/intern/MOD_remesh.cc b/source/blender/modifiers/intern/MOD_remesh.cc index 281a7300a4e4..1ca1b5c32360 100644 --- a/source/blender/modifiers/intern/MOD_remesh.cc +++ b/source/blender/modifiers/intern/MOD_remesh.cc @@ -61,8 +61,8 @@ static void init_dualcon_mesh(DualConInput *input, Mesh *mesh) input->co_stride = sizeof(blender::float3); input->totco = mesh->verts_num; - input->mloop = (DualConLoop)mesh->corner_verts().data(); - input->loop_stride = sizeof(int); + input->corner_verts = (DualConCornerVerts)mesh->corner_verts().data(); + input->corner_verts_stride = sizeof(int); input->corner_tris = (DualConTri)mesh->corner_tris().data(); input->tri_stride = sizeof(blender::int3); @@ -127,21 +127,16 @@ static void dualcon_add_quad(void *output_v, const int vert_indices[4]) output->curface++; } -static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext * /*ctx*/, Mesh *mesh) +static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh) { using namespace blender; - RemeshModifierData *rmd; - DualConOutput *output; - DualConInput input; + RemeshModifierData *rmd = (RemeshModifierData *)md; Mesh *result; - DualConFlags flags = DualConFlags(0); - DualConMode mode = DualConMode(0); - - rmd = (RemeshModifierData *)md; if (rmd->mode == MOD_REMESH_VOXEL) { /* OpenVDB modes. */ if (rmd->voxel_size == 0.0f) { + BKE_modifier_set_error(ctx->object, md, "Zero voxel size cannot be solved"); return nullptr; } result = BKE_mesh_remesh_voxel(mesh, rmd->voxel_size, rmd->adaptivity, 0.0f); @@ -150,6 +145,16 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext * /*ctx*/, } } else { + if (rmd->scale == 0.0f) { + BKE_modifier_set_error(ctx->object, md, "Zero scale cannot be solved"); + return nullptr; + } + + DualConOutput *output; + DualConInput input; + DualConFlags flags = DualConFlags(0); + DualConMode mode = DualConMode(0); + /* Dualcon modes. */ init_dualcon_mesh(&input, mesh); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc index bd8ceb46405b..161fa7a2c4ac 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc @@ -77,7 +77,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) uiItemR(layout, ptr, "domain", UI_ITEM_NONE, "", ICON_NONE); if (uiLayout *panel = uiLayoutPanel( - C, layout, "capture_attribute_items", false, TIP_("Capture Items"))) + C, layout, "capture_attribute_items", false, IFACE_("Capture Items"))) { socket_items::ui::draw_items_list_with_operators( C, panel, tree, node); diff --git a/source/blender/nodes/geometry/nodes/node_geo_bake.cc b/source/blender/nodes/geometry/nodes/node_geo_bake.cc index a1e6945aece5..685790d06d9e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_bake.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_bake.cc @@ -135,7 +135,7 @@ static void draw_bake_items(const bContext *C, uiLayout *layout, PointerRNA node bNode &node = *static_cast(node_ptr.data); NodeGeometryBake &storage = node_storage(node); - if (uiLayout *panel = uiLayoutPanel(C, layout, "bake_items", false, TIP_("Bake Items"))) { + if (uiLayout *panel = uiLayoutPanel(C, layout, "bake_items", false, IFACE_("Bake Items"))) { socket_items::ui::draw_items_list_with_operators(C, panel, tree, node); socket_items::ui::draw_active_item_props( tree, node, [&](PointerRNA *item_ptr) { @@ -879,7 +879,7 @@ void draw_data_blocks(const bContext *C, uiLayout *layout, PointerRNA &bake_rna) bake_rna.owner_id, &RNA_NodesModifierBakeDataBlocks, bake_rna.data); if (uiLayout *panel = uiLayoutPanel( - C, layout, "data_block_references", true, TIP_("Data-Block References"))) + C, layout, "data_block_references", true, IFACE_("Data-Block References"))) { uiTemplateList(panel, C, diff --git a/source/blender/nodes/geometry/nodes/node_geo_foreach_geometry_element.cc b/source/blender/nodes/geometry/nodes/node_geo_foreach_geometry_element.cc index c0954b749296..8ed2f77ab065 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_foreach_geometry_element.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_foreach_geometry_element.cc @@ -50,7 +50,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *current_no auto &storage = *static_cast(output_node.storage); if (is_zone_input_node) { - if (uiLayout *panel = uiLayoutPanel(C, layout, "input", false, TIP_("Input Fields"))) { + if (uiLayout *panel = uiLayoutPanel(C, layout, "input", false, IFACE_("Input Fields"))) { socket_items::ui::draw_items_list_with_operators( C, panel, ntree, output_node); socket_items::ui::draw_active_item_props( @@ -62,7 +62,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *current_no } } else { - if (uiLayout *panel = uiLayoutPanel(C, layout, "main_items", false, TIP_("Main Geometry"))) { + if (uiLayout *panel = uiLayoutPanel(C, layout, "main_items", false, IFACE_("Main Geometry"))) { socket_items::ui::draw_items_list_with_operators( C, panel, ntree, output_node); socket_items::ui::draw_active_item_props( @@ -73,7 +73,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *current_no }); } if (uiLayout *panel = uiLayoutPanel( - C, layout, "generation_items", false, TIP_("Generated Geometry"))) + C, layout, "generation_items", false, IFACE_("Generated Geometry"))) { socket_items::ui::draw_items_list_with_operators< ForeachGeometryElementGenerationItemsAccessor>(C, panel, ntree, output_node); diff --git a/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc b/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc index 937950959660..31852a007d9a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc @@ -70,7 +70,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) { bNode &node = *static_cast(ptr->data); NodeIndexSwitch &storage = node_storage(node); - if (uiLayout *panel = uiLayoutPanel(C, layout, "index_switch_items", false, TIP_("Items"))) { + if (uiLayout *panel = uiLayoutPanel(C, layout, "index_switch_items", false, IFACE_("Items"))) { uiItemO(panel, IFACE_("Add Item"), ICON_ADD, "node.index_switch_item_add"); uiLayout *col = uiLayoutColumn(panel, false); for (const int i : IndexRange(storage.items_num)) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc b/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc index a57c910cc312..44070d7d82a4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc @@ -361,7 +361,8 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) uiItemR(layout, ptr, "data_type", UI_ITEM_NONE, "", ICON_NONE); - if (uiLayout *panel = uiLayoutPanel(C, layout, "menu_switch_items", false, TIP_("Menu Items"))) { + if (uiLayout *panel = uiLayoutPanel(C, layout, "menu_switch_items", false, IFACE_("Menu Items"))) + { socket_items::ui::draw_items_list_with_operators( C, panel, tree, node); socket_items::ui::draw_active_item_props( diff --git a/source/blender/nodes/geometry/nodes/node_geo_repeat.cc b/source/blender/nodes/geometry/nodes/node_geo_repeat.cc index a2e93c023284..9698e5c87866 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_repeat.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_repeat.cc @@ -48,7 +48,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *current_no PointerRNA output_node_ptr = RNA_pointer_create( current_node_ptr->owner_id, &RNA_Node, &output_node); - if (uiLayout *panel = uiLayoutPanel(C, layout, "repeat_items", false, TIP_("Repeat Items"))) { + if (uiLayout *panel = uiLayoutPanel(C, layout, "repeat_items", false, IFACE_("Repeat Items"))) { socket_items::ui::draw_items_list_with_operators( C, panel, ntree, output_node); socket_items::ui::draw_active_item_props( diff --git a/source/blender/nodes/geometry/nodes/node_geo_simulation.cc b/source/blender/nodes/geometry/nodes/node_geo_simulation.cc index 0f75647e948e..fc1237fe07d7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_simulation.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_simulation.cc @@ -199,7 +199,7 @@ static void draw_simulation_state(const bContext *C, bNode &output_node) { if (uiLayout *panel = uiLayoutPanel( - C, layout, "simulation_state_items", false, TIP_("Simulation State"))) + C, layout, "simulation_state_items", false, IFACE_("Simulation State"))) { socket_items::ui::draw_items_list_with_operators( C, panel, ntree, output_node); diff --git a/source/blender/nodes/shader/materialx/node_graph.cc b/source/blender/nodes/shader/materialx/node_graph.cc index c8a270a2b162..088baaf47732 100644 --- a/source/blender/nodes/shader/materialx/node_graph.cc +++ b/source/blender/nodes/shader/materialx/node_graph.cc @@ -9,6 +9,8 @@ #include "BLI_hash.hh" #include "BLI_string_utils.hh" +#include "BKE_node_runtime.hh" + #include "node_graph.h" namespace blender::nodes::materialx { diff --git a/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc index 25f5a4b9b2f7..a7fbd6639de3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc +++ b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc @@ -50,7 +50,10 @@ static int gpu_shader_valtorgb(GPUMaterial *mat, int size; /* Common / easy case optimization. */ - if ((coba->tot <= 2) && (coba->color_mode == COLBAND_BLEND_RGB)) { + if (coba->tot == 1) { + return GPU_link(mat, "set_rgba", GPU_uniform(&coba->data[0].r), &out[0].link); + } + else if ((coba->tot == 2) && (coba->color_mode == COLBAND_BLEND_RGB)) { float mul_bias[2]; switch (coba->ipotype) { case COLBAND_INTERP_LINEAR: diff --git a/source/blender/render/hydra/CMakeLists.txt b/source/blender/render/hydra/CMakeLists.txt index d1c4ccc85ebd..955661ee0e0c 100644 --- a/source/blender/render/hydra/CMakeLists.txt +++ b/source/blender/render/hydra/CMakeLists.txt @@ -67,7 +67,6 @@ set(INC_SYS set(LIB ${Epoxy_LIBRARIES} ${PYTHON_LIBRARIES} - ${BOOST_LIBRARIES} ${USD_LIBRARIES} ${TBB_LIBRARIES} PRIVATE bf::blenkernel diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.cc b/source/blender/windowmanager/intern/wm_keymap_utils.cc index 50611aa334d9..a7dabbb8ad63 100644 --- a/source/blender/windowmanager/intern/wm_keymap_utils.cc +++ b/source/blender/windowmanager/intern/wm_keymap_utils.cc @@ -168,6 +168,7 @@ wmKeyMap *WM_keymap_guess_from_context(const bContext *C) else if (sl->spacetype == SPACE_IMAGE) { const SpaceImage *sima = (SpaceImage *)sl; const eSpaceImage_Mode mode = eSpaceImage_Mode(sima->mode); + space_type = SPACE_IMAGE; switch (mode) { case SI_MODE_VIEW: km_id = "Image"; diff --git a/source/blender/windowmanager/intern/wm_playanim.cc b/source/blender/windowmanager/intern/wm_playanim.cc index c7fcc1bb1527..cf656945005a 100644 --- a/source/blender/windowmanager/intern/wm_playanim.cc +++ b/source/blender/windowmanager/intern/wm_playanim.cc @@ -134,7 +134,6 @@ static bool buffer_from_filepath(const char *filepath, size_read); } else { - close(file); *r_size = size; if (r_mem) { *r_mem = mem;