diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-04-05 19:47:10 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-04-05 19:47:10 +0300 |
commit | 7748dd4ec735535f53f61d6aa4a2f6b9db9abdc1 (patch) | |
tree | 65f854f448a2503bef50781212355b74fa616839 | |
parent | 9e12a731db6f6647d5e6dfdaa32fc4d8117a523d (diff) | |
parent | b84255f590c07b129f726eadbfec72c73bfc2ee1 (diff) |
Merge remote-tracking branch 'origin/master' into temp-sculpt-colorstemp-sculpt-colors
127 files changed, 1990 insertions, 2333 deletions
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index 8ae38e03fb1..b0dbc0d3264 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -401,7 +401,7 @@ if(WITH_CODEC_FFMPEG) ${LIBDIR}/ffmpeg/include/msvc ) windows_find_package(FFmpeg) - if(NOT FFMPEG_FOUND) + if(NOT FFmpeg_FOUND) warn_hardcoded_paths(FFmpeg) set(FFMPEG_LIBRARIES ${LIBDIR}/ffmpeg/lib/avcodec.lib @@ -415,7 +415,7 @@ endif() if(WITH_IMAGE_OPENEXR) windows_find_package(OpenEXR REQUIRED) - if(NOT OPENEXR_FOUND) + if(NOT OpenEXR_FOUND) set(OPENEXR_ROOT_DIR ${LIBDIR}/openexr) set(OPENEXR_VERSION "2.1") warn_hardcoded_paths(OpenEXR) @@ -531,17 +531,20 @@ if(WITH_BOOST) set(BOOST_LIBRARIES ${Boost_LIBRARIES}) set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS}) endif() + set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB") endif() if(WITH_OPENIMAGEIO) windows_find_package(OpenImageIO) - set(OPENIMAGEIO ${LIBDIR}/OpenImageIO) - set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib) - set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include) - set(OIIO_OPTIMIZED optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO.lib optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util.lib) - set(OIIO_DEBUG debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_d.lib debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util_d.lib) - set(OPENIMAGEIO_LIBRARIES ${OIIO_OPTIMIZED} ${OIIO_DEBUG}) + if(NOT OpenImageIO_FOUND) + set(OPENIMAGEIO ${LIBDIR}/OpenImageIO) + set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib) + set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include) + set(OIIO_OPTIMIZED optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO.lib optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util.lib) + set(OIIO_DEBUG debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_d.lib debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util_d.lib) + set(OPENIMAGEIO_LIBRARIES ${OIIO_OPTIMIZED} ${OIIO_DEBUG}) + endif() set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0") set(OPENIMAGEIO_IDIFF "${OPENIMAGEIO}/bin/idiff.exe") @@ -572,31 +575,38 @@ if(WITH_LLVM) message(WARNING "LLVM debug libs not present on this system. Using release libs for debug builds.") set(LLVM_LIBRARY ${LLVM_LIBRARY_OPTIMIZED}) endif() - endif() if(WITH_OPENCOLORIO) - set(OPENCOLORIO ${LIBDIR}/OpenColorIO) - set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include) - set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib) - set(OPENCOLORIO_LIBRARIES - optimized ${OPENCOLORIO_LIBPATH}/OpenColorIO.lib - optimized ${OPENCOLORIO_LIBPATH}/libyaml-cpp.lib - optimized ${OPENCOLORIO_LIBPATH}/libexpatMD.lib - optimized ${OPENCOLORIO_LIBPATH}/pystring.lib - debug ${OPENCOLORIO_LIBPATH}/OpencolorIO_d.lib - debug ${OPENCOLORIO_LIBPATH}/libyaml-cpp_d.lib - debug ${OPENCOLORIO_LIBPATH}/libexpatdMD.lib - debug ${OPENCOLORIO_LIBPATH}/pystring_d.lib - ) + windows_find_package(OpenColorIO) + if(NOT OpenColorIO_FOUND) + set(OPENCOLORIO ${LIBDIR}/OpenColorIO) + set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include) + set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib) + set(OPENCOLORIO_LIBRARIES + optimized ${OPENCOLORIO_LIBPATH}/OpenColorIO.lib + optimized ${OPENCOLORIO_LIBPATH}/libyaml-cpp.lib + optimized ${OPENCOLORIO_LIBPATH}/libexpatMD.lib + optimized ${OPENCOLORIO_LIBPATH}/pystring.lib + debug ${OPENCOLORIO_LIBPATH}/OpencolorIO_d.lib + debug ${OPENCOLORIO_LIBPATH}/libyaml-cpp_d.lib + debug ${OPENCOLORIO_LIBPATH}/libexpatdMD.lib + debug ${OPENCOLORIO_LIBPATH}/pystring_d.lib + ) + endif() + set(OPENCOLORIO_DEFINITIONS "-DOpenColorIO_SKIP_IMPORTS") endif() if(WITH_OPENVDB) - set(OPENVDB ${LIBDIR}/openVDB) - set(OPENVDB_LIBPATH ${OPENVDB}/lib) - set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include) - set(OPENVDB_LIBRARIES optimized ${OPENVDB_LIBPATH}/openvdb.lib debug ${OPENVDB_LIBPATH}/openvdb_d.lib ) + windows_find_package(OpenVDB) + if(NOT OpenVDB_FOUND) + set(OPENVDB ${LIBDIR}/openVDB) + set(OPENVDB_LIBPATH ${OPENVDB}/lib) + set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include) + set(OPENVDB_LIBRARIES optimized ${OPENVDB_LIBPATH}/openvdb.lib debug ${OPENVDB_LIBPATH}/openvdb_d.lib) + endif() + set(OPENVDB_DEFINITIONS -DNOMINMAX -D_USE_MATH_DEFINES) endif() @@ -636,9 +646,10 @@ endif() if(WITH_OPENSUBDIV) windows_find_package(OpenSubdiv) - if (NOT OpenSubdiv_FOUND) - set(OPENSUBDIV_INCLUDE_DIRS ${LIBDIR}/opensubdiv/include) - set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib) + if(NOT OpenSubdiv_FOUND) + set(OPENSUBDIV ${LIBDIR}/opensubdiv) + set(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV}/include) + set(OPENSUBDIV_LIBPATH ${OPENSUBDIV}/lib) set(OPENSUBDIV_LIBRARIES optimized ${OPENSUBDIV_LIBPATH}/osdCPU.lib optimized ${OPENSUBDIV_LIBPATH}/osdGPU.lib @@ -673,7 +684,7 @@ endif() if(WITH_TBB) windows_find_package(TBB) - if (NOT TBB_FOUND) + if(NOT TBB_FOUND) set(TBB_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbb.lib debug ${LIBDIR}/tbb/lib/tbb_debug.lib) set(TBB_INCLUDE_DIR ${LIBDIR}/tbb/include) set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR}) @@ -699,7 +710,6 @@ if(WITH_OPENAL) else() set(OPENAL_LIBRARY ${OPENAL_LIBPATH}/wrap_oal.lib) endif() - endif() if(WITH_CODEC_SNDFILE) @@ -744,7 +754,7 @@ endif() if(WITH_CYCLES AND WITH_CYCLES_EMBREE) windows_find_package(Embree) - if(NOT EMBREE_FOUND) + if(NOT Embree_FOUND) set(EMBREE_INCLUDE_DIRS ${LIBDIR}/embree/include) set(EMBREE_LIBRARIES optimized ${LIBDIR}/embree/lib/embree3.lib @@ -772,7 +782,6 @@ endif() if(WITH_USD) windows_find_package(USD) if(NOT USD_FOUND) - set(USD_FOUND ON) set(USD_INCLUDE_DIRS ${LIBDIR}/usd/include) set(USD_RELEASE_LIB ${LIBDIR}/usd/lib/libusd_m.lib) set(USD_DEBUG_LIB ${LIBDIR}/usd/lib/libusd_m_d.lib) diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index 1cc3dccf426..911e1cf214c 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -3,11 +3,7 @@ # Standalone or with Blender if(NOT WITH_BLENDER) - if(WITH_CYCLES_STANDALONE OR NOT WITH_CYCLES_HYDRA_RENDER_DELEGATE) - set(CYCLES_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}) - else() - set(CYCLES_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/hdCycles/resources) - endif() + set(CYCLES_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}) else() set(WITH_CYCLES_BLENDER ON) # WINDOWS_PYTHON_DEBUG needs to write into the user addons folder since it will @@ -219,6 +215,15 @@ add_definitions( -DCCL_NAMESPACE_END=} ) +include_directories( + SYSTEM + ${BOOST_INCLUDE_DIR} + ${OPENIMAGEIO_INCLUDE_DIRS} + ${OPENEXR_INCLUDE_DIRS} + ${PUGIXML_INCLUDE_DIR} + ${TBB_INCLUDE_DIRS} +) + if(WITH_CYCLES_DEBUG) add_definitions(-DWITH_CYCLES_DEBUG) endif() @@ -259,7 +264,6 @@ endif() if(WITH_CYCLES_EMBREE) add_definitions(-DWITH_EMBREE) - add_definitions(-DEMBREE_STATIC_LIB) include_directories( SYSTEM ${EMBREE_INCLUDE_DIRS} @@ -284,7 +288,6 @@ endif() if(WITH_OPENIMAGEDENOISE) add_definitions(-DWITH_OPENIMAGEDENOISE) - add_definitions(-DOIDN_STATIC_LIB) include_directories( SYSTEM ${OPENIMAGEDENOISE_INCLUDE_DIRS} @@ -312,17 +315,6 @@ if(NOT OPENIMAGEIO_PUGIXML_FOUND) add_definitions(-DWITH_SYSTEM_PUGIXML) endif() -include_directories( - SYSTEM - ${BOOST_INCLUDE_DIR} - ${OPENIMAGEIO_INCLUDE_DIRS} - ${OPENIMAGEIO_INCLUDE_DIRS}/OpenImageIO - ${OPENEXR_INCLUDE_DIR} - ${OPENEXR_INCLUDE_DIRS} - ${PUGIXML_INCLUDE_DIR} - ${TBB_INCLUDE_DIRS} -) - if(CYCLES_STANDALONE_REPOSITORY) include_directories(../third_party/atomic) else() @@ -339,10 +331,13 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID MATCHES "Clang") unset(_has_no_error_unused_macros) endif() -if(WITH_CYCLES_HYDRA_RENDER_DELEGATE AND NOT WITH_USD) +if(WITH_CYCLES_HYDRA_RENDER_DELEGATE AND (NOT WITH_USD)) message(STATUS "USD not found, disabling WITH_CYCLES_HYDRA_RENDER_DELEGATE") set(WITH_CYCLES_HYDRA_RENDER_DELEGATE OFF) endif() +if(WITH_CYCLES_HYDRA_RENDER_DELEGATE AND (NOT WITH_BLENDER) AND (NOT WITH_CYCLES_STANDALONE)) + set(CYCLES_INSTALL_PATH ${CYCLES_INSTALL_PATH}/hdCycles/resources) +endif() if(WITH_CYCLES_CUDA_BINARIES AND (NOT WITH_CYCLES_CUBIN_COMPILER)) if(MSVC) diff --git a/intern/cycles/blender/object.cpp b/intern/cycles/blender/object.cpp index d8f236e0641..f77cbdf847d 100644 --- a/intern/cycles/blender/object.cpp +++ b/intern/cycles/blender/object.cpp @@ -66,9 +66,8 @@ bool BlenderSync::object_is_geometry(BObjectInfo &b_ob_info) } /* Other object types that are not meshes but evaluate to meshes are presented to render engines - * as separate instance objects. Metaballs and surface objects have not been affected by that - * change yet. */ - if (type == BL::Object::type_SURFACE || type == BL::Object::type_META) { + * as separate instance objects. Metaballs have not been affected by that change yet. */ + if (type == BL::Object::type_META) { return true; } diff --git a/intern/cycles/cmake/external_libs.cmake b/intern/cycles/cmake/external_libs.cmake index 6ad64d684c0..3ee92b7be88 100644 --- a/intern/cycles/cmake/external_libs.cmake +++ b/intern/cycles/cmake/external_libs.cmake @@ -69,6 +69,7 @@ if(CYCLES_STANDALONE_REPOSITORY) _set_default(OPENVDB_ROOT_DIR "${_cycles_lib_dir}/openvdb") _set_default(OSL_ROOT_DIR "${_cycles_lib_dir}/osl") _set_default(PNG_ROOT "${_cycles_lib_dir}/png") + _set_default(PUGIXML_ROOT_DIR "${_cycles_lib_dir}/pugixml") _set_default(TBB_ROOT_DIR "${_cycles_lib_dir}/tbb") _set_default(TIFF_ROOT "${_cycles_lib_dir}/tiff") _set_default(ZLIB_ROOT "${_cycles_lib_dir}/zlib") @@ -81,6 +82,23 @@ if(CYCLES_STANDALONE_REPOSITORY) endif() ########################################################################### +# USD +########################################################################### + +if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_HYDRA_RENDER_DELEGATE) + set(WITH_USD ON) +endif() +if(WITH_CYCLES_HYDRA_RENDER_DELEGATE) + find_package(pxr CONFIG REQUIRED PATHS ${PXR_ROOT} ${USD_ROOT} NO_DEFAULT_PATH) + if(pxr_FOUND) + set(PXR_LIBRARY_DIR ${PXR_CMAKE_DIR}/lib) + set(USD_INCLUDE_DIRS ${PXR_INCLUDE_DIRS}) + else() + set(WITH_USD OFF) + endif() +endif() + +########################################################################### # Zlib ########################################################################### @@ -126,31 +144,40 @@ if(CYCLES_STANDALONE_REPOSITORY) -DOIIO_STATIC_DEFINE ) + set(OPENIMAGEIO_INCLUDE_DIR ${OPENIMAGEIO_ROOT_DIR}/include) + set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO_INCLUDE_DIR} ${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO) # Special exceptions for libraries which needs explicit debug version - set(OPENIMAGEIO_LIBRARY + set(OPENIMAGEIO_LIBRARIES optimized ${OPENIMAGEIO_ROOT_DIR}/lib/OpenImageIO.lib optimized ${OPENIMAGEIO_ROOT_DIR}/lib/OpenImageIO_Util.lib debug ${OPENIMAGEIO_ROOT_DIR}/lib/OpenImageIO_d.lib debug ${OPENIMAGEIO_ROOT_DIR}/lib/OpenImageIO_Util_d.lib ) - endif() - find_package(OpenImageIO REQUIRED) - if(OPENIMAGEIO_PUGIXML_FOUND) - set(PUGIXML_INCLUDE_DIR "${OPENIMAGEIO_INCLUDE_DIR/OpenImageIO}") - set(PUGIXML_LIBRARIES "") + set(PUGIXML_INCLUDE_DIR ${PUGIXML_ROOT_DIR}/include) + set(PUGIXML_LIBRARIES + optimized ${PUGIXML_ROOT_DIR}/lib/pugixml.lib + debug ${PUGIXML_ROOT_DIR}/lib/pugixml_d.lib + ) else() - find_package(PugiXML REQUIRED) + find_package(OpenImageIO REQUIRED) + if(OPENIMAGEIO_PUGIXML_FOUND) + set(PUGIXML_INCLUDE_DIR "${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO") + set(PUGIXML_LIBRARIES "") + else() + find_package(PugiXML REQUIRED) + endif() endif() # Dependencies if(MSVC AND EXISTS ${_cycles_lib_dir}) set(OPENJPEG_INCLUDE_DIR ${OPENJPEG}/include/openjpeg-2.3) - set(OPENJPEG_LIBRARY ${_cycles_lib_dir}/openjpeg/lib/openjp2${CMAKE_STATIC_LIBRARY_SUFFIX}) + set(OPENJPEG_LIBRARIES ${_cycles_lib_dir}/openjpeg/lib/openjp2${CMAKE_STATIC_LIBRARY_SUFFIX}) + else() + find_package(OpenJPEG REQUIRED) endif() find_package(JPEG REQUIRED) - find_package(OpenJPEG REQUIRED) find_package(TIFF REQUIRED) find_package(PNG REQUIRED) endif() @@ -161,76 +188,70 @@ endif() if(CYCLES_STANDALONE_REPOSITORY) if(MSVC AND EXISTS ${_cycles_lib_dir}) - set(OPENEXR_IEX_LIBRARY + set(OPENEXR_INCLUDE_DIR ${OPENEXR_ROOT_DIR}/include) + set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR_ROOT_DIR}/include/OpenEXR) + set(OPENEXR_LIBRARIES optimized ${OPENEXR_ROOT_DIR}/lib/Iex_s.lib - debug ${OPENEXR_ROOT_DIR}/lib/Iex_s_d.lib - ) - set(OPENEXR_HALF_LIBRARY optimized ${OPENEXR_ROOT_DIR}/lib/Half_s.lib - debug ${OPENEXR_ROOT_DIR}/lib/Half_s_d.lib - ) - set(OPENEXR_ILMIMF_LIBRARY optimized ${OPENEXR_ROOT_DIR}/lib/IlmImf_s.lib - debug ${OPENEXR_ROOT_DIR}/lib/IlmImf_s_d.lib - ) - set(OPENEXR_IMATH_LIBRARY optimized ${OPENEXR_ROOT_DIR}/lib/Imath_s.lib - debug ${OPENEXR_ROOT_DIR}/lib/Imath_s_d.lib - ) - set(OPENEXR_ILMTHREAD_LIBRARY optimized ${OPENEXR_ROOT_DIR}/lib/IlmThread_s.lib + debug ${OPENEXR_ROOT_DIR}/lib/Iex_s_d.lib + debug ${OPENEXR_ROOT_DIR}/lib/Half_s_d.lib + debug ${OPENEXR_ROOT_DIR}/lib/IlmImf_s_d.lib + debug ${OPENEXR_ROOT_DIR}/lib/Imath_s_d.lib debug ${OPENEXR_ROOT_DIR}/lib/IlmThread_s_d.lib ) + else() + find_package(OpenEXR REQUIRED) endif() - - find_package(OpenEXR REQUIRED) endif() ########################################################################### # OpenShadingLanguage & LLVM ########################################################################### -if(WITH_CYCLES_OSL) - if(CYCLES_STANDALONE_REPOSITORY) - if(EXISTS ${_cycles_lib_dir}) - set(LLVM_STATIC ON) - endif() +if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_OSL) + if(EXISTS ${_cycles_lib_dir}) + set(LLVM_STATIC ON) + endif() + if(MSVC AND EXISTS ${_cycles_lib_dir}) + # TODO(sergey): On Windows llvm-config doesn't give proper results for the + # library names, use hardcoded libraries for now. + file(GLOB _llvm_libs_release ${LLVM_ROOT_DIR}/lib/*.lib) + file(GLOB _llvm_libs_debug ${LLVM_ROOT_DIR}/debug/lib/*.lib) + set(_llvm_libs) + foreach(_llvm_lib_path ${_llvm_libs_release}) + get_filename_component(_llvm_lib_name ${_llvm_lib_path} ABSOLUTE) + list(APPEND _llvm_libs optimized ${_llvm_lib_name}) + endforeach() + foreach(_llvm_lib_path ${_llvm_libs_debug}) + get_filename_component(_llvm_lib_name ${_llvm_lib_path} ABSOLUTE) + list(APPEND _llvm_libs debug ${_llvm_lib_name}) + endforeach() + set(LLVM_LIBRARY ${_llvm_libs}) + unset(_llvm_lib_name) + unset(_llvm_lib_path) + unset(_llvm_libs) + unset(_llvm_libs_debug) + unset(_llvm_libs_release) + + set(OSL_INCLUDE_DIR ${OSL_ROOT_DIR}/include) + set(OSL_LIBRARIES + optimized ${OSL_ROOT_DIR}/lib/oslcomp.lib + optimized ${OSL_ROOT_DIR}/lib/oslexec.lib + optimized ${OSL_ROOT_DIR}/lib/oslquery.lib + debug ${OSL_ROOT_DIR}/lib/oslcomp_d.lib + debug ${OSL_ROOT_DIR}/lib/oslexec_d.lib + debug ${OSL_ROOT_DIR}/lib/oslquery_d.lib + ${PUGIXML_LIBRARIES} + ) + + find_program(OSL_COMPILER NAMES oslc PATHS ${OSL_ROOT_DIR}/bin) + else() find_package(OSL REQUIRED) find_package(LLVM REQUIRED) - - if(MSVC AND EXISTS ${_cycles_lib_dir}) - # TODO(sergey): On Windows llvm-config doesn't give proper results for the - # library names, use hardcoded libraries for now. - file(GLOB _llvm_libs_release ${LLVM_ROOT_DIR}/lib/*.lib) - file(GLOB _llvm_libs_debug ${LLVM_ROOT_DIR}/debug/lib/*.lib) - set(_llvm_libs) - foreach(_llvm_lib_path ${_llvm_libs_release}) - get_filename_component(_llvm_lib_name ${_llvm_lib_path} ABSOLUTE) - list(APPEND _llvm_libs optimized ${_llvm_lib_name}) - endforeach() - foreach(_llvm_lib_path ${_llvm_libs_debug}) - get_filename_component(_llvm_lib_name ${_llvm_lib_path} ABSOLUTE) - list(APPEND _llvm_libs debug ${_llvm_lib_name}) - endforeach() - set(LLVM_LIBRARY ${_llvm_libs}) - unset(_llvm_lib_name) - unset(_llvm_lib_path) - unset(_llvm_libs) - unset(_llvm_libs_debug) - unset(_llvm_libs_release) - - set(OSL_LIBRARIES - optimized ${OSL_ROOT_DIR}/lib/oslcomp.lib - optimized ${OSL_ROOT_DIR}/lib/oslexec.lib - optimized ${OSL_ROOT_DIR}/lib/oslquery.lib - optimized ${OSL_ROOT_DIR}/lib/pugixml.lib - debug ${OSL_ROOT_DIR}/lib/oslcomp_d.lib - debug ${OSL_ROOT_DIR}/lib/oslexec_d.lib - debug ${OSL_ROOT_DIR}/lib/oslquery_d.lib - debug ${OSL_ROOT_DIR}/lib/pugixml_d.lib - ) - endif() endif() endif() @@ -238,22 +259,23 @@ endif() # OpenColorIO ########################################################################### -if(WITH_CYCLES_OPENCOLORIO) - if(CYCLES_STANDALONE_REPOSITORY) - find_package(OpenColorIO REQUIRED) - set(WITH_OPENCOLORIO ON) +if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_OPENCOLORIO) + set(WITH_OPENCOLORIO ON) - if(MSVC AND EXISTS ${_cycles_lib_dir}) - set(OPENCOLORIO_LIBPATH ${_cycles_lib_dir}/opencolorio/lib) - set(OPENCOLORIO_LIBRARIES - optimized ${OPENCOLORIO_LIBPATH}/OpenColorIO.lib - optimized ${OPENCOLORIO_LIBPATH}/tinyxml.lib - optimized ${OPENCOLORIO_LIBPATH}/libyaml-cpp.lib - debug ${OPENCOLORIO_LIBPATH}/OpencolorIO_d.lib - debug ${OPENCOLORIO_LIBPATH}/tinyxml_d.lib - debug ${OPENCOLORIO_LIBPATH}/libyaml-cpp_d.lib - ) - endif() + if(MSVC AND EXISTS ${_cycles_lib_dir}) + set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO_ROOT_DIR}/include) + set(OPENCOLORIO_LIBRARIES + optimized ${OPENCOLORIO_ROOT_DIR}/lib/OpenColorIO.lib + optimized ${OPENCOLORIO_ROOT_DIR}/lib/libyaml-cpp.lib + optimized ${OPENCOLORIO_ROOT_DIR}/lib/libexpatMD.lib + optimized ${OPENCOLORIO_ROOT_DIR}/lib/pystring.lib + debug ${OPENCOLORIO_ROOT_DIR}/lib/OpencolorIO_d.lib + debug ${OPENCOLORIO_ROOT_DIR}/lib/libyaml-cpp_d.lib + debug ${OPENCOLORIO_ROOT_DIR}/lib/libexpatdMD.lib + debug ${OPENCOLORIO_ROOT_DIR}/lib/pystring_d.lib + ) + else() + find_package(OpenColorIO REQUIRED) endif() endif() @@ -274,22 +296,59 @@ if(CYCLES_STANDALONE_REPOSITORY) endif() endif() - set(__boost_packages filesystem regex system thread date_time) - if(WITH_CYCLES_OSL) - list(APPEND __boost_packages wave) - endif() - find_package(Boost 1.48 COMPONENTS ${__boost_packages} REQUIRED) - if(NOT Boost_FOUND) - # Try to find non-multithreaded if -mt not found, this flag - # doesn't matter for us, it has nothing to do with thread - # safety, but keep it to not disturb build setups. - set(Boost_USE_MULTITHREADED OFF) - find_package(Boost 1.48 COMPONENTS ${__boost_packages}) + if(MSVC AND EXISTS ${_cycles_lib_dir}) + set(BOOST_INCLUDE_DIR ${BOOST_ROOT}/include) + set(BOOST_VERSION_HEADER ${BOOST_INCLUDE_DIR}/boost/version.hpp) + if(EXISTS ${BOOST_VERSION_HEADER}) + file(STRINGS "${BOOST_VERSION_HEADER}" BOOST_LIB_VERSION REGEX "#define BOOST_LIB_VERSION ") + if(BOOST_LIB_VERSION MATCHES "#define BOOST_LIB_VERSION \"([0-9_]+)\"") + set(BOOST_VERSION "${CMAKE_MATCH_1}") + endif() + endif() + if(NOT BOOST_VERSION) + message(FATAL_ERROR "Unable to determine Boost version") + endif() + set(BOOST_POSTFIX "vc141-mt-x64-${BOOST_VERSION}.lib") + set(BOOST_DEBUG_POSTFIX "vc141-mt-gd-x64-${BOOST_VERSION}.lib") + set(BOOST_LIBRARIES + optimized ${BOOST_ROOT}/lib/libboost_date_time-${BOOST_POSTFIX} + optimized ${BOOST_ROOT}/lib/libboost_filesystem-${BOOST_POSTFIX} + optimized ${BOOST_ROOT}/lib/libboost_regex-${BOOST_POSTFIX} + optimized ${BOOST_ROOT}/lib/libboost_system-${BOOST_POSTFIX} + optimized ${BOOST_ROOT}/lib/libboost_thread-${BOOST_POSTFIX} + optimized ${BOOST_ROOT}/lib/libboost_chrono-${BOOST_POSTFIX} + debug ${BOOST_ROOT}/lib/libboost_date_time-${BOOST_DEBUG_POSTFIX} + debug ${BOOST_ROOT}/lib/libboost_filesystem-${BOOST_DEBUG_POSTFIX} + debug ${BOOST_ROOT}/lib/libboost_regex-${BOOST_DEBUG_POSTFIX} + debug ${BOOST_ROOT}/lib/libboost_system-${BOOST_DEBUG_POSTFIX} + debug ${BOOST_ROOT}/lib/libboost_thread-${BOOST_DEBUG_POSTFIX} + debug ${BOOST_ROOT}/lib/libboost_chrono-${BOOST_DEBUG_POSTFIX} + ) + if(WITH_CYCLES_OSL) + set(BOOST_LIBRARIES ${BOOST_LIBRARIES} + optimized ${BOOST_ROOT}/lib/libboost_wave-${BOOST_POSTFIX} + debug ${BOOST_ROOT}/lib/libboost_wave-${BOOST_DEBUG_POSTFIX}) + endif() + else() + set(__boost_packages filesystem regex system thread date_time) + if(WITH_CYCLES_OSL) + list(APPEND __boost_packages wave) + endif() + find_package(Boost 1.48 COMPONENTS ${__boost_packages} REQUIRED) + if(NOT Boost_FOUND) + # Try to find non-multithreaded if -mt not found, this flag + # doesn't matter for us, it has nothing to do with thread + # safety, but keep it to not disturb build setups. + set(Boost_USE_MULTITHREADED OFF) + find_package(Boost 1.48 COMPONENTS ${__boost_packages}) + endif() + unset(__boost_packages) + + set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) + set(BOOST_LIBRARIES ${Boost_LIBRARIES}) + set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS}) endif() - unset(__boost_packages) - set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) - set(BOOST_LIBRARIES ${Boost_LIBRARIES}) - set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS}) + set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB") endif() @@ -297,47 +356,30 @@ endif() # Embree ########################################################################### -if(WITH_CYCLES_EMBREE) - if(CYCLES_STANDALONE_REPOSITORY) - if(MSVC AND EXISTS ${_cycles_lib_dir}) - set(EMBREE_TASKING_LIBRARY - optimized ${EMBREE_ROOT_DIR}/lib/tasking.lib - debug ${EMBREE_ROOT_DIR}/lib/tasking_d.lib - ) - set(EMBREE_EMBREE3_LIBRARY - optimized ${EMBREE_ROOT_DIR}/lib/embree3.lib - debug ${EMBREE_ROOT_DIR}/lib/embree3_d.lib - ) - set(EMBREE_EMBREE_AVX_LIBRARY - optimized ${EMBREE_ROOT_DIR}/lib/embree_avx.lib - debug ${EMBREE_ROOT_DIR}/lib/embree_avx_d.lib - ) - set(EMBREE_EMBREE_AVX2_LIBRARY - optimized ${EMBREE_ROOT_DIR}/lib/embree_avx2.lib - debug ${EMBREE_ROOT_DIR}/lib/embree_avx2_d.lib - ) - set(EMBREE_EMBREE_SSE42_LIBRARY - optimized ${EMBREE_ROOT_DIR}/lib/embree_sse42.lib - debug ${EMBREE_ROOT_DIR}/lib/embree_sse42_d.lib - ) - set(EMBREE_LEXERS_LIBRARY - optimized ${EMBREE_ROOT_DIR}/lib/lexers.lib - debug ${EMBREE_ROOT_DIR}/lib/lexers_d.lib - ) - set(EMBREE_MATH_LIBRARY - optimized ${EMBREE_ROOT_DIR}/lib/math.lib - debug ${EMBREE_ROOT_DIR}/lib/math_d.lib - ) - set(EMBREE_SIMD_LIBRARY - optimized ${EMBREE_ROOT_DIR}/lib/simd.lib - debug ${EMBREE_ROOT_DIR}/lib/simd_d.lib - ) - set(EMBREE_SYS_LIBRARY - optimized ${EMBREE_ROOT_DIR}/lib/sys.lib - debug ${EMBREE_ROOT_DIR}/lib/sys_d.lib - ) - endif() - +if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_EMBREE) + if(MSVC AND EXISTS ${_cycles_lib_dir}) + set(EMBREE_INCLUDE_DIRS ${EMBREE_ROOT_DIR}/include) + set(EMBREE_LIBRARIES + optimized ${EMBREE_ROOT_DIR}/lib/embree3.lib + optimized ${EMBREE_ROOT_DIR}/lib/embree_avx2.lib + optimized ${EMBREE_ROOT_DIR}/lib/embree_avx.lib + optimized ${EMBREE_ROOT_DIR}/lib/embree_sse42.lib + optimized ${EMBREE_ROOT_DIR}/lib/lexers.lib + optimized ${EMBREE_ROOT_DIR}/lib/math.lib + optimized ${EMBREE_ROOT_DIR}/lib/simd.lib + optimized ${EMBREE_ROOT_DIR}/lib/tasking.lib + optimized ${EMBREE_ROOT_DIR}/lib/sys.lib + debug ${EMBREE_ROOT_DIR}/lib/embree3_d.lib + debug ${EMBREE_ROOT_DIR}/lib/embree_avx2_d.lib + debug ${EMBREE_ROOT_DIR}/lib/embree_avx_d.lib + debug ${EMBREE_ROOT_DIR}/lib/embree_sse42_d.lib + debug ${EMBREE_ROOT_DIR}/lib/lexers_d.lib + debug ${EMBREE_ROOT_DIR}/lib/math_d.lib + debug ${EMBREE_ROOT_DIR}/lib/simd_d.lib + debug ${EMBREE_ROOT_DIR}/lib/sys_d.lib + debug ${EMBREE_ROOT_DIR}/lib/tasking_d.lib + ) + else() find_package(Embree 3.8.0 REQUIRED) endif() endif() @@ -346,29 +388,45 @@ endif() # Logging ########################################################################### -if(WITH_CYCLES_LOGGING) - if(CYCLES_STANDALONE_REPOSITORY) - find_package(Glog REQUIRED) - find_package(Gflags REQUIRED) - endif() +if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_LOGGING) + find_package(Glog REQUIRED) + find_package(Gflags REQUIRED) endif() ########################################################################### # OpenSubdiv ########################################################################### -if(WITH_CYCLES_OPENSUBDIV) - if(CYCLES_STANDALONE_REPOSITORY) - find_package(OpenSubdiv REQUIRED) - set(WITH_OPENSUBDIV ON) +if(WITH_CYCLES_HYDRA_RENDER_DELEGATE AND PXR_LIBRARY_DIR AND (WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV)) + find_library(OPENSUBDIV_LIBRARY_CPU_DEBUG_PXR NAMES osdCPU_d osdCPU PATHS ${PXR_LIBRARY_DIR} NO_CACHE NO_DEFAULT_PATH) + find_library(OPENSUBDIV_LIBRARY_GPU_DEBUG_PXR NAMES osdGPU_d osdGPU PATHS ${PXR_LIBRARY_DIR} NO_CACHE NO_DEFAULT_PATH) + find_library(OPENSUBDIV_LIBRARY_CPU_RELEASE_PXR NAMES osdCPU PATHS ${PXR_LIBRARY_DIR} NO_CACHE NO_DEFAULT_PATH) + find_library(OPENSUBDIV_LIBRARY_GPU_RELEASE_PXR NAMES osdGPU PATHS ${PXR_LIBRARY_DIR} NO_CACHE NO_DEFAULT_PATH) + if(OPENSUBDIV_LIBRARY_CPU_RELEASE_PXR AND OPENSUBDIV_LIBRARY_GPU_RELEASE_PXR) + set(OPENSUBDIV_INCLUDE_DIRS ${PXR_INCLUDE_DIRS}) + set(OPENSUBDIV_LIBRARIES + optimized ${OPENSUBDIV_LIBRARY_CPU_RELEASE_PXR} + optimized ${OPENSUBDIV_LIBRARY_GPU_RELEASE_PXR} + debug ${OPENSUBDIV_LIBRARY_CPU_DEBUG_PXR} + debug ${OPENSUBDIV_LIBRARY_GPU_DEBUG_PXR} + ) + endif() +endif() + +if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_OPENSUBDIV) + set(WITH_OPENSUBDIV ON) + if(NOT OPENSUBDIV_LIBRARY_CPU_RELEASE_PXR OR NOT OPENSUBDIV_LIBRARY_GPU_RELEASE_PXR) if(MSVC AND EXISTS ${_cycles_lib_dir}) + set(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV_ROOT_DIR}/include) set(OPENSUBDIV_LIBRARIES optimized ${OPENSUBDIV_ROOT_DIR}/lib/osdCPU.lib optimized ${OPENSUBDIV_ROOT_DIR}/lib/osdGPU.lib debug ${OPENSUBDIV_ROOT_DIR}/lib/osdCPU_d.lib debug ${OPENSUBDIV_ROOT_DIR}/lib/osdGPU_d.lib ) + else() + find_package(OpenSubdiv REQUIRED) endif() endif() endif() @@ -377,18 +435,29 @@ endif() # OpenVDB ########################################################################### -if(WITH_CYCLES_OPENVDB) - if(CYCLES_STANDALONE_REPOSITORY) +if(WITH_CYCLES_HYDRA_RENDER_DELEGATE AND PXR_LIBRARY_DIR AND (WITH_OPENVDB OR WITH_CYCLES_OPENVDB)) + find_library(OPENVDB_LIBRARY_PXR NAMES openvdb PATHS ${PXR_LIBRARY_DIR} NO_CACHE NO_DEFAULT_PATH) + if(OPENVDB_LIBRARY_PXR) + set(OPENVDB_INCLUDE_DIRS ${PXR_INCLUDE_DIRS}) + set(OPENVDB_LIBRARIES ${OPENVDB_LIBRARY_PXR}) + endif() +endif() + +if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_OPENVDB) + set(WITH_OPENVDB ON) + set(OPENVDB_DEFINITIONS -DNOMINMAX -D_USE_MATH_DEFINES) + + if(NOT OPENVDB_LIBRARY_PXR) + find_package(OpenVDB REQUIRED) + if(MSVC AND EXISTS ${_cycles_lib_dir}) set(BLOSC_LIBRARY - optimized ${BLOSC_ROOT_DIR}/lib/libblosc.lib - debug ${BLOSC_ROOT_DIR}/lib/libblosc_d.lib) + optimized ${BLOSC_ROOT_DIR}/lib/libblosc.lib + debug ${BLOSC_ROOT_DIR}/lib/libblosc_d.lib + ) + else() + find_package(Blosc REQUIRED) endif() - - find_package(OpenVDB REQUIRED) - find_package(Blosc REQUIRED) - set(WITH_OPENVDB ON) - set(OPENVDB_DEFINITIONS -DNOMINMAX -D_USE_MATH_DEFINES) endif() endif() @@ -396,21 +465,21 @@ endif() # OpenImageDenoise ########################################################################### -if(WITH_CYCLES_OPENIMAGEDENOISE) - if(CYCLES_STANDALONE_REPOSITORY) - find_package(OpenImageDenoise REQUIRED) - set(WITH_OPENIMAGEDENOISE ON) - - if(MSVC AND EXISTS ${_cycles_lib_dir}) - set(OPENIMAGEDENOISE_LIBRARIES - optimized ${OPENIMAGEDENOISE_ROOT_DIR}/lib/OpenImageDenoise.lib - optimized ${OPENIMAGEDENOISE_ROOT_DIR}/lib/common.lib - optimized ${OPENIMAGEDENOISE_ROOT_DIR}/lib/dnnl.lib - debug ${OPENIMAGEDENOISE_ROOT_DIR}/lib/OpenImageDenoise_d.lib - debug ${OPENIMAGEDENOISE_ROOT_DIR}/lib/common_d.lib - debug ${OPENIMAGEDENOISE_ROOT_DIR}/lib/dnnl_d.lib) - endif() +if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_OPENIMAGEDENOISE) + set(WITH_OPENIMAGEDENOISE ON) + if(MSVC AND EXISTS ${_cycles_lib_dir}) + set(OPENIMAGEDENOISE_INCLUDE_DIRS ${OPENIMAGEDENOISE_ROOT_DIR}/include) + set(OPENIMAGEDENOISE_LIBRARIES + optimized ${OPENIMAGEDENOISE_ROOT_DIR}/lib/OpenImageDenoise.lib + optimized ${OPENIMAGEDENOISE_ROOT_DIR}/lib/common.lib + optimized ${OPENIMAGEDENOISE_ROOT_DIR}/lib/dnnl.lib + debug ${OPENIMAGEDENOISE_ROOT_DIR}/lib/OpenImageDenoise_d.lib + debug ${OPENIMAGEDENOISE_ROOT_DIR}/lib/common_d.lib + debug ${OPENIMAGEDENOISE_ROOT_DIR}/lib/dnnl_d.lib + ) + else() + find_package(OpenImageDenoise REQUIRED) endif() endif() @@ -418,15 +487,30 @@ endif() # TBB ########################################################################### -if(CYCLES_STANDALONE_REPOSITORY) - if(MSVC AND EXISTS ${_cycles_lib_dir}) - set(TBB_LIBRARY - optimized ${TBB_ROOT_DIR}/lib/tbb.lib - debug ${TBB_ROOT_DIR}/lib/debug/tbb_debug.lib +if(WITH_CYCLES_HYDRA_RENDER_DELEGATE AND PXR_LIBRARY_DIR) + find_library(TBB_LIBRARY_DEBUG_PXR NAMES tbb_debug tbb PATHS ${PXR_LIBRARY_DIR} NO_CACHE NO_DEFAULT_PATH) + find_library(TBB_LIBRARY_RELEASE_PXR NAMES tbb PATHS ${PXR_LIBRARY_DIR} NO_CACHE NO_DEFAULT_PATH) + if(TBB_LIBRARY_RELEASE_PXR) + set(TBB_INCLUDE_DIRS ${PXR_INCLUDE_DIRS}) + set(TBB_LIBRARIES + optimized ${TBB_LIBRARY_RELEASE_PXR} + debug ${TBB_LIBRARY_DEBUG_PXR} ) endif() +endif() - find_package(TBB REQUIRED) +if(CYCLES_STANDALONE_REPOSITORY) + if(NOT TBB_LIBRARY_RELEASE_PXR) + if(MSVC AND EXISTS ${_cycles_lib_dir}) + set(TBB_INCLUDE_DIRS ${TBB_ROOT_DIR}/include) + set(TBB_LIBRARIES + optimized ${TBB_ROOT_DIR}/lib/tbb.lib + debug ${TBB_ROOT_DIR}/lib/tbb_debug.lib + ) + else() + find_package(TBB REQUIRED) + endif() + endif() endif() ########################################################################### @@ -438,9 +522,9 @@ if(CYCLES_STANDALONE_REPOSITORY) set(GLEW_LIBRARY "${_cycles_lib_dir}/opengl/lib/glew.lib") set(GLEW_INCLUDE_DIR "${_cycles_lib_dir}/opengl/include") add_definitions(-DGLEW_STATIC) + else() + find_package(GLEW REQUIRED) endif() - - find_package(GLEW REQUIRED) else() # Workaround for unconventional variable name use in Blender. set(GLEW_INCLUDE_DIR "${GLEW_INCLUDE_PATH}") @@ -466,11 +550,11 @@ if(CYCLES_STANDALONE_REPOSITORY) find_package(OpenGL REQUIRED) - set(CYCLES_GL_LIBRARIES - ${OPENGL_gl_LIBRARY} - ${OPENGL_glu_LIBRARY} - ${GLEW_LIBRARY} - ) + set(CYCLES_GL_LIBRARIES + ${OPENGL_gl_LIBRARY} + ${OPENGL_glu_LIBRARY} + ${GLEW_LIBRARY} + ) else() set(CYCLES_GL_LIBRARIES bf_intern_glew_mx diff --git a/intern/cycles/cmake/macros.cmake b/intern/cycles/cmake/macros.cmake index e69e31f8e52..7c14fd87518 100644 --- a/intern/cycles/cmake/macros.cmake +++ b/intern/cycles/cmake/macros.cmake @@ -144,13 +144,13 @@ macro(cycles_install_libraries target) if(CMAKE_BUILD_TYPE STREQUAL "Debug") install( FILES - ${TBB_ROOT_DIR}/lib/debug/tbb_debug${CMAKE_SHARED_LIBRARY_SUFFIX} + ${TBB_ROOT_DIR}/bin/tbb_debug${CMAKE_SHARED_LIBRARY_SUFFIX} ${OPENVDB_ROOT_DIR}/bin/openvdb_d${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION $<TARGET_FILE_DIR:${target}>) else() install( FILES - ${TBB_ROOT_DIR}/lib/tbb${CMAKE_SHARED_LIBRARY_SUFFIX} + ${TBB_ROOT_DIR}/bin/tbb${CMAKE_SHARED_LIBRARY_SUFFIX} ${OPENVDB_ROOT_DIR}/bin/openvdb${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION $<TARGET_FILE_DIR:${target}>) endif() diff --git a/intern/cycles/hydra/CMakeLists.txt b/intern/cycles/hydra/CMakeLists.txt index 703bd955135..d632cd01a02 100644 --- a/intern/cycles/hydra/CMakeLists.txt +++ b/intern/cycles/hydra/CMakeLists.txt @@ -91,35 +91,15 @@ target_compile_definitions(hdCyclesStatic ) target_link_libraries(hdCyclesStatic + PUBLIC + hd + hgi PRIVATE - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}hd${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}plug${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}tf${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}trace${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}vt${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}work${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}sdf${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}cameraUtil${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}hf${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}pxOsd${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}gf${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}arch${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}hgi${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}glf${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}hdx${CMAKE_LINK_LIBRARY_SUFFIX} - ${USD_LIBRARY_DIR}/${PXR_LIB_PREFIX}usdGeom${CMAKE_LINK_LIBRARY_SUFFIX} cycles_scene cycles_session cycles_graph ) -if(USD_PYTHON_LIBRARIES) - target_link_libraries(hdCyclesStatic - PRIVATE - ${USD_PYTHON_LIBRARIES} - ) -endif() - set(HdCyclesPluginName hdCycles) add_library(${HdCyclesPluginName} SHARED plugin.h @@ -144,12 +124,6 @@ target_link_libraries(${HdCyclesPluginName} hdCyclesStatic ) -target_link_directories(${HdCyclesPluginName} - BEFORE - PRIVATE - ${USD_LIBRARY_DIR} -) - cycles_target_link_libraries(${HdCyclesPluginName}) if(WITH_CYCLES_BLENDER) @@ -162,9 +136,10 @@ endif() delayed_install("" $<TARGET_FILE:${HdCyclesPluginName}> ${CYCLES_HYDRA_INSTALL_PATH}) -set(PLUG_INFO_ROOT "..") -set(PLUG_INFO_LIBRARY_PATH "../${HdCyclesPluginName}${CMAKE_SHARED_LIBRARY_SUFFIX}") -set(PLUG_INFO_RESOURCE_PATH "resources") +set(PLUG_INFO_ROOT "..") + +file(RELATIVE_PATH PLUG_INFO_LIBRARY_PATH "${CYCLES_HYDRA_INSTALL_PATH}/${HdCyclesPluginName}" "${CYCLES_HYDRA_INSTALL_PATH}/${HdCyclesPluginName}${CMAKE_SHARED_LIBRARY_SUFFIX}") +file(RELATIVE_PATH PLUG_INFO_RESOURCE_PATH "${CYCLES_HYDRA_INSTALL_PATH}/${HdCyclesPluginName}" "${CYCLES_INSTALL_PATH}") configure_file(resources/plugInfo.json ${CMAKE_CURRENT_BINARY_DIR}/resources/plugInfo.json diff --git a/intern/cycles/hydra/camera.cpp b/intern/cycles/hydra/camera.cpp index 05f1c32d3c4..5d961a6a090 100644 --- a/intern/cycles/hydra/camera.cpp +++ b/intern/cycles/hydra/camera.cpp @@ -13,6 +13,15 @@ HDCYCLES_NAMESPACE_OPEN_SCOPE extern Transform convert_transform(const GfMatrix4d &matrix); +#if PXR_VERSION < 2102 +// clang-format off +TF_DEFINE_PRIVATE_TOKENS(_tokens, + (projection) + (orthographic) +); +// clang-format on +#endif + HdCyclesCamera::HdCyclesCamera(const SdfPath &sprimId) : HdCamera(sprimId) { #if PXR_VERSION >= 2102 @@ -73,6 +82,7 @@ void HdCyclesCamera::Sync(HdSceneDelegate *sceneDelegate, } #endif +#if PXR_VERSION < 2111 if (*dirtyBits & DirtyBits::DirtyProjMatrix) { value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->projectionMatrix); if (!value.IsEmpty()) { @@ -113,6 +123,7 @@ void HdCyclesCamera::Sync(HdSceneDelegate *sceneDelegate, #endif } } +#endif if (*dirtyBits & DirtyBits::DirtyWindowPolicy) { value = sceneDelegate->GetCameraParamValue(id, HdCameraTokens->windowPolicy); @@ -137,9 +148,9 @@ void HdCyclesCamera::Sync(HdSceneDelegate *sceneDelegate, GfCamera::Orthographic); } #else - value = sceneDelegate->GetCameraParamValue(id, UsdGeomTokens->projection); + value = sceneDelegate->GetCameraParamValue(id, _tokens->projection); if (!value.IsEmpty()) { - _data.SetProjection(value.Get<TfToken>() != UsdGeomTokens->orthographic ? + _data.SetProjection(value.Get<TfToken>() != _tokens->orthographic ? GfCamera::Perspective : GfCamera::Orthographic); } diff --git a/intern/cycles/hydra/config.h b/intern/cycles/hydra/config.h index 034be302d9f..479980e0c11 100644 --- a/intern/cycles/hydra/config.h +++ b/intern/cycles/hydra/config.h @@ -40,5 +40,6 @@ class Session; class SessionParams; class Shader; class ShaderGraph; +class ShaderNode; class Volume; } // namespace CCL_NS diff --git a/intern/cycles/hydra/field.cpp b/intern/cycles/hydra/field.cpp index 8b92ddb6f1f..67945be9d52 100644 --- a/intern/cycles/hydra/field.cpp +++ b/intern/cycles/hydra/field.cpp @@ -12,11 +12,13 @@ HDCYCLES_NAMESPACE_OPEN_SCOPE +#if PXR_VERSION < 2108 // clang-format off TF_DEFINE_PRIVATE_TOKENS(_tokens, (fieldName) ); // clang-format on +#endif #ifdef WITH_OPENVDB class HdCyclesVolumeLoader : public VDBImageLoader { diff --git a/intern/cycles/hydra/material.cpp b/intern/cycles/hydra/material.cpp index a595102a605..b296d9f3751 100644 --- a/intern/cycles/hydra/material.cpp +++ b/intern/cycles/hydra/material.cpp @@ -40,8 +40,6 @@ TF_DEFINE_PRIVATE_TOKENS(CyclesMaterialTokens, ); // clang-format on -namespace { - // Simple class to handle remapping of USDPreviewSurface nodes and parameters to Cycles equivalents class UsdToCyclesMapping { using ParamMap = std::unordered_map<TfToken, ustring, TfToken::HashFunctor>; @@ -130,6 +128,8 @@ class UsdToCyclesTexture : public UsdToCyclesMapping { } }; +namespace { + class UsdToCycles { const UsdToCyclesMapping UsdPreviewSurface = { "principled_bsdf", @@ -183,11 +183,6 @@ TfStaticData<UsdToCycles> sUsdToCyles; } // namespace -struct HdCyclesMaterial::NodeDesc { - ShaderNode *node; - const UsdToCyclesMapping *mapping; -}; - HdCyclesMaterial::HdCyclesMaterial(const SdfPath &sprimId) : HdMaterial(sprimId) { } diff --git a/intern/cycles/hydra/material.h b/intern/cycles/hydra/material.h index 15925671bb8..5e08fd5c99e 100644 --- a/intern/cycles/hydra/material.h +++ b/intern/cycles/hydra/material.h @@ -34,9 +34,12 @@ class HdCyclesMaterial final : public PXR_NS::HdMaterial { return _shader; } - struct NodeDesc; - private: + struct NodeDesc { + CCL_NS::ShaderNode *node; + const class UsdToCyclesMapping *mapping; + }; + void Initialize(PXR_NS::HdRenderParam *renderParam); void UpdateParameters(NodeDesc &nodeDesc, diff --git a/intern/cycles/hydra/node_util.cpp b/intern/cycles/hydra/node_util.cpp index c7e49688f5c..bdf5786ed75 100644 --- a/intern/cycles/hydra/node_util.cpp +++ b/intern/cycles/hydra/node_util.cpp @@ -273,7 +273,7 @@ template<typename MatrixArray> array<Transform> convertToCyclesTransformArray(co array<Transform> cyclesArray; cyclesArray.reserve(valueData.size()); for (const auto &element : valueData) { - cyclesArray.push_back_reserved(convertMatrixToCycles<MatrixArray::value_type>(element)); + cyclesArray.push_back_reserved(convertMatrixToCycles<typename MatrixArray::value_type>(element)); } return cyclesArray; } diff --git a/intern/cycles/kernel/integrator/shade_surface.h b/intern/cycles/kernel/integrator/shade_surface.h index a9bf3b5b432..55bb08044ae 100644 --- a/intern/cycles/kernel/integrator/shade_surface.h +++ b/intern/cycles/kernel/integrator/shade_surface.h @@ -346,8 +346,8 @@ ccl_device_forceinline int integrate_surface_bsdf_bssrdf_bounce( } #ifdef __VOLUME__ -ccl_device_forceinline bool integrate_surface_volume_only_bounce(IntegratorState state, - ccl_private ShaderData *sd) +ccl_device_forceinline int integrate_surface_volume_only_bounce(IntegratorState state, + ccl_private ShaderData *sd) { if (!path_state_volume_next(state)) { return LABEL_NONE; diff --git a/intern/cycles/kernel/types.h b/intern/cycles/kernel/types.h index 9d9daaa0dda..db499a1e1bc 100644 --- a/intern/cycles/kernel/types.h +++ b/intern/cycles/kernel/types.h @@ -666,7 +666,7 @@ typedef struct AttributeDescriptor { /* For manifold next event estimation, we need space to store and evaluate * 2 closures (with extra data) on the refractive interfaces, in addition * to keeping the full sd at the current shading point. We need 4 because a - * refractive bsdf is instanced with a companion reflection bsdf, even though + * refractive BSDF is instanced with a companion reflection BSDF, even though * we only need the refractive one, and each of them requires 2 slots. */ #ifndef __CAUSTICS_MAX_CLOSURE__ # define CAUSTICS_MAX_CLOSURE 4 diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index a2a15416ae6..8152a27046f 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -180,7 +180,7 @@ bool Geometry::has_true_displacement() const } void Geometry::compute_bvh( - Device *device, DeviceScene *dscene, SceneParams *params, Progress *progress, int n, int total) + Device *device, DeviceScene *dscene, SceneParams *params, Progress *progress, size_t n, size_t total) { if (progress->get_cancel()) return; diff --git a/intern/cycles/scene/geometry.h b/intern/cycles/scene/geometry.h index bbb50d5cbfe..0c2e70d483d 100644 --- a/intern/cycles/scene/geometry.h +++ b/intern/cycles/scene/geometry.h @@ -110,8 +110,8 @@ class Geometry : public Node { DeviceScene *dscene, SceneParams *params, Progress *progress, - int n, - int total); + size_t n, + size_t total); virtual PrimitiveType primitive_type() const = 0; diff --git a/intern/cycles/session/merge.cpp b/intern/cycles/session/merge.cpp index a88ffee6409..316f56630d6 100644 --- a/intern/cycles/session/merge.cpp +++ b/intern/cycles/session/merge.cpp @@ -531,7 +531,7 @@ static void read_layer_samples(vector<MergeImage> &images, current_layer_samples.total = 0; current_layer_samples.per_pixel.resize(in_spec.width * in_spec.height); std::fill( - current_layer_samples.per_pixel.begin(), current_layer_samples.per_pixel.end(), 0); + current_layer_samples.per_pixel.begin(), current_layer_samples.per_pixel.end(), 0.0f); } if (layer.has_sample_pass) { diff --git a/release/datafiles/icons/ops.curves.sculpt_grow.dat b/release/datafiles/icons/ops.curves.sculpt_grow_shrink.dat Binary files differindex 9b3453085e4..9b3453085e4 100644 --- a/release/datafiles/icons/ops.curves.sculpt_grow.dat +++ b/release/datafiles/icons/ops.curves.sculpt_grow_shrink.dat diff --git a/release/datafiles/userdef/userdef_default.c b/release/datafiles/userdef/userdef_default.c index 7cf8158c42d..fba3c7882c6 100644 --- a/release/datafiles/userdef/userdef_default.c +++ b/release/datafiles/userdef/userdef_default.c @@ -23,7 +23,8 @@ const UserDef U_default = { USER_SCRIPT_AUTOEXEC_DISABLE | USER_NONEGFRAMES), .dupflag = USER_DUP_MESH | USER_DUP_CURVE | USER_DUP_SURF | USER_DUP_LATTICE | USER_DUP_FONT | USER_DUP_MBALL | USER_DUP_LAMP | USER_DUP_ARM | USER_DUP_CAMERA | USER_DUP_SPEAKER | - USER_DUP_ACT | USER_DUP_LIGHTPROBE | USER_DUP_GPENCIL, + USER_DUP_ACT | USER_DUP_LIGHTPROBE | USER_DUP_GPENCIL | USER_DUP_CURVES | + USER_DUP_POINTCLOUD, .pref_flag = USER_PREF_FLAG_SAVE, .savetime = 2, .tempdir = "", diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index cc764be6a2c..399c4519635 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -31,6 +31,12 @@ class Params: "context_menu_event", "cursor_set_event", "cursor_tweak_event", + # NOTE: this is intended to be used so pressing a button can then drag the current selection. + # This should not be used for button release values such as `CLICK` or `RELEASE` which should + # instead be bound to a binding that doesn't de-select all, this way: + # - Click-drag moves the current selection. + # - Click selects only the item at the cursor position. + # See: T97032. "use_tweak_select_passthrough", "use_tweak_tool_lmb_interaction", "use_mouse_emulate_3_button", @@ -451,7 +457,36 @@ def _template_items_change_frame(params): # Tool System Templates -def _template_items_tool_select(params, operator, cursor_operator, fallback): +def _template_items_tool_select( + params, operator, cursor_operator, *, + # Always use the cursor operator where possible, + # needed for time-line views where we always want to be able to scrub time. + cursor_prioritize=False, + fallback=False, +): + if not params.legacy and not fallback: + # Experimental support for LMB interaction for the tweak tool. see: T96544. + # NOTE: For RMB-select this is a much bigger change as it disables 3D cursor placement on LMB. + # For LMB-select this means an LMB -drag will not first de-select all (similar to node/graph editor). + select_passthrough = False + if params.select_mouse == 'LEFTMOUSE': + select_passthrough = params.use_tweak_select_passthrough + else: + if not cursor_prioritize: + select_passthrough = params.use_tweak_tool_lmb_interaction + + if select_passthrough: + return [ + (operator, {"type": 'LEFTMOUSE', "value": 'PRESS'}, + {"properties": [("deselect_all", True), ("select_passthrough", True)]}), + (operator, {"type": 'LEFTMOUSE', "value": 'CLICK'}, + {"properties": [("deselect_all", True)]}), + (operator, {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, + {"properties": [("deselect_all", False), ("toggle", True)]}), + ("transform.translate", {"type": 'LEFTMOUSE', "value": 'CLICK_DRAG'}, + {"properties": [("release_confirm", True)]}), + ] + if params.select_mouse == 'LEFTMOUSE': # By default use 'PRESS' for immediate select without quick delay. # Fallback key-maps 'CLICK' since 'PRESS' events passes through (allowing either click or drag). @@ -464,21 +499,15 @@ def _template_items_tool_select(params, operator, cursor_operator, fallback): {"properties": [("deselect_all", True)]}), (operator, {"type": 'LEFTMOUSE', "value": 'CLICK' if fallback else 'PRESS', "shift": True}, {"properties": [("toggle", True)]}), - ] - else: - # Experimental support for LMB interaction for the tweak tool. - if params.use_tweak_tool_lmb_interaction and not fallback: - return [ - (operator, {"type": 'LEFTMOUSE', "value": 'PRESS'}, - {"properties": [("deselect_all", True), ("select_passthrough", True)]}), - (operator, {"type": 'LEFTMOUSE', "value": 'CLICK'}, - {"properties": [("deselect_all", True)]}), - (operator, {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True}, - {"properties": [("deselect_all", False), ("toggle", True)]}), + + # Fallback key-map must transform as the primary tool is expected + # to be accessed via gizmos in this case. See: T96885. + *(() if not fallback else ( ("transform.translate", {"type": 'LEFTMOUSE', "value": 'CLICK_DRAG'}, {"properties": [("release_confirm", True)]}), - ] - + )) + ] + else: # For right mouse, set the cursor. return [ (cursor_operator, {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), @@ -2898,7 +2927,7 @@ def km_sequencer(params): ("transform.seq_slide", {"type": params.select_mouse, "value": 'CLICK_DRAG'}, {"properties": [("view2d_edge_pan", True)]}), ("transform.transform", {"type": 'E', "value": 'PRESS'}, - {"properties": [("mode", 'TIME_EXTEND'), ("view2d_edge_pan", True)]}), + {"properties": [("mode", 'TIME_EXTEND')]}), ("marker.add", {"type": 'M', "value": 'PRESS'}, None), ("marker.rename", {"type": 'M', "value": 'PRESS', "ctrl": True}, None), ("sequencer.select_side_of_frame", {"type": 'LEFT_BRACKET', "value": 'PRESS'}, @@ -4705,6 +4734,11 @@ def _template_paint_radial_control(paint, rotation=False, secondary_rotation=Fal def _template_view3d_select(*, type, value, legacy, select_passthrough, exclude_mod=None): # NOTE: `exclude_mod` is needed since we don't want this tool to exclude Control-RMB actions when this is used # as a tool key-map with RMB-select and `use_fallback_tool_rmb` is enabled. See T92467. + + # See: `use_tweak_select_passthrough` doc-string. + if select_passthrough and (value in {'CLICK', 'RELEASE'}): + select_passthrough = False + items = [( "view3d.select", {"type": type, "value": value, **{m: True for m in mods}}, @@ -4721,7 +4755,7 @@ def _template_view3d_select(*, type, value, legacy, select_passthrough, exclude_ (("toggle", "center", "enumerate"), ("shift", "ctrl", "alt")), ) if exclude_mod is None or exclude_mod not in mods] - if select_passthrough and (value == 'PRESS'): + if select_passthrough: # Add an additional click item to de-select all other items, # needed so pass-through is able to de-select other items. items.append(( @@ -4749,6 +4783,11 @@ def _template_view3d_gpencil_select(*, type, value, legacy, use_select_mouse=Tru def _template_uv_select(*, type, value, select_passthrough, legacy): + + # See: `use_tweak_select_passthrough` doc-string. + if select_passthrough and (value in {'CLICK', 'RELEASE'}): + select_passthrough = False + items = [ ("uv.select", {"type": type, "value": value}, {"properties": [ @@ -4759,7 +4798,7 @@ def _template_uv_select(*, type, value, select_passthrough, legacy): {"properties": [("toggle", True)]}), ] - if select_passthrough and (value == 'PRESS'): + if select_passthrough: # Add an additional click item to de-select all other items, # needed so pass-through is able to de-select other items. items.append(( @@ -5537,7 +5576,10 @@ def km_sculpt_curves(params): ) items.extend([ - ("sculpt_curves.brush_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), + ("sculpt_curves.brush_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS'}, + {"properties": [("mode", 'NORMAL')]}), + ("sculpt_curves.brush_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, + {"properties": [("mode", 'INVERT')]}), *_template_paint_radial_control("curves_sculpt"), ]) @@ -6376,7 +6418,7 @@ def km_image_editor_tool_uv_select(params, *, fallback): {"space_type": 'IMAGE_EDITOR', "region_type": 'WINDOW'}, {"items": [ *([] if (fallback and (params.select_mouse == 'RIGHTMOUSE')) else _template_items_tool_select( - params, "uv.select", "uv.cursor_set", fallback)), + params, "uv.select", "uv.cursor_set", fallback=fallback)), *([] if (not params.use_fallback_tool_rmb) else _template_uv_select( type=params.select_mouse, value=params.select_mouse_value, @@ -6587,7 +6629,7 @@ def km_3d_view_tool_select(params, *, fallback): {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, {"items": [ *([] if (fallback and (params.select_mouse == 'RIGHTMOUSE')) else _template_items_tool_select( - params, "view3d.select", "view3d.cursor3d", fallback)), + params, "view3d.select", "view3d.cursor3d", fallback=fallback)), *([] if (not params.use_fallback_tool_rmb) else _template_view3d_select( type=params.select_mouse, value=params.select_mouse_value, @@ -7524,7 +7566,7 @@ def km_3d_view_tool_edit_gpencil_select(params, *, fallback): {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, {"items": [ *([] if (fallback and (params.select_mouse == 'RIGHTMOUSE')) else _template_items_tool_select( - params, "gpencil.select", "view3d.cursor3d", fallback)), + params, "gpencil.select", "view3d.cursor3d", fallback=fallback)), *([] if (not params.use_fallback_tool_rmb) else _template_view3d_gpencil_select( type=params.select_mouse, value=params.select_mouse_value, legacy=params.legacy)), ]}, @@ -7662,7 +7704,7 @@ def km_3d_view_tool_sculpt_gpencil_select(params): return ( "3D View Tool: Sculpt Gpencil, Tweak", {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, - {"items": _template_items_tool_select(params, "gpencil.select", "view3d.cursor3d", False)}, + {"items": _template_items_tool_select(params, "gpencil.select", "view3d.cursor3d")}, ) @@ -7702,7 +7744,7 @@ def km_sequencer_editor_tool_generic_select(params, *, fallback): {"space_type": 'SEQUENCE_EDITOR', "region_type": 'WINDOW'}, {"items": [ *([] if (fallback and (params.select_mouse == 'RIGHTMOUSE')) else _template_items_tool_select( - params, "sequencer.select", "sequencer.cursor_set", fallback)), + params, "sequencer.select", "sequencer.cursor_set", cursor_prioritize=True, fallback=fallback)), *([] if (not params.use_fallback_tool_rmb) else _template_sequencer_preview_select( type=params.select_mouse, value=params.select_mouse_value, legacy=params.legacy)), diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index b0b618ada11..035c4fd1352 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -2261,7 +2261,6 @@ class USERPREF_PT_experimental_new_features(ExperimentalPanel, Panel): context, ( ({"property": "use_sculpt_tools_tilt"}, "T82877"), ({"property": "use_sculpt_texture_paint"}, "T96225"), - ({"property": "use_select_nearest_on_first_click"}, "T96752"), ({"property": "use_extended_asset_browser"}, ("project/view/130/", "Project Page")), ({"property": "use_override_templates"}, ("T73318", "Milestone 4")), ({"property": "use_named_attribute_nodes"}, ("T91742")), @@ -2283,6 +2282,17 @@ class USERPREF_PT_experimental_prototypes(ExperimentalPanel, Panel): ) +class USERPREF_PT_experimental_tweaks(ExperimentalPanel, Panel): + bl_label = "Tweaks" + + def draw(self, context): + self._draw_items( + context, ( + ({"property": "use_select_nearest_on_first_click"}, "T96752"), + ), + ) + + class USERPREF_PT_experimental_debugging(ExperimentalPanel, Panel): bl_label = "Debugging" @@ -2403,6 +2413,7 @@ classes = ( USERPREF_PT_experimental_new_features, USERPREF_PT_experimental_prototypes, + USERPREF_PT_experimental_tweaks, USERPREF_PT_experimental_debugging, # Add dynamically generated editor theme panels last, diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 0808b7fadae..41c1f3d0683 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -518,6 +518,13 @@ class _draw_tool_settings_context_mode: layout.prop(tool_settings.curves_sculpt, "interpolate_length") layout.prop(tool_settings.curves_sculpt, "interpolate_shape") + if brush.curves_sculpt_tool == 'GROW_SHRINK': + layout.prop(brush, "direction", expand=True, text="") + layout.prop(brush, "falloff_shape", expand=True) + layout.prop(brush.curves_sculpt_settings, "scale_uniform") + layout.prop(brush.curves_sculpt_settings, "minimum_length") + layout.prop(brush, "curve_preset") + if brush.curves_sculpt_tool == 'SNAKE_HOOK': layout.prop(brush, "falloff_shape", expand=True) layout.prop(brush, "curve_preset") diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h index 3d4d106fa09..f3968c0d761 100644 --- a/source/blender/blenkernel/BKE_attribute.h +++ b/source/blender/blenkernel/BKE_attribute.h @@ -21,7 +21,7 @@ struct CustomDataLayer; struct ID; struct ReportList; -/* Attribute.domain */ +/** #Attribute.domain */ typedef enum AttributeDomain { ATTR_DOMAIN_AUTO = -1, /* Use for nodes to choose automatically based on other data. */ ATTR_DOMAIN_POINT = 0, /* Mesh, Curve or Point Cloud Point */ diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 1f3b0606dfd..34f3b9afacd 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -25,7 +25,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 9 +#define BLENDER_FILE_SUBVERSION 11 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and show a warning if the file diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h index 9d254bba8e7..57dc1e288dc 100644 --- a/source/blender/blenkernel/BKE_camera.h +++ b/source/blender/blenkernel/BKE_camera.h @@ -114,7 +114,9 @@ bool BKE_camera_view_frame_fit_to_scene(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *camera_ob, float r_co[3], - float *r_scale); + float *r_scale, + float *r_clip_start, + float *r_clip_end); bool BKE_camera_view_frame_fit_to_coords(const struct Depsgraph *depsgraph, const float (*cos)[3], int num_cos, diff --git a/source/blender/blenkernel/BKE_displist_tangent.h b/source/blender/blenkernel/BKE_displist_tangent.h deleted file mode 100644 index c439ed5f8a4..00000000000 --- a/source/blender/blenkernel/BKE_displist_tangent.h +++ /dev/null @@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ - -#pragma once - -/** \file - * \ingroup bke - */ - -#ifdef __cplusplus -extern "C" { -#endif - -void BKE_displist_tangent_calc(const DispList *dl, float (*fnormals)[3], float (**r_tangent)[4]); - -#ifdef __cplusplus -} -#endif diff --git a/source/blender/blenkernel/BKE_gpencil_update_cache.h b/source/blender/blenkernel/BKE_gpencil_update_cache.h index 52b8716bab5..f6ae7b53005 100644 --- a/source/blender/blenkernel/BKE_gpencil_update_cache.h +++ b/source/blender/blenkernel/BKE_gpencil_update_cache.h @@ -20,7 +20,7 @@ struct bGPDlayer; struct bGPDstroke; struct bGPdata; -/* GPencilUpdateCache.flag */ +/** #GPencilUpdateCache.flag */ typedef enum eGPUpdateCacheNodeFlag { /* Node is a placeholder (e.g. when only an index is needed). */ GP_UPDATE_NODE_NO_COPY = 0, diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 2c64bb576b7..59b22f7759b 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -73,7 +73,7 @@ typedef struct MainIDRelationsEntry { uint tags; } MainIDRelationsEntry; -/* MainIDRelationsEntry.tags */ +/** #MainIDRelationsEntry.tags */ typedef enum eMainIDRelationsEntryTags { /* Generic tag marking the entry as to be processed. */ MAINIDRELATIONS_ENTRY_TAGS_DOIT = 1 << 0, diff --git a/source/blender/blenkernel/BKE_studiolight.h b/source/blender/blenkernel/BKE_studiolight.h index 68faa7613a9..1d1b6910b87 100644 --- a/source/blender/blenkernel/BKE_studiolight.h +++ b/source/blender/blenkernel/BKE_studiolight.h @@ -57,7 +57,7 @@ struct ImBuf; struct GPUTexture; struct StudioLight; -/* StudioLight.flag */ +/** #StudioLight.flag */ enum StudioLightFlag { STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED = (1 << 0), /* STUDIOLIGHT_LIGHT_DIRECTION_CALCULATED = (1 << 1), */ diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 57b7da8f5ba..61131cff06d 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -121,7 +121,6 @@ set(SRC intern/data_transfer.c intern/deform.c intern/displist.cc - intern/displist_tangent.c intern/dynamicpaint.c intern/editlattice.c intern/editmesh.c @@ -358,7 +357,6 @@ set(SRC BKE_data_transfer.h BKE_deform.h BKE_displist.h - BKE_displist_tangent.h BKE_duplilist.h BKE_dynamicpaint.h BKE_editlattice.h diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 8acb6092697..b9cd9e1ee59 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1558,6 +1558,7 @@ void BKE_brush_init_curves_sculpt_settings(Brush *brush) brush->curves_sculpt_settings = MEM_callocN(sizeof(BrushCurvesSculptSettings), __func__); } brush->curves_sculpt_settings->add_amount = 1; + brush->curves_sculpt_settings->minimum_length = 0.01f; } struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mode) diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index b840fb1e665..3897df9f05f 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -552,12 +552,11 @@ void BKE_camera_view_frame(const Scene *scene, const Camera *camera, float r_vec typedef struct CameraViewFrameData { float plane_tx[CAMERA_VIEWFRAME_NUM_PLANES][4]; /* 4 planes normalized */ float dist_vals[CAMERA_VIEWFRAME_NUM_PLANES]; /* distance (signed) */ + float camera_no[3]; + float z_range[2]; unsigned int tot; - /* Ortho camera only. */ - bool is_ortho; - float camera_no[3]; - float dist_to_cam; + bool do_zrange; /* Not used by callbacks... */ float camera_rotmat[3][3]; @@ -572,9 +571,10 @@ static void camera_to_frame_view_cb(const float co[3], void *user_data) CLAMP_MAX(data->dist_vals[i], nd); } - if (data->is_ortho) { + if (data->do_zrange) { const float d = dot_v3v3(data->camera_no, co); - CLAMP_MAX(data->dist_to_cam, d); + CLAMP_MAX(data->z_range[0], d); + CLAMP_MIN(data->z_range[1], d); } data->tot++; @@ -582,6 +582,7 @@ static void camera_to_frame_view_cb(const float co[3], void *user_data) static void camera_frame_fit_data_init(const Scene *scene, const Object *ob, + const bool do_clip_dists, CameraParams *params, CameraViewFrameData *data) { @@ -626,22 +627,27 @@ static void camera_frame_fit_data_init(const Scene *scene, mul_m4_v4(camera_rotmat_transposed_inversed, data->plane_tx[i]); /* Normalize. */ data->plane_tx[i][3] /= normalize_v3(data->plane_tx[i]); + + data->dist_vals[i] = FLT_MAX; } - copy_v4_fl(data->dist_vals, FLT_MAX); data->tot = 0; - data->is_ortho = params->is_ortho; - if (params->is_ortho) { - /* we want (0, 0, -1) transformed by camera_rotmat, this is a quicker shortcut. */ + data->do_zrange = params->is_ortho || do_clip_dists; + + if (data->do_zrange) { + /* We want (0, 0, -1) transformed by camera_rotmat, this is a quicker shortcut. */ negate_v3_v3(data->camera_no, data->camera_rotmat[2]); - data->dist_to_cam = FLT_MAX; + data->z_range[0] = FLT_MAX; + data->z_range[1] = -FLT_MAX; } } static bool camera_frame_fit_calc_from_data(CameraParams *params, CameraViewFrameData *data, float r_co[3], - float *r_scale) + float *r_scale, + float *r_clip_start, + float *r_clip_end) { float plane_tx[CAMERA_VIEWFRAME_NUM_PLANES][4]; @@ -669,37 +675,38 @@ static bool camera_frame_fit_calc_from_data(CameraParams *params, zero_v3(r_co); madd_v3_v3fl(r_co, cam_axis_x, (dists[2] - dists[0]) * 0.5f + params->shiftx * scale_diff); madd_v3_v3fl(r_co, cam_axis_y, (dists[1] - dists[3]) * 0.5f + params->shifty * scale_diff); - madd_v3_v3fl(r_co, cam_axis_z, -(data->dist_to_cam - 1.0f - params->clip_start)); - - return true; + madd_v3_v3fl(r_co, cam_axis_z, -(data->z_range[0] - 1.0f - params->clip_start)); } + else { + float plane_isect_1[3], plane_isect_1_no[3], plane_isect_1_other[3]; + float plane_isect_2[3], plane_isect_2_no[3], plane_isect_2_other[3]; - float plane_isect_1[3], plane_isect_1_no[3], plane_isect_1_other[3]; - float plane_isect_2[3], plane_isect_2_no[3], plane_isect_2_other[3]; + float plane_isect_pt_1[3], plane_isect_pt_2[3]; - float plane_isect_pt_1[3], plane_isect_pt_2[3]; + /* apply the dist-from-plane's to the transformed plane points */ + for (int i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) { + float co[3]; + mul_v3_v3fl(co, data->plane_tx[i], data->dist_vals[i]); + plane_from_point_normal_v3(plane_tx[i], co, data->plane_tx[i]); + } - /* apply the dist-from-plane's to the transformed plane points */ - for (int i = 0; i < CAMERA_VIEWFRAME_NUM_PLANES; i++) { - float co[3]; - mul_v3_v3fl(co, data->plane_tx[i], data->dist_vals[i]); - plane_from_point_normal_v3(plane_tx[i], co, data->plane_tx[i]); - } + if ((!isect_plane_plane_v3(plane_tx[0], plane_tx[2], plane_isect_1, plane_isect_1_no)) || + (!isect_plane_plane_v3(plane_tx[1], plane_tx[3], plane_isect_2, plane_isect_2_no))) { + return false; + } - if ((!isect_plane_plane_v3(plane_tx[0], plane_tx[2], plane_isect_1, plane_isect_1_no)) || - (!isect_plane_plane_v3(plane_tx[1], plane_tx[3], plane_isect_2, plane_isect_2_no))) { - return false; - } + add_v3_v3v3(plane_isect_1_other, plane_isect_1, plane_isect_1_no); + add_v3_v3v3(plane_isect_2_other, plane_isect_2, plane_isect_2_no); - add_v3_v3v3(plane_isect_1_other, plane_isect_1, plane_isect_1_no); - add_v3_v3v3(plane_isect_2_other, plane_isect_2, plane_isect_2_no); + if (!isect_line_line_v3(plane_isect_1, + plane_isect_1_other, + plane_isect_2, + plane_isect_2_other, + plane_isect_pt_1, + plane_isect_pt_2) != 0) { + return false; + } - if (isect_line_line_v3(plane_isect_1, - plane_isect_1_other, - plane_isect_2, - plane_isect_2_other, - plane_isect_pt_1, - plane_isect_pt_2) != 0) { float cam_plane_no[3]; float plane_isect_delta[3]; float plane_isect_delta_len; @@ -728,15 +735,23 @@ static bool camera_frame_fit_calc_from_data(CameraParams *params, normalize_v3(plane_isect_2_no); madd_v3_v3fl(r_co, plane_isect_2_no, params->shiftx * plane_isect_delta_len * shift_fac); } - - return true; } - return false; + if (r_clip_start && r_clip_end) { + const float z_offs = dot_v3v3(r_co, data->camera_no); + *r_clip_start = data->z_range[0] - z_offs; + *r_clip_end = data->z_range[1] - z_offs; + } + return true; } -bool BKE_camera_view_frame_fit_to_scene( - Depsgraph *depsgraph, const Scene *scene, Object *camera_ob, float r_co[3], float *r_scale) +bool BKE_camera_view_frame_fit_to_scene(Depsgraph *depsgraph, + const Scene *scene, + Object *camera_ob, + float r_co[3], + float *r_scale, + float *r_clip_start, + float *r_clip_end) { CameraParams params; CameraViewFrameData data_cb; @@ -744,12 +759,13 @@ bool BKE_camera_view_frame_fit_to_scene( /* just in case */ *r_scale = 1.0f; - camera_frame_fit_data_init(scene, camera_ob, ¶ms, &data_cb); + camera_frame_fit_data_init(scene, camera_ob, r_clip_start && r_clip_end, ¶ms, &data_cb); /* run callback on all visible points */ BKE_scene_foreach_display_point(depsgraph, camera_to_frame_view_cb, &data_cb); - return camera_frame_fit_calc_from_data(¶ms, &data_cb, r_co, r_scale); + return camera_frame_fit_calc_from_data( + ¶ms, &data_cb, r_co, r_scale, r_clip_start, r_clip_end); } bool BKE_camera_view_frame_fit_to_coords(const Depsgraph *depsgraph, @@ -767,14 +783,14 @@ bool BKE_camera_view_frame_fit_to_coords(const Depsgraph *depsgraph, /* just in case */ *r_scale = 1.0f; - camera_frame_fit_data_init(scene_eval, camera_ob_eval, ¶ms, &data_cb); + camera_frame_fit_data_init(scene_eval, camera_ob_eval, false, ¶ms, &data_cb); /* run callback on all given coordinates */ while (num_cos--) { camera_to_frame_view_cb(cos[num_cos], &data_cb); } - return camera_frame_fit_calc_from_data(¶ms, &data_cb, r_co, r_scale); + return camera_frame_fit_calc_from_data(¶ms, &data_cb, r_co, r_scale, NULL, NULL); } /** \} */ diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc index 26f5d7e9cb4..2d72ad28d18 100644 --- a/source/blender/blenkernel/intern/curve.cc +++ b/source/blender/blenkernel/intern/curve.cc @@ -123,8 +123,6 @@ static void curve_free_data(ID *id) MEM_SAFE_FREE(curve->str); MEM_SAFE_FREE(curve->strinfo); MEM_SAFE_FREE(curve->tb); - - delete curve->curve_eval; } static void curve_foreach_id(ID *id, LibraryForeachIDData *data) diff --git a/source/blender/blenkernel/intern/curve_bezier.cc b/source/blender/blenkernel/intern/curve_bezier.cc index 30a5869c976..dfe462d8566 100644 --- a/source/blender/blenkernel/intern/curve_bezier.cc +++ b/source/blender/blenkernel/intern/curve_bezier.cc @@ -218,6 +218,10 @@ void calculate_evaluated_positions(const Span<float3> positions, { BLI_assert(evaluated_offsets.last() == evaluated_positions.size()); BLI_assert(evaluated_offsets.size() == positions.size()); + if (evaluated_offsets.last() == 1) { + evaluated_positions.first() = positions.first(); + return; + } /* Evaluate the first segment. */ evaluate_segment(positions.first(), diff --git a/source/blender/blenkernel/intern/displist.cc b/source/blender/blenkernel/intern/displist.cc index 791e0faab3b..8c1161d6ff6 100644 --- a/source/blender/blenkernel/intern/displist.cc +++ b/source/blender/blenkernel/intern/displist.cc @@ -948,12 +948,11 @@ static void displist_surf_indices(DispList *dl) } } -static void evaluate_surface_object(Depsgraph *depsgraph, - const Scene *scene, - Object *ob, - const bool for_render, - ListBase *r_dispbase, - Mesh **r_final) +static GeometrySet evaluate_surface_object(Depsgraph *depsgraph, + const Scene *scene, + Object *ob, + const bool for_render, + ListBase *r_dispbase) { BLI_assert(ob->type == OB_SURF); const Curve *cu = (const Curve *)ob->data; @@ -1036,8 +1035,7 @@ static void evaluate_surface_object(Depsgraph *depsgraph, if (!geometry_set.has_mesh()) { geometry_set.replace_mesh(BKE_mesh_new_nomain(0, 0, 0, 0, 0)); } - MeshComponent &mesh_component = geometry_set.get_component_for_write<MeshComponent>(); - *r_final = mesh_component.release(); + return geometry_set; } static void rotateBevelPiece(const Curve *cu, @@ -1483,9 +1481,8 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph, ListBase *dispbase = &ob->runtime.curve_cache->disp; if (ob->type == OB_SURF) { - Mesh *mesh_eval; - evaluate_surface_object(depsgraph, scene, ob, for_render, dispbase, &mesh_eval); - BKE_object_eval_assign_data(ob, &mesh_eval->id, true); + GeometrySet geometry = evaluate_surface_object(depsgraph, scene, ob, for_render, dispbase); + ob->runtime.geometry_set_eval = new GeometrySet(std::move(geometry)); } else { GeometrySet geometry = evaluate_curve_type_object(depsgraph, scene, ob, for_render, dispbase); @@ -1497,7 +1494,7 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph, * the CurveEval data type was introduced, when an evaluated object's curve data was just a * copy of the original curve and everything else ended up in #CurveCache. */ CurveComponent &curve_component = geometry.get_component_for_write<CurveComponent>(); - cow_curve.curve_eval = curves_to_curve_eval(*curve_component.get_for_read()).release(); + cow_curve.curve_eval = curve_component.get_for_read(); BKE_object_eval_assign_data(ob, &cow_curve.id, false); } diff --git a/source/blender/blenkernel/intern/displist_tangent.c b/source/blender/blenkernel/intern/displist_tangent.c deleted file mode 100644 index eb6bdd8d5e9..00000000000 --- a/source/blender/blenkernel/intern/displist_tangent.c +++ /dev/null @@ -1,269 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup bke - */ - -#include "BLI_math.h" -#include "BLI_task.h" - -#include "BKE_displist.h" -#include "BKE_displist_tangent.h" - -#include "MEM_guardedalloc.h" - -/* interface */ -#include "mikktspace.h" - -/* -------------------------------------------------------------------- */ -/** \name Internal Types - * \{ */ - -typedef struct { - const DispList *dl; - float (*tangent)[4]; /* destination */ - /** Face normal for flat shading. */ - float (*fnormals)[3]; - /** Use by surfaces. Size of the surface in faces. */ - int u_len, v_len; -} SGLSLDisplistToTangent; - -/** \} */ - -/* ---------------------------------------------------------------------- */ -/** \name DL_INDEX3 tangents - * \{ */ - -static int dl3_ts_GetNumFaces(const SMikkTSpaceContext *pContext) -{ - SGLSLDisplistToTangent *dlt = pContext->m_pUserData; - - return dlt->dl->parts; -} - -static int dl3_ts_GetNumVertsOfFace(const SMikkTSpaceContext *pContext, const int face_num) -{ - UNUSED_VARS(pContext, face_num); - - return 3; -} - -static void dl3_ts_GetPosition(const SMikkTSpaceContext *pContext, - float r_co[3], - const int face_num, - const int vert_index) -{ - SGLSLDisplistToTangent *dlt = pContext->m_pUserData; - const float(*verts)[3] = (float(*)[3])dlt->dl->verts; - const int(*idx)[3] = (int(*)[3])dlt->dl->index; - - copy_v3_v3(r_co, verts[idx[face_num][vert_index]]); -} - -static void dl3_ts_GetTextureCoordinate(const SMikkTSpaceContext *pContext, - float r_uv[2], - const int face_num, - const int vert_index) -{ - SGLSLDisplistToTangent *dlt = pContext->m_pUserData; - const int(*idx)[3] = (int(*)[3])dlt->dl->index; - - r_uv[0] = idx[face_num][vert_index] / (float)(dlt->dl->nr - 1); - r_uv[1] = 0.0f; -} - -static void dl3_ts_GetNormal(const SMikkTSpaceContext *pContext, - float r_no[3], - const int face_num, - const int vert_index) -{ - SGLSLDisplistToTangent *dlt = pContext->m_pUserData; - UNUSED_VARS(face_num, vert_index); - - copy_v3_v3(r_no, dlt->dl->nors); -} - -static void dl3_ts_SetTSpace(const SMikkTSpaceContext *pContext, - const float fvTangent[3], - const float fSign, - const int face_num, - const int vert_index) -{ - SGLSLDisplistToTangent *dlt = pContext->m_pUserData; - UNUSED_VARS(face_num, vert_index); - - copy_v3_v3(dlt->tangent[0], fvTangent); - dlt->tangent[0][3] = fSign; -} - -/** \} */ - -/* ---------------------------------------------------------------------- */ -/** \name DL_SURF tangents - * \{ */ - -static int dlsurf_ts_GetNumFaces(const SMikkTSpaceContext *pContext) -{ - SGLSLDisplistToTangent *dlt = pContext->m_pUserData; - - return dlt->v_len * dlt->u_len; -} - -static int dlsurf_ts_GetNumVertsOfFace(const SMikkTSpaceContext *pContext, const int face_num) -{ - UNUSED_VARS(pContext, face_num); - - return 4; -} - -static int face_to_vert_index(SGLSLDisplistToTangent *dlt, - const int face_num, - const int vert_index) -{ - int u = face_num % dlt->u_len; - int v = face_num / dlt->u_len; - - if (vert_index == 0) { - u += 1; - } - else if (vert_index == 1) { - u += 1; - v += 1; - } - else if (vert_index == 2) { - v += 1; - } - - /* Cyclic correction. */ - u = u % dlt->dl->nr; - v = v % dlt->dl->parts; - - return v * dlt->dl->nr + u; -} - -static void dlsurf_ts_GetPosition(const SMikkTSpaceContext *pContext, - float r_co[3], - const int face_num, - const int vert_index) -{ - SGLSLDisplistToTangent *dlt = pContext->m_pUserData; - const float(*verts)[3] = (float(*)[3])dlt->dl->verts; - - copy_v3_v3(r_co, verts[face_to_vert_index(dlt, face_num, vert_index)]); -} - -static void dlsurf_ts_GetTextureCoordinate(const SMikkTSpaceContext *pContext, - float r_uv[2], - const int face_num, - const int vert_index) -{ - SGLSLDisplistToTangent *dlt = pContext->m_pUserData; - - int idx = face_to_vert_index(dlt, face_num, vert_index); - - /* NOTE: For some reason the shading U and V are swapped compared to the - * one described in the surface format. */ - r_uv[0] = (idx / dlt->dl->nr) / (float)(dlt->v_len); - r_uv[1] = (idx % dlt->dl->nr) / (float)(dlt->u_len); - - if (r_uv[0] == 0.0f && ELEM(vert_index, 1, 2)) { - r_uv[0] = 1.0f; - } - if (r_uv[1] == 0.0f && ELEM(vert_index, 0, 1)) { - r_uv[1] = 1.0f; - } -} - -static void dlsurf_ts_GetNormal(const SMikkTSpaceContext *pContext, - float r_no[3], - const int face_num, - const int vert_index) -{ - SGLSLDisplistToTangent *dlt = pContext->m_pUserData; - const float(*nors)[3] = (float(*)[3])dlt->dl->nors; - - if (dlt->fnormals) { - copy_v3_v3(r_no, dlt->fnormals[face_num]); - } - else { - copy_v3_v3(r_no, nors[face_to_vert_index(dlt, face_num, vert_index)]); - } -} - -static void dlsurf_ts_SetTSpace(const SMikkTSpaceContext *pContext, - const float fvTangent[3], - const float fSign, - const int face_num, - const int vert_index) -{ - SGLSLDisplistToTangent *dlt = pContext->m_pUserData; - UNUSED_VARS(face_num, vert_index); - - float *r_tan = dlt->tangent[face_num * 4 + vert_index]; - copy_v3_v3(r_tan, fvTangent); - r_tan[3] = fSign; -} - -/** \} */ - -/* ---------------------------------------------------------------------- */ -/** \name Entry point - * \{ */ - -void BKE_displist_tangent_calc(const DispList *dl, float (*fnormals)[3], float (**r_tangent)[4]) -{ - if (dl->type == DL_INDEX3) { - /* INDEX3 have only one tangent so we don't need actual allocation. */ - BLI_assert(*r_tangent != NULL); - - SGLSLDisplistToTangent mesh2tangent = { - .tangent = *r_tangent, - .dl = dl, - }; - SMikkTSpaceContext sContext = {NULL}; - SMikkTSpaceInterface sInterface = {NULL}; - sContext.m_pUserData = &mesh2tangent; - sContext.m_pInterface = &sInterface; - sInterface.m_getNumFaces = dl3_ts_GetNumFaces; - sInterface.m_getNumVerticesOfFace = dl3_ts_GetNumVertsOfFace; - sInterface.m_getPosition = dl3_ts_GetPosition; - sInterface.m_getTexCoord = dl3_ts_GetTextureCoordinate; - sInterface.m_getNormal = dl3_ts_GetNormal; - sInterface.m_setTSpaceBasic = dl3_ts_SetTSpace; - /* 0 if failed */ - genTangSpaceDefault(&sContext); - } - else if (dl->type == DL_SURF) { - SGLSLDisplistToTangent mesh2tangent = { - .dl = dl, - .u_len = dl->nr - ((dl->flag & DL_CYCL_U) ? 0 : 1), - .v_len = dl->parts - ((dl->flag & DL_CYCL_V) ? 0 : 1), - .fnormals = fnormals, - }; - - int loop_len = mesh2tangent.u_len * mesh2tangent.v_len * 4; - - if (*r_tangent == NULL) { - *r_tangent = MEM_mallocN(sizeof(float[4]) * loop_len, "displist tangents"); - } - mesh2tangent.tangent = *r_tangent; - SMikkTSpaceContext sContext = {NULL}; - SMikkTSpaceInterface sInterface = {NULL}; - sContext.m_pUserData = &mesh2tangent; - sContext.m_pInterface = &sInterface; - sInterface.m_getNumFaces = dlsurf_ts_GetNumFaces; - sInterface.m_getNumVerticesOfFace = dlsurf_ts_GetNumVertsOfFace; - sInterface.m_getPosition = dlsurf_ts_GetPosition; - sInterface.m_getTexCoord = dlsurf_ts_GetTextureCoordinate; - sInterface.m_getNormal = dlsurf_ts_GetNormal; - sInterface.m_setTSpaceBasic = dlsurf_ts_SetTSpace; - /* 0 if failed */ - genTangSpaceDefault(&sContext); - } - else { - /* Unsupported. */ - BLI_assert(0); - } -} - -/** \} */ diff --git a/source/blender/blenkernel/intern/geometry_component_curves.cc b/source/blender/blenkernel/intern/geometry_component_curves.cc index b5771cc063f..27c1a2f2f33 100644 --- a/source/blender/blenkernel/intern/geometry_component_curves.cc +++ b/source/blender/blenkernel/intern/geometry_component_curves.cc @@ -128,7 +128,7 @@ const Curve *CurveComponent::get_curve_for_render() const } curve_for_render_ = (Curve *)BKE_id_new_nomain(ID_CU_LEGACY, nullptr); - curve_for_render_->curve_eval = curves_to_curve_eval(*curves_).release(); + curve_for_render_->curve_eval = curves_; return curve_for_render_; } diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 9e65093a05f..5c1b6c8d774 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -329,6 +329,24 @@ float closest_to_line_segment_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2]); + +/** + * Finds the points where two line segments are closest to each other. + * + * `lambda_*` is a value between 0 and 1 for each segment that indicates where `r_closest_*` is on + * the corresponding segment. + * + * \return Squared distance between both segments. + */ +float closest_seg_seg_v2(float r_closest_a[2], + float r_closest_b[2], + float *r_lambda_a, + float *r_lambda_b, + const float a1[2], + const float a2[2], + const float b1[2], + const float b2[2]); + /** * Point closest to v1 on line v2-v3 in 3D. * diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 1b13493e00c..e7ccdeab80a 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -294,6 +294,66 @@ float dist_to_line_segment_v2(const float p[2], const float l1[2], const float l return sqrtf(dist_squared_to_line_segment_v2(p, l1, l2)); } +float closest_seg_seg_v2(float r_closest_a[2], + float r_closest_b[2], + float *r_lambda_a, + float *r_lambda_b, + const float a1[2], + const float a2[2], + const float b1[2], + const float b2[2]) +{ + if (isect_seg_seg_v2_simple(a1, a2, b1, b2)) { + float intersection[2]; + isect_line_line_v2_point(a1, a2, b1, b2, intersection); + copy_v2_v2(r_closest_a, intersection); + copy_v2_v2(r_closest_b, intersection); + float tmp[2]; + *r_lambda_a = closest_to_line_v2(tmp, intersection, a1, a2); + *r_lambda_b = closest_to_line_v2(tmp, intersection, b1, b2); + const float min_dist_sq = len_squared_v2v2(r_closest_a, r_closest_b); + return min_dist_sq; + } + + float p1[2], p2[2], p3[2], p4[2]; + const float lambda1 = closest_to_line_segment_v2(p1, a1, b1, b2); + const float lambda2 = closest_to_line_segment_v2(p2, a2, b1, b2); + const float lambda3 = closest_to_line_segment_v2(p3, b1, a1, a2); + const float lambda4 = closest_to_line_segment_v2(p4, b2, a1, a2); + const float dist_sq1 = len_squared_v2v2(p1, a1); + const float dist_sq2 = len_squared_v2v2(p2, a2); + const float dist_sq3 = len_squared_v2v2(p3, b1); + const float dist_sq4 = len_squared_v2v2(p4, b2); + + const float min_dist_sq = min_ffff(dist_sq1, dist_sq2, dist_sq3, dist_sq4); + if (min_dist_sq == dist_sq1) { + copy_v2_v2(r_closest_a, a1); + copy_v2_v2(r_closest_b, p1); + *r_lambda_a = 0.0f; + *r_lambda_b = lambda1; + } + else if (min_dist_sq == dist_sq2) { + copy_v2_v2(r_closest_a, a2); + copy_v2_v2(r_closest_b, p2); + *r_lambda_a = 1.0f; + *r_lambda_b = lambda2; + } + else if (min_dist_sq == dist_sq3) { + copy_v2_v2(r_closest_a, p3); + copy_v2_v2(r_closest_b, b1); + *r_lambda_a = lambda3; + *r_lambda_b = 0.0f; + } + else { + BLI_assert(min_dist_sq == dist_sq4); + copy_v2_v2(r_closest_a, p4); + copy_v2_v2(r_closest_b, b2); + *r_lambda_a = lambda4; + *r_lambda_b = 1.0f; + } + return min_dist_sq; +} + float closest_to_line_segment_v2(float r_close[2], const float p[2], const float l1[2], diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 32932c3dee1..bc07669687e 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -49,19 +49,19 @@ typedef struct ScanFillVertLink { #define SF_EPSILON 0.00003f #define SF_EPSILON_SQ (SF_EPSILON * SF_EPSILON) -/* ScanFillVert.status */ +/** #ScanFillVert.status */ #define SF_VERT_NEW 0 /* all new verts have this flag set */ #define SF_VERT_AVAILABLE 1 /* available - in an edge */ #define SF_VERT_ZERO_LEN 2 -/* ScanFillEdge.status */ +/** #ScanFillEdge.status */ /* Optionally set ScanFillEdge f to this to mark original boundary edges. * Only needed if there are internal diagonal edges passed to BLI_scanfill_calc. */ #define SF_EDGE_NEW 0 /* all new edges have this flag set */ // #define SF_EDGE_BOUNDARY 1 /* UNUSED */ #define SF_EDGE_INTERNAL 2 /* edge is created while scan-filling */ -/* PolyFill.status */ +/** #PolyFill.status */ #define SF_POLY_NEW 0 /* all polys initialized to this */ #define SF_POLY_VALID 1 /* has at least 3 verts */ diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c index 7aa2c219835..5ba7dc74e3d 100644 --- a/source/blender/blenloader/intern/versioning_300.c +++ b/source/blender/blenloader/intern/versioning_300.c @@ -2552,7 +2552,24 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - if (!MAIN_VERSION_ATLEAST(bmain, 302, 9)) { + if (!MAIN_VERSION_ATLEAST(bmain, 302, 10)) { + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { + if (sl->spacetype != SPACE_FILE) { + continue; + } + SpaceFile *sfile = (SpaceFile *)sl; + if (sfile->browse_mode != FILE_BROWSE_MODE_ASSETS) { + continue; + } + sfile->asset_params->base_params.filter_id |= FILTER_ID_GR; + } + } + } + } + + if (!MAIN_VERSION_ATLEAST(bmain, 302, 10)) { /* While vertex-colors were experimental the smear tool became corrupt due * to bugs in the wm_toolsystem API (auto-creation of sculpt brushes * was broken). Go through and reset all smear brushes. */ diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index dcf2ce4438d..b3f3b9cbf7d 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -354,7 +354,7 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) #undef USER_VERSION_ATLEAST } -/* UserDef.flag */ +/** #UserDef.flag */ #define USER_LMOUSESELECT (1 << 14) /* deprecated */ static void do_version_select_mouse(UserDef *userdef, wmKeyMapItem *kmi) @@ -1011,6 +1011,10 @@ void blo_do_versions_userdef(UserDef *userdef) NULL); } + if (!USER_VERSION_ATLEAST(302, 11)) { + userdef->dupflag |= USER_DUP_CURVES | USER_DUP_POINTCLOUD; + } + /** * Versioning code until next subversion bump goes here. * diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index f945e9b6fbc..b50081458ad 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -445,8 +445,8 @@ const char *update_source_as_string(eUpdateSource source) int deg_recalc_flags_for_legacy_zero() { - return ID_RECALC_ALL & - ~(ID_RECALC_PSYS_ALL | ID_RECALC_ANIMATION | ID_RECALC_SOURCE | ID_RECALC_EDITORS); + return ID_RECALC_ALL & ~(ID_RECALC_PSYS_ALL | ID_RECALC_ANIMATION | ID_RECALC_FRAME_CHANGE | + ID_RECALC_SOURCE | ID_RECALC_EDITORS); } int deg_recalc_flags_effective(Depsgraph *graph, int flags) diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 4fe169abdf7..858bb80a425 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -448,8 +448,6 @@ set(GLSL_SRC engines/overlay/shaders/edit_lattice_point_vert.glsl engines/overlay/shaders/edit_lattice_wire_vert.glsl engines/overlay/shaders/edit_mesh_common_lib.glsl - engines/overlay/shaders/edit_mesh_facefill_frag.glsl - engines/overlay/shaders/edit_mesh_facefill_vert.glsl engines/overlay/shaders/edit_mesh_frag.glsl engines/overlay/shaders/edit_mesh_geom.glsl engines/overlay/shaders/edit_mesh_normal_vert.glsl diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 585a508d9ce..4f520e61936 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -276,7 +276,7 @@ void GPENCIL_cache_init(void *ved) GPUShader *sh = GPENCIL_shader_depth_merge_get(); grp = DRW_shgroup_create(sh, psl->merge_depth_ps); DRW_shgroup_uniform_texture_ref(grp, "depthBuf", &pd->depth_tx); - DRW_shgroup_uniform_bool(grp, "gpStrokeOrder3d", &pd->is_stroke_order_3d, 1); + DRW_shgroup_uniform_bool(grp, "strokeOrder3d", &pd->is_stroke_order_3d, 1); DRW_shgroup_uniform_vec4(grp, "gpModelMatrix", pd->object_bound_mat[0], 4); DRW_shgroup_call_procedural_triangles(grp, NULL, 1); } diff --git a/source/blender/draw/engines/overlay/overlay_antialiasing.c b/source/blender/draw/engines/overlay/overlay_antialiasing.c index a07fd559f4f..27ee479cf36 100644 --- a/source/blender/draw/engines/overlay/overlay_antialiasing.c +++ b/source/blender/draw/engines/overlay/overlay_antialiasing.c @@ -63,7 +63,7 @@ void OVERLAY_antialiasing_init(OVERLAY_Data *vedata) return; } - bool need_wire_expansion = (G_draw.block.sizePixel > 1.0f); + bool need_wire_expansion = (G_draw.block.size_pixel > 1.0f); pd->antialiasing.enabled = need_wire_expansion || ((U.gpu_flag & USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE) != 0); diff --git a/source/blender/draw/engines/overlay/overlay_armature.c b/source/blender/draw/engines/overlay/overlay_armature.c index a2f9ad0d369..473fadab5ed 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.c +++ b/source/blender/draw/engines/overlay/overlay_armature.c @@ -784,28 +784,28 @@ static void drw_shgroup_bone_relationship_lines(ArmatureDrawContext *ctx, const float start[3], const float end[3]) { - drw_shgroup_bone_relationship_lines_ex(ctx, start, end, G_draw.block.colorWire); + drw_shgroup_bone_relationship_lines_ex(ctx, start, end, G_draw.block.color_wire); } static void drw_shgroup_bone_ik_lines(ArmatureDrawContext *ctx, const float start[3], const float end[3]) { - drw_shgroup_bone_relationship_lines_ex(ctx, start, end, G_draw.block.colorBoneIKLine); + drw_shgroup_bone_relationship_lines_ex(ctx, start, end, G_draw.block.color_bone_ik_line); } static void drw_shgroup_bone_ik_no_target_lines(ArmatureDrawContext *ctx, const float start[3], const float end[3]) { - drw_shgroup_bone_relationship_lines_ex(ctx, start, end, G_draw.block.colorBoneIKLineNoTarget); + drw_shgroup_bone_relationship_lines_ex(ctx, start, end, G_draw.block.color_bone_ik_line_no_target); } static void drw_shgroup_bone_ik_spline_lines(ArmatureDrawContext *ctx, const float start[3], const float end[3]) { - drw_shgroup_bone_relationship_lines_ex(ctx, start, end, G_draw.block.colorBoneIKLineSpline); + drw_shgroup_bone_relationship_lines_ex(ctx, start, end, G_draw.block.color_bone_ik_line_spline); } /** \} */ @@ -918,16 +918,16 @@ static bool set_pchan_color(const ArmatureDrawContext *ctx, } else { if ((boneflag & BONE_DRAW_ACTIVE) && (boneflag & BONE_SELECTED)) { - copy_v4_v4(fcolor, G_draw.block.colorBonePoseActive); + copy_v4_v4(fcolor, G_draw.block.color_bone_pose_active); } else if (boneflag & BONE_DRAW_ACTIVE) { - copy_v4_v4(fcolor, G_draw.block.colorBonePoseActiveUnsel); + copy_v4_v4(fcolor, G_draw.block.color_bone_pose_active_unsel); } else if (boneflag & BONE_SELECTED) { - copy_v4_v4(fcolor, G_draw.block.colorBonePose); + copy_v4_v4(fcolor, G_draw.block.color_bone_pose); } else { - copy_v4_v4(fcolor, G_draw.block.colorWire); + copy_v4_v4(fcolor, G_draw.block.color_wire); } } return true; @@ -940,23 +940,23 @@ static bool set_pchan_color(const ArmatureDrawContext *ctx, srgb_to_linearrgb_v4(fcolor, fcolor); } else { - copy_v4_v4(fcolor, G_draw.block.colorBoneSolid); + copy_v4_v4(fcolor, G_draw.block.color_bone_solid); } return true; } case PCHAN_COLOR_CONSTS: { if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) { if (constflag & PCHAN_HAS_TARGET) { - copy_v4_v4(fcolor, G_draw.block.colorBonePoseTarget); + copy_v4_v4(fcolor, G_draw.block.color_bone_pose_target); } else if (constflag & PCHAN_HAS_IK) { - copy_v4_v4(fcolor, G_draw.block.colorBonePoseIK); + copy_v4_v4(fcolor, G_draw.block.color_bone_pose_ik); } else if (constflag & PCHAN_HAS_SPLINEIK) { - copy_v4_v4(fcolor, G_draw.block.colorBonePoseSplineIK); + copy_v4_v4(fcolor, G_draw.block.color_bone_pose_spline_ik); } else if (constflag & PCHAN_HAS_CONST) { - copy_v4_v4(fcolor, G_draw.block.colorBonePoseConstraint); + copy_v4_v4(fcolor, G_draw.block.color_bone_pose_constraint); } else { return false; @@ -978,7 +978,7 @@ static bool set_pchan_color(const ArmatureDrawContext *ctx, static void bone_locked_color_shade(float color[4]) { - float *locked_color = G_draw.block.colorBoneLocked; + float *locked_color = G_draw.block.color_bone_locked; interp_v3_v3v3(color, color, locked_color, locked_color[3]); } @@ -991,7 +991,7 @@ static const float *get_bone_solid_color(const ArmatureDrawContext *ctx, const short constflag) { if (ctx->const_color) { - return G_draw.block.colorBoneSolid; + return G_draw.block.color_bone_solid; } if (arm->flag & ARM_POSEMODE) { @@ -1006,7 +1006,7 @@ static const float *get_bone_solid_color(const ArmatureDrawContext *ctx, return disp_color; } - return G_draw.block.colorBoneSolid; + return G_draw.block.color_bone_solid; } static const float *get_bone_solid_with_consts_color(const ArmatureDrawContext *ctx, @@ -1017,7 +1017,7 @@ static const float *get_bone_solid_with_consts_color(const ArmatureDrawContext * const short constflag) { if (ctx->const_color) { - return G_draw.block.colorBoneSolid; + return G_draw.block.color_bone_solid; } const float *col = get_bone_solid_color(ctx, eBone, pchan, arm, boneflag, constflag); @@ -1060,18 +1060,18 @@ static const float *get_bone_wire_color(const ArmatureDrawContext *ctx, else if (eBone) { if (boneflag & BONE_SELECTED) { if (boneflag & BONE_DRAW_ACTIVE) { - copy_v3_v3(disp_color, G_draw.block.colorBoneActive); + copy_v3_v3(disp_color, G_draw.block.color_bone_active); } else { - copy_v3_v3(disp_color, G_draw.block.colorBoneSelect); + copy_v3_v3(disp_color, G_draw.block.color_bone_select); } } else { if (boneflag & BONE_DRAW_ACTIVE) { - copy_v3_v3(disp_color, G_draw.block.colorBoneActiveUnsel); + copy_v3_v3(disp_color, G_draw.block.color_bone_active_unsel); } else { - copy_v3_v3(disp_color, G_draw.block.colorWireEdit); + copy_v3_v3(disp_color, G_draw.block.color_wire_edit); } } } @@ -1084,7 +1084,7 @@ static const float *get_bone_wire_color(const ArmatureDrawContext *ctx, } } else { - copy_v3_v3(disp_color, G_draw.block.colorVertex); + copy_v3_v3(disp_color, G_draw.block.color_vertex); } disp_color[3] = get_bone_wire_thickness(ctx, boneflag); @@ -1111,7 +1111,7 @@ static const float *get_bone_hint_color(const ArmatureDrawContext *ctx, static float hint_color[4] = {0.0f, 0.0f, 0.0f, 1.0f}; if (ctx->const_color) { - bone_hint_color_shade(hint_color, G_draw.block.colorBoneSolid); + bone_hint_color_shade(hint_color, G_draw.block.color_bone_solid); } else { const float *wire_color = get_bone_wire_color(ctx, eBone, pchan, arm, boneflag, constflag); @@ -1408,8 +1408,8 @@ static void draw_axes(ArmatureDrawContext *ctx, { float final_col[4]; const float *col = (ctx->const_color) ? ctx->const_color : - (BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? G_draw.block.colorTextHi : - G_draw.block.colorText; + (BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? G_draw.block.color_text_hi : + G_draw.block.color_text; copy_v4_v4(final_col, col); /* Mix with axes color. */ final_col[3] = (ctx->const_color) ? 1.0 : (BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? 0.1 : 0.65; @@ -1444,10 +1444,10 @@ static void draw_points(ArmatureDrawContext *ctx, float col_solid_root[4], col_solid_tail[4], col_wire_root[4], col_wire_tail[4]; float col_hint_root[4], col_hint_tail[4]; - copy_v4_v4(col_solid_root, G_draw.block.colorBoneSolid); - copy_v4_v4(col_solid_tail, G_draw.block.colorBoneSolid); - copy_v4_v4(col_wire_root, (ctx->const_color) ? ctx->const_color : G_draw.block.colorVertex); - copy_v4_v4(col_wire_tail, (ctx->const_color) ? ctx->const_color : G_draw.block.colorVertex); + copy_v4_v4(col_solid_root, G_draw.block.color_bone_solid); + copy_v4_v4(col_solid_tail, G_draw.block.color_bone_solid); + copy_v4_v4(col_wire_root, (ctx->const_color) ? ctx->const_color : G_draw.block.color_vertex); + copy_v4_v4(col_wire_tail, (ctx->const_color) ? ctx->const_color : G_draw.block.color_vertex); const bool is_envelope_draw = (arm->drawtype == ARM_ENVELOPE); const float envelope_ignore = -1.0f; @@ -1457,10 +1457,10 @@ static void draw_points(ArmatureDrawContext *ctx, /* Edit bone points can be selected */ if (eBone) { if (eBone->flag & BONE_ROOTSEL) { - copy_v3_v3(col_wire_root, G_draw.block.colorVertexSelect); + copy_v3_v3(col_wire_root, G_draw.block.color_vertex_select); } if (eBone->flag & BONE_TIPSEL) { - copy_v3_v3(col_wire_tail, G_draw.block.colorVertexSelect); + copy_v3_v3(col_wire_tail, G_draw.block.color_vertex_select); } } else if (arm->flag & ARM_POSEMODE) { @@ -1648,12 +1648,12 @@ static void draw_bone_line(ArmatureDrawContext *ctx, else { if (eBone) { if (eBone->flag & BONE_TIPSEL) { - col_tail = G_draw.block.colorVertexSelect; + col_tail = G_draw.block.color_vertex_select; } if (boneflag & BONE_SELECTED) { - col_bone = G_draw.block.colorBoneActive; + col_bone = G_draw.block.color_bone_active; } - col_wire = G_draw.block.colorWire; + col_wire = G_draw.block.color_wire; } /* Draw root point if we are not connected to our parent. */ @@ -1661,7 +1661,7 @@ static void draw_bone_line(ArmatureDrawContext *ctx, (pchan->bone->parent && (boneflag & BONE_CONNECTED)))) { if (eBone) { - col_head = (eBone->flag & BONE_ROOTSEL) ? G_draw.block.colorVertexSelect : col_bone; + col_head = (eBone->flag & BONE_ROOTSEL) ? G_draw.block.color_vertex_select : col_bone; } else { col_head = col_bone; diff --git a/source/blender/draw/engines/overlay/overlay_background.c b/source/blender/draw/engines/overlay/overlay_background.c index 74fed530ed7..6a87658b57c 100644 --- a/source/blender/draw/engines/overlay/overlay_background.c +++ b/source/blender/draw/engines/overlay/overlay_background.c @@ -96,7 +96,7 @@ void OVERLAY_background_cache_init(OVERLAY_Data *vedata) GPUShader *sh = OVERLAY_shader_clipbound(); DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->clipping_frustum_ps); - DRW_shgroup_uniform_vec4_copy(grp, "color", G_draw.block.colorClippingBorder); + DRW_shgroup_uniform_vec4_copy(grp, "color", G_draw.block.color_clipping_border); DRW_shgroup_uniform_vec3(grp, "boundbox", &bb->vec[0][0], 8); struct GPUBatch *cube = DRW_cache_cube_get(); diff --git a/source/blender/draw/engines/overlay/overlay_edit_text.c b/source/blender/draw/engines/overlay/overlay_edit_text.c index 40c905c6db9..dfef5b3c241 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_text.c +++ b/source/blender/draw/engines/overlay/overlay_edit_text.c @@ -35,7 +35,7 @@ void OVERLAY_edit_text_cache_init(OVERLAY_Data *vedata) sh = OVERLAY_shader_uniform_color(); pd->edit_text_wire_grp[i] = grp = DRW_shgroup_create(sh, psl->edit_text_wire_ps[i]); - DRW_shgroup_uniform_vec4_copy(grp, "color", G_draw.block.colorWire); + DRW_shgroup_uniform_vec4_copy(grp, "color", G_draw.block.color_wire); } { state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA; @@ -139,7 +139,7 @@ static void edit_text_cache_populate_boxes(OVERLAY_Data *vedata, Object *ob) for (int i = 0; i < cu->totbox; i++) { TextBox *tb = &cu->tb[i]; const bool is_active = (i == (cu->actbox - 1)); - float *color = is_active ? G_draw.block.colorActive : G_draw.block.colorWire; + float *color = is_active ? G_draw.block.color_active : G_draw.block.color_wire; if ((tb->w != 0.0f) || (tb->h != 0.0f)) { float vecs[4][3]; diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c index 4f0bf0b8048..73450db8eea 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.c +++ b/source/blender/draw/engines/overlay/overlay_extra.c @@ -194,23 +194,23 @@ void OVERLAY_extra_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); grp_sub = DRW_shgroup_create_sub(grp); - DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.colorActive); + DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.color_active); cb->center_active = BUF_POINT(grp_sub, format); grp_sub = DRW_shgroup_create_sub(grp); - DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.colorSelect); + DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.color_select); cb->center_selected = BUF_POINT(grp_sub, format); grp_sub = DRW_shgroup_create_sub(grp); - DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.colorDeselect); + DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.color_deselect); cb->center_deselected = BUF_POINT(grp_sub, format); grp_sub = DRW_shgroup_create_sub(grp); - DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.colorLibrarySelect); + DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.color_library_select); cb->center_selected_lib = BUF_POINT(grp_sub, format); grp_sub = DRW_shgroup_create_sub(grp); - DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.colorLibrary); + DRW_shgroup_uniform_vec4_copy(grp_sub, "color", G_draw.block.color_library); cb->center_deselected_lib = BUF_POINT(grp_sub, format); } } @@ -861,8 +861,8 @@ static void camera_view3d_reconstruction( int track_index = 1; float bundle_color_custom[3]; - float *bundle_color_solid = G_draw.block.colorBundleSolid; - float *bundle_color_unselected = G_draw.block.colorWire; + float *bundle_color_solid = G_draw.block.color_bundle_solid; + float *bundle_color_unselected = G_draw.block.color_wire; uchar text_color_selected[4], text_color_unselected[4]; /* Color Management: Exception here as texts are drawn in sRGB space directly. */ UI_GetThemeColor4ubv(TH_SELECT, text_color_selected); @@ -1034,7 +1034,7 @@ static void camera_stereoscopy_extra(OVERLAY_ExtraCallBuffers *cb, DRW_buffer_add_entry_struct(cb->camera_frame, &stereodata); /* Connecting line between cameras. */ - OVERLAY_extra_line_dashed(cb, stereodata.pos, instdata->pos, G_draw.block.colorWire); + OVERLAY_extra_line_dashed(cb, stereodata.pos, instdata->pos, G_draw.block.color_wire); } if (is_stereo3d_volume && !is_select) { @@ -1248,8 +1248,8 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, Scene *scene, Object *ob) { - float *relation_color = G_draw.block.colorWire; - float *constraint_color = G_draw.block.colorGridAxisZ; /* ? */ + float *relation_color = G_draw.block.color_wire; + float *constraint_color = G_draw.block.color_grid_axis_z; /* ? */ if (ob->parent && (DRW_object_visibility_in_active_context(ob->parent) & OB_VISIBLE_SELF)) { float *parent_pos = ob->runtime.parent_display_origin; diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.c b/source/blender/draw/engines/overlay/overlay_gpencil.c index 79d0e62c25c..5c5226bfe65 100644 --- a/source/blender/draw/engines/overlay/overlay_gpencil.c +++ b/source/blender/draw/engines/overlay/overlay_gpencil.c @@ -174,7 +174,7 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata) bGPDcontrolpoint *cp = &gpd->runtime.cp_points[i]; grp = DRW_shgroup_create_sub(grp); DRW_shgroup_uniform_vec3_copy(grp, "pPosition", &cp->x); - DRW_shgroup_uniform_float_copy(grp, "pSize", cp->size * 0.8f * G_draw.block.sizePixel); + DRW_shgroup_uniform_float_copy(grp, "pSize", cp->size * 0.8f * G_draw.block.size_pixel); DRW_shgroup_uniform_vec4_copy(grp, "pColor", cp->color); DRW_shgroup_call_procedural_points(grp, NULL, 1); } @@ -196,7 +196,7 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_vec3_copy(grp, "pPosition", scene->cursor.location); } DRW_shgroup_uniform_vec4_copy(grp, "pColor", color); - DRW_shgroup_uniform_float_copy(grp, "pSize", 8.0f * G_draw.block.sizePixel); + DRW_shgroup_uniform_float_copy(grp, "pSize", 8.0f * G_draw.block.size_pixel); DRW_shgroup_call_procedural_points(grp, NULL, 1); } } diff --git a/source/blender/draw/engines/overlay/overlay_grid.c b/source/blender/draw/engines/overlay/overlay_grid.c index 475af24d004..20403f156a1 100644 --- a/source/blender/draw/engines/overlay/overlay_grid.c +++ b/source/blender/draw/engines/overlay/overlay_grid.c @@ -224,7 +224,7 @@ void OVERLAY_grid_cache_init(OVERLAY_Data *vedata) sh = OVERLAY_shader_grid_background(); grp = DRW_shgroup_create(sh, psl->grid_ps); float color_back[4]; - interp_v4_v4v4(color_back, G_draw.block.colorBackground, G_draw.block.colorGrid, 0.5); + interp_v4_v4v4(color_back, G_draw.block.color_background, G_draw.block.color_grid, 0.5); DRW_shgroup_uniform_vec4_copy(grp, "color", color_back); DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); unit_m4(mat); diff --git a/source/blender/draw/engines/overlay/overlay_metaball.c b/source/blender/draw/engines/overlay/overlay_metaball.c index 7805b63993e..f024f5dfac8 100644 --- a/source/blender/draw/engines/overlay/overlay_metaball.c +++ b/source/blender/draw/engines/overlay/overlay_metaball.c @@ -60,10 +60,10 @@ void OVERLAY_edit_metaball_cache_populate(OVERLAY_Data *vedata, Object *ob) MetaBall *mb = ob->data; const float *color; - const float *col_radius = G_draw.block.colorMballRadius; - const float *col_radius_select = G_draw.block.colorMballRadiusSelect; - const float *col_stiffness = G_draw.block.colorMballStiffness; - const float *col_stiffness_select = G_draw.block.colorMballStiffnessSelect; + const float *col_radius = G_draw.block.color_mball_radius; + const float *col_radius_select = G_draw.block.color_mball_radius_select; + const float *col_stiffness = G_draw.block.color_mball_stiffness; + const float *col_stiffness_select = G_draw.block.color_mball_stiffness_select; int select_id = 0; if (is_select) { diff --git a/source/blender/draw/engines/overlay/shaders/edit_mesh_facefill_frag.glsl b/source/blender/draw/engines/overlay/shaders/edit_mesh_facefill_frag.glsl deleted file mode 100644 index a8371958ec2..00000000000 --- a/source/blender/draw/engines/overlay/shaders/edit_mesh_facefill_frag.glsl +++ /dev/null @@ -1,7 +0,0 @@ -flat in vec4 faceColor; -out vec4 FragColor; - -void main() -{ - FragColor = faceColor; -} diff --git a/source/blender/draw/engines/overlay/shaders/edit_mesh_facefill_vert.glsl b/source/blender/draw/engines/overlay/shaders/edit_mesh_facefill_vert.glsl deleted file mode 100644 index df37c6fb0bc..00000000000 --- a/source/blender/draw/engines/overlay/shaders/edit_mesh_facefill_vert.glsl +++ /dev/null @@ -1,23 +0,0 @@ - -uniform ivec4 dataMask = ivec4(0xFF); - -in vec3 pos; -in ivec4 data; - -flat out vec4 faceColor; - -void main() -{ - GPU_INTEL_VERTEX_SHADER_WORKAROUND - - vec3 world_pos = point_object_to_world(pos); - gl_Position = point_world_to_ndc(world_pos); - - ivec4 data_m = data & dataMask; - - faceColor = EDIT_MESH_face_color(data_m.x); - -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_calc_clip_distance(world_pos); -#endif -} diff --git a/source/blender/draw/engines/select/select_engine.c b/source/blender/draw/engines/select/select_engine.c index 60d9f8e1951..0b3db521e74 100644 --- a/source/blender/draw/engines/select/select_engine.c +++ b/source/blender/draw/engines/select/select_engine.c @@ -178,7 +178,7 @@ static void select_cache_init(void *vedata) if (e_data.context.select_mode & SCE_SELECT_VERTEX) { DRW_PASS_CREATE(psl->select_id_vert_pass, state); pd->shgrp_vert = DRW_shgroup_create(sh->select_id_flat, psl->select_id_vert_pass); - DRW_shgroup_uniform_float_copy(pd->shgrp_vert, "sizeVertex", 2 * G_draw.block.sizeVertex); + DRW_shgroup_uniform_float_copy(pd->shgrp_vert, "sizeVertex", 2 * G_draw.block.size_vertex); } } diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c index 010f424b9da..326727685fc 100644 --- a/source/blender/draw/engines/workbench/workbench_data.c +++ b/source/blender/draw/engines/workbench/workbench_data.c @@ -275,7 +275,7 @@ void workbench_update_world_ubo(WORKBENCH_PrivateData *wpd) copy_v2_v2(wd.viewport_size_inv, DRW_viewport_invert_size_get()); copy_v3_v3(wd.object_outline_color, wpd->shading.object_outline_color); wd.object_outline_color[3] = 1.0f; - wd.ui_scale = DRW_state_is_image_render() ? 1.0f : G_draw.block.sizePixel; + wd.ui_scale = DRW_state_is_image_render() ? 1.0f : G_draw.block.size_pixel; wd.matcap_orientation = (wpd->shading.flag & V3D_SHADING_MATCAP_FLIP_X) != 0; workbench_studiolight_data_update(wpd, &wd); diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 1c2a580e26d..5fa0b4fc26a 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -817,7 +817,7 @@ GPUBatch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold) case OB_CURVES_LEGACY: return NULL; case OB_SURF: - return DRW_cache_surf_edge_detection_get(ob, r_is_manifold); + return NULL; case OB_FONT: return NULL; case OB_MBALL: @@ -841,7 +841,7 @@ GPUBatch *DRW_cache_object_face_wireframe_get(Object *ob) case OB_CURVES_LEGACY: return NULL; case OB_SURF: - return DRW_cache_surf_face_wireframe_get(ob); + return NULL; case OB_FONT: return NULL; case OB_MBALL: @@ -868,7 +868,7 @@ GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob) case OB_CURVES_LEGACY: return NULL; case OB_SURF: - return DRW_cache_surf_loose_edges_get(ob); + return NULL; case OB_FONT: return NULL; case OB_MBALL: @@ -892,7 +892,7 @@ GPUBatch *DRW_cache_object_surface_get(Object *ob) case OB_CURVES_LEGACY: return NULL; case OB_SURF: - return DRW_cache_surf_surface_get(ob); + return NULL; case OB_FONT: return NULL; case OB_MBALL: @@ -919,7 +919,7 @@ GPUVertBuf *DRW_cache_object_pos_vertbuf_get(Object *ob) case OB_CURVES_LEGACY: case OB_SURF: case OB_FONT: - return DRW_curve_batch_cache_pos_vertbuf_get(ob->data); + return NULL; case OB_MBALL: return DRW_mball_batch_cache_pos_vertbuf_get(ob); case OB_CURVES: @@ -976,7 +976,7 @@ GPUBatch **DRW_cache_object_surface_material_get(struct Object *ob, case OB_CURVES_LEGACY: return NULL; case OB_SURF: - return DRW_cache_surf_surface_shaded_get(ob, gpumat_array, gpumat_array_len); + return NULL; case OB_FONT: return NULL; case OB_MBALL: @@ -3003,87 +3003,13 @@ GPUBatch *DRW_cache_text_edge_wire_get(Object *ob) /** \name Surface * \{ */ -GPUBatch *DRW_cache_surf_surface_get(Object *ob) -{ - BLI_assert(ob->type == OB_SURF); - - struct Curve *cu = ob->data; - struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh_no_subsurf(ob); - if (mesh_eval != NULL) { - return DRW_mesh_batch_cache_get_surface(mesh_eval); - } - - return DRW_curve_batch_cache_get_triangles_with_normals(cu); -} - GPUBatch *DRW_cache_surf_edge_wire_get(Object *ob) { BLI_assert(ob->type == OB_SURF); - struct Curve *cu = ob->data; - struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh_no_subsurf(ob); - if (mesh_eval != NULL) { - return DRW_mesh_batch_cache_get_loose_edges(mesh_eval); - } - return DRW_curve_batch_cache_get_wire_edge(cu); } -GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob) -{ - BLI_assert(ob->type == OB_SURF); - - struct Curve *cu = ob->data; - struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh_no_subsurf(ob); - if (mesh_eval != NULL) { - return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval); - } - - return DRW_curve_batch_cache_get_wireframes_face(cu); -} - -GPUBatch *DRW_cache_surf_edge_detection_get(Object *ob, bool *r_is_manifold) -{ - BLI_assert(ob->type == OB_SURF); - struct Curve *cu = ob->data; - struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh_no_subsurf(ob); - if (mesh_eval != NULL) { - return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold); - } - - return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold); -} - -GPUBatch *DRW_cache_surf_loose_edges_get(Object *ob) -{ - BLI_assert(ob->type == OB_SURF); - - struct Curve *cu = ob->data; - struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh_no_subsurf(ob); - if (mesh_eval != NULL) { - return DRW_mesh_batch_cache_get_loose_edges(mesh_eval); - } - - /* TODO */ - UNUSED_VARS(cu); - return NULL; -} - -GPUBatch **DRW_cache_surf_surface_shaded_get(Object *ob, - struct GPUMaterial **gpumat_array, - uint gpumat_array_len) -{ - BLI_assert(ob->type == OB_SURF); - - struct Curve *cu = ob->data; - struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh_no_subsurf(ob); - if (mesh_eval != NULL) { - return DRW_mesh_batch_cache_get_surface_shaded(ob, mesh_eval, gpumat_array, gpumat_array_len); - } - - return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len); -} - /** \} */ /* -------------------------------------------------------------------- */ @@ -3369,19 +3295,13 @@ GPUBatch *DRW_cache_cursor_get(bool crosshair_lines) void drw_batch_cache_validate(Object *ob) { - struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh_no_subsurf(ob); switch (ob->type) { case OB_MESH: DRW_mesh_batch_cache_validate(ob, (Mesh *)ob->data); break; case OB_CURVES_LEGACY: case OB_FONT: - DRW_curve_batch_cache_validate((Curve *)ob->data); - break; case OB_SURF: - if (mesh_eval != NULL) { - DRW_mesh_batch_cache_validate(ob, mesh_eval); - } DRW_curve_batch_cache_validate((Curve *)ob->data); break; case OB_MBALL: @@ -3418,7 +3338,6 @@ void drw_batch_cache_generate_requested(Object *ob) DRW_object_use_hide_faces(ob)) || ((mode == CTX_MODE_EDIT_MESH) && DRW_object_is_in_edit_mode(ob)))); - struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh_no_subsurf(ob); switch (ob->type) { case OB_MESH: DRW_mesh_batch_cache_create_requested( @@ -3426,13 +3345,7 @@ void drw_batch_cache_generate_requested(Object *ob) break; case OB_CURVES_LEGACY: case OB_FONT: - DRW_curve_batch_cache_create_requested(ob, scene); - break; case OB_SURF: - if (mesh_eval) { - DRW_mesh_batch_cache_create_requested( - DST.task_graph, ob, mesh_eval, scene, is_paint_mode, use_hide); - } DRW_curve_batch_cache_create_requested(ob, scene); break; /* TODO: all cases. */ @@ -3468,17 +3381,10 @@ void drw_batch_cache_generate_requested_delayed(Object *ob) void DRW_batch_cache_free_old(Object *ob, int ctime) { - struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh_no_subsurf(ob); - switch (ob->type) { case OB_MESH: DRW_mesh_batch_cache_free_old((Mesh *)ob->data, ctime); break; - case OB_SURF: - if (mesh_eval) { - DRW_mesh_batch_cache_free_old(mesh_eval, ctime); - } - break; /* TODO: all cases. */ default: break; diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index 56342440bf3..9af8ba38658 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -186,17 +186,7 @@ struct GPUBatch *DRW_cache_text_edge_wire_get(struct Object *ob); /* Surface */ -struct GPUBatch *DRW_cache_surf_surface_get(struct Object *ob); struct GPUBatch *DRW_cache_surf_edge_wire_get(struct Object *ob); -struct GPUBatch *DRW_cache_surf_loose_edges_get(struct Object *ob); - -/* Return list of batches */ - -struct GPUBatch **DRW_cache_surf_surface_shaded_get(struct Object *ob, - struct GPUMaterial **gpumat_array, - uint gpumat_array_len); -struct GPUBatch *DRW_cache_surf_face_wireframe_get(struct Object *ob); -struct GPUBatch *DRW_cache_surf_edge_detection_get(struct Object *ob, bool *r_is_manifold); /* Lattice */ diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h index d262d1a5d4d..e728d8614de 100644 --- a/source/blender/draw/intern/draw_cache_impl.h +++ b/source/blender/draw/intern/draw_cache_impl.h @@ -104,16 +104,9 @@ int DRW_curve_material_count_get(struct Curve *cu); struct GPUBatch *DRW_curve_batch_cache_get_wire_edge(struct Curve *cu); struct GPUBatch *DRW_curve_batch_cache_get_normal_edge(struct Curve *cu); -struct GPUBatch *DRW_curve_batch_cache_get_edge_detection(struct Curve *cu, bool *r_is_manifold); struct GPUBatch *DRW_curve_batch_cache_get_edit_edges(struct Curve *cu); struct GPUBatch *DRW_curve_batch_cache_get_edit_verts(struct Curve *cu); -struct GPUBatch *DRW_curve_batch_cache_get_triangles_with_normals(struct Curve *cu); -struct GPUBatch **DRW_curve_batch_cache_get_surface_shaded(struct Curve *cu, - struct GPUMaterial **gpumat_array, - uint gpumat_array_len); -struct GPUBatch *DRW_curve_batch_cache_get_wireframes_face(struct Curve *cu); - /** \} */ /* -------------------------------------------------------------------- */ @@ -141,16 +134,8 @@ void DRW_displist_vertbuf_create_pos_and_nor(struct ListBase *lb, struct GPUVertBuf *vbo, const struct Scene *scene); void DRW_displist_vertbuf_create_wiredata(struct ListBase *lb, struct GPUVertBuf *vbo); -void DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv_and_tan(struct ListBase *lb, - struct GPUVertBuf *vbo_pos_nor, - struct GPUVertBuf *vbo_uv, - struct GPUVertBuf *vbo_tan, - const struct Scene *scene); void DRW_displist_indexbuf_create_lines_in_order(struct ListBase *lb, struct GPUIndexBuf *ibo); void DRW_displist_indexbuf_create_triangles_in_order(struct ListBase *lb, struct GPUIndexBuf *ibo); -void DRW_displist_indexbuf_create_triangles_loop_split_by_material(struct ListBase *lb, - struct GPUIndexBuf **ibo_mat, - uint mat_len); void DRW_displist_indexbuf_create_edges_adjacency_lines(struct ListBase *lb, struct GPUIndexBuf *ibo, bool *r_is_manifold); @@ -309,7 +294,6 @@ struct GPUBatch *DRW_mesh_batch_cache_get_edit_mesh_analysis(struct Mesh *me); * \{ */ struct GPUVertBuf *DRW_mesh_batch_cache_pos_vertbuf_get(struct Mesh *me); -struct GPUVertBuf *DRW_curve_batch_cache_pos_vertbuf_get(struct Curve *cu); struct GPUVertBuf *DRW_mball_batch_cache_pos_vertbuf_get(struct Object *ob); int DRW_mesh_material_count_get(const struct Object *object, const struct Mesh *me); diff --git a/source/blender/draw/intern/draw_cache_impl_curve.cc b/source/blender/draw/intern/draw_cache_impl_curve.cc index 6a3d3fa5e9e..7b8f34b999c 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.cc +++ b/source/blender/draw/intern/draw_cache_impl_curve.cc @@ -19,9 +19,9 @@ #include "DNA_curve_types.h" #include "BKE_curve.h" +#include "BKE_curves.hh" #include "BKE_displist.h" #include "BKE_geometry_set.hh" -#include "BKE_spline.hh" #include "BKE_vfont.h" #include "GPU_batch.h" @@ -96,18 +96,19 @@ static void curve_render_overlay_verts_edges_len_get(ListBase *lb, } } -static void curve_eval_render_wire_verts_edges_len_get(const CurveEval &curve_eval, +static void curve_eval_render_wire_verts_edges_len_get(const blender::bke::CurvesGeometry &curves, int *r_curve_len, int *r_vert_len, int *r_edge_len) { - Span<SplinePtr> splines = curve_eval.splines(); - *r_curve_len = splines.size(); - *r_vert_len = 0; + *r_curve_len = curves.curves_num(); + *r_vert_len = curves.evaluated_points_num(); + *r_edge_len = 0; - for (const SplinePtr &spline : splines) { - *r_vert_len += spline->evaluated_points_size(); - *r_edge_len += spline->evaluated_edges_size(); + const blender::VArray<bool> cyclic = curves.cyclic(); + for (const int i : curves.curves_range()) { + const IndexRange points = curves.evaluated_points_for_curve(i); + *r_edge_len += blender::bke::curves::curve_segment_size(points.size(), cyclic[i]); } } @@ -165,7 +166,7 @@ struct CurveRenderData { CurveCache *ob_curve_cache; /* Owned by the evaluated object's geometry set (#geometry_set_eval). */ - const CurveEval *curve_eval; + const Curves *curve_eval; /* borrow from 'Curve' */ ListBase *nurbs; @@ -209,10 +210,11 @@ static CurveRenderData *curve_render_data_create(Curve *cu, if (types & CU_DATATYPE_WIRE) { if (rdata->curve_eval != nullptr) { - curve_eval_render_wire_verts_edges_len_get(*rdata->curve_eval, - &rdata->wire.curve_len, - &rdata->wire.vert_len, - &rdata->wire.edge_len); + curve_eval_render_wire_verts_edges_len_get( + blender::bke::CurvesGeometry::wrap(rdata->curve_eval->geometry), + &rdata->wire.curve_len, + &rdata->wire.vert_len, + &rdata->wire.edge_len); } } @@ -288,107 +290,39 @@ static int curve_render_data_normal_len_get(const CurveRenderData *rdata) return rdata->normal.len; } -static void curve_cd_calc_used_gpu_layers(CustomDataMask *cd_layers, - struct GPUMaterial **gpumat_array, - int gpumat_array_len) -{ - for (int i = 0; i < gpumat_array_len; i++) { - struct GPUMaterial *gpumat = gpumat_array[i]; - if (gpumat == nullptr) { - continue; - } - - ListBase gpu_attrs = GPU_material_attributes(gpumat); - LISTBASE_FOREACH (GPUMaterialAttribute *, gpu_attr, &gpu_attrs) { - const char *name = gpu_attr->name; - int type = gpu_attr->type; - - /* Curves cannot have named layers. - * NOTE: We could relax this assumption later. */ - if (name[0] != '\0') { - continue; - } - - if (type == CD_AUTO_FROM_NAME) { - type = CD_MTFACE; - } - - switch (type) { - case CD_MTFACE: - *cd_layers |= CD_MASK_MLOOPUV; - break; - case CD_TANGENT: - *cd_layers |= CD_MASK_TANGENT; - break; - case CD_MCOL: - /* Curve object don't have Color data. */ - break; - case CD_ORCO: - *cd_layers |= CD_MASK_ORCO; - break; - case CD_HAIRLENGTH: - *cd_layers |= CD_MASK_HAIRLENGTH; - break; - } - } - } -} - /* ---------------------------------------------------------------------- */ /* Curve GPUBatch Cache */ struct CurveBatchCache { struct { - GPUVertBuf *pos_nor; - GPUVertBuf *edge_fac; GPUVertBuf *curves_pos; - - GPUVertBuf *loop_pos_nor; - GPUVertBuf *loop_uv; - GPUVertBuf *loop_tan; } ordered; struct { - /* Curve points. Aligned with ordered.pos_nor */ GPUVertBuf *curves_nor; - GPUVertBuf *curves_weight; /* TODO. */ /* Edit points (beztriples and bpoints) */ GPUVertBuf *pos; GPUVertBuf *data; } edit; struct { - GPUIndexBuf *surfaces_tris; - GPUIndexBuf *surfaces_lines; GPUIndexBuf *curves_lines; - GPUIndexBuf *edges_adj_lines; /* Edit mode */ GPUIndexBuf *edit_verts; GPUIndexBuf *edit_lines; } ibo; struct { - GPUBatch *surfaces; - GPUBatch *surfaces_edges; GPUBatch *curves; /* control handles and vertices */ GPUBatch *edit_edges; GPUBatch *edit_verts; GPUBatch *edit_normals; - GPUBatch *edge_detection; } batch; - GPUIndexBuf **surf_per_mat_tris; - GPUBatch **surf_per_mat; - int mat_len; - CustomDataMask cd_used, cd_needed; - /* settings to determine if cache is invalid */ bool is_dirty; bool is_editmode; - - /* Valid only if edge_detection is up to date. */ - bool is_manifold; }; /* GPUBatch cache management. */ @@ -401,10 +335,6 @@ static bool curve_batch_cache_valid(Curve *cu) return false; } - if (cache->mat_len != DRW_curve_material_count_get(cu)) { - return false; - } - if (cache->is_dirty) { return false; } @@ -445,13 +375,6 @@ static void curve_batch_cache_init(Curve *cu) } #endif - cache->cd_used = 0; - cache->mat_len = DRW_curve_material_count_get(cu); - cache->surf_per_mat_tris = (GPUIndexBuf **)MEM_callocN( - sizeof(*cache->surf_per_mat_tris) * cache->mat_len, __func__); - cache->surf_per_mat = (GPUBatch **)MEM_callocN(sizeof(*cache->surf_per_mat) * cache->mat_len, - __func__); - cache->is_editmode = (cu->editnurb != nullptr) || (cu->editfont != nullptr); cache->is_dirty = false; @@ -514,15 +437,6 @@ static void curve_batch_cache_clear(Curve *cu) GPUBatch **batch = (GPUBatch **)&cache->batch; GPU_BATCH_DISCARD_SAFE(batch[i]); } - - for (int i = 0; i < cache->mat_len; i++) { - GPU_INDEXBUF_DISCARD_SAFE(cache->surf_per_mat_tris[i]); - GPU_BATCH_DISCARD_SAFE(cache->surf_per_mat[i]); - } - MEM_SAFE_FREE(cache->surf_per_mat_tris); - MEM_SAFE_FREE(cache->surf_per_mat); - cache->mat_len = 0; - cache->cd_used = 0; } void DRW_curve_batch_cache_free(Curve *cu) @@ -554,18 +468,10 @@ static void curve_create_curves_pos(CurveRenderData *rdata, GPUVertBuf *vbo_curv GPU_vertbuf_init_with_format(vbo_curves_pos, &format); GPU_vertbuf_data_alloc(vbo_curves_pos, vert_len); - const CurveEval &curve_eval = *rdata->curve_eval; - Span<SplinePtr> splines = curve_eval.splines(); - Array<int> offsets = curve_eval.evaluated_point_offsets(); - BLI_assert(offsets.last() == vert_len); - - for (const int i_spline : splines.index_range()) { - Span<float3> positions = splines[i_spline]->evaluated_positions(); - for (const int i_point : positions.index_range()) { - GPU_vertbuf_attr_set( - vbo_curves_pos, attr_id.pos, offsets[i_spline] + i_point, positions[i_point]); - } - } + const blender::bke::CurvesGeometry &curves = blender::bke::CurvesGeometry::wrap( + rdata->curve_eval->geometry); + const Span<float3> positions = curves.evaluated_positions(); + GPU_vertbuf_attr_fill(vbo_curves_pos, attr_id.pos, positions.data()); } static void curve_create_curves_lines(CurveRenderData *rdata, GPUIndexBuf *ibo_curve_lines) @@ -583,18 +489,16 @@ static void curve_create_curves_lines(CurveRenderData *rdata, GPUIndexBuf *ibo_c GPUIndexBufBuilder elb; GPU_indexbuf_init_ex(&elb, GPU_PRIM_LINE_STRIP, index_len, vert_len); - const CurveEval &curve_eval = *rdata->curve_eval; - Span<SplinePtr> splines = curve_eval.splines(); - Array<int> offsets = curve_eval.evaluated_point_offsets(); - BLI_assert(offsets.last() == vert_len); - - for (const int i_spline : splines.index_range()) { - const int eval_size = splines[i_spline]->evaluated_points_size(); - if (splines[i_spline]->is_cyclic() && splines[i_spline]->evaluated_edges_size() > 1) { - GPU_indexbuf_add_generic_vert(&elb, offsets[i_spline] + eval_size - 1); + const blender::bke::CurvesGeometry &curves = blender::bke::CurvesGeometry::wrap( + rdata->curve_eval->geometry); + const blender::VArray<bool> cyclic = curves.cyclic(); + for (const int i : curves.curves_range()) { + const IndexRange points = curves.evaluated_points_for_curve(i); + if (cyclic[i] && points.size() > 1) { + GPU_indexbuf_add_generic_vert(&elb, points.last()); } - for (const int i_point : IndexRange(eval_size)) { - GPU_indexbuf_add_generic_vert(&elb, offsets[i_spline] + i_point); + for (const int i_point : points) { + GPU_indexbuf_add_generic_vert(&elb, i_point); } GPU_indexbuf_add_primitive_restart(&elb); } @@ -883,55 +787,6 @@ GPUBatch *DRW_curve_batch_cache_get_edit_verts(Curve *cu) return DRW_batch_request(&cache->batch.edit_verts); } -GPUBatch *DRW_curve_batch_cache_get_triangles_with_normals(struct Curve *cu) -{ - CurveBatchCache *cache = curve_batch_cache_get(cu); - return DRW_batch_request(&cache->batch.surfaces); -} - -GPUBatch **DRW_curve_batch_cache_get_surface_shaded(struct Curve *cu, - struct GPUMaterial **gpumat_array, - uint gpumat_array_len) -{ - CurveBatchCache *cache = curve_batch_cache_get(cu); - - BLI_assert(gpumat_array_len == cache->mat_len); - - curve_cd_calc_used_gpu_layers(&cache->cd_needed, gpumat_array, gpumat_array_len); - - for (int i = 0; i < cache->mat_len; i++) { - DRW_batch_request(&cache->surf_per_mat[i]); - } - return cache->surf_per_mat; -} - -GPUVertBuf *DRW_curve_batch_cache_pos_vertbuf_get(struct Curve *cu) -{ - CurveBatchCache *cache = curve_batch_cache_get(cu); - /* Request surface to trigger the vbo filling. Otherwise it may do nothing. */ - DRW_batch_request(&cache->batch.surfaces); - - DRW_vbo_request(nullptr, &cache->ordered.loop_pos_nor); - return cache->ordered.loop_pos_nor; -} - -GPUBatch *DRW_curve_batch_cache_get_wireframes_face(Curve *cu) -{ - CurveBatchCache *cache = curve_batch_cache_get(cu); - return DRW_batch_request(&cache->batch.surfaces_edges); -} - -GPUBatch *DRW_curve_batch_cache_get_edge_detection(Curve *cu, bool *r_is_manifold) -{ - CurveBatchCache *cache = curve_batch_cache_get(cu); - /* Even if is_manifold is not correct (not updated), - * the default (not manifold) is just the worst case. */ - if (r_is_manifold) { - *r_is_manifold = cache->is_manifold; - } - return DRW_batch_request(&cache->batch.edge_detection); -} - int DRW_curve_material_count_get(Curve *cu) { return max_ii(1, cu->totcol); @@ -950,36 +805,11 @@ void DRW_curve_batch_cache_create_requested(Object *ob, const struct Scene *scen Curve *cu = (Curve *)ob->data; CurveBatchCache *cache = curve_batch_cache_get(cu); - /* Verify that all surface batches have needed attribute layers. */ - /* TODO(fclem): We could be a bit smarter here and only do it per material. */ - if ((cache->cd_used & cache->cd_needed) != cache->cd_needed) { - for (int i = 0; i < cache->mat_len; i++) { - /* We can't discard batches at this point as they have been - * referenced for drawing. Just clear them in place. */ - GPU_BATCH_CLEAR_SAFE(cache->surf_per_mat[i]); - } - - cache->cd_used |= cache->cd_needed; - cache->cd_needed = 0; - } - /* Init batches and request VBOs & IBOs */ - if (DRW_batch_requested(cache->batch.surfaces, GPU_PRIM_TRIS)) { - DRW_vbo_request(cache->batch.surfaces, &cache->ordered.loop_pos_nor); - } - if (DRW_batch_requested(cache->batch.surfaces_edges, GPU_PRIM_LINES)) { - DRW_ibo_request(cache->batch.surfaces_edges, &cache->ibo.surfaces_lines); - DRW_vbo_request(cache->batch.surfaces_edges, &cache->ordered.pos_nor); - DRW_vbo_request(cache->batch.surfaces_edges, &cache->ordered.edge_fac); - } if (DRW_batch_requested(cache->batch.curves, GPU_PRIM_LINE_STRIP)) { DRW_ibo_request(cache->batch.curves, &cache->ibo.curves_lines); DRW_vbo_request(cache->batch.curves, &cache->ordered.curves_pos); } - if (DRW_batch_requested(cache->batch.edge_detection, GPU_PRIM_LINES_ADJ)) { - DRW_ibo_request(cache->batch.edge_detection, &cache->ibo.edges_adj_lines); - DRW_vbo_request(cache->batch.edge_detection, &cache->ordered.pos_nor); - } /* Edit mode */ if (DRW_batch_requested(cache->batch.edit_edges, GPU_PRIM_LINES)) { @@ -995,20 +825,6 @@ void DRW_curve_batch_cache_create_requested(Object *ob, const struct Scene *scen if (DRW_batch_requested(cache->batch.edit_normals, GPU_PRIM_LINES)) { DRW_vbo_request(cache->batch.edit_normals, &cache->edit.curves_nor); } - for (int i = 0; i < cache->mat_len; i++) { - if (DRW_batch_requested(cache->surf_per_mat[i], GPU_PRIM_TRIS)) { - if (cache->mat_len > 1) { - DRW_ibo_request(cache->surf_per_mat[i], &cache->surf_per_mat_tris[i]); - } - if (cache->cd_used & CD_MASK_MLOOPUV) { - DRW_vbo_request(cache->surf_per_mat[i], &cache->ordered.loop_uv); - } - if (cache->cd_used & CD_MASK_TANGENT) { - DRW_vbo_request(cache->surf_per_mat[i], &cache->ordered.loop_tan); - } - DRW_vbo_request(cache->surf_per_mat[i], &cache->ordered.loop_pos_nor); - } - } #ifdef DRW_DEBUG_MESH_CACHE_REQUEST printf("-- %s %s --\n", __func__, ob->id.name + 2); @@ -1016,76 +832,28 @@ void DRW_curve_batch_cache_create_requested(Object *ob, const struct Scene *scen /* Generate MeshRenderData flags */ int mr_flag = 0; - DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.pos_nor, CU_DATATYPE_SURFACE); - DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.edge_fac, CU_DATATYPE_SURFACE); DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.curves_pos, CU_DATATYPE_WIRE); - DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.loop_pos_nor, CU_DATATYPE_SURFACE); - DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.loop_uv, CU_DATATYPE_SURFACE); - DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.loop_tan, CU_DATATYPE_SURFACE); - DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.surfaces_tris, CU_DATATYPE_SURFACE); - DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.surfaces_lines, CU_DATATYPE_SURFACE); DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.curves_lines, CU_DATATYPE_WIRE); - DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.edges_adj_lines, CU_DATATYPE_SURFACE); DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->edit.pos, CU_DATATYPE_OVERLAY); DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->edit.data, CU_DATATYPE_OVERLAY); DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->edit.curves_nor, CU_DATATYPE_NORMAL); - DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->edit.curves_weight, CU_DATATYPE_OVERLAY); DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.edit_verts, CU_DATATYPE_OVERLAY); DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.edit_lines, CU_DATATYPE_OVERLAY); - for (int i = 0; i < cache->mat_len; i++) { - DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->surf_per_mat_tris[i], CU_DATATYPE_SURFACE); - } - #ifdef DRW_DEBUG_MESH_CACHE_REQUEST printf(" mr_flag %d\n\n", mr_flag); #endif CurveRenderData *rdata = curve_render_data_create(cu, ob->runtime.curve_cache, mr_flag); - /* The object's curve cache can be empty (in one case because we use #CurveEval's cache instead), - * If so, point to an empty DispList list to avoid the need to check for null in the following - * functions. */ - ListBase empty_lb = {nullptr, nullptr}; - ListBase *lb = rdata->ob_curve_cache == nullptr ? &empty_lb : &rdata->ob_curve_cache->disp; - /* Generate VBOs */ - if (DRW_vbo_requested(cache->ordered.pos_nor)) { - DRW_displist_vertbuf_create_pos_and_nor(lb, cache->ordered.pos_nor, scene); - } - if (DRW_vbo_requested(cache->ordered.edge_fac)) { - DRW_displist_vertbuf_create_wiredata(lb, cache->ordered.edge_fac); - } if (DRW_vbo_requested(cache->ordered.curves_pos)) { curve_create_curves_pos(rdata, cache->ordered.curves_pos); } - - if (DRW_vbo_requested(cache->ordered.loop_pos_nor) || - DRW_vbo_requested(cache->ordered.loop_uv) || DRW_vbo_requested(cache->ordered.loop_tan)) { - DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv_and_tan( - lb, cache->ordered.loop_pos_nor, cache->ordered.loop_uv, cache->ordered.loop_tan, scene); - } - - if (DRW_ibo_requested(cache->surf_per_mat_tris[0])) { - DRW_displist_indexbuf_create_triangles_loop_split_by_material( - lb, cache->surf_per_mat_tris, cache->mat_len); - } - if (DRW_ibo_requested(cache->ibo.curves_lines)) { curve_create_curves_lines(rdata, cache->ibo.curves_lines); } - if (DRW_ibo_requested(cache->ibo.surfaces_tris)) { - DRW_displist_indexbuf_create_triangles_in_order(lb, cache->ibo.surfaces_tris); - } - if (DRW_ibo_requested(cache->ibo.surfaces_lines)) { - DRW_displist_indexbuf_create_lines_in_order(lb, cache->ibo.surfaces_lines); - } - if (DRW_ibo_requested(cache->ibo.edges_adj_lines)) { - DRW_displist_indexbuf_create_edges_adjacency_lines( - lb, cache->ibo.edges_adj_lines, &cache->is_manifold); - } - if (DRW_vbo_requested(cache->edit.pos) || DRW_vbo_requested(cache->edit.data) || DRW_ibo_requested(cache->ibo.edit_verts) || DRW_ibo_requested(cache->ibo.edit_lines)) { curve_create_edit_data_and_handles( diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c index ee3d16b2830..96c088c3ee9 100644 --- a/source/blender/draw/intern/draw_cache_impl_displist.c +++ b/source/blender/draw/intern/draw_cache_impl_displist.c @@ -9,7 +9,6 @@ * \note DispList may be removed soon! This is a utility for object types that use render. */ -#include "BLI_alloca.h" #include "BLI_edgehash.h" #include "BLI_listbase.h" #include "BLI_math_vector.h" @@ -19,7 +18,6 @@ #include "DNA_scene_types.h" #include "BKE_displist.h" -#include "BKE_displist_tangent.h" #include "GPU_batch.h" #include "GPU_capabilities.h" @@ -112,53 +110,6 @@ static void displist_indexbufbuilder_set( } } -static int displist_indexbufbuilder_tess_set( - SetTriIndicesFn *set_tri_indices, - SetTriIndicesFn *set_quad_tri_indices, /* meh, find a better solution. */ - void *thunk, - const DispList *dl, - const int ofs) -{ - int v_idx = ofs; - if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { - if (dl->type == DL_INDEX3) { - for (int i = 0; i < dl->parts; i++) { - set_tri_indices(thunk, v_idx + 0, v_idx + 1, v_idx + 2); - v_idx += 3; - } - } - else if (dl->type == DL_SURF) { - for (int a = 0; a < dl->parts; a++) { - if ((dl->flag & DL_CYCL_V) == 0 && a == dl->parts - 1) { - break; - } - int b = (dl->flag & DL_CYCL_U) ? 0 : 1; - for (; b < dl->nr; b++) { - set_quad_tri_indices(thunk, v_idx + 0, v_idx + 1, v_idx + 2); - set_quad_tri_indices(thunk, v_idx + 3, v_idx + 4, v_idx + 5); - v_idx += 6; - } - } - } - else { - BLI_assert(dl->type == DL_INDEX4); - const int *idx = dl->index; - for (int i = 0; i < dl->parts; i++, idx += 4) { - if (idx[2] != idx[3]) { - set_quad_tri_indices(thunk, v_idx + 0, v_idx + 1, v_idx + 2); - set_quad_tri_indices(thunk, v_idx + 3, v_idx + 4, v_idx + 5); - v_idx += 6; - } - else { - set_tri_indices(thunk, v_idx + 0, v_idx + 1, v_idx + 2); - v_idx += 3; - } - } - } - } - return v_idx; -} - void DRW_displist_vertbuf_create_pos_and_nor(ListBase *lb, GPUVertBuf *vbo, const Scene *scene) { const bool do_hq_normals = (scene->r.perf_flag & SCE_PERF_HQ_NORMALS) != 0 || @@ -273,35 +224,6 @@ void DRW_displist_indexbuf_create_triangles_in_order(ListBase *lb, GPUIndexBuf * GPU_indexbuf_build_in_place(&elb, ibo); } -void DRW_displist_indexbuf_create_triangles_loop_split_by_material(ListBase *lb, - GPUIndexBuf **ibo_mats, - uint mat_len) -{ - GPUIndexBufBuilder *elb = BLI_array_alloca(elb, mat_len); - - const int tri_len = curve_render_surface_tri_len_get(lb); - - /* Init each index buffer builder */ - for (int i = 0; i < mat_len; i++) { - GPU_indexbuf_init(&elb[i], GPU_PRIM_TRIS, tri_len * 3, tri_len * 3); - } - - /* calc each index buffer builder */ - uint v_idx = 0; - LISTBASE_FOREACH (const DispList *, dl, lb) { - v_idx = displist_indexbufbuilder_tess_set((SetTriIndicesFn *)GPU_indexbuf_add_tri_verts, - (SetTriIndicesFn *)GPU_indexbuf_add_tri_verts, - &elb[dl->col], - dl, - v_idx); - } - - /* build each indexbuf */ - for (int i = 0; i < mat_len; i++) { - GPU_indexbuf_build_in_place(&elb[i], ibo_mats[i]); - } -} - static void set_overlay_wires_tri_indices(void *thunk, uint v1, uint v2, uint v3) { GPUIndexBufBuilder *eld = (GPUIndexBufBuilder *)thunk; @@ -335,433 +257,6 @@ void DRW_displist_indexbuf_create_lines_in_order(ListBase *lb, GPUIndexBuf *ibo) GPU_indexbuf_build_in_place(&elb, ibo); } -static void surf_uv_quad(const DispList *dl, const uint quad[4], float r_uv[4][2]) -{ - int orco_sizeu = dl->nr - 1; - int orco_sizev = dl->parts - 1; - - /* exception as handled in convertblender.c too */ - if (dl->flag & DL_CYCL_U) { - orco_sizeu++; - } - if (dl->flag & DL_CYCL_V) { - orco_sizev++; - } - - for (int i = 0; i < 4; i++) { - /* NOTE: For some reason the shading U and V are swapped compared to the - * one described in the surface format. */ - /* find uv based on vertex index into grid array */ - r_uv[i][0] = (quad[i] / dl->nr) / (float)orco_sizev; - r_uv[i][1] = (quad[i] % dl->nr) / (float)orco_sizeu; - - /* cyclic correction */ - if (ELEM(i, 1, 2) && r_uv[i][0] == 0.0f) { - r_uv[i][0] = 1.0f; - } - if (ELEM(i, 0, 1) && r_uv[i][1] == 0.0f) { - r_uv[i][1] = 1.0f; - } - } -} - -static void displist_vertbuf_attr_set_nor(GPUVertBufRaw *step, - const GPUNormal *n1, - const GPUNormal *n2, - const GPUNormal *n3, - const bool do_hq_normals) -{ - if (do_hq_normals) { - copy_v3_v3_short(GPU_vertbuf_raw_step(step), n1->high); - copy_v3_v3_short(GPU_vertbuf_raw_step(step), n2->high); - copy_v3_v3_short(GPU_vertbuf_raw_step(step), n3->high); - } - else { - *(GPUPackedNormal *)GPU_vertbuf_raw_step(step) = n1->low; - *(GPUPackedNormal *)GPU_vertbuf_raw_step(step) = n2->low; - *(GPUPackedNormal *)GPU_vertbuf_raw_step(step) = n3->low; - } -} - -static void displist_vertbuf_attr_set_tri_pos_nor_uv(GPUVertBufRaw *pos_step, - GPUVertBufRaw *nor_step, - GPUVertBufRaw *uv_step, - GPUVertBufRaw *tan_step, - const float v1[3], - const float v2[3], - const float v3[3], - const GPUNormal *n1, - const GPUNormal *n2, - const GPUNormal *n3, - const GPUNormal *t1, - const GPUNormal *t2, - const GPUNormal *t3, - const float uv1[2], - const float uv2[2], - const float uv3[2], - const bool do_hq_normals) -{ - if (pos_step->size != 0) { - copy_v3_v3(GPU_vertbuf_raw_step(pos_step), v1); - copy_v3_v3(GPU_vertbuf_raw_step(pos_step), v2); - copy_v3_v3(GPU_vertbuf_raw_step(pos_step), v3); - displist_vertbuf_attr_set_nor(nor_step, n1, n2, n3, do_hq_normals); - } - if (uv_step->size != 0) { - normal_float_to_short_v2(GPU_vertbuf_raw_step(uv_step), uv1); - normal_float_to_short_v2(GPU_vertbuf_raw_step(uv_step), uv2); - normal_float_to_short_v2(GPU_vertbuf_raw_step(uv_step), uv3); - } - if (tan_step->size != 0) { - displist_vertbuf_attr_set_nor(tan_step, t1, t2, t3, do_hq_normals); - } -} - -#define SURFACE_QUAD_ITER_BEGIN(dl) \ - { \ - uint quad[4]; \ - int quad_index = 0; \ - int max_v = (dl->flag & DL_CYCL_V) ? dl->parts : (dl->parts - 1); \ - int max_u = (dl->flag & DL_CYCL_U) ? dl->nr : (dl->nr - 1); \ - for (int v = 0; v < max_v; v++) { \ - quad[3] = dl->nr * v; \ - quad[0] = quad[3] + 1; \ - quad[2] = quad[3] + dl->nr; \ - quad[1] = quad[0] + dl->nr; \ - /* Cyclic wrap */ \ - if (v == dl->parts - 1) { \ - quad[1] -= dl->parts * dl->nr; \ - quad[2] -= dl->parts * dl->nr; \ - } \ - for (int u = 0; u < max_u; u++, quad_index++) { \ - /* Cyclic wrap */ \ - if (u == dl->nr - 1) { \ - quad[0] -= dl->nr; \ - quad[1] -= dl->nr; \ - } - -#define SURFACE_QUAD_ITER_END \ - quad[2] = quad[1]; \ - quad[1]++; \ - quad[3] = quad[0]; \ - quad[0]++; \ - } \ - } \ - } - -static void displist_surf_fnors_ensure(const DispList *dl, float (**fnors)[3]) -{ - int u_len = dl->nr - ((dl->flag & DL_CYCL_U) ? 0 : 1); - int v_len = dl->parts - ((dl->flag & DL_CYCL_V) ? 0 : 1); - const float(*verts)[3] = (const float(*)[3])dl->verts; - float(*nor_flat)[3] = MEM_mallocN(sizeof(float[3]) * u_len * v_len, __func__); - *fnors = nor_flat; - - SURFACE_QUAD_ITER_BEGIN (dl) { - normal_quad_v3(*nor_flat, verts[quad[0]], verts[quad[1]], verts[quad[2]], verts[quad[3]]); - nor_flat++; - } - SURFACE_QUAD_ITER_END -} - -void DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv_and_tan(ListBase *lb, - GPUVertBuf *vbo_pos_nor, - GPUVertBuf *vbo_uv, - GPUVertBuf *vbo_tan, - const Scene *scene) -{ - const bool do_hq_normals = (scene->r.perf_flag & SCE_PERF_HQ_NORMALS) != 0 || - GPU_use_hq_normals_workaround(); - - static GPUVertFormat format_pos_nor = {0}; - static GPUVertFormat format_pos_nor_hq = {0}; - static GPUVertFormat format_uv = {0}; - static GPUVertFormat format_tan = {0}; - static GPUVertFormat format_tan_hq = {0}; - static struct { - uint pos, nor, uv, tan; - uint pos_hq, nor_hq, tan_hq; - } attr_id; - if (format_pos_nor.attr_len == 0) { - /* initialize vertex format */ - attr_id.pos = GPU_vertformat_attr_add( - &format_pos_nor, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - attr_id.nor = GPU_vertformat_attr_add( - &format_pos_nor, "nor", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); - attr_id.pos_hq = GPU_vertformat_attr_add( - &format_pos_nor_hq, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - attr_id.nor_hq = GPU_vertformat_attr_add( - &format_pos_nor_hq, "nor", GPU_COMP_I16, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); - - /* UVs are in [0..1] range. We can compress them. */ - attr_id.uv = GPU_vertformat_attr_add( - &format_uv, "u", GPU_COMP_I16, 2, GPU_FETCH_INT_TO_FLOAT_UNIT); - GPU_vertformat_alias_add(&format_uv, "au"); - - attr_id.tan = GPU_vertformat_attr_add( - &format_tan, "t", GPU_COMP_I10, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); - GPU_vertformat_alias_add(&format_tan, "at"); - attr_id.tan_hq = GPU_vertformat_attr_add( - &format_tan_hq, "t", GPU_COMP_I16, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); - GPU_vertformat_alias_add(&format_tan_hq, "at"); - } - uint pos_id = do_hq_normals ? attr_id.pos_hq : attr_id.pos; - uint nor_id = do_hq_normals ? attr_id.nor_hq : attr_id.nor; - uint tan_id = do_hq_normals ? attr_id.tan_hq : attr_id.tan; - - int vbo_len_capacity = curve_render_surface_tri_len_get(lb) * 3; - - GPUVertBufRaw pos_step = {0}; - GPUVertBufRaw nor_step = {0}; - GPUVertBufRaw uv_step = {0}; - GPUVertBufRaw tan_step = {0}; - -#define DRW_TEST_ASSIGN_VBO(v) (v = (DRW_vbo_requested(v) ? (v) : NULL)) - - if (DRW_TEST_ASSIGN_VBO(vbo_pos_nor)) { - GPU_vertbuf_init_with_format(vbo_pos_nor, - do_hq_normals ? &format_pos_nor_hq : &format_pos_nor); - GPU_vertbuf_data_alloc(vbo_pos_nor, vbo_len_capacity); - GPU_vertbuf_attr_get_raw_data(vbo_pos_nor, pos_id, &pos_step); - GPU_vertbuf_attr_get_raw_data(vbo_pos_nor, nor_id, &nor_step); - } - if (DRW_TEST_ASSIGN_VBO(vbo_uv)) { - GPU_vertbuf_init_with_format(vbo_uv, &format_uv); - GPU_vertbuf_data_alloc(vbo_uv, vbo_len_capacity); - GPU_vertbuf_attr_get_raw_data(vbo_uv, attr_id.uv, &uv_step); - } - if (DRW_TEST_ASSIGN_VBO(vbo_tan)) { - GPU_vertbuf_init_with_format(vbo_tan, do_hq_normals ? &format_tan_hq : &format_tan); - GPU_vertbuf_data_alloc(vbo_tan, vbo_len_capacity); - GPU_vertbuf_attr_get_raw_data(vbo_tan, tan_id, &tan_step); - } - -#undef DRW_TEST_ASSIGN_VBO - - BKE_displist_normals_add(lb); - - LISTBASE_FOREACH (const DispList *, dl, lb) { - const bool is_smooth = (dl->rt & CU_SMOOTH) != 0; - if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { - const float(*verts)[3] = (const float(*)[3])dl->verts; - const float(*nors)[3] = (const float(*)[3])dl->nors; - const int *idx = dl->index; - float uv[4][2]; - - if (dl->type == DL_INDEX3) { - /* Currently 'DL_INDEX3' is always a flat surface with a single normal. */ - GPUNormal tangent_packed; - GPUNormal normal_packed; - GPU_normal_convert_v3(&normal_packed, dl->nors, do_hq_normals); - if (vbo_tan) { - float tan[4]; - float(*tan_ptr)[4] = &tan; - BKE_displist_tangent_calc(dl, NULL, &tan_ptr); - GPU_normal_convert_v3(&tangent_packed, tan, do_hq_normals); - normal_float_to_short_v3(tangent_packed.high, tan); - } - else { - if (do_hq_normals) { - tangent_packed.high[0] = 0; - tangent_packed.high[1] = 0; - tangent_packed.high[2] = 0; - } - else { - tangent_packed.low = (GPUPackedNormal){0, 0, 0, 1}; - } - } - - const float x_max = (float)(dl->nr - 1); - uv[0][1] = uv[1][1] = uv[2][1] = 0.0f; - const int i_end = dl->parts; - for (int i = 0; i < i_end; i++, idx += 3) { - if (vbo_uv) { - uv[0][0] = idx[0] / x_max; - uv[1][0] = idx[1] / x_max; - uv[2][0] = idx[2] / x_max; - } - - displist_vertbuf_attr_set_tri_pos_nor_uv(&pos_step, - &nor_step, - &uv_step, - &tan_step, - verts[idx[0]], - verts[idx[2]], - verts[idx[1]], - &normal_packed, - &normal_packed, - &normal_packed, - &tangent_packed, - &tangent_packed, - &tangent_packed, - uv[0], - uv[2], - uv[1], - do_hq_normals); - } - } - else if (dl->type == DL_SURF) { - float(*tangents)[4] = NULL; - float(*fnors)[3] = NULL; - - if (!is_smooth) { - displist_surf_fnors_ensure(dl, &fnors); - } - - if (vbo_tan) { - BKE_displist_tangent_calc(dl, fnors, &tangents); - } - - SURFACE_QUAD_ITER_BEGIN (dl) { - if (vbo_uv) { - surf_uv_quad(dl, quad, uv); - } - GPUNormal pnors_quad[4]; - GPUNormal ptans_quad[4]; - - if (is_smooth) { - for (int j = 0; j < 4; j++) { - GPU_normal_convert_v3(&pnors_quad[j], nors[quad[j]], do_hq_normals); - } - } - else { - GPU_normal_convert_v3(&pnors_quad[0], fnors[quad_index], do_hq_normals); - pnors_quad[1] = pnors_quad[2] = pnors_quad[3] = pnors_quad[0]; - } - - if (vbo_tan) { - for (int j = 0; j < 4; j++) { - float *tan = tangents[quad_index * 4 + j]; - GPU_normal_convert_v3(&ptans_quad[j], tan, do_hq_normals); - } - } - - displist_vertbuf_attr_set_tri_pos_nor_uv(&pos_step, - &nor_step, - &uv_step, - &tan_step, - verts[quad[2]], - verts[quad[0]], - verts[quad[1]], - &pnors_quad[2], - &pnors_quad[0], - &pnors_quad[1], - &ptans_quad[2], - &ptans_quad[0], - &ptans_quad[1], - uv[2], - uv[0], - uv[1], - do_hq_normals); - - displist_vertbuf_attr_set_tri_pos_nor_uv(&pos_step, - &nor_step, - &uv_step, - &tan_step, - verts[quad[0]], - verts[quad[2]], - verts[quad[3]], - &pnors_quad[0], - &pnors_quad[2], - &pnors_quad[3], - &ptans_quad[0], - &ptans_quad[2], - &ptans_quad[3], - uv[0], - uv[2], - uv[3], - do_hq_normals); - } - SURFACE_QUAD_ITER_END - - MEM_SAFE_FREE(tangents); - MEM_SAFE_FREE(fnors); - } - else { - BLI_assert(dl->type == DL_INDEX4); - uv[0][0] = uv[0][1] = uv[1][0] = uv[3][1] = 0.0f; - uv[1][1] = uv[2][0] = uv[2][1] = uv[3][0] = 1.0f; - - const int i_end = dl->parts; - for (int i = 0; i < i_end; i++, idx += 4) { - const bool is_tri = idx[2] != idx[3]; - - GPUNormal ptan = {0}; - GPUNormal pnors_idx[4]; - if (is_smooth) { - int idx_len = is_tri ? 3 : 4; - for (int j = 0; j < idx_len; j++) { - GPU_normal_convert_v3(&pnors_idx[j], nors[idx[j]], do_hq_normals); - } - } - else { - float nor_flat[3]; - if (is_tri) { - normal_tri_v3(nor_flat, verts[idx[0]], verts[idx[1]], verts[idx[2]]); - } - else { - normal_quad_v3(nor_flat, verts[idx[0]], verts[idx[1]], verts[idx[2]], verts[idx[3]]); - } - GPU_normal_convert_v3(&pnors_idx[0], nor_flat, do_hq_normals); - pnors_idx[1] = pnors_idx[2] = pnors_idx[3] = pnors_idx[0]; - } - - displist_vertbuf_attr_set_tri_pos_nor_uv(&pos_step, - &nor_step, - &uv_step, - &tan_step, - verts[idx[0]], - verts[idx[2]], - verts[idx[1]], - &pnors_idx[0], - &pnors_idx[2], - &pnors_idx[1], - &ptan, - &ptan, - &ptan, - uv[0], - uv[2], - uv[1], - do_hq_normals); - - if (is_tri) { - displist_vertbuf_attr_set_tri_pos_nor_uv(&pos_step, - &nor_step, - &uv_step, - &tan_step, - verts[idx[2]], - verts[idx[0]], - verts[idx[3]], - &pnors_idx[2], - &pnors_idx[0], - &pnors_idx[3], - &ptan, - &ptan, - &ptan, - uv[2], - uv[0], - uv[3], - do_hq_normals); - } - } - } - } - } - /* Resize and finish. */ - if (pos_step.size != 0) { - int vbo_len_used = GPU_vertbuf_raw_used(&pos_step); - if (vbo_len_used < vbo_len_capacity) { - GPU_vertbuf_data_resize(vbo_pos_nor, vbo_len_used); - } - } - if (uv_step.size != 0) { - int vbo_len_used = GPU_vertbuf_raw_used(&uv_step); - if (vbo_len_used < vbo_len_capacity) { - GPU_vertbuf_data_resize(vbo_uv, vbo_len_used); - } - } -} - /* Edge detection/adjacency. */ #define NO_EDGE INT_MAX static void set_edge_adjacency_lines_indices( diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 462ae6f7cf1..0f330dbb519 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -40,154 +40,155 @@ void DRW_globals_update(void) { GlobalsUboStorage *gb = &G_draw.block; - UI_GetThemeColor4fv(TH_WIRE, gb->colorWire); - UI_GetThemeColor4fv(TH_WIRE_EDIT, gb->colorWireEdit); - UI_GetThemeColor4fv(TH_ACTIVE, gb->colorActive); - UI_GetThemeColor4fv(TH_SELECT, gb->colorSelect); - UI_COLOR_RGBA_FROM_U8(0x88, 0xFF, 0xFF, 155, gb->colorLibrarySelect); - UI_COLOR_RGBA_FROM_U8(0x55, 0xCC, 0xCC, 155, gb->colorLibrary); - UI_GetThemeColor4fv(TH_TRANSFORM, gb->colorTransform); - UI_GetThemeColor4fv(TH_LIGHT, gb->colorLight); - UI_GetThemeColor4fv(TH_SPEAKER, gb->colorSpeaker); - UI_GetThemeColor4fv(TH_CAMERA, gb->colorCamera); - UI_GetThemeColor4fv(TH_CAMERA_PATH, gb->colorCameraPath); - UI_GetThemeColor4fv(TH_EMPTY, gb->colorEmpty); - UI_GetThemeColor4fv(TH_VERTEX, gb->colorVertex); - UI_GetThemeColor4fv(TH_VERTEX_SELECT, gb->colorVertexSelect); - UI_GetThemeColor4fv(TH_VERTEX_UNREFERENCED, gb->colorVertexUnreferenced); - UI_COLOR_RGBA_FROM_U8(0xB0, 0x00, 0xB0, 0xFF, gb->colorVertexMissingData); - UI_GetThemeColor4fv(TH_EDITMESH_ACTIVE, gb->colorEditMeshActive); - UI_GetThemeColor4fv(TH_EDGE_SELECT, gb->colorEdgeSelect); - UI_GetThemeColor4fv(TH_GP_VERTEX, gb->colorGpencilVertex); - UI_GetThemeColor4fv(TH_GP_VERTEX_SELECT, gb->colorGpencilVertexSelect); - - UI_GetThemeColor4fv(TH_EDGE_SEAM, gb->colorEdgeSeam); - UI_GetThemeColor4fv(TH_EDGE_SHARP, gb->colorEdgeSharp); - UI_GetThemeColor4fv(TH_EDGE_CREASE, gb->colorEdgeCrease); - UI_GetThemeColor4fv(TH_EDGE_BEVEL, gb->colorEdgeBWeight); - UI_GetThemeColor4fv(TH_EDGE_FACESEL, gb->colorEdgeFaceSelect); - UI_GetThemeColor4fv(TH_FACE, gb->colorFace); - UI_GetThemeColor4fv(TH_FACE_SELECT, gb->colorFaceSelect); - UI_GetThemeColor4fv(TH_FACE_BACK, gb->colorFaceBack); - UI_GetThemeColor4fv(TH_FACE_FRONT, gb->colorFaceFront); - UI_GetThemeColor4fv(TH_NORMAL, gb->colorNormal); - UI_GetThemeColor4fv(TH_VNORMAL, gb->colorVNormal); - UI_GetThemeColor4fv(TH_LNORMAL, gb->colorLNormal); - UI_GetThemeColor4fv(TH_FACE_DOT, gb->colorFaceDot); - UI_GetThemeColor4fv(TH_SKIN_ROOT, gb->colorSkinRoot); - UI_GetThemeColor4fv(TH_BACK, gb->colorBackground); - UI_GetThemeColor4fv(TH_BACK_GRAD, gb->colorBackgroundGradient); - UI_GetThemeColor4fv(TH_TRANSPARENT_CHECKER_PRIMARY, gb->colorCheckerPrimary); - UI_GetThemeColor4fv(TH_TRANSPARENT_CHECKER_SECONDARY, gb->colorCheckerSecondary); - gb->sizeChecker = UI_GetThemeValuef(TH_TRANSPARENT_CHECKER_SIZE); - UI_GetThemeColor4fv(TH_V3D_CLIPPING_BORDER, gb->colorClippingBorder); + UI_GetThemeColor4fv(TH_WIRE, gb->color_wire); + UI_GetThemeColor4fv(TH_WIRE_EDIT, gb->color_wire_edit); + UI_GetThemeColor4fv(TH_ACTIVE, gb->color_active); + UI_GetThemeColor4fv(TH_SELECT, gb->color_select); + UI_COLOR_RGBA_FROM_U8(0x88, 0xFF, 0xFF, 155, gb->color_library_select); + UI_COLOR_RGBA_FROM_U8(0x55, 0xCC, 0xCC, 155, gb->color_library); + UI_GetThemeColor4fv(TH_TRANSFORM, gb->color_transform); + UI_GetThemeColor4fv(TH_LIGHT, gb->color_light); + UI_GetThemeColor4fv(TH_SPEAKER, gb->color_speaker); + UI_GetThemeColor4fv(TH_CAMERA, gb->color_camera); + UI_GetThemeColor4fv(TH_CAMERA_PATH, gb->color_camera_path); + UI_GetThemeColor4fv(TH_EMPTY, gb->color_empty); + UI_GetThemeColor4fv(TH_VERTEX, gb->color_vertex); + UI_GetThemeColor4fv(TH_VERTEX_SELECT, gb->color_vertex_select); + UI_GetThemeColor4fv(TH_VERTEX_UNREFERENCED, gb->color_vertex_unreferenced); + UI_COLOR_RGBA_FROM_U8(0xB0, 0x00, 0xB0, 0xFF, gb->color_vertex_missing_data); + UI_GetThemeColor4fv(TH_EDITMESH_ACTIVE, gb->color_edit_mesh_active); + UI_GetThemeColor4fv(TH_EDGE_SELECT, gb->color_edge_select); + UI_GetThemeColor4fv(TH_GP_VERTEX, gb->color_gpencil_vertex); + UI_GetThemeColor4fv(TH_GP_VERTEX_SELECT, gb->color_gpencil_vertex_select); + + UI_GetThemeColor4fv(TH_EDGE_SEAM, gb->color_edge_seam); + UI_GetThemeColor4fv(TH_EDGE_SHARP, gb->color_edge_sharp); + UI_GetThemeColor4fv(TH_EDGE_CREASE, gb->color_edge_crease); + UI_GetThemeColor4fv(TH_EDGE_BEVEL, gb->color_edge_bweight); + UI_GetThemeColor4fv(TH_EDGE_FACESEL, gb->color_edge_face_select); + UI_GetThemeColor4fv(TH_FACE, gb->color_face); + UI_GetThemeColor4fv(TH_FACE_SELECT, gb->color_face_select); + UI_GetThemeColor4fv(TH_FACE_BACK, gb->color_face_back); + UI_GetThemeColor4fv(TH_FACE_FRONT, gb->color_face_front); + UI_GetThemeColor4fv(TH_NORMAL, gb->color_normal); + UI_GetThemeColor4fv(TH_VNORMAL, gb->color_vnormal); + UI_GetThemeColor4fv(TH_LNORMAL, gb->color_lnormal); + UI_GetThemeColor4fv(TH_FACE_DOT, gb->color_facedot); + UI_GetThemeColor4fv(TH_SKIN_ROOT, gb->color_skinroot); + UI_GetThemeColor4fv(TH_BACK, gb->color_background); + UI_GetThemeColor4fv(TH_BACK_GRAD, gb->color_background_gradient); + UI_GetThemeColor4fv(TH_TRANSPARENT_CHECKER_PRIMARY, gb->color_checker_primary); + UI_GetThemeColor4fv(TH_TRANSPARENT_CHECKER_SECONDARY, gb->color_checker_secondary); + gb->size_checker = UI_GetThemeValuef(TH_TRANSPARENT_CHECKER_SIZE); + UI_GetThemeColor4fv(TH_V3D_CLIPPING_BORDER, gb->color_clipping_border); /* Custom median color to slightly affect the edit mesh colors. */ - interp_v4_v4v4(gb->colorEditMeshMiddle, gb->colorVertexSelect, gb->colorWireEdit, 0.35f); - copy_v3_fl( - gb->colorEditMeshMiddle, - dot_v3v3(gb->colorEditMeshMiddle, (float[3]){0.3333f, 0.3333f, 0.3333f})); /* Desaturate */ + interp_v4_v4v4(gb->color_edit_mesh_middle, gb->color_vertex_select, gb->color_wire_edit, 0.35f); + copy_v3_fl(gb->color_edit_mesh_middle, + dot_v3v3(gb->color_edit_mesh_middle, + (float[3]){0.3333f, 0.3333f, 0.3333f})); /* Desaturate */ #ifdef WITH_FREESTYLE - UI_GetThemeColor4fv(TH_FREESTYLE_EDGE_MARK, gb->colorEdgeFreestyle); - UI_GetThemeColor4fv(TH_FREESTYLE_FACE_MARK, gb->colorFaceFreestyle); + UI_GetThemeColor4fv(TH_FREESTYLE_EDGE_MARK, gb->color_edge_freestyle); + UI_GetThemeColor4fv(TH_FREESTYLE_FACE_MARK, gb->color_face_freestyle); #else - zero_v4(gb->colorEdgeFreestyle); - zero_v4(gb->colorFaceFreestyle); + zero_v4(gb->color_edge_freestyle); + zero_v4(gb->color_face_freestyle); #endif - UI_GetThemeColor4fv(TH_TEXT, gb->colorText); - UI_GetThemeColor4fv(TH_TEXT_HI, gb->colorTextHi); + UI_GetThemeColor4fv(TH_TEXT, gb->color_text); + UI_GetThemeColor4fv(TH_TEXT_HI, gb->color_text_hi); /* Bone colors */ - UI_GetThemeColor4fv(TH_BONE_POSE, gb->colorBonePose); - UI_GetThemeColor4fv(TH_BONE_POSE_ACTIVE, gb->colorBonePoseActive); - UI_GetThemeColorShade4fv(TH_EDGE_SELECT, 60, gb->colorBoneActive); - UI_GetThemeColorShade4fv(TH_EDGE_SELECT, -20, gb->colorBoneSelect); - UI_GetThemeColorBlendShade4fv(TH_WIRE, TH_BONE_POSE, 0.15f, 0, gb->colorBonePoseActiveUnsel); - UI_GetThemeColorBlendShade3fv(TH_WIRE_EDIT, TH_EDGE_SELECT, 0.15f, 0, gb->colorBoneActiveUnsel); - UI_COLOR_RGBA_FROM_U8(255, 150, 0, 80, gb->colorBonePoseTarget); - UI_COLOR_RGBA_FROM_U8(255, 255, 0, 80, gb->colorBonePoseIK); - UI_COLOR_RGBA_FROM_U8(200, 255, 0, 80, gb->colorBonePoseSplineIK); - UI_COLOR_RGBA_FROM_U8(0, 255, 120, 80, gb->colorBonePoseConstraint); - UI_GetThemeColor4fv(TH_BONE_SOLID, gb->colorBoneSolid); - UI_GetThemeColor4fv(TH_BONE_LOCKED_WEIGHT, gb->colorBoneLocked); - copy_v4_fl4(gb->colorBoneIKLine, 0.8f, 0.5f, 0.0f, 1.0f); - copy_v4_fl4(gb->colorBoneIKLineNoTarget, 0.8f, 0.8f, 0.2f, 1.0f); - copy_v4_fl4(gb->colorBoneIKLineSpline, 0.8f, 0.8f, 0.2f, 1.0f); + UI_GetThemeColor4fv(TH_BONE_POSE, gb->color_bone_pose); + UI_GetThemeColor4fv(TH_BONE_POSE_ACTIVE, gb->color_bone_pose_active); + UI_GetThemeColorShade4fv(TH_EDGE_SELECT, 60, gb->color_bone_active); + UI_GetThemeColorShade4fv(TH_EDGE_SELECT, -20, gb->color_bone_select); + UI_GetThemeColorBlendShade4fv(TH_WIRE, TH_BONE_POSE, 0.15f, 0, gb->color_bone_pose_active_unsel); + UI_GetThemeColorBlendShade3fv( + TH_WIRE_EDIT, TH_EDGE_SELECT, 0.15f, 0, gb->color_bone_active_unsel); + UI_COLOR_RGBA_FROM_U8(255, 150, 0, 80, gb->color_bone_pose_target); + UI_COLOR_RGBA_FROM_U8(255, 255, 0, 80, gb->color_bone_pose_ik); + UI_COLOR_RGBA_FROM_U8(200, 255, 0, 80, gb->color_bone_pose_spline_ik); + UI_COLOR_RGBA_FROM_U8(0, 255, 120, 80, gb->color_bone_pose_constraint); + UI_GetThemeColor4fv(TH_BONE_SOLID, gb->color_bone_solid); + UI_GetThemeColor4fv(TH_BONE_LOCKED_WEIGHT, gb->color_bone_locked); + copy_v4_fl4(gb->color_bone_ik_line, 0.8f, 0.5f, 0.0f, 1.0f); + copy_v4_fl4(gb->color_bone_ik_line_no_target, 0.8f, 0.8f, 0.2f, 1.0f); + copy_v4_fl4(gb->color_bone_ik_line_spline, 0.8f, 0.8f, 0.2f, 1.0f); /* Curve */ - UI_GetThemeColor4fv(TH_HANDLE_FREE, gb->colorHandleFree); - UI_GetThemeColor4fv(TH_HANDLE_AUTO, gb->colorHandleAuto); - UI_GetThemeColor4fv(TH_HANDLE_VECT, gb->colorHandleVect); - UI_GetThemeColor4fv(TH_HANDLE_ALIGN, gb->colorHandleAlign); - UI_GetThemeColor4fv(TH_HANDLE_AUTOCLAMP, gb->colorHandleAutoclamp); - UI_GetThemeColor4fv(TH_HANDLE_SEL_FREE, gb->colorHandleSelFree); - UI_GetThemeColor4fv(TH_HANDLE_SEL_AUTO, gb->colorHandleSelAuto); - UI_GetThemeColor4fv(TH_HANDLE_SEL_VECT, gb->colorHandleSelVect); - UI_GetThemeColor4fv(TH_HANDLE_SEL_ALIGN, gb->colorHandleSelAlign); - UI_GetThemeColor4fv(TH_HANDLE_SEL_AUTOCLAMP, gb->colorHandleSelAutoclamp); - UI_GetThemeColor4fv(TH_NURB_ULINE, gb->colorNurbUline); - UI_GetThemeColor4fv(TH_NURB_VLINE, gb->colorNurbVline); - UI_GetThemeColor4fv(TH_NURB_SEL_ULINE, gb->colorNurbSelUline); - UI_GetThemeColor4fv(TH_NURB_SEL_VLINE, gb->colorNurbSelVline); - UI_GetThemeColor4fv(TH_ACTIVE_SPLINE, gb->colorActiveSpline); - - UI_GetThemeColor4fv(TH_CFRAME, gb->colorCurrentFrame); + UI_GetThemeColor4fv(TH_HANDLE_FREE, gb->color_handle_free); + UI_GetThemeColor4fv(TH_HANDLE_AUTO, gb->color_handle_auto); + UI_GetThemeColor4fv(TH_HANDLE_VECT, gb->color_handle_vect); + UI_GetThemeColor4fv(TH_HANDLE_ALIGN, gb->color_handle_align); + UI_GetThemeColor4fv(TH_HANDLE_AUTOCLAMP, gb->color_handle_autoclamp); + UI_GetThemeColor4fv(TH_HANDLE_SEL_FREE, gb->color_handle_sel_free); + UI_GetThemeColor4fv(TH_HANDLE_SEL_AUTO, gb->color_handle_sel_auto); + UI_GetThemeColor4fv(TH_HANDLE_SEL_VECT, gb->color_handle_sel_vect); + UI_GetThemeColor4fv(TH_HANDLE_SEL_ALIGN, gb->color_handle_sel_align); + UI_GetThemeColor4fv(TH_HANDLE_SEL_AUTOCLAMP, gb->color_handle_sel_autoclamp); + UI_GetThemeColor4fv(TH_NURB_ULINE, gb->color_nurb_uline); + UI_GetThemeColor4fv(TH_NURB_VLINE, gb->color_nurb_vline); + UI_GetThemeColor4fv(TH_NURB_SEL_ULINE, gb->color_nurb_sel_uline); + UI_GetThemeColor4fv(TH_NURB_SEL_VLINE, gb->color_nurb_sel_vline); + UI_GetThemeColor4fv(TH_ACTIVE_SPLINE, gb->color_active_spline); + + UI_GetThemeColor4fv(TH_CFRAME, gb->color_current_frame); /* Meta-ball. */ - UI_COLOR_RGBA_FROM_U8(0xA0, 0x30, 0x30, 0xFF, gb->colorMballRadius); - UI_COLOR_RGBA_FROM_U8(0xF0, 0xA0, 0xA0, 0xFF, gb->colorMballRadiusSelect); - UI_COLOR_RGBA_FROM_U8(0x30, 0xA0, 0x30, 0xFF, gb->colorMballStiffness); - UI_COLOR_RGBA_FROM_U8(0xA0, 0xF0, 0xA0, 0xFF, gb->colorMballStiffnessSelect); + UI_COLOR_RGBA_FROM_U8(0xA0, 0x30, 0x30, 0xFF, gb->color_mball_radius); + UI_COLOR_RGBA_FROM_U8(0xF0, 0xA0, 0xA0, 0xFF, gb->color_mball_radius_select); + UI_COLOR_RGBA_FROM_U8(0x30, 0xA0, 0x30, 0xFF, gb->color_mball_stiffness); + UI_COLOR_RGBA_FROM_U8(0xA0, 0xF0, 0xA0, 0xFF, gb->color_mball_stiffness_select); /* Grid */ - UI_GetThemeColorShade4fv(TH_GRID, 10, gb->colorGrid); + UI_GetThemeColorShade4fv(TH_GRID, 10, gb->color_grid); /* Emphasize division lines lighter instead of darker, if background is darker than grid. */ UI_GetThemeColorShade4fv( TH_GRID, - (gb->colorGrid[0] + gb->colorGrid[1] + gb->colorGrid[2] + 0.12f > - gb->colorBackground[0] + gb->colorBackground[1] + gb->colorBackground[2]) ? + (gb->color_grid[0] + gb->color_grid[1] + gb->color_grid[2] + 0.12f > + gb->color_background[0] + gb->color_background[1] + gb->color_background[2]) ? 20 : -10, - gb->colorGridEmphasis); + gb->color_grid_emphasis); /* Grid Axis */ - UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_X, 0.5f, -10, gb->colorGridAxisX); - UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Y, 0.5f, -10, gb->colorGridAxisY); - UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Z, 0.5f, -10, gb->colorGridAxisZ); + UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_X, 0.5f, -10, gb->color_grid_axis_x); + UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Y, 0.5f, -10, gb->color_grid_axis_y); + UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Z, 0.5f, -10, gb->color_grid_axis_z); - UI_GetThemeColorShadeAlpha4fv(TH_TRANSFORM, 0, -80, gb->colorDeselect); - UI_GetThemeColorShadeAlpha4fv(TH_WIRE, 0, -30, gb->colorOutline); - UI_GetThemeColorShadeAlpha4fv(TH_LIGHT, 0, 255, gb->colorLightNoAlpha); + UI_GetThemeColorShadeAlpha4fv(TH_TRANSFORM, 0, -80, gb->color_deselect); + UI_GetThemeColorShadeAlpha4fv(TH_WIRE, 0, -30, gb->color_outline); + UI_GetThemeColorShadeAlpha4fv(TH_LIGHT, 0, 255, gb->color_light_no_alpha); /* UV colors */ - UI_GetThemeColor4fv(TH_UV_SHADOW, gb->colorUVShadow); + UI_GetThemeColor4fv(TH_UV_SHADOW, gb->color_uv_shadow); - gb->sizePixel = U.pixelsize; - gb->sizeObjectCenter = (UI_GetThemeValuef(TH_OBCENTER_DIA) + 1.0f) * U.pixelsize; - gb->sizeLightCenter = (UI_GetThemeValuef(TH_OBCENTER_DIA) + 1.5f) * U.pixelsize; - gb->sizeLightCircle = U.pixelsize * 9.0f; - gb->sizeLightCircleShadow = gb->sizeLightCircle + U.pixelsize * 3.0f; + gb->size_pixel = U.pixelsize; + gb->size_object_center = (UI_GetThemeValuef(TH_OBCENTER_DIA) + 1.0f) * U.pixelsize; + gb->size_light_center = (UI_GetThemeValuef(TH_OBCENTER_DIA) + 1.5f) * U.pixelsize; + gb->size_light_circle = U.pixelsize * 9.0f; + gb->size_light_circle_shadow = gb->size_light_circle + U.pixelsize * 3.0f; /* M_SQRT2 to be at least the same size of the old square */ - gb->sizeVertex = U.pixelsize * - (max_ff(1.0f, UI_GetThemeValuef(TH_VERTEX_SIZE) * (float)M_SQRT2 / 2.0f)); - gb->sizeVertexGpencil = U.pixelsize * UI_GetThemeValuef(TH_GP_VERTEX_SIZE); - gb->sizeFaceDot = U.pixelsize * UI_GetThemeValuef(TH_FACEDOT_SIZE); - gb->sizeEdge = U.pixelsize * (1.0f / 2.0f); /* TODO: Theme. */ - gb->sizeEdgeFix = U.pixelsize * (0.5f + 2.0f * (2.0f * (gb->sizeEdge * (float)M_SQRT1_2))); + gb->size_vertex = U.pixelsize * + (max_ff(1.0f, UI_GetThemeValuef(TH_VERTEX_SIZE) * (float)M_SQRT2 / 2.0f)); + gb->size_vertex_gpencil = U.pixelsize * UI_GetThemeValuef(TH_GP_VERTEX_SIZE); + gb->size_face_dot = U.pixelsize * UI_GetThemeValuef(TH_FACEDOT_SIZE); + gb->size_edge = U.pixelsize * (1.0f / 2.0f); /* TODO: Theme. */ + gb->size_edge_fix = U.pixelsize * (0.5f + 2.0f * (2.0f * (gb->size_edge * (float)M_SQRT1_2))); const float(*screen_vecs)[3] = (float(*)[3])DRW_viewport_screenvecs_get(); for (int i = 0; i < 2; i++) { - copy_v3_v3(gb->screenVecs[i], screen_vecs[i]); + copy_v3_v3(gb->screen_vecs[i], screen_vecs[i]); } - gb->pixelFac = *DRW_viewport_pixelsize_get(); + gb->pixel_fac = *DRW_viewport_pixelsize_get(); /* Deprecated, use drw_view.viewport_size instead */ - copy_v2_v2(&gb->sizeViewport[0], DRW_viewport_size_get()); - copy_v2_v2(&gb->sizeViewport[2], &gb->sizeViewport[0]); - invert_v2(&gb->sizeViewport[2]); + copy_v2_v2(&gb->size_viewport[0], DRW_viewport_size_get()); + copy_v2_v2(&gb->size_viewport[2], &gb->size_viewport[0]); + invert_v2(&gb->size_viewport[2]); /* Color management. */ { @@ -328,36 +329,36 @@ int DRW_object_wire_theme_get(Object *ob, ViewLayer *view_layer, float **r_color if (r_color != NULL) { if (UNLIKELY(ob->base_flag & BASE_FROM_SET)) { - *r_color = G_draw.block.colorWire; + *r_color = G_draw.block.color_wire; } else { switch (theme_id) { case TH_WIRE_EDIT: - *r_color = G_draw.block.colorWireEdit; + *r_color = G_draw.block.color_wire_edit; break; case TH_ACTIVE: - *r_color = G_draw.block.colorActive; + *r_color = G_draw.block.color_active; break; case TH_SELECT: - *r_color = G_draw.block.colorSelect; + *r_color = G_draw.block.color_select; break; case TH_TRANSFORM: - *r_color = G_draw.block.colorTransform; + *r_color = G_draw.block.color_transform; break; case TH_SPEAKER: - *r_color = G_draw.block.colorSpeaker; + *r_color = G_draw.block.color_speaker; break; case TH_CAMERA: - *r_color = G_draw.block.colorCamera; + *r_color = G_draw.block.color_camera; break; case TH_EMPTY: - *r_color = G_draw.block.colorEmpty; + *r_color = G_draw.block.color_empty; break; case TH_LIGHT: - *r_color = G_draw.block.colorLight; + *r_color = G_draw.block.color_light; break; default: - *r_color = G_draw.block.colorWire; + *r_color = G_draw.block.color_wire; break; } } diff --git a/source/blender/draw/intern/draw_common_shader_shared.h b/source/blender/draw/intern/draw_common_shader_shared.h index ecddddded78..52e0917ae5a 100644 --- a/source/blender/draw/intern/draw_common_shader_shared.h +++ b/source/blender/draw/intern/draw_common_shader_shared.h @@ -15,233 +15,233 @@ typedef struct GlobalsUboStorage GlobalsUboStorage; * have been merged into one engine, there is no reasons to keep these globals out of the overlay * engine. */ -#define UBO_FIRST_COLOR colorWire -#define UBO_LAST_COLOR colorUVShadow +#define UBO_FIRST_COLOR color_wire +#define UBO_LAST_COLOR color_uv_shadow /* Used as ubo but colors can be directly referenced as well */ /* NOTE: Also keep all color as vec4 and between #UBO_FIRST_COLOR and #UBO_LAST_COLOR. */ struct GlobalsUboStorage { /* UBOs data needs to be 16 byte aligned (size of vec4) */ - float4 colorWire; - float4 colorWireEdit; - float4 colorActive; - float4 colorSelect; - float4 colorLibrarySelect; - float4 colorLibrary; - float4 colorTransform; - float4 colorLight; - float4 colorSpeaker; - float4 colorCamera; - float4 colorCameraPath; - float4 colorEmpty; - float4 colorVertex; - float4 colorVertexSelect; - float4 colorVertexUnreferenced; - float4 colorVertexMissingData; - float4 colorEditMeshActive; - float4 colorEdgeSelect; - float4 colorEdgeSeam; - float4 colorEdgeSharp; - float4 colorEdgeCrease; - float4 colorEdgeBWeight; - float4 colorEdgeFaceSelect; - float4 colorEdgeFreestyle; - float4 colorFace; - float4 colorFaceSelect; - float4 colorFaceFreestyle; - float4 colorGpencilVertex; - float4 colorGpencilVertexSelect; - float4 colorNormal; - float4 colorVNormal; - float4 colorLNormal; - float4 colorFaceDot; - float4 colorSkinRoot; + float4 color_wire; + float4 color_wire_edit; + float4 color_active; + float4 color_select; + float4 color_library_select; + float4 color_library; + float4 color_transform; + float4 color_light; + float4 color_speaker; + float4 color_camera; + float4 color_camera_path; + float4 color_empty; + float4 color_vertex; + float4 color_vertex_select; + float4 color_vertex_unreferenced; + float4 color_vertex_missing_data; + float4 color_edit_mesh_active; + float4 color_edge_select; + float4 color_edge_seam; + float4 color_edge_sharp; + float4 color_edge_crease; + float4 color_edge_bweight; + float4 color_edge_face_select; + float4 color_edge_freestyle; + float4 color_face; + float4 color_face_select; + float4 color_face_freestyle; + float4 color_gpencil_vertex; + float4 color_gpencil_vertex_select; + float4 color_normal; + float4 color_vnormal; + float4 color_lnormal; + float4 color_facedot; + float4 color_skinroot; - float4 colorDeselect; - float4 colorOutline; - float4 colorLightNoAlpha; + float4 color_deselect; + float4 color_outline; + float4 color_light_no_alpha; - float4 colorBackground; - float4 colorBackgroundGradient; - float4 colorCheckerPrimary; - float4 colorCheckerSecondary; - float4 colorClippingBorder; - float4 colorEditMeshMiddle; + float4 color_background; + float4 color_background_gradient; + float4 color_checker_primary; + float4 color_checker_secondary; + float4 color_clipping_border; + float4 color_edit_mesh_middle; - float4 colorHandleFree; - float4 colorHandleAuto; - float4 colorHandleVect; - float4 colorHandleAlign; - float4 colorHandleAutoclamp; - float4 colorHandleSelFree; - float4 colorHandleSelAuto; - float4 colorHandleSelVect; - float4 colorHandleSelAlign; - float4 colorHandleSelAutoclamp; - float4 colorNurbUline; - float4 colorNurbVline; - float4 colorNurbSelUline; - float4 colorNurbSelVline; - float4 colorActiveSpline; + float4 color_handle_free; + float4 color_handle_auto; + float4 color_handle_vect; + float4 color_handle_align; + float4 color_handle_autoclamp; + float4 color_handle_sel_free; + float4 color_handle_sel_auto; + float4 color_handle_sel_vect; + float4 color_handle_sel_align; + float4 color_handle_sel_autoclamp; + float4 color_nurb_uline; + float4 color_nurb_vline; + float4 color_nurb_sel_uline; + float4 color_nurb_sel_vline; + float4 color_active_spline; - float4 colorBonePose; - float4 colorBonePoseActive; - float4 colorBonePoseActiveUnsel; - float4 colorBonePoseConstraint; - float4 colorBonePoseIK; - float4 colorBonePoseSplineIK; - float4 colorBonePoseTarget; - float4 colorBoneSolid; - float4 colorBoneLocked; - float4 colorBoneActive; - float4 colorBoneActiveUnsel; - float4 colorBoneSelect; - float4 colorBoneIKLine; - float4 colorBoneIKLineNoTarget; - float4 colorBoneIKLineSpline; + float4 color_bone_pose; + float4 color_bone_pose_active; + float4 color_bone_pose_active_unsel; + float4 color_bone_pose_constraint; + float4 color_bone_pose_ik; + float4 color_bone_pose_spline_ik; + float4 color_bone_pose_target; + float4 color_bone_solid; + float4 color_bone_locked; + float4 color_bone_active; + float4 color_bone_active_unsel; + float4 color_bone_select; + float4 color_bone_ik_line; + float4 color_bone_ik_line_no_target; + float4 color_bone_ik_line_spline; - float4 colorText; - float4 colorTextHi; + float4 color_text; + float4 color_text_hi; - float4 colorBundleSolid; + float4 color_bundle_solid; - float4 colorMballRadius; - float4 colorMballRadiusSelect; - float4 colorMballStiffness; - float4 colorMballStiffnessSelect; + float4 color_mball_radius; + float4 color_mball_radius_select; + float4 color_mball_stiffness; + float4 color_mball_stiffness_select; - float4 colorCurrentFrame; + float4 color_current_frame; - float4 colorGrid; - float4 colorGridEmphasis; - float4 colorGridAxisX; - float4 colorGridAxisY; - float4 colorGridAxisZ; + float4 color_grid; + float4 color_grid_emphasis; + float4 color_grid_axis_x; + float4 color_grid_axis_y; + float4 color_grid_axis_z; - float4 colorFaceBack; - float4 colorFaceFront; + float4 color_face_back; + float4 color_face_front; - float4 colorUVShadow; + float4 color_uv_shadow; /* NOTE: Put all color before #UBO_LAST_COLOR. */ - float4 screenVecs[2]; /* Padded as vec4. */ - float4 sizeViewport; /* Packed as vec4. */ + float4 screen_vecs[2]; /* Padded as vec4. */ + float4 size_viewport; /* Packed as vec4. */ /* Pack individual float at the end of the buffer to avoid alignment errors */ - float sizePixel, pixelFac; - float sizeObjectCenter, sizeLightCenter, sizeLightCircle, sizeLightCircleShadow; - float sizeVertex, sizeEdge, sizeEdgeFix, sizeFaceDot; - float sizeChecker; - float sizeVertexGpencil; + float size_pixel, pixel_fac; + float size_object_center, size_light_center, size_light_circle, size_light_circle_shadow; + float size_vertex, size_edge, size_edge_fix, size_face_dot; + float size_checker; + float size_vertex_gpencil; }; BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16) #ifdef GPU_SHADER /* Keep compatibility_with old global scope syntax. */ /* TODO(@fclem) Mass rename and remove the camel case. */ -# define colorWire globalsBlock.colorWire -# define colorWireEdit globalsBlock.colorWireEdit -# define colorActive globalsBlock.colorActive -# define colorSelect globalsBlock.colorSelect -# define colorLibrarySelect globalsBlock.colorLibrarySelect -# define colorLibrary globalsBlock.colorLibrary -# define colorTransform globalsBlock.colorTransform -# define colorLight globalsBlock.colorLight -# define colorSpeaker globalsBlock.colorSpeaker -# define colorCamera globalsBlock.colorCamera -# define colorCameraPath globalsBlock.colorCameraPath -# define colorEmpty globalsBlock.colorEmpty -# define colorVertex globalsBlock.colorVertex -# define colorVertexSelect globalsBlock.colorVertexSelect -# define colorVertexUnreferenced globalsBlock.colorVertexUnreferenced -# define colorVertexMissingData globalsBlock.colorVertexMissingData -# define colorEditMeshActive globalsBlock.colorEditMeshActive -# define colorEdgeSelect globalsBlock.colorEdgeSelect -# define colorEdgeSeam globalsBlock.colorEdgeSeam -# define colorEdgeSharp globalsBlock.colorEdgeSharp -# define colorEdgeCrease globalsBlock.colorEdgeCrease -# define colorEdgeBWeight globalsBlock.colorEdgeBWeight -# define colorEdgeFaceSelect globalsBlock.colorEdgeFaceSelect -# define colorEdgeFreestyle globalsBlock.colorEdgeFreestyle -# define colorFace globalsBlock.colorFace -# define colorFaceSelect globalsBlock.colorFaceSelect -# define colorFaceFreestyle globalsBlock.colorFaceFreestyle -# define colorGpencilVertex globalsBlock.colorGpencilVertex -# define colorGpencilVertexSelect globalsBlock.colorGpencilVertexSelect -# define colorNormal globalsBlock.colorNormal -# define colorVNormal globalsBlock.colorVNormal -# define colorLNormal globalsBlock.colorLNormal -# define colorFaceDot globalsBlock.colorFaceDot -# define colorSkinRoot globalsBlock.colorSkinRoot -# define colorDeselect globalsBlock.colorDeselect -# define colorOutline globalsBlock.colorOutline -# define colorLightNoAlpha globalsBlock.colorLightNoAlpha -# define colorBackground globalsBlock.colorBackground -# define colorBackgroundGradient globalsBlock.colorBackgroundGradient -# define colorCheckerPrimary globalsBlock.colorCheckerPrimary -# define colorCheckerSecondary globalsBlock.colorCheckerSecondary -# define colorClippingBorder globalsBlock.colorClippingBorder -# define colorEditMeshMiddle globalsBlock.colorEditMeshMiddle -# define colorHandleFree globalsBlock.colorHandleFree -# define colorHandleAuto globalsBlock.colorHandleAuto -# define colorHandleVect globalsBlock.colorHandleVect -# define colorHandleAlign globalsBlock.colorHandleAlign -# define colorHandleAutoclamp globalsBlock.colorHandleAutoclamp -# define colorHandleSelFree globalsBlock.colorHandleSelFree -# define colorHandleSelAuto globalsBlock.colorHandleSelAuto -# define colorHandleSelVect globalsBlock.colorHandleSelVect -# define colorHandleSelAlign globalsBlock.colorHandleSelAlign -# define colorHandleSelAutoclamp globalsBlock.colorHandleSelAutoclamp -# define colorNurbUline globalsBlock.colorNurbUline -# define colorNurbVline globalsBlock.colorNurbVline -# define colorNurbSelUline globalsBlock.colorNurbSelUline -# define colorNurbSelVline globalsBlock.colorNurbSelVline -# define colorActiveSpline globalsBlock.colorActiveSpline -# define colorBonePose globalsBlock.colorBonePose -# define colorBonePoseActive globalsBlock.colorBonePoseActive -# define colorBonePoseActiveUnsel globalsBlock.colorBonePoseActiveUnsel -# define colorBonePoseConstraint globalsBlock.colorBonePoseConstraint -# define colorBonePoseIK globalsBlock.colorBonePoseIK -# define colorBonePoseSplineIK globalsBlock.colorBonePoseSplineIK -# define colorBonePoseTarget globalsBlock.colorBonePoseTarget -# define colorBoneSolid globalsBlock.colorBoneSolid -# define colorBoneLocked globalsBlock.colorBoneLocked -# define colorBoneActive globalsBlock.colorBoneActive -# define colorBoneActiveUnsel globalsBlock.colorBoneActiveUnsel -# define colorBoneSelect globalsBlock.colorBoneSelect -# define colorBoneIKLine globalsBlock.colorBoneIKLine -# define colorBoneIKLineNoTarget globalsBlock.colorBoneIKLineNoTarget -# define colorBoneIKLineSpline globalsBlock.colorBoneIKLineSpline -# define colorText globalsBlock.colorText -# define colorTextHi globalsBlock.colorTextHi -# define colorBundleSolid globalsBlock.colorBundleSolid -# define colorMballRadius globalsBlock.colorMballRadius -# define colorMballRadiusSelect globalsBlock.colorMballRadiusSelect -# define colorMballStiffness globalsBlock.colorMballStiffness -# define colorMballStiffnessSelect globalsBlock.colorMballStiffnessSelect -# define colorCurrentFrame globalsBlock.colorCurrentFrame -# define colorGrid globalsBlock.colorGrid -# define colorGridEmphasis globalsBlock.colorGridEmphasis -# define colorGridAxisX globalsBlock.colorGridAxisX -# define colorGridAxisY globalsBlock.colorGridAxisY -# define colorGridAxisZ globalsBlock.colorGridAxisZ -# define colorFaceBack globalsBlock.colorFaceBack -# define colorFaceFront globalsBlock.colorFaceFront -# define colorUVShadow globalsBlock.colorUVShadow -# define screenVecs globalsBlock.screenVecs -# define sizeViewport globalsBlock.sizeViewport.xy -# define sizePixel globalsBlock.sizePixel -# define pixelFac globalsBlock.pixelFac -# define sizeObjectCenter globalsBlock.sizeObjectCenter -# define sizeLightCenter globalsBlock.sizeLightCenter -# define sizeLightCircle globalsBlock.sizeLightCircle -# define sizeLightCircleShadow globalsBlock.sizeLightCircleShadow -# define sizeVertex globalsBlock.sizeVertex -# define sizeEdge globalsBlock.sizeEdge -# define sizeEdgeFix globalsBlock.sizeEdgeFix -# define sizeFaceDot globalsBlock.sizeFaceDot -# define sizeChecker globalsBlock.sizeChecker -# define sizeVertexGpencil globalsBlock.sizeVertexGpencil +# define colorWire globalsBlock.color_wire +# define colorWireEdit globalsBlock.color_wire_edit +# define colorActive globalsBlock.color_active +# define colorSelect globalsBlock.color_select +# define colorLibrarySelect globalsBlock.color_library_select +# define colorLibrary globalsBlock.color_library +# define colorTransform globalsBlock.color_transform +# define colorLight globalsBlock.color_light +# define colorSpeaker globalsBlock.color_speaker +# define colorCamera globalsBlock.color_camera +# define colorCameraPath globalsBlock.color_camera_path +# define colorEmpty globalsBlock.color_empty +# define colorVertex globalsBlock.color_vertex +# define colorVertexSelect globalsBlock.color_vertex_select +# define colorVertexUnreferenced globalsBlock.color_vertex_unreferenced +# define colorVertexMissingData globalsBlock.color_vertex_missing_data +# define colorEditMeshActive globalsBlock.color_edit_mesh_active +# define colorEdgeSelect globalsBlock.color_edge_select +# define colorEdgeSeam globalsBlock.color_edge_seam +# define colorEdgeSharp globalsBlock.color_edge_sharp +# define colorEdgeCrease globalsBlock.color_edge_crease +# define colorEdgeBWeight globalsBlock.color_edge_bweight +# define colorEdgeFaceSelect globalsBlock.color_edge_face_select +# define colorEdgeFreestyle globalsBlock.color_edge_freestyle +# define colorFace globalsBlock.color_face +# define colorFaceSelect globalsBlock.color_face_select +# define colorFaceFreestyle globalsBlock.color_face_freestyle +# define colorGpencilVertex globalsBlock.color_gpencil_vertex +# define colorGpencilVertexSelect globalsBlock.color_gpencil_vertex_select +# define colorNormal globalsBlock.color_normal +# define colorVNormal globalsBlock.color_vnormal +# define colorLNormal globalsBlock.color_lnormal +# define colorFaceDot globalsBlock.color_face_dot +# define colorSkinRoot globalsBlock.color_skin_root +# define colorDeselect globalsBlock.color_deselect +# define colorOutline globalsBlock.color_outline +# define colorLightNoAlpha globalsBlock.color_light_no_alpha +# define colorBackground globalsBlock.color_background +# define colorBackgroundGradient globalsBlock.color_background_gradient +# define colorCheckerPrimary globalsBlock.color_checker_primary +# define colorCheckerSecondary globalsBlock.color_checker_secondary +# define colorClippingBorder globalsBlock.color_clipping_border +# define colorEditMeshMiddle globalsBlock.color_edit_mesh_middle +# define colorHandleFree globalsBlock.color_handle_free +# define colorHandleAuto globalsBlock.color_handle_auto +# define colorHandleVect globalsBlock.color_handle_vect +# define colorHandleAlign globalsBlock.color_handle_align +# define colorHandleAutoclamp globalsBlock.color_handle_autoclamp +# define colorHandleSelFree globalsBlock.color_handle_sel_free +# define colorHandleSelAuto globalsBlock.color_handle_sel_auto +# define colorHandleSelVect globalsBlock.color_handle_sel_vect +# define colorHandleSelAlign globalsBlock.color_handle_sel_align +# define colorHandleSelAutoclamp globalsBlock.color_handle_sel_autoclamp +# define colorNurbUline globalsBlock.color_nurb_uline +# define colorNurbVline globalsBlock.color_nurb_vline +# define colorNurbSelUline globalsBlock.color_nurb_sel_uline +# define colorNurbSelVline globalsBlock.color_nurb_sel_vline +# define colorActiveSpline globalsBlock.color_active_spline +# define colorBonePose globalsBlock.color_bone_pose +# define colorBonePoseActive globalsBlock.color_bone_pose_active +# define colorBonePoseActiveUnsel globalsBlock.color_bone_pose_active_unsel +# define colorBonePoseConstraint globalsBlock.color_bone_pose_constraint +# define colorBonePoseIK globalsBlock.color_bone_pose_ik +# define colorBonePoseSplineIK globalsBlock.color_bone_pose_spline_ik +# define colorBonePoseTarget globalsBlock.color_bone_pose_target +# define colorBoneSolid globalsBlock.color_bone_solid +# define colorBoneLocked globalsBlock.color_bone_locked +# define colorBoneActive globalsBlock.color_bone_active +# define colorBoneActiveUnsel globalsBlock.color_bone_active_unsel +# define colorBoneSelect globalsBlock.color_bone_select +# define colorBoneIKLine globalsBlock.color_bone_ik_line +# define colorBoneIKLineNoTarget globalsBlock.color_bone_ik_line_no_target +# define colorBoneIKLineSpline globalsBlock.color_bone_ik_line_spline +# define colorText globalsBlock.color_text +# define colorTextHi globalsBlock.color_text_hi +# define colorBundleSolid globalsBlock.color_bundle_solid +# define colorMballRadius globalsBlock.color_mball_radius +# define colorMballRadiusSelect globalsBlock.color_mball_radius_select +# define colorMballStiffness globalsBlock.color_mball_stiffness +# define colorMballStiffnessSelect globalsBlock.color_mball_stiffness_select +# define colorCurrentFrame globalsBlock.color_current_frame +# define colorGrid globalsBlock.color_grid +# define colorGridEmphasis globalsBlock.color_grid_emphasis +# define colorGridAxisX globalsBlock.color_grid_axis_x +# define colorGridAxisY globalsBlock.color_grid_axis_y +# define colorGridAxisZ globalsBlock.color_grid_axis_z +# define colorFaceBack globalsBlock.color_face_back +# define colorFaceFront globalsBlock.color_face_front +# define colorUVShadow globalsBlock.color_uv_shadow +# define screenVecs globalsBlock.screen_vecs +# define sizeViewport globalsBlock.size_viewport.xy +# define sizePixel globalsBlock.size_pixel +# define pixelFac globalsBlock.pixel_fac +# define sizeObjectCenter globalsBlock.size_object_center +# define sizeLightCenter globalsBlock.size_light_center +# define sizeLightCircle globalsBlock.size_light_circle +# define sizeLightCircleShadow globalsBlock.size_light_circle_shadow +# define sizeVertex globalsBlock.size_vertex +# define sizeEdge globalsBlock.size_edge +# define sizeEdgeFix globalsBlock.size_edge_fix +# define sizeFaceDot globalsBlock.size_face_dot +# define sizeChecker globalsBlock.size_checker +# define sizeVertexGpencil globalsBlock.size_vertex_gpencil #endif /* See: 'draw_cache_impl.h' for matching includes. */ diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index aec2b0f769a..00e2f221117 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -118,11 +118,13 @@ void clear_fcurve_keys(FCurve *fcu) /* ---------------- */ -void duplicate_fcurve_keys(FCurve *fcu) +bool duplicate_fcurve_keys(FCurve *fcu) { + bool changed = false; + /* this can only work when there is an F-Curve, and also when there are some BezTriples */ if (ELEM(NULL, fcu, fcu->bezt)) { - return; + return changed; } for (int i = 0; i < fcu->totvert; i++) { @@ -135,7 +137,7 @@ void duplicate_fcurve_keys(FCurve *fcu) memcpy(newbezt + i + 1, fcu->bezt + i, sizeof(BezTriple)); memcpy(newbezt + i + 2, fcu->bezt + i + 1, sizeof(BezTriple) * (fcu->totvert - (i + 1))); fcu->totvert++; - + changed = true; /* reassign pointers... (free old, and add new) */ MEM_freeN(fcu->bezt); fcu->bezt = newbezt; @@ -148,6 +150,7 @@ void duplicate_fcurve_keys(FCurve *fcu) BEZT_SEL_ALL(&fcu->bezt[i]); } } + return changed; } /* **************************************************** */ diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 755e538f415..9da9845116d 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1471,7 +1471,8 @@ static int curve_split_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); - int ok = -1; + bool changed = false; + int count_failed = 0; uint objects_len; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( @@ -1489,7 +1490,7 @@ static int curve_split_exec(bContext *C, wmOperator *op) adduplicateflagNurb(obedit, v3d, &newnurb, SELECT, true); if (BLI_listbase_is_empty(&newnurb)) { - ok = MAX2(ok, 0); + count_failed += 1; continue; } @@ -1504,14 +1505,16 @@ static int curve_split_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); } - ok = 1; + changed = true; WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DEG_id_tag_update(obedit->data, 0); } MEM_freeN(objects); - if (ok == 0) { - BKE_report(op->reports, RPT_ERROR, "Cannot split current selection"); + if (changed == false) { + if (count_failed != 0) { + BKE_report(op->reports, RPT_ERROR, "Cannot split current selection"); + } return OPERATOR_CANCELLED; } return OPERATOR_FINISHED; @@ -4998,7 +5001,8 @@ static int spin_exec(bContext *C, wmOperator *op) View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = ED_view3d_context_rv3d(C); float cent[3], axis[3], viewmat[4][4]; - int ok = -1; + bool changed = false; + int count_failed = 0; RNA_float_get_array(op->ptr, "center", cent); RNA_float_get_array(op->ptr, "axis", axis); @@ -5025,11 +5029,11 @@ static int spin_exec(bContext *C, wmOperator *op) mul_m4_v3(obedit->imat, cent); if (!ed_editnurb_spin(viewmat, v3d, obedit, axis, cent)) { - ok = MAX2(ok, 0); + count_failed += 1; continue; } - ok = 1; + changed = true; if (ED_curve_updateAnimPaths(bmain, cu)) { WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); } @@ -5039,8 +5043,11 @@ static int spin_exec(bContext *C, wmOperator *op) } MEM_freeN(objects); - if (ok == 0) { - BKE_report(op->reports, RPT_ERROR, "Cannot spin"); + if (changed == false) { + if (count_failed != 0) { + BKE_report(op->reports, RPT_ERROR, "Cannot spin"); + } + return OPERATOR_CANCELLED; } return OPERATOR_FINISHED; } @@ -5889,7 +5896,9 @@ static int duplicate_exec(bContext *C, wmOperator *op) { ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); - int ok = -1; + + bool changed = false; + int count_failed = 0; uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( @@ -5906,19 +5915,21 @@ static int duplicate_exec(bContext *C, wmOperator *op) adduplicateflagNurb(obedit, v3d, &newnurb, SELECT, false); if (BLI_listbase_is_empty(&newnurb)) { - ok = MAX2(ok, 0); + count_failed += 1; continue; } - ok = 1; + changed = true; BLI_movelisttolist(object_editcurve_get(obedit), &newnurb); DEG_id_tag_update(&cu->id, ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, &cu->id); } MEM_freeN(objects); - if (ok == 0) { - BKE_report(op->reports, RPT_ERROR, "Cannot duplicate current selection"); + if (changed == false) { + if (count_failed != 0) { + BKE_report(op->reports, RPT_ERROR, "Cannot duplicate current selection"); + } return OPERATOR_CANCELLED; } return OPERATOR_FINISHED; diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt index 1f31a384787..8fca0c46c82 100644 --- a/source/blender/editors/datafiles/CMakeLists.txt +++ b/source/blender/editors/datafiles/CMakeLists.txt @@ -776,7 +776,7 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES ops.curves.sculpt_comb ops.curves.sculpt_cut ops.curves.sculpt_delete - ops.curves.sculpt_grow + ops.curves.sculpt_grow_shrink ops.generic.cursor ops.generic.select ops.generic.select_box diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index a8fb344f366..3c8e6d6e5f5 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -994,9 +994,10 @@ static int gpencil_duplicate_exec(bContext *C, wmOperator *op) /* updates */ DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + return OPERATOR_FINISHED; } - return OPERATOR_FINISHED; + return OPERATOR_CANCELLED; } void GPENCIL_OT_duplicate(wmOperatorType *ot) diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h index 3a0bb9738ae..163797d395d 100644 --- a/source/blender/editors/include/ED_keyframes_edit.h +++ b/source/blender/editors/include/ED_keyframes_edit.h @@ -381,7 +381,7 @@ bool keyframe_region_circle_test(const KeyframeEdit_CircleData *data_circle, con void delete_fcurve_key(struct FCurve *fcu, int index, bool do_recalc); bool delete_fcurve_keys(struct FCurve *fcu); void clear_fcurve_keys(struct FCurve *fcu); -void duplicate_fcurve_keys(struct FCurve *fcu); +bool duplicate_fcurve_keys(struct FCurve *fcu); float get_default_rna_value(struct FCurve *fcu, struct PropertyRNA *prop, struct PointerRNA *ptr); typedef struct FCurveSegment { diff --git a/source/blender/editors/include/ED_numinput.h b/source/blender/editors/include/ED_numinput.h index 12e3ffee627..a1b4e3a4552 100644 --- a/source/blender/editors/include/ED_numinput.h +++ b/source/blender/editors/include/ED_numinput.h @@ -43,7 +43,7 @@ typedef struct NumInput { int str_cur; } NumInput; -/* NumInput.flag */ +/** #NumInput.flag */ enum { NUM_AFFECT_ALL = (1 << 0), /* (1 << 9) and above are reserved for internal flags! */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index c3571bb3788..3f9f26560b2 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -163,6 +163,11 @@ bool ED_view3d_camera_to_view_selected(struct Main *bmain, const struct Scene *scene, struct Object *camera_ob); +bool ED_view3d_camera_to_view_selected_with_set_clipping(struct Main *bmain, + struct Depsgraph *depsgraph, + const struct Scene *scene, + struct Object *camera_ob); + /** * Use to store the last view, before entering camera view. */ diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 0854b8b5cfa..4649fb06374 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -2948,7 +2948,7 @@ uiBlock *UI_region_block_find_mouse_over(const struct ARegion *region, */ struct ARegion *UI_region_searchbox_region_get(const struct ARegion *button_region); -/* uiFontStyle.align */ +/** #uiFontStyle.align */ typedef enum eFontStyle_Align { UI_STYLE_TEXT_LEFT = 0, UI_STYLE_TEXT_CENTER = 1, diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 56b0bd04a71..47c554f84e0 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -447,7 +447,7 @@ typedef struct View2DEdgePanData { struct ARegion *region; /** View2d we're operating in. */ struct View2D *v2d; - /* Limit maximum pannable area */ + /** Limit maximum pannable area. */ struct rctf limit; /** Panning should only start once being in the inside rect once (e.g. adding nodes can happen diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 9bd0498fcfb..b34d61d5192 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -6516,7 +6516,7 @@ uiBut *uiDefSearchButO_ptr(uiBlock *block, if (properties) { PointerRNA *ptr = UI_but_operator_ptr_get(but); - /* Copy idproperties. */ + /* Copy id-properties. */ ptr->data = IDP_CopyProperty(properties); } @@ -6755,7 +6755,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) PointerRNA *opptr = UI_but_operator_ptr_get(but); wmOperatorType *ot = but->optype; - /* so the context is passed to itemf functions */ + /* So the context is passed to `itemf` functions. */ WM_operator_properties_sanitize(opptr, false); /* if the default property of the operator is enum and it is set, diff --git a/source/blender/editors/interface/interface_region_menu_pie.cc b/source/blender/editors/interface/interface_region_menu_pie.cc index d30797cc4d0..b11564f09c5 100644 --- a/source/blender/editors/interface/interface_region_menu_pie.cc +++ b/source/blender/editors/interface/interface_region_menu_pie.cc @@ -332,7 +332,7 @@ static void ui_pie_menu_level_invoke(bContext *C, void *argN, void *arg2) PointerRNA ptr; WM_operator_properties_create_ptr(&ptr, lvl->ot); - /* so the context is passed to itemf functions (some need it) */ + /* So the context is passed to `itemf` functions (some need it). */ WM_operator_properties_sanitize(&ptr, false); PropertyRNA *prop = RNA_struct_find_property(&ptr, lvl->propname); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 64d10f7e2af..73716f6edba 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -4399,6 +4399,11 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) knifetool_exit(op); ED_workspace_status_text(C, NULL); + /* Exit early to prevent undo push for empty cuts. */ + if (kcd->totkvert == 0) { + return OPERATOR_CANCELLED; + } + return OPERATOR_FINISHED; case KNF_MODAL_UNDO: if (BLI_stack_is_empty(kcd->undostack)) { diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 0ea807586f9..5a0a2b7a09a 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2016,6 +2016,7 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op) uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( view_layer, CTX_wm_view3d(C), &objects_len); + bool changed = false; for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; @@ -2026,6 +2027,7 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op) BMOperator bmop; BMesh *bm = em->bm; + changed = true; EDBM_op_init(em, &bmop, @@ -2060,16 +2062,16 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op) } MEM_freeN(objects); - return OPERATOR_FINISHED; + return (changed) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } static int edbm_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { WM_cursor_wait(true); - edbm_duplicate_exec(C, op); + const int retval = edbm_duplicate_exec(C, op); WM_cursor_wait(false); - return OPERATOR_FINISHED; + return retval; } void MESH_OT_duplicate(wmOperatorType *ot) diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index 6a7920d4d75..ba11483722e 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -3564,6 +3564,7 @@ static int duplicate_exec(bContext *C, wmOperator *op) ViewLayer *view_layer = CTX_data_view_layer(C); const bool linked = RNA_boolean_get(op->ptr, "linked"); const eDupli_ID_Flags dupflag = (linked) ? (eDupli_ID_Flags)0 : (eDupli_ID_Flags)U.dupflag; + bool changed = false; /* We need to handle that here ourselves, because we may duplicate several objects, in which case * we also want to remap pointers between those... */ @@ -3582,6 +3583,7 @@ static int duplicate_exec(bContext *C, wmOperator *op) * the list is made in advance */ ED_object_base_select(base, BA_DESELECT); ED_object_base_select(basen, BA_SELECT); + changed = true; if (basen == nullptr) { continue; @@ -3598,6 +3600,10 @@ static int duplicate_exec(bContext *C, wmOperator *op) } CTX_DATA_END; + if (!changed) { + return OPERATOR_CANCELLED; + } + /* Note that this will also clear newid pointers and tags. */ copy_object_set_idnew(C); diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc index 7404b3bf010..78e786a2130 100644 --- a/source/blender/editors/render/render_preview.cc +++ b/source/blender/editors/render/render_preview.cc @@ -830,7 +830,8 @@ static Scene *object_preview_scene_create(const struct ObjectPreviewData *previe DEG_graph_build_from_view_layer(depsgraph); DEG_evaluate_on_refresh(depsgraph); - ED_view3d_camera_to_view_selected(preview_data->pr_main, depsgraph, scene, camera_object); + ED_view3d_camera_to_view_selected_with_set_clipping( + preview_data->pr_main, depsgraph, scene, camera_object); BKE_scene_graph_update_tagged(depsgraph, preview_data->pr_main); diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index c422c8c2033..fe7683d12f5 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -31,6 +31,7 @@ set(SRC curves_sculpt_add.cc curves_sculpt_comb.cc curves_sculpt_delete.cc + curves_sculpt_grow_shrink.cc curves_sculpt_ops.cc curves_sculpt_snake_hook.cc paint_cursor.c diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc b/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc new file mode 100644 index 00000000000..d26af20799e --- /dev/null +++ b/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc @@ -0,0 +1,526 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <algorithm> + +#include "curves_sculpt_intern.hh" + +#include "BLI_enumerable_thread_specific.hh" +#include "BLI_float4x4.hh" +#include "BLI_kdtree.h" +#include "BLI_rand.hh" +#include "BLI_vector.hh" + +#include "PIL_time.h" + +#include "DEG_depsgraph.h" + +#include "BKE_attribute_math.hh" +#include "BKE_brush.h" +#include "BKE_bvhutils.h" +#include "BKE_context.h" +#include "BKE_curves.hh" +#include "BKE_mesh.h" +#include "BKE_mesh_runtime.h" +#include "BKE_paint.h" +#include "BKE_spline.hh" + +#include "DNA_brush_enums.h" +#include "DNA_brush_types.h" +#include "DNA_curves_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_object_types.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" + +#include "ED_screen.h" +#include "ED_view3d.h" + +#include "curves_sculpt_intern.hh" + +/** + * The code below uses a suffix naming convention to indicate the coordinate space: + * - `cu`: Local space of the curves object that is being edited. + * - `su`: Local space of the surface object. + * - `wo`: World space. + * - `re`: 2D coordinates within the region. + */ + +namespace blender::ed::sculpt_paint { + +using bke::CurvesGeometry; + +/** + * Utility class to wrap different grow/shrink behaviors. + * It might be useful to use this for other future brushes as well, but better see if this + * abstraction holds up for a while before using it in more places. + */ +class CurvesEffect { + public: + virtual void execute(CurvesGeometry &curves, + Span<int> curve_indices, + Span<float> move_distances_cu) = 0; +}; + +/** + * Make curves smaller by trimming the end off. + */ +class ShrinkCurvesEffect : public CurvesEffect { + private: + Brush &brush_; + + public: + ShrinkCurvesEffect(Brush &brush) : brush_(brush) + { + } + + void execute(CurvesGeometry &curves, + const Span<int> curve_indices, + const Span<float> move_distances_cu) override + { + MutableSpan<float3> positions_cu = curves.positions(); + threading::parallel_for(curve_indices.index_range(), 256, [&](const IndexRange range) { + for (const int influence_i : range) { + const int curve_i = curve_indices[influence_i]; + const float move_distance_cu = move_distances_cu[influence_i]; + const IndexRange curve_points = curves.points_for_curve(curve_i); + this->shrink_curve(positions_cu, curve_points, move_distance_cu); + } + }); + } + + void shrink_curve(MutableSpan<float3> positions, + const IndexRange curve_points, + const float shrink_length) const + { + PolySpline spline; + spline.resize(curve_points.size()); + MutableSpan<float3> spline_positions = spline.positions(); + spline_positions.copy_from(positions.slice(curve_points)); + spline.mark_cache_invalid(); + const float min_length = brush_.curves_sculpt_settings->minimum_length; + const float old_length = spline.length(); + const float new_length = std::max(min_length, old_length - shrink_length); + const float length_factor = std::clamp(new_length / old_length, 0.0f, 1.0f); + + Vector<float> old_point_lengths; + old_point_lengths.append(0.0f); + for (const int i : spline_positions.index_range().drop_back(1)) { + const float3 &p1 = spline_positions[i]; + const float3 &p2 = spline_positions[i + 1]; + const float length = math::distance(p1, p2); + old_point_lengths.append(old_point_lengths.last() + length); + } + + for (const int i : spline_positions.index_range()) { + const float eval_length = old_point_lengths[i] * length_factor; + const Spline::LookupResult lookup = spline.lookup_evaluated_length(eval_length); + const float index_factor = lookup.evaluated_index + lookup.factor; + float3 p; + spline.sample_with_index_factors<float3>(spline_positions, {&index_factor, 1}, {&p, 1}); + positions[curve_points[i]] = p; + } + } +}; + +/** + * Make the curves longer by extrapolating them linearly. + */ +class ExtrapolateCurvesEffect : public CurvesEffect { + void execute(CurvesGeometry &curves, + const Span<int> curve_indices, + const Span<float> move_distances_cu) override + { + MutableSpan<float3> positions_cu = curves.positions(); + threading::parallel_for(curve_indices.index_range(), 256, [&](const IndexRange range) { + for (const int influence_i : range) { + const int curve_i = curve_indices[influence_i]; + const float move_distance_cu = move_distances_cu[influence_i]; + const IndexRange curve_points = curves.points_for_curve(curve_i); + + if (curve_points.size() <= 1) { + continue; + } + + const float3 old_last_pos_cu = positions_cu[curve_points.last()]; + /* Use some point within the curve rather than the end point to smooth out some random + * variation. */ + const float3 direction_reference_point = + positions_cu[curve_points[curve_points.size() / 2]]; + const float3 direction = math::normalize(old_last_pos_cu - direction_reference_point); + + const float3 new_last_pos_cu = old_last_pos_cu + direction * move_distance_cu; + this->move_last_point_and_resample(positions_cu, curve_points, new_last_pos_cu); + } + }); + } + + void move_last_point_and_resample(MutableSpan<float3> positions, + const IndexRange curve_points, + const float3 &new_last_point_position) const + { + Vector<float> old_lengths; + old_lengths.append(0.0f); + /* Used to (1) normalize the segment sizes over time and (2) support making zero-length + * segments */ + const float extra_length = 0.001f; + for (const int segment_i : IndexRange(curve_points.size() - 1)) { + const float3 &p1 = positions[curve_points[segment_i]]; + const float3 &p2 = positions[curve_points[segment_i] + 1]; + const float length = math::distance(p1, p2); + old_lengths.append(old_lengths.last() + length + extra_length); + } + Vector<float> point_factors; + for (float &old_length : old_lengths) { + point_factors.append(old_length / old_lengths.last()); + } + + PolySpline new_spline; + new_spline.resize(curve_points.size()); + MutableSpan<float3> new_spline_positions = new_spline.positions(); + for (const int i : IndexRange(curve_points.size() - 1)) { + new_spline_positions[i] = positions[curve_points[i]]; + } + new_spline_positions.last() = new_last_point_position; + new_spline.mark_cache_invalid(); + + for (const int i : IndexRange(curve_points.size())) { + const float factor = point_factors[i]; + const Spline::LookupResult lookup = new_spline.lookup_evaluated_factor(factor); + const float index_factor = lookup.evaluated_index + lookup.factor; + float3 p; + new_spline.sample_with_index_factors<float3>( + new_spline_positions, {&index_factor, 1}, {&p, 1}); + positions[curve_points[i]] = p; + } + } +}; + +/** + * Change the length of curves by scaling them uniformly. + */ +class ScaleCurvesEffect : public CurvesEffect { + private: + bool scale_up_; + Brush &brush_; + + public: + ScaleCurvesEffect(bool scale_up, Brush &brush) : scale_up_(scale_up), brush_(brush) + { + } + + void execute(CurvesGeometry &curves, + const Span<int> curve_indices, + const Span<float> move_distances_cu) override + { + MutableSpan<float3> positions_cu = curves.positions(); + threading::parallel_for(curve_indices.index_range(), 256, [&](const IndexRange range) { + for (const int influence_i : range) { + const int curve_i = curve_indices[influence_i]; + const float move_distance_cu = move_distances_cu[influence_i]; + const IndexRange points = curves.points_for_curve(curve_i); + + const float old_length = this->compute_poly_curve_length(positions_cu.slice(points)); + const float length_diff = scale_up_ ? move_distance_cu : -move_distance_cu; + const float min_length = brush_.curves_sculpt_settings->minimum_length; + const float new_length = std::max(min_length, old_length + length_diff); + const float scale_factor = safe_divide(new_length, old_length); + + const float3 &root_pos_cu = positions_cu[points[0]]; + for (float3 &pos_cu : positions_cu.slice(points.drop_front(1))) { + pos_cu = (pos_cu - root_pos_cu) * scale_factor + root_pos_cu; + } + } + }); + } + + float compute_poly_curve_length(const Span<float3> positions) + { + float length = 0.0f; + const int segments_num = positions.size() - 1; + for (const int segment_i : IndexRange(segments_num)) { + const float3 &p1 = positions[segment_i]; + const float3 &p2 = positions[segment_i + 1]; + length += math::distance(p1, p2); + } + return length; + } +}; + +class CurvesEffectOperation : public CurvesSculptStrokeOperation { + private: + std::unique_ptr<CurvesEffect> effect_; + float2 last_mouse_position_; + CurvesBrush3D brush_3d_; + + friend struct CurvesEffectOperationExecutor; + + public: + CurvesEffectOperation(std::unique_ptr<CurvesEffect> effect) : effect_(std::move(effect)) + { + } + + void on_stroke_extended(bContext *C, const StrokeExtension &stroke_extension) override; +}; + +/** + * Utility class that actually executes the update when the stroke is updated. That's useful + * because it avoids passing a very large number of parameters between functions. + */ +struct CurvesEffectOperationExecutor { + CurvesEffectOperation *self_ = nullptr; + Depsgraph *depsgraph_ = nullptr; + Scene *scene_ = nullptr; + Object *object_ = nullptr; + ARegion *region_ = nullptr; + View3D *v3d_ = nullptr; + RegionView3D *rv3d_ = nullptr; + + Curves *curves_id_ = nullptr; + CurvesGeometry *curves_ = nullptr; + + Brush *brush_ = nullptr; + float brush_radius_re_; + float brush_radius_sq_re_; + float brush_strength_; + eBrushFalloffShape falloff_shape_; + + float4x4 curves_to_world_mat_; + float4x4 world_to_curves_mat_; + + float2 brush_pos_start_re_; + float2 brush_pos_end_re_; + + struct Influences { + Vector<int> curve_indices; + Vector<float> move_distances_cu; + }; + + void execute(CurvesEffectOperation &self, bContext *C, const StrokeExtension &stroke_extension) + { + BLI_SCOPED_DEFER([&]() { self.last_mouse_position_ = stroke_extension.mouse_position; }); + + self_ = &self; + depsgraph_ = CTX_data_depsgraph_pointer(C); + scene_ = CTX_data_scene(C); + object_ = CTX_data_active_object(C); + region_ = CTX_wm_region(C); + v3d_ = CTX_wm_view3d(C); + rv3d_ = CTX_wm_region_view3d(C); + + curves_id_ = static_cast<Curves *>(object_->data); + curves_ = &CurvesGeometry::wrap(curves_id_->geometry); + + CurvesSculpt &curves_sculpt = *scene_->toolsettings->curves_sculpt; + brush_ = BKE_paint_brush(&curves_sculpt.paint); + brush_radius_re_ = BKE_brush_size_get(scene_, brush_); + brush_strength_ = BKE_brush_alpha_get(scene_, brush_); + brush_radius_sq_re_ = pow2f(brush_radius_re_); + falloff_shape_ = eBrushFalloffShape(brush_->falloff_shape); + + curves_to_world_mat_ = object_->obmat; + world_to_curves_mat_ = curves_to_world_mat_.inverted(); + + brush_pos_start_re_ = self.last_mouse_position_; + brush_pos_end_re_ = stroke_extension.mouse_position; + + if (stroke_extension.is_first) { + if (falloff_shape_ == PAINT_FALLOFF_SHAPE_SPHERE) { + if (std::optional<CurvesBrush3D> brush_3d = sample_curves_3d_brush( + *C, *object_, stroke_extension.mouse_position, brush_radius_re_)) { + self.brush_3d_ = *brush_3d; + } + } + + return; + } + + /* Compute influences. */ + threading::EnumerableThreadSpecific<Influences> influences_for_thread; + if (falloff_shape_ == PAINT_FALLOFF_SHAPE_TUBE) { + this->gather_influences_projected(influences_for_thread); + } + else if (falloff_shape_ == PAINT_FALLOFF_SHAPE_SPHERE) { + this->gather_influences_spherical(influences_for_thread); + } + + /* Execute effect. */ + threading::parallel_for_each(influences_for_thread, [&](const Influences &influences) { + BLI_assert(influences.curve_indices.size() == influences.move_distances_cu.size()); + self_->effect_->execute(*curves_, influences.curve_indices, influences.move_distances_cu); + }); + + curves_->tag_positions_changed(); + DEG_id_tag_update(&curves_id_->id, ID_RECALC_GEOMETRY); + ED_region_tag_redraw(region_); + } + + void gather_influences_projected( + threading::EnumerableThreadSpecific<Influences> &influences_for_thread) + { + const Span<float3> positions_cu = curves_->positions(); + + float4x4 projection; + ED_view3d_ob_project_mat_get(rv3d_, object_, projection.values); + + threading::parallel_for(curves_->curves_range(), 256, [&](const IndexRange curves_range) { + Influences &local_influences = influences_for_thread.local(); + + for (const int curve_i : curves_range) { + const IndexRange points = curves_->points_for_curve(curve_i); + const int tot_segments = points.size() - 1; + float max_move_distance_cu = 0.0f; + for (const int segment_i : IndexRange(tot_segments)) { + const float3 &p1_cu = positions_cu[points[segment_i]]; + const float3 &p2_cu = positions_cu[points[segment_i] + 1]; + + float2 p1_re, p2_re; + ED_view3d_project_float_v2_m4(region_, p1_cu, p1_re, projection.values); + ED_view3d_project_float_v2_m4(region_, p2_cu, p2_re, projection.values); + + float2 closest_on_brush_re; + float2 closest_on_segment_re; + float lambda_on_brush; + float lambda_on_segment; + const float dist_to_brush_sq_re = closest_seg_seg_v2(closest_on_brush_re, + closest_on_segment_re, + &lambda_on_brush, + &lambda_on_segment, + brush_pos_start_re_, + brush_pos_end_re_, + p1_re, + p2_re); + + if (dist_to_brush_sq_re > brush_radius_sq_re_) { + continue; + } + + const float dist_to_brush_re = std::sqrt(dist_to_brush_sq_re); + const float radius_falloff = BKE_brush_curve_strength( + brush_, dist_to_brush_re, brush_radius_re_); + const float weight = brush_strength_ * radius_falloff; + + const float3 closest_on_segment_cu = math::interpolate(p1_cu, p2_cu, lambda_on_segment); + + float3 brush_start_pos_wo, brush_end_pos_wo; + ED_view3d_win_to_3d(v3d_, + region_, + curves_to_world_mat_ * closest_on_segment_cu, + brush_pos_start_re_, + brush_start_pos_wo); + ED_view3d_win_to_3d(v3d_, + region_, + curves_to_world_mat_ * closest_on_segment_cu, + brush_pos_end_re_, + brush_end_pos_wo); + const float3 brush_start_pos_cu = world_to_curves_mat_ * brush_start_pos_wo; + const float3 brush_end_pos_cu = world_to_curves_mat_ * brush_end_pos_wo; + + const float move_distance_cu = weight * + math::distance(brush_start_pos_cu, brush_end_pos_cu); + max_move_distance_cu = std::max(max_move_distance_cu, move_distance_cu); + } + if (max_move_distance_cu > 0.0f) { + local_influences.curve_indices.append(curve_i); + local_influences.move_distances_cu.append(max_move_distance_cu); + } + } + }); + } + + void gather_influences_spherical( + threading::EnumerableThreadSpecific<Influences> &influences_for_thread) + { + const Span<float3> positions_cu = curves_->positions(); + + float3 brush_pos_start_wo, brush_pos_end_wo; + ED_view3d_win_to_3d(v3d_, + region_, + curves_to_world_mat_ * self_->brush_3d_.position_cu, + brush_pos_start_re_, + brush_pos_start_wo); + ED_view3d_win_to_3d(v3d_, + region_, + curves_to_world_mat_ * self_->brush_3d_.position_cu, + brush_pos_end_re_, + brush_pos_end_wo); + const float3 brush_pos_start_cu = world_to_curves_mat_ * brush_pos_start_wo; + const float3 brush_pos_end_cu = world_to_curves_mat_ * brush_pos_end_wo; + const float3 brush_pos_diff_cu = brush_pos_end_cu - brush_pos_start_cu; + const float brush_pos_diff_length_cu = math::length(brush_pos_diff_cu); + const float brush_radius_cu = self_->brush_3d_.radius_cu; + const float brush_radius_sq_cu = pow2f(brush_radius_cu); + threading::parallel_for(curves_->curves_range(), 256, [&](const IndexRange curves_range) { + Influences &local_influences = influences_for_thread.local(); + + for (const int curve_i : curves_range) { + const IndexRange points = curves_->points_for_curve(curve_i); + const int tot_segments = points.size() - 1; + float max_move_distance_cu = 0.0f; + for (const int segment_i : IndexRange(tot_segments)) { + const float3 &p1_cu = positions_cu[points[segment_i]]; + const float3 &p2_cu = positions_cu[points[segment_i] + 1]; + + float3 closest_on_segment_cu; + float3 closest_on_brush_cu; + isect_seg_seg_v3(p1_cu, + p2_cu, + brush_pos_start_cu, + brush_pos_end_cu, + closest_on_segment_cu, + closest_on_brush_cu); + + const float dist_to_brush_sq_cu = math::distance_squared(closest_on_segment_cu, + closest_on_brush_cu); + if (dist_to_brush_sq_cu > brush_radius_sq_cu) { + continue; + } + + const float dist_to_brush_cu = std::sqrt(dist_to_brush_sq_cu); + const float radius_falloff = BKE_brush_curve_strength( + brush_, dist_to_brush_cu, brush_radius_cu); + const float weight = brush_strength_ * radius_falloff; + + const float move_distance_cu = weight * brush_pos_diff_length_cu; + max_move_distance_cu = std::max(max_move_distance_cu, move_distance_cu); + } + if (max_move_distance_cu > 0.0f) { + local_influences.curve_indices.append(curve_i); + local_influences.move_distances_cu.append(max_move_distance_cu); + } + } + }); + } +}; + +void CurvesEffectOperation::on_stroke_extended(bContext *C, + const StrokeExtension &stroke_extension) +{ + CurvesEffectOperationExecutor executor; + executor.execute(*this, C, stroke_extension); +} + +std::unique_ptr<CurvesSculptStrokeOperation> new_grow_shrink_operation( + const BrushStrokeMode brush_mode, bContext *C) +{ + Scene &scene = *CTX_data_scene(C); + Brush &brush = *BKE_paint_brush(&scene.toolsettings->curves_sculpt->paint); + const bool use_scale_uniform = brush.curves_sculpt_settings->flag & + BRUSH_CURVES_SCULPT_FLAG_SCALE_UNIFORM; + const bool use_grow = (brush_mode == BRUSH_STROKE_INVERT) == ((brush.flag & BRUSH_DIR_IN) != 0); + + if (use_grow) { + if (use_scale_uniform) { + return std::make_unique<CurvesEffectOperation>( + std::make_unique<ScaleCurvesEffect>(true, brush)); + } + return std::make_unique<CurvesEffectOperation>(std::make_unique<ExtrapolateCurvesEffect>()); + } + if (use_scale_uniform) { + return std::make_unique<CurvesEffectOperation>( + std::make_unique<ScaleCurvesEffect>(false, brush)); + } + return std::make_unique<CurvesEffectOperation>(std::make_unique<ShrinkCurvesEffect>(brush)); +} + +} // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_intern.hh b/source/blender/editors/sculpt_paint/curves_sculpt_intern.hh index d021627921f..03413221907 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_intern.hh +++ b/source/blender/editors/sculpt_paint/curves_sculpt_intern.hh @@ -5,6 +5,7 @@ #include <optional> #include "curves_sculpt_intern.h" +#include "paint_intern.h" #include "BLI_math_vector.hh" @@ -36,6 +37,8 @@ std::unique_ptr<CurvesSculptStrokeOperation> new_add_operation(); std::unique_ptr<CurvesSculptStrokeOperation> new_comb_operation(); std::unique_ptr<CurvesSculptStrokeOperation> new_delete_operation(); std::unique_ptr<CurvesSculptStrokeOperation> new_snake_hook_operation(); +std::unique_ptr<CurvesSculptStrokeOperation> new_grow_shrink_operation( + const BrushStrokeMode brush_mode, bContext *C); struct CurvesBrush3D { float3 position_cu; diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index 208db92abf7..893b2640427 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -74,118 +74,6 @@ using blender::bke::CurvesGeometry; /** \name * SCULPT_CURVES_OT_brush_stroke * \{ */ -/** - * Resamples the curves to a shorter length. - */ -class ShrinkOperation : public CurvesSculptStrokeOperation { - private: - float2 last_mouse_position_; - - public: - void on_stroke_extended(bContext *C, const StrokeExtension &stroke_extension) override - { - BLI_SCOPED_DEFER([&]() { last_mouse_position_ = stroke_extension.mouse_position; }); - - if (stroke_extension.is_first) { - return; - } - - Scene &scene = *CTX_data_scene(C); - Object &object = *CTX_data_active_object(C); - ARegion *region = CTX_wm_region(C); - View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d = CTX_wm_region_view3d(C); - - CurvesSculpt &curves_sculpt = *scene.toolsettings->curves_sculpt; - Brush &brush = *BKE_paint_brush(&curves_sculpt.paint); - const float brush_radius = BKE_brush_size_get(&scene, &brush); - const float brush_strength = BKE_brush_alpha_get(&scene, &brush); - - const float4x4 ob_mat = object.obmat; - const float4x4 ob_imat = ob_mat.inverted(); - - float4x4 projection; - ED_view3d_ob_project_mat_get(rv3d, &object, projection.values); - - Curves &curves_id = *static_cast<Curves *>(object.data); - CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry); - MutableSpan<float3> positions = curves.positions(); - - const float2 mouse_prev = last_mouse_position_; - const float2 mouse_cur = stroke_extension.mouse_position; - const float2 mouse_diff = mouse_cur - mouse_prev; - - threading::parallel_for(curves.curves_range(), 256, [&](const IndexRange curves_range) { - for (const int curve_i : curves_range) { - const IndexRange curve_points = curves.points_for_curve(curve_i); - const int last_point_i = curve_points.last(); - - const float3 old_tip_position = positions[last_point_i]; - - float2 old_tip_position_screen; - ED_view3d_project_float_v2_m4( - region, old_tip_position, old_tip_position_screen, projection.values); - - const float distance_screen = math::distance(old_tip_position_screen, mouse_prev); - if (distance_screen > brush_radius) { - continue; - } - - const float radius_falloff = pow2f(1.0f - distance_screen / brush_radius); - const float weight = brush_strength * radius_falloff; - - const float2 offset_tip_position_screen = old_tip_position_screen + weight * mouse_diff; - float3 offset_tip_position; - ED_view3d_win_to_3d(v3d, - region, - ob_mat * old_tip_position, - offset_tip_position_screen, - offset_tip_position); - offset_tip_position = ob_imat * offset_tip_position; - const float shrink_length = math::distance(offset_tip_position, old_tip_position); - - this->shrink_curve(positions, curve_points, shrink_length); - } - }); - - curves.tag_positions_changed(); - DEG_id_tag_update(&curves_id.id, ID_RECALC_GEOMETRY); - ED_region_tag_redraw(region); - } - - void shrink_curve(MutableSpan<float3> positions, - const IndexRange curve_points, - const float shrink_length) const - { - PolySpline spline; - spline.resize(curve_points.size()); - MutableSpan<float3> spline_positions = spline.positions(); - spline_positions.copy_from(positions.slice(curve_points)); - spline.mark_cache_invalid(); - const float old_length = spline.length(); - const float new_length = std::max(0.0f, old_length - shrink_length); - const float length_factor = new_length / old_length; - - Vector<float> old_point_lengths; - old_point_lengths.append(0.0f); - for (const int i : spline_positions.index_range().drop_back(1)) { - const float3 &p1 = spline_positions[i]; - const float3 &p2 = spline_positions[i + 1]; - const float length = math::distance(p1, p2); - old_point_lengths.append(old_point_lengths.last() + length); - } - - for (const int i : spline_positions.index_range()) { - const float eval_length = old_point_lengths[i] * length_factor; - const Spline::LookupResult lookup = spline.lookup_evaluated_length(eval_length); - const float index_factor = lookup.evaluated_index + lookup.factor; - float3 p; - spline.sample_with_index_factors<float3>(spline_positions, {&index_factor, 1}, {&p, 1}); - positions[curve_points[i]] = p; - } - } -}; - class DensityAddOperation : public CurvesSculptStrokeOperation { private: /** Contains the root points of the curves that existed before this operation started. */ @@ -612,8 +500,10 @@ class DensityAddOperation : public CurvesSculptStrokeOperation { }; static std::unique_ptr<CurvesSculptStrokeOperation> start_brush_operation(bContext *C, - wmOperator *UNUSED(op)) + wmOperator *op) { + const BrushStrokeMode mode = static_cast<BrushStrokeMode>(RNA_enum_get(op->ptr, "mode")); + Scene &scene = *CTX_data_scene(C); CurvesSculpt &curves_sculpt = *scene.toolsettings->curves_sculpt; Brush &brush = *BKE_paint_brush(&curves_sculpt.paint); @@ -626,10 +516,10 @@ static std::unique_ptr<CurvesSculptStrokeOperation> start_brush_operation(bConte return new_snake_hook_operation(); case CURVES_SCULPT_TOOL_ADD: return new_add_operation(); + case CURVES_SCULPT_TOOL_GROW_SHRINK: + return new_grow_shrink_operation(mode, C); case CURVES_SCULPT_TOOL_TEST1: return std::make_unique<DensityAddOperation>(); - case CURVES_SCULPT_TOOL_TEST2: - return std::make_unique<ShrinkOperation>(); } BLI_assert_unreachable(); return {}; @@ -674,7 +564,9 @@ static void stroke_update_step(bContext *C, stroke_extension.is_first = false; } - op_data->operation->on_stroke_extended(C, stroke_extension); + if (op_data->operation) { + op_data->operation->on_stroke_extended(C, stroke_extension); + } } static void stroke_done(const bContext *C, PaintStroke *stroke) @@ -796,7 +688,7 @@ static int curves_sculptmode_toggle_exec(bContext *C, wmOperator *op) WM_toolsystem_update_from_context_view3d(C); WM_event_add_notifier(C, NC_SCENE | ND_MODE, nullptr); - return OPERATOR_CANCELLED; + return OPERATOR_FINISHED; } static void CURVES_OT_sculptmode_toggle(wmOperatorType *ot) diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index d33cf70e117..87a271543d1 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -878,11 +878,12 @@ void ACTION_OT_keyframe_insert(wmOperatorType *ot) /* ******************** Duplicate Keyframes Operator ************************* */ -static void duplicate_action_keys(bAnimContext *ac) +static bool duplicate_action_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; + bool changed = false; /* filter data */ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { @@ -898,10 +899,11 @@ static void duplicate_action_keys(bAnimContext *ac) /* loop through filtered data and delete selected keys */ for (ale = anim_data.first; ale; ale = ale->next) { if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { - duplicate_fcurve_keys((FCurve *)ale->key_data); + changed |= duplicate_fcurve_keys((FCurve *)ale->key_data); } else if (ale->type == ANIMTYPE_GPLAYER) { ED_gpencil_layer_frames_duplicate((bGPDlayer *)ale->data); + changed |= ED_gpencil_layer_frame_select_check((bGPDlayer *)ale->data); } else if (ale->type == ANIMTYPE_MASKLAYER) { ED_masklayer_frames_duplicate((MaskLayer *)ale->data); @@ -915,6 +917,8 @@ static void duplicate_action_keys(bAnimContext *ac) ANIM_animdata_update(ac, &anim_data); ANIM_animdata_freelist(&anim_data); + + return changed; } /* ------------------- */ @@ -929,7 +933,9 @@ static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) } /* duplicate keyframes */ - duplicate_action_keys(&ac); + if (!duplicate_action_keys(&ac)) { + return OPERATOR_CANCELLED; + } /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 7eba3d49616..09163842587 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -225,6 +225,9 @@ static void action_main_region_draw(const bContext *C, ARegion *region) /* reset view matrix */ UI_view2d_view_restore(C); + /* gizmos */ + WM_gizmomap_draw(region->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D); + /* scrubbing region */ ED_time_scrub_draw(region, scene, saction->flag & SACTION_DRAWTIME, true); } @@ -861,7 +864,7 @@ void ED_spacetype_action(void) art->draw_overlay = action_main_region_draw_overlay; art->listener = action_main_region_listener; art->message_subscribe = saction_main_region_message_subscribe; - art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; + art->keymapflag = ED_KEYMAP_GIZMO | ED_KEYMAP_VIEW2D | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index ceac53bde6b..08f4ecc0dd9 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -329,7 +329,7 @@ typedef struct FileListEntryCache { int previews_todo_count; } FileListEntryCache; -/* FileListCache.flags */ +/** #FileListCache.flags */ enum { FLC_IS_INIT = 1 << 0, FLC_PREVIEWS_ACTIVE = 1 << 1, @@ -359,7 +359,7 @@ typedef struct FileListFilter { FileAssetCatalogFilterSettingsHandle *asset_catalog_filter; } FileListFilter; -/* FileListFilter.flags */ +/** #FileListFilter.flags */ enum { FLF_DO_FILTER = 1 << 0, FLF_HIDE_DOT = 1 << 1, @@ -421,7 +421,7 @@ typedef struct FileList { short tags; /* FileListTags */ } FileList; -/* FileList.flags */ +/** #FileList.flags */ enum { FL_FORCE_RESET = 1 << 0, /* Don't do a full reset (unless #FL_FORCE_RESET is also set), only reset files representing main @@ -434,7 +434,7 @@ enum { FL_SORT_INVERT = 1 << 6, }; -/* FileList.tags */ +/** #FileList.tags */ enum FileListTags { /** The file list has references to main data (IDs) and needs special care. */ FILELIST_TAGS_USES_MAIN_DATA = (1 << 0), diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index bc82e7e20c2..2083a26f638 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -623,11 +623,12 @@ void GRAPH_OT_paste(wmOperatorType *ot) /** \name Duplicate Keyframes Operator * \{ */ -static void duplicate_graph_keys(bAnimContext *ac) +static bool duplicate_graph_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; + bool changed = false; /* Filter data. */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | @@ -636,13 +637,15 @@ static void duplicate_graph_keys(bAnimContext *ac) /* Loop through filtered data and delete selected keys. */ for (ale = anim_data.first; ale; ale = ale->next) { - duplicate_fcurve_keys((FCurve *)ale->key_data); + changed |= duplicate_fcurve_keys((FCurve *)ale->key_data); ale->update |= ANIM_UPDATE_DEFAULT; } ANIM_animdata_update(ac, &anim_data); ANIM_animdata_freelist(&anim_data); + + return changed; } /* ------------------- */ @@ -657,7 +660,9 @@ static int graphkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) } /* Duplicate keyframes. */ - duplicate_graph_keys(&ac); + if (!duplicate_graph_keys(&ac)) { + return OPERATOR_CANCELLED; + } /* Set notifier that keyframes have changed. */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 68cfd1c9ef0..88ab7617932 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -2579,8 +2579,20 @@ static void reroute_node_draw( const int x = BLI_rctf_cent_x(&node.totr) - (width / 2); const int y = node.totr.ymax; - uiBut *label_but = uiDefBut( - &block, UI_BTYPE_LABEL, 0, showname, x, y, width, (short)NODE_DY, nullptr, 0, 0, 0, 0, nullptr); + uiBut *label_but = uiDefBut(&block, + UI_BTYPE_LABEL, + 0, + showname, + x, + y, + width, + (short)NODE_DY, + nullptr, + 0, + 0, + 0, + 0, + nullptr); UI_but_drawflag_disable(label_but, UI_BUT_TEXT_LEFT); } diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 956bb581ee6..9d83f977fe0 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -1268,6 +1268,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree = snode->edittree; const bool keep_inputs = RNA_boolean_get(op->ptr, "keep_inputs"); + bool changed = false; ED_preview_kill_jobs(CTX_wm_manager(C), bmain); @@ -1280,6 +1281,7 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) bNode *new_node = blender::bke::node_copy_with_mapping( ntree, *node, LIB_ID_COPY_DEFAULT, true, socket_map); node_map.add_new(node, new_node); + changed = true; } /* make sure we don't copy new nodes again! */ @@ -1288,6 +1290,10 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } } + if (!changed) { + return OPERATOR_CANCELLED; + } + /* Copy links between selected nodes. */ bNodeLink *lastlink = (bNodeLink *)ntree->links.last; LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index b77f780e413..0305ad279a0 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1687,6 +1687,7 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) SEQ_select_active_set(scene, seq); } seq->flag &= ~(SEQ_LEFTSEL + SEQ_RIGHTSEL + SEQ_LOCK); + seq->flag |= SEQ_IGNORE_CHANNEL_LOCK; SEQ_animation_duplicate(scene, seq, &fcurves_original_backup); SEQ_ensure_unique_name(seq, scene); } @@ -2457,6 +2458,9 @@ static void sequencer_copy_animation(Scene *scene, Sequence *seq) } GSet *fcurves = SEQ_fcurves_by_strip_get(seq, &scene->adt->action->curves); + if (fcurves == NULL) { + return; + } GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) { BLI_addtail(&fcurves_clipboard, BKE_fcurve_copy(fcu)); diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 194aa518cd7..781aa521880 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -103,6 +103,7 @@ void draw_seq_strip_thumbnail(struct View2D *v2d, float pixely); /* sequencer_draw_channels.c */ + void draw_channels(const struct bContext *C, struct ARegion *region); void channel_draw_context_init(const struct bContext *C, struct ARegion *region, @@ -271,6 +272,7 @@ void SEQUENCER_OT_view_selected(struct wmOperatorType *ot); void SEQUENCER_OT_view_ghost_border(struct wmOperatorType *ot); /* sequencer_channels_edit.c */ + void SEQUENCER_OT_rename_channel(struct wmOperatorType *ot); /* sequencer_preview.c */ diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 66df1309d54..8e5931b127a 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -1700,7 +1700,9 @@ static int sequencer_box_select_invoke(bContext *C, wmOperator *op, const wmEven if (tweak) { int hand_dummy; - Sequence *seq = find_nearest_seq(scene, v2d, &hand_dummy, event->mval); + int mval[2]; + WM_event_drag_start_mval(event, region, mval); + Sequence *seq = find_nearest_seq(scene, v2d, &hand_dummy, mval); if (seq != NULL) { return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index 744fc61ddcf..e6895c0f4a3 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -1440,16 +1440,19 @@ void ED_view3d_to_object(const Depsgraph *depsgraph, BKE_object_apply_mat4_ex(ob, mat, ob_eval->parent, ob_eval->parentinv, true); } -bool ED_view3d_camera_to_view_selected(struct Main *bmain, - Depsgraph *depsgraph, - const Scene *scene, - Object *camera_ob) +static bool view3d_camera_to_view_selected_impl(struct Main *bmain, + Depsgraph *depsgraph, + const Scene *scene, + Object *camera_ob, + float *r_clip_start, + float *r_clip_end) { Object *camera_ob_eval = DEG_get_evaluated_object(depsgraph, camera_ob); float co[3]; /* the new location to apply */ float scale; /* only for ortho cameras */ - if (BKE_camera_view_frame_fit_to_scene(depsgraph, scene, camera_ob_eval, co, &scale)) { + if (BKE_camera_view_frame_fit_to_scene( + depsgraph, scene, camera_ob_eval, co, &scale, r_clip_start, r_clip_end)) { ObjectTfmProtectedChannels obtfm; float obmat_new[4][4]; @@ -1475,6 +1478,38 @@ bool ED_view3d_camera_to_view_selected(struct Main *bmain, return false; } +bool ED_view3d_camera_to_view_selected(struct Main *bmain, + Depsgraph *depsgraph, + const Scene *scene, + Object *camera_ob) +{ + return view3d_camera_to_view_selected_impl(bmain, depsgraph, scene, camera_ob, NULL, NULL); +} + +bool ED_view3d_camera_to_view_selected_with_set_clipping(struct Main *bmain, + Depsgraph *depsgraph, + const Scene *scene, + Object *camera_ob) +{ + float clip_start; + float clip_end; + if (view3d_camera_to_view_selected_impl( + bmain, depsgraph, scene, camera_ob, &clip_start, &clip_end)) { + + ((Camera *)camera_ob->data)->clip_start = clip_start; + ((Camera *)camera_ob->data)->clip_end = clip_end; + + /* TODO: Support update via #ID_RECALC_PARAMETERS. */ + Object *camera_ob_eval = DEG_get_evaluated_object(depsgraph, camera_ob); + ((Camera *)camera_ob_eval->data)->clip_start = clip_start; + ((Camera *)camera_ob_eval->data)->clip_end = clip_end; + + return true; + } + + return false; +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/transform/transform_convert_sequencer.c b/source/blender/editors/transform/transform_convert_sequencer.c index 16a96001fd2..990d3680057 100644 --- a/source/blender/editors/transform/transform_convert_sequencer.c +++ b/source/blender/editors/transform/transform_convert_sequencer.c @@ -606,6 +606,11 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c SeqCollection *transformed_strips = seq_transform_collection_from_transdata(tc); SEQ_collection_expand(seqbase_active_get(t), transformed_strips, SEQ_query_strip_effect_chain); + Sequence *seq; + SEQ_ITERATOR_FOREACH (seq, transformed_strips) { + seq->flag &= ~SEQ_IGNORE_CHANNEL_LOCK; + } + if (t->state == TRANS_CANCEL) { seq_transform_cancel(t, transformed_strips); SEQ_collection_free(transformed_strips); diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilshrinkwrap.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilshrinkwrap.c index d80224e6639..7de1cc89a45 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilshrinkwrap.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilshrinkwrap.c @@ -105,18 +105,16 @@ static void deformStroke(GpencilModifierData *md, /* Apply deformed coordinates. */ pt = gps->points; - bGPDstroke gps_old = *gps; - gps_old.points = (bGPDspoint *)MEM_dupallocN(gps->points); for (i = 0; i < gps->totpoints; i++, pt++) { copy_v3_v3(&pt->x, vert_coords[i]); - /* Smooth stroke. */ - BKE_gpencil_stroke_smooth_point( - &gps_old, i, mmd->smooth_factor, mmd->smooth_step, true, false, gps); } - MEM_freeN(gps_old.points); MEM_freeN(vert_coords); + /* Smooth stroke. */ + BKE_gpencil_stroke_smooth( + gps, mmd->smooth_factor, mmd->smooth_step, true, false, false, false, true, NULL); + /* Calc geometry data. */ BKE_gpencil_stroke_geometry_update(gpd, gps); } diff --git a/source/blender/io/wavefront_obj/IO_wavefront_obj.cc b/source/blender/io/wavefront_obj/IO_wavefront_obj.cc index c80d10d9efd..fb0b4a1aca9 100644 --- a/source/blender/io/wavefront_obj/IO_wavefront_obj.cc +++ b/source/blender/io/wavefront_obj/IO_wavefront_obj.cc @@ -11,18 +11,12 @@ #include "obj_exporter.hh" #include "obj_importer.hh" -/** - * C-interface for the exporter. - */ void OBJ_export(bContext *C, const OBJExportParams *export_params) { SCOPED_TIMER("OBJ export"); blender::io::obj::exporter_main(C, *export_params); } -/** - * Time the full import process. - */ void OBJ_import(bContext *C, const OBJImportParams *import_params) { SCOPED_TIMER(__func__); diff --git a/source/blender/io/wavefront_obj/IO_wavefront_obj.h b/source/blender/io/wavefront_obj/IO_wavefront_obj.h index b80c1e073b8..b06ccbf8702 100644 --- a/source/blender/io/wavefront_obj/IO_wavefront_obj.h +++ b/source/blender/io/wavefront_obj/IO_wavefront_obj.h @@ -86,8 +86,14 @@ struct OBJImportParams { eTransformAxisUp up_axis; }; +/** + * Time the full import process. + */ void OBJ_import(bContext *C, const struct OBJImportParams *import_params); +/** + * C-interface for the exporter. + */ void OBJ_export(bContext *C, const struct OBJExportParams *export_params); #ifdef __cplusplus diff --git a/source/blender/io/wavefront_obj/exporter/obj_exporter.cc b/source/blender/io/wavefront_obj/exporter/obj_exporter.cc index 30670d45ef7..584d8ae4ec0 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_exporter.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_exporter.cc @@ -88,8 +88,8 @@ filter_supported_objects(Depsgraph *depsgraph, const OBJExportParams &export_par } switch (object->type) { case OB_SURF: - /* Export in mesh form: vertices and polygons. */ - ATTR_FALLTHROUGH; + /* Evaluated surface objects appear as mesh objects from the iterator. */ + break; case OB_MESH: r_exportable_meshes.append(std::make_unique<OBJMesh>(depsgraph, export_params, object)); break; diff --git a/source/blender/io/wavefront_obj/importer/importer_mesh_utils.hh b/source/blender/io/wavefront_obj/importer/importer_mesh_utils.hh index 6db1fcdb2b7..ce47da3e863 100644 --- a/source/blender/io/wavefront_obj/importer/importer_mesh_utils.hh +++ b/source/blender/io/wavefront_obj/importer/importer_mesh_utils.hh @@ -19,10 +19,12 @@ namespace blender::io::obj { * Given an invalid polygon (with holes or duplicated vertex indices), * turn it into possibly multiple polygons that are valid. * - * \param vertex_coords Polygon's vertex coordinate list. - * \param face_vertex_indices A polygon's indices that index into the given vertex coordinate list. - * \return List of polygons with each element containing indices of one polygon. - * The indices are into face_vertex_indices array. + * \param vertex_coords: Polygon's vertex coordinate list. + * \param face_vertex_indices: A polygon's indices that index into the given vertex coordinate + * list. + * + * \return List of polygons with each element containing indices of one polygon. The indices + * are into face_vertex_indices array. */ Vector<Vector<int>> fixup_invalid_polygon(Span<float3> vertex_coords, Span<int> face_vertex_indices); diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc index c528d220d04..d3d4e1ba860 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc @@ -318,9 +318,6 @@ static void geom_update_smooth_group(const StringRef rest_line, bool &r_state_sh } } -/** - * Open OBJ file at the path given in import parameters. - */ OBJParser::OBJParser(const OBJImportParams &import_params) : import_params_(import_params) { obj_file_.open(import_params_.filepath); @@ -330,10 +327,6 @@ OBJParser::OBJParser(const OBJImportParams &import_params) : import_params_(impo } } -/** - * Read the OBJ file line by line and create OBJ Geometry instances. Also store all the vertex - * and UV vertex coordinates in a struct accessible by all objects. - */ void OBJParser::parse(Vector<std::unique_ptr<Geometry>> &r_all_geometries, GlobalVertices &r_global_vertices) { @@ -470,7 +463,7 @@ static StringRef skip_unsupported_options(StringRef line) return line; } - /* Remove upto start of the last option + size of the last option + space after it. */ + /* Remove up to start of the last option + size of the last option + space after it. */ line = line.drop_prefix(last_option_pos + last_option.size() + 1); for (int i = 0; i < map_options.number_of_args(last_option); i++) { const int64_t pos_space{line.find_first_of(' ')}; @@ -499,17 +492,11 @@ static string fix_bad_map_keys(StringRef map_key) return new_map_key; } -/** - * Return a list of all material library filepaths referenced by the OBJ file. - */ Span<std::string> OBJParser::mtl_libraries() const { return mtl_libraries_; } -/** - * Open material library file. - */ MTLParser::MTLParser(StringRef mtl_library, StringRefNull obj_filepath) { char obj_file_dir[FILE_MAXDIR]; @@ -523,9 +510,6 @@ MTLParser::MTLParser(StringRef mtl_library, StringRefNull obj_filepath) } } -/** - * Read MTL file(s) and add MTLMaterial instances to the given Map reference. - */ void MTLParser::parse_and_store(Map<string, std::unique_ptr<MTLMaterial>> &r_mtl_materials) { if (!mtl_file_.good()) { @@ -589,7 +573,7 @@ void MTLParser::parse_and_store(Map<string, std::unique_ptr<MTLMaterial>> &r_mtl /* Parse image textures. */ else if (line_key.find("map_") != StringRef::not_found) { - /* TODO howardt: fix this */ + /* TODO(@howardt): fix this. */ eMTLSyntaxElement line_key_enum = mtl_line_key_str_to_enum(line_key); if (line_key_enum == eMTLSyntaxElement::string || !current_mtlmaterial->texture_maps.contains_as(line_key_enum)) { @@ -601,7 +585,7 @@ void MTLParser::parse_and_store(Map<string, std::unique_ptr<MTLMaterial>> &r_mtl Vector<StringRef> str_map_xx_split; split_by_char(rest_line, ' ', str_map_xx_split); - /* TODO ankitm: use `skip_unsupported_options` for parsing these options too? */ + /* TODO(@ankitm): use `skip_unsupported_options` for parsing these options too? */ const int64_t pos_o{str_map_xx_split.first_index_of_try("-o")}; if (pos_o != -1 && pos_o + 3 < str_map_xx_split.size()) { copy_string_to_float({str_map_xx_split[pos_o + 1], diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.hh b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.hh index c8d8b78fc0e..24d026d75e5 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.hh +++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.hh @@ -22,10 +22,20 @@ class OBJParser { Vector<std::string> mtl_libraries_; public: + /** + * Open OBJ file at the path given in import parameters. + */ OBJParser(const OBJImportParams &import_params); + /** + * Read the OBJ file line by line and create OBJ Geometry instances. Also store all the vertex + * and UV vertex coordinates in a struct accessible by all objects. + */ void parse(Vector<std::unique_ptr<Geometry>> &r_all_geometries, GlobalVertices &r_global_vertices); + /** + * Return a list of all material library filepaths referenced by the OBJ file. + */ Span<std::string> mtl_libraries() const; }; @@ -144,8 +154,14 @@ class MTLParser { blender::fstream mtl_file_; public: + /** + * Open material library file. + */ MTLParser(StringRef mtl_library_, StringRefNull obj_filepath); + /** + * Read MTL file(s) and add MTLMaterial instances to the given Map reference. + */ void parse_and_store(Map<std::string, std::unique_ptr<MTLMaterial>> &r_mtl_materials); }; } // namespace blender::io::obj diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc index e9dfcf6d091..55b2873a3de 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc @@ -68,11 +68,6 @@ Object *MeshFromGeometry::create_mesh( return obj; } -/** - * OBJ files coming from the wild might have faces that are invalid in Blender - * (mostly with duplicate vertex indices, used by some software to indicate - * polygons with holes). This method tries to fix them up. - */ void MeshFromGeometry::fixup_invalid_faces() { for (int64_t face_idx = 0; face_idx < mesh_geometry_.face_elements_.size(); ++face_idx) { @@ -158,13 +153,6 @@ void MeshFromGeometry::create_vertices(Mesh *mesh) } } -/** - * Create polygons for the Mesh, set smooth shading flag, deform group name, assigned material - * also. - * - * It must receive all polygons to be added to the mesh. Remove holes from polygons before - * calling this. - */ void MeshFromGeometry::create_polys_loops(Object *obj, Mesh *mesh) { /* Will not be used if vertex groups are not imported. */ @@ -245,9 +233,6 @@ void MeshFromGeometry::create_polys_loops(Object *obj, Mesh *mesh) } } -/** - * Add explicitly imported OBJ edges to the mesh. - */ void MeshFromGeometry::create_edges(Mesh *mesh) { const int64_t tot_edges{mesh_geometry_.edges_.size()}; @@ -268,9 +253,6 @@ void MeshFromGeometry::create_edges(Mesh *mesh) BKE_mesh_calc_edges_loose(mesh); } -/** - * Add UV layer and vertices to the Mesh. - */ void MeshFromGeometry::create_uv_verts(Mesh *mesh) { if (global_vertices_.uv_vertices.size() <= 0) { @@ -329,9 +311,6 @@ static Material *get_or_create_material( return mat; } -/** - * Add materials and the nodetree to the Mesh Object. - */ void MeshFromGeometry::create_materials( Main *bmain, const Map<std::string, std::unique_ptr<MTLMaterial>> &materials, @@ -348,11 +327,10 @@ void MeshFromGeometry::create_materials( } } -/** - * Needs more clarity about what is expected in the viewport if the function works. - */ void MeshFromGeometry::create_normals(Mesh *mesh) { + /* NOTE: Needs more clarity about what is expected in the viewport if the function works. */ + /* No normal data: nothing to do. */ if (global_vertices_.vertex_normals.is_empty() || !mesh_geometry_.has_vertex_normals_) { return; diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.hh b/source/blender/io/wavefront_obj/importer/obj_import_mesh.hh index 86132b94a31..e2cdb4c0721 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.hh +++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.hh @@ -37,11 +37,32 @@ class MeshFromGeometry : NonMovable, NonCopyable { const OBJImportParams &import_params); private: + /** + * OBJ files coming from the wild might have faces that are invalid in Blender + * (mostly with duplicate vertex indices, used by some software to indicate + * polygons with holes). This method tries to fix them up. + */ void fixup_invalid_faces(); void create_vertices(Mesh *mesh); + /** + * Create polygons for the Mesh, set smooth shading flag, deform group name, + * assigned material also. + * + * It must receive all polygons to be added to the mesh. + * Remove holes from polygons before * calling this. + */ void create_polys_loops(Object *obj, Mesh *mesh); + /** + * Add explicitly imported OBJ edges to the mesh. + */ void create_edges(Mesh *mesh); + /** + * Add UV layer and vertices to the Mesh. + */ void create_uv_verts(Mesh *mesh); + /** + * Add materials and the nodetree to the Mesh Object. + */ void create_materials(Main *bmain, const Map<std::string, std::unique_ptr<MTLMaterial>> &materials, Map<std::string, Material *> &created_materials, diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc b/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc index ef97f58eb0e..88a8c07e325 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc @@ -111,10 +111,6 @@ static bool load_texture_image(Main *bmain, const tex_map_XX &tex_map, bNode *r_ return false; } -/** - * Initializes a nodetree with a p-BSDF node's BSDF socket connected to shader output node's - * surface socket. - */ ShaderNodetreeWrap::ShaderNodetreeWrap(Main *bmain, const MTLMaterial &mtl_mat, Material *mat) : mtl_mat_(mtl_mat) { @@ -141,10 +137,6 @@ ShaderNodetreeWrap::~ShaderNodetreeWrap() } } -/** - * Release nodetree for materials to own it. nodetree has its unique deleter - * if destructor is not reached for some reason. - */ bNodeTree *ShaderNodetreeWrap::get_nodetree() { /* If this function has been reached, we know that nodes and the nodetree @@ -152,19 +144,11 @@ bNodeTree *ShaderNodetreeWrap::get_nodetree() return nodetree_.release(); } -/** - * Add a new static node to the tree. - * No two nodes are linked here. - */ bNode *ShaderNodetreeWrap::add_node_to_tree(const int node_type) { return nodeAddStaticNode(nullptr, nodetree_.get(), node_type); } -/** - * Return x-y coordinates for a node where y is determined by other nodes present in - * the same vertical column. - */ std::pair<float, float> ShaderNodetreeWrap::set_node_locations(const int pos_x) { int pos_y = 0; @@ -186,11 +170,6 @@ std::pair<float, float> ShaderNodetreeWrap::set_node_locations(const int pos_x) } } -/** - * Link two nodes by the sockets of given IDs. - * Also releases the ownership of the "from" node for nodetree to free it. - * \param from_node_pos_x 0 to 4 value as per nodetree arrangement. - */ void ShaderNodetreeWrap::link_sockets(bNode *from_node, StringRef from_node_id, bNode *to_node, @@ -205,9 +184,6 @@ void ShaderNodetreeWrap::link_sockets(bNode *from_node, nodeAddLink(nodetree_.get(), from_node, from_sock, to_node, to_sock); } -/** - * Set values of sockets in p-BSDF node of the nodetree. - */ void ShaderNodetreeWrap::set_bsdf_socket_values() { const int illum = mtl_mat_.illum; @@ -331,10 +307,6 @@ void ShaderNodetreeWrap::set_bsdf_socket_values() set_property_of_socket(SOCK_FLOAT, "Alpha", {alpha}, bsdf_); } -/** - * Create image texture, vector and normal mapping nodes from MTL materials and link the - * nodes to p-BSDF node. - */ void ShaderNodetreeWrap::add_image_textures(Main *bmain, Material *mat) { for (const Map<const eMTLSyntaxElement, tex_map_XX>::Item texture_map : diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mtl.hh b/source/blender/io/wavefront_obj/importer/obj_import_mtl.hh index e48cf6e56da..4b7827b2035 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mtl.hh +++ b/source/blender/io/wavefront_obj/importer/obj_import_mtl.hh @@ -45,20 +45,48 @@ class ShaderNodetreeWrap { const float node_size_{300.f}; public: + /** + * Initializes a nodetree with a p-BSDF node's BSDF socket connected to shader output node's + * surface socket. + */ ShaderNodetreeWrap(Main *bmain, const MTLMaterial &mtl_mat, Material *mat); ~ShaderNodetreeWrap(); + /** + * Release nodetree for materials to own it. nodetree has its unique deleter + * if destructor is not reached for some reason. + */ bNodeTree *get_nodetree(); private: + /** + * Add a new static node to the tree. + * No two nodes are linked here. + */ bNode *add_node_to_tree(const int node_type); + /** + * Return x-y coordinates for a node where y is determined by other nodes present in + * the same vertical column. + */ std::pair<float, float> set_node_locations(const int pos_x); + /** + * Link two nodes by the sockets of given IDs. + * Also releases the ownership of the "from" node for nodetree to free it. + * \param from_node_pos_x: 0 to 4 value as per nodetree arrangement. + */ void link_sockets(bNode *from_node, StringRef from_node_id, bNode *to_node, StringRef to_node_id, const int from_node_pos_x); + /** + * Set values of sockets in p-BSDF node of the nodetree. + */ void set_bsdf_socket_values(); + /** + * Create image texture, vector and normal mapping nodes from MTL materials and link the + * nodes to p-BSDF node. + */ void add_image_textures(Main *bmain, Material *mat); }; diff --git a/source/blender/io/wavefront_obj/importer/obj_import_nurbs.cc b/source/blender/io/wavefront_obj/importer/obj_import_nurbs.cc index 80293c9ebfe..3ed95572450 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_nurbs.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_nurbs.cc @@ -45,9 +45,6 @@ Object *CurveFromGeometry::create_curve(Main *bmain, const OBJImportParams &impo return obj; } -/** - * Create a NURBS spline for the Curve converted from Geometry. - */ void CurveFromGeometry::create_nurbs(Curve *curve) { const NurbsElement &nurbs_geometry = curve_geometry_.nurbs_element_; diff --git a/source/blender/io/wavefront_obj/importer/obj_import_nurbs.hh b/source/blender/io/wavefront_obj/importer/obj_import_nurbs.hh index 56ac299283d..7c9ed56eeec 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_nurbs.hh +++ b/source/blender/io/wavefront_obj/importer/obj_import_nurbs.hh @@ -33,6 +33,9 @@ class CurveFromGeometry : NonMovable, NonCopyable { Object *create_curve(Main *bmain, const OBJImportParams &import_params); private: + /** + * Create a NURBS spline for the Curve converted from Geometry. + */ void create_nurbs(Curve *curve); }; } // namespace blender::io::obj diff --git a/source/blender/io/wavefront_obj/importer/parser_string_utils.cc b/source/blender/io/wavefront_obj/importer/parser_string_utils.cc index 3e45529c698..6671a86f5ee 100644 --- a/source/blender/io/wavefront_obj/importer/parser_string_utils.cc +++ b/source/blender/io/wavefront_obj/importer/parser_string_utils.cc @@ -17,10 +17,6 @@ namespace blender::io::obj { using std::string; -/** - * Store multiple lines separated by an escaped newline character: `\\n`. - * Use this before doing any parse operations on the read string. - */ void read_next_line(std::fstream &file, string &r_line) { std::string new_line; @@ -36,11 +32,6 @@ void read_next_line(std::fstream &file, string &r_line) } } -/** - * Split a line string into the first word (key) and the rest of the line. - * Also remove leading & trailing spaces as well as `\r` carriage return - * character if present. - */ void split_line_key_rest(const StringRef line, StringRef &r_line_key, StringRef &r_rest_line) { if (line.is_empty()) { @@ -83,11 +74,6 @@ void split_line_key_rest(const StringRef line, StringRef &r_line_key, StringRef } } -/** - * Split the given string by the delimiter and fill the given vector. - * If an intermediate string is empty, or space or null character, it is not appended to the - * vector. - */ void split_by_char(StringRef in_string, const char delimiter, Vector<StringRef> &r_out_list) { r_out_list.clear(); @@ -114,11 +100,6 @@ void split_by_char(StringRef in_string, const char delimiter, Vector<StringRef> } } -/** - * Convert the given string to float and assign it to the destination value. - * - * If the string cannot be converted to a float, the fallback value is used. - */ void copy_string_to_float(StringRef src, const float fallback_value, float &r_dst) { try { @@ -135,12 +116,6 @@ void copy_string_to_float(StringRef src, const float fallback_value, float &r_ds } } -/** - * Convert all members of the Span of strings to floats and assign them to the float - * array members. Usually used for values like coordinates. - * - * If a string cannot be converted to a float, the fallback value is used. - */ void copy_string_to_float(Span<StringRef> src, const float fallback_value, MutableSpan<float> r_dst) @@ -155,11 +130,6 @@ void copy_string_to_float(Span<StringRef> src, } } -/** - * Convert the given string to int and assign it to the destination value. - * - * If the string cannot be converted to an integer, the fallback value is used. - */ void copy_string_to_int(StringRef src, const int fallback_value, int &r_dst) { try { @@ -176,11 +146,6 @@ void copy_string_to_int(StringRef src, const int fallback_value, int &r_dst) } } -/** - * Convert the given strings to ints and fill the destination int buffer. - * - * If a string cannot be converted to an integer, the fallback value is used. - */ void copy_string_to_int(Span<StringRef> src, const int fallback_value, MutableSpan<int> r_dst) { for (int i = 0; i < r_dst.size(); ++i) { diff --git a/source/blender/io/wavefront_obj/importer/parser_string_utils.hh b/source/blender/io/wavefront_obj/importer/parser_string_utils.hh index 09540721604..62cfbebccf3 100644 --- a/source/blender/io/wavefront_obj/importer/parser_string_utils.hh +++ b/source/blender/io/wavefront_obj/importer/parser_string_utils.hh @@ -5,14 +5,49 @@ namespace blender::io::obj { /* Note: these OBJ parser helper functions are planned to get fairly large * changes "soon", so don't read too much into current implementation... */ +/** + * Store multiple lines separated by an escaped newline character: `\\n`. + * Use this before doing any parse operations on the read string. + */ void read_next_line(std::fstream &file, std::string &r_line); +/** + * Split a line string into the first word (key) and the rest of the line. + * Also remove leading & trailing spaces as well as `\r` carriage return + * character if present. + */ void split_line_key_rest(StringRef line, StringRef &r_line_key, StringRef &r_rest_line); +/** + * Split the given string by the delimiter and fill the given vector. + * If an intermediate string is empty, or space or null character, it is not appended to the + * vector. + */ void split_by_char(StringRef in_string, const char delimiter, Vector<StringRef> &r_out_list); +/** + * Convert the given string to float and assign it to the destination value. + * + * If the string cannot be converted to a float, the fallback value is used. + */ void copy_string_to_float(StringRef src, const float fallback_value, float &r_dst); +/** + * Convert all members of the Span of strings to floats and assign them to the float + * array members. Usually used for values like coordinates. + * + * If a string cannot be converted to a float, the fallback value is used. + */ void copy_string_to_float(Span<StringRef> src, const float fallback_value, MutableSpan<float> r_dst); +/** + * Convert the given string to int and assign it to the destination value. + * + * If the string cannot be converted to an integer, the fallback value is used. + */ void copy_string_to_int(StringRef src, const int fallback_value, int &r_dst); +/** + * Convert the given strings to ints and fill the destination int buffer. + * + * If a string cannot be converted to an integer, the fallback value is used. + */ void copy_string_to_int(Span<StringRef> src, const int fallback_value, MutableSpan<int> r_dst); std::string replace_all_occurences(StringRef original, StringRef to_remove, StringRef to_add); diff --git a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc index 2a0e2aaf510..0a70a03dc65 100644 --- a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc +++ b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc @@ -82,7 +82,7 @@ class obj_importer_test : public BlendfileLoadingBaseTest { EXPECT_V3_NEAR(object->rot, float3(M_PI_2, 0, 0), 0.0001f); } EXPECT_V3_NEAR(object->scale, float3(1, 1, 1), 0.0001f); - if (object->type == OB_MESH || object->type == OB_SURF) { + if (object->type == OB_MESH) { Mesh *mesh = BKE_object_get_evaluated_mesh(object); EXPECT_EQ(mesh->totvert, exp.totvert); EXPECT_EQ(mesh->totedge, exp.mesh_totedge_or_curve_endp); diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 3ebf085443a..e3a6f50531d 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -335,7 +335,7 @@ enum { /* 2 characters for ID code and 64 for actual name */ #define MAX_ID_NAME 66 -/* ID_Runtime_Remap.status */ +/** #ID_Runtime_Remap.status */ enum { /** new_id is directly linked in current .blend. */ ID_REMAP_IS_LINKED_DIRECT = 1 << 0, @@ -476,7 +476,7 @@ typedef struct Library { short versionfile, subversionfile; } Library; -/* Library.tag */ +/** #Library.tag */ enum eLibrary_Tag { /* Automatic recursive resync was needed when linking/loading data from that library. */ LIBRARY_TAG_RESYNC_REQUIRED = 1 << 0, diff --git a/source/blender/makesdna/DNA_brush_enums.h b/source/blender/makesdna/DNA_brush_enums.h index 783e79898ce..96a97648ac9 100644 --- a/source/blender/makesdna/DNA_brush_enums.h +++ b/source/blender/makesdna/DNA_brush_enums.h @@ -277,7 +277,7 @@ typedef enum eBrushSnakeHookDeformType { BRUSH_SNAKE_HOOK_DEFORM_ELASTIC = 1, } eBrushSnakeHookDeformType; -/* Gpencilsettings.Vertex_mode */ +/** #Gpencilsettings.Vertex_mode */ typedef enum eGp_Vertex_Mode { /* Affect to Stroke only. */ GPPAINT_MODE_STROKE = 0, @@ -327,7 +327,7 @@ typedef enum ePaintBrush_flag { BRUSH_PAINT_DENSITY_PRESSURE_INVERT = (1 << 9), } ePaintBrush_flag; -/* Brush.gradient_source */ +/** #Brush.gradient_source */ typedef enum eBrushGradientSourceStroke { BRUSH_GRADIENT_PRESSURE = 0, /* gradient from pressure */ BRUSH_GRADIENT_SPACING_REPEAT = 1, /* gradient from spacing */ @@ -339,7 +339,7 @@ typedef enum eBrushGradientSourceFill { BRUSH_GRADIENT_RADIAL = 1, /* gradient from spacing */ } eBrushGradientSourceFill; -/* Brush.flag */ +/** #Brush.flag */ typedef enum eBrushFlags { BRUSH_AIRBRUSH = (1 << 0), BRUSH_INVERT_TO_SCRAPE_FILL = (1 << 1), @@ -375,12 +375,12 @@ typedef enum eBrushFlags { BRUSH_CURVE = (1u << 31), } eBrushFlags; -/* Brush.sampling_flag */ +/** #Brush.sampling_flag */ typedef enum eBrushSamplingFlags { BRUSH_PAINT_ANTIALIASING = (1 << 0), } eBrushSamplingFlags; -/* Brush.flag2 */ +/** #Brush.flag2 */ typedef enum eBrushFlags2 { BRUSH_MULTIPLANE_SCRAPE_DYNAMIC = (1 << 0), BRUSH_MULTIPLANE_SCRAPE_PLANES_PREVIEW = (1 << 1), @@ -398,7 +398,7 @@ typedef enum { BRUSH_MASK_PRESSURE_CUTOFF = (1 << 2), } BrushMaskPressureFlags; -/* Brush.overlay_flags */ +/** #Brush.overlay_flags */ typedef enum eOverlayFlags { BRUSH_OVERLAY_CURSOR = (1), BRUSH_OVERLAY_PRIMARY = (1 << 1), @@ -412,7 +412,7 @@ typedef enum eOverlayFlags { (BRUSH_OVERLAY_CURSOR_OVERRIDE_ON_STROKE | BRUSH_OVERLAY_PRIMARY_OVERRIDE_ON_STROKE | \ BRUSH_OVERLAY_SECONDARY_OVERRIDE_ON_STROKE) -/* Brush.sculpt_tool */ +/** #Brush.sculpt_tool */ typedef enum eBrushSculptTool { SCULPT_TOOL_DRAW = 1, SCULPT_TOOL_SMOOTH = 2, @@ -448,7 +448,7 @@ typedef enum eBrushSculptTool { SCULPT_TOOL_DISPLACEMENT_SMEAR = 32, } eBrushSculptTool; -/* Brush.uv_sculpt_tool */ +/** #Brush.uv_sculpt_tool */ typedef enum eBrushUVSculptTool { UV_SCULPT_TOOL_GRAB = 0, UV_SCULPT_TOOL_RELAX = 1, @@ -461,8 +461,8 @@ typedef enum eBrushCurvesSculptTool { CURVES_SCULPT_TOOL_DELETE = 1, CURVES_SCULPT_TOOL_SNAKE_HOOK = 2, CURVES_SCULPT_TOOL_ADD = 3, - CURVES_SCULPT_TOOL_TEST1 = 4, - CURVES_SCULPT_TOOL_TEST2 = 5, + CURVES_SCULPT_TOOL_GROW_SHRINK = 4, + CURVES_SCULPT_TOOL_TEST1 = 5, } eBrushCurvesSculptTool; /** When #BRUSH_ACCUMULATE is used */ @@ -602,12 +602,17 @@ typedef enum eBlurKernelType { KERNEL_BOX = 1, } eBlurKernelType; -/* Brush.falloff_shape */ +/** #Brush.falloff_shape */ typedef enum eBrushFalloffShape { PAINT_FALLOFF_SHAPE_SPHERE = 0, PAINT_FALLOFF_SHAPE_TUBE = 1, } eBrushFalloffShape; +typedef enum eBrushCurvesSculptFlag { + BRUSH_CURVES_SCULPT_FLAG_SCALE_UNIFORM = (1 << 0), + BRUSH_CURVES_SCULPT_FLAG_GROW_SHRINK_INVERT = (1 << 1), +} eBrushCurvesSculptFlag; + #define MAX_BRUSH_PIXEL_RADIUS 500 #define GP_MAX_BRUSH_PIXEL_RADIUS 1000 diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 1382efca409..2d879f5afa0 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -140,6 +140,10 @@ typedef struct BrushGpencilSettings { typedef struct BrushCurvesSculptSettings { /** Number of curves added by the add brush. */ int add_amount; + /* eBrushCurvesSculptFlag. */ + uint32_t flag; + /** When shrinking curves, they shouldn't become shorter than this length. */ + float minimum_length; } BrushCurvesSculptSettings; typedef struct Brush { diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index eaae82d0ccd..6557f35970d 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -745,7 +745,7 @@ typedef enum eConstraint_EulerOrder { /* -------------------------------------- */ -/* bRotateLikeConstraint.flag */ +/** #bRotateLikeConstraint.flag */ typedef enum eCopyRotation_Flags { ROTLIKE_X = (1 << 0), ROTLIKE_Y = (1 << 1), @@ -758,7 +758,7 @@ typedef enum eCopyRotation_Flags { #endif } eCopyRotation_Flags; -/* bRotateLikeConstraint.mix_mode */ +/** #bRotateLikeConstraint.mix_mode */ typedef enum eCopyRotation_MixMode { /* Replace rotation channel values. */ ROTLIKE_MIX_REPLACE = 0, @@ -772,7 +772,7 @@ typedef enum eCopyRotation_MixMode { ROTLIKE_MIX_AFTER = 4, } eCopyRotation_MixMode; -/* bLocateLikeConstraint.flag */ +/** #bLocateLikeConstraint.flag */ typedef enum eCopyLocation_Flags { LOCLIKE_X = (1 << 0), LOCLIKE_Y = (1 << 1), @@ -785,7 +785,7 @@ typedef enum eCopyLocation_Flags { LOCLIKE_OFFSET = (1 << 7), } eCopyLocation_Flags; -/* bSizeLikeConstraint.flag */ +/** #bSizeLikeConstraint.flag */ typedef enum eCopyScale_Flags { SIZELIKE_X = (1 << 0), SIZELIKE_Y = (1 << 1), @@ -795,13 +795,13 @@ typedef enum eCopyScale_Flags { SIZELIKE_UNIFORM = (1 << 5), } eCopyScale_Flags; -/* bTransLikeConstraint.flag */ +/** #bTransLikeConstraint.flag */ typedef enum eCopyTransforms_Flags { /* Remove shear from the target matrix. */ TRANSLIKE_REMOVE_TARGET_SHEAR = (1 << 0), } eCopyTransforms_Flags; -/* bTransLikeConstraint.mix_mode */ +/** #bTransLikeConstraint.mix_mode */ typedef enum eCopyTransforms_MixMode { /* Replace rotation channel values. */ TRANSLIKE_MIX_REPLACE = 0, @@ -826,7 +826,7 @@ typedef enum eTransform_ToFrom { TRANS_SCALE = 2, } eTransform_ToFrom; -/* bTransformConstraint.mix_mode_loc */ +/** #bTransformConstraint.mix_mode_loc */ typedef enum eTransform_MixModeLoc { /* Add component values together (default). */ TRANS_MIXLOC_ADD = 0, @@ -834,7 +834,7 @@ typedef enum eTransform_MixModeLoc { TRANS_MIXLOC_REPLACE = 1, } eTransform_MixModeLoc; -/* bTransformConstraint.mix_mode_rot */ +/** #bTransformConstraint.mix_mode_rot */ typedef enum eTransform_MixModeRot { /* Add component values together (default). */ TRANS_MIXROT_ADD = 0, @@ -846,7 +846,7 @@ typedef enum eTransform_MixModeRot { TRANS_MIXROT_AFTER = 3, } eTransform_MixModeRot; -/* bTransformConstraint.mix_mode_scale */ +/** #bTransformConstraint.mix_mode_scale */ typedef enum eTransform_MixModeScale { /* Replace component values (default). */ TRANS_MIXSCALE_REPLACE = 0, @@ -854,14 +854,14 @@ typedef enum eTransform_MixModeScale { TRANS_MIXSCALE_MULTIPLY = 1, } eTransform_MixModeScale; -/* bSameVolumeConstraint.free_axis */ +/** #bSameVolumeConstraint.free_axis */ typedef enum eSameVolume_Axis { SAMEVOL_X = 0, SAMEVOL_Y = 1, SAMEVOL_Z = 2, } eSameVolume_Axis; -/* bSameVolumeConstraint.mode */ +/** #bSameVolumeConstraint.mode */ typedef enum eSameVolume_Mode { /* Strictly maintain the volume, overriding non-free axis scale. */ SAMEVOL_STRICT = 0, @@ -871,7 +871,7 @@ typedef enum eSameVolume_Mode { SAMEVOL_SINGLE_AXIS = 2, } eSameVolume_Mode; -/* bActionConstraint.flag */ +/** #bActionConstraint.flag */ typedef enum eActionConstraint_Flags { /* Bones use "object" part of target action, instead of "same bone name" part */ ACTCON_BONE_USE_OBJECT_ACTION = (1 << 0), @@ -879,7 +879,7 @@ typedef enum eActionConstraint_Flags { ACTCON_USE_EVAL_TIME = (1 << 1), } eActionConstraint_Flags; -/* bActionConstraint.mix_mode */ +/** #bActionConstraint.mix_mode */ typedef enum eActionConstraint_MixMode { /* Multiply the action transformation on the right. */ ACTCON_MIX_AFTER_FULL = 0, diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index 66206bcfddd..556e467c4b6 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -19,7 +19,7 @@ extern "C" { #define MAXTEXTBOX 256 /* used in readfile.c and editfont.c */ struct AnimData; -struct CurveEval; +struct Curves; struct CurveProfile; struct EditFont; struct GHash; @@ -291,7 +291,7 @@ typedef struct Curve { * since it also contains the result of geometry nodes evaluation, and isn't just a copy of the * original object data. */ - struct CurveEval *curve_eval; + const struct Curves *curve_eval; void *batch_cache; } Curve; @@ -300,13 +300,13 @@ typedef struct Curve { /* **************** CURVE ********************* */ -/* Curve.texflag */ +/** #Curve.texflag */ enum { CU_AUTOSPACE = 1, CU_AUTOSPACE_EVALUATED = 2, }; -/* Curve.flag */ +/** #Curve.flag */ enum { CU_3D = 1 << 0, CU_FRONT = 1 << 1, @@ -329,7 +329,7 @@ enum { CU_MAP_TAPER = 1 << 15, }; -/* Curve.twist_mode */ +/** #Curve.twist_mode */ enum { CU_TWIST_Z_UP = 0, /* CU_TWIST_Y_UP = 1, */ /* not used yet */ @@ -345,7 +345,7 @@ enum { CU_BEVFAC_MAP_SPLINE = 2, }; -/* Curve.spacemode */ +/** #Curve.spacemode */ enum { CU_ALIGN_X_LEFT = 0, CU_ALIGN_X_MIDDLE = 1, @@ -354,7 +354,7 @@ enum { CU_ALIGN_X_FLUSH = 4, }; -/* Curve.align_y */ +/** #Curve.align_y */ enum { CU_ALIGN_Y_TOP_BASELINE = 0, CU_ALIGN_Y_TOP = 1, @@ -363,7 +363,7 @@ enum { CU_ALIGN_Y_BOTTOM = 4, }; -/* Curve.bevel_mode */ +/** #Curve.bevel_mode */ enum { CU_BEV_MODE_ROUND = 0, CU_BEV_MODE_OBJECT = 1, @@ -387,12 +387,12 @@ enum { CU_OVERFLOW_TRUNCATE = 2, }; -/* Nurb.flag */ +/** #Nurb.flag */ enum { CU_SMOOTH = 1 << 0, }; -/* Nurb.type */ +/** #Nurb.type */ enum { CU_POLY = 0, CU_BEZIER = 1, @@ -573,7 +573,7 @@ typedef enum eBezTriple_KeyframeType { /* *************** CHARINFO **************** */ -/* CharInfo.flag */ +/** #CharInfo.flag */ enum { /* NOTE: CU_CHINFO_WRAP, CU_CHINFO_SMALLCAPS_TEST and CU_CHINFO_TRUNCATE are set dynamically. */ CU_CHINFO_BOLD = 1 << 0, diff --git a/source/blender/makesdna/DNA_curves_types.h b/source/blender/makesdna/DNA_curves_types.h index 97cc588e639..a1eefca4ab5 100644 --- a/source/blender/makesdna/DNA_curves_types.h +++ b/source/blender/makesdna/DNA_curves_types.h @@ -139,7 +139,7 @@ typedef struct Curves { void *batch_cache; } Curves; -/* Curves.flag */ +/** #Curves.flag */ enum { HA_DS_EXPAND = (1 << 0), }; diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index cf43574af55..858de733558 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -80,7 +80,7 @@ typedef struct CustomData { CustomDataExternal *external; } CustomData; -/* CustomData.type */ +/** #CustomData.type */ typedef enum CustomDataType { /* Used by GLSL attributes in the cases when we need a delayed CD type * assignment (in the cases when we don't know in advance which layer @@ -238,7 +238,7 @@ typedef struct CustomData_MeshMasks { uint64_t lmask; } CustomData_MeshMasks; -/* CustomData.flag */ +/** #CustomData.flag */ enum { /* Indicates layer should not be copied by CustomData_from_template or CustomData_copy_data */ CD_FLAG_NOCOPY = (1 << 0), diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index 06b589d4f76..4e66e2446f0 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -212,7 +212,7 @@ typedef struct Image { /* **************** IMAGE ********************* */ -/* Image.flag */ +/** #Image.flag */ enum { IMA_HIGH_BITDEPTH = (1 << 0), IMA_FLAG_UNUSED_1 = (1 << 1), /* cleared */ @@ -235,7 +235,7 @@ enum { IMA_FLAG_UNUSED_16 = (1 << 16), /* cleared */ }; -/* Image.gpuflag */ +/** #Image.gpuflag */ enum { /** All mipmap levels in OpenGL texture set? */ IMA_GPU_MIPMAP_COMPLETE = (1 << 0), @@ -268,7 +268,7 @@ typedef enum eImageType { IMA_TYPE_COMPOSITE = 5, } eImageType; -/* Image.gen_type */ +/** #Image.gen_type */ enum { IMA_GENTYPE_BLANK = 0, IMA_GENTYPE_GRID = 1, @@ -278,12 +278,12 @@ enum { /* render */ #define IMA_MAX_RENDER_TEXT (1 << 9) -/* Image.gen_flag */ +/** #Image.gen_flag */ enum { IMA_GEN_FLOAT = 1, }; -/* Image.alpha_mode */ +/** #Image.alpha_mode */ enum { IMA_ALPHA_STRAIGHT = 0, IMA_ALPHA_PREMUL = 1, diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 64bd1616494..fb1ba15a099 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -2447,11 +2447,11 @@ typedef enum eGPencil_Guide_Reference { /* UnitSettings */ #define USER_UNIT_ADAPTIVE 0xFF -/* UnitSettings.system */ +/** #UnitSettings.system */ #define USER_UNIT_NONE 0 #define USER_UNIT_METRIC 1 #define USER_UNIT_IMPERIAL 2 -/* UnitSettings.flag */ +/** #UnitSettings.flag */ #define USER_UNIT_OPT_SPLIT 1 #define USER_UNIT_ROT_RADIANS 2 diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index cb660619a37..d28550b5456 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -562,7 +562,7 @@ enum { SEQ_MAKE_FLOAT = (1 << 13), SEQ_LOCK = (1 << 14), SEQ_USE_PROXY = (1 << 15), - SEQ_FLAG_UNUSED_23 = (1 << 16), /* cleared */ + SEQ_IGNORE_CHANNEL_LOCK = (1 << 16), SEQ_FLAG_UNUSED_22 = (1 << 17), /* cleared */ SEQ_FLAG_UNUSED_18 = (1 << 18), /* cleared */ SEQ_FLAG_UNUSED_19 = (1 << 19), /* cleared */ diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index b2b6bdbcffc..062c827b9d0 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -248,8 +248,8 @@ const EnumPropertyItem rna_enum_brush_curves_sculpt_tool_items[] = { {CURVES_SCULPT_TOOL_DELETE, "DELETE", ICON_NONE, "Delete", ""}, {CURVES_SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", ICON_NONE, "Snake Hook", ""}, {CURVES_SCULPT_TOOL_ADD, "ADD", ICON_NONE, "Add", ""}, + {CURVES_SCULPT_TOOL_GROW_SHRINK, "GROW_SHRINK", ICON_NONE, "Grow / Shrink", ""}, {CURVES_SCULPT_TOOL_TEST1, "TEST1", ICON_NONE, "Test 1", ""}, - {CURVES_SCULPT_TOOL_TEST2, "TEST2", ICON_NONE, "Test 2", ""}, {0, NULL, 0, NULL, NULL}, }; @@ -883,7 +883,13 @@ static const EnumPropertyItem *rna_Brush_direction_itemf(bContext *C, default: return DummyRNA_DEFAULT_items; } - + case PAINT_MODE_SCULPT_CURVES: + switch (me->curves_sculpt_tool) { + case CURVES_SCULPT_TOOL_GROW_SHRINK: + return prop_direction_items; + default: + return DummyRNA_DEFAULT_items; + } default: return DummyRNA_DEFAULT_items; } @@ -1927,6 +1933,18 @@ static void rna_def_curves_sculpt_options(BlenderRNA *brna) prop = RNA_def_property(srna, "add_amount", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 1, INT32_MAX); RNA_def_property_ui_text(prop, "Add Amount", "Number of curves added by the Add brush"); + + prop = RNA_def_property(srna, "scale_uniform", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_CURVES_SCULPT_FLAG_SCALE_UNIFORM); + RNA_def_property_ui_text(prop, + "Scale Uniform", + "Grow or shrink curves by changing their size uniformly instead of " + "using trimming or extrapolation"); + + prop = RNA_def_property(srna, "minimum_length", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_text( + prop, "Minimum Length", "Avoid shrinking curves shorter than this length"); } static void rna_def_brush(BlenderRNA *brna) diff --git a/source/blender/render/RE_engine.h b/source/blender/render/RE_engine.h index e56e7b8d2e4..d7815ef3f3c 100644 --- a/source/blender/render/RE_engine.h +++ b/source/blender/render/RE_engine.h @@ -38,7 +38,7 @@ extern "C" { /* External Engine */ -/* RenderEngineType.flag */ +/** #RenderEngineType.flag */ #define RE_INTERNAL 1 /* #define RE_FLAG_DEPRECATED 2 */ #define RE_USE_PREVIEW 4 @@ -53,7 +53,7 @@ extern "C" { #define RE_USE_NO_IMAGE_SAVE 2048 #define RE_USE_ALEMBIC_PROCEDURAL 4096 -/* RenderEngine.flag */ +/** #RenderEngine.flag */ #define RE_ENGINE_ANIMATION 1 #define RE_ENGINE_PREVIEW 2 #define RE_ENGINE_DO_DRAW 4 diff --git a/source/blender/render/intern/render_types.h b/source/blender/render/intern/render_types.h index 27b014ac289..58a15e3f013 100644 --- a/source/blender/render/intern/render_types.h +++ b/source/blender/render/intern/render_types.h @@ -128,7 +128,7 @@ struct Render { /* **************** defines ********************* */ -/* R.flag */ +/** #R.flag */ #define R_ANIMATION 1 #ifdef __cplusplus diff --git a/source/blender/sequencer/SEQ_add.h b/source/blender/sequencer/SEQ_add.h index 2363a24589a..c195165a792 100644 --- a/source/blender/sequencer/SEQ_add.h +++ b/source/blender/sequencer/SEQ_add.h @@ -15,7 +15,7 @@ struct ListBase; struct Scene; struct Sequence; -/* SeqLoadData.flags */ +/** #SeqLoadData.flags */ typedef enum eSeqLoadFlags { SEQ_LOAD_SOUND_CACHE = (1 << 1), SEQ_LOAD_SOUND_MONO = (1 << 2), diff --git a/source/blender/sequencer/intern/animation.c b/source/blender/sequencer/intern/animation.c index 27f7316e042..82dc5970a7f 100644 --- a/source/blender/sequencer/intern/animation.c +++ b/source/blender/sequencer/intern/animation.c @@ -48,9 +48,13 @@ GSet *SEQ_fcurves_by_strip_get(const Sequence *seq, ListBase *fcurve_base) char rna_path[SEQ_RNAPATH_MAXSTR]; size_t rna_path_len = sequencer_rna_path_prefix(rna_path, seq->name + 2); - GSet *fcurves = BLI_gset_ptr_new(__func__); + /* Only allocate `fcurves` if it's needed as it's possible there is no animation for `seq`. */ + GSet *fcurves = NULL; LISTBASE_FOREACH (FCurve *, fcurve, fcurve_base) { if (STREQLEN(fcurve->rna_path, rna_path, rna_path_len)) { + if (fcurves == NULL) { + fcurves = BLI_gset_ptr_new(__func__); + } BLI_gset_add(fcurves, fcurve); } } @@ -65,8 +69,11 @@ void SEQ_offset_animdata(Scene *scene, Sequence *seq, int ofs) if (!seq_animation_curves_exist(scene) || ofs == 0) { return; } - GSet *fcurves = SEQ_fcurves_by_strip_get(seq, &scene->adt->action->curves); + if (fcurves == NULL) { + return; + } + GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) { unsigned int i; if (fcu->bezt) { @@ -95,8 +102,11 @@ void SEQ_free_animdata(Scene *scene, Sequence *seq) if (!seq_animation_curves_exist(scene)) { return; } - GSet *fcurves = SEQ_fcurves_by_strip_get(seq, &scene->adt->action->curves); + if (fcurves == NULL) { + return; + } + GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) { BLI_remlink(&scene->adt->action->curves, fcu); BKE_fcurve_free(fcu); @@ -126,10 +136,18 @@ void SEQ_animation_restore_original(Scene *scene, ListBase *list) void SEQ_animation_duplicate(Scene *scene, Sequence *seq, ListBase *list) { + if (BLI_listbase_is_empty(list)) { + return; + } GSet *fcurves = SEQ_fcurves_by_strip_get(seq, list); + if (fcurves == NULL) { + return; + } + GSET_FOREACH_BEGIN (FCurve *, fcu, fcurves) { FCurve *fcu_cpy = BKE_fcurve_copy(fcu); BLI_addtail(&scene->adt->action->curves, fcu_cpy); } GSET_FOREACH_END(); + BLI_gset_free(fcurves, NULL); } diff --git a/source/blender/sequencer/intern/strip_transform.c b/source/blender/sequencer/intern/strip_transform.c index 618fed079f4..087e2610bd6 100644 --- a/source/blender/sequencer/intern/strip_transform.c +++ b/source/blender/sequencer/intern/strip_transform.c @@ -395,7 +395,8 @@ void SEQ_transform_offset_after_frame(Scene *scene, bool SEQ_transform_is_locked(ListBase *channels, Sequence *seq) { SeqTimelineChannel *channel = SEQ_channel_get_by_index(channels, seq->machine); - return seq->flag & SEQ_LOCK || SEQ_channel_is_locked(channel); + return seq->flag & SEQ_LOCK || + (SEQ_channel_is_locked(channel) && ((seq->flag & SEQ_IGNORE_CHANNEL_LOCK) == 0)); } void SEQ_image_transform_mirror_factor_get(const Sequence *seq, float r_mirror[2]) diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c index c048b64426a..6e44246f3ef 100644 --- a/source/blender/windowmanager/intern/wm_operator_props.c +++ b/source/blender/windowmanager/intern/wm_operator_props.c @@ -383,7 +383,7 @@ void WM_operator_properties_select_operation(wmOperatorType *ot) {SEL_OP_SET, "SET", ICON_SELECT_SET, "Set", "Set a new selection"}, {SEL_OP_ADD, "ADD", ICON_SELECT_EXTEND, "Extend", "Extend existing selection"}, {SEL_OP_SUB, "SUB", ICON_SELECT_SUBTRACT, "Subtract", "Subtract existing selection"}, - {SEL_OP_XOR, "XOR", ICON_SELECT_DIFFERENCE, "Difference", "Inverts existing selection"}, + {SEL_OP_XOR, "XOR", ICON_SELECT_DIFFERENCE, "Difference", "Invert existing selection"}, {SEL_OP_AND, "AND", ICON_SELECT_INTERSECT, "Intersect", "Intersect existing selection"}, {0, NULL, 0, NULL, NULL}, }; |