diff --git a/.clang-format b/.clang-format index 728b128e251..17196f7ddab 100644 --- a/.clang-format +++ b/.clang-format @@ -278,6 +278,3 @@ StatementMacros: MacroBlockBegin: "^OSL_CLOSURE_STRUCT_BEGIN$" MacroBlockEnd: "^OSL_CLOSURE_STRUCT_END$" - -# Ensure new line at the end of source files. -InsertNewlineAtEOF: True diff --git a/GNUmakefile b/GNUmakefile index 881fcc076c6..0ab8c7572e0 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -535,7 +535,7 @@ check_spelling_shaders: .FORCE "$(BLENDER_DIR)/source/" check_descriptions: .FORCE - @$(BLENDER_BIN) --background --factory-startup --python \ + @$(BLENDER_BIN) --background -noaudio --factory-startup --python \ "$(BLENDER_DIR)/tools/check_source/check_descriptions.py" check_deprecated: .FORCE @@ -598,7 +598,7 @@ format: .FORCE doc_py: .FORCE @ASAN_OPTIONS=halt_on_error=0:${ASAN_OPTIONS} \ $(BLENDER_BIN) \ - --background --factory-startup \ + --background -noaudio --factory-startup \ --python doc/python_api/sphinx_doc_gen.py @sphinx-build -b html -j $(NPROCS) doc/python_api/sphinx-in doc/python_api/sphinx-out @echo "docs written into: '$(BLENDER_DIR)/doc/python_api/sphinx-out/index.html'" @@ -609,7 +609,7 @@ doc_doxy: .FORCE doc_dna: .FORCE @$(BLENDER_BIN) \ - --background --factory-startup \ + --background -noaudio --factory-startup \ --python doc/blender_file_format/BlendFileDnaExporter_25.py @echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'" diff --git a/build_files/build_environment/cmake/alembic.cmake b/build_files/build_environment/cmake/alembic.cmake index 42241c3ce9a..af36b977e4b 100644 --- a/build_files/build_environment/cmake/alembic.cmake +++ b/build_files/build_environment/cmake/alembic.cmake @@ -21,32 +21,20 @@ ExternalProject_Add(external_alembic URL_HASH ${ALEMBIC_HASH_TYPE}=${ALEMBIC_HASH} CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} PREFIX ${BUILD_DIR}/alembic - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/alembic - -Wno-dev - ${DEFAULT_CMAKE_FLAGS} - ${ALEMBIC_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/alembic -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${ALEMBIC_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/alembic ) if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_alembic after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/alembic - ${HARVEST_TARGET}/alembic - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/alembic ${HARVEST_TARGET}/alembic DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_alembic after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/alembic/lib/alembic.lib - ${HARVEST_TARGET}/alembic/lib/alembic_d.lib - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/alembic/lib/alembic.lib ${HARVEST_TARGET}/alembic/lib/alembic_d.lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/aom.cmake b/build_files/build_environment/cmake/aom.cmake index 18f3af70a94..91db1cd5253 100644 --- a/build_files/build_environment/cmake/aom.cmake +++ b/build_files/build_environment/cmake/aom.cmake @@ -24,19 +24,10 @@ ExternalProject_Add(external_aom DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${AOM_HASH_TYPE}=${AOM_HASH} PREFIX ${BUILD_DIR}/aom - - PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d - ${BUILD_DIR}/aom/src/external_aom < - ${PATCH_DIR}/aom.diff - + PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/aom/src/external_aom < ${PATCH_DIR}/aom.diff CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/aom/src/external_aom-build/ && - ${CMAKE_COMMAND} - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/aom - ${AOM_CMAKE_FLAGS} - ${AOM_EXTRA_ARGS} - ${BUILD_DIR}/aom/src/external_aom/ - + ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${LIBDIR}/aom ${AOM_CMAKE_FLAGS} ${AOM_EXTRA_ARGS} ${BUILD_DIR}/aom/src/external_aom/ BUILD_COMMAND ${CMAKE_COMMAND} --build . INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install INSTALL_DIR ${LIBDIR}/aom diff --git a/build_files/build_environment/cmake/blosc.cmake b/build_files/build_environment/cmake/blosc.cmake index d84f652e698..42679f8d4eb 100644 --- a/build_files/build_environment/cmake/blosc.cmake +++ b/build_files/build_environment/cmake/blosc.cmake @@ -26,12 +26,7 @@ ExternalProject_Add(external_blosc DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${BLOSC_HASH_TYPE}=${BLOSC_HASH} PREFIX ${BUILD_DIR}/blosc - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/blosc - ${DEFAULT_CMAKE_FLAGS} - ${BLOSC_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/blosc ${DEFAULT_CMAKE_FLAGS} ${BLOSC_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/blosc ) diff --git a/build_files/build_environment/cmake/boost.cmake b/build_files/build_environment/cmake/boost.cmake index a09775112c0..03182d4e679 100644 --- a/build_files/build_environment/cmake/boost.cmake +++ b/build_files/build_environment/cmake/boost.cmake @@ -16,29 +16,14 @@ if(WIN32) else() list(APPEND BOOST_BUILD_OPTIONS variant=release) endif() - set(BOOST_HARVEST_CMD - ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/boost/lib/ - ${HARVEST_TARGET}/boost/lib/ - ) + set(BOOST_HARVEST_CMD ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/lib/ ${HARVEST_TARGET}/boost/lib/) if(BUILD_MODE STREQUAL Release) - set(BOOST_HARVEST_CMD - ${BOOST_HARVEST_CMD} && - ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/boost/include/boost-${BOOST_VERSION_NODOTS_SHORT}/ - ${HARVEST_TARGET}/boost/include/ - ) + set(BOOST_HARVEST_CMD ${BOOST_HARVEST_CMD} && ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/boost/include/boost-${BOOST_VERSION_NODOTS_SHORT}/ ${HARVEST_TARGET}/boost/include/) endif() elseif(APPLE) set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh) set(BOOST_BUILD_COMMAND ./b2) - set(BOOST_BUILD_OPTIONS - toolset=clang-darwin - cxxflags=${PLATFORM_CXXFLAGS} - linkflags=${PLATFORM_LDFLAGS} - visibility=global - --disable-icu boost.locale.icu=off - ) + set(BOOST_BUILD_OPTIONS toolset=clang-darwin cxxflags=${PLATFORM_CXXFLAGS} linkflags=${PLATFORM_LDFLAGS} visibility=global --disable-icu boost.locale.icu=off) set(BOOST_HARVEST_CMD echo .) else() set(BOOST_HARVEST_CMD echo .) @@ -87,25 +72,9 @@ ExternalProject_Add(external_boost URL_HASH ${BOOST_HASH_TYPE}=${BOOST_HASH} PREFIX ${BUILD_DIR}/boost UPDATE_COMMAND "" - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/boost/src/external_boost < - ${PATCH_DIR}/boost.diff - + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/boost/src/external_boost < ${PATCH_DIR}/boost.diff CONFIGURE_COMMAND ${BOOST_CONFIGURE_COMMAND} - - BUILD_COMMAND - ${BOOST_BUILD_COMMAND} - ${BOOST_BUILD_OPTIONS} - -j${MAKE_THREADS} - architecture=${BOOST_ARCHITECTURE} - address-model=${BOOST_ADDRESS_MODEL} - link=shared - threading=multi - ${BOOST_OPTIONS} - --prefix=${LIBDIR}/boost - install - + BUILD_COMMAND ${BOOST_BUILD_COMMAND} ${BOOST_BUILD_OPTIONS} -j${MAKE_THREADS} architecture=${BOOST_ARCHITECTURE} address-model=${BOOST_ADDRESS_MODEL} link=shared threading=multi ${BOOST_OPTIONS} --prefix=${LIBDIR}/boost install BUILD_IN_SOURCE 1 INSTALL_COMMAND "${BOOST_HARVEST_CMD}" ) diff --git a/build_files/build_environment/cmake/brotli.cmake b/build_files/build_environment/cmake/brotli.cmake index 2258804f969..495999a50e2 100644 --- a/build_files/build_environment/cmake/brotli.cmake +++ b/build_files/build_environment/cmake/brotli.cmake @@ -10,27 +10,15 @@ ExternalProject_Add(external_brotli DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${BROTLI_HASH_TYPE}=${BROTLI_HASH} PREFIX ${BUILD_DIR}/brotli - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/brotli - ${DEFAULT_CMAKE_FLAGS} - ${BROTLI_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/brotli ${DEFAULT_CMAKE_FLAGS} ${BROTLI_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/brotli ) if(BUILD_MODE STREQUAL Release AND WIN32) ExternalProject_Add_Step(external_brotli after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/brotli/include - ${HARVEST_TARGET}/brotli/include - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/brotli/lib/brotlidec-static${LIBEXT} - ${HARVEST_TARGET}/brotli/lib/brotlidec-static${LIBEXT} - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/brotli/lib/brotlicommon-static${LIBEXT} - ${HARVEST_TARGET}/brotli/lib/brotlicommon-static${LIBEXT} - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/brotli/include ${HARVEST_TARGET}/brotli/include + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/brotli/lib/brotlidec-static${LIBEXT} ${HARVEST_TARGET}/brotli/lib/brotlidec-static${LIBEXT} + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/brotli/lib/brotlicommon-static${LIBEXT} ${HARVEST_TARGET}/brotli/lib/brotlicommon-static${LIBEXT} DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/bzip2.cmake b/build_files/build_environment/cmake/bzip2.cmake index 75731579db1..f0a8a3c4931 100644 --- a/build_files/build_environment/cmake/bzip2.cmake +++ b/build_files/build_environment/cmake/bzip2.cmake @@ -9,12 +9,8 @@ set(BZIP2_CONFIGURATION_ARGS) if(UNIX AND NOT APPLE) set(BZIP2_LDFLAGS "-Wl,--as-needed") set(BZIP2_CFLAGS "-fPIC -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64") - set(BZIP2_CONFIGURE_ENV - ${BZIP2_CONFIGURE_ENV} && - export LDFLAGS=${BZIP2_LDFLAGS} && - export CFLAGS=${BZIP2_CFLAGS} && - export PREFIX=${BZIP2_PREFIX} - ) + set(BZIP2_CONFIGURE_ENV ${BZIP2_CONFIGURE_ENV} && export LDFLAGS=${BZIP2_LDFLAGS} && export CFLAGS=${BZIP2_CFLAGS} + && export PREFIX=${BZIP2_PREFIX}) else() set(BZIP2_CONFIGURE_ENV ${CONFIGURE_ENV}) endif() @@ -25,14 +21,7 @@ ExternalProject_Add(external_bzip2 URL_HASH ${BZIP2_HASH_TYPE}=${BZIP2_HASH} PREFIX ${BUILD_DIR}/bzip2 CONFIGURE_COMMAND echo . - - BUILD_COMMAND ${BZIP2_CONFIGURE_ENV} && - cd ${BUILD_DIR}/bzip2/src/external_bzip2/ && - make CFLAGS=${BZIP2_CFLAGS} LDFLAGS=${BZIP2_LDFLAGS} -j${MAKE_THREADS} - - INSTALL_COMMAND ${BZIP2_CONFIGURE_ENV} && - cd ${BUILD_DIR}/bzip2/src/external_bzip2/ && - make CFLAGS=${BZIP2_CFLAGS} LDFLAGS=${BZIP2_LDFLAGS} PREFIX=${BZIP2_PREFIX} install - + BUILD_COMMAND ${BZIP2_CONFIGURE_ENV} && cd ${BUILD_DIR}/bzip2/src/external_bzip2/ && make CFLAGS=${BZIP2_CFLAGS} LDFLAGS=${BZIP2_LDFLAGS} -j${MAKE_THREADS} + INSTALL_COMMAND ${BZIP2_CONFIGURE_ENV} && cd ${BUILD_DIR}/bzip2/src/external_bzip2/ && make CFLAGS=${BZIP2_CFLAGS} LDFLAGS=${BZIP2_LDFLAGS} PREFIX=${BZIP2_PREFIX} install INSTALL_DIR ${LIBDIR}/bzip2 ) diff --git a/build_files/build_environment/cmake/deflate.cmake b/build_files/build_environment/cmake/deflate.cmake index 31e7f297f9a..ba08652c523 100644 --- a/build_files/build_environment/cmake/deflate.cmake +++ b/build_files/build_environment/cmake/deflate.cmake @@ -13,11 +13,6 @@ ExternalProject_Add(external_deflate URL_HASH ${DEFLATE_HASH_TYPE}=${DEFLATE_HASH} PREFIX ${BUILD_DIR}/deflate CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/deflate - ${DEFAULT_CMAKE_FLAGS} - ${DEFLATE_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/deflate ${DEFAULT_CMAKE_FLAGS} ${DEFLATE_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/deflate ) diff --git a/build_files/build_environment/cmake/download.cmake b/build_files/build_environment/cmake/download.cmake index d51a2909f48..0b59bee3aef 100644 --- a/build_files/build_environment/cmake/download.cmake +++ b/build_files/build_environment/cmake/download.cmake @@ -3,7 +3,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later ## Update and uncomment this in the release branch -# set(BLENDER_VERSION 3.1) +set(BLENDER_VERSION 4.1) function(download_source dep) set(TARGET_FILE ${${dep}_FILE}) diff --git a/build_files/build_environment/cmake/dpcpp.cmake b/build_files/build_environment/cmake/dpcpp.cmake index 6a2bad8f4d8..a689648cce9 100644 --- a/build_files/build_environment/cmake/dpcpp.cmake +++ b/build_files/build_environment/cmake/dpcpp.cmake @@ -89,23 +89,14 @@ ExternalProject_Add(external_dpcpp CMAKE_GENERATOR ${LLVM_GENERATOR} SOURCE_SUBDIR llvm LIST_SEPARATOR ^^ - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/dpcpp - ${DPCPP_CMAKE_FLAGS} - ${DPCPP_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/dpcpp ${DPCPP_CMAKE_FLAGS} ${DPCPP_EXTRA_ARGS} # CONFIGURE_COMMAND # ${PYTHON_BINARY} # ${BUILD_DIR}/dpcpp/src/external_dpcpp/buildbot/configure.py ${DPCPP_CONFIGURE_ARGS} # BUILD_COMMAND # echo "." # ${PYTHON_BINARY} ${BUILD_DIR}/dpcpp/src/external_dpcpp/buildbot/compile.py INSTALL_COMMAND ${CMAKE_COMMAND} --build . -- deploy-sycl-toolchain - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/dpcpp/src/external_dpcpp < - ${PATCH_DIR}/dpcpp.diff - + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/dpcpp/src/external_dpcpp < ${PATCH_DIR}/dpcpp.diff INSTALL_DIR ${LIBDIR}/dpcpp ) diff --git a/build_files/build_environment/cmake/embree.cmake b/build_files/build_environment/cmake/embree.cmake index 0c503173d05..9f462cbe3d3 100644 --- a/build_files/build_environment/cmake/embree.cmake +++ b/build_files/build_environment/cmake/embree.cmake @@ -86,16 +86,8 @@ ExternalProject_Add(external_embree URL_HASH ${EMBREE_HASH_TYPE}=${EMBREE_HASH} CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} PREFIX ${BUILD_DIR}/embree - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/embree/src/external_embree < - ${PATCH_DIR}/embree.diff - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/embree - ${EMBREE_CMAKE_FLAGS} - ${EMBREE_EXTRA_ARGS} - + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/embree/src/external_embree < ${PATCH_DIR}/embree.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/embree ${EMBREE_CMAKE_FLAGS} ${EMBREE_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/embree ) @@ -115,33 +107,17 @@ endif() if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_embree after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/embree/include - ${HARVEST_TARGET}/embree/include - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/embree/lib - ${HARVEST_TARGET}/embree/lib - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/embree/share - ${HARVEST_TARGET}/embree/share - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/embree/bin/embree4.dll - ${HARVEST_TARGET}/embree/bin/embree4.dll - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/embree/include ${HARVEST_TARGET}/embree/include + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/embree/lib ${HARVEST_TARGET}/embree/lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/embree/share ${HARVEST_TARGET}/embree/share + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/embree/bin/embree4.dll ${HARVEST_TARGET}/embree/bin/embree4.dll DEPENDEES install ) else() ExternalProject_Add_Step(external_embree after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/embree/bin/embree4_d.dll - ${HARVEST_TARGET}/embree/bin/embree4_d.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/embree/lib/embree4_d.lib - ${HARVEST_TARGET}/embree/lib/embree4_d.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/embree/lib/embree4_sycl_d.lib - ${HARVEST_TARGET}/embree/lib/embree4_sycl_d.lib - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/embree/bin/embree4_d.dll ${HARVEST_TARGET}/embree/bin/embree4_d.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/embree/lib/embree4_d.lib ${HARVEST_TARGET}/embree/lib/embree4_d.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/embree/lib/embree4_sycl_d.lib ${HARVEST_TARGET}/embree/lib/embree4_sycl_d.lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/epoxy.cmake b/build_files/build_environment/cmake/epoxy.cmake index f11b07bd626..cac688d6d5e 100644 --- a/build_files/build_environment/cmake/epoxy.cmake +++ b/build_files/build_environment/cmake/epoxy.cmake @@ -12,35 +12,17 @@ ExternalProject_Add(external_epoxy DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${EPOXY_HASH_TYPE}=${EPOXY_HASH} PREFIX ${BUILD_DIR}/epoxy - - PATCH_COMMAND ${PATCH_CMD} -p 1 -N -d - ${BUILD_DIR}/epoxy/src/external_epoxy/ < - ${PATCH_DIR}/epoxy.diff - - CONFIGURE_COMMAND ${CONFIGURE_ENV} && - ${MESON} setup - --prefix ${LIBDIR}/epoxy - --default-library ${EPOXY_LIB_TYPE} - --libdir lib - ${BUILD_DIR}/epoxy/src/external_epoxy-build - ${BUILD_DIR}/epoxy/src/external_epoxy - -Dtests=false ${MESON_BUILD_TYPE} - + PATCH_COMMAND ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/epoxy/src/external_epoxy/ < ${PATCH_DIR}/epoxy.diff + CONFIGURE_COMMAND ${CONFIGURE_ENV} && ${MESON} setup --prefix ${LIBDIR}/epoxy --default-library ${EPOXY_LIB_TYPE} --libdir lib ${BUILD_DIR}/epoxy/src/external_epoxy-build ${BUILD_DIR}/epoxy/src/external_epoxy -Dtests=false ${MESON_BUILD_TYPE} BUILD_COMMAND ninja INSTALL_COMMAND ninja install ) if(BUILD_MODE STREQUAL Release AND WIN32) ExternalProject_Add_Step(external_epoxy after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/epoxy/include - ${HARVEST_TARGET}/epoxy/include - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/epoxy/bin/epoxy-0.dll - ${HARVEST_TARGET}/epoxy/bin/epoxy-0.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/epoxy/lib/epoxy.lib - ${HARVEST_TARGET}/epoxy/lib/epoxy.lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/epoxy/include ${HARVEST_TARGET}/epoxy/include + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/epoxy/bin/epoxy-0.dll ${HARVEST_TARGET}/epoxy/bin/epoxy-0.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/epoxy/lib/epoxy.lib ${HARVEST_TARGET}/epoxy/lib/epoxy.lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/expat.cmake b/build_files/build_environment/cmake/expat.cmake index a8ba72828c6..da3f76ceaa8 100644 --- a/build_files/build_environment/cmake/expat.cmake +++ b/build_files/build_environment/cmake/expat.cmake @@ -15,12 +15,7 @@ ExternalProject_Add(external_expat DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${EXPAT_HASH_TYPE}=${EXPAT_HASH} PREFIX ${BUILD_DIR}/expat - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/expat - ${DEFAULT_CMAKE_FLAGS} - ${EXPAT_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/expat ${DEFAULT_CMAKE_FLAGS} ${EXPAT_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/expat SOURCE_SUBDIR expat ) diff --git a/build_files/build_environment/cmake/ffi.cmake b/build_files/build_environment/cmake/ffi.cmake index aac186af961..89deb00eb50 100644 --- a/build_files/build_environment/cmake/ffi.cmake +++ b/build_files/build_environment/cmake/ffi.cmake @@ -7,36 +7,20 @@ ExternalProject_Add(external_ffi URL_HASH ${FFI_HASH_TYPE}=${FFI_HASH} DOWNLOAD_DIR ${DOWNLOAD_DIR} PREFIX ${BUILD_DIR}/ffi - - CONFIGURE_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/ffi/src/external_ffi/ && - ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/ffi - --enable-shared=no - --enable-static=yes - --with-pic - --libdir=${LIBDIR}/ffi/lib/ - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/ffi/src/external_ffi/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/ffi/src/external_ffi/ && - make install - - PATCH_COMMAND ${PATCH_CMD} -p 0 -d - ${BUILD_DIR}/ffi/src/external_ffi < - ${PATCH_DIR}/ffi.diff - + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ffi/src/external_ffi/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/ffi + --enable-shared=no + --enable-static=yes + --with-pic + --libdir=${LIBDIR}/ffi/lib/ + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ffi/src/external_ffi/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ffi/src/external_ffi/ && make install + PATCH_COMMAND ${PATCH_CMD} -p 0 -d ${BUILD_DIR}/ffi/src/external_ffi < ${PATCH_DIR}/ffi.diff INSTALL_DIR ${LIBDIR}/ffi ) if(UNIX AND NOT APPLE) ExternalProject_Add_Step(external_ffi after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/ffi/lib/libffi.a - ${LIBDIR}/ffi/lib/libffi_pic.a - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/ffi/lib/libffi.a ${LIBDIR}/ffi/lib/libffi_pic.a DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/ffmpeg.cmake b/build_files/build_environment/cmake/ffmpeg.cmake index e7785c44ed2..61c6057ec56 100644 --- a/build_files/build_environment/cmake/ffmpeg.cmake +++ b/build_files/build_environment/cmake/ffmpeg.cmake @@ -149,76 +149,61 @@ ExternalProject_Add(external_ffmpeg URL file://${PACKAGE_DIR}/${FFMPEG_FILE} DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${FFMPEG_HASH_TYPE}=${FFMPEG_HASH} - - PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d - ${BUILD_DIR}/ffmpeg/src/external_ffmpeg < - ${FFMPEG_PATCH_FILE} - + PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/ffmpeg/src/external_ffmpeg < ${FFMPEG_PATCH_FILE} PREFIX ${BUILD_DIR}/ffmpeg - CONFIGURE_COMMAND ${FFMPEG_CONFIGURE_COMMAND} && cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && ${FFMPEG_ENV} ${CONFIGURE_COMMAND_NO_TARGET} ${FFMPEG_EXTRA_FLAGS} - --disable-lzma - --disable-avfilter - --disable-vdpau - --disable-bzlib - --disable-libgsm - --disable-libspeex - --enable-libvpx - --enable-libopus - --prefix=${LIBDIR}/ffmpeg - --enable-libtheora - --enable-libvorbis - --enable-zlib - --enable-stripping - --enable-runtime-cpudetect - --disable-vaapi - --disable-nonfree - --enable-gpl - --disable-postproc - --enable-libmp3lame - --disable-librtmp - --enable-libx264 - --enable-libaom - --disable-libopencore-amrnb - --disable-libopencore-amrwb - --disable-libdc1394 - --disable-version3 - --disable-debug - --enable-optimizations - --enable-ffplay - --disable-openssl - --disable-securetransport - --disable-indev=avfoundation - --disable-indev=qtkit - --disable-sdl2 - --disable-gnutls - --disable-videotoolbox - --disable-libxcb - --disable-xlib - --disable-audiotoolbox - --disable-cuvid - --disable-nvenc - --disable-indev=jack - --disable-indev=alsa - --disable-outdev=alsa - --disable-crystalhd - --disable-sndio - --disable-doc - - BUILD_COMMAND ${FFMPEG_CONFIGURE_COMMAND} && - cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${FFMPEG_CONFIGURE_COMMAND} && - cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && - make install - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ffmpeg - ${DEFAULT_CMAKE_FLAGS} - + --disable-lzma + --disable-avfilter + --disable-vdpau + --disable-bzlib + --disable-libgsm + --disable-libspeex + --enable-libvpx + --enable-libopus + --prefix=${LIBDIR}/ffmpeg + --enable-libtheora + --enable-libvorbis + --enable-zlib + --enable-stripping + --enable-runtime-cpudetect + --disable-vaapi + --disable-nonfree + --enable-gpl + --disable-postproc + --enable-libmp3lame + --disable-librtmp + --enable-libx264 + --enable-libaom + --disable-libopencore-amrnb + --disable-libopencore-amrwb + --disable-libdc1394 + --disable-version3 + --disable-debug + --enable-optimizations + --enable-ffplay + --disable-openssl + --disable-securetransport + --disable-indev=avfoundation + --disable-indev=qtkit + --disable-sdl2 + --disable-gnutls + --disable-videotoolbox + --disable-libxcb + --disable-xlib + --disable-audiotoolbox + --disable-cuvid + --disable-nvenc + --disable-indev=jack + --disable-indev=alsa + --disable-outdev=alsa + --disable-crystalhd + --disable-sndio + --disable-doc + BUILD_COMMAND ${FFMPEG_CONFIGURE_COMMAND} && cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${FFMPEG_CONFIGURE_COMMAND} && cd ${BUILD_DIR}/ffmpeg/src/external_ffmpeg/ && make install + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ffmpeg ${DEFAULT_CMAKE_FLAGS} INSTALL_DIR ${LIBDIR}/ffmpeg ) @@ -257,13 +242,8 @@ endif() if(BUILD_MODE STREQUAL Release AND WIN32) ExternalProject_Add_Step(external_ffmpeg after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/ffmpeg/include - ${HARVEST_TARGET}/ffmpeg/include - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/ffmpeg/bin - ${HARVEST_TARGET}/ffmpeg/lib - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/ffmpeg/include ${HARVEST_TARGET}/ffmpeg/include + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/ffmpeg/bin ${HARVEST_TARGET}/ffmpeg/lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/fftw.cmake b/build_files/build_environment/cmake/fftw.cmake index 426c4bd5096..e495c176ff0 100644 --- a/build_files/build_environment/cmake/fftw.cmake +++ b/build_files/build_environment/cmake/fftw.cmake @@ -15,11 +15,7 @@ macro(fftw_build FFTW_POSTFIX) DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${FFTW_HASH_TYPE}=${FFTW_HASH} PREFIX ${BUILD_DIR}/fftw3 - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/fftw3 - ${FFTW_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/fftw3 ${FFTW_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/fftw3 ) else() @@ -30,19 +26,9 @@ macro(fftw_build FFTW_POSTFIX) DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${FFTW_HASH_TYPE}=${FFTW_HASH} PREFIX ${BUILD_DIR}/fftw3 - - CONFIGURE_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/fftw3/src/external_fftw3_${FFTW_POSTFIX}/ && - ${CONFIGURE_COMMAND} ${FFTW_EXTRA_ARGS} ${ARGN} --prefix=${mingw_LIBDIR}/fftw3 - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/fftw3/src/external_fftw3_${FFTW_POSTFIX}/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/fftw3/src/external_fftw3_${FFTW_POSTFIX}/ && - make ${FFTW_INSTALL} - + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3_${FFTW_POSTFIX}/ && ${CONFIGURE_COMMAND} ${FFTW_EXTRA_ARGS} ${ARGN} --prefix=${mingw_LIBDIR}/fftw3 + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3_${FFTW_POSTFIX}/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/fftw3/src/external_fftw3_${FFTW_POSTFIX}/ && make ${FFTW_INSTALL} INSTALL_DIR ${LIBDIR}/fftw3 ) endif() @@ -54,24 +40,14 @@ fftw_build(float --enable-float) if(MSVC) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_fftw3_double after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/fftw3/lib/fftw3.lib - ${HARVEST_TARGET}/fftw3/lib/fftw3.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/fftw3/bin/fftw3.dll - ${HARVEST_TARGET}/fftw3/lib/fftw3.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/fftw3/include/fftw3.h - ${HARVEST_TARGET}/fftw3/include/fftw3.h + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/lib/fftw3.lib ${HARVEST_TARGET}/fftw3/lib/fftw3.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/bin/fftw3.dll ${HARVEST_TARGET}/fftw3/lib/fftw3.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/include/fftw3.h ${HARVEST_TARGET}/fftw3/include/fftw3.h DEPENDEES install ) ExternalProject_Add_Step(external_fftw3_float after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/fftw3/lib/fftw3f.lib - ${HARVEST_TARGET}/fftw3/lib/fftw3f.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/fftw3/bin/fftw3f.dll - ${HARVEST_TARGET}/fftw3/lib/fftw3f.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/lib/fftw3f.lib ${HARVEST_TARGET}/fftw3/lib/fftw3f.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fftw3/bin/fftw3f.dll ${HARVEST_TARGET}/fftw3/lib/fftw3f.dll DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/flac.cmake b/build_files/build_environment/cmake/flac.cmake index fb50a6cd119..13c2064f5f8 100644 --- a/build_files/build_environment/cmake/flac.cmake +++ b/build_files/build_environment/cmake/flac.cmake @@ -8,19 +8,9 @@ if(NOT WIN32) DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${FLAC_HASH_TYPE}=${FLAC_HASH} PREFIX ${BUILD_DIR}/flac - - CONFIGURE_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/flac/src/external_flac/ && - ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/flac --disable-shared --enable-static - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/flac/src/external_flac/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/flac/src/external_flac/ && - make install - + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/flac/src/external_flac/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/flac --disable-shared --enable-static + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/flac/src/external_flac/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/flac/src/external_flac/ && make install INSTALL_DIR ${LIBDIR}/flac ) else() @@ -44,12 +34,7 @@ else() URL_HASH ${FLAC_HASH_TYPE}=${FLAC_HASH} PREFIX ${BUILD_DIR}/flac CMAKE_GENERATOR "Ninja" - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/flac - ${DEFAULT_CMAKE_FLAGS} - ${FLAC_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/flac ${DEFAULT_CMAKE_FLAGS} ${FLAC_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/flac ) endif() diff --git a/build_files/build_environment/cmake/flex.cmake b/build_files/build_environment/cmake/flex.cmake index 626689d7d74..edea6144305 100644 --- a/build_files/build_environment/cmake/flex.cmake +++ b/build_files/build_environment/cmake/flex.cmake @@ -15,19 +15,9 @@ ExternalProject_Add(external_flex URL_HASH ${FLEX_HASH_TYPE}=${FLEX_HASH} DOWNLOAD_DIR ${DOWNLOAD_DIR} PREFIX ${BUILD_DIR}/flex - - CONFIGURE_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/flex/src/external_flex/ && - ${_autoconf_cmd_optional} ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/flex - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/flex/src/external_flex/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/flex/src/external_flex/ && - make install - + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/flex/src/external_flex/ && ${_autoconf_cmd_optional} ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/flex + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/flex/src/external_flex/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/flex/src/external_flex/ && make install INSTALL_DIR ${LIBDIR}/flex ) diff --git a/build_files/build_environment/cmake/flexbison.cmake b/build_files/build_environment/cmake/flexbison.cmake index 94c2e155135..5deac8ffa35 100644 --- a/build_files/build_environment/cmake/flexbison.cmake +++ b/build_files/build_environment/cmake/flexbison.cmake @@ -9,19 +9,9 @@ ExternalProject_Add(external_flexbison DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${FLEXBISON_HASH_TYPE}=${FLEXBISON_HASH} PREFIX ${BUILD_DIR}/flexbison - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/flexbison - ${DEFAULT_CMAKE_FLAGS} - ${FLEXBISON_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/flexbison ${DEFAULT_CMAKE_FLAGS} ${FLEXBISON_EXTRA_ARGS} CONFIGURE_COMMAND echo . BUILD_COMMAND echo . - - INSTALL_COMMAND - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${BUILD_DIR}/flexbison/src/external_flexbison/ - ${LIBDIR}/flexbison/ - + INSTALL_COMMAND COMMAND ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/flexbison/src/external_flexbison/ ${LIBDIR}/flexbison/ INSTALL_DIR ${LIBDIR}/flexbison ) diff --git a/build_files/build_environment/cmake/fmt.cmake b/build_files/build_environment/cmake/fmt.cmake index 79ef187e895..8e2ad18a6c9 100644 --- a/build_files/build_environment/cmake/fmt.cmake +++ b/build_files/build_environment/cmake/fmt.cmake @@ -12,11 +12,6 @@ ExternalProject_Add(external_fmt DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${FMT_HASH_TYPE}=${FMT_HASH} PREFIX ${BUILD_DIR}/fmt - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/fmt - ${DEFAULT_CMAKE_FLAGS} - ${FMT_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/fmt ${DEFAULT_CMAKE_FLAGS} ${FMT_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/fmt ) diff --git a/build_files/build_environment/cmake/freetype.cmake b/build_files/build_environment/cmake/freetype.cmake index 1dcc3c11631..37878ea0b17 100644 --- a/build_files/build_environment/cmake/freetype.cmake +++ b/build_files/build_environment/cmake/freetype.cmake @@ -21,12 +21,7 @@ ExternalProject_Add(external_freetype DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${FREETYPE_HASH_TYPE}=${FREETYPE_HASH} PREFIX ${BUILD_DIR}/freetype - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/freetype - ${DEFAULT_CMAKE_FLAGS} - ${FREETYPE_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/freetype ${DEFAULT_CMAKE_FLAGS} ${FREETYPE_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/freetype ) @@ -38,15 +33,10 @@ add_dependencies( if(BUILD_MODE STREQUAL Release AND WIN32) ExternalProject_Add_Step(external_freetype after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/freetype - ${HARVEST_TARGET}/freetype - - # `harfbuzz` *NEEDS* to find `freetype.lib` and will not be convinced to take - # alternative names so just give it what it wants. - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/freetype/lib/freetype2st.lib - ${LIBDIR}/freetype/lib/freetype.lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/freetype ${HARVEST_TARGET}/freetype + # harfbuzz *NEEDS* to find freetype.lib and will not be conviced to take alternative names so just give it + # what it wants. + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/freetype/lib/freetype2st.lib ${LIBDIR}/freetype/lib/freetype.lib DEPENDEES install ) diff --git a/build_files/build_environment/cmake/fribidi.cmake b/build_files/build_environment/cmake/fribidi.cmake index e2adb7bae0d..e01497693fd 100644 --- a/build_files/build_environment/cmake/fribidi.cmake +++ b/build_files/build_environment/cmake/fribidi.cmake @@ -11,17 +11,7 @@ ExternalProject_Add(external_fribidi URL_HASH ${FRIBIDI_HASH_TYPE}=${FRIBIDI_HASH} DOWNLOAD_DIR ${DOWNLOAD_DIR} PREFIX ${BUILD_DIR}/fribidi - - CONFIGURE_COMMAND - ${MESON} setup - --prefix ${LIBDIR}/fribidi - ${MESON_BUILD_TYPE} - -Ddocs=false - --default-library static - --libdir lib - ${BUILD_DIR}/fribidi/src/external_fribidi-build - ${BUILD_DIR}/fribidi/src/external_fribidi - + CONFIGURE_COMMAND ${MESON} setup --prefix ${LIBDIR}/fribidi ${MESON_BUILD_TYPE} -Ddocs=false --default-library static --libdir lib ${BUILD_DIR}/fribidi/src/external_fribidi-build ${BUILD_DIR}/fribidi/src/external_fribidi BUILD_COMMAND ninja INSTALL_COMMAND ninja install INSTALL_DIR ${LIBDIR}/fribidi @@ -36,13 +26,8 @@ add_dependencies( if(BUILD_MODE STREQUAL Release AND WIN32) ExternalProject_Add_Step(external_fribidi after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/fribidi/include - ${HARVEST_TARGET}/fribidi/include - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/fribidi/lib/libfribidi.a - ${HARVEST_TARGET}/fribidi/lib/libfribidi.lib - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/fribidi/include ${HARVEST_TARGET}/fribidi/include + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/fribidi/lib/libfribidi.a ${HARVEST_TARGET}/fribidi/lib/libfribidi.lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/gmmlib.cmake b/build_files/build_environment/cmake/gmmlib.cmake index fbb7d153c98..2ba7d26bd22 100644 --- a/build_files/build_environment/cmake/gmmlib.cmake +++ b/build_files/build_environment/cmake/gmmlib.cmake @@ -10,11 +10,6 @@ ExternalProject_Add(external_gmmlib URL_HASH ${GMMLIB_HASH_TYPE}=${GMMLIB_HASH} DOWNLOAD_DIR ${DOWNLOAD_DIR} PREFIX ${BUILD_DIR}/gmmlib - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/gmmlib - ${DEFAULT_CMAKE_FLAGS} - ${GMMLIB_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/gmmlib ${DEFAULT_CMAKE_FLAGS} ${GMMLIB_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/gmmlib ) diff --git a/build_files/build_environment/cmake/gmp.cmake b/build_files/build_environment/cmake/gmp.cmake index 04fbbb1b06b..0a2ad0b517b 100644 --- a/build_files/build_environment/cmake/gmp.cmake +++ b/build_files/build_environment/cmake/gmp.cmake @@ -12,42 +12,14 @@ if(WIN32) set(GMP_CC_CXX "${compilescript_path} cl") set(GMP_NM "dumpbin.exe -symbols -headers") - set(GMP_CONFIGURE_ENV - set AR=${arlib_joint_path} && - set NM=${GMP_NM} && - ${CONFIGURE_ENV_NO_PERL} && - set CC=${GMP_CC_CXX} && - set CXX=${GMP_CC_CXX} && - set CFLAGS=${GMP_CFLAGS} && - set AS=: - ) + set(GMP_CONFIGURE_ENV set AR=${arlib_joint_path} && set NM=${GMP_NM} && ${CONFIGURE_ENV_NO_PERL} && set CC=${GMP_CC_CXX} && set CXX=${GMP_CC_CXX} && set CFLAGS=${GMP_CFLAGS} && set AS=:) - set(GMP_OPTIONS - --disable-static - --enable-shared - --enable-cxx - --verbose - gmp_cv_check_libm_for_build=no - ac_cv_prog_LEX=: - ac_cv_prog_YACC=: - ac_cv_prog_ac_ct_STRIP=: - ac_cv_prog_RANLIB=: - ) + set(GMP_OPTIONS --disable-static --enable-shared --enable-cxx --verbose gmp_cv_check_libm_for_build=no ac_cv_prog_LEX=: ac_cv_prog_YACC=: ac_cv_prog_ac_ct_STRIP=: ac_cv_prog_RANLIB=:) if(BLENDER_PLATFORM_ARM) - set(GMP_OPTIONS - ${GMP_OPTIONS} - --enable-assembly=no - --build=aarch64-pc-mingw32 - ) + set(GMP_OPTIONS ${GMP_OPTIONS} --enable-assembly=no --build=aarch64-pc-mingw32) else() - set(GMP_OPTIONS - ${GMP_OPTIONS} - --enable-assembly=no - --build=x86_64-pc-mingw32 - ac_cv_func_memset=yes - gmp_cv_asm_w32=.word - ) + set(GMP_OPTIONS ${GMP_OPTIONS} --enable-assembly=no --build=x86_64-pc-mingw32 ac_cv_func_memset=yes gmp_cv_asm_w32=.word) endif() else() set(GMP_CONFIGURE_ENV ${CONFIGURE_ENV_NO_PERL}) @@ -80,39 +52,18 @@ ExternalProject_Add(external_gmp DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${GMP_HASH_TYPE}=${GMP_HASH} PREFIX ${BUILD_DIR}/gmp - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/gmp/src/external_gmp < - ${PATCH_DIR}/gmp.diff - - CONFIGURE_COMMAND ${GMP_CONFIGURE_ENV} && - cd ${BUILD_DIR}/gmp/src/external_gmp/ && - ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/gmp ${GMP_OPTIONS} ${GMP_EXTRA_ARGS} - - BUILD_COMMAND ${CONFIGURE_ENV_NO_PERL} && - cd ${BUILD_DIR}/gmp/src/external_gmp/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV_NO_PERL} && - cd ${BUILD_DIR}/gmp/src/external_gmp/ && - make install - + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/gmp/src/external_gmp < ${PATCH_DIR}/gmp.diff + CONFIGURE_COMMAND ${GMP_CONFIGURE_ENV} && cd ${BUILD_DIR}/gmp/src/external_gmp/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/gmp ${GMP_OPTIONS} ${GMP_EXTRA_ARGS} + BUILD_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/gmp/src/external_gmp/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV_NO_PERL} && cd ${BUILD_DIR}/gmp/src/external_gmp/ && make install INSTALL_DIR ${LIBDIR}/gmp ) if(BUILD_MODE STREQUAL Release AND WIN32) ExternalProject_Add_Step(external_gmp after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/gmp/bin/gmp-10.dll - ${HARVEST_TARGET}/gmp/lib/gmp-10.dll - - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/gmp/lib/gmp.dll.lib - ${HARVEST_TARGET}/gmp/lib/gmp.dll.lib - - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/gmp/include - ${HARVEST_TARGET}/gmp/include + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/gmp/bin/gmp-10.dll ${HARVEST_TARGET}/gmp/lib/gmp-10.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/gmp/lib/gmp.dll.lib ${HARVEST_TARGET}/gmp/lib/gmp.dll.lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/gmp/include ${HARVEST_TARGET}/gmp/include DEPENDEES install ) @@ -127,22 +78,9 @@ if(WIN32) DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${GMP_HASH_TYPE}=${GMP_HASH} PREFIX ${BUILD_DIR}/gmpxx - - PATCH_COMMAND COMMAND - ${CMAKE_COMMAND} -E copy - ${PATCH_DIR}/cmakelists_gmpxx.txt - ${BUILD_DIR}/gmpxx/src/external_gmpxx/CMakeLists.txt && - ${CMAKE_COMMAND} -E copy - ${PATCH_DIR}/config_gmpxx.h - ${BUILD_DIR}/gmpxx/src/external_gmpxx/config.h - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/gmpxx - ${DEFAULT_CMAKE_FLAGS} - -DGMP_LIBRARY=${BUILD_DIR}/gmp/src/external_gmp/.libs/gmp.dll.lib - -DGMP_INCLUDE_DIR=${BUILD_DIR}/gmp/src/external_gmp - -DCMAKE_DEBUG_POSTFIX=_d - + PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_gmpxx.txt ${BUILD_DIR}/gmpxx/src/external_gmpxx/CMakeLists.txt && + ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/config_gmpxx.h ${BUILD_DIR}/gmpxx/src/external_gmpxx/config.h + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/gmpxx ${DEFAULT_CMAKE_FLAGS} -DGMP_LIBRARY=${BUILD_DIR}/gmp/src/external_gmp/.libs/gmp.dll.lib -DGMP_INCLUDE_DIR=${BUILD_DIR}/gmp/src/external_gmp -DCMAKE_DEBUG_POSTFIX=_d INSTALL_DIR ${LIBDIR}/gmpxx ) @@ -152,10 +90,7 @@ if(WIN32) ) ExternalProject_Add_Step(external_gmpxx after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/gmpxx/ - ${HARVEST_TARGET}/gmp - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/gmpxx/ ${HARVEST_TARGET}/gmp DEPENDEES install ) diff --git a/build_files/build_environment/cmake/harfbuzz.cmake b/build_files/build_environment/cmake/harfbuzz.cmake index ff96b0481ec..c594be67ee2 100644 --- a/build_files/build_environment/cmake/harfbuzz.cmake +++ b/build_files/build_environment/cmake/harfbuzz.cmake @@ -33,12 +33,13 @@ ExternalProject_Add(external_harfbuzz PREFIX ${BUILD_DIR}/harfbuzz CONFIGURE_COMMAND ${HARFBUZZ_CONFIGURE_ENV} && - ${CMAKE_COMMAND} -E env ${HARFBUZZ_PKG_ENV} ${MESON} setup - --prefix ${LIBDIR}/harfbuzz ${HARFBUZZ_EXTRA_OPTIONS} - --default-library static - --libdir lib - ${BUILD_DIR}/harfbuzz/src/external_harfbuzz-build - ${BUILD_DIR}/harfbuzz/src/external_harfbuzz + ${CMAKE_COMMAND} -E env ${HARFBUZZ_PKG_ENV} + ${MESON} setup + --prefix ${LIBDIR}/harfbuzz ${HARFBUZZ_EXTRA_OPTIONS} + --default-library static + --libdir lib + ${BUILD_DIR}/harfbuzz/src/external_harfbuzz-build + ${BUILD_DIR}/harfbuzz/src/external_harfbuzz BUILD_COMMAND ninja INSTALL_COMMAND ninja install @@ -55,22 +56,16 @@ add_dependencies( if(BUILD_MODE STREQUAL Release AND WIN32) ExternalProject_Add_Step(external_harfbuzz after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/harfbuzz/include - ${HARVEST_TARGET}/harfbuzz/include + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/harfbuzz/include ${HARVEST_TARGET}/harfbuzz/include # We do not use the subset API currently, so copying only the main library will suffice for now - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/harfbuzz/lib/libharfbuzz.a - ${HARVEST_TARGET}/harfbuzz/lib/libharfbuzz.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/harfbuzz/lib/libharfbuzz.a ${HARVEST_TARGET}/harfbuzz/lib/libharfbuzz.lib DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug AND WIN32) ExternalProject_Add_Step(external_harfbuzz after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/harfbuzz/lib/libharfbuzz.a - ${HARVEST_TARGET}/harfbuzz/lib/libharfbuzz_d.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/harfbuzz/lib/libharfbuzz.a ${HARVEST_TARGET}/harfbuzz/lib/libharfbuzz_d.lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/haru.cmake b/build_files/build_environment/cmake/haru.cmake index 3da39d3da63..4bee6ba7f3a 100644 --- a/build_files/build_environment/cmake/haru.cmake +++ b/build_files/build_environment/cmake/haru.cmake @@ -14,28 +14,18 @@ ExternalProject_Add(external_haru DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${HARU_HASH_TYPE}=${HARU_HASH} PREFIX ${BUILD_DIR}/haru - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/haru/src/external_haru < - ${PATCH_DIR}/haru.diff - + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/haru/src/external_haru < ${PATCH_DIR}/haru.diff CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=${LIBDIR}/haru ${DEFAULT_CMAKE_FLAGS} ${HARU_EXTRA_ARGS} - INSTALL_DIR ${LIBDIR}/haru ) if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_haru after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/haru/include - ${HARVEST_TARGET}/haru/include - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/haru/lib/libhpdfs.lib - ${HARVEST_TARGET}/haru/lib/libhpdfs.lib - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/haru/include ${HARVEST_TARGET}/haru/include + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/haru/lib/libhpdfs.lib ${HARVEST_TARGET}/haru/lib/libhpdfs.lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake index 1c50d529736..21008a40459 100644 --- a/build_files/build_environment/cmake/harvest.cmake +++ b/build_files/build_environment/cmake/harvest.cmake @@ -16,21 +16,11 @@ if(WIN32) if(BUILD_MODE STREQUAL Release) add_custom_target(Harvest_Release_Results COMMAND # JPEG rename lib-file + copy include. - ${CMAKE_COMMAND} -E copy - ${LIBDIR}/jpeg/lib/jpeg-static.lib - ${HARVEST_TARGET}/jpeg/lib/libjpeg.lib && - ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/jpeg/include/ - ${HARVEST_TARGET}/jpeg/include/ && - + ${CMAKE_COMMAND} -E copy ${LIBDIR}/jpeg/lib/jpeg-static.lib ${HARVEST_TARGET}/jpeg/lib/libjpeg.lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/jpeg/include/ ${HARVEST_TARGET}/jpeg/include/ && # PNG. - ${CMAKE_COMMAND} -E copy - ${LIBDIR}/png/lib/libpng16_static.lib - ${HARVEST_TARGET}/png/lib/libpng.lib && - ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/png/include/ - ${HARVEST_TARGET}/png/include/ && - + ${CMAKE_COMMAND} -E copy ${LIBDIR}/png/lib/libpng16_static.lib ${HARVEST_TARGET}/png/lib/libpng.lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/png/include/ ${HARVEST_TARGET}/png/include/ && DEPENDS ) endif() diff --git a/build_files/build_environment/cmake/iconv.cmake b/build_files/build_environment/cmake/iconv.cmake index d5fc39e4500..9a1b31680b6 100644 --- a/build_files/build_environment/cmake/iconv.cmake +++ b/build_files/build_environment/cmake/iconv.cmake @@ -9,19 +9,9 @@ ExternalProject_Add(external_iconv DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${ICONV_HASH_TYPE}=${ICONV_HASH} PREFIX ${BUILD_DIR}/iconv - - CONFIGURE_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/iconv/src/external_iconv/ && - ${CONFIGURE_COMMAND} --enable-static --prefix=${mingw_LIBDIR}/iconv - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/iconv/src/external_iconv/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/iconv/src/external_iconv/ && - make install - + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/iconv/src/external_iconv/ && ${CONFIGURE_COMMAND} --enable-static --prefix=${mingw_LIBDIR}/iconv + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/iconv/src/external_iconv/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/iconv/src/external_iconv/ && make install INSTALL_DIR ${LIBDIR}/iconv ) @@ -29,12 +19,8 @@ if(MSVC) set_target_properties(external_iconv PROPERTIES FOLDER Mingw) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_iconv after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/iconv/lib/libiconv.a - ${HARVEST_TARGET}/iconv/lib/iconv.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/iconv/include/iconv.h - ${HARVEST_TARGET}/iconv/include/iconv.h + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/iconv/lib/libiconv.a ${HARVEST_TARGET}/iconv/lib/iconv.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/iconv/include/iconv.h ${HARVEST_TARGET}/iconv/include/iconv.h DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/igc.cmake b/build_files/build_environment/cmake/igc.cmake index 86bdabca251..1727f49fd39 100644 --- a/build_files/build_environment/cmake/igc.cmake +++ b/build_files/build_environment/cmake/igc.cmake @@ -21,10 +21,7 @@ ExternalProject_Add(external_igc_opencl_clang CONFIGURE_COMMAND echo . BUILD_COMMAND echo . INSTALL_COMMAND echo . - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/igc_opencl_clang/src/external_igc_opencl_clang/ < - ${PATCH_DIR}/igc_opencl_clang.diff + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/igc_opencl_clang/src/external_igc_opencl_clang/ < ${PATCH_DIR}/igc_opencl_clang.diff ) set(IGC_OPENCL_CLANG_PATCH_DIR ${BUILD_DIR}/igc_opencl_clang/src/external_igc_opencl_clang/patches) @@ -39,26 +36,12 @@ ExternalProject_Add(external_igc_llvm CONFIGURE_COMMAND echo . BUILD_COMMAND echo . INSTALL_COMMAND echo . - - PATCH_COMMAND - ${PATCH_CMD} -p 1 -d - ${IGC_LLVM_SOURCE_DIR} < - ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch && - ${PATCH_CMD} -p 1 -d - ${IGC_LLVM_SOURCE_DIR} < - ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0002-Remove-wrong-check-of-__opencl_c_images-feature-macr.patch && - ${PATCH_CMD} -p 1 -d - ${IGC_LLVM_SOURCE_DIR} < - ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0003-Fix-checking-mechanism-for-read_write-Image-type.patch && - ${PATCH_CMD} -p 1 -d - ${IGC_LLVM_SOURCE_DIR} < - ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0004-OpenCL-Allow-undefining-header-only-macros.patch && - ${PATCH_CMD} -p 1 -d - ${IGC_LLVM_SOURCE_DIR} < - ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0005-Enable-use-of-GNU-C-extension.patch && - ${PATCH_CMD} -p 1 -d - ${IGC_LLVM_SOURCE_DIR} < - ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0006-Make-globals-used-for-array-initialization-codegen-c.patch + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${IGC_LLVM_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0001-Remove-__IMAGE_SUPPORT__-macro-for-SPIR.patch && + ${PATCH_CMD} -p 1 -d ${IGC_LLVM_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0002-Remove-wrong-check-of-__opencl_c_images-feature-macr.patch && + ${PATCH_CMD} -p 1 -d ${IGC_LLVM_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0003-Fix-checking-mechanism-for-read_write-Image-type.patch && + ${PATCH_CMD} -p 1 -d ${IGC_LLVM_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0004-OpenCL-Allow-undefining-header-only-macros.patch && + ${PATCH_CMD} -p 1 -d ${IGC_LLVM_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0005-Enable-use-of-GNU-C-extension.patch && + ${PATCH_CMD} -p 1 -d ${IGC_LLVM_SOURCE_DIR} < ${IGC_OPENCL_CLANG_PATCH_DIR}/clang/0006-Make-globals-used-for-array-initialization-codegen-c.patch ) add_dependencies( external_igc_llvm @@ -103,36 +86,19 @@ ExternalProject_Add(external_igc URL file://${PACKAGE_DIR}/${IGC_FILE} DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${IGC_HASH_TYPE}=${IGC_HASH} - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/igc - ${DEFAULT_CMAKE_FLAGS} - ${IGC_EXTRA_ARGS} + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/igc ${DEFAULT_CMAKE_FLAGS} ${IGC_EXTRA_ARGS} # IGC is pretty set in its way where sub projects ought to live, for some it offers - # hooks to supply alternatives folders, other are just hard-coded with no way to configure + # hooks to supply alternatives folders, other are just hardocded with no way to configure # we symlink everything here, since it's less work than trying to convince the cmake # scripts to accept alternative locations. - PATCH_COMMAND - ${CMAKE_COMMAND} -E create_symlink - ${BUILD_DIR}/igc_llvm/src/external_igc_llvm/ - ${BUILD_DIR}/igc/src/llvm-project && - ${CMAKE_COMMAND} -E create_symlink - ${BUILD_DIR}/igc_opencl_clang/src/external_igc_opencl_clang/ - ${BUILD_DIR}/igc/src/llvm-project/llvm/projects/opencl-clang && - ${CMAKE_COMMAND} -E create_symlink - ${BUILD_DIR}/igc_spirv_translator/src/external_igc_spirv_translator/ - ${BUILD_DIR}/igc/src/llvm-project/llvm/projects/llvm-spirv && - ${CMAKE_COMMAND} -E create_symlink - ${BUILD_DIR}/igc_spirv_tools/src/external_igc_spirv_tools/ - ${BUILD_DIR}/igc/src/SPIRV-Tools && - ${CMAKE_COMMAND} -E create_symlink - ${BUILD_DIR}/igc_spirv_headers/src/external_igc_spirv_headers/ - ${BUILD_DIR}/igc/src/SPIRV-Headers && - ${CMAKE_COMMAND} -E create_symlink - ${BUILD_DIR}/igc_vcintrinsics/src/external_igc_vcintrinsics/ - ${BUILD_DIR}/igc/src/vc-intrinsics - + # + PATCH_COMMAND ${CMAKE_COMMAND} -E create_symlink ${BUILD_DIR}/igc_llvm/src/external_igc_llvm/ ${BUILD_DIR}/igc/src/llvm-project && + ${CMAKE_COMMAND} -E create_symlink ${BUILD_DIR}/igc_opencl_clang/src/external_igc_opencl_clang/ ${BUILD_DIR}/igc/src/llvm-project/llvm/projects/opencl-clang && + ${CMAKE_COMMAND} -E create_symlink ${BUILD_DIR}/igc_spirv_translator/src/external_igc_spirv_translator/ ${BUILD_DIR}/igc/src/llvm-project/llvm/projects/llvm-spirv && + ${CMAKE_COMMAND} -E create_symlink ${BUILD_DIR}/igc_spirv_tools/src/external_igc_spirv_tools/ ${BUILD_DIR}/igc/src/SPIRV-Tools && + ${CMAKE_COMMAND} -E create_symlink ${BUILD_DIR}/igc_spirv_headers/src/external_igc_spirv_headers/ ${BUILD_DIR}/igc/src/SPIRV-Headers && + ${CMAKE_COMMAND} -E create_symlink ${BUILD_DIR}/igc_vcintrinsics/src/external_igc_vcintrinsics/ ${BUILD_DIR}/igc/src/vc-intrinsics PREFIX ${BUILD_DIR}/igc INSTALL_DIR ${LIBDIR}/igc INSTALL_COMMAND ${CMAKE_COMMAND} --install . --strip diff --git a/build_files/build_environment/cmake/imath.cmake b/build_files/build_environment/cmake/imath.cmake index 4eff87a70a8..c9b101216ec 100644 --- a/build_files/build_environment/cmake/imath.cmake +++ b/build_files/build_environment/cmake/imath.cmake @@ -14,31 +14,16 @@ ExternalProject_Add(external_imath URL_HASH ${IMATH_HASH_TYPE}=${IMATH_HASH} PREFIX ${BUILD_DIR}/imath CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/imath - ${DEFAULT_CMAKE_FLAGS} - ${IMATH_EXTRA_ARGS} - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/imath/src/external_imath < - ${PATCH_DIR}/imath_358.diff - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/imath ${DEFAULT_CMAKE_FLAGS} ${IMATH_EXTRA_ARGS} + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/imath/src/external_imath < ${PATCH_DIR}/imath_358.diff INSTALL_DIR ${LIBDIR}/imath ) if(WIN32) ExternalProject_Add_Step(external_imath after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/imath/lib - ${HARVEST_TARGET}/imath/lib - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/imath/include - ${HARVEST_TARGET}/imath/include - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/imath/bin/imath${OPENEXR_VERSION_POSTFIX}.dll - ${HARVEST_TARGET}/imath/bin/imath${OPENEXR_VERSION_POSTFIX}.dll - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/imath/lib ${HARVEST_TARGET}/imath/lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/imath/include ${HARVEST_TARGET}/imath/include + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/imath/bin/imath${OPENEXR_VERSION_POSTFIX}.dll ${HARVEST_TARGET}/imath/bin/imath${OPENEXR_VERSION_POSTFIX}.dll DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/ispc.cmake b/build_files/build_environment/cmake/ispc.cmake index 90c9c860240..450fcf65d99 100644 --- a/build_files/build_environment/cmake/ispc.cmake +++ b/build_files/build_environment/cmake/ispc.cmake @@ -60,18 +60,8 @@ ExternalProject_Add(external_ispc DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${ISPC_HASH_TYPE}=${ISPC_HASH} PREFIX ${BUILD_DIR}/ispc - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/ispc/src/external_ispc < - ${PATCH_DIR}/ispc.diff - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ispc - -Wno-dev - ${DEFAULT_CMAKE_FLAGS} - ${ISPC_EXTRA_ARGS} - ${BUILD_DIR}/ispc/src/external_ispc - + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/ispc/src/external_ispc < ${PATCH_DIR}/ispc.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ispc -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${ISPC_EXTRA_ARGS} ${BUILD_DIR}/ispc/src/external_ispc INSTALL_DIR ${LIBDIR}/ispc ) diff --git a/build_files/build_environment/cmake/jemalloc.cmake b/build_files/build_environment/cmake/jemalloc.cmake index 25a3fade89a..be7b773aba1 100644 --- a/build_files/build_environment/cmake/jemalloc.cmake +++ b/build_files/build_environment/cmake/jemalloc.cmake @@ -7,18 +7,8 @@ ExternalProject_Add(external_jemalloc DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${JEMALLOC_HASH_TYPE}=${JEMALLOC_HASH} PREFIX ${BUILD_DIR}/jemalloc - - CONFIGURE_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/jemalloc/src/external_jemalloc/ && - ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/jemalloc --disable-shared --enable-static --with-pic - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/jemalloc/src/external_jemalloc/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/jemalloc/src/external_jemalloc/ && - make install - + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/jemalloc/src/external_jemalloc/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/jemalloc --disable-shared --enable-static --with-pic + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/jemalloc/src/external_jemalloc/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/jemalloc/src/external_jemalloc/ && make install INSTALL_DIR ${LIBDIR}/jemalloc ) diff --git a/build_files/build_environment/cmake/jpeg.cmake b/build_files/build_environment/cmake/jpeg.cmake index 0ab96fcf8e8..9525938f3c8 100644 --- a/build_files/build_environment/cmake/jpeg.cmake +++ b/build_files/build_environment/cmake/jpeg.cmake @@ -30,10 +30,7 @@ if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_jpeg after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/jpeg/lib/${JPEG_LIBRARY} - ${LIBDIR}/jpeg/lib/jpeg${LIBEXT} - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/jpeg/lib/${JPEG_LIBRARY} ${LIBDIR}/jpeg/lib/jpeg${LIBEXT} DEPENDEES install ) endif() @@ -51,12 +48,7 @@ else() DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${JPEG_HASH_TYPE}=${JPEG_HASH} PREFIX ${BUILD_DIR}/jpeg - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/jpeg - ${DEFAULT_CMAKE_FLAGS} - ${JPEG_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/jpeg ${DEFAULT_CMAKE_FLAGS} ${JPEG_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/jpeg ) diff --git a/build_files/build_environment/cmake/lame.cmake b/build_files/build_environment/cmake/lame.cmake index 5491f0aedf5..cdea7cd6634 100644 --- a/build_files/build_environment/cmake/lame.cmake +++ b/build_files/build_environment/cmake/lame.cmake @@ -5,45 +5,23 @@ set(LAME_EXTRA_ARGS) if(MSVC) set(LAME_ARCH Win64) - set(LAME_CONFIGURE echo .) - set(LAME_BUILD - cd ${BUILD_DIR}/lame/src/external_lame/ && - nmake /F MakeFile.msvc MSVCVER=${LAME_ARCH} all - ) - set(LAME_INSTALL - cd ${BUILD_DIR}/lame/src/external_lame/ && - ${CMAKE_COMMAND} -E copy - include/lame.h - ${LIBDIR}/lame/include/lame/lame.h && - ${CMAKE_COMMAND} -E copy - output/libmp3lame-static.lib - ${LIBDIR}/lame/lib/mp3lame.lib - ) + set (LAME_CONFIGURE echo .) + set (LAME_BUILD cd ${BUILD_DIR}/lame/src/external_lame/ && nmake /F MakeFile.msvc MSVCVER=${LAME_ARCH} all) + set (LAME_INSTALL cd ${BUILD_DIR}/lame/src/external_lame/ && + ${CMAKE_COMMAND} -E copy include/lame.h ${LIBDIR}/lame/include/lame/lame.h && + ${CMAKE_COMMAND} -E copy output/libmp3lame-static.lib ${LIBDIR}/lame/lib/mp3lame.lib ) else() - set(LAME_CONFIGURE - ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/lame/src/external_lame/ && - ${CONFIGURE_COMMAND} - --prefix=${LIBDIR}/lame - --disable-shared - --enable-static - ${LAME_EXTRA_ARGS} - --enable-export=full - --with-fileio=sndfile - --without-vorbis - --with-pic - --disable-mp3x - --disable-mp3rtp - --disable-gtktest - --disable-frontend) - set(LAME_BUILD ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/lame/src/external_lame/ && - make -j${MAKE_THREADS} - ) - set(LAME_INSTALL ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/lame/src/external_lame/ && - make install - ) + set(LAME_CONFIGURE ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lame/src/external_lame/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/lame --disable-shared --enable-static ${LAME_EXTRA_ARGS} + --enable-export=full + --with-fileio=sndfile + --without-vorbis + --with-pic + --disable-mp3x + --disable-mp3rtp + --disable-gtktest + --disable-frontend) + set(LAME_BUILD ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lame/src/external_lame/ && make -j${MAKE_THREADS}) + set(LAME_INSTALL ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lame/src/external_lame/ && make install) endif() ExternalProject_Add(external_lame @@ -51,11 +29,7 @@ ExternalProject_Add(external_lame DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${LAME_HASH_TYPE}=${LAME_HASH} PREFIX ${BUILD_DIR}/lame - - PATCH_COMMAND COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/lame/src/external_lame < - ${PATCH_DIR}/lame.diff - + PATCH_COMMAND COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/lame/src/external_lame < ${PATCH_DIR}/lame.diff CONFIGURE_COMMAND ${LAME_CONFIGURE} BUILD_COMMAND ${LAME_BUILD} INSTALL_COMMAND ${LAME_INSTALL} diff --git a/build_files/build_environment/cmake/level-zero.cmake b/build_files/build_environment/cmake/level-zero.cmake index 1777a761688..5a5f3275bf5 100644 --- a/build_files/build_environment/cmake/level-zero.cmake +++ b/build_files/build_environment/cmake/level-zero.cmake @@ -10,24 +10,14 @@ ExternalProject_Add(external_level-zero DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${LEVEL_ZERO_HASH_TYPE}=${LEVEL_ZERO_HASH} PREFIX ${BUILD_DIR}/level-zero - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/level-zero/src/external_level-zero < - ${PATCH_DIR}/level-zero.diff - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/level-zero - ${DEFAULT_CMAKE_FLAGS} - ${LEVEL_ZERO_EXTRA_ARGS} - + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/level-zero/src/external_level-zero < ${PATCH_DIR}/level-zero.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/level-zero ${DEFAULT_CMAKE_FLAGS} ${LEVEL_ZERO_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/level-zero ) if(BUILD_MODE STREQUAL Release AND WIN32) ExternalProject_Add_Step(external_level-zero after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/level-zero - ${HARVEST_TARGET}/level-zero + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/level-zero ${HARVEST_TARGET}/level-zero DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/libglu.cmake b/build_files/build_environment/cmake/libglu.cmake index e804f0e10e0..ffd493b5f0f 100644 --- a/build_files/build_environment/cmake/libglu.cmake +++ b/build_files/build_environment/cmake/libglu.cmake @@ -17,18 +17,10 @@ ExternalProject_Add(external_libglu DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${LIBGLU_HASH_TYPE}=${LIBGLU_HASH} PREFIX ${BUILD_DIR}/libglu - CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/libglu/src/external_libglu/ && ${CONFIGURE_COMMAND_NO_TARGET} --prefix=${LIBDIR}/libglu ${LIBGLU_EXTRA_FLAGS} - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/libglu/src/external_libglu/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/libglu/src/external_libglu/ && - make install - + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/libglu/src/external_libglu/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/libglu/src/external_libglu/ && make install INSTALL_DIR ${LIBDIR}/libglu ) diff --git a/build_files/build_environment/cmake/llvm.cmake b/build_files/build_environment/cmake/llvm.cmake index c27a5f37c88..c400ec46d77 100644 --- a/build_files/build_environment/cmake/llvm.cmake +++ b/build_files/build_environment/cmake/llvm.cmake @@ -58,40 +58,22 @@ ExternalProject_Add(ll LIST_SEPARATOR ^^ PREFIX ${BUILD_DIR}/ll SOURCE_SUBDIR llvm - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/ll/src/ll < - ${PATCH_DIR}/llvm.diff - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/llvm - ${LLVM_CMAKE_FLAGS} - ${LLVM_EXTRA_ARGS} - + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/ll/src/ll < ${PATCH_DIR}/llvm.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/llvm ${LLVM_CMAKE_FLAGS} ${LLVM_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/llvm ) if(MSVC) if(BUILD_MODE STREQUAL Release) set(LLVM_HARVEST_COMMAND - ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/llvm/lib - ${HARVEST_TARGET}/llvm/lib && - ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/llvm/include - ${HARVEST_TARGET}/llvm/include && - ${CMAKE_COMMAND} -E copy - ${LIBDIR}/llvm/bin/clang-format.exe - ${HARVEST_TARGET}/llvm/bin/clang-format.exe + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/lib ${HARVEST_TARGET}/llvm/lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/include ${HARVEST_TARGET}/llvm/include && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/llvm/bin/clang-format.exe ${HARVEST_TARGET}/llvm/bin/clang-format.exe ) else() set(LLVM_HARVEST_COMMAND - ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/llvm/lib/ - ${HARVEST_TARGET}/llvm/debug/lib/ && - ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/llvm/include/ - ${HARVEST_TARGET}/llvm/debug/include/ + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/lib/ ${HARVEST_TARGET}/llvm/debug/lib/ && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/llvm/include/ ${HARVEST_TARGET}/llvm/debug/include/ ) endif() ExternalProject_Add_Step(ll after_install diff --git a/build_files/build_environment/cmake/lzma.cmake b/build_files/build_environment/cmake/lzma.cmake index 057d13343f7..2934e471c69 100644 --- a/build_files/build_environment/cmake/lzma.cmake +++ b/build_files/build_environment/cmake/lzma.cmake @@ -10,18 +10,9 @@ ExternalProject_Add(external_lzma URL_HASH ${LZMA_HASH_TYPE}=${LZMA_HASH} PREFIX ${BUILD_DIR}/lzma PATCH_COMMAND ${LZMA_PATCH_CMD} - - CONFIGURE_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/lzma/src/external_lzma/ && - ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/lzma --disable-shared - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/lzma/src/external_lzma/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/lzma/src/external_lzma/ && - make install - + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lzma/src/external_lzma/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/lzma + --disable-shared + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lzma/src/external_lzma/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/lzma/src/external_lzma/ && make install INSTALL_DIR ${LIBDIR}/lzma ) diff --git a/build_files/build_environment/cmake/materialx.cmake b/build_files/build_environment/cmake/materialx.cmake index b8aa1947885..f0c3f6d8af8 100644 --- a/build_files/build_environment/cmake/materialx.cmake +++ b/build_files/build_environment/cmake/materialx.cmake @@ -27,12 +27,7 @@ ExternalProject_Add(external_materialx URL_HASH ${MATERIALX_HASH_TYPE}=${MATERIALX_HASH} PREFIX ${BUILD_DIR}/materialx CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/materialx - ${DEFAULT_CMAKE_FLAGS} - ${MATERIALX_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/materialx ${DEFAULT_CMAKE_FLAGS} ${MATERIALX_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/materialx ) @@ -41,39 +36,21 @@ if(WIN32) string(REPLACE "/" "\\" MATERIALX_PYTHON_TARGET_DOS "${MATERIALX_PYTHON_TARGET}") if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_materialx after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/materialx/include - ${HARVEST_TARGET}/materialx/include - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/materialx/libraries - ${HARVEST_TARGET}/materialx/libraries - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/materialx/lib/ - ${HARVEST_TARGET}/materialx/lib/ - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/materialx/bin/ - ${HARVEST_TARGET}/materialx/bin/ - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/materialx/python/ - ${MATERIALX_PYTHON_TARGET} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/materialx/include ${HARVEST_TARGET}/materialx/include + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/materialx/libraries ${HARVEST_TARGET}/materialx/libraries + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/materialx/lib/ ${HARVEST_TARGET}/materialx/lib/ + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/materialx/bin/ ${HARVEST_TARGET}/materialx/bin/ + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/materialx/python/ ${MATERIALX_PYTHON_TARGET} COMMAND del ${MATERIALX_PYTHON_TARGET_DOS}\\MaterialX\\*.lib - DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_materialx after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/materialx/lib/ - ${HARVEST_TARGET}/materialx/lib/ - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/materialx/bin/ - ${HARVEST_TARGET}/materialx/bin/ - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/materialx/python/ - ${MATERIALX_PYTHON_TARGET} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/materialx/lib/ ${HARVEST_TARGET}/materialx/lib/ + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/materialx/bin/ ${HARVEST_TARGET}/materialx/bin/ + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/materialx/python/ ${MATERIALX_PYTHON_TARGET} COMMAND del ${MATERIALX_PYTHON_TARGET_DOS}\\MaterialX\\*.lib - DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/mesa.cmake b/build_files/build_environment/cmake/mesa.cmake index 2473867af69..d7533e3c598 100644 --- a/build_files/build_environment/cmake/mesa.cmake +++ b/build_files/build_environment/cmake/mesa.cmake @@ -45,22 +45,11 @@ ExternalProject_Add(external_mesa DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${MESA_HASH_TYPE}=${MESA_HASH} PREFIX ${BUILD_DIR}/mesa - CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/mesa/src/external_mesa/ && - ${MESON} - ${BUILD_DIR}/mesa/src/external_mesa-build - --prefix=${LIBDIR}/mesa - ${MESA_EXTRA_FLAGS} - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/mesa/src/external_mesa-build && - ninja -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/mesa/src/external_mesa-build && - ninja install - + ${MESON} ${BUILD_DIR}/mesa/src/external_mesa-build --prefix=${LIBDIR}/mesa ${MESA_EXTRA_FLAGS} + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/mesa/src/external_mesa-build && ninja -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/mesa/src/external_mesa-build && ninja install INSTALL_DIR ${LIBDIR}/mesa ) diff --git a/build_files/build_environment/cmake/minizipng.cmake b/build_files/build_environment/cmake/minizipng.cmake index 48c6b415ce3..f9116eef7e4 100644 --- a/build_files/build_environment/cmake/minizipng.cmake +++ b/build_files/build_environment/cmake/minizipng.cmake @@ -28,12 +28,7 @@ ExternalProject_Add(external_minizipng URL_HASH ${MINIZIPNG_HASH_TYPE}=${MINIZIPNG_HASH} PREFIX ${BUILD_DIR}/minizipng CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/minizipng - ${DEFAULT_CMAKE_FLAGS} - ${MINIZIPNG_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/minizipng ${DEFAULT_CMAKE_FLAGS} ${MINIZIPNG_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/minizipng ) diff --git a/build_files/build_environment/cmake/nasm.cmake b/build_files/build_environment/cmake/nasm.cmake index 5004f9c0c13..2a04a6aa84c 100644 --- a/build_files/build_environment/cmake/nasm.cmake +++ b/build_files/build_environment/cmake/nasm.cmake @@ -7,25 +7,10 @@ ExternalProject_Add(external_nasm DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${NASM_HASH_TYPE}=${NASM_HASH} PREFIX ${BUILD_DIR}/nasm - - PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d - ${BUILD_DIR}/nasm/src/external_nasm < - ${PATCH_DIR}/nasm.diff - - CONFIGURE_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/nasm/src/external_nasm/ && - ./autogen.sh && - ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/nasm - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/nasm/src/external_nasm/ && - make -j${MAKE_THREADS} && - make manpages - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/nasm/src/external_nasm/ && - make install - + PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/nasm/src/external_nasm < ${PATCH_DIR}/nasm.diff + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && ./autogen.sh && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/nasm + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && make -j${MAKE_THREADS} && make manpages + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/nasm/src/external_nasm/ && make install INSTALL_DIR ${LIBDIR}/nasm ) diff --git a/build_files/build_environment/cmake/numpy.cmake b/build_files/build_environment/cmake/numpy.cmake index 11f11de8470..94e1578ad5f 100644 --- a/build_files/build_environment/cmake/numpy.cmake +++ b/build_files/build_environment/cmake/numpy.cmake @@ -25,13 +25,7 @@ ExternalProject_Add(external_numpy PATCH_COMMAND ${NUMPY_PATCH} CONFIGURE_COMMAND "" LOG_BUILD 1 - - BUILD_COMMAND - ${PYTHON_BINARY} ${BUILD_DIR}/numpy/src/external_numpy/setup.py - build ${NUMPY_BUILD_OPTION} - install - --old-and-unmanageable - + BUILD_COMMAND ${PYTHON_BINARY} ${BUILD_DIR}/numpy/src/external_numpy/setup.py build ${NUMPY_BUILD_OPTION} install --old-and-unmanageable INSTALL_COMMAND "" ) diff --git a/build_files/build_environment/cmake/ocloc.cmake b/build_files/build_environment/cmake/ocloc.cmake index 231fddf9382..2d55c133e80 100644 --- a/build_files/build_environment/cmake/ocloc.cmake +++ b/build_files/build_environment/cmake/ocloc.cmake @@ -15,17 +15,9 @@ ExternalProject_Add(external_ocloc URL_HASH ${OCLOC_HASH_TYPE}=${OCLOC_HASH} DOWNLOAD_DIR ${DOWNLOAD_DIR} PREFIX ${BUILD_DIR}/ocloc - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ocloc - ${DEFAULT_CMAKE_FLAGS} - ${OCLOC_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ocloc ${DEFAULT_CMAKE_FLAGS} ${OCLOC_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/ocloc - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/ocloc/src/external_ocloc/ < - ${PATCH_DIR}/ocloc.diff + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/ocloc/src/external_ocloc/ < ${PATCH_DIR}/ocloc.diff ) add_dependencies( diff --git a/build_files/build_environment/cmake/ogg.cmake b/build_files/build_environment/cmake/ogg.cmake index 6896f5a2cd2..eff23d21f61 100644 --- a/build_files/build_environment/cmake/ogg.cmake +++ b/build_files/build_environment/cmake/ogg.cmake @@ -7,10 +7,6 @@ ExternalProject_Add(external_ogg DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${OGG_HASH_TYPE}=${OGG_HASH} PREFIX ${BUILD_DIR}/ogg - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ogg - ${DEFAULT_CMAKE_FLAGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ogg ${DEFAULT_CMAKE_FLAGS} INSTALL_DIR ${LIBDIR}/ogg ) diff --git a/build_files/build_environment/cmake/openal.cmake b/build_files/build_environment/cmake/openal.cmake index 9ed73466f30..4287e5eb40a 100644 --- a/build_files/build_environment/cmake/openal.cmake +++ b/build_files/build_environment/cmake/openal.cmake @@ -36,27 +36,15 @@ if(BUILD_MODE STREQUAL Release) DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${OPENAL_HASH_TYPE}=${OPENAL_HASH} PREFIX ${BUILD_DIR}/openal - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openal - ${DEFAULT_CMAKE_FLAGS} - ${OPENAL_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openal ${DEFAULT_CMAKE_FLAGS} ${OPENAL_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/openal ) if(WIN32) ExternalProject_Add_Step(external_openal after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openal/lib/openal32.lib - ${HARVEST_TARGET}/openal/lib/openal32.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openal/bin/openal32.dll - ${HARVEST_TARGET}/openal/lib/openal32.dll - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/openal/include/ - ${HARVEST_TARGET}/openal/include/ - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openal/lib/openal32.lib ${HARVEST_TARGET}/openal/lib/openal32.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openal/bin/openal32.dll ${HARVEST_TARGET}/openal/lib/openal32.dll + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openal/include/ ${HARVEST_TARGET}/openal/include/ DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/opencollada.cmake b/build_files/build_environment/cmake/opencollada.cmake index 986e1211b8f..b3ac65c96c5 100644 --- a/build_files/build_environment/cmake/opencollada.cmake +++ b/build_files/build_environment/cmake/opencollada.cmake @@ -40,18 +40,10 @@ ExternalProject_Add(external_opencollada DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${OPENCOLLADA_HASH_TYPE}=${OPENCOLLADA_HASH} PREFIX ${BUILD_DIR}/opencollada - PATCH_COMMAND ${PATCH_MAYBE_DOS2UNIX_CMD} - ${PATCH_CMD} -p 1 -N -d - ${BUILD_DIR}/opencollada/src/external_opencollada < - ${PATCH_DIR}/opencollada.diff - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opencollada - ${DEFAULT_CMAKE_FLAGS} - ${OPENCOLLADA_EXTRA_ARGS} - + ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/opencollada/src/external_opencollada < ${PATCH_DIR}/opencollada.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opencollada ${DEFAULT_CMAKE_FLAGS} ${OPENCOLLADA_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/opencollada ) @@ -65,19 +57,13 @@ add_dependencies( if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_opencollada after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/opencollada/ - ${HARVEST_TARGET}/opencollada/ - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencollada/ ${HARVEST_TARGET}/opencollada/ DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_opencollada after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/opencollada/lib - ${HARVEST_TARGET}/opencollada/lib - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencollada/lib ${HARVEST_TARGET}/opencollada/lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/opencolorio.cmake b/build_files/build_environment/cmake/opencolorio.cmake index 8df5b961cea..d2ffbd82338 100644 --- a/build_files/build_environment/cmake/opencolorio.cmake +++ b/build_files/build_environment/cmake/opencolorio.cmake @@ -68,12 +68,7 @@ ExternalProject_Add(external_opencolorio URL_HASH ${OPENCOLORIO_HASH_TYPE}=${OPENCOLORIO_HASH} CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} PREFIX ${BUILD_DIR}/opencolorio - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opencolorio - ${DEFAULT_CMAKE_FLAGS} - ${OPENCOLORIO_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opencolorio ${DEFAULT_CMAKE_FLAGS} ${OPENCOLORIO_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/opencolorio ) @@ -92,46 +87,25 @@ add_dependencies( if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_opencolorio after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/opencolorio/include - ${HARVEST_TARGET}/opencolorio/include - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/opencolorio/bin/OpenColorIO_2_3.dll - ${HARVEST_TARGET}/opencolorio/bin/OpenColorIO_2_3.dll - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/opencolorio/lib - ${HARVEST_TARGET}/opencolorio/lib - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencolorio/include ${HARVEST_TARGET}/opencolorio/include + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencolorio/bin/OpenColorIO_2_3.dll ${HARVEST_TARGET}/opencolorio/bin/OpenColorIO_2_3.dll + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencolorio/lib ${HARVEST_TARGET}/opencolorio/lib DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_opencolorio after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/opencolorio/bin/OpenColorIO_d_2_3.dll - ${HARVEST_TARGET}/opencolorio/bin/OpenColorIO_d_2_3.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/opencolorio/lib/Opencolorio_d.lib - ${HARVEST_TARGET}/opencolorio/lib/OpenColorIO_d.lib - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/opencolorio/lib/site-packages - ${HARVEST_TARGET}/opencolorio/lib/site-packages-debug - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencolorio/bin/OpenColorIO_d_2_3.dll ${HARVEST_TARGET}/opencolorio/bin/OpenColorIO_d_2_3.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencolorio/lib/Opencolorio_d.lib ${HARVEST_TARGET}/opencolorio/lib/OpenColorIO_d.lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencolorio/lib/site-packages ${HARVEST_TARGET}/opencolorio/lib/site-packages-debug DEPENDEES install ) endif() else() ExternalProject_Add_Step(external_opencolorio after_install - COMMAND cp - ${LIBDIR}/yamlcpp/lib/libyaml-cpp.a - ${LIBDIR}/opencolorio/lib/ - COMMAND cp - ${LIBDIR}/expat/lib/libexpat.a - ${LIBDIR}/opencolorio/lib/ - COMMAND cp - ${LIBDIR}/pystring/lib/libpystring.a - ${LIBDIR}/opencolorio/lib/ - + COMMAND cp ${LIBDIR}/yamlcpp/lib/libyaml-cpp.a ${LIBDIR}/opencolorio/lib/ + COMMAND cp ${LIBDIR}/expat/lib/libexpat.a ${LIBDIR}/opencolorio/lib/ + COMMAND cp ${LIBDIR}/pystring/lib/libpystring.a ${LIBDIR}/opencolorio/lib/ DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/openexr.cmake b/build_files/build_environment/cmake/openexr.cmake index ea458c1cf05..32787cde37c 100644 --- a/build_files/build_environment/cmake/openexr.cmake +++ b/build_files/build_environment/cmake/openexr.cmake @@ -28,46 +28,22 @@ ExternalProject_Add(external_openexr URL file://${PACKAGE_DIR}/${OPENEXR_FILE} DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${OPENEXR_HASH_TYPE}=${OPENEXR_HASH} - - PATCH_COMMAND ${PATCH_CMD} -p 2 -d - ${BUILD_DIR}/openexr/src/external_openexr < - ${PATCH_DIR}/openexr_deflate_1588.diff - + PATCH_COMMAND ${PATCH_CMD} -p 2 -d ${BUILD_DIR}/openexr/src/external_openexr < ${PATCH_DIR}/openexr_deflate_1588.diff CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} PREFIX ${BUILD_DIR}/openexr - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openexr - ${DEFAULT_CMAKE_FLAGS} - ${OPENEXR_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openexr ${DEFAULT_CMAKE_FLAGS} ${OPENEXR_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/openexr ) if(WIN32) ExternalProject_Add_Step(external_openexr after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/openexr/lib - ${HARVEST_TARGET}/openexr/lib - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/openexr/include - ${HARVEST_TARGET}/openexr/include - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openexr/bin/Iex${OPENEXR_VERSION_POSTFIX}.dll - ${HARVEST_TARGET}/openexr/bin/Iex${OPENEXR_VERSION_POSTFIX}.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openexr/bin/IlmThread${OPENEXR_VERSION_POSTFIX}.dll - ${HARVEST_TARGET}/openexr/bin/IlmThread${OPENEXR_VERSION_POSTFIX}.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openexr/bin/OpenEXRCore${OPENEXR_VERSION_POSTFIX}.dll - ${HARVEST_TARGET}/openexr/bin/OpenEXRCore${OPENEXR_VERSION_POSTFIX}.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openexr/bin/OpenEXRUtil${OPENEXR_VERSION_POSTFIX}.dll - ${HARVEST_TARGET}/openexr/bin/OpenEXRUtil${OPENEXR_VERSION_POSTFIX}.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openexr/bin/OpenEXR${OPENEXR_VERSION_POSTFIX}.dll - ${HARVEST_TARGET}/openexr/bin/OpenEXR${OPENEXR_VERSION_POSTFIX}.dll - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openexr/lib ${HARVEST_TARGET}/openexr/lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openexr/include ${HARVEST_TARGET}/openexr/include + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openexr/bin/Iex${OPENEXR_VERSION_POSTFIX}.dll ${HARVEST_TARGET}/openexr/bin/Iex${OPENEXR_VERSION_POSTFIX}.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openexr/bin/IlmThread${OPENEXR_VERSION_POSTFIX}.dll ${HARVEST_TARGET}/openexr/bin/IlmThread${OPENEXR_VERSION_POSTFIX}.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openexr/bin/OpenEXRCore${OPENEXR_VERSION_POSTFIX}.dll ${HARVEST_TARGET}/openexr/bin/OpenEXRCore${OPENEXR_VERSION_POSTFIX}.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openexr/bin/OpenEXRUtil${OPENEXR_VERSION_POSTFIX}.dll ${HARVEST_TARGET}/openexr/bin/OpenEXRUtil${OPENEXR_VERSION_POSTFIX}.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openexr/bin/OpenEXR${OPENEXR_VERSION_POSTFIX}.dll ${HARVEST_TARGET}/openexr/bin/OpenEXR${OPENEXR_VERSION_POSTFIX}.dll DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/openimagedenoise.cmake b/build_files/build_environment/cmake/openimagedenoise.cmake index 2585de31aea..03ca17a7abc 100644 --- a/build_files/build_environment/cmake/openimagedenoise.cmake +++ b/build_files/build_environment/cmake/openimagedenoise.cmake @@ -58,16 +58,8 @@ ExternalProject_Add(external_openimagedenoise URL_HASH ${OIDN_HASH_TYPE}=${OIDN_HASH} PREFIX ${BUILD_DIR}/openimagedenoise CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openimagedenoise - ${OIDN_CMAKE_FLAGS} - ${OIDN_EXTRA_ARGS} - - PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d - ${BUILD_DIR}/openimagedenoise/src/external_openimagedenoise < - ${PATCH_DIR}/oidn.diff - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openimagedenoise ${OIDN_CMAKE_FLAGS} ${OIDN_EXTRA_ARGS} + PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/openimagedenoise/src/external_openimagedenoise < ${PATCH_DIR}/oidn.diff INSTALL_DIR ${LIBDIR}/openimagedenoise ) @@ -95,16 +87,9 @@ endif() if(BUILD_MODE STREQUAL Release AND WIN32) ExternalProject_Add_Step(external_openimagedenoise after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/openimagedenoise/bin - ${HARVEST_TARGET}/openimagedenoise/bin - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/openimagedenoise/lib - ${HARVEST_TARGET}/openimagedenoise/lib - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/openimagedenoise/include - ${HARVEST_TARGET}/openimagedenoise/include - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openimagedenoise/bin ${HARVEST_TARGET}/openimagedenoise/bin + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openimagedenoise/lib ${HARVEST_TARGET}/openimagedenoise/lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openimagedenoise/include ${HARVEST_TARGET}/openimagedenoise/include DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/openimageio.cmake b/build_files/build_environment/cmake/openimageio.cmake index 534ab069bb9..440ec9d1644 100644 --- a/build_files/build_environment/cmake/openimageio.cmake +++ b/build_files/build_environment/cmake/openimageio.cmake @@ -108,26 +108,11 @@ ExternalProject_Add(external_openimageio URL_HASH ${OPENIMAGEIO_HASH_TYPE}=${OPENIMAGEIO_HASH} CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} PREFIX ${BUILD_DIR}/openimageio - - PATCH_COMMAND - ${PATCH_CMD} -p 1 -N -d - ${BUILD_DIR}/openimageio/src/external_openimageio/ < - ${PATCH_DIR}/openimageio.diff && - ${PATCH_CMD} -p 1 -N -d - ${BUILD_DIR}/openimageio/src/external_openimageio/ < - ${PATCH_DIR}/oiio_webp.diff && - ${PATCH_CMD} -p 1 -N -d - ${BUILD_DIR}/openimageio/src/external_openimageio/ < - ${PATCH_DIR}/oiio_4044.diff && - ${PATCH_CMD} -p 1 -N -d - ${BUILD_DIR}/openimageio/src/external_openimageio/ < - ${PATCH_DIR}/oiio_4062.diff - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openimageio - ${DEFAULT_CMAKE_FLAGS} - ${OPENIMAGEIO_EXTRA_ARGS} - + PATCH_COMMAND ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/openimageio.diff && + ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/oiio_webp.diff && + ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/oiio_4044.diff && + ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/oiio_4062.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openimageio ${DEFAULT_CMAKE_FLAGS} ${OPENIMAGEIO_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/openimageio ) @@ -153,58 +138,26 @@ add_dependencies( if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_openimageio after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/OpenImageIO/include - ${HARVEST_TARGET}/OpenImageIO/include - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/OpenImageIO/lib - ${HARVEST_TARGET}/OpenImageIO/lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/OpenImageIO/bin/iconvert.exe - ${HARVEST_TARGET}/OpenImageIO/bin/iconvert.exe - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/OpenImageIO/bin/idiff.exe - ${HARVEST_TARGET}/OpenImageIO/bin/idiff.exe - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/OpenImageIO/bin/igrep.exe - ${HARVEST_TARGET}/OpenImageIO/bin/igrep.exe - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/OpenImageIO/bin/iinfo.exe - ${HARVEST_TARGET}/OpenImageIO/bin/iinfo.exe - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/OpenImageIO/bin/maketx.exe - ${HARVEST_TARGET}/OpenImageIO/bin/maketx.exe - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/OpenImageIO/bin/oiiotool.exe - ${HARVEST_TARGET}/OpenImageIO/bin/oiiotool.exe - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/OpenImageIO/bin/OpenImageIO.dll - ${HARVEST_TARGET}/OpenImageIO/bin/OpenImageIO.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/OpenImageIO/bin/OpenImageIO_Util.dll - ${HARVEST_TARGET}/OpenImageIO/bin/OpenImageIO_Util.dll - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenImageIO/include ${HARVEST_TARGET}/OpenImageIO/include + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenImageIO/lib ${HARVEST_TARGET}/OpenImageIO/lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/iconvert.exe ${HARVEST_TARGET}/OpenImageIO/bin/iconvert.exe + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/idiff.exe ${HARVEST_TARGET}/OpenImageIO/bin/idiff.exe + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/igrep.exe ${HARVEST_TARGET}/OpenImageIO/bin/igrep.exe + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/iinfo.exe ${HARVEST_TARGET}/OpenImageIO/bin/iinfo.exe + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/maketx.exe ${HARVEST_TARGET}/OpenImageIO/bin/maketx.exe + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/oiiotool.exe ${HARVEST_TARGET}/OpenImageIO/bin/oiiotool.exe + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/OpenImageIO.dll ${HARVEST_TARGET}/OpenImageIO/bin/OpenImageIO.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/OpenImageIO_Util.dll ${HARVEST_TARGET}/OpenImageIO/bin/OpenImageIO_Util.dll DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_openimageio after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openimageio/lib/OpenImageIO_d.lib - ${HARVEST_TARGET}/openimageio/lib/OpenImageIO_d.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openimageio/lib/OpenImageIO_Util_d.lib - ${HARVEST_TARGET}/openimageio/lib/OpenImageIO_Util_d.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/OpenImageIO/bin/OpenImageIO_d.dll - ${HARVEST_TARGET}/OpenImageIO/bin/OpenImageIO_d.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/OpenImageIO/bin/OpenImageIO_Util_d.dll - ${HARVEST_TARGET}/OpenImageIO/bin/OpenImageIO_Util_d.dll - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/OpenImageIO/lib/python${PYTHON_SHORT_VERSION}/ - ${HARVEST_TARGET}/OpenImageIO/lib/python${PYTHON_SHORT_VERSION}_debug/ - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimageio/lib/OpenImageIO_d.lib ${HARVEST_TARGET}/openimageio/lib/OpenImageIO_d.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openimageio/lib/OpenImageIO_Util_d.lib ${HARVEST_TARGET}/openimageio/lib/OpenImageIO_Util_d.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/OpenImageIO_d.dll ${HARVEST_TARGET}/OpenImageIO/bin/OpenImageIO_d.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/OpenImageIO/bin/OpenImageIO_Util_d.dll ${HARVEST_TARGET}/OpenImageIO/bin/OpenImageIO_Util_d.dll + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/OpenImageIO/lib/python${PYTHON_SHORT_VERSION}/ ${HARVEST_TARGET}/OpenImageIO/lib/python${PYTHON_SHORT_VERSION}_debug/ DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/openjpeg.cmake b/build_files/build_environment/cmake/openjpeg.cmake index cc3af20d18f..053e63be906 100644 --- a/build_files/build_environment/cmake/openjpeg.cmake +++ b/build_files/build_environment/cmake/openjpeg.cmake @@ -19,22 +19,9 @@ if(NOT WIN32) DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${OPENJPEG_HASH_TYPE}=${OPENJPEG_HASH} PREFIX ${BUILD_DIR}/openjpeg - - CONFIGURE_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/openjpeg/src/external_openjpeg-build && - ${CMAKE_COMMAND} - ${OPENJPEG_EXTRA_ARGS} - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openjpeg - ${BUILD_DIR}/openjpeg/src/external_openjpeg - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/openjpeg/src/external_openjpeg-build/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/openjpeg/src/external_openjpeg-build/ && - make install - + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/openjpeg/src/external_openjpeg-build && ${CMAKE_COMMAND} ${OPENJPEG_EXTRA_ARGS} -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openjpeg ${BUILD_DIR}/openjpeg/src/external_openjpeg + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/openjpeg/src/external_openjpeg-build/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/openjpeg/src/external_openjpeg-build/ && make install INSTALL_DIR ${LIBDIR}/openjpeg ) else() @@ -43,34 +30,20 @@ else() URL file://${PACKAGE_DIR}/${OPENJPEG_FILE} DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${OPENJPEG_HASH_TYPE}=${OPENJPEG_HASH} - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/openjpeg_msvc/src/external_openjpeg_msvc < - ${PATCH_DIR}/openjpeg_msvc.diff - + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openjpeg_msvc/src/external_openjpeg_msvc < ${PATCH_DIR}/openjpeg_msvc.diff PREFIX ${BUILD_DIR}/openjpeg_msvc - - CMAKE_ARGS - ${OPENJPEG_EXTRA_ARGS} - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openjpeg_msvc - -DBUILD_SHARED_LIBS=Off - -DBUILD_THIRDPARTY=OFF - + CMAKE_ARGS ${OPENJPEG_EXTRA_ARGS} -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openjpeg_msvc -DBUILD_SHARED_LIBS=Off -DBUILD_THIRDPARTY=OFF INSTALL_DIR ${LIBDIR}/openjpeg_msvc ) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_openjpeg_msvc after_install COMMAND - ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/openjpeg_msvc/lib - ${HARVEST_TARGET}/openjpeg/lib && - ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/openjpeg_msvc/include - ${HARVEST_TARGET}/openjpeg/include + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openjpeg_msvc/lib ${HARVEST_TARGET}/openjpeg/lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openjpeg_msvc/include ${HARVEST_TARGET}/openjpeg/include DEPENDEES install ) - endif() +endif() endif() set(OPENJPEG_LIBRARY libopenjp2${LIBEXT}) diff --git a/build_files/build_environment/cmake/openmp.cmake b/build_files/build_environment/cmake/openmp.cmake index bf3fd94ec0b..33825dc3b8e 100644 --- a/build_files/build_environment/cmake/openmp.cmake +++ b/build_files/build_environment/cmake/openmp.cmake @@ -3,11 +3,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later if(APPLE) - set(OPENMP_PATCH_COMMAND - ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/openmp/src/external_openmp < - ${PATCH_DIR}/openmp.diff - ) + set(OPENMP_PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openmp/src/external_openmp < ${PATCH_DIR}/openmp.diff) else() set(OPENMP_PATCH_COMMAND) endif() @@ -18,16 +14,8 @@ ExternalProject_Add(external_openmp URL_HASH ${OPENMP_HASH_TYPE}=${OPENMP_HASH} PREFIX ${BUILD_DIR}/openmp PATCH_COMMAND ${OPENMP_PATCH_COMMAND} - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openmp - ${DEFAULT_CMAKE_FLAGS} - - INSTALL_COMMAND - cd ${BUILD_DIR}/openmp/src/external_openmp-build && - install_name_tool -id @rpath/libomp.dylib runtime/src/libomp.dylib && - make install - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openmp ${DEFAULT_CMAKE_FLAGS} + INSTALL_COMMAND cd ${BUILD_DIR}/openmp/src/external_openmp-build && install_name_tool -id @rpath/libomp.dylib runtime/src/libomp.dylib && make install INSTALL_DIR ${LIBDIR}/openmp ) diff --git a/build_files/build_environment/cmake/openpgl.cmake b/build_files/build_environment/cmake/openpgl.cmake index 7f0b4a5cac1..53e3daa8841 100644 --- a/build_files/build_environment/cmake/openpgl.cmake +++ b/build_files/build_environment/cmake/openpgl.cmake @@ -24,12 +24,7 @@ ExternalProject_Add(external_openpgl DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${OPENPGL_HASH_TYPE}=${OPENPGL_HASH} PREFIX ${BUILD_DIR}/openpgl - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openpgl - ${DEFAULT_CMAKE_FLAGS} - ${OPENPGL_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openpgl ${DEFAULT_CMAKE_FLAGS} ${OPENPGL_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/openpgl ) @@ -41,21 +36,13 @@ add_dependencies( if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_openpgl after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/openpgl - ${HARVEST_TARGET}/openpgl - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openpgl ${HARVEST_TARGET}/openpgl DEPENDEES install ) else() ExternalProject_Add_Step(external_openpgl after_install - COMMAND ${CMAKE_COMMAND} -E copy $ - {LIBDIR}/openpgl/lib/openpgl_d.lib - ${HARVEST_TARGET}/openpgl/lib/openpgl_d.lib - COMMAND ${CMAKE_COMMAND} -E copy $ - {LIBDIR}/openpgl/lib/cmake/openpgl-${OPENPGL_SHORT_VERSION}/openpgl_Exports-debug.cmake - ${HARVEST_TARGET}/openpgl/lib/cmake/openpgl-${OPENPGL_SHORT_VERSION}/openpgl_Exports-debug.cmake - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openpgl/lib/openpgl_d.lib ${HARVEST_TARGET}/openpgl/lib/openpgl_d.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openpgl/lib/cmake/openpgl-${OPENPGL_SHORT_VERSION}/openpgl_Exports-debug.cmake ${HARVEST_TARGET}/openpgl/lib/cmake/openpgl-${OPENPGL_SHORT_VERSION}/openpgl_Exports-debug.cmake DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/opensubdiv.cmake b/build_files/build_environment/cmake/opensubdiv.cmake index 11ae926702f..4d5eff38211 100644 --- a/build_files/build_environment/cmake/opensubdiv.cmake +++ b/build_files/build_environment/cmake/opensubdiv.cmake @@ -31,37 +31,22 @@ ExternalProject_Add(external_opensubdiv URL_HASH ${OPENSUBDIV_HASH_TYPE}=${OPENSUBDIV_HASH} PREFIX ${BUILD_DIR}/opensubdiv CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opensubdiv - -Wno-dev ${DEFAULT_CMAKE_FLAGS} - ${OPENSUBDIV_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opensubdiv -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${OPENSUBDIV_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/opensubdiv ) if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_opensubdiv after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/opensubdiv/lib - ${HARVEST_TARGET}/opensubdiv/lib - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/opensubdiv/include - ${HARVEST_TARGET}/opensubdiv/include - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opensubdiv/lib ${HARVEST_TARGET}/opensubdiv/lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opensubdiv/include ${HARVEST_TARGET}/opensubdiv/include DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_opensubdiv after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/opensubdiv/lib/osdCPU.lib - ${HARVEST_TARGET}/opensubdiv/lib/osdCPU_d.lib - COMMAND ${CMAKE_COMMAND} -E copy $ - {LIBDIR}/opensubdiv/lib/osdGPU.lib - ${HARVEST_TARGET}/opensubdiv/lib/osdGPU_d.lib - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/opensubdiv/lib/osdCPU.lib ${HARVEST_TARGET}/opensubdiv/lib/osdCPU_d.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/opensubdiv/lib/osdGPU.lib ${HARVEST_TARGET}/opensubdiv/lib/osdGPU_d.lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/openvdb.cmake b/build_files/build_environment/cmake/openvdb.cmake index 36f59aa6bbd..5f5dbe00895 100644 --- a/build_files/build_environment/cmake/openvdb.cmake +++ b/build_files/build_environment/cmake/openvdb.cmake @@ -48,15 +48,9 @@ set(OPENVDB_EXTRA_ARGS ) set(OPENVDB_PATCH - ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/openvdb/src/openvdb < - ${PATCH_DIR}/openvdb.diff && - ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/openvdb/src/openvdb < - ${PATCH_DIR}/openvdb_1706.diff && - ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/openvdb/src/openvdb < - ${PATCH_DIR}/openvdb_1733.diff + ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openvdb/src/openvdb < ${PATCH_DIR}/openvdb.diff && + ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openvdb/src/openvdb < ${PATCH_DIR}/openvdb_1706.diff && + ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openvdb/src/openvdb < ${PATCH_DIR}/openvdb_1733.diff ) ExternalProject_Add(openvdb @@ -66,12 +60,7 @@ ExternalProject_Add(openvdb CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} PREFIX ${BUILD_DIR}/openvdb PATCH_COMMAND ${OPENVDB_PATCH} - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openvdb - ${DEFAULT_CMAKE_FLAGS} - ${OPENVDB_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openvdb ${DEFAULT_CMAKE_FLAGS} ${OPENVDB_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/openvdb ) @@ -89,34 +78,18 @@ add_dependencies( if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(openvdb after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/openvdb/include - ${HARVEST_TARGET}/openvdb/include - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openvdb/lib/openvdb.lib - ${HARVEST_TARGET}/openvdb/lib/openvdb.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openvdb/bin/openvdb.dll - ${HARVEST_TARGET}/openvdb/bin/openvdb.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openvdb/lib/python${PYTHON_SHORT_VERSION}/site-packages/pyopenvdb.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_amd64.pyd - ${HARVEST_TARGET}openvdb/python/pyopenvdb.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_amd64.pyd - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/openvdb/include ${HARVEST_TARGET}/openvdb/include + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/openvdb.lib ${HARVEST_TARGET}/openvdb/lib/openvdb.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/bin/openvdb.dll ${HARVEST_TARGET}/openvdb/bin/openvdb.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/python${PYTHON_SHORT_VERSION}/site-packages/pyopenvdb.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_amd64.pyd ${HARVEST_TARGET}openvdb/python/pyopenvdb.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_amd64.pyd DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(openvdb after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openvdb/lib/openvdb_d.lib - ${HARVEST_TARGET}/openvdb/lib/openvdb_d.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openvdb/bin/openvdb_d.dll - ${HARVEST_TARGET}/openvdb/bin/openvdb_d.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openvdb/lib/python${PYTHON_SHORT_VERSION}/site-packages/pyopenvdb_d.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_amd64.pyd - ${HARVEST_TARGET}openvdb/python/pyopenvdb_d.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_amd64.pyd - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/openvdb_d.lib ${HARVEST_TARGET}/openvdb/lib/openvdb_d.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/bin/openvdb_d.dll ${HARVEST_TARGET}/openvdb/bin/openvdb_d.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/openvdb/lib/python${PYTHON_SHORT_VERSION}/site-packages/pyopenvdb_d.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_amd64.pyd ${HARVEST_TARGET}openvdb/python/pyopenvdb_d.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_amd64.pyd DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/opus.cmake b/build_files/build_environment/cmake/opus.cmake index b9b948df60f..12a892e1803 100644 --- a/build_files/build_environment/cmake/opus.cmake +++ b/build_files/build_environment/cmake/opus.cmake @@ -16,24 +16,13 @@ if(NOT WIN32) DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${OPUS_HASH_TYPE}=${OPUS_HASH} PREFIX ${BUILD_DIR}/opus - - CONFIGURE_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/opus/src/external_opus/ && - ${CONFIGURE_COMMAND} - --prefix=${LIBDIR}/opus - --disable-shared - --enable-static - --with-pic - --disable-maintainer-mode - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/opus/src/external_opus/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/opus/src/external_opus/ && - make install - + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/opus/src/external_opus/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/opus + --disable-shared + --enable-static + --with-pic + --disable-maintainer-mode + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/opus/src/external_opus/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/opus/src/external_opus/ && make install INSTALL_DIR ${LIBDIR}/opus ) else() @@ -42,16 +31,8 @@ else() DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${OPUS_HASH_TYPE}=${OPUS_HASH} PREFIX ${BUILD_DIR}/opus - - PATCH_COMMAND COMMAND - ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/opus/src/external_opus < - ${PATCH_DIR}/opus_windows.diff - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opus - ${OPUS_CMAKE_ARGS} - + PATCH_COMMAND COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/opus/src/external_opus < ${PATCH_DIR}/opus_windows.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opus ${OPUS_CMAKE_ARGS} INSTALL_DIR ${LIBDIR}/opus ) endif() diff --git a/build_files/build_environment/cmake/osl.cmake b/build_files/build_environment/cmake/osl.cmake index 7277b102158..07be3eb0913 100644 --- a/build_files/build_environment/cmake/osl.cmake +++ b/build_files/build_environment/cmake/osl.cmake @@ -54,17 +54,8 @@ ExternalProject_Add(external_osl LIST_SEPARATOR ^^ URL_HASH ${OSL_HASH_TYPE}=${OSL_HASH} PREFIX ${BUILD_DIR}/osl - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/osl/src/external_osl < - ${PATCH_DIR}/osl.diff - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/osl - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - ${DEFAULT_CMAKE_FLAGS} - ${OSL_EXTRA_ARGS} - + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/osl/src/external_osl < ${PATCH_DIR}/osl.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/osl -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${DEFAULT_CMAKE_FLAGS} ${OSL_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/osl ) @@ -92,40 +83,20 @@ endif() if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_osl after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/osl/ - ${HARVEST_TARGET}/osl - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/osl/ ${HARVEST_TARGET}/osl DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_osl after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/osl/lib/oslcomp_d.lib - ${HARVEST_TARGET}/osl/lib/oslcomp_d.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/osl/lib/oslexec_d.lib - ${HARVEST_TARGET}/osl/lib/oslexec_d.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/osl/lib/oslquery_d.lib - ${HARVEST_TARGET}/osl/lib/oslquery_d.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/osl/lib/oslnoise_d.lib - ${HARVEST_TARGET}/osl/lib/oslnoise_d.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/osl/bin/oslcomp_d.dll - ${HARVEST_TARGET}/osl/bin/oslcomp_d.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/osl/bin/oslexec_d.dll - ${HARVEST_TARGET}/osl/bin/oslexec_d.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/osl/bin/oslquery_d.dll - ${HARVEST_TARGET}/osl/bin/oslquery_d.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/osl/bin/oslnoise_d.dll - ${HARVEST_TARGET}/osl/bin/oslnoise_d.dll - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslcomp_d.lib ${HARVEST_TARGET}/osl/lib/oslcomp_d.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslexec_d.lib ${HARVEST_TARGET}/osl/lib/oslexec_d.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslquery_d.lib ${HARVEST_TARGET}/osl/lib/oslquery_d.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/lib/oslnoise_d.lib ${HARVEST_TARGET}/osl/lib/oslnoise_d.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/bin/oslcomp_d.dll ${HARVEST_TARGET}/osl/bin/oslcomp_d.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/bin/oslexec_d.dll ${HARVEST_TARGET}/osl/bin/oslexec_d.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/bin/oslquery_d.dll ${HARVEST_TARGET}/osl/bin/oslquery_d.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/bin/oslnoise_d.dll ${HARVEST_TARGET}/osl/bin/oslnoise_d.dll DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/package_python.cmake b/build_files/build_environment/cmake/package_python.cmake index 8077fe36d1a..98f93fcc48a 100644 --- a/build_files/build_environment/cmake/package_python.cmake +++ b/build_files/build_environment/cmake/package_python.cmake @@ -9,92 +9,38 @@ if(MSVC) if(BUILD_MODE STREQUAL Release) add_custom_command( OUTPUT ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe - COMMAND echo packaging python COMMAND echo this should output at ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe COMMAND ${CMAKE_COMMAND} -E make_directory ${PYTARGET}/libs - COMMAND ${CMAKE_COMMAND} -E copy - ${PYSRC}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}.lib - ${PYTARGET}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${PYSRC}/python.exe - ${PYTARGET}/bin/python.exe - COMMAND ${CMAKE_COMMAND} -E copy - ${PYSRC}/python${PYTHON_SHORT_VERSION_NO_DOTS}.dll - ${PYTARGET}/bin/python${PYTHON_SHORT_VERSION_NO_DOTS}.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${PYSRC}/python3${PYTHON_POSTFIX}.dll - ${PYTARGET}/bin/python3${PYTHON_POSTFIX}.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${PYSRC}/python${PYTHON_SHORT_VERSION_NO_DOTS}.pdb - ${PYTARGET}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}.pdb - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${PYSRC}/include/ - ${PYTARGET}/include/ - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${PYSRC}/lib/ - ${PYTARGET}/lib/ - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${PYSRC}/DLLs/ - ${PYTARGET}/DLLs/ - - COMMAND cd ${PYTARGET}/lib/ && - for /d /r . %%d in (__pycache__) do @if exist "%%d" echo "%%d" && - rd /s/q "%%d" - ) - add_custom_target(Package_Python - ALL - DEPENDS - external_python - external_numpy - external_python_site_packages - OUTPUT - ${HARVEST_TARGET}/python/${PYTHON_SHORT_VERSION_NO_DOTS}/bin/python${PYTHON_POSTFIX}.exe + COMMAND ${CMAKE_COMMAND} -E copy ${PYSRC}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}.lib ${PYTARGET}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}.lib + COMMAND ${CMAKE_COMMAND} -E copy ${PYSRC}/python.exe ${PYTARGET}/bin/python.exe + COMMAND ${CMAKE_COMMAND} -E copy ${PYSRC}/python${PYTHON_SHORT_VERSION_NO_DOTS}.dll ${PYTARGET}/bin/python${PYTHON_SHORT_VERSION_NO_DOTS}.dll + COMMAND ${CMAKE_COMMAND} -E copy ${PYSRC}/python3${PYTHON_POSTFIX}.dll ${PYTARGET}/bin/python3${PYTHON_POSTFIX}.dll + COMMAND ${CMAKE_COMMAND} -E copy ${PYSRC}/python${PYTHON_SHORT_VERSION_NO_DOTS}.pdb ${PYTARGET}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}.pdb + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYSRC}/include/ ${PYTARGET}/include/ + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYSRC}/lib/ ${PYTARGET}/lib/ + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYSRC}/DLLs/ ${PYTARGET}/DLLs/ + COMMAND cd ${PYTARGET}/lib/ && for /d /r . %%d in (__pycache__) do @if exist "%%d" echo "%%d" && rd /s/q "%%d" ) + add_custom_target(Package_Python ALL DEPENDS external_python external_numpy external_python_site_packages OUTPUT ${HARVEST_TARGET}/python/${PYTHON_SHORT_VERSION_NO_DOTS}/bin/python${PYTHON_POSTFIX}.exe) endif() if(BUILD_MODE STREQUAL Debug) add_custom_command( OUTPUT ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe - COMMAND echo packaging python COMMAND echo this should output at ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe COMMAND ${CMAKE_COMMAND} -E make_directory ${PYTARGET}/libs - COMMAND ${CMAKE_COMMAND} -E copy - ${PYSRC}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib - ${PYTARGET}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${PYSRC}/python${PYTHON_POSTFIX}.exe - ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe - COMMAND ${CMAKE_COMMAND} -E copy - ${PYSRC}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.dll - ${PYTARGET}/bin/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${PYSRC}/python3${PYTHON_POSTFIX}.dll - ${PYTARGET}/bin/python3${PYTHON_POSTFIX}.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${PYSRC}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.pdb - ${PYTARGET}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.pdb - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${PYSRC}/include/ - ${PYTARGET}/include/ - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${PYSRC}/lib/ - ${PYTARGET}/lib/ - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${PYSRC}/DLLs/ - ${PYTARGET}/DLLs/ - - COMMAND cd ${PYTARGET}/lib/ && - for /d /r . %%d in (__pycache__) do @if exist "%%d" echo "%%d" && - rd /s/q "%%d" - ) - add_custom_target(Package_Python - ALL - DEPENDS - external_python external_numpy external_python_site_packages - OUTPUT - ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe + COMMAND ${CMAKE_COMMAND} -E copy ${PYSRC}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib ${PYTARGET}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib + COMMAND ${CMAKE_COMMAND} -E copy ${PYSRC}/python${PYTHON_POSTFIX}.exe ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe + COMMAND ${CMAKE_COMMAND} -E copy ${PYSRC}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.dll ${PYTARGET}/bin/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.dll + COMMAND ${CMAKE_COMMAND} -E copy ${PYSRC}/python3${PYTHON_POSTFIX}.dll ${PYTARGET}/bin/python3${PYTHON_POSTFIX}.dll + COMMAND ${CMAKE_COMMAND} -E copy ${PYSRC}/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.pdb ${PYTARGET}/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.pdb + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYSRC}/include/ ${PYTARGET}/include/ + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYSRC}/lib/ ${PYTARGET}/lib/ + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PYSRC}/DLLs/ ${PYTARGET}/DLLs/ + COMMAND cd ${PYTARGET}/lib/ && for /d /r . %%d in (__pycache__) do @if exist "%%d" echo "%%d" && rd /s/q "%%d" ) + add_custom_target(Package_Python ALL DEPENDS external_python external_numpy external_python_site_packages OUTPUT ${PYTARGET}/bin/python${PYTHON_POSTFIX}.exe) endif() endif() diff --git a/build_files/build_environment/cmake/png.cmake b/build_files/build_environment/cmake/png.cmake index 9cc3cc55f83..643eaa6d462 100644 --- a/build_files/build_environment/cmake/png.cmake +++ b/build_files/build_environment/cmake/png.cmake @@ -9,12 +9,7 @@ set(PNG_EXTRA_ARGS ) if(BLENDER_PLATFORM_ARM) - set(PNG_EXTRA_ARGS - ${PNG_EXTRA_ARGS} - -DPNG_HARDWARE_OPTIMIZATIONS=ON - -DPNG_ARM_NEON=on - -DCMAKE_SYSTEM_PROCESSOR="aarch64" - ) + set(PNG_EXTRA_ARGS ${PNG_EXTRA_ARGS} -DPNG_HARDWARE_OPTIMIZATIONS=ON -DPNG_ARM_NEON=on -DCMAKE_SYSTEM_PROCESSOR="aarch64") endif() ExternalProject_Add(external_png @@ -22,12 +17,7 @@ ExternalProject_Add(external_png DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${PNG_HASH_TYPE}=${PNG_HASH} PREFIX ${BUILD_DIR}/png - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/png - ${DEFAULT_CMAKE_FLAGS} - ${PNG_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/png ${DEFAULT_CMAKE_FLAGS} ${PNG_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/png ) @@ -38,23 +28,15 @@ add_dependencies( if(WIN32 AND BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_png after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/png/include/ - ${HARVEST_TARGET}/png/include/ - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/png/lib/libpng16_static${LIBEXT} - ${HARVEST_TARGET}/png/lib/libpng${LIBEXT} - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/png/include/ ${HARVEST_TARGET}/png/include/ + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/png/lib/libpng16_static${LIBEXT} ${HARVEST_TARGET}/png/lib/libpng${LIBEXT} DEPENDEES install ) endif() if(WIN32 AND BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_png after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/png/lib/libpng16_staticd${LIBEXT} - ${LIBDIR}/png/lib/libpng16${LIBEXT} - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/png/lib/libpng16_staticd${LIBEXT} ${LIBDIR}/png/lib/libpng16${LIBEXT} DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/potrace.cmake b/build_files/build_environment/cmake/potrace.cmake index f23356a34fb..8410833c4a1 100644 --- a/build_files/build_environment/cmake/potrace.cmake +++ b/build_files/build_environment/cmake/potrace.cmake @@ -11,24 +11,13 @@ if((WIN32 AND BUILD_MODE STREQUAL Release) OR UNIX) DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${POTRACE_HASH_TYPE}=${POTRACE_HASH} PREFIX ${BUILD_DIR}/potrace - - PATCH_COMMAND ${CMAKE_COMMAND} -E copy - ${PATCH_DIR}/cmakelists_potrace.txt - ${BUILD_DIR}/potrace/src/external_potrace/CMakeLists.txt - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/potrace - ${DEFAULT_CMAKE_FLAGS} - ${POTRACE_EXTRA_ARGS} - + PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_potrace.txt ${BUILD_DIR}/potrace/src/external_potrace/CMakeLists.txt + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/potrace ${DEFAULT_CMAKE_FLAGS} ${POTRACE_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/potrace ) if(WIN32) ExternalProject_Add_Step(external_potrace after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/potrace - ${HARVEST_TARGET}/potrace - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/potrace ${HARVEST_TARGET}/potrace DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/pthreads.cmake b/build_files/build_environment/cmake/pthreads.cmake index 7384e0da614..009f766e1a1 100644 --- a/build_files/build_environment/cmake/pthreads.cmake +++ b/build_files/build_environment/cmake/pthreads.cmake @@ -10,11 +10,7 @@ if(WIN32) set(PTHREAD_CPPFLAGS "/I. /DHAVE_CONFIG_H ") endif() - set(PTHREADS_BUILD - cd ${BUILD_DIR}/pthreads/src/external_pthreads/ && - cd && - nmake VC-static /e CPPFLAGS=${PTHREAD_CPPFLAGS} - ) + set(PTHREADS_BUILD cd ${BUILD_DIR}/pthreads/src/external_pthreads/ && cd && nmake VC-static /e CPPFLAGS=${PTHREAD_CPPFLAGS}) ExternalProject_Add(external_pthreads URL file://${PACKAGE_DIR}/${PTHREADS_FILE} @@ -22,42 +18,21 @@ if(WIN32) URL_HASH ${PTHREADS_HASH_TYPE}=${PTHREADS_HASH} PREFIX ${BUILD_DIR}/pthreads CONFIGURE_COMMAND echo . - - PATCH_COMMAND COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/pthreads/src/external_pthreads < - ${PATCH_DIR}/pthreads.diff - + PATCH_COMMAND COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/pthreads/src/external_pthreads < ${PATCH_DIR}/pthreads.diff BUILD_COMMAND ${PTHREADS_BUILD} - INSTALL_COMMAND COMMAND - ${CMAKE_COMMAND} -E copy - ${BUILD_DIR}/pthreads/src/external_pthreads/libpthreadVC3${LIBEXT} - ${LIBDIR}/pthreads/lib/pthreadVC3${LIBEXT} && - ${CMAKE_COMMAND} -E copy - ${BUILD_DIR}/pthreads/src/external_pthreads/pthread.h - ${LIBDIR}/pthreads/inc/pthread.h && - ${CMAKE_COMMAND} -E copy - ${BUILD_DIR}/pthreads/src/external_pthreads/sched.h - ${LIBDIR}/pthreads/inc/sched.h && - ${CMAKE_COMMAND} -E copy - ${BUILD_DIR}/pthreads/src/external_pthreads/semaphore.h - ${LIBDIR}/pthreads/inc/semaphore.h && - ${CMAKE_COMMAND} -E copy - ${BUILD_DIR}/pthreads/src/external_pthreads/_ptw32.h - ${LIBDIR}/pthreads/inc/_ptw32.h - + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/libpthreadVC3${LIBEXT} ${LIBDIR}/pthreads/lib/pthreadVC3${LIBEXT} && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/pthread.h ${LIBDIR}/pthreads/inc/pthread.h && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/sched.h ${LIBDIR}/pthreads/inc/sched.h && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/semaphore.h ${LIBDIR}/pthreads/inc/semaphore.h && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/pthreads/src/external_pthreads/_ptw32.h ${LIBDIR}/pthreads/inc/_ptw32.h INSTALL_DIR ${LIBDIR}/pthreads ) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_pthreads after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/pthreads/inc/ - ${HARVEST_TARGET}/pthreads/include/ - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/pthreads/lib/ - ${HARVEST_TARGET}/pthreads/lib - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pthreads/inc/ ${HARVEST_TARGET}/pthreads/include/ + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pthreads/lib/ ${HARVEST_TARGET}/pthreads/lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/pugixml.cmake b/build_files/build_environment/cmake/pugixml.cmake index 6fdc8cf875f..51586aed869 100644 --- a/build_files/build_environment/cmake/pugixml.cmake +++ b/build_files/build_environment/cmake/pugixml.cmake @@ -10,30 +10,19 @@ ExternalProject_Add(external_pugixml DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${PUGIXML_HASH_TYPE}=${PUGIXML_HASH} PREFIX ${BUILD_DIR}/pugixml - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/pugixml - ${DEFAULT_CMAKE_FLAGS} - ${PUGIXML_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/pugixml ${DEFAULT_CMAKE_FLAGS} ${PUGIXML_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/pugixml ) if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_pugixml after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/pugixml - ${HARVEST_TARGET}/pugixml - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pugixml ${HARVEST_TARGET}/pugixml DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_pugixml after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/pugixml/lib/pugixml.lib - ${HARVEST_TARGET}/pugixml/lib/pugixml_d.lib - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/pugixml/lib/pugixml.lib ${HARVEST_TARGET}/pugixml/lib/pugixml_d.lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/pybind11.cmake b/build_files/build_environment/cmake/pybind11.cmake index 1c06c689c64..5167861e86c 100644 --- a/build_files/build_environment/cmake/pybind11.cmake +++ b/build_files/build_environment/cmake/pybind11.cmake @@ -13,16 +13,8 @@ ExternalProject_Add(external_pybind11 URL_HASH ${PYBIND11_HASH_TYPE}=${PYBIND11_HASH} PREFIX ${BUILD_DIR}/pybind11 CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/pybind11/src/external_pybind11 < - ${PATCH_DIR}/pybind11_4761.diff - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/pybind11 - ${DEFAULT_CMAKE_FLAGS} - ${PYBIND11_EXTRA_ARGS} - + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/pybind11/src/external_pybind11 < ${PATCH_DIR}/pybind11_4761.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/pybind11 ${DEFAULT_CMAKE_FLAGS} ${PYBIND11_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/pybind11 ) diff --git a/build_files/build_environment/cmake/pystring.cmake b/build_files/build_environment/cmake/pystring.cmake index 8fe2b95ab59..524454cd6f8 100644 --- a/build_files/build_environment/cmake/pystring.cmake +++ b/build_files/build_environment/cmake/pystring.cmake @@ -10,28 +10,15 @@ ExternalProject_Add(external_pystring DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${PYSTRING_HASH_TYPE}=${PYSTRING_HASH} PREFIX ${BUILD_DIR}/pystring - - PATCH_COMMAND ${CMAKE_COMMAND} -E copy - ${PATCH_DIR}/cmakelists_pystring.txt - ${BUILD_DIR}/pystring/src/external_pystring/CMakeLists.txt - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/pystring - ${DEFAULT_CMAKE_FLAGS} - ${PYSTRING_EXTRA_ARGS} - + PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_pystring.txt ${BUILD_DIR}/pystring/src/external_pystring/CMakeLists.txt + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/pystring ${DEFAULT_CMAKE_FLAGS} ${PYSTRING_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/pystring ) if(WIN32) ExternalProject_Add_Step(external_pystring after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/pystring/lib - ${HARVEST_TARGET}/pystring/lib - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/pystring/include - ${HARVEST_TARGET}/pystring/include - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pystring/lib ${HARVEST_TARGET}/pystring/lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/pystring/include ${HARVEST_TARGET}/pystring/include DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/python.cmake b/build_files/build_environment/cmake/python.cmake index e2cf2141c7c..f2052f4327d 100644 --- a/build_files/build_environment/cmake/python.cmake +++ b/build_files/build_environment/cmake/python.cmake @@ -31,7 +31,6 @@ if(WIN32) DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${PYTHON_HASH_TYPE}=${PYTHON_HASH} PREFIX ${BUILD_DIR}/python - # Python will download its own deps and there's very little we can do about # that beyond placing some code in their externals dir before it tries. # the foldernames *HAVE* to match the ones inside pythons get_externals.cmd. @@ -39,35 +38,11 @@ if(WIN32) PATCH_COMMAND mkdir ${PYTHON_EXTERNALS_FOLDER_DOS} && mklink /J ${PYTHON_EXTERNALS_FOLDER_DOS}\\zlib-1.2.13 ${ZLIB_SOURCE_FOLDER_DOS} && mklink /J ${PYTHON_EXTERNALS_FOLDER_DOS}\\openssl-3.0.11 ${SSL_SOURCE_FOLDER_DOS} && - ${CMAKE_COMMAND} -E copy - ${ZLIB_SOURCE_FOLDER}/../external_zlib-build/zconf.h - ${PYTHON_EXTERNALS_FOLDER}/zlib-1.2.13/zconf.h && - ${PATCH_CMD} --verbose -p1 -d - ${BUILD_DIR}/python/src/external_python < - ${PATCH_DIR}/python_windows.diff - + ${CMAKE_COMMAND} -E copy ${ZLIB_SOURCE_FOLDER}/../external_zlib-build/zconf.h ${PYTHON_EXTERNALS_FOLDER}/zlib-1.2.13/zconf.h && + ${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_windows.diff CONFIGURE_COMMAND echo "." - - BUILD_COMMAND ${CONFIGURE_ENV_MSVC} && - cd ${BUILD_DIR}/python/src/external_python/pcbuild/ && - set IncludeTkinter=false && - set LDFLAGS=/DEBUG && - call prepare_ssl.bat && - call build.bat -e -p x64 -c ${BUILD_MODE} - - INSTALL_COMMAND ${PYTHON_BINARY_INTERNAL} ${PYTHON_SRC}/PC/layout/main.py - -b ${PYTHON_SRC}/PCbuild/amd64 - -s ${PYTHON_SRC} - -t ${PYTHON_SRC}/tmp/ - --include-stable - --include-pip - --include-dev - --include-launchers - --include-venv - --include-symbols - ${PYTHON_EXTRA_INSTLAL_FLAGS} - --copy - ${LIBDIR}/python + BUILD_COMMAND ${CONFIGURE_ENV_MSVC} && cd ${BUILD_DIR}/python/src/external_python/pcbuild/ && set IncludeTkinter=false && set LDFLAGS=/DEBUG && call prepare_ssl.bat && call build.bat -e -p x64 -c ${BUILD_MODE} + INSTALL_COMMAND ${PYTHON_BINARY_INTERNAL} ${PYTHON_SRC}/PC/layout/main.py -b ${PYTHON_SRC}/PCbuild/amd64 -s ${PYTHON_SRC} -t ${PYTHON_SRC}/tmp/ --include-stable --include-pip --include-dev --include-launchers --include-venv --include-symbols ${PYTHON_EXTRA_INSTLAL_FLAGS} --copy ${LIBDIR}/python ) add_dependencies( external_python @@ -125,22 +100,14 @@ else() export LIBLZMA_LIBS=${LIBDIR}/lzma/lib/${LIBPREFIX}lzma${LIBEXT} export ZLIB_CFLAGS=-I${LIBDIR}/zlib/include export ZLIB_LIBS=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY} - ) + ) # This patch indludes changes to fix missing -lm for sqlite and and fix the order of # -ldl flags for ssl to avoid link errors. if(APPLE) - set(PYTHON_PATCH - ${PATCH_CMD} --verbose -p1 -d - ${BUILD_DIR}/python/src/external_python < - ${PATCH_DIR}/python_apple.diff - ) + set(PYTHON_PATCH ${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_apple.diff) else() - set(PYTHON_PATCH - ${PATCH_CMD} --verbose -p1 -d - ${BUILD_DIR}/python/src/external_python < - ${PATCH_DIR}/python_unix.diff - ) + set(PYTHON_PATCH ${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/python_unix.diff) endif() # NOTE: untested on APPLE so far. @@ -162,20 +129,9 @@ else() URL_HASH ${PYTHON_HASH_TYPE}=${PYTHON_HASH} PREFIX ${BUILD_DIR}/python PATCH_COMMAND ${PYTHON_PATCH} - - CONFIGURE_COMMAND ${PYTHON_CONFIGURE_ENV} && - ${PYTHON_CONFIGURE_EXTRA_ENV} && - cd ${BUILD_DIR}/python/src/external_python/ && - ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/python ${PYTHON_CONFIGURE_EXTRA_ARGS} - - BUILD_COMMAND ${PYTHON_CONFIGURE_ENV} && - cd ${BUILD_DIR}/python/src/external_python/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${PYTHON_CONFIGURE_ENV} && - cd ${BUILD_DIR}/python/src/external_python/ && - make install - + CONFIGURE_COMMAND ${PYTHON_CONFIGURE_ENV} && ${PYTHON_CONFIGURE_EXTRA_ENV} && cd ${BUILD_DIR}/python/src/external_python/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/python ${PYTHON_CONFIGURE_EXTRA_ARGS} + BUILD_COMMAND ${PYTHON_CONFIGURE_ENV} && cd ${BUILD_DIR}/python/src/external_python/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${PYTHON_CONFIGURE_ENV} && cd ${BUILD_DIR}/python/src/external_python/ && make install INSTALL_DIR ${LIBDIR}/python) endif() @@ -202,10 +158,7 @@ if(WIN32) # correctly to instruct it to use the debug version # of python. So just copy the debug imports file over # and call it a day... - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/python/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib - ${LIBDIR}/python/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}.lib - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/python/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}${PYTHON_POSTFIX}.lib ${LIBDIR}/python/libs/python${PYTHON_SHORT_VERSION_NO_DOTS}.lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/robinmap.cmake b/build_files/build_environment/cmake/robinmap.cmake index 41345b81523..80e92cd198f 100644 --- a/build_files/build_environment/cmake/robinmap.cmake +++ b/build_files/build_environment/cmake/robinmap.cmake @@ -10,11 +10,6 @@ ExternalProject_Add(external_robinmap DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${ROBINMAP_HASH_TYPE}=${ROBINMAP_HASH} PREFIX ${BUILD_DIR}/robinmap - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/robinmap - ${DEFAULT_CMAKE_FLAGS} - ${ROBINMAP_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/robinmap ${DEFAULT_CMAKE_FLAGS} ${ROBINMAP_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/robinmap ) diff --git a/build_files/build_environment/cmake/sdl.cmake b/build_files/build_environment/cmake/sdl.cmake index 7c55ce0ddd2..0524e44d0e7 100644 --- a/build_files/build_environment/cmake/sdl.cmake +++ b/build_files/build_environment/cmake/sdl.cmake @@ -2,11 +2,7 @@ # # SPDX-License-Identifier: GPL-2.0-or-later -set(SDL_PATCH - ${PATCH_CMD} -p 0 -N -d - ${BUILD_DIR}/sdl/src/external_sdl < - ${PATCH_DIR}/sdl.diff -) +set(SDL_PATCH ${PATCH_CMD} -p 0 -N -d ${BUILD_DIR}/sdl/src/external_sdl < ${PATCH_DIR}/sdl.diff) if(WIN32) set(SDL_EXTRA_ARGS @@ -25,10 +21,7 @@ else() list(APPEND SDL_EXTRA_ARGS -DSDL_HAPTICS=OFF) set(SDL_PATCH ${SDL_PATCH} && - ${PATCH_CMD} -p 0 -N -d - ${BUILD_DIR}/sdl/src/external_sdl < - ${PATCH_DIR}/sdl_haptics.diff - ) + ${PATCH_CMD} -p 0 -N -d ${BUILD_DIR}/sdl/src/external_sdl < ${PATCH_DIR}/sdl_haptics.diff) endif() endif() @@ -38,27 +31,15 @@ ExternalProject_Add(external_sdl URL_HASH ${SDL_HASH_TYPE}=${SDL_HASH} PREFIX ${BUILD_DIR}/sdl PATCH_COMMAND ${SDL_PATCH} - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/sdl - ${DEFAULT_CMAKE_FLAGS} - ${SDL_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/sdl ${DEFAULT_CMAKE_FLAGS} ${SDL_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/sdl ) if(BUILD_MODE STREQUAL Release AND WIN32) ExternalProject_Add_Step(external_sdl after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/sdl/include/sdl2 - ${HARVEST_TARGET}/sdl/include - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/sdl/lib - ${HARVEST_TARGET}/sdl/lib - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/sdl/bin - ${HARVEST_TARGET}/sdl/lib - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/sdl/include/sdl2 ${HARVEST_TARGET}/sdl/include + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/sdl/lib ${HARVEST_TARGET}/sdl/lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/sdl/bin ${HARVEST_TARGET}/sdl/lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/setup_msys2.cmake b/build_files/build_environment/cmake/setup_msys2.cmake index f82c49eda5f..d9f670c46f7 100644 --- a/build_files/build_environment/cmake/setup_msys2.cmake +++ b/build_files/build_environment/cmake/setup_msys2.cmake @@ -25,10 +25,7 @@ message("msys2_LIBDIR = ${msys2_LIBDIR}") message("Checking for msys2 base") if(NOT EXISTS "${DOWNLOAD_DIR}/msys2-base-x86_64-20221028.tar.xz") message("Downloading msys2-base") - file(DOWNLOAD - "https://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20221028.tar.xz" - "${DOWNLOAD_DIR}/msys2-base-x86_64-20221028.tar.xz" - ) + file(DOWNLOAD "https://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20221028.tar.xz" "${DOWNLOAD_DIR}/msys2-base-x86_64-20221028.tar.xz") endif() # Make msys2 root directory @@ -40,8 +37,7 @@ if(NOT EXISTS "${DOWNLOAD_DIR}/msys2") endif() # Extract msys2 -if((NOT EXISTS "${DOWNLOAD_DIR}/msys2/msys64/msys2_shell.cmd") AND - (EXISTS "${DOWNLOAD_DIR}/msys2-base-x86_64-20221028.tar.xz")) +if((NOT EXISTS "${DOWNLOAD_DIR}/msys2/msys64/msys2_shell.cmd") AND (EXISTS "${DOWNLOAD_DIR}/msys2-base-x86_64-20221028.tar.xz")) message("Extracting msys2 base") execute_process( COMMAND ${CMAKE_COMMAND} -E tar jxf ${DOWNLOAD_DIR}/msys2-base-x86_64-20221028.tar.xz @@ -98,10 +94,7 @@ endif() message("Checking for nasm") if(NOT EXISTS "${DOWNLOAD_DIR}/nasm-2.13.02-win64.zip") message("Downloading nasm") - file(DOWNLOAD - "http://www.nasm.us/pub/nasm/releasebuilds/2.13.02/win64/nasm-2.13.02-win64.zip" - "${DOWNLOAD_DIR}/nasm-2.13.02-win64.zip" - ) + file(DOWNLOAD "http://www.nasm.us/pub/nasm/releasebuilds/2.13.02/win64/nasm-2.13.02-win64.zip" "${DOWNLOAD_DIR}/nasm-2.13.02-win64.zip") endif() # extract nasm @@ -112,9 +105,7 @@ if((NOT EXISTS "${DOWNLOAD_DIR}/msys2/msys64/usr/bin/nasm.exe") AND (EXISTS "${D WORKING_DIRECTORY ${DOWNLOAD_DIR}/ ) execute_process( - COMMAND ${CMAKE_COMMAND} -E copy - "${DOWNLOAD_DIR}/nasm-2.13.02/nasm.exe" - "${DOWNLOAD_DIR}/msys2/msys64/usr/bin/nasm.exe" + COMMAND ${CMAKE_COMMAND} -E copy "${DOWNLOAD_DIR}/nasm-2.13.02/nasm.exe" "${DOWNLOAD_DIR}/msys2/msys64/usr/bin/nasm.exe" ) endif() @@ -122,10 +113,7 @@ message("Checking for perl") # download perl for libvpx if(NOT EXISTS "${DOWNLOAD_DIR}/strawberry-perl-5.38.0.1-64bit-portable.zip") message("Downloading perl") - file(DOWNLOAD - "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip" - "${DOWNLOAD_DIR}/strawberry-perl-5.38.0.1-64bit-portable.zip" - ) + file(DOWNLOAD "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip" "${DOWNLOAD_DIR}/strawberry-perl-5.38.0.1-64bit-portable.zip") endif() # make perl root directory @@ -150,27 +138,19 @@ endif() message("Checking for gas-preprocessor.pl") if(NOT EXISTS "${DOWNLOAD_DIR}/msys2/msys64/usr/bin/gas-preprocessor.pl") message("Downloading gas-preprocessor.pl") - file(DOWNLOAD - "https://raw.githubusercontent.com/FFmpeg/gas-preprocessor/9309c67acb535ca6248f092e96131d8eb07eefc1/gas-preprocessor.pl" - "${DOWNLOAD_DIR}/msys2/msys64/usr/bin/gas-preprocessor.pl" - ) + file(DOWNLOAD "https://raw.githubusercontent.com/FFmpeg/gas-preprocessor/9309c67acb535ca6248f092e96131d8eb07eefc1/gas-preprocessor.pl" "${DOWNLOAD_DIR}/msys2/msys64/usr/bin/gas-preprocessor.pl") endif() # Get ar-lib message("Checking for ar-lib") if(NOT EXISTS "${DOWNLOAD_DIR}/msys2/msys64/usr/bin/ar-lib") message("Downloading ar-lib") - file(DOWNLOAD - "https://raw.githubusercontent.com/gcc-mirror/gcc/releases/gcc-12.2.0/ar-lib" - "${DOWNLOAD_DIR}/msys2/msys64/usr/bin/ar-lib" - ) + file(DOWNLOAD "https://raw.githubusercontent.com/gcc-mirror/gcc/releases/gcc-12.2.0/ar-lib" "${DOWNLOAD_DIR}/msys2/msys64/usr/bin/ar-lib") endif() if(NOT EXISTS "${DOWNLOAD_DIR}/msys2/msys64/ming64sh.cmd") message("Installing ming64sh.cmd") execute_process( - COMMAND ${CMAKE_COMMAND} -E copy - ${PATCH_DIR}/ming64sh.cmd - ${DOWNLOAD_DIR}/msys2/msys64/ming64sh.cmd + COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/ming64sh.cmd ${DOWNLOAD_DIR}/msys2/msys64/ming64sh.cmd ) endif() diff --git a/build_files/build_environment/cmake/shaderc.cmake b/build_files/build_environment/cmake/shaderc.cmake index e03d0903217..4d4226769a1 100644 --- a/build_files/build_environment/cmake/shaderc.cmake +++ b/build_files/build_environment/cmake/shaderc.cmake @@ -16,12 +16,7 @@ ExternalProject_Add(external_shaderc URL_HASH ${SHADERC_HASH_TYPE}=${SHADERC_HASH} DOWNLOAD_DIR ${DOWNLOAD_DIR} PREFIX ${BUILD_DIR}/shaderc - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/shaderc - ${DEFAULT_CMAKE_FLAGS} - ${SHADERC_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/shaderc ${DEFAULT_CMAKE_FLAGS} ${SHADERC_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/shaderc ) @@ -37,28 +32,17 @@ add_dependencies( if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_shaderc after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/shaderc/include - ${HARVEST_TARGET}/shaderc/include - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/shaderc/bin/shaderc_shared.dll - ${HARVEST_TARGET}/shaderc/bin/shaderc_shared.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/shaderc/lib/shaderc_shared.lib - ${HARVEST_TARGET}/shaderc/lib/shaderc_shared.lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/shaderc/include ${HARVEST_TARGET}/shaderc/include + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/shaderc/bin/shaderc_shared.dll ${HARVEST_TARGET}/shaderc/bin/shaderc_shared.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/shaderc/lib/shaderc_shared.lib ${HARVEST_TARGET}/shaderc/lib/shaderc_shared.lib DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_shaderc after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/shaderc/bin/shaderc_shared_d.dll - ${HARVEST_TARGET}/shaderc/bin/shaderc_shared_d.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/shaderc/lib/shaderc_shared_d.lib - ${HARVEST_TARGET}/shaderc/lib/shaderc_shared_d.lib - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/shaderc/bin/shaderc_shared_d.dll ${HARVEST_TARGET}/shaderc/bin/shaderc_shared_d.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/shaderc/lib/shaderc_shared_d.lib ${HARVEST_TARGET}/shaderc/lib/shaderc_shared_d.lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/sndfile.cmake b/build_files/build_environment/cmake/sndfile.cmake index cfd738dd116..83ab1ccd4fc 100644 --- a/build_files/build_environment/cmake/sndfile.cmake +++ b/build_files/build_environment/cmake/sndfile.cmake @@ -15,19 +15,9 @@ if(NOT WIN32) DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${SNDFILE_HASH_TYPE}=${SNDFILE_HASH} PREFIX ${BUILD_DIR}/sndfile - - CONFIGURE_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && - ${SNDFILE_ENV} ${CONFIGURE_COMMAND} ${SNDFILE_OPTIONS} --prefix=${mingw_LIBDIR}/sndfile - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && - make install - + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && ${SNDFILE_ENV} ${CONFIGURE_COMMAND} ${SNDFILE_OPTIONS} --prefix=${mingw_LIBDIR}/sndfile + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sndfile/src/external_sndfile/ && make install INSTALL_DIR ${LIBDIR}/sndfile ) else() @@ -55,31 +45,17 @@ else() DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${SNDFILE_HASH_TYPE}=${SNDFILE_HASH} PREFIX ${BUILD_DIR}/sndfile - - PATCH_COMMAND ${CMAKE_COMMAND} -E copy - ${PATCH_DIR}/cmake/modules/FindLame.cmake - ${BUILD_DIR}/sndfile/src/external_sndfile/cmake/FindLame.cmake - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/sndfile - ${DEFAULT_CMAKE_FLAGS} - ${SNDFILE_EXTRA_ARGS} - + PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmake/modules/FindLame.cmake ${BUILD_DIR}/sndfile/src/external_sndfile/cmake/FindLame.cmake + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/sndfile ${DEFAULT_CMAKE_FLAGS} ${SNDFILE_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/sndfile ) endif() if(BUILD_MODE STREQUAL Release AND WIN32) ExternalProject_Add_Step(external_sndfile after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/sndfile/bin/sndfile.dll - ${HARVEST_TARGET}/sndfile/lib/sndfile.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/sndfile/lib/sndfile.lib - ${HARVEST_TARGET}/sndfile/lib/sndfile.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/sndfile/include/sndfile.h - ${HARVEST_TARGET}/sndfile/include/sndfile.h + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/sndfile/bin/sndfile.dll ${HARVEST_TARGET}/sndfile/lib/sndfile.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/sndfile/lib/sndfile.lib ${HARVEST_TARGET}/sndfile/lib/sndfile.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/sndfile/include/sndfile.h ${HARVEST_TARGET}/sndfile/include/sndfile.h DEPENDEES install ) diff --git a/build_files/build_environment/cmake/spnav.cmake b/build_files/build_environment/cmake/spnav.cmake index 6535e0d9927..1f9d56f0b57 100644 --- a/build_files/build_environment/cmake/spnav.cmake +++ b/build_files/build_environment/cmake/spnav.cmake @@ -8,25 +8,20 @@ ExternalProject_Add(external_spnav URL_HASH ${SPNAV_HASH_TYPE}=${SPNAV_HASH} PREFIX ${BUILD_DIR}/spnav - CONFIGURE_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/spnav/src/external_spnav/ && - ${CONFIGURE_COMMAND} - --prefix=${LIBDIR}/spnav - # X11 is not needed as Blender polls the device as part of the GHOST event loop. - # This is used to support `3dxserv`, however this is no longer supported by 3DCONNEXION. - # Disable so building without X11 is supported (WAYLAND only). - --disable-x11 - --disable-shared - --enable-static - --with-pic - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/spnav/src/external_spnav/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/spnav/src/external_spnav/ && - make install + CONFIGURE_COMMAND + ${CONFIGURE_ENV} && + cd ${BUILD_DIR}/spnav/src/external_spnav/ && + ${CONFIGURE_COMMAND} + --prefix=${LIBDIR}/spnav + # X11 is not needed as Blender polls the device as part of the GHOST event loop. + # This is used to support `3dxserv`, however this is no longer supported by 3DCONNEXION. + # Disable so building without X11 is supported (WAYLAND only). + --disable-x11 + --disable-shared + --enable-static + --with-pic + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/spnav/src/external_spnav/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/spnav/src/external_spnav/ && make install INSTALL_DIR ${LIBDIR}/spnav ) diff --git a/build_files/build_environment/cmake/sqlite.cmake b/build_files/build_environment/cmake/sqlite.cmake index 57c3f0fb97f..fca5d9b62a7 100644 --- a/build_files/build_environment/cmake/sqlite.cmake +++ b/build_files/build_environment/cmake/sqlite.cmake @@ -32,11 +32,7 @@ if(UNIX) -DSQLITE_MAX_VARIABLE_NUMBER=250000 \ -fPIC" ) - set(SQLITE_CONFIGURE_ENV - ${SQLITE_CONFIGURE_ENV} && - export LDFLAGS=${SQLITE_LDFLAGS} && - export CFLAGS=${SQLITE_CFLAGS} - ) + set(SQLITE_CONFIGURE_ENV ${SQLITE_CONFIGURE_ENV} && export LDFLAGS=${SQLITE_LDFLAGS} && export CFLAGS=${SQLITE_CFLAGS}) set(SQLITE_CONFIGURATION_ARGS ${SQLITE_CONFIGURATION_ARGS} --enable-threadsafe @@ -59,18 +55,8 @@ ExternalProject_Add(external_sqlite DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${SQLITE_HASH_TYPE}=${SQLITE_HASH} PREFIX ${BUILD_DIR}/sqlite - - CONFIGURE_COMMAND ${SQLITE_CONFIGURE_ENV} && - cd ${BUILD_DIR}/sqlite/src/external_sqlite/ && - ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/sqlite ${SQLITE_CONFIGURATION_ARGS} - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/sqlite/src/external_sqlite/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/sqlite/src/external_sqlite/ && - make install - + CONFIGURE_COMMAND ${SQLITE_CONFIGURE_ENV} && cd ${BUILD_DIR}/sqlite/src/external_sqlite/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/sqlite ${SQLITE_CONFIGURATION_ARGS} + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sqlite/src/external_sqlite/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/sqlite/src/external_sqlite/ && make install INSTALL_DIR ${LIBDIR}/sqlite ) diff --git a/build_files/build_environment/cmake/sse2neon.cmake b/build_files/build_environment/cmake/sse2neon.cmake index c8a8f494976..7113d71e04d 100644 --- a/build_files/build_environment/cmake/sse2neon.cmake +++ b/build_files/build_environment/cmake/sse2neon.cmake @@ -9,9 +9,6 @@ ExternalProject_Add(external_sse2neon PREFIX ${BUILD_DIR}/sse2neon CONFIGURE_COMMAND echo sse2neon - Nothing to configure BUILD_COMMAND echo sse2neon - nothing to build - - INSTALL_COMMAND mkdir -p ${LIBDIR}/sse2neon && - cp ${BUILD_DIR}/sse2neon/src/external_sse2neon/sse2neon.h ${LIBDIR}/sse2neon - + INSTALL_COMMAND mkdir -p ${LIBDIR}/sse2neon && cp ${BUILD_DIR}/sse2neon/src/external_sse2neon/sse2neon.h ${LIBDIR}/sse2neon INSTALL_DIR ${LIBDIR}/sse2neon ) diff --git a/build_files/build_environment/cmake/ssl.cmake b/build_files/build_environment/cmake/ssl.cmake index d515eff0e93..7ddc24a62a6 100644 --- a/build_files/build_environment/cmake/ssl.cmake +++ b/build_files/build_environment/cmake/ssl.cmake @@ -35,33 +35,22 @@ else() DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${SSL_HASH_TYPE}=${SSL_HASH} PREFIX ${BUILD_DIR}/ssl - - CONFIGURE_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/ssl/src/external_ssl/ && - ${SSL_CONFIGURE_COMMAND} - --prefix=${LIBDIR}/ssl - --openssldir=${LIBDIR}/ssl - # Without this: Python will use the build directories. - # using the system directory `/etc/ssl` might seem the obvious choice, - # there is no guarantee the version of SSL used with Blender is compatible with the systems, - # where changes to the SSL configuration format can cause SSL not to load (see #114452). - # So reference a directory known not to exist. Ideally Blender could distribute its own SSL - # directory, but this isn't compatible with hard coded paths. - # See #111132 & https://github.com/openssl/openssl/issues/20185 for details. - -DOPENSSLDIR=\\"/dev/null\\" - no-shared - no-idea no-mdc2 no-rc5 no-zlib no-ssl3 enable-unit-test no-ssl3-method enable-rfc3779 enable-cms - --config=${CMAKE_CURRENT_SOURCE_DIR}/cmake/ssl.conf - ${SSL_OS_COMPILER} - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/ssl/src/external_ssl/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/ssl/src/external_ssl/ && - make install - + CONFIGURE_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ssl/src/external_ssl/ && ${SSL_CONFIGURE_COMMAND} --prefix=${LIBDIR}/ssl + --openssldir=${LIBDIR}/ssl + # Without this: Python will use the build directories. + # using the system directory `/etc/ssl` might seem the obvious choice, + # there is no guarantee the version of SSL used with Blender is compatible with the systems, + # where changes to the SSL configuration format can cause SSL not to load (see #114452). + # So reference a directory known not to exist. Ideally Blender could distribute its own SSL + # directory, but this isn't compatible with hard coded paths. + # See #111132 & https://github.com/openssl/openssl/issues/20185 for details. + -DOPENSSLDIR=\\"/dev/null\\" + no-shared + no-idea no-mdc2 no-rc5 no-zlib no-ssl3 enable-unit-test no-ssl3-method enable-rfc3779 enable-cms + --config=${CMAKE_CURRENT_SOURCE_DIR}/cmake/ssl.conf + ${SSL_OS_COMPILER} + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ssl/src/external_ssl/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/ssl/src/external_ssl/ && make install INSTALL_DIR ${LIBDIR}/ssl ) endif() diff --git a/build_files/build_environment/cmake/tbb.cmake b/build_files/build_environment/cmake/tbb.cmake index 2901d8bd4f2..27b2d7a637a 100644 --- a/build_files/build_environment/cmake/tbb.cmake +++ b/build_files/build_environment/cmake/tbb.cmake @@ -25,19 +25,9 @@ ExternalProject_Add(external_tbb DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${TBB_HASH_TYPE}=${TBB_HASH} PREFIX ${BUILD_DIR}/tbb - - PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy - ${PATCH_DIR}/cmakelists_tbb.txt - ${BUILD_DIR}/tbb/src/external_tbb/CMakeLists.txt && - - ${CMAKE_COMMAND} -E copy - ${BUILD_DIR}/tbb/src/external_tbb/build/vs2013/version_string.ver - ${BUILD_DIR}/tbb/src/external_tbb/build/version_string.ver.in && - - ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/tbb/src/external_tbb < - ${PATCH_DIR}/tbb.diff - + PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_tbb.txt ${BUILD_DIR}/tbb/src/external_tbb/CMakeLists.txt && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/tbb/src/external_tbb/build/vs2013/version_string.ver ${BUILD_DIR}/tbb/src/external_tbb/build/version_string.ver.in && + ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/tbb/src/external_tbb < ${PATCH_DIR}/tbb.diff CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/tbb ${DEFAULT_CMAKE_FLAGS} ${TBB_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/tbb ) @@ -45,72 +35,35 @@ ExternalProject_Add(external_tbb if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_tbb after_install - # `findtbb.cmake` in some deps *NEEDS* to find `tbb_debug.lib` even if they are not going - # to use it to make that test pass, we place a copy with the right name in the lib folder. - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbb.lib - ${LIBDIR}/tbb/lib/tbb_debug.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbbmalloc.lib - ${LIBDIR}/tbb/lib/tbbmalloc_debug.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbb.dll - ${LIBDIR}/tbb/bin/tbb_debug.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbbmalloc.dll - ${LIBDIR}/tbb/bin/tbbmalloc_debug.dll + # findtbb.cmake in some deps *NEEDS* to find tbb_debug.lib even if they are not going to use it + # to make that test pass, we place a copy with the right name in the lib folder. + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb.lib ${LIBDIR}/tbb/lib/tbb_debug.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc.lib ${LIBDIR}/tbb/lib/tbbmalloc_debug.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbb.dll ${LIBDIR}/tbb/bin/tbb_debug.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbbmalloc.dll ${LIBDIR}/tbb/bin/tbbmalloc_debug.dll # Normal collection of build artifacts - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbb.lib - ${HARVEST_TARGET}/tbb/lib/tbb.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbb.dll - ${HARVEST_TARGET}/tbb/bin/tbb.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbbmalloc.lib - ${HARVEST_TARGET}/tbb/lib/tbbmalloc.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbbmalloc.dll - ${HARVEST_TARGET}/tbb/bin/tbbmalloc.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbbmalloc_proxy.lib - ${HARVEST_TARGET}/tbb/lib/tbbmalloc_proxy.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbbmalloc_proxy.dll - ${HARVEST_TARGET}/tbb/bin/tbbmalloc_proxy.dll - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/tbb/include/ - ${HARVEST_TARGET}/tbb/include/ - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb.lib ${HARVEST_TARGET}/tbb/lib/tbb.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbb.dll ${HARVEST_TARGET}/tbb/bin/tbb.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbbmalloc.dll ${HARVEST_TARGET}/tbb/bin/tbbmalloc.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc_proxy.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc_proxy.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbbmalloc_proxy.dll ${HARVEST_TARGET}/tbb/bin/tbbmalloc_proxy.dll + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tbb/include/ ${HARVEST_TARGET}/tbb/include/ DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_tbb after_install - # `findtbb.cmake` in some deps *NEEDS* to find `tbb.lib` even if they are not going to use - # it to make that test pass, we place a copy with the right name in the lib folder. - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbb_debug.lib - ${LIBDIR}/tbb/lib/tbb.lib + # findtbb.cmake in some deps *NEEDS* to find tbb.lib even if they are not going to use it + # to make that test pass, we place a copy with the right name in the lib folder. + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb_debug.lib ${LIBDIR}/tbb/lib/tbb.lib # Normal collection of build artifacts - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbb_debug.lib - ${HARVEST_TARGET}/tbb/lib/tbb_debug.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbb_debug.dll - ${HARVEST_TARGET}/tbb/bin/tbb_debug.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbbmalloc_debug.lib - ${HARVEST_TARGET}/tbb/lib/tbbmalloc_debug.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbbmalloc_proxy_debug.lib - ${HARVEST_TARGET}/tbb/lib/tbbmalloc_proxy_debug.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbbmalloc_debug.dll - ${HARVEST_TARGET}/tbb/bin/tbbmalloc_debug.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbbmalloc_proxy_debug.dll - ${HARVEST_TARGET}/tbb/bin/tbbmalloc_proxy_debug.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbb_debug.lib ${HARVEST_TARGET}/tbb/lib/tbb_debug.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbb_debug.dll ${HARVEST_TARGET}/tbb/bin/tbb_debug.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc_debug.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc_debug.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/lib/tbbmalloc_proxy_debug.lib ${HARVEST_TARGET}/tbb/lib/tbbmalloc_proxy_debug.lib + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbbmalloc_debug.dll ${HARVEST_TARGET}/tbb/bin/tbbmalloc_debug.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tbb/bin/tbbmalloc_proxy_debug.dll ${HARVEST_TARGET}/tbb/bin/tbbmalloc_proxy_debug.dll DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/theora.cmake b/build_files/build_environment/cmake/theora.cmake index c5286c40761..2b6944c3480 100644 --- a/build_files/build_environment/cmake/theora.cmake +++ b/build_files/build_environment/cmake/theora.cmake @@ -14,30 +14,16 @@ if(NOT WIN32) DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${THEORA_HASH_TYPE}=${THEORA_HASH} PREFIX ${BUILD_DIR}/theora - - PATCH_COMMAND ${PATCH_CMD} -p 0 -d - ${BUILD_DIR}/theora/src/external_theora < - ${PATCH_DIR}/theora.diff - - CONFIGURE_COMMAND ${THEORA_CONFIGURE_ENV} && - cd ${BUILD_DIR}/theora/src/external_theora/ && - ${CONFIGURE_COMMAND} - --prefix=${LIBDIR}/theora - --disable-shared - --enable-static - --with-pic - --with-ogg=${LIBDIR}/ogg - --with-vorbis=${LIBDIR}/vorbis - --disable-examples - - BUILD_COMMAND ${THEORA_CONFIGURE_ENV} && - cd ${BUILD_DIR}/theora/src/external_theora/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${THEORA_CONFIGURE_ENV} && - cd ${BUILD_DIR}/theora/src/external_theora/ && - make install - + PATCH_COMMAND ${PATCH_CMD} -p 0 -d ${BUILD_DIR}/theora/src/external_theora < ${PATCH_DIR}/theora.diff + CONFIGURE_COMMAND ${THEORA_CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/theora + --disable-shared + --enable-static + --with-pic + --with-ogg=${LIBDIR}/ogg + --with-vorbis=${LIBDIR}/vorbis + --disable-examples + BUILD_COMMAND ${THEORA_CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${THEORA_CONFIGURE_ENV} && cd ${BUILD_DIR}/theora/src/external_theora/ && make install INSTALL_DIR ${LIBDIR}/theora ) else() @@ -47,24 +33,10 @@ else() DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${THEORA_HASH_TYPE}=${THEORA_HASH} PREFIX ${BUILD_DIR}/theora - - PATCH_COMMAND COMMAND - ${CMAKE_COMMAND} -E copy - ${PATCH_DIR}/cmakelists_theora.txt - ${BUILD_DIR}/theora/src/external_theora/CMakeLists.txt && - ${CMAKE_COMMAND} -E copy - ${PATCH_DIR}/libtheora.def - ${BUILD_DIR}/theora/src/external_theora/libtheora.def && - ${CMAKE_COMMAND} -E copy - ${BUILD_DIR}/vorbis/src/external_vorbis/cmake/FindOgg.cmake - ${BUILD_DIR}/theora/src/external_theora/FindOgg.cmake - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/theora - -DOGG_ROOT=${LIBDIR}/ogg - ${DEFAULT_CMAKE_FLAGS} - -DLIBDIR=${LIBDIR} - + PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/cmakelists_theora.txt ${BUILD_DIR}/theora/src/external_theora/CMakeLists.txt && + ${CMAKE_COMMAND} -E copy ${PATCH_DIR}/libtheora.def ${BUILD_DIR}/theora/src/external_theora/libtheora.def && + ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/vorbis/src/external_vorbis/cmake/FindOgg.cmake ${BUILD_DIR}/theora/src/external_theora/FindOgg.cmake + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/theora -DOGG_ROOT=${LIBDIR}/ogg ${DEFAULT_CMAKE_FLAGS} -DLIBDIR=${LIBDIR} INSTALL_DIR ${LIBDIR}/theora ) endif() diff --git a/build_files/build_environment/cmake/tiff.cmake b/build_files/build_environment/cmake/tiff.cmake index ef3f544ffc7..7fd314d2b7c 100644 --- a/build_files/build_environment/cmake/tiff.cmake +++ b/build_files/build_environment/cmake/tiff.cmake @@ -22,12 +22,7 @@ ExternalProject_Add(external_tiff DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${TIFF_HASH_TYPE}=${TIFF_HASH} PREFIX ${BUILD_DIR}/tiff - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/tiff - ${DEFAULT_CMAKE_FLAGS} - ${TIFF_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/tiff ${DEFAULT_CMAKE_FLAGS} ${TIFF_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/tiff ) @@ -39,13 +34,8 @@ add_dependencies( if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_tiff after_install - COMMAND - ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tiff/lib/tiff.lib - ${HARVEST_TARGET}/tiff/lib/libtiff.lib && - ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/tiff/include/ - ${HARVEST_TARGET}/tiff/include/ + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tiff/lib/tiff.lib ${HARVEST_TARGET}/tiff/lib/libtiff.lib && + ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/tiff/include/ ${HARVEST_TARGET}/tiff/include/ DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/usd.cmake b/build_files/build_environment/cmake/usd.cmake index 99ab8b3366c..1251de4d89d 100644 --- a/build_files/build_environment/cmake/usd.cmake +++ b/build_files/build_environment/cmake/usd.cmake @@ -111,21 +111,9 @@ ExternalProject_Add(external_usd CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} PREFIX ${BUILD_DIR}/usd LIST_SEPARATOR ^^ - - PATCH_COMMAND - ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/usd/src/external_usd < - ${PATCH_DIR}/usd.diff && - ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/usd/src/external_usd < - ${PATCH_DIR}/usd_core_profile.diff - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/usd - -Wno-dev - ${DEFAULT_CMAKE_FLAGS} - ${USD_EXTRA_ARGS} - + PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/usd/src/external_usd < ${PATCH_DIR}/usd.diff && + ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/usd/src/external_usd < ${PATCH_DIR}/usd_core_profile.diff + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/usd -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${USD_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/usd ) @@ -140,8 +128,7 @@ add_dependencies( openvdb ) -# Since USD 21.11 the libraries are prefixed with "usd_", -# i.e. "libusd_m.a" became "libusd_usd_m.a". +# Since USD 21.11 the libraries are prefixed with "usd_", i.e. "libusd_m.a" became "libusd_usd_m.a". # See https://github.com/PixarAnimationStudios/USD/blob/release/CHANGELOG.md#2111---2021-11-01 if(NOT WIN32) if(USD_VERSION VERSION_LESS 21.11) @@ -154,24 +141,15 @@ endif() if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_usd after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/usd - ${HARVEST_TARGET}/usd - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/usd ${HARVEST_TARGET}/usd DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_usd after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/usd/lib/python - ${HARVEST_TARGET}/usd/lib/debug/python - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/usd/lib/usd_ms_d.dll - ${HARVEST_TARGET}/usd/lib/usd_ms_d.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/usd/lib/usd_ms_d.lib - ${HARVEST_TARGET}/usd/lib/usd_ms_d.lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/usd/lib/python ${HARVEST_TARGET}/usd/lib/debug/python + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/usd/lib/usd_ms_d.dll ${HARVEST_TARGET}/usd/lib/usd_ms_d.dll + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/usd/lib/usd_ms_d.lib ${HARVEST_TARGET}/usd/lib/usd_ms_d.lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake index 096b115816b..d9efc173c55 100644 --- a/build_files/build_environment/cmake/versions.cmake +++ b/build_files/build_environment/cmake/versions.cmake @@ -639,10 +639,10 @@ set(BROTLI_HASH_TYPE SHA256) set(BROTLI_FILE brotli-v${BROTLI_VERSION}.tar.gz) set(BROTLI_CPE "cpe:2.3:a:google:brotli:${BROTLI_VERSION}:*:*:*:*:*:*:*") -set(OPENPGL_VERSION v0.6.0) -set(OPENPGL_SHORT_VERSION 0.6.0) +set(OPENPGL_VERSION v0.5.0) +set(OPENPGL_SHORT_VERSION 0.5.0) set(OPENPGL_URI https://github.com/OpenPathGuidingLibrary/openpgl/archive/refs/tags/${OPENPGL_VERSION}.tar.gz) -set(OPENPGL_HASH 4192a4096ee3e3d31878cd013f8de23418c8037c576537551f946c4811931c5e) +set(OPENPGL_HASH 1ec806d434d45e43e098f82ee9be0cb74928343898c57490b34ff80584e9805a) set(OPENPGL_HASH_TYPE SHA256) set(OPENPGL_FILE openpgl-${OPENPGL_VERSION}.tar.gz) diff --git a/build_files/build_environment/cmake/vorbis.cmake b/build_files/build_environment/cmake/vorbis.cmake index e141c4d0908..13074256cdc 100644 --- a/build_files/build_environment/cmake/vorbis.cmake +++ b/build_files/build_environment/cmake/vorbis.cmake @@ -3,18 +3,13 @@ # SPDX-License-Identifier: GPL-2.0-or-later ExternalProject_Add(external_vorbis - URL file://${PACKAGE_DIR}/${VORBIS_FILE} - DOWNLOAD_DIR ${DOWNLOAD_DIR} - URL_HASH ${VORBIS_HASH_TYPE}=${VORBIS_HASH} - PREFIX ${BUILD_DIR}/vorbis - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/vorbis - -DOGG_ROOT=${LIBDIR}/ogg - ${DEFAULT_CMAKE_FLAGS} - - INSTALL_DIR ${LIBDIR}/vorbis -) + URL file://${PACKAGE_DIR}/${VORBIS_FILE} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH ${VORBIS_HASH_TYPE}=${VORBIS_HASH} + PREFIX ${BUILD_DIR}/vorbis + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/vorbis -DOGG_ROOT=${LIBDIR}/ogg ${DEFAULT_CMAKE_FLAGS} + INSTALL_DIR ${LIBDIR}/vorbis + ) add_dependencies( external_vorbis diff --git a/build_files/build_environment/cmake/vpx.cmake b/build_files/build_environment/cmake/vpx.cmake index 243885ec1c5..aca22358ef6 100644 --- a/build_files/build_environment/cmake/vpx.cmake +++ b/build_files/build_environment/cmake/vpx.cmake @@ -9,11 +9,7 @@ if(WIN32) # layer using win32 threads. So all this patch does is make it not find # pthead.h - set(VPX_PATCH - ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/vpx/src/external_vpx < - ${PATCH_DIR}/vpx_windows.diff - ) + set(VPX_PATCH ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/vpx/src/external_vpx < ${PATCH_DIR}/vpx_windows.diff) if(MSVC_VERSION GREATER_EQUAL 1920) # 2019 set(VPX_COMPILER_STRING vs16) @@ -34,23 +30,10 @@ if(WIN32) set(VPX_INCLUDE_PATH ${BUILD_DIR}/vpx/src/external_vpx/vpx-vp8-vp9-${VPX_INCL_ARCH}md-${VPX_COMPILER_STRING}-v${VPX_VERSION}) - set(VPX_BUILD_COMMAND - ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/vpx/src/external_vpx/ && - make dist && - msbuild /m vpx.sln /p:OutDir=${BUILD_DIR}/vpx/src/external_vpx-build/ /p:Configuration=Release - ) - set(VPX_INSTALL_COMMAND - ${CONFIGURE_ENV} && - ${CMAKE_COMMAND} -E copy_directory - ${VPX_INCLUDE_PATH}/include - ${LIBDIR}/vpx/include && - ${CMAKE_COMMAND} -E copy_directory - ${BUILD_DIR}/vpx/src/external_vpx-build/ - ${LIBDIR}/vpx/lib/ && - ${CMAKE_COMMAND} -E copy - ${LIBDIR}/vpx/lib/vpxmd.lib - ${LIBDIR}/vpx/lib/vpx.lib) + set(VPX_BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vpx/src/external_vpx/ && make dist && msbuild /m vpx.sln /p:OutDir=${BUILD_DIR}/vpx/src/external_vpx-build/ /p:Configuration=Release) + set(VPX_INSTALL_COMMAND ${CONFIGURE_ENV} && ${CMAKE_COMMAND} -E copy_directory ${VPX_INCLUDE_PATH}/include ${LIBDIR}/vpx/include && + ${CMAKE_COMMAND} -E copy_directory ${BUILD_DIR}/vpx/src/external_vpx-build/ ${LIBDIR}/vpx/lib/ && + ${CMAKE_COMMAND} -E copy ${LIBDIR}/vpx/lib/vpxmd.lib ${LIBDIR}/vpx/lib/vpx.lib) else() if(APPLE) if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64") @@ -64,14 +47,8 @@ else() set(VPX_CONFIGURE_COMMAND ${CONFIGURE_ENV}) - set(VPX_BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/vpx/src/external_vpx/ && - make -j${MAKE_THREADS} - ) - set(VPX_INSTALL_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/vpx/src/external_vpx/ && - make install - ) + set(VPX_BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vpx/src/external_vpx/ && make -j${MAKE_THREADS}) + set(VPX_INSTALL_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/vpx/src/external_vpx/ && make install) endif() if(NOT BLENDER_PLATFORM_ARM) @@ -89,7 +66,6 @@ ExternalProject_Add(external_vpx DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${VPX_HASH_TYPE}=${VPX_HASH} PREFIX ${BUILD_DIR}/vpx - CONFIGURE_COMMAND ${VPX_CONFIGURE_COMMAND} && cd ${BUILD_DIR}/vpx/src/external_vpx/ && ${CONFIGURE_COMMAND_NO_TARGET} --prefix=${LIBDIR}/vpx @@ -102,7 +78,6 @@ ExternalProject_Add(external_vpx --enable-vp8 --enable-vp9 ${VPX_EXTRA_FLAGS} - BUILD_COMMAND ${VPX_BUILD_COMMAND} INSTALL_COMMAND ${VPX_INSTALL_COMMAND} PATCH_COMMAND ${VPX_PATCH} diff --git a/build_files/build_environment/cmake/vulkan.cmake b/build_files/build_environment/cmake/vulkan.cmake index 80523563d52..0f7dd4549fe 100644 --- a/build_files/build_environment/cmake/vulkan.cmake +++ b/build_files/build_environment/cmake/vulkan.cmake @@ -8,12 +8,7 @@ ExternalProject_Add(external_vulkan_headers URL file://${PACKAGE_DIR}/${VULKAN_HEADERS_FILE} URL_HASH ${VULKAN_HEADERS_HASH_TYPE}=${VULKAN_HEADERS_HASH} PREFIX ${BUILD_DIR}/vulkan_headers - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/vulkan_headers - -Wno-dev ${DEFAULT_CMAKE_FLAGS} - ${VULKAN_HEADERS_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/vulkan_headers -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${VULKAN_HEADERS_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/vulkan_headers ) @@ -36,13 +31,7 @@ ExternalProject_Add(external_vulkan_loader URL file://${PACKAGE_DIR}/${VULKAN_LOADER_FILE} URL_HASH ${VULKAN_LOADER_HASH_TYPE}=${VULKAN_LOADER_HASH} PREFIX ${BUILD_DIR}/vulkan_loader - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/vulkan_loader - -Wno-dev - ${DEFAULT_CMAKE_FLAGS} - ${VULKAN_LOADER_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/vulkan_loader -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${VULKAN_LOADER_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/vulkan_loader ) @@ -59,12 +48,8 @@ if(UNIX AND NOT APPLE) elseif(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_vulkan_loader after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/vulkan_loader/ - ${HARVEST_TARGET}/vulkan - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/vulkan_headers/ - ${HARVEST_TARGET}/vulkan + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/vulkan_loader/ ${HARVEST_TARGET}/vulkan + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/vulkan_headers/ ${HARVEST_TARGET}/vulkan DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/wayland.cmake b/build_files/build_environment/cmake/wayland.cmake index bbf1f7e5801..778237f8926 100644 --- a/build_files/build_environment/cmake/wayland.cmake +++ b/build_files/build_environment/cmake/wayland.cmake @@ -7,7 +7,6 @@ ExternalProject_Add(external_wayland DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${WAYLAND_HASH_TYPE}=${WAYLAND_HASH} PREFIX ${BUILD_DIR}/wayland - # Use `-E` so the `PKG_CONFIG_PATH` can be defined to link against our own LIBEXPAT & LIBXML2. # # NOTE: passing link args "ffi/lib" should not be needed, but @@ -15,18 +14,8 @@ ExternalProject_Add(external_wayland # # NOTE: `-lm` is needed for `libxml2` which is a static library that uses `libm.so`, # without this, math symbols such as `floor` aren't found. - CONFIGURE_COMMAND - ${CMAKE_COMMAND} -E env - PKG_CONFIG_PATH=${LIBDIR}/expat/lib/pkgconfig:${LIBDIR}/xml2/lib/pkgconfig:${LIBDIR}/ffi/lib/pkgconfig:$PKG_CONFIG_PATH - ${MESON} - --prefix ${LIBDIR}/wayland - ${MESON_BUILD_TYPE} - -Ddocumentation=false - -Dtests=false - -D "c_link_args=-L${LIBDIR}/ffi/lib -lm" - . - ../external_wayland - + CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env PKG_CONFIG_PATH=${LIBDIR}/expat/lib/pkgconfig:${LIBDIR}/xml2/lib/pkgconfig:${LIBDIR}/ffi/lib/pkgconfig:$PKG_CONFIG_PATH + ${MESON} --prefix ${LIBDIR}/wayland ${MESON_BUILD_TYPE} -Ddocumentation=false -Dtests=false -D "c_link_args=-L${LIBDIR}/ffi/lib -lm" . ../external_wayland BUILD_COMMAND ninja INSTALL_COMMAND ninja install ) diff --git a/build_files/build_environment/cmake/wayland_libdecor.cmake b/build_files/build_environment/cmake/wayland_libdecor.cmake index 0df79ebfb9d..a0310a9eb88 100644 --- a/build_files/build_environment/cmake/wayland_libdecor.cmake +++ b/build_files/build_environment/cmake/wayland_libdecor.cmake @@ -12,10 +12,6 @@ ExternalProject_Add(external_wayland_libdecor PREFIX ${BUILD_DIR}/wayland_libdecor BUILD_COMMAND echo . CONFIGURE_COMMAND echo . - - INSTALL_COMMAND cp - ../external_wayland_libdecor/src/libdecor.h - ${LIBDIR}/wayland_libdecor/include/libdecor-0/libdecor.h - + INSTALL_COMMAND cp ../external_wayland_libdecor/src/libdecor.h ${LIBDIR}/wayland_libdecor/include/libdecor-0/libdecor.h INSTALL_DIR ${LIBDIR}/wayland_libdecor/include/libdecor-0 ) diff --git a/build_files/build_environment/cmake/wayland_protocols.cmake b/build_files/build_environment/cmake/wayland_protocols.cmake index 29e37975384..f5ddd137a28 100644 --- a/build_files/build_environment/cmake/wayland_protocols.cmake +++ b/build_files/build_environment/cmake/wayland_protocols.cmake @@ -8,16 +8,8 @@ ExternalProject_Add(external_wayland_protocols URL_HASH ${WL_PROTOCOLS_HASH_TYPE}=${WL_PROTOCOLS_HASH} PREFIX ${BUILD_DIR}/wayland-protocols # Use `-E` so the `PKG_CONFIG_PATH` can be defined to link against our own WAYLAND. - - CONFIGURE_COMMAND ${CMAKE_COMMAND} -E - env PKG_CONFIG_PATH=${LIBDIR}/wayland/lib64/pkgconfig:$PKG_CONFIG_PATH - ${MESON} - --prefix ${LIBDIR}/wayland-protocols - ${MESON_BUILD_TYPE} - . - ../external_wayland_protocols - -Dtests=false - + CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env PKG_CONFIG_PATH=${LIBDIR}/wayland/lib64/pkgconfig:$PKG_CONFIG_PATH + ${MESON} --prefix ${LIBDIR}/wayland-protocols ${MESON_BUILD_TYPE} . ../external_wayland_protocols -Dtests=false BUILD_COMMAND ninja INSTALL_COMMAND ninja install ) diff --git a/build_files/build_environment/cmake/wayland_weston.cmake b/build_files/build_environment/cmake/wayland_weston.cmake index 2d61b28d081..ff97f4222b9 100644 --- a/build_files/build_environment/cmake/wayland_weston.cmake +++ b/build_files/build_environment/cmake/wayland_weston.cmake @@ -20,35 +20,36 @@ ExternalProject_Add(external_wayland_weston # - Keep X11 and WAYLAND back-ends enabled so it's possible # to run the instance inside existing X11/WAYLAND sessions (for debugging). CONFIGURE_COMMAND ${WAYLAND_WESTON_CONFIGURE_ENV} && - ${CMAKE_COMMAND} -E env ${WAYLAND_WESTON_PKG_ENV} ${MESON} setup - ${MESON_BUILD_TYPE} - --prefix ${LIBDIR}/wayland_weston - --libdir lib - -Dbackend-default=headless # For tests. - -Dbackend-drm-screencast-vaapi=false - -Dbackend-drm=false - -Dbackend-pipewire=false - -Dbackend-rdp=false - -Dbackend-vnc=false - -Dcolor-management-lcms=false - -Ddemo-clients=false - -Ddoc=false - -Dimage-jpeg=false - -Dimage-webp=false - -Dpipewire=false - -Dremoting=false - -Dscreenshare=false - -Dshell-fullscreen=false - -Dshell-ivi=false - -Dshell-kiosk=false - -Dsimple-clients= - -Dsystemd=false - -Dtest-junit-xml=false - -Dtools= - -Dwcap-decode=false - -Dxwayland=false - ${BUILD_DIR}/wayland_weston/src/external_wayland_weston-build - ${BUILD_DIR}/wayland_weston/src/external_wayland_weston + ${CMAKE_COMMAND} -E env ${WAYLAND_WESTON_PKG_ENV} + ${MESON} setup + ${MESON_BUILD_TYPE} + --prefix ${LIBDIR}/wayland_weston + --libdir lib + -Dbackend-default=headless # For tests. + -Dbackend-drm-screencast-vaapi=false + -Dbackend-drm=false + -Dbackend-pipewire=false + -Dbackend-rdp=false + -Dbackend-vnc=false + -Dcolor-management-lcms=false + -Ddemo-clients=false + -Ddoc=false + -Dimage-jpeg=false + -Dimage-webp=false + -Dpipewire=false + -Dremoting=false + -Dscreenshare=false + -Dshell-fullscreen=false + -Dshell-ivi=false + -Dshell-kiosk=false + -Dsimple-clients= + -Dsystemd=false + -Dtest-junit-xml=false + -Dtools= + -Dwcap-decode=false + -Dxwayland=false + ${BUILD_DIR}/wayland_weston/src/external_wayland_weston-build + ${BUILD_DIR}/wayland_weston/src/external_wayland_weston BUILD_COMMAND ninja INSTALL_COMMAND ninja install diff --git a/build_files/build_environment/cmake/webp.cmake b/build_files/build_environment/cmake/webp.cmake index 9be9c4fc1a3..3a87b36ac60 100644 --- a/build_files/build_environment/cmake/webp.cmake +++ b/build_files/build_environment/cmake/webp.cmake @@ -28,23 +28,14 @@ ExternalProject_Add(external_webp DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${WEBP_HASH_TYPE}=${WEBP_HASH} PREFIX ${BUILD_DIR}/webp - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/webp - -Wno-dev - ${DEFAULT_CMAKE_FLAGS} - ${WEBP_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/webp -Wno-dev ${DEFAULT_CMAKE_FLAGS} ${WEBP_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/webp ) if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_webp after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/webp - ${HARVEST_TARGET}/webp - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/webp ${HARVEST_TARGET}/webp DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/x264.cmake b/build_files/build_environment/cmake/x264.cmake index be861efcc9a..a451a8aea84 100644 --- a/build_files/build_environment/cmake/x264.cmake +++ b/build_files/build_environment/cmake/x264.cmake @@ -11,8 +11,8 @@ if(BLENDER_PLATFORM_ARM) endif() if((APPLE AND NOT BLENDER_PLATFORM_ARM) OR (UNIX AND NOT APPLE)) - set(X264_CONFIGURE_ENV ${CONFIGURE_ENV} && - export AS=${LIBDIR}/nasm/bin/nasm + set(X264_CONFIGURE_ENV + ${CONFIGURE_ENV} && export AS=${LIBDIR}/nasm/bin/nasm ) elseif(WIN32) set(X264_CONFIGURE_ENV ${CONFIGURE_ENV_NO_PERL}) @@ -25,23 +25,14 @@ ExternalProject_Add(external_x264 DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${X264_HASH_TYPE}=${X264_HASH} PREFIX ${BUILD_DIR}/x264 - - CONFIGURE_COMMAND ${X264_CONFIGURE_ENV} && - cd ${BUILD_DIR}/x264/src/external_x264/ && + CONFIGURE_COMMAND ${X264_CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ && ${CONFIGURE_COMMAND} --prefix=${LIBDIR}/x264 - --enable-static - --enable-pic - --disable-lavf - ${X264_EXTRA_ARGS} - - BUILD_COMMAND ${X264_CONFIGURE_ENV} && - cd ${BUILD_DIR}/x264/src/external_x264/ && - make -j${MAKE_THREADS} - - INSTALL_COMMAND ${X264_CONFIGURE_ENV} && - cd ${BUILD_DIR}/x264/src/external_x264/ && - make install - + --enable-static + --enable-pic + --disable-lavf + ${X264_EXTRA_ARGS} + BUILD_COMMAND ${X264_CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ && make -j${MAKE_THREADS} + INSTALL_COMMAND ${X264_CONFIGURE_ENV} && cd ${BUILD_DIR}/x264/src/external_x264/ && make install INSTALL_DIR ${LIBDIR}/x264 ) diff --git a/build_files/build_environment/cmake/xml2.cmake b/build_files/build_environment/cmake/xml2.cmake index a9bcb6ccb39..2c95b89a9e2 100644 --- a/build_files/build_environment/cmake/xml2.cmake +++ b/build_files/build_environment/cmake/xml2.cmake @@ -15,25 +15,15 @@ ExternalProject_Add(external_xml2 URL file://${PACKAGE_DIR}/${XML2_FILE} DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${XML2_HASH_TYPE}=${XML2_HASH} - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/xml2 - ${DEFAULT_CMAKE_FLAGS} - ${XML2_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/xml2 ${DEFAULT_CMAKE_FLAGS} ${XML2_EXTRA_ARGS} PREFIX ${BUILD_DIR}/xml2 INSTALL_DIR ${LIBDIR}/xml2 ) if(WIN32 AND BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_xml2 after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/xml2/include - ${HARVEST_TARGET}/xml2/include - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/xml2/lib/libxml2s.lib - ${HARVEST_TARGET}/xml2/lib/libxml2s.lib - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/xml2/include ${HARVEST_TARGET}/xml2/include + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/xml2/lib/libxml2s.lib ${HARVEST_TARGET}/xml2/lib/libxml2s.lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/xr_openxr.cmake b/build_files/build_environment/cmake/xr_openxr.cmake index eb091506e70..77ae7d96212 100644 --- a/build_files/build_environment/cmake/xr_openxr.cmake +++ b/build_files/build_environment/cmake/xr_openxr.cmake @@ -25,34 +25,21 @@ ExternalProject_Add(external_xr_openxr_sdk DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${XR_OPENXR_SDK_HASH_TYPE}=${XR_OPENXR_SDK_HASH} PREFIX ${BUILD_DIR}/xr_openxr_sdk - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/xr_openxr_sdk - ${DEFAULT_CMAKE_FLAGS} - ${XR_OPENXR_SDK_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/xr_openxr_sdk ${DEFAULT_CMAKE_FLAGS} ${XR_OPENXR_SDK_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/xr_openxr_sdk ) if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_xr_openxr_sdk after_install - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/xr_openxr_sdk/include/openxr - ${HARVEST_TARGET}/xr_openxr_sdk/include/openxr - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/xr_openxr_sdk/lib - ${HARVEST_TARGET}/xr_openxr_sdk/lib - + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/xr_openxr_sdk/include/openxr ${HARVEST_TARGET}/xr_openxr_sdk/include/openxr + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/xr_openxr_sdk/lib ${HARVEST_TARGET}/xr_openxr_sdk/lib DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_xr_openxr_sdk after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/xr_openxr_sdk/lib/openxr_loaderd.lib - ${HARVEST_TARGET}/xr_openxr_sdk/lib/openxr_loaderd.lib - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/xr_openxr_sdk/lib/openxr_loaderd.lib ${HARVEST_TARGET}/xr_openxr_sdk/lib/openxr_loaderd.lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/yamlcpp.cmake b/build_files/build_environment/cmake/yamlcpp.cmake index 5cf85f36f6b..35fa74ca5a8 100644 --- a/build_files/build_environment/cmake/yamlcpp.cmake +++ b/build_files/build_environment/cmake/yamlcpp.cmake @@ -22,11 +22,6 @@ ExternalProject_Add(external_yamlcpp URL_HASH ${YAMLCPP_HASH_TYPE}=${YAMLCPP_HASH} PREFIX ${BUILD_DIR}/yamlcpp CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/yamlcpp - ${DEFAULT_CMAKE_FLAGS} - ${YAMLCPP_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/yamlcpp ${DEFAULT_CMAKE_FLAGS} ${YAMLCPP_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/yamlcpp ) diff --git a/build_files/build_environment/cmake/zlib.cmake b/build_files/build_environment/cmake/zlib.cmake index eca964d7785..72d8441c390 100644 --- a/build_files/build_environment/cmake/zlib.cmake +++ b/build_files/build_environment/cmake/zlib.cmake @@ -3,11 +3,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later if(MSVC) - set(ZLIB_PATCH_COMMAND - ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/zlib/src/external_zlib < - ${PATCH_DIR}/zlib.diff - ) + set(ZLIB_PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/zlib/src/external_zlib < ${PATCH_DIR}/zlib.diff) else() set(ZLIB_PATCH_COMMAND echo .) endif() @@ -17,37 +13,24 @@ ExternalProject_Add(external_zlib URL_HASH ${ZLIB_HASH_TYPE}=${ZLIB_HASH} PREFIX ${BUILD_DIR}/zlib PATCH_COMMAND ${ZLIB_PATCH_COMMAND} - - CMAKE_ARGS - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/zlib - ${DEFAULT_CMAKE_FLAGS} - + CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=${LIBDIR}/zlib ${DEFAULT_CMAKE_FLAGS} INSTALL_DIR ${LIBDIR}/zlib ) if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_zlib after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/zlib/lib/zlibstatic${LIBEXT} - ${HARVEST_TARGET}/zlib/lib/libz_st${LIBEXT} - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/zlib/include/ - ${HARVEST_TARGET}/zlib/include/ + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/zlib/lib/zlibstatic${LIBEXT} ${HARVEST_TARGET}/zlib/lib/libz_st${LIBEXT} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/zlib/include/ ${HARVEST_TARGET}/zlib/include/ COMMAND ${CMAKE_COMMAND} -E rm -f ${LIBDIR}/zlib/bin/zlib.dll COMMAND ${CMAKE_COMMAND} -E rm -f ${LIBDIR}/zlib/lib/zlib.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/zlib/lib/zlibstatic${LIBEXT} - ${LIBDIR}/zlib/lib/zlib${LIBEXT} + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/zlib/lib/zlibstatic${LIBEXT} ${LIBDIR}/zlib/lib/zlib${LIBEXT} DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_zlib after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/zlib/lib/zlibstaticd${LIBEXT} - ${HARVEST_TARGET}/zlib/lib/libz_st_d${LIBEXT} + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/zlib/lib/zlibstaticd${LIBEXT} ${HARVEST_TARGET}/zlib/lib/libz_st_d${LIBEXT} COMMAND ${CMAKE_COMMAND} -E rm -f ${LIBDIR}/zlib/bin/zlib.dll COMMAND ${CMAKE_COMMAND} -E rm -f ${LIBDIR}/zlib/lib/zlib.lib DEPENDEES install @@ -55,10 +38,7 @@ if(WIN32) endif() else() ExternalProject_Add_Step(external_zlib after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/zlib/lib/libz.a - ${LIBDIR}/zlib/lib/libz_pic.a - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/zlib/lib/libz.a ${LIBDIR}/zlib/lib/libz_pic.a DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/zlib_mingw.cmake b/build_files/build_environment/cmake/zlib_mingw.cmake index f0ebf00bb33..61495252f11 100644 --- a/build_files/build_environment/cmake/zlib_mingw.cmake +++ b/build_files/build_environment/cmake/zlib_mingw.cmake @@ -8,21 +8,14 @@ ExternalProject_Add(external_zlib_mingw DOWNLOAD_DIR ${DOWNLOAD_DIR} PREFIX ${BUILD_DIR}/zlib_mingw CONFIGURE_COMMAND echo . - - BUILD_COMMAND ${CONFIGURE_ENV} && - cd ${BUILD_DIR}/zlib_mingw/src/external_zlib_mingw/ && - make -f win32/makefile.gcc -j${MAKE_THREADS} - + BUILD_COMMAND ${CONFIGURE_ENV} && cd ${BUILD_DIR}/zlib_mingw/src/external_zlib_mingw/ && make -f win32/makefile.gcc -j${MAKE_THREADS} INSTALL_COMMAND echo . INSTALL_DIR ${LIBDIR}/zlib_mingw ) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_zlib_mingw after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${BUILD_DIR}/zlib_mingw/src/external_zlib_mingw/libz.a - ${LIBDIR}/zlib/lib/z.lib - + COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/zlib_mingw/src/external_zlib_mingw/libz.a ${LIBDIR}/zlib/lib/z.lib DEPENDEES install ) endif() diff --git a/build_files/build_environment/cmake/zstd.cmake b/build_files/build_environment/cmake/zstd.cmake index 842a4a87443..0ccded1d51c 100644 --- a/build_files/build_environment/cmake/zstd.cmake +++ b/build_files/build_environment/cmake/zstd.cmake @@ -22,25 +22,15 @@ ExternalProject_Add(external_zstd URL_HASH ${ZSTD_HASH_TYPE}=${ZSTD_HASH} PREFIX ${BUILD_DIR}/zstd SOURCE_SUBDIR build/cmake - - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${LIBDIR}/zstd - ${DEFAULT_CMAKE_FLAGS} - ${ZSTD_EXTRA_ARGS} - + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/zstd ${DEFAULT_CMAKE_FLAGS} ${ZSTD_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/zstd ) if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_zstd after_install - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/zstd/lib/zstd_static${LIBEXT} - ${HARVEST_TARGET}/zstd/lib/zstd_static${LIBEXT} - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/zstd/include/ - ${HARVEST_TARGET}/zstd/include/ - + COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/zstd/lib/zstd_static${LIBEXT} ${HARVEST_TARGET}/zstd/lib/zstd_static${LIBEXT} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/zstd/include/ ${HARVEST_TARGET}/zstd/include/ DEPENDEES install ) endif() diff --git a/build_files/build_environment/install_linux_packages.py b/build_files/build_environment/install_linux_packages.py index b6b002f7b08..ab4ad2efd21 100755 --- a/build_files/build_environment/install_linux_packages.py +++ b/build_files/build_environment/install_linux_packages.py @@ -899,7 +899,7 @@ PACKAGES_ALL = ( DISTRO_ID_ARCH: "level-zero-headers", # ??? }, ), - Package(name="OpenPGL Library", is_mandatory=False, version="0.6.0", version_short="0.6", version_min="0.5.0", version_mex="0.7", + Package(name="OpenPGL Library", is_mandatory=False, version="0.5.0", version_short="0.5", version_min="0.5.0", version_mex="0.6", sub_packages=(), distro_package_names={DISTRO_ID_DEBIAN: None, DISTRO_ID_FEDORA: "openpgl-devel", diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 7737e4989fd..4ffeb6b316f 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -849,7 +849,7 @@ function(get_blender_version) # - BLENDER_VERSION_PATCH # - BLENDER_VERSION_CYCLE (alpha, beta, rc, release) - # So CMAKE depends on `BKE_blender_version.h`, beware of infinite-loops! + # So CMAKE depends on `BKE_blender.h`, beware of infinite-loops! configure_file( ${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender_version.h ${CMAKE_BINARY_DIR}/source/blender/blenkernel/BKE_blender_version.h.done diff --git a/build_files/utils/make_source_archive.py b/build_files/utils/make_source_archive.py index ac6b1f73228..7b405c815ed 100755 --- a/build_files/utils/make_source_archive.py +++ b/build_files/utils/make_source_archive.py @@ -8,7 +8,6 @@ import make_utils import os import re import subprocess -import sys from pathlib import Path from typing import Iterable, TextIO, Optional, Any, Union @@ -177,14 +176,9 @@ def create_tarball( packages_dir: Optional[Path], ) -> None: print(f'Creating archive: "{tarball}" ...', end="", flush=True) + command = ["tar"] # Requires GNU `tar`, since `--transform` is used. - if sys.platform == "darwin": - # Provided by `brew install gnu-tar`. - command = ["gtar"] - else: - command = ["tar"] - if packages_dir: command += ["--transform", f"s,{packages_dir}/,packages/,g"] diff --git a/build_files/windows/doc_py.cmd b/build_files/windows/doc_py.cmd index d09c348d997..d33a0289083 100644 --- a/build_files/windows/doc_py.cmd +++ b/build_files/windows/doc_py.cmd @@ -26,7 +26,7 @@ exit /b 1 :detect_blender_done %BLENDER_BIN% ^ - --background --factory-startup ^ + --background -noaudio --factory-startup ^ --python %BLENDER_DIR%/doc/python_api/sphinx_doc_gen.py "%SPHINX_BIN%" -b html %SPHINXOPTS% %O% %SOURCEDIR% %BUILDDIR% diff --git a/doc/blender_file_format/BlendFileDnaExporter_25.py b/doc/blender_file_format/BlendFileDnaExporter_25.py index f51ecf5c8a4..6aabbdc22b0 100755 --- a/doc/blender_file_format/BlendFileDnaExporter_25.py +++ b/doc/blender_file_format/BlendFileDnaExporter_25.py @@ -363,15 +363,15 @@ class DNACatalogHTML: def usage(): - print("\nUsage: \n\tblender2.5 --background --python BlendFileDnaExporter_25.py [-- [options]]") + print("\nUsage: \n\tblender2.5 --background -noaudio --python BlendFileDnaExporter_25.py [-- [options]]") print("Options:") print("\t--dna-keep-blend: doesn't delete the produced blend file DNA export to html") print("\t--dna-debug: sets the logging level to DEBUG (lots of additional info)") print("\t--dna-versioned saves version information in the html and blend filenames") print("\t--dna-overwrite-css overwrite dna.css, useful when modifying css in the script") print("Examples:") - print("\tdefault: % blender2.5 --background --python BlendFileDnaExporter_25.py") - print("\twith options: % blender2.5 --background --python BlendFileDnaExporter_25.py -- --dna-keep-blend --dna-debug\n") + print("\tdefault: % blender2.5 --background -noaudio --python BlendFileDnaExporter_25.py") + print("\twith options: % blender2.5 --background -noaudio --python BlendFileDnaExporter_25.py -- --dna-keep-blend --dna-debug\n") ###################################################### diff --git a/doc/blender_file_format/README b/doc/blender_file_format/README index 25bb189d980..531756eb34a 100644 --- a/doc/blender_file_format/README +++ b/doc/blender_file_format/README @@ -16,14 +16,14 @@ Below you have the help message with a list of options you can use. Usage: - blender2.5 --background --python BlendFileDnaExporter_25.py [-- [options]] + blender2.5 --background -noaudio --python BlendFileDnaExporter_25.py [-- [options]] Options: --dna-keep-blend: doesn't delete the produced blend file DNA export to html --dna-debug: sets the logging level to DEBUG (lots of additional info) --dna-versioned saves version information in the html and blend filenames --dna-overwrite-css overwrite dna.css, useful when modifying css in the script Examples: - default: % blender2.5 --background --python BlendFileDnaExporter_25.py - with options: % blender2.5 --background --python BlendFileDnaExporter_25.py -- --dna-keep-blend --dna-debug + default: % blender2.5 --background -noaudio --python BlendFileDnaExporter_25.py + with options: % blender2.5 --background -noaudio --python BlendFileDnaExporter_25.py -- --dna-keep-blend --dna-debug diff --git a/doc/doxygen/Doxyfile b/doc/doxygen/Doxyfile index 51d461628a9..80eaa0ec556 100644 --- a/doc/doxygen/Doxyfile +++ b/doc/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = Blender # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = V4.2 +PROJECT_NUMBER = V4.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/doc/python_api/rst/include__bmesh.rst b/doc/python_api/rst/include__bmesh.rst index e42255424fd..e8cd23e41da 100644 --- a/doc/python_api/rst/include__bmesh.rst +++ b/doc/python_api/rst/include__bmesh.rst @@ -1,7 +1,7 @@ .. This document is appended to the auto generated BMesh API doc to avoid clogging up the C files with details. to test this run: - ./blender.bin -b -P doc/python_api/sphinx_doc_gen.py -- \ + ./blender.bin -b -noaudio -P doc/python_api/sphinx_doc_gen.py -- \ --partial bmesh* ; cd doc/python_api ; sphinx-build sphinx-in sphinx-out ; cd ../../ diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 637a1c7ffa9..0a7702bf09c 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -7,7 +7,7 @@ API dump in RST files --------------------- Run this script from Blender's root path once you have compiled Blender - blender --background --factory-startup --python doc/python_api/sphinx_doc_gen.py + blender --background --factory-startup -noaudio --python doc/python_api/sphinx_doc_gen.py This will generate python files in doc/python_api/sphinx-in/ providing ./blender is or links to the blender executable @@ -239,12 +239,12 @@ BPY_LOGGER.setLevel(logging.DEBUG) """ # for quick rebuilds rm -rf /b/doc/python_api/sphinx-* && \ -./blender -b --factory-startup -P doc/python_api/sphinx_doc_gen.py && \ +./blender -b -noaudio --factory-startup -P doc/python_api/sphinx_doc_gen.py && \ sphinx-build doc/python_api/sphinx-in doc/python_api/sphinx-out or -./blender -b --factory-startup -P doc/python_api/sphinx_doc_gen.py -- -f -B +./blender -b -noaudio --factory-startup -P doc/python_api/sphinx_doc_gen.py -- -f -B """ # Switch for quick testing so doc-builds don't take so long. diff --git a/extern/lzma/7zTypes.h b/extern/lzma/7zTypes.h deleted file mode 100644 index 1fcb2473e18..00000000000 --- a/extern/lzma/7zTypes.h +++ /dev/null @@ -1,597 +0,0 @@ -/* 7zTypes.h -- Basic types -2023-04-02 : Igor Pavlov : Public domain */ - -#ifndef ZIP7_7Z_TYPES_H -#define ZIP7_7Z_TYPES_H - -#ifdef _WIN32 -/* #include */ -#else -#include -#endif - -#include - -#ifndef EXTERN_C_BEGIN -#ifdef __cplusplus -#define EXTERN_C_BEGIN extern "C" { -#define EXTERN_C_END } -#else -#define EXTERN_C_BEGIN -#define EXTERN_C_END -#endif -#endif - -EXTERN_C_BEGIN - -#define SZ_OK 0 - -#define SZ_ERROR_DATA 1 -#define SZ_ERROR_MEM 2 -#define SZ_ERROR_CRC 3 -#define SZ_ERROR_UNSUPPORTED 4 -#define SZ_ERROR_PARAM 5 -#define SZ_ERROR_INPUT_EOF 6 -#define SZ_ERROR_OUTPUT_EOF 7 -#define SZ_ERROR_READ 8 -#define SZ_ERROR_WRITE 9 -#define SZ_ERROR_PROGRESS 10 -#define SZ_ERROR_FAIL 11 -#define SZ_ERROR_THREAD 12 - -#define SZ_ERROR_ARCHIVE 16 -#define SZ_ERROR_NO_ARCHIVE 17 - -typedef int SRes; - - -#ifdef _MSC_VER - #if _MSC_VER > 1200 - #define MY_ALIGN(n) __declspec(align(n)) - #else - #define MY_ALIGN(n) - #endif -#else - /* - // C11/C++11: - #include - #define MY_ALIGN(n) alignas(n) - */ - #define MY_ALIGN(n) __attribute__ ((aligned(n))) -#endif - - -#ifdef _WIN32 - -/* typedef DWORD WRes; */ -typedef unsigned WRes; -#define MY_SRes_HRESULT_FROM_WRes(x) HRESULT_FROM_WIN32(x) - -// #define MY_HRES_ERROR_INTERNAL_ERROR MY_SRes_HRESULT_FROM_WRes(ERROR_INTERNAL_ERROR) - -#else // _WIN32 - -// #define ENV_HAVE_LSTAT -typedef int WRes; - -// (FACILITY_ERRNO = 0x800) is 7zip's FACILITY constant to represent (errno) errors in HRESULT -#define MY_FACILITY_ERRNO 0x800 -#define MY_FACILITY_WIN32 7 -#define MY_FACILITY_WRes MY_FACILITY_ERRNO - -#define MY_HRESULT_FROM_errno_CONST_ERROR(x) ((HRESULT)( \ - ( (HRESULT)(x) & 0x0000FFFF) \ - | (MY_FACILITY_WRes << 16) \ - | (HRESULT)0x80000000 )) - -#define MY_SRes_HRESULT_FROM_WRes(x) \ - ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : MY_HRESULT_FROM_errno_CONST_ERROR(x)) - -// we call macro HRESULT_FROM_WIN32 for system errors (WRes) that are (errno) -#define HRESULT_FROM_WIN32(x) MY_SRes_HRESULT_FROM_WRes(x) - -/* -#define ERROR_FILE_NOT_FOUND 2L -#define ERROR_ACCESS_DENIED 5L -#define ERROR_NO_MORE_FILES 18L -#define ERROR_LOCK_VIOLATION 33L -#define ERROR_FILE_EXISTS 80L -#define ERROR_DISK_FULL 112L -#define ERROR_NEGATIVE_SEEK 131L -#define ERROR_ALREADY_EXISTS 183L -#define ERROR_DIRECTORY 267L -#define ERROR_TOO_MANY_POSTS 298L - -#define ERROR_INTERNAL_ERROR 1359L -#define ERROR_INVALID_REPARSE_DATA 4392L -#define ERROR_REPARSE_TAG_INVALID 4393L -#define ERROR_REPARSE_TAG_MISMATCH 4394L -*/ - -// we use errno equivalents for some WIN32 errors: - -#define ERROR_INVALID_PARAMETER EINVAL -#define ERROR_INVALID_FUNCTION EINVAL -#define ERROR_ALREADY_EXISTS EEXIST -#define ERROR_FILE_EXISTS EEXIST -#define ERROR_PATH_NOT_FOUND ENOENT -#define ERROR_FILE_NOT_FOUND ENOENT -#define ERROR_DISK_FULL ENOSPC -// #define ERROR_INVALID_HANDLE EBADF - -// we use FACILITY_WIN32 for errors that has no errno equivalent -// Too many posts were made to a semaphore. -#define ERROR_TOO_MANY_POSTS ((HRESULT)0x8007012AL) -#define ERROR_INVALID_REPARSE_DATA ((HRESULT)0x80071128L) -#define ERROR_REPARSE_TAG_INVALID ((HRESULT)0x80071129L) - -// if (MY_FACILITY_WRes != FACILITY_WIN32), -// we use FACILITY_WIN32 for COM errors: -#define E_OUTOFMEMORY ((HRESULT)0x8007000EL) -#define E_INVALIDARG ((HRESULT)0x80070057L) -#define MY_E_ERROR_NEGATIVE_SEEK ((HRESULT)0x80070083L) - -/* -// we can use FACILITY_ERRNO for some COM errors, that have errno equivalents: -#define E_OUTOFMEMORY MY_HRESULT_FROM_errno_CONST_ERROR(ENOMEM) -#define E_INVALIDARG MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL) -#define MY_E_ERROR_NEGATIVE_SEEK MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL) -*/ - -#define TEXT(quote) quote - -#define FILE_ATTRIBUTE_READONLY 0x0001 -#define FILE_ATTRIBUTE_HIDDEN 0x0002 -#define FILE_ATTRIBUTE_SYSTEM 0x0004 -#define FILE_ATTRIBUTE_DIRECTORY 0x0010 -#define FILE_ATTRIBUTE_ARCHIVE 0x0020 -#define FILE_ATTRIBUTE_DEVICE 0x0040 -#define FILE_ATTRIBUTE_NORMAL 0x0080 -#define FILE_ATTRIBUTE_TEMPORARY 0x0100 -#define FILE_ATTRIBUTE_SPARSE_FILE 0x0200 -#define FILE_ATTRIBUTE_REPARSE_POINT 0x0400 -#define FILE_ATTRIBUTE_COMPRESSED 0x0800 -#define FILE_ATTRIBUTE_OFFLINE 0x1000 -#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x2000 -#define FILE_ATTRIBUTE_ENCRYPTED 0x4000 - -#define FILE_ATTRIBUTE_UNIX_EXTENSION 0x8000 /* trick for Unix */ - -#endif - - -#ifndef RINOK -#define RINOK(x) { const int _result_ = (x); if (_result_ != 0) return _result_; } -#endif - -#ifndef RINOK_WRes -#define RINOK_WRes(x) { const WRes _result_ = (x); if (_result_ != 0) return _result_; } -#endif - -typedef unsigned char Byte; -typedef short Int16; -typedef unsigned short UInt16; - -#ifdef Z7_DECL_Int32_AS_long -typedef long Int32; -typedef unsigned long UInt32; -#else -typedef int Int32; -typedef unsigned int UInt32; -#endif - - -#ifndef _WIN32 - -typedef int INT; -typedef Int32 INT32; -typedef unsigned int UINT; -typedef UInt32 UINT32; -typedef INT32 LONG; // LONG, ULONG and DWORD must be 32-bit for _WIN32 compatibility -typedef UINT32 ULONG; - -#undef DWORD -typedef UINT32 DWORD; - -#define VOID void - -#define HRESULT LONG - -typedef void *LPVOID; -// typedef void VOID; -// typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR; -// gcc / clang on Unix : sizeof(long==sizeof(void*) in 32 or 64 bits) -typedef long INT_PTR; -typedef unsigned long UINT_PTR; -typedef long LONG_PTR; -typedef unsigned long DWORD_PTR; - -typedef size_t SIZE_T; - -#endif // _WIN32 - - -#define MY_HRES_ERROR_INTERNAL_ERROR ((HRESULT)0x8007054FL) - - -#ifdef Z7_DECL_Int64_AS_long - -typedef long Int64; -typedef unsigned long UInt64; - -#else - -#if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(__clang__) -typedef __int64 Int64; -typedef unsigned __int64 UInt64; -#else -#if defined(__clang__) || defined(__GNUC__) -#include -typedef int64_t Int64; -typedef uint64_t UInt64; -#else -typedef long long int Int64; -typedef unsigned long long int UInt64; -// #define UINT64_CONST(n) n ## ULL -#endif -#endif - -#endif - -#define UINT64_CONST(n) n - - -#ifdef Z7_DECL_SizeT_AS_unsigned_int -typedef unsigned int SizeT; -#else -typedef size_t SizeT; -#endif - -/* -#if (defined(_MSC_VER) && _MSC_VER <= 1200) -typedef size_t MY_uintptr_t; -#else -#include -typedef uintptr_t MY_uintptr_t; -#endif -*/ - -typedef int BoolInt; -/* typedef BoolInt Bool; */ -#define True 1 -#define False 0 - - -#ifdef _WIN32 -#define Z7_STDCALL __stdcall -#else -#define Z7_STDCALL -#endif - -#ifdef _MSC_VER - -#if _MSC_VER >= 1300 -#define Z7_NO_INLINE __declspec(noinline) -#else -#define Z7_NO_INLINE -#endif - -#define Z7_FORCE_INLINE __forceinline - -#define Z7_CDECL __cdecl -#define Z7_FASTCALL __fastcall - -#else // _MSC_VER - -#if (defined(__GNUC__) && (__GNUC__ >= 4)) \ - || (defined(__clang__) && (__clang_major__ >= 4)) \ - || defined(__INTEL_COMPILER) \ - || defined(__xlC__) -#define Z7_NO_INLINE __attribute__((noinline)) -#define Z7_FORCE_INLINE __attribute__((always_inline)) inline -#else -#define Z7_NO_INLINE -#define Z7_FORCE_INLINE -#endif - -#define Z7_CDECL - -#if defined(_M_IX86) \ - || defined(__i386__) -// #define Z7_FASTCALL __attribute__((fastcall)) -// #define Z7_FASTCALL __attribute__((cdecl)) -#define Z7_FASTCALL -#elif defined(MY_CPU_AMD64) -// #define Z7_FASTCALL __attribute__((ms_abi)) -#define Z7_FASTCALL -#else -#define Z7_FASTCALL -#endif - -#endif // _MSC_VER - - -/* The following interfaces use first parameter as pointer to structure */ - -// #define Z7_C_IFACE_CONST_QUAL -#define Z7_C_IFACE_CONST_QUAL const - -#define Z7_C_IFACE_DECL(a) \ - struct a ## _; \ - typedef Z7_C_IFACE_CONST_QUAL struct a ## _ * a ## Ptr; \ - typedef struct a ## _ a; \ - struct a ## _ - - -Z7_C_IFACE_DECL (IByteIn) -{ - Byte (*Read)(IByteInPtr p); /* reads one byte, returns 0 in case of EOF or error */ -}; -#define IByteIn_Read(p) (p)->Read(p) - - -Z7_C_IFACE_DECL (IByteOut) -{ - void (*Write)(IByteOutPtr p, Byte b); -}; -#define IByteOut_Write(p, b) (p)->Write(p, b) - - -Z7_C_IFACE_DECL (ISeqInStream) -{ - SRes (*Read)(ISeqInStreamPtr p, void *buf, size_t *size); - /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. - (output(*size) < input(*size)) is allowed */ -}; -#define ISeqInStream_Read(p, buf, size) (p)->Read(p, buf, size) - -/* try to read as much as avail in stream and limited by (*processedSize) */ -SRes SeqInStream_ReadMax(ISeqInStreamPtr stream, void *buf, size_t *processedSize); -/* it can return SZ_ERROR_INPUT_EOF */ -// SRes SeqInStream_Read(ISeqInStreamPtr stream, void *buf, size_t size); -// SRes SeqInStream_Read2(ISeqInStreamPtr stream, void *buf, size_t size, SRes errorType); -SRes SeqInStream_ReadByte(ISeqInStreamPtr stream, Byte *buf); - - -Z7_C_IFACE_DECL (ISeqOutStream) -{ - size_t (*Write)(ISeqOutStreamPtr p, const void *buf, size_t size); - /* Returns: result - the number of actually written bytes. - (result < size) means error */ -}; -#define ISeqOutStream_Write(p, buf, size) (p)->Write(p, buf, size) - -typedef enum -{ - SZ_SEEK_SET = 0, - SZ_SEEK_CUR = 1, - SZ_SEEK_END = 2 -} ESzSeek; - - -Z7_C_IFACE_DECL (ISeekInStream) -{ - SRes (*Read)(ISeekInStreamPtr p, void *buf, size_t *size); /* same as ISeqInStream::Read */ - SRes (*Seek)(ISeekInStreamPtr p, Int64 *pos, ESzSeek origin); -}; -#define ISeekInStream_Read(p, buf, size) (p)->Read(p, buf, size) -#define ISeekInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin) - - -Z7_C_IFACE_DECL (ILookInStream) -{ - SRes (*Look)(ILookInStreamPtr p, const void **buf, size_t *size); - /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. - (output(*size) > input(*size)) is not allowed - (output(*size) < input(*size)) is allowed */ - SRes (*Skip)(ILookInStreamPtr p, size_t offset); - /* offset must be <= output(*size) of Look */ - SRes (*Read)(ILookInStreamPtr p, void *buf, size_t *size); - /* reads directly (without buffer). It's same as ISeqInStream::Read */ - SRes (*Seek)(ILookInStreamPtr p, Int64 *pos, ESzSeek origin); -}; - -#define ILookInStream_Look(p, buf, size) (p)->Look(p, buf, size) -#define ILookInStream_Skip(p, offset) (p)->Skip(p, offset) -#define ILookInStream_Read(p, buf, size) (p)->Read(p, buf, size) -#define ILookInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin) - - -SRes LookInStream_LookRead(ILookInStreamPtr stream, void *buf, size_t *size); -SRes LookInStream_SeekTo(ILookInStreamPtr stream, UInt64 offset); - -/* reads via ILookInStream::Read */ -SRes LookInStream_Read2(ILookInStreamPtr stream, void *buf, size_t size, SRes errorType); -SRes LookInStream_Read(ILookInStreamPtr stream, void *buf, size_t size); - - -typedef struct -{ - ILookInStream vt; - ISeekInStreamPtr realStream; - - size_t pos; - size_t size; /* it's data size */ - - /* the following variables must be set outside */ - Byte *buf; - size_t bufSize; -} CLookToRead2; - -void LookToRead2_CreateVTable(CLookToRead2 *p, int lookahead); - -#define LookToRead2_INIT(p) { (p)->pos = (p)->size = 0; } - - -typedef struct -{ - ISeqInStream vt; - ILookInStreamPtr realStream; -} CSecToLook; - -void SecToLook_CreateVTable(CSecToLook *p); - - - -typedef struct -{ - ISeqInStream vt; - ILookInStreamPtr realStream; -} CSecToRead; - -void SecToRead_CreateVTable(CSecToRead *p); - - -Z7_C_IFACE_DECL (ICompressProgress) -{ - SRes (*Progress)(ICompressProgressPtr p, UInt64 inSize, UInt64 outSize); - /* Returns: result. (result != SZ_OK) means break. - Value (UInt64)(Int64)-1 for size means unknown value. */ -}; - -#define ICompressProgress_Progress(p, inSize, outSize) (p)->Progress(p, inSize, outSize) - - - -typedef struct ISzAlloc ISzAlloc; -typedef const ISzAlloc * ISzAllocPtr; - -struct ISzAlloc -{ - void *(*Alloc)(ISzAllocPtr p, size_t size); - void (*Free)(ISzAllocPtr p, void *address); /* address can be 0 */ -}; - -#define ISzAlloc_Alloc(p, size) (p)->Alloc(p, size) -#define ISzAlloc_Free(p, a) (p)->Free(p, a) - -/* deprecated */ -#define IAlloc_Alloc(p, size) ISzAlloc_Alloc(p, size) -#define IAlloc_Free(p, a) ISzAlloc_Free(p, a) - - - - - -#ifndef MY_offsetof - #ifdef offsetof - #define MY_offsetof(type, m) offsetof(type, m) - /* - #define MY_offsetof(type, m) FIELD_OFFSET(type, m) - */ - #else - #define MY_offsetof(type, m) ((size_t)&(((type *)0)->m)) - #endif -#endif - - - -#ifndef Z7_container_of - -/* -#define Z7_container_of(ptr, type, m) container_of(ptr, type, m) -#define Z7_container_of(ptr, type, m) CONTAINING_RECORD(ptr, type, m) -#define Z7_container_of(ptr, type, m) ((type *)((char *)(ptr) - offsetof(type, m))) -#define Z7_container_of(ptr, type, m) (&((type *)0)->m == (ptr), ((type *)(((char *)(ptr)) - MY_offsetof(type, m)))) -*/ - -/* - GCC shows warning: "perhaps the 'offsetof' macro was used incorrectly" - GCC 3.4.4 : classes with constructor - GCC 4.8.1 : classes with non-public variable members" -*/ - -#define Z7_container_of(ptr, type, m) \ - ((type *)(void *)((char *)(void *) \ - (1 ? (ptr) : &((type *)NULL)->m) - MY_offsetof(type, m))) - -#define Z7_container_of_CONST(ptr, type, m) \ - ((const type *)(const void *)((const char *)(const void *) \ - (1 ? (ptr) : &((type *)NULL)->m) - MY_offsetof(type, m))) - -/* -#define Z7_container_of_NON_CONST_FROM_CONST(ptr, type, m) \ - ((type *)(void *)(const void *)((const char *)(const void *) \ - (1 ? (ptr) : &((type *)NULL)->m) - MY_offsetof(type, m))) -*/ - -#endif - -#define Z7_CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) ((type *)(void *)(ptr)) - -// #define Z7_CONTAINER_FROM_VTBL(ptr, type, m) Z7_CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) -#define Z7_CONTAINER_FROM_VTBL(ptr, type, m) Z7_container_of(ptr, type, m) -// #define Z7_CONTAINER_FROM_VTBL(ptr, type, m) Z7_container_of_NON_CONST_FROM_CONST(ptr, type, m) - -#define Z7_CONTAINER_FROM_VTBL_CONST(ptr, type, m) Z7_container_of_CONST(ptr, type, m) - -#define Z7_CONTAINER_FROM_VTBL_CLS(ptr, type, m) Z7_CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) -/* -#define Z7_CONTAINER_FROM_VTBL_CLS(ptr, type, m) Z7_CONTAINER_FROM_VTBL(ptr, type, m) -*/ -#if defined (__clang__) || defined(__GNUC__) -#define Z7_DIAGNOSCTIC_IGNORE_BEGIN_CAST_QUAL \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") -#define Z7_DIAGNOSCTIC_IGNORE_END_CAST_QUAL \ - _Pragma("GCC diagnostic pop") -#else -#define Z7_DIAGNOSCTIC_IGNORE_BEGIN_CAST_QUAL -#define Z7_DIAGNOSCTIC_IGNORE_END_CAST_QUAL -#endif - -#define Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR(ptr, type, m, p) \ - Z7_DIAGNOSCTIC_IGNORE_BEGIN_CAST_QUAL \ - type *p = Z7_CONTAINER_FROM_VTBL(ptr, type, m); \ - Z7_DIAGNOSCTIC_IGNORE_END_CAST_QUAL - -#define Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR_pp_vt_p(type) \ - Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR(pp, type, vt, p) - - -// #define ZIP7_DECLARE_HANDLE(name) typedef void *name; -#define Z7_DECLARE_HANDLE(name) struct name##_dummy{int unused;}; typedef struct name##_dummy *name; - - -#define Z7_memset_0_ARRAY(a) memset((a), 0, sizeof(a)) - -#ifndef Z7_ARRAY_SIZE -#define Z7_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) -#endif - - -#ifdef _WIN32 - -#define CHAR_PATH_SEPARATOR '\\' -#define WCHAR_PATH_SEPARATOR L'\\' -#define STRING_PATH_SEPARATOR "\\" -#define WSTRING_PATH_SEPARATOR L"\\" - -#else - -#define CHAR_PATH_SEPARATOR '/' -#define WCHAR_PATH_SEPARATOR L'/' -#define STRING_PATH_SEPARATOR "/" -#define WSTRING_PATH_SEPARATOR L"/" - -#endif - -#define k_PropVar_TimePrec_0 0 -#define k_PropVar_TimePrec_Unix 1 -#define k_PropVar_TimePrec_DOS 2 -#define k_PropVar_TimePrec_HighPrec 3 -#define k_PropVar_TimePrec_Base 16 -#define k_PropVar_TimePrec_100ns (k_PropVar_TimePrec_Base + 7) -#define k_PropVar_TimePrec_1ns (k_PropVar_TimePrec_Base + 9) - -EXTERN_C_END - -#endif - -/* -#ifndef Z7_ST -#ifdef _7ZIP_ST -#define Z7_ST -#endif -#endif -*/ diff --git a/extern/lzma/7zWindows.h b/extern/lzma/7zWindows.h deleted file mode 100644 index 42c6db8bfc2..00000000000 --- a/extern/lzma/7zWindows.h +++ /dev/null @@ -1,101 +0,0 @@ -/* 7zWindows.h -- StdAfx -2023-04-02 : Igor Pavlov : Public domain */ - -#ifndef ZIP7_INC_7Z_WINDOWS_H -#define ZIP7_INC_7Z_WINDOWS_H - -#ifdef _WIN32 - -#if defined(__clang__) -# pragma clang diagnostic push -#endif - -#if defined(_MSC_VER) - -#pragma warning(push) -#pragma warning(disable : 4668) // '_WIN32_WINNT' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' - -#if _MSC_VER == 1900 -// for old kit10 versions -// #pragma warning(disable : 4255) // winuser.h(13979): warning C4255: 'GetThreadDpiAwarenessContext': -#endif -// win10 Windows Kit: -#endif // _MSC_VER - -#if defined(_MSC_VER) && _MSC_VER <= 1200 && !defined(_WIN64) -// for msvc6 without sdk2003 -#define RPC_NO_WINDOWS_H -#endif - -#if defined(__MINGW32__) || defined(__MINGW64__) -// #if defined(__GNUC__) && !defined(__clang__) -#include -#else -#include -#endif -// #include -// #include - -// but if precompiled with clang-cl then we need -// #include -#if defined(_MSC_VER) -#pragma warning(pop) -#endif - -#if defined(__clang__) -# pragma clang diagnostic pop -#endif - -#if defined(_MSC_VER) && _MSC_VER <= 1200 && !defined(_WIN64) -#ifndef _W64 - -typedef long LONG_PTR, *PLONG_PTR; -typedef unsigned long ULONG_PTR, *PULONG_PTR; -typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR; - -#define Z7_OLD_WIN_SDK -#endif // _W64 -#endif // _MSC_VER == 1200 - -#ifdef Z7_OLD_WIN_SDK - -#ifndef INVALID_FILE_ATTRIBUTES -#define INVALID_FILE_ATTRIBUTES ((DWORD)-1) -#endif -#ifndef INVALID_SET_FILE_POINTER -#define INVALID_SET_FILE_POINTER ((DWORD)-1) -#endif -#ifndef FILE_SPECIAL_ACCESS -#define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS) -#endif - -// ShlObj.h: -// #define BIF_NEWDIALOGSTYLE 0x0040 - -#pragma warning(disable : 4201) -// #pragma warning(disable : 4115) - -#undef VARIANT_TRUE -#define VARIANT_TRUE ((VARIANT_BOOL)-1) -#endif - -#endif // Z7_OLD_WIN_SDK - -#ifdef UNDER_CE -#undef VARIANT_TRUE -#define VARIANT_TRUE ((VARIANT_BOOL)-1) -#endif - - -#if defined(_MSC_VER) -#if _MSC_VER >= 1400 && _MSC_VER <= 1600 - // BaseTsd.h(148) : 'HandleToULong' : unreferenced inline function has been removed - // string.h - // #pragma warning(disable : 4514) -#endif -#endif - - -/* #include "7zTypes.h" */ - -#endif diff --git a/extern/lzma/Alloc.c b/extern/lzma/Alloc.c index d841bf20a35..358a7b52650 100644 --- a/extern/lzma/Alloc.c +++ b/extern/lzma/Alloc.c @@ -1,182 +1,33 @@ /* Alloc.c -- Memory allocation functions -2023-04-02 : Igor Pavlov : Public domain */ - -#include "Precomp.h" +2008-09-24 +Igor Pavlov +Public domain */ #ifdef _WIN32 -#include "7zWindows.h" +#include #endif #include #include "Alloc.h" -#ifdef _WIN32 -#ifdef Z7_LARGE_PAGES -#if defined(__clang__) || defined(__GNUC__) -typedef void (*Z7_voidFunction)(void); -#define MY_CAST_FUNC (Z7_voidFunction) -#elif defined(_MSC_VER) && _MSC_VER > 1920 -#define MY_CAST_FUNC (void *) -// #pragma warning(disable : 4191) // 'type cast': unsafe conversion from 'FARPROC' to 'void (__cdecl *)()' -#else -#define MY_CAST_FUNC -#endif -#endif // Z7_LARGE_PAGES -#endif // _WIN32 +/* #define _SZ_ALLOC_DEBUG */ -// #define SZ_ALLOC_DEBUG -/* #define SZ_ALLOC_DEBUG */ - -/* use SZ_ALLOC_DEBUG to debug alloc/free operations */ -#ifdef SZ_ALLOC_DEBUG - -#include +/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ +#ifdef _SZ_ALLOC_DEBUG #include -static int g_allocCount = 0; -#ifdef _WIN32 -static int g_allocCountMid = 0; -static int g_allocCountBig = 0; +int g_allocCount = 0; +int g_allocCountMid = 0; +int g_allocCountBig = 0; #endif - -#define CONVERT_INT_TO_STR(charType, tempSize) \ - char temp[tempSize]; unsigned i = 0; \ - while (val >= 10) { temp[i++] = (char)('0' + (unsigned)(val % 10)); val /= 10; } \ - *s++ = (charType)('0' + (unsigned)val); \ - while (i != 0) { i--; *s++ = temp[i]; } \ - *s = 0; - -static void ConvertUInt64ToString(UInt64 val, char *s) -{ - CONVERT_INT_TO_STR(char, 24) -} - -#define GET_HEX_CHAR(t) ((char)(((t < 10) ? ('0' + t) : ('A' + (t - 10))))) - -static void ConvertUInt64ToHex(UInt64 val, char *s) -{ - UInt64 v = val; - unsigned i; - for (i = 1;; i++) - { - v >>= 4; - if (v == 0) - break; - } - s[i] = 0; - do - { - unsigned t = (unsigned)(val & 0xF); - val >>= 4; - s[--i] = GET_HEX_CHAR(t); - } - while (i); -} - -#define DEBUG_OUT_STREAM stderr - -static void Print(const char *s) -{ - fputs(s, DEBUG_OUT_STREAM); -} - -static void PrintAligned(const char *s, size_t align) -{ - size_t len = strlen(s); - for(;;) - { - fputc(' ', DEBUG_OUT_STREAM); - if (len >= align) - break; - ++len; - } - Print(s); -} - -static void PrintLn(void) -{ - Print("\n"); -} - -static void PrintHex(UInt64 v, size_t align) -{ - char s[32]; - ConvertUInt64ToHex(v, s); - PrintAligned(s, align); -} - -static void PrintDec(int v, size_t align) -{ - char s[32]; - ConvertUInt64ToString((unsigned)v, s); - PrintAligned(s, align); -} - -static void PrintAddr(void *p) -{ - PrintHex((UInt64)(size_t)(ptrdiff_t)p, 12); -} - - -#define PRINT_REALLOC(name, cnt, size, ptr) { \ - Print(name " "); \ - if (!ptr) PrintDec(cnt++, 10); \ - PrintHex(size, 10); \ - PrintAddr(ptr); \ - PrintLn(); } - -#define PRINT_ALLOC(name, cnt, size, ptr) { \ - Print(name " "); \ - PrintDec(cnt++, 10); \ - PrintHex(size, 10); \ - PrintAddr(ptr); \ - PrintLn(); } - -#define PRINT_FREE(name, cnt, ptr) if (ptr) { \ - Print(name " "); \ - PrintDec(--cnt, 10); \ - PrintAddr(ptr); \ - PrintLn(); } - -#else - -#ifdef _WIN32 -#define PRINT_ALLOC(name, cnt, size, ptr) -#endif -#define PRINT_FREE(name, cnt, ptr) -#define Print(s) -#define PrintLn() -#define PrintHex(v, align) -#define PrintAddr(p) - -#endif - - -/* -by specification: - malloc(non_NULL, 0) : returns NULL or a unique pointer value that can later be successfully passed to free() - realloc(NULL, size) : the call is equivalent to malloc(size) - realloc(non_NULL, 0) : the call is equivalent to free(ptr) - -in main compilers: - malloc(0) : returns non_NULL - realloc(NULL, 0) : returns non_NULL - realloc(non_NULL, 0) : returns NULL -*/ - - void *MyAlloc(size_t size) { if (size == 0) - return NULL; - // PRINT_ALLOC("Alloc ", g_allocCount, size, NULL) - #ifdef SZ_ALLOC_DEBUG + return 0; + #ifdef _SZ_ALLOC_DEBUG { void *p = malloc(size); - if (p) - { - PRINT_ALLOC("Alloc ", g_allocCount, size, p) - } + fprintf(stderr, "\nAlloc %10d bytes, count = %10d, addr = %8X", size, g_allocCount++, (unsigned)p); return p; } #else @@ -186,350 +37,91 @@ void *MyAlloc(size_t size) void MyFree(void *address) { - PRINT_FREE("Free ", g_allocCount, address) - + #ifdef _SZ_ALLOC_DEBUG + if (address != 0) + fprintf(stderr, "\nFree; count = %10d, addr = %8X", --g_allocCount, (unsigned)address); + #endif free(address); } -void *MyRealloc(void *address, size_t size) -{ - if (size == 0) - { - MyFree(address); - return NULL; - } - // PRINT_REALLOC("Realloc ", g_allocCount, size, address) - #ifdef SZ_ALLOC_DEBUG - { - void *p = realloc(address, size); - if (p) - { - PRINT_REALLOC("Realloc ", g_allocCount, size, address) - } - return p; - } - #else - return realloc(address, size); - #endif -} - - #ifdef _WIN32 void *MidAlloc(size_t size) { if (size == 0) - return NULL; - #ifdef SZ_ALLOC_DEBUG - { - void *p = VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); - if (p) - { - PRINT_ALLOC("Alloc-Mid", g_allocCountMid, size, p) - } - return p; - } - #else - return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); + return 0; + #ifdef _SZ_ALLOC_DEBUG + fprintf(stderr, "\nAlloc_Mid %10d bytes; count = %10d", size, g_allocCountMid++); #endif + return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE); } void MidFree(void *address) { - PRINT_FREE("Free-Mid", g_allocCountMid, address) - - if (!address) + #ifdef _SZ_ALLOC_DEBUG + if (address != 0) + fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid); + #endif + if (address == 0) return; VirtualFree(address, 0, MEM_RELEASE); } -#ifdef Z7_LARGE_PAGES - -#ifdef MEM_LARGE_PAGES - #define MY__MEM_LARGE_PAGES MEM_LARGE_PAGES -#else - #define MY__MEM_LARGE_PAGES 0x20000000 +#ifndef MEM_LARGE_PAGES +#undef _7ZIP_LARGE_PAGES #endif -extern -SIZE_T g_LargePageSize; +#ifdef _7ZIP_LARGE_PAGES SIZE_T g_LargePageSize = 0; -typedef SIZE_T (WINAPI *Func_GetLargePageMinimum)(VOID); +typedef SIZE_T (WINAPI *GetLargePageMinimumP)(); +#endif -void SetLargePageSize(void) +void SetLargePageSize() { - #ifdef Z7_LARGE_PAGES - SIZE_T size; - const - Func_GetLargePageMinimum fn = - (Func_GetLargePageMinimum) MY_CAST_FUNC GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), - "GetLargePageMinimum"); - if (!fn) + #ifdef _7ZIP_LARGE_PAGES + SIZE_T size = 0; + GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP) + GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum"); + if (largePageMinimum == 0) return; - size = fn(); + size = largePageMinimum(); if (size == 0 || (size & (size - 1)) != 0) return; g_LargePageSize = size; #endif } -#endif // Z7_LARGE_PAGES void *BigAlloc(size_t size) { if (size == 0) - return NULL; - - PRINT_ALLOC("Alloc-Big", g_allocCountBig, size, NULL) - - #ifdef Z7_LARGE_PAGES + return 0; + #ifdef _SZ_ALLOC_DEBUG + fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++); + #endif + + #ifdef _7ZIP_LARGE_PAGES + if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18)) { - SIZE_T ps = g_LargePageSize; - if (ps != 0 && ps <= (1 << 30) && size > (ps / 2)) - { - size_t size2; - ps--; - size2 = (size + ps) & ~ps; - if (size2 >= size) - { - void *p = VirtualAlloc(NULL, size2, MEM_COMMIT | MY__MEM_LARGE_PAGES, PAGE_READWRITE); - if (p) - { - PRINT_ALLOC("Alloc-BM ", g_allocCountMid, size2, p) - return p; - } - } - } + void *res = VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)), + MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE); + if (res != 0) + return res; } #endif - - return MidAlloc(size); + return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE); } void BigFree(void *address) { - PRINT_FREE("Free-Big", g_allocCountBig, address) - MidFree(address); -} - -#endif // _WIN32 - - -static void *SzAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p) return MyAlloc(size); } -static void SzFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p) MyFree(address); } -const ISzAlloc g_Alloc = { SzAlloc, SzFree }; - -#ifdef _WIN32 -static void *SzMidAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p) return MidAlloc(size); } -static void SzMidFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p) MidFree(address); } -static void *SzBigAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p) return BigAlloc(size); } -static void SzBigFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p) BigFree(address); } -const ISzAlloc g_MidAlloc = { SzMidAlloc, SzMidFree }; -const ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree }; -#endif - -/* - uintptr_t : C99 (optional) - : unsupported in VS6 -*/ - -#ifdef _WIN32 - typedef UINT_PTR UIntPtr; -#else - /* - typedef uintptr_t UIntPtr; - */ - typedef ptrdiff_t UIntPtr; -#endif - - -#define ADJUST_ALLOC_SIZE 0 -/* -#define ADJUST_ALLOC_SIZE (sizeof(void *) - 1) -*/ -/* - Use (ADJUST_ALLOC_SIZE = (sizeof(void *) - 1)), if - MyAlloc() can return address that is NOT multiple of sizeof(void *). -*/ - - -/* -#define MY_ALIGN_PTR_DOWN(p, align) ((void *)((char *)(p) - ((size_t)(UIntPtr)(p) & ((align) - 1)))) -*/ -#define MY_ALIGN_PTR_DOWN(p, align) ((void *)((((UIntPtr)(p)) & ~((UIntPtr)(align) - 1)))) - - -#if !defined(_WIN32) && defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) - #define USE_posix_memalign -#endif - -#ifndef USE_posix_memalign -#define MY_ALIGN_PTR_UP_PLUS(p, align) MY_ALIGN_PTR_DOWN(((char *)(p) + (align) + ADJUST_ALLOC_SIZE), align) -#endif - -/* - This posix_memalign() is for test purposes only. - We also need special Free() function instead of free(), - if this posix_memalign() is used. -*/ - -/* -static int posix_memalign(void **ptr, size_t align, size_t size) -{ - size_t newSize = size + align; - void *p; - void *pAligned; - *ptr = NULL; - if (newSize < size) - return 12; // ENOMEM - p = MyAlloc(newSize); - if (!p) - return 12; // ENOMEM - pAligned = MY_ALIGN_PTR_UP_PLUS(p, align); - ((void **)pAligned)[-1] = p; - *ptr = pAligned; - return 0; -} -*/ - -/* - ALLOC_ALIGN_SIZE >= sizeof(void *) - ALLOC_ALIGN_SIZE >= cache_line_size -*/ - -#define ALLOC_ALIGN_SIZE ((size_t)1 << 7) - -static void *SzAlignedAlloc(ISzAllocPtr pp, size_t size) -{ - #ifndef USE_posix_memalign - - void *p; - void *pAligned; - size_t newSize; - UNUSED_VAR(pp) - - /* also we can allocate additional dummy ALLOC_ALIGN_SIZE bytes after aligned - block to prevent cache line sharing with another allocated blocks */ - - newSize = size + ALLOC_ALIGN_SIZE * 1 + ADJUST_ALLOC_SIZE; - if (newSize < size) - return NULL; - - p = MyAlloc(newSize); - - if (!p) - return NULL; - pAligned = MY_ALIGN_PTR_UP_PLUS(p, ALLOC_ALIGN_SIZE); - - Print(" size="); PrintHex(size, 8); - Print(" a_size="); PrintHex(newSize, 8); - Print(" ptr="); PrintAddr(p); - Print(" a_ptr="); PrintAddr(pAligned); - PrintLn(); - - ((void **)pAligned)[-1] = p; - - return pAligned; - - #else - - void *p; - UNUSED_VAR(pp) - if (posix_memalign(&p, ALLOC_ALIGN_SIZE, size)) - return NULL; - - Print(" posix_memalign="); PrintAddr(p); - PrintLn(); - - return p; - + #ifdef _SZ_ALLOC_DEBUG + if (address != 0) + fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig); #endif -} - - -static void SzAlignedFree(ISzAllocPtr pp, void *address) -{ - UNUSED_VAR(pp) - #ifndef USE_posix_memalign - if (address) - MyFree(((void **)address)[-1]); - #else - free(address); - #endif -} - - -const ISzAlloc g_AlignedAlloc = { SzAlignedAlloc, SzAlignedFree }; - - - -#define MY_ALIGN_PTR_DOWN_1(p) MY_ALIGN_PTR_DOWN(p, sizeof(void *)) - -/* we align ptr to support cases where CAlignOffsetAlloc::offset is not multiply of sizeof(void *) */ -#define REAL_BLOCK_PTR_VAR(p) ((void **)MY_ALIGN_PTR_DOWN_1(p))[-1] -/* -#define REAL_BLOCK_PTR_VAR(p) ((void **)(p))[-1] -*/ - -static void *AlignOffsetAlloc_Alloc(ISzAllocPtr pp, size_t size) -{ - const CAlignOffsetAlloc *p = Z7_CONTAINER_FROM_VTBL_CONST(pp, CAlignOffsetAlloc, vt); - void *adr; - void *pAligned; - size_t newSize; - size_t extra; - size_t alignSize = (size_t)1 << p->numAlignBits; - - if (alignSize < sizeof(void *)) - alignSize = sizeof(void *); - if (p->offset >= alignSize) - return NULL; - - /* also we can allocate additional dummy ALLOC_ALIGN_SIZE bytes after aligned - block to prevent cache line sharing with another allocated blocks */ - extra = p->offset & (sizeof(void *) - 1); - newSize = size + alignSize + extra + ADJUST_ALLOC_SIZE; - if (newSize < size) - return NULL; - - adr = ISzAlloc_Alloc(p->baseAlloc, newSize); - - if (!adr) - return NULL; - - pAligned = (char *)MY_ALIGN_PTR_DOWN((char *)adr + - alignSize - p->offset + extra + ADJUST_ALLOC_SIZE, alignSize) + p->offset; - - PrintLn(); - Print("- Aligned: "); - Print(" size="); PrintHex(size, 8); - Print(" a_size="); PrintHex(newSize, 8); - Print(" ptr="); PrintAddr(adr); - Print(" a_ptr="); PrintAddr(pAligned); - PrintLn(); - - REAL_BLOCK_PTR_VAR(pAligned) = adr; - - return pAligned; + if (address == 0) + return; + VirtualFree(address, 0, MEM_RELEASE); } - -static void AlignOffsetAlloc_Free(ISzAllocPtr pp, void *address) -{ - if (address) - { - const CAlignOffsetAlloc *p = Z7_CONTAINER_FROM_VTBL_CONST(pp, CAlignOffsetAlloc, vt); - PrintLn(); - Print("- Aligned Free: "); - PrintLn(); - ISzAlloc_Free(p->baseAlloc, REAL_BLOCK_PTR_VAR(address)); - } -} - - -void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p) -{ - p->vt.Alloc = AlignOffsetAlloc_Alloc; - p->vt.Free = AlignOffsetAlloc_Free; -} +#endif diff --git a/extern/lzma/Alloc.h b/extern/lzma/Alloc.h index fac5b62fb9f..ff0669cad8d 100644 --- a/extern/lzma/Alloc.h +++ b/extern/lzma/Alloc.h @@ -1,32 +1,19 @@ /* Alloc.h -- Memory allocation functions -2023-03-04 : Igor Pavlov : Public domain */ +2008-03-13 +Igor Pavlov +Public domain */ -#ifndef ZIP7_INC_ALLOC_H -#define ZIP7_INC_ALLOC_H +#ifndef __COMMON_ALLOC_H +#define __COMMON_ALLOC_H -#include "7zTypes.h" - -EXTERN_C_BEGIN - -/* - MyFree(NULL) : is allowed, as free(NULL) - MyAlloc(0) : returns NULL : but malloc(0) is allowed to return NULL or non_NULL - MyRealloc(NULL, 0) : returns NULL : but realloc(NULL, 0) is allowed to return NULL or non_NULL -MyRealloc() is similar to realloc() for the following cases: - MyRealloc(non_NULL, 0) : returns NULL and always calls MyFree(ptr) - MyRealloc(NULL, non_ZERO) : returns NULL, if allocation failed - MyRealloc(non_NULL, non_ZERO) : returns NULL, if reallocation failed -*/ +#include void *MyAlloc(size_t size); void MyFree(void *address); -void *MyRealloc(void *address, size_t size); #ifdef _WIN32 -#ifdef Z7_LARGE_PAGES -void SetLargePageSize(void); -#endif +void SetLargePageSize(); void *MidAlloc(size_t size); void MidFree(void *address); @@ -42,30 +29,4 @@ void BigFree(void *address); #endif -extern const ISzAlloc g_Alloc; - -#ifdef _WIN32 -extern const ISzAlloc g_BigAlloc; -extern const ISzAlloc g_MidAlloc; -#else -#define g_BigAlloc g_AlignedAlloc -#define g_MidAlloc g_AlignedAlloc -#endif - -extern const ISzAlloc g_AlignedAlloc; - - -typedef struct -{ - ISzAlloc vt; - ISzAllocPtr baseAlloc; - unsigned numAlignBits; /* ((1 << numAlignBits) >= sizeof(void *)) */ - size_t offset; /* (offset == (k * sizeof(void *)) && offset < (1 << numAlignBits) */ -} CAlignOffsetAlloc; - -void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p); - - -EXTERN_C_END - #endif diff --git a/extern/lzma/CMakeLists.txt b/extern/lzma/CMakeLists.txt index fdee58401df..aa2a0e7d7fa 100644 --- a/extern/lzma/CMakeLists.txt +++ b/extern/lzma/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2024 Blender Foundation +# SPDX-FileCopyrightText: 2006 Blender Foundation # # SPDX-License-Identifier: GPL-2.0-or-later @@ -19,28 +19,18 @@ set(INC_SYS set(SRC Alloc.c - CpuArch.c LzFind.c - LzFindMt.c - LzFindOpt.c LzmaDec.c LzmaEnc.c LzmaLib.c - Threads.c - 7zTypes.h - 7zWindows.h Alloc.h - Compiler.h - CpuArch.h LzFind.h - LzFindMt.h LzHash.h LzmaDec.h LzmaEnc.h LzmaLib.h - Precomp.h - Threads.h + Types.h ) set(LIB diff --git a/extern/lzma/Compiler.h b/extern/lzma/Compiler.h deleted file mode 100644 index 185a52deb50..00000000000 --- a/extern/lzma/Compiler.h +++ /dev/null @@ -1,159 +0,0 @@ -/* Compiler.h : Compiler specific defines and pragmas -2023-04-02 : Igor Pavlov : Public domain */ - -#ifndef ZIP7_INC_COMPILER_H -#define ZIP7_INC_COMPILER_H - -#if defined(__clang__) -# define Z7_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) -#endif -#if defined(__clang__) && defined(__apple_build_version__) -# define Z7_APPLE_CLANG_VERSION Z7_CLANG_VERSION -#elif defined(__clang__) -# define Z7_LLVM_CLANG_VERSION Z7_CLANG_VERSION -#elif defined(__GNUC__) -# define Z7_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) -#endif - -#ifdef _MSC_VER -#if !defined(__clang__) && !defined(__GNUC__) -#define Z7_MSC_VER_ORIGINAL _MSC_VER -#endif -#endif - -#if defined(__MINGW32__) || defined(__MINGW64__) -#define Z7_MINGW -#endif - -// #pragma GCC diagnostic ignored "-Wunknown-pragmas" - -#ifdef __clang__ -// padding size of '' with 4 bytes to alignment boundary -#pragma GCC diagnostic ignored "-Wpadded" -#endif - - -#ifdef _MSC_VER - - #ifdef UNDER_CE - #define RPC_NO_WINDOWS_H - /* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */ - #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union - #pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int - #endif - -#if defined(_MSC_VER) && _MSC_VER >= 1800 -#pragma warning(disable : 4464) // relative include path contains '..' -#endif - -// == 1200 : -O1 : for __forceinline -// >= 1900 : -O1 : for printf -#pragma warning(disable : 4710) // function not inlined - -#if _MSC_VER < 1900 -// winnt.h: 'Int64ShllMod32' -#pragma warning(disable : 4514) // unreferenced inline function has been removed -#endif - -#if _MSC_VER < 1300 -// #pragma warning(disable : 4702) // unreachable code -// Bra.c : -O1: -#pragma warning(disable : 4714) // function marked as __forceinline not inlined -#endif - -/* -#if _MSC_VER > 1400 && _MSC_VER <= 1900 -// strcat: This function or variable may be unsafe -// sysinfoapi.h: kit10: GetVersion was declared deprecated -#pragma warning(disable : 4996) -#endif -*/ - -#if _MSC_VER > 1200 -// -Wall warnings - -#pragma warning(disable : 4711) // function selected for automatic inline expansion -#pragma warning(disable : 4820) // '2' bytes padding added after data member - -#if _MSC_VER >= 1400 && _MSC_VER < 1920 -// 1400: string.h: _DBG_MEMCPY_INLINE_ -// 1600 - 191x : smmintrin.h __cplusplus' -// is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' -#pragma warning(disable : 4668) - -// 1400 - 1600 : WinDef.h : 'FARPROC' : -// 1900 - 191x : immintrin.h: _readfsbase_u32 -// no function prototype given : converting '()' to '(void)' -#pragma warning(disable : 4255) -#endif - -#if _MSC_VER >= 1914 -// Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified -#pragma warning(disable : 5045) -#endif - -#endif // _MSC_VER > 1200 -#endif // _MSC_VER - - -#if defined(__clang__) && (__clang_major__ >= 4) - #define Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE \ - _Pragma("clang loop unroll(disable)") \ - _Pragma("clang loop vectorize(disable)") - #define Z7_ATTRIB_NO_VECTORIZE -#elif defined(__GNUC__) && (__GNUC__ >= 5) - #define Z7_ATTRIB_NO_VECTORIZE __attribute__((optimize("no-tree-vectorize"))) - // __attribute__((optimize("no-unroll-loops"))); - #define Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE -#elif defined(_MSC_VER) && (_MSC_VER >= 1920) - #define Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE \ - _Pragma("loop( no_vector )") - #define Z7_ATTRIB_NO_VECTORIZE -#else - #define Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE - #define Z7_ATTRIB_NO_VECTORIZE -#endif - -#if defined(MY_CPU_X86_OR_AMD64) && ( \ - defined(__clang__) && (__clang_major__ >= 4) \ - || defined(__GNUC__) && (__GNUC__ >= 5)) - #define Z7_ATTRIB_NO_SSE __attribute__((__target__("no-sse"))) -#else - #define Z7_ATTRIB_NO_SSE -#endif - -#define Z7_ATTRIB_NO_VECTOR \ - Z7_ATTRIB_NO_VECTORIZE \ - Z7_ATTRIB_NO_SSE - - -#if defined(__clang__) && (__clang_major__ >= 8) \ - || defined(__GNUC__) && (__GNUC__ >= 1000) \ - /* || defined(_MSC_VER) && (_MSC_VER >= 1920) */ - // GCC is not good for __builtin_expect() - #define Z7_LIKELY(x) (__builtin_expect((x), 1)) - #define Z7_UNLIKELY(x) (__builtin_expect((x), 0)) - // #define Z7_unlikely [[unlikely]] - // #define Z7_likely [[likely]] -#else - #define Z7_LIKELY(x) (x) - #define Z7_UNLIKELY(x) (x) - // #define Z7_likely -#endif - - -#if (defined(Z7_CLANG_VERSION) && (Z7_CLANG_VERSION >= 36000)) -#define Z7_DIAGNOSCTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wreserved-macro-identifier\"") -#define Z7_DIAGNOSCTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER \ - _Pragma("GCC diagnostic pop") -#else -#define Z7_DIAGNOSCTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER -#define Z7_DIAGNOSCTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER -#endif - -#define UNUSED_VAR(x) (void)x; -/* #define UNUSED_VAR(x) x=x; */ - -#endif diff --git a/extern/lzma/CpuArch.c b/extern/lzma/CpuArch.c deleted file mode 100644 index 33f8a3ab4c1..00000000000 --- a/extern/lzma/CpuArch.c +++ /dev/null @@ -1,823 +0,0 @@ -/* CpuArch.c -- CPU specific code -2023-05-18 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -// #include - -#include "CpuArch.h" - -#ifdef MY_CPU_X86_OR_AMD64 - -#undef NEED_CHECK_FOR_CPUID -#if !defined(MY_CPU_AMD64) -#define NEED_CHECK_FOR_CPUID -#endif - -/* - cpuid instruction supports (subFunction) parameter in ECX, - that is used only with some specific (function) parameter values. - But we always use only (subFunction==0). -*/ -/* - __cpuid(): MSVC and GCC/CLANG use same function/macro name - but parameters are different. - We use MSVC __cpuid() parameters style for our z7_x86_cpuid() function. -*/ - -#if defined(__GNUC__) /* && (__GNUC__ >= 10) */ \ - || defined(__clang__) /* && (__clang_major__ >= 10) */ - -/* there was some CLANG/GCC compilers that have issues with - rbx(ebx) handling in asm blocks in -fPIC mode (__PIC__ is defined). - compiler's contains the macro __cpuid() that is similar to our code. - The history of __cpuid() changes in CLANG/GCC: - GCC: - 2007: it preserved ebx for (__PIC__ && __i386__) - 2013: it preserved rbx and ebx for __PIC__ - 2014: it doesn't preserves rbx and ebx anymore - we suppose that (__GNUC__ >= 5) fixed that __PIC__ ebx/rbx problem. - CLANG: - 2014+: it preserves rbx, but only for 64-bit code. No __PIC__ check. - Why CLANG cares about 64-bit mode only, and doesn't care about ebx (in 32-bit)? - Do we need __PIC__ test for CLANG or we must care about rbx even if - __PIC__ is not defined? -*/ - -#define ASM_LN "\n" - -#if defined(MY_CPU_AMD64) && defined(__PIC__) \ - && ((defined (__GNUC__) && (__GNUC__ < 5)) || defined(__clang__)) - -#define x86_cpuid_MACRO(p, func) { \ - __asm__ __volatile__ ( \ - ASM_LN "mov %%rbx, %q1" \ - ASM_LN "cpuid" \ - ASM_LN "xchg %%rbx, %q1" \ - : "=a" ((p)[0]), "=&r" ((p)[1]), "=c" ((p)[2]), "=d" ((p)[3]) : "0" (func), "2"(0)); } - - /* "=&r" selects free register. It can select even rbx, if that register is free. - "=&D" for (RDI) also works, but the code can be larger with "=&D" - "2"(0) means (subFunction = 0), - 2 is (zero-based) index in the output constraint list "=c" (ECX). */ - -#elif defined(MY_CPU_X86) && defined(__PIC__) \ - && ((defined (__GNUC__) && (__GNUC__ < 5)) || defined(__clang__)) - -#define x86_cpuid_MACRO(p, func) { \ - __asm__ __volatile__ ( \ - ASM_LN "mov %%ebx, %k1" \ - ASM_LN "cpuid" \ - ASM_LN "xchg %%ebx, %k1" \ - : "=a" ((p)[0]), "=&r" ((p)[1]), "=c" ((p)[2]), "=d" ((p)[3]) : "0" (func), "2"(0)); } - -#else - -#define x86_cpuid_MACRO(p, func) { \ - __asm__ __volatile__ ( \ - ASM_LN "cpuid" \ - : "=a" ((p)[0]), "=b" ((p)[1]), "=c" ((p)[2]), "=d" ((p)[3]) : "0" (func), "2"(0)); } - -#endif - - -void Z7_FASTCALL z7_x86_cpuid(UInt32 p[4], UInt32 func) -{ - x86_cpuid_MACRO(p, func) -} - - -Z7_NO_INLINE -UInt32 Z7_FASTCALL z7_x86_cpuid_GetMaxFunc(void) -{ - #if defined(NEED_CHECK_FOR_CPUID) - #define EFALGS_CPUID_BIT 21 - UInt32 a; - __asm__ __volatile__ ( - ASM_LN "pushf" - ASM_LN "pushf" - ASM_LN "pop %0" - // ASM_LN "movl %0, %1" - // ASM_LN "xorl $0x200000, %0" - ASM_LN "btc %1, %0" - ASM_LN "push %0" - ASM_LN "popf" - ASM_LN "pushf" - ASM_LN "pop %0" - ASM_LN "xorl (%%esp), %0" - - ASM_LN "popf" - ASM_LN - : "=&r" (a) // "=a" - : "i" (EFALGS_CPUID_BIT) - ); - if ((a & (1 << EFALGS_CPUID_BIT)) == 0) - return 0; - #endif - { - UInt32 p[4]; - x86_cpuid_MACRO(p, 0) - return p[0]; - } -} - -#undef ASM_LN - -#elif !defined(_MSC_VER) - -/* -// for gcc/clang and other: we can try to use __cpuid macro: -#include -void Z7_FASTCALL z7_x86_cpuid(UInt32 p[4], UInt32 func) -{ - __cpuid(func, p[0], p[1], p[2], p[3]); -} -UInt32 Z7_FASTCALL z7_x86_cpuid_GetMaxFunc(void) -{ - return (UInt32)__get_cpuid_max(0, NULL); -} -*/ -// for unsupported cpuid: -void Z7_FASTCALL z7_x86_cpuid(UInt32 p[4], UInt32 func) -{ - UNUSED_VAR(func) - p[0] = p[1] = p[2] = p[3] = 0; -} -UInt32 Z7_FASTCALL z7_x86_cpuid_GetMaxFunc(void) -{ - return 0; -} - -#else // _MSC_VER - -#if !defined(MY_CPU_AMD64) - -UInt32 __declspec(naked) Z7_FASTCALL z7_x86_cpuid_GetMaxFunc(void) -{ - #if defined(NEED_CHECK_FOR_CPUID) - #define EFALGS_CPUID_BIT 21 - __asm pushfd - __asm pushfd - /* - __asm pop eax - // __asm mov edx, eax - __asm btc eax, EFALGS_CPUID_BIT - __asm push eax - */ - __asm btc dword ptr [esp], EFALGS_CPUID_BIT - __asm popfd - __asm pushfd - __asm pop eax - // __asm xor eax, edx - __asm xor eax, [esp] - // __asm push edx - __asm popfd - __asm and eax, (1 shl EFALGS_CPUID_BIT) - __asm jz end_func - #endif - __asm push ebx - __asm xor eax, eax // func - __asm xor ecx, ecx // subFunction (optional) for (func == 0) - __asm cpuid - __asm pop ebx - #if defined(NEED_CHECK_FOR_CPUID) - end_func: - #endif - __asm ret 0 -} - -void __declspec(naked) Z7_FASTCALL z7_x86_cpuid(UInt32 p[4], UInt32 func) -{ - UNUSED_VAR(p) - UNUSED_VAR(func) - __asm push ebx - __asm push edi - __asm mov edi, ecx // p - __asm mov eax, edx // func - __asm xor ecx, ecx // subfunction (optional) for (func == 0) - __asm cpuid - __asm mov [edi ], eax - __asm mov [edi + 4], ebx - __asm mov [edi + 8], ecx - __asm mov [edi + 12], edx - __asm pop edi - __asm pop ebx - __asm ret 0 -} - -#else // MY_CPU_AMD64 - - #if _MSC_VER >= 1600 - #include - #define MY_cpuidex __cpuidex - #else -/* - __cpuid (func == (0 or 7)) requires subfunction number in ECX. - MSDN: The __cpuid intrinsic clears the ECX register before calling the cpuid instruction. - __cpuid() in new MSVC clears ECX. - __cpuid() in old MSVC (14.00) x64 doesn't clear ECX - We still can use __cpuid for low (func) values that don't require ECX, - but __cpuid() in old MSVC will be incorrect for some func values: (func == 7). - So here we use the hack for old MSVC to send (subFunction) in ECX register to cpuid instruction, - where ECX value is first parameter for FASTCALL / NO_INLINE func, - So the caller of MY_cpuidex_HACK() sets ECX as subFunction, and - old MSVC for __cpuid() doesn't change ECX and cpuid instruction gets (subFunction) value. - -DON'T remove Z7_NO_INLINE and Z7_FASTCALL for MY_cpuidex_HACK(): !!! -*/ -static -Z7_NO_INLINE void Z7_FASTCALL MY_cpuidex_HACK(UInt32 subFunction, UInt32 func, int *CPUInfo) -{ - UNUSED_VAR(subFunction) - __cpuid(CPUInfo, func); -} - #define MY_cpuidex(info, func, func2) MY_cpuidex_HACK(func2, func, info) - #pragma message("======== MY_cpuidex_HACK WAS USED ========") - #endif // _MSC_VER >= 1600 - -#if !defined(MY_CPU_AMD64) -/* inlining for __cpuid() in MSVC x86 (32-bit) produces big ineffective code, - so we disable inlining here */ -Z7_NO_INLINE -#endif -void Z7_FASTCALL z7_x86_cpuid(UInt32 p[4], UInt32 func) -{ - MY_cpuidex((int *)p, (int)func, 0); -} - -Z7_NO_INLINE -UInt32 Z7_FASTCALL z7_x86_cpuid_GetMaxFunc(void) -{ - int a[4]; - MY_cpuidex(a, 0, 0); - return a[0]; -} - -#endif // MY_CPU_AMD64 -#endif // _MSC_VER - -#if defined(NEED_CHECK_FOR_CPUID) -#define CHECK_CPUID_IS_SUPPORTED { if (z7_x86_cpuid_GetMaxFunc() == 0) return 0; } -#else -#define CHECK_CPUID_IS_SUPPORTED -#endif -#undef NEED_CHECK_FOR_CPUID - - -static -BoolInt x86cpuid_Func_1(UInt32 *p) -{ - CHECK_CPUID_IS_SUPPORTED - z7_x86_cpuid(p, 1); - return True; -} - -/* -static const UInt32 kVendors[][1] = -{ - { 0x756E6547 }, // , 0x49656E69, 0x6C65746E }, - { 0x68747541 }, // , 0x69746E65, 0x444D4163 }, - { 0x746E6543 } // , 0x48727561, 0x736C7561 } -}; -*/ - -/* -typedef struct -{ - UInt32 maxFunc; - UInt32 vendor[3]; - UInt32 ver; - UInt32 b; - UInt32 c; - UInt32 d; -} Cx86cpuid; - -enum -{ - CPU_FIRM_INTEL, - CPU_FIRM_AMD, - CPU_FIRM_VIA -}; -int x86cpuid_GetFirm(const Cx86cpuid *p); -#define x86cpuid_ver_GetFamily(ver) (((ver >> 16) & 0xff0) | ((ver >> 8) & 0xf)) -#define x86cpuid_ver_GetModel(ver) (((ver >> 12) & 0xf0) | ((ver >> 4) & 0xf)) -#define x86cpuid_ver_GetStepping(ver) (ver & 0xf) - -int x86cpuid_GetFirm(const Cx86cpuid *p) -{ - unsigned i; - for (i = 0; i < sizeof(kVendors) / sizeof(kVendors[0]); i++) - { - const UInt32 *v = kVendors[i]; - if (v[0] == p->vendor[0] - // && v[1] == p->vendor[1] - // && v[2] == p->vendor[2] - ) - return (int)i; - } - return -1; -} - -BoolInt CPU_Is_InOrder() -{ - Cx86cpuid p; - UInt32 family, model; - if (!x86cpuid_CheckAndRead(&p)) - return True; - - family = x86cpuid_ver_GetFamily(p.ver); - model = x86cpuid_ver_GetModel(p.ver); - - switch (x86cpuid_GetFirm(&p)) - { - case CPU_FIRM_INTEL: return (family < 6 || (family == 6 && ( - // In-Order Atom CPU - model == 0x1C // 45 nm, N4xx, D4xx, N5xx, D5xx, 230, 330 - || model == 0x26 // 45 nm, Z6xx - || model == 0x27 // 32 nm, Z2460 - || model == 0x35 // 32 nm, Z2760 - || model == 0x36 // 32 nm, N2xxx, D2xxx - ))); - case CPU_FIRM_AMD: return (family < 5 || (family == 5 && (model < 6 || model == 0xA))); - case CPU_FIRM_VIA: return (family < 6 || (family == 6 && model < 0xF)); - } - return False; // v23 : unknown processors are not In-Order -} -*/ - -#ifdef _WIN32 -#include "7zWindows.h" -#endif - -#if !defined(MY_CPU_AMD64) && defined(_WIN32) - -/* for legacy SSE ia32: there is no user-space cpu instruction to check - that OS supports SSE register storing/restoring on context switches. - So we need some OS-specific function to check that it's safe to use SSE registers. -*/ - -Z7_FORCE_INLINE -static BoolInt CPU_Sys_Is_SSE_Supported(void) -{ -#ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable : 4996) // `GetVersion': was declared deprecated -#endif - /* low byte is major version of Windows - We suppose that any Windows version since - Windows2000 (major == 5) supports SSE registers */ - return (Byte)GetVersion() >= 5; -#if defined(_MSC_VER) - #pragma warning(pop) -#endif -} -#define CHECK_SYS_SSE_SUPPORT if (!CPU_Sys_Is_SSE_Supported()) return False; -#else -#define CHECK_SYS_SSE_SUPPORT -#endif - - -#if !defined(MY_CPU_AMD64) - -BoolInt CPU_IsSupported_CMOV(void) -{ - UInt32 a[4]; - if (!x86cpuid_Func_1(&a[0])) - return 0; - return (a[3] >> 15) & 1; -} - -BoolInt CPU_IsSupported_SSE(void) -{ - UInt32 a[4]; - CHECK_SYS_SSE_SUPPORT - if (!x86cpuid_Func_1(&a[0])) - return 0; - return (a[3] >> 25) & 1; -} - -BoolInt CPU_IsSupported_SSE2(void) -{ - UInt32 a[4]; - CHECK_SYS_SSE_SUPPORT - if (!x86cpuid_Func_1(&a[0])) - return 0; - return (a[3] >> 26) & 1; -} - -#endif - - -static UInt32 x86cpuid_Func_1_ECX(void) -{ - UInt32 a[4]; - CHECK_SYS_SSE_SUPPORT - if (!x86cpuid_Func_1(&a[0])) - return 0; - return a[2]; -} - -BoolInt CPU_IsSupported_AES(void) -{ - return (x86cpuid_Func_1_ECX() >> 25) & 1; -} - -BoolInt CPU_IsSupported_SSSE3(void) -{ - return (x86cpuid_Func_1_ECX() >> 9) & 1; -} - -BoolInt CPU_IsSupported_SSE41(void) -{ - return (x86cpuid_Func_1_ECX() >> 19) & 1; -} - -BoolInt CPU_IsSupported_SHA(void) -{ - CHECK_SYS_SSE_SUPPORT - - if (z7_x86_cpuid_GetMaxFunc() < 7) - return False; - { - UInt32 d[4]; - z7_x86_cpuid(d, 7); - return (d[1] >> 29) & 1; - } -} - -/* -MSVC: _xgetbv() intrinsic is available since VS2010SP1. - MSVC also defines (_XCR_XFEATURE_ENABLED_MASK) macro in - that we can use or check. - For any 32-bit x86 we can use asm code in MSVC, - but MSVC asm code is huge after compilation. - So _xgetbv() is better - -ICC: _xgetbv() intrinsic is available (in what version of ICC?) - ICC defines (__GNUC___) and it supports gnu assembler - also ICC supports MASM style code with -use-msasm switch. - but ICC doesn't support __attribute__((__target__)) - -GCC/CLANG 9: - _xgetbv() is macro that works via __builtin_ia32_xgetbv() - and we need __attribute__((__target__("xsave")). - But with __target__("xsave") the function will be not - inlined to function that has no __target__("xsave") attribute. - If we want _xgetbv() call inlining, then we should use asm version - instead of calling _xgetbv(). - Note:intrinsic is broke before GCC 8.2: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85684 -*/ - -#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1100) \ - || defined(_MSC_VER) && (_MSC_VER >= 1600) && (_MSC_FULL_VER >= 160040219) \ - || defined(__GNUC__) && (__GNUC__ >= 9) \ - || defined(__clang__) && (__clang_major__ >= 9) -// we define ATTRIB_XGETBV, if we want to use predefined _xgetbv() from compiler -#if defined(__INTEL_COMPILER) -#define ATTRIB_XGETBV -#elif defined(__GNUC__) || defined(__clang__) -// we don't define ATTRIB_XGETBV here, because asm version is better for inlining. -// #define ATTRIB_XGETBV __attribute__((__target__("xsave"))) -#else -#define ATTRIB_XGETBV -#endif -#endif - -#if defined(ATTRIB_XGETBV) -#include -#endif - - -// XFEATURE_ENABLED_MASK/XCR0 -#define MY_XCR_XFEATURE_ENABLED_MASK 0 - -#if defined(ATTRIB_XGETBV) -ATTRIB_XGETBV -#endif -static UInt64 x86_xgetbv_0(UInt32 num) -{ -#if defined(ATTRIB_XGETBV) - { - return - #if (defined(_MSC_VER)) - _xgetbv(num); - #else - __builtin_ia32_xgetbv( - #if !defined(__clang__) - (int) - #endif - num); - #endif - } - -#elif defined(__GNUC__) || defined(__clang__) || defined(__SUNPRO_CC) - - UInt32 a, d; - #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) - __asm__ - ( - "xgetbv" - : "=a"(a), "=d"(d) : "c"(num) : "cc" - ); - #else // is old gcc - __asm__ - ( - ".byte 0x0f, 0x01, 0xd0" "\n\t" - : "=a"(a), "=d"(d) : "c"(num) : "cc" - ); - #endif - return ((UInt64)d << 32) | a; - // return a; - -#elif defined(_MSC_VER) && !defined(MY_CPU_AMD64) - - UInt32 a, d; - __asm { - push eax - push edx - push ecx - mov ecx, num; - // xor ecx, ecx // = MY_XCR_XFEATURE_ENABLED_MASK - _emit 0x0f - _emit 0x01 - _emit 0xd0 - mov a, eax - mov d, edx - pop ecx - pop edx - pop eax - } - return ((UInt64)d << 32) | a; - // return a; - -#else // it's unknown compiler - // #error "Need xgetbv function" - UNUSED_VAR(num) - // for MSVC-X64 we could call external function from external file. - /* Actually we had checked OSXSAVE/AVX in cpuid before. - So it's expected that OS supports at least AVX and below. */ - // if (num != MY_XCR_XFEATURE_ENABLED_MASK) return 0; // if not XCR0 - return - // (1 << 0) | // x87 - (1 << 1) // SSE - | (1 << 2); // AVX - -#endif -} - -#ifdef _WIN32 -/* - Windows versions do not know about new ISA extensions that - can be introduced. But we still can use new extensions, - even if Windows doesn't report about supporting them, - But we can use new extensions, only if Windows knows about new ISA extension - that changes the number or size of registers: SSE, AVX/XSAVE, AVX512 - So it's enough to check - MY_PF_AVX_INSTRUCTIONS_AVAILABLE - instead of - MY_PF_AVX2_INSTRUCTIONS_AVAILABLE -*/ -#define MY_PF_XSAVE_ENABLED 17 -// #define MY_PF_SSSE3_INSTRUCTIONS_AVAILABLE 36 -// #define MY_PF_SSE4_1_INSTRUCTIONS_AVAILABLE 37 -// #define MY_PF_SSE4_2_INSTRUCTIONS_AVAILABLE 38 -// #define MY_PF_AVX_INSTRUCTIONS_AVAILABLE 39 -// #define MY_PF_AVX2_INSTRUCTIONS_AVAILABLE 40 -// #define MY_PF_AVX512F_INSTRUCTIONS_AVAILABLE 41 -#endif - -BoolInt CPU_IsSupported_AVX(void) -{ - #ifdef _WIN32 - if (!IsProcessorFeaturePresent(MY_PF_XSAVE_ENABLED)) - return False; - /* PF_AVX_INSTRUCTIONS_AVAILABLE probably is supported starting from - some latest Win10 revisions. But we need AVX in older Windows also. - So we don't use the following check: */ - /* - if (!IsProcessorFeaturePresent(MY_PF_AVX_INSTRUCTIONS_AVAILABLE)) - return False; - */ - #endif - - /* - OS must use new special XSAVE/XRSTOR instructions to save - AVX registers when it required for context switching. - At OS statring: - OS sets CR4.OSXSAVE flag to signal the processor that OS supports the XSAVE extensions. - Also OS sets bitmask in XCR0 register that defines what - registers will be processed by XSAVE instruction: - XCR0.SSE[bit 0] - x87 registers and state - XCR0.SSE[bit 1] - SSE registers and state - XCR0.AVX[bit 2] - AVX registers and state - CR4.OSXSAVE is reflected to CPUID.1:ECX.OSXSAVE[bit 27]. - So we can read that bit in user-space. - XCR0 is available for reading in user-space by new XGETBV instruction. - */ - { - const UInt32 c = x86cpuid_Func_1_ECX(); - if (0 == (1 - & (c >> 28) // AVX instructions are supported by hardware - & (c >> 27))) // OSXSAVE bit: XSAVE and related instructions are enabled by OS. - return False; - } - - /* also we can check - CPUID.1:ECX.XSAVE [bit 26] : that shows that - XSAVE, XRESTOR, XSETBV, XGETBV instructions are supported by hardware. - But that check is redundant, because if OSXSAVE bit is set, then XSAVE is also set */ - - /* If OS have enabled XSAVE extension instructions (OSXSAVE == 1), - in most cases we expect that OS also will support storing/restoring - for AVX and SSE states at least. - But to be ensure for that we call user-space instruction - XGETBV(0) to get XCR0 value that contains bitmask that defines - what exact states(registers) OS have enabled for storing/restoring. - */ - - { - const UInt32 bm = (UInt32)x86_xgetbv_0(MY_XCR_XFEATURE_ENABLED_MASK); - // printf("\n=== XGetBV=%d\n", bm); - return 1 - & (bm >> 1) // SSE state is supported (set by OS) for storing/restoring - & (bm >> 2); // AVX state is supported (set by OS) for storing/restoring - } - // since Win7SP1: we can use GetEnabledXStateFeatures(); -} - - -BoolInt CPU_IsSupported_AVX2(void) -{ - if (!CPU_IsSupported_AVX()) - return False; - if (z7_x86_cpuid_GetMaxFunc() < 7) - return False; - { - UInt32 d[4]; - z7_x86_cpuid(d, 7); - // printf("\ncpuid(7): ebx=%8x ecx=%8x\n", d[1], d[2]); - return 1 - & (d[1] >> 5); // avx2 - } -} - -BoolInt CPU_IsSupported_VAES_AVX2(void) -{ - if (!CPU_IsSupported_AVX()) - return False; - if (z7_x86_cpuid_GetMaxFunc() < 7) - return False; - { - UInt32 d[4]; - z7_x86_cpuid(d, 7); - // printf("\ncpuid(7): ebx=%8x ecx=%8x\n", d[1], d[2]); - return 1 - & (d[1] >> 5) // avx2 - // & (d[1] >> 31) // avx512vl - & (d[2] >> 9); // vaes // VEX-256/EVEX - } -} - -BoolInt CPU_IsSupported_PageGB(void) -{ - CHECK_CPUID_IS_SUPPORTED - { - UInt32 d[4]; - z7_x86_cpuid(d, 0x80000000); - if (d[0] < 0x80000001) - return False; - z7_x86_cpuid(d, 0x80000001); - return (d[3] >> 26) & 1; - } -} - - -#elif defined(MY_CPU_ARM_OR_ARM64) - -#ifdef _WIN32 - -#include "7zWindows.h" - -BoolInt CPU_IsSupported_CRC32(void) { return IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE) ? 1 : 0; } -BoolInt CPU_IsSupported_CRYPTO(void) { return IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) ? 1 : 0; } -BoolInt CPU_IsSupported_NEON(void) { return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) ? 1 : 0; } - -#else - -#if defined(__APPLE__) - -/* -#include -#include -static void Print_sysctlbyname(const char *name) -{ - size_t bufSize = 256; - char buf[256]; - int res = sysctlbyname(name, &buf, &bufSize, NULL, 0); - { - int i; - printf("\nres = %d : %s : '%s' : bufSize = %d, numeric", res, name, buf, (unsigned)bufSize); - for (i = 0; i < 20; i++) - printf(" %2x", (unsigned)(Byte)buf[i]); - - } -} -*/ -/* - Print_sysctlbyname("hw.pagesize"); - Print_sysctlbyname("machdep.cpu.brand_string"); -*/ - -static BoolInt z7_sysctlbyname_Get_BoolInt(const char *name) -{ - UInt32 val = 0; - if (z7_sysctlbyname_Get_UInt32(name, &val) == 0 && val == 1) - return 1; - return 0; -} - -BoolInt CPU_IsSupported_CRC32(void) -{ - return z7_sysctlbyname_Get_BoolInt("hw.optional.armv8_crc32"); -} - -BoolInt CPU_IsSupported_NEON(void) -{ - return z7_sysctlbyname_Get_BoolInt("hw.optional.neon"); -} - -#ifdef MY_CPU_ARM64 -#define APPLE_CRYPTO_SUPPORT_VAL 1 -#else -#define APPLE_CRYPTO_SUPPORT_VAL 0 -#endif - -BoolInt CPU_IsSupported_SHA1(void) { return APPLE_CRYPTO_SUPPORT_VAL; } -BoolInt CPU_IsSupported_SHA2(void) { return APPLE_CRYPTO_SUPPORT_VAL; } -BoolInt CPU_IsSupported_AES (void) { return APPLE_CRYPTO_SUPPORT_VAL; } - - -#else // __APPLE__ - -#include - -#define USE_HWCAP - -#ifdef USE_HWCAP - -#include - - #define MY_HWCAP_CHECK_FUNC_2(name1, name2) \ - BoolInt CPU_IsSupported_ ## name1() { return (getauxval(AT_HWCAP) & (HWCAP_ ## name2)) ? 1 : 0; } - -#ifdef MY_CPU_ARM64 - #define MY_HWCAP_CHECK_FUNC(name) \ - MY_HWCAP_CHECK_FUNC_2(name, name) - MY_HWCAP_CHECK_FUNC_2(NEON, ASIMD) -// MY_HWCAP_CHECK_FUNC (ASIMD) -#elif defined(MY_CPU_ARM) - #define MY_HWCAP_CHECK_FUNC(name) \ - BoolInt CPU_IsSupported_ ## name() { return (getauxval(AT_HWCAP2) & (HWCAP2_ ## name)) ? 1 : 0; } - MY_HWCAP_CHECK_FUNC_2(NEON, NEON) -#endif - -#else // USE_HWCAP - - #define MY_HWCAP_CHECK_FUNC(name) \ - BoolInt CPU_IsSupported_ ## name() { return 0; } - MY_HWCAP_CHECK_FUNC(NEON) - -#endif // USE_HWCAP - -MY_HWCAP_CHECK_FUNC (CRC32) -MY_HWCAP_CHECK_FUNC (SHA1) -MY_HWCAP_CHECK_FUNC (SHA2) -MY_HWCAP_CHECK_FUNC (AES) - -#endif // __APPLE__ -#endif // _WIN32 - -#endif // MY_CPU_ARM_OR_ARM64 - - - -#ifdef __APPLE__ - -#include - -int z7_sysctlbyname_Get(const char *name, void *buf, size_t *bufSize) -{ - return sysctlbyname(name, buf, bufSize, NULL, 0); -} - -int z7_sysctlbyname_Get_UInt32(const char *name, UInt32 *val) -{ - size_t bufSize = sizeof(*val); - const int res = z7_sysctlbyname_Get(name, val, &bufSize); - if (res == 0 && bufSize != sizeof(*val)) - return EFAULT; - return res; -} - -#endif diff --git a/extern/lzma/CpuArch.h b/extern/lzma/CpuArch.h deleted file mode 100644 index 8e5d8a543f8..00000000000 --- a/extern/lzma/CpuArch.h +++ /dev/null @@ -1,523 +0,0 @@ -/* CpuArch.h -- CPU specific code -2023-04-02 : Igor Pavlov : Public domain */ - -#ifndef ZIP7_INC_CPU_ARCH_H -#define ZIP7_INC_CPU_ARCH_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -/* -MY_CPU_LE means that CPU is LITTLE ENDIAN. -MY_CPU_BE means that CPU is BIG ENDIAN. -If MY_CPU_LE and MY_CPU_BE are not defined, we don't know about ENDIANNESS of platform. - -MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses. - -MY_CPU_64BIT means that processor can work with 64-bit registers. - MY_CPU_64BIT can be used to select fast code branch - MY_CPU_64BIT doesn't mean that (sizeof(void *) == 8) -*/ - -#if defined(_M_X64) \ - || defined(_M_AMD64) \ - || defined(__x86_64__) \ - || defined(__AMD64__) \ - || defined(__amd64__) - #define MY_CPU_AMD64 - #ifdef __ILP32__ - #define MY_CPU_NAME "x32" - #define MY_CPU_SIZEOF_POINTER 4 - #else - #define MY_CPU_NAME "x64" - #define MY_CPU_SIZEOF_POINTER 8 - #endif - #define MY_CPU_64BIT -#endif - - -#if defined(_M_IX86) \ - || defined(__i386__) - #define MY_CPU_X86 - #define MY_CPU_NAME "x86" - /* #define MY_CPU_32BIT */ - #define MY_CPU_SIZEOF_POINTER 4 -#endif - - -#if defined(_M_ARM64) \ - || defined(__AARCH64EL__) \ - || defined(__AARCH64EB__) \ - || defined(__aarch64__) - #define MY_CPU_ARM64 - #ifdef __ILP32__ - #define MY_CPU_NAME "arm64-32" - #define MY_CPU_SIZEOF_POINTER 4 - #else - #define MY_CPU_NAME "arm64" - #define MY_CPU_SIZEOF_POINTER 8 - #endif - #define MY_CPU_64BIT -#endif - - -#if defined(_M_ARM) \ - || defined(_M_ARM_NT) \ - || defined(_M_ARMT) \ - || defined(__arm__) \ - || defined(__thumb__) \ - || defined(__ARMEL__) \ - || defined(__ARMEB__) \ - || defined(__THUMBEL__) \ - || defined(__THUMBEB__) - #define MY_CPU_ARM - - #if defined(__thumb__) || defined(__THUMBEL__) || defined(_M_ARMT) - #define MY_CPU_ARMT - #define MY_CPU_NAME "armt" - #else - #define MY_CPU_ARM32 - #define MY_CPU_NAME "arm" - #endif - /* #define MY_CPU_32BIT */ - #define MY_CPU_SIZEOF_POINTER 4 -#endif - - -#if defined(_M_IA64) \ - || defined(__ia64__) - #define MY_CPU_IA64 - #define MY_CPU_NAME "ia64" - #define MY_CPU_64BIT -#endif - - -#if defined(__mips64) \ - || defined(__mips64__) \ - || (defined(__mips) && (__mips == 64 || __mips == 4 || __mips == 3)) - #define MY_CPU_NAME "mips64" - #define MY_CPU_64BIT -#elif defined(__mips__) - #define MY_CPU_NAME "mips" - /* #define MY_CPU_32BIT */ -#endif - - -#if defined(__ppc64__) \ - || defined(__powerpc64__) \ - || defined(__ppc__) \ - || defined(__powerpc__) \ - || defined(__PPC__) \ - || defined(_POWER) - -#define MY_CPU_PPC_OR_PPC64 - -#if defined(__ppc64__) \ - || defined(__powerpc64__) \ - || defined(_LP64) \ - || defined(__64BIT__) - #ifdef __ILP32__ - #define MY_CPU_NAME "ppc64-32" - #define MY_CPU_SIZEOF_POINTER 4 - #else - #define MY_CPU_NAME "ppc64" - #define MY_CPU_SIZEOF_POINTER 8 - #endif - #define MY_CPU_64BIT -#else - #define MY_CPU_NAME "ppc" - #define MY_CPU_SIZEOF_POINTER 4 - /* #define MY_CPU_32BIT */ -#endif -#endif - - -#if defined(__riscv) \ - || defined(__riscv__) - #if __riscv_xlen == 32 - #define MY_CPU_NAME "riscv32" - #elif __riscv_xlen == 64 - #define MY_CPU_NAME "riscv64" - #else - #define MY_CPU_NAME "riscv" - #endif -#endif - - -#if defined(MY_CPU_X86) || defined(MY_CPU_AMD64) -#define MY_CPU_X86_OR_AMD64 -#endif - -#if defined(MY_CPU_ARM) || defined(MY_CPU_ARM64) -#define MY_CPU_ARM_OR_ARM64 -#endif - - -#ifdef _WIN32 - - #ifdef MY_CPU_ARM - #define MY_CPU_ARM_LE - #endif - - #ifdef MY_CPU_ARM64 - #define MY_CPU_ARM64_LE - #endif - - #ifdef _M_IA64 - #define MY_CPU_IA64_LE - #endif - -#endif - - -#if defined(MY_CPU_X86_OR_AMD64) \ - || defined(MY_CPU_ARM_LE) \ - || defined(MY_CPU_ARM64_LE) \ - || defined(MY_CPU_IA64_LE) \ - || defined(__LITTLE_ENDIAN__) \ - || defined(__ARMEL__) \ - || defined(__THUMBEL__) \ - || defined(__AARCH64EL__) \ - || defined(__MIPSEL__) \ - || defined(__MIPSEL) \ - || defined(_MIPSEL) \ - || defined(__BFIN__) \ - || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) - #define MY_CPU_LE -#endif - -#if defined(__BIG_ENDIAN__) \ - || defined(__ARMEB__) \ - || defined(__THUMBEB__) \ - || defined(__AARCH64EB__) \ - || defined(__MIPSEB__) \ - || defined(__MIPSEB) \ - || defined(_MIPSEB) \ - || defined(__m68k__) \ - || defined(__s390__) \ - || defined(__s390x__) \ - || defined(__zarch__) \ - || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) - #define MY_CPU_BE -#endif - - -#if defined(MY_CPU_LE) && defined(MY_CPU_BE) - #error Stop_Compiling_Bad_Endian -#endif - -#if !defined(MY_CPU_LE) && !defined(MY_CPU_BE) - #error Stop_Compiling_CPU_ENDIAN_must_be_detected_at_compile_time -#endif - -#if defined(MY_CPU_32BIT) && defined(MY_CPU_64BIT) - #error Stop_Compiling_Bad_32_64_BIT -#endif - -#ifdef __SIZEOF_POINTER__ - #ifdef MY_CPU_SIZEOF_POINTER - #if MY_CPU_SIZEOF_POINTER != __SIZEOF_POINTER__ - #error Stop_Compiling_Bad_MY_CPU_PTR_SIZE - #endif - #else - #define MY_CPU_SIZEOF_POINTER __SIZEOF_POINTER__ - #endif -#endif - -#if defined(MY_CPU_SIZEOF_POINTER) && (MY_CPU_SIZEOF_POINTER == 4) -#if defined (_LP64) - #error Stop_Compiling_Bad_MY_CPU_PTR_SIZE -#endif -#endif - -#ifdef _MSC_VER - #if _MSC_VER >= 1300 - #define MY_CPU_pragma_pack_push_1 __pragma(pack(push, 1)) - #define MY_CPU_pragma_pop __pragma(pack(pop)) - #else - #define MY_CPU_pragma_pack_push_1 - #define MY_CPU_pragma_pop - #endif -#else - #ifdef __xlC__ - #define MY_CPU_pragma_pack_push_1 _Pragma("pack(1)") - #define MY_CPU_pragma_pop _Pragma("pack()") - #else - #define MY_CPU_pragma_pack_push_1 _Pragma("pack(push, 1)") - #define MY_CPU_pragma_pop _Pragma("pack(pop)") - #endif -#endif - - -#ifndef MY_CPU_NAME - #ifdef MY_CPU_LE - #define MY_CPU_NAME "LE" - #elif defined(MY_CPU_BE) - #define MY_CPU_NAME "BE" - #else - /* - #define MY_CPU_NAME "" - */ - #endif -#endif - - - - - -#ifdef __has_builtin - #define Z7_has_builtin(x) __has_builtin(x) -#else - #define Z7_has_builtin(x) 0 -#endif - - -#define Z7_BSWAP32_CONST(v) \ - ( (((UInt32)(v) << 24) ) \ - | (((UInt32)(v) << 8) & (UInt32)0xff0000) \ - | (((UInt32)(v) >> 8) & (UInt32)0xff00 ) \ - | (((UInt32)(v) >> 24) )) - - -#if defined(_MSC_VER) && (_MSC_VER >= 1300) - -#include - -/* Note: these macros will use bswap instruction (486), that is unsupported in 386 cpu */ - -#pragma intrinsic(_byteswap_ushort) -#pragma intrinsic(_byteswap_ulong) -#pragma intrinsic(_byteswap_uint64) - -#define Z7_BSWAP16(v) _byteswap_ushort(v) -#define Z7_BSWAP32(v) _byteswap_ulong (v) -#define Z7_BSWAP64(v) _byteswap_uint64(v) -#define Z7_CPU_FAST_BSWAP_SUPPORTED - -#elif (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) \ - || (defined(__clang__) && Z7_has_builtin(__builtin_bswap16)) - -#define Z7_BSWAP16(v) __builtin_bswap16(v) -#define Z7_BSWAP32(v) __builtin_bswap32(v) -#define Z7_BSWAP64(v) __builtin_bswap64(v) -#define Z7_CPU_FAST_BSWAP_SUPPORTED - -#else - -#define Z7_BSWAP16(v) ((UInt16) \ - ( ((UInt32)(v) << 8) \ - | ((UInt32)(v) >> 8) \ - )) - -#define Z7_BSWAP32(v) Z7_BSWAP32_CONST(v) - -#define Z7_BSWAP64(v) \ - ( ( ( (UInt64)(v) ) << 8 * 7 ) \ - | ( ( (UInt64)(v) & ((UInt32)0xff << 8 * 1) ) << 8 * 5 ) \ - | ( ( (UInt64)(v) & ((UInt32)0xff << 8 * 2) ) << 8 * 3 ) \ - | ( ( (UInt64)(v) & ((UInt32)0xff << 8 * 3) ) << 8 * 1 ) \ - | ( ( (UInt64)(v) >> 8 * 1 ) & ((UInt32)0xff << 8 * 3) ) \ - | ( ( (UInt64)(v) >> 8 * 3 ) & ((UInt32)0xff << 8 * 2) ) \ - | ( ( (UInt64)(v) >> 8 * 5 ) & ((UInt32)0xff << 8 * 1) ) \ - | ( ( (UInt64)(v) >> 8 * 7 ) ) \ - ) - -#endif - - - -#ifdef MY_CPU_LE - #if defined(MY_CPU_X86_OR_AMD64) \ - || defined(MY_CPU_ARM64) - #define MY_CPU_LE_UNALIGN - #define MY_CPU_LE_UNALIGN_64 - #elif defined(__ARM_FEATURE_UNALIGNED) - /* gcc9 for 32-bit arm can use LDRD instruction that requires 32-bit alignment. - So we can't use unaligned 64-bit operations. */ - #define MY_CPU_LE_UNALIGN - #endif -#endif - - -#ifdef MY_CPU_LE_UNALIGN - -#define GetUi16(p) (*(const UInt16 *)(const void *)(p)) -#define GetUi32(p) (*(const UInt32 *)(const void *)(p)) -#ifdef MY_CPU_LE_UNALIGN_64 -#define GetUi64(p) (*(const UInt64 *)(const void *)(p)) -#define SetUi64(p, v) { *(UInt64 *)(void *)(p) = (v); } -#endif - -#define SetUi16(p, v) { *(UInt16 *)(void *)(p) = (v); } -#define SetUi32(p, v) { *(UInt32 *)(void *)(p) = (v); } - -#else - -#define GetUi16(p) ( (UInt16) ( \ - ((const Byte *)(p))[0] | \ - ((UInt16)((const Byte *)(p))[1] << 8) )) - -#define GetUi32(p) ( \ - ((const Byte *)(p))[0] | \ - ((UInt32)((const Byte *)(p))[1] << 8) | \ - ((UInt32)((const Byte *)(p))[2] << 16) | \ - ((UInt32)((const Byte *)(p))[3] << 24)) - -#define SetUi16(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \ - _ppp_[0] = (Byte)_vvv_; \ - _ppp_[1] = (Byte)(_vvv_ >> 8); } - -#define SetUi32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \ - _ppp_[0] = (Byte)_vvv_; \ - _ppp_[1] = (Byte)(_vvv_ >> 8); \ - _ppp_[2] = (Byte)(_vvv_ >> 16); \ - _ppp_[3] = (Byte)(_vvv_ >> 24); } - -#endif - - -#ifndef GetUi64 -#define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32)) -#endif - -#ifndef SetUi64 -#define SetUi64(p, v) { Byte *_ppp2_ = (Byte *)(p); UInt64 _vvv2_ = (v); \ - SetUi32(_ppp2_ , (UInt32)_vvv2_) \ - SetUi32(_ppp2_ + 4, (UInt32)(_vvv2_ >> 32)) } -#endif - - -#if defined(MY_CPU_LE_UNALIGN) && defined(Z7_CPU_FAST_BSWAP_SUPPORTED) - -#define GetBe32(p) Z7_BSWAP32 (*(const UInt32 *)(const void *)(p)) -#define SetBe32(p, v) { (*(UInt32 *)(void *)(p)) = Z7_BSWAP32(v); } - -#if defined(MY_CPU_LE_UNALIGN_64) -#define GetBe64(p) Z7_BSWAP64 (*(const UInt64 *)(const void *)(p)) -#endif - -#else - -#define GetBe32(p) ( \ - ((UInt32)((const Byte *)(p))[0] << 24) | \ - ((UInt32)((const Byte *)(p))[1] << 16) | \ - ((UInt32)((const Byte *)(p))[2] << 8) | \ - ((const Byte *)(p))[3] ) - -#define SetBe32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \ - _ppp_[0] = (Byte)(_vvv_ >> 24); \ - _ppp_[1] = (Byte)(_vvv_ >> 16); \ - _ppp_[2] = (Byte)(_vvv_ >> 8); \ - _ppp_[3] = (Byte)_vvv_; } - -#endif - -#ifndef GetBe64 -#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4)) -#endif - -#ifndef GetBe16 -#define GetBe16(p) ( (UInt16) ( \ - ((UInt16)((const Byte *)(p))[0] << 8) | \ - ((const Byte *)(p))[1] )) -#endif - - -#if defined(MY_CPU_BE) -#define Z7_CONV_BE_TO_NATIVE_CONST32(v) (v) -#define Z7_CONV_LE_TO_NATIVE_CONST32(v) Z7_BSWAP32_CONST(v) -#define Z7_CONV_NATIVE_TO_BE_32(v) (v) -#elif defined(MY_CPU_LE) -#define Z7_CONV_BE_TO_NATIVE_CONST32(v) Z7_BSWAP32_CONST(v) -#define Z7_CONV_LE_TO_NATIVE_CONST32(v) (v) -#define Z7_CONV_NATIVE_TO_BE_32(v) Z7_BSWAP32(v) -#else -#error Stop_Compiling_Unknown_Endian_CONV -#endif - - -#if defined(MY_CPU_BE) - -#define GetBe32a(p) (*(const UInt32 *)(const void *)(p)) -#define GetBe16a(p) (*(const UInt16 *)(const void *)(p)) -#define SetBe32a(p, v) { *(UInt32 *)(void *)(p) = (v); } -#define SetBe16a(p, v) { *(UInt16 *)(void *)(p) = (v); } - -#define GetUi32a(p) GetUi32(p) -#define GetUi16a(p) GetUi16(p) -#define SetUi32a(p, v) SetUi32(p, v) -#define SetUi16a(p, v) SetUi16(p, v) - -#elif defined(MY_CPU_LE) - -#define GetUi32a(p) (*(const UInt32 *)(const void *)(p)) -#define GetUi16a(p) (*(const UInt16 *)(const void *)(p)) -#define SetUi32a(p, v) { *(UInt32 *)(void *)(p) = (v); } -#define SetUi16a(p, v) { *(UInt16 *)(void *)(p) = (v); } - -#define GetBe32a(p) GetBe32(p) -#define GetBe16a(p) GetBe16(p) -#define SetBe32a(p, v) SetBe32(p, v) -#define SetBe16a(p, v) SetBe16(p, v) - -#else -#error Stop_Compiling_Unknown_Endian_CPU_a -#endif - - -#if defined(MY_CPU_X86_OR_AMD64) \ - || defined(MY_CPU_ARM_OR_ARM64) \ - || defined(MY_CPU_PPC_OR_PPC64) - #define Z7_CPU_FAST_ROTATE_SUPPORTED -#endif - - -#ifdef MY_CPU_X86_OR_AMD64 - -void Z7_FASTCALL z7_x86_cpuid(UInt32 a[4], UInt32 function); -UInt32 Z7_FASTCALL z7_x86_cpuid_GetMaxFunc(void); -#if defined(MY_CPU_AMD64) -#define Z7_IF_X86_CPUID_SUPPORTED -#else -#define Z7_IF_X86_CPUID_SUPPORTED if (z7_x86_cpuid_GetMaxFunc()) -#endif - -BoolInt CPU_IsSupported_AES(void); -BoolInt CPU_IsSupported_AVX(void); -BoolInt CPU_IsSupported_AVX2(void); -BoolInt CPU_IsSupported_VAES_AVX2(void); -BoolInt CPU_IsSupported_CMOV(void); -BoolInt CPU_IsSupported_SSE(void); -BoolInt CPU_IsSupported_SSE2(void); -BoolInt CPU_IsSupported_SSSE3(void); -BoolInt CPU_IsSupported_SSE41(void); -BoolInt CPU_IsSupported_SHA(void); -BoolInt CPU_IsSupported_PageGB(void); - -#elif defined(MY_CPU_ARM_OR_ARM64) - -BoolInt CPU_IsSupported_CRC32(void); -BoolInt CPU_IsSupported_NEON(void); - -#if defined(_WIN32) -BoolInt CPU_IsSupported_CRYPTO(void); -#define CPU_IsSupported_SHA1 CPU_IsSupported_CRYPTO -#define CPU_IsSupported_SHA2 CPU_IsSupported_CRYPTO -#define CPU_IsSupported_AES CPU_IsSupported_CRYPTO -#else -BoolInt CPU_IsSupported_SHA1(void); -BoolInt CPU_IsSupported_SHA2(void); -BoolInt CPU_IsSupported_AES(void); -#endif - -#endif - -#if defined(__APPLE__) -int z7_sysctlbyname_Get(const char *name, void *buf, size_t *bufSize); -int z7_sysctlbyname_Get_UInt32(const char *name, UInt32 *val); -#endif - -EXTERN_C_END - -#endif diff --git a/extern/lzma/LzFind.c b/extern/lzma/LzFind.c index 0fbd5aae563..34f4f09ea58 100644 --- a/extern/lzma/LzFind.c +++ b/extern/lzma/LzFind.c @@ -1,166 +1,70 @@ /* LzFind.c -- Match finder for LZ algorithms -2023-03-14 : Igor Pavlov : Public domain */ - -#include "Precomp.h" +2008-10-04 : Igor Pavlov : Public domain */ #include -// #include -#include "CpuArch.h" #include "LzFind.h" #include "LzHash.h" -#define kBlockMoveAlign (1 << 7) // alignment for memmove() -#define kBlockSizeAlign (1 << 16) // alignment for block allocation -#define kBlockSizeReserveMin (1 << 24) // it's 1/256 from 4 GB dictinary - #define kEmptyHashValue 0 +#define kMaxValForNormalize ((UInt32)0xFFFFFFFF) +#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */ +#define kNormalizeMask (~(kNormalizeStepMin - 1)) +#define kMaxHistorySize ((UInt32)3 << 30) -#define kMaxValForNormalize ((UInt32)0) -// #define kMaxValForNormalize ((UInt32)(1 << 20) + 0xfff) // for debug +#define kStartMaxLen 3 -// #define kNormalizeAlign (1 << 7) // alignment for speculated accesses - -#define GET_AVAIL_BYTES(p) \ - Inline_MatchFinder_GetNumAvailableBytes(p) - - -// #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) -#define kFix5HashSize kFix4HashSize - -/* - HASH2_CALC: - if (hv) match, then cur[0] and cur[1] also match -*/ -#define HASH2_CALC hv = GetUi16(cur); - -// (crc[0 ... 255] & 0xFF) provides one-to-one correspondence to [0 ... 255] - -/* - HASH3_CALC: - if (cur[0]) and (h2) match, then cur[1] also match - if (cur[0]) and (hv) match, then cur[1] and cur[2] also match -*/ -#define HASH3_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - h2 = temp & (kHash2Size - 1); \ - hv = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; } - -#define HASH4_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - h2 = temp & (kHash2Size - 1); \ - temp ^= ((UInt32)cur[2] << 8); \ - h3 = temp & (kHash3Size - 1); \ - hv = (temp ^ (p->crc[cur[3]] << kLzHash_CrcShift_1)) & p->hashMask; } - -#define HASH5_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - h2 = temp & (kHash2Size - 1); \ - temp ^= ((UInt32)cur[2] << 8); \ - h3 = temp & (kHash3Size - 1); \ - temp ^= (p->crc[cur[3]] << kLzHash_CrcShift_1); \ - /* h4 = temp & p->hash4Mask; */ /* (kHash4Size - 1); */ \ - hv = (temp ^ (p->crc[cur[4]] << kLzHash_CrcShift_2)) & p->hashMask; } - -#define HASH_ZIP_CALC hv = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF; - - -static void LzInWindow_Free(CMatchFinder *p, ISzAllocPtr alloc) +static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc) { - // if (!p->directInput) + if (!p->directInput) { - ISzAlloc_Free(alloc, p->bufBase); - p->bufBase = NULL; + alloc->Free(alloc, p->bufferBase); + p->bufferBase = 0; } } +/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */ -static int LzInWindow_Create2(CMatchFinder *p, UInt32 blockSize, ISzAllocPtr alloc) +static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAlloc *alloc) { - if (blockSize == 0) - return 0; - if (!p->bufBase || p->blockSize != blockSize) + UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv; + if (p->directInput) + { + p->blockSize = blockSize; + return 1; + } + if (p->bufferBase == 0 || p->blockSize != blockSize) { - // size_t blockSizeT; LzInWindow_Free(p, alloc); p->blockSize = blockSize; - // blockSizeT = blockSize; - - // printf("\nblockSize = 0x%x\n", blockSize); - /* - #if defined _WIN64 - // we can allocate 4GiB, but still use UInt32 for (p->blockSize) - // we use UInt32 type for (p->blockSize), because - // we don't want to wrap over 4 GiB, - // when we use (p->streamPos - p->pos) that is UInt32. - if (blockSize >= (UInt32)0 - (UInt32)kBlockSizeAlign) - { - blockSizeT = ((size_t)1 << 32); - printf("\nchanged to blockSizeT = 4GiB\n"); - } - #endif - */ - - p->bufBase = (Byte *)ISzAlloc_Alloc(alloc, blockSize); - // printf("\nbufferBase = %p\n", p->bufBase); - // return 0; // for debug + p->bufferBase = (Byte *)alloc->Alloc(alloc, (size_t)blockSize); } - return (p->bufBase != NULL); + return (p->bufferBase != 0); } -static const Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; } +Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; } +Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; } -static UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return GET_AVAIL_BYTES(p); } +UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; } +void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue) +{ + p->posLimit -= subValue; + p->pos -= subValue; + p->streamPos -= subValue; +} -Z7_NO_INLINE static void MatchFinder_ReadBlock(CMatchFinder *p) { if (p->streamEndWasReached || p->result != SZ_OK) return; - - /* We use (p->streamPos - p->pos) value. - (p->streamPos < p->pos) is allowed. */ - - if (p->directInput) - { - UInt32 curSize = 0xFFFFFFFF - GET_AVAIL_BYTES(p); - if (curSize > p->directInputRem) - curSize = (UInt32)p->directInputRem; - p->streamPos += curSize; - p->directInputRem -= curSize; - if (p->directInputRem == 0) - p->streamEndWasReached = 1; - return; - } - for (;;) { - const Byte *dest = p->buffer + GET_AVAIL_BYTES(p); - size_t size = (size_t)(p->bufBase + p->blockSize - dest); + Byte *dest = p->buffer + (p->streamPos - p->pos); + size_t size = (p->bufferBase + p->blockSize - dest); if (size == 0) - { - /* we call ReadBlock() after NeedMove() and MoveBlock(). - NeedMove() and MoveBlock() povide more than (keepSizeAfter) - to the end of (blockSize). - So we don't execute this branch in normal code flow. - We can go here, if we will call ReadBlock() before NeedMove(), MoveBlock(). - */ - // p->result = SZ_ERROR_FAIL; // we can show error here return; - } - - // #define kRead 3 - // if (size > kRead) size = kRead; // for debug - - /* - // we need cast (Byte *)dest. - #ifdef __clang__ - #pragma GCC diagnostic ignored "-Wcast-qual" - #endif - */ - p->result = ISeqInStream_Read(p->stream, - p->bufBase + (dest - p->bufBase), &size); + p->result = p->stream->Read(p->stream, dest, &size); if (p->result != SZ_OK) return; if (size == 0) @@ -169,60 +73,47 @@ static void MatchFinder_ReadBlock(CMatchFinder *p) return; } p->streamPos += (UInt32)size; - if (GET_AVAIL_BYTES(p) > p->keepSizeAfter) + if (p->streamPos - p->pos > p->keepSizeAfter) return; - /* here and in another (p->keepSizeAfter) checks we keep on 1 byte more than was requested by Create() function - (GET_AVAIL_BYTES(p) >= p->keepSizeAfter) - minimal required size */ } - - // on exit: (p->result != SZ_OK || p->streamEndWasReached || GET_AVAIL_BYTES(p) > p->keepSizeAfter) } - - -Z7_NO_INLINE void MatchFinder_MoveBlock(CMatchFinder *p) { - const size_t offset = (size_t)(p->buffer - p->bufBase) - p->keepSizeBefore; - const size_t keepBefore = (offset & (kBlockMoveAlign - 1)) + p->keepSizeBefore; - p->buffer = p->bufBase + keepBefore; - memmove(p->bufBase, - p->bufBase + (offset & ~((size_t)kBlockMoveAlign - 1)), - keepBefore + (size_t)GET_AVAIL_BYTES(p)); + memmove(p->bufferBase, + p->buffer - p->keepSizeBefore, + (size_t)(p->streamPos - p->pos + p->keepSizeBefore)); + p->buffer = p->bufferBase + p->keepSizeBefore; } -/* We call MoveBlock() before ReadBlock(). - So MoveBlock() can be wasteful operation, if the whole input data - can fit in current block even without calling MoveBlock(). - in important case where (dataSize <= historySize) - condition (p->blockSize > dataSize + p->keepSizeAfter) is met - So there is no MoveBlock() in that case case. -*/ - int MatchFinder_NeedMove(CMatchFinder *p) { - if (p->directInput) - return 0; - if (p->streamEndWasReached || p->result != SZ_OK) - return 0; - return ((size_t)(p->bufBase + p->blockSize - p->buffer) <= p->keepSizeAfter); + /* if (p->streamEndWasReached) return 0; */ + return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter); } void MatchFinder_ReadIfRequired(CMatchFinder *p) { - if (p->keepSizeAfter >= GET_AVAIL_BYTES(p)) + if (p->streamEndWasReached) + return; + if (p->keepSizeAfter >= p->streamPos - p->pos) MatchFinder_ReadBlock(p); } - +static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p) +{ + if (MatchFinder_NeedMove(p)) + MatchFinder_MoveBlock(p); + MatchFinder_ReadBlock(p); +} static void MatchFinder_SetDefaultSettings(CMatchFinder *p) { p->cutValue = 32; p->btMode = 1; p->numHashBytes = 4; - p->numHashBytes_Min = 2; - p->numHashOutBits = 0; + /* p->skipModeBits = 0; */ + p->directInput = 0; p->bigHash = 0; } @@ -230,657 +121,204 @@ static void MatchFinder_SetDefaultSettings(CMatchFinder *p) void MatchFinder_Construct(CMatchFinder *p) { - unsigned i; - p->buffer = NULL; - p->bufBase = NULL; + UInt32 i; + p->bufferBase = 0; p->directInput = 0; - p->stream = NULL; - p->hash = NULL; - p->expectedDataSize = (UInt64)(Int64)-1; + p->hash = 0; MatchFinder_SetDefaultSettings(p); for (i = 0; i < 256; i++) { - UInt32 r = (UInt32)i; - unsigned j; + UInt32 r = i; + int j; for (j = 0; j < 8; j++) - r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1))); + r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); p->crc[i] = r; } } -#undef kCrcPoly - -static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAllocPtr alloc) +static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc) { - ISzAlloc_Free(alloc, p->hash); - p->hash = NULL; + alloc->Free(alloc, p->hash); + p->hash = 0; } -void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc) +void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc) { MatchFinder_FreeThisClassMemory(p, alloc); LzInWindow_Free(p, alloc); } -static CLzRef* AllocRefs(size_t num, ISzAllocPtr alloc) +static CLzRef* AllocRefs(UInt32 num, ISzAlloc *alloc) { - const size_t sizeInBytes = (size_t)num * sizeof(CLzRef); + size_t sizeInBytes = (size_t)num * sizeof(CLzRef); if (sizeInBytes / sizeof(CLzRef) != num) - return NULL; - return (CLzRef *)ISzAlloc_Alloc(alloc, sizeInBytes); -} - -#if (kBlockSizeReserveMin < kBlockSizeAlign * 2) - #error Stop_Compiling_Bad_Reserve -#endif - - - -static UInt32 GetBlockSize(CMatchFinder *p, UInt32 historySize) -{ - UInt32 blockSize = (p->keepSizeBefore + p->keepSizeAfter); - /* - if (historySize > kMaxHistorySize) return 0; - */ - // printf("\nhistorySize == 0x%x\n", historySize); - - if (p->keepSizeBefore < historySize || blockSize < p->keepSizeBefore) // if 32-bit overflow - return 0; - - { - const UInt32 kBlockSizeMax = (UInt32)0 - (UInt32)kBlockSizeAlign; - const UInt32 rem = kBlockSizeMax - blockSize; - const UInt32 reserve = (blockSize >> (blockSize < ((UInt32)1 << 30) ? 1 : 2)) - + (1 << 12) + kBlockMoveAlign + kBlockSizeAlign; // do not overflow 32-bit here - if (blockSize >= kBlockSizeMax - || rem < kBlockSizeReserveMin) // we reject settings that will be slow - return 0; - if (reserve >= rem) - blockSize = kBlockSizeMax; - else - { - blockSize += reserve; - blockSize &= ~(UInt32)(kBlockSizeAlign - 1); - } - } - // printf("\n LzFind_blockSize = %x\n", blockSize); - // printf("\n LzFind_blockSize = %d\n", blockSize >> 20); - return blockSize; + return (CLzRef *)alloc->Alloc(alloc, sizeInBytes); } - -// input is historySize -static UInt32 MatchFinder_GetHashMask2(CMatchFinder *p, UInt32 hs) -{ - if (p->numHashBytes == 2) - return (1 << 16) - 1; - if (hs != 0) - hs--; - hs |= (hs >> 1); - hs |= (hs >> 2); - hs |= (hs >> 4); - hs |= (hs >> 8); - // we propagated 16 bits in (hs). Low 16 bits must be set later - if (hs >= (1 << 24)) - { - if (p->numHashBytes == 3) - hs = (1 << 24) - 1; - /* if (bigHash) mode, GetHeads4b() in LzFindMt.c needs (hs >= ((1 << 24) - 1))) */ - } - // (hash_size >= (1 << 16)) : Required for (numHashBytes > 2) - hs |= (1 << 16) - 1; /* don't change it! */ - // bt5: we adjust the size with recommended minimum size - if (p->numHashBytes >= 5) - hs |= (256 << kLzHash_CrcShift_2) - 1; - return hs; -} - -// input is historySize -static UInt32 MatchFinder_GetHashMask(CMatchFinder *p, UInt32 hs) -{ - if (p->numHashBytes == 2) - return (1 << 16) - 1; - if (hs != 0) - hs--; - hs |= (hs >> 1); - hs |= (hs >> 2); - hs |= (hs >> 4); - hs |= (hs >> 8); - // we propagated 16 bits in (hs). Low 16 bits must be set later - hs >>= 1; - if (hs >= (1 << 24)) - { - if (p->numHashBytes == 3) - hs = (1 << 24) - 1; - else - hs >>= 1; - /* if (bigHash) mode, GetHeads4b() in LzFindMt.c needs (hs >= ((1 << 24) - 1))) */ - } - // (hash_size >= (1 << 16)) : Required for (numHashBytes > 2) - hs |= (1 << 16) - 1; /* don't change it! */ - // bt5: we adjust the size with recommended minimum size - if (p->numHashBytes >= 5) - hs |= (256 << kLzHash_CrcShift_2) - 1; - return hs; -} - - int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, - ISzAllocPtr alloc) + ISzAlloc *alloc) { - /* we need one additional byte in (p->keepSizeBefore), - since we use MoveBlock() after (p->pos++) and before dictionary using */ - // keepAddBufferBefore = (UInt32)0xFFFFFFFF - (1 << 22); // for debug - p->keepSizeBefore = historySize + keepAddBufferBefore + 1; - - keepAddBufferAfter += matchMaxLen; - /* we need (p->keepSizeAfter >= p->numHashBytes) */ - if (keepAddBufferAfter < p->numHashBytes) - keepAddBufferAfter = p->numHashBytes; - // keepAddBufferAfter -= 2; // for debug - p->keepSizeAfter = keepAddBufferAfter; - - if (p->directInput) - p->blockSize = 0; - if (p->directInput || LzInWindow_Create2(p, GetBlockSize(p, historySize), alloc)) + UInt32 sizeReserv; + if (historySize > kMaxHistorySize) { - size_t hashSizeSum; + MatchFinder_Free(p, alloc); + return 0; + } + sizeReserv = historySize >> 1; + if (historySize > ((UInt32)2 << 30)) + sizeReserv = historySize >> 2; + sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19); + + p->keepSizeBefore = historySize + keepAddBufferBefore + 1; + p->keepSizeAfter = matchMaxLen + keepAddBufferAfter; + /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */ + if (LzInWindow_Create(p, sizeReserv, alloc)) + { + UInt32 newCyclicBufferSize = (historySize /* >> p->skipModeBits */) + 1; + UInt32 hs; + p->matchMaxLen = matchMaxLen; { - UInt32 hs; - UInt32 hsCur; - - if (p->numHashOutBits != 0) - { - unsigned numBits = p->numHashOutBits; - const unsigned nbMax = - (p->numHashBytes == 2 ? 16 : - (p->numHashBytes == 3 ? 24 : 32)); - if (numBits > nbMax) - numBits = nbMax; - if (numBits >= 32) - hs = (UInt32)0 - 1; - else - hs = ((UInt32)1 << numBits) - 1; - // (hash_size >= (1 << 16)) : Required for (numHashBytes > 2) - hs |= (1 << 16) - 1; /* don't change it! */ - if (p->numHashBytes >= 5) - hs |= (256 << kLzHash_CrcShift_2) - 1; - { - const UInt32 hs2 = MatchFinder_GetHashMask2(p, historySize); - if (hs > hs2) - hs = hs2; - } - hsCur = hs; - if (p->expectedDataSize < historySize) - { - const UInt32 hs2 = MatchFinder_GetHashMask2(p, (UInt32)p->expectedDataSize); - if (hsCur > hs2) - hsCur = hs2; - } - } + p->fixedHashSize = 0; + if (p->numHashBytes == 2) + hs = (1 << 16) - 1; else { - hs = MatchFinder_GetHashMask(p, historySize); - hsCur = hs; - if (p->expectedDataSize < historySize) + hs = historySize - 1; + hs |= (hs >> 1); + hs |= (hs >> 2); + hs |= (hs >> 4); + hs |= (hs >> 8); + hs >>= 1; + /* hs >>= p->skipModeBits; */ + hs |= 0xFFFF; /* don't change it! It's required for Deflate */ + if (hs > (1 << 24)) { - hsCur = MatchFinder_GetHashMask(p, (UInt32)p->expectedDataSize); - if (hsCur > hs) // is it possible? - hsCur = hs; + if (p->numHashBytes == 3) + hs = (1 << 24) - 1; + else + hs >>= 1; } } - - p->hashMask = hsCur; - - hashSizeSum = hs; - hashSizeSum++; - if (hashSizeSum < hs) - return 0; - { - UInt32 fixedHashSize = 0; - if (p->numHashBytes > 2 && p->numHashBytes_Min <= 2) fixedHashSize += kHash2Size; - if (p->numHashBytes > 3 && p->numHashBytes_Min <= 3) fixedHashSize += kHash3Size; - // if (p->numHashBytes > 4) p->fixedHashSize += hs4; // kHash4Size; - hashSizeSum += fixedHashSize; - p->fixedHashSize = fixedHashSize; - } + p->hashMask = hs; + hs++; + if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size; + if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size; + if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size; + hs += p->fixedHashSize; } - p->matchMaxLen = matchMaxLen; - { - size_t newSize; - size_t numSons; - const UInt32 newCyclicBufferSize = historySize + 1; // do not change it + UInt32 prevSize = p->hashSizeSum + p->numSons; + UInt32 newSize; p->historySize = historySize; - p->cyclicBufferSize = newCyclicBufferSize; // it must be = (historySize + 1) - - numSons = newCyclicBufferSize; - if (p->btMode) - numSons <<= 1; - newSize = hashSizeSum + numSons; - - if (numSons < newCyclicBufferSize || newSize < numSons) - return 0; - - // aligned size is not required here, but it can be better for some loops - #define NUM_REFS_ALIGN_MASK 0xF - newSize = (newSize + NUM_REFS_ALIGN_MASK) & ~(size_t)NUM_REFS_ALIGN_MASK; - - // 22.02: we don't reallocate buffer, if old size is enough - if (p->hash && p->numRefs >= newSize) + p->hashSizeSum = hs; + p->cyclicBufferSize = newCyclicBufferSize; + p->numSons = (p->btMode ? newCyclicBufferSize * 2 : newCyclicBufferSize); + newSize = p->hashSizeSum + p->numSons; + if (p->hash != 0 && prevSize == newSize) return 1; - MatchFinder_FreeThisClassMemory(p, alloc); - p->numRefs = newSize; p->hash = AllocRefs(newSize, alloc); - - if (p->hash) + if (p->hash != 0) { - p->son = p->hash + hashSizeSum; + p->son = p->hash + p->hashSizeSum; return 1; } } } - MatchFinder_Free(p, alloc); return 0; } - static void MatchFinder_SetLimits(CMatchFinder *p) { - UInt32 k; - UInt32 n = kMaxValForNormalize - p->pos; - if (n == 0) - n = (UInt32)(Int32)-1; // we allow (pos == 0) at start even with (kMaxValForNormalize == 0) - - k = p->cyclicBufferSize - p->cyclicBufferPos; - if (k < n) - n = k; - - k = GET_AVAIL_BYTES(p); + UInt32 limit = kMaxValForNormalize - p->pos; + UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos; + if (limit2 < limit) + limit = limit2; + limit2 = p->streamPos - p->pos; + if (limit2 <= p->keepSizeAfter) { - const UInt32 ksa = p->keepSizeAfter; - UInt32 mm = p->matchMaxLen; - if (k > ksa) - k -= ksa; // we must limit exactly to keepSizeAfter for ReadBlock - else if (k >= mm) - { - // the limitation for (p->lenLimit) update - k -= mm; // optimization : to reduce the number of checks - k++; - // k = 1; // non-optimized version : for debug - } - else - { - mm = k; - if (k != 0) - k = 1; - } - p->lenLimit = mm; + if (limit2 > 0) + limit2 = 1; } - if (k < n) - n = k; - - p->posLimit = p->pos + n; -} - - -void MatchFinder_Init_LowHash(CMatchFinder *p) -{ - size_t i; - CLzRef *items = p->hash; - const size_t numItems = p->fixedHashSize; - for (i = 0; i < numItems; i++) - items[i] = kEmptyHashValue; -} - - -void MatchFinder_Init_HighHash(CMatchFinder *p) -{ - size_t i; - CLzRef *items = p->hash + p->fixedHashSize; - const size_t numItems = (size_t)p->hashMask + 1; - for (i = 0; i < numItems; i++) - items[i] = kEmptyHashValue; -} - - -void MatchFinder_Init_4(CMatchFinder *p) -{ - if (!p->directInput) - p->buffer = p->bufBase; + else + limit2 -= p->keepSizeAfter; + if (limit2 < limit) + limit = limit2; { - /* kEmptyHashValue = 0 (Zero) is used in hash tables as NO-VALUE marker. - the code in CMatchFinderMt expects (pos = 1) */ - p->pos = - p->streamPos = - 1; // it's smallest optimal value. do not change it - // 0; // for debug + UInt32 lenLimit = p->streamPos - p->pos; + if (lenLimit > p->matchMaxLen) + lenLimit = p->matchMaxLen; + p->lenLimit = lenLimit; } - p->result = SZ_OK; - p->streamEndWasReached = 0; + p->posLimit = p->pos + limit; } - -// (CYC_TO_POS_OFFSET == 0) is expected by some optimized code -#define CYC_TO_POS_OFFSET 0 -// #define CYC_TO_POS_OFFSET 1 // for debug - void MatchFinder_Init(CMatchFinder *p) { - MatchFinder_Init_HighHash(p); - MatchFinder_Init_LowHash(p); - MatchFinder_Init_4(p); - // if (readData) + UInt32 i; + for (i = 0; i < p->hashSizeSum; i++) + p->hash[i] = kEmptyHashValue; + p->cyclicBufferPos = 0; + p->buffer = p->bufferBase; + p->pos = p->streamPos = p->cyclicBufferSize; + p->result = SZ_OK; + p->streamEndWasReached = 0; MatchFinder_ReadBlock(p); - - /* if we init (cyclicBufferPos = pos), then we can use one variable - instead of both (cyclicBufferPos) and (pos) : only before (cyclicBufferPos) wrapping */ - p->cyclicBufferPos = (p->pos - CYC_TO_POS_OFFSET); // init with relation to (pos) - // p->cyclicBufferPos = 0; // smallest value - // p->son[0] = p->son[1] = 0; // unused: we can init skipped record for speculated accesses. MatchFinder_SetLimits(p); } - - -#ifdef MY_CPU_X86_OR_AMD64 - #if defined(__clang__) && (__clang_major__ >= 4) \ - || defined(Z7_GCC_VERSION) && (Z7_GCC_VERSION >= 40701) - // || defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1900) - - #define USE_LZFIND_SATUR_SUB_128 - #define USE_LZFIND_SATUR_SUB_256 - #define LZFIND_ATTRIB_SSE41 __attribute__((__target__("sse4.1"))) - #define LZFIND_ATTRIB_AVX2 __attribute__((__target__("avx2"))) - #elif defined(_MSC_VER) - #if (_MSC_VER >= 1600) - #define USE_LZFIND_SATUR_SUB_128 - #endif - #if (_MSC_VER >= 1900) - #define USE_LZFIND_SATUR_SUB_256 - #endif - #endif - -// #elif defined(MY_CPU_ARM_OR_ARM64) -#elif defined(MY_CPU_ARM64) - - #if defined(__clang__) && (__clang_major__ >= 8) \ - || defined(__GNUC__) && (__GNUC__ >= 8) - #define USE_LZFIND_SATUR_SUB_128 - #ifdef MY_CPU_ARM64 - // #define LZFIND_ATTRIB_SSE41 __attribute__((__target__(""))) - #else - // #define LZFIND_ATTRIB_SSE41 __attribute__((__target__("fpu=crypto-neon-fp-armv8"))) - #endif - - #elif defined(_MSC_VER) - #if (_MSC_VER >= 1910) - #define USE_LZFIND_SATUR_SUB_128 - #endif - #endif - - #if defined(_MSC_VER) && defined(MY_CPU_ARM64) - #include - #else - #include - #endif - -#endif - - -#ifdef USE_LZFIND_SATUR_SUB_128 - -// #define Z7_SHOW_HW_STATUS - -#ifdef Z7_SHOW_HW_STATUS -#include -#define PRF(x) x -PRF(;) -#else -#define PRF(x) -#endif - - -#ifdef MY_CPU_ARM_OR_ARM64 - -#ifdef MY_CPU_ARM64 -// #define FORCE_LZFIND_SATUR_SUB_128 -#endif -typedef uint32x4_t LzFind_v128; -#define SASUB_128_V(v, s) \ - vsubq_u32(vmaxq_u32(v, s), s) - -#else // MY_CPU_ARM_OR_ARM64 - -#include // sse4.1 - -typedef __m128i LzFind_v128; -// SSE 4.1 -#define SASUB_128_V(v, s) \ - _mm_sub_epi32(_mm_max_epu32(v, s), s) - -#endif // MY_CPU_ARM_OR_ARM64 - - -#define SASUB_128(i) \ - *( LzFind_v128 *)( void *)(items + (i) * 4) = SASUB_128_V( \ - *(const LzFind_v128 *)(const void *)(items + (i) * 4), sub2); - - -Z7_NO_INLINE -static -#ifdef LZFIND_ATTRIB_SSE41 -LZFIND_ATTRIB_SSE41 -#endif -void -Z7_FASTCALL -LzFind_SaturSub_128(UInt32 subValue, CLzRef *items, const CLzRef *lim) +static UInt32 MatchFinder_GetSubValue(CMatchFinder *p) { - const LzFind_v128 sub2 = - #ifdef MY_CPU_ARM_OR_ARM64 - vdupq_n_u32(subValue); - #else - _mm_set_epi32((Int32)subValue, (Int32)subValue, (Int32)subValue, (Int32)subValue); - #endif - Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE - do - { - SASUB_128(0) SASUB_128(1) items += 2 * 4; - SASUB_128(0) SASUB_128(1) items += 2 * 4; - } - while (items != lim); + return (p->pos - p->historySize - 1) & kNormalizeMask; } - - -#ifdef USE_LZFIND_SATUR_SUB_256 - -#include // avx -/* -clang :immintrin.h uses -#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \ - defined(__AVX2__) -#include -#endif -so we need for clang-cl */ - -#if defined(__clang__) -#include -#include -#endif - -// AVX2: -#define SASUB_256(i) \ - *( __m256i *)( void *)(items + (i) * 8) = \ - _mm256_sub_epi32(_mm256_max_epu32( \ - *(const __m256i *)(const void *)(items + (i) * 8), sub2), sub2); - -Z7_NO_INLINE -static -#ifdef LZFIND_ATTRIB_AVX2 -LZFIND_ATTRIB_AVX2 -#endif -void -Z7_FASTCALL -LzFind_SaturSub_256(UInt32 subValue, CLzRef *items, const CLzRef *lim) +void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems) { - const __m256i sub2 = _mm256_set_epi32( - (Int32)subValue, (Int32)subValue, (Int32)subValue, (Int32)subValue, - (Int32)subValue, (Int32)subValue, (Int32)subValue, (Int32)subValue); - Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE - do + UInt32 i; + for (i = 0; i < numItems; i++) { - SASUB_256(0) SASUB_256(1) items += 2 * 8; - SASUB_256(0) SASUB_256(1) items += 2 * 8; - } - while (items != lim); -} -#endif // USE_LZFIND_SATUR_SUB_256 - -#ifndef FORCE_LZFIND_SATUR_SUB_128 -typedef void (Z7_FASTCALL *LZFIND_SATUR_SUB_CODE_FUNC)( - UInt32 subValue, CLzRef *items, const CLzRef *lim); -static LZFIND_SATUR_SUB_CODE_FUNC g_LzFind_SaturSub; -#endif // FORCE_LZFIND_SATUR_SUB_128 - -#endif // USE_LZFIND_SATUR_SUB_128 - - -// kEmptyHashValue must be zero -// #define SASUB_32(i) { UInt32 v = items[i]; UInt32 m = v - subValue; if (v < subValue) m = kEmptyHashValue; items[i] = m; } -#define SASUB_32(i) { UInt32 v = items[i]; if (v < subValue) v = subValue; items[i] = v - subValue; } - -#ifdef FORCE_LZFIND_SATUR_SUB_128 - -#define DEFAULT_SaturSub LzFind_SaturSub_128 - -#else - -#define DEFAULT_SaturSub LzFind_SaturSub_32 - -Z7_NO_INLINE -static -void -Z7_FASTCALL -LzFind_SaturSub_32(UInt32 subValue, CLzRef *items, const CLzRef *lim) -{ - Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE - do - { - SASUB_32(0) SASUB_32(1) items += 2; - SASUB_32(0) SASUB_32(1) items += 2; - SASUB_32(0) SASUB_32(1) items += 2; - SASUB_32(0) SASUB_32(1) items += 2; - } - while (items != lim); -} - -#endif - - -Z7_NO_INLINE -void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems) -{ - #define LZFIND_NORM_ALIGN_BLOCK_SIZE (1 << 7) - Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE - for (; numItems != 0 && ((unsigned)(ptrdiff_t)items & (LZFIND_NORM_ALIGN_BLOCK_SIZE - 1)) != 0; numItems--) - { - SASUB_32(0) - items++; - } - { - const size_t k_Align_Mask = (LZFIND_NORM_ALIGN_BLOCK_SIZE / 4 - 1); - CLzRef *lim = items + (numItems & ~(size_t)k_Align_Mask); - numItems &= k_Align_Mask; - if (items != lim) - { - #if defined(USE_LZFIND_SATUR_SUB_128) && !defined(FORCE_LZFIND_SATUR_SUB_128) - if (g_LzFind_SaturSub) - g_LzFind_SaturSub(subValue, items, lim); - else - #endif - DEFAULT_SaturSub(subValue, items, lim); - } - items = lim; - } - Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE - for (; numItems != 0; numItems--) - { - SASUB_32(0) - items++; + UInt32 value = items[i]; + if (value <= subValue) + value = kEmptyHashValue; + else + value -= subValue; + items[i] = value; } } +static void MatchFinder_Normalize(CMatchFinder *p) +{ + UInt32 subValue = MatchFinder_GetSubValue(p); + MatchFinder_Normalize3(subValue, p->hash, p->hashSizeSum + p->numSons); + MatchFinder_ReduceOffsets(p, subValue); +} - -// call MatchFinder_CheckLimits() only after (p->pos++) update - -Z7_NO_INLINE static void MatchFinder_CheckLimits(CMatchFinder *p) { - if (// !p->streamEndWasReached && p->result == SZ_OK && - p->keepSizeAfter == GET_AVAIL_BYTES(p)) - { - // we try to read only in exact state (p->keepSizeAfter == GET_AVAIL_BYTES(p)) - if (MatchFinder_NeedMove(p)) - MatchFinder_MoveBlock(p); - MatchFinder_ReadBlock(p); - } - if (p->pos == kMaxValForNormalize) - if (GET_AVAIL_BYTES(p) >= p->numHashBytes) // optional optimization for last bytes of data. - /* - if we disable normalization for last bytes of data, and - if (data_size == 4 GiB), we don't call wastfull normalization, - but (pos) will be wrapped over Zero (0) in that case. - And we cannot resume later to normal operation - */ - { - // MatchFinder_Normalize(p); - /* after normalization we need (p->pos >= p->historySize + 1); */ - /* we can reduce subValue to aligned value, if want to keep alignment - of (p->pos) and (p->buffer) for speculated accesses. */ - const UInt32 subValue = (p->pos - p->historySize - 1) /* & ~(UInt32)(kNormalizeAlign - 1) */; - // const UInt32 subValue = (1 << 15); // for debug - // printf("\nMatchFinder_Normalize() subValue == 0x%x\n", subValue); - MatchFinder_REDUCE_OFFSETS(p, subValue) - MatchFinder_Normalize3(subValue, p->hash, (size_t)p->hashMask + 1 + p->fixedHashSize); - { - size_t numSonRefs = p->cyclicBufferSize; - if (p->btMode) - numSonRefs <<= 1; - MatchFinder_Normalize3(subValue, p->son, numSonRefs); - } - } - + MatchFinder_Normalize(p); + if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos) + MatchFinder_CheckAndMoveAndRead(p); if (p->cyclicBufferPos == p->cyclicBufferSize) p->cyclicBufferPos = 0; - MatchFinder_SetLimits(p); } - -/* - (lenLimit > maxLen) -*/ -Z7_FORCE_INLINE -static UInt32 * Hc_GetMatchesSpec(size_t lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, - size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, - UInt32 *d, unsigned maxLen) +static UInt32 * Hc_GetMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, + UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, + UInt32 *distances, UInt32 maxLen) { - /* son[_cyclicBufferPos] = curMatch; for (;;) { UInt32 delta = pos - curMatch; if (cutValue-- == 0 || delta >= _cyclicBufferSize) - return d; + return distances; { const Byte *pb = cur - delta; curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; @@ -892,91 +330,35 @@ static UInt32 * Hc_GetMatchesSpec(size_t lenLimit, UInt32 curMatch, UInt32 pos, break; if (maxLen < len) { - maxLen = len; - *d++ = len; - *d++ = delta - 1; + *distances++ = maxLen = len; + *distances++ = delta - 1; if (len == lenLimit) - return d; + return distances; } } } } - */ - - const Byte *lim = cur + lenLimit; - son[_cyclicBufferPos] = curMatch; - - do - { - UInt32 delta; - - if (curMatch == 0) - break; - // if (curMatch2 >= curMatch) return NULL; - delta = pos - curMatch; - if (delta >= _cyclicBufferSize) - break; - { - ptrdiff_t diff; - curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; - diff = (ptrdiff_t)0 - (ptrdiff_t)delta; - if (cur[maxLen] == cur[(ptrdiff_t)maxLen + diff]) - { - const Byte *c = cur; - while (*c == c[diff]) - { - if (++c == lim) - { - d[0] = (UInt32)(lim - cur); - d[1] = delta - 1; - return d + 2; - } - } - { - const unsigned len = (unsigned)(c - cur); - if (maxLen < len) - { - maxLen = len; - d[0] = (UInt32)len; - d[1] = delta - 1; - d += 2; - } - } - } - } - } - while (--cutValue); - - return d; } - -Z7_FORCE_INLINE UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, - size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, - UInt32 *d, UInt32 maxLen) + UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, + UInt32 *distances, UInt32 maxLen) { - CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1; - CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); - unsigned len0 = 0, len1 = 0; - - UInt32 cmCheck; - - // if (curMatch >= pos) { *ptr0 = *ptr1 = kEmptyHashValue; return NULL; } - - cmCheck = (UInt32)(pos - _cyclicBufferSize); - if ((UInt32)pos <= _cyclicBufferSize) - cmCheck = 0; - - if (cmCheck < curMatch) - do + CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1; + CLzRef *ptr1 = son + (_cyclicBufferPos << 1); + UInt32 len0 = 0, len1 = 0; + for (;;) { - const UInt32 delta = pos - curMatch; + UInt32 delta = pos - curMatch; + if (cutValue-- == 0 || delta >= _cyclicBufferSize) { - CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); + *ptr0 = *ptr1 = kEmptyHashValue; + return distances; + } + { + CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); const Byte *pb = cur - delta; - unsigned len = (len0 < len1 ? len0 : len1); - const UInt32 pair0 = pair[0]; + UInt32 len = (len0 < len1 ? len0 : len1); if (pb[len] == cur[len]) { if (++len != lenLimit && pb[len] == cur[len]) @@ -985,65 +367,52 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt break; if (maxLen < len) { - maxLen = (UInt32)len; - *d++ = (UInt32)len; - *d++ = delta - 1; + *distances++ = maxLen = len; + *distances++ = delta - 1; if (len == lenLimit) { - *ptr1 = pair0; + *ptr1 = pair[0]; *ptr0 = pair[1]; - return d; + return distances; } } } if (pb[len] < cur[len]) { *ptr1 = curMatch; - // const UInt32 curMatch2 = pair[1]; - // if (curMatch2 >= curMatch) { *ptr0 = *ptr1 = kEmptyHashValue; return NULL; } - // curMatch = curMatch2; - curMatch = pair[1]; ptr1 = pair + 1; + curMatch = *ptr1; len1 = len; } else { *ptr0 = curMatch; - curMatch = pair[0]; ptr0 = pair; + curMatch = *ptr0; len0 = len; } } } - while(--cutValue && cmCheck < curMatch); - - *ptr0 = *ptr1 = kEmptyHashValue; - return d; } - static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, - size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue) + UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue) { - CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1; - CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); - unsigned len0 = 0, len1 = 0; - - UInt32 cmCheck; - - cmCheck = (UInt32)(pos - _cyclicBufferSize); - if ((UInt32)pos <= _cyclicBufferSize) - cmCheck = 0; - - if (// curMatch >= pos || // failure - cmCheck < curMatch) - do + CLzRef *ptr0 = son + (_cyclicBufferPos << 1) + 1; + CLzRef *ptr1 = son + (_cyclicBufferPos << 1); + UInt32 len0 = 0, len1 = 0; + for (;;) { - const UInt32 delta = pos - curMatch; + UInt32 delta = pos - curMatch; + if (cutValue-- == 0 || delta >= _cyclicBufferSize) { - CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); + *ptr0 = *ptr1 = kEmptyHashValue; + return; + } + { + CLzRef *pair = son + ((_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); const Byte *pb = cur - delta; - unsigned len = (len0 < len1 ? len0 : len1); + UInt32 len = (len0 < len1 ? len0 : len1); if (pb[len] == cur[len]) { while (++len != lenLimit) @@ -1061,594 +430,308 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const if (pb[len] < cur[len]) { *ptr1 = curMatch; - curMatch = pair[1]; ptr1 = pair + 1; + curMatch = *ptr1; len1 = len; } else { *ptr0 = curMatch; - curMatch = pair[0]; ptr0 = pair; + curMatch = *ptr0; len0 = len; } } } - while(--cutValue && cmCheck < curMatch); - - *ptr0 = *ptr1 = kEmptyHashValue; - return; } - #define MOVE_POS \ ++p->cyclicBufferPos; \ p->buffer++; \ - { const UInt32 pos1 = p->pos + 1; p->pos = pos1; if (pos1 == p->posLimit) MatchFinder_CheckLimits(p); } + if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p); -#define MOVE_POS_RET MOVE_POS return distances; +#define MOVE_POS_RET MOVE_POS return offset; -Z7_NO_INLINE -static void MatchFinder_MovePos(CMatchFinder *p) -{ - /* we go here at the end of stream data, when (avail < num_hash_bytes) - We don't update sons[cyclicBufferPos << btMode]. - So (sons) record will contain junk. And we cannot resume match searching - to normal operation, even if we will provide more input data in buffer. - p->sons[p->cyclicBufferPos << p->btMode] = 0; // kEmptyHashValue - if (p->btMode) - p->sons[(p->cyclicBufferPos << p->btMode) + 1] = 0; // kEmptyHashValue - */ - MOVE_POS -} +static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } #define GET_MATCHES_HEADER2(minLen, ret_op) \ - unsigned lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \ - lenLimit = (unsigned)p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \ + UInt32 lenLimit; UInt32 hashValue; const Byte *cur; UInt32 curMatch; \ + lenLimit = p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \ cur = p->buffer; -#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return distances) -#define SKIP_HEADER(minLen) do { GET_MATCHES_HEADER2(minLen, continue) +#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0) +#define SKIP_HEADER(minLen) GET_MATCHES_HEADER2(minLen, continue) -#define MF_PARAMS(p) lenLimit, curMatch, p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue +#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue -#define SKIP_FOOTER SkipMatchesSpec(MF_PARAMS(p)); MOVE_POS } while (--num); +#define GET_MATCHES_FOOTER(offset, maxLen) \ + offset = (UInt32)(GetMatchesSpec1(lenLimit, curMatch, MF_PARAMS(p), \ + distances + offset, maxLen) - distances); MOVE_POS_RET; -#define GET_MATCHES_FOOTER_BASE(_maxLen_, func) \ - distances = func(MF_PARAMS(p), \ - distances, (UInt32)_maxLen_); MOVE_POS_RET +#define SKIP_FOOTER \ + SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS; -#define GET_MATCHES_FOOTER_BT(_maxLen_) \ - GET_MATCHES_FOOTER_BASE(_maxLen_, GetMatchesSpec1) - -#define GET_MATCHES_FOOTER_HC(_maxLen_) \ - GET_MATCHES_FOOTER_BASE(_maxLen_, Hc_GetMatchesSpec) - - - -#define UPDATE_maxLen { \ - const ptrdiff_t diff = (ptrdiff_t)0 - (ptrdiff_t)d2; \ - const Byte *c = cur + maxLen; \ - const Byte *lim = cur + lenLimit; \ - for (; c != lim; c++) if (*(c + diff) != *c) break; \ - maxLen = (unsigned)(c - cur); } - -static UInt32* Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) { + UInt32 offset; GET_MATCHES_HEADER(2) - HASH2_CALC - curMatch = p->hash[hv]; - p->hash[hv] = p->pos; - GET_MATCHES_FOOTER_BT(1) + HASH2_CALC; + curMatch = p->hash[hashValue]; + p->hash[hashValue] = p->pos; + offset = 0; + GET_MATCHES_FOOTER(offset, 1) } -UInt32* Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) { + UInt32 offset; GET_MATCHES_HEADER(3) - HASH_ZIP_CALC - curMatch = p->hash[hv]; - p->hash[hv] = p->pos; - GET_MATCHES_FOOTER_BT(2) + HASH_ZIP_CALC; + curMatch = p->hash[hashValue]; + p->hash[hashValue] = p->pos; + offset = 0; + GET_MATCHES_FOOTER(offset, 2) } - -#define SET_mmm \ - mmm = p->cyclicBufferSize; \ - if (pos < mmm) \ - mmm = pos; - - -static UInt32* Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) { - UInt32 mmm; - UInt32 h2, d2, pos; - unsigned maxLen; - UInt32 *hash; + UInt32 hash2Value, delta2, maxLen, offset; GET_MATCHES_HEADER(3) - HASH3_CALC + HASH3_CALC; - hash = p->hash; - pos = p->pos; - - d2 = pos - hash[h2]; - - curMatch = (hash + kFix3HashSize)[hv]; + delta2 = p->pos - p->hash[hash2Value]; + curMatch = p->hash[kFix3HashSize + hashValue]; - hash[h2] = pos; - (hash + kFix3HashSize)[hv] = pos; + p->hash[hash2Value] = + p->hash[kFix3HashSize + hashValue] = p->pos; - SET_mmm maxLen = 2; - - if (d2 < mmm && *(cur - d2) == *cur) + offset = 0; + if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) { - UPDATE_maxLen - distances[0] = (UInt32)maxLen; - distances[1] = d2 - 1; - distances += 2; + for (; maxLen != lenLimit; maxLen++) + if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) + break; + distances[0] = maxLen; + distances[1] = delta2 - 1; + offset = 2; if (maxLen == lenLimit) { - SkipMatchesSpec(MF_PARAMS(p)); - MOVE_POS_RET + SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); + MOVE_POS_RET; } } - - GET_MATCHES_FOOTER_BT(maxLen) + GET_MATCHES_FOOTER(offset, maxLen) } - -static UInt32* Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) { - UInt32 mmm; - UInt32 h2, h3, d2, d3, pos; - unsigned maxLen; - UInt32 *hash; + UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset; GET_MATCHES_HEADER(4) - HASH4_CALC + HASH4_CALC; - hash = p->hash; - pos = p->pos; - - d2 = pos - hash [h2]; - d3 = pos - (hash + kFix3HashSize)[h3]; - curMatch = (hash + kFix4HashSize)[hv]; - - hash [h2] = pos; - (hash + kFix3HashSize)[h3] = pos; - (hash + kFix4HashSize)[hv] = pos; - - SET_mmm - - maxLen = 3; + delta2 = p->pos - p->hash[ hash2Value]; + delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; + curMatch = p->hash[kFix4HashSize + hashValue]; - for (;;) + p->hash[ hash2Value] = + p->hash[kFix3HashSize + hash3Value] = + p->hash[kFix4HashSize + hashValue] = p->pos; + + maxLen = 1; + offset = 0; + if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) { - if (d2 < mmm && *(cur - d2) == *cur) - { - distances[0] = 2; - distances[1] = d2 - 1; - distances += 2; - if (*(cur - d2 + 2) == cur[2]) - { - // distances[-2] = 3; - } - else if (d3 < mmm && *(cur - d3) == *cur) - { - d2 = d3; - distances[1] = d3 - 1; - distances += 2; - } - else + distances[0] = maxLen = 2; + distances[1] = delta2 - 1; + offset = 2; + } + if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur) + { + maxLen = 3; + distances[offset + 1] = delta3 - 1; + offset += 2; + delta2 = delta3; + } + if (offset != 0) + { + for (; maxLen != lenLimit; maxLen++) + if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) break; - } - else if (d3 < mmm && *(cur - d3) == *cur) - { - d2 = d3; - distances[1] = d3 - 1; - distances += 2; - } - else - break; - - UPDATE_maxLen - distances[-2] = (UInt32)maxLen; + distances[offset - 2] = maxLen; if (maxLen == lenLimit) { - SkipMatchesSpec(MF_PARAMS(p)); - MOVE_POS_RET + SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); + MOVE_POS_RET; } - break; } - - GET_MATCHES_FOOTER_BT(maxLen) + if (maxLen < 3) + maxLen = 3; + GET_MATCHES_FOOTER(offset, maxLen) } - -static UInt32* Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) { - UInt32 mmm; - UInt32 h2, h3, d2, d3, maxLen, pos; - UInt32 *hash; - GET_MATCHES_HEADER(5) - - HASH5_CALC - - hash = p->hash; - pos = p->pos; - - d2 = pos - hash [h2]; - d3 = pos - (hash + kFix3HashSize)[h3]; - // d4 = pos - (hash + kFix4HashSize)[h4]; - - curMatch = (hash + kFix5HashSize)[hv]; - - hash [h2] = pos; - (hash + kFix3HashSize)[h3] = pos; - // (hash + kFix4HashSize)[h4] = pos; - (hash + kFix5HashSize)[hv] = pos; - - SET_mmm - - maxLen = 4; - - for (;;) - { - if (d2 < mmm && *(cur - d2) == *cur) - { - distances[0] = 2; - distances[1] = d2 - 1; - distances += 2; - if (*(cur - d2 + 2) == cur[2]) - { - } - else if (d3 < mmm && *(cur - d3) == *cur) - { - distances[1] = d3 - 1; - distances += 2; - d2 = d3; - } - else - break; - } - else if (d3 < mmm && *(cur - d3) == *cur) - { - distances[1] = d3 - 1; - distances += 2; - d2 = d3; - } - else - break; - - distances[-2] = 3; - if (*(cur - d2 + 3) != cur[3]) - break; - UPDATE_maxLen - distances[-2] = (UInt32)maxLen; - if (maxLen == lenLimit) - { - SkipMatchesSpec(MF_PARAMS(p)); - MOVE_POS_RET - } - break; - } - - GET_MATCHES_FOOTER_BT(maxLen) -} - - -static UInt32* Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - UInt32 mmm; - UInt32 h2, h3, d2, d3, pos; - unsigned maxLen; - UInt32 *hash; + UInt32 hash2Value, hash3Value, delta2, delta3, maxLen, offset; GET_MATCHES_HEADER(4) - HASH4_CALC + HASH4_CALC; - hash = p->hash; - pos = p->pos; - - d2 = pos - hash [h2]; - d3 = pos - (hash + kFix3HashSize)[h3]; - curMatch = (hash + kFix4HashSize)[hv]; + delta2 = p->pos - p->hash[ hash2Value]; + delta3 = p->pos - p->hash[kFix3HashSize + hash3Value]; + curMatch = p->hash[kFix4HashSize + hashValue]; - hash [h2] = pos; - (hash + kFix3HashSize)[h3] = pos; - (hash + kFix4HashSize)[hv] = pos; + p->hash[ hash2Value] = + p->hash[kFix3HashSize + hash3Value] = + p->hash[kFix4HashSize + hashValue] = p->pos; - SET_mmm - - maxLen = 3; - - for (;;) + maxLen = 1; + offset = 0; + if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur) { - if (d2 < mmm && *(cur - d2) == *cur) - { - distances[0] = 2; - distances[1] = d2 - 1; - distances += 2; - if (*(cur - d2 + 2) == cur[2]) - { - // distances[-2] = 3; - } - else if (d3 < mmm && *(cur - d3) == *cur) - { - d2 = d3; - distances[1] = d3 - 1; - distances += 2; - } - else + distances[0] = maxLen = 2; + distances[1] = delta2 - 1; + offset = 2; + } + if (delta2 != delta3 && delta3 < p->cyclicBufferSize && *(cur - delta3) == *cur) + { + maxLen = 3; + distances[offset + 1] = delta3 - 1; + offset += 2; + delta2 = delta3; + } + if (offset != 0) + { + for (; maxLen != lenLimit; maxLen++) + if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen]) break; - } - else if (d3 < mmm && *(cur - d3) == *cur) - { - d2 = d3; - distances[1] = d3 - 1; - distances += 2; - } - else - break; - - UPDATE_maxLen - distances[-2] = (UInt32)maxLen; + distances[offset - 2] = maxLen; if (maxLen == lenLimit) { p->son[p->cyclicBufferPos] = curMatch; - MOVE_POS_RET + MOVE_POS_RET; } - break; } - - GET_MATCHES_FOOTER_HC(maxLen) + if (maxLen < 3) + maxLen = 3; + offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), + distances + offset, maxLen) - (distances)); + MOVE_POS_RET } - -static UInt32 * Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - UInt32 mmm; - UInt32 h2, h3, d2, d3, maxLen, pos; - UInt32 *hash; - GET_MATCHES_HEADER(5) - - HASH5_CALC - - hash = p->hash; - pos = p->pos; - - d2 = pos - hash [h2]; - d3 = pos - (hash + kFix3HashSize)[h3]; - // d4 = pos - (hash + kFix4HashSize)[h4]; - - curMatch = (hash + kFix5HashSize)[hv]; - - hash [h2] = pos; - (hash + kFix3HashSize)[h3] = pos; - // (hash + kFix4HashSize)[h4] = pos; - (hash + kFix5HashSize)[hv] = pos; - - SET_mmm - - maxLen = 4; - - for (;;) - { - if (d2 < mmm && *(cur - d2) == *cur) - { - distances[0] = 2; - distances[1] = d2 - 1; - distances += 2; - if (*(cur - d2 + 2) == cur[2]) - { - } - else if (d3 < mmm && *(cur - d3) == *cur) - { - distances[1] = d3 - 1; - distances += 2; - d2 = d3; - } - else - break; - } - else if (d3 < mmm && *(cur - d3) == *cur) - { - distances[1] = d3 - 1; - distances += 2; - d2 = d3; - } - else - break; - - distances[-2] = 3; - if (*(cur - d2 + 3) != cur[3]) - break; - UPDATE_maxLen - distances[-2] = maxLen; - if (maxLen == lenLimit) - { - p->son[p->cyclicBufferPos] = curMatch; - MOVE_POS_RET - } - break; - } - - GET_MATCHES_FOOTER_HC(maxLen) -} - - -UInt32* Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) { + UInt32 offset; GET_MATCHES_HEADER(3) - HASH_ZIP_CALC - curMatch = p->hash[hv]; - p->hash[hv] = p->pos; - GET_MATCHES_FOOTER_HC(2) + HASH_ZIP_CALC; + curMatch = p->hash[hashValue]; + p->hash[hashValue] = p->pos; + offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p), + distances, 2) - (distances)); + MOVE_POS_RET } - static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num) { - SKIP_HEADER(2) + do { - HASH2_CALC - curMatch = p->hash[hv]; - p->hash[hv] = p->pos; + SKIP_HEADER(2) + HASH2_CALC; + curMatch = p->hash[hashValue]; + p->hash[hashValue] = p->pos; + SKIP_FOOTER } - SKIP_FOOTER + while (--num != 0); } void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) { - SKIP_HEADER(3) + do { - HASH_ZIP_CALC - curMatch = p->hash[hv]; - p->hash[hv] = p->pos; + SKIP_HEADER(3) + HASH_ZIP_CALC; + curMatch = p->hash[hashValue]; + p->hash[hashValue] = p->pos; + SKIP_FOOTER } - SKIP_FOOTER + while (--num != 0); } static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num) { - SKIP_HEADER(3) + do { - UInt32 h2; - UInt32 *hash; - HASH3_CALC - hash = p->hash; - curMatch = (hash + kFix3HashSize)[hv]; - hash[h2] = - (hash + kFix3HashSize)[hv] = p->pos; + UInt32 hash2Value; + SKIP_HEADER(3) + HASH3_CALC; + curMatch = p->hash[kFix3HashSize + hashValue]; + p->hash[hash2Value] = + p->hash[kFix3HashSize + hashValue] = p->pos; + SKIP_FOOTER } - SKIP_FOOTER + while (--num != 0); } static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) { - SKIP_HEADER(4) + do { - UInt32 h2, h3; - UInt32 *hash; - HASH4_CALC - hash = p->hash; - curMatch = (hash + kFix4HashSize)[hv]; - hash [h2] = - (hash + kFix3HashSize)[h3] = - (hash + kFix4HashSize)[hv] = p->pos; + UInt32 hash2Value, hash3Value; + SKIP_HEADER(4) + HASH4_CALC; + curMatch = p->hash[kFix4HashSize + hashValue]; + p->hash[ hash2Value] = + p->hash[kFix3HashSize + hash3Value] = p->pos; + p->hash[kFix4HashSize + hashValue] = p->pos; + SKIP_FOOTER } - SKIP_FOOTER + while (--num != 0); } -static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - SKIP_HEADER(5) - { - UInt32 h2, h3; - UInt32 *hash; - HASH5_CALC - hash = p->hash; - curMatch = (hash + kFix5HashSize)[hv]; - hash [h2] = - (hash + kFix3HashSize)[h3] = - // (hash + kFix4HashSize)[h4] = - (hash + kFix5HashSize)[hv] = p->pos; - } - SKIP_FOOTER -} - - -#define HC_SKIP_HEADER(minLen) \ - do { if (p->lenLimit < minLen) { MatchFinder_MovePos(p); num--; continue; } { \ - const Byte *cur; \ - UInt32 *hash; \ - UInt32 *son; \ - UInt32 pos = p->pos; \ - UInt32 num2 = num; \ - /* (p->pos == p->posLimit) is not allowed here !!! */ \ - { const UInt32 rem = p->posLimit - pos; if (num2 > rem) num2 = rem; } \ - num -= num2; \ - { const UInt32 cycPos = p->cyclicBufferPos; \ - son = p->son + cycPos; \ - p->cyclicBufferPos = cycPos + num2; } \ - cur = p->buffer; \ - hash = p->hash; \ - do { \ - UInt32 curMatch; \ - UInt32 hv; - - -#define HC_SKIP_FOOTER \ - cur++; pos++; *son++ = curMatch; \ - } while (--num2); \ - p->buffer = cur; \ - p->pos = pos; \ - if (pos == p->posLimit) MatchFinder_CheckLimits(p); \ - }} while(num); \ - - static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) { - HC_SKIP_HEADER(4) - - UInt32 h2, h3; - HASH4_CALC - curMatch = (hash + kFix4HashSize)[hv]; - hash [h2] = - (hash + kFix3HashSize)[h3] = - (hash + kFix4HashSize)[hv] = pos; - - HC_SKIP_FOOTER + do + { + UInt32 hash2Value, hash3Value; + SKIP_HEADER(4) + HASH4_CALC; + curMatch = p->hash[kFix4HashSize + hashValue]; + p->hash[ hash2Value] = + p->hash[kFix3HashSize + hash3Value] = + p->hash[kFix4HashSize + hashValue] = p->pos; + p->son[p->cyclicBufferPos] = curMatch; + MOVE_POS + } + while (--num != 0); } - -static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - HC_SKIP_HEADER(5) - - UInt32 h2, h3; - HASH5_CALC - curMatch = (hash + kFix5HashSize)[hv]; - hash [h2] = - (hash + kFix3HashSize)[h3] = - // (hash + kFix4HashSize)[h4] = - (hash + kFix5HashSize)[hv] = pos; - - HC_SKIP_FOOTER -} - - void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) { - HC_SKIP_HEADER(3) - - HASH_ZIP_CALC - curMatch = hash[hv]; - hash[hv] = pos; - - HC_SKIP_FOOTER + do + { + SKIP_HEADER(3) + HASH_ZIP_CALC; + curMatch = p->hash[hashValue]; + p->hash[hashValue] = p->pos; + p->son[p->cyclicBufferPos] = curMatch; + MOVE_POS + } + while (--num != 0); } - -void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder2 *vTable) +void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable) { vTable->Init = (Mf_Init_Func)MatchFinder_Init; + vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte; vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes; vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos; if (!p->btMode) { - if (p->numHashBytes <= 4) - { - vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches; - vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip; - } - else - { - vTable->GetMatches = (Mf_GetMatches_Func)Hc5_MatchFinder_GetMatches; - vTable->Skip = (Mf_Skip_Func)Hc5_MatchFinder_Skip; - } + vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches; + vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip; } else if (p->numHashBytes == 2) { @@ -1660,58 +743,9 @@ void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder2 *vTable) vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches; vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip; } - else if (p->numHashBytes == 4) + else { vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches; vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip; } - else - { - vTable->GetMatches = (Mf_GetMatches_Func)Bt5_MatchFinder_GetMatches; - vTable->Skip = (Mf_Skip_Func)Bt5_MatchFinder_Skip; - } } - - - -void LzFindPrepare(void) -{ - #ifndef FORCE_LZFIND_SATUR_SUB_128 - #ifdef USE_LZFIND_SATUR_SUB_128 - LZFIND_SATUR_SUB_CODE_FUNC f = NULL; - #ifdef MY_CPU_ARM_OR_ARM64 - { - if (CPU_IsSupported_NEON()) - { - // #pragma message ("=== LzFind NEON") - PRF(printf("\n=== LzFind NEON\n")); - f = LzFind_SaturSub_128; - } - // f = 0; // for debug - } - #else // MY_CPU_ARM_OR_ARM64 - if (CPU_IsSupported_SSE41()) - { - // #pragma message ("=== LzFind SSE41") - PRF(printf("\n=== LzFind SSE41\n")); - f = LzFind_SaturSub_128; - - #ifdef USE_LZFIND_SATUR_SUB_256 - if (CPU_IsSupported_AVX2()) - { - // #pragma message ("=== LzFind AVX2") - PRF(printf("\n=== LzFind AVX2\n")); - f = LzFind_SaturSub_256; - } - #endif - } - #endif // MY_CPU_ARM_OR_ARM64 - g_LzFind_SaturSub = f; - #endif // USE_LZFIND_SATUR_SUB_128 - #endif // FORCE_LZFIND_SATUR_SUB_128 -} - - -#undef MOVE_POS -#undef MOVE_POS_RET -#undef PRF diff --git a/extern/lzma/LzFind.h b/extern/lzma/LzFind.h index a3f72c98700..5b9cebfdffe 100644 --- a/extern/lzma/LzFind.h +++ b/extern/lzma/LzFind.h @@ -1,121 +1,76 @@ /* LzFind.h -- Match finder for LZ algorithms -2023-03-04 : Igor Pavlov : Public domain */ +2008-10-04 : Igor Pavlov : Public domain */ -#ifndef ZIP7_INC_LZ_FIND_H -#define ZIP7_INC_LZ_FIND_H +#ifndef __LZFIND_H +#define __LZFIND_H -#include "7zTypes.h" - -EXTERN_C_BEGIN +#include "Types.h" typedef UInt32 CLzRef; -typedef struct +typedef struct _CMatchFinder { - const Byte *buffer; + Byte *buffer; UInt32 pos; UInt32 posLimit; - UInt32 streamPos; /* wrap over Zero is allowed (streamPos < pos). Use (UInt32)(streamPos - pos) */ + UInt32 streamPos; UInt32 lenLimit; UInt32 cyclicBufferPos; UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ - Byte streamEndWasReached; - Byte btMode; - Byte bigHash; - Byte directInput; - UInt32 matchMaxLen; CLzRef *hash; CLzRef *son; UInt32 hashMask; UInt32 cutValue; - Byte *bufBase; - ISeqInStreamPtr stream; - + Byte *bufferBase; + ISeqInStream *stream; + int streamEndWasReached; + UInt32 blockSize; UInt32 keepSizeBefore; UInt32 keepSizeAfter; UInt32 numHashBytes; - size_t directInputRem; + int directInput; + int btMode; + /* int skipModeBits; */ + int bigHash; UInt32 historySize; UInt32 fixedHashSize; - Byte numHashBytes_Min; - Byte numHashOutBits; - Byte _pad2_[2]; + UInt32 hashSizeSum; + UInt32 numSons; SRes result; UInt32 crc[256]; - size_t numRefs; - - UInt64 expectedDataSize; } CMatchFinder; -#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((const Byte *)(p)->buffer) +#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer) +#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)]) -#define Inline_MatchFinder_GetNumAvailableBytes(p) ((UInt32)((p)->streamPos - (p)->pos)) +#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos) -/* -#define Inline_MatchFinder_IsFinishedOK(p) \ - ((p)->streamEndWasReached \ - && (p)->streamPos == (p)->pos \ - && (!(p)->directInput || (p)->directInputRem == 0)) -*/ - int MatchFinder_NeedMove(CMatchFinder *p); -/* Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); */ +Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); void MatchFinder_MoveBlock(CMatchFinder *p); void MatchFinder_ReadIfRequired(CMatchFinder *p); void MatchFinder_Construct(CMatchFinder *p); -/* (directInput = 0) is default value. - It's required to provide correct (directInput) value - before calling MatchFinder_Create(). - You can set (directInput) by any of the following calls: - - MatchFinder_SET_DIRECT_INPUT_BUF() - - MatchFinder_SET_STREAM() - - MatchFinder_SET_STREAM_MODE() +/* Conditions: + historySize <= 3 GB + keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB */ - -#define MatchFinder_SET_DIRECT_INPUT_BUF(p, _src_, _srcLen_) { \ - (p)->stream = NULL; \ - (p)->directInput = 1; \ - (p)->buffer = (_src_); \ - (p)->directInputRem = (_srcLen_); } - -/* -#define MatchFinder_SET_STREAM_MODE(p) { \ - (p)->directInput = 0; } -*/ - -#define MatchFinder_SET_STREAM(p, _stream_) { \ - (p)->stream = _stream_; \ - (p)->directInput = 0; } - - int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, - ISzAllocPtr alloc); -void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc); -void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems); - -/* -#define MatchFinder_INIT_POS(p, val) \ - (p)->pos = (val); \ - (p)->streamPos = (val); -*/ - -// void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue); -#define MatchFinder_REDUCE_OFFSETS(p, subValue) \ - (p)->pos -= (subValue); \ - (p)->streamPos -= (subValue); - + ISzAlloc *alloc); +void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc); +void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems); +void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue); UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son, - size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue, + UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue, UInt32 *distances, UInt32 maxLen); /* @@ -125,35 +80,28 @@ Conditions: */ typedef void (*Mf_Init_Func)(void *object); +typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index); typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object); typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object); -typedef UInt32 * (*Mf_GetMatches_Func)(void *object, UInt32 *distances); +typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances); typedef void (*Mf_Skip_Func)(void *object, UInt32); -typedef struct +typedef struct _IMatchFinder { Mf_Init_Func Init; + Mf_GetIndexByte_Func GetIndexByte; Mf_GetNumAvailableBytes_Func GetNumAvailableBytes; Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos; Mf_GetMatches_Func GetMatches; Mf_Skip_Func Skip; -} IMatchFinder2; +} IMatchFinder; -void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder2 *vTable); +void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable); -void MatchFinder_Init_LowHash(CMatchFinder *p); -void MatchFinder_Init_HighHash(CMatchFinder *p); -void MatchFinder_Init_4(CMatchFinder *p); void MatchFinder_Init(CMatchFinder *p); - -UInt32* Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); -UInt32* Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); - +UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); +UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); -void LzFindPrepare(void); - -EXTERN_C_END - #endif diff --git a/extern/lzma/LzFindMt.c b/extern/lzma/LzFindMt.c deleted file mode 100644 index 5253e6ebb35..00000000000 --- a/extern/lzma/LzFindMt.c +++ /dev/null @@ -1,1406 +0,0 @@ -/* LzFindMt.c -- multithreaded Match finder for LZ algorithms -2023-04-02 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -// #include - -#include "CpuArch.h" - -#include "LzHash.h" -#include "LzFindMt.h" - -// #define LOG_ITERS - -// #define LOG_THREAD - -#ifdef LOG_THREAD -#include -#define PRF(x) x -#else -#define PRF(x) -#endif - -#ifdef LOG_ITERS -#include -extern UInt64 g_NumIters_Tree; -extern UInt64 g_NumIters_Loop; -extern UInt64 g_NumIters_Bytes; -#define LOG_ITER(x) x -#else -#define LOG_ITER(x) -#endif - -#define kMtHashBlockSize ((UInt32)1 << 17) -#define kMtHashNumBlocks (1 << 1) - -#define GET_HASH_BLOCK_OFFSET(i) (((i) & (kMtHashNumBlocks - 1)) * kMtHashBlockSize) - -#define kMtBtBlockSize ((UInt32)1 << 16) -#define kMtBtNumBlocks (1 << 4) - -#define GET_BT_BLOCK_OFFSET(i) (((i) & (kMtBtNumBlocks - 1)) * (size_t)kMtBtBlockSize) - -/* - HASH functions: - We use raw 8/16 bits from a[1] and a[2], - xored with crc(a[0]) and crc(a[3]). - We check a[0], a[3] only. We don't need to compare a[1] and a[2] in matches. - our crc() function provides one-to-one correspondence for low 8-bit values: - (crc[0...0xFF] & 0xFF) <-> [0...0xFF] -*/ - -#define MF(mt) ((mt)->MatchFinder) -#define MF_CRC (p->crc) - -// #define MF(mt) (&(mt)->MatchFinder) -// #define MF_CRC (p->MatchFinder.crc) - -#define MT_HASH2_CALC \ - h2 = (MF_CRC[cur[0]] ^ cur[1]) & (kHash2Size - 1); - -#define MT_HASH3_CALC { \ - UInt32 temp = MF_CRC[cur[0]] ^ cur[1]; \ - h2 = temp & (kHash2Size - 1); \ - h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } - -/* -#define MT_HASH3_CALC__NO_2 { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } - -#define MT_HASH4_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - h2 = temp & (kHash2Size - 1); \ - temp ^= ((UInt32)cur[2] << 8); \ - h3 = temp & (kHash3Size - 1); \ - h4 = (temp ^ (p->crc[cur[3]] << kLzHash_CrcShift_1)) & p->hash4Mask; } - // (kHash4Size - 1); -*/ - - -Z7_NO_INLINE -static void MtSync_Construct(CMtSync *p) -{ - p->affinity = 0; - p->wasCreated = False; - p->csWasInitialized = False; - p->csWasEntered = False; - Thread_CONSTRUCT(&p->thread) - Event_Construct(&p->canStart); - Event_Construct(&p->wasStopped); - Semaphore_Construct(&p->freeSemaphore); - Semaphore_Construct(&p->filledSemaphore); -} - - -#define DEBUG_BUFFER_LOCK // define it to debug lock state - -#ifdef DEBUG_BUFFER_LOCK -#include -#define BUFFER_MUST_BE_LOCKED(p) if (!(p)->csWasEntered) exit(1); -#define BUFFER_MUST_BE_UNLOCKED(p) if ( (p)->csWasEntered) exit(1); -#else -#define BUFFER_MUST_BE_LOCKED(p) -#define BUFFER_MUST_BE_UNLOCKED(p) -#endif - -#define LOCK_BUFFER(p) { \ - BUFFER_MUST_BE_UNLOCKED(p); \ - CriticalSection_Enter(&(p)->cs); \ - (p)->csWasEntered = True; } - -#define UNLOCK_BUFFER(p) { \ - BUFFER_MUST_BE_LOCKED(p); \ - CriticalSection_Leave(&(p)->cs); \ - (p)->csWasEntered = False; } - - -Z7_NO_INLINE -static UInt32 MtSync_GetNextBlock(CMtSync *p) -{ - UInt32 numBlocks = 0; - if (p->needStart) - { - BUFFER_MUST_BE_UNLOCKED(p) - p->numProcessedBlocks = 1; - p->needStart = False; - p->stopWriting = False; - p->exit = False; - Event_Reset(&p->wasStopped); - Event_Set(&p->canStart); - } - else - { - UNLOCK_BUFFER(p) - // we free current block - numBlocks = p->numProcessedBlocks++; - Semaphore_Release1(&p->freeSemaphore); - } - - // buffer is UNLOCKED here - Semaphore_Wait(&p->filledSemaphore); - LOCK_BUFFER(p) - return numBlocks; -} - - -/* if Writing (Processing) thread was started, we must call MtSync_StopWriting() */ - -Z7_NO_INLINE -static void MtSync_StopWriting(CMtSync *p) -{ - if (!Thread_WasCreated(&p->thread) || p->needStart) - return; - - PRF(printf("\nMtSync_StopWriting %p\n", p)); - - if (p->csWasEntered) - { - /* we don't use buffer in this thread after StopWriting(). - So we UNLOCK buffer. - And we restore default UNLOCKED state for stopped thread */ - UNLOCK_BUFFER(p) - } - - /* We send (p->stopWriting) message and release freeSemaphore - to free current block. - So the thread will see (p->stopWriting) at some - iteration after Wait(freeSemaphore). - The thread doesn't need to fill all avail free blocks, - so we can get fast thread stop. - */ - - p->stopWriting = True; - Semaphore_Release1(&p->freeSemaphore); // check semaphore count !!! - - PRF(printf("\nMtSync_StopWriting %p : Event_Wait(&p->wasStopped)\n", p)); - Event_Wait(&p->wasStopped); - PRF(printf("\nMtSync_StopWriting %p : Event_Wait() finsihed\n", p)); - - /* 21.03 : we don't restore samaphore counters here. - We will recreate and reinit samaphores in next start */ - - p->needStart = True; -} - - -Z7_NO_INLINE -static void MtSync_Destruct(CMtSync *p) -{ - PRF(printf("\nMtSync_Destruct %p\n", p)); - - if (Thread_WasCreated(&p->thread)) - { - /* we want thread to be in Stopped state before sending EXIT command. - note: stop(btSync) will stop (htSync) also */ - MtSync_StopWriting(p); - /* thread in Stopped state here : (p->needStart == true) */ - p->exit = True; - // if (p->needStart) // it's (true) - Event_Set(&p->canStart); // we send EXIT command to thread - Thread_Wait_Close(&p->thread); // we wait thread finishing - } - - if (p->csWasInitialized) - { - CriticalSection_Delete(&p->cs); - p->csWasInitialized = False; - } - p->csWasEntered = False; - - Event_Close(&p->canStart); - Event_Close(&p->wasStopped); - Semaphore_Close(&p->freeSemaphore); - Semaphore_Close(&p->filledSemaphore); - - p->wasCreated = False; -} - - -// #define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; } -// we want to get real system error codes here instead of SZ_ERROR_THREAD -#define RINOK_THREAD(x) RINOK_WRes(x) - - -// call it before each new file (when new starting is required): -Z7_NO_INLINE -static SRes MtSync_Init(CMtSync *p, UInt32 numBlocks) -{ - WRes wres; - // BUFFER_MUST_BE_UNLOCKED(p) - if (!p->needStart || p->csWasEntered) - return SZ_ERROR_FAIL; - wres = Semaphore_OptCreateInit(&p->freeSemaphore, numBlocks, numBlocks); - if (wres == 0) - wres = Semaphore_OptCreateInit(&p->filledSemaphore, 0, numBlocks); - return MY_SRes_HRESULT_FROM_WRes(wres); -} - - -static WRes MtSync_Create_WRes(CMtSync *p, THREAD_FUNC_TYPE startAddress, void *obj) -{ - WRes wres; - - if (p->wasCreated) - return SZ_OK; - - RINOK_THREAD(CriticalSection_Init(&p->cs)) - p->csWasInitialized = True; - p->csWasEntered = False; - - RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canStart)) - RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStopped)) - - p->needStart = True; - p->exit = True; /* p->exit is unused before (canStart) Event. - But in case of some unexpected code failure we will get fast exit from thread */ - - // return ERROR_TOO_MANY_POSTS; // for debug - // return EINVAL; // for debug - - if (p->affinity != 0) - wres = Thread_Create_With_Affinity(&p->thread, startAddress, obj, (CAffinityMask)p->affinity); - else - wres = Thread_Create(&p->thread, startAddress, obj); - - RINOK_THREAD(wres) - p->wasCreated = True; - return SZ_OK; -} - - -Z7_NO_INLINE -static SRes MtSync_Create(CMtSync *p, THREAD_FUNC_TYPE startAddress, void *obj) -{ - const WRes wres = MtSync_Create_WRes(p, startAddress, obj); - if (wres == 0) - return 0; - MtSync_Destruct(p); - return MY_SRes_HRESULT_FROM_WRes(wres); -} - - -// ---------- HASH THREAD ---------- - -#define kMtMaxValForNormalize 0xFFFFFFFF -// #define kMtMaxValForNormalize ((1 << 21)) // for debug -// #define kNormalizeAlign (1 << 7) // alignment for speculated accesses - -#ifdef MY_CPU_LE_UNALIGN - #define GetUi24hi_from32(p) ((UInt32)GetUi32(p) >> 8) -#else - #define GetUi24hi_from32(p) ((p)[1] ^ ((UInt32)(p)[2] << 8) ^ ((UInt32)(p)[3] << 16)) -#endif - -#define GetHeads_DECL(name) \ - static void GetHeads ## name(const Byte *p, UInt32 pos, \ - UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc) - -#define GetHeads_LOOP(v) \ - for (; numHeads != 0; numHeads--) { \ - const UInt32 value = (v); \ - p++; \ - *heads++ = pos - hash[value]; \ - hash[value] = pos++; } - -#define DEF_GetHeads2(name, v, action) \ - GetHeads_DECL(name) { action \ - GetHeads_LOOP(v) } - -#define DEF_GetHeads(name, v) DEF_GetHeads2(name, v, ;) - -DEF_GetHeads2(2, GetUi16(p), UNUSED_VAR(hashMask); UNUSED_VAR(crc); ) -DEF_GetHeads(3, (crc[p[0]] ^ GetUi16(p + 1)) & hashMask) -DEF_GetHeads2(3b, GetUi16(p) ^ ((UInt32)(p)[2] << 16), UNUSED_VAR(hashMask); UNUSED_VAR(crc); ) -// BT3 is not good for crc collisions for big hashMask values. - -/* -GetHeads_DECL(3b) -{ - UNUSED_VAR(hashMask); - UNUSED_VAR(crc); - { - const Byte *pLim = p + numHeads; - if (numHeads == 0) - return; - pLim--; - while (p < pLim) - { - UInt32 v1 = GetUi32(p); - UInt32 v0 = v1 & 0xFFFFFF; - UInt32 h0, h1; - p += 2; - v1 >>= 8; - h0 = hash[v0]; hash[v0] = pos; heads[0] = pos - h0; pos++; - h1 = hash[v1]; hash[v1] = pos; heads[1] = pos - h1; pos++; - heads += 2; - } - if (p == pLim) - { - UInt32 v0 = GetUi16(p) ^ ((UInt32)(p)[2] << 16); - *heads = pos - hash[v0]; - hash[v0] = pos; - } - } -} -*/ - -/* -GetHeads_DECL(4) -{ - unsigned sh = 0; - UNUSED_VAR(crc) - while ((hashMask & 0x80000000) == 0) - { - hashMask <<= 1; - sh++; - } - GetHeads_LOOP((GetUi32(p) * 0xa54a1) >> sh) -} -#define GetHeads4b GetHeads4 -*/ - -#define USE_GetHeads_LOCAL_CRC - -#ifdef USE_GetHeads_LOCAL_CRC - -GetHeads_DECL(4) -{ - UInt32 crc0[256]; - UInt32 crc1[256]; - { - unsigned i; - for (i = 0; i < 256; i++) - { - UInt32 v = crc[i]; - crc0[i] = v & hashMask; - crc1[i] = (v << kLzHash_CrcShift_1) & hashMask; - // crc1[i] = rotlFixed(v, 8) & hashMask; - } - } - GetHeads_LOOP(crc0[p[0]] ^ crc1[p[3]] ^ (UInt32)GetUi16(p+1)) -} - -GetHeads_DECL(4b) -{ - UInt32 crc0[256]; - { - unsigned i; - for (i = 0; i < 256; i++) - crc0[i] = crc[i] & hashMask; - } - GetHeads_LOOP(crc0[p[0]] ^ GetUi24hi_from32(p)) -} - -GetHeads_DECL(5) -{ - UInt32 crc0[256]; - UInt32 crc1[256]; - UInt32 crc2[256]; - { - unsigned i; - for (i = 0; i < 256; i++) - { - UInt32 v = crc[i]; - crc0[i] = v & hashMask; - crc1[i] = (v << kLzHash_CrcShift_1) & hashMask; - crc2[i] = (v << kLzHash_CrcShift_2) & hashMask; - } - } - GetHeads_LOOP(crc0[p[0]] ^ crc1[p[3]] ^ crc2[p[4]] ^ (UInt32)GetUi16(p+1)) -} - -GetHeads_DECL(5b) -{ - UInt32 crc0[256]; - UInt32 crc1[256]; - { - unsigned i; - for (i = 0; i < 256; i++) - { - UInt32 v = crc[i]; - crc0[i] = v & hashMask; - crc1[i] = (v << kLzHash_CrcShift_1) & hashMask; - } - } - GetHeads_LOOP(crc0[p[0]] ^ crc1[p[4]] ^ GetUi24hi_from32(p)) -} - -#else - -DEF_GetHeads(4, (crc[p[0]] ^ (crc[p[3]] << kLzHash_CrcShift_1) ^ (UInt32)GetUi16(p+1)) & hashMask) -DEF_GetHeads(4b, (crc[p[0]] ^ GetUi24hi_from32(p)) & hashMask) -DEF_GetHeads(5, (crc[p[0]] ^ (crc[p[3]] << kLzHash_CrcShift_1) ^ (crc[p[4]] << kLzHash_CrcShift_2) ^ (UInt32)GetUi16(p + 1)) & hashMask) -DEF_GetHeads(5b, (crc[p[0]] ^ (crc[p[4]] << kLzHash_CrcShift_1) ^ GetUi24hi_from32(p)) & hashMask) - -#endif - - -static void HashThreadFunc(CMatchFinderMt *mt) -{ - CMtSync *p = &mt->hashSync; - PRF(printf("\nHashThreadFunc\n")); - - for (;;) - { - UInt32 blockIndex = 0; - PRF(printf("\nHashThreadFunc : Event_Wait(&p->canStart)\n")); - Event_Wait(&p->canStart); - PRF(printf("\nHashThreadFunc : Event_Wait(&p->canStart) : after \n")); - if (p->exit) - { - PRF(printf("\nHashThreadFunc : exit \n")); - return; - } - - MatchFinder_Init_HighHash(MF(mt)); - - for (;;) - { - PRF(printf("Hash thread block = %d pos = %d\n", (unsigned)blockIndex, mt->MatchFinder->pos)); - - { - CMatchFinder *mf = MF(mt); - if (MatchFinder_NeedMove(mf)) - { - CriticalSection_Enter(&mt->btSync.cs); - CriticalSection_Enter(&mt->hashSync.cs); - { - const Byte *beforePtr = Inline_MatchFinder_GetPointerToCurrentPos(mf); - ptrdiff_t offset; - MatchFinder_MoveBlock(mf); - offset = beforePtr - Inline_MatchFinder_GetPointerToCurrentPos(mf); - mt->pointerToCurPos -= offset; - mt->buffer -= offset; - } - CriticalSection_Leave(&mt->hashSync.cs); - CriticalSection_Leave(&mt->btSync.cs); - continue; - } - - Semaphore_Wait(&p->freeSemaphore); - - if (p->exit) // exit is unexpected here. But we check it here for some failure case - return; - - // for faster stop : we check (p->stopWriting) after Wait(freeSemaphore) - if (p->stopWriting) - break; - - MatchFinder_ReadIfRequired(mf); - { - UInt32 *heads = mt->hashBuf + GET_HASH_BLOCK_OFFSET(blockIndex++); - UInt32 num = Inline_MatchFinder_GetNumAvailableBytes(mf); - heads[0] = 2; - heads[1] = num; - - /* heads[1] contains the number of avail bytes: - if (avail < mf->numHashBytes) : - { - it means that stream was finished - HASH_THREAD and BT_TREAD must move position for heads[1] (avail) bytes. - HASH_THREAD doesn't stop, - HASH_THREAD fills only the header (2 numbers) for all next blocks: - {2, NumHashBytes - 1}, {2,0}, {2,0}, ... , {2,0} - } - else - { - HASH_THREAD and BT_TREAD must move position for (heads[0] - 2) bytes; - } - */ - - if (num >= mf->numHashBytes) - { - num = num - mf->numHashBytes + 1; - if (num > kMtHashBlockSize - 2) - num = kMtHashBlockSize - 2; - - if (mf->pos > (UInt32)kMtMaxValForNormalize - num) - { - const UInt32 subValue = (mf->pos - mf->historySize - 1); // & ~(UInt32)(kNormalizeAlign - 1); - MatchFinder_REDUCE_OFFSETS(mf, subValue) - MatchFinder_Normalize3(subValue, mf->hash + mf->fixedHashSize, (size_t)mf->hashMask + 1); - } - - heads[0] = 2 + num; - mt->GetHeadsFunc(mf->buffer, mf->pos, mf->hash + mf->fixedHashSize, mf->hashMask, heads + 2, num, mf->crc); - } - - mf->pos += num; // wrap over zero is allowed at the end of stream - mf->buffer += num; - } - } - - Semaphore_Release1(&p->filledSemaphore); - } // for() processing end - - // p->numBlocks_Sent = blockIndex; - Event_Set(&p->wasStopped); - } // for() thread end -} - - - - -// ---------- BT THREAD ---------- - -/* we use one variable instead of two (cyclicBufferPos == pos) before CyclicBuf wrap. - here we define fixed offset of (p->pos) from (p->cyclicBufferPos) */ -#define CYC_TO_POS_OFFSET 0 -// #define CYC_TO_POS_OFFSET 1 // for debug - -#define MFMT_GM_INLINE - -#ifdef MFMT_GM_INLINE - -/* - we use size_t for (pos) instead of UInt32 - to eliminate "movsx" BUG in old MSVC x64 compiler. -*/ - - -UInt32 * Z7_FASTCALL GetMatchesSpecN_2(const Byte *lenLimit, size_t pos, const Byte *cur, CLzRef *son, - UInt32 _cutValue, UInt32 *d, size_t _maxLen, const UInt32 *hash, const UInt32 *limit, const UInt32 *size, - size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, - UInt32 *posRes); - -#endif - - -static void BtGetMatches(CMatchFinderMt *p, UInt32 *d) -{ - UInt32 numProcessed = 0; - UInt32 curPos = 2; - - /* GetMatchesSpec() functions don't create (len = 1) - in [len, dist] match pairs, if (p->numHashBytes >= 2) - Also we suppose here that (matchMaxLen >= 2). - So the following code for (reserve) is not required - UInt32 reserve = (p->matchMaxLen * 2); - const UInt32 kNumHashBytes_Max = 5; // BT_HASH_BYTES_MAX - if (reserve < kNumHashBytes_Max - 1) - reserve = kNumHashBytes_Max - 1; - const UInt32 limit = kMtBtBlockSize - (reserve); - */ - - const UInt32 limit = kMtBtBlockSize - (p->matchMaxLen * 2); - - d[1] = p->hashNumAvail; - - if (p->failure_BT) - { - // printf("\n == 1 BtGetMatches() p->failure_BT\n"); - d[0] = 0; - // d[1] = 0; - return; - } - - while (curPos < limit) - { - if (p->hashBufPos == p->hashBufPosLimit) - { - // MatchFinderMt_GetNextBlock_Hash(p); - UInt32 avail; - { - const UInt32 bi = MtSync_GetNextBlock(&p->hashSync); - const UInt32 k = GET_HASH_BLOCK_OFFSET(bi); - const UInt32 *h = p->hashBuf + k; - avail = h[1]; - p->hashBufPosLimit = k + h[0]; - p->hashNumAvail = avail; - p->hashBufPos = k + 2; - } - - { - /* we must prevent UInt32 overflow for avail total value, - if avail was increased with new hash block */ - UInt32 availSum = numProcessed + avail; - if (availSum < numProcessed) - availSum = (UInt32)(Int32)-1; - d[1] = availSum; - } - - if (avail >= p->numHashBytes) - continue; - - // if (p->hashBufPos != p->hashBufPosLimit) exit(1); - - /* (avail < p->numHashBytes) - It means that stream was finished. - And (avail) - is a number of remaining bytes, - we fill (d) for (avail) bytes for LZ_THREAD (receiver). - but we don't update (p->pos) and (p->cyclicBufferPos) here in BT_THREAD */ - - /* here we suppose that we have space enough: - (kMtBtBlockSize - curPos >= p->hashNumAvail) */ - p->hashNumAvail = 0; - d[0] = curPos + avail; - d += curPos; - for (; avail != 0; avail--) - *d++ = 0; - return; - } - { - UInt32 size = p->hashBufPosLimit - p->hashBufPos; - UInt32 pos = p->pos; - UInt32 cyclicBufferPos = p->cyclicBufferPos; - UInt32 lenLimit = p->matchMaxLen; - if (lenLimit >= p->hashNumAvail) - lenLimit = p->hashNumAvail; - { - UInt32 size2 = p->hashNumAvail - lenLimit + 1; - if (size2 < size) - size = size2; - size2 = p->cyclicBufferSize - cyclicBufferPos; - if (size2 < size) - size = size2; - } - - if (pos > (UInt32)kMtMaxValForNormalize - size) - { - const UInt32 subValue = (pos - p->cyclicBufferSize); // & ~(UInt32)(kNormalizeAlign - 1); - pos -= subValue; - p->pos = pos; - MatchFinder_Normalize3(subValue, p->son, (size_t)p->cyclicBufferSize * 2); - } - - #ifndef MFMT_GM_INLINE - while (curPos < limit && size-- != 0) - { - UInt32 *startDistances = d + curPos; - UInt32 num = (UInt32)(GetMatchesSpec1(lenLimit, pos - p->hashBuf[p->hashBufPos++], - pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue, - startDistances + 1, p->numHashBytes - 1) - startDistances); - *startDistances = num - 1; - curPos += num; - cyclicBufferPos++; - pos++; - p->buffer++; - } - #else - { - UInt32 posRes = pos; - const UInt32 *d_end; - { - d_end = GetMatchesSpecN_2( - p->buffer + lenLimit - 1, - pos, p->buffer, p->son, p->cutValue, d + curPos, - p->numHashBytes - 1, p->hashBuf + p->hashBufPos, - d + limit, p->hashBuf + p->hashBufPos + size, - cyclicBufferPos, p->cyclicBufferSize, - &posRes); - } - { - if (!d_end) - { - // printf("\n == 2 BtGetMatches() p->failure_BT\n"); - // internal data failure - p->failure_BT = True; - d[0] = 0; - // d[1] = 0; - return; - } - } - curPos = (UInt32)(d_end - d); - { - const UInt32 processed = posRes - pos; - pos = posRes; - p->hashBufPos += processed; - cyclicBufferPos += processed; - p->buffer += processed; - } - } - #endif - - { - const UInt32 processed = pos - p->pos; - numProcessed += processed; - p->hashNumAvail -= processed; - p->pos = pos; - } - if (cyclicBufferPos == p->cyclicBufferSize) - cyclicBufferPos = 0; - p->cyclicBufferPos = cyclicBufferPos; - } - } - - d[0] = curPos; -} - - -static void BtFillBlock(CMatchFinderMt *p, UInt32 globalBlockIndex) -{ - CMtSync *sync = &p->hashSync; - - BUFFER_MUST_BE_UNLOCKED(sync) - - if (!sync->needStart) - { - LOCK_BUFFER(sync) - } - - BtGetMatches(p, p->btBuf + GET_BT_BLOCK_OFFSET(globalBlockIndex)); - - /* We suppose that we have called GetNextBlock() from start. - So buffer is LOCKED */ - - UNLOCK_BUFFER(sync) -} - - -Z7_NO_INLINE -static void BtThreadFunc(CMatchFinderMt *mt) -{ - CMtSync *p = &mt->btSync; - for (;;) - { - UInt32 blockIndex = 0; - Event_Wait(&p->canStart); - - for (;;) - { - PRF(printf(" BT thread block = %d pos = %d\n", (unsigned)blockIndex, mt->pos)); - /* (p->exit == true) is possible after (p->canStart) at first loop iteration - and is unexpected after more Wait(freeSemaphore) iterations */ - if (p->exit) - return; - - Semaphore_Wait(&p->freeSemaphore); - - // for faster stop : we check (p->stopWriting) after Wait(freeSemaphore) - if (p->stopWriting) - break; - - BtFillBlock(mt, blockIndex++); - - Semaphore_Release1(&p->filledSemaphore); - } - - // we stop HASH_THREAD here - MtSync_StopWriting(&mt->hashSync); - - // p->numBlocks_Sent = blockIndex; - Event_Set(&p->wasStopped); - } -} - - -void MatchFinderMt_Construct(CMatchFinderMt *p) -{ - p->hashBuf = NULL; - MtSync_Construct(&p->hashSync); - MtSync_Construct(&p->btSync); -} - -static void MatchFinderMt_FreeMem(CMatchFinderMt *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->hashBuf); - p->hashBuf = NULL; -} - -void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAllocPtr alloc) -{ - /* - HASH_THREAD can use CriticalSection(s) btSync.cs and hashSync.cs. - So we must be sure that HASH_THREAD will not use CriticalSection(s) - after deleting CriticalSection here. - - we call ReleaseStream(p) - that calls StopWriting(btSync) - that calls StopWriting(hashSync), if it's required to stop HASH_THREAD. - after StopWriting() it's safe to destruct MtSync(s) in any order */ - - MatchFinderMt_ReleaseStream(p); - - MtSync_Destruct(&p->btSync); - MtSync_Destruct(&p->hashSync); - - LOG_ITER( - printf("\nTree %9d * %7d iter = %9d = sum : bytes = %9d\n", - (UInt32)(g_NumIters_Tree / 1000), - (UInt32)(((UInt64)g_NumIters_Loop * 1000) / (g_NumIters_Tree + 1)), - (UInt32)(g_NumIters_Loop / 1000), - (UInt32)(g_NumIters_Bytes / 1000) - )); - - MatchFinderMt_FreeMem(p, alloc); -} - - -#define kHashBufferSize (kMtHashBlockSize * kMtHashNumBlocks) -#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks) - - -static THREAD_FUNC_DECL HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; } -static THREAD_FUNC_DECL BtThreadFunc2(void *p) -{ - Byte allocaDummy[0x180]; - unsigned i = 0; - for (i = 0; i < 16; i++) - allocaDummy[i] = (Byte)0; - if (allocaDummy[0] == 0) - BtThreadFunc((CMatchFinderMt *)p); - return 0; -} - - -SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore, - UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAllocPtr alloc) -{ - CMatchFinder *mf = MF(p); - p->historySize = historySize; - if (kMtBtBlockSize <= matchMaxLen * 4) - return SZ_ERROR_PARAM; - if (!p->hashBuf) - { - p->hashBuf = (UInt32 *)ISzAlloc_Alloc(alloc, ((size_t)kHashBufferSize + (size_t)kBtBufferSize) * sizeof(UInt32)); - if (!p->hashBuf) - return SZ_ERROR_MEM; - p->btBuf = p->hashBuf + kHashBufferSize; - } - keepAddBufferBefore += (kHashBufferSize + kBtBufferSize); - keepAddBufferAfter += kMtHashBlockSize; - if (!MatchFinder_Create(mf, historySize, keepAddBufferBefore, matchMaxLen, keepAddBufferAfter, alloc)) - return SZ_ERROR_MEM; - - RINOK(MtSync_Create(&p->hashSync, HashThreadFunc2, p)) - RINOK(MtSync_Create(&p->btSync, BtThreadFunc2, p)) - return SZ_OK; -} - - -SRes MatchFinderMt_InitMt(CMatchFinderMt *p) -{ - RINOK(MtSync_Init(&p->hashSync, kMtHashNumBlocks)) - return MtSync_Init(&p->btSync, kMtBtNumBlocks); -} - - -static void MatchFinderMt_Init(CMatchFinderMt *p) -{ - CMatchFinder *mf = MF(p); - - p->btBufPos = - p->btBufPosLimit = NULL; - p->hashBufPos = - p->hashBufPosLimit = 0; - p->hashNumAvail = 0; // 21.03 - - p->failure_BT = False; - - /* Init without data reading. We don't want to read data in this thread */ - MatchFinder_Init_4(mf); - - MatchFinder_Init_LowHash(mf); - - p->pointerToCurPos = Inline_MatchFinder_GetPointerToCurrentPos(mf); - p->btNumAvailBytes = 0; - p->failure_LZ_BT = False; - // p->failure_LZ_LZ = False; - - p->lzPos = - 1; // optimal smallest value - // 0; // for debug: ignores match to start - // kNormalizeAlign; // for debug - - p->hash = mf->hash; - p->fixedHashSize = mf->fixedHashSize; - // p->hash4Mask = mf->hash4Mask; - p->crc = mf->crc; - // memcpy(p->crc, mf->crc, sizeof(mf->crc)); - - p->son = mf->son; - p->matchMaxLen = mf->matchMaxLen; - p->numHashBytes = mf->numHashBytes; - - /* (mf->pos) and (mf->streamPos) were already initialized to 1 in MatchFinder_Init_4() */ - // mf->streamPos = mf->pos = 1; // optimal smallest value - // 0; // for debug: ignores match to start - // kNormalizeAlign; // for debug - - /* we must init (p->pos = mf->pos) for BT, because - BT code needs (p->pos == delta_value_for_empty_hash_record == mf->pos) */ - p->pos = mf->pos; // do not change it - - p->cyclicBufferPos = (p->pos - CYC_TO_POS_OFFSET); - p->cyclicBufferSize = mf->cyclicBufferSize; - p->buffer = mf->buffer; - p->cutValue = mf->cutValue; - // p->son[0] = p->son[1] = 0; // unused: to init skipped record for speculated accesses. -} - - -/* ReleaseStream is required to finish multithreading */ -void MatchFinderMt_ReleaseStream(CMatchFinderMt *p) -{ - // Sleep(1); // for debug - MtSync_StopWriting(&p->btSync); - // Sleep(200); // for debug - /* p->MatchFinder->ReleaseStream(); */ -} - - -Z7_NO_INLINE -static UInt32 MatchFinderMt_GetNextBlock_Bt(CMatchFinderMt *p) -{ - if (p->failure_LZ_BT) - p->btBufPos = p->failureBuf; - else - { - const UInt32 bi = MtSync_GetNextBlock(&p->btSync); - const UInt32 *bt = p->btBuf + GET_BT_BLOCK_OFFSET(bi); - { - const UInt32 numItems = bt[0]; - p->btBufPosLimit = bt + numItems; - p->btNumAvailBytes = bt[1]; - p->btBufPos = bt + 2; - if (numItems < 2 || numItems > kMtBtBlockSize) - { - p->failureBuf[0] = 0; - p->btBufPos = p->failureBuf; - p->btBufPosLimit = p->failureBuf + 1; - p->failure_LZ_BT = True; - // p->btNumAvailBytes = 0; - /* we don't want to decrease AvailBytes, that was load before. - that can be unxepected for the code that have loaded anopther value before */ - } - } - - if (p->lzPos >= (UInt32)kMtMaxValForNormalize - (UInt32)kMtBtBlockSize) - { - /* we don't check (lzPos) over exact avail bytes in (btBuf). - (fixedHashSize) is small, so normalization is fast */ - const UInt32 subValue = (p->lzPos - p->historySize - 1); // & ~(UInt32)(kNormalizeAlign - 1); - p->lzPos -= subValue; - MatchFinder_Normalize3(subValue, p->hash, p->fixedHashSize); - } - } - return p->btNumAvailBytes; -} - - - -static const Byte * MatchFinderMt_GetPointerToCurrentPos(CMatchFinderMt *p) -{ - return p->pointerToCurPos; -} - - -#define GET_NEXT_BLOCK_IF_REQUIRED if (p->btBufPos == p->btBufPosLimit) MatchFinderMt_GetNextBlock_Bt(p); - - -static UInt32 MatchFinderMt_GetNumAvailableBytes(CMatchFinderMt *p) -{ - if (p->btBufPos != p->btBufPosLimit) - return p->btNumAvailBytes; - return MatchFinderMt_GetNextBlock_Bt(p); -} - - -// #define CHECK_FAILURE_LZ(_match_, _pos_) if (_match_ >= _pos_) { p->failure_LZ_LZ = True; return d; } -#define CHECK_FAILURE_LZ(_match_, _pos_) - -static UInt32 * MixMatches2(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *d) -{ - UInt32 h2, c2; - UInt32 *hash = p->hash; - const Byte *cur = p->pointerToCurPos; - const UInt32 m = p->lzPos; - MT_HASH2_CALC - - c2 = hash[h2]; - hash[h2] = m; - - if (c2 >= matchMinPos) - { - CHECK_FAILURE_LZ(c2, m) - if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m] == cur[0]) - { - *d++ = 2; - *d++ = m - c2 - 1; - } - } - - return d; -} - -static UInt32 * MixMatches3(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *d) -{ - UInt32 h2, h3, c2, c3; - UInt32 *hash = p->hash; - const Byte *cur = p->pointerToCurPos; - const UInt32 m = p->lzPos; - MT_HASH3_CALC - - c2 = hash[h2]; - c3 = (hash + kFix3HashSize)[h3]; - - hash[h2] = m; - (hash + kFix3HashSize)[h3] = m; - - if (c2 >= matchMinPos) - { - CHECK_FAILURE_LZ(c2, m) - if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m] == cur[0]) - { - d[1] = m - c2 - 1; - if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 2] == cur[2]) - { - d[0] = 3; - return d + 2; - } - d[0] = 2; - d += 2; - } - } - - if (c3 >= matchMinPos) - { - CHECK_FAILURE_LZ(c3, m) - if (cur[(ptrdiff_t)c3 - (ptrdiff_t)m] == cur[0]) - { - *d++ = 3; - *d++ = m - c3 - 1; - } - } - - return d; -} - - -#define INCREASE_LZ_POS p->lzPos++; p->pointerToCurPos++; - -/* -static -UInt32* MatchFinderMt_GetMatches_Bt4(CMatchFinderMt *p, UInt32 *d) -{ - const UInt32 *bt = p->btBufPos; - const UInt32 len = *bt++; - const UInt32 *btLim = bt + len; - UInt32 matchMinPos; - UInt32 avail = p->btNumAvailBytes - 1; - p->btBufPos = btLim; - - { - p->btNumAvailBytes = avail; - - #define BT_HASH_BYTES_MAX 5 - - matchMinPos = p->lzPos; - - if (len != 0) - matchMinPos -= bt[1]; - else if (avail < (BT_HASH_BYTES_MAX - 1) - 1) - { - INCREASE_LZ_POS - return d; - } - else - { - const UInt32 hs = p->historySize; - if (matchMinPos > hs) - matchMinPos -= hs; - else - matchMinPos = 1; - } - } - - for (;;) - { - - UInt32 h2, h3, c2, c3; - UInt32 *hash = p->hash; - const Byte *cur = p->pointerToCurPos; - UInt32 m = p->lzPos; - MT_HASH3_CALC - - c2 = hash[h2]; - c3 = (hash + kFix3HashSize)[h3]; - - hash[h2] = m; - (hash + kFix3HashSize)[h3] = m; - - if (c2 >= matchMinPos && cur[(ptrdiff_t)c2 - (ptrdiff_t)m] == cur[0]) - { - d[1] = m - c2 - 1; - if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 2] == cur[2]) - { - d[0] = 3; - d += 2; - break; - } - // else - { - d[0] = 2; - d += 2; - } - } - if (c3 >= matchMinPos && cur[(ptrdiff_t)c3 - (ptrdiff_t)m] == cur[0]) - { - *d++ = 3; - *d++ = m - c3 - 1; - } - break; - } - - if (len != 0) - { - do - { - const UInt32 v0 = bt[0]; - const UInt32 v1 = bt[1]; - bt += 2; - d[0] = v0; - d[1] = v1; - d += 2; - } - while (bt != btLim); - } - INCREASE_LZ_POS - return d; -} -*/ - - -static UInt32 * MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *d) -{ - UInt32 h2, h3, /* h4, */ c2, c3 /* , c4 */; - UInt32 *hash = p->hash; - const Byte *cur = p->pointerToCurPos; - const UInt32 m = p->lzPos; - MT_HASH3_CALC - // MT_HASH4_CALC - c2 = hash[h2]; - c3 = (hash + kFix3HashSize)[h3]; - // c4 = (hash + kFix4HashSize)[h4]; - - hash[h2] = m; - (hash + kFix3HashSize)[h3] = m; - // (hash + kFix4HashSize)[h4] = m; - - // #define BT5_USE_H2 - // #ifdef BT5_USE_H2 - if (c2 >= matchMinPos && cur[(ptrdiff_t)c2 - (ptrdiff_t)m] == cur[0]) - { - d[1] = m - c2 - 1; - if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 2] == cur[2]) - { - // d[0] = (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 3] == cur[3]) ? 4 : 3; - // return d + 2; - - if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 3] == cur[3]) - { - d[0] = 4; - return d + 2; - } - d[0] = 3; - d += 2; - - #ifdef BT5_USE_H4 - if (c4 >= matchMinPos) - if ( - cur[(ptrdiff_t)c4 - (ptrdiff_t)m] == cur[0] && - cur[(ptrdiff_t)c4 - (ptrdiff_t)m + 3] == cur[3] - ) - { - *d++ = 4; - *d++ = m - c4 - 1; - } - #endif - return d; - } - d[0] = 2; - d += 2; - } - // #endif - - if (c3 >= matchMinPos && cur[(ptrdiff_t)c3 - (ptrdiff_t)m] == cur[0]) - { - d[1] = m - c3 - 1; - if (cur[(ptrdiff_t)c3 - (ptrdiff_t)m + 3] == cur[3]) - { - d[0] = 4; - return d + 2; - } - d[0] = 3; - d += 2; - } - - #ifdef BT5_USE_H4 - if (c4 >= matchMinPos) - if ( - cur[(ptrdiff_t)c4 - (ptrdiff_t)m] == cur[0] && - cur[(ptrdiff_t)c4 - (ptrdiff_t)m + 3] == cur[3] - ) - { - *d++ = 4; - *d++ = m - c4 - 1; - } - #endif - - return d; -} - - -static UInt32 * MatchFinderMt2_GetMatches(CMatchFinderMt *p, UInt32 *d) -{ - const UInt32 *bt = p->btBufPos; - const UInt32 len = *bt++; - const UInt32 *btLim = bt + len; - p->btBufPos = btLim; - p->btNumAvailBytes--; - INCREASE_LZ_POS - { - while (bt != btLim) - { - const UInt32 v0 = bt[0]; - const UInt32 v1 = bt[1]; - bt += 2; - d[0] = v0; - d[1] = v1; - d += 2; - } - } - return d; -} - - - -static UInt32 * MatchFinderMt_GetMatches(CMatchFinderMt *p, UInt32 *d) -{ - const UInt32 *bt = p->btBufPos; - UInt32 len = *bt++; - const UInt32 avail = p->btNumAvailBytes - 1; - p->btNumAvailBytes = avail; - p->btBufPos = bt + len; - if (len == 0) - { - #define BT_HASH_BYTES_MAX 5 - if (avail >= (BT_HASH_BYTES_MAX - 1) - 1) - { - UInt32 m = p->lzPos; - if (m > p->historySize) - m -= p->historySize; - else - m = 1; - d = p->MixMatchesFunc(p, m, d); - } - } - else - { - /* - first match pair from BinTree: (match_len, match_dist), - (match_len >= numHashBytes). - MixMatchesFunc() inserts only hash matches that are nearer than (match_dist) - */ - d = p->MixMatchesFunc(p, p->lzPos - bt[1], d); - // if (d) // check for failure - do - { - const UInt32 v0 = bt[0]; - const UInt32 v1 = bt[1]; - bt += 2; - d[0] = v0; - d[1] = v1; - d += 2; - } - while (len -= 2); - } - INCREASE_LZ_POS - return d; -} - -#define SKIP_HEADER2_MT do { GET_NEXT_BLOCK_IF_REQUIRED -#define SKIP_HEADER_MT(n) SKIP_HEADER2_MT if (p->btNumAvailBytes-- >= (n)) { const Byte *cur = p->pointerToCurPos; UInt32 *hash = p->hash; -#define SKIP_FOOTER_MT } INCREASE_LZ_POS p->btBufPos += (size_t)*p->btBufPos + 1; } while (--num != 0); - -static void MatchFinderMt0_Skip(CMatchFinderMt *p, UInt32 num) -{ - SKIP_HEADER2_MT { p->btNumAvailBytes--; - SKIP_FOOTER_MT -} - -static void MatchFinderMt2_Skip(CMatchFinderMt *p, UInt32 num) -{ - SKIP_HEADER_MT(2) - UInt32 h2; - MT_HASH2_CALC - hash[h2] = p->lzPos; - SKIP_FOOTER_MT -} - -static void MatchFinderMt3_Skip(CMatchFinderMt *p, UInt32 num) -{ - SKIP_HEADER_MT(3) - UInt32 h2, h3; - MT_HASH3_CALC - (hash + kFix3HashSize)[h3] = - hash[ h2] = - p->lzPos; - SKIP_FOOTER_MT -} - -/* -// MatchFinderMt4_Skip() is similar to MatchFinderMt3_Skip(). -// The difference is that MatchFinderMt3_Skip() updates hash for last 3 bytes of stream. - -static void MatchFinderMt4_Skip(CMatchFinderMt *p, UInt32 num) -{ - SKIP_HEADER_MT(4) - UInt32 h2, h3; // h4 - MT_HASH3_CALC - // MT_HASH4_CALC - // (hash + kFix4HashSize)[h4] = - (hash + kFix3HashSize)[h3] = - hash[ h2] = - p->lzPos; - SKIP_FOOTER_MT -} -*/ - -void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder2 *vTable) -{ - vTable->Init = (Mf_Init_Func)MatchFinderMt_Init; - vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinderMt_GetNumAvailableBytes; - vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinderMt_GetPointerToCurrentPos; - vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt_GetMatches; - - switch (MF(p)->numHashBytes) - { - case 2: - p->GetHeadsFunc = GetHeads2; - p->MixMatchesFunc = (Mf_Mix_Matches)NULL; - vTable->Skip = (Mf_Skip_Func)MatchFinderMt0_Skip; - vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt2_GetMatches; - break; - case 3: - p->GetHeadsFunc = MF(p)->bigHash ? GetHeads3b : GetHeads3; - p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches2; - vTable->Skip = (Mf_Skip_Func)MatchFinderMt2_Skip; - break; - case 4: - p->GetHeadsFunc = MF(p)->bigHash ? GetHeads4b : GetHeads4; - - // it's fast inline version of GetMatches() - // vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt_GetMatches_Bt4; - - p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches3; - vTable->Skip = (Mf_Skip_Func)MatchFinderMt3_Skip; - break; - default: - p->GetHeadsFunc = MF(p)->bigHash ? GetHeads5b : GetHeads5; - p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches4; - vTable->Skip = - (Mf_Skip_Func)MatchFinderMt3_Skip; - // (Mf_Skip_Func)MatchFinderMt4_Skip; - break; - } -} - -#undef RINOK_THREAD -#undef PRF -#undef MF -#undef GetUi24hi_from32 -#undef LOCK_BUFFER -#undef UNLOCK_BUFFER diff --git a/extern/lzma/LzFindMt.h b/extern/lzma/LzFindMt.h deleted file mode 100644 index db5923ea05b..00000000000 --- a/extern/lzma/LzFindMt.h +++ /dev/null @@ -1,109 +0,0 @@ -/* LzFindMt.h -- multithreaded Match finder for LZ algorithms -2023-03-05 : Igor Pavlov : Public domain */ - -#ifndef ZIP7_INC_LZ_FIND_MT_H -#define ZIP7_INC_LZ_FIND_MT_H - -#include "LzFind.h" -#include "Threads.h" - -EXTERN_C_BEGIN - -typedef struct -{ - UInt32 numProcessedBlocks; - CThread thread; - UInt64 affinity; - - BoolInt wasCreated; - BoolInt needStart; - BoolInt csWasInitialized; - BoolInt csWasEntered; - - BoolInt exit; - BoolInt stopWriting; - - CAutoResetEvent canStart; - CAutoResetEvent wasStopped; - CSemaphore freeSemaphore; - CSemaphore filledSemaphore; - CCriticalSection cs; - // UInt32 numBlocks_Sent; -} CMtSync; - -typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances); - -/* kMtCacheLineDummy must be >= size_of_CPU_cache_line */ -#define kMtCacheLineDummy 128 - -typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos, - UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc); - -typedef struct -{ - /* LZ */ - const Byte *pointerToCurPos; - UInt32 *btBuf; - const UInt32 *btBufPos; - const UInt32 *btBufPosLimit; - UInt32 lzPos; - UInt32 btNumAvailBytes; - - UInt32 *hash; - UInt32 fixedHashSize; - // UInt32 hash4Mask; - UInt32 historySize; - const UInt32 *crc; - - Mf_Mix_Matches MixMatchesFunc; - UInt32 failure_LZ_BT; // failure in BT transfered to LZ - // UInt32 failure_LZ_LZ; // failure in LZ tables - UInt32 failureBuf[1]; - // UInt32 crc[256]; - - /* LZ + BT */ - CMtSync btSync; - Byte btDummy[kMtCacheLineDummy]; - - /* BT */ - UInt32 *hashBuf; - UInt32 hashBufPos; - UInt32 hashBufPosLimit; - UInt32 hashNumAvail; - UInt32 failure_BT; - - - CLzRef *son; - UInt32 matchMaxLen; - UInt32 numHashBytes; - UInt32 pos; - const Byte *buffer; - UInt32 cyclicBufferPos; - UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ - UInt32 cutValue; - - /* BT + Hash */ - CMtSync hashSync; - /* Byte hashDummy[kMtCacheLineDummy]; */ - - /* Hash */ - Mf_GetHeads GetHeadsFunc; - CMatchFinder *MatchFinder; - // CMatchFinder MatchFinder; -} CMatchFinderMt; - -// only for Mt part -void MatchFinderMt_Construct(CMatchFinderMt *p); -void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAllocPtr alloc); - -SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore, - UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAllocPtr alloc); -void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder2 *vTable); - -/* call MatchFinderMt_InitMt() before IMatchFinder::Init() */ -SRes MatchFinderMt_InitMt(CMatchFinderMt *p); -void MatchFinderMt_ReleaseStream(CMatchFinderMt *p); - -EXTERN_C_END - -#endif diff --git a/extern/lzma/LzFindOpt.c b/extern/lzma/LzFindOpt.c deleted file mode 100644 index 85bdc136d67..00000000000 --- a/extern/lzma/LzFindOpt.c +++ /dev/null @@ -1,578 +0,0 @@ -/* LzFindOpt.c -- multithreaded Match finder for LZ algorithms -2023-04-02 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "CpuArch.h" -#include "LzFind.h" - -// #include "LzFindMt.h" - -// #define LOG_ITERS - -// #define LOG_THREAD - -#ifdef LOG_THREAD -#include -#define PRF(x) x -#else -// #define PRF(x) -#endif - -#ifdef LOG_ITERS -#include -UInt64 g_NumIters_Tree; -UInt64 g_NumIters_Loop; -UInt64 g_NumIters_Bytes; -#define LOG_ITER(x) x -#else -#define LOG_ITER(x) -#endif - -// ---------- BT THREAD ---------- - -#define USE_SON_PREFETCH -#define USE_LONG_MATCH_OPT - -#define kEmptyHashValue 0 - -// #define CYC_TO_POS_OFFSET 0 - -// #define CYC_TO_POS_OFFSET 1 // for debug - -/* -Z7_NO_INLINE -UInt32 * Z7_FASTCALL GetMatchesSpecN_1(const Byte *lenLimit, size_t pos, const Byte *cur, CLzRef *son, - UInt32 _cutValue, UInt32 *d, size_t _maxLen, const UInt32 *hash, const UInt32 *limit, const UInt32 *size, UInt32 *posRes) -{ - do - { - UInt32 delta; - if (hash == size) - break; - delta = *hash++; - - if (delta == 0 || delta > (UInt32)pos) - return NULL; - - lenLimit++; - - if (delta == (UInt32)pos) - { - CLzRef *ptr1 = son + ((size_t)pos << 1) - CYC_TO_POS_OFFSET * 2; - *d++ = 0; - ptr1[0] = kEmptyHashValue; - ptr1[1] = kEmptyHashValue; - } -else -{ - UInt32 *_distances = ++d; - - CLzRef *ptr0 = son + ((size_t)(pos) << 1) - CYC_TO_POS_OFFSET * 2 + 1; - CLzRef *ptr1 = son + ((size_t)(pos) << 1) - CYC_TO_POS_OFFSET * 2; - - const Byte *len0 = cur, *len1 = cur; - UInt32 cutValue = _cutValue; - const Byte *maxLen = cur + _maxLen; - - for (LOG_ITER(g_NumIters_Tree++);;) - { - LOG_ITER(g_NumIters_Loop++); - { - const ptrdiff_t diff = (ptrdiff_t)0 - (ptrdiff_t)delta; - CLzRef *pair = son + ((size_t)(((ptrdiff_t)pos - CYC_TO_POS_OFFSET) + diff) << 1); - const Byte *len = (len0 < len1 ? len0 : len1); - - #ifdef USE_SON_PREFETCH - const UInt32 pair0 = *pair; - #endif - - if (len[diff] == len[0]) - { - if (++len != lenLimit && len[diff] == len[0]) - while (++len != lenLimit) - { - LOG_ITER(g_NumIters_Bytes++); - if (len[diff] != len[0]) - break; - } - if (maxLen < len) - { - maxLen = len; - *d++ = (UInt32)(len - cur); - *d++ = delta - 1; - - if (len == lenLimit) - { - const UInt32 pair1 = pair[1]; - *ptr1 = - #ifdef USE_SON_PREFETCH - pair0; - #else - pair[0]; - #endif - *ptr0 = pair1; - - _distances[-1] = (UInt32)(d - _distances); - - #ifdef USE_LONG_MATCH_OPT - - if (hash == size || *hash != delta || lenLimit[diff] != lenLimit[0] || d >= limit) - break; - - { - for (;;) - { - hash++; - pos++; - cur++; - lenLimit++; - { - CLzRef *ptr = son + ((size_t)(pos) << 1) - CYC_TO_POS_OFFSET * 2; - #if 0 - *(UInt64 *)(void *)ptr = ((const UInt64 *)(const void *)ptr)[diff]; - #else - const UInt32 p0 = ptr[0 + (diff * 2)]; - const UInt32 p1 = ptr[1 + (diff * 2)]; - ptr[0] = p0; - ptr[1] = p1; - // ptr[0] = ptr[0 + (diff * 2)]; - // ptr[1] = ptr[1 + (diff * 2)]; - #endif - } - // PrintSon(son + 2, pos - 1); - // printf("\npos = %x delta = %x\n", pos, delta); - len++; - *d++ = 2; - *d++ = (UInt32)(len - cur); - *d++ = delta - 1; - if (hash == size || *hash != delta || lenLimit[diff] != lenLimit[0] || d >= limit) - break; - } - } - #endif - - break; - } - } - } - - { - const UInt32 curMatch = (UInt32)pos - delta; // (UInt32)(pos + diff); - if (len[diff] < len[0]) - { - delta = pair[1]; - if (delta >= curMatch) - return NULL; - *ptr1 = curMatch; - ptr1 = pair + 1; - len1 = len; - } - else - { - delta = *pair; - if (delta >= curMatch) - return NULL; - *ptr0 = curMatch; - ptr0 = pair; - len0 = len; - } - - delta = (UInt32)pos - delta; - - if (--cutValue == 0 || delta >= pos) - { - *ptr0 = *ptr1 = kEmptyHashValue; - _distances[-1] = (UInt32)(d - _distances); - break; - } - } - } - } // for (tree iterations) -} - pos++; - cur++; - } - while (d < limit); - *posRes = (UInt32)pos; - return d; -} -*/ - -/* define cbs if you use 2 functions. - GetMatchesSpecN_1() : (pos < _cyclicBufferSize) - GetMatchesSpecN_2() : (pos >= _cyclicBufferSize) - - do not define cbs if you use 1 function: - GetMatchesSpecN_2() -*/ - -// #define cbs _cyclicBufferSize - -/* - we use size_t for (pos) and (_cyclicBufferPos_ instead of UInt32 - to eliminate "movsx" BUG in old MSVC x64 compiler. -*/ - -UInt32 * Z7_FASTCALL GetMatchesSpecN_2(const Byte *lenLimit, size_t pos, const Byte *cur, CLzRef *son, - UInt32 _cutValue, UInt32 *d, size_t _maxLen, const UInt32 *hash, const UInt32 *limit, const UInt32 *size, - size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, - UInt32 *posRes); - -Z7_NO_INLINE -UInt32 * Z7_FASTCALL GetMatchesSpecN_2(const Byte *lenLimit, size_t pos, const Byte *cur, CLzRef *son, - UInt32 _cutValue, UInt32 *d, size_t _maxLen, const UInt32 *hash, const UInt32 *limit, const UInt32 *size, - size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, - UInt32 *posRes) -{ - do // while (hash != size) - { - UInt32 delta; - - #ifndef cbs - UInt32 cbs; - #endif - - if (hash == size) - break; - - delta = *hash++; - - if (delta == 0) - return NULL; - - lenLimit++; - - #ifndef cbs - cbs = _cyclicBufferSize; - if ((UInt32)pos < cbs) - { - if (delta > (UInt32)pos) - return NULL; - cbs = (UInt32)pos; - } - #endif - - if (delta >= cbs) - { - CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); - *d++ = 0; - ptr1[0] = kEmptyHashValue; - ptr1[1] = kEmptyHashValue; - } -else -{ - UInt32 *_distances = ++d; - - CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1; - CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); - - UInt32 cutValue = _cutValue; - const Byte *len0 = cur, *len1 = cur; - const Byte *maxLen = cur + _maxLen; - - // if (cutValue == 0) { *ptr0 = *ptr1 = kEmptyHashValue; } else - for (LOG_ITER(g_NumIters_Tree++);;) - { - LOG_ITER(g_NumIters_Loop++); - { - // SPEC code - CLzRef *pair = son + ((size_t)((ptrdiff_t)_cyclicBufferPos - (ptrdiff_t)delta - + (ptrdiff_t)(UInt32)(_cyclicBufferPos < delta ? cbs : 0) - ) << 1); - - const ptrdiff_t diff = (ptrdiff_t)0 - (ptrdiff_t)delta; - const Byte *len = (len0 < len1 ? len0 : len1); - - #ifdef USE_SON_PREFETCH - const UInt32 pair0 = *pair; - #endif - - if (len[diff] == len[0]) - { - if (++len != lenLimit && len[diff] == len[0]) - while (++len != lenLimit) - { - LOG_ITER(g_NumIters_Bytes++); - if (len[diff] != len[0]) - break; - } - if (maxLen < len) - { - maxLen = len; - *d++ = (UInt32)(len - cur); - *d++ = delta - 1; - - if (len == lenLimit) - { - const UInt32 pair1 = pair[1]; - *ptr1 = - #ifdef USE_SON_PREFETCH - pair0; - #else - pair[0]; - #endif - *ptr0 = pair1; - - _distances[-1] = (UInt32)(d - _distances); - - #ifdef USE_LONG_MATCH_OPT - - if (hash == size || *hash != delta || lenLimit[diff] != lenLimit[0] || d >= limit) - break; - - { - for (;;) - { - *d++ = 2; - *d++ = (UInt32)(lenLimit - cur); - *d++ = delta - 1; - cur++; - lenLimit++; - // SPEC - _cyclicBufferPos++; - { - // SPEC code - CLzRef *dest = son + ((size_t)(_cyclicBufferPos) << 1); - const CLzRef *src = dest + ((diff - + (ptrdiff_t)(UInt32)((_cyclicBufferPos < delta) ? cbs : 0)) << 1); - // CLzRef *ptr = son + ((size_t)(pos) << 1) - CYC_TO_POS_OFFSET * 2; - #if 0 - *(UInt64 *)(void *)dest = *((const UInt64 *)(const void *)src); - #else - const UInt32 p0 = src[0]; - const UInt32 p1 = src[1]; - dest[0] = p0; - dest[1] = p1; - #endif - } - pos++; - hash++; - if (hash == size || *hash != delta || lenLimit[diff] != lenLimit[0] || d >= limit) - break; - } // for() end for long matches - } - #endif - - break; // break from TREE iterations - } - } - } - { - const UInt32 curMatch = (UInt32)pos - delta; // (UInt32)(pos + diff); - if (len[diff] < len[0]) - { - delta = pair[1]; - *ptr1 = curMatch; - ptr1 = pair + 1; - len1 = len; - if (delta >= curMatch) - return NULL; - } - else - { - delta = *pair; - *ptr0 = curMatch; - ptr0 = pair; - len0 = len; - if (delta >= curMatch) - return NULL; - } - delta = (UInt32)pos - delta; - - if (--cutValue == 0 || delta >= cbs) - { - *ptr0 = *ptr1 = kEmptyHashValue; - _distances[-1] = (UInt32)(d - _distances); - break; - } - } - } - } // for (tree iterations) -} - pos++; - _cyclicBufferPos++; - cur++; - } - while (d < limit); - *posRes = (UInt32)pos; - return d; -} - - - -/* -typedef UInt32 uint32plus; // size_t - -UInt32 * Z7_FASTCALL GetMatchesSpecN_3(uint32plus lenLimit, size_t pos, const Byte *cur, CLzRef *son, - UInt32 _cutValue, UInt32 *d, uint32plus _maxLen, const UInt32 *hash, const UInt32 *limit, const UInt32 *size, - size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, - UInt32 *posRes) -{ - do // while (hash != size) - { - UInt32 delta; - - #ifndef cbs - UInt32 cbs; - #endif - - if (hash == size) - break; - - delta = *hash++; - - if (delta == 0) - return NULL; - - #ifndef cbs - cbs = _cyclicBufferSize; - if ((UInt32)pos < cbs) - { - if (delta > (UInt32)pos) - return NULL; - cbs = (UInt32)pos; - } - #endif - - if (delta >= cbs) - { - CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); - *d++ = 0; - ptr1[0] = kEmptyHashValue; - ptr1[1] = kEmptyHashValue; - } -else -{ - CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1; - CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); - UInt32 *_distances = ++d; - uint32plus len0 = 0, len1 = 0; - UInt32 cutValue = _cutValue; - uint32plus maxLen = _maxLen; - // lenLimit++; // const Byte *lenLimit = cur + _lenLimit; - - for (LOG_ITER(g_NumIters_Tree++);;) - { - LOG_ITER(g_NumIters_Loop++); - { - // const ptrdiff_t diff = (ptrdiff_t)0 - (ptrdiff_t)delta; - CLzRef *pair = son + ((size_t)((ptrdiff_t)_cyclicBufferPos - delta - + (ptrdiff_t)(UInt32)(_cyclicBufferPos < delta ? cbs : 0) - ) << 1); - const Byte *pb = cur - delta; - uint32plus len = (len0 < len1 ? len0 : len1); - - #ifdef USE_SON_PREFETCH - const UInt32 pair0 = *pair; - #endif - - if (pb[len] == cur[len]) - { - if (++len != lenLimit && pb[len] == cur[len]) - while (++len != lenLimit) - if (pb[len] != cur[len]) - break; - if (maxLen < len) - { - maxLen = len; - *d++ = (UInt32)len; - *d++ = delta - 1; - if (len == lenLimit) - { - { - const UInt32 pair1 = pair[1]; - *ptr0 = pair1; - *ptr1 = - #ifdef USE_SON_PREFETCH - pair0; - #else - pair[0]; - #endif - } - - _distances[-1] = (UInt32)(d - _distances); - - #ifdef USE_LONG_MATCH_OPT - - if (hash == size || *hash != delta || pb[lenLimit] != cur[lenLimit] || d >= limit) - break; - - { - const ptrdiff_t diff = (ptrdiff_t)0 - (ptrdiff_t)delta; - for (;;) - { - *d++ = 2; - *d++ = (UInt32)lenLimit; - *d++ = delta - 1; - _cyclicBufferPos++; - { - CLzRef *dest = son + ((size_t)_cyclicBufferPos << 1); - const CLzRef *src = dest + ((diff + - (ptrdiff_t)(UInt32)(_cyclicBufferPos < delta ? cbs : 0)) << 1); - #if 0 - *(UInt64 *)(void *)dest = *((const UInt64 *)(const void *)src); - #else - const UInt32 p0 = src[0]; - const UInt32 p1 = src[1]; - dest[0] = p0; - dest[1] = p1; - #endif - } - hash++; - pos++; - cur++; - pb++; - if (hash == size || *hash != delta || pb[lenLimit] != cur[lenLimit] || d >= limit) - break; - } - } - #endif - - break; - } - } - } - { - const UInt32 curMatch = (UInt32)pos - delta; - if (pb[len] < cur[len]) - { - delta = pair[1]; - *ptr1 = curMatch; - ptr1 = pair + 1; - len1 = len; - } - else - { - delta = *pair; - *ptr0 = curMatch; - ptr0 = pair; - len0 = len; - } - - { - if (delta >= curMatch) - return NULL; - delta = (UInt32)pos - delta; - if (delta >= cbs - // delta >= _cyclicBufferSize || delta >= pos - || --cutValue == 0) - { - *ptr0 = *ptr1 = kEmptyHashValue; - _distances[-1] = (UInt32)(d - _distances); - break; - } - } - } - } - } // for (tree iterations) -} - pos++; - _cyclicBufferPos++; - cur++; - } - while (d < limit); - *posRes = (UInt32)pos; - return d; -} -*/ diff --git a/extern/lzma/LzHash.h b/extern/lzma/LzHash.h index 2b6290b64c0..9f4173e7e33 100644 --- a/extern/lzma/LzHash.h +++ b/extern/lzma/LzHash.h @@ -1,34 +1,54 @@ -/* LzHash.h -- HASH constants for LZ algorithms -2023-03-05 : Igor Pavlov : Public domain */ +/* LzHash.h -- HASH functions for LZ algorithms +2008-10-04 : Igor Pavlov : Public domain */ -#ifndef ZIP7_INC_LZ_HASH_H -#define ZIP7_INC_LZ_HASH_H - -/* - (kHash2Size >= (1 << 8)) : Required - (kHash3Size >= (1 << 16)) : Required -*/ +#ifndef __LZHASH_H +#define __LZHASH_H #define kHash2Size (1 << 10) #define kHash3Size (1 << 16) -// #define kHash4Size (1 << 20) +#define kHash4Size (1 << 20) #define kFix3HashSize (kHash2Size) #define kFix4HashSize (kHash2Size + kHash3Size) -// #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) +#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) -/* - We use up to 3 crc values for hash: - crc0 - crc1 << Shift_1 - crc2 << Shift_2 - (Shift_1 = 5) and (Shift_2 = 10) is good tradeoff. - Small values for Shift are not good for collision rate. - Big value for Shift_2 increases the minimum size - of hash table, that will be slow for small files. -*/ +#define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8); -#define kLzHash_CrcShift_1 5 -#define kLzHash_CrcShift_2 10 +#define HASH3_CALC { \ + UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + hash2Value = temp & (kHash2Size - 1); \ + hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; } + +#define HASH4_CALC { \ + UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + hash2Value = temp & (kHash2Size - 1); \ + hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ + hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; } + +#define HASH5_CALC { \ + UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + hash2Value = temp & (kHash2Size - 1); \ + hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ + hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \ + hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \ + hash4Value &= (kHash4Size - 1); } + +/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */ +#define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF; + + +#define MT_HASH2_CALC \ + hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1); + +#define MT_HASH3_CALC { \ + UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + hash2Value = temp & (kHash2Size - 1); \ + hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } + +#define MT_HASH4_CALC { \ + UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + hash2Value = temp & (kHash2Size - 1); \ + hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ + hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); } #endif diff --git a/extern/lzma/LzmaDec.c b/extern/lzma/LzmaDec.c index 69bb8bba9d4..d87eb1914ea 100644 --- a/extern/lzma/LzmaDec.c +++ b/extern/lzma/LzmaDec.c @@ -1,107 +1,81 @@ /* LzmaDec.c -- LZMA Decoder -2023-04-07 : Igor Pavlov : Public domain */ +2008-11-06 : Igor Pavlov : Public domain */ -#include "Precomp.h" +#include "LzmaDec.h" #include -/* #include "CpuArch.h" */ -#include "LzmaDec.h" - -// #define kNumTopBits 24 -#define kTopValue ((UInt32)1 << 24) +#define kNumTopBits 24 +#define kTopValue ((UInt32)1 << kNumTopBits) #define kNumBitModelTotalBits 11 #define kBitModelTotal (1 << kNumBitModelTotalBits) +#define kNumMoveBits 5 #define RC_INIT_SIZE 5 -#ifndef Z7_LZMA_DEC_OPT - -#define kNumMoveBits 5 #define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); } -#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound) +#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) #define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); #define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); #define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \ - { UPDATE_0(p) i = (i + i); A0; } else \ - { UPDATE_1(p) i = (i + i) + 1; A1; } - -#define TREE_GET_BIT(probs, i) { GET_BIT2(probs + i, i, ;, ;); } - -#define REV_BIT(p, i, A0, A1) IF_BIT_0(p + i) \ - { UPDATE_0(p + i) A0; } else \ - { UPDATE_1(p + i) A1; } -#define REV_BIT_VAR( p, i, m) REV_BIT(p, i, i += m; m += m, m += m; i += m; ) -#define REV_BIT_CONST(p, i, m) REV_BIT(p, i, i += m; , i += m * 2; ) -#define REV_BIT_LAST( p, i, m) REV_BIT(p, i, i -= m , ; ) + { UPDATE_0(p); i = (i + i); A0; } else \ + { UPDATE_1(p); i = (i + i) + 1; A1; } +#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;) +#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); } #define TREE_DECODE(probs, limit, i) \ { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; } -/* #define Z7_LZMA_SIZE_OPT */ +/* #define _LZMA_SIZE_OPT */ -#ifdef Z7_LZMA_SIZE_OPT +#ifdef _LZMA_SIZE_OPT #define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i) #else #define TREE_6_DECODE(probs, i) \ { i = 1; \ - TREE_GET_BIT(probs, i) \ - TREE_GET_BIT(probs, i) \ - TREE_GET_BIT(probs, i) \ - TREE_GET_BIT(probs, i) \ - TREE_GET_BIT(probs, i) \ - TREE_GET_BIT(probs, i) \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ i -= 0x40; } #endif -#define NORMAL_LITER_DEC TREE_GET_BIT(prob, symbol) -#define MATCHED_LITER_DEC \ - matchByte += matchByte; \ - bit = offs; \ - offs &= matchByte; \ - probLit = prob + (offs + bit + symbol); \ - GET_BIT2(probLit, symbol, offs ^= bit; , ;) +#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); } -#endif // Z7_LZMA_DEC_OPT - - -#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_INPUT_EOF; range <<= 8; code = (code << 8) | (*buf++); } - -#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound) +#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) #define UPDATE_0_CHECK range = bound; #define UPDATE_1_CHECK range -= bound; code -= bound; #define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ - { UPDATE_0_CHECK i = (i + i); A0; } else \ - { UPDATE_1_CHECK i = (i + i) + 1; A1; } + { UPDATE_0_CHECK; i = (i + i); A0; } else \ + { UPDATE_1_CHECK; i = (i + i) + 1; A1; } #define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) #define TREE_DECODE_CHECK(probs, limit, i) \ { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; } -#define REV_BIT_CHECK(p, i, m) IF_BIT_0_CHECK(p + i) \ - { UPDATE_0_CHECK i += m; m += m; } else \ - { UPDATE_1_CHECK m += m; i += m; } - - #define kNumPosBitsMax 4 #define kNumPosStatesMax (1 << kNumPosBitsMax) #define kLenNumLowBits 3 #define kLenNumLowSymbols (1 << kLenNumLowBits) +#define kLenNumMidBits 3 +#define kLenNumMidSymbols (1 << kLenNumMidBits) #define kLenNumHighBits 8 #define kLenNumHighSymbols (1 << kLenNumHighBits) -#define LenLow 0 -#define LenHigh (LenLow + 2 * (kNumPosStatesMax << kLenNumLowBits)) +#define LenChoice 0 +#define LenChoice2 (LenChoice + 1) +#define LenLow (LenChoice2 + 1) +#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) +#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) #define kNumLenProbs (LenHigh + kLenNumHighSymbols) -#define LenChoice LenLow -#define LenChoice2 (LenLow + (1 << kLenNumLowBits)) #define kNumStates 12 -#define kNumStates2 16 #define kNumLitStates 7 #define kStartPosModelIndex 4 @@ -115,130 +89,60 @@ #define kAlignTableSize (1 << kNumAlignBits) #define kMatchMinLen 2 -#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols * 2 + kLenNumHighSymbols) +#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) -#define kMatchSpecLen_Error_Data (1 << 9) -#define kMatchSpecLen_Error_Fail (kMatchSpecLen_Error_Data - 1) - -/* External ASM code needs same CLzmaProb array layout. So don't change it. */ - -/* (probs_1664) is faster and better for code size at some platforms */ -/* -#ifdef MY_CPU_X86_OR_AMD64 -*/ -#define kStartOffset 1664 -#define GET_PROBS p->probs_1664 -/* -#define GET_PROBS p->probs + kStartOffset -#else -#define kStartOffset 0 -#define GET_PROBS p->probs -#endif -*/ - -#define SpecPos (-kStartOffset) -#define IsRep0Long (SpecPos + kNumFullDistances) -#define RepLenCoder (IsRep0Long + (kNumStates2 << kNumPosBitsMax)) -#define LenCoder (RepLenCoder + kNumLenProbs) -#define IsMatch (LenCoder + kNumLenProbs) -#define Align (IsMatch + (kNumStates2 << kNumPosBitsMax)) -#define IsRep (Align + kAlignTableSize) +#define IsMatch 0 +#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) #define IsRepG0 (IsRep + kNumStates) #define IsRepG1 (IsRepG0 + kNumStates) #define IsRepG2 (IsRepG1 + kNumStates) -#define PosSlot (IsRepG2 + kNumStates) -#define Literal (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) -#define NUM_BASE_PROBS (Literal + kStartOffset) +#define IsRep0Long (IsRepG2 + kNumStates) +#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) +#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) +#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) +#define LenCoder (Align + kAlignTableSize) +#define RepLenCoder (LenCoder + kNumLenProbs) +#define Literal (RepLenCoder + kNumLenProbs) -#if Align != 0 && kStartOffset != 0 - #error Stop_Compiling_Bad_LZMA_kAlign +#define LZMA_BASE_SIZE 1846 +#define LZMA_LIT_SIZE 768 + +#define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) + +#if Literal != LZMA_BASE_SIZE +StopCompilingDueBUG #endif -#if NUM_BASE_PROBS != 1984 - #error Stop_Compiling_Bad_LZMA_PROBS -#endif - - -#define LZMA_LIT_SIZE 0x300 - -#define LzmaProps_GetNumProbs(p) (NUM_BASE_PROBS + ((UInt32)LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) - - -#define CALC_POS_STATE(processedPos, pbMask) (((processedPos) & (pbMask)) << 4) -#define COMBINED_PS_STATE (posState + state) -#define GET_LEN_STATE (posState) +static const Byte kLiteralNextStates[kNumStates * 2] = +{ + 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5, + 7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10 +}; #define LZMA_DIC_MIN (1 << 12) -/* -p->remainLen : shows status of LZMA decoder: - < kMatchSpecLenStart : the number of bytes to be copied with (p->rep0) offset - = kMatchSpecLenStart : the LZMA stream was finished with end mark - = kMatchSpecLenStart + 1 : need init range coder - = kMatchSpecLenStart + 2 : need init range coder and state - = kMatchSpecLen_Error_Fail : Internal Code Failure - = kMatchSpecLen_Error_Data + [0 ... 273] : LZMA Data Error -*/ - -/* ---------- LZMA_DECODE_REAL ---------- */ -/* -LzmaDec_DecodeReal_3() can be implemented in external ASM file. -3 - is the code compatibility version of that function for check at link time. -*/ - -#define LZMA_DECODE_REAL LzmaDec_DecodeReal_3 - -/* -LZMA_DECODE_REAL() -In: - RangeCoder is normalized - if (p->dicPos == limit) - { - LzmaDec_TryDummy() was called before to exclude LITERAL and MATCH-REP cases. - So first symbol can be only MATCH-NON-REP. And if that MATCH-NON-REP symbol - is not END_OF_PAYALOAD_MARKER, then the function doesn't write any byte to dictionary, - the function returns SZ_OK, and the caller can use (p->remainLen) and (p->reps[0]) later. - } - -Processing: - The first LZMA symbol will be decoded in any case. - All main checks for limits are at the end of main loop, - It decodes additional LZMA-symbols while (p->buf < bufLimit && dicPos < limit), - RangeCoder is still without last normalization when (p->buf < bufLimit) is being checked. - But if (p->buf < bufLimit), the caller provided at least (LZMA_REQUIRED_INPUT_MAX + 1) bytes for - next iteration before limit (bufLimit + LZMA_REQUIRED_INPUT_MAX), - that is enough for worst case LZMA symbol with one additional RangeCoder normalization for one bit. - So that function never reads bufLimit [LZMA_REQUIRED_INPUT_MAX] byte. - +/* First LZMA-symbol is always decoded. +And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization Out: - RangeCoder is normalized Result: SZ_OK - OK - p->remainLen: - < kMatchSpecLenStart : the number of bytes to be copied with (p->reps[0]) offset - = kMatchSpecLenStart : the LZMA stream was finished with end mark - - SZ_ERROR_DATA - error, when the MATCH-Symbol refers out of dictionary - p->remainLen : undefined - p->reps[*] : undefined + SZ_ERROR_DATA - Error + p->remainLen: + < kMatchSpecLenStart : normal remain + = kMatchSpecLenStart : finished + = kMatchSpecLenStart + 1 : Flush marker + = kMatchSpecLenStart + 2 : State Init Marker */ - -#ifdef Z7_LZMA_DEC_OPT - -int Z7_FASTCALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit); - -#else - -static -int Z7_FASTCALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit) +static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit) { - CLzmaProb *probs = GET_PROBS; - unsigned state = (unsigned)p->state; + CLzmaProb *probs = p->probs; + + unsigned state = p->state; UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; + unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1; unsigned lc = p->prop.lc; - unsigned lpMask = ((unsigned)0x100 << p->prop.lp) - ((unsigned)0x100 >> lc); Byte *dic = p->dic; SizeT dicBufSize = p->dicBufSize; @@ -257,126 +161,99 @@ int Z7_FASTCALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit) CLzmaProb *prob; UInt32 bound; unsigned ttt; - unsigned posState = CALC_POS_STATE(processedPos, pbMask); + unsigned posState = processedPos & pbMask; - prob = probs + IsMatch + COMBINED_PS_STATE; + prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; IF_BIT_0(prob) { unsigned symbol; - UPDATE_0(prob) + UPDATE_0(prob); prob = probs + Literal; - if (processedPos != 0 || checkDicSize != 0) - prob += (UInt32)3 * ((((processedPos << 8) + dic[(dicPos == 0 ? dicBufSize : dicPos) - 1]) & lpMask) << lc); - processedPos++; + if (checkDicSize != 0 || processedPos != 0) + prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) + + (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc)))); if (state < kNumLitStates) { - state -= (state < 4) ? state : 3; symbol = 1; - #ifdef Z7_LZMA_SIZE_OPT - do { NORMAL_LITER_DEC } while (symbol < 0x100); - #else - NORMAL_LITER_DEC - NORMAL_LITER_DEC - NORMAL_LITER_DEC - NORMAL_LITER_DEC - NORMAL_LITER_DEC - NORMAL_LITER_DEC - NORMAL_LITER_DEC - NORMAL_LITER_DEC - #endif + do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100); } else { - unsigned matchByte = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)]; + unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; unsigned offs = 0x100; - state -= (state < 10) ? 3 : 6; symbol = 1; - #ifdef Z7_LZMA_SIZE_OPT do { unsigned bit; CLzmaProb *probLit; - MATCHED_LITER_DEC + matchByte <<= 1; + bit = (matchByte & offs); + probLit = prob + offs + bit + symbol; + GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit) } while (symbol < 0x100); - #else - { - unsigned bit; - CLzmaProb *probLit; - MATCHED_LITER_DEC - MATCHED_LITER_DEC - MATCHED_LITER_DEC - MATCHED_LITER_DEC - MATCHED_LITER_DEC - MATCHED_LITER_DEC - MATCHED_LITER_DEC - MATCHED_LITER_DEC - } - #endif } - dic[dicPos++] = (Byte)symbol; + processedPos++; + + state = kLiteralNextStates[state]; + /* if (state < 4) state = 0; else if (state < 10) state -= 3; else state -= 6; */ continue; } - + else { - UPDATE_1(prob) + UPDATE_1(prob); prob = probs + IsRep + state; IF_BIT_0(prob) { - UPDATE_0(prob) + UPDATE_0(prob); state += kNumStates; prob = probs + LenCoder; } else { - UPDATE_1(prob) + UPDATE_1(prob); + if (checkDicSize == 0 && processedPos == 0) + return SZ_ERROR_DATA; prob = probs + IsRepG0 + state; IF_BIT_0(prob) { - UPDATE_0(prob) - prob = probs + IsRep0Long + COMBINED_PS_STATE; + UPDATE_0(prob); + prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; IF_BIT_0(prob) { - UPDATE_0(prob) - - // that case was checked before with kBadRepCode - // if (checkDicSize == 0 && processedPos == 0) { len = kMatchSpecLen_Error_Data + 1; break; } - // The caller doesn't allow (dicPos == limit) case here - // so we don't need the following check: - // if (dicPos == limit) { state = state < kNumLitStates ? 9 : 11; len = 1; break; } - - dic[dicPos] = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)]; + UPDATE_0(prob); + dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; dicPos++; processedPos++; state = state < kNumLitStates ? 9 : 11; continue; } - UPDATE_1(prob) + UPDATE_1(prob); } else { UInt32 distance; - UPDATE_1(prob) + UPDATE_1(prob); prob = probs + IsRepG1 + state; IF_BIT_0(prob) { - UPDATE_0(prob) + UPDATE_0(prob); distance = rep1; } else { - UPDATE_1(prob) + UPDATE_1(prob); prob = probs + IsRepG2 + state; IF_BIT_0(prob) { - UPDATE_0(prob) + UPDATE_0(prob); distance = rep2; } else { - UPDATE_1(prob) + UPDATE_1(prob); distance = rep3; rep3 = rep2; } @@ -388,101 +265,63 @@ int Z7_FASTCALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit) state = state < kNumLitStates ? 8 : 11; prob = probs + RepLenCoder; } - - #ifdef Z7_LZMA_SIZE_OPT { - unsigned lim, offset; + unsigned limit, offset; CLzmaProb *probLen = prob + LenChoice; IF_BIT_0(probLen) { - UPDATE_0(probLen) - probLen = prob + LenLow + GET_LEN_STATE; + UPDATE_0(probLen); + probLen = prob + LenLow + (posState << kLenNumLowBits); offset = 0; - lim = (1 << kLenNumLowBits); + limit = (1 << kLenNumLowBits); } else { - UPDATE_1(probLen) + UPDATE_1(probLen); probLen = prob + LenChoice2; IF_BIT_0(probLen) { - UPDATE_0(probLen) - probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits); + UPDATE_0(probLen); + probLen = prob + LenMid + (posState << kLenNumMidBits); offset = kLenNumLowSymbols; - lim = (1 << kLenNumLowBits); + limit = (1 << kLenNumMidBits); } else { - UPDATE_1(probLen) + UPDATE_1(probLen); probLen = prob + LenHigh; - offset = kLenNumLowSymbols * 2; - lim = (1 << kLenNumHighBits); + offset = kLenNumLowSymbols + kLenNumMidSymbols; + limit = (1 << kLenNumHighBits); } } - TREE_DECODE(probLen, lim, len) + TREE_DECODE(probLen, limit, len); len += offset; } - #else - { - CLzmaProb *probLen = prob + LenChoice; - IF_BIT_0(probLen) - { - UPDATE_0(probLen) - probLen = prob + LenLow + GET_LEN_STATE; - len = 1; - TREE_GET_BIT(probLen, len) - TREE_GET_BIT(probLen, len) - TREE_GET_BIT(probLen, len) - len -= 8; - } - else - { - UPDATE_1(probLen) - probLen = prob + LenChoice2; - IF_BIT_0(probLen) - { - UPDATE_0(probLen) - probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits); - len = 1; - TREE_GET_BIT(probLen, len) - TREE_GET_BIT(probLen, len) - TREE_GET_BIT(probLen, len) - } - else - { - UPDATE_1(probLen) - probLen = prob + LenHigh; - TREE_DECODE(probLen, (1 << kLenNumHighBits), len) - len += kLenNumLowSymbols * 2; - } - } - } - #endif if (state >= kNumStates) { UInt32 distance; prob = probs + PosSlot + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); - TREE_6_DECODE(prob, distance) + TREE_6_DECODE(prob, distance); if (distance >= kStartPosModelIndex) { unsigned posSlot = (unsigned)distance; - unsigned numDirectBits = (unsigned)(((distance >> 1) - 1)); + int numDirectBits = (int)(((distance >> 1) - 1)); distance = (2 | (distance & 1)); if (posSlot < kEndPosModelIndex) { distance <<= numDirectBits; - prob = probs + SpecPos; + prob = probs + SpecPos + distance - posSlot - 1; { - UInt32 m = 1; - distance++; + UInt32 mask = 1; + unsigned i = 1; do { - REV_BIT_VAR(prob, distance, m) + GET_BIT2(prob + i, i, ; , distance |= mask); + mask <<= 1; } - while (--numDirectBits); - distance -= m; + while (--numDirectBits != 0); } } else @@ -509,70 +348,57 @@ int Z7_FASTCALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit) } */ } - while (--numDirectBits); + while (--numDirectBits != 0); prob = probs + Align; distance <<= kNumAlignBits; { unsigned i = 1; - REV_BIT_CONST(prob, i, 1) - REV_BIT_CONST(prob, i, 2) - REV_BIT_CONST(prob, i, 4) - REV_BIT_LAST (prob, i, 8) - distance |= i; + GET_BIT2(prob + i, i, ; , distance |= 1); + GET_BIT2(prob + i, i, ; , distance |= 2); + GET_BIT2(prob + i, i, ; , distance |= 4); + GET_BIT2(prob + i, i, ; , distance |= 8); } if (distance == (UInt32)0xFFFFFFFF) { - len = kMatchSpecLenStart; + len += kMatchSpecLenStart; state -= kNumStates; break; } } } - rep3 = rep2; rep2 = rep1; rep1 = rep0; rep0 = distance + 1; - state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; - if (distance >= (checkDicSize == 0 ? processedPos: checkDicSize)) + if (checkDicSize == 0) { - len += kMatchSpecLen_Error_Data + kMatchMinLen; - // len = kMatchSpecLen_Error_Data; - // len += kMatchMinLen; - break; + if (distance >= processedPos) + return SZ_ERROR_DATA; } + else if (distance >= checkDicSize) + return SZ_ERROR_DATA; + state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; + /* state = kLiteralNextStates[state]; */ } len += kMatchMinLen; + if (limit == dicPos) + return SZ_ERROR_DATA; { - SizeT rem; - unsigned curLen; - SizeT pos; - - if ((rem = limit - dicPos) == 0) - { - /* - We stop decoding and return SZ_OK, and we can resume decoding later. - Any error conditions can be tested later in caller code. - For more strict mode we can stop decoding with error - // len += kMatchSpecLen_Error_Data; - */ - break; - } - - curLen = ((rem < len) ? (unsigned)rem : len); - pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0); + SizeT rem = limit - dicPos; + unsigned curLen = ((rem < len) ? (unsigned)rem : len); + SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0); - processedPos += (UInt32)curLen; + processedPos += curLen; len -= curLen; - if (curLen <= dicBufSize - pos) + if (pos + curLen <= dicBufSize) { Byte *dest = dic + dicPos; ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; const Byte *lim = dest + curLen; - dicPos += (SizeT)curLen; + dicPos += curLen; do *(dest) = (Byte)*(dest + src); while (++dest != lim); @@ -591,153 +417,108 @@ int Z7_FASTCALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit) } } while (dicPos < limit && buf < bufLimit); - - NORMALIZE - + NORMALIZE; p->buf = buf; p->range = range; p->code = code; - p->remainLen = (UInt32)len; // & (kMatchSpecLen_Error_Data - 1); // we can write real length for error matches too. + p->remainLen = len; p->dicPos = dicPos; p->processedPos = processedPos; p->reps[0] = rep0; p->reps[1] = rep1; p->reps[2] = rep2; p->reps[3] = rep3; - p->state = (UInt32)state; - if (len >= kMatchSpecLen_Error_Data) - return SZ_ERROR_DATA; + p->state = state; + return SZ_OK; } -#endif - - -static void Z7_FASTCALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) +static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) { - unsigned len = (unsigned)p->remainLen; - if (len == 0 /* || len >= kMatchSpecLenStart */) - return; + if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart) { + Byte *dic = p->dic; SizeT dicPos = p->dicPos; - Byte *dic; - SizeT dicBufSize; - SizeT rep0; /* we use SizeT to avoid the BUG of VC14 for AMD64 */ - { - SizeT rem = limit - dicPos; - if (rem < len) - { - len = (unsigned)(rem); - if (len == 0) - return; - } - } + SizeT dicBufSize = p->dicBufSize; + unsigned len = p->remainLen; + UInt32 rep0 = p->reps[0]; + if (limit - dicPos < len) + len = (unsigned)(limit - dicPos); if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) p->checkDicSize = p->prop.dicSize; - p->processedPos += (UInt32)len; - p->remainLen -= (UInt32)len; - dic = p->dic; - rep0 = p->reps[0]; - dicBufSize = p->dicBufSize; - do + p->processedPos += len; + p->remainLen -= len; + while (len-- != 0) { - dic[dicPos] = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)]; + dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; dicPos++; } - while (--len); p->dicPos = dicPos; } } - -/* -At staring of new stream we have one of the following symbols: - - Literal - is allowed - - Non-Rep-Match - is allowed only if it's end marker symbol - - Rep-Match - is not allowed -We use early check of (RangeCoder:Code) over kBadRepCode to simplify main decoding code -*/ - -#define kRange0 0xFFFFFFFF -#define kBound0 ((kRange0 >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1)) -#define kBadRepCode (kBound0 + (((kRange0 - kBound0) >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1))) -#if kBadRepCode != (0xC0000000 - 0x400) - #error Stop_Compiling_Bad_LZMA_Check -#endif - - -/* -LzmaDec_DecodeReal2(): - It calls LZMA_DECODE_REAL() and it adjusts limit according (p->checkDicSize). - -We correct (p->checkDicSize) after LZMA_DECODE_REAL() and in LzmaDec_WriteRem(), -and we support the following state of (p->checkDicSize): - if (total_processed < p->prop.dicSize) then - { - (total_processed == p->processedPos) - (p->checkDicSize == 0) - } - else - (p->checkDicSize == p->prop.dicSize) -*/ - -static int Z7_FASTCALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit) +static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit) { - if (p->checkDicSize == 0) + do { - UInt32 rem = p->prop.dicSize - p->processedPos; - if (limit - p->dicPos > rem) - limit = p->dicPos + rem; - } - { - int res = LZMA_DECODE_REAL(p, limit, bufLimit); - if (p->checkDicSize == 0 && p->processedPos >= p->prop.dicSize) + SizeT limit2 = limit; + if (p->checkDicSize == 0) + { + UInt32 rem = p->prop.dicSize - p->processedPos; + if (limit - p->dicPos > rem) + limit2 = p->dicPos + rem; + } + RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit)); + if (p->processedPos >= p->prop.dicSize) p->checkDicSize = p->prop.dicSize; - return res; + LzmaDec_WriteRem(p, limit); } + while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart); + + if (p->remainLen > kMatchSpecLenStart) + { + p->remainLen = kMatchSpecLenStart; + } + return 0; } - - typedef enum { - DUMMY_INPUT_EOF, /* need more input data */ + DUMMY_ERROR, /* unexpected end of input stream */ DUMMY_LIT, DUMMY_MATCH, DUMMY_REP } ELzmaDummy; - -#define IS_DUMMY_END_MARKER_POSSIBLE(dummyRes) ((dummyRes) == DUMMY_MATCH) - -static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, const Byte **bufOut) +static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize) { UInt32 range = p->range; UInt32 code = p->code; - const Byte *bufLimit = *bufOut; - const CLzmaProb *probs = GET_PROBS; - unsigned state = (unsigned)p->state; + const Byte *bufLimit = buf + inSize; + CLzmaProb *probs = p->probs; + unsigned state = p->state; ELzmaDummy res; - for (;;) { - const CLzmaProb *prob; + CLzmaProb *prob; UInt32 bound; unsigned ttt; - unsigned posState = CALC_POS_STATE(p->processedPos, ((unsigned)1 << p->prop.pb) - 1); + unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1); - prob = probs + IsMatch + COMBINED_PS_STATE; + prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; IF_BIT_0_CHECK(prob) { UPDATE_0_CHECK + /* if (bufLimit - buf >= 7) return DUMMY_LIT; */ + prob = probs + Literal; if (p->checkDicSize != 0 || p->processedPos != 0) - prob += ((UInt32)LZMA_LIT_SIZE * - ((((p->processedPos) & (((unsigned)1 << (p->prop.lp)) - 1)) << p->prop.lc) + - ((unsigned)p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); + prob += (LZMA_LIT_SIZE * + ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) + + (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); if (state < kNumLitStates) { @@ -747,18 +528,17 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, const Byt else { unsigned matchByte = p->dic[p->dicPos - p->reps[0] + - (p->dicPos < p->reps[0] ? p->dicBufSize : 0)]; + ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)]; unsigned offs = 0x100; unsigned symbol = 1; do { unsigned bit; - const CLzmaProb *probLit; - matchByte += matchByte; - bit = offs; - offs &= matchByte; - probLit = prob + (offs + bit + symbol); - GET_BIT2_CHECK(probLit, symbol, offs ^= bit; , ; ) + CLzmaProb *probLit; + matchByte <<= 1; + bit = (matchByte & offs); + probLit = prob + offs + bit + symbol; + GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit) } while (symbol < 0x100); } @@ -767,54 +547,55 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, const Byt else { unsigned len; - UPDATE_1_CHECK + UPDATE_1_CHECK; prob = probs + IsRep + state; IF_BIT_0_CHECK(prob) { - UPDATE_0_CHECK + UPDATE_0_CHECK; state = 0; prob = probs + LenCoder; res = DUMMY_MATCH; } else { - UPDATE_1_CHECK + UPDATE_1_CHECK; res = DUMMY_REP; prob = probs + IsRepG0 + state; IF_BIT_0_CHECK(prob) { - UPDATE_0_CHECK - prob = probs + IsRep0Long + COMBINED_PS_STATE; + UPDATE_0_CHECK; + prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; IF_BIT_0_CHECK(prob) { - UPDATE_0_CHECK - break; + UPDATE_0_CHECK; + NORMALIZE_CHECK; + return DUMMY_REP; } else { - UPDATE_1_CHECK + UPDATE_1_CHECK; } } else { - UPDATE_1_CHECK + UPDATE_1_CHECK; prob = probs + IsRepG1 + state; IF_BIT_0_CHECK(prob) { - UPDATE_0_CHECK + UPDATE_0_CHECK; } else { - UPDATE_1_CHECK + UPDATE_1_CHECK; prob = probs + IsRepG2 + state; IF_BIT_0_CHECK(prob) { - UPDATE_0_CHECK + UPDATE_0_CHECK; } else { - UPDATE_1_CHECK + UPDATE_1_CHECK; } } } @@ -823,34 +604,34 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, const Byt } { unsigned limit, offset; - const CLzmaProb *probLen = prob + LenChoice; + CLzmaProb *probLen = prob + LenChoice; IF_BIT_0_CHECK(probLen) { - UPDATE_0_CHECK - probLen = prob + LenLow + GET_LEN_STATE; + UPDATE_0_CHECK; + probLen = prob + LenLow + (posState << kLenNumLowBits); offset = 0; limit = 1 << kLenNumLowBits; } else { - UPDATE_1_CHECK + UPDATE_1_CHECK; probLen = prob + LenChoice2; IF_BIT_0_CHECK(probLen) { - UPDATE_0_CHECK - probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits); + UPDATE_0_CHECK; + probLen = prob + LenMid + (posState << kLenNumMidBits); offset = kLenNumLowSymbols; - limit = 1 << kLenNumLowBits; + limit = 1 << kLenNumMidBits; } else { - UPDATE_1_CHECK + UPDATE_1_CHECK; probLen = prob + LenHigh; - offset = kLenNumLowSymbols * 2; + offset = kLenNumLowSymbols + kLenNumMidSymbols; limit = 1 << kLenNumHighBits; } } - TREE_DECODE_CHECK(probLen, limit, len) + TREE_DECODE_CHECK(probLen, limit, len); len += offset; } @@ -858,16 +639,18 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, const Byt { unsigned posSlot; prob = probs + PosSlot + - ((len < kNumLenToPosStates - 1 ? len : kNumLenToPosStates - 1) << + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); - TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot) + TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot); if (posSlot >= kStartPosModelIndex) { - unsigned numDirectBits = ((posSlot >> 1) - 1); + int numDirectBits = ((posSlot >> 1) - 1); + + /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */ if (posSlot < kEndPosModelIndex) { - prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits); + prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1; } else { @@ -879,44 +662,48 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, const Byt code -= range & (((code - range) >> 31) - 1); /* if (code >= range) code -= range; */ } - while (--numDirectBits); + while (--numDirectBits != 0); prob = probs + Align; numDirectBits = kNumAlignBits; } { unsigned i = 1; - unsigned m = 1; do { - REV_BIT_CHECK(prob, i, m) + GET_BIT_CHECK(prob + i, i); } - while (--numDirectBits); + while (--numDirectBits != 0); } } } } - break; } - NORMALIZE_CHECK - - *bufOut = buf; + NORMALIZE_CHECK; return res; } -void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState); -void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState) + +static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data) { - p->remainLen = kMatchSpecLenStart + 1; + p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]); + p->range = 0xFFFFFFFF; + p->needFlush = 0; +} + +void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState) +{ + p->needFlush = 1; + p->remainLen = 0; p->tempBufSize = 0; if (initDic) { p->processedPos = 0; p->checkDicSize = 0; - p->remainLen = kMatchSpecLenStart + 2; + p->needInitState = 1; } if (initState) - p->remainLen = kMatchSpecLenStart + 2; + p->needInitState = 1; } void LzmaDec_Init(CLzmaDec *p) @@ -925,96 +712,48 @@ void LzmaDec_Init(CLzmaDec *p) LzmaDec_InitDicAndState(p, True, True); } - -/* -LZMA supports optional end_marker. -So the decoder can lookahead for one additional LZMA-Symbol to check end_marker. -That additional LZMA-Symbol can require up to LZMA_REQUIRED_INPUT_MAX bytes in input stream. -When the decoder reaches dicLimit, it looks (finishMode) parameter: - if (finishMode == LZMA_FINISH_ANY), the decoder doesn't lookahead - if (finishMode != LZMA_FINISH_ANY), the decoder lookahead, if end_marker is possible for current position - -When the decoder lookahead, and the lookahead symbol is not end_marker, we have two ways: - 1) Strict mode (default) : the decoder returns SZ_ERROR_DATA. - 2) The relaxed mode (alternative mode) : we could return SZ_OK, and the caller - must check (status) value. The caller can show the error, - if the end of stream is expected, and the (status) is noit - LZMA_STATUS_FINISHED_WITH_MARK or LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK. -*/ - - -#define RETURN_NOT_FINISHED_FOR_FINISH \ - *status = LZMA_STATUS_NOT_FINISHED; \ - return SZ_ERROR_DATA; // for strict mode - // return SZ_OK; // for relaxed mode - +static void LzmaDec_InitStateReal(CLzmaDec *p) +{ + UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); + UInt32 i; + CLzmaProb *probs = p->probs; + for (i = 0; i < numProbs; i++) + probs[i] = kBitModelTotal >> 1; + p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; + p->state = 0; + p->needInitState = 0; +} SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) { SizeT inSize = *srcLen; (*srcLen) = 0; + LzmaDec_WriteRem(p, dicLimit); + *status = LZMA_STATUS_NOT_SPECIFIED; - if (p->remainLen > kMatchSpecLenStart) + while (p->remainLen != kMatchSpecLenStart) { - if (p->remainLen > kMatchSpecLenStart + 2) - return p->remainLen == kMatchSpecLen_Error_Fail ? SZ_ERROR_FAIL : SZ_ERROR_DATA; + int checkEndMarkNow; - for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) - p->tempBuf[p->tempBufSize++] = *src++; - if (p->tempBufSize != 0 && p->tempBuf[0] != 0) - return SZ_ERROR_DATA; - if (p->tempBufSize < RC_INIT_SIZE) - { - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - p->code = - ((UInt32)p->tempBuf[1] << 24) - | ((UInt32)p->tempBuf[2] << 16) - | ((UInt32)p->tempBuf[3] << 8) - | ((UInt32)p->tempBuf[4]); + if (p->needFlush != 0) + { + for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) + p->tempBuf[p->tempBufSize++] = *src++; + if (p->tempBufSize < RC_INIT_SIZE) + { + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + if (p->tempBuf[0] != 0) + return SZ_ERROR_DATA; - if (p->checkDicSize == 0 - && p->processedPos == 0 - && p->code >= kBadRepCode) - return SZ_ERROR_DATA; - - p->range = 0xFFFFFFFF; - p->tempBufSize = 0; - - if (p->remainLen > kMatchSpecLenStart + 1) - { - SizeT numProbs = LzmaProps_GetNumProbs(&p->prop); - SizeT i; - CLzmaProb *probs = p->probs; - for (i = 0; i < numProbs; i++) - probs[i] = kBitModelTotal >> 1; - p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; - p->state = 0; - } - - p->remainLen = 0; - } - - for (;;) - { - if (p->remainLen == kMatchSpecLenStart) - { - if (p->code != 0) - return SZ_ERROR_DATA; - *status = LZMA_STATUS_FINISHED_WITH_MARK; - return SZ_OK; - } - - LzmaDec_WriteRem(p, dicLimit); - - { - // (p->remainLen == 0 || p->dicPos == dicLimit) - - int checkEndMarkNow = 0; + LzmaDec_InitRc(p, p->tempBuf); + p->tempBufSize = 0; + } + checkEndMarkNow = 0; if (p->dicPos >= dicLimit) { if (p->remainLen == 0 && p->code == 0) @@ -1029,174 +768,83 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr } if (p->remainLen != 0) { - RETURN_NOT_FINISHED_FOR_FINISH + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_ERROR_DATA; } checkEndMarkNow = 1; } - // (p->remainLen == 0) - + if (p->needInitState) + LzmaDec_InitStateReal(p); + if (p->tempBufSize == 0) { + SizeT processed; const Byte *bufLimit; - int dummyProcessed = -1; - if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) { - const Byte *bufOut = src + inSize; - - ELzmaDummy dummyRes = LzmaDec_TryDummy(p, src, &bufOut); - - if (dummyRes == DUMMY_INPUT_EOF) + int dummyRes = LzmaDec_TryDummy(p, src, inSize); + if (dummyRes == DUMMY_ERROR) { - size_t i; - if (inSize >= LZMA_REQUIRED_INPUT_MAX) - break; - (*srcLen) += inSize; + memcpy(p->tempBuf, src, inSize); p->tempBufSize = (unsigned)inSize; - for (i = 0; i < inSize; i++) - p->tempBuf[i] = src[i]; + (*srcLen) += inSize; *status = LZMA_STATUS_NEEDS_MORE_INPUT; return SZ_OK; } - - dummyProcessed = (int)(bufOut - src); - if ((unsigned)dummyProcessed > LZMA_REQUIRED_INPUT_MAX) - break; - - if (checkEndMarkNow && !IS_DUMMY_END_MARKER_POSSIBLE(dummyRes)) + if (checkEndMarkNow && dummyRes != DUMMY_MATCH) { - unsigned i; - (*srcLen) += (unsigned)dummyProcessed; - p->tempBufSize = (unsigned)dummyProcessed; - for (i = 0; i < (unsigned)dummyProcessed; i++) - p->tempBuf[i] = src[i]; - // p->remainLen = kMatchSpecLen_Error_Data; - RETURN_NOT_FINISHED_FOR_FINISH + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_ERROR_DATA; } - bufLimit = src; - // we will decode only one iteration } else bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; - p->buf = src; - - { - int res = LzmaDec_DecodeReal2(p, dicLimit, bufLimit); - - SizeT processed = (SizeT)(p->buf - src); - - if (dummyProcessed < 0) - { - if (processed > inSize) - break; - } - else if ((unsigned)dummyProcessed != processed) - break; - - src += processed; - inSize -= processed; - (*srcLen) += processed; - - if (res != SZ_OK) - { - p->remainLen = kMatchSpecLen_Error_Data; - return SZ_ERROR_DATA; - } - } - continue; + if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0) + return SZ_ERROR_DATA; + processed = (SizeT)(p->buf - src); + (*srcLen) += processed; + src += processed; + inSize -= processed; } - + else { - // we have some data in (p->tempBuf) - // in strict mode: tempBufSize is not enough for one Symbol decoding. - // in relaxed mode: tempBufSize not larger than required for one Symbol decoding. - - unsigned rem = p->tempBufSize; - unsigned ahead = 0; - int dummyProcessed = -1; - - while (rem < LZMA_REQUIRED_INPUT_MAX && ahead < inSize) - p->tempBuf[rem++] = src[ahead++]; - - // ahead - the size of new data copied from (src) to (p->tempBuf) - // rem - the size of temp buffer including new data from (src) - + unsigned rem = p->tempBufSize, lookAhead = 0; + while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize) + p->tempBuf[rem++] = src[lookAhead++]; + p->tempBufSize = rem; if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) { - const Byte *bufOut = p->tempBuf + rem; - - ELzmaDummy dummyRes = LzmaDec_TryDummy(p, p->tempBuf, &bufOut); - - if (dummyRes == DUMMY_INPUT_EOF) + int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem); + if (dummyRes == DUMMY_ERROR) { - if (rem >= LZMA_REQUIRED_INPUT_MAX) - break; - p->tempBufSize = rem; - (*srcLen) += (SizeT)ahead; + (*srcLen) += lookAhead; *status = LZMA_STATUS_NEEDS_MORE_INPUT; return SZ_OK; } - - dummyProcessed = (int)(bufOut - p->tempBuf); - - if ((unsigned)dummyProcessed < p->tempBufSize) - break; - - if (checkEndMarkNow && !IS_DUMMY_END_MARKER_POSSIBLE(dummyRes)) + if (checkEndMarkNow && dummyRes != DUMMY_MATCH) { - (*srcLen) += (unsigned)dummyProcessed - p->tempBufSize; - p->tempBufSize = (unsigned)dummyProcessed; - // p->remainLen = kMatchSpecLen_Error_Data; - RETURN_NOT_FINISHED_FOR_FINISH - } - } - - p->buf = p->tempBuf; - - { - // we decode one symbol from (p->tempBuf) here, so the (bufLimit) is equal to (p->buf) - int res = LzmaDec_DecodeReal2(p, dicLimit, p->buf); - - SizeT processed = (SizeT)(p->buf - p->tempBuf); - rem = p->tempBufSize; - - if (dummyProcessed < 0) - { - if (processed > LZMA_REQUIRED_INPUT_MAX) - break; - if (processed < rem) - break; - } - else if ((unsigned)dummyProcessed != processed) - break; - - processed -= rem; - - src += processed; - inSize -= processed; - (*srcLen) += processed; - p->tempBufSize = 0; - - if (res != SZ_OK) - { - p->remainLen = kMatchSpecLen_Error_Data; + *status = LZMA_STATUS_NOT_FINISHED; return SZ_ERROR_DATA; } } + p->buf = p->tempBuf; + if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0) + return SZ_ERROR_DATA; + lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf)); + (*srcLen) += lookAhead; + src += lookAhead; + inSize -= lookAhead; + p->tempBufSize = 0; } - } } - - /* Some unexpected error: internal error of code, memory corruption or hardware failure */ - p->remainLen = kMatchSpecLen_Error_Fail; - return SZ_ERROR_FAIL; + if (p->code == 0) + *status = LZMA_STATUS_FINISHED_WITH_MARK; + return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; } - - SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) { SizeT outSize = *destLen; @@ -1237,19 +885,19 @@ SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *sr } } -void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc) +void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) { - ISzAlloc_Free(alloc, p->probs); - p->probs = NULL; + alloc->Free(alloc, p->probs); + p->probs = 0; } -static void LzmaDec_FreeDict(CLzmaDec *p, ISzAllocPtr alloc) +static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) { - ISzAlloc_Free(alloc, p->dic); - p->dic = NULL; + alloc->Free(alloc, p->dic); + p->dic = 0; } -void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc) +void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) { LzmaDec_FreeProbs(p, alloc); LzmaDec_FreeDict(p, alloc); @@ -1273,60 +921,49 @@ SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) if (d >= (9 * 5 * 5)) return SZ_ERROR_UNSUPPORTED; - p->lc = (Byte)(d % 9); + p->lc = d % 9; d /= 9; - p->pb = (Byte)(d / 5); - p->lp = (Byte)(d % 5); + p->pb = d / 5; + p->lp = d % 5; return SZ_OK; } -static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAllocPtr alloc) +static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc) { UInt32 numProbs = LzmaProps_GetNumProbs(propNew); - if (!p->probs || numProbs != p->numProbs) + if (p->probs == 0 || numProbs != p->numProbs) { LzmaDec_FreeProbs(p, alloc); - p->probs = (CLzmaProb *)ISzAlloc_Alloc(alloc, numProbs * sizeof(CLzmaProb)); - if (!p->probs) - return SZ_ERROR_MEM; - p->probs_1664 = p->probs + 1664; + p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb)); p->numProbs = numProbs; + if (p->probs == 0) + return SZ_ERROR_MEM; } return SZ_OK; } -SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc) +SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) { CLzmaProps propNew; - RINOK(LzmaProps_Decode(&propNew, props, propsSize)) - RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)) + RINOK(LzmaProps_Decode(&propNew, props, propsSize)); + RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); p->prop = propNew; return SZ_OK; } -SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc) +SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) { CLzmaProps propNew; SizeT dicBufSize; - RINOK(LzmaProps_Decode(&propNew, props, propsSize)) - RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)) - - { - UInt32 dictSize = propNew.dicSize; - SizeT mask = ((UInt32)1 << 12) - 1; - if (dictSize >= ((UInt32)1 << 30)) mask = ((UInt32)1 << 22) - 1; - else if (dictSize >= ((UInt32)1 << 22)) mask = ((UInt32)1 << 20) - 1; - dicBufSize = ((SizeT)dictSize + mask) & ~mask; - if (dicBufSize < dictSize) - dicBufSize = dictSize; - } - - if (!p->dic || dicBufSize != p->dicBufSize) + RINOK(LzmaProps_Decode(&propNew, props, propsSize)); + RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); + dicBufSize = propNew.dicSize; + if (p->dic == 0 || dicBufSize != p->dicBufSize) { LzmaDec_FreeDict(p, alloc); - p->dic = (Byte *)ISzAlloc_Alloc(alloc, dicBufSize); - if (!p->dic) + p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize); + if (p->dic == 0) { LzmaDec_FreeProbs(p, alloc); return SZ_ERROR_MEM; @@ -1339,25 +976,32 @@ SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAll SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, - ELzmaStatus *status, ISzAllocPtr alloc) + ELzmaStatus *status, ISzAlloc *alloc) { CLzmaDec p; SRes res; - SizeT outSize = *destLen, inSize = *srcLen; - *destLen = *srcLen = 0; - *status = LZMA_STATUS_NOT_SPECIFIED; + SizeT inSize = *srcLen; + SizeT outSize = *destLen; + *srcLen = *destLen = 0; if (inSize < RC_INIT_SIZE) return SZ_ERROR_INPUT_EOF; - LzmaDec_CONSTRUCT(&p) - RINOK(LzmaDec_AllocateProbs(&p, propData, propSize, alloc)) + + LzmaDec_Construct(&p); + res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc); + if (res != 0) + return res; p.dic = dest; p.dicBufSize = outSize; + LzmaDec_Init(&p); + *srcLen = inSize; res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); - *destLen = p.dicPos; + if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) res = SZ_ERROR_INPUT_EOF; + + (*destLen) = p.dicPos; LzmaDec_FreeProbs(&p, alloc); return res; } diff --git a/extern/lzma/LzmaDec.h b/extern/lzma/LzmaDec.h index b0ce28fa02a..98cdbe94949 100644 --- a/extern/lzma/LzmaDec.h +++ b/extern/lzma/LzmaDec.h @@ -1,36 +1,29 @@ /* LzmaDec.h -- LZMA Decoder -2023-04-02 : Igor Pavlov : Public domain */ +2008-10-04 : Igor Pavlov : Public domain */ -#ifndef ZIP7_INC_LZMA_DEC_H -#define ZIP7_INC_LZMA_DEC_H +#ifndef __LZMADEC_H +#define __LZMADEC_H -#include "7zTypes.h" +#include "Types.h" -EXTERN_C_BEGIN - -/* #define Z7_LZMA_PROB32 */ -/* Z7_LZMA_PROB32 can increase the speed on some CPUs, +/* #define _LZMA_PROB32 */ +/* _LZMA_PROB32 can increase the speed on some CPUs, but memory usage for CLzmaDec::probs will be doubled in that case */ -typedef -#ifdef Z7_LZMA_PROB32 - UInt32 +#ifdef _LZMA_PROB32 +#define CLzmaProb UInt32 #else - UInt16 +#define CLzmaProb UInt16 #endif - CLzmaProb; /* ---------- LZMA Properties ---------- */ #define LZMA_PROPS_SIZE 5 -typedef struct +typedef struct _CLzmaProps { - Byte lc; - Byte lp; - Byte pb; - Byte _pad_; + unsigned lc, lp, pb; UInt32 dicSize; } CLzmaProps; @@ -52,35 +45,32 @@ SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size); typedef struct { - /* Don't change this structure. ASM code can use it. */ CLzmaProps prop; CLzmaProb *probs; - CLzmaProb *probs_1664; Byte *dic; - SizeT dicBufSize; - SizeT dicPos; const Byte *buf; - UInt32 range; - UInt32 code; + UInt32 range, code; + SizeT dicPos; + SizeT dicBufSize; UInt32 processedPos; UInt32 checkDicSize; + unsigned state; UInt32 reps[4]; - UInt32 state; - UInt32 remainLen; - + unsigned remainLen; + int needFlush; + int needInitState; UInt32 numProbs; unsigned tempBufSize; Byte tempBuf[LZMA_REQUIRED_INPUT_MAX]; } CLzmaDec; -#define LzmaDec_CONSTRUCT(p) { (p)->dic = NULL; (p)->probs = NULL; } -#define LzmaDec_Construct(p) LzmaDec_CONSTRUCT(p) +#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; } void LzmaDec_Init(CLzmaDec *p); /* There are two types of LZMA streams: - - Stream with end mark. That end mark adds about 6 bytes to compressed size. - - Stream without end mark. You must know exact uncompressed size to decompress such stream. */ + 0) Stream with end mark. That end mark adds about 6 bytes to compressed size. + 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */ typedef enum { @@ -137,11 +127,11 @@ LzmaDec_Allocate* can return: SZ_ERROR_UNSUPPORTED - Unsupported properties */ -SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc); -void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc); +SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc); +void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc); -SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc); -void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc); +SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc); +void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc); /* ---------- Dictionary Interface ---------- */ @@ -150,7 +140,7 @@ void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc); You must work with CLzmaDec variables directly in this interface. STEPS: - LzmaDec_Construct() + LzmaDec_Constr() LzmaDec_Allocate() for (each new stream) { @@ -182,7 +172,6 @@ Returns: LZMA_STATUS_NEEDS_MORE_INPUT LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK SZ_ERROR_DATA - Data error - SZ_ERROR_FAIL - Some unexpected error: internal error of code, memory corruption or hardware failure */ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, @@ -225,13 +214,10 @@ Returns: SZ_ERROR_MEM - Memory allocation error SZ_ERROR_UNSUPPORTED - Unsupported properties SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). - SZ_ERROR_FAIL - Some unexpected error: internal error of code, memory corruption or hardware failure */ SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, - ELzmaStatus *status, ISzAllocPtr alloc); - -EXTERN_C_END + ELzmaStatus *status, ISzAlloc *alloc); #endif diff --git a/extern/lzma/LzmaEnc.c b/extern/lzma/LzmaEnc.c index 6d13cac8ce2..8c5636fc89e 100644 --- a/extern/lzma/LzmaEnc.c +++ b/extern/lzma/LzmaEnc.c @@ -1,7 +1,5 @@ /* LzmaEnc.c -- LZMA Encoder -2023-04-13: Igor Pavlov : Public domain */ - -#include "Precomp.h" +2009-02-02 : Igor Pavlov : Public domain */ #include @@ -12,36 +10,28 @@ #include #endif -#include "CpuArch.h" #include "LzmaEnc.h" #include "LzFind.h" -#ifndef Z7_ST +#ifdef COMPRESS_MF_MT #include "LzFindMt.h" #endif -/* the following LzmaEnc_* declarations is internal LZMA interface for LZMA2 encoder */ - -SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle p, ISeqInStreamPtr inStream, UInt32 keepWindowSize, - ISzAllocPtr alloc, ISzAllocPtr allocBig); -SRes LzmaEnc_MemPrepare(CLzmaEncHandle p, const Byte *src, SizeT srcLen, - UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig); -SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle p, BoolInt reInit, - Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize); -const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle p); -void LzmaEnc_Finish(CLzmaEncHandle p); -void LzmaEnc_SaveState(CLzmaEncHandle p); -void LzmaEnc_RestoreState(CLzmaEncHandle p); - #ifdef SHOW_STAT -static unsigned g_STAT_OFFSET = 0; +static int ttt = 0; #endif -/* for good normalization speed we still reserve 256 MB before 4 GB range */ -#define kLzmaMaxHistorySize ((UInt32)15 << 28) +#define kBlockSizeMax ((1 << LZMA_NUM_BLOCK_SIZE_BITS) - 1) -// #define kNumTopBits 24 -#define kTopValue ((UInt32)1 << 24) +#define kBlockSize (9 << 10) +#define kUnpackBlockSize (1 << 18) +#define kMatchArraySize (1 << 21) +#define kMatchRecordMaxSize ((LZMA_MATCH_LEN_MAX * 2 + 3) * LZMA_MATCH_LEN_MAX) + +#define kNumMaxDirectBits (31) + +#define kNumTopBits 24 +#define kTopValue ((UInt32)1 << kNumTopBits) #define kNumBitModelTotalBits 11 #define kBitModelTotal (1 << kNumBitModelTotalBits) @@ -50,19 +40,14 @@ static unsigned g_STAT_OFFSET = 0; #define kNumMoveReducingBits 4 #define kNumBitPriceShiftBits 4 -// #define kBitPrice (1 << kNumBitPriceShiftBits) - -#define REP_LEN_COUNT 64 +#define kBitPrice (1 << kNumBitPriceShiftBits) void LzmaEncProps_Init(CLzmaEncProps *p) { p->level = 5; p->dictSize = p->mc = 0; - p->reduceSize = (UInt64)(Int64)-1; p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1; - p->numHashOutBits = 0; p->writeEndMark = 0; - p->affinity = 0; } void LzmaEncProps_Normalize(CLzmaEncProps *p) @@ -70,37 +55,18 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p) int level = p->level; if (level < 0) level = 5; p->level = level; - - if (p->dictSize == 0) - p->dictSize = - ( level <= 3 ? ((UInt32)1 << (level * 2 + 16)) : - ( level <= 6 ? ((UInt32)1 << (level + 19)) : - ( level <= 7 ? ((UInt32)1 << 25) : ((UInt32)1 << 26) - ))); - - if (p->dictSize > p->reduceSize) - { - UInt32 v = (UInt32)p->reduceSize; - const UInt32 kReduceMin = ((UInt32)1 << 12); - if (v < kReduceMin) - v = kReduceMin; - if (p->dictSize > v) - p->dictSize = v; - } - + if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26))); if (p->lc < 0) p->lc = 3; if (p->lp < 0) p->lp = 0; if (p->pb < 0) p->pb = 2; - if (p->algo < 0) p->algo = (level < 5 ? 0 : 1); if (p->fb < 0) p->fb = (level < 7 ? 32 : 64); if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1); - if (p->numHashBytes < 0) p->numHashBytes = (p->btMode ? 4 : 5); - if (p->mc == 0) p->mc = (16 + ((unsigned)p->fb >> 1)) >> (p->btMode ? 0 : 1); - + if (p->numHashBytes < 0) p->numHashBytes = 4; + if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1); if (p->numThreads < 0) p->numThreads = - #ifndef Z7_ST + #ifdef COMPRESS_MF_MT ((p->btMode && p->algo) ? 2 : 1); #else 1; @@ -114,133 +80,48 @@ UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2) return props.dictSize; } +/* #define LZMA_LOG_BSR */ +/* Define it for Intel's CPU */ -/* -x86/x64: - -BSR: - IF (SRC == 0) ZF = 1, DEST is undefined; - AMD : DEST is unchanged; - IF (SRC != 0) ZF = 0; DEST is index of top non-zero bit - BSR is slow in some processors - -LZCNT: - IF (SRC == 0) CF = 1, DEST is size_in_bits_of_register(src) (32 or 64) - IF (SRC != 0) CF = 0, DEST = num_lead_zero_bits - IF (DEST == 0) ZF = 1; - -LZCNT works only in new processors starting from Haswell. -if LZCNT is not supported by processor, then it's executed as BSR. -LZCNT can be faster than BSR, if supported. -*/ - -// #define LZMA_LOG_BSR - -#if defined(MY_CPU_ARM_OR_ARM64) /* || defined(MY_CPU_X86_OR_AMD64) */ - - #if (defined(__clang__) && (__clang_major__ >= 6)) \ - || (defined(__GNUC__) && (__GNUC__ >= 6)) - #define LZMA_LOG_BSR - #elif defined(_MSC_VER) && (_MSC_VER >= 1300) - // #if defined(MY_CPU_ARM_OR_ARM64) - #define LZMA_LOG_BSR - // #endif - #endif -#endif - -// #include #ifdef LZMA_LOG_BSR -#if defined(__clang__) \ - || defined(__GNUC__) +#define kDicLogSizeMaxCompress 30 -/* - C code: : (30 - __builtin_clz(x)) - gcc9/gcc10 for x64 /x86 : 30 - (bsr(x) xor 31) - clang10 for x64 : 31 + (bsr(x) xor -32) -*/ +#define BSR2_RET(pos, res) { unsigned long i; _BitScanReverse(&i, (pos)); res = (i + i) + ((pos >> (i - 1)) & 1); } - #define MY_clz(x) ((unsigned)__builtin_clz(x)) - // __lzcnt32 - // __builtin_ia32_lzcnt_u32 - -#else // #if defined(_MSC_VER) - - #ifdef MY_CPU_ARM_OR_ARM64 - - #define MY_clz _CountLeadingZeros - - #else // if defined(MY_CPU_X86_OR_AMD64) - - // #define MY_clz __lzcnt // we can use lzcnt (unsupported by old CPU) - // _BitScanReverse code is not optimal for some MSVC compilers - #define BSR2_RET(pos, res) { unsigned long zz; _BitScanReverse(&zz, (pos)); zz--; \ - res = (zz + zz) + (pos >> zz); } - - #endif // MY_CPU_X86_OR_AMD64 - -#endif // _MSC_VER - - -#ifndef BSR2_RET - - #define BSR2_RET(pos, res) { unsigned zz = 30 - MY_clz(pos); \ - res = (zz + zz) + (pos >> zz); } - -#endif - - -unsigned GetPosSlot1(UInt32 pos); -unsigned GetPosSlot1(UInt32 pos) +UInt32 GetPosSlot1(UInt32 pos) { - unsigned res; + UInt32 res; BSR2_RET(pos, res); return res; } #define GetPosSlot2(pos, res) { BSR2_RET(pos, res); } #define GetPosSlot(pos, res) { if (pos < 2) res = pos; else BSR2_RET(pos, res); } +#else -#else // ! LZMA_LOG_BSR - -#define kNumLogBits (11 + sizeof(size_t) / 8 * 3) - +#define kNumLogBits (9 + (int)sizeof(size_t) / 2) #define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7) -static void LzmaEnc_FastPosInit(Byte *g_FastPos) +void LzmaEnc_FastPosInit(Byte *g_FastPos) { - unsigned slot; + int c = 2, slotFast; g_FastPos[0] = 0; g_FastPos[1] = 1; - g_FastPos += 2; - for (slot = 2; slot < kNumLogBits * 2; slot++) + for (slotFast = 2; slotFast < kNumLogBits * 2; slotFast++) { - size_t k = ((size_t)1 << ((slot >> 1) - 1)); - size_t j; - for (j = 0; j < k; j++) - g_FastPos[j] = (Byte)slot; - g_FastPos += k; + UInt32 k = (1 << ((slotFast >> 1) - 1)); + UInt32 j; + for (j = 0; j < k; j++, c++) + g_FastPos[c] = (Byte)slotFast; } } -/* we can use ((limit - pos) >> 31) only if (pos < ((UInt32)1 << 31)) */ -/* -#define BSR2_RET(pos, res) { unsigned zz = 6 + ((kNumLogBits - 1) & \ +#define BSR2_RET(pos, res) { UInt32 i = 6 + ((kNumLogBits - 1) & \ (0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \ - res = p->g_FastPos[pos >> zz] + (zz * 2); } -*/ - -/* -#define BSR2_RET(pos, res) { unsigned zz = 6 + ((kNumLogBits - 1) & \ - (0 - (((((UInt32)1 << (kNumLogBits)) - 1) - (pos >> 6)) >> 31))); \ - res = p->g_FastPos[pos >> zz] + (zz * 2); } -*/ - -#define BSR2_RET(pos, res) { unsigned zz = (pos < (1 << (kNumLogBits + 6))) ? 6 : 6 + kNumLogBits - 1; \ - res = p->g_FastPos[pos >> zz] + (zz * 2); } - + res = p->g_FastPos[pos >> i] + (i * 2); } /* #define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \ p->g_FastPos[pos >> 6] + 12 : \ @@ -249,57 +130,55 @@ static void LzmaEnc_FastPosInit(Byte *g_FastPos) #define GetPosSlot1(pos) p->g_FastPos[pos] #define GetPosSlot2(pos, res) { BSR2_RET(pos, res); } -#define GetPosSlot(pos, res) { if (pos < kNumFullDistances) res = p->g_FastPos[pos & (kNumFullDistances - 1)]; else BSR2_RET(pos, res); } +#define GetPosSlot(pos, res) { if (pos < kNumFullDistances) res = p->g_FastPos[pos]; else BSR2_RET(pos, res); } -#endif // LZMA_LOG_BSR +#endif #define LZMA_NUM_REPS 4 -typedef UInt16 CState; -typedef UInt16 CExtra; +typedef unsigned CState; -typedef struct +typedef struct _COptimal { UInt32 price; + CState state; - CExtra extra; - // 0 : normal - // 1 : LIT : MATCH - // > 1 : MATCH (extra-1) : LIT : REP0 (len) - UInt32 len; - UInt32 dist; - UInt32 reps[LZMA_NUM_REPS]; + int prev1IsChar; + int prev2; + + UInt32 posPrev2; + UInt32 backPrev2; + + UInt32 posPrev; + UInt32 backPrev; + UInt32 backs[LZMA_NUM_REPS]; } COptimal; - -// 18.06 -#define kNumOpts (1 << 11) -#define kPackReserve (kNumOpts * 8) -// #define kNumOpts (1 << 12) -// #define kPackReserve (1 + kNumOpts * 2) +#define kNumOpts (1 << 12) #define kNumLenToPosStates 4 #define kNumPosSlotBits 6 -// #define kDicLogSizeMin 0 +#define kDicLogSizeMin 0 #define kDicLogSizeMax 32 #define kDistTableSizeMax (kDicLogSizeMax * 2) + #define kNumAlignBits 4 #define kAlignTableSize (1 << kNumAlignBits) #define kAlignMask (kAlignTableSize - 1) #define kStartPosModelIndex 4 #define kEndPosModelIndex 14 -#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) +#define kNumPosModels (kEndPosModelIndex - kStartPosModelIndex) -typedef -#ifdef Z7_LZMA_PROB32 - UInt32 +#define kNumFullDistances (1 << (kEndPosModelIndex / 2)) + +#ifdef _LZMA_PROB32 +#define CLzmaProb UInt32 #else - UInt16 +#define CLzmaProb UInt16 #endif - CLzmaProb; #define LZMA_PB_MAX 4 #define LZMA_LC_MAX 8 @@ -307,287 +186,270 @@ typedef #define LZMA_NUM_PB_STATES_MAX (1 << LZMA_PB_MAX) + #define kLenNumLowBits 3 #define kLenNumLowSymbols (1 << kLenNumLowBits) +#define kLenNumMidBits 3 +#define kLenNumMidSymbols (1 << kLenNumMidBits) #define kLenNumHighBits 8 #define kLenNumHighSymbols (1 << kLenNumHighBits) -#define kLenNumSymbolsTotal (kLenNumLowSymbols * 2 + kLenNumHighSymbols) + +#define kLenNumSymbolsTotal (kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) #define LZMA_MATCH_LEN_MIN 2 #define LZMA_MATCH_LEN_MAX (LZMA_MATCH_LEN_MIN + kLenNumSymbolsTotal - 1) #define kNumStates 12 - typedef struct { - CLzmaProb low[LZMA_NUM_PB_STATES_MAX << (kLenNumLowBits + 1)]; + CLzmaProb choice; + CLzmaProb choice2; + CLzmaProb low[LZMA_NUM_PB_STATES_MAX << kLenNumLowBits]; + CLzmaProb mid[LZMA_NUM_PB_STATES_MAX << kLenNumMidBits]; CLzmaProb high[kLenNumHighSymbols]; } CLenEnc; - typedef struct { - unsigned tableSize; + CLenEnc p; UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal]; - // UInt32 prices1[LZMA_NUM_PB_STATES_MAX][kLenNumLowSymbols * 2]; - // UInt32 prices2[kLenNumSymbolsTotal]; + UInt32 tableSize; + UInt32 counters[LZMA_NUM_PB_STATES_MAX]; } CLenPriceEnc; -#define GET_PRICE_LEN(p, posState, len) \ - ((p)->prices[posState][(size_t)(len) - LZMA_MATCH_LEN_MIN]) - -/* -#define GET_PRICE_LEN(p, posState, len) \ - ((p)->prices2[(size_t)(len) - 2] + ((p)->prices1[posState][((len) - 2) & (kLenNumLowSymbols * 2 - 1)] & (((len) - 2 - kLenNumLowSymbols * 2) >> 9))) -*/ - -typedef struct +typedef struct _CRangeEnc { UInt32 range; - unsigned cache; + Byte cache; UInt64 low; UInt64 cacheSize; Byte *buf; Byte *bufLim; Byte *bufBase; - ISeqOutStreamPtr outStream; + ISeqOutStream *outStream; UInt64 processed; SRes res; } CRangeEnc; +typedef struct _CSeqInStreamBuf +{ + ISeqInStream funcTable; + const Byte *data; + SizeT rem; +} CSeqInStreamBuf; + +static SRes MyRead(void *pp, void *data, size_t *size) +{ + size_t curSize = *size; + CSeqInStreamBuf *p = (CSeqInStreamBuf *)pp; + if (p->rem < curSize) + curSize = p->rem; + memcpy(data, p->data, curSize); + p->rem -= curSize; + p->data += curSize; + *size = curSize; + return SZ_OK; +} typedef struct { CLzmaProb *litProbs; - unsigned state; - UInt32 reps[LZMA_NUM_REPS]; - - CLzmaProb posAlignEncoder[1 << kNumAlignBits]; + CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX]; CLzmaProb isRep[kNumStates]; CLzmaProb isRepG0[kNumStates]; CLzmaProb isRepG1[kNumStates]; CLzmaProb isRepG2[kNumStates]; - CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX]; CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX]; CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; - CLzmaProb posEncoders[kNumFullDistances]; + CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; + CLzmaProb posAlignEncoder[1 << kNumAlignBits]; - CLenEnc lenProbs; - CLenEnc repLenProbs; + CLenPriceEnc lenEnc; + CLenPriceEnc repLenEnc; + UInt32 reps[LZMA_NUM_REPS]; + UInt32 state; } CSaveState; - -typedef UInt32 CProbPrice; - - -struct CLzmaEnc +typedef struct _CLzmaEnc { + IMatchFinder matchFinder; void *matchFinderObj; - IMatchFinder2 matchFinder; - unsigned optCur; - unsigned optEnd; - - unsigned longestMatchLen; - unsigned numPairs; - UInt32 numAvail; - - unsigned state; - unsigned numFastBytes; - unsigned additionalOffset; - UInt32 reps[LZMA_NUM_REPS]; - unsigned lpMask, pbMask; - CLzmaProb *litProbs; - CRangeEnc rc; - - UInt32 backRes; - - unsigned lc, lp, pb; - unsigned lclp; - - BoolInt fastMode; - BoolInt writeEndMark; - BoolInt finished; - BoolInt multiThread; - BoolInt needInit; - // BoolInt _maxMode; - - UInt64 nowPos64; - - unsigned matchPriceCount; - // unsigned alignPriceCount; - int repLenEncCounter; - - unsigned distTableSize; - - UInt32 dictSize; - SRes result; - - #ifndef Z7_ST - BoolInt mtMode; - // begin of CMatchFinderMt is used in LZ thread + #ifdef COMPRESS_MF_MT + Bool mtMode; CMatchFinderMt matchFinderMt; - // end of CMatchFinderMt is used in BT and HASH threads - // #else - // CMatchFinder matchFinderBase; #endif + CMatchFinder matchFinderBase; - - // we suppose that we have 8-bytes alignment after CMatchFinder - - #ifndef Z7_ST + #ifdef COMPRESS_MF_MT Byte pad[128]; #endif - // LZ thread - CProbPrice ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; + UInt32 optimumEndIndex; + UInt32 optimumCurrentIndex; - // we want {len , dist} pairs to be 8-bytes aligned in matches array - UInt32 matches[LZMA_MATCH_LEN_MAX * 2 + 2]; - - // we want 8-bytes alignment here - UInt32 alignPrices[kAlignTableSize]; - UInt32 posSlotPrices[kNumLenToPosStates][kDistTableSizeMax]; - UInt32 distancesPrices[kNumLenToPosStates][kNumFullDistances]; - - CLzmaProb posAlignEncoder[1 << kNumAlignBits]; - CLzmaProb isRep[kNumStates]; - CLzmaProb isRepG0[kNumStates]; - CLzmaProb isRepG1[kNumStates]; - CLzmaProb isRepG2[kNumStates]; - CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX]; - CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX]; - CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; - CLzmaProb posEncoders[kNumFullDistances]; + UInt32 longestMatchLength; + UInt32 numPairs; + UInt32 numAvail; + COptimal opt[kNumOpts]; - CLenEnc lenProbs; - CLenEnc repLenProbs; - #ifndef LZMA_LOG_BSR Byte g_FastPos[1 << kNumLogBits]; #endif + UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; + UInt32 matches[LZMA_MATCH_LEN_MAX * 2 + 2 + 1]; + UInt32 numFastBytes; + UInt32 additionalOffset; + UInt32 reps[LZMA_NUM_REPS]; + UInt32 state; + + UInt32 posSlotPrices[kNumLenToPosStates][kDistTableSizeMax]; + UInt32 distancesPrices[kNumLenToPosStates][kNumFullDistances]; + UInt32 alignPrices[kAlignTableSize]; + UInt32 alignPriceCount; + + UInt32 distTableSize; + + unsigned lc, lp, pb; + unsigned lpMask, pbMask; + + CLzmaProb *litProbs; + + CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX]; + CLzmaProb isRep[kNumStates]; + CLzmaProb isRepG0[kNumStates]; + CLzmaProb isRepG1[kNumStates]; + CLzmaProb isRepG2[kNumStates]; + CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX]; + + CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; + CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; + CLzmaProb posAlignEncoder[1 << kNumAlignBits]; + CLenPriceEnc lenEnc; CLenPriceEnc repLenEnc; - COptimal opt[kNumOpts]; + unsigned lclp; + + Bool fastMode; + + CRangeEnc rc; + + Bool writeEndMark; + UInt64 nowPos64; + UInt32 matchPriceCount; + Bool finished; + Bool multiThread; + + SRes result; + UInt32 dictSize; + UInt32 matchFinderCycles; + + ISeqInStream *inStream; + CSeqInStreamBuf seqBufInStream; CSaveState saveState; +} CLzmaEnc; - // BoolInt mf_Failure; - #ifndef Z7_ST - Byte pad2[128]; - #endif -}; - - -#define MFB (p->matchFinderBase) -/* -#ifndef Z7_ST -#define MFB (p->matchFinderMt.MatchFinder) -#endif -*/ - -// #define GET_CLzmaEnc_p CLzmaEnc *p = (CLzmaEnc*)(void *)p; -// #define GET_const_CLzmaEnc_p const CLzmaEnc *p = (const CLzmaEnc*)(const void *)p; - -#define COPY_ARR(dest, src, arr) memcpy((dest)->arr, (src)->arr, sizeof((src)->arr)); - -#define COPY_LZMA_ENC_STATE(d, s, p) \ - (d)->state = (s)->state; \ - COPY_ARR(d, s, reps) \ - COPY_ARR(d, s, posAlignEncoder) \ - COPY_ARR(d, s, isRep) \ - COPY_ARR(d, s, isRepG0) \ - COPY_ARR(d, s, isRepG1) \ - COPY_ARR(d, s, isRepG2) \ - COPY_ARR(d, s, isMatch) \ - COPY_ARR(d, s, isRep0Long) \ - COPY_ARR(d, s, posSlotEncoder) \ - COPY_ARR(d, s, posEncoders) \ - (d)->lenProbs = (s)->lenProbs; \ - (d)->repLenProbs = (s)->repLenProbs; \ - memcpy((d)->litProbs, (s)->litProbs, ((UInt32)0x300 << (p)->lclp) * sizeof(CLzmaProb)); - -void LzmaEnc_SaveState(CLzmaEncHandle p) +void LzmaEnc_SaveState(CLzmaEncHandle pp) { - // GET_CLzmaEnc_p - CSaveState *v = &p->saveState; - COPY_LZMA_ENC_STATE(v, p, p) + CLzmaEnc *p = (CLzmaEnc *)pp; + CSaveState *dest = &p->saveState; + int i; + dest->lenEnc = p->lenEnc; + dest->repLenEnc = p->repLenEnc; + dest->state = p->state; + + for (i = 0; i < kNumStates; i++) + { + memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i])); + memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i])); + } + for (i = 0; i < kNumLenToPosStates; i++) + memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i])); + memcpy(dest->isRep, p->isRep, sizeof(p->isRep)); + memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0)); + memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1)); + memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2)); + memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders)); + memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder)); + memcpy(dest->reps, p->reps, sizeof(p->reps)); + memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb)); } -void LzmaEnc_RestoreState(CLzmaEncHandle p) +void LzmaEnc_RestoreState(CLzmaEncHandle pp) { - // GET_CLzmaEnc_p - const CSaveState *v = &p->saveState; - COPY_LZMA_ENC_STATE(p, v, p) + CLzmaEnc *dest = (CLzmaEnc *)pp; + const CSaveState *p = &dest->saveState; + int i; + dest->lenEnc = p->lenEnc; + dest->repLenEnc = p->repLenEnc; + dest->state = p->state; + + for (i = 0; i < kNumStates; i++) + { + memcpy(dest->isMatch[i], p->isMatch[i], sizeof(p->isMatch[i])); + memcpy(dest->isRep0Long[i], p->isRep0Long[i], sizeof(p->isRep0Long[i])); + } + for (i = 0; i < kNumLenToPosStates; i++) + memcpy(dest->posSlotEncoder[i], p->posSlotEncoder[i], sizeof(p->posSlotEncoder[i])); + memcpy(dest->isRep, p->isRep, sizeof(p->isRep)); + memcpy(dest->isRepG0, p->isRepG0, sizeof(p->isRepG0)); + memcpy(dest->isRepG1, p->isRepG1, sizeof(p->isRepG1)); + memcpy(dest->isRepG2, p->isRepG2, sizeof(p->isRepG2)); + memcpy(dest->posEncoders, p->posEncoders, sizeof(p->posEncoders)); + memcpy(dest->posAlignEncoder, p->posAlignEncoder, sizeof(p->posAlignEncoder)); + memcpy(dest->reps, p->reps, sizeof(p->reps)); + memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb)); } - -Z7_NO_INLINE -SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props2) +SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2) { - // GET_CLzmaEnc_p + CLzmaEnc *p = (CLzmaEnc *)pp; CLzmaEncProps props = *props2; LzmaEncProps_Normalize(&props); - if (props.lc > LZMA_LC_MAX - || props.lp > LZMA_LP_MAX - || props.pb > LZMA_PB_MAX) + if (props.lc > LZMA_LC_MAX || props.lp > LZMA_LP_MAX || props.pb > LZMA_PB_MAX || + props.dictSize > (1 << kDicLogSizeMaxCompress) || props.dictSize > (1 << 30)) return SZ_ERROR_PARAM; - - - if (props.dictSize > kLzmaMaxHistorySize) - props.dictSize = kLzmaMaxHistorySize; - - #ifndef LZMA_LOG_BSR - { - const UInt64 dict64 = props.dictSize; - if (dict64 > ((UInt64)1 << kDicLogSizeMaxCompress)) - return SZ_ERROR_PARAM; - } - #endif - p->dictSize = props.dictSize; + p->matchFinderCycles = props.mc; { - unsigned fb = (unsigned)props.fb; + unsigned fb = props.fb; if (fb < 5) fb = 5; if (fb > LZMA_MATCH_LEN_MAX) fb = LZMA_MATCH_LEN_MAX; p->numFastBytes = fb; } - p->lc = (unsigned)props.lc; - p->lp = (unsigned)props.lp; - p->pb = (unsigned)props.pb; + p->lc = props.lc; + p->lp = props.lp; + p->pb = props.pb; p->fastMode = (props.algo == 0); - // p->_maxMode = True; - MFB.btMode = (Byte)(props.btMode ? 1 : 0); - // MFB.btMode = (Byte)(props.btMode); + p->matchFinderBase.btMode = props.btMode; { - unsigned numHashBytes = 4; + UInt32 numHashBytes = 4; if (props.btMode) { - if (props.numHashBytes < 2) numHashBytes = 2; - else if (props.numHashBytes < 4) numHashBytes = (unsigned)props.numHashBytes; + if (props.numHashBytes < 2) + numHashBytes = 2; + else if (props.numHashBytes < 4) + numHashBytes = props.numHashBytes; } - if (props.numHashBytes >= 5) numHashBytes = 5; - - MFB.numHashBytes = numHashBytes; - // MFB.numHashBytes_Min = 2; - MFB.numHashOutBits = (Byte)props.numHashOutBits; + p->matchFinderBase.numHashBytes = numHashBytes; } - MFB.cutValue = props.mc; + p->matchFinderBase.cutValue = props.mc; - p->writeEndMark = (BoolInt)props.writeEndMark; + p->writeEndMark = props.writeEndMark; - #ifndef Z7_ST + #ifdef COMPRESS_MF_MT /* if (newMultiThread != _multiThread) { @@ -596,73 +458,56 @@ SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props2) } */ p->multiThread = (props.numThreads > 1); - p->matchFinderMt.btSync.affinity = - p->matchFinderMt.hashSync.affinity = props.affinity; #endif return SZ_OK; } +static const int kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5}; +static const int kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10}; +static const int kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11}; +static const int kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11}; -void LzmaEnc_SetDataSize(CLzmaEncHandle p, UInt64 expectedDataSiize) -{ - // GET_CLzmaEnc_p - MFB.expectedDataSize = expectedDataSiize; -} +#define IsCharState(s) ((s) < 7) - -#define kState_Start 0 -#define kState_LitAfterMatch 4 -#define kState_LitAfterRep 5 -#define kState_MatchAfterLit 7 -#define kState_RepAfterLit 8 - -static const Byte kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5}; -static const Byte kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10}; -static const Byte kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11}; -static const Byte kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11}; - -#define IsLitState(s) ((s) < 7) -#define GetLenToPosState2(len) (((len) < kNumLenToPosStates - 1) ? (len) : kNumLenToPosStates - 1) #define GetLenToPosState(len) (((len) < kNumLenToPosStates + 1) ? (len) - 2 : kNumLenToPosStates - 1) #define kInfinityPrice (1 << 30) static void RangeEnc_Construct(CRangeEnc *p) { - p->outStream = NULL; - p->bufBase = NULL; + p->outStream = 0; + p->bufBase = 0; } -#define RangeEnc_GetProcessed(p) ( (p)->processed + (size_t)((p)->buf - (p)->bufBase) + (p)->cacheSize) -#define RangeEnc_GetProcessed_sizet(p) ((size_t)(p)->processed + (size_t)((p)->buf - (p)->bufBase) + (size_t)(p)->cacheSize) +#define RangeEnc_GetProcessed(p) ((p)->processed + ((p)->buf - (p)->bufBase) + (p)->cacheSize) #define RC_BUF_SIZE (1 << 16) - -static int RangeEnc_Alloc(CRangeEnc *p, ISzAllocPtr alloc) +static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc) { - if (!p->bufBase) + if (p->bufBase == 0) { - p->bufBase = (Byte *)ISzAlloc_Alloc(alloc, RC_BUF_SIZE); - if (!p->bufBase) + p->bufBase = (Byte *)alloc->Alloc(alloc, RC_BUF_SIZE); + if (p->bufBase == 0) return 0; p->bufLim = p->bufBase + RC_BUF_SIZE; } return 1; } -static void RangeEnc_Free(CRangeEnc *p, ISzAllocPtr alloc) +static void RangeEnc_Free(CRangeEnc *p, ISzAlloc *alloc) { - ISzAlloc_Free(alloc, p->bufBase); - p->bufBase = NULL; + alloc->Free(alloc, p->bufBase); + p->bufBase = 0; } static void RangeEnc_Init(CRangeEnc *p) { - p->range = 0xFFFFFFFF; - p->cache = 0; + /* Stream.Init(); */ p->low = 0; - p->cacheSize = 0; + p->range = 0xFFFFFFFF; + p->cacheSize = 1; + p->cache = 0; p->buf = p->bufBase; @@ -670,48 +515,37 @@ static void RangeEnc_Init(CRangeEnc *p) p->res = SZ_OK; } -Z7_NO_INLINE static void RangeEnc_FlushStream(CRangeEnc *p) +static void RangeEnc_FlushStream(CRangeEnc *p) { - const size_t num = (size_t)(p->buf - p->bufBase); - if (p->res == SZ_OK) - { - if (num != ISeqOutStream_Write(p->outStream, p->bufBase, num)) - p->res = SZ_ERROR_WRITE; - } + size_t num; + if (p->res != SZ_OK) + return; + num = p->buf - p->bufBase; + if (num != p->outStream->Write(p->outStream, p->bufBase, num)) + p->res = SZ_ERROR_WRITE; p->processed += num; p->buf = p->bufBase; } -Z7_NO_INLINE static void Z7_FASTCALL RangeEnc_ShiftLow(CRangeEnc *p) +static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p) { - UInt32 low = (UInt32)p->low; - unsigned high = (unsigned)(p->low >> 32); - p->low = (UInt32)(low << 8); - if (low < (UInt32)0xFF000000 || high != 0) + if ((UInt32)p->low < (UInt32)0xFF000000 || (int)(p->low >> 32) != 0) { + Byte temp = p->cache; + do { Byte *buf = p->buf; - *buf++ = (Byte)(p->cache + high); - p->cache = (unsigned)(low >> 24); + *buf++ = (Byte)(temp + (Byte)(p->low >> 32)); p->buf = buf; if (buf == p->bufLim) RangeEnc_FlushStream(p); - if (p->cacheSize == 0) - return; - } - high += 0xFF; - for (;;) - { - Byte *buf = p->buf; - *buf++ = (Byte)(high); - p->buf = buf; - if (buf == p->bufLim) - RangeEnc_FlushStream(p); - if (--p->cacheSize == 0) - return; + temp = 0xFF; } + while (--p->cacheSize != 0); + p->cache = (Byte)((UInt32)p->low >> 24); } p->cacheSize++; + p->low = (UInt32)p->low << 8; } static void RangeEnc_FlushData(CRangeEnc *p) @@ -721,121 +555,78 @@ static void RangeEnc_FlushData(CRangeEnc *p) RangeEnc_ShiftLow(p); } -#define RC_NORM(p) if (range < kTopValue) { range <<= 8; RangeEnc_ShiftLow(p); } - -#define RC_BIT_PRE(p, prob) \ - ttt = *(prob); \ - newBound = (range >> kNumBitModelTotalBits) * ttt; - -// #define Z7_LZMA_ENC_USE_BRANCH - -#ifdef Z7_LZMA_ENC_USE_BRANCH - -#define RC_BIT(p, prob, bit) { \ - RC_BIT_PRE(p, prob) \ - if (bit == 0) { range = newBound; ttt += (kBitModelTotal - ttt) >> kNumMoveBits; } \ - else { (p)->low += newBound; range -= newBound; ttt -= ttt >> kNumMoveBits; } \ - *(prob) = (CLzmaProb)ttt; \ - RC_NORM(p) \ - } - -#else - -#define RC_BIT(p, prob, bit) { \ - UInt32 mask; \ - RC_BIT_PRE(p, prob) \ - mask = 0 - (UInt32)bit; \ - range &= mask; \ - mask &= newBound; \ - range -= mask; \ - (p)->low += mask; \ - mask = (UInt32)bit - 1; \ - range += newBound & mask; \ - mask &= (kBitModelTotal - ((1 << kNumMoveBits) - 1)); \ - mask += ((1 << kNumMoveBits) - 1); \ - ttt += (UInt32)((Int32)(mask - ttt) >> kNumMoveBits); \ - *(prob) = (CLzmaProb)ttt; \ - RC_NORM(p) \ - } - -#endif - - - - -#define RC_BIT_0_BASE(p, prob) \ - range = newBound; *(prob) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); - -#define RC_BIT_1_BASE(p, prob) \ - range -= newBound; (p)->low += newBound; *(prob) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); \ - -#define RC_BIT_0(p, prob) \ - RC_BIT_0_BASE(p, prob) \ - RC_NORM(p) - -#define RC_BIT_1(p, prob) \ - RC_BIT_1_BASE(p, prob) \ - RC_NORM(p) - -static void RangeEnc_EncodeBit_0(CRangeEnc *p, CLzmaProb *prob) +static void RangeEnc_EncodeDirectBits(CRangeEnc *p, UInt32 value, int numBits) { - UInt32 range, ttt, newBound; - range = p->range; - RC_BIT_PRE(p, prob) - RC_BIT_0(p, prob) - p->range = range; -} - -static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 sym) -{ - UInt32 range = p->range; - sym |= 0x100; do { - UInt32 ttt, newBound; - // RangeEnc_EncodeBit(p, probs + (sym >> 8), (sym >> 7) & 1); - CLzmaProb *prob = probs + (sym >> 8); - UInt32 bit = (sym >> 7) & 1; - sym <<= 1; - RC_BIT(p, prob, bit) + p->range >>= 1; + p->low += p->range & (0 - ((value >> --numBits) & 1)); + if (p->range < kTopValue) + { + p->range <<= 8; + RangeEnc_ShiftLow(p); + } } - while (sym < 0x10000); - p->range = range; + while (numBits != 0); } -static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 sym, UInt32 matchByte) +static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, UInt32 symbol) +{ + UInt32 ttt = *prob; + UInt32 newBound = (p->range >> kNumBitModelTotalBits) * ttt; + if (symbol == 0) + { + p->range = newBound; + ttt += (kBitModelTotal - ttt) >> kNumMoveBits; + } + else + { + p->low += newBound; + p->range -= newBound; + ttt -= ttt >> kNumMoveBits; + } + *prob = (CLzmaProb)ttt; + if (p->range < kTopValue) + { + p->range <<= 8; + RangeEnc_ShiftLow(p); + } +} + +static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol) +{ + symbol |= 0x100; + do + { + RangeEnc_EncodeBit(p, probs + (symbol >> 8), (symbol >> 7) & 1); + symbol <<= 1; + } + while (symbol < 0x10000); +} + +static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 symbol, UInt32 matchByte) { - UInt32 range = p->range; UInt32 offs = 0x100; - sym |= 0x100; + symbol |= 0x100; do { - UInt32 ttt, newBound; - CLzmaProb *prob; - UInt32 bit; matchByte <<= 1; - // RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (sym >> 8)), (sym >> 7) & 1); - prob = probs + (offs + (matchByte & offs) + (sym >> 8)); - bit = (sym >> 7) & 1; - sym <<= 1; - offs &= ~(matchByte ^ sym); - RC_BIT(p, prob, bit) + RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (symbol >> 8)), (symbol >> 7) & 1); + symbol <<= 1; + offs &= ~(matchByte ^ symbol); } - while (sym < 0x10000); - p->range = range; + while (symbol < 0x10000); } - - -static void LzmaEnc_InitPriceTables(CProbPrice *ProbPrices) +void LzmaEnc_InitPriceTables(UInt32 *ProbPrices) { UInt32 i; - for (i = 0; i < (kBitModelTotal >> kNumMoveReducingBits); i++) + for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits)) { - const unsigned kCyclesBits = kNumBitPriceShiftBits; - UInt32 w = (i << kNumMoveReducingBits) + (1 << (kNumMoveReducingBits - 1)); - unsigned bitCount = 0; - unsigned j; + const int kCyclesBits = kNumBitPriceShiftBits; + UInt32 w = i; + UInt32 bitCount = 0; + int j; for (j = 0; j < kCyclesBits; j++) { w = w * w; @@ -846,663 +637,554 @@ static void LzmaEnc_InitPriceTables(CProbPrice *ProbPrices) bitCount++; } } - ProbPrices[i] = (CProbPrice)(((unsigned)kNumBitModelTotalBits << kCyclesBits) - 15 - bitCount); - // printf("\n%3d: %5d", i, ProbPrices[i]); + ProbPrices[i >> kNumMoveReducingBits] = ((kNumBitModelTotalBits << kCyclesBits) - 15 - bitCount); } } -#define GET_PRICE(prob, bit) \ - p->ProbPrices[((prob) ^ (unsigned)(((-(int)(bit))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits] +#define GET_PRICE(prob, symbol) \ + p->ProbPrices[((prob) ^ (((-(int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits]; -#define GET_PRICEa(prob, bit) \ - ProbPrices[((prob) ^ (unsigned)((-((int)(bit))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits] +#define GET_PRICEa(prob, symbol) \ + ProbPrices[((prob) ^ ((-((int)(symbol))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits]; #define GET_PRICE_0(prob) p->ProbPrices[(prob) >> kNumMoveReducingBits] #define GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits] -#define GET_PRICEa_0(prob) ProbPrices[(prob) >> kNumMoveReducingBits] -#define GET_PRICEa_1(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits] +#define GET_PRICE_0a(prob) ProbPrices[(prob) >> kNumMoveReducingBits] +#define GET_PRICE_1a(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits] - -static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 sym, const CProbPrice *ProbPrices) +static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 symbol, UInt32 *ProbPrices) { UInt32 price = 0; - sym |= 0x100; + symbol |= 0x100; do { - unsigned bit = sym & 1; - sym >>= 1; - price += GET_PRICEa(probs[sym], bit); + price += GET_PRICEa(probs[symbol >> 8], (symbol >> 7) & 1); + symbol <<= 1; } - while (sym >= 2); + while (symbol < 0x10000); return price; } - -static UInt32 LitEnc_Matched_GetPrice(const CLzmaProb *probs, UInt32 sym, UInt32 matchByte, const CProbPrice *ProbPrices) +static UInt32 LitEnc_GetPriceMatched(const CLzmaProb *probs, UInt32 symbol, UInt32 matchByte, UInt32 *ProbPrices) { UInt32 price = 0; UInt32 offs = 0x100; - sym |= 0x100; + symbol |= 0x100; do { matchByte <<= 1; - price += GET_PRICEa(probs[offs + (matchByte & offs) + (sym >> 8)], (sym >> 7) & 1); - sym <<= 1; - offs &= ~(matchByte ^ sym); + price += GET_PRICEa(probs[offs + (matchByte & offs) + (symbol >> 8)], (symbol >> 7) & 1); + symbol <<= 1; + offs &= ~(matchByte ^ symbol); } - while (sym < 0x10000); + while (symbol < 0x10000); return price; } -static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, unsigned numBits, unsigned sym) +static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol) { - UInt32 range = rc->range; - unsigned m = 1; - do + UInt32 m = 1; + int i; + for (i = numBitLevels; i != 0;) { - UInt32 ttt, newBound; - unsigned bit = sym & 1; - // RangeEnc_EncodeBit(rc, probs + m, bit); - sym >>= 1; - RC_BIT(rc, probs + m, bit) + UInt32 bit; + i--; + bit = (symbol >> i) & 1; + RangeEnc_EncodeBit(rc, probs + m, bit); m = (m << 1) | bit; } - while (--numBits); - rc->range = range; } +static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, UInt32 symbol) +{ + UInt32 m = 1; + int i; + for (i = 0; i < numBitLevels; i++) + { + UInt32 bit = symbol & 1; + RangeEnc_EncodeBit(rc, probs + m, bit); + m = (m << 1) | bit; + symbol >>= 1; + } +} + +static UInt32 RcTree_GetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices) +{ + UInt32 price = 0; + symbol |= (1 << numBitLevels); + while (symbol != 1) + { + price += GET_PRICEa(probs[symbol >> 1], symbol & 1); + symbol >>= 1; + } + return price; +} + +static UInt32 RcTree_ReverseGetPrice(const CLzmaProb *probs, int numBitLevels, UInt32 symbol, UInt32 *ProbPrices) +{ + UInt32 price = 0; + UInt32 m = 1; + int i; + for (i = numBitLevels; i != 0; i--) + { + UInt32 bit = symbol & 1; + symbol >>= 1; + price += GET_PRICEa(probs[m], bit); + m = (m << 1) | bit; + } + return price; +} static void LenEnc_Init(CLenEnc *p) { unsigned i; - for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << (kLenNumLowBits + 1)); i++) + p->choice = p->choice2 = kProbInitValue; + for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumLowBits); i++) p->low[i] = kProbInitValue; + for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << kLenNumMidBits); i++) + p->mid[i] = kProbInitValue; for (i = 0; i < kLenNumHighSymbols; i++) p->high[i] = kProbInitValue; } -static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned sym, unsigned posState) +static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState) { - UInt32 range, ttt, newBound; - CLzmaProb *probs = p->low; - range = rc->range; - RC_BIT_PRE(rc, probs) - if (sym >= kLenNumLowSymbols) + if (symbol < kLenNumLowSymbols) { - RC_BIT_1(rc, probs) - probs += kLenNumLowSymbols; - RC_BIT_PRE(rc, probs) - if (sym >= kLenNumLowSymbols * 2) + RangeEnc_EncodeBit(rc, &p->choice, 0); + RcTree_Encode(rc, p->low + (posState << kLenNumLowBits), kLenNumLowBits, symbol); + } + else + { + RangeEnc_EncodeBit(rc, &p->choice, 1); + if (symbol < kLenNumLowSymbols + kLenNumMidSymbols) { - RC_BIT_1(rc, probs) - rc->range = range; - // RcTree_Encode(rc, p->high, kLenNumHighBits, sym - kLenNumLowSymbols * 2); - LitEnc_Encode(rc, p->high, sym - kLenNumLowSymbols * 2); + RangeEnc_EncodeBit(rc, &p->choice2, 0); + RcTree_Encode(rc, p->mid + (posState << kLenNumMidBits), kLenNumMidBits, symbol - kLenNumLowSymbols); + } + else + { + RangeEnc_EncodeBit(rc, &p->choice2, 1); + RcTree_Encode(rc, p->high, kLenNumHighBits, symbol - kLenNumLowSymbols - kLenNumMidSymbols); + } + } +} + +static void LenEnc_SetPrices(CLenEnc *p, UInt32 posState, UInt32 numSymbols, UInt32 *prices, UInt32 *ProbPrices) +{ + UInt32 a0 = GET_PRICE_0a(p->choice); + UInt32 a1 = GET_PRICE_1a(p->choice); + UInt32 b0 = a1 + GET_PRICE_0a(p->choice2); + UInt32 b1 = a1 + GET_PRICE_1a(p->choice2); + UInt32 i = 0; + for (i = 0; i < kLenNumLowSymbols; i++) + { + if (i >= numSymbols) return; - } - sym -= kLenNumLowSymbols; + prices[i] = a0 + RcTree_GetPrice(p->low + (posState << kLenNumLowBits), kLenNumLowBits, i, ProbPrices); } - - // RcTree_Encode(rc, probs + (posState << kLenNumLowBits), kLenNumLowBits, sym); + for (; i < kLenNumLowSymbols + kLenNumMidSymbols; i++) { - unsigned m; - unsigned bit; - RC_BIT_0(rc, probs) - probs += (posState << (1 + kLenNumLowBits)); - bit = (sym >> 2) ; RC_BIT(rc, probs + 1, bit) m = (1 << 1) + bit; - bit = (sym >> 1) & 1; RC_BIT(rc, probs + m, bit) m = (m << 1) + bit; - bit = sym & 1; RC_BIT(rc, probs + m, bit) - rc->range = range; + if (i >= numSymbols) + return; + prices[i] = b0 + RcTree_GetPrice(p->mid + (posState << kLenNumMidBits), kLenNumMidBits, i - kLenNumLowSymbols, ProbPrices); } + for (; i < numSymbols; i++) + prices[i] = b1 + RcTree_GetPrice(p->high, kLenNumHighBits, i - kLenNumLowSymbols - kLenNumMidSymbols, ProbPrices); } -static void SetPrices_3(const CLzmaProb *probs, UInt32 startPrice, UInt32 *prices, const CProbPrice *ProbPrices) +static void MY_FAST_CALL LenPriceEnc_UpdateTable(CLenPriceEnc *p, UInt32 posState, UInt32 *ProbPrices) { - unsigned i; - for (i = 0; i < 8; i += 2) - { - UInt32 price = startPrice; - UInt32 prob; - price += GET_PRICEa(probs[1 ], (i >> 2)); - price += GET_PRICEa(probs[2 + (i >> 2)], (i >> 1) & 1); - prob = probs[4 + (i >> 1)]; - prices[i ] = price + GET_PRICEa_0(prob); - prices[i + 1] = price + GET_PRICEa_1(prob); - } + LenEnc_SetPrices(&p->p, posState, p->tableSize, p->prices[posState], ProbPrices); + p->counters[posState] = p->tableSize; } - -Z7_NO_INLINE static void Z7_FASTCALL LenPriceEnc_UpdateTables( - CLenPriceEnc *p, - unsigned numPosStates, - const CLenEnc *enc, - const CProbPrice *ProbPrices) +static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, UInt32 numPosStates, UInt32 *ProbPrices) { - UInt32 b; - - { - unsigned prob = enc->low[0]; - UInt32 a, c; - unsigned posState; - b = GET_PRICEa_1(prob); - a = GET_PRICEa_0(prob); - c = b + GET_PRICEa_0(enc->low[kLenNumLowSymbols]); - for (posState = 0; posState < numPosStates; posState++) - { - UInt32 *prices = p->prices[posState]; - const CLzmaProb *probs = enc->low + (posState << (1 + kLenNumLowBits)); - SetPrices_3(probs, a, prices, ProbPrices); - SetPrices_3(probs + kLenNumLowSymbols, c, prices + kLenNumLowSymbols, ProbPrices); - } - } - - /* - { - unsigned i; - UInt32 b; - a = GET_PRICEa_0(enc->low[0]); - for (i = 0; i < kLenNumLowSymbols; i++) - p->prices2[i] = a; - a = GET_PRICEa_1(enc->low[0]); - b = a + GET_PRICEa_0(enc->low[kLenNumLowSymbols]); - for (i = kLenNumLowSymbols; i < kLenNumLowSymbols * 2; i++) - p->prices2[i] = b; - a += GET_PRICEa_1(enc->low[kLenNumLowSymbols]); - } - */ - - // p->counter = numSymbols; - // p->counter = 64; - - { - unsigned i = p->tableSize; - - if (i > kLenNumLowSymbols * 2) - { - const CLzmaProb *probs = enc->high; - UInt32 *prices = p->prices[0] + kLenNumLowSymbols * 2; - i -= kLenNumLowSymbols * 2 - 1; - i >>= 1; - b += GET_PRICEa_1(enc->low[kLenNumLowSymbols]); - do - { - /* - p->prices2[i] = a + - // RcTree_GetPrice(enc->high, kLenNumHighBits, i - kLenNumLowSymbols * 2, ProbPrices); - LitEnc_GetPrice(probs, i - kLenNumLowSymbols * 2, ProbPrices); - */ - // UInt32 price = a + RcTree_GetPrice(probs, kLenNumHighBits - 1, sym, ProbPrices); - unsigned sym = --i + (1 << (kLenNumHighBits - 1)); - UInt32 price = b; - do - { - unsigned bit = sym & 1; - sym >>= 1; - price += GET_PRICEa(probs[sym], bit); - } - while (sym >= 2); - - { - unsigned prob = probs[(size_t)i + (1 << (kLenNumHighBits - 1))]; - prices[(size_t)i * 2 ] = price + GET_PRICEa_0(prob); - prices[(size_t)i * 2 + 1] = price + GET_PRICEa_1(prob); - } - } - while (i); - - { - unsigned posState; - size_t num = (p->tableSize - kLenNumLowSymbols * 2) * sizeof(p->prices[0][0]); - for (posState = 1; posState < numPosStates; posState++) - memcpy(p->prices[posState] + kLenNumLowSymbols * 2, p->prices[0] + kLenNumLowSymbols * 2, num); - } - } - } + UInt32 posState; + for (posState = 0; posState < numPosStates; posState++) + LenPriceEnc_UpdateTable(p, posState, ProbPrices); } -/* +static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32 posState, Bool updatePrice, UInt32 *ProbPrices) +{ + LenEnc_Encode(&p->p, rc, symbol, posState); + if (updatePrice) + if (--p->counters[posState] == 0) + LenPriceEnc_UpdateTable(p, posState, ProbPrices); +} + + + + +static void MovePos(CLzmaEnc *p, UInt32 num) +{ #ifdef SHOW_STAT - g_STAT_OFFSET += num; - printf("\n MovePos %u", num); + ttt += num; + printf("\n MovePos %d", num); #endif -*/ - -#define MOVE_POS(p, num) { \ - p->additionalOffset += (num); \ - p->matchFinder.Skip(p->matchFinderObj, (UInt32)(num)); } + if (num != 0) + { + p->additionalOffset += num; + p->matchFinder.Skip(p->matchFinderObj, num); + } +} - -static unsigned ReadMatchDistances(CLzmaEnc *p, unsigned *numPairsRes) +static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes) { - unsigned numPairs; - - p->additionalOffset++; + UInt32 lenRes = 0, numPairs; p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); - { - const UInt32 *d = p->matchFinder.GetMatches(p->matchFinderObj, p->matches); - // if (!d) { p->mf_Failure = True; *numPairsRes = 0; return 0; } - numPairs = (unsigned)(d - p->matches); - } - *numPairsRes = numPairs; - + numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches); #ifdef SHOW_STAT - printf("\n i = %u numPairs = %u ", g_STAT_OFFSET, numPairs / 2); - g_STAT_OFFSET++; + printf("\n i = %d numPairs = %d ", ttt, numPairs / 2); + ttt++; { - unsigned i; + UInt32 i; for (i = 0; i < numPairs; i += 2) - printf("%2u %6u | ", p->matches[i], p->matches[i + 1]); + printf("%2d %6d | ", p->matches[i], p->matches[i + 1]); } #endif - - if (numPairs == 0) - return 0; + if (numPairs > 0) { - const unsigned len = p->matches[(size_t)numPairs - 2]; - if (len != p->numFastBytes) - return len; + lenRes = p->matches[numPairs - 2]; + if (lenRes == p->numFastBytes) { + const Byte *pby = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; + UInt32 distance = p->matches[numPairs - 1] + 1; UInt32 numAvail = p->numAvail; if (numAvail > LZMA_MATCH_LEN_MAX) numAvail = LZMA_MATCH_LEN_MAX; { - const Byte *p1 = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; - const Byte *p2 = p1 + len; - const ptrdiff_t dif = (ptrdiff_t)-1 - (ptrdiff_t)p->matches[(size_t)numPairs - 1]; - const Byte *lim = p1 + numAvail; - for (; p2 != lim && *p2 == p2[dif]; p2++) - {} - return (unsigned)(p2 - p1); + const Byte *pby2 = pby - distance; + for (; lenRes < numAvail && pby[lenRes] == pby2[lenRes]; lenRes++); } } } + p->additionalOffset++; + *numDistancePairsRes = numPairs; + return lenRes; } -#define MARK_LIT ((UInt32)(Int32)-1) -#define MakeAs_Lit(p) { (p)->dist = MARK_LIT; (p)->extra = 0; } -#define MakeAs_ShortRep(p) { (p)->dist = 0; (p)->extra = 0; } -#define IsShortRep(p) ((p)->dist == 0) +#define MakeAsChar(p) (p)->backPrev = (UInt32)(-1); (p)->prev1IsChar = False; +#define MakeAsShortRep(p) (p)->backPrev = 0; (p)->prev1IsChar = False; +#define IsShortRep(p) ((p)->backPrev == 0) +static UInt32 GetRepLen1Price(CLzmaEnc *p, UInt32 state, UInt32 posState) +{ + return + GET_PRICE_0(p->isRepG0[state]) + + GET_PRICE_0(p->isRep0Long[state][posState]); +} -#define GetPrice_ShortRep(p, state, posState) \ - ( GET_PRICE_0(p->isRepG0[state]) + GET_PRICE_0(p->isRep0Long[state][posState])) - -#define GetPrice_Rep_0(p, state, posState) ( \ - GET_PRICE_1(p->isMatch[state][posState]) \ - + GET_PRICE_1(p->isRep0Long[state][posState])) \ - + GET_PRICE_1(p->isRep[state]) \ - + GET_PRICE_0(p->isRepG0[state]) - -Z7_FORCE_INLINE -static UInt32 GetPrice_PureRep(const CLzmaEnc *p, unsigned repIndex, size_t state, size_t posState) +static UInt32 GetPureRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 state, UInt32 posState) { UInt32 price; - UInt32 prob = p->isRepG0[state]; if (repIndex == 0) { - price = GET_PRICE_0(prob); + price = GET_PRICE_0(p->isRepG0[state]); price += GET_PRICE_1(p->isRep0Long[state][posState]); } else { - price = GET_PRICE_1(prob); - prob = p->isRepG1[state]; + price = GET_PRICE_1(p->isRepG0[state]); if (repIndex == 1) - price += GET_PRICE_0(prob); + price += GET_PRICE_0(p->isRepG1[state]); else { - price += GET_PRICE_1(prob); + price += GET_PRICE_1(p->isRepG1[state]); price += GET_PRICE(p->isRepG2[state], repIndex - 2); } } return price; } - -static unsigned Backward(CLzmaEnc *p, unsigned cur) +static UInt32 GetRepPrice(CLzmaEnc *p, UInt32 repIndex, UInt32 len, UInt32 state, UInt32 posState) { - unsigned wr = cur + 1; - p->optEnd = wr; - - for (;;) - { - UInt32 dist = p->opt[cur].dist; - unsigned len = (unsigned)p->opt[cur].len; - unsigned extra = (unsigned)p->opt[cur].extra; - cur -= len; - - if (extra) - { - wr--; - p->opt[wr].len = (UInt32)len; - cur -= extra; - len = extra; - if (extra == 1) - { - p->opt[wr].dist = dist; - dist = MARK_LIT; - } - else - { - p->opt[wr].dist = 0; - len--; - wr--; - p->opt[wr].dist = MARK_LIT; - p->opt[wr].len = 1; - } - } - - if (cur == 0) - { - p->backRes = dist; - p->optCur = wr; - return len; - } - - wr--; - p->opt[wr].dist = dist; - p->opt[wr].len = (UInt32)len; - } + return p->repLenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN] + + GetPureRepPrice(p, repIndex, state, posState); } - - -#define LIT_PROBS(pos, prevByte) \ - (p->litProbs + (UInt32)3 * (((((pos) << 8) + (prevByte)) & p->lpMask) << p->lc)) - - -static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) +static UInt32 Backward(CLzmaEnc *p, UInt32 *backRes, UInt32 cur) { - unsigned last, cur; - UInt32 reps[LZMA_NUM_REPS]; - unsigned repLens[LZMA_NUM_REPS]; + UInt32 posMem = p->opt[cur].posPrev; + UInt32 backMem = p->opt[cur].backPrev; + p->optimumEndIndex = cur; + do + { + if (p->opt[cur].prev1IsChar) + { + MakeAsChar(&p->opt[posMem]) + p->opt[posMem].posPrev = posMem - 1; + if (p->opt[cur].prev2) + { + p->opt[posMem - 1].prev1IsChar = False; + p->opt[posMem - 1].posPrev = p->opt[cur].posPrev2; + p->opt[posMem - 1].backPrev = p->opt[cur].backPrev2; + } + } + { + UInt32 posPrev = posMem; + UInt32 backCur = backMem; + + backMem = p->opt[posPrev].backPrev; + posMem = p->opt[posPrev].posPrev; + + p->opt[posPrev].backPrev = backCur; + p->opt[posPrev].posPrev = cur; + cur = posPrev; + } + } + while (cur != 0); + *backRes = p->opt[0].backPrev; + p->optimumCurrentIndex = p->opt[0].posPrev; + return p->optimumCurrentIndex; +} + +#define LIT_PROBS(pos, prevByte) (p->litProbs + ((((pos) & p->lpMask) << p->lc) + ((prevByte) >> (8 - p->lc))) * 0x300) + +static UInt32 GetOptimum(CLzmaEnc *p, UInt32 position, UInt32 *backRes) +{ + UInt32 numAvail, mainLen, numPairs, repMaxIndex, i, posState, lenEnd, len, cur; + UInt32 matchPrice, repMatchPrice, normalMatchPrice; + UInt32 reps[LZMA_NUM_REPS], repLens[LZMA_NUM_REPS]; UInt32 *matches; + const Byte *data; + Byte curByte, matchByte; + if (p->optimumEndIndex != p->optimumCurrentIndex) + { + const COptimal *opt = &p->opt[p->optimumCurrentIndex]; + UInt32 lenRes = opt->posPrev - p->optimumCurrentIndex; + *backRes = opt->backPrev; + p->optimumCurrentIndex = opt->posPrev; + return lenRes; + } + p->optimumCurrentIndex = p->optimumEndIndex = 0; + + if (p->additionalOffset == 0) + mainLen = ReadMatchDistances(p, &numPairs); + else + { + mainLen = p->longestMatchLength; + numPairs = p->numPairs; + } + + numAvail = p->numAvail; + if (numAvail < 2) + { + *backRes = (UInt32)(-1); + return 1; + } + if (numAvail > LZMA_MATCH_LEN_MAX) + numAvail = LZMA_MATCH_LEN_MAX; + + data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; + repMaxIndex = 0; + for (i = 0; i < LZMA_NUM_REPS; i++) + { + UInt32 lenTest; + const Byte *data2; + reps[i] = p->reps[i]; + data2 = data - (reps[i] + 1); + if (data[0] != data2[0] || data[1] != data2[1]) + { + repLens[i] = 0; + continue; + } + for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++); + repLens[i] = lenTest; + if (lenTest > repLens[repMaxIndex]) + repMaxIndex = i; + } + if (repLens[repMaxIndex] >= p->numFastBytes) + { + UInt32 lenRes; + *backRes = repMaxIndex; + lenRes = repLens[repMaxIndex]; + MovePos(p, lenRes - 1); + return lenRes; + } + + matches = p->matches; + if (mainLen >= p->numFastBytes) + { + *backRes = matches[numPairs - 1] + LZMA_NUM_REPS; + MovePos(p, mainLen - 1); + return mainLen; + } + curByte = *data; + matchByte = *(data - (reps[0] + 1)); + + if (mainLen < 2 && curByte != matchByte && repLens[repMaxIndex] < 2) + { + *backRes = (UInt32)-1; + return 1; + } + + p->opt[0].state = (CState)p->state; + + posState = (position & p->pbMask); { - UInt32 numAvail; - unsigned numPairs, mainLen, repMaxIndex, i, posState; - UInt32 matchPrice, repMatchPrice; - const Byte *data; - Byte curByte, matchByte; - - p->optCur = p->optEnd = 0; - - if (p->additionalOffset == 0) - mainLen = ReadMatchDistances(p, &numPairs); - else - { - mainLen = p->longestMatchLen; - numPairs = p->numPairs; - } - - numAvail = p->numAvail; - if (numAvail < 2) - { - p->backRes = MARK_LIT; - return 1; - } - if (numAvail > LZMA_MATCH_LEN_MAX) - numAvail = LZMA_MATCH_LEN_MAX; - - data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; - repMaxIndex = 0; - - for (i = 0; i < LZMA_NUM_REPS; i++) - { - unsigned len; - const Byte *data2; - reps[i] = p->reps[i]; - data2 = data - reps[i]; - if (data[0] != data2[0] || data[1] != data2[1]) - { - repLens[i] = 0; - continue; - } - for (len = 2; len < numAvail && data[len] == data2[len]; len++) - {} - repLens[i] = len; - if (len > repLens[repMaxIndex]) - repMaxIndex = i; - if (len == LZMA_MATCH_LEN_MAX) // 21.03 : optimization - break; - } - - if (repLens[repMaxIndex] >= p->numFastBytes) - { - unsigned len; - p->backRes = (UInt32)repMaxIndex; - len = repLens[repMaxIndex]; - MOVE_POS(p, len - 1) - return len; - } - - matches = p->matches; - #define MATCHES matches - // #define MATCHES p->matches - - if (mainLen >= p->numFastBytes) - { - p->backRes = MATCHES[(size_t)numPairs - 1] + LZMA_NUM_REPS; - MOVE_POS(p, mainLen - 1) - return mainLen; - } - - curByte = *data; - matchByte = *(data - reps[0]); - - last = repLens[repMaxIndex]; - if (last <= mainLen) - last = mainLen; - - if (last < 2 && curByte != matchByte) - { - p->backRes = MARK_LIT; - return 1; - } - - p->opt[0].state = (CState)p->state; - - posState = (position & p->pbMask); - - { - const CLzmaProb *probs = LIT_PROBS(position, *(data - 1)); - p->opt[1].price = GET_PRICE_0(p->isMatch[p->state][posState]) + - (!IsLitState(p->state) ? - LitEnc_Matched_GetPrice(probs, curByte, matchByte, p->ProbPrices) : + const CLzmaProb *probs = LIT_PROBS(position, *(data - 1)); + p->opt[1].price = GET_PRICE_0(p->isMatch[p->state][posState]) + + (!IsCharState(p->state) ? + LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) : LitEnc_GetPrice(probs, curByte, p->ProbPrices)); - } + } - MakeAs_Lit(&p->opt[1]) - - matchPrice = GET_PRICE_1(p->isMatch[p->state][posState]); - repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[p->state]); - - // 18.06 - if (matchByte == curByte && repLens[0] == 0) - { - UInt32 shortRepPrice = repMatchPrice + GetPrice_ShortRep(p, p->state, posState); - if (shortRepPrice < p->opt[1].price) - { - p->opt[1].price = shortRepPrice; - MakeAs_ShortRep(&p->opt[1]) - } - if (last < 2) - { - p->backRes = p->opt[1].dist; - return 1; - } - } - - p->opt[1].len = 1; - - p->opt[0].reps[0] = reps[0]; - p->opt[0].reps[1] = reps[1]; - p->opt[0].reps[2] = reps[2]; - p->opt[0].reps[3] = reps[3]; - - // ---------- REP ---------- - - for (i = 0; i < LZMA_NUM_REPS; i++) - { - unsigned repLen = repLens[i]; - UInt32 price; - if (repLen < 2) - continue; - price = repMatchPrice + GetPrice_PureRep(p, i, p->state, posState); - do - { - UInt32 price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState, repLen); - COptimal *opt = &p->opt[repLen]; - if (price2 < opt->price) - { - opt->price = price2; - opt->len = (UInt32)repLen; - opt->dist = (UInt32)i; - opt->extra = 0; - } - } - while (--repLen >= 2); - } - - - // ---------- MATCH ---------- - { - unsigned len = repLens[0] + 1; - if (len <= mainLen) - { - unsigned offs = 0; - UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]); + MakeAsChar(&p->opt[1]); - if (len < 2) - len = 2; - else - while (len > MATCHES[offs]) - offs += 2; - - for (; ; len++) - { - COptimal *opt; - UInt32 dist = MATCHES[(size_t)offs + 1]; - UInt32 price = normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, posState, len); - unsigned lenToPosState = GetLenToPosState(len); - - if (dist < kNumFullDistances) - price += p->distancesPrices[lenToPosState][dist & (kNumFullDistances - 1)]; - else - { - unsigned slot; - GetPosSlot2(dist, slot) - price += p->alignPrices[dist & kAlignMask]; - price += p->posSlotPrices[lenToPosState][slot]; - } - - opt = &p->opt[len]; - - if (price < opt->price) - { - opt->price = price; - opt->len = (UInt32)len; - opt->dist = dist + LZMA_NUM_REPS; - opt->extra = 0; - } - - if (len == MATCHES[offs]) - { - offs += 2; - if (offs == numPairs) - break; - } - } + matchPrice = GET_PRICE_1(p->isMatch[p->state][posState]); + repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[p->state]); + + if (matchByte == curByte) + { + UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, p->state, posState); + if (shortRepPrice < p->opt[1].price) + { + p->opt[1].price = shortRepPrice; + MakeAsShortRep(&p->opt[1]); + } + } + lenEnd = ((mainLen >= repLens[repMaxIndex]) ? mainLen : repLens[repMaxIndex]); + + if (lenEnd < 2) + { + *backRes = p->opt[1].backPrev; + return 1; + } + + p->opt[1].posPrev = 0; + for (i = 0; i < LZMA_NUM_REPS; i++) + p->opt[0].backs[i] = reps[i]; + + len = lenEnd; + do + p->opt[len--].price = kInfinityPrice; + while (len >= 2); + + for (i = 0; i < LZMA_NUM_REPS; i++) + { + UInt32 repLen = repLens[i]; + UInt32 price; + if (repLen < 2) + continue; + price = repMatchPrice + GetPureRepPrice(p, i, p->state, posState); + do + { + UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][repLen - 2]; + COptimal *opt = &p->opt[repLen]; + if (curAndLenPrice < opt->price) + { + opt->price = curAndLenPrice; + opt->posPrev = 0; + opt->backPrev = i; + opt->prev1IsChar = False; } } - + while (--repLen >= 2); + } - cur = 0; + normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]); + + len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2); + if (len <= mainLen) + { + UInt32 offs = 0; + while (len > matches[offs]) + offs += 2; + for (; ; len++) + { + COptimal *opt; + UInt32 distance = matches[offs + 1]; + + UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN]; + UInt32 lenToPosState = GetLenToPosState(len); + if (distance < kNumFullDistances) + curAndLenPrice += p->distancesPrices[lenToPosState][distance]; + else + { + UInt32 slot; + GetPosSlot2(distance, slot); + curAndLenPrice += p->alignPrices[distance & kAlignMask] + p->posSlotPrices[lenToPosState][slot]; + } + opt = &p->opt[len]; + if (curAndLenPrice < opt->price) + { + opt->price = curAndLenPrice; + opt->posPrev = 0; + opt->backPrev = distance + LZMA_NUM_REPS; + opt->prev1IsChar = False; + } + if (len == matches[offs]) + { + offs += 2; + if (offs == numPairs) + break; + } + } + } + + cur = 0; #ifdef SHOW_STAT2 - /* if (position >= 0) */ + if (position >= 0) { unsigned i; printf("\n pos = %4X", position); - for (i = cur; i <= last; i++) - printf("\nprice[%4X] = %u", position - cur + i, p->opt[i].price); + for (i = cur; i <= lenEnd; i++) + printf("\nprice[%4X] = %d", position - cur + i, p->opt[i].price); } #endif - } - - - - // ---------- Optimal Parsing ---------- for (;;) { - unsigned numAvail; - UInt32 numAvailFull; - unsigned newLen, numPairs, prev, state, posState, startLen; - UInt32 litPrice, matchPrice, repMatchPrice; - BoolInt nextIsLit; + UInt32 numAvailFull, newLen, numPairs, posPrev, state, posState, startLen; + UInt32 curPrice, curAnd1Price, matchPrice, repMatchPrice; + Bool nextIsChar; Byte curByte, matchByte; const Byte *data; - COptimal *curOpt, *nextOpt; + COptimal *curOpt; + COptimal *nextOpt; - if (++cur == last) - break; - - // 18.06 - if (cur >= kNumOpts - 64) - { - unsigned j, best; - UInt32 price = p->opt[cur].price; - best = cur; - for (j = cur + 1; j <= last; j++) - { - UInt32 price2 = p->opt[j].price; - if (price >= price2) - { - price = price2; - best = j; - } - } - { - unsigned delta = best - cur; - if (delta != 0) - { - MOVE_POS(p, delta) - } - } - cur = best; - break; - } + cur++; + if (cur == lenEnd) + return Backward(p, backRes, cur); newLen = ReadMatchDistances(p, &numPairs); - if (newLen >= p->numFastBytes) { p->numPairs = numPairs; - p->longestMatchLen = newLen; - break; + p->longestMatchLength = newLen; + return Backward(p, backRes, cur); } - - curOpt = &p->opt[cur]; - position++; - - // we need that check here, if skip_items in p->opt are possible - /* - if (curOpt->price >= kInfinityPrice) - continue; - */ - - prev = cur - curOpt->len; - - if (curOpt->len == 1) + curOpt = &p->opt[cur]; + posPrev = curOpt->posPrev; + if (curOpt->prev1IsChar) + { + posPrev--; + if (curOpt->prev2) + { + state = p->opt[curOpt->posPrev2].state; + if (curOpt->backPrev2 < LZMA_NUM_REPS) + state = kRepNextStates[state]; + else + state = kMatchNextStates[state]; + } + else + state = p->opt[posPrev].state; + state = kLiteralNextStates[state]; + } + else + state = p->opt[posPrev].state; + if (posPrev == cur - 1) { - state = (unsigned)p->opt[prev].state; if (IsShortRep(curOpt)) state = kShortRepNextStates[state]; else @@ -1510,499 +1192,355 @@ static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) } else { + UInt32 pos; const COptimal *prevOpt; - UInt32 b0; - UInt32 dist = curOpt->dist; - - if (curOpt->extra) + if (curOpt->prev1IsChar && curOpt->prev2) { - prev -= (unsigned)curOpt->extra; - state = kState_RepAfterLit; - if (curOpt->extra == 1) - state = (dist < LZMA_NUM_REPS ? kState_RepAfterLit : kState_MatchAfterLit); + posPrev = curOpt->posPrev2; + pos = curOpt->backPrev2; + state = kRepNextStates[state]; } else { - state = (unsigned)p->opt[prev].state; - if (dist < LZMA_NUM_REPS) + pos = curOpt->backPrev; + if (pos < LZMA_NUM_REPS) state = kRepNextStates[state]; else state = kMatchNextStates[state]; } - - prevOpt = &p->opt[prev]; - b0 = prevOpt->reps[0]; - - if (dist < LZMA_NUM_REPS) + prevOpt = &p->opt[posPrev]; + if (pos < LZMA_NUM_REPS) { - if (dist == 0) - { - reps[0] = b0; - reps[1] = prevOpt->reps[1]; - reps[2] = prevOpt->reps[2]; - reps[3] = prevOpt->reps[3]; - } - else - { - reps[1] = b0; - b0 = prevOpt->reps[1]; - if (dist == 1) - { - reps[0] = b0; - reps[2] = prevOpt->reps[2]; - reps[3] = prevOpt->reps[3]; - } - else - { - reps[2] = b0; - reps[0] = prevOpt->reps[dist]; - reps[3] = prevOpt->reps[dist ^ 1]; - } - } + UInt32 i; + reps[0] = prevOpt->backs[pos]; + for (i = 1; i <= pos; i++) + reps[i] = prevOpt->backs[i - 1]; + for (; i < LZMA_NUM_REPS; i++) + reps[i] = prevOpt->backs[i]; } else { - reps[0] = (dist - LZMA_NUM_REPS + 1); - reps[1] = b0; - reps[2] = prevOpt->reps[1]; - reps[3] = prevOpt->reps[2]; + UInt32 i; + reps[0] = (pos - LZMA_NUM_REPS); + for (i = 1; i < LZMA_NUM_REPS; i++) + reps[i] = prevOpt->backs[i - 1]; } } - curOpt->state = (CState)state; - curOpt->reps[0] = reps[0]; - curOpt->reps[1] = reps[1]; - curOpt->reps[2] = reps[2]; - curOpt->reps[3] = reps[3]; + curOpt->backs[0] = reps[0]; + curOpt->backs[1] = reps[1]; + curOpt->backs[2] = reps[2]; + curOpt->backs[3] = reps[3]; + + curPrice = curOpt->price; + nextIsChar = False; data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; curByte = *data; - matchByte = *(data - reps[0]); + matchByte = *(data - (reps[0] + 1)); posState = (position & p->pbMask); - /* - The order of Price checks: - < LIT - <= SHORT_REP - < LIT : REP_0 - < REP [ : LIT : REP_0 ] - < MATCH [ : LIT : REP_0 ] - */ - - { - UInt32 curPrice = curOpt->price; - unsigned prob = p->isMatch[state][posState]; - matchPrice = curPrice + GET_PRICE_1(prob); - litPrice = curPrice + GET_PRICE_0(prob); - } - - nextOpt = &p->opt[(size_t)cur + 1]; - nextIsLit = False; - - // here we can allow skip_items in p->opt, if we don't check (nextOpt->price < kInfinityPrice) - // 18.new.06 - if ((nextOpt->price < kInfinityPrice - // && !IsLitState(state) - && matchByte == curByte) - || litPrice > nextOpt->price - ) - litPrice = 0; - else + curAnd1Price = curPrice + GET_PRICE_0(p->isMatch[state][posState]); { const CLzmaProb *probs = LIT_PROBS(position, *(data - 1)); - litPrice += (!IsLitState(state) ? - LitEnc_Matched_GetPrice(probs, curByte, matchByte, p->ProbPrices) : + curAnd1Price += + (!IsCharState(state) ? + LitEnc_GetPriceMatched(probs, curByte, matchByte, p->ProbPrices) : LitEnc_GetPrice(probs, curByte, p->ProbPrices)); - - if (litPrice < nextOpt->price) - { - nextOpt->price = litPrice; - nextOpt->len = 1; - MakeAs_Lit(nextOpt) - nextIsLit = True; - } } + nextOpt = &p->opt[cur + 1]; + + if (curAnd1Price < nextOpt->price) + { + nextOpt->price = curAnd1Price; + nextOpt->posPrev = cur; + MakeAsChar(nextOpt); + nextIsChar = True; + } + + matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]); repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]); - numAvailFull = p->numAvail; + if (matchByte == curByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0)) { - unsigned temp = kNumOpts - 1 - cur; - if (numAvailFull > temp) - numAvailFull = (UInt32)temp; - } - - // 18.06 - // ---------- SHORT_REP ---------- - if (IsLitState(state)) // 18.new - if (matchByte == curByte) - if (repMatchPrice < nextOpt->price) // 18.new - // if (numAvailFull < 2 || data[1] != *(data - reps[0] + 1)) - if ( - // nextOpt->price >= kInfinityPrice || - nextOpt->len < 2 // we can check nextOpt->len, if skip items are not allowed in p->opt - || (nextOpt->dist != 0 - // && nextOpt->extra <= 1 // 17.old - ) - ) - { - UInt32 shortRepPrice = repMatchPrice + GetPrice_ShortRep(p, state, posState); - // if (shortRepPrice <= nextOpt->price) // 17.old - if (shortRepPrice < nextOpt->price) // 18.new + UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState); + if (shortRepPrice <= nextOpt->price) { nextOpt->price = shortRepPrice; - nextOpt->len = 1; - MakeAs_ShortRep(nextOpt) - nextIsLit = False; + nextOpt->posPrev = cur; + MakeAsShortRep(nextOpt); + nextIsChar = True; } } - + numAvailFull = p->numAvail; + { + UInt32 temp = kNumOpts - 1 - cur; + if (temp < numAvailFull) + numAvailFull = temp; + } + if (numAvailFull < 2) continue; numAvail = (numAvailFull <= p->numFastBytes ? numAvailFull : p->numFastBytes); - // numAvail <= p->numFastBytes - - // ---------- LIT : REP_0 ---------- - - if (!nextIsLit - && litPrice != 0 // 18.new - && matchByte != curByte - && numAvailFull > 2) + if (!nextIsChar && matchByte != curByte) /* speed optimization */ { - const Byte *data2 = data - reps[0]; - if (data[1] == data2[1] && data[2] == data2[2]) + /* try Literal + rep0 */ + UInt32 temp; + UInt32 lenTest2; + const Byte *data2 = data - (reps[0] + 1); + UInt32 limit = p->numFastBytes + 1; + if (limit > numAvailFull) + limit = numAvailFull; + + for (temp = 1; temp < limit && data[temp] == data2[temp]; temp++); + lenTest2 = temp - 1; + if (lenTest2 >= 2) { - unsigned len; - unsigned limit = p->numFastBytes + 1; - if (limit > numAvailFull) - limit = numAvailFull; - for (len = 3; len < limit && data[len] == data2[len]; len++) - {} - + UInt32 state2 = kLiteralNextStates[state]; + UInt32 posStateNext = (position + 1) & p->pbMask; + UInt32 nextRepMatchPrice = curAnd1Price + + GET_PRICE_1(p->isMatch[state2][posStateNext]) + + GET_PRICE_1(p->isRep[state2]); + /* for (; lenTest2 >= 2; lenTest2--) */ { - unsigned state2 = kLiteralNextStates[state]; - unsigned posState2 = (position + 1) & p->pbMask; - UInt32 price = litPrice + GetPrice_Rep_0(p, state2, posState2); + UInt32 curAndLenPrice; + COptimal *opt; + UInt32 offset = cur + 1 + lenTest2; + while (lenEnd < offset) + p->opt[++lenEnd].price = kInfinityPrice; + curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext); + opt = &p->opt[offset]; + if (curAndLenPrice < opt->price) { - unsigned offset = cur + len; - - if (last < offset) - last = offset; - - // do - { - UInt32 price2; - COptimal *opt; - len--; - // price2 = price + GetPrice_Len_Rep_0(p, len, state2, posState2); - price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState2, len); - - opt = &p->opt[offset]; - // offset--; - if (price2 < opt->price) - { - opt->price = price2; - opt->len = (UInt32)len; - opt->dist = 0; - opt->extra = 1; - } - } - // while (len >= 3); + opt->price = curAndLenPrice; + opt->posPrev = cur + 1; + opt->backPrev = 0; + opt->prev1IsChar = True; + opt->prev2 = False; } } } } startLen = 2; /* speed optimization */ - { - // ---------- REP ---------- - unsigned repIndex = 0; // 17.old - // unsigned repIndex = IsLitState(state) ? 0 : 1; // 18.notused - for (; repIndex < LZMA_NUM_REPS; repIndex++) + UInt32 repIndex; + for (repIndex = 0; repIndex < LZMA_NUM_REPS; repIndex++) + { + UInt32 lenTest; + UInt32 lenTestTemp; + UInt32 price; + const Byte *data2 = data - (reps[repIndex] + 1); + if (data[0] != data2[0] || data[1] != data2[1]) + continue; + for (lenTest = 2; lenTest < numAvail && data[lenTest] == data2[lenTest]; lenTest++); + while (lenEnd < cur + lenTest) + p->opt[++lenEnd].price = kInfinityPrice; + lenTestTemp = lenTest; + price = repMatchPrice + GetPureRepPrice(p, repIndex, state, posState); + do { - unsigned len; - UInt32 price; - const Byte *data2 = data - reps[repIndex]; - if (data[0] != data2[0] || data[1] != data2[1]) - continue; - - for (len = 2; len < numAvail && data[len] == data2[len]; len++) - {} - - // if (len < startLen) continue; // 18.new: speed optimization - + UInt32 curAndLenPrice = price + p->repLenEnc.prices[posState][lenTest - 2]; + COptimal *opt = &p->opt[cur + lenTest]; + if (curAndLenPrice < opt->price) { - unsigned offset = cur + len; - if (last < offset) - last = offset; - } - { - unsigned len2 = len; - price = repMatchPrice + GetPrice_PureRep(p, repIndex, state, posState); - do - { - UInt32 price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState, len2); - COptimal *opt = &p->opt[cur + len2]; - if (price2 < opt->price) - { - opt->price = price2; - opt->len = (UInt32)len2; - opt->dist = (UInt32)repIndex; - opt->extra = 0; - } - } - while (--len2 >= 2); - } - - if (repIndex == 0) startLen = len + 1; // 17.old - // startLen = len + 1; // 18.new - - /* if (_maxMode) */ - { - // ---------- REP : LIT : REP_0 ---------- - // numFastBytes + 1 + numFastBytes - - unsigned len2 = len + 1; - unsigned limit = len2 + p->numFastBytes; - if (limit > numAvailFull) - limit = numAvailFull; - - len2 += 2; - if (len2 <= limit) - if (data[len2 - 2] == data2[len2 - 2]) - if (data[len2 - 1] == data2[len2 - 1]) - { - unsigned state2 = kRepNextStates[state]; - unsigned posState2 = (position + len) & p->pbMask; - price += GET_PRICE_LEN(&p->repLenEnc, posState, len) - + GET_PRICE_0(p->isMatch[state2][posState2]) - + LitEnc_Matched_GetPrice(LIT_PROBS(position + len, data[(size_t)len - 1]), - data[len], data2[len], p->ProbPrices); - - // state2 = kLiteralNextStates[state2]; - state2 = kState_LitAfterRep; - posState2 = (posState2 + 1) & p->pbMask; - - - price += GetPrice_Rep_0(p, state2, posState2); - - for (; len2 < limit && data[len2] == data2[len2]; len2++) - {} - - len2 -= len; - // if (len2 >= 3) - { - { - unsigned offset = cur + len + len2; - - if (last < offset) - last = offset; - // do - { - UInt32 price2; - COptimal *opt; - len2--; - // price2 = price + GetPrice_Len_Rep_0(p, len2, state2, posState2); - price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState2, len2); - - opt = &p->opt[offset]; - // offset--; - if (price2 < opt->price) - { - opt->price = price2; - opt->len = (UInt32)len2; - opt->extra = (CExtra)(len + 1); - opt->dist = (UInt32)repIndex; - } - } - // while (len2 >= 3); - } - } - } + opt->price = curAndLenPrice; + opt->posPrev = cur; + opt->backPrev = repIndex; + opt->prev1IsChar = False; } } + while (--lenTest >= 2); + lenTest = lenTestTemp; + + if (repIndex == 0) + startLen = lenTest + 1; + + /* if (_maxMode) */ + { + UInt32 lenTest2 = lenTest + 1; + UInt32 limit = lenTest2 + p->numFastBytes; + UInt32 nextRepMatchPrice; + if (limit > numAvailFull) + limit = numAvailFull; + for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++); + lenTest2 -= lenTest + 1; + if (lenTest2 >= 2) + { + UInt32 state2 = kRepNextStates[state]; + UInt32 posStateNext = (position + lenTest) & p->pbMask; + UInt32 curAndLenCharPrice = + price + p->repLenEnc.prices[posState][lenTest - 2] + + GET_PRICE_0(p->isMatch[state2][posStateNext]) + + LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]), + data[lenTest], data2[lenTest], p->ProbPrices); + state2 = kLiteralNextStates[state2]; + posStateNext = (position + lenTest + 1) & p->pbMask; + nextRepMatchPrice = curAndLenCharPrice + + GET_PRICE_1(p->isMatch[state2][posStateNext]) + + GET_PRICE_1(p->isRep[state2]); + + /* for (; lenTest2 >= 2; lenTest2--) */ + { + UInt32 curAndLenPrice; + COptimal *opt; + UInt32 offset = cur + lenTest + 1 + lenTest2; + while (lenEnd < offset) + p->opt[++lenEnd].price = kInfinityPrice; + curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext); + opt = &p->opt[offset]; + if (curAndLenPrice < opt->price) + { + opt->price = curAndLenPrice; + opt->posPrev = cur + lenTest + 1; + opt->backPrev = 0; + opt->prev1IsChar = True; + opt->prev2 = True; + opt->posPrev2 = cur; + opt->backPrev2 = repIndex; + } + } + } + } } - - - // ---------- MATCH ---------- - /* for (unsigned len = 2; len <= newLen; len++) */ + } + /* for (UInt32 lenTest = 2; lenTest <= newLen; lenTest++) */ if (newLen > numAvail) { newLen = numAvail; - for (numPairs = 0; newLen > MATCHES[numPairs]; numPairs += 2); - MATCHES[numPairs] = (UInt32)newLen; + for (numPairs = 0; newLen > matches[numPairs]; numPairs += 2); + matches[numPairs] = newLen; numPairs += 2; } - - // startLen = 2; /* speed optimization */ - if (newLen >= startLen) { UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]); - UInt32 dist; - unsigned offs, posSlot, len; - - { - unsigned offset = cur + newLen; - if (last < offset) - last = offset; - } + UInt32 offs, curBack, posSlot; + UInt32 lenTest; + while (lenEnd < cur + newLen) + p->opt[++lenEnd].price = kInfinityPrice; offs = 0; - while (startLen > MATCHES[offs]) + while (startLen > matches[offs]) offs += 2; - dist = MATCHES[(size_t)offs + 1]; - - // if (dist >= kNumFullDistances) - GetPosSlot2(dist, posSlot) - - for (len = /*2*/ startLen; ; len++) + curBack = matches[offs + 1]; + GetPosSlot2(curBack, posSlot); + for (lenTest = /*2*/ startLen; ; lenTest++) { - UInt32 price = normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, posState, len); + UInt32 curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN]; + UInt32 lenToPosState = GetLenToPosState(lenTest); + COptimal *opt; + if (curBack < kNumFullDistances) + curAndLenPrice += p->distancesPrices[lenToPosState][curBack]; + else + curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask]; + + opt = &p->opt[cur + lenTest]; + if (curAndLenPrice < opt->price) { - COptimal *opt; - unsigned lenNorm = len - 2; - lenNorm = GetLenToPosState2(lenNorm); - if (dist < kNumFullDistances) - price += p->distancesPrices[lenNorm][dist & (kNumFullDistances - 1)]; - else - price += p->posSlotPrices[lenNorm][posSlot] + p->alignPrices[dist & kAlignMask]; - - opt = &p->opt[cur + len]; - if (price < opt->price) - { - opt->price = price; - opt->len = (UInt32)len; - opt->dist = dist + LZMA_NUM_REPS; - opt->extra = 0; - } + opt->price = curAndLenPrice; + opt->posPrev = cur; + opt->backPrev = curBack + LZMA_NUM_REPS; + opt->prev1IsChar = False; } - if (len == MATCHES[offs]) + if (/*_maxMode && */lenTest == matches[offs]) { - // if (p->_maxMode) { - // MATCH : LIT : REP_0 - - const Byte *data2 = data - dist - 1; - unsigned len2 = len + 1; - unsigned limit = len2 + p->numFastBytes; + /* Try Match + Literal + Rep0 */ + const Byte *data2 = data - (curBack + 1); + UInt32 lenTest2 = lenTest + 1; + UInt32 limit = lenTest2 + p->numFastBytes; + UInt32 nextRepMatchPrice; if (limit > numAvailFull) limit = numAvailFull; - - len2 += 2; - if (len2 <= limit) - if (data[len2 - 2] == data2[len2 - 2]) - if (data[len2 - 1] == data2[len2 - 1]) + for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++); + lenTest2 -= lenTest + 1; + if (lenTest2 >= 2) { - for (; len2 < limit && data[len2] == data2[len2]; len2++) - {} - - len2 -= len; - - // if (len2 >= 3) - { - unsigned state2 = kMatchNextStates[state]; - unsigned posState2 = (position + len) & p->pbMask; - unsigned offset; - price += GET_PRICE_0(p->isMatch[state2][posState2]); - price += LitEnc_Matched_GetPrice(LIT_PROBS(position + len, data[(size_t)len - 1]), - data[len], data2[len], p->ProbPrices); - - // state2 = kLiteralNextStates[state2]; - state2 = kState_LitAfterMatch; - - posState2 = (posState2 + 1) & p->pbMask; - price += GetPrice_Rep_0(p, state2, posState2); - - offset = cur + len + len2; - - if (last < offset) - last = offset; - // do + UInt32 state2 = kMatchNextStates[state]; + UInt32 posStateNext = (position + lenTest) & p->pbMask; + UInt32 curAndLenCharPrice = curAndLenPrice + + GET_PRICE_0(p->isMatch[state2][posStateNext]) + + LitEnc_GetPriceMatched(LIT_PROBS(position + lenTest, data[lenTest - 1]), + data[lenTest], data2[lenTest], p->ProbPrices); + state2 = kLiteralNextStates[state2]; + posStateNext = (posStateNext + 1) & p->pbMask; + nextRepMatchPrice = curAndLenCharPrice + + GET_PRICE_1(p->isMatch[state2][posStateNext]) + + GET_PRICE_1(p->isRep[state2]); + + /* for (; lenTest2 >= 2; lenTest2--) */ { - UInt32 price2; + UInt32 offset = cur + lenTest + 1 + lenTest2; + UInt32 curAndLenPrice; COptimal *opt; - len2--; - // price2 = price + GetPrice_Len_Rep_0(p, len2, state2, posState2); - price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState2, len2); + while (lenEnd < offset) + p->opt[++lenEnd].price = kInfinityPrice; + curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext); opt = &p->opt[offset]; - // offset--; - if (price2 < opt->price) + if (curAndLenPrice < opt->price) { - opt->price = price2; - opt->len = (UInt32)len2; - opt->extra = (CExtra)(len + 1); - opt->dist = dist + LZMA_NUM_REPS; + opt->price = curAndLenPrice; + opt->posPrev = cur + lenTest + 1; + opt->backPrev = 0; + opt->prev1IsChar = True; + opt->prev2 = True; + opt->posPrev2 = cur; + opt->backPrev2 = curBack + LZMA_NUM_REPS; } } - // while (len2 >= 3); } - - } - offs += 2; if (offs == numPairs) break; - dist = MATCHES[(size_t)offs + 1]; - // if (dist >= kNumFullDistances) - GetPosSlot2(dist, posSlot) + curBack = matches[offs + 1]; + if (curBack >= kNumFullDistances) + GetPosSlot2(curBack, posSlot); } } } } - - do - p->opt[last].price = kInfinityPrice; - while (--last); - - return Backward(p, cur); } - - #define ChangePair(smallDist, bigDist) (((bigDist) >> 7) > (smallDist)) - - -static unsigned GetOptimumFast(CLzmaEnc *p) +static UInt32 GetOptimumFast(CLzmaEnc *p, UInt32 *backRes) { - UInt32 numAvail, mainDist; - unsigned mainLen, numPairs, repIndex, repLen, i; + UInt32 numAvail, mainLen, mainDist, numPairs, repIndex, repLen, i; const Byte *data; + const UInt32 *matches; if (p->additionalOffset == 0) mainLen = ReadMatchDistances(p, &numPairs); else { - mainLen = p->longestMatchLen; + mainLen = p->longestMatchLength; numPairs = p->numPairs; } numAvail = p->numAvail; - p->backRes = MARK_LIT; + *backRes = (UInt32)-1; if (numAvail < 2) return 1; - // if (mainLen < 2 && p->state == 0) return 1; // 18.06.notused if (numAvail > LZMA_MATCH_LEN_MAX) numAvail = LZMA_MATCH_LEN_MAX; data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; + repLen = repIndex = 0; - for (i = 0; i < LZMA_NUM_REPS; i++) { - unsigned len; - const Byte *data2 = data - p->reps[i]; + UInt32 len; + const Byte *data2 = data - (p->reps[i] + 1); if (data[0] != data2[0] || data[1] != data2[1]) continue; - for (len = 2; len < numAvail && data[len] == data2[len]; len++) - {} + for (len = 2; len < numAvail && data[len] == data2[len]; len++); if (len >= p->numFastBytes) { - p->backRes = (UInt32)i; - MOVE_POS(p, len - 1) + *backRes = i; + MovePos(p, len - 1); return len; } if (len > repLen) @@ -2012,182 +1550,98 @@ static unsigned GetOptimumFast(CLzmaEnc *p) } } + matches = p->matches; if (mainLen >= p->numFastBytes) { - p->backRes = p->matches[(size_t)numPairs - 1] + LZMA_NUM_REPS; - MOVE_POS(p, mainLen - 1) + *backRes = matches[numPairs - 1] + LZMA_NUM_REPS; + MovePos(p, mainLen - 1); return mainLen; } mainDist = 0; /* for GCC */ - if (mainLen >= 2) { - mainDist = p->matches[(size_t)numPairs - 1]; - while (numPairs > 2) + mainDist = matches[numPairs - 1]; + while (numPairs > 2 && mainLen == matches[numPairs - 4] + 1) { - UInt32 dist2; - if (mainLen != p->matches[(size_t)numPairs - 4] + 1) - break; - dist2 = p->matches[(size_t)numPairs - 3]; - if (!ChangePair(dist2, mainDist)) + if (!ChangePair(matches[numPairs - 3], mainDist)) break; numPairs -= 2; - mainLen--; - mainDist = dist2; + mainLen = matches[numPairs - 2]; + mainDist = matches[numPairs - 1]; } if (mainLen == 2 && mainDist >= 0x80) mainLen = 1; } - if (repLen >= 2) - if ( repLen + 1 >= mainLen - || (repLen + 2 >= mainLen && mainDist >= (1 << 9)) - || (repLen + 3 >= mainLen && mainDist >= (1 << 15))) + if (repLen >= 2 && ( + (repLen + 1 >= mainLen) || + (repLen + 2 >= mainLen && mainDist >= (1 << 9)) || + (repLen + 3 >= mainLen && mainDist >= (1 << 15)))) { - p->backRes = (UInt32)repIndex; - MOVE_POS(p, repLen - 1) + *backRes = repIndex; + MovePos(p, repLen - 1); return repLen; } if (mainLen < 2 || numAvail <= 2) return 1; + p->longestMatchLength = ReadMatchDistances(p, &p->numPairs); + if (p->longestMatchLength >= 2) { - unsigned len1 = ReadMatchDistances(p, &p->numPairs); - p->longestMatchLen = len1; - - if (len1 >= 2) - { - UInt32 newDist = p->matches[(size_t)p->numPairs - 1]; - if ( (len1 >= mainLen && newDist < mainDist) - || (len1 == mainLen + 1 && !ChangePair(mainDist, newDist)) - || (len1 > mainLen + 1) - || (len1 + 1 >= mainLen && mainLen >= 3 && ChangePair(newDist, mainDist))) - return 1; - } + UInt32 newDistance = matches[p->numPairs - 1]; + if ((p->longestMatchLength >= mainLen && newDistance < mainDist) || + (p->longestMatchLength == mainLen + 1 && !ChangePair(mainDist, newDistance)) || + (p->longestMatchLength > mainLen + 1) || + (p->longestMatchLength + 1 >= mainLen && mainLen >= 3 && ChangePair(newDistance, mainDist))) + return 1; } data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; - for (i = 0; i < LZMA_NUM_REPS; i++) { - unsigned len, limit; - const Byte *data2 = data - p->reps[i]; + UInt32 len, limit; + const Byte *data2 = data - (p->reps[i] + 1); if (data[0] != data2[0] || data[1] != data2[1]) continue; limit = mainLen - 1; - for (len = 2;; len++) - { - if (len >= limit) - return 1; - if (data[len] != data2[len]) - break; - } - } - - p->backRes = mainDist + LZMA_NUM_REPS; - if (mainLen != 2) - { - MOVE_POS(p, mainLen - 2) + for (len = 2; len < limit && data[len] == data2[len]; len++); + if (len >= limit) + return 1; } + *backRes = mainDist + LZMA_NUM_REPS; + MovePos(p, mainLen - 2); return mainLen; } - - - -static void WriteEndMarker(CLzmaEnc *p, unsigned posState) +static void WriteEndMarker(CLzmaEnc *p, UInt32 posState) { - UInt32 range; - range = p->rc.range; - { - UInt32 ttt, newBound; - CLzmaProb *prob = &p->isMatch[p->state][posState]; - RC_BIT_PRE(&p->rc, prob) - RC_BIT_1(&p->rc, prob) - prob = &p->isRep[p->state]; - RC_BIT_PRE(&p->rc, prob) - RC_BIT_0(&p->rc, prob) - } + UInt32 len; + RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1); + RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0); p->state = kMatchNextStates[p->state]; - - p->rc.range = range; - LenEnc_Encode(&p->lenProbs, &p->rc, 0, posState); - range = p->rc.range; - - { - // RcTree_Encode_PosSlot(&p->rc, p->posSlotEncoder[0], (1 << kNumPosSlotBits) - 1); - CLzmaProb *probs = p->posSlotEncoder[0]; - unsigned m = 1; - do - { - UInt32 ttt, newBound; - RC_BIT_PRE(p, probs + m) - RC_BIT_1(&p->rc, probs + m) - m = (m << 1) + 1; - } - while (m < (1 << kNumPosSlotBits)); - } - { - // RangeEnc_EncodeDirectBits(&p->rc, ((UInt32)1 << (30 - kNumAlignBits)) - 1, 30 - kNumAlignBits); UInt32 range = p->range; - unsigned numBits = 30 - kNumAlignBits; - do - { - range >>= 1; - p->rc.low += range; - RC_NORM(&p->rc) - } - while (--numBits); - } - - { - // RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask); - CLzmaProb *probs = p->posAlignEncoder; - unsigned m = 1; - do - { - UInt32 ttt, newBound; - RC_BIT_PRE(p, probs + m) - RC_BIT_1(&p->rc, probs + m) - m = (m << 1) + 1; - } - while (m < kAlignTableSize); - } - p->rc.range = range; + len = LZMA_MATCH_LEN_MIN; + LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices); + RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, (1 << kNumPosSlotBits) - 1); + RangeEnc_EncodeDirectBits(&p->rc, (((UInt32)1 << 30) - 1) >> kNumAlignBits, 30 - kNumAlignBits); + RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask); } - static SRes CheckErrors(CLzmaEnc *p) { if (p->result != SZ_OK) return p->result; if (p->rc.res != SZ_OK) p->result = SZ_ERROR_WRITE; - - #ifndef Z7_ST - if ( - // p->mf_Failure || - (p->mtMode && - ( // p->matchFinderMt.failure_LZ_LZ || - p->matchFinderMt.failure_LZ_BT)) - ) - { - p->result = MY_HRES_ERROR_INTERNAL_ERROR; - // printf("\nCheckErrors p->matchFinderMt.failureLZ\n"); - } - #endif - - if (MFB.result != SZ_OK) + if (p->matchFinderBase.result != SZ_OK) p->result = SZ_ERROR_READ; - if (p->result != SZ_OK) p->finished = True; return p->result; } - -Z7_NO_INLINE static SRes Flush(CLzmaEnc *p, UInt32 nowPos) +static SRes Flush(CLzmaEnc *p, UInt32 nowPos) { /* ReleaseMFStream(); */ p->finished = True; @@ -2198,140 +1652,61 @@ Z7_NO_INLINE static SRes Flush(CLzmaEnc *p, UInt32 nowPos) return CheckErrors(p); } - -Z7_NO_INLINE static void FillAlignPrices(CLzmaEnc *p) +static void FillAlignPrices(CLzmaEnc *p) { - unsigned i; - const CProbPrice *ProbPrices = p->ProbPrices; - const CLzmaProb *probs = p->posAlignEncoder; - // p->alignPriceCount = 0; - for (i = 0; i < kAlignTableSize / 2; i++) - { - UInt32 price = 0; - unsigned sym = i; - unsigned m = 1; - unsigned bit; - UInt32 prob; - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; - prob = probs[m]; - p->alignPrices[i ] = price + GET_PRICEa_0(prob); - p->alignPrices[i + 8] = price + GET_PRICEa_1(prob); - // p->alignPrices[i] = RcTree_ReverseGetPrice(p->posAlignEncoder, kNumAlignBits, i, p->ProbPrices); - } + UInt32 i; + for (i = 0; i < kAlignTableSize; i++) + p->alignPrices[i] = RcTree_ReverseGetPrice(p->posAlignEncoder, kNumAlignBits, i, p->ProbPrices); + p->alignPriceCount = 0; } - -Z7_NO_INLINE static void FillDistancesPrices(CLzmaEnc *p) +static void FillDistancesPrices(CLzmaEnc *p) { - // int y; for (y = 0; y < 100; y++) { - UInt32 tempPrices[kNumFullDistances]; - unsigned i, lps; + UInt32 i, lenToPosState; + for (i = kStartPosModelIndex; i < kNumFullDistances; i++) + { + UInt32 posSlot = GetPosSlot1(i); + UInt32 footerBits = ((posSlot >> 1) - 1); + UInt32 base = ((2 | (posSlot & 1)) << footerBits); + tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base - posSlot - 1, footerBits, i - base, p->ProbPrices); + } - const CProbPrice *ProbPrices = p->ProbPrices; + for (lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++) + { + UInt32 posSlot; + const CLzmaProb *encoder = p->posSlotEncoder[lenToPosState]; + UInt32 *posSlotPrices = p->posSlotPrices[lenToPosState]; + for (posSlot = 0; posSlot < p->distTableSize; posSlot++) + posSlotPrices[posSlot] = RcTree_GetPrice(encoder, kNumPosSlotBits, posSlot, p->ProbPrices); + for (posSlot = kEndPosModelIndex; posSlot < p->distTableSize; posSlot++) + posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << kNumBitPriceShiftBits); + + { + UInt32 *distancesPrices = p->distancesPrices[lenToPosState]; + UInt32 i; + for (i = 0; i < kStartPosModelIndex; i++) + distancesPrices[i] = posSlotPrices[i]; + for (; i < kNumFullDistances; i++) + distancesPrices[i] = posSlotPrices[GetPosSlot1(i)] + tempPrices[i]; + } + } p->matchPriceCount = 0; - - for (i = kStartPosModelIndex / 2; i < kNumFullDistances / 2; i++) - { - unsigned posSlot = GetPosSlot1(i); - unsigned footerBits = (posSlot >> 1) - 1; - unsigned base = ((2 | (posSlot & 1)) << footerBits); - const CLzmaProb *probs = p->posEncoders + (size_t)base * 2; - // tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base, footerBits, i - base, p->ProbPrices); - UInt32 price = 0; - unsigned m = 1; - unsigned sym = i; - unsigned offset = (unsigned)1 << footerBits; - base += i; - - if (footerBits) - do - { - unsigned bit = sym & 1; - sym >>= 1; - price += GET_PRICEa(probs[m], bit); - m = (m << 1) + bit; - } - while (--footerBits); - - { - unsigned prob = probs[m]; - tempPrices[base ] = price + GET_PRICEa_0(prob); - tempPrices[base + offset] = price + GET_PRICEa_1(prob); - } - } - - for (lps = 0; lps < kNumLenToPosStates; lps++) - { - unsigned slot; - unsigned distTableSize2 = (p->distTableSize + 1) >> 1; - UInt32 *posSlotPrices = p->posSlotPrices[lps]; - const CLzmaProb *probs = p->posSlotEncoder[lps]; - - for (slot = 0; slot < distTableSize2; slot++) - { - // posSlotPrices[slot] = RcTree_GetPrice(encoder, kNumPosSlotBits, slot, p->ProbPrices); - UInt32 price; - unsigned bit; - unsigned sym = slot + (1 << (kNumPosSlotBits - 1)); - unsigned prob; - bit = sym & 1; sym >>= 1; price = GET_PRICEa(probs[sym], bit); - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit); - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit); - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit); - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit); - prob = probs[(size_t)slot + (1 << (kNumPosSlotBits - 1))]; - posSlotPrices[(size_t)slot * 2 ] = price + GET_PRICEa_0(prob); - posSlotPrices[(size_t)slot * 2 + 1] = price + GET_PRICEa_1(prob); - } - - { - UInt32 delta = ((UInt32)((kEndPosModelIndex / 2 - 1) - kNumAlignBits) << kNumBitPriceShiftBits); - for (slot = kEndPosModelIndex / 2; slot < distTableSize2; slot++) - { - posSlotPrices[(size_t)slot * 2 ] += delta; - posSlotPrices[(size_t)slot * 2 + 1] += delta; - delta += ((UInt32)1 << kNumBitPriceShiftBits); - } - } - - { - UInt32 *dp = p->distancesPrices[lps]; - - dp[0] = posSlotPrices[0]; - dp[1] = posSlotPrices[1]; - dp[2] = posSlotPrices[2]; - dp[3] = posSlotPrices[3]; - - for (i = 4; i < kNumFullDistances; i += 2) - { - UInt32 slotPrice = posSlotPrices[GetPosSlot1(i)]; - dp[i ] = slotPrice + tempPrices[i]; - dp[i + 1] = slotPrice + tempPrices[i + 1]; - } - } - } - // } } - - -static void LzmaEnc_Construct(CLzmaEnc *p) +void LzmaEnc_Construct(CLzmaEnc *p) { RangeEnc_Construct(&p->rc); - MatchFinder_Construct(&MFB); - - #ifndef Z7_ST - p->matchFinderMt.MatchFinder = &MFB; + MatchFinder_Construct(&p->matchFinderBase); + #ifdef COMPRESS_MF_MT MatchFinderMt_Construct(&p->matchFinderMt); + p->matchFinderMt.MatchFinder = &p->matchFinderBase; #endif { CLzmaEncProps props; LzmaEncProps_Init(&props); - LzmaEnc_SetProps((CLzmaEncHandle)(void *)p, &props); + LzmaEnc_SetProps(p, &props); } #ifndef LZMA_LOG_BSR @@ -2339,370 +1714,226 @@ static void LzmaEnc_Construct(CLzmaEnc *p) #endif LzmaEnc_InitPriceTables(p->ProbPrices); - p->litProbs = NULL; - p->saveState.litProbs = NULL; + p->litProbs = 0; + p->saveState.litProbs = 0; } -CLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc) +CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc) { void *p; - p = ISzAlloc_Alloc(alloc, sizeof(CLzmaEnc)); - if (p) + p = alloc->Alloc(alloc, sizeof(CLzmaEnc)); + if (p != 0) LzmaEnc_Construct((CLzmaEnc *)p); return p; } -static void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAllocPtr alloc) +void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc) { - ISzAlloc_Free(alloc, p->litProbs); - ISzAlloc_Free(alloc, p->saveState.litProbs); - p->litProbs = NULL; - p->saveState.litProbs = NULL; + alloc->Free(alloc, p->litProbs); + alloc->Free(alloc, p->saveState.litProbs); + p->litProbs = 0; + p->saveState.litProbs = 0; } -static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAllocPtr alloc, ISzAllocPtr allocBig) +void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig) { - #ifndef Z7_ST + #ifdef COMPRESS_MF_MT MatchFinderMt_Destruct(&p->matchFinderMt, allocBig); #endif - - MatchFinder_Free(&MFB, allocBig); + MatchFinder_Free(&p->matchFinderBase, allocBig); LzmaEnc_FreeLits(p, alloc); RangeEnc_Free(&p->rc, alloc); } -void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig) +void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig) { - // GET_CLzmaEnc_p - LzmaEnc_Destruct(p, alloc, allocBig); - ISzAlloc_Free(alloc, p); + LzmaEnc_Destruct((CLzmaEnc *)p, alloc, allocBig); + alloc->Free(alloc, p); } - -Z7_NO_INLINE -static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpackSize) +static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize, UInt32 maxUnpackSize) { UInt32 nowPos32, startPos32; - if (p->needInit) + if (p->inStream != 0) { - #ifndef Z7_ST - if (p->mtMode) - { - RINOK(MatchFinderMt_InitMt(&p->matchFinderMt)) - } - #endif + p->matchFinderBase.stream = p->inStream; p->matchFinder.Init(p->matchFinderObj); - p->needInit = 0; + p->inStream = 0; } if (p->finished) return p->result; - RINOK(CheckErrors(p)) + RINOK(CheckErrors(p)); nowPos32 = (UInt32)p->nowPos64; startPos32 = nowPos32; if (p->nowPos64 == 0) { - unsigned numPairs; + UInt32 numPairs; Byte curByte; if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0) return Flush(p, nowPos32); ReadMatchDistances(p, &numPairs); - RangeEnc_EncodeBit_0(&p->rc, &p->isMatch[kState_Start][0]); - // p->state = kLiteralNextStates[p->state]; - curByte = *(p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset); + RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][0], 0); + p->state = kLiteralNextStates[p->state]; + curByte = p->matchFinder.GetIndexByte(p->matchFinderObj, 0 - p->additionalOffset); LitEnc_Encode(&p->rc, p->litProbs, curByte); p->additionalOffset--; nowPos32++; } if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) != 0) - for (;;) { - UInt32 dist; - unsigned len, posState; - UInt32 range, ttt, newBound; - CLzmaProb *probs; - - if (p->fastMode) - len = GetOptimumFast(p); - else - { - unsigned oci = p->optCur; - if (p->optEnd == oci) - len = GetOptimum(p, nowPos32); - else - { - const COptimal *opt = &p->opt[oci]; - len = opt->len; - p->backRes = opt->dist; - p->optCur = oci + 1; - } - } + UInt32 pos, len, posState; - posState = (unsigned)nowPos32 & p->pbMask; - range = p->rc.range; - probs = &p->isMatch[p->state][posState]; - - RC_BIT_PRE(&p->rc, probs) - - dist = p->backRes; + if (p->fastMode) + len = GetOptimumFast(p, &pos); + else + len = GetOptimum(p, nowPos32, &pos); #ifdef SHOW_STAT2 - printf("\n pos = %6X, len = %3u pos = %6u", nowPos32, len, dist); + printf("\n pos = %4X, len = %d pos = %d", nowPos32, len, pos); #endif - if (dist == MARK_LIT) + posState = nowPos32 & p->pbMask; + if (len == 1 && pos == (UInt32)-1) { Byte curByte; + CLzmaProb *probs; const Byte *data; - unsigned state; - RC_BIT_0(&p->rc, probs) - p->rc.range = range; + RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 0); data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; - probs = LIT_PROBS(nowPos32, *(data - 1)); curByte = *data; - state = p->state; - p->state = kLiteralNextStates[state]; - if (IsLitState(state)) + probs = LIT_PROBS(nowPos32, *(data - 1)); + if (IsCharState(p->state)) LitEnc_Encode(&p->rc, probs, curByte); else - LitEnc_EncodeMatched(&p->rc, probs, curByte, *(data - p->reps[0])); + LitEnc_EncodeMatched(&p->rc, probs, curByte, *(data - p->reps[0] - 1)); + p->state = kLiteralNextStates[p->state]; } else { - RC_BIT_1(&p->rc, probs) - probs = &p->isRep[p->state]; - RC_BIT_PRE(&p->rc, probs) - - if (dist < LZMA_NUM_REPS) + RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1); + if (pos < LZMA_NUM_REPS) { - RC_BIT_1(&p->rc, probs) - probs = &p->isRepG0[p->state]; - RC_BIT_PRE(&p->rc, probs) - if (dist == 0) + RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 1); + if (pos == 0) { - RC_BIT_0(&p->rc, probs) - probs = &p->isRep0Long[p->state][posState]; - RC_BIT_PRE(&p->rc, probs) - if (len != 1) - { - RC_BIT_1_BASE(&p->rc, probs) - } - else - { - RC_BIT_0_BASE(&p->rc, probs) - p->state = kShortRepNextStates[p->state]; - } + RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 0); + RangeEnc_EncodeBit(&p->rc, &p->isRep0Long[p->state][posState], ((len == 1) ? 0 : 1)); } else { - RC_BIT_1(&p->rc, probs) - probs = &p->isRepG1[p->state]; - RC_BIT_PRE(&p->rc, probs) - if (dist == 1) - { - RC_BIT_0_BASE(&p->rc, probs) - dist = p->reps[1]; - } + UInt32 distance = p->reps[pos]; + RangeEnc_EncodeBit(&p->rc, &p->isRepG0[p->state], 1); + if (pos == 1) + RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 0); else { - RC_BIT_1(&p->rc, probs) - probs = &p->isRepG2[p->state]; - RC_BIT_PRE(&p->rc, probs) - if (dist == 2) - { - RC_BIT_0_BASE(&p->rc, probs) - dist = p->reps[2]; - } - else - { - RC_BIT_1_BASE(&p->rc, probs) - dist = p->reps[3]; + RangeEnc_EncodeBit(&p->rc, &p->isRepG1[p->state], 1); + RangeEnc_EncodeBit(&p->rc, &p->isRepG2[p->state], pos - 2); + if (pos == 3) p->reps[3] = p->reps[2]; - } p->reps[2] = p->reps[1]; } p->reps[1] = p->reps[0]; - p->reps[0] = dist; + p->reps[0] = distance; } - - RC_NORM(&p->rc) - - p->rc.range = range; - - if (len != 1) + if (len == 1) + p->state = kShortRepNextStates[p->state]; + else { - LenEnc_Encode(&p->repLenProbs, &p->rc, len - LZMA_MATCH_LEN_MIN, posState); - --p->repLenEncCounter; + LenEnc_Encode2(&p->repLenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices); p->state = kRepNextStates[p->state]; } } else { - unsigned posSlot; - RC_BIT_0(&p->rc, probs) - p->rc.range = range; + UInt32 posSlot; + RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0); p->state = kMatchNextStates[p->state]; + LenEnc_Encode2(&p->lenEnc, &p->rc, len - LZMA_MATCH_LEN_MIN, posState, !p->fastMode, p->ProbPrices); + pos -= LZMA_NUM_REPS; + GetPosSlot(pos, posSlot); + RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot); + + if (posSlot >= kStartPosModelIndex) + { + UInt32 footerBits = ((posSlot >> 1) - 1); + UInt32 base = ((2 | (posSlot & 1)) << footerBits); + UInt32 posReduced = pos - base; - LenEnc_Encode(&p->lenProbs, &p->rc, len - LZMA_MATCH_LEN_MIN, posState); - // --p->lenEnc.counter; - - dist -= LZMA_NUM_REPS; + if (posSlot < kEndPosModelIndex) + RcTree_ReverseEncode(&p->rc, p->posEncoders + base - posSlot - 1, footerBits, posReduced); + else + { + RangeEnc_EncodeDirectBits(&p->rc, posReduced >> kNumAlignBits, footerBits - kNumAlignBits); + RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, posReduced & kAlignMask); + p->alignPriceCount++; + } + } p->reps[3] = p->reps[2]; p->reps[2] = p->reps[1]; p->reps[1] = p->reps[0]; - p->reps[0] = dist + 1; - + p->reps[0] = pos; p->matchPriceCount++; - GetPosSlot(dist, posSlot) - // RcTree_Encode_PosSlot(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], posSlot); - { - UInt32 sym = (UInt32)posSlot + (1 << kNumPosSlotBits); - range = p->rc.range; - probs = p->posSlotEncoder[GetLenToPosState(len)]; - do - { - CLzmaProb *prob = probs + (sym >> kNumPosSlotBits); - UInt32 bit = (sym >> (kNumPosSlotBits - 1)) & 1; - sym <<= 1; - RC_BIT(&p->rc, prob, bit) - } - while (sym < (1 << kNumPosSlotBits * 2)); - p->rc.range = range; - } - - if (dist >= kStartPosModelIndex) - { - unsigned footerBits = ((posSlot >> 1) - 1); - - if (dist < kNumFullDistances) - { - unsigned base = ((2 | (posSlot & 1)) << footerBits); - RcTree_ReverseEncode(&p->rc, p->posEncoders + base, footerBits, (unsigned)(dist /* - base */)); - } - else - { - UInt32 pos2 = (dist | 0xF) << (32 - footerBits); - range = p->rc.range; - // RangeEnc_EncodeDirectBits(&p->rc, posReduced >> kNumAlignBits, footerBits - kNumAlignBits); - /* - do - { - range >>= 1; - p->rc.low += range & (0 - ((dist >> --footerBits) & 1)); - RC_NORM(&p->rc) - } - while (footerBits > kNumAlignBits); - */ - do - { - range >>= 1; - p->rc.low += range & (0 - (pos2 >> 31)); - pos2 += pos2; - RC_NORM(&p->rc) - } - while (pos2 != 0xF0000000); - - - // RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, posReduced & kAlignMask); - - { - unsigned m = 1; - unsigned bit; - bit = dist & 1; dist >>= 1; RC_BIT(&p->rc, p->posAlignEncoder + m, bit) m = (m << 1) + bit; - bit = dist & 1; dist >>= 1; RC_BIT(&p->rc, p->posAlignEncoder + m, bit) m = (m << 1) + bit; - bit = dist & 1; dist >>= 1; RC_BIT(&p->rc, p->posAlignEncoder + m, bit) m = (m << 1) + bit; - bit = dist & 1; RC_BIT(&p->rc, p->posAlignEncoder + m, bit) - p->rc.range = range; - // p->alignPriceCount++; - } - } - } } } - - nowPos32 += (UInt32)len; p->additionalOffset -= len; - + nowPos32 += len; if (p->additionalOffset == 0) { UInt32 processed; - if (!p->fastMode) { - /* - if (p->alignPriceCount >= 16) // kAlignTableSize - FillAlignPrices(p); - if (p->matchPriceCount >= 128) + if (p->matchPriceCount >= (1 << 7)) FillDistancesPrices(p); - if (p->lenEnc.counter <= 0) - LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, &p->lenProbs, p->ProbPrices); - */ - if (p->matchPriceCount >= 64) - { + if (p->alignPriceCount >= kAlignTableSize) FillAlignPrices(p); - // { int y; for (y = 0; y < 100; y++) { - FillDistancesPrices(p); - // }} - LenPriceEnc_UpdateTables(&p->lenEnc, (unsigned)1 << p->pb, &p->lenProbs, p->ProbPrices); - } - if (p->repLenEncCounter <= 0) - { - p->repLenEncCounter = REP_LEN_COUNT; - LenPriceEnc_UpdateTables(&p->repLenEnc, (unsigned)1 << p->pb, &p->repLenProbs, p->ProbPrices); - } } - if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0) break; processed = nowPos32 - startPos32; - - if (maxPackSize) + if (useLimits) { - if (processed + kNumOpts + 300 >= maxUnpackSize - || RangeEnc_GetProcessed_sizet(&p->rc) + kPackReserve >= maxPackSize) + if (processed + kNumOpts + 300 >= maxUnpackSize || + RangeEnc_GetProcessed(&p->rc) + kNumOpts * 2 >= maxPackSize) break; } - else if (processed >= (1 << 17)) + else if (processed >= (1 << 15)) { p->nowPos64 += nowPos32 - startPos32; return CheckErrors(p); } } } - p->nowPos64 += nowPos32 - startPos32; return Flush(p, nowPos32); } - - #define kBigHashDicLimit ((UInt32)1 << 24) -static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) +static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) { UInt32 beforeSize = kNumOpts; - UInt32 dictSize; - if (!RangeEnc_Alloc(&p->rc, alloc)) return SZ_ERROR_MEM; - - #ifndef Z7_ST - p->mtMode = (p->multiThread && !p->fastMode && (MFB.btMode != 0)); + #ifdef COMPRESS_MF_MT + Bool btMode = (p->matchFinderBase.btMode != 0);; + p->mtMode = (p->multiThread && !p->fastMode && btMode); #endif { unsigned lclp = p->lc + p->lp; - if (!p->litProbs || !p->saveState.litProbs || p->lclp != lclp) + if (p->litProbs == 0 || p->saveState.litProbs == 0 || p->lclp != lclp) { LzmaEnc_FreeLits(p, alloc); - p->litProbs = (CLzmaProb *)ISzAlloc_Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb)); - p->saveState.litProbs = (CLzmaProb *)ISzAlloc_Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb)); - if (!p->litProbs || !p->saveState.litProbs) + p->litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb)); + p->saveState.litProbs = (CLzmaProb *)alloc->Alloc(alloc, (0x300 << lclp) * sizeof(CLzmaProb)); + if (p->litProbs == 0 || p->saveState.litProbs == 0) { LzmaEnc_FreeLits(p, alloc); return SZ_ERROR_MEM; @@ -2711,71 +1942,42 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAllocPtr alloc, } } - MFB.bigHash = (Byte)(p->dictSize > kBigHashDicLimit ? 1 : 0); + p->matchFinderBase.bigHash = (p->dictSize > kBigHashDicLimit); + if (beforeSize + p->dictSize < keepWindowSize) + beforeSize = keepWindowSize - p->dictSize; - dictSize = p->dictSize; - if (dictSize == ((UInt32)2 << 30) || - dictSize == ((UInt32)3 << 30)) - { - /* 21.03 : here we reduce the dictionary for 2 reasons: - 1) we don't want 32-bit back_distance matches in decoder for 2 GB dictionary. - 2) we want to elimate useless last MatchFinder_Normalize3() for corner cases, - where data size is aligned for 1 GB: 5/6/8 GB. - That reducing must be >= 1 for such corner cases. */ - dictSize -= 1; - } - - if (beforeSize + dictSize < keepWindowSize) - beforeSize = keepWindowSize - dictSize; - - /* in worst case we can look ahead for - max(LZMA_MATCH_LEN_MAX, numFastBytes + 1 + numFastBytes) bytes. - we send larger value for (keepAfter) to MantchFinder_Create(): - (numFastBytes + LZMA_MATCH_LEN_MAX + 1) - */ - - #ifndef Z7_ST + #ifdef COMPRESS_MF_MT if (p->mtMode) { - RINOK(MatchFinderMt_Create(&p->matchFinderMt, dictSize, beforeSize, - p->numFastBytes, LZMA_MATCH_LEN_MAX + 1 /* 18.04 */ - , allocBig)) + RINOK(MatchFinderMt_Create(&p->matchFinderMt, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig)); p->matchFinderObj = &p->matchFinderMt; - MFB.bigHash = (Byte)(MFB.hashMask >= 0xFFFFFF ? 1 : 0); MatchFinderMt_CreateVTable(&p->matchFinderMt, &p->matchFinder); } else #endif { - if (!MatchFinder_Create(&MFB, dictSize, beforeSize, - p->numFastBytes, LZMA_MATCH_LEN_MAX + 1 /* 21.03 */ - , allocBig)) + if (!MatchFinder_Create(&p->matchFinderBase, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig)) return SZ_ERROR_MEM; - p->matchFinderObj = &MFB; - MatchFinder_CreateVTable(&MFB, &p->matchFinder); + p->matchFinderObj = &p->matchFinderBase; + MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder); } - return SZ_OK; } -static void LzmaEnc_Init(CLzmaEnc *p) +void LzmaEnc_Init(CLzmaEnc *p) { - unsigned i; + UInt32 i; p->state = 0; - p->reps[0] = - p->reps[1] = - p->reps[2] = - p->reps[3] = 1; + for (i = 0 ; i < LZMA_NUM_REPS; i++) + p->reps[i] = 0; RangeEnc_Init(&p->rc); - for (i = 0; i < (1 << kNumAlignBits); i++) - p->posAlignEncoder[i] = kProbInitValue; for (i = 0; i < kNumStates; i++) { - unsigned j; + UInt32 j; for (j = 0; j < LZMA_NUM_PB_STATES_MAX; j++) { p->isMatch[i][j] = kProbInitValue; @@ -2787,50 +1989,41 @@ static void LzmaEnc_Init(CLzmaEnc *p) p->isRepG2[i] = kProbInitValue; } + { + UInt32 num = 0x300 << (p->lp + p->lc); + for (i = 0; i < num; i++) + p->litProbs[i] = kProbInitValue; + } + { for (i = 0; i < kNumLenToPosStates; i++) { CLzmaProb *probs = p->posSlotEncoder[i]; - unsigned j; + UInt32 j; for (j = 0; j < (1 << kNumPosSlotBits); j++) probs[j] = kProbInitValue; } } { - for (i = 0; i < kNumFullDistances; i++) + for (i = 0; i < kNumFullDistances - kEndPosModelIndex; i++) p->posEncoders[i] = kProbInitValue; } - { - UInt32 num = (UInt32)0x300 << (p->lp + p->lc); - UInt32 k; - CLzmaProb *probs = p->litProbs; - for (k = 0; k < num; k++) - probs[k] = kProbInitValue; - } + LenEnc_Init(&p->lenEnc.p); + LenEnc_Init(&p->repLenEnc.p); + for (i = 0; i < (1 << kNumAlignBits); i++) + p->posAlignEncoder[i] = kProbInitValue; - LenEnc_Init(&p->lenProbs); - LenEnc_Init(&p->repLenProbs); - - p->optEnd = 0; - p->optCur = 0; - - { - for (i = 0; i < kNumOpts; i++) - p->opt[i].price = kInfinityPrice; - } - + p->optimumEndIndex = 0; + p->optimumCurrentIndex = 0; p->additionalOffset = 0; - p->pbMask = ((unsigned)1 << p->pb) - 1; - p->lpMask = ((UInt32)0x100 << p->lp) - ((unsigned)0x100 >> p->lc); - - // p->mf_Failure = False; + p->pbMask = (1 << p->pb) - 1; + p->lpMask = (1 << p->lp) - 1; } - -static void LzmaEnc_InitPrices(CLzmaEnc *p) +void LzmaEnc_InitPrices(CLzmaEnc *p) { if (!p->fastMode) { @@ -2841,125 +2034,116 @@ static void LzmaEnc_InitPrices(CLzmaEnc *p) p->lenEnc.tableSize = p->repLenEnc.tableSize = p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN; - - p->repLenEncCounter = REP_LEN_COUNT; - - LenPriceEnc_UpdateTables(&p->lenEnc, (unsigned)1 << p->pb, &p->lenProbs, p->ProbPrices); - LenPriceEnc_UpdateTables(&p->repLenEnc, (unsigned)1 << p->pb, &p->repLenProbs, p->ProbPrices); + LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, p->ProbPrices); + LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, p->ProbPrices); } -static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) +static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) { - unsigned i; - for (i = kEndPosModelIndex / 2; i < kDicLogSizeMax; i++) + UInt32 i; + for (i = 0; i < (UInt32)kDicLogSizeMaxCompress; i++) if (p->dictSize <= ((UInt32)1 << i)) break; p->distTableSize = i * 2; p->finished = False; p->result = SZ_OK; - p->nowPos64 = 0; - p->needInit = 1; - RINOK(LzmaEnc_Alloc(p, keepWindowSize, alloc, allocBig)) + RINOK(LzmaEnc_Alloc(p, keepWindowSize, alloc, allocBig)); LzmaEnc_Init(p); LzmaEnc_InitPrices(p); + p->nowPos64 = 0; return SZ_OK; } -static SRes LzmaEnc_Prepare(CLzmaEncHandle p, - ISeqOutStreamPtr outStream, - ISeqInStreamPtr inStream, - ISzAllocPtr alloc, ISzAllocPtr allocBig) +static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqInStream *inStream, ISeqOutStream *outStream, + ISzAlloc *alloc, ISzAlloc *allocBig) { - // GET_CLzmaEnc_p - MatchFinder_SET_STREAM(&MFB, inStream) + CLzmaEnc *p = (CLzmaEnc *)pp; + p->inStream = inStream; p->rc.outStream = outStream; return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig); } -SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle p, - ISeqInStreamPtr inStream, UInt32 keepWindowSize, - ISzAllocPtr alloc, ISzAllocPtr allocBig) +SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, + ISeqInStream *inStream, UInt32 keepWindowSize, + ISzAlloc *alloc, ISzAlloc *allocBig) { - // GET_CLzmaEnc_p - MatchFinder_SET_STREAM(&MFB, inStream) + CLzmaEnc *p = (CLzmaEnc *)pp; + p->inStream = inStream; return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); } -SRes LzmaEnc_MemPrepare(CLzmaEncHandle p, - const Byte *src, SizeT srcLen, - UInt32 keepWindowSize, - ISzAllocPtr alloc, ISzAllocPtr allocBig) +static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen) { - // GET_CLzmaEnc_p - MatchFinder_SET_DIRECT_INPUT_BUF(&MFB, src, srcLen) - LzmaEnc_SetDataSize(p, srcLen); + p->seqBufInStream.funcTable.Read = MyRead; + p->seqBufInStream.data = src; + p->seqBufInStream.rem = srcLen; +} + +SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, + UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig) +{ + CLzmaEnc *p = (CLzmaEnc *)pp; + LzmaEnc_SetInputBuf(p, src, srcLen); + p->inStream = &p->seqBufInStream.funcTable; return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); } -void LzmaEnc_Finish(CLzmaEncHandle p) +void LzmaEnc_Finish(CLzmaEncHandle pp) { - #ifndef Z7_ST - // GET_CLzmaEnc_p + #ifdef COMPRESS_MF_MT + CLzmaEnc *p = (CLzmaEnc *)pp; if (p->mtMode) MatchFinderMt_ReleaseStream(&p->matchFinderMt); #else - UNUSED_VAR(p) + pp = pp; #endif } - -typedef struct +typedef struct _CSeqOutStreamBuf { - ISeqOutStream vt; + ISeqOutStream funcTable; Byte *data; - size_t rem; - BoolInt overflow; -} CLzmaEnc_SeqOutStreamBuf; + SizeT rem; + Bool overflow; +} CSeqOutStreamBuf; -static size_t SeqOutStreamBuf_Write(ISeqOutStreamPtr pp, const void *data, size_t size) +static size_t MyWrite(void *pp, const void *data, size_t size) { - Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR_pp_vt_p(CLzmaEnc_SeqOutStreamBuf) + CSeqOutStreamBuf *p = (CSeqOutStreamBuf *)pp; if (p->rem < size) { size = p->rem; p->overflow = True; } - if (size != 0) - { - memcpy(p->data, data, size); - p->rem -= size; - p->data += size; - } + memcpy(p->data, data, size); + p->rem -= size; + p->data += size; return size; } -/* -UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle p) +UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) { - GET_const_CLzmaEnc_p + const CLzmaEnc *p = (CLzmaEnc *)pp; return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); } -*/ -const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle p) +const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp) { - // GET_const_CLzmaEnc_p + const CLzmaEnc *p = (CLzmaEnc *)pp; return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; } - -// (desiredPackSize == 0) is not allowed -SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle p, BoolInt reInit, +SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize) { - // GET_CLzmaEnc_p + CLzmaEnc *p = (CLzmaEnc *)pp; UInt64 nowPos64; SRes res; - CLzmaEnc_SeqOutStreamBuf outStream; + CSeqOutStreamBuf outStream; - outStream.vt.Write = SeqOutStreamBuf_Write; + outStream.funcTable.Write = MyWrite; outStream.data = dest; outStream.rem = *destLen; outStream.overflow = False; @@ -2971,11 +2155,11 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle p, BoolInt reInit, if (reInit) LzmaEnc_Init(p); LzmaEnc_InitPrices(p); - RangeEnc_Init(&p->rc); - p->rc.outStream = &outStream.vt; nowPos64 = p->nowPos64; - - res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize); + RangeEnc_Init(&p->rc); + p->rc.outStream = &outStream.funcTable; + + res = LzmaEnc_CodeOneBlock(p, True, desiredPackSize, *unpackSize); *unpackSize = (UInt32)(p->nowPos64 - nowPos64); *destLen -= outStream.rem; @@ -2985,26 +2169,29 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle p, BoolInt reInit, return res; } - -Z7_NO_INLINE -static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgressPtr progress) +SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress, + ISzAlloc *alloc, ISzAlloc *allocBig) { + CLzmaEnc *p = (CLzmaEnc *)pp; SRes res = SZ_OK; - #ifndef Z7_ST + #ifdef COMPRESS_MF_MT Byte allocaDummy[0x300]; - allocaDummy[0] = 0; - allocaDummy[1] = allocaDummy[0]; + int i = 0; + for (i = 0; i < 16; i++) + allocaDummy[i] = (Byte)i; #endif + RINOK(LzmaEnc_Prepare(pp, inStream, outStream, alloc, allocBig)); + for (;;) { - res = LzmaEnc_CodeOneBlock(p, 0, 0); - if (res != SZ_OK || p->finished) + res = LzmaEnc_CodeOneBlock(p, False, 0, 0); + if (res != SZ_OK || p->finished != 0) break; - if (progress) + if (progress != 0) { - res = ICompressProgress_Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc)); + res = progress->Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc)); if (res != SZ_OK) { res = SZ_ERROR_PROGRESS; @@ -3012,110 +2199,71 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgressPtr progress) } } } - - LzmaEnc_Finish((CLzmaEncHandle)(void *)p); - - /* - if (res == SZ_OK && !Inline_MatchFinder_IsFinishedOK(&MFB)) - res = SZ_ERROR_FAIL; - } - */ - + LzmaEnc_Finish(pp); return res; } - -SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStreamPtr outStream, ISeqInStreamPtr inStream, ICompressProgressPtr progress, - ISzAllocPtr alloc, ISzAllocPtr allocBig) -{ - // GET_CLzmaEnc_p - RINOK(LzmaEnc_Prepare(p, outStream, inStream, alloc, allocBig)) - return LzmaEnc_Encode2(p, progress); -} - - -SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *props, SizeT *size) +SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size) { + CLzmaEnc *p = (CLzmaEnc *)pp; + int i; + UInt32 dictSize = p->dictSize; if (*size < LZMA_PROPS_SIZE) return SZ_ERROR_PARAM; *size = LZMA_PROPS_SIZE; + props[0] = (Byte)((p->pb * 5 + p->lp) * 9 + p->lc); + + for (i = 11; i <= 30; i++) { - // GET_CLzmaEnc_p - const UInt32 dictSize = p->dictSize; - UInt32 v; - props[0] = (Byte)((p->pb * 5 + p->lp) * 9 + p->lc); - - // we write aligned dictionary value to properties for lzma decoder - if (dictSize >= ((UInt32)1 << 21)) + if (dictSize <= ((UInt32)2 << i)) { - const UInt32 kDictMask = ((UInt32)1 << 20) - 1; - v = (dictSize + kDictMask) & ~kDictMask; - if (v < dictSize) - v = dictSize; + dictSize = (2 << i); + break; } - else + if (dictSize <= ((UInt32)3 << i)) { - unsigned i = 11 * 2; - do - { - v = (UInt32)(2 + (i & 1)) << (i >> 1); - i++; - } - while (v < dictSize); + dictSize = (3 << i); + break; } - - SetUi32(props + 1, v) - return SZ_OK; } + + for (i = 0; i < 4; i++) + props[1 + i] = (Byte)(dictSize >> (8 * i)); + return SZ_OK; } - -unsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle p) -{ - // GET_CLzmaEnc_p - return (unsigned)p->writeEndMark; -} - - -SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, - int writeEndMark, ICompressProgressPtr progress, ISzAllocPtr alloc, ISzAllocPtr allocBig) +SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, + int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) { SRes res; - // GET_CLzmaEnc_p + CLzmaEnc *p = (CLzmaEnc *)pp; - CLzmaEnc_SeqOutStreamBuf outStream; + CSeqOutStreamBuf outStream; - outStream.vt.Write = SeqOutStreamBuf_Write; + LzmaEnc_SetInputBuf(p, src, srcLen); + + outStream.funcTable.Write = MyWrite; outStream.data = dest; outStream.rem = *destLen; outStream.overflow = False; p->writeEndMark = writeEndMark; - p->rc.outStream = &outStream.vt; + res = LzmaEnc_Encode(pp, &outStream.funcTable, &p->seqBufInStream.funcTable, + progress, alloc, allocBig); - res = LzmaEnc_MemPrepare(p, src, srcLen, 0, alloc, allocBig); - - if (res == SZ_OK) - { - res = LzmaEnc_Encode2(p, progress); - if (res == SZ_OK && p->nowPos64 != srcLen) - res = SZ_ERROR_FAIL; - } - - *destLen -= (SizeT)outStream.rem; + *destLen -= outStream.rem; if (outStream.overflow) return SZ_ERROR_OUTPUT_EOF; return res; } - SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, - ICompressProgressPtr progress, ISzAllocPtr alloc, ISzAllocPtr allocBig) + ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig) { - CLzmaEncHandle p = LzmaEnc_Create(alloc); + CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc); SRes res; - if (!p) + if (p == 0) return SZ_ERROR_MEM; res = LzmaEnc_SetProps(p, props); @@ -3130,15 +2278,3 @@ SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, LzmaEnc_Destroy(p, alloc, allocBig); return res; } - - -/* -#ifndef Z7_ST -void LzmaEnc_GetLzThreads(CLzmaEncHandle p, HANDLE lz_threads[2]) -{ - GET_const_CLzmaEnc_p - lz_threads[0] = p->matchFinderMt.hashSync.thread; - lz_threads[1] = p->matchFinderMt.btSync.thread; -} -#endif -*/ diff --git a/extern/lzma/LzmaEnc.h b/extern/lzma/LzmaEnc.h index 9f8039a1032..bfbc7d2b9c3 100644 --- a/extern/lzma/LzmaEnc.h +++ b/extern/lzma/LzmaEnc.h @@ -1,21 +1,19 @@ /* LzmaEnc.h -- LZMA Encoder -2023-04-13 : Igor Pavlov : Public domain */ +2008-10-04 : Igor Pavlov : Public domain */ -#ifndef ZIP7_INC_LZMA_ENC_H -#define ZIP7_INC_LZMA_ENC_H +#ifndef __LZMAENC_H +#define __LZMAENC_H -#include "7zTypes.h" - -EXTERN_C_BEGIN +#include "Types.h" #define LZMA_PROPS_SIZE 5 -typedef struct +typedef struct _CLzmaEncProps { - int level; /* 0 <= level <= 9 */ + int level; /* 0 <= level <= 9 */ UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version - (1 << 12) <= dictSize <= (3 << 29) for 64-bit version - default = (1 << 24) */ + (1 << 12) <= dictSize <= (1 << 30) for 64-bit version + default = (1 << 24) */ int lc; /* 0 <= lc <= 8, default = 3 */ int lp; /* 0 <= lp <= 4, default = 0 */ int pb; /* 0 <= pb <= 4, default = 2 */ @@ -23,17 +21,9 @@ typedef struct int fb; /* 5 <= fb <= 273, default = 32 */ int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */ int numHashBytes; /* 2, 3 or 4, default = 4 */ - unsigned numHashOutBits; /* default = ? */ - UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */ + UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */ unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */ int numThreads; /* 1 or 2, default = 2 */ - - // int _pad; - - UInt64 reduceSize; /* estimated size of data that will be compressed. default = (UInt64)(Int64)-1. - Encoder uses this value to reduce dictionary size */ - - UInt64 affinity; } CLzmaEncProps; void LzmaEncProps_Init(CLzmaEncProps *p); @@ -43,41 +33,40 @@ UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2); /* ---------- CLzmaEncHandle Interface ---------- */ -/* LzmaEnc* functions can return the following exit codes: -SRes: +/* LzmaEnc_* functions can return the following exit codes: +Returns: SZ_OK - OK SZ_ERROR_MEM - Memory allocation error SZ_ERROR_PARAM - Incorrect paramater in props - SZ_ERROR_WRITE - ISeqOutStream write callback error - SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output + SZ_ERROR_WRITE - Write callback error. SZ_ERROR_PROGRESS - some break from progress callback - SZ_ERROR_THREAD - error in multithreading functions (only for Mt version) + SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) */ -typedef struct CLzmaEnc CLzmaEnc; -typedef CLzmaEnc * CLzmaEncHandle; -// Z7_DECLARE_HANDLE(CLzmaEncHandle) - -CLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc); -void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig); +typedef void * CLzmaEncHandle; +CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc); +void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig); SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props); -void LzmaEnc_SetDataSize(CLzmaEncHandle p, UInt64 expectedDataSiize); SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size); -unsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle p); - -SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStreamPtr outStream, ISeqInStreamPtr inStream, - ICompressProgressPtr progress, ISzAllocPtr alloc, ISzAllocPtr allocBig); +SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, + ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, - int writeEndMark, ICompressProgressPtr progress, ISzAllocPtr alloc, ISzAllocPtr allocBig); - + int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); /* ---------- One Call Interface ---------- */ +/* LzmaEncode +Return code: + SZ_OK - OK + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_PARAM - Incorrect paramater + SZ_ERROR_OUTPUT_EOF - output buffer overflow + SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) +*/ + SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, - ICompressProgressPtr progress, ISzAllocPtr alloc, ISzAllocPtr allocBig); - -EXTERN_C_END + ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); #endif diff --git a/extern/lzma/LzmaLib.c b/extern/lzma/LzmaLib.c index 785e8848744..02a511857c9 100644 --- a/extern/lzma/LzmaLib.c +++ b/extern/lzma/LzmaLib.c @@ -1,14 +1,18 @@ /* LzmaLib.c -- LZMA library wrapper -2023-04-02 : Igor Pavlov : Public domain */ +2008-08-05 +Igor Pavlov +Public domain */ -#include "Precomp.h" - -#include "Alloc.h" -#include "LzmaDec.h" #include "LzmaEnc.h" +#include "LzmaDec.h" +#include "Alloc.h" #include "LzmaLib.h" -Z7_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen, +static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); } +static void SzFree(void *p, void *address) { p = p; MyFree(address); } +static ISzAlloc g_Alloc = { SzAlloc, SzFree }; + +MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen, unsigned char *outProps, size_t *outPropsSize, int level, /* 0 <= level <= 9, default = 5 */ unsigned dictSize, /* use (1 << N) or (3 << N). 4 KB < dictSize <= 128 MB */ @@ -34,7 +38,7 @@ Z7_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char } -Z7_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t *srcLen, +MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t *srcLen, const unsigned char *props, size_t propsSize) { ELzmaStatus status; diff --git a/extern/lzma/LzmaLib.h b/extern/lzma/LzmaLib.h index d7c0724de5e..5c9eeec73ca 100644 --- a/extern/lzma/LzmaLib.h +++ b/extern/lzma/LzmaLib.h @@ -1,14 +1,20 @@ /* LzmaLib.h -- LZMA library interface -2023-04-02 : Igor Pavlov : Public domain */ +2008-08-05 +Igor Pavlov +Public domain */ -#ifndef ZIP7_INC_LZMA_LIB_H -#define ZIP7_INC_LZMA_LIB_H +#ifndef __LZMALIB_H +#define __LZMALIB_H -#include "7zTypes.h" +#include "Types.h" -EXTERN_C_BEGIN +#ifdef __cplusplus + #define MY_EXTERN_C extern "C" +#else + #define MY_EXTERN_C extern +#endif -#define Z7_STDAPI int Z7_STDCALL +#define MY_STDAPI MY_EXTERN_C int MY_STD_CALL #define LZMA_PROPS_SIZE 5 @@ -40,16 +46,14 @@ outPropsSize - level - compression level: 0 <= level <= 9; level dictSize algo fb - 0: 64 KB 0 32 - 1: 256 KB 0 32 - 2: 1 MB 0 32 - 3: 4 MB 0 32 - 4: 16 MB 0 32 + 0: 16 KB 0 32 + 1: 64 KB 0 32 + 2: 256 KB 0 32 + 3: 1 MB 0 32 + 4: 4 MB 0 32 5: 16 MB 1 32 6: 32 MB 1 32 - 7: 32 MB 1 64 - 8: 64 MB 1 64 - 9: 64 MB 1 64 + 7+: 64 MB 1 64 The default value for "level" is 5. @@ -85,11 +89,6 @@ fb - Word size (the number of fast bytes). numThreads - The number of thereads. 1 or 2. The default value is 2. Fast mode (algo = 0) can use only 1 thread. -In: - dest - output data buffer - destLen - output data buffer size - src - input data - srcLen - input data size Out: destLen - processed output size Returns: @@ -100,7 +99,7 @@ Returns: SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) */ -Z7_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen, +MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen, unsigned char *outProps, size_t *outPropsSize, /* *outPropsSize must be = 5 */ int level, /* 0 <= level <= 9, default = 5 */ unsigned dictSize, /* default = (1 << 24) */ @@ -115,8 +114,8 @@ Z7_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char LzmaUncompress -------------- In: - dest - output data buffer - destLen - output data buffer size + dest - output data + destLen - output data size src - input data srcLen - input data size Out: @@ -130,9 +129,7 @@ Returns: SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer (src) */ -Z7_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen, +MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen, const unsigned char *props, size_t propsSize); -EXTERN_C_END - #endif diff --git a/extern/lzma/Precomp.h b/extern/lzma/Precomp.h deleted file mode 100644 index 69afb2ffd10..00000000000 --- a/extern/lzma/Precomp.h +++ /dev/null @@ -1,10 +0,0 @@ -/* Precomp.h -- StdAfx -2023-04-02 : Igor Pavlov : Public domain */ - -#ifndef ZIP7_INC_PRECOMP_H -#define ZIP7_INC_PRECOMP_H - -#include "Compiler.h" -/* #include "7zTypes.h" */ - -#endif diff --git a/extern/lzma/README.blender b/extern/lzma/README.blender index 48ac4ab1ee4..0111946e30e 100644 --- a/extern/lzma/README.blender +++ b/extern/lzma/README.blender @@ -1,8 +1,5 @@ Project: LZMA SDK URL: https://www.7-zip.org/sdk.html License: Public Domain -Upstream version: 23.01 -Local modifications: No code changes - -- Took only files needed for Blender: C source for raw LZMA1 encoder/decoder. -- CMakeLists.txt is made for Blender codebase +Upstream version: 4.65 +Local modifications: None diff --git a/extern/lzma/Threads.c b/extern/lzma/Threads.c deleted file mode 100644 index cf52bd30307..00000000000 --- a/extern/lzma/Threads.c +++ /dev/null @@ -1,562 +0,0 @@ -/* Threads.c -- multithreading library -2023-03-04 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#ifdef _WIN32 - -#ifndef USE_THREADS_CreateThread -#include -#endif - -#include "Threads.h" - -static WRes GetError(void) -{ - const DWORD res = GetLastError(); - return res ? (WRes)res : 1; -} - -static WRes HandleToWRes(HANDLE h) { return (h != NULL) ? 0 : GetError(); } -static WRes BOOLToWRes(BOOL v) { return v ? 0 : GetError(); } - -WRes HandlePtr_Close(HANDLE *p) -{ - if (*p != NULL) - { - if (!CloseHandle(*p)) - return GetError(); - *p = NULL; - } - return 0; -} - -WRes Handle_WaitObject(HANDLE h) -{ - DWORD dw = WaitForSingleObject(h, INFINITE); - /* - (dw) result: - WAIT_OBJECT_0 // 0 - WAIT_ABANDONED // 0x00000080 : is not compatible with Win32 Error space - WAIT_TIMEOUT // 0x00000102 : is compatible with Win32 Error space - WAIT_FAILED // 0xFFFFFFFF - */ - if (dw == WAIT_FAILED) - { - dw = GetLastError(); - if (dw == 0) - return WAIT_FAILED; - } - return (WRes)dw; -} - -#define Thread_Wait(p) Handle_WaitObject(*(p)) - -WRes Thread_Wait_Close(CThread *p) -{ - WRes res = Thread_Wait(p); - WRes res2 = Thread_Close(p); - return (res != 0 ? res : res2); -} - -WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param) -{ - /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */ - - #ifdef USE_THREADS_CreateThread - - DWORD threadId; - *p = CreateThread(NULL, 0, func, param, 0, &threadId); - - #else - - unsigned threadId; - *p = (HANDLE)(_beginthreadex(NULL, 0, func, param, 0, &threadId)); - - #endif - - /* maybe we must use errno here, but probably GetLastError() is also OK. */ - return HandleToWRes(*p); -} - - -WRes Thread_Create_With_Affinity(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, CAffinityMask affinity) -{ - #ifdef USE_THREADS_CreateThread - - UNUSED_VAR(affinity) - return Thread_Create(p, func, param); - - #else - - /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */ - HANDLE h; - WRes wres; - unsigned threadId; - h = (HANDLE)(_beginthreadex(NULL, 0, func, param, CREATE_SUSPENDED, &threadId)); - *p = h; - wres = HandleToWRes(h); - if (h) - { - { - // DWORD_PTR prevMask = - SetThreadAffinityMask(h, (DWORD_PTR)affinity); - /* - if (prevMask == 0) - { - // affinity change is non-critical error, so we can ignore it - // wres = GetError(); - } - */ - } - { - DWORD prevSuspendCount = ResumeThread(h); - /* ResumeThread() returns: - 0 : was_not_suspended - 1 : was_resumed - -1 : error - */ - if (prevSuspendCount == (DWORD)-1) - wres = GetError(); - } - } - - /* maybe we must use errno here, but probably GetLastError() is also OK. */ - return wres; - - #endif -} - - -static WRes Event_Create(CEvent *p, BOOL manualReset, int signaled) -{ - *p = CreateEvent(NULL, manualReset, (signaled ? TRUE : FALSE), NULL); - return HandleToWRes(*p); -} - -WRes Event_Set(CEvent *p) { return BOOLToWRes(SetEvent(*p)); } -WRes Event_Reset(CEvent *p) { return BOOLToWRes(ResetEvent(*p)); } - -WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled) { return Event_Create(p, TRUE, signaled); } -WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled) { return Event_Create(p, FALSE, signaled); } -WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p) { return ManualResetEvent_Create(p, 0); } -WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p) { return AutoResetEvent_Create(p, 0); } - - -WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount) -{ - // negative ((LONG)maxCount) is not supported in WIN32::CreateSemaphore() - *p = CreateSemaphore(NULL, (LONG)initCount, (LONG)maxCount, NULL); - return HandleToWRes(*p); -} - -WRes Semaphore_OptCreateInit(CSemaphore *p, UInt32 initCount, UInt32 maxCount) -{ - // if (Semaphore_IsCreated(p)) - { - WRes wres = Semaphore_Close(p); - if (wres != 0) - return wres; - } - return Semaphore_Create(p, initCount, maxCount); -} - -static WRes Semaphore_Release(CSemaphore *p, LONG releaseCount, LONG *previousCount) - { return BOOLToWRes(ReleaseSemaphore(*p, releaseCount, previousCount)); } -WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num) - { return Semaphore_Release(p, (LONG)num, NULL); } -WRes Semaphore_Release1(CSemaphore *p) { return Semaphore_ReleaseN(p, 1); } - -WRes CriticalSection_Init(CCriticalSection *p) -{ - /* InitializeCriticalSection() can raise exception: - Windows XP, 2003 : can raise a STATUS_NO_MEMORY exception - Windows Vista+ : no exceptions */ - #ifdef _MSC_VER - #ifdef __clang__ - #pragma GCC diagnostic ignored "-Wlanguage-extension-token" - #endif - __try - #endif - { - InitializeCriticalSection(p); - /* InitializeCriticalSectionAndSpinCount(p, 0); */ - } - #ifdef _MSC_VER - __except (EXCEPTION_EXECUTE_HANDLER) { return ERROR_NOT_ENOUGH_MEMORY; } - #endif - return 0; -} - - - - -#else // _WIN32 - -// ---------- POSIX ---------- - -#ifndef __APPLE__ -#ifndef Z7_AFFINITY_DISABLE -// _GNU_SOURCE can be required for pthread_setaffinity_np() / CPU_ZERO / CPU_SET -// clang < 3.6 : unknown warning group '-Wreserved-id-macro' -// clang 3.6 - 12.01 : gives warning "macro name is a reserved identifier" -// clang >= 13 : do not give warning -#if !defined(_GNU_SOURCE) - #if defined(__clang__) && (__clang_major__ >= 4) && (__clang_major__ <= 12) - #pragma GCC diagnostic ignored "-Wreserved-id-macro" - #endif -#define _GNU_SOURCE -#endif // !defined(_GNU_SOURCE) -#endif // Z7_AFFINITY_DISABLE -#endif // __APPLE__ - -#include "Threads.h" - -#include -#include -#include -#ifdef Z7_AFFINITY_SUPPORTED -// #include -#endif - - -// #include -// #define PRF(p) p -#define PRF(p) -#define Print(s) PRF(printf("\n%s\n", s);) - -WRes Thread_Create_With_CpuSet(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, const CCpuSet *cpuSet) -{ - // new thread in Posix probably inherits affinity from parrent thread - Print("Thread_Create_With_CpuSet") - - pthread_attr_t attr; - int ret; - // int ret2; - - p->_created = 0; - - RINOK(pthread_attr_init(&attr)) - - ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - - if (!ret) - { - if (cpuSet) - { - #ifdef Z7_AFFINITY_SUPPORTED - - /* - printf("\n affinity :"); - unsigned i; - for (i = 0; i < sizeof(*cpuSet) && i < 8; i++) - { - Byte b = *((const Byte *)cpuSet + i); - char temp[32]; - #define GET_HEX_CHAR(t) ((char)(((t < 10) ? ('0' + t) : ('A' + (t - 10))))) - temp[0] = GET_HEX_CHAR((b & 0xF)); - temp[1] = GET_HEX_CHAR((b >> 4)); - // temp[0] = GET_HEX_CHAR((b >> 4)); // big-endian - // temp[1] = GET_HEX_CHAR((b & 0xF)); // big-endian - temp[2] = 0; - printf("%s", temp); - } - printf("\n"); - */ - - // ret2 = - pthread_attr_setaffinity_np(&attr, sizeof(*cpuSet), cpuSet); - // if (ret2) ret = ret2; - #endif - } - - ret = pthread_create(&p->_tid, &attr, func, param); - - if (!ret) - { - p->_created = 1; - /* - if (cpuSet) - { - // ret2 = - pthread_setaffinity_np(p->_tid, sizeof(*cpuSet), cpuSet); - // if (ret2) ret = ret2; - } - */ - } - } - // ret2 = - pthread_attr_destroy(&attr); - // if (ret2 != 0) ret = ret2; - return ret; -} - - -WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param) -{ - return Thread_Create_With_CpuSet(p, func, param, NULL); -} - - -WRes Thread_Create_With_Affinity(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, CAffinityMask affinity) -{ - Print("Thread_Create_WithAffinity") - CCpuSet cs; - unsigned i; - CpuSet_Zero(&cs); - for (i = 0; i < sizeof(affinity) * 8; i++) - { - if (affinity == 0) - break; - if (affinity & 1) - { - CpuSet_Set(&cs, i); - } - affinity >>= 1; - } - return Thread_Create_With_CpuSet(p, func, param, &cs); -} - - -WRes Thread_Close(CThread *p) -{ - // Print("Thread_Close") - int ret; - if (!p->_created) - return 0; - - ret = pthread_detach(p->_tid); - p->_tid = 0; - p->_created = 0; - return ret; -} - - -WRes Thread_Wait_Close(CThread *p) -{ - // Print("Thread_Wait_Close") - void *thread_return; - int ret; - if (!p->_created) - return EINVAL; - - ret = pthread_join(p->_tid, &thread_return); - // probably we can't use that (_tid) after pthread_join(), so we close thread here - p->_created = 0; - p->_tid = 0; - return ret; -} - - - -static WRes Event_Create(CEvent *p, int manualReset, int signaled) -{ - RINOK(pthread_mutex_init(&p->_mutex, NULL)) - RINOK(pthread_cond_init(&p->_cond, NULL)) - p->_manual_reset = manualReset; - p->_state = (signaled ? True : False); - p->_created = 1; - return 0; -} - -WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled) - { return Event_Create(p, True, signaled); } -WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p) - { return ManualResetEvent_Create(p, 0); } -WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled) - { return Event_Create(p, False, signaled); } -WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p) - { return AutoResetEvent_Create(p, 0); } - - -WRes Event_Set(CEvent *p) -{ - RINOK(pthread_mutex_lock(&p->_mutex)) - p->_state = True; - int res1 = pthread_cond_broadcast(&p->_cond); - int res2 = pthread_mutex_unlock(&p->_mutex); - return (res2 ? res2 : res1); -} - -WRes Event_Reset(CEvent *p) -{ - RINOK(pthread_mutex_lock(&p->_mutex)) - p->_state = False; - return pthread_mutex_unlock(&p->_mutex); -} - -WRes Event_Wait(CEvent *p) -{ - RINOK(pthread_mutex_lock(&p->_mutex)) - while (p->_state == False) - { - // ETIMEDOUT - // ret = - pthread_cond_wait(&p->_cond, &p->_mutex); - // if (ret != 0) break; - } - if (p->_manual_reset == False) - { - p->_state = False; - } - return pthread_mutex_unlock(&p->_mutex); -} - -WRes Event_Close(CEvent *p) -{ - if (!p->_created) - return 0; - p->_created = 0; - { - int res1 = pthread_mutex_destroy(&p->_mutex); - int res2 = pthread_cond_destroy(&p->_cond); - return (res1 ? res1 : res2); - } -} - - -WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount) -{ - if (initCount > maxCount || maxCount < 1) - return EINVAL; - RINOK(pthread_mutex_init(&p->_mutex, NULL)) - RINOK(pthread_cond_init(&p->_cond, NULL)) - p->_count = initCount; - p->_maxCount = maxCount; - p->_created = 1; - return 0; -} - - -WRes Semaphore_OptCreateInit(CSemaphore *p, UInt32 initCount, UInt32 maxCount) -{ - if (Semaphore_IsCreated(p)) - { - /* - WRes wres = Semaphore_Close(p); - if (wres != 0) - return wres; - */ - if (initCount > maxCount || maxCount < 1) - return EINVAL; - // return EINVAL; // for debug - p->_count = initCount; - p->_maxCount = maxCount; - return 0; - } - return Semaphore_Create(p, initCount, maxCount); -} - - -WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 releaseCount) -{ - UInt32 newCount; - int ret; - - if (releaseCount < 1) - return EINVAL; - - RINOK(pthread_mutex_lock(&p->_mutex)) - - newCount = p->_count + releaseCount; - if (newCount > p->_maxCount) - ret = ERROR_TOO_MANY_POSTS; // EINVAL; - else - { - p->_count = newCount; - ret = pthread_cond_broadcast(&p->_cond); - } - RINOK(pthread_mutex_unlock(&p->_mutex)) - return ret; -} - -WRes Semaphore_Wait(CSemaphore *p) -{ - RINOK(pthread_mutex_lock(&p->_mutex)) - while (p->_count < 1) - { - pthread_cond_wait(&p->_cond, &p->_mutex); - } - p->_count--; - return pthread_mutex_unlock(&p->_mutex); -} - -WRes Semaphore_Close(CSemaphore *p) -{ - if (!p->_created) - return 0; - p->_created = 0; - { - int res1 = pthread_mutex_destroy(&p->_mutex); - int res2 = pthread_cond_destroy(&p->_cond); - return (res1 ? res1 : res2); - } -} - - - -WRes CriticalSection_Init(CCriticalSection *p) -{ - // Print("CriticalSection_Init") - if (!p) - return EINTR; - return pthread_mutex_init(&p->_mutex, NULL); -} - -void CriticalSection_Enter(CCriticalSection *p) -{ - // Print("CriticalSection_Enter") - if (p) - { - // int ret = - pthread_mutex_lock(&p->_mutex); - } -} - -void CriticalSection_Leave(CCriticalSection *p) -{ - // Print("CriticalSection_Leave") - if (p) - { - // int ret = - pthread_mutex_unlock(&p->_mutex); - } -} - -void CriticalSection_Delete(CCriticalSection *p) -{ - // Print("CriticalSection_Delete") - if (p) - { - // int ret = - pthread_mutex_destroy(&p->_mutex); - } -} - -LONG InterlockedIncrement(LONG volatile *addend) -{ - // Print("InterlockedIncrement") - #ifdef USE_HACK_UNSAFE_ATOMIC - LONG val = *addend + 1; - *addend = val; - return val; - #else - - #if defined(__clang__) && (__clang_major__ >= 8) - #pragma GCC diagnostic ignored "-Watomic-implicit-seq-cst" - #endif - return __sync_add_and_fetch(addend, 1); - #endif -} - -#endif // _WIN32 - -WRes AutoResetEvent_OptCreate_And_Reset(CAutoResetEvent *p) -{ - if (Event_IsCreated(p)) - return Event_Reset(p); - return AutoResetEvent_CreateNotSignaled(p); -} - -#undef PRF -#undef Print diff --git a/extern/lzma/Threads.h b/extern/lzma/Threads.h deleted file mode 100644 index 4028464a337..00000000000 --- a/extern/lzma/Threads.h +++ /dev/null @@ -1,240 +0,0 @@ -/* Threads.h -- multithreading library -2023-04-02 : Igor Pavlov : Public domain */ - -#ifndef ZIP7_INC_THREADS_H -#define ZIP7_INC_THREADS_H - -#ifdef _WIN32 -#include "7zWindows.h" - -#else - -#if defined(__linux__) -#if !defined(__APPLE__) && !defined(_AIX) && !defined(__ANDROID__) -#ifndef Z7_AFFINITY_DISABLE -#define Z7_AFFINITY_SUPPORTED -// #pragma message(" ==== Z7_AFFINITY_SUPPORTED") -// #define _GNU_SOURCE -#endif -#endif -#endif - -#include - -#endif - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -#ifdef _WIN32 - -WRes HandlePtr_Close(HANDLE *h); -WRes Handle_WaitObject(HANDLE h); - -typedef HANDLE CThread; - -#define Thread_CONSTRUCT(p) { *(p) = NULL; } -#define Thread_WasCreated(p) (*(p) != NULL) -#define Thread_Close(p) HandlePtr_Close(p) -// #define Thread_Wait(p) Handle_WaitObject(*(p)) - -#ifdef UNDER_CE - // if (USE_THREADS_CreateThread is defined), we use _beginthreadex() - // if (USE_THREADS_CreateThread is not definned), we use CreateThread() - #define USE_THREADS_CreateThread -#endif - -typedef - #ifdef USE_THREADS_CreateThread - DWORD - #else - unsigned - #endif - THREAD_FUNC_RET_TYPE; - -#define THREAD_FUNC_RET_ZERO 0 - -typedef DWORD_PTR CAffinityMask; -typedef DWORD_PTR CCpuSet; - -#define CpuSet_Zero(p) *(p) = (0) -#define CpuSet_Set(p, cpu) *(p) |= ((DWORD_PTR)1 << (cpu)) - -#else // _WIN32 - -typedef struct -{ - pthread_t _tid; - int _created; -} CThread; - -#define Thread_CONSTRUCT(p) { (p)->_tid = 0; (p)->_created = 0; } -#define Thread_WasCreated(p) ((p)->_created != 0) -WRes Thread_Close(CThread *p); -// #define Thread_Wait Thread_Wait_Close - -typedef void * THREAD_FUNC_RET_TYPE; -#define THREAD_FUNC_RET_ZERO NULL - - -typedef UInt64 CAffinityMask; - -#ifdef Z7_AFFINITY_SUPPORTED - -typedef cpu_set_t CCpuSet; -#define CpuSet_Zero(p) CPU_ZERO(p) -#define CpuSet_Set(p, cpu) CPU_SET(cpu, p) -#define CpuSet_IsSet(p, cpu) CPU_ISSET(cpu, p) - -#else - -typedef UInt64 CCpuSet; -#define CpuSet_Zero(p) *(p) = (0) -#define CpuSet_Set(p, cpu) *(p) |= ((UInt64)1 << (cpu)) -#define CpuSet_IsSet(p, cpu) ((*(p) & ((UInt64)1 << (cpu))) != 0) - -#endif - - -#endif // _WIN32 - - -#define THREAD_FUNC_CALL_TYPE Z7_STDCALL - -#if defined(_WIN32) && defined(__GNUC__) -/* GCC compiler for x86 32-bit uses the rule: - the stack is 16-byte aligned before CALL instruction for function calling. - But only root function main() contains instructions that - set 16-byte alignment for stack pointer. And another functions - just keep alignment, if it was set in some parent function. - - The problem: - if we create new thread in MinGW (GCC) 32-bit x86 via _beginthreadex() or CreateThread(), - the root function of thread doesn't set 16-byte alignment. - And stack frames in all child functions also will be unaligned in that case. - - Here we set (force_align_arg_pointer) attribute for root function of new thread. - Do we need (force_align_arg_pointer) also for another systems? */ - - #define THREAD_FUNC_ATTRIB_ALIGN_ARG __attribute__((force_align_arg_pointer)) - // #define THREAD_FUNC_ATTRIB_ALIGN_ARG // for debug : bad alignment in SSE functions -#else - #define THREAD_FUNC_ATTRIB_ALIGN_ARG -#endif - -#define THREAD_FUNC_DECL THREAD_FUNC_ATTRIB_ALIGN_ARG THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE - -typedef THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE * THREAD_FUNC_TYPE)(void *); -WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param); -WRes Thread_Create_With_Affinity(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, CAffinityMask affinity); -WRes Thread_Wait_Close(CThread *p); - -#ifdef _WIN32 -#define Thread_Create_With_CpuSet(p, func, param, cs) \ - Thread_Create_With_Affinity(p, func, param, *cs) -#else -WRes Thread_Create_With_CpuSet(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, const CCpuSet *cpuSet); -#endif - - -#ifdef _WIN32 - -typedef HANDLE CEvent; -typedef CEvent CAutoResetEvent; -typedef CEvent CManualResetEvent; -#define Event_Construct(p) *(p) = NULL -#define Event_IsCreated(p) (*(p) != NULL) -#define Event_Close(p) HandlePtr_Close(p) -#define Event_Wait(p) Handle_WaitObject(*(p)) -WRes Event_Set(CEvent *p); -WRes Event_Reset(CEvent *p); -WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled); -WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p); -WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled); -WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p); - -typedef HANDLE CSemaphore; -#define Semaphore_Construct(p) *(p) = NULL -#define Semaphore_IsCreated(p) (*(p) != NULL) -#define Semaphore_Close(p) HandlePtr_Close(p) -#define Semaphore_Wait(p) Handle_WaitObject(*(p)) -WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount); -WRes Semaphore_OptCreateInit(CSemaphore *p, UInt32 initCount, UInt32 maxCount); -WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num); -WRes Semaphore_Release1(CSemaphore *p); - -typedef CRITICAL_SECTION CCriticalSection; -WRes CriticalSection_Init(CCriticalSection *p); -#define CriticalSection_Delete(p) DeleteCriticalSection(p) -#define CriticalSection_Enter(p) EnterCriticalSection(p) -#define CriticalSection_Leave(p) LeaveCriticalSection(p) - - -#else // _WIN32 - -typedef struct _CEvent -{ - int _created; - int _manual_reset; - int _state; - pthread_mutex_t _mutex; - pthread_cond_t _cond; -} CEvent; - -typedef CEvent CAutoResetEvent; -typedef CEvent CManualResetEvent; - -#define Event_Construct(p) (p)->_created = 0 -#define Event_IsCreated(p) ((p)->_created) - -WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled); -WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p); -WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled); -WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p); - -WRes Event_Set(CEvent *p); -WRes Event_Reset(CEvent *p); -WRes Event_Wait(CEvent *p); -WRes Event_Close(CEvent *p); - - -typedef struct _CSemaphore -{ - int _created; - UInt32 _count; - UInt32 _maxCount; - pthread_mutex_t _mutex; - pthread_cond_t _cond; -} CSemaphore; - -#define Semaphore_Construct(p) (p)->_created = 0 -#define Semaphore_IsCreated(p) ((p)->_created) - -WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount); -WRes Semaphore_OptCreateInit(CSemaphore *p, UInt32 initCount, UInt32 maxCount); -WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num); -#define Semaphore_Release1(p) Semaphore_ReleaseN(p, 1) -WRes Semaphore_Wait(CSemaphore *p); -WRes Semaphore_Close(CSemaphore *p); - - -typedef struct _CCriticalSection -{ - pthread_mutex_t _mutex; -} CCriticalSection; - -WRes CriticalSection_Init(CCriticalSection *p); -void CriticalSection_Delete(CCriticalSection *cs); -void CriticalSection_Enter(CCriticalSection *cs); -void CriticalSection_Leave(CCriticalSection *cs); - -LONG InterlockedIncrement(LONG volatile *addend); - -#endif // _WIN32 - -WRes AutoResetEvent_OptCreate_And_Reset(CAutoResetEvent *p); - -EXTERN_C_END - -#endif diff --git a/extern/lzma/Types.h b/extern/lzma/Types.h new file mode 100644 index 00000000000..1af5cfc4d86 --- /dev/null +++ b/extern/lzma/Types.h @@ -0,0 +1,208 @@ +/* Types.h -- Basic types +2008-11-23 : Igor Pavlov : Public domain */ + +#ifndef __7Z_TYPES_H +#define __7Z_TYPES_H + +#include + +#ifdef _WIN32 +#include +#endif + +#define SZ_OK 0 + +#define SZ_ERROR_DATA 1 +#define SZ_ERROR_MEM 2 +#define SZ_ERROR_CRC 3 +#define SZ_ERROR_UNSUPPORTED 4 +#define SZ_ERROR_PARAM 5 +#define SZ_ERROR_INPUT_EOF 6 +#define SZ_ERROR_OUTPUT_EOF 7 +#define SZ_ERROR_READ 8 +#define SZ_ERROR_WRITE 9 +#define SZ_ERROR_PROGRESS 10 +#define SZ_ERROR_FAIL 11 +#define SZ_ERROR_THREAD 12 + +#define SZ_ERROR_ARCHIVE 16 +#define SZ_ERROR_NO_ARCHIVE 17 + +typedef int SRes; + +#ifdef _WIN32 +typedef DWORD WRes; +#else +typedef int WRes; +#endif + +#ifndef RINOK +#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; } +#endif + +typedef unsigned char Byte; +typedef short Int16; +typedef unsigned short UInt16; + +#ifdef _LZMA_UINT32_IS_ULONG +typedef long Int32; +typedef unsigned long UInt32; +#else +typedef int Int32; +typedef unsigned int UInt32; +#endif + +#ifdef _SZ_NO_INT_64 + +/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers. + NOTES: Some code will work incorrectly in that case! */ + +typedef long Int64; +typedef unsigned long UInt64; + +#else + +#if defined(_MSC_VER) || defined(__BORLANDC__) +typedef __int64 Int64; +typedef unsigned __int64 UInt64; +#else +typedef long long int Int64; +typedef unsigned long long int UInt64; +#endif + +#endif + +#ifdef _LZMA_NO_SYSTEM_SIZE_T +typedef UInt32 SizeT; +#else +typedef size_t SizeT; +#endif + +typedef int Bool; +#define True 1 +#define False 0 + + +#ifdef _MSC_VER + +#if _MSC_VER >= 1300 +#define MY_NO_INLINE __declspec(noinline) +#else +#define MY_NO_INLINE +#endif + +#define MY_CDECL __cdecl +#define MY_STD_CALL __stdcall +#define MY_FAST_CALL MY_NO_INLINE __fastcall + +#else + +#define MY_CDECL +#define MY_STD_CALL +#define MY_FAST_CALL + +#endif + + +/* The following interfaces use first parameter as pointer to structure */ + +typedef struct +{ + SRes (*Read)(void *p, void *buf, size_t *size); + /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. + (output(*size) < input(*size)) is allowed */ +} ISeqInStream; + +/* it can return SZ_ERROR_INPUT_EOF */ +SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size); +SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType); +SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf); + +typedef struct +{ + size_t (*Write)(void *p, const void *buf, size_t size); + /* Returns: result - the number of actually written bytes. + (result < size) means error */ +} ISeqOutStream; + +typedef enum +{ + SZ_SEEK_SET = 0, + SZ_SEEK_CUR = 1, + SZ_SEEK_END = 2 +} ESzSeek; + +typedef struct +{ + SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */ + SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); +} ISeekInStream; + +typedef struct +{ + SRes (*Look)(void *p, void **buf, size_t *size); + /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. + (output(*size) > input(*size)) is not allowed + (output(*size) < input(*size)) is allowed */ + SRes (*Skip)(void *p, size_t offset); + /* offset must be <= output(*size) of Look */ + + SRes (*Read)(void *p, void *buf, size_t *size); + /* reads directly (without buffer). It's same as ISeqInStream::Read */ + SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); +} ILookInStream; + +SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size); +SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset); + +/* reads via ILookInStream::Read */ +SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType); +SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size); + +#define LookToRead_BUF_SIZE (1 << 14) + +typedef struct +{ + ILookInStream s; + ISeekInStream *realStream; + size_t pos; + size_t size; + Byte buf[LookToRead_BUF_SIZE]; +} CLookToRead; + +void LookToRead_CreateVTable(CLookToRead *p, int lookahead); +void LookToRead_Init(CLookToRead *p); + +typedef struct +{ + ISeqInStream s; + ILookInStream *realStream; +} CSecToLook; + +void SecToLook_CreateVTable(CSecToLook *p); + +typedef struct +{ + ISeqInStream s; + ILookInStream *realStream; +} CSecToRead; + +void SecToRead_CreateVTable(CSecToRead *p); + +typedef struct +{ + SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize); + /* Returns: result. (result != SZ_OK) means break. + Value (UInt64)(Int64)-1 for size means unknown value. */ +} ICompressProgress; + +typedef struct +{ + void *(*Alloc)(void *p, size_t size); + void (*Free)(void *p, void *address); /* address can be 0 */ +} ISzAlloc; + +#define IAlloc_Alloc(p, size) (p)->Alloc((p), size) +#define IAlloc_Free(p, a) (p)->Free((p), a) + +#endif diff --git a/extern/lzma/history.txt b/extern/lzma/history.txt new file mode 100644 index 00000000000..014186717da --- /dev/null +++ b/extern/lzma/history.txt @@ -0,0 +1,236 @@ +HISTORY of the LZMA SDK +----------------------- + +4.65 2009-02-03 +------------------------- +- Some minor fixes + + +4.63 2008-12-31 +------------------------- +- Some minor fixes + + +4.61 beta 2008-11-23 +------------------------- +- The bug in ANSI-C LZMA Decoder was fixed: + If encoded stream was corrupted, decoder could access memory + outside of allocated range. +- Some changes in ANSI-C 7z Decoder interfaces. +- LZMA SDK is placed in the public domain. + + +4.60 beta 2008-08-19 +------------------------- +- Some minor fixes. + + +4.59 beta 2008-08-13 +------------------------- +- The bug was fixed: + LZMA Encoder in fast compression mode could access memory outside of + allocated range in some rare cases. + + +4.58 beta 2008-05-05 +------------------------- +- ANSI-C LZMA Decoder was rewritten for speed optimizations. +- ANSI-C LZMA Encoder was included to LZMA SDK. +- C++ LZMA code now is just wrapper over ANSI-C code. + + +4.57 2007-12-12 +------------------------- +- Speed optimizations in Ñ++ LZMA Decoder. +- Small changes for more compatibility with some C/C++ compilers. + + +4.49 beta 2007-07-05 +------------------------- +- .7z ANSI-C Decoder: + - now it supports BCJ and BCJ2 filters + - now it supports files larger than 4 GB. + - now it supports "Last Write Time" field for files. +- C++ code for .7z archives compressing/decompressing from 7-zip + was included to LZMA SDK. + + +4.43 2006-06-04 +------------------------- +- Small changes for more compatibility with some C/C++ compilers. + + +4.42 2006-05-15 +------------------------- +- Small changes in .h files in ANSI-C version. + + +4.39 beta 2006-04-14 +------------------------- +- The bug in versions 4.33b:4.38b was fixed: + C++ version of LZMA encoder could not correctly compress + files larger than 2 GB with HC4 match finder (-mfhc4). + + +4.37 beta 2005-04-06 +------------------------- +- Fixes in C++ code: code could no be compiled if _NO_EXCEPTIONS was defined. + + +4.35 beta 2005-03-02 +------------------------- +- The bug was fixed in C++ version of LZMA Decoder: + If encoded stream was corrupted, decoder could access memory + outside of allocated range. + + +4.34 beta 2006-02-27 +------------------------- +- Compressing speed and memory requirements for compressing were increased +- LZMA now can use only these match finders: HC4, BT2, BT3, BT4 + + +4.32 2005-12-09 +------------------------- +- Java version of LZMA SDK was included + + +4.30 2005-11-20 +------------------------- +- Compression ratio was improved in -a2 mode +- Speed optimizations for compressing in -a2 mode +- -fb switch now supports values up to 273 +- The bug in 7z_C (7zIn.c) was fixed: + It used Alloc/Free functions from different memory pools. + So if program used two memory pools, it worked incorrectly. +- 7z_C: .7z format supporting was improved +- LZMA# SDK (C#.NET version) was included + + +4.27 (Updated) 2005-09-21 +------------------------- +- Some GUIDs/interfaces in C++ were changed. + IStream.h: + ISequentialInStream::Read now works as old ReadPart + ISequentialOutStream::Write now works as old WritePart + + +4.27 2005-08-07 +------------------------- +- The bug in LzmaDecodeSize.c was fixed: + if _LZMA_IN_CB and _LZMA_OUT_READ were defined, + decompressing worked incorrectly. + + +4.26 2005-08-05 +------------------------- +- Fixes in 7z_C code and LzmaTest.c: + previous versions could work incorrectly, + if malloc(0) returns 0 + + +4.23 2005-06-29 +------------------------- +- Small fixes in C++ code + + +4.22 2005-06-10 +------------------------- +- Small fixes + + +4.21 2005-06-08 +------------------------- +- Interfaces for ANSI-C LZMA Decoder (LzmaDecode.c) were changed +- New additional version of ANSI-C LZMA Decoder with zlib-like interface: + - LzmaStateDecode.h + - LzmaStateDecode.c + - LzmaStateTest.c +- ANSI-C LZMA Decoder now can decompress files larger than 4 GB + + +4.17 2005-04-18 +------------------------- +- New example for RAM->RAM compressing/decompressing: + LZMA + BCJ (filter for x86 code): + - LzmaRam.h + - LzmaRam.cpp + - LzmaRamDecode.h + - LzmaRamDecode.c + - -f86 switch for lzma.exe + + +4.16 2005-03-29 +------------------------- +- The bug was fixed in LzmaDecode.c (ANSI-C LZMA Decoder): + If _LZMA_OUT_READ was defined, and if encoded stream was corrupted, + decoder could access memory outside of allocated range. +- Speed optimization of ANSI-C LZMA Decoder (now it's about 20% faster). + Old version of LZMA Decoder now is in file LzmaDecodeSize.c. + LzmaDecodeSize.c can provide slightly smaller code than LzmaDecode.c +- Small speed optimization in LZMA C++ code +- filter for SPARC's code was added +- Simplified version of .7z ANSI-C Decoder was included + + +4.06 2004-09-05 +------------------------- +- The bug in v4.05 was fixed: + LZMA-Encoder didn't release output stream in some cases. + + +4.05 2004-08-25 +------------------------- +- Source code of filters for x86, IA-64, ARM, ARM-Thumb + and PowerPC code was included to SDK +- Some internal minor changes + + +4.04 2004-07-28 +------------------------- +- More compatibility with some C++ compilers + + +4.03 2004-06-18 +------------------------- +- "Benchmark" command was added. It measures compressing + and decompressing speed and shows rating values. + Also it checks hardware errors. + + +4.02 2004-06-10 +------------------------- +- C++ LZMA Encoder/Decoder code now is more portable + and it can be compiled by GCC on Linux. + + +4.01 2004-02-15 +------------------------- +- Some detection of data corruption was enabled. + LzmaDecode.c / RangeDecoderReadByte + ..... + { + rd->ExtraBytes = 1; + return 0xFF; + } + + +4.00 2004-02-13 +------------------------- +- Original version of LZMA SDK + + + +HISTORY of the LZMA +------------------- + 2001-2008: Improvements to LZMA compressing/decompressing code, + keeping compatibility with original LZMA format + 1996-2001: Development of LZMA compression format + + Some milestones: + + 2001-08-30: LZMA compression was added to 7-Zip + 1999-01-02: First version of 7-Zip was released + + +End of document diff --git a/extern/lzma/lzma.txt b/extern/lzma/lzma.txt new file mode 100644 index 00000000000..715792d6c17 --- /dev/null +++ b/extern/lzma/lzma.txt @@ -0,0 +1,594 @@ +LZMA SDK 4.65 +------------- + +LZMA SDK provides the documentation, samples, header files, libraries, +and tools you need to develop applications that use LZMA compression. + +LZMA is default and general compression method of 7z format +in 7-Zip compression program (www.7-zip.org). LZMA provides high +compression ratio and very fast decompression. + +LZMA is an improved version of famous LZ77 compression algorithm. +It was improved in way of maximum increasing of compression ratio, +keeping high decompression speed and low memory requirements for +decompressing. + + + +LICENSE +------- + +LZMA SDK is written and placed in the public domain by Igor Pavlov. + + +LZMA SDK Contents +----------------- + +LZMA SDK includes: + + - ANSI-C/C++/C#/Java source code for LZMA compressing and decompressing + - Compiled file->file LZMA compressing/decompressing program for Windows system + + +UNIX/Linux version +------------------ +To compile C++ version of file->file LZMA encoding, go to directory +C++/7zip/Compress/LZMA_Alone +and call make to recompile it: + make -f makefile.gcc clean all + +In some UNIX/Linux versions you must compile LZMA with static libraries. +To compile with static libraries, you can use +LIB = -lm -static + + +Files +--------------------- +lzma.txt - LZMA SDK description (this file) +7zFormat.txt - 7z Format description +7zC.txt - 7z ANSI-C Decoder description +methods.txt - Compression method IDs for .7z +lzma.exe - Compiled file->file LZMA encoder/decoder for Windows +history.txt - history of the LZMA SDK + + +Source code structure +--------------------- + +C/ - C files + 7zCrc*.* - CRC code + Alloc.* - Memory allocation functions + Bra*.* - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code + LzFind.* - Match finder for LZ (LZMA) encoders + LzFindMt.* - Match finder for LZ (LZMA) encoders for multithreading encoding + LzHash.h - Additional file for LZ match finder + LzmaDec.* - LZMA decoding + LzmaEnc.* - LZMA encoding + LzmaLib.* - LZMA Library for DLL calling + Types.h - Basic types for another .c files + Threads.* - The code for multithreading. + + LzmaLib - LZMA Library (.DLL for Windows) + + LzmaUtil - LZMA Utility (file->file LZMA encoder/decoder). + + Archive - files related to archiving + 7z - 7z ANSI-C Decoder + +CPP/ -- CPP files + + Common - common files for C++ projects + Windows - common files for Windows related code + + 7zip - files related to 7-Zip Project + + Common - common files for 7-Zip + + Compress - files related to compression/decompression + + Copy - Copy coder + RangeCoder - Range Coder (special code of compression/decompression) + LZMA - LZMA compression/decompression on C++ + LZMA_Alone - file->file LZMA compression/decompression + Branch - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code + + Archive - files related to archiving + + Common - common files for archive handling + 7z - 7z C++ Encoder/Decoder + + Bundles - Modules that are bundles of other modules + + Alone7z - 7zr.exe: Standalone version of 7z.exe that supports only 7z/LZMA/BCJ/BCJ2 + Format7zR - 7zr.dll: Reduced version of 7za.dll: extracting/compressing to 7z/LZMA/BCJ/BCJ2 + Format7zExtractR - 7zxr.dll: Reduced version of 7zxa.dll: extracting from 7z/LZMA/BCJ/BCJ2. + + UI - User Interface files + + Client7z - Test application for 7za.dll, 7zr.dll, 7zxr.dll + Common - Common UI files + Console - Code for console archiver + + + +CS/ - C# files + 7zip + Common - some common files for 7-Zip + Compress - files related to compression/decompression + LZ - files related to LZ (Lempel-Ziv) compression algorithm + LZMA - LZMA compression/decompression + LzmaAlone - file->file LZMA compression/decompression + RangeCoder - Range Coder (special code of compression/decompression) + +Java/ - Java files + SevenZip + Compression - files related to compression/decompression + LZ - files related to LZ (Lempel-Ziv) compression algorithm + LZMA - LZMA compression/decompression + RangeCoder - Range Coder (special code of compression/decompression) + + +C/C++ source code of LZMA SDK is part of 7-Zip project. +7-Zip source code can be downloaded from 7-Zip's SourceForge page: + + http://sourceforge.net/projects/sevenzip/ + + + +LZMA features +------------- + - Variable dictionary size (up to 1 GB) + - Estimated compressing speed: about 2 MB/s on 2 GHz CPU + - Estimated decompressing speed: + - 20-30 MB/s on 2 GHz Core 2 or AMD Athlon 64 + - 1-2 MB/s on 200 MHz ARM, MIPS, PowerPC or other simple RISC + - Small memory requirements for decompressing (16 KB + DictionarySize) + - Small code size for decompressing: 5-8 KB + +LZMA decoder uses only integer operations and can be +implemented in any modern 32-bit CPU (or on 16-bit CPU with some conditions). + +Some critical operations that affect the speed of LZMA decompression: + 1) 32*16 bit integer multiply + 2) Misspredicted branches (penalty mostly depends from pipeline length) + 3) 32-bit shift and arithmetic operations + +The speed of LZMA decompressing mostly depends from CPU speed. +Memory speed has no big meaning. But if your CPU has small data cache, +overall weight of memory speed will slightly increase. + + +How To Use +---------- + +Using LZMA encoder/decoder executable +-------------------------------------- + +Usage: LZMA inputFile outputFile [...] + + e: encode file + + d: decode file + + b: Benchmark. There are two tests: compressing and decompressing + with LZMA method. Benchmark shows rating in MIPS (million + instructions per second). Rating value is calculated from + measured speed and it is normalized with Intel's Core 2 results. + Also Benchmark checks possible hardware errors (RAM + errors in most cases). Benchmark uses these settings: + (-a1, -d21, -fb32, -mfbt4). You can change only -d parameter. + Also you can change the number of iterations. Example for 30 iterations: + LZMA b 30 + Default number of iterations is 10. + + + + + -a{N}: set compression mode 0 = fast, 1 = normal + default: 1 (normal) + + d{N}: Sets Dictionary size - [0, 30], default: 23 (8MB) + The maximum value for dictionary size is 1 GB = 2^30 bytes. + Dictionary size is calculated as DictionarySize = 2^N bytes. + For decompressing file compressed by LZMA method with dictionary + size D = 2^N you need about D bytes of memory (RAM). + + -fb{N}: set number of fast bytes - [5, 273], default: 128 + Usually big number gives a little bit better compression ratio + and slower compression process. + + -lc{N}: set number of literal context bits - [0, 8], default: 3 + Sometimes lc=4 gives gain for big files. + + -lp{N}: set number of literal pos bits - [0, 4], default: 0 + lp switch is intended for periodical data when period is + equal 2^N. For example, for 32-bit (4 bytes) + periodical data you can use lp=2. Often it's better to set lc0, + if you change lp switch. + + -pb{N}: set number of pos bits - [0, 4], default: 2 + pb switch is intended for periodical data + when period is equal 2^N. + + -mf{MF_ID}: set Match Finder. Default: bt4. + Algorithms from hc* group doesn't provide good compression + ratio, but they often works pretty fast in combination with + fast mode (-a0). + + Memory requirements depend from dictionary size + (parameter "d" in table below). + + MF_ID Memory Description + + bt2 d * 9.5 + 4MB Binary Tree with 2 bytes hashing. + bt3 d * 11.5 + 4MB Binary Tree with 3 bytes hashing. + bt4 d * 11.5 + 4MB Binary Tree with 4 bytes hashing. + hc4 d * 7.5 + 4MB Hash Chain with 4 bytes hashing. + + -eos: write End Of Stream marker. By default LZMA doesn't write + eos marker, since LZMA decoder knows uncompressed size + stored in .lzma file header. + + -si: Read data from stdin (it will write End Of Stream marker). + -so: Write data to stdout + + +Examples: + +1) LZMA e file.bin file.lzma -d16 -lc0 + +compresses file.bin to file.lzma with 64 KB dictionary (2^16=64K) +and 0 literal context bits. -lc0 allows to reduce memory requirements +for decompression. + + +2) LZMA e file.bin file.lzma -lc0 -lp2 + +compresses file.bin to file.lzma with settings suitable +for 32-bit periodical data (for example, ARM or MIPS code). + +3) LZMA d file.lzma file.bin + +decompresses file.lzma to file.bin. + + +Compression ratio hints +----------------------- + +Recommendations +--------------- + +To increase the compression ratio for LZMA compressing it's desirable +to have aligned data (if it's possible) and also it's desirable to locate +data in such order, where code is grouped in one place and data is +grouped in other place (it's better than such mixing: code, data, code, +data, ...). + + +Filters +------- +You can increase the compression ratio for some data types, using +special filters before compressing. For example, it's possible to +increase the compression ratio on 5-10% for code for those CPU ISAs: +x86, IA-64, ARM, ARM-Thumb, PowerPC, SPARC. + +You can find C source code of such filters in C/Bra*.* files + +You can check the compression ratio gain of these filters with such +7-Zip commands (example for ARM code): +No filter: + 7z a a1.7z a.bin -m0=lzma + +With filter for little-endian ARM code: + 7z a a2.7z a.bin -m0=arm -m1=lzma + +It works in such manner: +Compressing = Filter_encoding + LZMA_encoding +Decompressing = LZMA_decoding + Filter_decoding + +Compressing and decompressing speed of such filters is very high, +so it will not increase decompressing time too much. +Moreover, it reduces decompression time for LZMA_decoding, +since compression ratio with filtering is higher. + +These filters convert CALL (calling procedure) instructions +from relative offsets to absolute addresses, so such data becomes more +compressible. + +For some ISAs (for example, for MIPS) it's impossible to get gain from such filter. + + +LZMA compressed file format +--------------------------- +Offset Size Description + 0 1 Special LZMA properties (lc,lp, pb in encoded form) + 1 4 Dictionary size (little endian) + 5 8 Uncompressed size (little endian). -1 means unknown size + 13 Compressed data + + +ANSI-C LZMA Decoder +~~~~~~~~~~~~~~~~~~~ + +Please note that interfaces for ANSI-C code were changed in LZMA SDK 4.58. +If you want to use old interfaces you can download previous version of LZMA SDK +from sourceforge.net site. + +To use ANSI-C LZMA Decoder you need the following files: +1) LzmaDec.h + LzmaDec.c + Types.h +LzmaUtil/LzmaUtil.c is example application that uses these files. + + +Memory requirements for LZMA decoding +------------------------------------- + +Stack usage of LZMA decoding function for local variables is not +larger than 200-400 bytes. + +LZMA Decoder uses dictionary buffer and internal state structure. +Internal state structure consumes + state_size = (4 + (1.5 << (lc + lp))) KB +by default (lc=3, lp=0), state_size = 16 KB. + + +How To decompress data +---------------------- + +LZMA Decoder (ANSI-C version) now supports 2 interfaces: +1) Single-call Decompressing +2) Multi-call State Decompressing (zlib-like interface) + +You must use external allocator: +Example: +void *SzAlloc(void *p, size_t size) { p = p; return malloc(size); } +void SzFree(void *p, void *address) { p = p; free(address); } +ISzAlloc alloc = { SzAlloc, SzFree }; + +You can use p = p; operator to disable compiler warnings. + + +Single-call Decompressing +------------------------- +When to use: RAM->RAM decompressing +Compile files: LzmaDec.h + LzmaDec.c + Types.h +Compile defines: no defines +Memory Requirements: + - Input buffer: compressed size + - Output buffer: uncompressed size + - LZMA Internal Structures: state_size (16 KB for default settings) + +Interface: + int LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, + const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, + ELzmaStatus *status, ISzAlloc *alloc); + In: + dest - output data + destLen - output data size + src - input data + srcLen - input data size + propData - LZMA properties (5 bytes) + propSize - size of propData buffer (5 bytes) + finishMode - It has meaning only if the decoding reaches output limit (*destLen). + LZMA_FINISH_ANY - Decode just destLen bytes. + LZMA_FINISH_END - Stream must be finished after (*destLen). + You can use LZMA_FINISH_END, when you know that + current output buffer covers last bytes of stream. + alloc - Memory allocator. + + Out: + destLen - processed output size + srcLen - processed input size + + Output: + SZ_OK + status: + LZMA_STATUS_FINISHED_WITH_MARK + LZMA_STATUS_NOT_FINISHED + LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK + SZ_ERROR_DATA - Data error + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_UNSUPPORTED - Unsupported properties + SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). + + If LZMA decoder sees end_marker before reaching output limit, it returns OK result, + and output value of destLen will be less than output buffer size limit. + + You can use multiple checks to test data integrity after full decompression: + 1) Check Result and "status" variable. + 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize. + 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. + You must use correct finish mode in that case. */ + + +Multi-call State Decompressing (zlib-like interface) +---------------------------------------------------- + +When to use: file->file decompressing +Compile files: LzmaDec.h + LzmaDec.c + Types.h + +Memory Requirements: + - Buffer for input stream: any size (for example, 16 KB) + - Buffer for output stream: any size (for example, 16 KB) + - LZMA Internal Structures: state_size (16 KB for default settings) + - LZMA dictionary (dictionary size is encoded in LZMA properties header) + +1) read LZMA properties (5 bytes) and uncompressed size (8 bytes, little-endian) to header: + unsigned char header[LZMA_PROPS_SIZE + 8]; + ReadFile(inFile, header, sizeof(header) + +2) Allocate CLzmaDec structures (state + dictionary) using LZMA properties + + CLzmaDec state; + LzmaDec_Constr(&state); + res = LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc); + if (res != SZ_OK) + return res; + +3) Init LzmaDec structure before any new LZMA stream. And call LzmaDec_DecodeToBuf in loop + + LzmaDec_Init(&state); + for (;;) + { + ... + int res = LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, + const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode); + ... + } + + +4) Free all allocated structures + LzmaDec_Free(&state, &g_Alloc); + +For full code example, look at C/LzmaUtil/LzmaUtil.c code. + + +How To compress data +-------------------- + +Compile files: LzmaEnc.h + LzmaEnc.c + Types.h + +LzFind.c + LzFind.h + LzFindMt.c + LzFindMt.h + LzHash.h + +Memory Requirements: + - (dictSize * 11.5 + 6 MB) + state_size + +Lzma Encoder can use two memory allocators: +1) alloc - for small arrays. +2) allocBig - for big arrays. + +For example, you can use Large RAM Pages (2 MB) in allocBig allocator for +better compression speed. Note that Windows has bad implementation for +Large RAM Pages. +It's OK to use same allocator for alloc and allocBig. + + +Single-call Compression with callbacks +-------------------------------------- + +Check C/LzmaUtil/LzmaUtil.c as example, + +When to use: file->file decompressing + +1) you must implement callback structures for interfaces: +ISeqInStream +ISeqOutStream +ICompressProgress +ISzAlloc + +static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); } +static void SzFree(void *p, void *address) { p = p; MyFree(address); } +static ISzAlloc g_Alloc = { SzAlloc, SzFree }; + + CFileSeqInStream inStream; + CFileSeqOutStream outStream; + + inStream.funcTable.Read = MyRead; + inStream.file = inFile; + outStream.funcTable.Write = MyWrite; + outStream.file = outFile; + + +2) Create CLzmaEncHandle object; + + CLzmaEncHandle enc; + + enc = LzmaEnc_Create(&g_Alloc); + if (enc == 0) + return SZ_ERROR_MEM; + + +3) initialize CLzmaEncProps properties; + + LzmaEncProps_Init(&props); + + Then you can change some properties in that structure. + +4) Send LZMA properties to LZMA Encoder + + res = LzmaEnc_SetProps(enc, &props); + +5) Write encoded properties to header + + Byte header[LZMA_PROPS_SIZE + 8]; + size_t headerSize = LZMA_PROPS_SIZE; + UInt64 fileSize; + int i; + + res = LzmaEnc_WriteProperties(enc, header, &headerSize); + fileSize = MyGetFileLength(inFile); + for (i = 0; i < 8; i++) + header[headerSize++] = (Byte)(fileSize >> (8 * i)); + MyWriteFileAndCheck(outFile, header, headerSize) + +6) Call encoding function: + res = LzmaEnc_Encode(enc, &outStream.funcTable, &inStream.funcTable, + NULL, &g_Alloc, &g_Alloc); + +7) Destroy LZMA Encoder Object + LzmaEnc_Destroy(enc, &g_Alloc, &g_Alloc); + + +If callback function return some error code, LzmaEnc_Encode also returns that code. + + +Single-call RAM->RAM Compression +-------------------------------- + +Single-call RAM->RAM Compression is similar to Compression with callbacks, +but you provide pointers to buffers instead of pointers to stream callbacks: + +HRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, + CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, + ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); + +Return code: + SZ_OK - OK + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_PARAM - Incorrect paramater + SZ_ERROR_OUTPUT_EOF - output buffer overflow + SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) + + + +LZMA Defines +------------ + +_LZMA_SIZE_OPT - Enable some optimizations in LZMA Decoder to get smaller executable code. + +_LZMA_PROB32 - It can increase the speed on some 32-bit CPUs, but memory usage for + some structures will be doubled in that case. + +_LZMA_UINT32_IS_ULONG - Define it if int is 16-bit on your compiler and long is 32-bit. + +_LZMA_NO_SYSTEM_SIZE_T - Define it if you don't want to use size_t type. + + +C++ LZMA Encoder/Decoder +~~~~~~~~~~~~~~~~~~~~~~~~ +C++ LZMA code use COM-like interfaces. So if you want to use it, +you can study basics of COM/OLE. +C++ LZMA code is just wrapper over ANSI-C code. + + +C++ Notes +~~~~~~~~~~~~~~~~~~~~~~~~ +If you use some C++ code folders in 7-Zip (for example, C++ code for .7z handling), +you must check that you correctly work with "new" operator. +7-Zip can be compiled with MSVC 6.0 that doesn't throw "exception" from "new" operator. +So 7-Zip uses "CPP\Common\NewHandler.cpp" that redefines "new" operator: +operator new(size_t size) +{ + void *p = ::malloc(size); + if (p == 0) + throw CNewException(); + return p; +} +If you use MSCV that throws exception for "new" operator, you can compile without +"NewHandler.cpp". So standard exception will be used. Actually some code of +7-Zip catches any exception in internal code and converts it to HRESULT code. +So you don't need to catch CNewException, if you call COM interfaces of 7-Zip. + +--- + +http://www.7-zip.org +http://www.7-zip.org/sdk.html +http://www.7-zip.org/support.html diff --git a/intern/clog/CLG_log.h b/intern/clog/CLG_log.h index 8fc887cb1ce..04bd03a6563 100644 --- a/intern/clog/CLG_log.h +++ b/intern/clog/CLG_log.h @@ -176,6 +176,19 @@ int CLG_color_support_get(CLG_LogRef *clg_ref); } \ ((void)0) +#define CLOG_STR_AT_SEVERITY_N(clg_ref, severity, verbose_level, str) \ + { \ + CLG_LogType *_lg_ty = CLOG_ENSURE(clg_ref); \ + if (((_lg_ty->flag & CLG_FLAG_USE) && (_lg_ty->level >= verbose_level)) || \ + (severity >= CLG_SEVERITY_WARN)) \ + { \ + const char *_str = str; \ + CLG_log_str(_lg_ty, severity, __FILE__ ":" STRINGIFY(__LINE__), __func__, _str); \ + MEM_freeN((void *)_str); \ + } \ + } \ + ((void)0) + #define CLOG_INFO(clg_ref, level, ...) \ CLOG_AT_SEVERITY(clg_ref, CLG_SEVERITY_INFO, level, __VA_ARGS__) #define CLOG_WARN(clg_ref, ...) CLOG_AT_SEVERITY(clg_ref, CLG_SEVERITY_WARN, 0, __VA_ARGS__) @@ -188,6 +201,13 @@ int CLG_color_support_get(CLG_LogRef *clg_ref); #define CLOG_STR_ERROR(clg_ref, str) CLOG_STR_AT_SEVERITY(clg_ref, CLG_SEVERITY_ERROR, 0, str) #define CLOG_STR_FATAL(clg_ref, str) CLOG_STR_AT_SEVERITY(clg_ref, CLG_SEVERITY_FATAL, 0, str) +/* Allocated string which is immediately freed. */ +#define CLOG_STR_INFO_N(clg_ref, level, str) \ + CLOG_STR_AT_SEVERITY_N(clg_ref, CLG_SEVERITY_INFO, level, str) +#define CLOG_STR_WARN_N(clg_ref, str) CLOG_STR_AT_SEVERITY_N(clg_ref, CLG_SEVERITY_WARN, 0, str) +#define CLOG_STR_ERROR_N(clg_ref, str) CLOG_STR_AT_SEVERITY_N(clg_ref, CLG_SEVERITY_ERROR, 0, str) +#define CLOG_STR_FATAL_N(clg_ref, str) CLOG_STR_AT_SEVERITY_N(clg_ref, CLG_SEVERITY_FATAL, 0, str) + #ifdef __cplusplus } #endif diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index bee0fe16637..080d2ef79dc 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -96,11 +96,11 @@ elseif(WIN32 AND MSVC AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") # there is no /arch:SSE3, but intrinsics are available anyway if(CMAKE_CL_64) set(CYCLES_SSE2_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS}") - set(CYCLES_SSE42_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS}") + set(CYCLES_SSE41_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS}") set(CYCLES_AVX2_KERNEL_FLAGS "${CYCLES_AVX2_ARCH_FLAGS} ${CYCLES_KERNEL_FLAGS}") else() set(CYCLES_SSE2_KERNEL_FLAGS "/arch:SSE2 ${CYCLES_KERNEL_FLAGS}") - set(CYCLES_SSE42_KERNEL_FLAGS "/arch:SSE2 ${CYCLES_KERNEL_FLAGS}") + set(CYCLES_SSE41_KERNEL_FLAGS "/arch:SSE2 ${CYCLES_KERNEL_FLAGS}") set(CYCLES_AVX2_KERNEL_FLAGS "${CYCLES_AVX2_ARCH_FLAGS} ${CYCLES_KERNEL_FLAGS}") endif() @@ -133,9 +133,9 @@ elseif(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) endif() set(CYCLES_SSE2_KERNEL_FLAGS "${CYCLES_KERNEL_FLAGS} -msse -msse2") - set(CYCLES_SSE42_KERNEL_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS} -msse3 -mssse3 -msse4.1 -msse4.2") + set(CYCLES_SSE41_KERNEL_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS} -msse3 -mssse3 -msse4.1") if(CXX_HAS_AVX2) - set(CYCLES_AVX2_KERNEL_FLAGS "${CYCLES_SSE42_KERNEL_FLAGS} -mavx -mavx2 -mfma -mlzcnt -mbmi -mbmi2 -mf16c") + set(CYCLES_AVX2_KERNEL_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS} -mavx -mavx2 -mfma -mlzcnt -mbmi -mbmi2 -mf16c") endif() endif() @@ -147,7 +147,7 @@ elseif(WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "Intel") if(CXX_HAS_SSE) set(CYCLES_SSE2_KERNEL_FLAGS "/QxSSE2") - set(CYCLES_SSE42_KERNEL_FLAGS "/QxSSE4.2") + set(CYCLES_SSE41_KERNEL_FLAGS "/QxSSE4.1") if(CXX_HAS_AVX2) set(CYCLES_AVX2_KERNEL_FLAGS "/QxCORE-AVX2") @@ -172,7 +172,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") set(CYCLES_SSE2_KERNEL_FLAGS "-xsse2") endif() - set(CYCLES_SSE42_KERNEL_FLAGS "-xsse4.2") + set(CYCLES_SSE41_KERNEL_FLAGS "-xsse4.1") if(CXX_HAS_AVX2) set(CYCLES_AVX2_KERNEL_FLAGS "-xcore-avx2") @@ -183,7 +183,7 @@ endif() if(CXX_HAS_SSE) add_definitions( -DWITH_KERNEL_SSE2 - -DWITH_KERNEL_SSE42 + -DWITH_KERNEL_SSE41 ) endif() diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 086f30dcf24..049c50e143d 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -888,6 +888,17 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): unit='LENGTH' ) + motion_blur_position: EnumProperty( + name="Motion Blur Position", + default='CENTER', + description="Offset for the shutter's time interval, allows to change the motion blur trails", + items=( + ('START', "Start on Frame", "The shutter opens at the current frame"), + ('CENTER', "Center on Frame", "The shutter is open during the current frame"), + ('END', "End on Frame", "The shutter closes at the current frame"), + ), + ) + rolling_shutter_type: EnumProperty( name="Shutter Type", default='NONE', @@ -969,7 +980,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): return _cycles.debug_flags_update(scene) debug_use_cpu_avx2: BoolProperty(name="AVX2", default=True) - debug_use_cpu_sse42: BoolProperty(name="SSE42", default=True) + debug_use_cpu_sse41: BoolProperty(name="SSE41", default=True) debug_use_cpu_sse2: BoolProperty(name="SSE2", default=True) debug_bvh_layout: EnumProperty( name="BVH Layout", diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 258a463e889..b9614a46a7c 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -653,7 +653,7 @@ class CYCLES_RENDER_PT_motion_blur(CyclesButtonsPanel, Panel): layout.active = rd.use_motion_blur col = layout.column() - col.prop(rd, "motion_blur_position", text="Position") + col.prop(cscene, "motion_blur_position", text="Position") col.prop(rd, "motion_blur_shutter") col.separator() col.prop(cscene, "rolling_shutter_type", text="Rolling Shutter") @@ -927,7 +927,6 @@ class CYCLES_RENDER_PT_override(CyclesButtonsPanel, Panel): view_layer = context.view_layer layout.prop(view_layer, "material_override") - layout.prop(view_layer, "world_override") layout.prop(view_layer, "samples") @@ -2235,7 +2234,7 @@ class CYCLES_RENDER_PT_debug(CyclesDebugButtonsPanel, Panel): row = col.row(align=True) row.prop(cscene, "debug_use_cpu_sse2", toggle=True) - row.prop(cscene, "debug_use_cpu_sse42", toggle=True) + row.prop(cscene, "debug_use_cpu_sse41", toggle=True) row.prop(cscene, "debug_use_cpu_avx2", toggle=True) col.prop(cscene, "debug_bvh_layout", text="BVH") diff --git a/intern/cycles/blender/camera.cpp b/intern/cycles/blender/camera.cpp index 59a129ae567..b743d7815ae 100644 --- a/intern/cycles/blender/camera.cpp +++ b/intern/cycles/blender/camera.cpp @@ -577,21 +577,6 @@ static void blender_camera_sync(Camera *cam, /* Sync Render Camera */ -static MotionPosition blender_motion_blur_position_type_to_cycles( - const BL::RenderSettings::motion_blur_position_enum type) -{ - switch (type) { - case BL::RenderSettings::motion_blur_position_START: - return MOTION_POSITION_START; - case BL::RenderSettings::motion_blur_position_CENTER: - return MOTION_POSITION_CENTER; - case BL::RenderSettings::motion_blur_position_END: - return MOTION_POSITION_END; - } - /* Could happen if loading a newer file that has an unsupported type. */ - return MOTION_POSITION_CENTER; -} - void BlenderSync::sync_camera(BL::RenderSettings &b_render, BL::Object &b_override, int width, @@ -605,13 +590,13 @@ void BlenderSync::sync_camera(BL::RenderSettings &b_render, bcam.pixelaspect.x = b_render.pixel_aspect_x(); bcam.pixelaspect.y = b_render.pixel_aspect_y(); bcam.shuttertime = b_render.motion_blur_shutter(); - bcam.motion_position = blender_motion_blur_position_type_to_cycles( - b_render.motion_blur_position()); BL::CurveMapping b_shutter_curve(b_render.motion_blur_shutter_curve()); curvemapping_to_array(b_shutter_curve, bcam.shutter_curve, RAMP_TABLE_SIZE); PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); + bcam.motion_position = (MotionPosition)get_enum( + cscene, "motion_blur_position", MOTION_NUM_POSITIONS, MOTION_POSITION_CENTER); bcam.rolling_shutter_type = (Camera::RollingShutterType)get_enum( cscene, "rolling_shutter_type", diff --git a/intern/cycles/blender/light.cpp b/intern/cycles/blender/light.cpp index 08898f0e440..6eaa4529250 100644 --- a/intern/cycles/blender/light.cpp +++ b/intern/cycles/blender/light.cpp @@ -166,7 +166,7 @@ void BlenderSync::sync_light(BL::Object &b_parent, void BlenderSync::sync_background_light(BL::SpaceView3D &b_v3d, bool use_portal) { - BL::World b_world = view_layer.world_override ? view_layer.world_override : b_scene.world(); + BL::World b_world = b_scene.world(); if (b_world) { PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles"); diff --git a/intern/cycles/blender/object.cpp b/intern/cycles/blender/object.cpp index 54d88477bc8..3bdefd47b62 100644 --- a/intern/cycles/blender/object.cpp +++ b/intern/cycles/blender/object.cpp @@ -25,7 +25,7 @@ #include "util/log.h" #include "util/task.h" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" CCL_NAMESPACE_BEGIN diff --git a/intern/cycles/blender/python.cpp b/intern/cycles/blender/python.cpp index ea41b12bd42..6bff3ee7aba 100644 --- a/intern/cycles/blender/python.cpp +++ b/intern/cycles/blender/python.cpp @@ -65,7 +65,7 @@ static void debug_flags_sync_from_scene(BL::Scene b_scene) PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); /* Synchronize CPU flags. */ flags.cpu.avx2 = get_boolean(cscene, "debug_use_cpu_avx2"); - flags.cpu.sse42 = get_boolean(cscene, "debug_use_cpu_sse42"); + flags.cpu.sse41 = get_boolean(cscene, "debug_use_cpu_sse41"); flags.cpu.sse2 = get_boolean(cscene, "debug_use_cpu_sse2"); flags.cpu.bvh_layout = (BVHLayout)get_enum(cscene, "debug_bvh_layout"); /* Synchronize CUDA flags. */ @@ -615,12 +615,14 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args) if (!found_existing) { /* Create new socket. */ - BL::NodeSocket b_sock = - (param->isoutput) ? - b_node.outputs.create( - b_data, socket_type.c_str(), param_label.c_str(), param->name.c_str(), false) : - b_node.inputs.create( - b_data, socket_type.c_str(), param_label.c_str(), param->name.c_str(), false); + BL::NodeSocket b_sock = (param->isoutput) ? b_node.outputs.create(b_data, + socket_type.c_str(), + param_label.c_str(), + param->name.c_str()) : + b_node.inputs.create(b_data, + socket_type.c_str(), + param_label.c_str(), + param->name.c_str()); /* set default value */ if (data_type == BL::NodeSocket::type_VALUE) { diff --git a/intern/cycles/blender/shader.cpp b/intern/cycles/blender/shader.cpp index e318b09d87c..998be73d555 100644 --- a/intern/cycles/blender/shader.cpp +++ b/intern/cycles/blender/shader.cpp @@ -23,7 +23,7 @@ #include "util/string.h" #include "util/task.h" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" CCL_NAMESPACE_BEGIN @@ -1592,7 +1592,7 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, Integrator *integrator = scene->integrator; PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); - BL::World b_world = view_layer.world_override ? view_layer.world_override : b_scene.world(); + BL::World b_world = b_scene.world(); BlenderViewportParameters new_viewport_parameters(b_v3d, use_developer_ui); diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp index 255b05998da..2f177731fd6 100644 --- a/intern/cycles/blender/sync.cpp +++ b/intern/cycles/blender/sync.cpp @@ -555,8 +555,6 @@ void BlenderSync::sync_view_layer(BL::ViewLayer &b_view_layer) /* Material override. */ view_layer.material_override = b_view_layer.material_override(); - /* World override. */ - view_layer.world_override = b_view_layer.world_override(); /* Sample override. */ PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); diff --git a/intern/cycles/blender/sync.h b/intern/cycles/blender/sync.h index 2c892c21e7f..6c3c5f26237 100644 --- a/intern/cycles/blender/sync.h +++ b/intern/cycles/blender/sync.h @@ -249,7 +249,6 @@ class BlenderSync { struct RenderLayerInfo { RenderLayerInfo() : material_override(PointerRNA_NULL), - world_override(PointerRNA_NULL), use_background_shader(true), use_surfaces(true), use_hair(true), @@ -262,7 +261,6 @@ class BlenderSync { string name; BL::Material material_override; - BL::World world_override; bool use_background_shader; bool use_surfaces; bool use_hair; diff --git a/intern/cycles/device/cpu/device.cpp b/intern/cycles/device/cpu/device.cpp index 77d7f6cc2a2..5d0959d5e6d 100644 --- a/intern/cycles/device/cpu/device.cpp +++ b/intern/cycles/device/cpu/device.cpp @@ -47,7 +47,7 @@ string device_cpu_capabilities() { string capabilities = ""; capabilities += system_cpu_support_sse2() ? "SSE2 " : ""; - capabilities += system_cpu_support_sse42() ? "SSE42 " : ""; + capabilities += system_cpu_support_sse41() ? "SSE41 " : ""; capabilities += system_cpu_support_avx2() ? "AVX2" : ""; if (capabilities[capabilities.size() - 1] == ' ') { capabilities.resize(capabilities.size() - 1); diff --git a/intern/cycles/device/cpu/kernel.cpp b/intern/cycles/device/cpu/kernel.cpp index 1a597ee3cef..8718820a0c8 100644 --- a/intern/cycles/device/cpu/kernel.cpp +++ b/intern/cycles/device/cpu/kernel.cpp @@ -10,7 +10,7 @@ CCL_NAMESPACE_BEGIN #define KERNEL_FUNCTIONS(name) \ KERNEL_NAME_EVAL(cpu, name), KERNEL_NAME_EVAL(cpu_sse2, name), \ - KERNEL_NAME_EVAL(cpu_sse42, name), KERNEL_NAME_EVAL(cpu_avx2, name) + KERNEL_NAME_EVAL(cpu_sse41, name), KERNEL_NAME_EVAL(cpu_avx2, name) #define REGISTER_KERNEL(name) name(KERNEL_FUNCTIONS(name)) #define REGISTER_KERNEL_FILM_CONVERT(name) \ diff --git a/intern/cycles/device/cpu/kernel_function.h b/intern/cycles/device/cpu/kernel_function.h index 4ba7cfda928..899849674b3 100644 --- a/intern/cycles/device/cpu/kernel_function.h +++ b/intern/cycles/device/cpu/kernel_function.h @@ -13,15 +13,15 @@ CCL_NAMESPACE_BEGIN * * Provides a function-call-like API which gets routed to the most suitable implementation. * - * For example, on a computer which only has SSE4.2 the kernel_sse42 will be used. */ + * For example, on a computer which only has SSE4.1 the kernel_sse41 will be used. */ template class CPUKernelFunction { public: CPUKernelFunction(FunctionType kernel_default, FunctionType kernel_sse2, - FunctionType kernel_sse42, + FunctionType kernel_sse41, FunctionType kernel_avx2) { - kernel_info_ = get_best_kernel_info(kernel_default, kernel_sse2, kernel_sse42, kernel_avx2); + kernel_info_ = get_best_kernel_info(kernel_default, kernel_sse2, kernel_sse41, kernel_avx2); } template inline auto operator()(Args... args) const @@ -56,12 +56,12 @@ template class CPUKernelFunction { KernelInfo get_best_kernel_info(FunctionType kernel_default, FunctionType kernel_sse2, - FunctionType kernel_sse42, + FunctionType kernel_sse41, FunctionType kernel_avx2) { /* Silence warnings about unused variables when compiling without some architectures. */ (void)kernel_sse2; - (void)kernel_sse42; + (void)kernel_sse41; (void)kernel_avx2; #ifdef WITH_CYCLES_OPTIMIZED_KERNEL_AVX2 @@ -70,9 +70,9 @@ template class CPUKernelFunction { } #endif -#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE42 - if (DebugFlags().cpu.has_sse42() && system_cpu_support_sse42()) { - return KernelInfo("SSE4.2", kernel_sse42); +#ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41 + if (DebugFlags().cpu.has_sse41() && system_cpu_support_sse41()) { + return KernelInfo("SSE4.1", kernel_sse41); } #endif diff --git a/intern/cycles/device/denoise.h b/intern/cycles/device/denoise.h index ad7a31fea60..ca5f651bb05 100644 --- a/intern/cycles/device/denoise.h +++ b/intern/cycles/device/denoise.h @@ -70,7 +70,8 @@ class DenoiseParams : public Node { bool temporally_stable = false; /* If true, then allow, if supported, OpenImageDenoise to use GPU device. - * If false, then OpenImageDenoise will always use CPU regardless of GPU device presence. */ + * If false, then OpenImageDenoise will always use CPU regardless of GPU device + * precense. */ bool use_gpu = true; DenoiserPrefilter prefilter = DENOISER_PREFILTER_FAST; diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index 3b53e3b9b0e..9c91c8fd9e3 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -15,7 +15,7 @@ set(INC_SYS set(SRC_KERNEL_DEVICE_CPU device/cpu/kernel.cpp device/cpu/kernel_sse2.cpp - device/cpu/kernel_sse42.cpp + device/cpu/kernel_sse41.cpp device/cpu/kernel_avx2.cpp ) @@ -1165,7 +1165,7 @@ set_source_files_properties(device/cpu/kernel.cpp PROPERTIES COMPILE_FLAGS "${CY if(CXX_HAS_SSE) set_source_files_properties(device/cpu/kernel_sse2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS}") - set_source_files_properties(device/cpu/kernel_sse42.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE42_KERNEL_FLAGS}") + set_source_files_properties(device/cpu/kernel_sse41.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS}") endif() if(CXX_HAS_AVX2) diff --git a/intern/cycles/kernel/device/cpu/kernel.cpp b/intern/cycles/kernel/device/cpu/kernel.cpp index cf42b8d6cda..a90d351c7c9 100644 --- a/intern/cycles/kernel/device/cpu/kernel.cpp +++ b/intern/cycles/kernel/device/cpu/kernel.cpp @@ -27,8 +27,8 @@ # ifdef __SSSE3__ # define __KERNEL_SSSE3__ # endif -# ifdef __SSE4_2__ -# define __KERNEL_SSE42__ +# ifdef __SSE4_1__ +# define __KERNEL_SSE41__ # endif # ifdef __AVX__ # ifndef __KERNEL_SSE__ diff --git a/intern/cycles/kernel/device/cpu/kernel.h b/intern/cycles/kernel/device/cpu/kernel.h index 902e2d341a9..63ea39c17bc 100644 --- a/intern/cycles/kernel/device/cpu/kernel.h +++ b/intern/cycles/kernel/device/cpu/kernel.h @@ -36,7 +36,7 @@ void kernel_global_memory_copy(KernelGlobalsCPU *kg, const char *name, void *mem #define KERNEL_ARCH cpu_sse2 #include "kernel/device/cpu/kernel_arch.h" -#define KERNEL_ARCH cpu_sse42 +#define KERNEL_ARCH cpu_sse41 #include "kernel/device/cpu/kernel_arch.h" #define KERNEL_ARCH cpu_avx2 diff --git a/intern/cycles/kernel/device/cpu/kernel_avx2.cpp b/intern/cycles/kernel/device/cpu/kernel_avx2.cpp index 097601e1950..8015fe23968 100644 --- a/intern/cycles/kernel/device/cpu/kernel_avx2.cpp +++ b/intern/cycles/kernel/device/cpu/kernel_avx2.cpp @@ -17,7 +17,7 @@ # define __KERNEL_SSE2__ # define __KERNEL_SSE3__ # define __KERNEL_SSSE3__ -# define __KERNEL_SSE42__ +# define __KERNEL_SSE41__ # define __KERNEL_AVX__ # define __KERNEL_AVX2__ # endif diff --git a/intern/cycles/kernel/device/cpu/kernel_sse42.cpp b/intern/cycles/kernel/device/cpu/kernel_sse41.cpp similarity index 81% rename from intern/cycles/kernel/device/cpu/kernel_sse42.cpp rename to intern/cycles/kernel/device/cpu/kernel_sse41.cpp index 6215df32f12..20df03dd9d2 100644 --- a/intern/cycles/kernel/device/cpu/kernel_sse42.cpp +++ b/intern/cycles/kernel/device/cpu/kernel_sse41.cpp @@ -8,7 +8,7 @@ #include "util/optimization.h" -#ifndef WITH_CYCLES_OPTIMIZED_KERNEL_SSE42 +#ifndef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41 # define KERNEL_STUB #else /* SSE optimization disabled for now on 32 bit, see bug #36316. */ @@ -16,10 +16,10 @@ # define __KERNEL_SSE2__ # define __KERNEL_SSE3__ # define __KERNEL_SSSE3__ -# define __KERNEL_SSE42__ +# define __KERNEL_SSE41__ # endif -#endif /* WITH_CYCLES_OPTIMIZED_KERNEL_SSE42 */ +#endif /* WITH_CYCLES_OPTIMIZED_KERNEL_SSE41 */ #include "kernel/device/cpu/kernel.h" -#define KERNEL_ARCH cpu_sse42 +#define KERNEL_ARCH cpu_sse41 #include "kernel/device/cpu/kernel_arch_impl.h" diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt index c8c8373436b..fca9b02b396 100644 --- a/intern/cycles/util/CMakeLists.txt +++ b/intern/cycles/util/CMakeLists.txt @@ -27,7 +27,7 @@ set(SRC time.cpp transform.cpp transform_avx2.cpp - transform_sse42.cpp + transform_sse41.cpp windows.cpp ) @@ -137,7 +137,7 @@ set(SRC_HEADERS ) if(CXX_HAS_SSE) - set_source_files_properties(transform_sse42.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE42_KERNEL_FLAGS}") + set_source_files_properties(transform_sse41.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS}") endif() if(CXX_HAS_AVX2) set_source_files_properties(transform_avx2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX2_KERNEL_FLAGS}") diff --git a/intern/cycles/util/debug.cpp b/intern/cycles/util/debug.cpp index 903a1d4cf23..de536690c11 100644 --- a/intern/cycles/util/debug.cpp +++ b/intern/cycles/util/debug.cpp @@ -30,7 +30,7 @@ void DebugFlags::CPU::reset() } while (0) CHECK_CPU_FLAGS(avx2, "CYCLES_CPU_NO_AVX2"); - CHECK_CPU_FLAGS(sse42, "CYCLES_CPU_NO_SSE42"); + CHECK_CPU_FLAGS(sse41, "CYCLES_CPU_NO_SSE41"); CHECK_CPU_FLAGS(sse2, "CYCLES_CPU_NO_SSE2"); #undef STRINGIFY diff --git a/intern/cycles/util/debug.h b/intern/cycles/util/debug.h index 6759256c1a4..71f7165cd56 100644 --- a/intern/cycles/util/debug.h +++ b/intern/cycles/util/debug.h @@ -26,7 +26,7 @@ class DebugFlags { /* Flags describing which instructions sets are allowed for use. */ bool avx2 = true; - bool sse42 = true; + bool sse41 = true; bool sse2 = true; /* Check functions to see whether instructions up to the given one @@ -34,11 +34,11 @@ class DebugFlags { */ bool has_avx2() { - return has_sse42() && avx2; + return has_sse41() && avx2; } - bool has_sse42() + bool has_sse41() { - return has_sse2() && sse42; + return has_sse2() && sse41; } bool has_sse2() { diff --git a/intern/cycles/util/guiding.h b/intern/cycles/util/guiding.h index 1c5dbb24814..c4bd3992251 100644 --- a/intern/cycles/util/guiding.h +++ b/intern/cycles/util/guiding.h @@ -22,7 +22,7 @@ static int guiding_device_type() if (system_cpu_support_avx2()) { return 8; } - if (system_cpu_support_sse42()) { + if (system_cpu_support_sse41()) { return 4; } return 0; diff --git a/intern/cycles/util/math_fast.h b/intern/cycles/util/math_fast.h index cec5e5391fb..059c876fd8c 100644 --- a/intern/cycles/util/math_fast.h +++ b/intern/cycles/util/math_fast.h @@ -62,7 +62,7 @@ ccl_device_inline float4 madd4(const float4 a, const float4 b, const float4 c) ccl_device_inline int fast_rint(float x) { /* used by sin/cos/tan range reduction. */ -#ifdef __KERNEL_SSE42__ +#ifdef __KERNEL_SSE41__ /* Single `roundps` instruction on SSE4.1+ for gcc/clang but not MSVC 19.35: * float_to_int(rintf(x)); so we use the equivalent intrinsics. */ __m128 vec = _mm_set_ss(x); diff --git a/intern/cycles/util/math_float3.h b/intern/cycles/util/math_float3.h index 38f86de6054..eaf13cf779f 100644 --- a/intern/cycles/util/math_float3.h +++ b/intern/cycles/util/math_float3.h @@ -200,7 +200,7 @@ ccl_device_inline bool operator!=(const float3 a, const float3 b) ccl_device_inline float dot(const float3 a, const float3 b) { -# if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__) +# if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__) return _mm_cvtss_f32(_mm_dp_ps(a, b, 0x7F)); # else return a.x * b.x + a.y * b.y + a.z * b.z; @@ -211,7 +211,7 @@ ccl_device_inline float dot(const float3 a, const float3 b) ccl_device_inline float dot_xy(const float3 a, const float3 b) { -#if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__) +#if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__) return _mm_cvtss_f32(_mm_hadd_ps(_mm_mul_ps(a, b), b)); #else return a.x * b.x + a.y * b.y; @@ -220,7 +220,7 @@ ccl_device_inline float dot_xy(const float3 a, const float3 b) ccl_device_inline float len(const float3 a) { -#if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__) +#if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__) return _mm_cvtss_f32(_mm_sqrt_ss(_mm_dp_ps(a.m128, a.m128, 0x7F))); #else return sqrtf(dot(a, a)); @@ -264,7 +264,7 @@ ccl_device_inline float3 cross(const float3 a, const float3 b) ccl_device_inline float3 normalize(const float3 a) { -# if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__) +# if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__) __m128 norm = _mm_sqrt_ps(_mm_dp_ps(a.m128, a.m128, 0x7F)); return float3(_mm_div_ps(a.m128, norm)); # else diff --git a/intern/cycles/util/math_float4.h b/intern/cycles/util/math_float4.h index 369b5fef3c2..235bf3fa373 100644 --- a/intern/cycles/util/math_float4.h +++ b/intern/cycles/util/math_float4.h @@ -364,7 +364,7 @@ ccl_device_inline float reduce_max(const float4 a) #if !defined(__KERNEL_METAL__) ccl_device_inline float dot(const float4 a, const float4 b) { -# if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__) +# if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__) # if defined(__KERNEL_NEON__) __m128 t = vmulq_f32(a, b); return vaddvq_f32(t); @@ -534,7 +534,7 @@ ccl_device_inline bool isequal(const float4 a, const float4 b) ccl_device_inline float4 select(const int4 mask, const float4 a, const float4 b) { # ifdef __KERNEL_SSE__ -# ifdef __KERNEL_SSE42__ +# ifdef __KERNEL_SSE41__ return float4(_mm_blendv_ps(b.m128, a.m128, _mm_castsi128_ps(mask.m128))); # else return float4( diff --git a/intern/cycles/util/math_int3.h b/intern/cycles/util/math_int3.h index dfc30ead886..ae0b81f88a8 100644 --- a/intern/cycles/util/math_int3.h +++ b/intern/cycles/util/math_int3.h @@ -14,7 +14,7 @@ CCL_NAMESPACE_BEGIN #if !defined(__KERNEL_METAL__) ccl_device_inline int3 min(int3 a, int3 b) { -# if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE42__) +# if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE41__) return int3(_mm_min_epi32(a.m128, b.m128)); # else return make_int3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z)); @@ -23,7 +23,7 @@ ccl_device_inline int3 min(int3 a, int3 b) ccl_device_inline int3 max(int3 a, int3 b) { -# if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE42__) +# if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE41__) return int3(_mm_max_epi32(a.m128, b.m128)); # else return make_int3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z)); diff --git a/intern/cycles/util/math_int4.h b/intern/cycles/util/math_int4.h index 8929290e9a4..ce5eaf40a52 100644 --- a/intern/cycles/util/math_int4.h +++ b/intern/cycles/util/math_int4.h @@ -203,7 +203,7 @@ ccl_device_forceinline const int4 srl(const int4 a, const int32_t b) ccl_device_inline int4 min(int4 a, int4 b) { -# if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE42__) +# if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE41__) return int4(_mm_min_epi32(a.m128, b.m128)); # else return make_int4(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w)); @@ -212,7 +212,7 @@ ccl_device_inline int4 min(int4 a, int4 b) ccl_device_inline int4 max(int4 a, int4 b) { -# if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE42__) +# if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE41__) return int4(_mm_max_epi32(a.m128, b.m128)); # else return make_int4(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w)); diff --git a/intern/cycles/util/math_intersect.h b/intern/cycles/util/math_intersect.h index f662ed4f394..b5eb209ec82 100644 --- a/intern/cycles/util/math_intersect.h +++ b/intern/cycles/util/math_intersect.h @@ -136,7 +136,7 @@ ccl_device_forceinline float ray_triangle_rcp(const float x) ccl_device_inline float ray_triangle_dot(const float3 a, const float3 b) { -#if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__) +#if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__) return madd(make_float4(a.x), make_float4(b.x), madd(make_float4(a.y), make_float4(b.y), make_float4(a.z) * make_float4(b.z)))[0]; @@ -147,7 +147,7 @@ ccl_device_inline float ray_triangle_dot(const float3 a, const float3 b) ccl_device_inline float3 ray_triangle_cross(const float3 a, const float3 b) { -#if defined(__KERNEL_SSE42__) && defined(__KERNEL_SSE__) +#if defined(__KERNEL_SSE41__) && defined(__KERNEL_SSE__) return make_float3( msub(make_float4(a.y), make_float4(b.z), make_float4(a.z) * make_float4(b.y))[0], msub(make_float4(a.z), make_float4(b.x), make_float4(a.x) * make_float4(b.z))[0], diff --git a/intern/cycles/util/openimagedenoise.h b/intern/cycles/util/openimagedenoise.h index da3952b7257..be4ca39a3c4 100644 --- a/intern/cycles/util/openimagedenoise.h +++ b/intern/cycles/util/openimagedenoise.h @@ -20,7 +20,7 @@ static inline bool openimagedenoise_supported() /* Always supported through Accelerate framework BNNS. */ return true; # else - return system_cpu_support_sse42(); + return system_cpu_support_sse41(); # endif #else return false; diff --git a/intern/cycles/util/optimization.h b/intern/cycles/util/optimization.h index dfa19f11352..d4cdc4c1d6e 100644 --- a/intern/cycles/util/optimization.h +++ b/intern/cycles/util/optimization.h @@ -21,15 +21,15 @@ /* x86-64 * - * Compile a regular (includes SSE2), SSE 4.2 and AVX2 kernel. */ + * Compile a regular (includes SSE2), SSE3, SSE 4.1, AVX and AVX2 kernel. */ # elif defined(__x86_64__) || defined(_M_X64) /* SSE2 is always available on x86-64 CPUs, so auto enable */ # define __KERNEL_SSE2__ /* no SSE2 kernel on x86-64, part of regular kernel */ -# ifdef WITH_KERNEL_SSE42 -# define WITH_CYCLES_OPTIMIZED_KERNEL_SSE42 +# ifdef WITH_KERNEL_SSE41 +# define WITH_CYCLES_OPTIMIZED_KERNEL_SSE41 # endif # ifdef WITH_KERNEL_AVX2 # define WITH_CYCLES_OPTIMIZED_KERNEL_AVX2 @@ -47,7 +47,7 @@ # define __KERNEL_SSE__ # define __KERNEL_SSE2__ # define __KERNEL_SSE3__ -# define __KERNEL_SSE42__ +# define __KERNEL_SSE41__ # endif diff --git a/intern/cycles/util/simd.h b/intern/cycles/util/simd.h index 8c1c46b89dc..e612475d765 100644 --- a/intern/cycles/util/simd.h +++ b/intern/cycles/util/simd.h @@ -463,10 +463,10 @@ __forceinline uint64_t bitscan(uint64_t value) * implementations. */ #ifdef __KERNEL_SSE2__ -/* Test __KERNEL_SSE42__ for MSVC which does not define __SSE4_2__, and test - * __SSE4_1__ and __SSE4_2__ to avoid OpenImageIO conflicts with our emulation macros on other +/* Test __KERNEL_SSE41__ for MSVC which does not define __SSE4_1__, and test + * __SSE4_1__ to avoid OpenImageIO conflicts with our emulation macros on other * platforms when compiling code outside the kernel. */ -# if !(defined(__KERNEL_SSE42__) || defined(__SSE4_1__) || defined(__SSE4_2__)) +# if !(defined(__KERNEL_SSE41__) || defined(__SSE4_1__) || defined(__SSE4_2__)) /* Emulation of SSE4 functions with SSE2 */ @@ -573,7 +573,7 @@ __forceinline __m128 _mm_round_ps_emu(__m128 value, const int flags) return value; } -# endif /* !(defined(__KERNEL_SSE42__) || defined(__SSE4_1__) || defined(__SSE4_2__)) */ +# endif /* !(defined(__KERNEL_SSE41__) || defined(__SSE4_1__) || defined(__SSE4_2__)) */ /* Older GCC versions do not have _mm256_cvtss_f32 yet, so define it ourselves. * _mm256_castps256_ps128 generates no instructions so this is just as efficient. */ @@ -586,7 +586,7 @@ __forceinline __m128 _mm_round_ps_emu(__m128 value, const int flags) /* quiet unused define warnings */ #if defined(__KERNEL_SSE2__) || defined(__KERNEL_SSE3__) || defined(__KERNEL_SSSE3__) || \ - defined(__KERNEL_SSE42__) || defined(__KERNEL_AVX__) || defined(__KERNEL_AVX2__) + defined(__KERNEL_SSE41__) || defined(__KERNEL_AVX__) || defined(__KERNEL_AVX2__) /* do nothing */ #endif diff --git a/intern/cycles/util/system.cpp b/intern/cycles/util/system.cpp index afd3bef1961..0af0d1fad4e 100644 --- a/intern/cycles/util/system.cpp +++ b/intern/cycles/util/system.cpp @@ -130,7 +130,9 @@ int system_cpu_bits() struct CPUCapabilities { bool sse2; - bool sse42; + bool sse3; + bool sse41; + bool avx; bool avx2; }; @@ -153,7 +155,7 @@ static CPUCapabilities &system_cpu_capabilities() const bool ssse3 = (result[2] & ((int)1 << 9)) != 0; const bool sse41 = (result[2] & ((int)1 << 19)) != 0; - const bool sse42 = (result[2] & ((int)1 << 20)) != 0; + // const bool sse42 = (result[2] & ((int)1 << 20)) != 0; const bool fma3 = (result[2] & ((int)1 << 12)) != 0; const bool os_uses_xsave_xrestore = (result[2] & ((int)1 << 27)) != 0; @@ -161,7 +163,8 @@ static CPUCapabilities &system_cpu_capabilities() /* Simplify to combined capabilities for which we specialize kernels. */ caps.sse2 = sse && sse2; - caps.sse42 = sse && sse2 && sse3 && ssse3 && sse41 && sse42; + caps.sse3 = sse && sse2 && sse3 && ssse3; + caps.sse41 = sse && sse2 && sse3 && ssse3 && sse41; if (os_uses_xsave_xrestore && cpu_avx_support) { // Check if the OS will save the YMM registers @@ -184,8 +187,9 @@ static CPUCapabilities &system_cpu_capabilities() bool bmi2 = (result[1] & ((int)1 << 8)) != 0; bool avx2 = (result[1] & ((int)1 << 5)) != 0; - caps.avx2 = sse && sse2 && sse3 && ssse3 && sse41 && sse42 && avx && f16c && avx2 && - fma3 && bmi1 && bmi2; + caps.avx = sse && sse2 && sse3 && ssse3 && sse41 && avx; + caps.avx2 = sse && sse2 && sse3 && ssse3 && sse41 && avx && f16c && avx2 && fma3 && bmi1 && + bmi2; } } @@ -201,10 +205,10 @@ bool system_cpu_support_sse2() return caps.sse2; } -bool system_cpu_support_sse42() +bool system_cpu_support_sse41() { CPUCapabilities &caps = system_cpu_capabilities(); - return caps.sse42; + return caps.sse41; } bool system_cpu_support_avx2() @@ -219,7 +223,7 @@ bool system_cpu_support_sse2() return false; } -bool system_cpu_support_sse42() +bool system_cpu_support_sse41() { return false; } diff --git a/intern/cycles/util/system.h b/intern/cycles/util/system.h index f14c0551056..187ab5cd3fc 100644 --- a/intern/cycles/util/system.h +++ b/intern/cycles/util/system.h @@ -18,7 +18,7 @@ int system_console_width(); std::string system_cpu_brand_string(); int system_cpu_bits(); bool system_cpu_support_sse2(); -bool system_cpu_support_sse42(); +bool system_cpu_support_sse41(); bool system_cpu_support_avx2(); size_t system_physical_ram(); diff --git a/intern/cycles/util/transform.h b/intern/cycles/util/transform.h index 208c68dc5a1..af12ac3d0ea 100644 --- a/intern/cycles/util/transform.h +++ b/intern/cycles/util/transform.h @@ -405,7 +405,7 @@ ccl_device_inline float4 quat_interpolate(float4 q1, float4 q2, float t) } #ifndef __KERNEL_GPU__ -void transform_inverse_cpu_sse42(const Transform &tfm, Transform &itfm); +void transform_inverse_cpu_sse41(const Transform &tfm, Transform &itfm); void transform_inverse_cpu_avx2(const Transform &tfm, Transform &itfm); #endif @@ -418,9 +418,9 @@ ccl_device_inline Transform transform_inverse(const Transform tfm) transform_inverse_cpu_avx2(tfm, itfm); return itfm; } - else if (system_cpu_support_sse42()) { + else if (system_cpu_support_sse41()) { Transform itfm; - transform_inverse_cpu_sse42(tfm, itfm); + transform_inverse_cpu_sse41(tfm, itfm); return itfm; } #endif diff --git a/intern/cycles/util/transform_inverse.h b/intern/cycles/util/transform_inverse.h index fe43e88e49a..32a62a27620 100644 --- a/intern/cycles/util/transform_inverse.h +++ b/intern/cycles/util/transform_inverse.h @@ -30,7 +30,7 @@ ccl_device_forceinline float3 transform_inverse_cross(const float3 a_, const flo ccl_device_forceinline float transform_inverse_dot(const float3 a_, const float3 b_) { -#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE42__) +#if defined(__KERNEL_SSE__) && defined(__KERNEL_SSE41__) const __m128 a = (const __m128 &)a_; const __m128 b = (const __m128 &)b_; return _mm_cvtss_f32(_mm_dp_ps(a, b, 0x7F)); diff --git a/intern/cycles/util/transform_sse42.cpp b/intern/cycles/util/transform_sse41.cpp similarity index 77% rename from intern/cycles/util/transform_sse42.cpp rename to intern/cycles/util/transform_sse41.cpp index b47392e6f34..8e64cc9cd71 100644 --- a/intern/cycles/util/transform_sse42.cpp +++ b/intern/cycles/util/transform_sse41.cpp @@ -6,7 +6,7 @@ CCL_NAMESPACE_BEGIN -void transform_inverse_cpu_sse42(const Transform &tfm, Transform &itfm) +void transform_inverse_cpu_sse41(const Transform &tfm, Transform &itfm) { itfm = transform_inverse_impl(tfm); } diff --git a/intern/ghost/intern/GHOST_DropTargetX11.cc b/intern/ghost/intern/GHOST_DropTargetX11.cc index 45edd553886..505cd07ab23 100644 --- a/intern/ghost/intern/GHOST_DropTargetX11.cc +++ b/intern/ghost/intern/GHOST_DropTargetX11.cc @@ -102,8 +102,7 @@ GHOST_DropTargetX11::~GHOST_DropTargetX11() char *GHOST_DropTargetX11::FileUrlDecode(const char *fileUrl) { if (strncmp(fileUrl, "file://", 7) == 0) { - const char *file = fileUrl + 7; - return GHOST_URL_decode_alloc(file, strlen(file)); + return GHOST_URL_decode_alloc(fileUrl + 7); } return nullptr; diff --git a/intern/ghost/intern/GHOST_PathUtils.cc b/intern/ghost/intern/GHOST_PathUtils.cc index b53b2a85cba..4c51a803871 100644 --- a/intern/ghost/intern/GHOST_PathUtils.cc +++ b/intern/ghost/intern/GHOST_PathUtils.cc @@ -12,7 +12,6 @@ #include #include -#include "GHOST_Debug.hh" #include "GHOST_PathUtils.hh" #include "GHOST_Types.h" @@ -25,10 +24,9 @@ using DecodeState_e = enum DecodeState_e { STATE_CONVERTING }; -void GHOST_URL_decode(char *buf_dst, int buf_dst_size, const char *buf_src, const int buf_src_len) +void GHOST_URL_decode(char *buf_dst, int buf_dst_size, const char *buf_src) { - GHOST_ASSERT(strnlen(buf_src, buf_src_len) == buf_src_len, "Incorrect length"); - + const uint buf_src_len = strlen(buf_src); DecodeState_e state = STATE_SEARCH; uint ascii_character; @@ -87,12 +85,12 @@ void GHOST_URL_decode(char *buf_dst, int buf_dst_size, const char *buf_src, cons } } -char *GHOST_URL_decode_alloc(const char *buf_src, const int buf_src_len) +char *GHOST_URL_decode_alloc(const char *buf_src) { /* Assume one character of encoded URL can be expanded to 4 chars max. */ - const size_t decoded_size_max = 4 * buf_src_len + 1; + const size_t decoded_size_max = 4 * strlen(buf_src) + 1; char *buf_dst = (char *)malloc(decoded_size_max); - GHOST_URL_decode(buf_dst, decoded_size_max, buf_src, buf_src_len); + GHOST_URL_decode(buf_dst, decoded_size_max, buf_src); const size_t decoded_size = strlen(buf_dst) + 1; if (decoded_size != decoded_size_max) { char *buf_dst_trim = (char *)malloc(decoded_size); diff --git a/intern/ghost/intern/GHOST_PathUtils.hh b/intern/ghost/intern/GHOST_PathUtils.hh index bc8a2a894b3..941e405344a 100644 --- a/intern/ghost/intern/GHOST_PathUtils.hh +++ b/intern/ghost/intern/GHOST_PathUtils.hh @@ -14,13 +14,12 @@ * \param buf_dst: Buffer for decoded URL. * \param buf_dst_maxlen: Size of output buffer. * \param buf_src: Input encoded buffer to be decoded. - * \param buf_src_len: The length of `buf_src` to use. */ -void GHOST_URL_decode(char *buf_dst, int buf_dst_size, const char *buf_src, int buf_src_len); +void GHOST_URL_decode(char *buf_dst, int buf_dst_size, const char *buf_src); /** * A version of #GHOST_URL_decode that allocates the string & returns it. * * \param buf_src: Input encoded buffer to be decoded. * \return The decoded output buffer. */ -char *GHOST_URL_decode_alloc(const char *buf_src, int buf_src_len); +char *GHOST_URL_decode_alloc(const char *buf_src); diff --git a/intern/ghost/intern/GHOST_SystemWayland.cc b/intern/ghost/intern/GHOST_SystemWayland.cc index 84fab4825ec..77480f92072 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cc +++ b/intern/ghost/intern/GHOST_SystemWayland.cc @@ -2926,9 +2926,6 @@ static char *read_buffer_from_data_offer(GWL_DataOffer *data_offer, } close(pipefd[0]); } - else { - *r_len = 0; - } return buf; } @@ -3262,19 +3259,20 @@ static void data_device_handle_drop(void *data, wl_data_device * /*wl_data_devic CLOG_INFO(LOG, 2, "drop mime_recieve=%s", mime_receive); - auto read_drop_data_fn = [](GWL_Seat *const seat, - GWL_DataOffer *data_offer, - wl_surface *wl_surface_window, - const char *mime_receive) { + auto read_uris_fn = [](GWL_Seat *const seat, + GWL_DataOffer *data_offer, + wl_surface *wl_surface_window, + const char *mime_receive) { const uint64_t event_ms = seat->system->getMilliSeconds(); const wl_fixed_t xy[2] = {UNPACK2(data_offer->dnd.xy)}; - const bool nil_terminate = (mime_receive != ghost_wl_mime_text_uri); size_t data_buf_len = 0; const char *data_buf = read_buffer_from_data_offer( - data_offer, mime_receive, nullptr, nil_terminate, &data_buf_len); + data_offer, mime_receive, nullptr, false, &data_buf_len); + std::string data = data_buf ? std::string(data_buf, data_buf_len) : ""; + free(const_cast(data_buf)); - CLOG_INFO(LOG, 2, "read_drop_data mime_receive=%s, data_len=%zu", mime_receive, data_buf_len); + CLOG_INFO(LOG, 2, "drop_read_uris mime_receive=%s, data=%s", mime_receive, data.c_str()); wl_data_offer_finish(data_offer->wl.id); wl_data_offer_destroy(data_offer->wl.id); @@ -3285,97 +3283,69 @@ static void data_device_handle_drop(void *data, wl_data_device * /*wl_data_devic delete data_offer; data_offer = nullptr; - /* Don't generate a drop event if the data could not be read, - * an error will have been logged. */ - if (data_buf != nullptr) { - GHOST_TDragnDropTypes ghost_dnd_type = GHOST_kDragnDropTypeUnknown; - void *ghost_dnd_data = nullptr; + GHOST_SystemWayland *const system = seat->system; - /* Failure to receive drop data . */ - if (mime_receive == ghost_wl_mime_text_uri) { - const char file_proto[] = "file://"; - /* NOTE: some applications CRLF (`\r\n`) GTK3 for e.g. & others don't `pcmanfm-qt`. - * So support both, once `\n` is found, strip the preceding `\r` if found. */ - const char lf = '\n'; + if (mime_receive == ghost_wl_mime_text_uri) { + const char file_proto[] = "file://"; + /* NOTE: some applications CRLF (`\r\n`) GTK3 for e.g. & others don't `pcmanfm-qt`. + * So support both, once `\n` is found, strip the preceding `\r` if found. */ + const char lf = '\n'; - const std::string_view data = std::string_view(data_buf, data_buf_len); - std::vector uris; + GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_window); + std::vector uris; - size_t pos = 0; - while (pos != std::string::npos) { - pos = data.find(file_proto, pos); - if (pos == std::string::npos) { - break; - } - const size_t start = pos + sizeof(file_proto) - 1; - pos = data.find(lf, pos); - - size_t end = pos; - if (UNLIKELY(end == std::string::npos)) { - /* Note that most well behaved file managers will add a trailing newline, - * Gnome's web browser (44.3) doesn't, so support reading up until the last byte. */ - end = data.size(); - } - /* Account for 'CRLF' case. */ - if (data[end - 1] == '\r') { - end -= 1; - } - - std::string_view data_substr = data.substr(start, end - start); - uris.push_back(data_substr); - CLOG_INFO(LOG, - 2, - "read_drop_data pos=%zu, text_uri=\"%.*s\"", - start, - int(data_substr.size()), - data_substr.data()); + size_t pos = 0; + while (pos != std::string::npos) { + pos = data.find(file_proto, pos); + if (pos == std::string::npos) { + break; } + const size_t start = pos + sizeof(file_proto) - 1; + pos = data.find(lf, pos); - GHOST_TStringArray *flist = static_cast( - malloc(sizeof(GHOST_TStringArray))); - flist->count = int(uris.size()); - flist->strings = static_cast(malloc(uris.size() * sizeof(uint8_t *))); - for (size_t i = 0; i < uris.size(); i++) { - flist->strings[i] = reinterpret_cast( - GHOST_URL_decode_alloc(uris[i].data(), uris[i].size())); + size_t end = pos; + if (UNLIKELY(end == std::string::npos)) { + /* Note that most well behaved file managers will add a trailing newline, + * Gnome's web browser (44.3) doesn't, so support reading up until the last byte. */ + end = data.size(); } - - CLOG_INFO(LOG, 2, "read_drop_data file_count=%d", flist->count); - ghost_dnd_type = GHOST_kDragnDropTypeFilenames; - ghost_dnd_data = flist; - } - else if (ELEM(mime_receive, ghost_wl_mime_text_plain, ghost_wl_mime_text_utf8)) { - ghost_dnd_type = GHOST_kDragnDropTypeString; - ghost_dnd_data = (void *)data_buf; /* Move ownership to the event. */ - data_buf = nullptr; + /* Account for 'CRLF' case. */ + if (data[end - 1] == '\r') { + end -= 1; + } + uris.push_back(data.substr(start, end - start)); + CLOG_INFO(LOG, 2, "drop_read_uris pos=%zu, text_uri=\"%s\"", start, uris.back().c_str()); } - if (ghost_dnd_type != GHOST_kDragnDropTypeUnknown) { - GHOST_SystemWayland *const system = seat->system; - GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_window); - const int event_xy[2] = {WL_FIXED_TO_INT_FOR_WINDOW_V2(win, xy)}; - - system->pushEvent_maybe_pending(new GHOST_EventDragnDrop(event_ms, - GHOST_kEventDraggingDropDone, - ghost_dnd_type, - win, - UNPACK2(event_xy), - ghost_dnd_data)); - - wl_display_roundtrip(system->wl_display_get()); - } - else { - CLOG_INFO(LOG, 2, "read_drop_data, unhandled!"); + GHOST_TStringArray *flist = static_cast( + malloc(sizeof(GHOST_TStringArray))); + flist->count = int(uris.size()); + flist->strings = static_cast(malloc(uris.size() * sizeof(uint8_t *))); + for (size_t i = 0; i < uris.size(); i++) { + flist->strings[i] = reinterpret_cast(GHOST_URL_decode_alloc(uris[i].c_str())); } - free(const_cast(data_buf)); + CLOG_INFO(LOG, 2, "drop_read_uris_fn file_count=%d", flist->count); + const int event_xy[2] = {WL_FIXED_TO_INT_FOR_WINDOW_V2(win, xy)}; + system->pushEvent_maybe_pending(new GHOST_EventDragnDrop(event_ms, + GHOST_kEventDraggingDropDone, + GHOST_kDragnDropTypeFilenames, + win, + UNPACK2(event_xy), + flist)); } + else if (ELEM(mime_receive, ghost_wl_mime_text_plain, ghost_wl_mime_text_utf8)) { + /* TODO: enable use of internal functions 'txt_insert_buf' and + * 'text_update_edited' to behave like dropped text was pasted. */ + CLOG_INFO(LOG, 2, "drop_read_uris_fn (text_plain, text_utf8), unhandled!"); + } + wl_display_roundtrip(system->wl_display_get()); }; /* Pass in `seat->wl_surface_window_focus_dnd` instead of accessing it from `seat` since the * leave callback (#data_device_handle_leave) will clear the value once this function starts. */ std::thread read_thread( - read_drop_data_fn, seat, data_offer, seat->wl.surface_window_focus_dnd, mime_receive); + read_uris_fn, seat, data_offer, seat->wl.surface_window_focus_dnd, mime_receive); read_thread.detach(); } diff --git a/intern/ghost/intern/GHOST_SystemWin32.cc b/intern/ghost/intern/GHOST_SystemWin32.cc index 35b8de3672f..33708e92058 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cc +++ b/intern/ghost/intern/GHOST_SystemWin32.cc @@ -135,7 +135,8 @@ static void initRawInput() typedef BOOL(API *GHOST_WIN32_EnableNonClientDpiScaling)(HWND); -GHOST_SystemWin32::GHOST_SystemWin32() : m_hasPerformanceCounter(false), m_freq(0) +GHOST_SystemWin32::GHOST_SystemWin32() + : m_hasPerformanceCounter(false), m_freq(0), m_start(0), m_lfstart(0) { m_displayManager = new GHOST_DisplayManagerWin32(); GHOST_ASSERT(m_displayManager, "GHOST_SystemWin32::GHOST_SystemWin32(): m_displayManager==0\n"); @@ -177,17 +178,22 @@ GHOST_SystemWin32::~GHOST_SystemWin32() uint64_t GHOST_SystemWin32::performanceCounterToMillis(__int64 perf_ticks) const { /* Calculate the time passed since system initialization. */ - __int64 delta = perf_ticks * 1000; + __int64 delta = (perf_ticks - m_start) * 1000; uint64_t t = uint64_t(delta / m_freq); return t; } +uint64_t GHOST_SystemWin32::tickCountToMillis(__int64 ticks) const +{ + return ticks - m_lfstart; +} + uint64_t GHOST_SystemWin32::getMilliSeconds() const { /* Hardware does not support high resolution timers. We will use GetTickCount instead then. */ if (!m_hasPerformanceCounter) { - return ::GetTickCount64(); + return tickCountToMillis(::GetTickCount()); } /* Retrieve current count */ @@ -198,9 +204,10 @@ uint64_t GHOST_SystemWin32::getMilliSeconds() const } /** - * Returns the message time, compatible with the time value from #getMilliSeconds. - * This should be used instead of #getMilliSeconds when you need the time a message was delivered - * versus collected, so for all event creation that are in response to receiving a Windows message. + * Returns the number of milliseconds since the start of the Blender process to the time of the + * last message, using the high frequency timer if available. This should be used instead of + * getMilliSeconds when you need the time a message was delivered versus collected, so for all + * event creation that are in response to receiving a Windows message. */ static uint64_t getMessageTime(GHOST_SystemWin32 *system) { @@ -212,7 +219,7 @@ static uint64_t getMessageTime(GHOST_SystemWin32 *system) t_delta -= int64_t(UINT32_MAX) + 1; } - /* Return message time as 64-bit milliseconds with the delta applied. */ + /* Return message time as 64-bit milliseconds since Blender start. */ return system->getMilliSeconds() + t_delta; } @@ -568,8 +575,16 @@ GHOST_TSuccess GHOST_SystemWin32::init() SetProcessDPIAware(); initRawInput(); + m_lfstart = ::GetTickCount(); /* Determine whether this system has a high frequency performance counter. */ m_hasPerformanceCounter = ::QueryPerformanceFrequency((LARGE_INTEGER *)&m_freq) == TRUE; + if (m_hasPerformanceCounter) { + GHOST_PRINT("GHOST_SystemWin32::init: High Frequency Performance Timer available\n"); + ::QueryPerformanceCounter((LARGE_INTEGER *)&m_start); + } + else { + GHOST_PRINT("GHOST_SystemWin32::init: High Frequency Performance Timer not available\n"); + } if (success) { WNDCLASSW wc = {0}; diff --git a/intern/ghost/intern/GHOST_SystemWin32.hh b/intern/ghost/intern/GHOST_SystemWin32.hh index 5d6f7a752c3..e61709f1788 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.hh +++ b/intern/ghost/intern/GHOST_SystemWin32.hh @@ -60,6 +60,13 @@ class GHOST_SystemWin32 : public GHOST_System { */ uint64_t performanceCounterToMillis(__int64 perf_ticks) const; + /** + * This method converts system ticks into milliseconds since the start of the + * Blender process. + * \return The number of milliseconds since the start of the Blender process. + */ + uint64_t tickCountToMillis(__int64 ticks) const; + /** * Returns the system time. * Returns the number of milliseconds since the start of the Blender process. @@ -469,6 +476,10 @@ class GHOST_SystemWin32 : public GHOST_System { bool m_hasPerformanceCounter; /** High frequency timer variable. */ __int64 m_freq; + /** High frequency timer variable. */ + __int64 m_start; + /** Low frequency timer variable. */ + __int64 m_lfstart; /** AltGr on current keyboard layout. */ bool m_hasAltGr; /** Language identifier. */ diff --git a/release/datafiles/blender_icons_geom_update.py b/release/datafiles/blender_icons_geom_update.py index e6f6729bdcf..fb6a1d4cf84 100755 --- a/release/datafiles/blender_icons_geom_update.py +++ b/release/datafiles/blender_icons_geom_update.py @@ -76,7 +76,7 @@ for blend in icons_blend: output_dir = os.path.join(BASEDIR, "icons") files_old = set(names_and_time_from_path(output_dir)) cmd = ( - blender_bin, "--background", "--factory-startup", + blender_bin, "--background", "--factory-startup", "-noaudio", blend, "--python", os.path.join(BASEDIR, "blender_icons_geom.py"), "--", diff --git a/release/datafiles/blender_icons_update.py b/release/datafiles/blender_icons_update.py index 397aaa93749..87fef1c552f 100755 --- a/release/datafiles/blender_icons_update.py +++ b/release/datafiles/blender_icons_update.py @@ -71,7 +71,7 @@ datatoc_icon_split_py = os.path.join(BASEDIR, "..", "..", "source", "blender", " # create .dat pixmaps (which are stored in git) cmd = ( - blender_bin, "--background", "--factory-startup", + blender_bin, "--background", "--factory-startup", "-noaudio", "--python", datatoc_icon_split_py, "--", "--image=" + os.path.join(BASEDIR, "blender_icons16.png"), "--output=" + os.path.join(BASEDIR, "blender_icons16"), @@ -85,7 +85,7 @@ cmd = ( run(cmd, env=env) cmd = ( - blender_bin, "--background", "--factory-startup", + blender_bin, "--background", "--factory-startup", "-noaudio", "--python", datatoc_icon_split_py, "--", "--image=" + os.path.join(BASEDIR, "blender_icons32.png"), "--output=" + os.path.join(BASEDIR, "blender_icons32"), diff --git a/release/datafiles/userdef/userdef_default.c b/release/datafiles/userdef/userdef_default.c index 4f5af963461..bf6addd41bf 100644 --- a/release/datafiles/userdef/userdef_default.c +++ b/release/datafiles/userdef/userdef_default.c @@ -18,7 +18,7 @@ #include "GPU_platform.h" -#include "BLO_userdef_default.h" /* own include */ +#include "BLO_readfile.h" /* own include */ const UserDef U_default = { .versionfile = BLENDER_FILE_VERSION, diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 19e9ab723fc..994e62ea257 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -10,7 +10,7 @@ #include "DNA_userdef_types.h" -#include "BLO_userdef_default.h" +#include "BLO_readfile.h" /* clang-format off */ diff --git a/release/license/THIRD-PARTY-LICENSES.txt b/release/license/THIRD-PARTY-LICENSES.txt index 1ec9401b0fe..717d1b533f1 100644 --- a/release/license/THIRD-PARTY-LICENSES.txt +++ b/release/license/THIRD-PARTY-LICENSES.txt @@ -25,7 +25,7 @@ PERFORMANCE OF THIS SOFTWARE. ** Embree; version 4.1.0 -- https://github.com/embree/embree ** Intel(R) oneAPI DPC++ compiler; version 2022-12 -- https://github.com/intel/llvm#oneapi-dpc-compiler -** Intel® Open Path Guiding Library; version 0.6.0 -- http://www.openpgl.org/ +** Intel® Open Path Guiding Library; version 0.5.0 -- http://www.openpgl.org/ ** Mantaflow; version 0.13 -- http://mantaflow.com/ ** materialX; version 1.38.6 -- https://github.com/AcademySoftwareFoundation/MaterialX diff --git a/scripts/modules/bpy_extras/anim_utils.py b/scripts/modules/bpy_extras/anim_utils.py index 747c2516d23..15c45104551 100644 --- a/scripts/modules/bpy_extras/anim_utils.py +++ b/scripts/modules/bpy_extras/anim_utils.py @@ -233,7 +233,7 @@ def bake_action_iter( return {} # Be careful about which properties to actually consider for baking, as - # keeping references to complex Blender data-structures around for too long + # keeping references to complex Blender datastructures around for too long # can cause crashes. See #117988. clean_props = { key: rna_idprop_value_to_python(value) diff --git a/scripts/modules/rna_manual_reference.py b/scripts/modules/rna_manual_reference.py index ab4e8ef6f72..cf01b632ce0 100644 --- a/scripts/modules/rna_manual_reference.py +++ b/scripts/modules/rna_manual_reference.py @@ -262,6 +262,7 @@ url_manual_mapping = ( ("bpy.types.clothsettings.compression_stiffness_max*", "physics/cloth/settings/property_weights.html#bpy-types-clothsettings-compression-stiffness-max"), ("bpy.types.colormanagedsequencercolorspacesettings*", "render/color_management.html#bpy-types-colormanagedsequencercolorspacesettings"), ("bpy.types.colormanagedviewsettings.view_transform*", "render/color_management.html#bpy-types-colormanagedviewsettings-view-transform"), + ("bpy.types.compositornodetree.use_groupnode_buffer*", "compositing/sidebar.html#bpy-types-compositornodetree-use-groupnode-buffer"), ("bpy.types.cyclesmaterialsettings.volume_step_rate*", "render/cycles/material_settings.html#bpy-types-cyclesmaterialsettings-volume-step-rate"), ("bpy.types.cyclesobjectsettings.is_caustics_caster*", "render/cycles/object_settings/object_data.html#bpy-types-cyclesobjectsettings-is-caustics-caster"), ("bpy.types.cyclesrendersettings.adaptive_threshold*", "render/cycles/render_settings/sampling.html#bpy-types-cyclesrendersettings-adaptive-threshold"), @@ -1022,6 +1023,7 @@ url_manual_mapping = ( ("bpy.types.compositornodecolorcorrection*", "compositing/types/color/adjust/color_correction.html#bpy-types-compositornodecolorcorrection"), ("bpy.types.compositornodemoviedistortion*", "compositing/types/transform/movie_distortion.html#bpy-types-compositornodemoviedistortion"), ("bpy.types.compositornodetree.chunk_size*", "compositing/sidebar.html#bpy-types-compositornodetree-chunk-size"), + ("bpy.types.compositornodetree.use_opencl*", "compositing/sidebar.html#bpy-types-compositornodetree-use-opencl"), ("bpy.types.cyclesrendersettings.caustics*", "render/cycles/render_settings/light_paths.html#bpy-types-cyclesrendersettings-caustics"), ("bpy.types.cyclesrendersettings.denoiser*", "render/cycles/render_settings/sampling.html#bpy-types-cyclesrendersettings-denoiser"), ("bpy.types.editbone.use_inherit_rotation*", "animation/armatures/bones/properties/relations.html#bpy-types-editbone-use-inherit-rotation"), diff --git a/scripts/startup/bl_operators/file.py b/scripts/startup/bl_operators/file.py index 53944292ed2..db1348a5a28 100644 --- a/scripts/startup/bl_operators/file.py +++ b/scripts/startup/bl_operators/file.py @@ -105,6 +105,7 @@ class WM_OT_previews_batch_generate(Operator): bpy.app.binary_path, "--background", "--factory-startup", + "-noaudio", ] if self.use_trusted: cmd.append("--enable-autoexec") @@ -214,6 +215,7 @@ class WM_OT_previews_batch_clear(Operator): bpy.app.binary_path, "--background", "--factory-startup", + "-noaudio", ] if self.use_trusted: cmd.append("--enable-autoexec") diff --git a/scripts/startup/bl_ui/node_add_menu_geometry.py b/scripts/startup/bl_ui/node_add_menu_geometry.py index d6e57853269..af54f2d961d 100644 --- a/scripts/startup/bl_ui/node_add_menu_geometry.py +++ b/scripts/startup/bl_ui/node_add_menu_geometry.py @@ -533,7 +533,7 @@ class NODE_MT_category_GEO_UTILITIES(Menu): bl_idname = "NODE_MT_category_GEO_UTILITIES" bl_label = "Utilities" - def draw(self, context): + def draw(self, _context): layout = self.layout layout.menu("NODE_MT_geometry_node_GEO_COLOR") layout.menu("NODE_MT_category_GEO_TEXT") @@ -541,8 +541,6 @@ class NODE_MT_category_GEO_UTILITIES(Menu): layout.separator() layout.menu("NODE_MT_category_GEO_UTILITIES_FIELD") layout.menu("NODE_MT_category_GEO_UTILITIES_MATH") - if context.preferences.experimental.use_new_matrix_socket: - layout.menu("NODE_MT_category_utilities_matrix") layout.menu("NODE_MT_category_GEO_UTILITIES_ROTATION") layout.menu("NODE_MT_category_GEO_UTILITIES_DEPRECATED") layout.separator() @@ -594,22 +592,6 @@ class NODE_MT_category_GEO_UTILITIES_ROTATION(Menu): node_add_menu.draw_assets_for_catalog(layout, "Utilities/Rotation") -class NODE_MT_category_utilities_matrix(Menu): - bl_idname = "NODE_MT_category_utilities_matrix" - bl_label = "Matrix" - - def draw(self, _context): - layout = self.layout - node_add_menu.add_node_type(layout, "FunctionNodeCombineTransform") - node_add_menu.add_node_type(layout, "FunctionNodeInvertMatrix") - node_add_menu.add_node_type(layout, "FunctionNodeMatrixMultiply") - node_add_menu.add_node_type(layout, "FunctionNodeSeparateTransform") - node_add_menu.add_node_type(layout, "FunctionNodeTransformDirection") - node_add_menu.add_node_type(layout, "FunctionNodeTransformPoint") - node_add_menu.add_node_type(layout, "FunctionNodeTransposeMatrix") - node_add_menu.draw_assets_for_catalog(layout, "Utilities/Matrix") - - class NODE_MT_category_GEO_UTILITIES_MATH(Menu): bl_idname = "NODE_MT_category_GEO_UTILITIES_MATH" bl_label = "Math" @@ -797,7 +779,6 @@ classes = ( NODE_MT_category_GEO_UTILITIES_FIELD, NODE_MT_category_GEO_UTILITIES_MATH, NODE_MT_category_GEO_UTILITIES_ROTATION, - NODE_MT_category_utilities_matrix, NODE_MT_category_GEO_UTILITIES_DEPRECATED, NODE_MT_category_GEO_GROUP, ) diff --git a/scripts/startup/bl_ui/properties_animviz.py b/scripts/startup/bl_ui/properties_animviz.py index 2952c14ef06..8aa63915c85 100644 --- a/scripts/startup/bl_ui/properties_animviz.py +++ b/scripts/startup/bl_ui/properties_animviz.py @@ -43,7 +43,7 @@ class MotionPathButtonsPanel: col.prop(mps, "frame_step", text="Step") row = col.row() - row.prop(mps, "use_camera_space_bake", text="Bake to Active Camera") + row.prop(mps, "bake_in_camera_space", text="Bake to Active Camera") if bones: op_category = "pose" diff --git a/scripts/startup/bl_ui/properties_data_grease_pencil.py b/scripts/startup/bl_ui/properties_data_grease_pencil.py index 6ee46abecf6..0d2499e911c 100644 --- a/scripts/startup/bl_ui/properties_data_grease_pencil.py +++ b/scripts/startup/bl_ui/properties_data_grease_pencil.py @@ -15,17 +15,6 @@ class DataButtonsPanel: return hasattr(context, "grease_pencil") and context.grease_pencil -class LayerDataButtonsPanel: - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - bl_context = "data" - - @classmethod - def poll(cls, context): - grease_pencil = context.grease_pencil - return grease_pencil and grease_pencil.layers.active - - class DATA_PT_context_grease_pencil(DataButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} @@ -48,26 +37,8 @@ class GREASE_PENCIL_MT_grease_pencil_add_layer_extra(Menu): def draw(self, context): layout = self.layout - grease_pencil = context.object.data - space = context.space_data - if space.type == 'PROPERTIES': - layout.operator("grease_pencil.layer_group_add", text="Add Group") - - layout.separator() - layout.operator("grease_pencil.layer_duplicate", text="Duplicate", icon='DUPLICATE') - layout.operator("grease_pencil.layer_duplicate", text="Duplicate Empty Keyframes").empty_keyframes = True - - layout.separator() - layout.operator("grease_pencil.layer_reveal", icon='RESTRICT_VIEW_OFF', text="Show All") - layout.operator("grease_pencil.layer_hide", icon='RESTRICT_VIEW_ON', text="Hide Others").unselected = True - - layout.separator() - layout.operator("grease_pencil.layer_lock_all", icon='LOCKED', text="Lock All") - layout.operator("grease_pencil.layer_lock_all", icon='UNLOCKED', text="Unlock All").lock = False - - layout.separator() - layout.prop(grease_pencil, "use_autolock_layers", text="Autolock Inactive Layers") + layout.operator("grease_pencil.layer_group_add", text="Add Group") class DATA_PT_grease_pencil_layers(DataButtonsPanel, Panel): @@ -96,59 +67,13 @@ class DATA_PT_grease_pencil_layers(DataButtonsPanel, Panel): layout.use_property_decorate = True col = layout.column(align=True) - row = layout.row(align=True) - row.prop(layer, "opacity", text="Opacity", slider=True) - - -class DATA_PT_grease_pencil_layer_transform(LayerDataButtonsPanel, Panel): - bl_label = "Transform" - bl_parent_id = "DATA_PT_grease_pencil_layers" - bl_options = {'DEFAULT_CLOSED'} - - def draw(self, context): - layout = self.layout - layout.use_property_split = True - - grease_pencil = context.grease_pencil - layer = grease_pencil.layers.active - layout.active = not layer.lock - - row = layout.row(align=True) - row.prop(layer, "translation") - - row = layout.row(align=True) - row.prop(layer, "rotation") - - row = layout.row(align=True) - row.prop(layer, "scale") - - -class DATA_PT_grease_pencil_layer_relations(LayerDataButtonsPanel, Panel): - bl_label = "Relations" - bl_parent_id = "DATA_PT_grease_pencil_layers" - bl_options = {'DEFAULT_CLOSED'} - - def draw(self, context): - layout = self.layout - layout.use_property_split = True - - grease_pencil = context.grease_pencil - layer = grease_pencil.layers.active - layout.active = not layer.lock - - row = layout.row(align=True) - row.prop(layer, "parent", text="Parent") - - if layer.parent and layer.parent.type == 'ARMATURE': - row = layout.row(align=True) - row.prop_search(layer, "parent_bone", layer.parent.data, "bones", text="Bone") + col = layout.row(align=True) + col.prop(layer, "opacity", text="Opacity", slider=True) classes = ( DATA_PT_context_grease_pencil, DATA_PT_grease_pencil_layers, - DATA_PT_grease_pencil_layer_transform, - DATA_PT_grease_pencil_layer_relations, GREASE_PENCIL_MT_grease_pencil_add_layer_extra, ) diff --git a/scripts/startup/bl_ui/properties_data_modifier.py b/scripts/startup/bl_ui/properties_data_modifier.py index ca0ed5537f4..3f82086ccd3 100644 --- a/scripts/startup/bl_ui/properties_data_modifier.py +++ b/scripts/startup/bl_ui/properties_data_modifier.py @@ -71,7 +71,7 @@ class OBJECT_MT_modifier_add(ModifierAddMenu, Menu): if geometry_nodes_supported: self.operator_modifier_add(layout, 'NODES') layout.separator() - if ob_type in {'MESH', 'CURVE', 'FONT', 'SURFACE', 'LATTICE', 'GREASEPENCIL'}: + if ob_type in {'MESH', 'CURVE', 'FONT', 'SURFACE', 'LATTICE'}: layout.menu("OBJECT_MT_modifier_add_edit") if ob_type in {'MESH', 'CURVE', 'FONT', 'SURFACE', 'VOLUME', 'GREASEPENCIL'}: layout.menu("OBJECT_MT_modifier_add_generate") @@ -107,9 +107,6 @@ class OBJECT_MT_modifier_add_edit(ModifierAddMenu, Menu): self.operator_modifier_add(layout, 'VERTEX_WEIGHT_EDIT') self.operator_modifier_add(layout, 'VERTEX_WEIGHT_MIX') self.operator_modifier_add(layout, 'VERTEX_WEIGHT_PROXIMITY') - if ob_type == 'GREASEPENCIL': - self.operator_modifier_add(layout, 'GREASE_PENCIL_VERTEX_WEIGHT_PROXIMITY') - self.operator_modifier_add(layout, 'GREASE_PENCIL_VERTEX_WEIGHT_ANGLE') layout.template_modifier_asset_menu_items(catalog_path=self.bl_label) @@ -153,11 +150,7 @@ class OBJECT_MT_modifier_add_generate(ModifierAddMenu, Menu): if ob_type == 'MESH': self.operator_modifier_add(layout, 'WIREFRAME') if ob_type == 'GREASEPENCIL': - self.operator_modifier_add(layout, 'GREASE_PENCIL_ARRAY') - self.operator_modifier_add(layout, 'GREASE_PENCIL_DASH') - self.operator_modifier_add(layout, 'GREASE_PENCIL_LENGTH') self.operator_modifier_add(layout, 'GREASE_PENCIL_MIRROR') - self.operator_modifier_add(layout, 'GREASE_PENCIL_MULTIPLY') self.operator_modifier_add(layout, 'GREASE_PENCIL_SUBDIV') layout.template_modifier_asset_menu_items(catalog_path=self.bl_label) @@ -196,7 +189,6 @@ class OBJECT_MT_modifier_add_deform(ModifierAddMenu, Menu): if ob_type == 'VOLUME': self.operator_modifier_add(layout, 'VOLUME_DISPLACE') if ob_type == 'GREASEPENCIL': - self.operator_modifier_add(layout, 'GREASE_PENCIL_LATTICE') self.operator_modifier_add(layout, 'GREASE_PENCIL_NOISE') self.operator_modifier_add(layout, 'GREASE_PENCIL_OFFSET') self.operator_modifier_add(layout, 'GREASE_PENCIL_SMOOTH') diff --git a/scripts/startup/bl_ui/properties_render.py b/scripts/startup/bl_ui/properties_render.py index 7b15daff379..440da92e96d 100644 --- a/scripts/startup/bl_ui/properties_render.py +++ b/scripts/startup/bl_ui/properties_render.py @@ -210,24 +210,23 @@ class RENDER_PT_eevee_motion_blur(RenderButtonsPanel, Panel): def draw_header(self, context): scene = context.scene - props = scene.render + props = scene.eevee self.layout.prop(props, "use_motion_blur", text="") def draw(self, context): layout = self.layout layout.use_property_split = True scene = context.scene - props = scene.render - eevee_props = scene.eevee + props = scene.eevee layout.active = props.use_motion_blur col = layout.column() col.prop(props, "motion_blur_position", text="Position") col.prop(props, "motion_blur_shutter") col.separator() - col.prop(eevee_props, "motion_blur_depth_scale") - col.prop(eevee_props, "motion_blur_max") - col.prop(eevee_props, "motion_blur_steps", text="Steps") + col.prop(props, "motion_blur_depth_scale") + col.prop(props, "motion_blur_max") + col.prop(props, "motion_blur_steps", text="Steps") class RENDER_PT_eevee_next_motion_blur(RenderButtonsPanel, Panel): @@ -241,24 +240,22 @@ class RENDER_PT_eevee_next_motion_blur(RenderButtonsPanel, Panel): def draw_header(self, context): scene = context.scene - props = scene.render + props = scene.eevee self.layout.prop(props, "use_motion_blur", text="") def draw(self, context): layout = self.layout layout.use_property_split = True scene = context.scene - props = scene.render - eevee_props = scene.eevee + props = scene.eevee layout.active = props.use_motion_blur col = layout.column() col.prop(props, "motion_blur_position", text="Position") col.prop(props, "motion_blur_shutter") col.separator() - col.prop(eevee_props, "motion_blur_depth_scale") - col.prop(eevee_props, "motion_blur_max") - col.prop(eevee_props, "motion_blur_steps", text="Steps") + col.prop(props, "motion_blur_depth_scale") + col.prop(props, "motion_blur_steps", text="Steps") class RENDER_PT_eevee_next_motion_blur_curve(RenderButtonsPanel, Panel): diff --git a/scripts/startup/bl_ui/properties_view_layer.py b/scripts/startup/bl_ui/properties_view_layer.py index 0af22a8c35a..847965ab59c 100644 --- a/scripts/startup/bl_ui/properties_view_layer.py +++ b/scripts/startup/bl_ui/properties_view_layer.py @@ -100,7 +100,7 @@ class VIEWLAYER_PT_eevee_next_layer_passes_data(ViewLayerButtonsPanel, Panel): col.prop(view_layer, "use_pass_normal") col.prop(view_layer, "use_pass_position") sub = col.column() - sub.active = not scene.render.use_motion_blur + sub.active = not scene.eevee.use_motion_blur sub.prop(view_layer, "use_pass_vector") @@ -342,7 +342,7 @@ class VIEWLAYER_PT_filter(ViewLayerButtonsPanel, Panel): col = layout.column(heading="Use") sub = col.row() sub.prop(view_layer, "use_motion_blur", text="Motion Blur") - sub.active = scene.render.use_motion_blur + sub.active = scene.eevee.use_motion_blur class VIEWLAYER_PT_layer_custom_props(PropertyPanel, Panel): diff --git a/scripts/startup/bl_ui/space_graph.py b/scripts/startup/bl_ui/space_graph.py index fb4f3ffa309..7df05c233b2 100644 --- a/scripts/startup/bl_ui/space_graph.py +++ b/scripts/startup/bl_ui/space_graph.py @@ -159,7 +159,7 @@ class GRAPH_MT_view(Menu): layout.prop(st, "use_realtime_update") layout.prop(st, "show_sliders") layout.prop(st, "use_auto_merge_keyframes") - layout.prop(st, "use_auto_lock_translation_axis") + layout.prop(st, "autolock_translation_axis") layout.separator() if st.mode != 'DRIVERS': diff --git a/scripts/startup/bl_ui/space_node.py b/scripts/startup/bl_ui/space_node.py index a739c9b1c66..b69e5de6d5b 100644 --- a/scripts/startup/bl_ui/space_node.py +++ b/scripts/startup/bl_ui/space_node.py @@ -818,9 +818,12 @@ class NODE_PT_quality(bpy.types.Panel): col.active = not use_realtime col.prop(tree, "render_quality", text="Render") col.prop(tree, "edit_quality", text="Edit") + col.prop(tree, "chunk_size") col = layout.column() col.active = not use_realtime + col.prop(tree, "use_opencl") + col.prop(tree, "use_groupnode_buffer") col.prop(tree, "use_two_pass") col.prop(tree, "use_viewer_border") @@ -864,9 +867,6 @@ class NODE_PT_overlay(Panel): col.prop(overlay, "show_timing", text="Timings") col.prop(overlay, "show_named_attributes", text="Named Attributes") - if snode.tree_type == 'CompositorNodeTree': - col.prop(overlay, "show_timing", text="Timings") - class NODE_MT_node_tree_interface_context_menu(Menu): bl_label = "Node Tree Interface Specials" diff --git a/scripts/startup/bl_ui/space_topbar.py b/scripts/startup/bl_ui/space_topbar.py index 9b9ad81f9a9..d7ea640d3a8 100644 --- a/scripts/startup/bl_ui/space_topbar.py +++ b/scripts/startup/bl_ui/space_topbar.py @@ -240,6 +240,33 @@ class TOPBAR_MT_file_cleanup(Menu): layout.separator() props = layout.operator("outliner.orphans_purge", text="Unused Data-Blocks") + props.do_local_ids = True + props.do_linked_ids = True + props.do_recursive = False + props = layout.operator("outliner.orphans_purge", text="Recursive Unused Data-Blocks") + props.do_local_ids = True + props.do_linked_ids = True + props.do_recursive = True + + layout.separator() + props = layout.operator("outliner.orphans_purge", text="Unused Linked Data-Blocks") + props.do_local_ids = False + props.do_linked_ids = True + props.do_recursive = False + props = layout.operator("outliner.orphans_purge", text="Recursive Unused Linked Data-Blocks") + props.do_local_ids = False + props.do_linked_ids = True + props.do_recursive = True + + layout.separator() + props = layout.operator("outliner.orphans_purge", text="Unused Local Data-Blocks") + props.do_local_ids = True + props.do_linked_ids = False + props.do_recursive = False + props = layout.operator("outliner.orphans_purge", text="Recursive Unused Local Data-Blocks") + props.do_local_ids = True + props.do_linked_ids = False + props.do_recursive = True class TOPBAR_MT_file(Menu): diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index 95e2638fd9e..dfa42725cc6 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -2025,7 +2025,7 @@ class USERPREF_PT_extensions_repos(Panel): bl_region_type = 'HEADER' # Show wider than most panels so the URL & directory aren't overly clipped. - bl_ui_units_x = 16 + bl_ui_units_x = 24 # NOTE: ideally `if panel := layout.panel("extensions_repo_advanced", default_closed=True):` # would be used but it isn't supported here, use a kludge to achieve a similar UI. @@ -2082,6 +2082,8 @@ class USERPREF_PT_extensions_repos(Panel): if active_repo is None: return + layout.separator() + # NOTE: changing repositories from remote to local & vice versa could be supported but is obscure enough # that it can be hidden entirely. If there is a some justification to show this, it can be exposed. # For now it can be accessed from Python if someone is. @@ -2089,11 +2091,9 @@ class USERPREF_PT_extensions_repos(Panel): if active_repo.use_remote_path: row = layout.row() - split = row.split(factor=0.936) if active_repo.remote_path == "": - split.alert = True - split.prop(active_repo, "remote_path", text="URL") - split = row.split() + row.alert = True + row.prop(active_repo, "remote_path", text="URL") if layout_panel := self._panel_layout_kludge(layout, text="Advanced"): @@ -2669,9 +2669,8 @@ class USERPREF_PT_experimental_prototypes(ExperimentalPanel, Panel): ({"property": "use_sculpt_texture_paint"}, ("blender/blender/issues/96225", "#96225")), ({"property": "use_experimental_compositors"}, ("blender/blender/issues/88150", "#88150")), ({"property": "use_grease_pencil_version3"}, ("blender/blender/projects/6", "Grease Pencil 3.0")), - ({"property": "use_new_matrix_socket"}, ("blender/blender/issues/116067", "Matrix Socket")), ({"property": "enable_overlay_next"}, ("blender/blender/issues/102179", "#102179")), - ({"property": "use_extension_repos"}, ("/blender/blender/issues/117286", "#117286")), + ({"property": "use_extension_repos"}, ("/blender/blender/issues/106254", "#106254")), ), ) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index a2029153f92..3d7c2f57aeb 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -827,21 +827,13 @@ class VIEW3D_HT_header(Header): depress=(tool_settings.gpencil_selectmode_edit == 'STROKE'), ).mode = 'STROKE' - if object_mode == 'PAINT_GREASE_PENCIL': - row = layout.row(align=True) - row.prop(tool_settings, "use_gpencil_draw_additive", text="", icon='FREEZE') - - if object_mode in {'PAINT_GREASE_PENCIL', 'EDIT', 'WEIGHT_PAINT'}: row = layout.row(align=True) row.prop(tool_settings, "use_grease_pencil_multi_frame_editing", text="") - if object_mode in {'EDIT', 'WEIGHT_PAINT'}: - sub = row.row(align=True) - sub.enabled = tool_settings.use_grease_pencil_multi_frame_editing - sub.popover( - panel="VIEW3D_PT_grease_pencil_multi_frame", - text="Multiframe", - ) + if object_mode == 'PAINT_GREASE_PENCIL': + row = layout.row() + sub = row.row(align=True) + sub.prop(tool_settings, "use_gpencil_draw_additive", text="", icon='FREEZE') # Grease Pencil (legacy) if obj and obj.type == 'GPENCIL' and context.gpencil_data: @@ -1142,12 +1134,11 @@ class VIEW3D_MT_editor_menus(Menu): elif mode_string == 'VERTEX_GPENCIL': layout.menu("VIEW3D_MT_select_edit_gpencil") elif mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}: - if obj.type == 'MESH': - mesh = obj.data - if mesh.use_paint_mask: - layout.menu("VIEW3D_MT_select_paint_mask") - elif mesh.use_paint_mask_vertex and mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX'}: - layout.menu("VIEW3D_MT_select_paint_mask_vertex") + mesh = obj.data + if mesh.use_paint_mask: + layout.menu("VIEW3D_MT_select_paint_mask") + elif mesh.use_paint_mask_vertex and mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX'}: + layout.menu("VIEW3D_MT_select_paint_mask_vertex") elif mode_string not in {'SCULPT', 'SCULPT_CURVES', 'PAINT_GREASE_PENCIL'}: layout.menu("VIEW3D_MT_select_%s" % mode_string.lower()) @@ -3568,10 +3559,8 @@ class VIEW3D_MT_paint_weight(Menu): layout.menu("VIEW3D_MT_paint_weight_lock", text="Locks") - def draw(self, context): - obj = context.active_object - if obj.type == 'MESH': - self.draw_generic(self.layout, is_editmode=False) + def draw(self, _context): + self.draw_generic(self.layout, is_editmode=False) class VIEW3D_MT_sculpt(Menu): @@ -4704,6 +4693,7 @@ class VIEW3D_MT_edit_mesh_edges(Menu): layout.operator("mesh.set_sharpness_by_angle") + if with_freestyle: layout.separator() @@ -5840,22 +5830,28 @@ class VIEW3D_MT_edit_greasepencil(Menu): layout.separator() + layout.operator_menu_enum("grease_pencil.separate", "mode", text="Separate") + + layout.separator() + layout.menu("GREASE_PENCIL_MT_layer_active", text="Active Layer") layout.separator() - layout.operator("grease_pencil.duplicate_move", text="Duplicate") + layout.operator("grease_pencil.duplicate_move") layout.separator() layout.menu("VIEW3D_MT_edit_greasepencil_showhide") - layout.operator_menu_enum("grease_pencil.separate", "mode", text="Separate") - layout.operator("grease_pencil.clean_loose") layout.separator() layout.menu("VIEW3D_MT_edit_greasepencil_delete") + layout.separator() + + layout.operator("grease_pencil.clean_loose") + class VIEW3D_MT_edit_greasepencil_stroke(Menu): bl_label = "Stroke" @@ -5871,26 +5867,27 @@ class VIEW3D_MT_edit_greasepencil_stroke(Menu): layout.menu("GREASE_PENCIL_MT_move_to_layer") layout.menu("VIEW3D_MT_grease_pencil_assign_material") layout.operator("grease_pencil.set_active_material") - layout.operator_menu_enum("grease_pencil.reorder", text="Arrange", property="direction") layout.separator() layout.operator("grease_pencil.cyclical_set", text="Toggle Cyclic").type = 'TOGGLE' - layout.operator_menu_enum("grease_pencil.caps_set", text="Set Caps", property="type") layout.operator("grease_pencil.stroke_switch_direction") + layout.operator_menu_enum("grease_pencil.caps_set", text="Set Caps", property="type") layout.separator() layout.operator("grease_pencil.set_uniform_thickness") layout.operator("grease_pencil.set_uniform_opacity") + layout.operator_menu_enum("grease_pencil.reorder", text="Reorder", property="direction") + class VIEW3D_MT_edit_greasepencil_point(Menu): bl_label = "Point" def draw(self, _context): layout = self.layout - layout.operator("grease_pencil.stroke_smooth", text="Smooth") + layout.operator("grease_pencil.stroke_smooth", text="Smooth Points") class VIEW3D_MT_edit_curves(Menu): @@ -8014,25 +8011,6 @@ class VIEW3D_PT_gpencil_multi_frame(Panel): layout.template_curve_mapping(settings, "multiframe_falloff_curve", brush=True) -class VIEW3D_PT_grease_pencil_multi_frame(Panel): - bl_space_type = 'VIEW_3D' - bl_region_type = 'HEADER' - bl_label = "Multi Frame" - - def draw(self, context): - layout = self.layout - tool_settings = context.tool_settings - - settings = tool_settings.gpencil_sculpt - - col = layout.column(align=True) - col.prop(settings, "use_multiframe_falloff") - - # Falloff curve - if settings.use_multiframe_falloff: - layout.template_curve_mapping(settings, "multiframe_falloff_curve", brush=True) - - # Grease Pencil Object - Curve Editing tools class VIEW3D_PT_gpencil_curve_edit(Panel): bl_space_type = 'VIEW_3D' @@ -8254,11 +8232,7 @@ class VIEW3D_MT_greasepencil_edit_context_menu(Menu): col.separator() - col.menu("VIEW3D_MT_mirror", text="Mirror") - - col.separator() - - col.operator("grease_pencil.duplicate_move", text="Duplicate") + col.menu("VIEW3D_MT_mirror", text="Mirror Points") col.separator() @@ -8281,15 +8255,13 @@ class VIEW3D_MT_greasepencil_edit_context_menu(Menu): col.separator() # Deform Operators - col.operator("grease_pencil.stroke_smooth", text="Smooth") + col.operator("grease_pencil.stroke_smooth", text="Smooth Points") col.operator("transform.transform", text="Radius").mode = 'CURVE_SHRINKFATTEN' col.separator() - col.menu("GREASE_PENCIL_MT_move_to_layer") col.menu("VIEW3D_MT_grease_pencil_assign_material") col.operator("grease_pencil.set_active_material", text="Set as Active Material") - col.operator_menu_enum("grease_pencil.reorder", text="Arrange", property="direction") col.separator() @@ -8297,10 +8269,6 @@ class VIEW3D_MT_greasepencil_edit_context_menu(Menu): col.separator() - col.operator("grease_pencil.duplicate_move", text="Duplicate") - - col.separator() - col.operator("grease_pencil.separate", text="Separate").mode = 'SELECTED' @@ -9053,7 +9021,6 @@ classes = ( VIEW3D_PT_grease_pencil, VIEW3D_PT_annotation_onion, VIEW3D_PT_gpencil_multi_frame, - VIEW3D_PT_grease_pencil_multi_frame, VIEW3D_PT_gpencil_curve_edit, VIEW3D_PT_gpencil_sculpt_automasking, VIEW3D_PT_quad_view, diff --git a/scripts/templates_py/custom_nodes.py b/scripts/templates_py/custom_nodes.py index bf2886fd00f..f6fe0979ac1 100644 --- a/scripts/templates_py/custom_nodes.py +++ b/scripts/templates_py/custom_nodes.py @@ -99,7 +99,7 @@ class MyCustomNode(MyCustomTreeNode, Node): def init(self, context): self.inputs.new('CustomSocketType', "Hello") self.inputs.new('NodeSocketFloat', "World") - self.inputs.new('NodeSocketVector', "!", use_multi_input=True) + self.inputs.new('NodeSocketVector', "!") self.outputs.new('NodeSocketColor', "How") self.outputs.new('NodeSocketColor', "are") diff --git a/source/blender/animrig/intern/bone_collections.cc b/source/blender/animrig/intern/bone_collections.cc index 825be048b4c..26ecbffd303 100644 --- a/source/blender/animrig/intern/bone_collections.cc +++ b/source/blender/animrig/intern/bone_collections.cc @@ -6,17 +6,21 @@ * \ingroup animrig */ +#include "BLI_linklist.h" #include "BLI_listbase.h" #include "BLI_map.hh" +#include "BLI_math_color.h" #include "BLI_string.h" #include "BLI_string_utf8.h" #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_armature_types.h" +#include "BLI_math_bits.h" + #include "MEM_guardedalloc.h" #include "BKE_animsys.h" @@ -129,8 +133,6 @@ static void bonecoll_ensure_name_unique(bArmature *armature, BoneCollection *bco BoneCollection *bcoll; }; - /* Cannot capture armature & bcoll by reference in the lambda, as that would change its signature - * and no longer be compatible with BLI_uniquename_cb(). */ auto bonecoll_name_is_duplicate = [](void *arg, const char *name) -> bool { DupNameCheckData *data = static_cast(arg); for (BoneCollection *bcoll : data->arm->collections_span()) { @@ -436,7 +438,7 @@ void ANIM_armature_bonecoll_active_name_set(bArmature *armature, const char *nam ANIM_armature_bonecoll_active_set(armature, bcoll); } -void ANIM_armature_bonecoll_active_runtime_refresh(bArmature *armature) +void ANIM_armature_bonecoll_active_runtime_refresh(struct bArmature *armature) { const std::string_view active_name = armature->active_collection_name; if (active_name.empty()) { @@ -1058,8 +1060,8 @@ static bool bcoll_list_contains(const ListBase /*BoneCollectionRef*/ *collection return false; } -bool ANIM_armature_bonecoll_contains_active_bone(const bArmature *armature, - const BoneCollection *bcoll) +bool ANIM_armature_bonecoll_contains_active_bone(const struct bArmature *armature, + const struct BoneCollection *bcoll) { if (armature->edbo) { if (!armature->act_edbone) { diff --git a/source/blender/animrig/intern/bone_collections_test.cc b/source/blender/animrig/intern/bone_collections_test.cc index e44d5409d8a..80a79143601 100644 --- a/source/blender/animrig/intern/bone_collections_test.cc +++ b/source/blender/animrig/intern/bone_collections_test.cc @@ -4,7 +4,7 @@ #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" diff --git a/source/blender/animrig/intern/driver.cc b/source/blender/animrig/intern/driver.cc index 3d884e21ece..f317355e9c4 100644 --- a/source/blender/animrig/intern/driver.cc +++ b/source/blender/animrig/intern/driver.cc @@ -7,6 +7,7 @@ */ #include "ANIM_driver.hh" +#include "BKE_animsys.h" #include "BKE_fcurve_driver.h" #include "DNA_anim_types.h" #include "RNA_access.hh" diff --git a/source/blender/animrig/intern/keyframing.cc b/source/blender/animrig/intern/keyframing.cc index 4edcd334bb9..064eaf64c97 100644 --- a/source/blender/animrig/intern/keyframing.cc +++ b/source/blender/animrig/intern/keyframing.cc @@ -24,14 +24,14 @@ #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_nla.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DNA_scene_types.h" #include "BLI_dynstr.h" #include "BLI_math_base.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" @@ -41,6 +41,7 @@ #include "RNA_path.hh" #include "RNA_prototypes.h" +#include "WM_api.hh" #include "WM_types.hh" namespace blender::animrig { diff --git a/source/blender/animrig/intern/keyframing_auto.cc b/source/blender/animrig/intern/keyframing_auto.cc index 06c40e8a964..8c8a0a6ae6e 100644 --- a/source/blender/animrig/intern/keyframing_auto.cc +++ b/source/blender/animrig/intern/keyframing_auto.cc @@ -9,7 +9,9 @@ #include "BKE_animsys.h" #include "BKE_context.hh" #include "BKE_fcurve.h" -#include "BKE_scene.hh" +#include "BKE_layer.hh" +#include "BKE_object.hh" +#include "BKE_scene.h" #include "BLI_listbase.h" #include "BLI_string.h" @@ -20,8 +22,11 @@ #include "RNA_prototypes.h" #include "ED_keyframing.hh" +#include "ED_scene.hh" +#include "ED_transform.hh" #include "ANIM_keyframing.hh" +#include "ANIM_rna.hh" #include "WM_api.hh" #include "WM_types.hh" diff --git a/source/blender/animrig/intern/visualkey.cc b/source/blender/animrig/intern/visualkey.cc index ff7595f6994..deeb9c0abc2 100644 --- a/source/blender/animrig/intern/visualkey.cc +++ b/source/blender/animrig/intern/visualkey.cc @@ -12,10 +12,12 @@ #include "ANIM_rna.hh" #include "ANIM_visualkey.hh" +#include "BKE_animsys.h" #include "BKE_armature.hh" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" +#include "BLI_math_vector.h" #include "DNA_constraint_types.h" #include "DNA_object_types.h" @@ -23,6 +25,7 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "RNA_types.hh" namespace blender::animrig { @@ -211,11 +214,11 @@ Vector visualkey_get_values(PointerRNA *ptr, PropertyRNA *prop) Object *ob = static_cast(ptr->data); /* Loc code is specific... */ if (strstr(identifier, "location")) { - values.extend({ob->object_to_world().location(), 3}); + values.extend({ob->object_to_world[3], 3}); return values; } - copy_m4_m4(tmat, ob->object_to_world().ptr()); + copy_m4_m4(tmat, ob->object_to_world); rotmode = ob->rotmode; } else if (ptr->type == &RNA_PoseBone) { diff --git a/source/blender/asset_system/AS_asset_library.hh b/source/blender/asset_system/AS_asset_library.hh index a2a1b3bd871..3ff6d01c9d0 100644 --- a/source/blender/asset_system/AS_asset_library.hh +++ b/source/blender/asset_system/AS_asset_library.hh @@ -19,14 +19,11 @@ #include "BLI_string_ref.hh" #include "BLI_vector.hh" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" +struct IDRemapper; struct Main; -namespace blender::bke::id { -class IDRemapper; -} - namespace blender::asset_system { class AssetIdentifier; @@ -143,7 +140,7 @@ class AssetLibrary { * mapped to null (typically when an ID gets removed), the asset is removed, because we don't * support such empty/null assets. */ - void remap_ids_and_remove_invalid(const blender::bke::id::IDRemapper &mappings); + void remap_ids_and_remove_invalid(const IDRemapper &mappings); /** * Update `catalog_simple_name` by looking up the asset's catalog by its ID. @@ -233,6 +230,11 @@ std::string AS_asset_library_find_suitable_root_path_from_path(blender::StringRe */ std::string AS_asset_library_find_suitable_root_path_from_main(const Main *bmain); +blender::asset_system::AssetCatalogService *AS_asset_library_get_catalog_service( + const blender::asset_system::AssetLibrary *library); +blender::asset_system::AssetCatalogTree *AS_asset_library_get_catalog_tree( + const blender::asset_system::AssetLibrary *library); + /** * Force clearing of all asset library data. After calling this, new asset libraries can be loaded * just as usual using #AS_asset_library_load(), no init or other setup is needed. @@ -251,6 +253,10 @@ void AS_asset_libraries_exit(); blender::asset_system::AssetLibrary *AS_asset_library_load(const char *name, const char *library_dirpath); +/** Look up the asset's catalog and copy its simple name into #asset_data. */ +void AS_asset_library_refresh_catalog_simplename( + blender::asset_system::AssetLibrary *asset_library, AssetMetaData *asset_data); + /** Return whether any loaded AssetLibrary has unsaved changes to its catalogs. */ bool AS_asset_library_has_any_unsaved_catalogs(void); @@ -258,7 +264,7 @@ bool AS_asset_library_has_any_unsaved_catalogs(void); * An asset library can include local IDs (IDs in the current file). Their pointers need to be * remapped on change (or assets removed as IDs gets removed). */ -void AS_asset_library_remap_ids(const blender::bke::id::IDRemapper &mappings); +void AS_asset_library_remap_ids(const IDRemapper *mappings); /** * Attempt to resolve a full path to an asset based on the currently available (not necessary diff --git a/source/blender/asset_system/AS_asset_representation.hh b/source/blender/asset_system/AS_asset_representation.hh index e49fd742927..4ec03e31225 100644 --- a/source/blender/asset_system/AS_asset_representation.hh +++ b/source/blender/asset_system/AS_asset_representation.hh @@ -39,7 +39,7 @@ class AssetRepresentation { */ const bool is_local_id_ = false; /** Asset library that owns this asset representation. */ - const AssetLibrary &owner_asset_library_; + const AssetLibrary *owner_asset_library_; struct ExternalAsset { std::string name; @@ -67,12 +67,16 @@ class AssetRepresentation { AssetRepresentation(AssetIdentifier &&identifier, ID &id, const AssetLibrary &owner_asset_library); + AssetRepresentation(AssetRepresentation &&other); + /* Non-copyable type. */ + AssetRepresentation(const AssetRepresentation &other) = delete; ~AssetRepresentation(); - AssetRepresentation(const AssetRepresentation &) = delete; - AssetRepresentation(AssetRepresentation &&) = delete; - AssetRepresentation &operator=(AssetRepresentation &&) = delete; - AssetRepresentation &operator=(const AssetRepresentation &) = delete; + /* Non-move-assignable type. Move construction is fine, but treat the "identity" (e.g. local vs + * external asset) of an asset representation as immutable. */ + AssetRepresentation &operator=(AssetRepresentation &&other) = delete; + /* Non-copyable type. */ + AssetRepresentation &operator=(const AssetRepresentation &other) = delete; const AssetIdentifier &get_identifier() const; @@ -80,8 +84,10 @@ class AssetRepresentation { * Create a weak reference for this asset that can be written to files, but can break under a * number of conditions. * A weak reference can only be created if an asset representation is owned by an asset library. + * + * Must be freed using #BKE_asset_weak_reference_free(). */ - AssetWeakReference make_weak_reference() const; + AssetWeakReference *make_weak_reference() const; StringRefNull get_name() const; ID_Type get_id_type() const; diff --git a/source/blender/asset_system/intern/asset_catalog.cc b/source/blender/asset_system/intern/asset_catalog.cc index b7bd7d0f2f1..1ea12295414 100644 --- a/source/blender/asset_system/intern/asset_catalog.cc +++ b/source/blender/asset_system/intern/asset_catalog.cc @@ -174,7 +174,7 @@ AssetCatalogFilter AssetCatalogService::create_catalog_filter( Set known_catalog_ids; matching_catalog_ids.add(active_catalog_id); - const AssetCatalog *active_catalog = this->find_catalog(active_catalog_id); + const AssetCatalog *active_catalog = find_catalog(active_catalog_id); /* This cannot just iterate over tree items to get all the required data, because tree items only * represent single UUIDs. It could be used to get the main UUIDs of the children, though, and @@ -317,7 +317,7 @@ static std::string asset_definition_default_file_path_from_dir(StringRef asset_l void AssetCatalogService::load_from_disk() { - this->load_from_disk(asset_library_root_); + load_from_disk(asset_library_root_); } void AssetCatalogService::load_from_disk(const CatalogFilePath &file_or_directory_path) @@ -330,10 +330,10 @@ void AssetCatalogService::load_from_disk(const CatalogFilePath &file_or_director } if (S_ISREG(status.st_mode)) { - this->load_single_file(file_or_directory_path); + load_single_file(file_or_directory_path); } else if (S_ISDIR(status.st_mode)) { - this->load_directory_recursive(file_or_directory_path); + load_directory_recursive(file_or_directory_path); } else { /* TODO(@sybren): throw an appropriate exception. */ @@ -341,7 +341,7 @@ void AssetCatalogService::load_from_disk(const CatalogFilePath &file_or_director /* TODO: Should there be a sanitize step? E.g. to remove catalogs with identical paths? */ - this->rebuild_tree(); + rebuild_tree(); } void AssetCatalogService::add_from_existing(const AssetCatalogService &other_service) @@ -423,7 +423,7 @@ void AssetCatalogService::reload_catalogs() const CatalogID catalog_id = catalog->catalog_id; cats_in_file.add(catalog_id); - const bool should_skip = this->is_catalog_known_with_unsaved_changes(catalog_id); + const bool should_skip = is_catalog_known_with_unsaved_changes(catalog_id); if (should_skip) { /* Do not overwrite unsaved local changes. */ return false; @@ -447,7 +447,7 @@ void AssetCatalogService::purge_catalogs_not_listed(const Set &catalo if (catalogs_to_keep.contains(cat_id)) { continue; } - if (this->is_catalog_known_with_unsaved_changes(cat_id)) { + if (is_catalog_known_with_unsaved_changes(cat_id)) { continue; } /* This catalog is not on disk, but also not modified, so get rid of it. */ @@ -455,7 +455,7 @@ void AssetCatalogService::purge_catalogs_not_listed(const Set &catalo } for (CatalogID cat_id : cats_to_remove) { - this->delete_catalog_by_id_hard(cat_id); + delete_catalog_by_id_hard(cat_id); } } @@ -481,12 +481,12 @@ bool AssetCatalogService::write_to_disk(const CatalogFilePath &blend_file_path) { BLI_assert(!is_read_only_); - if (!this->write_to_disk_ex(blend_file_path)) { + if (!write_to_disk_ex(blend_file_path)) { return false; } - this->untag_has_unsaved_changes(); - this->rebuild_tree(); + untag_has_unsaved_changes(); + rebuild_tree(); return true; } @@ -496,7 +496,7 @@ bool AssetCatalogService::write_to_disk_ex(const CatalogFilePath &blend_file_pat /* - Already loaded a CDF from disk? -> Always write to that file. */ if (catalog_collection_->catalog_definition_file_) { - this->reload_catalogs(); + reload_catalogs(); return catalog_collection_->catalog_definition_file_->write_to_disk(); } @@ -507,10 +507,9 @@ bool AssetCatalogService::write_to_disk_ex(const CatalogFilePath &blend_file_pat return true; /* Writing nothing when there is nothing to write is still a success. */ } - const CatalogFilePath cdf_path_to_write = this->find_suitable_cdf_path_for_writing( - blend_file_path); - catalog_collection_->catalog_definition_file_ = this->construct_cdf_in_memory(cdf_path_to_write); - this->reload_catalogs(); + const CatalogFilePath cdf_path_to_write = find_suitable_cdf_path_for_writing(blend_file_path); + catalog_collection_->catalog_definition_file_ = construct_cdf_in_memory(cdf_path_to_write); + reload_catalogs(); return catalog_collection_->catalog_definition_file_->write_to_disk(); } @@ -529,7 +528,7 @@ void AssetCatalogService::prepare_to_merge_on_write() /* Mark all in-memory catalogs as "dirty", to force them to be kept around on * the next "load-merge-write" cycle. */ - this->tag_all_catalogs_as_unsaved_changes(); + tag_all_catalogs_as_unsaved_changes(); } CatalogFilePath AssetCatalogService::find_suitable_cdf_path_for_writing( @@ -591,8 +590,8 @@ std::unique_ptr AssetCatalogService::read_into_tree() void AssetCatalogService::rebuild_tree() { - this->create_missing_catalogs(); - this->catalog_tree_ = this->read_into_tree(); + create_missing_catalogs(); + this->catalog_tree_ = read_into_tree(); } void AssetCatalogService::create_missing_catalogs() @@ -626,7 +625,7 @@ void AssetCatalogService::create_missing_catalogs() } /* The parent doesn't exist, so create it and queue it up for checking its parent. */ - AssetCatalog *parent_catalog = this->create_catalog(parent_path); + AssetCatalog *parent_catalog = create_catalog(parent_path); parent_catalog->flags.has_unsaved_changes = true; paths_to_check.insert(parent_path); @@ -651,7 +650,7 @@ void AssetCatalogService::undo() redo_snapshots_.append(std::move(catalog_collection_)); catalog_collection_ = undo_snapshots_.pop_last(); - this->rebuild_tree(); + rebuild_tree(); AssetLibraryService::get()->rebuild_all_library(); } @@ -662,7 +661,7 @@ void AssetCatalogService::redo() undo_snapshots_.append(std::move(catalog_collection_)); catalog_collection_ = redo_snapshots_.pop_last(); - this->rebuild_tree(); + rebuild_tree(); AssetLibraryService::get()->rebuild_all_library(); } @@ -681,8 +680,8 @@ std::unique_ptr AssetCatalogCollection::deep_copy() cons auto copy = std::make_unique(); copy->has_unsaved_changes_ = this->has_unsaved_changes_; - copy->catalogs_ = this->copy_catalog_map(this->catalogs_); - copy->deleted_catalogs_ = this->copy_catalog_map(this->deleted_catalogs_); + copy->catalogs_ = copy_catalog_map(this->catalogs_); + copy->deleted_catalogs_ = copy_catalog_map(this->deleted_catalogs_); if (catalog_definition_file_) { copy->catalog_definition_file_ = catalog_definition_file_->copy_and_remap( diff --git a/source/blender/asset_system/intern/asset_catalog_path.cc b/source/blender/asset_system/intern/asset_catalog_path.cc index a9643a69c72..a8d7924db9e 100644 --- a/source/blender/asset_system/intern/asset_catalog_path.cc +++ b/source/blender/asset_system/intern/asset_catalog_path.cc @@ -30,37 +30,37 @@ AssetCatalogPath::AssetCatalogPath(AssetCatalogPath &&other_path) noexcept uint64_t AssetCatalogPath::hash() const { std::hash hasher{}; - return hasher(path_); + return hasher(this->path_); } uint64_t AssetCatalogPath::length() const { - return path_.length(); + return this->path_.length(); } const char *AssetCatalogPath::c_str() const { - return path_.c_str(); + return this->path_.c_str(); } const std::string &AssetCatalogPath::str() const { - return path_; + return this->path_; } StringRefNull AssetCatalogPath::name() const { - const size_t last_sep_index = path_.rfind(SEPARATOR); + const size_t last_sep_index = this->path_.rfind(SEPARATOR); if (last_sep_index == std::string::npos) { - return StringRefNull(path_); + return StringRefNull(this->path_); } - return StringRefNull(path_.c_str() + last_sep_index + 1); + return StringRefNull(this->path_.c_str() + last_sep_index + 1); } bool AssetCatalogPath::operator==(const AssetCatalogPath &other_path) const { - return path_ == other_path.path_; + return this->path_ == other_path.path_; } bool AssetCatalogPath::operator!=(const AssetCatalogPath &other_path) const @@ -70,7 +70,7 @@ bool AssetCatalogPath::operator!=(const AssetCatalogPath &other_path) const bool AssetCatalogPath::operator<(const AssetCatalogPath &other_path) const { - return path_ < other_path.path_; + return this->path_ < other_path.path_; } AssetCatalogPath AssetCatalogPath::operator/(const AssetCatalogPath &path_to_append) const @@ -84,13 +84,13 @@ AssetCatalogPath AssetCatalogPath::operator/(const AssetCatalogPath &path_to_app } std::stringstream new_path; - new_path << path_ << SEPARATOR << path_to_append.path_; + new_path << this->path_ << SEPARATOR << path_to_append.path_; return AssetCatalogPath(new_path.str()); } AssetCatalogPath::operator bool() const { - return !path_.empty(); + return !this->path_.empty(); } std::ostream &operator<<(std::ostream &stream, const AssetCatalogPath &path_to_append) @@ -142,7 +142,7 @@ bool AssetCatalogPath::is_contained_in(const AssetCatalogPath &other_path) const return true; } - if (path_ == other_path.path_) { + if (this->path_ == other_path.path_) { /* Weak is-in relation: equal paths contain each other. */ return true; } @@ -154,7 +154,7 @@ bool AssetCatalogPath::is_contained_in(const AssetCatalogPath &other_path) const } /* Create StringRef to be able to use .startswith(). */ - const StringRef this_path(path_); + const StringRef this_path(this->path_); const bool prefix_ok = this_path.startswith(other_path.path_); const char next_char = this_path[other_path.length()]; return prefix_ok && next_char == SEPARATOR; @@ -165,18 +165,18 @@ AssetCatalogPath AssetCatalogPath::parent() const if (!*this) { return AssetCatalogPath(""); } - std::string::size_type last_sep_index = path_.rfind(SEPARATOR); + std::string::size_type last_sep_index = this->path_.rfind(SEPARATOR); if (last_sep_index == std::string::npos) { return AssetCatalogPath(""); } - return AssetCatalogPath(path_.substr(0, last_sep_index)); + return AssetCatalogPath(this->path_.substr(0, last_sep_index)); } void AssetCatalogPath::iterate_components(ComponentIteratorFn callback) const { const char *next_slash_ptr; - for (const char *path_component = path_.data(); path_component && path_component[0]; + for (const char *path_component = this->path_.data(); path_component && path_component[0]; /* Jump to one after the next slash if there is any. */ path_component = next_slash_ptr ? next_slash_ptr + 1 : nullptr) { @@ -215,7 +215,7 @@ AssetCatalogPath AssetCatalogPath::rebase(const AssetCatalogPath &from_path, } /* When from_path = "test", we need to skip "test/" to get the rest of the path, hence the +1. */ - const StringRef suffix = StringRef(path_).substr(from_path.length() + 1); + const StringRef suffix = StringRef(this->path_).substr(from_path.length() + 1); const AssetCatalogPath path_suffix(suffix); return to_path / path_suffix; } diff --git a/source/blender/asset_system/intern/asset_library.cc b/source/blender/asset_system/intern/asset_library.cc index e2b4a5b8b28..f48c72562f7 100644 --- a/source/blender/asset_system/intern/asset_library.cc +++ b/source/blender/asset_system/intern/asset_library.cc @@ -13,7 +13,6 @@ #include "AS_asset_library.hh" #include "AS_asset_representation.hh" -#include "BKE_lib_remap.hh" #include "BKE_main.hh" #include "BKE_preferences.h" @@ -94,11 +93,36 @@ std::string AS_asset_library_find_suitable_root_path_from_main(const Main *bmain return AS_asset_library_find_suitable_root_path_from_path(bmain->filepath); } -void AS_asset_library_remap_ids(const bke::id::IDRemapper &mappings) +AssetCatalogService *AS_asset_library_get_catalog_service(const AssetLibrary *library) +{ + if (library == nullptr) { + return nullptr; + } + return library->catalog_service.get(); +} + +AssetCatalogTree *AS_asset_library_get_catalog_tree(const AssetLibrary *library) +{ + AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(library); + if (catalog_service == nullptr) { + return nullptr; + } + + return catalog_service->get_catalog_tree(); +} + +void AS_asset_library_refresh_catalog_simplename(AssetLibrary *asset_library, + AssetMetaData *asset_data) +{ + asset_library->refresh_catalog_simplename(asset_data); +} + +void AS_asset_library_remap_ids(const IDRemapper *mappings) { AssetLibraryService *service = AssetLibraryService::get(); service->foreach_loaded_asset_library( - [mappings](AssetLibrary &library) { library.remap_ids_and_remove_invalid(mappings); }, true); + [mappings](AssetLibrary &library) { library.remap_ids_and_remove_invalid(*mappings); }, + true); } void AS_asset_full_path_explode_from_weak_ref(const AssetWeakReference *asset_reference, @@ -215,7 +239,7 @@ bool AssetLibrary::remove_asset(AssetRepresentation &asset) return asset_storage_->remove_asset(asset); } -void AssetLibrary::remap_ids_and_remove_invalid(const bke::id::IDRemapper &mappings) +void AssetLibrary::remap_ids_and_remove_invalid(const IDRemapper &mappings) { asset_storage_->remap_ids_and_remove_invalid(mappings); } diff --git a/source/blender/asset_system/intern/asset_library_on_disk.cc b/source/blender/asset_system/intern/asset_library_on_disk.cc index aad2e195009..7028a517de9 100644 --- a/source/blender/asset_system/intern/asset_library_on_disk.cc +++ b/source/blender/asset_system/intern/asset_library_on_disk.cc @@ -15,7 +15,7 @@ OnDiskAssetLibrary::OnDiskAssetLibrary(eAssetLibraryType library_type, StringRef root_path) : AssetLibrary(library_type, name, root_path) { - this->on_blend_save_handler_register(); + on_blend_save_handler_register(); } void OnDiskAssetLibrary::refresh_catalogs() diff --git a/source/blender/asset_system/intern/asset_library_runtime.cc b/source/blender/asset_system/intern/asset_library_runtime.cc index 21dee8d5ff3..486786e79e7 100644 --- a/source/blender/asset_system/intern/asset_library_runtime.cc +++ b/source/blender/asset_system/intern/asset_library_runtime.cc @@ -12,7 +12,7 @@ namespace blender::asset_system { RuntimeAssetLibrary::RuntimeAssetLibrary() : AssetLibrary(ASSET_LIBRARY_LOCAL) { - this->on_blend_save_handler_register(); + on_blend_save_handler_register(); } } // namespace blender::asset_system diff --git a/source/blender/asset_system/intern/asset_library_service.cc b/source/blender/asset_system/intern/asset_library_service.cc index b14b587bf4c..675b1f2c160 100644 --- a/source/blender/asset_system/intern/asset_library_service.cc +++ b/source/blender/asset_system/intern/asset_library_service.cc @@ -6,7 +6,7 @@ * \ingroup asset_system */ -#include "BKE_blender.hh" +#include "BKE_blender.h" #include "BKE_preferences.h" #include "BLI_path_util.h" @@ -74,7 +74,7 @@ AssetLibrary *AssetLibraryService::get_asset_library( return nullptr; } - return this->get_asset_library_on_disk_builtin(type, root_path); + return get_asset_library_on_disk_builtin(type, root_path); } case ASSET_LIBRARY_LOCAL: { /* For the "Current File" library we get the asset library root path based on main. */ @@ -83,14 +83,14 @@ AssetLibrary *AssetLibraryService::get_asset_library( if (root_path.empty()) { /* File wasn't saved yet. */ - return this->get_asset_library_current_file(); + return get_asset_library_current_file(); } - return this->get_asset_library_on_disk_builtin(type, root_path); + return get_asset_library_on_disk_builtin(type, root_path); } case ASSET_LIBRARY_ALL: - return this->get_asset_library_all(bmain); + return get_asset_library_all(bmain); case ASSET_LIBRARY_CUSTOM: { - bUserAssetLibrary *custom_library = this->find_custom_asset_library_from_library_ref( + bUserAssetLibrary *custom_library = find_custom_asset_library_from_library_ref( library_reference); if (!custom_library) { return nullptr; @@ -101,8 +101,7 @@ AssetLibrary *AssetLibraryService::get_asset_library( return nullptr; } - AssetLibrary *library = this->get_asset_library_on_disk_custom(custom_library->name, - root_path); + AssetLibrary *library = get_asset_library_on_disk_custom(custom_library->name, root_path); library->import_method_ = eAssetImportMethod(custom_library->import_method); library->may_override_import_method_ = true; library->use_relative_path_ = (custom_library->flag & ASSET_LIBRARY_RELATIVE_PATH) != 0; @@ -157,7 +156,7 @@ AssetLibrary *AssetLibraryService::get_asset_library_on_disk(eAssetLibraryType l AssetLibrary *AssetLibraryService::get_asset_library_on_disk_custom(StringRef name, StringRefNull root_path) { - return this->get_asset_library_on_disk(ASSET_LIBRARY_CUSTOM, name, root_path); + return get_asset_library_on_disk(ASSET_LIBRARY_CUSTOM, name, root_path); } AssetLibrary *AssetLibraryService::get_asset_library_on_disk_builtin(eAssetLibraryType type, @@ -169,7 +168,7 @@ AssetLibrary *AssetLibraryService::get_asset_library_on_disk_builtin(eAssetLibra /* Builtin asset libraries don't need a name, the #eAssetLibraryType is enough to identify them * (and doesn't change, unlike the name). */ - return this->get_asset_library_on_disk(type, {}, root_path); + return get_asset_library_on_disk(type, {}, root_path); } AssetLibrary *AssetLibraryService::get_asset_library_current_file() @@ -204,7 +203,7 @@ AssetLibrary *AssetLibraryService::get_asset_library_all(const Main *bmain) } /* Ensure all asset libraries are loaded. */ - this->get_asset_library(bmain, library_ref); + get_asset_library(bmain, library_ref); } if (all_library_) { @@ -250,8 +249,8 @@ std::string AssetLibraryService::resolve_asset_weak_reference_to_library_path( switch (eAssetLibraryType(asset_reference.asset_library_type)) { case ASSET_LIBRARY_CUSTOM: { - bUserAssetLibrary *custom_lib = - this->find_custom_preferences_asset_library_from_asset_weak_ref(asset_reference); + bUserAssetLibrary *custom_lib = find_custom_preferences_asset_library_from_asset_weak_ref( + asset_reference); if (custom_lib) { library_dirpath = custom_lib->dirpath; break; @@ -259,7 +258,7 @@ std::string AssetLibraryService::resolve_asset_weak_reference_to_library_path( /* A bit of an odd-ball, the API supports loading custom libraries from arbitrary paths (used * by unit tests). So check all loaded on-disk libraries too. */ - AssetLibrary *loaded_custom_lib = this->find_loaded_on_disk_asset_library_from_name( + AssetLibrary *loaded_custom_lib = find_loaded_on_disk_asset_library_from_name( asset_reference.asset_library_identifier); if (!loaded_custom_lib) { return ""; @@ -369,7 +368,7 @@ std::optional AssetLibraryService:: switch (eAssetLibraryType(asset_reference.asset_library_type)) { case ASSET_LIBRARY_LOCAL: { - std::string path_in_file = this->normalize_asset_weak_reference_relative_asset_identifier( + std::string path_in_file = normalize_asset_weak_reference_relative_asset_identifier( asset_reference); const int64_t group_len = int64_t(path_in_file.find(SEP)); @@ -382,14 +381,14 @@ std::optional AssetLibraryService:: } case ASSET_LIBRARY_CUSTOM: case ASSET_LIBRARY_ESSENTIALS: { - std::string full_path = this->resolve_asset_weak_reference_to_full_path(asset_reference); + std::string full_path = resolve_asset_weak_reference_to_full_path(asset_reference); /* #full_path uses native slashes, so others don't need to be considered in the following. */ if (full_path.empty()) { return std::nullopt; } - int64_t blendfile_extension_pos = this->rfind_blendfile_extension(full_path); + int64_t blendfile_extension_pos = rfind_blendfile_extension(full_path); BLI_assert(blendfile_extension_pos != StringRef::not_found); size_t group_pos = full_path.find(SEP, blendfile_extension_pos); diff --git a/source/blender/asset_system/intern/asset_representation.cc b/source/blender/asset_system/intern/asset_representation.cc index df6782241f7..0528a1c4c31 100644 --- a/source/blender/asset_system/intern/asset_representation.cc +++ b/source/blender/asset_system/intern/asset_representation.cc @@ -10,6 +10,7 @@ #include "DNA_ID.h" #include "DNA_asset_types.h" +#include "DNA_userdef_types.h" #include "AS_asset_identifier.hh" #include "AS_asset_library.hh" @@ -24,7 +25,7 @@ AssetRepresentation::AssetRepresentation(AssetIdentifier &&identifier, const AssetLibrary &owner_asset_library) : identifier_(identifier), is_local_id_(false), - owner_asset_library_(owner_asset_library), + owner_asset_library_(&owner_asset_library), external_asset_() { external_asset_.name = name; @@ -37,7 +38,7 @@ AssetRepresentation::AssetRepresentation(AssetIdentifier &&identifier, const AssetLibrary &owner_asset_library) : identifier_(identifier), is_local_id_(true), - owner_asset_library_(owner_asset_library), + owner_asset_library_(&owner_asset_library), local_asset_id_(&id) { if (!id.asset_data) { @@ -45,6 +46,18 @@ AssetRepresentation::AssetRepresentation(AssetIdentifier &&identifier, } } +AssetRepresentation::AssetRepresentation(AssetRepresentation &&other) + : identifier_(std::move(other.identifier_)), is_local_id_(other.is_local_id_) +{ + if (is_local_id_) { + local_asset_id_ = other.local_asset_id_; + other.local_asset_id_ = nullptr; + } + else { + external_asset_ = std::move(other.external_asset_); + } +} + AssetRepresentation::~AssetRepresentation() { if (!is_local_id_) { @@ -57,9 +70,13 @@ const AssetIdentifier &AssetRepresentation::get_identifier() const return identifier_; } -AssetWeakReference AssetRepresentation::make_weak_reference() const +AssetWeakReference *AssetRepresentation::make_weak_reference() const { - return AssetWeakReference::make_reference(owner_asset_library_, identifier_); + if (!owner_asset_library_) { + return nullptr; + } + + return AssetWeakReference::make_reference(*owner_asset_library_, identifier_); } StringRefNull AssetRepresentation::get_name() const @@ -87,20 +104,26 @@ AssetMetaData &AssetRepresentation::get_metadata() const std::optional AssetRepresentation::get_import_method() const { - return owner_asset_library_.import_method_; + if (!owner_asset_library_) { + return {}; + } + return owner_asset_library_->import_method_; } bool AssetRepresentation::may_override_import_method() const { - if (!owner_asset_library_.import_method_) { + if (!owner_asset_library_ || !owner_asset_library_->import_method_) { return true; } - return owner_asset_library_.may_override_import_method_; + return owner_asset_library_->may_override_import_method_; } bool AssetRepresentation::get_use_relative_path() const { - return owner_asset_library_.use_relative_path_; + if (!owner_asset_library_) { + return false; + } + return owner_asset_library_->use_relative_path_; } ID *AssetRepresentation::local_id() const @@ -115,7 +138,7 @@ bool AssetRepresentation::is_local_id() const const AssetLibrary &AssetRepresentation::owner_asset_library() const { - return owner_asset_library_; + return *owner_asset_library_; } } // namespace blender::asset_system diff --git a/source/blender/asset_system/intern/asset_storage.cc b/source/blender/asset_system/intern/asset_storage.cc index 02db8550e4c..ecf33f72c95 100644 --- a/source/blender/asset_system/intern/asset_storage.cc +++ b/source/blender/asset_system/intern/asset_storage.cc @@ -43,7 +43,7 @@ bool AssetStorage::remove_asset(AssetRepresentation &asset) return external_assets_.remove_as(&asset); } -void AssetStorage::remap_ids_and_remove_invalid(const blender::bke::id::IDRemapper &mappings) +void AssetStorage::remap_ids_and_remove_invalid(const IDRemapper &mappings) { Set removed_assets{}; @@ -51,8 +51,8 @@ void AssetStorage::remap_ids_and_remove_invalid(const blender::bke::id::IDRemapp AssetRepresentation &asset = *asset_ptr; BLI_assert(asset.is_local_id()); - const IDRemapperApplyResult result = mappings.apply(&asset.local_asset_id_, - ID_REMAP_APPLY_DEFAULT); + const IDRemapperApplyResult result = BKE_id_remapper_apply( + &mappings, &asset.local_asset_id_, ID_REMAP_APPLY_DEFAULT); /* Entirely remove assets whose ID is unset. We don't want assets with a null ID pointer. */ if (result == ID_REMAP_RESULT_SOURCE_UNASSIGNED) { diff --git a/source/blender/asset_system/intern/asset_storage.hh b/source/blender/asset_system/intern/asset_storage.hh index 21553e762bb..91de06703fe 100644 --- a/source/blender/asset_system/intern/asset_storage.hh +++ b/source/blender/asset_system/intern/asset_storage.hh @@ -17,10 +17,7 @@ struct AssetMetaData; struct ID; - -namespace blender::bke::id { -class IDRemapper; -} +struct IDRemapper; namespace blender::asset_system { @@ -52,7 +49,7 @@ class AssetStorage { bool remove_asset(AssetRepresentation &asset); /** See #AssetLibrary::remap_ids_and_remove_nulled(). */ - void remap_ids_and_remove_invalid(const blender::bke::id::IDRemapper &mappings); + void remap_ids_and_remove_invalid(const IDRemapper &mappings); }; } // namespace blender::asset_system diff --git a/source/blender/asset_system/tests/asset_library_service_test.cc b/source/blender/asset_system/tests/asset_library_service_test.cc index 2cce1b4589a..c36f55c1b60 100644 --- a/source/blender/asset_system/tests/asset_library_service_test.cc +++ b/source/blender/asset_system/tests/asset_library_service_test.cc @@ -9,7 +9,7 @@ #include "BLI_string.h" #include "BKE_appdir.hh" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "BKE_main.hh" #include "DNA_asset_types.h" diff --git a/source/blender/asset_system/tests/asset_library_test.cc b/source/blender/asset_system/tests/asset_library_test.cc index d660b9ad20e..6afa11c058d 100644 --- a/source/blender/asset_system/tests/asset_library_test.cc +++ b/source/blender/asset_system/tests/asset_library_test.cc @@ -5,7 +5,7 @@ #include "AS_asset_catalog.hh" #include "AS_asset_library.hh" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "asset_library_service.hh" diff --git a/source/blender/asset_system/tests/asset_library_test_common.hh b/source/blender/asset_system/tests/asset_library_test_common.hh index ec6cd5d69d2..d7aecb8a1a0 100644 --- a/source/blender/asset_system/tests/asset_library_test_common.hh +++ b/source/blender/asset_system/tests/asset_library_test_common.hh @@ -13,7 +13,7 @@ #include "asset_library_service.hh" #include "BKE_appdir.hh" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "BLI_fileops.h" #include "BLI_path_util.h" diff --git a/source/blender/asset_system/tests/asset_representation_test.cc b/source/blender/asset_system/tests/asset_representation_test.cc index 30aaa5e1e01..93934dc4927 100644 --- a/source/blender/asset_system/tests/asset_representation_test.cc +++ b/source/blender/asset_system/tests/asset_representation_test.cc @@ -48,10 +48,12 @@ TEST_F(AssetRepresentationTest, weak_reference__current_file) AssetRepresentation &asset = add_dummy_asset(*library, "path/to/an/asset"); { - AssetWeakReference weak_ref = asset.make_weak_reference(); - EXPECT_EQ(weak_ref.asset_library_type, ASSET_LIBRARY_LOCAL); - EXPECT_EQ(weak_ref.asset_library_identifier, nullptr); - EXPECT_STREQ(weak_ref.relative_asset_identifier, "path/to/an/asset"); + AssetWeakReference *weak_ref = asset.make_weak_reference(); + EXPECT_EQ(weak_ref->asset_library_type, ASSET_LIBRARY_LOCAL); + EXPECT_EQ(weak_ref->asset_library_identifier, nullptr); + EXPECT_STREQ(weak_ref->relative_asset_identifier, "path/to/an/asset"); + + BKE_asset_weak_reference_free(&weak_ref); } } @@ -63,10 +65,11 @@ TEST_F(AssetRepresentationTest, weak_reference__custom_library) AssetRepresentation &asset = add_dummy_asset(*library, "path/to/an/asset"); { - AssetWeakReference weak_ref = asset.make_weak_reference(); - EXPECT_EQ(weak_ref.asset_library_type, ASSET_LIBRARY_CUSTOM); - EXPECT_STREQ(weak_ref.asset_library_identifier, "My custom lib"); - EXPECT_STREQ(weak_ref.relative_asset_identifier, "path/to/an/asset"); + AssetWeakReference *weak_ref = asset.make_weak_reference(); + EXPECT_EQ(weak_ref->asset_library_type, ASSET_LIBRARY_CUSTOM); + EXPECT_STREQ(weak_ref->asset_library_identifier, "My custom lib"); + EXPECT_STREQ(weak_ref->relative_asset_identifier, "path/to/an/asset"); + BKE_asset_weak_reference_free(&weak_ref); } } @@ -76,10 +79,11 @@ TEST_F(AssetRepresentationTest, weak_reference__resolve_to_full_path__current_fi AssetLibrary *library = get_builtin_library_from_type(ASSET_LIBRARY_LOCAL); AssetRepresentation &asset = add_dummy_asset(*library, "path/to/an/asset"); - AssetWeakReference weak_ref = asset.make_weak_reference(); + AssetWeakReference *weak_ref = asset.make_weak_reference(); - std::string resolved_path = service->resolve_asset_weak_reference_to_full_path(weak_ref); + std::string resolved_path = service->resolve_asset_weak_reference_to_full_path(*weak_ref); EXPECT_EQ(resolved_path, ""); + BKE_asset_weak_reference_free(&weak_ref); } /* #AssetLibraryService::resolve_asset_weak_reference_to_full_path(). */ @@ -90,13 +94,14 @@ TEST_F(AssetRepresentationTest, weak_reference__resolve_to_full_path__custom_lib asset_library_root_); AssetRepresentation &asset = add_dummy_asset(*library, "path/to/an/asset"); - AssetWeakReference weak_ref = asset.make_weak_reference(); + AssetWeakReference *weak_ref = asset.make_weak_reference(); std::string expected_path = utils::normalize_path(asset_library_root_ + "/" + "path/") + "to/an/asset"; - std::string resolved_path = service->resolve_asset_weak_reference_to_full_path(weak_ref); + std::string resolved_path = service->resolve_asset_weak_reference_to_full_path(*weak_ref); EXPECT_EQ(BLI_path_cmp(resolved_path.c_str(), expected_path.c_str()), 0); + BKE_asset_weak_reference_free(&weak_ref); } TEST_F(AssetRepresentationTest, @@ -107,13 +112,14 @@ TEST_F(AssetRepresentationTest, asset_library_root_); AssetRepresentation &asset = add_dummy_asset(*library, "path\\to\\an\\asset"); - AssetWeakReference weak_ref = asset.make_weak_reference(); + AssetWeakReference *weak_ref = asset.make_weak_reference(); std::string expected_path = utils::normalize_path(asset_library_root_ + "\\" + "path\\") + "to\\an\\asset"; - std::string resolved_path = service->resolve_asset_weak_reference_to_full_path(weak_ref); + std::string resolved_path = service->resolve_asset_weak_reference_to_full_path(*weak_ref); EXPECT_EQ(BLI_path_cmp(resolved_path.c_str(), expected_path.c_str()), 0); + BKE_asset_weak_reference_free(&weak_ref); } /* #AssetLibraryService::resolve_asset_weak_reference_to_exploded_path(). */ @@ -123,17 +129,18 @@ TEST_F(AssetRepresentationTest, weak_reference__resolve_to_exploded_path__curren AssetLibrary *library = get_builtin_library_from_type(ASSET_LIBRARY_LOCAL); AssetRepresentation &asset = add_dummy_asset(*library, "path/to/an/asset"); - AssetWeakReference weak_ref = asset.make_weak_reference(); + AssetWeakReference *weak_ref = asset.make_weak_reference(); std::string expected_full_path = utils::normalize_path("path/to/an/asset", 5); std::optional resolved_path = - service->resolve_asset_weak_reference_to_exploded_path(weak_ref); + service->resolve_asset_weak_reference_to_exploded_path(*weak_ref); EXPECT_EQ(*resolved_path->full_path, expected_full_path); EXPECT_EQ(resolved_path->dir_component, ""); EXPECT_EQ(resolved_path->group_component, "path"); /* ID names may contain slashes. */ EXPECT_EQ(resolved_path->name_component, "to/an/asset"); + BKE_asset_weak_reference_free(&weak_ref); } /* #AssetLibraryService::resolve_asset_weak_reference_to_exploded_path(). */ @@ -144,13 +151,13 @@ TEST_F(AssetRepresentationTest, weak_reference__resolve_to_exploded_path__custom asset_library_root_); AssetRepresentation &asset = add_dummy_asset(*library, "some.blend/Material/asset/name"); - AssetWeakReference weak_ref = asset.make_weak_reference(); + AssetWeakReference *weak_ref = asset.make_weak_reference(); std::string expected_full_path = utils::normalize_path(asset_library_root_ + "/some.blend/Material/") + "asset/name"; std::optional resolved_path = - service->resolve_asset_weak_reference_to_exploded_path(weak_ref); + service->resolve_asset_weak_reference_to_exploded_path(*weak_ref); EXPECT_EQ(BLI_path_cmp(resolved_path->full_path->c_str(), expected_full_path.c_str()), 0); EXPECT_EQ(BLI_path_cmp_normalized(std::string(resolved_path->dir_component).c_str(), @@ -159,6 +166,7 @@ TEST_F(AssetRepresentationTest, weak_reference__resolve_to_exploded_path__custom EXPECT_EQ(resolved_path->group_component, "Material"); /* ID names may contain slashes. */ EXPECT_EQ(resolved_path->name_component, "asset/name"); + BKE_asset_weak_reference_free(&weak_ref); } /* #AssetLibraryService::resolve_asset_weak_reference_to_exploded_path(). */ @@ -170,13 +178,13 @@ TEST_F(AssetRepresentationTest, asset_library_root_); AssetRepresentation &asset = add_dummy_asset(*library, "some.blend\\Material\\asset/name"); - AssetWeakReference weak_ref = asset.make_weak_reference(); + AssetWeakReference *weak_ref = asset.make_weak_reference(); std::string expected_full_path = utils::normalize_path(asset_library_root_ + "\\some.blend\\Material\\") + "asset/name"; std::optional resolved_path = - service->resolve_asset_weak_reference_to_exploded_path(weak_ref); + service->resolve_asset_weak_reference_to_exploded_path(*weak_ref); EXPECT_EQ(BLI_path_cmp(resolved_path->full_path->c_str(), expected_full_path.c_str()), 0); EXPECT_EQ(BLI_path_cmp_normalized(std::string(resolved_path->dir_component).c_str(), @@ -185,6 +193,7 @@ TEST_F(AssetRepresentationTest, EXPECT_EQ(resolved_path->group_component, "Material"); /* ID names may contain slashes. */ EXPECT_EQ(resolved_path->name_component, "asset/name"); + BKE_asset_weak_reference_free(&weak_ref); } } // namespace blender::asset_system::tests diff --git a/source/blender/blenfont/intern/blf_font.cc b/source/blender/blenfont/intern/blf_font.cc index d0f935d229f..dcd8b550df2 100644 --- a/source/blender/blenfont/intern/blf_font.cc +++ b/source/blender/blenfont/intern/blf_font.cc @@ -46,7 +46,7 @@ #include "blf_internal.hh" #include "blf_internal_types.hh" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" #ifdef WIN32 # define FT_New_Face FT_New_Face__win32_compat @@ -1376,6 +1376,7 @@ static void blf_font_fill(FontBLF *font) font->char_width = 1.0f; font->char_spacing = 0.0f; + BLI_listbase_clear(&font->cache); font->kerning_cache = nullptr; #if BLF_BLUR_ENABLE font->blur = 0; @@ -1735,7 +1736,7 @@ static FontBLF *blf_font_new_impl(const char *filepath, const size_t mem_size, void *ft_library) { - FontBLF *font = MEM_new(__func__); + FontBLF *font = (FontBLF *)MEM_callocN(sizeof(FontBLF), "blf_font_new"); font->mem_name = mem_name ? BLI_strdup(mem_name) : nullptr; font->filepath = filepath ? BLI_strdup(filepath) : nullptr; @@ -1755,6 +1756,8 @@ static FontBLF *blf_font_new_impl(const char *filepath, font->ft_lib = ft_library ? (FT_Library)ft_library : ft_lib; + BLI_mutex_init(&font->glyph_cache_mutex); + /* If we have static details about this font file, we don't have to load the Face yet. */ bool face_needed = true; @@ -1851,7 +1854,9 @@ void blf_font_free(FontBLF *font) MEM_freeN(font->mem_name); } - MEM_delete(font); + BLI_mutex_end(&font->glyph_cache_mutex); + + MEM_freeN(font); } /** \} */ diff --git a/source/blender/blenfont/intern/blf_glyph.cc b/source/blender/blenfont/intern/blf_glyph.cc index 3fa01e56ff4..3fdb2d99db3 100644 --- a/source/blender/blenfont/intern/blf_glyph.cc +++ b/source/blender/blenfont/intern/blf_glyph.cc @@ -38,10 +38,9 @@ #include "blf_internal_types.hh" #include "BLI_math_vector.h" +#include "BLI_strict_flags.h" #include "BLI_string_utf8.h" -#include "BLI_strict_flags.h" /* Keep last. */ - /** * Convert glyph coverage amounts to lightness values. Uses a LUT that perceptually improves * anti-aliasing and results in text that looks a bit fuller and slightly brighter. This should @@ -75,24 +74,28 @@ static float from_16dot16(FT_Fixed value) /** \name Glyph Cache * \{ */ -static GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, const float size) +static GlyphCacheBLF *blf_glyph_cache_find(const FontBLF *font, const float size) { - for (std::unique_ptr &gc : font->cache) { + GlyphCacheBLF *gc = (GlyphCacheBLF *)font->cache.first; + while (gc) { if (gc->size == size && (gc->bold == ((font->flags & BLF_BOLD) != 0)) && (gc->italic == ((font->flags & BLF_ITALIC) != 0)) && (gc->char_weight == font->char_weight) && (gc->char_slant == font->char_slant) && (gc->char_width == font->char_width) && (gc->char_spacing == font->char_spacing)) { - return gc.get(); + return gc; } + gc = gc->next; } return nullptr; } static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) { - std::unique_ptr gc = std::make_unique(GlyphCacheBLF{}); + GlyphCacheBLF *gc = (GlyphCacheBLF *)MEM_callocN(sizeof(GlyphCacheBLF), "blf_glyph_cache_new"); + gc->next = nullptr; + gc->prev = nullptr; gc->size = font->size; gc->bold = ((font->flags & BLF_BOLD) != 0); gc->italic = ((font->flags & BLF_ITALIC) != 0); @@ -121,14 +124,13 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) gc->fixed_width = 1; } - font->cache.append(std::move(gc)); - - return font->cache.last().get(); + BLI_addhead(&font->cache, gc); + return gc; } GlyphCacheBLF *blf_glyph_cache_acquire(FontBLF *font) { - font->glyph_cache_mutex.lock(); + BLI_mutex_lock(&font->glyph_cache_mutex); GlyphCacheBLF *gc = blf_glyph_cache_find(font, font->size); @@ -141,28 +143,34 @@ GlyphCacheBLF *blf_glyph_cache_acquire(FontBLF *font) void blf_glyph_cache_release(FontBLF *font) { - font->glyph_cache_mutex.unlock(); + BLI_mutex_unlock(&font->glyph_cache_mutex); } -GlyphCacheBLF::~GlyphCacheBLF() +static void blf_glyph_cache_free(GlyphCacheBLF *gc) { - for (uint i = 0; i < ARRAY_SIZE(this->bucket); i++) { - while (GlyphBLF *g = static_cast(BLI_pophead(&this->bucket[i]))) { + for (uint i = 0; i < ARRAY_SIZE(gc->bucket); i++) { + while (GlyphBLF *g = static_cast(BLI_pophead(&gc->bucket[i]))) { blf_glyph_free(g); } } - if (this->texture) { - GPU_texture_free(this->texture); + if (gc->texture) { + GPU_texture_free(gc->texture); } - if (this->bitmap_result) { - MEM_freeN(this->bitmap_result); + if (gc->bitmap_result) { + MEM_freeN(gc->bitmap_result); } + MEM_freeN(gc); } void blf_glyph_cache_clear(FontBLF *font) { - std::lock_guard lock{font->glyph_cache_mutex}; - font->cache.clear_and_shrink(); + BLI_mutex_lock(&font->glyph_cache_mutex); + + while (GlyphCacheBLF *gc = static_cast(BLI_pophead(&font->cache))) { + blf_glyph_cache_free(gc); + } + + BLI_mutex_unlock(&font->glyph_cache_mutex); } /** diff --git a/source/blender/blenfont/intern/blf_internal_types.hh b/source/blender/blenfont/intern/blf_internal_types.hh index 4443150ef75..b92e951894d 100644 --- a/source/blender/blenfont/intern/blf_internal_types.hh +++ b/source/blender/blenfont/intern/blf_internal_types.hh @@ -8,26 +8,16 @@ #pragma once -#include - -#include "BLI_vector.hh" - #include "GPU_texture.h" #include "GPU_vertex_buffer.h" -struct ColorManagedDisplay; -struct FontBLF; -struct GPUBatch; -struct GPUVertBuf; -struct GPUVertBufRaw; - #include FT_MULTIPLE_MASTERS_H /* Variable font support. */ /** Maximum variation axes per font. */ #define BLF_VARIATIONS_MAX 16 #define MAKE_DVAR_TAG(a, b, c, d) \ - ((uint32_t(a) << 24u) | (uint32_t(b) << 16u) | (uint32_t(c) << 8u) | (uint32_t(d))) + (((uint32_t)a << 24u) | ((uint32_t)b << 16u) | ((uint32_t)c << 8u) | ((uint32_t)d)) #define BLF_VARIATION_AXIS_WEIGHT MAKE_DVAR_TAG('w', 'g', 'h', 't') /* 'wght' weight axis. */ #define BLF_VARIATION_AXIS_SLANT MAKE_DVAR_TAG('s', 'l', 'n', 't') /* 'slnt' slant axis. */ @@ -54,27 +44,27 @@ typedef int32_t ft_pix; #define FT_PIX_ROUND(x) FT_PIX_FLOOR((x) + 32) #define FT_PIX_CEIL(x) ((x) + 63) -inline int ft_pix_to_int(ft_pix v) +BLI_INLINE int ft_pix_to_int(ft_pix v) { - return int(v >> 6); + return (int)(v >> 6); } -inline int ft_pix_to_int_floor(ft_pix v) +BLI_INLINE int ft_pix_to_int_floor(ft_pix v) { - return int(v >> 6); /* No need for explicit floor as the bits are removed when shifting. */ + return (int)(v >> 6); /* No need for explicit floor as the bits are removed when shifting. */ } -inline int ft_pix_to_int_ceil(ft_pix v) +BLI_INLINE int ft_pix_to_int_ceil(ft_pix v) { - return int(FT_PIX_CEIL(v) >> 6); + return (int)(FT_PIX_CEIL(v) >> 6); } -inline ft_pix ft_pix_from_int(int v) +BLI_INLINE ft_pix ft_pix_from_int(int v) { return v * 64; } -inline ft_pix ft_pix_from_float(float v) +BLI_INLINE ft_pix ft_pix_from_float(float v) { return lroundf(v * 64.0f); } @@ -89,12 +79,12 @@ inline ft_pix ft_pix_from_float(float v) /** A value in the kerning cache that indicates it is not yet set. */ #define KERNING_ENTRY_UNSET INT_MAX -struct BatchBLF { +typedef struct BatchBLF { /** Can only batch glyph from the same font. */ - FontBLF *font; - GPUBatch *batch; - GPUVertBuf *verts; - GPUVertBufRaw pos_step, col_step, offset_step, glyph_size_step, glyph_comp_len_step, + struct FontBLF *font; + struct GPUBatch *batch; + struct GPUVertBuf *verts; + struct GPUVertBufRaw pos_step, col_step, offset_step, glyph_size_step, glyph_comp_len_step, glyph_mode_step; unsigned int pos_loc, col_loc, offset_loc, glyph_size_loc, glyph_comp_len_loc, glyph_mode_loc; unsigned int glyph_len; @@ -103,20 +93,23 @@ struct BatchBLF { /* Previous call `modelmatrix`. */ float mat[4][4]; bool enabled, active, simple_shader; - GlyphCacheBLF *glyph_cache; -}; + struct GlyphCacheBLF *glyph_cache; +} BatchBLF; extern BatchBLF g_batch; -struct KerningCacheBLF { +typedef struct KerningCacheBLF { /** * Cache a ascii glyph pairs. Only store the x offset we are interested in, * instead of the full #FT_Vector since it's not used for drawing at the moment. */ int ascii_table[KERNING_CACHE_TABLE_SIZE][KERNING_CACHE_TABLE_SIZE]; -}; +} KerningCacheBLF; + +typedef struct GlyphCacheBLF { + struct GlyphCacheBLF *next; + struct GlyphCacheBLF *prev; -struct GlyphCacheBLF { /** Font size. */ float size; @@ -141,12 +134,11 @@ struct GlyphCacheBLF { int bitmap_len_landed; int bitmap_len_alloc; - ~GlyphCacheBLF(); -}; +} GlyphCacheBLF; -struct GlyphBLF { - GlyphBLF *next; - GlyphBLF *prev; +typedef struct GlyphBLF { + struct GlyphBLF *next; + struct GlyphBLF *prev; /** The character, as UTF-32. */ unsigned int c; @@ -191,10 +183,10 @@ struct GlyphBLF { */ int pos[2]; - GlyphCacheBLF *glyph_cache; -}; + struct GlyphCacheBLF *glyph_cache; +} GlyphBLF; -struct FontBufInfoBLF { +typedef struct FontBufInfoBLF { /** For draw to buffer, always set this to NULL after finish! */ float *fbuf; @@ -208,16 +200,17 @@ struct FontBufInfoBLF { int ch; /** Display device used for color management. */ - ColorManagedDisplay *display; + struct ColorManagedDisplay *display; /** The color, the alphas is get from the glyph! (color is sRGB space). */ float col_init[4]; /** Cached conversion from 'col_init'. */ unsigned char col_char[4]; float col_float[4]; -}; -struct FontMetrics { +} FontBufInfoBLF; + +typedef struct FontMetrics { /** Indicate that these values have been properly loaded. */ bool valid; /** This font's default weight, 100-900, 400 is normal. */ @@ -281,9 +274,9 @@ struct FontMetrics { short superscript_xoffset; /** Positive (!) number of font units below baseline for subscript characters. */ short superscript_yoffset; -}; +} FontMetrics; -struct FontBLF { +typedef struct FontBLF { /** Full path to font file or NULL if from memory. */ char *filepath; @@ -364,7 +357,7 @@ struct FontBLF { * List of glyph caches (#GlyphCacheBLF) for this font for size, DPI, bold, italic. * Use blf_glyph_cache_acquire(font) and blf_glyph_cache_release(font) to access cache! */ - blender::Vector> cache; + ListBase cache; /** Cache of unscaled kerning values. Will be NULL if font does not have kerning. */ KerningCacheBLF *kerning_cache; @@ -388,5 +381,5 @@ struct FontBLF { FontBufInfoBLF buf_info; /** Mutex lock for glyph cache. */ - std::mutex glyph_cache_mutex; -}; + ThreadMutex glyph_cache_mutex; +} FontBLF; diff --git a/source/blender/blenfont/intern/blf_thumbs.cc b/source/blender/blenfont/intern/blf_thumbs.cc index 69662fdf11f..3733c0df12f 100644 --- a/source/blender/blenfont/intern/blf_thumbs.cc +++ b/source/blender/blenfont/intern/blf_thumbs.cc @@ -33,7 +33,7 @@ #include "BLF_api.hh" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* Maximum length of text sample in char32_t, including nullptr terminator. */ #define BLF_SAMPLE_LEN 5 diff --git a/source/blender/blenkernel/BKE_DerivedMesh.hh b/source/blender/blenkernel/BKE_DerivedMesh.hh index ff63a9dd465..139bf33b7be 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.hh +++ b/source/blender/blenkernel/BKE_DerivedMesh.hh @@ -58,6 +58,7 @@ struct CCGElem; struct CCGKey; struct CustomData_MeshMasks; struct Depsgraph; +struct vec2i; struct MFace; struct Mesh; struct ModifierData; @@ -96,7 +97,7 @@ struct DerivedMesh { * \warning The real return type is `float(*)[3]`. */ float *(*getVertArray)(DerivedMesh *dm); - blender::int2 *(*getEdgeArray)(DerivedMesh *dm); + vec2i *(*getEdgeArray)(DerivedMesh *dm); int *(*getCornerVertArray)(DerivedMesh *dm); int *(*getCornerEdgeArray)(DerivedMesh *dm); int *(*getPolyArray)(DerivedMesh *dm); @@ -105,7 +106,7 @@ struct DerivedMesh { * *{vert/edge/face}_r (must point to a buffer large enough) */ void (*copyVertArray)(DerivedMesh *dm, float (*r_positions)[3]); - void (*copyEdgeArray)(DerivedMesh *dm, blender::int2 *r_edge); + void (*copyEdgeArray)(DerivedMesh *dm, vec2i *r_edge); void (*copyCornerVertArray)(DerivedMesh *dm, int *r_corner_verts); void (*copyCornerEdgeArray)(DerivedMesh *dm, int *r_corner_edges); void (*copyPolyArray)(DerivedMesh *dm, int *r_face_offsets); @@ -125,6 +126,7 @@ struct DerivedMesh { CCGElem **(*getGridData)(DerivedMesh *dm); int *(*getGridOffset)(DerivedMesh *dm); void (*getGridKey)(DerivedMesh *dm, CCGKey *key); + unsigned int **(*getGridHidden)(DerivedMesh *dm); /* Direct Access Operations * - Can be undefined diff --git a/source/blender/blenkernel/BKE_asset.hh b/source/blender/blenkernel/BKE_asset.hh index 31b73e3a113..110c0af7469 100644 --- a/source/blender/blenkernel/BKE_asset.hh +++ b/source/blender/blenkernel/BKE_asset.hh @@ -76,6 +76,8 @@ PreviewImage *BKE_asset_metadata_preview_get_from_id(const AssetMetaData *asset_ void BKE_asset_metadata_write(BlendWriter *writer, AssetMetaData *asset_data); void BKE_asset_metadata_read(BlendDataReader *reader, AssetMetaData *asset_data); +/** Frees the weak reference and its data, and nulls the given pointer. */ +void BKE_asset_weak_reference_free(AssetWeakReference **weak_ref); AssetWeakReference *BKE_asset_weak_reference_copy(AssetWeakReference *weak_ref); void BKE_asset_weak_reference_write(BlendWriter *writer, const AssetWeakReference *weak_ref); void BKE_asset_weak_reference_read(BlendDataReader *reader, AssetWeakReference *weak_ref); diff --git a/source/blender/blenkernel/BKE_attribute_math.hh b/source/blender/blenkernel/BKE_attribute_math.hh index 1838ac5171a..3395c6e6d31 100644 --- a/source/blender/blenkernel/BKE_attribute_math.hh +++ b/source/blender/blenkernel/BKE_attribute_math.hh @@ -35,8 +35,7 @@ inline void convert_to_static_type(const CPPType &cpp_type, const Func &func) int8_t, ColorGeometry4f, ColorGeometry4b, - math::Quaternion, - float4x4>([&](auto type_tag) { + math::Quaternion>([&](auto type_tag) { using T = typename decltype(type_tag)::type; if constexpr (std::is_same_v) { /* It's expected that the given cpp type is one of the supported ones. */ @@ -518,26 +517,6 @@ class ColorGeometry4bMixer { void finalize(const IndexMask &mask); }; -class float4x4Mixer { - private: - MutableSpan buffer_; - Array total_weights_; - Array location_buffer_; - Array expmap_buffer_; - Array scale_buffer_; - - public: - float4x4Mixer(MutableSpan buffer); - /** - * \param mask: Only initialize these indices. Other indices in the buffer will be invalid. - */ - float4x4Mixer(MutableSpan buffer, const IndexMask &mask); - void set(int64_t index, const float4x4 &value, float weight = 1.0f); - void mix_in(int64_t index, const float4x4 &value, float weight = 1.0f); - void finalize(); - void finalize(const IndexMask &mask); -}; - template struct DefaultMixerStruct { /* Use void by default. This can be checked for in `if constexpr` statements. */ using type = void; @@ -559,9 +538,6 @@ template<> struct DefaultMixerStruct { template<> struct DefaultMixerStruct { using type = ColorGeometry4bMixer; }; -template<> struct DefaultMixerStruct { - using type = float4x4Mixer; -}; template<> struct DefaultMixerStruct { static double int_to_double(const int &value) { diff --git a/source/blender/blenkernel/BKE_blender.hh b/source/blender/blenkernel/BKE_blender.h similarity index 61% rename from source/blender/blenkernel/BKE_blender.hh rename to source/blender/blenkernel/BKE_blender.h index e5f6dd11c14..2ac27710922 100644 --- a/source/blender/blenkernel/BKE_blender.hh +++ b/source/blender/blenkernel/BKE_blender.h @@ -8,6 +8,10 @@ * \brief Blender util stuff */ +#ifdef __cplusplus +extern "C" { +#endif + #include "BLI_compiler_attrs.h" struct Main; @@ -22,35 +26,40 @@ void BKE_blender_globals_init(void); void BKE_blender_globals_clear(void); /** Replace current global Main by the given one, freeing existing one. */ -void BKE_blender_globals_main_replace(Main *bmain); +void BKE_blender_globals_main_replace(struct Main *bmain); /** * Replace current global Main by the given one, returning the old one. * * \warning Advanced, risky workaround addressing the issue that current RNA is not able to process * correctly non-G_MAIN data, use with (a lot of) care. */ -Main *BKE_blender_globals_main_swap(Main *new_gmain); +struct Main *BKE_blender_globals_main_swap(struct Main *new_gmain); -void BKE_blender_userdef_data_swap(UserDef *userdef_a, UserDef *userdef_b); -void BKE_blender_userdef_data_set(UserDef *userdef); -void BKE_blender_userdef_data_set_and_free(UserDef *userdef); +void BKE_blender_userdef_data_swap(struct UserDef *userdef_a, struct UserDef *userdef_b); +void BKE_blender_userdef_data_set(struct UserDef *userdef); +void BKE_blender_userdef_data_set_and_free(struct UserDef *userdef); /** * This function defines which settings a template will override for the user preferences. * * \note the order of `userdef_a` & `userdef_b` isn't important as values are simply swapped. */ -void BKE_blender_userdef_app_template_data_swap(UserDef *userdef_a, UserDef *userdef_b); -void BKE_blender_userdef_app_template_data_set(UserDef *userdef); -void BKE_blender_userdef_app_template_data_set_and_free(UserDef *userdef); +void BKE_blender_userdef_app_template_data_swap(struct UserDef *userdef_a, + struct UserDef *userdef_b); +void BKE_blender_userdef_app_template_data_set(struct UserDef *userdef); +void BKE_blender_userdef_app_template_data_set_and_free(struct UserDef *userdef); /** * When loading a new userdef from file, * or when exiting Blender. */ -void BKE_blender_userdef_data_free(UserDef *userdef, bool clear_fonts); +void BKE_blender_userdef_data_free(struct UserDef *userdef, bool clear_fonts); /* Blenders' own atexit (avoids leaking) */ void BKE_blender_atexit_register(void (*func)(void *user_data), void *user_data); void BKE_blender_atexit_unregister(void (*func)(void *user_data), const void *user_data); void BKE_blender_atexit(void); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index f760a0febb9..b1dcbe3e730 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -21,15 +21,15 @@ extern "C" { */ /** Blender major and minor version. */ -#define BLENDER_VERSION 402 +#define BLENDER_VERSION 401 /** Blender patch version for bug-fix releases. */ #define BLENDER_VERSION_PATCH 0 /** Blender release cycle stage: alpha/beta/rc/release. */ -#define BLENDER_VERSION_CYCLE alpha +#define BLENDER_VERSION_CYCLE beta /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 3 +#define BLENDER_FILE_SUBVERSION 21 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and cancel loading the file, showing a warning to diff --git a/source/blender/blenkernel/BKE_blendfile_link_append.hh b/source/blender/blenkernel/BKE_blendfile_link_append.hh index be00e60dee6..23821db2556 100644 --- a/source/blender/blenkernel/BKE_blendfile_link_append.hh +++ b/source/blender/blenkernel/BKE_blendfile_link_append.hh @@ -29,7 +29,7 @@ void BKE_blendfile_link_append_context_free(BlendfileLinkAppendContext *lapp_con * * \param flag: A combination of: * - #eFileSel_Params_Flag from `DNA_space_types.h` & - * - #eBLOLibLinkFlags * from `BLO_readfile.hh`. + * - #eBLOLibLinkFlags * from `BLO_readfile.h`. * \param do_set: Set the given \a flag if true, clear it otherwise. */ void BKE_blendfile_link_append_context_flag_set(BlendfileLinkAppendContext *lapp_context, diff --git a/source/blender/blenkernel/BKE_bpath.hh b/source/blender/blenkernel/BKE_bpath.h similarity index 81% rename from source/blender/blenkernel/BKE_bpath.hh rename to source/blender/blenkernel/BKE_bpath.h index 26f4d1b3fba..d7275594449 100644 --- a/source/blender/blenkernel/BKE_bpath.hh +++ b/source/blender/blenkernel/BKE_bpath.h @@ -16,6 +16,10 @@ #include "BLI_utildefines.h" +#ifdef __cplusplus +extern "C" { +#endif + struct ID; struct Main; struct ReportList; @@ -23,7 +27,7 @@ struct ReportList; /** \name Core `foreach_path` API. * \{ */ -enum eBPathForeachFlag { +typedef enum eBPathForeachFlag { /* Flags controlling the behavior of the generic BPath API. */ /** * Ensures the `absolute_base_path` member of #BPathForeachPathData is initialized properly with @@ -58,7 +62,7 @@ enum eBPathForeachFlag { * \note Only used by Image #IDType currently. */ BKE_BPATH_FOREACH_PATH_RELOAD_EDITED = (1 << 9), -}; +} eBPathForeachFlag; ENUM_OPERATORS(eBPathForeachFlag, BKE_BPATH_FOREACH_PATH_RELOAD_EDITED) struct BPathForeachPathData; @@ -75,14 +79,14 @@ struct BPathForeachPathData; * \return `true` if the path has been changed, and in that case, * result must be written to `path_dst`. */ -using BPathForeachPathFunctionCallback = bool (*)(BPathForeachPathData *bpath_data, - char *path_dst, - size_t path_dst_maxncpy, - const char *path_src); +typedef bool (*BPathForeachPathFunctionCallback)(struct BPathForeachPathData *bpath_data, + char *path_dst, + size_t path_dst_maxncpy, + const char *path_src); /** Storage for common data needed across the BPath 'foreach_path' code. */ -struct BPathForeachPathData { - Main *bmain; +typedef struct BPathForeachPathData { + struct Main *bmain; BPathForeachPathFunctionCallback callback_function; eBPathForeachFlag flag; @@ -96,16 +100,16 @@ struct BPathForeachPathData { const char *absolute_base_path; /** ID owning the path being processed. */ - ID *owner_id; + struct ID *owner_id; /** * IDTypeInfo callbacks are responsible to set this boolean if they modified one or more paths. */ bool is_path_modified; -}; +} BPathForeachPathData; /** Run `bpath_data.callback_function` on all paths contained in `id`. */ -void BKE_bpath_foreach_path_id(BPathForeachPathData *bpath_data, ID *id); +void BKE_bpath_foreach_path_id(BPathForeachPathData *bpath_data, struct ID *id); /** Run `bpath_data.callback_function` on all paths of all IDs in `bmain`. */ void BKE_bpath_foreach_path_main(BPathForeachPathData *bpath_data); @@ -125,7 +129,7 @@ void BKE_bpath_foreach_path_main(BPathForeachPathData *bpath_data); * * \return true is \a path was modified, false otherwise. */ -bool BKE_bpath_foreach_path_fixed_process(BPathForeachPathData *bpath_data, +bool BKE_bpath_foreach_path_fixed_process(struct BPathForeachPathData *bpath_data, char *path, size_t path_maxncpy); @@ -138,7 +142,7 @@ bool BKE_bpath_foreach_path_fixed_process(BPathForeachPathData *bpath_data, * * \return true is \a path_dir and/or \a path_file were modified, false otherwise. */ -bool BKE_bpath_foreach_path_dirfile_fixed_process(BPathForeachPathData *bpath_data, +bool BKE_bpath_foreach_path_dirfile_fixed_process(struct BPathForeachPathData *bpath_data, char *path_dir, size_t path_dir_maxncpy, char *path_file, @@ -153,7 +157,8 @@ bool BKE_bpath_foreach_path_dirfile_fixed_process(BPathForeachPathData *bpath_da * * \return true is \a path was modified and re-allocated, false otherwise. */ -bool BKE_bpath_foreach_path_allocated_process(BPathForeachPathData *bpath_data, char **path); +bool BKE_bpath_foreach_path_allocated_process(struct BPathForeachPathData *bpath_data, + char **path); /** \} */ @@ -161,7 +166,7 @@ bool BKE_bpath_foreach_path_allocated_process(BPathForeachPathData *bpath_data, * \{ */ /** Check for missing files. */ -void BKE_bpath_missing_files_check(Main *bmain, ReportList *reports); +void BKE_bpath_missing_files_check(struct Main *bmain, struct ReportList *reports); /** * Recursively search into given search directory, for all file paths of all IDs in given @@ -176,29 +181,33 @@ void BKE_bpath_missing_files_check(Main *bmain, ReportList *reports); * \param find_all: If `true`, also search for files which current path is still valid, if `false` * skip those still valid paths. */ -void BKE_bpath_missing_files_find(Main *bmain, +void BKE_bpath_missing_files_find(struct Main *bmain, const char *searchpath, - ReportList *reports, + struct ReportList *reports, bool find_all); /** Rebase all relative file paths in given \a bmain from \a basedir_src to \a basedir_dst. */ -void BKE_bpath_relative_rebase(Main *bmain, +void BKE_bpath_relative_rebase(struct Main *bmain, const char *basedir_src, const char *basedir_dst, - ReportList *reports); + struct ReportList *reports); /** Make all absolute file paths in given \a bmain relative to given \a basedir. */ -void BKE_bpath_relative_convert(Main *bmain, const char *basedir, ReportList *reports); +void BKE_bpath_relative_convert(struct Main *bmain, + const char *basedir, + struct ReportList *reports); /** Make all relative file paths in given \a bmain absolute, using given \a basedir as root. */ -void BKE_bpath_absolute_convert(Main *bmain, const char *basedir, ReportList *reports); +void BKE_bpath_absolute_convert(struct Main *bmain, + const char *basedir, + struct ReportList *reports); /** * Temp backup of paths from all IDs in given \a bmain. * * \return An opaque handle to pass to #BKE_bpath_list_restore and #BKE_bpath_list_free. */ -void *BKE_bpath_list_backup(Main *bmain, eBPathForeachFlag flag); +void *BKE_bpath_list_backup(struct Main *bmain, eBPathForeachFlag flag); /** * Restore the temp backup of paths from \a path_list_handle into all IDs in given \a bmain. @@ -207,7 +216,7 @@ void *BKE_bpath_list_backup(Main *bmain, eBPathForeachFlag flag); * addition/deletion/re-ordering of IDs, or their file paths) since the call to * #BKE_bpath_list_backup that generated the given \a path_list_handle. */ -void BKE_bpath_list_restore(Main *bmain, eBPathForeachFlag flag, void *path_list_handle); +void BKE_bpath_list_restore(struct Main *bmain, eBPathForeachFlag flag, void *path_list_handle); /** * Free the temp backup of paths in \a path_list_handle. @@ -218,3 +227,7 @@ void BKE_bpath_list_restore(Main *bmain, eBPathForeachFlag flag, void *path_list void BKE_bpath_list_free(void *path_list_handle); /** \} */ + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenkernel/BKE_bvhutils.hh b/source/blender/blenkernel/BKE_bvhutils.hh index 84906820738..70bd5401eae 100644 --- a/source/blender/blenkernel/BKE_bvhutils.hh +++ b/source/blender/blenkernel/BKE_bvhutils.hh @@ -12,16 +12,31 @@ #include #include "BLI_bit_span.hh" -#include "BLI_index_mask_fwd.hh" #include "BLI_kdopbvh.h" #include "BLI_math_vector_types.hh" #include "BLI_span.hh" +struct BMEditMesh; struct BVHCache; struct BVHTree; struct MFace; struct Mesh; struct PointCloud; +struct vec2i; + +/** + * Struct that stores basic information about a BVHTree built from a edit-mesh. + */ +struct BVHTreeFromEditMesh { + BVHTree *tree; + + /** Default callbacks to BVH nearest and ray-cast. */ + BVHTree_NearestPointCallback nearest_callback; + BVHTree_RayCastCallback raycast_callback; + + /* Private data */ + bool cached; +}; /** * Struct that stores basic information about a #BVHTree built from a mesh. @@ -55,10 +70,39 @@ enum BVHCacheType { BVHTREE_FROM_LOOSEVERTS, BVHTREE_FROM_LOOSEEDGES, + BVHTREE_FROM_EM_LOOSEVERTS, + BVHTREE_FROM_EM_EDGES, + BVHTREE_FROM_EM_LOOPTRIS, + /* Keep `BVHTREE_MAX_ITEM` as last item. */ BVHTREE_MAX_ITEM, }; +/** + * Builds a BVH tree where nodes are the relevant elements of the given mesh. + * Configures #BVHTreeFromMesh. + * + * The tree is build in mesh space coordinates, this means special care must be made on queries + * so that the coordinates and rays are first translated on the mesh local coordinates. + * Reason for this is that bvh_from_mesh_* can use a cache in some cases and so it + * becomes possible to reuse a #BVHTree. + * + * #free_bvhtree_from_mesh should be called when the tree is no longer needed. + */ +BVHTree *bvhtree_from_editmesh_verts( + BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis); + +/** + * Builds a BVH-tree where nodes are the vertices of the given `em`. + */ +BVHTree *bvhtree_from_editmesh_verts_ex(BVHTreeFromEditMesh *data, + BMEditMesh *em, + blender::BitSpan verts_mask, + int verts_num_active, + float epsilon, + int tree_type, + int axis); + /** * Builds a BVH-tree where nodes are the given vertices (NOTE: does not copy given `vert`!). * \param vert_allocated: if true, vert freeing will be done when freeing data. @@ -74,6 +118,20 @@ BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data, int tree_type, int axis); +BVHTree *bvhtree_from_editmesh_edges( + BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis); + +/** + * Builds a BVH-tree where nodes are the edges of the given `em`. + */ +BVHTree *bvhtree_from_editmesh_edges_ex(BVHTreeFromEditMesh *data, + BMEditMesh *em, + blender::BitSpan edges_mask, + int edges_num_active, + float epsilon, + int tree_type, + int axis); + /** * Builds a BVH-tree where nodes are the given edges. * \param vert, vert_allocated: if true, elem freeing will be done when freeing data. @@ -91,6 +149,20 @@ BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data, int tree_type, int axis); +BVHTree *bvhtree_from_editmesh_corner_tris( + BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis); + +/** + * Builds a BVH-tree where nodes are triangles faces (#MLoopTri) of the given `bm`. + */ +BVHTree *bvhtree_from_editmesh_looptris_ex(BVHTreeFromEditMesh *data, + BMEditMesh *em, + blender::BitSpan corner_tris_mask, + int corner_tris_num_active, + float epsilon, + int tree_type, + int axis); + /** * Builds a BVH-tree where nodes are the triangle faces (#MLoopTri) of the given mesh. */ @@ -116,12 +188,19 @@ BVHTree *BKE_bvhtree_from_mesh_get(BVHTreeFromMesh *data, int tree_type); /** - * Build a bvh tree from the triangles in the mesh that correspond to the faces in the given mask. + * Builds or queries a BVH-cache for the cache BVH-tree of the request type. */ -void BKE_bvhtree_from_mesh_tris_init(const Mesh &mesh, - const blender::IndexMask &faces_mask, - BVHTreeFromMesh &r_data); +BVHTree *BKE_bvhtree_from_editmesh_get(BVHTreeFromEditMesh *data, + BMEditMesh *em, + int tree_type, + BVHCacheType bvh_cache_type, + BVHCache **bvh_cache_p, + std::mutex *mesh_eval_mutex); +/** + * Frees data allocated by a call to `bvhtree_from_editmesh_*`. + */ +void free_bvhtree_from_editmesh(BVHTreeFromEditMesh *data); /** * Frees data allocated by a call to `bvhtree_from_mesh_*`. */ diff --git a/source/blender/blenkernel/BKE_cachefile.h b/source/blender/blenkernel/BKE_cachefile.h new file mode 100644 index 00000000000..900d5ae7242 --- /dev/null +++ b/source/blender/blenkernel/BKE_cachefile.h @@ -0,0 +1,70 @@ +/* SPDX-FileCopyrightText: 2016 Blender Authors + * + * SPDX-License-Identifier: GPL-2.0-or-later */ + +#pragma once + +/** \file + * \ingroup bke + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct CacheFile; +struct CacheFileLayer; +struct CacheReader; +struct Depsgraph; +struct Main; +struct Object; +struct Scene; + +void BKE_cachefiles_init(void); +void BKE_cachefiles_exit(void); + +void *BKE_cachefile_add(struct Main *bmain, const char *name); + +void BKE_cachefile_reload(struct Depsgraph *depsgraph, struct CacheFile *cache_file); + +void BKE_cachefile_eval(struct Main *bmain, + struct Depsgraph *depsgraph, + struct CacheFile *cache_file); + +bool BKE_cachefile_filepath_get(const struct Main *bmain, + const struct Depsgraph *depsgraph, + const struct CacheFile *cache_file, + char r_filepath[1024]); + +double BKE_cachefile_time_offset(const struct CacheFile *cache_file, double time, double fps); + +/* Modifiers and constraints open and free readers through these. */ +void BKE_cachefile_reader_open(struct CacheFile *cache_file, + struct CacheReader **reader, + struct Object *object, + const char *object_path); +void BKE_cachefile_reader_free(struct CacheFile *cache_file, struct CacheReader **reader); + +/** + * Determine whether the #CacheFile should use a render engine procedural. If so, data is not read + * from the file and bounding boxes are used to represent the objects in the Scene. + * Render engines will receive the bounding box as a placeholder but can instead + * load the data directly if they support it. + */ +bool BKE_cache_file_uses_render_procedural(const struct CacheFile *cache_file, + struct Scene *scene); + +/** + * Add a layer to the cache_file. Return NULL if the `filepath` is already that of an existing + * layer or if the number of layers exceeds the maximum allowed layer count. + */ +struct CacheFileLayer *BKE_cachefile_add_layer(struct CacheFile *cache_file, + const char filepath[1024]); + +struct CacheFileLayer *BKE_cachefile_get_active_layer(struct CacheFile *cache_file); + +void BKE_cachefile_remove_layer(struct CacheFile *cache_file, struct CacheFileLayer *layer); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenkernel/BKE_cachefile.hh b/source/blender/blenkernel/BKE_cachefile.hh deleted file mode 100644 index 7b51c920b89..00000000000 --- a/source/blender/blenkernel/BKE_cachefile.hh +++ /dev/null @@ -1,58 +0,0 @@ -/* SPDX-FileCopyrightText: 2016 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#pragma once - -/** \file - * \ingroup bke - */ - -struct CacheFile; -struct CacheFileLayer; -struct CacheReader; -struct Depsgraph; -struct Main; -struct Object; -struct Scene; - -void BKE_cachefiles_init(void); -void BKE_cachefiles_exit(void); - -void *BKE_cachefile_add(Main *bmain, const char *name); - -void BKE_cachefile_reload(Depsgraph *depsgraph, CacheFile *cache_file); - -void BKE_cachefile_eval(Main *bmain, Depsgraph *depsgraph, CacheFile *cache_file); - -bool BKE_cachefile_filepath_get(const Main *bmain, - const Depsgraph *depsgraph, - const CacheFile *cache_file, - char r_filepath[1024]); - -double BKE_cachefile_time_offset(const CacheFile *cache_file, double time, double fps); - -/* Modifiers and constraints open and free readers through these. */ -void BKE_cachefile_reader_open(CacheFile *cache_file, - CacheReader **reader, - Object *object, - const char *object_path); -void BKE_cachefile_reader_free(CacheFile *cache_file, CacheReader **reader); - -/** - * Determine whether the #CacheFile should use a render engine procedural. If so, data is not read - * from the file and bounding boxes are used to represent the objects in the Scene. - * Render engines will receive the bounding box as a placeholder but can instead - * load the data directly if they support it. - */ -bool BKE_cache_file_uses_render_procedural(const CacheFile *cache_file, Scene *scene); - -/** - * Add a layer to the cache_file. Return NULL if the `filepath` is already that of an existing - * layer or if the number of layers exceeds the maximum allowed layer count. - */ -CacheFileLayer *BKE_cachefile_add_layer(CacheFile *cache_file, const char filepath[1024]); - -CacheFileLayer *BKE_cachefile_get_active_layer(CacheFile *cache_file); - -void BKE_cachefile_remove_layer(CacheFile *cache_file, CacheFileLayer *layer); diff --git a/source/blender/blenkernel/BKE_callbacks.hh b/source/blender/blenkernel/BKE_callbacks.h similarity index 80% rename from source/blender/blenkernel/BKE_callbacks.hh rename to source/blender/blenkernel/BKE_callbacks.h index 370a1d7e2e5..b382638febc 100644 --- a/source/blender/blenkernel/BKE_callbacks.hh +++ b/source/blender/blenkernel/BKE_callbacks.h @@ -8,6 +8,10 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + struct Depsgraph; struct ID; struct Main; @@ -69,7 +73,7 @@ struct PointerRNA; * All callbacks here must be exposed via the Python module `bpy.app.handlers`, * see `bpy_app_handlers.cc`. */ -enum eCbEvent { +typedef enum { BKE_CB_EVT_FRAME_CHANGE_PRE, BKE_CB_EVT_FRAME_CHANGE_POST, BKE_CB_EVT_RENDER_PRE, @@ -111,20 +115,26 @@ enum eCbEvent { BKE_CB_EVT_EXTENSION_REPOS_SYNC, BKE_CB_EVT_EXTENSION_REPOS_UPGRADE, BKE_CB_EVT_TOT, -}; +} eCbEvent; -struct bCallbackFuncStore { - bCallbackFuncStore *next, *prev; - void (*func)(Main *, PointerRNA **, int num_pointers, void *arg); +typedef struct bCallbackFuncStore { + struct bCallbackFuncStore *next, *prev; + void (*func)(struct Main *, struct PointerRNA **, int num_pointers, void *arg); void *arg; short alloc; -}; +} bCallbackFuncStore; -void BKE_callback_exec(Main *bmain, PointerRNA **pointers, int num_pointers, eCbEvent evt); -void BKE_callback_exec_null(Main *bmain, eCbEvent evt); -void BKE_callback_exec_id(Main *bmain, ID *id, eCbEvent evt); -void BKE_callback_exec_id_depsgraph(Main *bmain, ID *id, Depsgraph *depsgraph, eCbEvent evt); -void BKE_callback_exec_string(Main *bmain, eCbEvent evt, const char *str); +void BKE_callback_exec(struct Main *bmain, + struct PointerRNA **pointers, + int num_pointers, + eCbEvent evt); +void BKE_callback_exec_null(struct Main *bmain, eCbEvent evt); +void BKE_callback_exec_id(struct Main *bmain, struct ID *id, eCbEvent evt); +void BKE_callback_exec_id_depsgraph(struct Main *bmain, + struct ID *id, + struct Depsgraph *depsgraph, + eCbEvent evt); +void BKE_callback_exec_string(struct Main *bmain, eCbEvent evt, const char *str); void BKE_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt); void BKE_callback_remove(bCallbackFuncStore *funcstore, eCbEvent evt); @@ -133,3 +143,7 @@ void BKE_callback_global_init(void); * Call on application exit. */ void BKE_callback_global_finalize(void); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenkernel/BKE_collection.hh b/source/blender/blenkernel/BKE_collection.h similarity index 51% rename from source/blender/blenkernel/BKE_collection.hh rename to source/blender/blenkernel/BKE_collection.h index 0dca0a64f8b..06391282d07 100644 --- a/source/blender/blenkernel/BKE_collection.hh +++ b/source/blender/blenkernel/BKE_collection.h @@ -15,6 +15,10 @@ #include "DNA_listBase.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Structs */ struct BLI_Iterator; @@ -31,10 +35,10 @@ struct Object; struct Scene; struct ViewLayer; -struct CollectionParent { +typedef struct CollectionParent { struct CollectionParent *next, *prev; struct Collection *collection; -}; +} CollectionParent; /* Collections */ @@ -42,36 +46,38 @@ struct CollectionParent { * Add a collection to a collection ListBase and synchronize all render layers * The ListBase is NULL when the collection is to be added to the master collection */ -Collection *BKE_collection_add(Main *bmain, Collection *parent, const char *name); +struct Collection *BKE_collection_add(struct Main *bmain, + struct Collection *parent, + const char *name); /** * Add \a collection_dst to all scene collections that reference object \a ob_src is in. * Used to replace an instance object with a collection (library override operator). * * Logic is very similar to #BKE_collection_object_add_from(). */ -void BKE_collection_add_from_object(Main *bmain, - Scene *scene, - const Object *ob_src, - Collection *collection_dst); +void BKE_collection_add_from_object(struct Main *bmain, + struct Scene *scene, + const struct Object *ob_src, + struct Collection *collection_dst); /** * Add \a collection_dst to all scene collections that reference collection \a collection_src is * in. * * Logic is very similar to #BKE_collection_object_add_from(). */ -void BKE_collection_add_from_collection(Main *bmain, - Scene *scene, - Collection *collection_src, - Collection *collection_dst); +void BKE_collection_add_from_collection(struct Main *bmain, + struct Scene *scene, + struct Collection *collection_src, + struct Collection *collection_dst); /** * Free (or release) any data used by this collection (does not free the collection itself). */ -void BKE_collection_free_data(Collection *collection); +void BKE_collection_free_data(struct Collection *collection); /** * Remove a collection, optionally removing its child objects or moving * them to parent collections. */ -bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy); +bool BKE_collection_delete(struct Main *bmain, struct Collection *collection, bool hierarchy); /** * Make a deep copy (aka duplicate) of the given collection and all of its children, recursively. @@ -81,33 +87,36 @@ bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy); * responsible to reconstruct collection dependencies information's * (i.e. call #BKE_main_collection_sync). */ -Collection *BKE_collection_duplicate(Main *bmain, - Collection *parent, - Collection *collection, - uint duplicate_flags, - uint duplicate_options); +struct Collection *BKE_collection_duplicate(struct Main *bmain, + struct Collection *parent, + struct Collection *collection, + uint duplicate_flags, + uint duplicate_options); /* Master Collection for Scene */ #define BKE_SCENE_COLLECTION_NAME "Scene Collection" -Collection *BKE_collection_master_add(Scene *scene); +struct Collection *BKE_collection_master_add(struct Scene *scene); /* Collection Objects */ -bool BKE_collection_has_object(Collection *collection, const Object *ob); -bool BKE_collection_has_object_recursive(Collection *collection, Object *ob); -bool BKE_collection_has_object_recursive_instanced(Collection *collection, Object *ob); -Collection *BKE_collection_object_find(Main *bmain, - Scene *scene, - Collection *collection, - Object *ob); -bool BKE_collection_is_empty(const Collection *collection); +bool BKE_collection_has_object(struct Collection *collection, const struct Object *ob); +bool BKE_collection_has_object_recursive(struct Collection *collection, struct Object *ob); +bool BKE_collection_has_object_recursive_instanced(struct Collection *collection, + struct Object *ob); +struct Collection *BKE_collection_object_find(struct Main *bmain, + struct Scene *scene, + struct Collection *collection, + struct Object *ob); +bool BKE_collection_is_empty(const struct Collection *collection); /** * Add object to given collection, ensuring this collection is 'editable' (i.e. local and not a * liboverride), and finding a suitable parent one otherwise. */ -bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob); +bool BKE_collection_object_add(struct Main *bmain, + struct Collection *collection, + struct Object *ob); /** * Add object to given collection, similar to #BKE_collection_object_add. @@ -115,51 +124,62 @@ bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob); * However, it additionally ensures that the selected collection is also part of the given * `view_layer`, if non-NULL. Otherwise, the object is not added to any collection. */ -bool BKE_collection_viewlayer_object_add(Main *bmain, - const ViewLayer *view_layer, - Collection *collection, - Object *ob); +bool BKE_collection_viewlayer_object_add(struct Main *bmain, + const struct ViewLayer *view_layer, + struct Collection *collection, + struct Object *ob); /** * Same as #BKE_collection_object_add, but unconditionally adds the object to the given collection. * * NOTE: required in certain cases, like do-versioning or complex ID management tasks. */ -bool BKE_collection_object_add_notest(Main *bmain, Collection *collection, Object *ob); +bool BKE_collection_object_add_notest(struct Main *bmain, + struct Collection *collection, + struct Object *ob); /** * Add \a ob_dst to all scene collections that reference object \a ob_src is in. * Used for copying objects. * * Logic is very similar to #BKE_collection_add_from_object() */ -void BKE_collection_object_add_from(Main *bmain, Scene *scene, Object *ob_src, Object *ob_dst); +void BKE_collection_object_add_from(struct Main *bmain, + struct Scene *scene, + struct Object *ob_src, + struct Object *ob_dst); /** * Remove object from collection. */ -bool BKE_collection_object_remove(Main *bmain, - Collection *collection, - Object *object, +bool BKE_collection_object_remove(struct Main *bmain, + struct Collection *collection, + struct Object *object, bool free_us); /** * Replace one object with another in a collection (managing user counts). */ -bool BKE_collection_object_replace(Main *bmain, - Collection *collection, - Object *ob_old, - Object *ob_new); +bool BKE_collection_object_replace(struct Main *bmain, + struct Collection *collection, + struct Object *ob_old, + struct Object *ob_new); /** * Move object from a collection into another * * If source collection is NULL move it from all the existing collections. */ -void BKE_collection_object_move( - Main *bmain, Scene *scene, Collection *collection_dst, Collection *collection_src, Object *ob); +void BKE_collection_object_move(struct Main *bmain, + struct Scene *scene, + struct Collection *collection_dst, + struct Collection *collection_src, + struct Object *ob); /** * Remove object from all collections of scene */ -bool BKE_scene_collections_object_remove(Main *bmain, Scene *scene, Object *object, bool free_us); +bool BKE_scene_collections_object_remove(struct Main *bmain, + struct Scene *scene, + struct Object *object, + bool free_us); /** * Check all collections in \a bmain (including embedded ones in scenes) for invalid @@ -168,7 +188,7 @@ bool BKE_scene_collections_object_remove(Main *bmain, Scene *scene, Object *obje * \note In case of duplicates, the first CollectionObject in the list is kept, all others are * removed. */ -void BKE_collections_object_remove_invalids(Main *bmain); +void BKE_collections_object_remove_invalids(struct Main *bmain); /** * Remove all NULL children from parent collections of changed \a collection. @@ -182,20 +202,22 @@ void BKE_collections_object_remove_invalids(Main *bmain); * \param child_collection: The collection that was remapped to another pointer. May be \a NULL, * in which case whole \a bmain database of collections is checked. */ -void BKE_collections_child_remove_nulls(Main *bmain, - Collection *parent_collection, - Collection *child_collection); +void BKE_collections_child_remove_nulls(struct Main *bmain, + struct Collection *parent_collection, + struct Collection *child_collection); /* Dependencies. */ -bool BKE_collection_is_in_scene(Collection *collection); -void BKE_collections_after_lib_link(Main *bmain); -bool BKE_collection_object_cyclic_check(Main *bmain, Object *object, Collection *collection); +bool BKE_collection_is_in_scene(struct Collection *collection); +void BKE_collections_after_lib_link(struct Main *bmain); +bool BKE_collection_object_cyclic_check(struct Main *bmain, + struct Object *object, + struct Collection *collection); /* Object list cache. */ -ListBase BKE_collection_object_cache_get(Collection *collection); -ListBase BKE_collection_object_cache_instanced_get(Collection *collection); +struct ListBase BKE_collection_object_cache_get(struct Collection *collection); +ListBase BKE_collection_object_cache_instanced_get(struct Collection *collection); /** Free the object cache of given `collection` and all of its ancestors (recursively). * * \param bmain: The Main database owning the collection. May be `nullptr`, only used if doing @@ -203,18 +225,18 @@ ListBase BKE_collection_object_cache_instanced_get(Collection *collection); * \param id_create_flag: Flags controlling ID creation, used here to enable or * not depsgraph tagging of affected IDs (e.g. #LIB_ID_CREATE_NO_DEG_TAG would prevent depsgraph * tagging). */ -void BKE_collection_object_cache_free(const Main *bmain, - Collection *collection, +void BKE_collection_object_cache_free(const struct Main *bmain, + struct Collection *collection, const int id_create_flag); /** * Free the object cache of all collections in given `bmain`, including master collections of * scenes. */ -void BKE_main_collections_object_cache_free(const Main *bmain); +void BKE_main_collections_object_cache_free(const struct Main *bmain); -Base *BKE_collection_or_layer_objects(const Scene *scene, - ViewLayer *view_layer, - Collection *collection); +struct Base *BKE_collection_or_layer_objects(const struct Scene *scene, + struct ViewLayer *view_layer, + struct Collection *collection); /* Editing. */ @@ -223,38 +245,44 @@ Base *BKE_collection_or_layer_objects(const Scene *scene, * * The index is calculated from top to bottom counting the children before the siblings. */ -Collection *BKE_collection_from_index(Scene *scene, int index); +struct Collection *BKE_collection_from_index(struct Scene *scene, int index); /** * The automatic/fallback name of a new collection. */ -void BKE_collection_new_name_get(Collection *collection_parent, char *rname); +void BKE_collection_new_name_get(struct Collection *collection_parent, char *rname); /** * The name to show in the interface. */ -const char *BKE_collection_ui_name_get(Collection *collection); +const char *BKE_collection_ui_name_get(struct Collection *collection); /** * Select all the objects in this Collection (and its nested collections) for this ViewLayer. * Return true if any object was selected. */ -bool BKE_collection_objects_select(const Scene *scene, - ViewLayer *view_layer, - Collection *collection, +bool BKE_collection_objects_select(const struct Scene *scene, + struct ViewLayer *view_layer, + struct Collection *collection, bool deselect); /* Collection children */ -bool BKE_collection_child_add(Main *bmain, Collection *parent, Collection *child); +bool BKE_collection_child_add(struct Main *bmain, + struct Collection *parent, + struct Collection *child); -bool BKE_collection_child_add_no_sync(Main *bmain, Collection *parent, Collection *child); +bool BKE_collection_child_add_no_sync(struct Main *bmain, + struct Collection *parent, + struct Collection *child); -bool BKE_collection_child_remove(Main *bmain, Collection *parent, Collection *child); +bool BKE_collection_child_remove(struct Main *bmain, + struct Collection *parent, + struct Collection *child); -bool BKE_collection_move(Main *bmain, - Collection *to_parent, - Collection *from_parent, - Collection *relative, +bool BKE_collection_move(struct Main *bmain, + struct Collection *to_parent, + struct Collection *from_parent, + struct Collection *relative, bool relative_after, - Collection *collection); + struct Collection *collection); /** * Find potential cycles in collections. @@ -265,33 +293,34 @@ bool BKE_collection_move(Main *bmain, * may be NULL if we just want to ensure \a new_ancestor does not already have cycles. * \return true if a cycle is found. */ -bool BKE_collection_cycle_find(Collection *new_ancestor, Collection *collection); +bool BKE_collection_cycle_find(struct Collection *new_ancestor, struct Collection *collection); /** * Find and fix potential cycles in collections. * * \param collection: The collection to check for existing cycles. * \return true if cycles are found and fixed. */ -bool BKE_collection_cycles_fix(Main *bmain, Collection *collection); +bool BKE_collection_cycles_fix(struct Main *bmain, struct Collection *collection); -bool BKE_collection_has_collection(const Collection *parent, const Collection *collection); +bool BKE_collection_has_collection(const struct Collection *parent, + const struct Collection *collection); /** * Rebuild parent relationships from child ones, for all children of given \a collection. * * \note Given collection is assumed to already have valid parents. */ -void BKE_collection_parent_relations_rebuild(Collection *collection); +void BKE_collection_parent_relations_rebuild(struct Collection *collection); /** * Rebuild parent relationships from child ones, for all collections in given \a bmain. */ -void BKE_main_collections_parent_relations_rebuild(Main *bmain); +void BKE_main_collections_parent_relations_rebuild(struct Main *bmain); /** * Perform some validation on integrity of the data of this collection. * * \return `true` if everything is OK, false if some errors are detected. */ -bool BKE_collection_validate(Collection *collection); +bool BKE_collection_validate(struct Collection *collection); /* .blend file I/O */ @@ -299,14 +328,17 @@ bool BKE_collection_validate(Collection *collection); * Perform some pre-writing cleanup on the COllection data itself (_not_ in any sub-data * referenced by pointers). To be called before writing the Collection struct itself. */ -void BKE_collection_blend_write_prepare_nolib(BlendWriter *writer, Collection *collection); -void BKE_collection_blend_write_nolib(BlendWriter *writer, Collection *collection); -void BKE_collection_blend_read_data(BlendDataReader *reader, Collection *collection, ID *owner_id); +void BKE_collection_blend_write_prepare_nolib(struct BlendWriter *writer, + struct Collection *collection); +void BKE_collection_blend_write_nolib(struct BlendWriter *writer, struct Collection *collection); +void BKE_collection_blend_read_data(struct BlendDataReader *reader, + struct Collection *collection, + struct ID *owner_id); /* Iteration callbacks. */ -using BKE_scene_objects_Cb = void (*)(Object *ob, void *data); -using BKE_scene_collections_Cb = void (*)(Collection *ob, void *data); +typedef void (*BKE_scene_objects_Cb)(struct Object *ob, void *data); +typedef void (*BKE_scene_collections_Cb)(struct Collection *ob, void *data); /* Iteration over objects in collection. */ @@ -316,8 +348,7 @@ using BKE_scene_collections_Cb = void (*)(Collection *ob, void *data); int _object_visibility_flag = (_mode == DAG_EVAL_VIEWPORT) ? OB_HIDE_VIEWPORT : \ OB_HIDE_RENDER; \ int _base_id = 0; \ - for (Base *_base = static_cast(BKE_collection_object_cache_get(_collection).first); \ - _base; \ + for (Base *_base = (Base *)BKE_collection_object_cache_get(_collection).first; _base; \ _base = _base->next, _base_id++) \ { \ Object *_object = _base->object; \ @@ -331,8 +362,7 @@ using BKE_scene_collections_Cb = void (*)(Collection *ob, void *data); ((void)0) #define FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(_collection, _object) \ - for (Base *_base = static_cast(BKE_collection_object_cache_get(_collection).first); \ - _base; \ + for (Base *_base = (Base *)BKE_collection_object_cache_get(_collection).first; _base; \ _base = _base->next) \ { \ Object *_object = _base->object; \ @@ -348,28 +378,28 @@ using BKE_scene_collections_Cb = void (*)(Collection *ob, void *data); * Only use this in non-performance critical situations * (it iterates over all scene collections twice) */ -void BKE_scene_collections_iterator_begin(BLI_Iterator *iter, void *data_in); -void BKE_scene_collections_iterator_next(BLI_Iterator *iter); -void BKE_scene_collections_iterator_end(BLI_Iterator *iter); +void BKE_scene_collections_iterator_begin(struct BLI_Iterator *iter, void *data_in); +void BKE_scene_collections_iterator_next(struct BLI_Iterator *iter); +void BKE_scene_collections_iterator_end(struct BLI_Iterator *iter); -void BKE_scene_objects_iterator_begin(BLI_Iterator *iter, void *data_in); -void BKE_scene_objects_iterator_next(BLI_Iterator *iter); -void BKE_scene_objects_iterator_end(BLI_Iterator *iter); +void BKE_scene_objects_iterator_begin(struct BLI_Iterator *iter, void *data_in); +void BKE_scene_objects_iterator_next(struct BLI_Iterator *iter); +void BKE_scene_objects_iterator_end(struct BLI_Iterator *iter); /** * Iterate over objects in the scene based on a flag. * * \note The object->flag is tested against flag. */ -struct SceneObjectsIteratorExData { - Scene *scene; +typedef struct SceneObjectsIteratorExData { + struct Scene *scene; int flag; void *iter_data; -}; +} SceneObjectsIteratorExData; -void BKE_scene_objects_iterator_begin_ex(BLI_Iterator *iter, void *data_in); -void BKE_scene_objects_iterator_next_ex(BLI_Iterator *iter); -void BKE_scene_objects_iterator_end_ex(BLI_Iterator *iter); +void BKE_scene_objects_iterator_begin_ex(struct BLI_Iterator *iter, void *data_in); +void BKE_scene_objects_iterator_next_ex(struct BLI_Iterator *iter); +void BKE_scene_objects_iterator_end_ex(struct BLI_Iterator *iter); /** * Generate a new #GSet (or extend given `objects_gset` if not NULL) with all objects referenced by @@ -378,7 +408,7 @@ void BKE_scene_objects_iterator_end_ex(BLI_Iterator *iter); * \note This will include objects without a base currently * (because they would belong to excluded collections only e.g.). */ -GSet *BKE_scene_objects_as_gset(Scene *scene, GSet *objects_gset); +struct GSet *BKE_scene_objects_as_gset(struct Scene *scene, struct GSet *objects_gset); #define FOREACH_SCENE_COLLECTION_BEGIN(scene, _instance) \ ITER_BEGIN (BKE_scene_collections_iterator_begin, \ @@ -400,16 +430,16 @@ GSet *BKE_scene_objects_as_gset(Scene *scene, GSet *objects_gset); _instance_next = _scene->master_collection; \ } \ else { \ - _instance_next = static_cast((_bmain)->collections.first); \ + _instance_next = (Collection *)(_bmain)->collections.first; \ } \ \ while ((_instance = _instance_next)) { \ if (is_scene_collection) { \ - _instance_next = static_cast((_bmain)->collections.first); \ + _instance_next = (Collection *)(_bmain)->collections.first; \ is_scene_collection = false; \ } \ else { \ - _instance_next = static_cast(_instance->id.next); \ + _instance_next = (Collection *)_instance->id.next; \ } #define FOREACH_COLLECTION_END \ @@ -426,3 +456,7 @@ GSet *BKE_scene_objects_as_gset(Scene *scene, GSet *objects_gset); _instance) #define FOREACH_SCENE_OBJECT_END ITER_END + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenkernel/BKE_curve.hh b/source/blender/blenkernel/BKE_curve.hh index 49a7b26ed53..7ce2203a8f6 100644 --- a/source/blender/blenkernel/BKE_curve.hh +++ b/source/blender/blenkernel/BKE_curve.hh @@ -32,7 +32,7 @@ struct Object; struct rctf; struct TextBox; -using eBezTriple_Flag__Alias = int; +typedef int eBezTriple_Flag__Alias; struct CurveCache { ListBase disp; diff --git a/source/blender/blenkernel/BKE_customdata.hh b/source/blender/blenkernel/BKE_customdata.hh index 550e735ae4e..101a1bbf121 100644 --- a/source/blender/blenkernel/BKE_customdata.hh +++ b/source/blender/blenkernel/BKE_customdata.hh @@ -73,7 +73,7 @@ extern const CustomData_MeshMasks CD_MASK_EVERYTHING; * CD_NUMTYPES elements, that indicate if a layer can be copied. */ /** Add/copy/merge allocation types. */ -enum eCDAllocType { +typedef enum eCDAllocType { /** Allocate and set to default, which is usually just zeroed memory. */ CD_SET_DEFAULT = 2, /** @@ -81,18 +81,18 @@ enum eCDAllocType { * if all layer values will be set by the caller after creating the layer. */ CD_CONSTRUCT = 5, -}; +} eCDAllocType; #define CD_TYPE_AS_MASK(_type) (eCustomDataMask)((eCustomDataMask)1 << (eCustomDataMask)(_type)) void customData_mask_layers__print(const CustomData_MeshMasks *mask); -using cd_interp = void (*)( +typedef void (*cd_interp)( const void **sources, const float *weights, const float *sub_weights, int count, void *dest); -using cd_copy = void (*)(const void *source, void *dest, int count); -using cd_set_default_value = void (*)(void *data, int count); -using cd_free = void (*)(void *data, int count); -using cd_validate = bool (*)(void *item, uint totitems, bool do_fixes); +typedef void (*cd_copy)(const void *source, void *dest, int count); +typedef void (*cd_set_default_value)(void *data, int count); +typedef void (*cd_free)(void *data, int count); +typedef bool (*cd_validate)(void *item, uint totitems, bool do_fixes); /** * Update mask_dst with layers defined in mask_src (equivalent to a bit-wise OR). @@ -261,17 +261,14 @@ const void *CustomData_add_layer_with_data(CustomData *data, /** * Same as above but accepts a name. */ -void *CustomData_add_layer_named(CustomData *data, - eCustomDataType type, - eCDAllocType alloctype, - int totelem, - blender::StringRef name); +void *CustomData_add_layer_named( + CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem, const char *name); const void *CustomData_add_layer_named_with_data(CustomData *data, eCustomDataType type, void *layer_data, int totelem, - blender::StringRef name, + const char *name, const ImplicitSharingInfoHandle *sharing_info); void *CustomData_add_layer_anonymous(CustomData *data, @@ -294,7 +291,7 @@ const void *CustomData_add_layer_anonymous_with_data( * In edit-mode, use #EDBM_data_layer_free instead of this function. */ bool CustomData_free_layer(CustomData *data, eCustomDataType type, int totelem, int index); -bool CustomData_free_layer_named(CustomData *data, blender::StringRef name, const int totelem); +bool CustomData_free_layer_named(CustomData *data, const char *name, const int totelem); /** * Frees the layer index with the give type. @@ -313,9 +310,7 @@ void CustomData_free_layers(CustomData *data, eCustomDataType type, int totelem) * Returns true if a layer with the specified type exists. */ bool CustomData_has_layer(const CustomData *data, eCustomDataType type); -bool CustomData_has_layer_named(const CustomData *data, - eCustomDataType type, - blender::StringRef name); +bool CustomData_has_layer_named(const CustomData *data, eCustomDataType type, const char *name); /** * Returns the number of layers with this type. @@ -495,10 +490,7 @@ void *CustomData_bmesh_get_n(const CustomData *data, void *block, eCustomDataTyp */ void *CustomData_bmesh_get_layer_n(const CustomData *data, void *block, int n); -bool CustomData_set_layer_name(CustomData *data, - eCustomDataType type, - int n, - blender::StringRef name); +bool CustomData_set_layer_name(CustomData *data, eCustomDataType type, int n, const char *name); const char *CustomData_get_layer_name(const CustomData *data, eCustomDataType type, int n); /** @@ -521,31 +513,27 @@ void *CustomData_get_layer_n_for_write(CustomData *data, eCustomDataType type, i */ const void *CustomData_get_layer_named(const CustomData *data, eCustomDataType type, - blender::StringRef name); + const char *name); void *CustomData_get_layer_named_for_write(CustomData *data, eCustomDataType type, - blender::StringRef name, + const char *name, int totelem); int CustomData_get_offset(const CustomData *data, eCustomDataType type); -int CustomData_get_offset_named(const CustomData *data, - eCustomDataType type, - blender::StringRef name); +int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, const char *name); int CustomData_get_n_offset(const CustomData *data, eCustomDataType type, int n); int CustomData_get_layer_index(const CustomData *data, eCustomDataType type); int CustomData_get_layer_index_n(const CustomData *data, eCustomDataType type, int n); int CustomData_get_named_layer_index(const CustomData *data, eCustomDataType type, - blender::StringRef name); -int CustomData_get_named_layer_index_notype(const CustomData *data, blender::StringRef name); + const char *name); +int CustomData_get_named_layer_index_notype(const CustomData *data, const char *name); int CustomData_get_active_layer_index(const CustomData *data, eCustomDataType type); int CustomData_get_render_layer_index(const CustomData *data, eCustomDataType type); int CustomData_get_clone_layer_index(const CustomData *data, eCustomDataType type); int CustomData_get_stencil_layer_index(const CustomData *data, eCustomDataType type); -int CustomData_get_named_layer(const CustomData *data, - eCustomDataType type, - blender::StringRef name); +int CustomData_get_named_layer(const CustomData *data, eCustomDataType type, const char *name); int CustomData_get_active_layer(const CustomData *data, eCustomDataType type); int CustomData_get_render_layer(const CustomData *data, eCustomDataType type); int CustomData_get_clone_layer(const CustomData *data, eCustomDataType type); @@ -643,7 +631,7 @@ void CustomData_set_layer_unique_name(CustomData *data, int index); void CustomData_validate_layer_name(const CustomData *data, eCustomDataType type, - blender::StringRef name, + const char *name, char *outname); /** diff --git a/source/blender/blenkernel/BKE_duplilist.hh b/source/blender/blenkernel/BKE_duplilist.h similarity index 62% rename from source/blender/blenkernel/BKE_duplilist.hh rename to source/blender/blenkernel/BKE_duplilist.h index 5b5cc52474e..c78a98129f7 100644 --- a/source/blender/blenkernel/BKE_duplilist.hh +++ b/source/blender/blenkernel/BKE_duplilist.h @@ -1,13 +1,25 @@ /* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved. * * SPDX-License-Identifier: GPL-2.0-or-later */ - #pragma once /** \file * \ingroup bke */ +#ifdef __cplusplus +namespace blender::bke { +struct GeometrySet; +} +using GeometrySetHandle = blender::bke::GeometrySet; +#else +typedef struct GeometrySetHandle GeometrySetHandle; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + struct Depsgraph; struct ID; struct ListBase; @@ -16,9 +28,6 @@ struct ParticleSystem; struct Scene; struct ViewLayer; struct ViewerPath; -namespace blender::bke { -struct GeometrySet; -} /* ---------------------------------------------------- */ /* Dupli-Geometry */ @@ -26,29 +35,31 @@ struct GeometrySet; /** * \return a #ListBase of #DupliObject. */ -ListBase *object_duplilist(Depsgraph *depsgraph, Scene *sce, Object *ob); +struct ListBase *object_duplilist(struct Depsgraph *depsgraph, + struct Scene *sce, + struct Object *ob); /** * \return a #ListBase of #DupliObject for the preview geometry referenced by the #ViewerPath. */ -ListBase *object_duplilist_preview(Depsgraph *depsgraph, - Scene *scene, - Object *ob, - const ViewerPath *viewer_path); -void free_object_duplilist(ListBase *lb); +struct ListBase *object_duplilist_preview(struct Depsgraph *depsgraph, + struct Scene *scene, + struct Object *ob, + const struct ViewerPath *viewer_path); +void free_object_duplilist(struct ListBase *lb); -struct DupliObject { - DupliObject *next, *prev; +typedef struct DupliObject { + struct DupliObject *next, *prev; /* Object whose geometry is instanced. */ - Object *ob; + struct Object *ob; /* Data owned by the object above that is instanced. This might not be the same as `ob->data`. */ - ID *ob_data; + struct ID *ob_data; float mat[4][4]; float orco[3], uv[2]; - short type; /* From #Object::transflag. */ + short type; /* from Object.transflag */ char no_draw; /* If this dupli object is belongs to a preview, this is non-null. */ - const blender::bke::GeometrySet *preview_base_geometry; + const GeometrySetHandle *preview_base_geometry; /* Index of the top-level instance this dupli is part of or -1 when unused. */ int preview_instance_index; @@ -57,7 +68,7 @@ struct DupliObject { int persistent_id[8]; /* MAX_DUPLI_RECUR */ /* Particle this dupli was generated from. */ - ParticleSystem *particle_system; + struct ParticleSystem *particle_system; /* Geometry set stack for instance attributes; for each level lists the * geometry set and instance index within it. @@ -68,19 +79,19 @@ struct DupliObject { * size between 1 and MAX_DUPLI_RECUR can be used without issues. */ int instance_idx[4]; - const blender::bke::GeometrySet *instance_data[4]; + const GeometrySetHandle *instance_data[4]; /* Random ID for shading */ unsigned int random_id; -}; +} DupliObject; /** * Look up the RGBA value of a uniform shader attribute. * \return true if the attribute was found; if not, r_value is also set to zero. */ -bool BKE_object_dupli_find_rgba_attribute(const Object *ob, - const DupliObject *dupli, - const Object *dupli_parent, +bool BKE_object_dupli_find_rgba_attribute(const struct Object *ob, + const struct DupliObject *dupli, + const struct Object *dupli_parent, const char *name, float r_value[4]); @@ -88,7 +99,11 @@ bool BKE_object_dupli_find_rgba_attribute(const Object *ob, * Look up the RGBA value of a view layer/scene/world shader attribute. * \return true if the attribute was found; if not, r_value is also set to zero. */ -bool BKE_view_layer_find_rgba_attribute(const Scene *scene, - const ViewLayer *layer, +bool BKE_view_layer_find_rgba_attribute(const struct Scene *scene, + const struct ViewLayer *layer, const char *name, float r_value[4]); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenkernel/BKE_global.hh b/source/blender/blenkernel/BKE_global.h similarity index 98% rename from source/blender/blenkernel/BKE_global.hh rename to source/blender/blenkernel/BKE_global.h index 07581c54ae0..a143f0aab7a 100644 --- a/source/blender/blenkernel/BKE_global.hh +++ b/source/blender/blenkernel/BKE_global.h @@ -14,9 +14,13 @@ #include "BLI_utildefines.h" #include "DNA_listBase.h" +#ifdef __cplusplus +extern "C" { +#endif + struct Main; -struct Global { +typedef struct Global { /** * Data for the current active blend file. @@ -24,13 +28,13 @@ struct Global { * Note that `CTX_data_main(C)` should be used where possible. * Otherwise access via #G_MAIN. */ - Main *main; + struct Main *main; /** * Preview main is stored to avoid loading the preview file in multiple scenarios. * It is actually shared between shader node previews and asset previews. */ - Main *pr_main; + struct Main *pr_main; /** Last saved location for images. */ char filepath_last_image[/*FILE_MAX*/ 1024]; @@ -41,7 +45,7 @@ struct Global { * Strings of recently opened files to show in the file menu. * A list of #RecentFile read from #BLENDER_HISTORY_FILE. */ - ListBase recent_files; + struct ListBase recent_files; /** * Set when Escape been pressed or `Ctrl-C` pressed in background mode. @@ -158,7 +162,7 @@ struct Global { bool opengl_deprecation_usage_detected; const char *opengl_deprecation_usage_filename; int opengl_deprecation_usage_lineno; -}; +} Global; /* **************** GLOBAL ********************* */ @@ -286,3 +290,7 @@ extern Global G; * helps with cleanup task. */ #define G_MAIN (G).main + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenkernel/BKE_grease_pencil.hh b/source/blender/blenkernel/BKE_grease_pencil.hh index 1365fb67ae6..2322df93546 100644 --- a/source/blender/blenkernel/BKE_grease_pencil.hh +++ b/source/blender/blenkernel/BKE_grease_pencil.hh @@ -34,6 +34,14 @@ namespace blender::bke { namespace greasepencil { +struct DrawingTransforms { + float4x4 world_space_to_layer_space; + float4x4 layer_space_to_world_space; + + DrawingTransforms() = default; + DrawingTransforms(const Object &grease_pencil_ob); +}; + class DrawingRuntime { public: /** @@ -439,23 +447,6 @@ class Layer : public ::GreasePencilLayer { */ void update_from_dna_read(); - /** - * Returns the transformation from layer space to object space. - */ - float4x4 to_object_space(const Object &object) const; - - /** - * Returns the transformation from layer space to world space. - */ - float4x4 to_world_space(const Object &object) const; - - /** - * Returns the name of the parent bone. Should only be used in case the parent object is an - * armature. - */ - StringRefNull parent_bone_name() const; - void set_parent_bone_name(const char *new_name); - private: using SortedKeysIterator = const int *; @@ -469,16 +460,6 @@ class Layer : public ::GreasePencilLayer { */ SortedKeysIterator remove_leading_null_frames_in_range(SortedKeysIterator begin, SortedKeysIterator end); - - /** - * The local transform of the layer (in layer space, not object space). - */ - float4x4 local_transform() const; - - /** - * Get the parent to world matrix for this layer. - */ - float4x4 parent_to_world(const Object &parent) const; }; class LayerGroupRuntime { @@ -513,8 +494,6 @@ class LayerGroup : public ::GreasePencilLayerTreeGroup { LayerGroup(const LayerGroup &other); ~LayerGroup(); - LayerGroup &operator=(const LayerGroup &other); - public: /* Define the common functions for #TreeNode. */ TREENODE_COMMON_METHODS; @@ -724,6 +703,14 @@ inline LayerGroup &Layer::parent_group() const TREENODE_COMMON_METHODS_FORWARD_IMPL(LayerGroup); +namespace convert { + +void legacy_gpencil_frame_to_grease_pencil_drawing(const bGPDframe &gpf, + const ListBase &vertex_group_names, + GreasePencilDrawing &r_drawing); +void legacy_gpencil_to_grease_pencil(Main &main, GreasePencil &grease_pencil, bGPdata &gpd); + +} // namespace convert } // namespace greasepencil class GreasePencilRuntime { diff --git a/source/blender/blenkernel/BKE_grease_pencil_legacy_convert.hh b/source/blender/blenkernel/BKE_grease_pencil_legacy_convert.hh deleted file mode 100644 index db431b69d97..00000000000 --- a/source/blender/blenkernel/BKE_grease_pencil_legacy_convert.hh +++ /dev/null @@ -1,33 +0,0 @@ -/* SPDX-FileCopyrightText: 2023 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#pragma once - -/** \file - * \ingroup bke - */ - -struct bGPdata; -struct bGPDframe; -struct GreasePencil; -struct GreasePencilDrawing; -struct ListBase; -struct Main; -struct Object; - -namespace blender::bke::greasepencil::convert { - -void legacy_gpencil_frame_to_grease_pencil_drawing(const bGPDframe &gpf, - const ListBase &vertex_group_names, - GreasePencilDrawing &r_drawing); -void legacy_gpencil_to_grease_pencil(Main &bmain, GreasePencil &grease_pencil, bGPdata &gpd); - -void legacy_gpencil_object(Main &bmain, Object &object); - -void thickness_factor_to_modifier(const bGPdata &src_object_data, Object &dst_object); -void layer_adjustments_to_modifiers(Main &bmain, - const bGPdata &src_object_data, - Object &dst_object); - -} // namespace blender::bke::greasepencil::convert diff --git a/source/blender/blenkernel/BKE_idtype.hh b/source/blender/blenkernel/BKE_idtype.hh index 50ef2d8fd9a..6c34de86ade 100644 --- a/source/blender/blenkernel/BKE_idtype.hh +++ b/source/blender/blenkernel/BKE_idtype.hh @@ -60,40 +60,40 @@ bool BKE_idtype_cache_key_cmp(const void *key_a_v, const void *key_b_v); /* ********** Prototypes for #IDTypeInfo callbacks. ********** */ -using IDTypeInitDataFunction = void (*)(ID *id); +typedef void (*IDTypeInitDataFunction)(ID *id); /** \param flag: Copying options (see BKE_lib_id.hh's LIB_ID_COPY_... flags for more). */ -using IDTypeCopyDataFunction = void (*)(Main *bmain, ID *id_dst, const ID *id_src, int flag); +typedef void (*IDTypeCopyDataFunction)(Main *bmain, ID *id_dst, const ID *id_src, int flag); -using IDTypeFreeDataFunction = void (*)(ID *id); +typedef void (*IDTypeFreeDataFunction)(ID *id); /** \param flags: See BKE_lib_id.hh's LIB_ID_MAKELOCAL_... flags. */ -using IDTypeMakeLocalFunction = void (*)(Main *bmain, ID *id, int flags); +typedef void (*IDTypeMakeLocalFunction)(Main *bmain, ID *id, int flags); -using IDTypeForeachIDFunction = void (*)(ID *id, LibraryForeachIDData *data); +typedef void (*IDTypeForeachIDFunction)(ID *id, LibraryForeachIDData *data); -enum eIDTypeInfoCacheCallbackFlags { +typedef enum eIDTypeInfoCacheCallbackFlags { /** Indicates to the callback that cache may be stored in the .blend file, * so its pointer should not be cleared at read-time. */ IDTYPE_CACHE_CB_FLAGS_PERSISTENT = 1 << 0, -}; -using IDTypeForeachCacheFunctionCallback = - void (*)(ID *id, const IDCacheKey *cache_key, void **cache_p, uint flags, void *user_data); -using IDTypeForeachCacheFunction = void (*)(ID *id, - IDTypeForeachCacheFunctionCallback function_callback, - void *user_data); +} eIDTypeInfoCacheCallbackFlags; +typedef void (*IDTypeForeachCacheFunctionCallback)( + ID *id, const IDCacheKey *cache_key, void **cache_p, uint flags, void *user_data); +typedef void (*IDTypeForeachCacheFunction)(ID *id, + IDTypeForeachCacheFunctionCallback function_callback, + void *user_data); -using IDTypeForeachPathFunction = void (*)(ID *id, BPathForeachPathData *bpath_data); +typedef void (*IDTypeForeachPathFunction)(ID *id, BPathForeachPathData *bpath_data); -using IDTypeEmbeddedOwnerPointerGetFunction = ID **(*)(ID *id); +typedef ID **(*IDTypeEmbeddedOwnerPointerGetFunction)(ID *id); -using IDTypeBlendWriteFunction = void (*)(BlendWriter *writer, ID *id, const void *id_address); -using IDTypeBlendReadDataFunction = void (*)(BlendDataReader *reader, ID *id); -using IDTypeBlendReadAfterLiblinkFunction = void (*)(BlendLibReader *reader, ID *id); +typedef void (*IDTypeBlendWriteFunction)(BlendWriter *writer, ID *id, const void *id_address); +typedef void (*IDTypeBlendReadDataFunction)(BlendDataReader *reader, ID *id); +typedef void (*IDTypeBlendReadAfterLiblinkFunction)(BlendLibReader *reader, ID *id); -using IDTypeBlendReadUndoPreserve = void (*)(BlendLibReader *reader, ID *id_new, ID *id_old); +typedef void (*IDTypeBlendReadUndoPreserve)(BlendLibReader *reader, ID *id_new, ID *id_old); -using IDTypeLibOverrideApplyPost = void (*)(ID *id_dst, ID *id_src); +typedef void (*IDTypeLibOverrideApplyPost)(ID *id_dst, ID *id_src); struct IDTypeInfo { /* ********** General IDType data. ********** */ @@ -109,14 +109,6 @@ struct IDTypeInfo { */ uint64_t id_filter; - /** - * Known types of ID dependencies. - * - * Used by #BKE_library_id_can_use_filter_id, together with additional runtime heuristics, to - * generate a filter value containing only ID types that given ID could be using. - */ - uint64_t dependencies_id_types; - /** * Define the position of this data-block type in the virtual list of all data in a Main that is * returned by `set_listbasepointers()`. @@ -279,7 +271,6 @@ extern IDTypeInfo IDType_ID_LINK_PLACEHOLDER; void BKE_idtype_init(void); /* General helpers. */ -const IDTypeInfo *BKE_idtype_get_info_from_idtype_index(const int idtype_index); const IDTypeInfo *BKE_idtype_get_info_from_idcode(short id_code); const IDTypeInfo *BKE_idtype_get_info_from_id(const ID *id); @@ -345,24 +336,6 @@ bool BKE_idtype_idcode_append_is_reusable(short idcode); */ short BKE_idtype_idcode_from_name(const char *idtype_name); -/** - * Convert an \a idcode into an \a idtype_index (e.g. #ID_OB -> #INDEX_ID_OB). - */ -int BKE_idtype_idcode_to_index(short idcode); -/** - * Convert an \a idfilter into an \a idtype_index (e.g. #FILTER_ID_OB -> #INDEX_ID_OB). - */ -int BKE_idtype_idfilter_to_index(uint64_t idfilter); - -/** - * Convert an \a idtype_index into an \a idcode (e.g. #INDEX_ID_OB -> #ID_OB). - */ -short BKE_idtype_index_to_idcode(int idtype_index); -/** - * Convert an \a idtype_index into an \a idfilter (e.g. #INDEX_ID_OB -> #FILTER_ID_OB). - */ -uint64_t BKE_idtype_index_to_idfilter(int idtype_index); - /** * Convert an \a idcode into an \a idfilter (e.g. #ID_OB -> #FILTER_ID_OB). */ @@ -370,7 +343,16 @@ uint64_t BKE_idtype_idcode_to_idfilter(short idcode); /** * Convert an \a idfilter into an \a idcode (e.g. #FILTER_ID_OB -> #ID_OB). */ -short BKE_idtype_idfilter_to_idcode(uint64_t idfilter); +short BKE_idtype_idcode_from_idfilter(uint64_t idfilter); + +/** + * Convert an \a idcode into an index (e.g. #ID_OB -> #INDEX_ID_OB). + */ +int BKE_idtype_idcode_to_index(short idcode); +/** + * Get an \a idcode from an index (e.g. #INDEX_ID_OB -> #ID_OB). + */ +short BKE_idtype_idcode_from_index(int index); /** * Return an ID code and steps the index forward 1. @@ -378,7 +360,7 @@ short BKE_idtype_idfilter_to_idcode(uint64_t idfilter); * \param index: start as 0. * \return the code, 0 when all codes have been returned. */ -short BKE_idtype_idcode_iter_step(int *idtype_index); +short BKE_idtype_idcode_iter_step(int *index); /* Some helpers/wrappers around callbacks defined in #IDTypeInfo, dealing e.g. with embedded IDs. * XXX Ideally those would rather belong to #BKE_lib_id, but using callback function pointers makes diff --git a/source/blender/blenkernel/BKE_layer.hh b/source/blender/blenkernel/BKE_layer.hh index d489957004d..fb4eab42c38 100644 --- a/source/blender/blenkernel/BKE_layer.hh +++ b/source/blender/blenkernel/BKE_layer.hh @@ -10,7 +10,7 @@ #include "BLI_vector.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "DNA_layer_types.h" #include "DNA_listBase.h" diff --git a/source/blender/blenkernel/BKE_lib_id.hh b/source/blender/blenkernel/BKE_lib_id.hh index 4076cf0ba2d..3958d4d497d 100644 --- a/source/blender/blenkernel/BKE_lib_id.hh +++ b/source/blender/blenkernel/BKE_lib_id.hh @@ -33,8 +33,6 @@ #include "BLI_compiler_attrs.h" #include "BLI_utildefines.h" -#include "BLI_set.hh" - #include "DNA_userdef_enums.h" struct BlendWriter; @@ -214,7 +212,7 @@ ID *BKE_libblock_find_name_and_library(Main *bmain, * Duplicate (a.k.a. deep copy) common processing options. * See also eDupli_ID_Flags for options controlling what kind of IDs to duplicate. */ -enum eLibIDDuplicateFlags { +typedef enum eLibIDDuplicateFlags { /** This call to a duplicate function is part of another call for some parent ID. * Therefore, this sub-process should not clear `newid` pointers, nor handle remapping itself. * NOTE: In some cases (like Object one), the duplicate function may be called on the root ID @@ -224,7 +222,7 @@ enum eLibIDDuplicateFlags { /** This call is performed on a 'root' ID, and should therefore perform some decisions regarding * sub-IDs (dependencies), check for linked vs. locale data, etc. */ LIB_ID_DUPLICATE_IS_ROOT_ID = 1 << 1, -}; +} eLibIDDuplicateFlags; ENUM_OPERATORS(eLibIDDuplicateFlags, LIB_ID_DUPLICATE_IS_ROOT_ID) @@ -321,23 +319,11 @@ void BKE_id_delete_ex(Main *bmain, void *idv, const int extra_remapping_flags) A * This is more efficient than calling #BKE_id_delete repetitively on a large set of IDs * (several times faster when deleting most of the IDs at once). * + * \warning Considered experimental for now, seems to be working OK but this is + * risky code in a complicated area. * \return Number of deleted data-blocks. */ size_t BKE_id_multi_tagged_delete(Main *bmain) ATTR_NONNULL(); -/** - * Properly delete all IDs from \a ids_to_delete, from given \a bmain database. - * - * This is more efficient than calling #BKE_id_delete repetitively on a large set of IDs - * (several times faster when deleting most of the IDs at once). - * - * \note The ID pointers are not removed from the Set (which may contain more pointers than - * originally given, when extra users or dependencies also had to be deleted with the original set - * of IDs). They are all freed though, so these pointers are all invalid after calling this - * function. - * - * \return Number of deleted data-blocks. - */ -size_t BKE_id_multi_delete(Main *bmain, blender::Set &ids_to_delete); /** * Add a 'NO_MAIN' data-block to given main (also sets user-counts of its IDs if needed). diff --git a/source/blender/blenkernel/BKE_lib_query.hh b/source/blender/blenkernel/BKE_lib_query.hh index a7405c505fd..74a286b3dd8 100644 --- a/source/blender/blenkernel/BKE_lib_query.hh +++ b/source/blender/blenkernel/BKE_lib_query.hh @@ -19,13 +19,10 @@ * - `BKE_lib_query_` should be used for functions in that file. */ -#include "DNA_ID.h" - #include "BLI_sys_types.h" -#include - -struct IDTypeInfo; +struct ID; +struct IDProperty; struct LibraryForeachIDData; struct Main; @@ -142,7 +139,7 @@ struct LibraryIDLinkCallbackData { * * \return a set of flags to control further iteration (0 to keep going). */ -using LibraryIDLinkCallback = int (*)(LibraryIDLinkCallbackData *cb_data); +typedef int (*LibraryIDLinkCallback)(LibraryIDLinkCallbackData *cb_data); /* Flags for the foreach function itself. */ enum { @@ -300,9 +297,7 @@ bool BKE_library_id_can_use_idtype(ID *owner_id, short id_type_used); /** * Given the owner_id return the type of id_types it can use as a filter_id. */ -uint64_t BKE_library_id_can_use_filter_id(const ID *owner_id, - const bool include_ui, - const IDTypeInfo *owner_id_type = nullptr); +uint64_t BKE_library_id_can_use_filter_id(const ID *owner_id, const bool include_ui); /** * Check whether given ID is used locally (i.e. by another non-linked ID). @@ -321,81 +316,27 @@ void BKE_library_ID_test_usages(Main *bmain, bool *r_is_used_local, bool *r_is_used_linked); -/** Parameters and result data structure for the 'unused IDs' functions below. */ -struct LibQueryUnusedIDsData { - /** Process local data-blocks. */ - bool do_local_ids; - /** Process linked data-blocks. */ - bool do_linked_ids; - /** - * Process all actually unused data-blocks, including these that are currently only used by - * other unused data-blocks, and 'dependency islands' of several data-blocks using each-other, - * without any external valid user. - */ - bool do_recursive; - - /** - * Amount of detected as unused data-blocks, per type and total as the last value of the array - * (#INDEX_ID_NULL). - * - * \note: Return value, set by the executed function. - */ - std::array num_total; - /** - * Amount of detected as unused local data-blocks, per type and total as the last value of the - * array (#INDEX_ID_NULL). - * - * \note: Return value, set by the executed function. - */ - std::array num_local; - /** - * Amount of detected as unused linked data-blocks, per type and total as the last value of the - * array (#INDEX_ID_NULL). - * - * \note: Return value, set by the executed function. - */ - std::array num_linked; -}; - -/** - * Compute amount of unused IDs (a.k.a 'orphaned'). - * - * By default only consider IDs with `0` user count. - * If `do_recursive` is set, it will check dependencies to detect all IDs that are not actually - * used in current file, including 'archipelagos` (i.e. set of IDs referencing each other in - * loops, but without any 'external' valid usages. - * - * Valid usages here are defined as ref-counting usages, which are not towards embedded or - * loop-back data. - * - * \param r_num_total: A zero-initialized array of #INDEX_ID_MAX integers. Number of IDs detected - * as unused from given parameters, per ID type in the matching index, and as total in - * #INDEX_ID_NULL item. - * \param r_num_local: A zero-initialized array of #INDEX_ID_MAX integers. Number of local IDs - * detected as unused from given parameters (but assuming \a do_local_ids is true), per ID type in - * the matching index, and as total in #INDEX_ID_NULL item. - * \param r_num_linked: A zero-initialized array of #INDEX_ID_MAX integers. Number of linked IDs - * detected as unused from given parameters (but assuming \a do_linked_ids is true), per ID type in - * the matching index, and as total in #INDEX_ID_NULL item. - */ -void BKE_lib_query_unused_ids_amounts(Main *bmain, LibQueryUnusedIDsData ¶meters); /** * Tag all unused IDs (a.k.a 'orphaned'). * * By default only tag IDs with `0` user count. - * If `do_recursive` is set, it will check dependencies to detect all IDs that are not actually + * If `do_tag_recursive` is set, it will check dependencies to detect all IDs that are not actually * used in current file, including 'archipelagos` (i.e. set of IDs referencing each other in * loops, but without any 'external' valid usages. * * Valid usages here are defined as ref-counting usages, which are not towards embedded or * loop-back data. * - * \param tag: the ID tag to use to mark the ID as unused. Should never be `0`. - * \param r_num_tagged_total: A zero-initialized array of #INDEX_ID_MAX integers. Number of IDs - * tagged as unused from given parameters, per ID type in the matching index, and as total in + * \param r_num_tagged: If non-NULL, must be a zero-initialized array of #INDEX_ID_MAX integers. + * Number of tagged-as-unused IDs is then set for each type, and as total in * #INDEX_ID_NULL item. */ -void BKE_lib_query_unused_ids_tag(Main *bmain, int tag, LibQueryUnusedIDsData ¶meters); +void BKE_lib_query_unused_ids_tag(Main *bmain, + int tag, + bool do_local_ids, + bool do_linked_ids, + bool do_tag_recursive, + int *r_num_tagged); /** * Detect orphaned linked data blocks (i.e. linked data not used (directly or indirectly) diff --git a/source/blender/blenkernel/BKE_lib_remap.hh b/source/blender/blenkernel/BKE_lib_remap.hh index 6717d75021e..968bdb91af1 100644 --- a/source/blender/blenkernel/BKE_lib_remap.hh +++ b/source/blender/blenkernel/BKE_lib_remap.hh @@ -21,18 +21,13 @@ */ #include "BLI_compiler_attrs.h" -#include "BLI_map.hh" -#include "BLI_set.hh" #include "BLI_span.hh" #include "BLI_utildefines.h" struct ID; +struct IDRemapper; struct Main; -namespace blender::bke::id { -class IDRemapper; -} - /* BKE_libblock_free, delete are declared in BKE_lib_id.hh for convenience. */ /* Also IDRemap->flag. */ @@ -49,11 +44,10 @@ enum { */ ID_REMAP_SKIP_NEVER_NULL_USAGE = 1 << 1, /** - * Store in the #IDRemapper all IDs using target one with a 'never NULL' pointer (like e.g. - * #Object.data), when such ID usage has (or should have) been remapped to `nullptr`. See also - * #ID_REMAP_FORCE_NEVER_NULL_USAGE and #ID_REMAP_SKIP_NEVER_NULL_USAGE. + * This tells the callback func to flag with #LIB_DOIT all IDs + * using target one with a 'never NULL' pointer (like e.g. #Object.data). */ - ID_REMAP_STORE_NEVER_NULL_USAGE = 1 << 2, + ID_REMAP_FLAG_NEVER_NULL_USAGE = 1 << 2, /** * This tells the callback func to force setting IDs * using target one with a 'never NULL' pointer to NULL. @@ -130,13 +124,9 @@ enum eIDRemapType { * * \note Is preferred over BKE_libblock_remap_locked due to performance. */ -void BKE_libblock_remap_multiple_locked(Main *bmain, - blender::bke::id::IDRemapper &mappings, - const int remap_flags); +void BKE_libblock_remap_multiple_locked(Main *bmain, IDRemapper *mappings, const int remap_flags); -void BKE_libblock_remap_multiple(Main *bmain, - blender::bke::id::IDRemapper &mappings, - const int remap_flags); +void BKE_libblock_remap_multiple(Main *bmain, IDRemapper *mappings, const int remap_flags); /** * Bare raw remapping of IDs, with no other processing than actually updating the ID pointers. @@ -147,9 +137,7 @@ void BKE_libblock_remap_multiple(Main *bmain, * case e.g. in read-file process. * * WARNING: This call will likely leave the given BMain in invalid state in many aspects. */ -void BKE_libblock_remap_multiple_raw(Main *bmain, - blender::bke::id::IDRemapper &mappings, - const int remap_flags); +void BKE_libblock_remap_multiple_raw(Main *bmain, IDRemapper *mappings, const int remap_flags); /** * Replace all references in given Main to \a old_id by \a new_id * (if \a new_id is NULL, it unlinks \a old_id). @@ -165,8 +153,12 @@ void BKE_libblock_remap(Main *bmain, void *old_idv, void *new_idv, int remap_fla /** * Unlink given \a id from given \a bmain * (does not touch to indirect, i.e. library, usages of the ID). + * + * \param do_flag_never_null: If true, all IDs using \a idv in a 'non-NULL' way are flagged by + * #LIB_TAG_DOIT flag (quite obviously, 'non-NULL' usages can never be unlinked by this function). */ -void BKE_libblock_unlink(Main *bmain, void *idv, bool do_skip_indirect) ATTR_NONNULL(); +void BKE_libblock_unlink(Main *bmain, void *idv, bool do_flag_never_null, bool do_skip_indirect) + ATTR_NONNULL(); /** * Similar to libblock_remap, but only affects IDs used by given \a idv ID. @@ -186,7 +178,7 @@ void BKE_libblock_relink_ex(Main *bmain, void *idv, void *old_idv, void *new_idv void BKE_libblock_relink_multiple(Main *bmain, const blender::Span ids, eIDRemapType remap_type, - blender::bke::id::IDRemapper &id_remapper, + IDRemapper *id_remapper, int remap_flags); /** @@ -201,8 +193,7 @@ void BKE_libblock_relink_multiple(Main *bmain, void BKE_libblock_relink_to_newid(Main *bmain, ID *id, int remap_flag) ATTR_NONNULL(); using BKE_library_free_notifier_reference_cb = void (*)(const void *); -using BKE_library_remap_editor_id_reference_cb = - void (*)(const blender::bke::id::IDRemapper &mappings); +using BKE_library_remap_editor_id_reference_cb = void (*)(const IDRemapper *mappings); void BKE_library_callback_free_notifier_reference_set(BKE_library_free_notifier_reference_cb func); void BKE_library_callback_remap_editor_id_reference_set( @@ -229,7 +220,7 @@ enum IDRemapperApplyOptions { * * NOTE: Currently unused by main remapping code, since user-count is handled by * `foreach_libblock_remap_callback_apply` there, depending on whether the remapped pointer does - * use it or not. Needed for rare cases in UI handling though (see e.g. `image_id_remap` in + * use it or not. Need for rare cases in UI handling though (see e.g. `image_id_remap` in * `space_image.cc`). */ ID_REMAP_APPLY_UPDATE_REFCOUNT = (1 << 0), @@ -242,9 +233,9 @@ enum IDRemapperApplyOptions { ID_REMAP_APPLY_ENSURE_REAL = (1 << 1), /** - * Unassign instead of remap when the new ID pointer would point to itself. + * Unassign in stead of remap when the new ID data-block would become id_self. * - * To use this option #IDRemapper::apply must be used with a non-null id_self parameter. + * To use this option 'BKE_id_remapper_apply_ex' must be used with a not-null id_self parameter. */ ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF = (1 << 2), @@ -253,83 +244,58 @@ enum IDRemapperApplyOptions { ENUM_OPERATORS(IDRemapperApplyOptions, ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF) using IDRemapperIterFunction = void (*)(ID *old_id, ID *new_id, void *user_data); -using IDTypeFilter = uint64_t; -namespace blender::bke::id { +/** + * Create a new ID Remapper. + * + * An ID remapper stores multiple remapping rules. + */ +IDRemapper *BKE_id_remapper_create(); -class IDRemapper { - blender::Map mappings_; - IDTypeFilter source_types_ = 0; +void BKE_id_remapper_clear(IDRemapper *id_remapper); +bool BKE_id_remapper_is_empty(const IDRemapper *id_remapper); +/** Free the given ID Remapper. */ +void BKE_id_remapper_free(IDRemapper *id_remapper); +/** Add a new remapping. Does not replace an existing mapping for `old_id`, if any. */ +void BKE_id_remapper_add(IDRemapper *id_remapper, ID *old_id, ID *new_id); +/** Add a new remapping, replacing a potential already existing mapping of `old_id`. */ +void BKE_id_remapper_add_overwrite(IDRemapper *id_remapper, ID *old_id, ID *new_id); - /** - * Store all IDs using another ID with the 'NEVER_NULL' flag, which have (or - * should have been) remapped to `nullptr`. - */ - blender::Set never_null_users_; +/** + * Apply a remapping. + * + * Update the id pointer stored in the given r_id_ptr if a remapping rule exists. + */ +IDRemapperApplyResult BKE_id_remapper_apply(const IDRemapper *id_remapper, + ID **r_id_ptr, + IDRemapperApplyOptions options); +/** + * Apply a remapping. + * + * Use this function when `ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF`. In this case + * the #id_self parameter is required. Otherwise the #BKE_id_remapper_apply can be used. + * + * \param id_self: required for ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF. + * When remapping to id_self it will then be remapped to NULL. + */ +IDRemapperApplyResult BKE_id_remapper_apply_ex(const IDRemapper *id_remapper, + ID **r_id_ptr, + IDRemapperApplyOptions options, + ID *id_self); +bool BKE_id_remapper_has_mapping_for(const IDRemapper *id_remapper, uint64_t type_filter); - public: - void clear(void) - { - mappings_.clear(); - never_null_users_.clear(); - source_types_ = 0; - } +/** + * Determine the mapping result, without applying the mapping. + */ +IDRemapperApplyResult BKE_id_remapper_get_mapping_result(const IDRemapper *id_remapper, + ID *id, + IDRemapperApplyOptions options, + const ID *id_self); +void BKE_id_remapper_iter(const IDRemapper *id_remapper, + IDRemapperIterFunction func, + void *user_data); - bool is_empty(void) const - { - return mappings_.is_empty(); - } - - bool contains_mappings_for_any(IDTypeFilter filter) const - { - return (source_types_ & filter) != 0; - } - - /** Add a new remapping. Does not replace an existing mapping for `old_id`, if any. */ - void add(ID *old_id, ID *new_id); - /** Add a new remapping, replacing a potential already existing mapping of `old_id`. */ - void add_overwrite(ID *old_id, ID *new_id); - - /** Determine the mapping result, without applying the mapping. */ - IDRemapperApplyResult get_mapping_result(ID *id, - IDRemapperApplyOptions options, - const ID *id_self) const; - - /** - * Apply a remapping. - * - * Update the id pointer stored in the given r_id_ptr if a remapping rule exists. - * - * \param id_self: Only for ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF. - * When remapping to `id_self` it will then be remapped to `nullptr` instead. - */ - IDRemapperApplyResult apply(ID **r_id_ptr, - IDRemapperApplyOptions options, - ID *id_self = nullptr) const; - - void never_null_users_add(ID *id) - { - never_null_users_.add(id); - } - - const blender::Set &never_null_users(void) const - { - return never_null_users_; - } - - /** Iterate over all remapping pairs in the remapper, and call the callback function on them. */ - void iter(IDRemapperIterFunction func, void *user_data) const - { - for (auto item : mappings_.items()) { - func(item.key, item.value, user_data); - } - } - - /** Return a readable string for the given result. Can be used for debugging purposes. */ - static const blender::StringRefNull result_to_string(const IDRemapperApplyResult result); - - /** Print out the rules inside the given id_remapper. Can be used for debugging purposes. */ - void print(void) const; -}; - -} // namespace blender::bke::id +/** Returns a readable string for the given result. Can be used for debugging purposes. */ +const char *BKE_id_remapper_result_string(const IDRemapperApplyResult result); +/** Prints out the rules inside the given id_remapper. Can be used for debugging purposes. */ +void BKE_id_remapper_print(const IDRemapper *id_remapper); diff --git a/source/blender/blenkernel/BKE_mesh.hh b/source/blender/blenkernel/BKE_mesh.hh index 8de79f0737c..e7ac48ccf55 100644 --- a/source/blender/blenkernel/BKE_mesh.hh +++ b/source/blender/blenkernel/BKE_mesh.hh @@ -290,17 +290,6 @@ inline int face_triangles_num(const int face_size) return face_size - 2; } -/** - * Return the range of triangles that belong to the given face. - */ -inline IndexRange face_triangles_range(OffsetIndices faces, int face_i) -{ - const IndexRange face = faces[face_i]; - /* This is the same as #poly_to_tri_count which is not included here. */ - const int start_triangle = face.start() - face_i * 2; - return IndexRange(start_triangle, face_triangles_num(face.size())); -} - /** * Return the index of the edge's vertex that is not the \a vert. */ @@ -317,9 +306,6 @@ inline int edge_other_vert(const int2 edge, const int vert) } // namespace mesh -/** Create a mesh with no built-in attributes. */ -Mesh *mesh_new_no_attributes(int verts_num, int edges_num, int faces_num, int corners_num); - /** Calculate edges from faces. */ void mesh_calc_edges(Mesh &mesh, bool keep_existing_edges, bool select_new_edges); diff --git a/source/blender/blenkernel/BKE_modifier.hh b/source/blender/blenkernel/BKE_modifier.hh index b31d5caa89b..18b76155bdf 100644 --- a/source/blender/blenkernel/BKE_modifier.hh +++ b/source/blender/blenkernel/BKE_modifier.hh @@ -165,15 +165,15 @@ struct ModifierEvalContext { struct ModifierTypeInfo { /* A unique identifier for this modifier. Used to generate the panel id type name. * See #BKE_modifier_type_panel_id. */ - char idname[64]; + char idname[32]; /* The user visible name for this modifier */ - char name[64]; + char name[32]; /* The DNA struct name for the modifier data type, used to * write the DNA data out. */ - char struct_name[64]; + char struct_name[32]; /* The size of the modifier data type, used by allocation. */ int struct_size; diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h new file mode 100644 index 00000000000..0fbc59f166e --- /dev/null +++ b/source/blender/blenkernel/BKE_node.h @@ -0,0 +1,1377 @@ +/* SPDX-FileCopyrightText: 2005 Blender Authors + * + * SPDX-License-Identifier: GPL-2.0-or-later */ + +#pragma once + +/** \file + * \ingroup bke + */ + +#include "BLI_compiler_compat.h" +#include "BLI_ghash.h" + +#include "DNA_listBase.h" + +/* for FOREACH_NODETREE_BEGIN */ +#include "DNA_node_types.h" + +#include "RNA_types.hh" + +#ifdef __cplusplus +# include "BLI_map.hh" +# include "BLI_string_ref.hh" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* not very important, but the stack solver likes to know a maximum */ +#define MAX_SOCKET 512 + +struct BlendDataReader; +struct BlendLibReader; +struct BlendWriter; +struct FreestyleLineStyle; +struct GPUMaterial; +struct GPUNodeStack; +struct ID; +struct ImBuf; +struct Light; +struct Main; +struct Material; +struct PointerRNA; +struct Scene; +struct SpaceNode; +struct Tex; +struct World; +struct bContext; +struct bNode; +struct bNodeExecContext; +struct bNodeExecData; +struct bNodeInstanceHash; +struct bNodeLink; +struct bNodeSocket; +struct bNodeStack; +struct bNodeTree; +struct bNodeTreeExec; +struct bNodeTreeType; +struct uiLayout; + +/* -------------------------------------------------------------------- */ +/** \name Node Type Definitions + * \{ */ + +/** + * \brief Compact definition of a node socket. + * + * Can be used to quickly define a list of static sockets for a node, + * which are added to each new node of that type. + * + * \deprecated This struct is used by C nodes to define templates as simple + * static struct lists. These are converted to the new template collections + * in RNA types automatically. + */ +typedef struct bNodeSocketTemplate { + int type; + char name[64]; /* MAX_NAME */ + float val1, val2, val3, val4; /* default alloc value for inputs */ + float min, max; + int subtype; /* would use PropertySubType but this is a bad level include to use RNA */ + int flag; + + /* after this line is used internal only */ + struct bNodeSocket *sock; /* used to hold verified socket */ + char identifier[64]; /* generated from name */ +} bNodeSocketTemplate; + +/* Use `void *` for callbacks that require C++. This is rather ugly, but works well for now. This + * would not be necessary if we would use bNodeSocketType and bNodeType only in C++ code. + * However, achieving this requires quite a few changes currently. */ +#ifdef __cplusplus +namespace blender { +class CPPType; +namespace nodes { +class DNode; +class NodeMultiFunctionBuilder; +class GeoNodeExecParams; +class NodeDeclaration; +class NodeDeclarationBuilder; +class GatherAddNodeSearchParams; +class GatherLinkSearchOpParams; +struct NodeExtraInfoParams; +} // namespace nodes +namespace realtime_compositor { +class Context; +class NodeOperation; +class ShaderNode; +} // namespace realtime_compositor +} // namespace blender + +using CPPTypeHandle = blender::CPPType; +using NodeMultiFunctionBuildFunction = void (*)(blender::nodes::NodeMultiFunctionBuilder &builder); +using NodeGeometryExecFunction = void (*)(blender::nodes::GeoNodeExecParams params); +using NodeDeclareFunction = void (*)(blender::nodes::NodeDeclarationBuilder &builder); +using NodeDeclareDynamicFunction = void (*)(const bNodeTree &tree, + const bNode &node, + blender::nodes::NodeDeclarationBuilder &builder); +using SocketGetCPPValueFunction = void (*)(const void *socket_value, void *r_value); +using SocketGetGeometryNodesCPPValueFunction = void (*)(const void *socket_value, void *r_value); + +/* Adds socket link operations that are specific to this node type. */ +using NodeGatherSocketLinkOperationsFunction = + void (*)(blender::nodes::GatherLinkSearchOpParams ¶ms); + +/* Adds node add menu operations that are specific to this node type. */ +using NodeGatherAddOperationsFunction = + void (*)(blender::nodes::GatherAddNodeSearchParams ¶ms); + +using NodeGetCompositorOperationFunction = blender::realtime_compositor::NodeOperation + *(*)(blender::realtime_compositor::Context &context, blender::nodes::DNode node); +using NodeGetCompositorShaderNodeFunction = + blender::realtime_compositor::ShaderNode *(*)(blender::nodes::DNode node); +using NodeExtraInfoFunction = void (*)(blender::nodes::NodeExtraInfoParams ¶ms); + +#else +typedef void *NodeGetCompositorOperationFunction; +typedef void *NodeGetCompositorShaderNodeFunction; +typedef void *NodeMultiFunctionBuildFunction; +typedef void *NodeGeometryExecFunction; +typedef void *NodeDeclareFunction; +typedef void *NodeDeclareDynamicFunction; +typedef void *NodeGatherSocketLinkOperationsFunction; +typedef void *NodeGatherAddOperationsFunction; +typedef void *SocketGetCPPTypeFunction; +typedef void *SocketGetGeometryNodesCPPTypeFunction; +typedef void *SocketGetGeometryNodesCPPValueFunction; +typedef void *SocketGetCPPValueFunction; +typedef void *NodeExtraInfoFunction; +typedef struct CPPTypeHandle CPPTypeHandle; +#endif + +/** + * \brief Defines a socket type. + * + * Defines the appearance and behavior of a socket in the UI. + */ +typedef struct bNodeSocketType { + /** Identifier name. */ + char idname[64]; + /** Type label. */ + char label[64]; + /** Sub-type label. */ + char subtype_label[64]; + + void (*draw)(struct bContext *C, + struct uiLayout *layout, + struct PointerRNA *ptr, + struct PointerRNA *node_ptr, + const char *text); + void (*draw_color)(struct bContext *C, + struct PointerRNA *ptr, + struct PointerRNA *node_ptr, + float *r_color); + void (*draw_color_simple)(const bNodeSocketType *socket_type, float *r_color); + + void (*interface_draw)(struct ID *id, + struct bNodeTreeInterfaceSocket *socket, + struct bContext *C, + struct uiLayout *layout); + void (*interface_init_socket)(struct ID *id, + const struct bNodeTreeInterfaceSocket *interface_socket, + struct bNode *node, + struct bNodeSocket *socket, + const char *data_path); + void (*interface_from_socket)(struct ID *id, + struct bNodeTreeInterfaceSocket *interface_socket, + const struct bNode *node, + const struct bNodeSocket *socket); + + /* RNA integration */ + ExtensionRNA ext_socket; + ExtensionRNA ext_interface; + + /* for standard socket types in C */ + int type, subtype; + + /* When set, bNodeSocket->limit does not have any effect anymore. */ + bool use_link_limits_of_type; + int input_link_limit; + int output_link_limit; + + /* Callback to free the socket type. */ + void (*free_self)(struct bNodeSocketType *stype); + + /* Return the CPPType of this socket. */ + const CPPTypeHandle *base_cpp_type; + /* Get the value of this socket in a generic way. */ + SocketGetCPPValueFunction get_base_cpp_value; + /* Get geometry nodes cpp type. */ + const CPPTypeHandle *geometry_nodes_cpp_type; + /* Get geometry nodes cpp value. */ + SocketGetGeometryNodesCPPValueFunction get_geometry_nodes_cpp_value; + /* Default value for this socket type. */ + const void *geometry_nodes_default_cpp_value; +} bNodeSocketType; + +typedef void *(*NodeInitExecFunction)(struct bNodeExecContext *context, + struct bNode *node, + bNodeInstanceKey key); +typedef void (*NodeFreeExecFunction)(void *nodedata); +typedef void (*NodeExecFunction)(void *data, + int thread, + struct bNode *, + struct bNodeExecData *execdata, + struct bNodeStack **in, + struct bNodeStack **out); +typedef int (*NodeGPUExecFunction)(struct GPUMaterial *mat, + struct bNode *node, + struct bNodeExecData *execdata, + struct GPUNodeStack *in, + struct GPUNodeStack *out); +typedef void (*NodeMaterialXFunction)(void *data, struct bNode *node, struct bNodeSocket *out); + +/** + * \brief Defines a node type. + * + * Initial attributes and constants for a node as well as callback functions + * implementing the node behavior. + */ +typedef struct bNodeType { + char idname[64]; /* identifier name */ + int type; + + char ui_name[64]; /* MAX_NAME */ + char ui_description[256]; + int ui_icon; + /** Should usually use the idname instead, but this enum type is still exposed in Python. */ + const char *enum_name_legacy; + + float width, minwidth, maxwidth; + float height, minheight, maxheight; + short nclass, flag; + + /* templates for static sockets */ + bNodeSocketTemplate *inputs, *outputs; + + char storagename[64]; /* struct name for DNA */ + + /* Draw the option buttons on the node */ + void (*draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr); + /* Additional parameters in the side panel */ + void (*draw_buttons_ex)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr); + + /* Additional drawing on backdrop */ + void (*draw_backdrop)( + struct SpaceNode *snode, struct ImBuf *backdrop, struct bNode *node, int x, int y); + + /** + * Optional custom label function for the node header. + * \note Used as a fallback when #bNode.label isn't set. + */ + void (*labelfunc)(const struct bNodeTree *ntree, + const struct bNode *node, + char *label, + int label_maxncpy); + + /** Optional override for node class, used for drawing node header. */ + int (*ui_class)(const struct bNode *node); + + /** Called when the node is updated in the editor. */ + void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node); + /** Check and update if internal ID data has changed. */ + void (*group_update_func)(struct bNodeTree *ntree, struct bNode *node); + + /** + * Initialize a new node instance of this type after creation. + * + * \note Assignments to `node->id` must not increment the user of the ID. + * This is handled by the caller of this callback. + */ + void (*initfunc)(struct bNodeTree *ntree, struct bNode *node); + /** + * Free the node instance. + * + * \note Access to `node->id` must be avoided in this function as this is called + * while freeing #Main, the state of this ID is undefined. + * Higher level logic to remove the node handles the user-count. + */ + void (*freefunc)(struct bNode *node); + /** Make a copy of the node instance. */ + void (*copyfunc)(struct bNodeTree *dest_ntree, + struct bNode *dest_node, + const struct bNode *src_node); + + /* Registerable API callback versions, called in addition to C callbacks */ + void (*initfunc_api)(const struct bContext *C, struct PointerRNA *ptr); + void (*freefunc_api)(struct PointerRNA *ptr); + void (*copyfunc_api)(struct PointerRNA *ptr, const struct bNode *src_node); + + /** + * An additional poll test for deciding whether nodes should be an option in search menus. + * Potentially more strict poll than #poll(), but doesn't have to check the same things. + */ + bool (*add_ui_poll)(const struct bContext *C); + + /** + * Can this node type be added to a node tree? + * \param r_disabled_hint: Hint to display in the UI when the poll fails. + * The callback can set this to a static string without having to + * null-check it (or without setting it to null if it's not used). + * The caller must pass a valid `const char **` and null-initialize it + * when it's not just a dummy, that is, if it actually wants to access + * the returned disabled-hint (null-check needed!). + */ + bool (*poll)(const struct bNodeType *ntype, + const struct bNodeTree *nodetree, + const char **r_disabled_hint); + /** + * Can this node be added to a node tree? + * \param r_disabled_hint: See `poll()`. + */ + bool (*poll_instance)(const struct bNode *node, + const struct bNodeTree *nodetree, + const char **r_disabled_hint); + + /* Optional handling of link insertion. Returns false if the link shouldn't be created. */ + bool (*insert_link)(struct bNodeTree *ntree, struct bNode *node, struct bNodeLink *link); + + void (*free_self)(struct bNodeType *ntype); + + /* **** execution callbacks **** */ + NodeInitExecFunction init_exec_fn; + NodeFreeExecFunction free_exec_fn; + NodeExecFunction exec_fn; + /* gpu */ + NodeGPUExecFunction gpu_fn; + /* MaterialX */ + NodeMaterialXFunction materialx_fn; + + /* Get an instance of this node's compositor operation. Freeing the instance is the + * responsibility of the caller. */ + NodeGetCompositorOperationFunction get_compositor_operation; + + /* Get an instance of this node's compositor shader node. Freeing the instance is the + * responsibility of the caller. */ + NodeGetCompositorShaderNodeFunction get_compositor_shader_node; + + /* A message to display in the node header for unsupported realtime compositor nodes. The message + * is assumed to be static and thus require no memory handling. This field is to be removed when + * all nodes are supported. */ + const char *realtime_compositor_unsupported_message; + + /* Build a multi-function for this node. */ + NodeMultiFunctionBuildFunction build_multi_function; + + /* Execute a geometry node. */ + NodeGeometryExecFunction geometry_node_execute; + + /** + * Declares which sockets and panels the node has. It has to be able to generate a declaration + * with and without a specific node context. If the declaration depends on the node, but the node + * is not provided, then the declaration should be generated as much as possible and everything + * that depends on the node context should be skipped. + */ + NodeDeclareFunction declare; + + /** + * Declaration of the node outside of any context. If the node declaration is never dependent on + * the node context, this declaration is also shared with the corresponding node instances. + * Otherwise, it mainly allows checking what sockets a node will have, without having to create + * the node. In this case, the static declaration is mostly just a hint, and does not have to + * match with the final node. + */ + NodeDeclarationHandle *static_declaration; + + /** + * Add to the list of search names and operations gathered by node link drag searching. + * Usually it isn't necessary to override the default behavior here, but a node type can have + * custom behavior here like adding custom search items. + */ + NodeGatherSocketLinkOperationsFunction gather_link_search_ops; + + /** Get extra information that is drawn next to the node. */ + NodeExtraInfoFunction get_extra_info; + + /** True when the node cannot be muted. */ + bool no_muting; + /** True when the node still works but it's usage is discouraged. */ + const char *deprecation_notice; + + /* RNA integration */ + ExtensionRNA rna_ext; +} bNodeType; + +/** #bNodeType.nclass (for add-menu and themes). */ +#define NODE_CLASS_INPUT 0 +#define NODE_CLASS_OUTPUT 1 +#define NODE_CLASS_OP_COLOR 3 +#define NODE_CLASS_OP_VECTOR 4 +#define NODE_CLASS_OP_FILTER 5 +#define NODE_CLASS_GROUP 6 +#define NODE_CLASS_CONVERTER 8 +#define NODE_CLASS_MATTE 9 +#define NODE_CLASS_DISTORT 10 +#define NODE_CLASS_PATTERN 12 +#define NODE_CLASS_TEXTURE 13 +#define NODE_CLASS_SCRIPT 32 +#define NODE_CLASS_INTERFACE 33 +#define NODE_CLASS_SHADER 40 +#define NODE_CLASS_GEOMETRY 41 +#define NODE_CLASS_ATTRIBUTE 42 +#define NODE_CLASS_LAYOUT 100 + +struct bNodeTreeExec; + +typedef void (*bNodeClassCallback)(void *calldata, int nclass, const char *name); +typedef struct bNodeTreeType { + int type; /* type identifier */ + char idname[64]; /* identifier name */ + + /* The ID name of group nodes for this type. */ + char group_idname[64]; + + char ui_name[64]; + char ui_description[256]; + int ui_icon; + + /* callbacks */ + /* Iteration over all node classes. */ + void (*foreach_nodeclass)(struct Scene *scene, void *calldata, bNodeClassCallback func); + /* Check visibility in the node editor */ + bool (*poll)(const struct bContext *C, struct bNodeTreeType *ntreetype); + /* Select a node tree from the context */ + void (*get_from_context)(const struct bContext *C, + struct bNodeTreeType *ntreetype, + struct bNodeTree **r_ntree, + struct ID **r_id, + struct ID **r_from); + + /* calls allowing threaded composite */ + void (*localize)(struct bNodeTree *localtree, struct bNodeTree *ntree); + void (*local_merge)(struct Main *bmain, struct bNodeTree *localtree, struct bNodeTree *ntree); + + /* Tree update. Overrides `nodetype->updatetreefunc`. */ + void (*update)(struct bNodeTree *ntree); + + bool (*validate_link)(eNodeSocketDatatype from, eNodeSocketDatatype to); + + void (*node_add_init)(struct bNodeTree *ntree, struct bNode *bnode); + + /* Check if the socket type is valid for this tree type. */ + bool (*valid_socket_type)(struct bNodeTreeType *ntreetype, struct bNodeSocketType *socket_type); + + /* RNA integration */ + ExtensionRNA rna_ext; +} bNodeTreeType; + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Generic API, Trees + * \{ */ + +struct bNodeTreeType *ntreeTypeFind(const char *idname); +void ntreeTypeAdd(struct bNodeTreeType *nt); +void ntreeTypeFreeLink(const struct bNodeTreeType *nt); +bool ntreeIsRegistered(const struct bNodeTree *ntree); +struct GHashIterator *ntreeTypeGetIterator(void); + +/* Helper macros for iterating over tree types. */ +#define NODE_TREE_TYPES_BEGIN(ntype) \ + { \ + GHashIterator *__node_tree_type_iter__ = ntreeTypeGetIterator(); \ + for (; !BLI_ghashIterator_done(__node_tree_type_iter__); \ + BLI_ghashIterator_step(__node_tree_type_iter__)) \ + { \ + bNodeTreeType *ntype = (bNodeTreeType *)BLI_ghashIterator_getValue(__node_tree_type_iter__); + +#define NODE_TREE_TYPES_END \ + } \ + BLI_ghashIterator_free(__node_tree_type_iter__); \ + } \ + (void)0 + +/** + * Try to initialize all type-info in a node tree. + * + * \note In general undefined type-info is a perfectly valid case, + * the type may just be registered later. + * In that case the update_typeinfo function will set type-info on registration + * and do necessary updates. + */ +void ntreeSetTypes(const struct bContext *C, struct bNodeTree *ntree); + +struct bNodeTree *ntreeAddTree(struct Main *bmain, const char *name, const char *idname); + +/** + * Free tree which is embedded into another data-block. + */ +void ntreeFreeEmbeddedTree(struct bNodeTree *ntree); + +/** + * Get address of potential node-tree pointer of given ID. + * + * \warning Using this function directly is potentially dangerous, if you don't know or are not + * sure, please use `ntreeFromID()` instead. + */ +struct bNodeTree **BKE_ntree_ptr_from_id(struct ID *id); + +/** + * Returns the private NodeTree object of the data-block, if it has one. + */ +struct bNodeTree *ntreeFromID(struct ID *id); + +void ntreeFreeLocalTree(struct bNodeTree *ntree); + +/** + * Check recursively if a node tree contains another. + */ +bool ntreeContainsTree(const struct bNodeTree *tree_to_search_in, + const struct bNodeTree *tree_to_search_for); + +void ntreeUpdateAllUsers(struct Main *main, struct ID *id); + +/** + * XXX: old trees handle output flags automatically based on special output + * node types and last active selection. + * New tree types have a per-output socket flag to indicate the final output to use explicitly. + */ +void ntreeSetOutput(struct bNodeTree *ntree); + +/** + * Returns localized tree for execution in threads. + */ +struct bNodeTree *ntreeLocalize(struct bNodeTree *ntree); + +/** + * This is only direct data, tree itself should have been written. + */ +void ntreeBlendWrite(struct BlendWriter *writer, struct bNodeTree *ntree); + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Generic API, Nodes + * \{ */ + +struct bNodeType *nodeTypeFind(const char *idname); +const char *nodeTypeFindAlias(const char *idname); +void nodeRegisterType(struct bNodeType *ntype); +void nodeUnregisterType(struct bNodeType *ntype); +void nodeRegisterAlias(struct bNodeType *nt, const char *alias); +struct GHashIterator *nodeTypeGetIterator(void); + +/* Helper macros for iterating over node types. */ +#define NODE_TYPES_BEGIN(ntype) \ + { \ + GHashIterator *__node_type_iter__ = nodeTypeGetIterator(); \ + for (; !BLI_ghashIterator_done(__node_type_iter__); \ + BLI_ghashIterator_step(__node_type_iter__)) { \ + bNodeType *ntype = (bNodeType *)BLI_ghashIterator_getValue(__node_type_iter__); + +#define NODE_TYPES_END \ + } \ + BLI_ghashIterator_free(__node_type_iter__); \ + } \ + ((void)0) + +struct bNodeSocketType *nodeSocketTypeFind(const char *idname); +void nodeRegisterSocketType(struct bNodeSocketType *stype); +void nodeUnregisterSocketType(struct bNodeSocketType *stype); +bool nodeSocketIsRegistered(const struct bNodeSocket *sock); +struct GHashIterator *nodeSocketTypeGetIterator(void); +const char *nodeSocketTypeLabel(const bNodeSocketType *stype); + +const char *nodeStaticSocketType(int type, int subtype); +const char *nodeStaticSocketInterfaceTypeNew(int type, int subtype); +const char *nodeStaticSocketLabel(int type, int subtype); + +/* Helper macros for iterating over node types. */ +#define NODE_SOCKET_TYPES_BEGIN(stype) \ + { \ + GHashIterator *__node_socket_type_iter__ = nodeSocketTypeGetIterator(); \ + for (; !BLI_ghashIterator_done(__node_socket_type_iter__); \ + BLI_ghashIterator_step(__node_socket_type_iter__)) \ + { \ + bNodeSocketType *stype = (bNodeSocketType *)BLI_ghashIterator_getValue( \ + __node_socket_type_iter__); + +#define NODE_SOCKET_TYPES_END \ + } \ + BLI_ghashIterator_free(__node_socket_type_iter__); \ + } \ + ((void)0) + +struct bNodeSocket *nodeFindSocket(const struct bNode *node, + eNodeSocketInOut in_out, + const char *identifier); +struct bNodeSocket *nodeAddSocket(struct bNodeTree *ntree, + struct bNode *node, + eNodeSocketInOut in_out, + const char *idname, + const char *identifier, + const char *name); +struct bNodeSocket *nodeAddStaticSocket(struct bNodeTree *ntree, + struct bNode *node, + eNodeSocketInOut in_out, + int type, + int subtype, + const char *identifier, + const char *name); +void nodeRemoveSocket(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock); + +void nodeModifySocketTypeStatic( + struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock, int type, int subtype); + +struct bNode *nodeAddNode(const struct bContext *C, struct bNodeTree *ntree, const char *idname); +struct bNode *nodeAddStaticNode(const struct bContext *C, struct bNodeTree *ntree, int type); + +/** + * Find the first available, non-duplicate name for a given node. + */ +void nodeUniqueName(struct bNodeTree *ntree, struct bNode *node); +/** + * Create a new unique integer identifier for the node. Also set the node's + * index in the tree, which is an eagerly maintained cache. + */ +void nodeUniqueID(struct bNodeTree *ntree, struct bNode *node); + +/** + * Delete node, associated animation data and ID user count. + */ +void nodeRemoveNode(struct Main *bmain, + struct bNodeTree *ntree, + struct bNode *node, + bool do_id_user); + +void nodeDimensionsGet(const struct bNode *node, float *r_width, float *r_height); +void nodeTagUpdateID(struct bNode *node); +void nodeInternalLinks(struct bNode *node, struct bNodeLink **r_links, int *r_len); + +/** + * Also used via RNA API, so we check for proper input output direction. + */ +struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, + struct bNode *fromnode, + struct bNodeSocket *fromsock, + struct bNode *tonode, + struct bNodeSocket *tosock); +void nodeRemLink(struct bNodeTree *ntree, struct bNodeLink *link); +void nodeRemSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock); + +bool nodeLinkIsHidden(const struct bNodeLink *link); + +void nodeAttachNode(struct bNodeTree *ntree, struct bNode *node, struct bNode *parent); +void nodeDetachNode(struct bNodeTree *ntree, struct bNode *node); + +/** + * Same as above but expects that the socket definitely is in the node tree. + */ +void nodeFindNode(struct bNodeTree *ntree, + struct bNodeSocket *sock, + struct bNode **r_node, + int *r_sockindex); +/** + * Finds a node based on its name. + */ +struct bNode *nodeFindNodebyName(struct bNodeTree *ntree, const char *name); +/** + * Finds a node based on given socket and returns true on success. + */ +bool nodeFindNodeTry(struct bNodeTree *ntree, + struct bNodeSocket *sock, + struct bNode **r_node, + int *r_sockindex); + +bool nodeIsParentAndChild(const bNode *parent, const bNode *child); + +int nodeCountSocketLinks(const struct bNodeTree *ntree, const struct bNodeSocket *sock); + +void nodeSetSelected(struct bNode *node, bool select); +/** + * Two active flags, ID nodes have special flag for buttons display. + */ +void nodeSetActive(struct bNodeTree *ntree, struct bNode *node); +struct bNode *nodeGetActive(struct bNodeTree *ntree); +void nodeClearActive(struct bNodeTree *ntree); +/** + * Two active flags, ID nodes have special flag for buttons display. + */ +struct bNode *nodeGetActiveTexture(struct bNodeTree *ntree); + +int nodeSocketLinkLimit(const struct bNodeSocket *sock); + +/** + * Node Instance Hash. + */ +typedef struct bNodeInstanceHash { + /** XXX should be made a direct member, #GHash allocation needs to support it */ + GHash *ghash; +} bNodeInstanceHash; + +typedef void (*bNodeInstanceValueFP)(void *value); + +/** + * Magic number for initial hash key. + */ +extern const bNodeInstanceKey NODE_INSTANCE_KEY_BASE; +extern const bNodeInstanceKey NODE_INSTANCE_KEY_NONE; + +bNodeInstanceKey BKE_node_instance_key(bNodeInstanceKey parent_key, + const struct bNodeTree *ntree, + const struct bNode *node); + +bNodeInstanceHash *BKE_node_instance_hash_new(const char *info); +void BKE_node_instance_hash_free(bNodeInstanceHash *hash, bNodeInstanceValueFP valfreefp); +void BKE_node_instance_hash_insert(bNodeInstanceHash *hash, bNodeInstanceKey key, void *value); +void *BKE_node_instance_hash_lookup(bNodeInstanceHash *hash, bNodeInstanceKey key); +int BKE_node_instance_hash_remove(bNodeInstanceHash *hash, + bNodeInstanceKey key, + bNodeInstanceValueFP valfreefp); +void BKE_node_instance_hash_clear(bNodeInstanceHash *hash, bNodeInstanceValueFP valfreefp); +void *BKE_node_instance_hash_pop(bNodeInstanceHash *hash, bNodeInstanceKey key); +int BKE_node_instance_hash_haskey(bNodeInstanceHash *hash, bNodeInstanceKey key); +int BKE_node_instance_hash_size(bNodeInstanceHash *hash); + +void BKE_node_instance_hash_clear_tags(bNodeInstanceHash *hash); +void BKE_node_instance_hash_tag(bNodeInstanceHash *hash, void *value); +bool BKE_node_instance_hash_tag_key(bNodeInstanceHash *hash, bNodeInstanceKey key); +void BKE_node_instance_hash_remove_untagged(bNodeInstanceHash *hash, + bNodeInstanceValueFP valfreefp); + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Node Type Access + * \{ */ + +bool nodeGroupPoll(const struct bNodeTree *nodetree, + const struct bNodeTree *grouptree, + const char **r_disabled_hint); + +void node_type_base_custom(struct bNodeType *ntype, + const char *idname, + const char *name, + const char *enum_name, + short nclass); + +/** + * \warning Nodes defining a storage type _must_ allocate this for new nodes. + * Otherwise nodes will reload as undefined (#46619). + */ +void node_type_storage(struct bNodeType *ntype, + const char *storagename, + void (*freefunc)(struct bNode *node), + void (*copyfunc)(struct bNodeTree *dest_ntree, + struct bNode *dest_node, + const struct bNode *src_node)); + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Common Node Types + * \{ */ + +#define NODE_UNDEFINED -2 /* node type is not registered */ +#define NODE_CUSTOM -1 /* for dynamically registered custom types */ +#define NODE_GROUP 2 +// #define NODE_FORLOOP 3 /* deprecated */ +// #define NODE_WHILELOOP 4 /* deprecated */ +#define NODE_FRAME 5 +#define NODE_REROUTE 6 +#define NODE_GROUP_INPUT 7 +#define NODE_GROUP_OUTPUT 8 +#define NODE_CUSTOM_GROUP 9 + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Node Tree Iterator + * + * Utility macro for visiting every node tree in the library data, + * including local bNodeTree blocks in other IDs. + * This avoids the need for callback functions and allows executing code + * in a single inner code block. + * + * Variables: + * + * - nodetree: + * The actual bNodeTree data block. + * Check `nodetree->idname` or `nodetree->typeinfo` to use only specific types. + * + * - id: + * The owner of the bNodeTree data block. + * Same as nodetree if it's a linkable node tree from the library. + * + * Examples: + * + * \code{.c} + * FOREACH_NODETREE_BEGIN(bmain, nodetree, id) { + * if (id == nodetree) + * printf("This is a linkable node tree"); + * } FOREACH_NODETREE_END; + * + * FOREACH_NODETREE_BEGIN(bmain, nodetree, id) { + * if (nodetree->idname == "ShaderNodeTree") + * printf("This is a shader node tree); + * if (GS(id) == ID_MA) + * printf(" and it's owned by a material"); + * } FOREACH_NODETREE_END; + * \endcode + * + * \{ */ + +/* should be an opaque type, only for internal use by BKE_node_tree_iter_*** */ +struct NodeTreeIterStore { + bNodeTree *ngroup; + Scene *scene; + struct Material *mat; + Tex *tex; + struct Light *light; + struct World *world; + struct FreestyleLineStyle *linestyle; +}; + +void BKE_node_tree_iter_init(struct NodeTreeIterStore *ntreeiter, struct Main *bmain); +bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter, + struct bNodeTree **r_nodetree, + struct ID **r_id); + +#define FOREACH_NODETREE_BEGIN(bmain, _nodetree, _id) \ + { \ + struct NodeTreeIterStore _nstore; \ + bNodeTree *_nodetree; \ + ID *_id; \ + /* avoid compiler warning about unused variables */ \ + BKE_node_tree_iter_init(&_nstore, bmain); \ + while (BKE_node_tree_iter_step(&_nstore, &_nodetree, &_id) == true) { \ + if (_nodetree) { + +#define FOREACH_NODETREE_END \ + } \ + } \ + } \ + ((void)0) + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Node Tree + */ + +void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, int layer_index); + +/* -------------------------------------------------------------------- */ +/** \name Shader Nodes + * \{ */ + +/* NOTE: types are needed to restore callbacks, don't change values. */ + +// #define SH_NODE_MATERIAL 100 +#define SH_NODE_RGB 101 +#define SH_NODE_VALUE 102 +#define SH_NODE_MIX_RGB_LEGACY 103 +#define SH_NODE_VALTORGB 104 +#define SH_NODE_RGBTOBW 105 +#define SH_NODE_SHADERTORGB 106 +// #define SH_NODE_TEXTURE 106 +#define SH_NODE_NORMAL 107 +// #define SH_NODE_GEOMETRY 108 +#define SH_NODE_MAPPING 109 +#define SH_NODE_CURVE_VEC 110 +#define SH_NODE_CURVE_RGB 111 +#define SH_NODE_CAMERA 114 +#define SH_NODE_MATH 115 +#define SH_NODE_VECTOR_MATH 116 +#define SH_NODE_SQUEEZE 117 +// #define SH_NODE_MATERIAL_EXT 118 +#define SH_NODE_INVERT 119 +#define SH_NODE_SEPRGB_LEGACY 120 +#define SH_NODE_COMBRGB_LEGACY 121 +#define SH_NODE_HUE_SAT 122 + +#define SH_NODE_OUTPUT_MATERIAL 124 +#define SH_NODE_OUTPUT_WORLD 125 +#define SH_NODE_OUTPUT_LIGHT 126 +#define SH_NODE_FRESNEL 127 +#define SH_NODE_MIX_SHADER 128 +#define SH_NODE_ATTRIBUTE 129 +#define SH_NODE_BACKGROUND 130 +#define SH_NODE_BSDF_GLOSSY 131 +#define SH_NODE_BSDF_DIFFUSE 132 +#define SH_NODE_BSDF_GLOSSY_LEGACY 133 +#define SH_NODE_BSDF_GLASS 134 +#define SH_NODE_BSDF_TRANSLUCENT 137 +#define SH_NODE_BSDF_TRANSPARENT 138 +#define SH_NODE_BSDF_SHEEN 139 +#define SH_NODE_EMISSION 140 +#define SH_NODE_NEW_GEOMETRY 141 +#define SH_NODE_LIGHT_PATH 142 +#define SH_NODE_TEX_IMAGE 143 +#define SH_NODE_TEX_SKY 145 +#define SH_NODE_TEX_GRADIENT 146 +#define SH_NODE_TEX_VORONOI 147 +#define SH_NODE_TEX_MAGIC 148 +#define SH_NODE_TEX_WAVE 149 +#define SH_NODE_TEX_NOISE 150 +#define SH_NODE_TEX_MUSGRAVE_DEPRECATED 152 +#define SH_NODE_TEX_COORD 155 +#define SH_NODE_ADD_SHADER 156 +#define SH_NODE_TEX_ENVIRONMENT 157 +// #define SH_NODE_OUTPUT_TEXTURE 158 +#define SH_NODE_HOLDOUT 159 +#define SH_NODE_LAYER_WEIGHT 160 +#define SH_NODE_VOLUME_ABSORPTION 161 +#define SH_NODE_VOLUME_SCATTER 162 +#define SH_NODE_GAMMA 163 +#define SH_NODE_TEX_CHECKER 164 +#define SH_NODE_BRIGHTCONTRAST 165 +#define SH_NODE_LIGHT_FALLOFF 166 +#define SH_NODE_OBJECT_INFO 167 +#define SH_NODE_PARTICLE_INFO 168 +#define SH_NODE_TEX_BRICK 169 +#define SH_NODE_BUMP 170 +#define SH_NODE_SCRIPT 171 +#define SH_NODE_AMBIENT_OCCLUSION 172 +#define SH_NODE_BSDF_REFRACTION 173 +#define SH_NODE_TANGENT 174 +#define SH_NODE_NORMAL_MAP 175 +#define SH_NODE_HAIR_INFO 176 +#define SH_NODE_SUBSURFACE_SCATTERING 177 +#define SH_NODE_WIREFRAME 178 +#define SH_NODE_BSDF_TOON 179 +#define SH_NODE_WAVELENGTH 180 +#define SH_NODE_BLACKBODY 181 +#define SH_NODE_VECT_TRANSFORM 182 +#define SH_NODE_SEPHSV_LEGACY 183 +#define SH_NODE_COMBHSV_LEGACY 184 +#define SH_NODE_BSDF_HAIR 185 +// #define SH_NODE_LAMP 186 +#define SH_NODE_UVMAP 187 +#define SH_NODE_SEPXYZ 188 +#define SH_NODE_COMBXYZ 189 +#define SH_NODE_OUTPUT_LINESTYLE 190 +#define SH_NODE_UVALONGSTROKE 191 +#define SH_NODE_TEX_POINTDENSITY 192 +#define SH_NODE_BSDF_PRINCIPLED 193 +#define SH_NODE_TEX_IES 194 +#define SH_NODE_EEVEE_SPECULAR 195 +#define SH_NODE_BEVEL 197 +#define SH_NODE_DISPLACEMENT 198 +#define SH_NODE_VECTOR_DISPLACEMENT 199 +#define SH_NODE_VOLUME_PRINCIPLED 200 +/* 201..700 occupied by other node types, continue from 701 */ +#define SH_NODE_BSDF_HAIR_PRINCIPLED 701 +#define SH_NODE_MAP_RANGE 702 +#define SH_NODE_CLAMP 703 +#define SH_NODE_TEX_WHITE_NOISE 704 +#define SH_NODE_VOLUME_INFO 705 +#define SH_NODE_VERTEX_COLOR 706 +#define SH_NODE_OUTPUT_AOV 707 +#define SH_NODE_VECTOR_ROTATE 708 +#define SH_NODE_CURVE_FLOAT 709 +#define SH_NODE_POINT_INFO 710 +#define SH_NODE_COMBINE_COLOR 711 +#define SH_NODE_SEPARATE_COLOR 712 +#define SH_NODE_MIX 713 + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Composite Nodes + * \{ */ + +/* output socket defines */ +#define RRES_OUT_IMAGE 0 +#define RRES_OUT_ALPHA 1 + +/* NOTE: types are needed to restore callbacks, don't change values. */ +#define CMP_NODE_VIEWER 201 +#define CMP_NODE_RGB 202 +#define CMP_NODE_VALUE 203 +#define CMP_NODE_MIX_RGB 204 +#define CMP_NODE_VALTORGB 205 +#define CMP_NODE_RGBTOBW 206 +#define CMP_NODE_NORMAL 207 +#define CMP_NODE_CURVE_VEC 208 +#define CMP_NODE_CURVE_RGB 209 +#define CMP_NODE_ALPHAOVER 210 +#define CMP_NODE_BLUR 211 +#define CMP_NODE_FILTER 212 +#define CMP_NODE_MAP_VALUE 213 +#define CMP_NODE_TIME 214 +#define CMP_NODE_VECBLUR 215 +#define CMP_NODE_SEPRGBA_LEGACY 216 +#define CMP_NODE_SEPHSVA_LEGACY 217 +#define CMP_NODE_SETALPHA 218 +#define CMP_NODE_HUE_SAT 219 +#define CMP_NODE_IMAGE 220 +#define CMP_NODE_R_LAYERS 221 +#define CMP_NODE_COMPOSITE 222 +#define CMP_NODE_OUTPUT_FILE 223 +#define CMP_NODE_TEXTURE 224 +#define CMP_NODE_TRANSLATE 225 +#define CMP_NODE_ZCOMBINE 226 +#define CMP_NODE_COMBRGBA_LEGACY 227 +#define CMP_NODE_DILATEERODE 228 +#define CMP_NODE_ROTATE 229 +#define CMP_NODE_SCALE 230 +#define CMP_NODE_SEPYCCA_LEGACY 231 +#define CMP_NODE_COMBYCCA_LEGACY 232 +#define CMP_NODE_SEPYUVA_LEGACY 233 +#define CMP_NODE_COMBYUVA_LEGACY 234 +#define CMP_NODE_DIFF_MATTE 235 +#define CMP_NODE_COLOR_SPILL 236 +#define CMP_NODE_CHROMA_MATTE 237 +#define CMP_NODE_CHANNEL_MATTE 238 +#define CMP_NODE_FLIP 239 +/* Split viewer node is now a regular split node: CMP_NODE_SPLIT. */ +#define CMP_NODE_SPLITVIEWER__DEPRECATED 240 +// #define CMP_NODE_INDEX_MASK 241 +#define CMP_NODE_MAP_UV 242 +#define CMP_NODE_ID_MASK 243 +#define CMP_NODE_DEFOCUS 244 +#define CMP_NODE_DISPLACE 245 +#define CMP_NODE_COMBHSVA_LEGACY 246 +#define CMP_NODE_MATH 247 +#define CMP_NODE_LUMA_MATTE 248 +#define CMP_NODE_BRIGHTCONTRAST 249 +#define CMP_NODE_GAMMA 250 +#define CMP_NODE_INVERT 251 +#define CMP_NODE_NORMALIZE 252 +#define CMP_NODE_CROP 253 +#define CMP_NODE_DBLUR 254 +#define CMP_NODE_BILATERALBLUR 255 +#define CMP_NODE_PREMULKEY 256 +#define CMP_NODE_DIST_MATTE 257 +#define CMP_NODE_VIEW_LEVELS 258 +#define CMP_NODE_COLOR_MATTE 259 +#define CMP_NODE_COLORBALANCE 260 +#define CMP_NODE_HUECORRECT 261 +#define CMP_NODE_MOVIECLIP 262 +#define CMP_NODE_STABILIZE2D 263 +#define CMP_NODE_TRANSFORM 264 +#define CMP_NODE_MOVIEDISTORTION 265 +#define CMP_NODE_DOUBLEEDGEMASK 266 +#define CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED \ + 267 /* DEPRECATED multi file node has been merged into regular CMP_NODE_OUTPUT_FILE */ +#define CMP_NODE_MASK 268 +#define CMP_NODE_KEYINGSCREEN 269 +#define CMP_NODE_KEYING 270 +#define CMP_NODE_TRACKPOS 271 +#define CMP_NODE_INPAINT 272 +#define CMP_NODE_DESPECKLE 273 +#define CMP_NODE_ANTIALIASING 274 +#define CMP_NODE_KUWAHARA 275 +#define CMP_NODE_SPLIT 276 + +#define CMP_NODE_GLARE 301 +#define CMP_NODE_TONEMAP 302 +#define CMP_NODE_LENSDIST 303 +#define CMP_NODE_SUNBEAMS 304 + +#define CMP_NODE_COLORCORRECTION 312 +#define CMP_NODE_MASK_BOX 313 +#define CMP_NODE_MASK_ELLIPSE 314 +#define CMP_NODE_BOKEHIMAGE 315 +#define CMP_NODE_BOKEHBLUR 316 +#define CMP_NODE_SWITCH 317 +#define CMP_NODE_PIXELATE 318 + +#define CMP_NODE_MAP_RANGE 319 +#define CMP_NODE_PLANETRACKDEFORM 320 +#define CMP_NODE_CORNERPIN 321 +#define CMP_NODE_SWITCH_VIEW 322 +#define CMP_NODE_CRYPTOMATTE_LEGACY 323 +#define CMP_NODE_DENOISE 324 +#define CMP_NODE_EXPOSURE 325 +#define CMP_NODE_CRYPTOMATTE 326 +#define CMP_NODE_POSTERIZE 327 +#define CMP_NODE_CONVERT_COLOR_SPACE 328 +#define CMP_NODE_SCENE_TIME 329 +#define CMP_NODE_SEPARATE_XYZ 330 +#define CMP_NODE_COMBINE_XYZ 331 +#define CMP_NODE_COMBINE_COLOR 332 +#define CMP_NODE_SEPARATE_COLOR 333 + +/* channel toggles */ +#define CMP_CHAN_RGB 1 +#define CMP_CHAN_A 2 + +/* Default SMAA configuration values. */ +#define CMP_DEFAULT_SMAA_THRESHOLD 1.0f +#define CMP_DEFAULT_SMAA_CONTRAST_LIMIT 0.2f +#define CMP_DEFAULT_SMAA_CORNER_ROUNDING 0.25f + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Texture Nodes + * \{ */ + +#define TEX_NODE_OUTPUT 401 +#define TEX_NODE_CHECKER 402 +#define TEX_NODE_TEXTURE 403 +#define TEX_NODE_BRICKS 404 +#define TEX_NODE_MATH 405 +#define TEX_NODE_MIX_RGB 406 +#define TEX_NODE_RGBTOBW 407 +#define TEX_NODE_VALTORGB 408 +#define TEX_NODE_IMAGE 409 +#define TEX_NODE_CURVE_RGB 410 +#define TEX_NODE_INVERT 411 +#define TEX_NODE_HUE_SAT 412 +#define TEX_NODE_CURVE_TIME 413 +#define TEX_NODE_ROTATE 414 +#define TEX_NODE_VIEWER 415 +#define TEX_NODE_TRANSLATE 416 +#define TEX_NODE_COORD 417 +#define TEX_NODE_DISTANCE 418 +#define TEX_NODE_COMPOSE_LEGACY 419 +#define TEX_NODE_DECOMPOSE_LEGACY 420 +#define TEX_NODE_VALTONOR 421 +#define TEX_NODE_SCALE 422 +#define TEX_NODE_AT 423 +#define TEX_NODE_COMBINE_COLOR 424 +#define TEX_NODE_SEPARATE_COLOR 425 + +/* 501-599 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */ +#define TEX_NODE_PROC 500 +#define TEX_NODE_PROC_MAX 600 + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Geometry Nodes + * \{ */ + +#define GEO_NODE_TRIANGULATE 1000 +#define GEO_NODE_TRANSFORM_GEOMETRY 1002 +#define GEO_NODE_MESH_BOOLEAN 1003 +#define GEO_NODE_OBJECT_INFO 1007 +#define GEO_NODE_JOIN_GEOMETRY 1010 +#define GEO_NODE_COLLECTION_INFO 1023 +#define GEO_NODE_IS_VIEWPORT 1024 +#define GEO_NODE_SUBDIVIDE_MESH 1029 +#define GEO_NODE_MESH_PRIMITIVE_CUBE 1032 +#define GEO_NODE_MESH_PRIMITIVE_CIRCLE 1033 +#define GEO_NODE_MESH_PRIMITIVE_UV_SPHERE 1034 +#define GEO_NODE_MESH_PRIMITIVE_CYLINDER 1035 +#define GEO_NODE_MESH_PRIMITIVE_ICO_SPHERE 1036 +#define GEO_NODE_MESH_PRIMITIVE_CONE 1037 +#define GEO_NODE_MESH_PRIMITIVE_LINE 1038 +#define GEO_NODE_MESH_PRIMITIVE_GRID 1039 +#define GEO_NODE_BOUNDING_BOX 1042 +#define GEO_NODE_SWITCH 1043 +#define GEO_NODE_CURVE_TO_MESH 1045 +#define GEO_NODE_RESAMPLE_CURVE 1047 +#define GEO_NODE_INPUT_MATERIAL 1050 +#define GEO_NODE_REPLACE_MATERIAL 1051 +#define GEO_NODE_CURVE_LENGTH 1054 +#define GEO_NODE_CONVEX_HULL 1056 +#define GEO_NODE_SEPARATE_COMPONENTS 1059 +#define GEO_NODE_CURVE_PRIMITIVE_STAR 1062 +#define GEO_NODE_CURVE_PRIMITIVE_SPIRAL 1063 +#define GEO_NODE_CURVE_PRIMITIVE_QUADRATIC_BEZIER 1064 +#define GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT 1065 +#define GEO_NODE_CURVE_PRIMITIVE_CIRCLE 1066 +#define GEO_NODE_VIEWER 1067 +#define GEO_NODE_CURVE_PRIMITIVE_LINE 1068 +#define GEO_NODE_CURVE_PRIMITIVE_QUADRILATERAL 1070 +#define GEO_NODE_TRIM_CURVE 1071 +#define GEO_NODE_FILL_CURVE 1075 +#define GEO_NODE_INPUT_POSITION 1076 +#define GEO_NODE_SET_POSITION 1077 +#define GEO_NODE_INPUT_INDEX 1078 +#define GEO_NODE_INPUT_NORMAL 1079 +#define GEO_NODE_CAPTURE_ATTRIBUTE 1080 +#define GEO_NODE_MATERIAL_SELECTION 1081 +#define GEO_NODE_SET_MATERIAL 1082 +#define GEO_NODE_REALIZE_INSTANCES 1083 +#define GEO_NODE_ATTRIBUTE_STATISTIC 1084 +#define GEO_NODE_SAMPLE_CURVE 1085 +#define GEO_NODE_INPUT_TANGENT 1086 +#define GEO_NODE_STRING_JOIN 1087 +#define GEO_NODE_CURVE_SPLINE_PARAMETER 1088 +#define GEO_NODE_FILLET_CURVE 1089 +#define GEO_NODE_DISTRIBUTE_POINTS_ON_FACES 1090 +#define GEO_NODE_STRING_TO_CURVES 1091 +#define GEO_NODE_INSTANCE_ON_POINTS 1092 +#define GEO_NODE_MESH_TO_POINTS 1093 +#define GEO_NODE_POINTS_TO_VERTICES 1094 +#define GEO_NODE_REVERSE_CURVE 1095 +#define GEO_NODE_PROXIMITY 1096 +#define GEO_NODE_SUBDIVIDE_CURVE 1097 +#define GEO_NODE_INPUT_SPLINE_LENGTH 1098 +#define GEO_NODE_CURVE_SPLINE_TYPE 1099 +#define GEO_NODE_CURVE_SET_HANDLE_TYPE 1100 +#define GEO_NODE_POINTS_TO_VOLUME 1101 +#define GEO_NODE_CURVE_HANDLE_TYPE_SELECTION 1102 +#define GEO_NODE_DELETE_GEOMETRY 1103 +#define GEO_NODE_SEPARATE_GEOMETRY 1104 +#define GEO_NODE_INPUT_RADIUS 1105 +#define GEO_NODE_INPUT_CURVE_TILT 1106 +#define GEO_NODE_INPUT_CURVE_HANDLES 1107 +#define GEO_NODE_INPUT_FACE_SMOOTH 1108 +#define GEO_NODE_INPUT_SPLINE_RESOLUTION 1109 +#define GEO_NODE_INPUT_SPLINE_CYCLIC 1110 +#define GEO_NODE_SET_CURVE_RADIUS 1111 +#define GEO_NODE_SET_CURVE_TILT 1112 +#define GEO_NODE_SET_CURVE_HANDLES 1113 +#define GEO_NODE_SET_SHADE_SMOOTH 1114 +#define GEO_NODE_SET_SPLINE_RESOLUTION 1115 +#define GEO_NODE_SET_SPLINE_CYCLIC 1116 +#define GEO_NODE_SET_POINT_RADIUS 1117 +#define GEO_NODE_INPUT_MATERIAL_INDEX 1118 +#define GEO_NODE_SET_MATERIAL_INDEX 1119 +#define GEO_NODE_TRANSLATE_INSTANCES 1120 +#define GEO_NODE_SCALE_INSTANCES 1121 +#define GEO_NODE_ROTATE_INSTANCES 1122 +#define GEO_NODE_SPLIT_EDGES 1123 +#define GEO_NODE_MESH_TO_CURVE 1124 +#define GEO_NODE_TRANSFER_ATTRIBUTE_DEPRECATED 1125 +#define GEO_NODE_SUBDIVISION_SURFACE 1126 +#define GEO_NODE_CURVE_ENDPOINT_SELECTION 1127 +#define GEO_NODE_RAYCAST 1128 +#define GEO_NODE_CURVE_TO_POINTS 1130 +#define GEO_NODE_INSTANCES_TO_POINTS 1131 +#define GEO_NODE_IMAGE_TEXTURE 1132 +#define GEO_NODE_VOLUME_TO_MESH 1133 +#define GEO_NODE_INPUT_ID 1134 +#define GEO_NODE_SET_ID 1135 +#define GEO_NODE_ATTRIBUTE_DOMAIN_SIZE 1136 +#define GEO_NODE_DUAL_MESH 1137 +#define GEO_NODE_INPUT_MESH_EDGE_VERTICES 1138 +#define GEO_NODE_INPUT_MESH_FACE_AREA 1139 +#define GEO_NODE_INPUT_MESH_FACE_NEIGHBORS 1140 +#define GEO_NODE_INPUT_MESH_VERTEX_NEIGHBORS 1141 +#define GEO_NODE_GEOMETRY_TO_INSTANCE 1142 +#define GEO_NODE_INPUT_MESH_EDGE_NEIGHBORS 1143 +#define GEO_NODE_INPUT_MESH_ISLAND 1144 +#define GEO_NODE_INPUT_SCENE_TIME 1145 +#define GEO_NODE_ACCUMULATE_FIELD 1146 +#define GEO_NODE_INPUT_MESH_EDGE_ANGLE 1147 +#define GEO_NODE_EVALUATE_AT_INDEX 1148 +#define GEO_NODE_CURVE_PRIMITIVE_ARC 1149 +#define GEO_NODE_FLIP_FACES 1150 +#define GEO_NODE_SCALE_ELEMENTS 1151 +#define GEO_NODE_EXTRUDE_MESH 1152 +#define GEO_NODE_MERGE_BY_DISTANCE 1153 +#define GEO_NODE_DUPLICATE_ELEMENTS 1154 +#define GEO_NODE_INPUT_MESH_FACE_IS_PLANAR 1155 +#define GEO_NODE_STORE_NAMED_ATTRIBUTE 1156 +#define GEO_NODE_INPUT_NAMED_ATTRIBUTE 1157 +#define GEO_NODE_REMOVE_ATTRIBUTE 1158 +#define GEO_NODE_INPUT_INSTANCE_ROTATION 1159 +#define GEO_NODE_INPUT_INSTANCE_SCALE 1160 +#define GEO_NODE_VOLUME_CUBE 1161 +#define GEO_NODE_POINTS 1162 +#define GEO_NODE_EVALUATE_ON_DOMAIN 1163 +#define GEO_NODE_MESH_TO_VOLUME 1164 +#define GEO_NODE_UV_UNWRAP 1165 +#define GEO_NODE_UV_PACK_ISLANDS 1166 +#define GEO_NODE_DEFORM_CURVES_ON_SURFACE 1167 +#define GEO_NODE_INPUT_SHORTEST_EDGE_PATHS 1168 +#define GEO_NODE_EDGE_PATHS_TO_CURVES 1169 +#define GEO_NODE_EDGE_PATHS_TO_SELECTION 1170 +#define GEO_NODE_MESH_FACE_GROUP_BOUNDARIES 1171 +#define GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME 1172 +#define GEO_NODE_SELF_OBJECT 1173 +#define GEO_NODE_SAMPLE_INDEX 1174 +#define GEO_NODE_SAMPLE_NEAREST 1175 +#define GEO_NODE_SAMPLE_NEAREST_SURFACE 1176 +#define GEO_NODE_OFFSET_POINT_IN_CURVE 1177 +#define GEO_NODE_CURVE_TOPOLOGY_CURVE_OF_POINT 1178 +#define GEO_NODE_CURVE_TOPOLOGY_POINTS_OF_CURVE 1179 +#define GEO_NODE_MESH_TOPOLOGY_OFFSET_CORNER_IN_FACE 1180 +#define GEO_NODE_MESH_TOPOLOGY_CORNERS_OF_FACE 1181 +#define GEO_NODE_MESH_TOPOLOGY_CORNERS_OF_VERTEX 1182 +#define GEO_NODE_MESH_TOPOLOGY_EDGES_OF_CORNER 1183 +#define GEO_NODE_MESH_TOPOLOGY_EDGES_OF_VERTEX 1184 +#define GEO_NODE_MESH_TOPOLOGY_FACE_OF_CORNER 1185 +#define GEO_NODE_MESH_TOPOLOGY_VERTEX_OF_CORNER 1186 +#define GEO_NODE_SAMPLE_UV_SURFACE 1187 +#define GEO_NODE_SET_CURVE_NORMAL 1188 +#define GEO_NODE_IMAGE_INFO 1189 +#define GEO_NODE_BLUR_ATTRIBUTE 1190 +#define GEO_NODE_IMAGE 1191 +#define GEO_NODE_INTERPOLATE_CURVES 1192 +#define GEO_NODE_EDGES_TO_FACE_GROUPS 1193 +// #define GEO_NODE_POINTS_TO_SDF_VOLUME 1194 +// #define GEO_NODE_MESH_TO_SDF_VOLUME 1195 +// #define GEO_NODE_SDF_VOLUME_SPHERE 1196 +// #define GEO_NODE_MEAN_FILTER_SDF_VOLUME 1197 +// #define GEO_NODE_OFFSET_SDF_VOLUME 1198 +#define GEO_NODE_INDEX_OF_NEAREST 1199 +/* Function nodes use the range starting at 1200. */ +#define GEO_NODE_SIMULATION_INPUT 2100 +#define GEO_NODE_SIMULATION_OUTPUT 2101 +// #define GEO_NODE_INPUT_SIGNED_DISTANCE 2102 +// #define GEO_NODE_SAMPLE_VOLUME 2103 +#define GEO_NODE_MESH_TOPOLOGY_CORNERS_OF_EDGE 2104 +/* Leaving out two indices to avoid crashes with files that were created during the development of + * the repeat zone. */ +#define GEO_NODE_REPEAT_INPUT 2107 +#define GEO_NODE_REPEAT_OUTPUT 2108 +#define GEO_NODE_TOOL_SELECTION 2109 +#define GEO_NODE_TOOL_SET_SELECTION 2110 +#define GEO_NODE_TOOL_3D_CURSOR 2111 +#define GEO_NODE_TOOL_FACE_SET 2112 +#define GEO_NODE_TOOL_SET_FACE_SET 2113 +#define GEO_NODE_POINTS_TO_CURVES 2114 +#define GEO_NODE_INPUT_EDGE_SMOOTH 2115 +#define GEO_NODE_SPLIT_TO_INSTANCES 2116 +#define GEO_NODE_INPUT_NAMED_LAYER_SELECTION 2117 +#define GEO_NODE_INDEX_SWITCH 2118 +#define GEO_NODE_INPUT_ACTIVE_CAMERA 2119 +#define GEO_NODE_BAKE 2120 +#define GEO_NODE_GET_NAMED_GRID 2121 +#define GEO_NODE_STORE_NAMED_GRID 2122 +#define GEO_NODE_SORT_ELEMENTS 2123 +#define GEO_NODE_MENU_SWITCH 2124 + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Function Nodes + * \{ */ + +#define FN_NODE_BOOLEAN_MATH 1200 +#define FN_NODE_COMPARE 1202 +#define FN_NODE_LEGACY_RANDOM_FLOAT 1206 +#define FN_NODE_INPUT_VECTOR 1207 +#define FN_NODE_INPUT_STRING 1208 +#define FN_NODE_FLOAT_TO_INT 1209 +#define FN_NODE_VALUE_TO_STRING 1210 +#define FN_NODE_STRING_LENGTH 1211 +#define FN_NODE_SLICE_STRING 1212 +#define FN_NODE_INPUT_SPECIAL_CHARACTERS 1213 +#define FN_NODE_RANDOM_VALUE 1214 +#define FN_NODE_ROTATE_EULER 1215 +#define FN_NODE_ALIGN_EULER_TO_VECTOR 1216 +#define FN_NODE_INPUT_COLOR 1217 +#define FN_NODE_REPLACE_STRING 1218 +#define FN_NODE_INPUT_BOOL 1219 +#define FN_NODE_INPUT_INT 1220 +#define FN_NODE_SEPARATE_COLOR 1221 +#define FN_NODE_COMBINE_COLOR 1222 +#define FN_NODE_AXIS_ANGLE_TO_ROTATION 1223 +#define FN_NODE_EULER_TO_ROTATION 1224 +#define FN_NODE_QUATERNION_TO_ROTATION 1225 +#define FN_NODE_ROTATION_TO_AXIS_ANGLE 1226 +#define FN_NODE_ROTATION_TO_EULER 1227 +#define FN_NODE_ROTATION_TO_QUATERNION 1228 +#define FN_NODE_ROTATE_VECTOR 1229 +#define FN_NODE_ROTATE_ROTATION 1230 +#define FN_NODE_INVERT_ROTATION 1231 + +/** \} */ + +void BKE_node_system_init(void); +void BKE_node_system_exit(void); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenkernel/BKE_node.hh b/source/blender/blenkernel/BKE_node.hh index c41e03b012c..6b3ce114a83 100644 --- a/source/blender/blenkernel/BKE_node.hh +++ b/source/blender/blenkernel/BKE_node.hh @@ -15,6 +15,7 @@ #include "DNA_listBase.h" +#include "BKE_node.h" #include "BKE_volume_enums.hh" /* for FOREACH_NODETREE_BEGIN */ @@ -25,1358 +26,6 @@ #include "BLI_map.hh" #include "BLI_string_ref.hh" -/* not very important, but the stack solver likes to know a maximum */ -#define MAX_SOCKET 512 - -struct BlendDataReader; -struct BlendLibReader; -struct BlendWriter; -struct FreestyleLineStyle; -struct GPUMaterial; -struct GPUNodeStack; -struct ID; -struct ImBuf; -struct Light; -struct Main; -struct Material; -struct PointerRNA; -struct Scene; -struct SpaceNode; -struct Tex; -struct World; -struct bContext; -struct bNode; -struct bNodeExecContext; -struct bNodeExecData; -struct bNodeInstanceHash; -struct bNodeLink; -struct bNodeSocket; -struct bNodeStack; -struct bNodeTree; -struct bNodeTreeExec; -struct bNodeTreeType; -struct uiLayout; - -/* -------------------------------------------------------------------- */ -/** \name Node Type Definitions - * \{ */ - -/** - * \brief Compact definition of a node socket. - * - * Can be used to quickly define a list of static sockets for a node, - * which are added to each new node of that type. - * - * \deprecated This struct is used by C nodes to define templates as simple - * static struct lists. These are converted to the new template collections - * in RNA types automatically. - */ -typedef struct bNodeSocketTemplate { - int type; - char name[64]; /* MAX_NAME */ - float val1, val2, val3, val4; /* default alloc value for inputs */ - float min, max; - int subtype; /* would use PropertySubType but this is a bad level include to use RNA */ - int flag; - - /* after this line is used internal only */ - struct bNodeSocket *sock; /* used to hold verified socket */ - char identifier[64]; /* generated from name */ -} bNodeSocketTemplate; - -/* Use `void *` for callbacks that require C++. This is rather ugly, but works well for now. This - * would not be necessary if we would use bNodeSocketType and bNodeType only in C++ code. - * However, achieving this requires quite a few changes currently. */ -#ifdef __cplusplus -namespace blender { -class CPPType; -namespace nodes { -class DNode; -class NodeMultiFunctionBuilder; -class GeoNodeExecParams; -class NodeDeclaration; -class NodeDeclarationBuilder; -class GatherAddNodeSearchParams; -class GatherLinkSearchOpParams; -struct NodeExtraInfoParams; -} // namespace nodes -namespace realtime_compositor { -class Context; -class NodeOperation; -class ShaderNode; -} // namespace realtime_compositor -} // namespace blender - -using CPPTypeHandle = blender::CPPType; -using NodeMultiFunctionBuildFunction = void (*)(blender::nodes::NodeMultiFunctionBuilder &builder); -using NodeGeometryExecFunction = void (*)(blender::nodes::GeoNodeExecParams params); -using NodeDeclareFunction = void (*)(blender::nodes::NodeDeclarationBuilder &builder); -using NodeDeclareDynamicFunction = void (*)(const bNodeTree &tree, - const bNode &node, - blender::nodes::NodeDeclarationBuilder &builder); -using SocketGetCPPValueFunction = void (*)(const void *socket_value, void *r_value); -using SocketGetGeometryNodesCPPValueFunction = void (*)(const void *socket_value, void *r_value); - -/* Adds socket link operations that are specific to this node type. */ -using NodeGatherSocketLinkOperationsFunction = - void (*)(blender::nodes::GatherLinkSearchOpParams ¶ms); - -/* Adds node add menu operations that are specific to this node type. */ -using NodeGatherAddOperationsFunction = - void (*)(blender::nodes::GatherAddNodeSearchParams ¶ms); - -using NodeGetCompositorOperationFunction = blender::realtime_compositor::NodeOperation - *(*)(blender::realtime_compositor::Context &context, blender::nodes::DNode node); -using NodeGetCompositorShaderNodeFunction = - blender::realtime_compositor::ShaderNode *(*)(blender::nodes::DNode node); -using NodeExtraInfoFunction = void (*)(blender::nodes::NodeExtraInfoParams ¶ms); - -#else -typedef void *NodeGetCompositorOperationFunction; -typedef void *NodeGetCompositorShaderNodeFunction; -typedef void *NodeMultiFunctionBuildFunction; -typedef void *NodeGeometryExecFunction; -typedef void *NodeDeclareFunction; -typedef void *NodeDeclareDynamicFunction; -typedef void *NodeGatherSocketLinkOperationsFunction; -typedef void *NodeGatherAddOperationsFunction; -typedef void *SocketGetCPPTypeFunction; -typedef void *SocketGetGeometryNodesCPPTypeFunction; -typedef void *SocketGetGeometryNodesCPPValueFunction; -typedef void *SocketGetCPPValueFunction; -typedef void *NodeExtraInfoFunction; -typedef struct CPPTypeHandle CPPTypeHandle; -#endif - -/** - * \brief Defines a socket type. - * - * Defines the appearance and behavior of a socket in the UI. - */ -typedef struct bNodeSocketType { - /** Identifier name. */ - char idname[64]; - /** Type label. */ - char label[64]; - /** Sub-type label. */ - char subtype_label[64]; - - void (*draw)(struct bContext *C, - struct uiLayout *layout, - struct PointerRNA *ptr, - struct PointerRNA *node_ptr, - const char *text); - void (*draw_color)(struct bContext *C, - struct PointerRNA *ptr, - struct PointerRNA *node_ptr, - float *r_color); - void (*draw_color_simple)(const bNodeSocketType *socket_type, float *r_color); - - void (*interface_draw)(struct ID *id, - struct bNodeTreeInterfaceSocket *socket, - struct bContext *C, - struct uiLayout *layout); - void (*interface_init_socket)(struct ID *id, - const struct bNodeTreeInterfaceSocket *interface_socket, - struct bNode *node, - struct bNodeSocket *socket, - const char *data_path); - void (*interface_from_socket)(struct ID *id, - struct bNodeTreeInterfaceSocket *interface_socket, - const struct bNode *node, - const struct bNodeSocket *socket); - - /* RNA integration */ - ExtensionRNA ext_socket; - ExtensionRNA ext_interface; - - /* for standard socket types in C */ - int type, subtype; - - /* When set, bNodeSocket->limit does not have any effect anymore. */ - bool use_link_limits_of_type; - int input_link_limit; - int output_link_limit; - - /* Callback to free the socket type. */ - void (*free_self)(struct bNodeSocketType *stype); - - /* Return the CPPType of this socket. */ - const CPPTypeHandle *base_cpp_type; - /* Get the value of this socket in a generic way. */ - SocketGetCPPValueFunction get_base_cpp_value; - /* Get geometry nodes cpp type. */ - const CPPTypeHandle *geometry_nodes_cpp_type; - /* Get geometry nodes cpp value. */ - SocketGetGeometryNodesCPPValueFunction get_geometry_nodes_cpp_value; - /* Default value for this socket type. */ - const void *geometry_nodes_default_cpp_value; -} bNodeSocketType; - -typedef void *(*NodeInitExecFunction)(struct bNodeExecContext *context, - struct bNode *node, - bNodeInstanceKey key); -typedef void (*NodeFreeExecFunction)(void *nodedata); -typedef void (*NodeExecFunction)(void *data, - int thread, - struct bNode *, - struct bNodeExecData *execdata, - struct bNodeStack **in, - struct bNodeStack **out); -typedef int (*NodeGPUExecFunction)(struct GPUMaterial *mat, - struct bNode *node, - struct bNodeExecData *execdata, - struct GPUNodeStack *in, - struct GPUNodeStack *out); -typedef void (*NodeMaterialXFunction)(void *data, struct bNode *node, struct bNodeSocket *out); - -/** - * \brief Defines a node type. - * - * Initial attributes and constants for a node as well as callback functions - * implementing the node behavior. - */ -typedef struct bNodeType { - char idname[64]; /* identifier name */ - int type; - - char ui_name[64]; /* MAX_NAME */ - char ui_description[256]; - int ui_icon; - /** Should usually use the idname instead, but this enum type is still exposed in Python. */ - const char *enum_name_legacy; - - float width, minwidth, maxwidth; - float height, minheight, maxheight; - short nclass, flag; - - /* templates for static sockets */ - bNodeSocketTemplate *inputs, *outputs; - - char storagename[64]; /* struct name for DNA */ - - /* Draw the option buttons on the node */ - void (*draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr); - /* Additional parameters in the side panel */ - void (*draw_buttons_ex)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr); - - /* Additional drawing on backdrop */ - void (*draw_backdrop)( - struct SpaceNode *snode, struct ImBuf *backdrop, struct bNode *node, int x, int y); - - /** - * Optional custom label function for the node header. - * \note Used as a fallback when #bNode.label isn't set. - */ - void (*labelfunc)(const struct bNodeTree *ntree, - const struct bNode *node, - char *label, - int label_maxncpy); - - /** Optional override for node class, used for drawing node header. */ - int (*ui_class)(const struct bNode *node); - - /** Called when the node is updated in the editor. */ - void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node); - /** Check and update if internal ID data has changed. */ - void (*group_update_func)(struct bNodeTree *ntree, struct bNode *node); - - /** - * Initialize a new node instance of this type after creation. - * - * \note Assignments to `node->id` must not increment the user of the ID. - * This is handled by the caller of this callback. - */ - void (*initfunc)(struct bNodeTree *ntree, struct bNode *node); - /** - * Free the node instance. - * - * \note Access to `node->id` must be avoided in this function as this is called - * while freeing #Main, the state of this ID is undefined. - * Higher level logic to remove the node handles the user-count. - */ - void (*freefunc)(struct bNode *node); - /** Make a copy of the node instance. */ - void (*copyfunc)(struct bNodeTree *dest_ntree, - struct bNode *dest_node, - const struct bNode *src_node); - - /* Registerable API callback versions, called in addition to C callbacks */ - void (*initfunc_api)(const struct bContext *C, struct PointerRNA *ptr); - void (*freefunc_api)(struct PointerRNA *ptr); - void (*copyfunc_api)(struct PointerRNA *ptr, const struct bNode *src_node); - - /** - * An additional poll test for deciding whether nodes should be an option in search menus. - * Potentially more strict poll than #poll(), but doesn't have to check the same things. - */ - bool (*add_ui_poll)(const struct bContext *C); - - /** - * Can this node type be added to a node tree? - * \param r_disabled_hint: Hint to display in the UI when the poll fails. - * The callback can set this to a static string without having to - * null-check it (or without setting it to null if it's not used). - * The caller must pass a valid `const char **` and null-initialize it - * when it's not just a dummy, that is, if it actually wants to access - * the returned disabled-hint (null-check needed!). - */ - bool (*poll)(const struct bNodeType *ntype, - const struct bNodeTree *nodetree, - const char **r_disabled_hint); - /** - * Can this node be added to a node tree? - * \param r_disabled_hint: See `poll()`. - */ - bool (*poll_instance)(const struct bNode *node, - const struct bNodeTree *nodetree, - const char **r_disabled_hint); - - /* Optional handling of link insertion. Returns false if the link shouldn't be created. */ - bool (*insert_link)(struct bNodeTree *ntree, struct bNode *node, struct bNodeLink *link); - - void (*free_self)(struct bNodeType *ntype); - - /* **** execution callbacks **** */ - NodeInitExecFunction init_exec_fn; - NodeFreeExecFunction free_exec_fn; - NodeExecFunction exec_fn; - /* gpu */ - NodeGPUExecFunction gpu_fn; - /* MaterialX */ - NodeMaterialXFunction materialx_fn; - - /* Get an instance of this node's compositor operation. Freeing the instance is the - * responsibility of the caller. */ - NodeGetCompositorOperationFunction get_compositor_operation; - - /* Get an instance of this node's compositor shader node. Freeing the instance is the - * responsibility of the caller. */ - NodeGetCompositorShaderNodeFunction get_compositor_shader_node; - - /* A message to display in the node header for unsupported realtime compositor nodes. The message - * is assumed to be static and thus require no memory handling. This field is to be removed when - * all nodes are supported. */ - const char *realtime_compositor_unsupported_message; - - /* Build a multi-function for this node. */ - NodeMultiFunctionBuildFunction build_multi_function; - - /* Execute a geometry node. */ - NodeGeometryExecFunction geometry_node_execute; - - /** - * Declares which sockets and panels the node has. It has to be able to generate a declaration - * with and without a specific node context. If the declaration depends on the node, but the node - * is not provided, then the declaration should be generated as much as possible and everything - * that depends on the node context should be skipped. - */ - NodeDeclareFunction declare; - - /** - * Declaration of the node outside of any context. If the node declaration is never dependent on - * the node context, this declaration is also shared with the corresponding node instances. - * Otherwise, it mainly allows checking what sockets a node will have, without having to create - * the node. In this case, the static declaration is mostly just a hint, and does not have to - * match with the final node. - */ - NodeDeclarationHandle *static_declaration; - - /** - * Add to the list of search names and operations gathered by node link drag searching. - * Usually it isn't necessary to override the default behavior here, but a node type can have - * custom behavior here like adding custom search items. - */ - NodeGatherSocketLinkOperationsFunction gather_link_search_ops; - - /** Get extra information that is drawn next to the node. */ - NodeExtraInfoFunction get_extra_info; - - /** True when the node cannot be muted. */ - bool no_muting; - /** True when the node still works but it's usage is discouraged. */ - const char *deprecation_notice; - - /* RNA integration */ - ExtensionRNA rna_ext; -} bNodeType; - -/** #bNodeType.nclass (for add-menu and themes). */ -#define NODE_CLASS_INPUT 0 -#define NODE_CLASS_OUTPUT 1 -#define NODE_CLASS_OP_COLOR 3 -#define NODE_CLASS_OP_VECTOR 4 -#define NODE_CLASS_OP_FILTER 5 -#define NODE_CLASS_GROUP 6 -#define NODE_CLASS_CONVERTER 8 -#define NODE_CLASS_MATTE 9 -#define NODE_CLASS_DISTORT 10 -#define NODE_CLASS_PATTERN 12 -#define NODE_CLASS_TEXTURE 13 -#define NODE_CLASS_SCRIPT 32 -#define NODE_CLASS_INTERFACE 33 -#define NODE_CLASS_SHADER 40 -#define NODE_CLASS_GEOMETRY 41 -#define NODE_CLASS_ATTRIBUTE 42 -#define NODE_CLASS_LAYOUT 100 - -struct bNodeTreeExec; - -typedef void (*bNodeClassCallback)(void *calldata, int nclass, const char *name); -typedef struct bNodeTreeType { - int type; /* type identifier */ - char idname[64]; /* identifier name */ - - /* The ID name of group nodes for this type. */ - char group_idname[64]; - - char ui_name[64]; - char ui_description[256]; - int ui_icon; - - /* callbacks */ - /* Iteration over all node classes. */ - void (*foreach_nodeclass)(struct Scene *scene, void *calldata, bNodeClassCallback func); - /* Check visibility in the node editor */ - bool (*poll)(const struct bContext *C, struct bNodeTreeType *ntreetype); - /* Select a node tree from the context */ - void (*get_from_context)(const struct bContext *C, - struct bNodeTreeType *ntreetype, - struct bNodeTree **r_ntree, - struct ID **r_id, - struct ID **r_from); - - /* calls allowing threaded composite */ - void (*localize)(struct bNodeTree *localtree, struct bNodeTree *ntree); - void (*local_merge)(struct Main *bmain, struct bNodeTree *localtree, struct bNodeTree *ntree); - - /* Tree update. Overrides `nodetype->updatetreefunc`. */ - void (*update)(struct bNodeTree *ntree); - - bool (*validate_link)(eNodeSocketDatatype from, eNodeSocketDatatype to); - - void (*node_add_init)(struct bNodeTree *ntree, struct bNode *bnode); - - /* Check if the socket type is valid for this tree type. */ - bool (*valid_socket_type)(struct bNodeTreeType *ntreetype, struct bNodeSocketType *socket_type); - - /* RNA integration */ - ExtensionRNA rna_ext; -} bNodeTreeType; - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Generic API, Trees - * \{ */ - -struct bNodeTreeType *ntreeTypeFind(const char *idname); -void ntreeTypeAdd(struct bNodeTreeType *nt); -void ntreeTypeFreeLink(const struct bNodeTreeType *nt); -bool ntreeIsRegistered(const struct bNodeTree *ntree); -struct GHashIterator *ntreeTypeGetIterator(void); - -/* Helper macros for iterating over tree types. */ -#define NODE_TREE_TYPES_BEGIN(ntype) \ - { \ - GHashIterator *__node_tree_type_iter__ = ntreeTypeGetIterator(); \ - for (; !BLI_ghashIterator_done(__node_tree_type_iter__); \ - BLI_ghashIterator_step(__node_tree_type_iter__)) \ - { \ - bNodeTreeType *ntype = (bNodeTreeType *)BLI_ghashIterator_getValue(__node_tree_type_iter__); - -#define NODE_TREE_TYPES_END \ - } \ - BLI_ghashIterator_free(__node_tree_type_iter__); \ - } \ - (void)0 - -/** - * Try to initialize all type-info in a node tree. - * - * \note In general undefined type-info is a perfectly valid case, - * the type may just be registered later. - * In that case the update_typeinfo function will set type-info on registration - * and do necessary updates. - */ -void ntreeSetTypes(const struct bContext *C, struct bNodeTree *ntree); - -struct bNodeTree *ntreeAddTree(struct Main *bmain, const char *name, const char *idname); - -/** - * Free tree which is embedded into another data-block. - */ -void ntreeFreeEmbeddedTree(struct bNodeTree *ntree); - -/** - * Get address of potential node-tree pointer of given ID. - * - * \warning Using this function directly is potentially dangerous, if you don't know or are not - * sure, please use `ntreeFromID()` instead. - */ -struct bNodeTree **BKE_ntree_ptr_from_id(struct ID *id); - -/** - * Returns the private NodeTree object of the data-block, if it has one. - */ -struct bNodeTree *ntreeFromID(struct ID *id); - -void ntreeFreeLocalTree(struct bNodeTree *ntree); - -/** - * Check recursively if a node tree contains another. - */ -bool ntreeContainsTree(const struct bNodeTree *tree_to_search_in, - const struct bNodeTree *tree_to_search_for); - -void ntreeUpdateAllUsers(struct Main *main, struct ID *id); - -/** - * XXX: old trees handle output flags automatically based on special output - * node types and last active selection. - * New tree types have a per-output socket flag to indicate the final output to use explicitly. - */ -void ntreeSetOutput(struct bNodeTree *ntree); - -/** - * Returns localized tree for execution in threads. - */ -struct bNodeTree *ntreeLocalize(struct bNodeTree *ntree); - -/** - * This is only direct data, tree itself should have been written. - */ -void ntreeBlendWrite(struct BlendWriter *writer, struct bNodeTree *ntree); - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Generic API, Nodes - * \{ */ - -struct bNodeType *nodeTypeFind(const char *idname); -const char *nodeTypeFindAlias(const char *idname); -void nodeRegisterType(struct bNodeType *ntype); -void nodeUnregisterType(struct bNodeType *ntype); -void nodeRegisterAlias(struct bNodeType *nt, const char *alias); -struct GHashIterator *nodeTypeGetIterator(void); - -/* Helper macros for iterating over node types. */ -#define NODE_TYPES_BEGIN(ntype) \ - { \ - GHashIterator *__node_type_iter__ = nodeTypeGetIterator(); \ - for (; !BLI_ghashIterator_done(__node_type_iter__); \ - BLI_ghashIterator_step(__node_type_iter__)) { \ - bNodeType *ntype = (bNodeType *)BLI_ghashIterator_getValue(__node_type_iter__); - -#define NODE_TYPES_END \ - } \ - BLI_ghashIterator_free(__node_type_iter__); \ - } \ - ((void)0) - -struct bNodeSocketType *nodeSocketTypeFind(const char *idname); -void nodeRegisterSocketType(struct bNodeSocketType *stype); -void nodeUnregisterSocketType(struct bNodeSocketType *stype); -bool nodeSocketIsRegistered(const struct bNodeSocket *sock); -struct GHashIterator *nodeSocketTypeGetIterator(void); -const char *nodeSocketTypeLabel(const bNodeSocketType *stype); - -const char *nodeStaticSocketType(int type, int subtype); -const char *nodeStaticSocketInterfaceTypeNew(int type, int subtype); -const char *nodeStaticSocketLabel(int type, int subtype); - -/* Helper macros for iterating over node types. */ -#define NODE_SOCKET_TYPES_BEGIN(stype) \ - { \ - GHashIterator *__node_socket_type_iter__ = nodeSocketTypeGetIterator(); \ - for (; !BLI_ghashIterator_done(__node_socket_type_iter__); \ - BLI_ghashIterator_step(__node_socket_type_iter__)) \ - { \ - bNodeSocketType *stype = (bNodeSocketType *)BLI_ghashIterator_getValue( \ - __node_socket_type_iter__); - -#define NODE_SOCKET_TYPES_END \ - } \ - BLI_ghashIterator_free(__node_socket_type_iter__); \ - } \ - ((void)0) - -struct bNodeSocket *nodeFindSocket(const struct bNode *node, - eNodeSocketInOut in_out, - const char *identifier); -struct bNodeSocket *nodeAddSocket(struct bNodeTree *ntree, - struct bNode *node, - eNodeSocketInOut in_out, - const char *idname, - const char *identifier, - const char *name); -struct bNodeSocket *nodeAddStaticSocket(struct bNodeTree *ntree, - struct bNode *node, - eNodeSocketInOut in_out, - int type, - int subtype, - const char *identifier, - const char *name); -void nodeRemoveSocket(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock); - -void nodeModifySocketTypeStatic( - struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock, int type, int subtype); - -struct bNode *nodeAddNode(const struct bContext *C, struct bNodeTree *ntree, const char *idname); -struct bNode *nodeAddStaticNode(const struct bContext *C, struct bNodeTree *ntree, int type); - -/** - * Find the first available, non-duplicate name for a given node. - */ -void nodeUniqueName(struct bNodeTree *ntree, struct bNode *node); -/** - * Create a new unique integer identifier for the node. Also set the node's - * index in the tree, which is an eagerly maintained cache. - */ -void nodeUniqueID(struct bNodeTree *ntree, struct bNode *node); - -/** - * Delete node, associated animation data and ID user count. - */ -void nodeRemoveNode(struct Main *bmain, - struct bNodeTree *ntree, - struct bNode *node, - bool do_id_user); - -void nodeDimensionsGet(const struct bNode *node, float *r_width, float *r_height); -void nodeTagUpdateID(struct bNode *node); -void nodeInternalLinks(struct bNode *node, struct bNodeLink **r_links, int *r_len); - -/** - * Also used via RNA API, so we check for proper input output direction. - */ -struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, - struct bNode *fromnode, - struct bNodeSocket *fromsock, - struct bNode *tonode, - struct bNodeSocket *tosock); -void nodeRemLink(struct bNodeTree *ntree, struct bNodeLink *link); -void nodeRemSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock); - -bool nodeLinkIsHidden(const struct bNodeLink *link); - -void nodeAttachNode(struct bNodeTree *ntree, struct bNode *node, struct bNode *parent); -void nodeDetachNode(struct bNodeTree *ntree, struct bNode *node); - -/** - * Same as above but expects that the socket definitely is in the node tree. - */ -void nodeFindNode(struct bNodeTree *ntree, - struct bNodeSocket *sock, - struct bNode **r_node, - int *r_sockindex); -/** - * Finds a node based on its name. - */ -struct bNode *nodeFindNodebyName(struct bNodeTree *ntree, const char *name); -/** - * Finds a node based on given socket and returns true on success. - */ -bool nodeFindNodeTry(struct bNodeTree *ntree, - struct bNodeSocket *sock, - struct bNode **r_node, - int *r_sockindex); - -bool nodeIsParentAndChild(const bNode *parent, const bNode *child); - -int nodeCountSocketLinks(const struct bNodeTree *ntree, const struct bNodeSocket *sock); - -void nodeSetSelected(struct bNode *node, bool select); -/** - * Two active flags, ID nodes have special flag for buttons display. - */ -void nodeSetActive(struct bNodeTree *ntree, struct bNode *node); -struct bNode *nodeGetActive(struct bNodeTree *ntree); -void nodeClearActive(struct bNodeTree *ntree); -/** - * Two active flags, ID nodes have special flag for buttons display. - */ -struct bNode *nodeGetActiveTexture(struct bNodeTree *ntree); - -int nodeSocketLinkLimit(const struct bNodeSocket *sock); - -/** - * Node Instance Hash. - */ -typedef struct bNodeInstanceHash { - /** XXX should be made a direct member, #GHash allocation needs to support it */ - GHash *ghash; -} bNodeInstanceHash; - -typedef void (*bNodeInstanceValueFP)(void *value); - -/** - * Magic number for initial hash key. - */ -extern const bNodeInstanceKey NODE_INSTANCE_KEY_BASE; -extern const bNodeInstanceKey NODE_INSTANCE_KEY_NONE; - -bNodeInstanceKey BKE_node_instance_key(bNodeInstanceKey parent_key, - const struct bNodeTree *ntree, - const struct bNode *node); - -bNodeInstanceHash *BKE_node_instance_hash_new(const char *info); -void BKE_node_instance_hash_free(bNodeInstanceHash *hash, bNodeInstanceValueFP valfreefp); -void BKE_node_instance_hash_insert(bNodeInstanceHash *hash, bNodeInstanceKey key, void *value); -void *BKE_node_instance_hash_lookup(bNodeInstanceHash *hash, bNodeInstanceKey key); -int BKE_node_instance_hash_remove(bNodeInstanceHash *hash, - bNodeInstanceKey key, - bNodeInstanceValueFP valfreefp); -void BKE_node_instance_hash_clear(bNodeInstanceHash *hash, bNodeInstanceValueFP valfreefp); -void *BKE_node_instance_hash_pop(bNodeInstanceHash *hash, bNodeInstanceKey key); -int BKE_node_instance_hash_haskey(bNodeInstanceHash *hash, bNodeInstanceKey key); -int BKE_node_instance_hash_size(bNodeInstanceHash *hash); - -void BKE_node_instance_hash_clear_tags(bNodeInstanceHash *hash); -void BKE_node_instance_hash_tag(bNodeInstanceHash *hash, void *value); -bool BKE_node_instance_hash_tag_key(bNodeInstanceHash *hash, bNodeInstanceKey key); -void BKE_node_instance_hash_remove_untagged(bNodeInstanceHash *hash, - bNodeInstanceValueFP valfreefp); - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Node Type Access - * \{ */ - -bool nodeGroupPoll(const struct bNodeTree *nodetree, - const struct bNodeTree *grouptree, - const char **r_disabled_hint); - -void node_type_base_custom(struct bNodeType *ntype, - const char *idname, - const char *name, - const char *enum_name, - short nclass); - -/** - * \warning Nodes defining a storage type _must_ allocate this for new nodes. - * Otherwise nodes will reload as undefined (#46619). - */ -void node_type_storage(struct bNodeType *ntype, - const char *storagename, - void (*freefunc)(struct bNode *node), - void (*copyfunc)(struct bNodeTree *dest_ntree, - struct bNode *dest_node, - const struct bNode *src_node)); - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Common Node Types - * \{ */ - -#define NODE_UNDEFINED -2 /* node type is not registered */ -#define NODE_CUSTOM -1 /* for dynamically registered custom types */ -#define NODE_GROUP 2 -// #define NODE_FORLOOP 3 /* deprecated */ -// #define NODE_WHILELOOP 4 /* deprecated */ -#define NODE_FRAME 5 -#define NODE_REROUTE 6 -#define NODE_GROUP_INPUT 7 -#define NODE_GROUP_OUTPUT 8 -#define NODE_CUSTOM_GROUP 9 - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Node Tree Iterator - * - * Utility macro for visiting every node tree in the library data, - * including local bNodeTree blocks in other IDs. - * This avoids the need for callback functions and allows executing code - * in a single inner code block. - * - * Variables: - * - * - nodetree: - * The actual bNodeTree data block. - * Check `nodetree->idname` or `nodetree->typeinfo` to use only specific types. - * - * - id: - * The owner of the bNodeTree data block. - * Same as nodetree if it's a linkable node tree from the library. - * - * Examples: - * - * \code{.c} - * FOREACH_NODETREE_BEGIN(bmain, nodetree, id) { - * if (id == nodetree) - * printf("This is a linkable node tree"); - * } FOREACH_NODETREE_END; - * - * FOREACH_NODETREE_BEGIN(bmain, nodetree, id) { - * if (nodetree->idname == "ShaderNodeTree") - * printf("This is a shader node tree); - * if (GS(id) == ID_MA) - * printf(" and it's owned by a material"); - * } FOREACH_NODETREE_END; - * \endcode - * - * \{ */ - -/* should be an opaque type, only for internal use by BKE_node_tree_iter_*** */ -struct NodeTreeIterStore { - bNodeTree *ngroup; - Scene *scene; - struct Material *mat; - Tex *tex; - struct Light *light; - struct World *world; - struct FreestyleLineStyle *linestyle; -}; - -void BKE_node_tree_iter_init(struct NodeTreeIterStore *ntreeiter, struct Main *bmain); -bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter, - struct bNodeTree **r_nodetree, - struct ID **r_id); - -#define FOREACH_NODETREE_BEGIN(bmain, _nodetree, _id) \ - { \ - struct NodeTreeIterStore _nstore; \ - bNodeTree *_nodetree; \ - ID *_id; \ - /* avoid compiler warning about unused variables */ \ - BKE_node_tree_iter_init(&_nstore, bmain); \ - while (BKE_node_tree_iter_step(&_nstore, &_nodetree, &_id) == true) { \ - if (_nodetree) { - -#define FOREACH_NODETREE_END \ - } \ - } \ - } \ - ((void)0) - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Node Tree - */ - -void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, int layer_index); - -/* -------------------------------------------------------------------- */ -/** \name Shader Nodes - * \{ */ - -/* NOTE: types are needed to restore callbacks, don't change values. */ - -// #define SH_NODE_MATERIAL 100 -#define SH_NODE_RGB 101 -#define SH_NODE_VALUE 102 -#define SH_NODE_MIX_RGB_LEGACY 103 -#define SH_NODE_VALTORGB 104 -#define SH_NODE_RGBTOBW 105 -#define SH_NODE_SHADERTORGB 106 -// #define SH_NODE_TEXTURE 106 -#define SH_NODE_NORMAL 107 -// #define SH_NODE_GEOMETRY 108 -#define SH_NODE_MAPPING 109 -#define SH_NODE_CURVE_VEC 110 -#define SH_NODE_CURVE_RGB 111 -#define SH_NODE_CAMERA 114 -#define SH_NODE_MATH 115 -#define SH_NODE_VECTOR_MATH 116 -#define SH_NODE_SQUEEZE 117 -// #define SH_NODE_MATERIAL_EXT 118 -#define SH_NODE_INVERT 119 -#define SH_NODE_SEPRGB_LEGACY 120 -#define SH_NODE_COMBRGB_LEGACY 121 -#define SH_NODE_HUE_SAT 122 - -#define SH_NODE_OUTPUT_MATERIAL 124 -#define SH_NODE_OUTPUT_WORLD 125 -#define SH_NODE_OUTPUT_LIGHT 126 -#define SH_NODE_FRESNEL 127 -#define SH_NODE_MIX_SHADER 128 -#define SH_NODE_ATTRIBUTE 129 -#define SH_NODE_BACKGROUND 130 -#define SH_NODE_BSDF_GLOSSY 131 -#define SH_NODE_BSDF_DIFFUSE 132 -#define SH_NODE_BSDF_GLOSSY_LEGACY 133 -#define SH_NODE_BSDF_GLASS 134 -#define SH_NODE_BSDF_TRANSLUCENT 137 -#define SH_NODE_BSDF_TRANSPARENT 138 -#define SH_NODE_BSDF_SHEEN 139 -#define SH_NODE_EMISSION 140 -#define SH_NODE_NEW_GEOMETRY 141 -#define SH_NODE_LIGHT_PATH 142 -#define SH_NODE_TEX_IMAGE 143 -#define SH_NODE_TEX_SKY 145 -#define SH_NODE_TEX_GRADIENT 146 -#define SH_NODE_TEX_VORONOI 147 -#define SH_NODE_TEX_MAGIC 148 -#define SH_NODE_TEX_WAVE 149 -#define SH_NODE_TEX_NOISE 150 -#define SH_NODE_TEX_MUSGRAVE_DEPRECATED 152 -#define SH_NODE_TEX_COORD 155 -#define SH_NODE_ADD_SHADER 156 -#define SH_NODE_TEX_ENVIRONMENT 157 -// #define SH_NODE_OUTPUT_TEXTURE 158 -#define SH_NODE_HOLDOUT 159 -#define SH_NODE_LAYER_WEIGHT 160 -#define SH_NODE_VOLUME_ABSORPTION 161 -#define SH_NODE_VOLUME_SCATTER 162 -#define SH_NODE_GAMMA 163 -#define SH_NODE_TEX_CHECKER 164 -#define SH_NODE_BRIGHTCONTRAST 165 -#define SH_NODE_LIGHT_FALLOFF 166 -#define SH_NODE_OBJECT_INFO 167 -#define SH_NODE_PARTICLE_INFO 168 -#define SH_NODE_TEX_BRICK 169 -#define SH_NODE_BUMP 170 -#define SH_NODE_SCRIPT 171 -#define SH_NODE_AMBIENT_OCCLUSION 172 -#define SH_NODE_BSDF_REFRACTION 173 -#define SH_NODE_TANGENT 174 -#define SH_NODE_NORMAL_MAP 175 -#define SH_NODE_HAIR_INFO 176 -#define SH_NODE_SUBSURFACE_SCATTERING 177 -#define SH_NODE_WIREFRAME 178 -#define SH_NODE_BSDF_TOON 179 -#define SH_NODE_WAVELENGTH 180 -#define SH_NODE_BLACKBODY 181 -#define SH_NODE_VECT_TRANSFORM 182 -#define SH_NODE_SEPHSV_LEGACY 183 -#define SH_NODE_COMBHSV_LEGACY 184 -#define SH_NODE_BSDF_HAIR 185 -// #define SH_NODE_LAMP 186 -#define SH_NODE_UVMAP 187 -#define SH_NODE_SEPXYZ 188 -#define SH_NODE_COMBXYZ 189 -#define SH_NODE_OUTPUT_LINESTYLE 190 -#define SH_NODE_UVALONGSTROKE 191 -#define SH_NODE_TEX_POINTDENSITY 192 -#define SH_NODE_BSDF_PRINCIPLED 193 -#define SH_NODE_TEX_IES 194 -#define SH_NODE_EEVEE_SPECULAR 195 -#define SH_NODE_BEVEL 197 -#define SH_NODE_DISPLACEMENT 198 -#define SH_NODE_VECTOR_DISPLACEMENT 199 -#define SH_NODE_VOLUME_PRINCIPLED 200 -/* 201..700 occupied by other node types, continue from 701 */ -#define SH_NODE_BSDF_HAIR_PRINCIPLED 701 -#define SH_NODE_MAP_RANGE 702 -#define SH_NODE_CLAMP 703 -#define SH_NODE_TEX_WHITE_NOISE 704 -#define SH_NODE_VOLUME_INFO 705 -#define SH_NODE_VERTEX_COLOR 706 -#define SH_NODE_OUTPUT_AOV 707 -#define SH_NODE_VECTOR_ROTATE 708 -#define SH_NODE_CURVE_FLOAT 709 -#define SH_NODE_POINT_INFO 710 -#define SH_NODE_COMBINE_COLOR 711 -#define SH_NODE_SEPARATE_COLOR 712 -#define SH_NODE_MIX 713 - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Composite Nodes - * \{ */ - -/* output socket defines */ -#define RRES_OUT_IMAGE 0 -#define RRES_OUT_ALPHA 1 - -/* NOTE: types are needed to restore callbacks, don't change values. */ -#define CMP_NODE_VIEWER 201 -#define CMP_NODE_RGB 202 -#define CMP_NODE_VALUE 203 -#define CMP_NODE_MIX_RGB 204 -#define CMP_NODE_VALTORGB 205 -#define CMP_NODE_RGBTOBW 206 -#define CMP_NODE_NORMAL 207 -#define CMP_NODE_CURVE_VEC 208 -#define CMP_NODE_CURVE_RGB 209 -#define CMP_NODE_ALPHAOVER 210 -#define CMP_NODE_BLUR 211 -#define CMP_NODE_FILTER 212 -#define CMP_NODE_MAP_VALUE 213 -#define CMP_NODE_TIME 214 -#define CMP_NODE_VECBLUR 215 -#define CMP_NODE_SEPRGBA_LEGACY 216 -#define CMP_NODE_SEPHSVA_LEGACY 217 -#define CMP_NODE_SETALPHA 218 -#define CMP_NODE_HUE_SAT 219 -#define CMP_NODE_IMAGE 220 -#define CMP_NODE_R_LAYERS 221 -#define CMP_NODE_COMPOSITE 222 -#define CMP_NODE_OUTPUT_FILE 223 -#define CMP_NODE_TEXTURE 224 -#define CMP_NODE_TRANSLATE 225 -#define CMP_NODE_ZCOMBINE 226 -#define CMP_NODE_COMBRGBA_LEGACY 227 -#define CMP_NODE_DILATEERODE 228 -#define CMP_NODE_ROTATE 229 -#define CMP_NODE_SCALE 230 -#define CMP_NODE_SEPYCCA_LEGACY 231 -#define CMP_NODE_COMBYCCA_LEGACY 232 -#define CMP_NODE_SEPYUVA_LEGACY 233 -#define CMP_NODE_COMBYUVA_LEGACY 234 -#define CMP_NODE_DIFF_MATTE 235 -#define CMP_NODE_COLOR_SPILL 236 -#define CMP_NODE_CHROMA_MATTE 237 -#define CMP_NODE_CHANNEL_MATTE 238 -#define CMP_NODE_FLIP 239 -/* Split viewer node is now a regular split node: CMP_NODE_SPLIT. */ -#define CMP_NODE_SPLITVIEWER__DEPRECATED 240 -// #define CMP_NODE_INDEX_MASK 241 -#define CMP_NODE_MAP_UV 242 -#define CMP_NODE_ID_MASK 243 -#define CMP_NODE_DEFOCUS 244 -#define CMP_NODE_DISPLACE 245 -#define CMP_NODE_COMBHSVA_LEGACY 246 -#define CMP_NODE_MATH 247 -#define CMP_NODE_LUMA_MATTE 248 -#define CMP_NODE_BRIGHTCONTRAST 249 -#define CMP_NODE_GAMMA 250 -#define CMP_NODE_INVERT 251 -#define CMP_NODE_NORMALIZE 252 -#define CMP_NODE_CROP 253 -#define CMP_NODE_DBLUR 254 -#define CMP_NODE_BILATERALBLUR 255 -#define CMP_NODE_PREMULKEY 256 -#define CMP_NODE_DIST_MATTE 257 -#define CMP_NODE_VIEW_LEVELS 258 -#define CMP_NODE_COLOR_MATTE 259 -#define CMP_NODE_COLORBALANCE 260 -#define CMP_NODE_HUECORRECT 261 -#define CMP_NODE_MOVIECLIP 262 -#define CMP_NODE_STABILIZE2D 263 -#define CMP_NODE_TRANSFORM 264 -#define CMP_NODE_MOVIEDISTORTION 265 -#define CMP_NODE_DOUBLEEDGEMASK 266 -#define CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED \ - 267 /* DEPRECATED multi file node has been merged into regular CMP_NODE_OUTPUT_FILE */ -#define CMP_NODE_MASK 268 -#define CMP_NODE_KEYINGSCREEN 269 -#define CMP_NODE_KEYING 270 -#define CMP_NODE_TRACKPOS 271 -#define CMP_NODE_INPAINT 272 -#define CMP_NODE_DESPECKLE 273 -#define CMP_NODE_ANTIALIASING 274 -#define CMP_NODE_KUWAHARA 275 -#define CMP_NODE_SPLIT 276 - -#define CMP_NODE_GLARE 301 -#define CMP_NODE_TONEMAP 302 -#define CMP_NODE_LENSDIST 303 -#define CMP_NODE_SUNBEAMS 304 - -#define CMP_NODE_COLORCORRECTION 312 -#define CMP_NODE_MASK_BOX 313 -#define CMP_NODE_MASK_ELLIPSE 314 -#define CMP_NODE_BOKEHIMAGE 315 -#define CMP_NODE_BOKEHBLUR 316 -#define CMP_NODE_SWITCH 317 -#define CMP_NODE_PIXELATE 318 - -#define CMP_NODE_MAP_RANGE 319 -#define CMP_NODE_PLANETRACKDEFORM 320 -#define CMP_NODE_CORNERPIN 321 -#define CMP_NODE_SWITCH_VIEW 322 -#define CMP_NODE_CRYPTOMATTE_LEGACY 323 -#define CMP_NODE_DENOISE 324 -#define CMP_NODE_EXPOSURE 325 -#define CMP_NODE_CRYPTOMATTE 326 -#define CMP_NODE_POSTERIZE 327 -#define CMP_NODE_CONVERT_COLOR_SPACE 328 -#define CMP_NODE_SCENE_TIME 329 -#define CMP_NODE_SEPARATE_XYZ 330 -#define CMP_NODE_COMBINE_XYZ 331 -#define CMP_NODE_COMBINE_COLOR 332 -#define CMP_NODE_SEPARATE_COLOR 333 - -/* channel toggles */ -#define CMP_CHAN_RGB 1 -#define CMP_CHAN_A 2 - -/* Default SMAA configuration values. */ -#define CMP_DEFAULT_SMAA_THRESHOLD 1.0f -#define CMP_DEFAULT_SMAA_CONTRAST_LIMIT 0.2f -#define CMP_DEFAULT_SMAA_CORNER_ROUNDING 0.25f - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Texture Nodes - * \{ */ - -#define TEX_NODE_OUTPUT 401 -#define TEX_NODE_CHECKER 402 -#define TEX_NODE_TEXTURE 403 -#define TEX_NODE_BRICKS 404 -#define TEX_NODE_MATH 405 -#define TEX_NODE_MIX_RGB 406 -#define TEX_NODE_RGBTOBW 407 -#define TEX_NODE_VALTORGB 408 -#define TEX_NODE_IMAGE 409 -#define TEX_NODE_CURVE_RGB 410 -#define TEX_NODE_INVERT 411 -#define TEX_NODE_HUE_SAT 412 -#define TEX_NODE_CURVE_TIME 413 -#define TEX_NODE_ROTATE 414 -#define TEX_NODE_VIEWER 415 -#define TEX_NODE_TRANSLATE 416 -#define TEX_NODE_COORD 417 -#define TEX_NODE_DISTANCE 418 -#define TEX_NODE_COMPOSE_LEGACY 419 -#define TEX_NODE_DECOMPOSE_LEGACY 420 -#define TEX_NODE_VALTONOR 421 -#define TEX_NODE_SCALE 422 -#define TEX_NODE_AT 423 -#define TEX_NODE_COMBINE_COLOR 424 -#define TEX_NODE_SEPARATE_COLOR 425 - -/* 501-599 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */ -#define TEX_NODE_PROC 500 -#define TEX_NODE_PROC_MAX 600 - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Geometry Nodes - * \{ */ - -#define GEO_NODE_TRIANGULATE 1000 -#define GEO_NODE_TRANSFORM_GEOMETRY 1002 -#define GEO_NODE_MESH_BOOLEAN 1003 -#define GEO_NODE_OBJECT_INFO 1007 -#define GEO_NODE_JOIN_GEOMETRY 1010 -#define GEO_NODE_COLLECTION_INFO 1023 -#define GEO_NODE_IS_VIEWPORT 1024 -#define GEO_NODE_SUBDIVIDE_MESH 1029 -#define GEO_NODE_MESH_PRIMITIVE_CUBE 1032 -#define GEO_NODE_MESH_PRIMITIVE_CIRCLE 1033 -#define GEO_NODE_MESH_PRIMITIVE_UV_SPHERE 1034 -#define GEO_NODE_MESH_PRIMITIVE_CYLINDER 1035 -#define GEO_NODE_MESH_PRIMITIVE_ICO_SPHERE 1036 -#define GEO_NODE_MESH_PRIMITIVE_CONE 1037 -#define GEO_NODE_MESH_PRIMITIVE_LINE 1038 -#define GEO_NODE_MESH_PRIMITIVE_GRID 1039 -#define GEO_NODE_BOUNDING_BOX 1042 -#define GEO_NODE_SWITCH 1043 -#define GEO_NODE_CURVE_TO_MESH 1045 -#define GEO_NODE_RESAMPLE_CURVE 1047 -#define GEO_NODE_INPUT_MATERIAL 1050 -#define GEO_NODE_REPLACE_MATERIAL 1051 -#define GEO_NODE_CURVE_LENGTH 1054 -#define GEO_NODE_CONVEX_HULL 1056 -#define GEO_NODE_SEPARATE_COMPONENTS 1059 -#define GEO_NODE_CURVE_PRIMITIVE_STAR 1062 -#define GEO_NODE_CURVE_PRIMITIVE_SPIRAL 1063 -#define GEO_NODE_CURVE_PRIMITIVE_QUADRATIC_BEZIER 1064 -#define GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT 1065 -#define GEO_NODE_CURVE_PRIMITIVE_CIRCLE 1066 -#define GEO_NODE_VIEWER 1067 -#define GEO_NODE_CURVE_PRIMITIVE_LINE 1068 -#define GEO_NODE_CURVE_PRIMITIVE_QUADRILATERAL 1070 -#define GEO_NODE_TRIM_CURVE 1071 -#define GEO_NODE_FILL_CURVE 1075 -#define GEO_NODE_INPUT_POSITION 1076 -#define GEO_NODE_SET_POSITION 1077 -#define GEO_NODE_INPUT_INDEX 1078 -#define GEO_NODE_INPUT_NORMAL 1079 -#define GEO_NODE_CAPTURE_ATTRIBUTE 1080 -#define GEO_NODE_MATERIAL_SELECTION 1081 -#define GEO_NODE_SET_MATERIAL 1082 -#define GEO_NODE_REALIZE_INSTANCES 1083 -#define GEO_NODE_ATTRIBUTE_STATISTIC 1084 -#define GEO_NODE_SAMPLE_CURVE 1085 -#define GEO_NODE_INPUT_TANGENT 1086 -#define GEO_NODE_STRING_JOIN 1087 -#define GEO_NODE_CURVE_SPLINE_PARAMETER 1088 -#define GEO_NODE_FILLET_CURVE 1089 -#define GEO_NODE_DISTRIBUTE_POINTS_ON_FACES 1090 -#define GEO_NODE_STRING_TO_CURVES 1091 -#define GEO_NODE_INSTANCE_ON_POINTS 1092 -#define GEO_NODE_MESH_TO_POINTS 1093 -#define GEO_NODE_POINTS_TO_VERTICES 1094 -#define GEO_NODE_REVERSE_CURVE 1095 -#define GEO_NODE_PROXIMITY 1096 -#define GEO_NODE_SUBDIVIDE_CURVE 1097 -#define GEO_NODE_INPUT_SPLINE_LENGTH 1098 -#define GEO_NODE_CURVE_SPLINE_TYPE 1099 -#define GEO_NODE_CURVE_SET_HANDLE_TYPE 1100 -#define GEO_NODE_POINTS_TO_VOLUME 1101 -#define GEO_NODE_CURVE_HANDLE_TYPE_SELECTION 1102 -#define GEO_NODE_DELETE_GEOMETRY 1103 -#define GEO_NODE_SEPARATE_GEOMETRY 1104 -#define GEO_NODE_INPUT_RADIUS 1105 -#define GEO_NODE_INPUT_CURVE_TILT 1106 -#define GEO_NODE_INPUT_CURVE_HANDLES 1107 -#define GEO_NODE_INPUT_FACE_SMOOTH 1108 -#define GEO_NODE_INPUT_SPLINE_RESOLUTION 1109 -#define GEO_NODE_INPUT_SPLINE_CYCLIC 1110 -#define GEO_NODE_SET_CURVE_RADIUS 1111 -#define GEO_NODE_SET_CURVE_TILT 1112 -#define GEO_NODE_SET_CURVE_HANDLES 1113 -#define GEO_NODE_SET_SHADE_SMOOTH 1114 -#define GEO_NODE_SET_SPLINE_RESOLUTION 1115 -#define GEO_NODE_SET_SPLINE_CYCLIC 1116 -#define GEO_NODE_SET_POINT_RADIUS 1117 -#define GEO_NODE_INPUT_MATERIAL_INDEX 1118 -#define GEO_NODE_SET_MATERIAL_INDEX 1119 -#define GEO_NODE_TRANSLATE_INSTANCES 1120 -#define GEO_NODE_SCALE_INSTANCES 1121 -#define GEO_NODE_ROTATE_INSTANCES 1122 -#define GEO_NODE_SPLIT_EDGES 1123 -#define GEO_NODE_MESH_TO_CURVE 1124 -#define GEO_NODE_TRANSFER_ATTRIBUTE_DEPRECATED 1125 -#define GEO_NODE_SUBDIVISION_SURFACE 1126 -#define GEO_NODE_CURVE_ENDPOINT_SELECTION 1127 -#define GEO_NODE_RAYCAST 1128 -#define GEO_NODE_CURVE_TO_POINTS 1130 -#define GEO_NODE_INSTANCES_TO_POINTS 1131 -#define GEO_NODE_IMAGE_TEXTURE 1132 -#define GEO_NODE_VOLUME_TO_MESH 1133 -#define GEO_NODE_INPUT_ID 1134 -#define GEO_NODE_SET_ID 1135 -#define GEO_NODE_ATTRIBUTE_DOMAIN_SIZE 1136 -#define GEO_NODE_DUAL_MESH 1137 -#define GEO_NODE_INPUT_MESH_EDGE_VERTICES 1138 -#define GEO_NODE_INPUT_MESH_FACE_AREA 1139 -#define GEO_NODE_INPUT_MESH_FACE_NEIGHBORS 1140 -#define GEO_NODE_INPUT_MESH_VERTEX_NEIGHBORS 1141 -#define GEO_NODE_GEOMETRY_TO_INSTANCE 1142 -#define GEO_NODE_INPUT_MESH_EDGE_NEIGHBORS 1143 -#define GEO_NODE_INPUT_MESH_ISLAND 1144 -#define GEO_NODE_INPUT_SCENE_TIME 1145 -#define GEO_NODE_ACCUMULATE_FIELD 1146 -#define GEO_NODE_INPUT_MESH_EDGE_ANGLE 1147 -#define GEO_NODE_EVALUATE_AT_INDEX 1148 -#define GEO_NODE_CURVE_PRIMITIVE_ARC 1149 -#define GEO_NODE_FLIP_FACES 1150 -#define GEO_NODE_SCALE_ELEMENTS 1151 -#define GEO_NODE_EXTRUDE_MESH 1152 -#define GEO_NODE_MERGE_BY_DISTANCE 1153 -#define GEO_NODE_DUPLICATE_ELEMENTS 1154 -#define GEO_NODE_INPUT_MESH_FACE_IS_PLANAR 1155 -#define GEO_NODE_STORE_NAMED_ATTRIBUTE 1156 -#define GEO_NODE_INPUT_NAMED_ATTRIBUTE 1157 -#define GEO_NODE_REMOVE_ATTRIBUTE 1158 -#define GEO_NODE_INPUT_INSTANCE_ROTATION 1159 -#define GEO_NODE_INPUT_INSTANCE_SCALE 1160 -#define GEO_NODE_VOLUME_CUBE 1161 -#define GEO_NODE_POINTS 1162 -#define GEO_NODE_EVALUATE_ON_DOMAIN 1163 -#define GEO_NODE_MESH_TO_VOLUME 1164 -#define GEO_NODE_UV_UNWRAP 1165 -#define GEO_NODE_UV_PACK_ISLANDS 1166 -#define GEO_NODE_DEFORM_CURVES_ON_SURFACE 1167 -#define GEO_NODE_INPUT_SHORTEST_EDGE_PATHS 1168 -#define GEO_NODE_EDGE_PATHS_TO_CURVES 1169 -#define GEO_NODE_EDGE_PATHS_TO_SELECTION 1170 -#define GEO_NODE_MESH_FACE_GROUP_BOUNDARIES 1171 -#define GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME 1172 -#define GEO_NODE_SELF_OBJECT 1173 -#define GEO_NODE_SAMPLE_INDEX 1174 -#define GEO_NODE_SAMPLE_NEAREST 1175 -#define GEO_NODE_SAMPLE_NEAREST_SURFACE 1176 -#define GEO_NODE_OFFSET_POINT_IN_CURVE 1177 -#define GEO_NODE_CURVE_TOPOLOGY_CURVE_OF_POINT 1178 -#define GEO_NODE_CURVE_TOPOLOGY_POINTS_OF_CURVE 1179 -#define GEO_NODE_MESH_TOPOLOGY_OFFSET_CORNER_IN_FACE 1180 -#define GEO_NODE_MESH_TOPOLOGY_CORNERS_OF_FACE 1181 -#define GEO_NODE_MESH_TOPOLOGY_CORNERS_OF_VERTEX 1182 -#define GEO_NODE_MESH_TOPOLOGY_EDGES_OF_CORNER 1183 -#define GEO_NODE_MESH_TOPOLOGY_EDGES_OF_VERTEX 1184 -#define GEO_NODE_MESH_TOPOLOGY_FACE_OF_CORNER 1185 -#define GEO_NODE_MESH_TOPOLOGY_VERTEX_OF_CORNER 1186 -#define GEO_NODE_SAMPLE_UV_SURFACE 1187 -#define GEO_NODE_SET_CURVE_NORMAL 1188 -#define GEO_NODE_IMAGE_INFO 1189 -#define GEO_NODE_BLUR_ATTRIBUTE 1190 -#define GEO_NODE_IMAGE 1191 -#define GEO_NODE_INTERPOLATE_CURVES 1192 -#define GEO_NODE_EDGES_TO_FACE_GROUPS 1193 -// #define GEO_NODE_POINTS_TO_SDF_VOLUME 1194 -// #define GEO_NODE_MESH_TO_SDF_VOLUME 1195 -// #define GEO_NODE_SDF_VOLUME_SPHERE 1196 -// #define GEO_NODE_MEAN_FILTER_SDF_VOLUME 1197 -// #define GEO_NODE_OFFSET_SDF_VOLUME 1198 -#define GEO_NODE_INDEX_OF_NEAREST 1199 -/* Function nodes use the range starting at 1200. */ -#define GEO_NODE_SIMULATION_INPUT 2100 -#define GEO_NODE_SIMULATION_OUTPUT 2101 -// #define GEO_NODE_INPUT_SIGNED_DISTANCE 2102 -// #define GEO_NODE_SAMPLE_VOLUME 2103 -#define GEO_NODE_MESH_TOPOLOGY_CORNERS_OF_EDGE 2104 -/* Leaving out two indices to avoid crashes with files that were created during the development of - * the repeat zone. */ -#define GEO_NODE_REPEAT_INPUT 2107 -#define GEO_NODE_REPEAT_OUTPUT 2108 -#define GEO_NODE_TOOL_SELECTION 2109 -#define GEO_NODE_TOOL_SET_SELECTION 2110 -#define GEO_NODE_TOOL_3D_CURSOR 2111 -#define GEO_NODE_TOOL_FACE_SET 2112 -#define GEO_NODE_TOOL_SET_FACE_SET 2113 -#define GEO_NODE_POINTS_TO_CURVES 2114 -#define GEO_NODE_INPUT_EDGE_SMOOTH 2115 -#define GEO_NODE_SPLIT_TO_INSTANCES 2116 -#define GEO_NODE_INPUT_NAMED_LAYER_SELECTION 2117 -#define GEO_NODE_INDEX_SWITCH 2118 -#define GEO_NODE_INPUT_ACTIVE_CAMERA 2119 -#define GEO_NODE_BAKE 2120 -#define GEO_NODE_GET_NAMED_GRID 2121 -#define GEO_NODE_STORE_NAMED_GRID 2122 -#define GEO_NODE_SORT_ELEMENTS 2123 -#define GEO_NODE_MENU_SWITCH 2124 - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Function Nodes - * \{ */ - -#define FN_NODE_BOOLEAN_MATH 1200 -#define FN_NODE_COMPARE 1202 -#define FN_NODE_LEGACY_RANDOM_FLOAT 1206 -#define FN_NODE_INPUT_VECTOR 1207 -#define FN_NODE_INPUT_STRING 1208 -#define FN_NODE_FLOAT_TO_INT 1209 -#define FN_NODE_VALUE_TO_STRING 1210 -#define FN_NODE_STRING_LENGTH 1211 -#define FN_NODE_SLICE_STRING 1212 -#define FN_NODE_INPUT_SPECIAL_CHARACTERS 1213 -#define FN_NODE_RANDOM_VALUE 1214 -#define FN_NODE_ROTATE_EULER 1215 -#define FN_NODE_ALIGN_EULER_TO_VECTOR 1216 -#define FN_NODE_INPUT_COLOR 1217 -#define FN_NODE_REPLACE_STRING 1218 -#define FN_NODE_INPUT_BOOL 1219 -#define FN_NODE_INPUT_INT 1220 -#define FN_NODE_SEPARATE_COLOR 1221 -#define FN_NODE_COMBINE_COLOR 1222 -#define FN_NODE_AXIS_ANGLE_TO_ROTATION 1223 -#define FN_NODE_EULER_TO_ROTATION 1224 -#define FN_NODE_QUATERNION_TO_ROTATION 1225 -#define FN_NODE_ROTATION_TO_AXIS_ANGLE 1226 -#define FN_NODE_ROTATION_TO_EULER 1227 -#define FN_NODE_ROTATION_TO_QUATERNION 1228 -#define FN_NODE_ROTATE_VECTOR 1229 -#define FN_NODE_ROTATE_ROTATION 1230 -#define FN_NODE_INVERT_ROTATION 1231 -#define FN_NODE_TRANSFORM_POINT 1232 -#define FN_NODE_TRANSFORM_DIRECTION 1233 -#define FN_NODE_MATRIX_MULTIPLY 1234 -#define FN_NODE_COMBINE_TRANSFORM 1235 -#define FN_NODE_SEPARATE_TRANSFORM 1236 -#define FN_NODE_INVERT_MATRIX 1237 -#define FN_NODE_TRANSPOSE_MATRIX 1238 - -/** \} */ - -void BKE_node_system_init(void); -void BKE_node_system_exit(void); - namespace blender::bke { bNodeTree *ntreeAddTreeEmbedded(Main *bmain, ID *owner_id, const char *name, const char *idname); @@ -1514,9 +163,6 @@ void nodeChainIter(const bNodeTree *ntree, * Can be called recursively (using another nodeChainIterBackwards) by * setting the recursion_lvl accordingly. * - * WARN: No node is guaranteed to be iterated as a to_node, - * since it could have been iterated earlier as a from_node. - * * \note Needs updated socket links (ntreeUpdateTree). * \note Recursive */ diff --git a/source/blender/blenkernel/BKE_node_runtime.hh b/source/blender/blenkernel/BKE_node_runtime.hh index 7a475cb4254..08f4ced5ab1 100644 --- a/source/blender/blenkernel/BKE_node_runtime.hh +++ b/source/blender/blenkernel/BKE_node_runtime.hh @@ -75,12 +75,6 @@ namespace blender::bke { using NodeIDVectorSet = VectorSet; -/** - * Runtime data for #bNodeTree from the perspective of execution instructions (rather than runtime - * data from evaluation of the node tree). Evaluation data is not the responsibility of the node - * tree and should be stored elsewhere. Evaluating a node tree should be possible without changing - * it. - */ class bNodeTreeRuntime : NonCopyable, NonMovable { public: /** @@ -115,12 +109,18 @@ class bNodeTreeRuntime : NonCopyable, NonMovable { NodeIDVectorSet nodes_by_id; /** - * Legacy execution data. + * Execution data. * - * \todo Move this out of the node tree to improve semantic/physical separation between the node - * tree execution instructions and its evaluation. + * XXX It would be preferable to completely move this data out of the underlying node tree, + * so node tree execution could finally run independent of the tree itself. + * This would allow node trees to be merely linked by other data (materials, textures, etc.), + * as ID data is supposed to. + * Execution data is generated from the tree once at execution start and can then be used + * as long as necessary, even while the tree is being modified. */ bNodeTreeExec *execdata = nullptr; + + /* Callbacks. */ void (*progress)(void *, float progress) = nullptr; /** \warning may be called by different threads */ void (*stats_draw)(void *, const char *str) = nullptr; @@ -128,8 +128,6 @@ class bNodeTreeRuntime : NonCopyable, NonMovable { void (*update_draw)(void *) = nullptr; void *tbh = nullptr, *prh = nullptr, *sdh = nullptr, *udh = nullptr; - /* End legacy execution data. */ - /** Information about how inputs and outputs of the node group interact with fields. */ std::unique_ptr field_inferencing_interface; /** Information about usage of anonymous attributes within the group. */ diff --git a/source/blender/blenkernel/BKE_node_tree_interface.hh b/source/blender/blenkernel/BKE_node_tree_interface.hh index 9d88f208985..c699df7f31a 100644 --- a/source/blender/blenkernel/BKE_node_tree_interface.hh +++ b/source/blender/blenkernel/BKE_node_tree_interface.hh @@ -7,7 +7,7 @@ #include "DNA_node_tree_interface_types.h" #include "DNA_node_types.h" -#include "BKE_node.hh" +#include "BKE_node.h" #include #include @@ -130,7 +130,6 @@ static const bNodeSocketStaticTypeInfo node_socket_subtypes[] = { {"NodeSocketIntFactor", "NodeTreeInterfaceSocketIntFactor", SOCK_INT, PROP_FACTOR}, {"NodeSocketBool", "NodeTreeInterfaceSocketBool", SOCK_BOOLEAN, PROP_NONE}, {"NodeSocketRotation", "NodeTreeInterfaceSocketRotation", SOCK_ROTATION, PROP_NONE}, - {"NodeSocketMatrix", "NodeTreeInterfaceSocketMatrix", SOCK_MATRIX, PROP_NONE}, {"NodeSocketVector", "NodeTreeInterfaceSocketVector", SOCK_VECTOR, PROP_NONE}, {"NodeSocketVectorTranslation", "NodeTreeInterfaceSocketVectorTranslation", @@ -207,7 +206,6 @@ template bool socket_data_to_static_type(const eNodeSocketDatatype case SOCK_CUSTOM: case SOCK_SHADER: - case SOCK_MATRIX: case SOCK_GEOMETRY: return true; } diff --git a/source/blender/blenkernel/BKE_object.hh b/source/blender/blenkernel/BKE_object.hh index d9200ec24c1..3c2e219030b 100644 --- a/source/blender/blenkernel/BKE_object.hh +++ b/source/blender/blenkernel/BKE_object.hh @@ -319,7 +319,7 @@ blender::Vector BKE_object_pose_base_array_get(const Scene *scene, void BKE_object_get_parent_matrix(Object *ob, Object *par, float r_parentmat[4][4]); /** - * Compute object world transform and store it in `ob->object_to_world().ptr()`. + * Compute object world transform and store it in `ob->object_to_world`. */ void BKE_object_where_is_calc(Depsgraph *depsgraph, Scene *scene, Object *ob); void BKE_object_where_is_calc_ex( diff --git a/source/blender/blenkernel/BKE_object_types.hh b/source/blender/blenkernel/BKE_object_types.hh index 0d15d82a02d..fcfbedb4284 100644 --- a/source/blender/blenkernel/BKE_object_types.hh +++ b/source/blender/blenkernel/BKE_object_types.hh @@ -26,9 +26,6 @@ namespace blender::bke { struct GeometrySet; struct ObjectRuntime { - /** Final transformation matrices with constraints & animsys applied. */ - float4x4 object_to_world; - float4x4 world_to_object; /** * The custom data layer mask that was last used * to calculate data_eval and mesh_deform_eval. diff --git a/source/blender/blenkernel/BKE_report.hh b/source/blender/blenkernel/BKE_report.h similarity index 97% rename from source/blender/blenkernel/BKE_report.hh rename to source/blender/blenkernel/BKE_report.h index 60dd71f053c..8ec9360bab5 100644 --- a/source/blender/blenkernel/BKE_report.hh +++ b/source/blender/blenkernel/BKE_report.h @@ -14,6 +14,10 @@ #include "BLI_utildefines.h" #include "DNA_windowmanager_types.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * Reporting Information and Errors. * @@ -87,3 +91,7 @@ const char *BKE_report_type_str(eReportType type); bool BKE_report_write_file_fp(FILE *fp, ReportList *reports, const char *header); bool BKE_report_write_file(const char *filepath, ReportList *reports, const char *header); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h new file mode 100644 index 00000000000..f644b06f1ad --- /dev/null +++ b/source/blender/blenkernel/BKE_scene.h @@ -0,0 +1,363 @@ +/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved. + * + * SPDX-License-Identifier: GPL-2.0-or-later */ +#pragma once + +/** \file + * \ingroup bke + */ + +#include "BLI_sys_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct AviCodecData; +struct Collection; +struct Depsgraph; +struct GHash; +struct Main; +struct Object; +struct RenderData; +struct Scene; +struct TransformOrientation; +struct UnitSettings; +struct View3DCursor; +struct ViewLayer; + +typedef enum eSceneCopyMethod { + SCE_COPY_NEW = 0, + SCE_COPY_EMPTY = 1, + SCE_COPY_LINK_COLLECTION = 2, + SCE_COPY_FULL = 3, +} eSceneCopyMethod; + +/** Use as the contents of a 'for' loop: `for (SETLOOPER(...)) { ... }`. */ +#define SETLOOPER(_sce_basis, _sce_iter, _base) \ + _sce_iter = _sce_basis, \ + _base = _setlooper_base_step( \ + &_sce_iter, BKE_view_layer_context_active_PLACEHOLDER(_sce_basis), NULL); \ + _base; \ + _base = _setlooper_base_step(&_sce_iter, NULL, _base) + +#define SETLOOPER_VIEW_LAYER(_sce_basis, _view_layer, _sce_iter, _base) \ + _sce_iter = _sce_basis, _base = _setlooper_base_step(&_sce_iter, _view_layer, NULL); \ + _base; \ + _base = _setlooper_base_step(&_sce_iter, NULL, _base) + +#define SETLOOPER_SET_ONLY(_sce_basis, _sce_iter, _base) \ + _sce_iter = _sce_basis, _base = _setlooper_base_step(&_sce_iter, NULL, NULL); \ + _base; \ + _base = _setlooper_base_step(&_sce_iter, NULL, _base) + +/** + * Helper function for the #SETLOOPER and #SETLOOPER_VIEW_LAYER macros + * + * It iterates over the bases of the active layer and then the bases + * of the active layer of the background (set) scenes recursively. + */ +struct Base *_setlooper_base_step(struct Scene **sce_iter, + struct ViewLayer *view_layer, + struct Base *base); + +void free_avicodecdata(struct AviCodecData *acd); + +struct Scene *BKE_scene_add(struct Main *bmain, const char *name); + +void BKE_scene_remove_rigidbody_object(struct Main *bmain, + struct Scene *scene, + struct Object *ob, + bool free_us); + +/** + * Check if there is any instance of the object in the scene. + */ +bool BKE_scene_object_find(struct Scene *scene, struct Object *ob); +struct Object *BKE_scene_object_find_by_name(const struct Scene *scene, const char *name); + +/* Scene base iteration function. + * Define struct here, so no need to bother with alloc/free it. + */ +typedef struct SceneBaseIter { + struct ListBase *duplilist; + struct DupliObject *dupob; + float omat[4][4]; + struct Object *dupli_refob; + int phase; +} SceneBaseIter; + +/** + * Used by meta-balls, return *all* objects (including duplis) + * existing in the scene (including scene's sets). + */ +int BKE_scene_base_iter_next(struct Depsgraph *depsgraph, + struct SceneBaseIter *iter, + struct Scene **scene, + int val, + struct Base **base, + struct Object **ob); + +void BKE_scene_base_flag_to_objects(const struct Scene *scene, struct ViewLayer *view_layer); +/** + * Synchronize object base flags + * + * This is usually handled by the depsgraph. + * However, in rare occasions we need to use the latest object flags + * before depsgraph is fully updated. + * + * It should (ideally) only run for copy-on-written objects since this is + * runtime data generated per-view-layer. + */ +void BKE_scene_object_base_flag_sync_from_base(struct Base *base); + +/** + * Sets the active scene, mainly used when running in background mode + * (`--scene` command line argument). + * This is also called to set the scene directly, bypassing windowing code. + * Otherwise #WM_window_set_active_scene is used when changing scenes by the user. + */ +void BKE_scene_set_background(struct Main *bmain, struct Scene *sce); +/** + * Called from `creator_args.c`. + */ +struct Scene *BKE_scene_set_name(struct Main *bmain, const char *name); + +/** + * \param flag: copying options (see BKE_lib_id.hh's `LIB_ID_COPY_...` flags for more). + */ +struct ToolSettings *BKE_toolsettings_copy(struct ToolSettings *toolsettings, int flag); +void BKE_toolsettings_free(struct ToolSettings *toolsettings); + +struct Scene *BKE_scene_duplicate(struct Main *bmain, struct Scene *sce, eSceneCopyMethod type); +void BKE_scene_groups_relink(struct Scene *sce); + +bool BKE_scene_can_be_removed(const struct Main *bmain, const struct Scene *scene); + +bool BKE_scene_has_view_layer(const struct Scene *scene, const struct ViewLayer *layer); +struct Scene *BKE_scene_find_from_collection(const struct Main *bmain, + const struct Collection *collection); + +#ifdef DURIAN_CAMERA_SWITCH +struct Object *BKE_scene_camera_switch_find(struct Scene *scene); /* DURIAN_CAMERA_SWITCH */ +#endif +bool BKE_scene_camera_switch_update(struct Scene *scene); + +const char *BKE_scene_find_marker_name(const struct Scene *scene, int frame); +/** + * Return the current marker for this frame, + * we can have more than 1 marker per frame, this just returns the first (unfortunately). + */ +const char *BKE_scene_find_last_marker_name(const struct Scene *scene, int frame); + +int BKE_scene_frame_snap_by_seconds(struct Scene *scene, double interval_in_seconds, int frame); + +/** + * Checks for cycle, returns true if it's all OK. + */ +bool BKE_scene_validate_setscene(struct Main *bmain, struct Scene *sce); + +/** + * Return fractional frame number taking into account sub-frames and time + * remapping. This the time value used by animation, modifiers and physics + * evaluation. */ +float BKE_scene_ctime_get(const struct Scene *scene); +/** + * Convert integer frame number to fractional frame number taking into account + * sub-frames and time remapping. + */ +float BKE_scene_frame_to_ctime(const struct Scene *scene, int frame); + +/** + * Get current fractional frame based on frame and sub-frame. + */ +float BKE_scene_frame_get(const struct Scene *scene); +/** + * Set current frame and sub-frame based on a fractional frame. + */ +void BKE_scene_frame_set(struct Scene *scene, float frame); + +struct TransformOrientationSlot *BKE_scene_orientation_slot_get_from_flag(struct Scene *scene, + int flag); +struct TransformOrientationSlot *BKE_scene_orientation_slot_get(struct Scene *scene, + int slot_index); +/** + * Activate a transform orientation in a 3D view based on an enum value. + * + * \param orientation: If this is #V3D_ORIENT_CUSTOM or greater, the custom transform orientation + * with index \a orientation - #V3D_ORIENT_CUSTOM gets activated. + */ +void BKE_scene_orientation_slot_set_index(struct TransformOrientationSlot *orient_slot, + int orientation); +int BKE_scene_orientation_slot_get_index(const struct TransformOrientationSlot *orient_slot); +int BKE_scene_orientation_get_index(struct Scene *scene, int slot_index); +int BKE_scene_orientation_get_index_from_flag(struct Scene *scene, int flag); + +/* ** Scene evaluation ** */ + +void BKE_scene_update_sound(struct Depsgraph *depsgraph, struct Main *bmain); +void BKE_scene_update_tag_audio_volume(struct Depsgraph *, struct Scene *scene); + +void BKE_scene_graph_update_tagged(struct Depsgraph *depsgraph, struct Main *bmain); +void BKE_scene_graph_evaluated_ensure(struct Depsgraph *depsgraph, struct Main *bmain); + +void BKE_scene_graph_update_for_newframe(struct Depsgraph *depsgraph); +/** + * Applies changes right away, does all sets too. + */ +void BKE_scene_graph_update_for_newframe_ex(struct Depsgraph *depsgraph, bool clear_recalc); + +/** + * Ensures given scene/view_layer pair has a valid, up-to-date depsgraph. + * + * \warning Sets matching depsgraph as active, + * so should only be called from the active editing context (usually, from operators). + */ +void BKE_scene_view_layer_graph_evaluated_ensure(struct Main *bmain, + struct Scene *scene, + struct ViewLayer *view_layer); + +/** + * Return default view. + */ +struct SceneRenderView *BKE_scene_add_render_view(struct Scene *sce, const char *name); +bool BKE_scene_remove_render_view(struct Scene *scene, struct SceneRenderView *srv); + +/* Render profile. */ + +int get_render_subsurf_level(const struct RenderData *r, int lvl, bool for_render); +int get_render_child_particle_number(const struct RenderData *r, int child_num, bool for_render); + +bool BKE_scene_use_shading_nodes_custom(struct Scene *scene); +bool BKE_scene_use_spherical_stereo(struct Scene *scene); + +bool BKE_scene_uses_blender_eevee(const struct Scene *scene); +bool BKE_scene_uses_blender_workbench(const struct Scene *scene); +bool BKE_scene_uses_cycles(const struct Scene *scene); + +bool BKE_scene_uses_shader_previews(const struct Scene *scene); + +/** + * Return whether the Cycles experimental feature is enabled. It is invalid to call without first + * ensuring that Cycles is the active render engine (e.g. with #BKE_scene_uses_cycles). + * + * \note We cannot use `const` as RNA_id_pointer_create is not using a const ID. + */ +bool BKE_scene_uses_cycles_experimental_features(struct Scene *scene); + +void BKE_scene_copy_data_eevee(struct Scene *sce_dst, const struct Scene *sce_src); + +void BKE_scene_disable_color_management(struct Scene *scene); +bool BKE_scene_check_rigidbody_active(const struct Scene *scene); + +int BKE_scene_num_threads(const struct Scene *scene); +int BKE_render_num_threads(const struct RenderData *r); + +void BKE_render_resolution(const struct RenderData *r, + const bool use_crop, + int *r_width, + int *r_height); +int BKE_render_preview_pixel_size(const struct RenderData *r); + +/**********************************/ + +/** + * Apply the needed correction factor to value, based on unit_type + * (only length-related are affected currently) and `unit->scale_length`. + */ +double BKE_scene_unit_scale(const struct UnitSettings *unit, int unit_type, double value); + +/* Multi-view. */ + +bool BKE_scene_multiview_is_stereo3d(const struct RenderData *rd); +/** + * Return whether to render this #SceneRenderView. + */ +bool BKE_scene_multiview_is_render_view_active(const struct RenderData *rd, + const struct SceneRenderView *srv); +/** + * \return true if `viewname` is the first or if the name is NULL or not found. + */ +bool BKE_scene_multiview_is_render_view_first(const struct RenderData *rd, const char *viewname); +/** + * \return true if `viewname` is the last or if the name is NULL or not found. + */ +bool BKE_scene_multiview_is_render_view_last(const struct RenderData *rd, const char *viewname); +int BKE_scene_multiview_num_views_get(const struct RenderData *rd); +struct SceneRenderView *BKE_scene_multiview_render_view_findindex(const struct RenderData *rd, + int view_id); +const char *BKE_scene_multiview_render_view_name_get(const struct RenderData *rd, int view_id); +int BKE_scene_multiview_view_id_get(const struct RenderData *rd, const char *viewname); +void BKE_scene_multiview_filepath_get(const struct SceneRenderView *srv, + const char *filepath, + char *r_filepath); +/** + * When multi-view is not used the `filepath` is as usual (e.g., `Image.jpg`). + * When multi-view is on, even if only one view is enabled the view is incorporated + * into the file name (e.g., `Image_L.jpg`). That allows for the user to re-render + * individual views. + */ +void BKE_scene_multiview_view_filepath_get(const struct RenderData *rd, + const char *filepath, + const char *view, + char *r_filepath); +const char *BKE_scene_multiview_view_suffix_get(const struct RenderData *rd, const char *viewname); +const char *BKE_scene_multiview_view_id_suffix_get(const struct RenderData *rd, int view_id); +void BKE_scene_multiview_view_prefix_get(struct Scene *scene, + const char *name, + char *r_prefix, + const char **r_ext); +void BKE_scene_multiview_videos_dimensions_get( + const struct RenderData *rd, size_t width, size_t height, size_t *r_width, size_t *r_height); +int BKE_scene_multiview_num_videos_get(const struct RenderData *rd); + +/* depsgraph */ +void BKE_scene_allocate_depsgraph_hash(struct Scene *scene); +void BKE_scene_ensure_depsgraph_hash(struct Scene *scene); +void BKE_scene_free_depsgraph_hash(struct Scene *scene); +void BKE_scene_free_view_layer_depsgraph(struct Scene *scene, struct ViewLayer *view_layer); + +/** + * \note Do not allocate new depsgraph. + */ +struct Depsgraph *BKE_scene_get_depsgraph(const struct Scene *scene, + const struct ViewLayer *view_layer); +/** + * \note Allocate new depsgraph if necessary. + */ +struct Depsgraph *BKE_scene_ensure_depsgraph(struct Main *bmain, + struct Scene *scene, + struct ViewLayer *view_layer); + +struct GHash *BKE_scene_undo_depsgraphs_extract(struct Main *bmain); +void BKE_scene_undo_depsgraphs_restore(struct Main *bmain, struct GHash *depsgraph_extract); + +void BKE_scene_transform_orientation_remove(struct Scene *scene, + struct TransformOrientation *orientation); +struct TransformOrientation *BKE_scene_transform_orientation_find(const struct Scene *scene, + int index); +/** + * \return the index that \a orientation has within \a scene's transform-orientation list + * or -1 if not found. + */ +int BKE_scene_transform_orientation_get_index(const struct Scene *scene, + const struct TransformOrientation *orientation); + +void BKE_scene_cursor_rot_to_mat3(const struct View3DCursor *cursor, float mat[3][3]); +void BKE_scene_cursor_mat3_to_rot(struct View3DCursor *cursor, + const float mat[3][3], + bool use_compat); + +void BKE_scene_cursor_rot_to_quat(const struct View3DCursor *cursor, float quat[4]); +void BKE_scene_cursor_quat_to_rot(struct View3DCursor *cursor, + const float quat[4], + bool use_compat); + +void BKE_scene_cursor_to_mat4(const struct View3DCursor *cursor, float mat[4][4]); +void BKE_scene_cursor_from_mat4(struct View3DCursor *cursor, + const float mat[4][4], + bool use_compat); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenkernel/BKE_scene.hh b/source/blender/blenkernel/BKE_scene.hh deleted file mode 100644 index 518a9d47929..00000000000 --- a/source/blender/blenkernel/BKE_scene.hh +++ /dev/null @@ -1,330 +0,0 @@ -/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved. - * - * SPDX-License-Identifier: GPL-2.0-or-later */ -#pragma once - -/** \file - * \ingroup bke - */ - -#include "BLI_sys_types.h" - -struct AviCodecData; -struct Base; -struct Collection; -struct Depsgraph; -struct DupliObject; -struct GHash; -struct Main; -struct ListBase; -struct Object; -struct RenderData; -struct Scene; -struct SceneRenderView; -struct ToolSettings; -struct TransformOrientation; -struct TransformOrientationSlot; -struct UnitSettings; -struct View3DCursor; -struct ViewLayer; - -enum eSceneCopyMethod { - SCE_COPY_NEW = 0, - SCE_COPY_EMPTY = 1, - SCE_COPY_LINK_COLLECTION = 2, - SCE_COPY_FULL = 3, -}; - -/** Use as the contents of a 'for' loop: `for (SETLOOPER(...)) { ... }`. */ -#define SETLOOPER(_sce_basis, _sce_iter, _base) \ - _sce_iter = _sce_basis, \ - _base = _setlooper_base_step( \ - &_sce_iter, BKE_view_layer_context_active_PLACEHOLDER(_sce_basis), NULL); \ - _base; \ - _base = _setlooper_base_step(&_sce_iter, NULL, _base) - -#define SETLOOPER_VIEW_LAYER(_sce_basis, _view_layer, _sce_iter, _base) \ - _sce_iter = _sce_basis, _base = _setlooper_base_step(&_sce_iter, _view_layer, NULL); \ - _base; \ - _base = _setlooper_base_step(&_sce_iter, NULL, _base) - -#define SETLOOPER_SET_ONLY(_sce_basis, _sce_iter, _base) \ - _sce_iter = _sce_basis, _base = _setlooper_base_step(&_sce_iter, NULL, NULL); \ - _base; \ - _base = _setlooper_base_step(&_sce_iter, NULL, _base) - -/** - * Helper function for the #SETLOOPER and #SETLOOPER_VIEW_LAYER macros - * - * It iterates over the bases of the active layer and then the bases - * of the active layer of the background (set) scenes recursively. - */ -Base *_setlooper_base_step(Scene **sce_iter, ViewLayer *view_layer, Base *base); - -void free_avicodecdata(AviCodecData *acd); - -Scene *BKE_scene_add(Main *bmain, const char *name); - -void BKE_scene_remove_rigidbody_object(Main *bmain, Scene *scene, Object *ob, bool free_us); - -/** - * Check if there is any instance of the object in the scene. - */ -bool BKE_scene_object_find(Scene *scene, Object *ob); -Object *BKE_scene_object_find_by_name(const Scene *scene, const char *name); - -/* Scene base iteration function. - * Define struct here, so no need to bother with alloc/free it. - */ -struct SceneBaseIter { - ListBase *duplilist; - DupliObject *dupob; - float omat[4][4]; - Object *dupli_refob; - int phase; -}; - -/** - * Used by meta-balls, return *all* objects (including duplis) - * existing in the scene (including scene's sets). - */ -int BKE_scene_base_iter_next( - Depsgraph *depsgraph, SceneBaseIter *iter, Scene **scene, int val, Base **base, Object **ob); - -void BKE_scene_base_flag_to_objects(const Scene *scene, ViewLayer *view_layer); -/** - * Synchronize object base flags - * - * This is usually handled by the depsgraph. - * However, in rare occasions we need to use the latest object flags - * before depsgraph is fully updated. - * - * It should (ideally) only run for copy-on-written objects since this is - * runtime data generated per-view-layer. - */ -void BKE_scene_object_base_flag_sync_from_base(Base *base); - -/** - * Sets the active scene, mainly used when running in background mode - * (`--scene` command line argument). - * This is also called to set the scene directly, bypassing windowing code. - * Otherwise #WM_window_set_active_scene is used when changing scenes by the user. - */ -void BKE_scene_set_background(Main *bmain, Scene *sce); -/** - * Called from `creator_args.c`. - */ -Scene *BKE_scene_set_name(Main *bmain, const char *name); - -/** - * \param flag: copying options (see BKE_lib_id.hh's `LIB_ID_COPY_...` flags for more). - */ -ToolSettings *BKE_toolsettings_copy(ToolSettings *toolsettings, int flag); -void BKE_toolsettings_free(ToolSettings *toolsettings); - -Scene *BKE_scene_duplicate(Main *bmain, Scene *sce, eSceneCopyMethod type); -void BKE_scene_groups_relink(Scene *sce); - -bool BKE_scene_can_be_removed(const Main *bmain, const Scene *scene); - -bool BKE_scene_has_view_layer(const Scene *scene, const ViewLayer *layer); -Scene *BKE_scene_find_from_collection(const Main *bmain, const Collection *collection); - -#ifdef DURIAN_CAMERA_SWITCH -Object *BKE_scene_camera_switch_find(Scene *scene); /* DURIAN_CAMERA_SWITCH */ -#endif -bool BKE_scene_camera_switch_update(Scene *scene); - -const char *BKE_scene_find_marker_name(const Scene *scene, int frame); -/** - * Return the current marker for this frame, - * we can have more than 1 marker per frame, this just returns the first (unfortunately). - */ -const char *BKE_scene_find_last_marker_name(const Scene *scene, int frame); - -int BKE_scene_frame_snap_by_seconds(Scene *scene, double interval_in_seconds, int frame); - -/** - * Checks for cycle, returns true if it's all OK. - */ -bool BKE_scene_validate_setscene(Main *bmain, Scene *sce); - -/** - * Return fractional frame number taking into account sub-frames and time - * remapping. This the time value used by animation, modifiers and physics - * evaluation. */ -float BKE_scene_ctime_get(const Scene *scene); -/** - * Convert integer frame number to fractional frame number taking into account - * sub-frames and time remapping. - */ -float BKE_scene_frame_to_ctime(const Scene *scene, int frame); - -/** - * Get current fractional frame based on frame and sub-frame. - */ -float BKE_scene_frame_get(const Scene *scene); -/** - * Set current frame and sub-frame based on a fractional frame. - */ -void BKE_scene_frame_set(Scene *scene, float frame); - -TransformOrientationSlot *BKE_scene_orientation_slot_get_from_flag(Scene *scene, int flag); -TransformOrientationSlot *BKE_scene_orientation_slot_get(Scene *scene, int slot_index); -/** - * Activate a transform orientation in a 3D view based on an enum value. - * - * \param orientation: If this is #V3D_ORIENT_CUSTOM or greater, the custom transform orientation - * with index \a orientation - #V3D_ORIENT_CUSTOM gets activated. - */ -void BKE_scene_orientation_slot_set_index(TransformOrientationSlot *orient_slot, int orientation); -int BKE_scene_orientation_slot_get_index(const TransformOrientationSlot *orient_slot); -int BKE_scene_orientation_get_index(Scene *scene, int slot_index); -int BKE_scene_orientation_get_index_from_flag(Scene *scene, int flag); - -/* ** Scene evaluation ** */ - -void BKE_scene_update_sound(Depsgraph *depsgraph, Main *bmain); -void BKE_scene_update_tag_audio_volume(Depsgraph *, Scene *scene); - -void BKE_scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain); -void BKE_scene_graph_evaluated_ensure(Depsgraph *depsgraph, Main *bmain); - -void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph); -/** - * Applies changes right away, does all sets too. - */ -void BKE_scene_graph_update_for_newframe_ex(Depsgraph *depsgraph, bool clear_recalc); - -/** - * Ensures given scene/view_layer pair has a valid, up-to-date depsgraph. - * - * \warning Sets matching depsgraph as active, - * so should only be called from the active editing context (usually, from operators). - */ -void BKE_scene_view_layer_graph_evaluated_ensure(Main *bmain, Scene *scene, ViewLayer *view_layer); - -/** - * Return default view. - */ -SceneRenderView *BKE_scene_add_render_view(Scene *sce, const char *name); -bool BKE_scene_remove_render_view(Scene *scene, SceneRenderView *srv); - -/* Render profile. */ - -int get_render_subsurf_level(const RenderData *r, int lvl, bool for_render); -int get_render_child_particle_number(const RenderData *r, int child_num, bool for_render); - -bool BKE_scene_use_shading_nodes_custom(Scene *scene); -bool BKE_scene_use_spherical_stereo(Scene *scene); - -bool BKE_scene_uses_blender_eevee(const Scene *scene); -bool BKE_scene_uses_blender_workbench(const Scene *scene); -bool BKE_scene_uses_cycles(const Scene *scene); - -bool BKE_scene_uses_shader_previews(const Scene *scene); - -/** - * Return whether the Cycles experimental feature is enabled. It is invalid to call without first - * ensuring that Cycles is the active render engine (e.g. with #BKE_scene_uses_cycles). - * - * \note We cannot use `const` as RNA_id_pointer_create is not using a const ID. - */ -bool BKE_scene_uses_cycles_experimental_features(Scene *scene); - -void BKE_scene_copy_data_eevee(Scene *sce_dst, const Scene *sce_src); - -void BKE_scene_disable_color_management(Scene *scene); -bool BKE_scene_check_rigidbody_active(const Scene *scene); - -int BKE_scene_num_threads(const Scene *scene); -int BKE_render_num_threads(const RenderData *r); - -void BKE_render_resolution(const RenderData *r, const bool use_crop, int *r_width, int *r_height); -int BKE_render_preview_pixel_size(const RenderData *r); - -/**********************************/ - -/** - * Apply the needed correction factor to value, based on unit_type - * (only length-related are affected currently) and `unit->scale_length`. - */ -double BKE_scene_unit_scale(const UnitSettings *unit, int unit_type, double value); - -/* Multi-view. */ - -bool BKE_scene_multiview_is_stereo3d(const RenderData *rd); -/** - * Return whether to render this #SceneRenderView. - */ -bool BKE_scene_multiview_is_render_view_active(const RenderData *rd, const SceneRenderView *srv); -/** - * \return true if `viewname` is the first or if the name is NULL or not found. - */ -bool BKE_scene_multiview_is_render_view_first(const RenderData *rd, const char *viewname); -/** - * \return true if `viewname` is the last or if the name is NULL or not found. - */ -bool BKE_scene_multiview_is_render_view_last(const RenderData *rd, const char *viewname); -int BKE_scene_multiview_num_views_get(const RenderData *rd); -SceneRenderView *BKE_scene_multiview_render_view_findindex(const RenderData *rd, int view_id); -const char *BKE_scene_multiview_render_view_name_get(const RenderData *rd, int view_id); -int BKE_scene_multiview_view_id_get(const RenderData *rd, const char *viewname); -void BKE_scene_multiview_filepath_get(const SceneRenderView *srv, - const char *filepath, - char *r_filepath); -/** - * When multi-view is not used the `filepath` is as usual (e.g., `Image.jpg`). - * When multi-view is on, even if only one view is enabled the view is incorporated - * into the file name (e.g., `Image_L.jpg`). That allows for the user to re-render - * individual views. - */ -void BKE_scene_multiview_view_filepath_get(const RenderData *rd, - const char *filepath, - const char *view, - char *r_filepath); -const char *BKE_scene_multiview_view_suffix_get(const RenderData *rd, const char *viewname); -const char *BKE_scene_multiview_view_id_suffix_get(const RenderData *rd, int view_id); -void BKE_scene_multiview_view_prefix_get(Scene *scene, - const char *name, - char *r_prefix, - const char **r_ext); -void BKE_scene_multiview_videos_dimensions_get( - const RenderData *rd, size_t width, size_t height, size_t *r_width, size_t *r_height); -int BKE_scene_multiview_num_videos_get(const RenderData *rd); - -/* depsgraph */ -void BKE_scene_allocate_depsgraph_hash(Scene *scene); -void BKE_scene_ensure_depsgraph_hash(Scene *scene); -void BKE_scene_free_depsgraph_hash(Scene *scene); -void BKE_scene_free_view_layer_depsgraph(Scene *scene, ViewLayer *view_layer); - -/** - * \note Do not allocate new depsgraph. - */ -Depsgraph *BKE_scene_get_depsgraph(const Scene *scene, const ViewLayer *view_layer); -/** - * \note Allocate new depsgraph if necessary. - */ -Depsgraph *BKE_scene_ensure_depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer); - -GHash *BKE_scene_undo_depsgraphs_extract(Main *bmain); -void BKE_scene_undo_depsgraphs_restore(Main *bmain, GHash *depsgraph_extract); - -void BKE_scene_transform_orientation_remove(Scene *scene, TransformOrientation *orientation); -TransformOrientation *BKE_scene_transform_orientation_find(const Scene *scene, int index); -/** - * \return the index that \a orientation has within \a scene's transform-orientation list - * or -1 if not found. - */ -int BKE_scene_transform_orientation_get_index(const Scene *scene, - const TransformOrientation *orientation); - -void BKE_scene_cursor_rot_to_mat3(const View3DCursor *cursor, float mat[3][3]); -void BKE_scene_cursor_mat3_to_rot(View3DCursor *cursor, const float mat[3][3], bool use_compat); - -void BKE_scene_cursor_rot_to_quat(const View3DCursor *cursor, float quat[4]); -void BKE_scene_cursor_quat_to_rot(View3DCursor *cursor, const float quat[4], bool use_compat); - -void BKE_scene_cursor_to_mat4(const View3DCursor *cursor, float mat[4][4]); -void BKE_scene_cursor_from_mat4(View3DCursor *cursor, const float mat[4][4], bool use_compat); diff --git a/source/blender/blenkernel/BKE_scene_runtime.hh b/source/blender/blenkernel/BKE_scene_runtime.hh deleted file mode 100644 index 87b2faf7552..00000000000 --- a/source/blender/blenkernel/BKE_scene_runtime.hh +++ /dev/null @@ -1,25 +0,0 @@ -/* SPDX-FileCopyrightText: 2024 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#pragma once - -#include "BLI_map.hh" -#include "BLI_timeit.hh" -#include "BLI_utility_mixins.hh" - -namespace blender::bke { - -/* Runtime data specific to the compositing trees. */ -struct CompositorRuntime { - /* Per-node instance total execution time for the corresponding node, during the last tree - * evaluation. */ - Map per_node_execution_time; -}; - -class SceneRuntime : NonCopyable, NonMovable { - public: - CompositorRuntime compositor; -}; - -} // namespace blender::bke diff --git a/source/blender/blenkernel/BKE_screen.hh b/source/blender/blenkernel/BKE_screen.hh index 8053eaa36ab..2b4ef5a5e01 100644 --- a/source/blender/blenkernel/BKE_screen.hh +++ b/source/blender/blenkernel/BKE_screen.hh @@ -17,10 +17,6 @@ #include "BKE_context.hh" -namespace blender::bke::id { -class IDRemapper; -} - namespace blender::asset_system { class AssetRepresentation; } @@ -32,6 +28,7 @@ struct BlendLibReader; struct BlendWriter; struct Header; struct ID; +struct IDRemapper; struct LayoutPanelState; struct LibraryForeachIDData; struct ListBase; @@ -112,7 +109,7 @@ struct SpaceType { bContextDataCallback context; /* Used when we want to replace an ID by another (or NULL). */ - void (*id_remap)(ScrArea *area, SpaceLink *sl, const blender::bke::id::IDRemapper &mappings); + void (*id_remap)(ScrArea *area, SpaceLink *sl, const IDRemapper *mappings); /** * foreach_id callback to process all ID pointers of the editor. Used indirectly by lib_query's diff --git a/source/blender/blenkernel/BKE_undo_system.hh b/source/blender/blenkernel/BKE_undo_system.hh index de8d5c9e7fd..c194bbb2549 100644 --- a/source/blender/blenkernel/BKE_undo_system.hh +++ b/source/blender/blenkernel/BKE_undo_system.hh @@ -17,7 +17,6 @@ struct UndoType; struct bContext; /* IDs */ -struct GreasePencil; struct Main; struct Mesh; struct Object; @@ -34,7 +33,6 @@ struct UndoRefID { struct ptr_ty *ptr; \ char name[MAX_ID_NAME]; \ } -UNDO_REF_ID_TYPE(GreasePencil); UNDO_REF_ID_TYPE(Mesh); UNDO_REF_ID_TYPE(Object); UNDO_REF_ID_TYPE(Scene); diff --git a/source/blender/blenkernel/BKE_viewer_path.hh b/source/blender/blenkernel/BKE_viewer_path.hh index c4dd2fee0ad..da485e1cdb9 100644 --- a/source/blender/blenkernel/BKE_viewer_path.hh +++ b/source/blender/blenkernel/BKE_viewer_path.hh @@ -29,10 +29,7 @@ struct BlendDataReader; struct BlendLibReader; struct LibraryForeachIDData; struct Library; - -namespace blender::bke::id { -class IDRemapper; -} +struct IDRemapper; enum ViewerPathEqualFlag { VIEWER_PATH_EQUAL_FLAG_IGNORE_REPEAT_ITERATION = (1 << 0), @@ -47,8 +44,7 @@ bool BKE_viewer_path_equal(const ViewerPath *a, void BKE_viewer_path_blend_write(BlendWriter *writer, const ViewerPath *viewer_path); void BKE_viewer_path_blend_read_data(BlendDataReader *reader, ViewerPath *viewer_path); void BKE_viewer_path_foreach_id(LibraryForeachIDData *data, ViewerPath *viewer_path); -void BKE_viewer_path_id_remap(ViewerPath *viewer_path, - const blender::bke::id::IDRemapper &mappings); +void BKE_viewer_path_id_remap(ViewerPath *viewer_path, const IDRemapper *mappings); ViewerPathElem *BKE_viewer_path_elem_new(ViewerPathElemType type); IDViewerPathElem *BKE_viewer_path_elem_new_id(); diff --git a/source/blender/blenkernel/BKE_wm_runtime.hh b/source/blender/blenkernel/BKE_wm_runtime.hh deleted file mode 100644 index 01ccdd8d301..00000000000 --- a/source/blender/blenkernel/BKE_wm_runtime.hh +++ /dev/null @@ -1,23 +0,0 @@ -/* SPDX-FileCopyrightText: 2024 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#pragma once - -#include "DNA_windowmanager_types.h" - -namespace blender::bke { - -class WindowManagerRuntime { - public: - /** Indicates whether interface is locked for user interaction. */ - bool is_interface_locked = false; - - /** Information and error reports. */ - ReportList reports; - - WindowManagerRuntime(); - ~WindowManagerRuntime(); -}; - -} // namespace blender::bke diff --git a/source/blender/blenkernel/BKE_writeffmpeg.hh b/source/blender/blenkernel/BKE_writeffmpeg.hh index d63e1cfcf25..7910371e9a3 100644 --- a/source/blender/blenkernel/BKE_writeffmpeg.hh +++ b/source/blender/blenkernel/BKE_writeffmpeg.hh @@ -29,10 +29,14 @@ enum { enum { FFMPEG_PRESET_NONE = 0, - FFMPEG_PRESET_H264 = 1, - FFMPEG_PRESET_THEORA = 2, - FFMPEG_PRESET_XVID = 3, - FFMPEG_PRESET_AV1 = 4, + FFMPEG_PRESET_DVD = 1, + FFMPEG_PRESET_SVCD = 2, + FFMPEG_PRESET_VCD = 3, + FFMPEG_PRESET_DV = 4, + FFMPEG_PRESET_H264 = 5, + FFMPEG_PRESET_THEORA = 6, + FFMPEG_PRESET_XVID = 7, + FFMPEG_PRESET_AV1 = 8, }; struct AVFrame; @@ -71,18 +75,8 @@ bool BKE_ffmpeg_alpha_channel_is_supported(const RenderData *rd); void *BKE_ffmpeg_context_create(void); void BKE_ffmpeg_context_free(void *context_v); -void BKE_ffmpeg_exit(); - -/** - * Gets a `libswscale` context for given size and format parameters. - * After you're done using the context, call #BKE_ffmpeg_sws_release_context - * to release it. Internally the contexts are coming from the context - * pool/cache. - */ SwsContext *BKE_ffmpeg_sws_get_context( int width, int height, int av_src_format, int av_dst_format, int sws_flags); -void BKE_ffmpeg_sws_release_context(SwsContext *ctx); - void BKE_ffmpeg_sws_scale_frame(SwsContext *ctx, AVFrame *dst, const AVFrame *src); #endif diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index fd67cdbf541..b6f1be2ee5f 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -315,7 +315,6 @@ set(SRC intern/volume_grid_file_cache.cc intern/volume_render.cc intern/volume_to_mesh.cc - intern/wm_runtime.cc intern/workspace.cc intern/world.cc intern/writeavi.cc @@ -342,7 +341,7 @@ set(SRC BKE_bake_items_paths.hh BKE_bake_items_serialize.hh BKE_bake_items_socket.hh - BKE_blender.hh + BKE_blender.h BKE_blender_copybuffer.hh BKE_blender_undo.hh BKE_blender_user_menu.hh @@ -350,16 +349,16 @@ set(SRC BKE_blendfile.hh BKE_blendfile_link_append.hh BKE_boids.h - BKE_bpath.hh + BKE_bpath.h BKE_brush.hh BKE_bvhutils.hh - BKE_cachefile.hh - BKE_callbacks.hh + BKE_cachefile.h + BKE_callbacks.h BKE_camera.h BKE_ccg.h BKE_cdderivedmesh.h BKE_cloth.hh - BKE_collection.hh + BKE_collection.h BKE_collision.h BKE_colorband.hh BKE_colortools.hh @@ -382,7 +381,7 @@ set(SRC BKE_data_transfer.h BKE_deform.hh BKE_displist.h - BKE_duplilist.hh + BKE_duplilist.h BKE_dynamicpaint.h BKE_editlattice.h BKE_editmesh.hh @@ -398,7 +397,7 @@ set(SRC BKE_geometry_fields.hh BKE_geometry_set.hh BKE_geometry_set_instances.hh - BKE_global.hh + BKE_global.h BKE_gpencil_curve_legacy.h BKE_gpencil_geom_legacy.h BKE_gpencil_legacy.h @@ -406,7 +405,6 @@ set(SRC BKE_gpencil_update_cache_legacy.h BKE_grease_pencil.h BKE_grease_pencil.hh - BKE_grease_pencil_legacy_convert.hh BKE_grease_pencil_vertex_groups.hh BKE_icons.h BKE_idprop.h @@ -460,6 +458,7 @@ set(SRC BKE_movieclip.h BKE_multires.hh BKE_nla.h + BKE_node.h BKE_node.hh BKE_node_enum.hh BKE_node_runtime.hh @@ -485,10 +484,9 @@ set(SRC BKE_pose_backup.h BKE_preferences.h BKE_preview_image.hh - BKE_report.hh + BKE_report.h BKE_rigidbody.h - BKE_scene.hh - BKE_scene_runtime.hh + BKE_scene.h BKE_screen.hh BKE_sequencer_offscreen.h BKE_shader_fx.h @@ -523,7 +521,6 @@ set(SRC BKE_volume_openvdb.hh BKE_volume_render.hh BKE_volume_to_mesh.hh - BKE_wm_runtime.hh BKE_workspace.h BKE_world.h BKE_writeavi.h diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc index 17877da57a2..6c4553d4f08 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.cc +++ b/source/blender/blenkernel/intern/DerivedMesh.cc @@ -109,13 +109,13 @@ static float *dm_getVertArray(DerivedMesh *dm) return (float *)positions; } -static blender::int2 *dm_getEdgeArray(DerivedMesh *dm) +static vec2i *dm_getEdgeArray(DerivedMesh *dm) { - blender::int2 *edge = (blender::int2 *)CustomData_get_layer_named_for_write( + vec2i *edge = (vec2i *)CustomData_get_layer_named_for_write( &dm->edgeData, CD_PROP_INT32_2D, ".edge_verts", dm->getNumEdges(dm)); if (!edge) { - edge = (blender::int2 *)CustomData_add_layer_named( + edge = (vec2i *)CustomData_add_layer_named( &dm->edgeData, CD_PROP_INT32_2D, CD_SET_DEFAULT, dm->getNumEdges(dm), ".edge_verts"); CustomData_set_layer_flag(&dm->edgeData, CD_PROP_INT32_2D, CD_FLAG_TEMPORARY); dm->copyEdgeArray(dm, edge); diff --git a/source/blender/blenkernel/intern/action.cc b/source/blender/blenkernel/intern/action.cc index 91fe3fbad05..232be615bb4 100644 --- a/source/blender/blenkernel/intern/action.cc +++ b/source/blender/blenkernel/intern/action.cc @@ -32,7 +32,7 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" #include "BKE_anim_data.h" @@ -268,7 +268,6 @@ static AssetTypeInfo AssetType_AC = { IDTypeInfo IDType_ID_AC = { /*id_code*/ ID_AC, /*id_filter*/ FILTER_ID_AC, - /*dependencies_id_types*/ 0, /*main_listbase_index*/ INDEX_ID_AC, /*struct_size*/ sizeof(bAction), /*name*/ "Action", @@ -1712,7 +1711,7 @@ void what_does_obaction(Object *ob, workob->runtime = &workob_runtime; /* init workob */ - copy_m4_m4(workob->runtime->object_to_world.ptr(), ob->object_to_world().ptr()); + copy_m4_m4(workob->object_to_world, ob->object_to_world); copy_m4_m4(workob->parentinv, ob->parentinv); copy_m4_m4(workob->constinv, ob->constinv); workob->parent = ob->parent; diff --git a/source/blender/blenkernel/intern/anim_data.cc b/source/blender/blenkernel/intern/anim_data.cc index 1ba45d00a26..0e7e9badcde 100644 --- a/source/blender/blenkernel/intern/anim_data.cc +++ b/source/blender/blenkernel/intern/anim_data.cc @@ -15,14 +15,14 @@ #include "BKE_context.hh" #include "BKE_fcurve.h" #include "BKE_fcurve_driver.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_main.hh" #include "BKE_nla.h" -#include "BKE_node.hh" -#include "BKE_report.hh" +#include "BKE_node.h" +#include "BKE_report.h" #include "DNA_ID.h" #include "DNA_anim_types.h" diff --git a/source/blender/blenkernel/intern/anim_sys.cc b/source/blender/blenkernel/intern/anim_sys.cc index 343c40509aa..db4fa849efc 100644 --- a/source/blender/blenkernel/intern/anim_sys.cc +++ b/source/blender/blenkernel/intern/anim_sys.cc @@ -23,7 +23,7 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_anim_types.h" #include "DNA_light_types.h" @@ -40,14 +40,14 @@ #include "BKE_animsys.h" #include "BKE_context.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_main.hh" #include "BKE_material.h" #include "BKE_nla.h" -#include "BKE_node.hh" -#include "BKE_report.hh" +#include "BKE_node.h" +#include "BKE_report.h" #include "BKE_texture.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/blenkernel/intern/anim_visualization.cc b/source/blender/blenkernel/intern/anim_visualization.cc index ac10946a2bf..940d63f6c06 100644 --- a/source/blender/blenkernel/intern/anim_visualization.cc +++ b/source/blender/blenkernel/intern/anim_visualization.cc @@ -8,12 +8,14 @@ #include "MEM_guardedalloc.h" #include "DNA_action_types.h" +#include "DNA_anim_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_anim_visualization.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "GPU_batch.h" diff --git a/source/blender/blenkernel/intern/appdir.cc b/source/blender/blenkernel/intern/appdir.cc index 9a6e1ae0f53..e0f63b147df 100644 --- a/source/blender/blenkernel/intern/appdir.cc +++ b/source/blender/blenkernel/intern/appdir.cc @@ -25,7 +25,7 @@ #include "BKE_appdir.hh" /* own include */ #include "BKE_blender_version.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "GHOST_Path-api.hh" diff --git a/source/blender/blenkernel/intern/armature.cc b/source/blender/blenkernel/intern/armature.cc index 1e2ab9e7f50..3cfb9d1b431 100644 --- a/source/blender/blenkernel/intern/armature.cc +++ b/source/blender/blenkernel/intern/armature.cc @@ -27,7 +27,7 @@ #include "BLI_string.h" #include "BLI_string_ref.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" @@ -50,7 +50,7 @@ #include "BKE_main.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "ANIM_bone_collections.hh" @@ -475,8 +475,6 @@ static void armature_undo_preserve(BlendLibReader * /*reader*/, ID *id_new, ID * IDTypeInfo IDType_ID_AR = { /*id_code*/ ID_AR, /*id_filter*/ FILTER_ID_AR, - /* IDProps of armature bones can use any type of ID. */ - /*dependencies_id_types*/ FILTER_ID_ALL, /*main_listbase_index*/ INDEX_ID_AR, /*struct_size*/ sizeof(bArmature), /*name*/ "Armature", @@ -1994,7 +1992,7 @@ void BKE_armature_mat_world_to_pose(Object *ob, const float inmat[4][4], float o } /* Get inverse of (armature) object's matrix. */ - invert_m4_m4(obmat, ob->object_to_world().ptr()); + invert_m4_m4(obmat, ob->object_to_world); /* multiply given matrix by object's-inverse to find pose-space matrix */ mul_m4_m4m4(outmat, inmat, obmat); @@ -2969,7 +2967,7 @@ void BKE_pose_where_is(Depsgraph *depsgraph, Scene *scene, Object *ob) } } else { - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); /* world_to_object is needed */ /* 1. clear flags */ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { @@ -3070,16 +3068,16 @@ void BKE_pchan_minmax(const Object *ob, pchan->custom_translation[0], pchan->custom_translation[1], pchan->custom_translation[2]); - mul_m4_series(mat, ob->object_to_world().ptr(), tmp, rmat, smat); + mul_m4_series(mat, ob->object_to_world, tmp, rmat, smat); BoundBox bb; BKE_boundbox_init_from_minmax(&bb, bb_custom->min, bb_custom->max); BKE_boundbox_minmax(&bb, mat, r_min, r_max); } else { float vec[3]; - mul_v3_m4v3(vec, ob->object_to_world().ptr(), pchan_tx->pose_head); + mul_v3_m4v3(vec, ob->object_to_world, pchan_tx->pose_head); minmax_v3v3_v3(r_min, r_max, vec); - mul_v3_m4v3(vec, ob->object_to_world().ptr(), pchan_tx->pose_tail); + mul_v3_m4v3(vec, ob->object_to_world, pchan_tx->pose_tail); minmax_v3v3_v3(r_min, r_max, vec); } } diff --git a/source/blender/blenkernel/intern/armature_deform.cc b/source/blender/blenkernel/intern/armature_deform.cc index 99b21353c70..1ec7101abb1 100644 --- a/source/blender/blenkernel/intern/armature_deform.cc +++ b/source/blender/blenkernel/intern/armature_deform.cc @@ -600,9 +600,9 @@ static void armature_deform_coords_impl(const Object *ob_arm, data.bmesh.cd_dvert_offset = cd_dvert_offset; float obinv[4][4]; - invert_m4_m4(obinv, ob_target->object_to_world().ptr()); + invert_m4_m4(obinv, ob_target->object_to_world); - mul_m4_m4m4(data.postmat, obinv, ob_arm->object_to_world().ptr()); + mul_m4_m4m4(data.postmat, obinv, ob_arm->object_to_world); invert_m4_m4(data.premat, data.postmat); if (em_target != nullptr) { diff --git a/source/blender/blenkernel/intern/armature_update.cc b/source/blender/blenkernel/intern/armature_update.cc index 957121ee0cc..8175f10bf29 100644 --- a/source/blender/blenkernel/intern/armature_update.cc +++ b/source/blender/blenkernel/intern/armature_update.cc @@ -19,14 +19,17 @@ #include "DNA_armature_types.h" #include "DNA_constraint_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BKE_action.h" #include "BKE_anim_path.h" #include "BKE_armature.hh" #include "BKE_curve.hh" +#include "BKE_displist.h" #include "BKE_fcurve.h" +#include "BKE_object.hh" #include "BKE_object_types.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BIK_api.h" @@ -254,11 +257,11 @@ static void apply_curve_transform( * unless the option to allow curve to be positioned elsewhere is activated (i.e. no root). */ if ((ik_data->flag & CONSTRAINT_SPLINEIK_NO_ROOT) == 0) { - mul_m4_v3(ik_data->tar->object_to_world().ptr(), r_vec); + mul_m4_v3(ik_data->tar->object_to_world, r_vec); } /* Convert the position to pose-space. */ - mul_m4_v3(ob->world_to_object().ptr(), r_vec); + mul_m4_v3(ob->world_to_object, r_vec); /* Set the new radius (it should be the average value). */ *r_radius = (radius + *r_radius) / 2; @@ -829,7 +832,7 @@ void BKE_pose_eval_init(Depsgraph *depsgraph, Scene * /*scene*/, Object *object) BLI_assert((object->pose->flag & POSE_RECALC) == 0); /* world_to_object is needed for solvers. */ - invert_m4_m4(object->runtime->world_to_object.ptr(), object->object_to_world().ptr()); + invert_m4_m4(object->world_to_object, object->object_to_world); /* clear flags */ for (bPoseChannel *pchan = static_cast(pose->chanbase.first); pchan != nullptr; diff --git a/source/blender/blenkernel/intern/asset.cc b/source/blender/blenkernel/intern/asset.cc index 0b3daf5eee9..1337c017ffd 100644 --- a/source/blender/blenkernel/intern/asset.cc +++ b/source/blender/blenkernel/intern/asset.cc @@ -52,10 +52,18 @@ AssetMetaData *BKE_asset_metadata_copy(const AssetMetaData *source) BKE_asset_metadata_catalog_id_set(copy, source->catalog_id, source->catalog_simple_name); - copy->author = BLI_strdup_null(source->author); - copy->description = BLI_strdup_null(source->description); - copy->copyright = BLI_strdup_null(source->copyright); - copy->license = BLI_strdup_null(source->license); + if (source->author) { + copy->author = BLI_strdup(source->author); + } + if (source->description) { + copy->description = BLI_strdup(source->description); + } + if (source->copyright) { + copy->copyright = BLI_strdup(source->copyright); + } + if (source->license) { + copy->license = BLI_strdup(source->license); + } BLI_duplicatelist(©->tags, &source->tags); copy->active_tag = source->active_tag; diff --git a/source/blender/blenkernel/intern/asset_weak_reference.cc b/source/blender/blenkernel/intern/asset_weak_reference.cc index 15ec9b3275b..f1d0d06f72a 100644 --- a/source/blender/blenkernel/intern/asset_weak_reference.cc +++ b/source/blender/blenkernel/intern/asset_weak_reference.cc @@ -46,6 +46,12 @@ AssetWeakReference::~AssetWeakReference() MEM_delete(relative_asset_identifier); } +void BKE_asset_weak_reference_free(AssetWeakReference **weak_ref) +{ + MEM_delete(*weak_ref); + *weak_ref = nullptr; +} + AssetWeakReference *BKE_asset_weak_reference_copy(AssetWeakReference *weak_ref) { if (weak_ref == nullptr) { @@ -60,21 +66,21 @@ AssetWeakReference *BKE_asset_weak_reference_copy(AssetWeakReference *weak_ref) return weak_ref_copy; } -AssetWeakReference AssetWeakReference::make_reference( +AssetWeakReference *AssetWeakReference::make_reference( const asset_system::AssetLibrary &library, const asset_system::AssetIdentifier &asset_identifier) { - AssetWeakReference weak_ref{}; + AssetWeakReference *weak_ref = MEM_new(__func__); - weak_ref.asset_library_type = library.library_type(); + weak_ref->asset_library_type = library.library_type(); StringRefNull name = library.name(); if (!name.is_empty()) { - weak_ref.asset_library_identifier = BLI_strdupn(name.c_str(), name.size()); + weak_ref->asset_library_identifier = BLI_strdupn(name.c_str(), name.size()); } StringRefNull relative_identifier = asset_identifier.library_relative_identifier(); - weak_ref.relative_asset_identifier = BLI_strdupn(relative_identifier.c_str(), - relative_identifier.size()); + weak_ref->relative_asset_identifier = BLI_strdupn(relative_identifier.c_str(), + relative_identifier.size()); return weak_ref; } diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index 78bd04e6f30..b9837058413 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -24,7 +24,7 @@ #include "BLI_string_utf8.h" #include "BLI_string_utils.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_attribute.hh" #include "BKE_curves.hh" @@ -33,7 +33,7 @@ #include "BKE_grease_pencil.hh" #include "BKE_mesh.hh" #include "BKE_pointcloud.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "RNA_access.hh" @@ -287,7 +287,7 @@ CustomDataLayer *BKE_id_attribute_new(ID *id, Mesh *mesh = reinterpret_cast(id); if (BMEditMesh *em = mesh->edit_mesh) { BM_data_layer_add_named(em->bm, customdata, type, uniquename.c_str()); - const int index = CustomData_get_named_layer_index(customdata, type, uniquename); + const int index = CustomData_get_named_layer_index(customdata, type, uniquename.c_str()); return (index == -1) ? nullptr : &(customdata->layers[index]); } } @@ -299,7 +299,7 @@ CustomDataLayer *BKE_id_attribute_new(ID *id, attributes->add(uniquename, domain, eCustomDataType(type), AttributeInitDefaultValue()); - const int index = CustomData_get_named_layer_index(customdata, type, uniquename); + const int index = CustomData_get_named_layer_index(customdata, type, uniquename.c_str()); if (index == -1) { BKE_reportf(reports, RPT_WARNING, "Layer '%s' could not be created", uniquename.c_str()); } @@ -417,7 +417,7 @@ bool BKE_id_attribute_remove(ID *id, const char *name, ReportList *reports) for (const int domain : IndexRange(ATTR_DOMAIN_NUM)) { if (CustomData *data = info[domain].customdata) { const std::string name_copy = name; - const int layer_index = CustomData_get_named_layer_index_notype(data, name_copy); + const int layer_index = CustomData_get_named_layer_index_notype(data, name_copy.c_str()); if (layer_index == -1) { continue; } diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index e728a0a7659..92764d2df09 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -17,7 +17,7 @@ #include "BLI_math_vector_types.hh" #include "BLI_span.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "FN_field.hh" @@ -50,8 +50,6 @@ const blender::CPPType *custom_data_type_to_cpp_type(const eCustomDataType type) return &CPPType::get(); case CD_PROP_QUATERNION: return &CPPType::get(); - case CD_PROP_FLOAT4X4: - return &CPPType::get(); case CD_PROP_STRING: return &CPPType::get(); default: @@ -91,9 +89,6 @@ eCustomDataType cpp_type_to_custom_data_type(const blender::CPPType &type) if (type.is()) { return CD_PROP_QUATERNION; } - if (type.is()) { - return CD_PROP_FLOAT4X4; - } if (type.is()) { return CD_PROP_STRING; } @@ -172,8 +167,6 @@ static int attribute_data_type_complexity(const eCustomDataType data_type) return 8; case CD_PROP_COLOR: return 9; - case CD_PROP_FLOAT4X4: - return 10; #if 0 /* These attribute types are not supported yet. */ case CD_PROP_STRING: return 10; @@ -331,8 +324,10 @@ static const void *add_generic_custom_data_layer_with_existing_data( return CustomData_add_layer_anonymous_with_data( &custom_data, data_type, &anonymous_id, domain_size, layer_data, sharing_info); } + char attribute_name_c[MAX_CUSTOMDATA_LAYER_NAME]; + attribute_id.name().copy(attribute_name_c); return CustomData_add_layer_named_with_data( - &custom_data, data_type, layer_data, domain_size, attribute_id.name(), sharing_info); + &custom_data, data_type, layer_data, domain_size, attribute_name_c, sharing_info); } static bool add_custom_data_layer_from_attribute_init(const AttributeIDRef &attribute_id, @@ -394,7 +389,7 @@ static bool custom_data_layer_matches_attribute_id(const CustomDataLayer &layer, bool BuiltinCustomDataLayerProvider::layer_exists(const CustomData &custom_data) const { if (stored_as_named_attribute_) { - return CustomData_get_named_layer_index(&custom_data, stored_type_, name_) != -1; + return CustomData_get_named_layer_index(&custom_data, stored_type_, name_.c_str()) != -1; } return CustomData_has_layer(&custom_data, stored_type_); } @@ -418,7 +413,7 @@ GAttributeReader BuiltinCustomDataLayerProvider::try_get_for_read(const void *ow int index; if (stored_as_named_attribute_) { - index = CustomData_get_named_layer_index(custom_data, stored_type_, name_); + index = CustomData_get_named_layer_index(custom_data, stored_type_, name_.c_str()); } else { index = CustomData_get_layer_index(custom_data, stored_type_); @@ -454,7 +449,8 @@ GAttributeWriter BuiltinCustomDataLayerProvider::try_get_for_write(void *owner) void *data = nullptr; if (stored_as_named_attribute_) { - data = CustomData_get_layer_named_for_write(custom_data, stored_type_, name_, element_num); + data = CustomData_get_layer_named_for_write( + custom_data, stored_type_, name_.c_str(), element_num); } else { data = CustomData_get_layer_for_write(custom_data, stored_type_, element_num); @@ -483,7 +479,7 @@ bool BuiltinCustomDataLayerProvider::try_delete(void *owner) const const int element_num = custom_data_access_.get_element_num(owner); if (stored_as_named_attribute_) { - if (CustomData_free_layer_named(custom_data, name_, element_num)) { + if (CustomData_free_layer_named(custom_data, name_.c_str(), element_num)) { update(); return true; } @@ -512,7 +508,7 @@ bool BuiltinCustomDataLayerProvider::try_create(void *owner, const int element_num = custom_data_access_.get_element_num(owner); if (stored_as_named_attribute_) { - if (CustomData_has_layer_named(custom_data, data_type_, name_)) { + if (CustomData_has_layer_named(custom_data, data_type_, name_.c_str())) { /* Exists already. */ return false; } @@ -535,7 +531,7 @@ bool BuiltinCustomDataLayerProvider::exists(const void *owner) const return false; } if (stored_as_named_attribute_) { - return CustomData_has_layer_named(custom_data, stored_type_, name_); + return CustomData_has_layer_named(custom_data, stored_type_, name_.c_str()); } return CustomData_get_layer(custom_data, stored_type_) != nullptr; } diff --git a/source/blender/blenkernel/intern/attribute_math.cc b/source/blender/blenkernel/intern/attribute_math.cc index a9509101059..f0f9101374d 100644 --- a/source/blender/blenkernel/intern/attribute_math.cc +++ b/source/blender/blenkernel/intern/attribute_math.cc @@ -3,7 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "BLI_array_utils.hh" -#include "BLI_math_matrix.hh" #include "BLI_math_quaternion.hh" #include "BKE_attribute_math.hh" @@ -37,40 +36,6 @@ math::Quaternion mix4(const float4 &weights, return math::Quaternion::expmap(expmap_mixed); } -template<> float4x4 mix2(const float factor, const float4x4 &a, const float4x4 &b) -{ - return math::interpolate(a, b, factor); -} - -template<> -float4x4 mix3(const float3 &weights, const float4x4 &v0, const float4x4 &v1, const float4x4 &v2) -{ - const float3 location = mix3(weights, v0.location(), v1.location(), v2.location()); - const math::Quaternion rotation = mix3( - weights, math::to_quaternion(v0), math::to_quaternion(v1), math::to_quaternion(v2)); - const float3 scale = mix3(weights, math::to_scale(v0), math::to_scale(v1), math::to_scale(v2)); - return math::from_loc_rot_scale(location, rotation, scale); -} - -template<> -float4x4 mix4(const float4 &weights, - const float4x4 &v0, - const float4x4 &v1, - const float4x4 &v2, - const float4x4 &v3) -{ - const float3 location = mix4( - weights, v0.location(), v1.location(), v2.location(), v3.location()); - const math::Quaternion rotation = mix4(weights, - math::to_quaternion(v0), - math::to_quaternion(v1), - math::to_quaternion(v2), - math::to_quaternion(v3)); - const float3 scale = mix4( - weights, math::to_scale(v0), math::to_scale(v1), math::to_scale(v2), math::to_scale(v3)); - return math::from_loc_rot_scale(location, rotation, scale); -} - ColorGeometry4fMixer::ColorGeometry4fMixer(MutableSpan buffer, ColorGeometry4f default_color) : ColorGeometry4fMixer(buffer, buffer.index_range(), default_color) @@ -195,58 +160,6 @@ void ColorGeometry4bMixer::finalize(const IndexMask &mask) }); } -float4x4Mixer::float4x4Mixer(MutableSpan buffer) - : float4x4Mixer(buffer, buffer.index_range()) -{ -} - -float4x4Mixer::float4x4Mixer(MutableSpan buffer, const IndexMask & /*mask*/) - : buffer_(buffer), - total_weights_(buffer.size(), 0.0f), - location_buffer_(buffer.size(), float3(0)), - expmap_buffer_(buffer.size(), float3(0)), - scale_buffer_(buffer.size(), float3(0)) -{ -} - -void float4x4Mixer::float4x4Mixer::set(int64_t index, const float4x4 &value, const float weight) -{ - location_buffer_[index] = value.location() * weight; - expmap_buffer_[index] = math::to_quaternion(value).expmap() * weight; - scale_buffer_[index] = math::to_scale(value) * weight; - total_weights_[index] = weight; -} - -void float4x4Mixer::mix_in(int64_t index, const float4x4 &value, float weight) -{ - location_buffer_[index] += value.location() * weight; - expmap_buffer_[index] += math::to_quaternion(value).expmap() * weight; - scale_buffer_[index] += math::to_scale(value) * weight; - total_weights_[index] += weight; -} - -void float4x4Mixer::finalize() -{ - this->finalize(buffer_.index_range()); -} - -void float4x4Mixer::finalize(const IndexMask &mask) -{ - mask.foreach_index([&](const int64_t i) { - const float weight = total_weights_[i]; - if (weight > 0.0f) { - const float weight_inv = math::rcp(weight); - buffer_[i] = math::from_loc_rot_scale( - location_buffer_[i] * weight_inv, - math::Quaternion::expmap(expmap_buffer_[i] * weight_inv), - scale_buffer_[i] * weight_inv); - } - else { - buffer_[i] = float4x4::identity(); - } - }); -} - void gather(const GSpan src, const Span map, GMutableSpan dst) { attribute_math::convert_to_static_type(src.type(), [&](auto dummy) { diff --git a/source/blender/blenkernel/intern/bake_geometry_nodes_modifier.cc b/source/blender/blenkernel/intern/bake_geometry_nodes_modifier.cc index 7ff12aeeeb8..c2c17b1ea28 100644 --- a/source/blender/blenkernel/intern/bake_geometry_nodes_modifier.cc +++ b/source/blender/blenkernel/intern/bake_geometry_nodes_modifier.cc @@ -5,16 +5,20 @@ #include #include "BKE_bake_geometry_nodes_modifier.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" +#include "BKE_curves.hh" #include "BKE_main.hh" #include "DNA_modifier_types.h" #include "DNA_node_types.h" +#include "DNA_pointcloud_types.h" #include "BLI_binary_search.hh" #include "BLI_fileops.hh" +#include "BLI_hash_md5.hh" #include "BLI_path_util.h" #include "BLI_string.h" +#include "BLI_string_utils.hh" #include "MOD_nodes.hh" diff --git a/source/blender/blenkernel/intern/bake_items.cc b/source/blender/blenkernel/intern/bake_items.cc index 24f9995deb2..97fd43e6e44 100644 --- a/source/blender/blenkernel/intern/bake_items.cc +++ b/source/blender/blenkernel/intern/bake_items.cc @@ -6,15 +6,22 @@ #include "BKE_bake_items_serialize.hh" #include "BKE_curves.hh" #include "BKE_instances.hh" +#include "BKE_lib_id.hh" #include "BKE_mesh.hh" #include "BKE_pointcloud.hh" #include "BKE_volume.hh" +#include "BLI_endian_defines.h" +#include "BLI_endian_switch.h" #include "BLI_math_matrix_types.hh" +#include "BLI_path_util.h" #include "DNA_material_types.h" #include "DNA_volume_types.h" +#include "RNA_access.hh" +#include "RNA_enum_types.hh" + namespace blender::bke::bake { using namespace io::serialize; diff --git a/source/blender/blenkernel/intern/bake_items_serialize.cc b/source/blender/blenkernel/intern/bake_items_serialize.cc index 5c013965fa2..28edca63a09 100644 --- a/source/blender/blenkernel/intern/bake_items_serialize.cc +++ b/source/blender/blenkernel/intern/bake_items_serialize.cc @@ -1042,10 +1042,6 @@ static std::shared_ptr serialize_primitive_value( const math::Quaternion value = *static_cast(value_ptr); return serialize_float_array({&value.x, 4}); } - case CD_PROP_FLOAT4X4: { - const float4x4 value = *static_cast(value_ptr); - return serialize_float_array({value.base_ptr(), value.col_len * value.row_len}); - } default: break; } @@ -1164,9 +1160,6 @@ template case CD_PROP_QUATERNION: { return deserialize_float_array(io_value, {static_cast(r_value), 4}); } - case CD_PROP_FLOAT4X4: { - return deserialize_float_array(io_value, {static_cast(r_value), 4 * 4}); - } default: break; } diff --git a/source/blender/blenkernel/intern/bake_items_socket.cc b/source/blender/blenkernel/intern/bake_items_socket.cc index 11893dcaab2..7ecee920194 100644 --- a/source/blender/blenkernel/intern/bake_items_socket.cc +++ b/source/blender/blenkernel/intern/bake_items_socket.cc @@ -47,7 +47,6 @@ Array> move_socket_values_to_bake_items(const Span(socket_value); if (value_variant.is_context_dependent_field()) { @@ -132,7 +131,6 @@ Array> move_socket_values_to_bake_items(const Span(&bake_item)) { diff --git a/source/blender/blenkernel/intern/blender.cc b/source/blender/blenkernel/intern/blender.cc index 56c15a898d3..a94244eee6c 100644 --- a/source/blender/blenkernel/intern/blender.cc +++ b/source/blender/blenkernel/intern/blender.cc @@ -22,25 +22,31 @@ #include "IMB_moviecache.hh" #include "BKE_addon.h" -#include "BKE_blender.hh" /* own include */ +#include "BKE_blender.h" /* own include */ #include "BKE_blender_user_menu.hh" /* own include */ #include "BKE_blender_version.h" /* own include */ +#include "BKE_blendfile.hh" #include "BKE_brush.hh" -#include "BKE_cachefile.hh" -#include "BKE_callbacks.hh" -#include "BKE_global.hh" +#include "BKE_cachefile.h" +#include "BKE_callbacks.h" +#include "BKE_global.h" #include "BKE_idprop.h" +#include "BKE_image.h" +#include "BKE_layer.hh" #include "BKE_main.hh" -#include "BKE_node.hh" -#include "BKE_report.hh" +#include "BKE_node.h" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_studiolight.h" -#include "BKE_writeffmpeg.hh" #include "DEG_depsgraph.hh" +#include "RE_pipeline.h" #include "RE_texture.h" +#include "SEQ_sequencer.hh" + #include "BLF_api.hh" Global G; @@ -75,9 +81,6 @@ void BKE_blender_free() BKE_callback_global_finalize(); IMB_moviecache_destruct(); -#ifdef WITH_FFMPEG - BKE_ffmpeg_exit(); -#endif BKE_node_system_exit(); } @@ -360,11 +363,6 @@ void BKE_blender_userdef_app_template_data_swap(UserDef *userdef_a, UserDef *use * - various minor settings (add as needed). */ -#define VALUE_SWAP(id) \ - { \ - std::swap(userdef_a->id, userdef_b->id); \ - } - #define DATA_SWAP(id) \ { \ UserDef userdef_tmp; \ @@ -385,12 +383,12 @@ void BKE_blender_userdef_app_template_data_swap(UserDef *userdef_a, UserDef *use } \ ((void)0) - VALUE_SWAP(uistyles); - VALUE_SWAP(uifonts); - VALUE_SWAP(themes); - VALUE_SWAP(addons); - VALUE_SWAP(user_keymaps); - VALUE_SWAP(user_keyconfig_prefs); + std::swap(userdef_a->uistyles, userdef_b->uistyles); + std::swap(userdef_a->uifonts, userdef_b->uifonts); + std::swap(userdef_a->themes, userdef_b->themes); + std::swap(userdef_a->addons, userdef_b->addons); + std::swap(userdef_a->user_keymaps, userdef_b->user_keymaps); + std::swap(userdef_a->user_keyconfig_prefs, userdef_b->user_keyconfig_prefs); DATA_SWAP(font_path_ui); DATA_SWAP(font_path_ui_mono); @@ -404,8 +402,9 @@ void BKE_blender_userdef_app_template_data_swap(UserDef *userdef_a, UserDef *use DATA_SWAP(ui_scale); -#undef VALUE_SWAP +#undef SWAP_TYPELESS #undef DATA_SWAP +#undef LISTBASE_SWAP #undef FLAG_SWAP } diff --git a/source/blender/blenkernel/intern/blender_copybuffer.cc b/source/blender/blenkernel/intern/blender_copybuffer.cc index d7399311336..a6be7e2686c 100644 --- a/source/blender/blenkernel/intern/blender_copybuffer.cc +++ b/source/blender/blenkernel/intern/blender_copybuffer.cc @@ -12,20 +12,32 @@ #include "MEM_guardedalloc.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" #include "DNA_userdef_types.h" +#include "DNA_view3d_types.h" +#include "DNA_windowmanager_types.h" +#include "BLI_blenlib.h" #include "BLI_utildefines.h" +#include "IMB_imbuf.hh" +#include "IMB_moviecache.hh" + #include "BKE_blender_copybuffer.hh" /* own include */ #include "BKE_blendfile.hh" #include "BKE_blendfile_link_append.hh" #include "BKE_context.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" +#include "BKE_main.hh" +#include "BKE_scene.h" +#include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "BLO_writefile.hh" #include "IMB_colormanagement.hh" diff --git a/source/blender/blenkernel/intern/blender_undo.cc b/source/blender/blenkernel/intern/blender_undo.cc index 59c15140b16..880a541f0ff 100644 --- a/source/blender/blenkernel/intern/blender_undo.cc +++ b/source/blender/blenkernel/intern/blender_undo.cc @@ -34,11 +34,11 @@ #include "BKE_blender_undo.hh" /* own include */ #include "BKE_blendfile.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_main.hh" #include "BKE_undo_system.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "BLO_undofile.hh" #include "BLO_writefile.hh" diff --git a/source/blender/blenkernel/intern/blendfile.cc b/source/blender/blenkernel/intern/blendfile.cc index 8c98d10e6bc..879d1e20d93 100644 --- a/source/blender/blenkernel/intern/blendfile.cc +++ b/source/blender/blenkernel/intern/blendfile.cc @@ -31,13 +31,16 @@ #include "BKE_addon.h" #include "BKE_appdir.hh" -#include "BKE_blender.hh" +#include "BKE_blender.h" #include "BKE_blender_version.h" #include "BKE_blendfile.hh" -#include "BKE_bpath.hh" +#include "BKE_bpath.h" #include "BKE_colorband.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" +#include "BKE_idtype.hh" +#include "BKE_ipo.h" +#include "BKE_keyconfig.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_lib_override.hh" @@ -47,25 +50,24 @@ #include "BKE_main_idmap.hh" #include "BKE_main_namemap.hh" #include "BKE_preferences.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_studiolight.h" #include "BKE_undo_system.hh" #include "BKE_workspace.h" -#include "BLO_readfile.hh" -#include "BLO_userdef_default.h" +#include "BLO_readfile.h" #include "BLO_writefile.hh" +#include "RNA_access.hh" + #include "RE_pipeline.h" #ifdef WITH_PYTHON # include "BPY_extern.h" #endif -using namespace blender::bke; - /* -------------------------------------------------------------------- */ /** \name Blend/Library Paths * \{ */ @@ -230,7 +232,7 @@ struct ReuseOldBMainData { /** Storage for all remapping rules (old_id -> new_id) required by the preservation of old IDs * into the new Main. */ - id::IDRemapper *remapper; + IDRemapper *remapper; bool is_libraries_remapped; /** Used to find matching IDs by name/lib in new main, to remap ID usages of data ported over @@ -248,25 +250,25 @@ struct ReuseOldBMainData { * double of a linked data as a local one, without any known relationships between them. In * practice, this latter case is not expected to commonly happen. */ -static id::IDRemapper &reuse_bmain_data_remapper_ensure(ReuseOldBMainData *reuse_data) +static IDRemapper *reuse_bmain_data_remapper_ensure(ReuseOldBMainData *reuse_data) { if (reuse_data->is_libraries_remapped) { - return *reuse_data->remapper; + return reuse_data->remapper; } if (reuse_data->remapper == nullptr) { - reuse_data->remapper = MEM_new(__func__); + reuse_data->remapper = BKE_id_remapper_create(); } Main *new_bmain = reuse_data->new_bmain; Main *old_bmain = reuse_data->old_bmain; - id::IDRemapper &remapper = *reuse_data->remapper; + IDRemapper *remapper = reuse_data->remapper; LISTBASE_FOREACH (Library *, old_lib_iter, &old_bmain->libraries) { /* In case newly opened `new_bmain` is a library of the `old_bmain`, remap it to null, since a * file should never ever have linked data from itself. */ if (STREQ(old_lib_iter->filepath_abs, new_bmain->filepath)) { - remapper.add(&old_lib_iter->id, nullptr); + BKE_id_remapper_add(remapper, &old_lib_iter->id, nullptr); continue; } @@ -279,18 +281,19 @@ static id::IDRemapper &reuse_bmain_data_remapper_ensure(ReuseOldBMainData *reuse continue; } - remapper.add(&old_lib_iter->id, &new_lib_iter->id); + BKE_id_remapper_add(remapper, &old_lib_iter->id, &new_lib_iter->id); break; } } reuse_data->is_libraries_remapped = true; - return *reuse_data->remapper; + return reuse_data->remapper; } -static bool reuse_bmain_data_remapper_is_id_remapped(id::IDRemapper &remapper, ID *id) +static bool reuse_bmain_data_remapper_is_id_remapped(IDRemapper *remapper, ID *id) { - IDRemapperApplyResult result = remapper.get_mapping_result(id, ID_REMAP_APPLY_DEFAULT, nullptr); + IDRemapperApplyResult result = BKE_id_remapper_get_mapping_result( + remapper, id, ID_REMAP_APPLY_DEFAULT, nullptr); if (ELEM(result, ID_REMAP_RESULT_SOURCE_REMAPPED, ID_REMAP_RESULT_SOURCE_UNASSIGNED)) { /* ID is already remapped to its matching ID in the new main, or explicitly remapped to null, * nothing else to do here. */ @@ -320,7 +323,7 @@ static void swap_old_bmain_data_for_blendfile(ReuseOldBMainData *reuse_data, con ListBase *new_lb = which_libbase(new_bmain, id_code); ListBase *old_lb = which_libbase(old_bmain, id_code); - id::IDRemapper &remapper = reuse_bmain_data_remapper_ensure(reuse_data); + IDRemapper *remapper = reuse_bmain_data_remapper_ensure(reuse_data); /* NOTE: Full swapping is only supported for ID types that are assumed to be only local * data-blocks (like UI-like ones). Otherwise, the swapping could fail in many funny ways. */ @@ -347,14 +350,14 @@ static void swap_old_bmain_data_for_blendfile(ReuseOldBMainData *reuse_data, con const int strcmp_result = strcmp(discarded_id_iter->name + 2, reused_id_iter->name + 2); if (strcmp_result == 0) { /* Matching IDs, we can remap the discarded 'new' one to the re-used 'old' one. */ - remapper.add(discarded_id_iter, reused_id_iter); + BKE_id_remapper_add(remapper, discarded_id_iter, reused_id_iter); discarded_id_iter = static_cast(discarded_id_iter->next); reused_id_iter = static_cast(reused_id_iter->next); } else if (strcmp_result < 0) { /* No matching reused 'old' ID for this discarded 'new' one. */ - remapper.add(discarded_id_iter, nullptr); + BKE_id_remapper_add(remapper, discarded_id_iter, nullptr); discarded_id_iter = static_cast(discarded_id_iter->next); } @@ -366,7 +369,7 @@ static void swap_old_bmain_data_for_blendfile(ReuseOldBMainData *reuse_data, con for (; discarded_id_iter != nullptr; discarded_id_iter = static_cast(discarded_id_iter->next)) { - remapper.add(discarded_id_iter, nullptr); + BKE_id_remapper_add(remapper, discarded_id_iter, nullptr); } FOREACH_MAIN_LISTBASE_ID_BEGIN (new_lb, reused_id_iter) { @@ -375,7 +378,7 @@ static void swap_old_bmain_data_for_blendfile(ReuseOldBMainData *reuse_data, con /* Ensure that the reused ID is remapped to itself, since it is known to be in the `new_bmain`. */ - remapper.add_overwrite(reused_id_iter, reused_id_iter); + BKE_id_remapper_add_overwrite(remapper, reused_id_iter, reused_id_iter); } FOREACH_MAIN_LISTBASE_ID_END; } @@ -429,8 +432,8 @@ static void swap_wm_data_for_blendfile(ReuseOldBMainData *reuse_data, const bool * new WM, and is responsible to free it properly. */ reuse_data->wm_setup_data->old_wm = old_wm; - id::IDRemapper &remapper = reuse_bmain_data_remapper_ensure(reuse_data); - remapper.add(&old_wm->id, &new_wm->id); + IDRemapper *remapper = reuse_bmain_data_remapper_ensure(reuse_data); + BKE_id_remapper_add(remapper, &old_wm->id, &new_wm->id); } /* Current (old) WM, but no (new) one in file (should only happen when reading pre 2.5 files, no * WM back then), or not loading UI: Keep current WM. */ @@ -453,7 +456,7 @@ static int swap_old_bmain_data_for_blendfile_dependencies_process_cb( ReuseOldBMainData *reuse_data = static_cast(cb_data->user_data); /* First check if it has already been remapped. */ - id::IDRemapper &remapper = reuse_bmain_data_remapper_ensure(reuse_data); + IDRemapper *remapper = reuse_bmain_data_remapper_ensure(reuse_data); if (reuse_bmain_data_remapper_is_id_remapped(remapper, id)) { return IDWALK_RET_NOP; } @@ -462,7 +465,7 @@ static int swap_old_bmain_data_for_blendfile_dependencies_process_cb( BLI_assert(id_map != nullptr); ID *id_new = BKE_main_idmap_lookup_id(id_map, id); - remapper.add(id, id_new); + BKE_id_remapper_add(remapper, id, id_new); return IDWALK_RET_NOP; } @@ -785,7 +788,7 @@ static void setup_app_data(bContext *C, /* Handle all pending remapping from swapping old and new IDs around. */ BKE_libblock_remap_multiple_raw(bfd->main, - *reuse_data.remapper, + reuse_data.remapper, (ID_REMAP_FORCE_UI_POINTERS | ID_REMAP_SKIP_USER_REFCOUNT | ID_REMAP_SKIP_UPDATE_TAGGING | ID_REMAP_SKIP_USER_CLEAR)); @@ -794,7 +797,7 @@ static void setup_app_data(bContext *C, * library of the previous opened blendfile'. */ reuse_bmain_data_invalid_local_usages_fix(&reuse_data); - MEM_delete(reuse_data.remapper); + BKE_id_remapper_free(reuse_data.remapper); reuse_data.remapper = nullptr; wm_data_consistency_ensure(CTX_wm_manager(C), curscene, cur_view_layer); @@ -939,7 +942,7 @@ static void setup_app_data(bContext *C, BLI_assert(BKE_main_namemap_validate(bmain)); if (mode != LOAD_UNDO && !USER_EXPERIMENTAL_TEST(&U, no_override_auto_resync)) { - reports->duration.lib_overrides_resync = BLI_time_now_seconds(); + reports->duration.lib_overrides_resync = BLI_check_seconds_timer(); BKE_lib_override_library_main_resync( bmain, @@ -947,7 +950,7 @@ static void setup_app_data(bContext *C, bfd->cur_view_layer ? bfd->cur_view_layer : BKE_view_layer_default_view(curscene), reports); - reports->duration.lib_overrides_resync = BLI_time_now_seconds() - + reports->duration.lib_overrides_resync = BLI_check_seconds_timer() - reports->duration.lib_overrides_resync; /* We need to rebuild some of the deleted override rules (for UI feedback purpose). */ diff --git a/source/blender/blenkernel/intern/blendfile_link_append.cc b/source/blender/blenkernel/intern/blendfile_link_append.cc index 2f4d8f63c96..4c43bf5fa78 100644 --- a/source/blender/blenkernel/intern/blendfile_link_append.cc +++ b/source/blender/blenkernel/intern/blendfile_link_append.cc @@ -34,7 +34,7 @@ #include "BLI_memarena.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_idtype.hh" #include "BKE_key.hh" @@ -47,13 +47,13 @@ #include "BKE_main_namemap.hh" #include "BKE_material.h" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_rigidbody.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_blendfile_link_append.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "BLO_writefile.hh" static CLG_LogRef LOG = {"bke.blendfile_link_append"}; diff --git a/source/blender/blenkernel/intern/boids.cc b/source/blender/blenkernel/intern/boids.cc index 55395a6bb47..c3157334d5a 100644 --- a/source/blender/blenkernel/intern/boids.cc +++ b/source/blender/blenkernel/intern/boids.cc @@ -28,7 +28,7 @@ #include "BKE_particle.h" #include "BLI_kdopbvh.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_modifier.hh" @@ -962,7 +962,7 @@ void boids_precalc_rules(ParticleSettings *part, float cfra) if (flbr->ob && flbr->cfra != cfra) { /* save object locations for velocity calculations */ copy_v3_v3(flbr->oloc, flbr->loc); - copy_v3_v3(flbr->loc, flbr->ob->object_to_world().location()); + copy_v3_v3(flbr->loc, flbr->ob->object_to_world[3]); flbr->cfra = cfra; } } diff --git a/source/blender/blenkernel/intern/bpath.cc b/source/blender/blenkernel/intern/bpath.cc index 4c6102e3490..4d94ac261e4 100644 --- a/source/blender/blenkernel/intern/bpath.cc +++ b/source/blender/blenkernel/intern/bpath.cc @@ -61,18 +61,18 @@ #include "BKE_lib_id.hh" #include "BKE_library.hh" #include "BKE_main.hh" -#include "BKE_node.hh" -#include "BKE_report.hh" +#include "BKE_node.h" +#include "BKE_report.h" #include "BKE_vfont.hh" -#include "BKE_bpath.hh" /* own include */ +#include "BKE_bpath.h" /* own include */ #include "CLG_log.h" #include "SEQ_iterator.hh" #ifndef _MSC_VER -# include "BLI_strict_flags.h" /* Keep last. */ +# include "BLI_strict_flags.h" #endif static CLG_LogRef LOG = {"bke.bpath"}; diff --git a/source/blender/blenkernel/intern/bpath_test.cc b/source/blender/blenkernel/intern/bpath_test.cc index 08a726f140c..e2012d692a1 100644 --- a/source/blender/blenkernel/intern/bpath_test.cc +++ b/source/blender/blenkernel/intern/bpath_test.cc @@ -5,7 +5,7 @@ #include "CLG_log.h" -#include "BKE_bpath.hh" +#include "BKE_bpath.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" diff --git a/source/blender/blenkernel/intern/brush.cc b/source/blender/blenkernel/intern/brush.cc index 6abda3f884e..3e45f6db5e5 100644 --- a/source/blender/blenkernel/intern/brush.cc +++ b/source/blender/blenkernel/intern/brush.cc @@ -10,18 +10,21 @@ #include "DNA_brush_types.h" #include "DNA_defaults.h" +#include "DNA_gpencil_legacy_types.h" #include "DNA_material_types.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "BLI_listbase.h" #include "BLI_math_rotation.h" #include "BLI_rand.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" -#include "BKE_bpath.hh" +#include "BKE_bpath.h" #include "BKE_brush.hh" #include "BKE_colortools.hh" +#include "BKE_context.hh" #include "BKE_gpencil_legacy.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" @@ -409,8 +412,6 @@ static void brush_undo_preserve(BlendLibReader *reader, ID *id_new, ID *id_old) IDTypeInfo IDType_ID_BR = { /*id_code*/ ID_BR, /*id_filter*/ FILTER_ID_BR, - /*dependencies_id_types*/ - (FILTER_ID_BR | FILTER_ID_IM | FILTER_ID_PC | FILTER_ID_TE | FILTER_ID_MA), /*main_listbase_index*/ INDEX_ID_BR, /*struct_size*/ sizeof(Brush), /*name*/ "Brush", diff --git a/source/blender/blenkernel/intern/bvhutils.cc b/source/blender/blenkernel/intern/bvhutils.cc index 9e96822501e..7e54bc2bffb 100644 --- a/source/blender/blenkernel/intern/bvhutils.cc +++ b/source/blender/blenkernel/intern/bvhutils.cc @@ -6,16 +6,31 @@ * \ingroup bke */ +#include +#include +#include + +#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_pointcloud_types.h" +#include "BLI_bit_vector.hh" +#include "BLI_linklist.h" #include "BLI_math_geom.h" +#include "BLI_math_vector.h" +#include "BLI_span.hh" #include "BLI_task.h" +#include "BLI_threads.h" +#include "BLI_utildefines.h" #include "BKE_attribute.hh" #include "BKE_bvhutils.hh" #include "BKE_editmesh.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" +#include "BKE_pointcloud.hh" + +#include "MEM_guardedalloc.h" using blender::BitSpan; using blender::BitVector; @@ -279,6 +294,34 @@ static void mesh_corner_tris_nearest_point(void *userdata, normal_tri_v3(nearest->no, UNPACK3(vtri_co)); } } +/* Copy of function above (warning, should de-duplicate with `editmesh_bvh.cc`). */ +static void editmesh_corner_tris_nearest_point(void *userdata, + int index, + const float co[3], + BVHTreeNearest *nearest) +{ + BMEditMesh *em = static_cast(userdata); + const BMLoop **ltri = const_cast(em->looptris[index]); + + const float *t0, *t1, *t2; + t0 = ltri[0]->v->co; + t1 = ltri[1]->v->co; + t2 = ltri[2]->v->co; + + { + float nearest_tmp[3], dist_sq; + + closest_on_tri_to_point_v3(nearest_tmp, co, t0, t1, t2); + dist_sq = len_squared_v3v3(co, nearest_tmp); + + if (dist_sq < nearest->dist_sq) { + nearest->index = index; + nearest->dist_sq = dist_sq; + copy_v3_v3(nearest->co, nearest_tmp); + normal_tri_v3(nearest->no, t0, t1, t2); + } + } +} /** * Callback to BVH-tree ray-cast. @@ -354,6 +397,38 @@ static void mesh_corner_tris_spherecast(void *userdata, normal_tri_v3(hit->no, UNPACK3(vtri_co)); } } +/* Copy of function above (warning, should de-duplicate with `editmesh_bvh.cc`). */ +static void editmesh_corner_tris_spherecast(void *userdata, + int index, + const BVHTreeRay *ray, + BVHTreeRayHit *hit) +{ + BMEditMesh *em = static_cast(userdata); + const BMLoop **ltri = const_cast(em->looptris[index]); + + const float *t0, *t1, *t2; + t0 = ltri[0]->v->co; + t1 = ltri[1]->v->co; + t2 = ltri[2]->v->co; + + { + float dist; + if (ray->radius == 0.0f) { + dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2); + } + else { + dist = bvhtree_sphereray_tri_intersection(ray, ray->radius, hit->dist, t0, t1, t2); + } + + if (dist >= 0 && dist < hit->dist) { + hit->index = index; + hit->dist = dist; + madd_v3_v3v3fl(hit->co, ray->origin, ray->direction, dist); + + normal_tri_v3(hit->no, t0, t1, t2); + } + } +} /** * Callback to BVH-tree nearest point. @@ -409,6 +484,17 @@ static void mesh_verts_spherecast_do(int index, } } +static void editmesh_verts_spherecast(void *userdata, + int index, + const BVHTreeRay *ray, + BVHTreeRayHit *hit) +{ + BMEditMesh *em = static_cast(userdata); + BMVert *eve = BM_vert_at_index(em->bm, index); + + mesh_verts_spherecast_do(index, eve->co, ray, hit); +} + /** * Callback to BVH-tree ray-cast. * The tree must have been built using bvhtree_from_mesh_verts. @@ -529,6 +615,44 @@ static void bvhtree_from_mesh_setup_data(BVHTree *tree, r_data->nearest_callback = mesh_corner_tris_nearest_point; r_data->raycast_callback = mesh_corner_tris_spherecast; break; + case BVHTREE_FROM_EM_LOOSEVERTS: + case BVHTREE_FROM_EM_EDGES: + case BVHTREE_FROM_EM_LOOPTRIS: + case BVHTREE_MAX_ITEM: + BLI_assert(false); + break; + } +} + +static void bvhtree_from_editmesh_setup_data(BVHTree *tree, + const BVHCacheType bvh_cache_type, + BVHTreeFromEditMesh *r_data) +{ + memset(r_data, 0, sizeof(*r_data)); + + r_data->tree = tree; + + switch (bvh_cache_type) { + case BVHTREE_FROM_EM_LOOSEVERTS: + r_data->nearest_callback = nullptr; + r_data->raycast_callback = editmesh_verts_spherecast; + break; + case BVHTREE_FROM_EM_EDGES: + r_data->nearest_callback = nullptr; /* TODO */ + r_data->raycast_callback = nullptr; /* TODO */ + break; + case BVHTREE_FROM_EM_LOOPTRIS: + r_data->nearest_callback = editmesh_corner_tris_nearest_point; + r_data->raycast_callback = editmesh_corner_tris_spherecast; + break; + + case BVHTREE_FROM_VERTS: + case BVHTREE_FROM_LOOSEVERTS: + case BVHTREE_FROM_EDGES: + case BVHTREE_FROM_LOOSEEDGES: + case BVHTREE_FROM_FACES: + case BVHTREE_FROM_CORNER_TRIS: + case BVHTREE_FROM_CORNER_TRIS_NO_HIDDEN: case BVHTREE_MAX_ITEM: BLI_assert(false); break; @@ -558,6 +682,34 @@ static BVHTree *bvhtree_new_common( /** \name Vertex Builder * \{ */ +static BVHTree *bvhtree_from_editmesh_verts_create_tree(float epsilon, + int tree_type, + int axis, + BMEditMesh *em, + const BitSpan verts_mask, + int verts_num_active) +{ + const int verts_num = em->bm->totvert; + + BVHTree *tree = bvhtree_new_common(epsilon, tree_type, axis, verts_num, verts_num_active); + if (!tree) { + return nullptr; + } + + BM_mesh_elem_table_ensure(em->bm, BM_VERT); + + for (int i = 0; i < verts_num; i++) { + if (!verts_mask.is_empty() && !verts_mask[i]) { + continue; + } + BMVert *eve = BM_vert_at_index(em->bm, i); + BLI_bvhtree_insert(tree, i, eve->co, 1); + } + BLI_assert(BLI_bvhtree_get_len(tree) == verts_num_active); + + return tree; +} + static BVHTree *bvhtree_from_mesh_verts_create_tree(float epsilon, int tree_type, int axis, @@ -581,6 +733,32 @@ static BVHTree *bvhtree_from_mesh_verts_create_tree(float epsilon, return tree; } +BVHTree *bvhtree_from_editmesh_verts_ex(BVHTreeFromEditMesh *data, + BMEditMesh *em, + const BitSpan verts_mask, + int verts_num_active, + float epsilon, + int tree_type, + int axis) +{ + BVHTree *tree = bvhtree_from_editmesh_verts_create_tree( + epsilon, tree_type, axis, em, verts_mask, verts_num_active); + + bvhtree_balance(tree, false); + + if (data) { + bvhtree_from_editmesh_setup_data(tree, BVHTREE_FROM_EM_LOOSEVERTS, data); + } + + return tree; +} + +BVHTree *bvhtree_from_editmesh_verts( + BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis) +{ + return bvhtree_from_editmesh_verts_ex(data, em, {}, -1, epsilon, tree_type, axis); +} + BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data, const Span vert_positions, const BitSpan verts_mask, @@ -608,6 +786,40 @@ BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data, /** \name Edge Builder * \{ */ +static BVHTree *bvhtree_from_editmesh_edges_create_tree(float epsilon, + int tree_type, + int axis, + BMEditMesh *em, + const BitSpan edges_mask, + int edges_num_active) +{ + const int edges_num = em->bm->totedge; + + BVHTree *tree = bvhtree_new_common(epsilon, tree_type, axis, edges_num, edges_num_active); + if (!tree) { + return nullptr; + } + + BM_mesh_elem_table_ensure(em->bm, BM_EDGE); + + int i; + BMIter iter; + BMEdge *eed; + BM_ITER_MESH_INDEX (eed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (!edges_mask.is_empty() && !edges_mask[i]) { + continue; + } + float co[2][3]; + copy_v3_v3(co[0], eed->v1->co); + copy_v3_v3(co[1], eed->v2->co); + + BLI_bvhtree_insert(tree, i, co[0], 2); + } + BLI_assert(BLI_bvhtree_get_len(tree) == edges_num_active); + + return tree; +} + static BVHTree *bvhtree_from_mesh_edges_create_tree(const Span positions, const blender::Span edges, const BitSpan edges_mask, @@ -635,6 +847,32 @@ static BVHTree *bvhtree_from_mesh_edges_create_tree(const Span positions return tree; } +BVHTree *bvhtree_from_editmesh_edges_ex(BVHTreeFromEditMesh *data, + BMEditMesh *em, + const BitSpan edges_mask, + int edges_num_active, + float epsilon, + int tree_type, + int axis) +{ + BVHTree *tree = bvhtree_from_editmesh_edges_create_tree( + epsilon, tree_type, axis, em, edges_mask, edges_num_active); + + bvhtree_balance(tree, false); + + if (data) { + bvhtree_from_editmesh_setup_data(tree, BVHTREE_FROM_EM_EDGES, data); + } + + return tree; +} + +BVHTree *bvhtree_from_editmesh_edges( + BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis) +{ + return bvhtree_from_editmesh_edges_ex(data, em, {}, -1, epsilon, tree_type, axis); +} + BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data, const Span vert_positions, const Span edges, @@ -706,6 +944,46 @@ static BVHTree *bvhtree_from_mesh_faces_create_tree(float epsilon, /** \name corner_tri Face Builder * \{ */ +static BVHTree *bvhtree_from_editmesh_corner_tris_create_tree(float epsilon, + int tree_type, + int axis, + BMEditMesh *em, + const BitSpan corner_tris_mask, + int corner_tris_num_active) +{ + const int corner_tris_num = em->tottri; + + BVHTree *tree = bvhtree_new_common( + epsilon, tree_type, axis, corner_tris_num, corner_tris_num_active); + if (!tree) { + return nullptr; + } + + const BMLoop *(*corner_tris)[3] = const_cast(em->looptris); + + /* Insert BMesh-tessellation triangles into the BVH-tree, unless they are hidden + * and/or selected. Even if the faces themselves are not selected for the snapped + * transform, having a vertex selected means the face (and thus it's tessellated + * triangles) will be moving and will not be a good snap targets. */ + for (int i = 0; i < corner_tris_num; i++) { + const BMLoop **ltri = corner_tris[i]; + bool insert = !corner_tris_mask.is_empty() ? corner_tris_mask[i] : true; + + if (insert) { + /* No reason found to block hit-testing the triangle for snap, so insert it now. */ + float co[3][3]; + copy_v3_v3(co[0], ltri[0]->v->co); + copy_v3_v3(co[1], ltri[1]->v->co); + copy_v3_v3(co[2], ltri[2]->v->co); + + BLI_bvhtree_insert(tree, i, co[0], 3); + } + } + BLI_assert(BLI_bvhtree_get_len(tree) == corner_tris_num_active); + + return tree; +} + static BVHTree *bvhtree_from_mesh_corner_tris_create_tree(float epsilon, int tree_type, int axis, @@ -744,6 +1022,33 @@ static BVHTree *bvhtree_from_mesh_corner_tris_create_tree(float epsilon, return tree; } +BVHTree *bvhtree_from_editmesh_looptris_ex(BVHTreeFromEditMesh *data, + BMEditMesh *em, + const BitSpan corner_tris_mask, + int corner_tris_num_active, + float epsilon, + int tree_type, + int axis) +{ + /* BMESH specific check that we have tessfaces, + * we _could_ tessellate here but rather not - campbell */ + BVHTree *tree = bvhtree_from_editmesh_corner_tris_create_tree( + epsilon, tree_type, axis, em, corner_tris_mask, corner_tris_num_active); + + bvhtree_balance(tree, false); + + if (data) { + bvhtree_from_editmesh_setup_data(tree, BVHTREE_FROM_EM_LOOPTRIS, data); + } + return tree; +} + +BVHTree *bvhtree_from_editmesh_corner_tris( + BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis) +{ + return bvhtree_from_editmesh_looptris_ex(data, em, {}, -1, epsilon, tree_type, axis); +} + BVHTree *bvhtree_from_mesh_corner_tris_ex(BVHTreeFromMesh *data, const Span vert_positions, const Span corner_verts, @@ -905,6 +1210,9 @@ BVHTree *BKE_bvhtree_from_mesh_get(BVHTreeFromMesh *data, 0.0f, tree_type, 6, positions, corner_verts, corner_tris, {}, -1); break; } + case BVHTREE_FROM_EM_LOOSEVERTS: + case BVHTREE_FROM_EM_EDGES: + case BVHTREE_FROM_EM_LOOPTRIS: case BVHTREE_MAX_ITEM: BLI_assert_unreachable(); break; @@ -932,51 +1240,94 @@ BVHTree *BKE_bvhtree_from_mesh_get(BVHTreeFromMesh *data, return data->tree; } -void BKE_bvhtree_from_mesh_tris_init(const Mesh &mesh, - const blender::IndexMask &faces_mask, - BVHTreeFromMesh &r_data) +static BitVector<> bmverts_loose_map_get(BMesh *bm, int *r_bmvert_active_len) { - using namespace blender; - using namespace blender::bke; + BitVector<> bmvert_mask(bm->totvert); - const Span positions = mesh.vert_positions(); - const Span edges = mesh.edges(); - const Span corner_verts = mesh.corner_verts(); - const OffsetIndices faces = mesh.faces(); - const Span corner_tris = mesh.corner_tris(); - bvhtree_from_mesh_setup_data(nullptr, - BVHTREE_FROM_CORNER_TRIS, - positions, - edges, - corner_verts, - corner_tris, - nullptr, - &r_data); - - int tris_num = 0; - faces_mask.foreach_index( - [&](const int i) { tris_num += mesh::face_triangles_num(faces[i].size()); }); - - int active_num = -1; - BVHTree *tree = bvhtree_new_common(0.0f, 2, 6, tris_num, active_num); - r_data.tree = tree; - if (tree == nullptr) { - return; + int i, bmvert_loose_len = 0; + BMIter iter; + BMVert *v; + BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) { + if (v->e == nullptr) { + bmvert_mask[i].set(); + bmvert_loose_len++; + } } - faces_mask.foreach_index([&](const int face_i) { - const IndexRange triangles_range = mesh::face_triangles_range(faces, face_i); - for (const int tri_i : triangles_range) { - float co[3][3]; - copy_v3_v3(co[0], positions[corner_verts[corner_tris[tri_i][0]]]); - copy_v3_v3(co[1], positions[corner_verts[corner_tris[tri_i][1]]]); - copy_v3_v3(co[2], positions[corner_verts[corner_tris[tri_i][2]]]); + *r_bmvert_active_len = bmvert_loose_len; - BLI_bvhtree_insert(tree, tri_i, co[0], 3); + return bmvert_mask; +} + +BVHTree *BKE_bvhtree_from_editmesh_get(BVHTreeFromEditMesh *data, + BMEditMesh *em, + const int tree_type, + const BVHCacheType bvh_cache_type, + BVHCache **bvh_cache_p, + std::mutex *mesh_eval_mutex) +{ + bool lock_started = false; + + bvhtree_from_editmesh_setup_data(nullptr, bvh_cache_type, data); + + if (bvh_cache_p) { + data->cached = bvhcache_find( + bvh_cache_p, bvh_cache_type, &data->tree, &lock_started, mesh_eval_mutex); + + if (data->cached) { + BLI_assert(lock_started == false); + return data->tree; } - }); + } - BLI_bvhtree_balance(tree); + switch (bvh_cache_type) { + case BVHTREE_FROM_EM_LOOSEVERTS: { + int mask_bits_act_len = -1; + const BitVector<> mask = bmverts_loose_map_get(em->bm, &mask_bits_act_len); + data->tree = bvhtree_from_editmesh_verts_create_tree( + 0.0f, tree_type, 6, em, mask, mask_bits_act_len); + break; + } + case BVHTREE_FROM_EM_EDGES: + data->tree = bvhtree_from_editmesh_edges_create_tree(0.0f, tree_type, 6, em, {}, -1); + break; + case BVHTREE_FROM_EM_LOOPTRIS: + data->tree = bvhtree_from_editmesh_corner_tris_create_tree(0.0f, tree_type, 6, em, {}, -1); + break; + case BVHTREE_FROM_VERTS: + case BVHTREE_FROM_EDGES: + case BVHTREE_FROM_FACES: + case BVHTREE_FROM_CORNER_TRIS: + case BVHTREE_FROM_CORNER_TRIS_NO_HIDDEN: + case BVHTREE_FROM_LOOSEVERTS: + case BVHTREE_FROM_LOOSEEDGES: + case BVHTREE_MAX_ITEM: + BLI_assert(false); + break; + } + + bvhtree_balance(data->tree, lock_started); + + if (bvh_cache_p) { + /* Save on cache for later use */ + // printf("BVHTree built and saved on cache\n"); + BLI_assert(data->cached == false); + data->cached = true; + bvhcache_insert(*bvh_cache_p, data->tree, bvh_cache_type); + bvhcache_unlock(*bvh_cache_p, lock_started); + } + +#ifndef NDEBUG + if (data->tree != nullptr) { + if (BLI_bvhtree_get_tree_type(data->tree) != tree_type) { + printf("tree_type %d obtained instead of %d\n", + BLI_bvhtree_get_tree_type(data->tree), + tree_type); + } + } +#endif + + return data->tree; } /** \} */ @@ -985,6 +1336,16 @@ void BKE_bvhtree_from_mesh_tris_init(const Mesh &mesh, /** \name Free Functions * \{ */ +void free_bvhtree_from_editmesh(BVHTreeFromEditMesh *data) +{ + if (data->tree) { + if (!data->cached) { + BLI_bvhtree_free(data->tree); + } + memset(data, 0, sizeof(*data)); + } +} + void free_bvhtree_from_mesh(BVHTreeFromMesh *data) { if (data->tree && !data->cached) { diff --git a/source/blender/blenkernel/intern/cachefile.cc b/source/blender/blenkernel/intern/cachefile.cc index 40288a495af..04f00f185a2 100644 --- a/source/blender/blenkernel/intern/cachefile.cc +++ b/source/blender/blenkernel/intern/cachefile.cc @@ -8,7 +8,9 @@ #include +#include "DNA_anim_types.h" #include "DNA_cachefile_types.h" +#include "DNA_constraint_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -20,14 +22,16 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" -#include "BKE_bpath.hh" -#include "BKE_cachefile.hh" +#include "BKE_anim_data.h" +#include "BKE_bpath.h" +#include "BKE_cachefile.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_modifier.hh" +#include "BKE_scene.h" #include "DEG_depsgraph_query.hh" @@ -121,7 +125,6 @@ static void cache_file_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_CF = { /*id_code*/ ID_CF, /*id_filter*/ FILTER_ID_CF, - /*dependencies_id_types*/ 0, /*main_listbase_index*/ INDEX_ID_CF, /*struct_size*/ sizeof(CacheFile), /*name*/ "CacheFile", diff --git a/source/blender/blenkernel/intern/callbacks.cc b/source/blender/blenkernel/intern/callbacks.cc index dd656074ae4..309b6124ce0 100644 --- a/source/blender/blenkernel/intern/callbacks.cc +++ b/source/blender/blenkernel/intern/callbacks.cc @@ -9,12 +9,13 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "MEM_guardedalloc.h" #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "RNA_types.hh" static ListBase callback_slots[BKE_CB_EVT_TOT] = {{nullptr}}; diff --git a/source/blender/blenkernel/intern/camera.cc b/source/blender/blenkernel/intern/camera.cc index aaabf3bed1d..875006487c0 100644 --- a/source/blender/blenkernel/intern/camera.cc +++ b/source/blender/blenkernel/intern/camera.cc @@ -29,16 +29,19 @@ #include "BLI_utildefines.h" #include "BKE_action.h" +#include "BKE_anim_data.h" #include "BKE_camera.h" #include "BKE_idprop.h" #include "BKE_idtype.hh" +#include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_screen.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph_query.hh" @@ -229,7 +232,6 @@ static void camera_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_CA = { /*id_code*/ ID_CA, /*id_filter*/ FILTER_ID_CA, - /*dependencies_id_types*/ FILTER_ID_OB | FILTER_ID_IM, /*main_listbase_index*/ INDEX_ID_CA, /*struct_size*/ sizeof(Camera), /*name*/ "Camera", @@ -279,18 +281,16 @@ float BKE_camera_object_dof_distance(const Object *ob) } if (cam->dof.focus_object) { float view_dir[3], dof_dir[3]; - normalize_v3_v3(view_dir, ob->object_to_world().ptr()[2]); + normalize_v3_v3(view_dir, ob->object_to_world[2]); bPoseChannel *pchan = BKE_pose_channel_find_name(cam->dof.focus_object->pose, cam->dof.focus_subtarget); if (pchan) { float posemat[4][4]; - mul_m4_m4m4(posemat, cam->dof.focus_object->object_to_world().ptr(), pchan->pose_mat); - sub_v3_v3v3(dof_dir, ob->object_to_world().location(), posemat[3]); + mul_m4_m4m4(posemat, cam->dof.focus_object->object_to_world, pchan->pose_mat); + sub_v3_v3v3(dof_dir, ob->object_to_world[3], posemat[3]); } else { - sub_v3_v3v3(dof_dir, - ob->object_to_world().location(), - cam->dof.focus_object->object_to_world().location()); + sub_v3_v3v3(dof_dir, ob->object_to_world[3], cam->dof.focus_object->object_to_world[3]); } return fabsf(dot_v3v3(view_dir, dof_dir)); } @@ -685,7 +685,7 @@ static void camera_frame_fit_data_init(const Scene *scene, BKE_camera_params_compute_matrix(params); /* initialize callback data */ - copy_m3_m4(data->camera_rotmat, (float(*)[4])ob->object_to_world().ptr()); + copy_m3_m4(data->camera_rotmat, (float(*)[4])ob->object_to_world); normalize_m3(data->camera_rotmat); /* To transform a plane which is in its homogeneous representation (4d vector), * we need the inverse of the transpose of the transform matrix... */ @@ -887,7 +887,7 @@ bool BKE_camera_view_frame_fit_to_coords(const Depsgraph *depsgraph, static void camera_model_matrix(const Object *camera, float r_modelmat[4][4]) { - copy_m4_m4(r_modelmat, camera->object_to_world().ptr()); + copy_m4_m4(r_modelmat, camera->object_to_world); } static void camera_stereo3d_model_matrix(const Object *camera, @@ -913,7 +913,7 @@ static void camera_stereo3d_model_matrix(const Object *camera, } float size[3]; - mat4_to_size(size, camera->object_to_world().ptr()); + mat4_to_size(size, camera->object_to_world); size_to_mat4(sizemat, size); if (pivot == CAM_S3D_PIVOT_CENTER) { @@ -953,7 +953,7 @@ static void camera_stereo3d_model_matrix(const Object *camera, toeinmat[3][0] = interocular_distance * fac_signed; /* transform */ - normalize_m4_m4(r_modelmat, camera->object_to_world().ptr()); + normalize_m4_m4(r_modelmat, camera->object_to_world); mul_m4_m4m4(r_modelmat, r_modelmat, toeinmat); /* scale back to the original size */ @@ -961,7 +961,7 @@ static void camera_stereo3d_model_matrix(const Object *camera, } else { /* CAM_S3D_PIVOT_LEFT, CAM_S3D_PIVOT_RIGHT */ /* rotate perpendicular to the interocular line */ - normalize_m4_m4(r_modelmat, camera->object_to_world().ptr()); + normalize_m4_m4(r_modelmat, camera->object_to_world); mul_m4_m4m4(r_modelmat, r_modelmat, rotmat); /* translate along the interocular line */ @@ -977,7 +977,7 @@ static void camera_stereo3d_model_matrix(const Object *camera, } } else { - normalize_m4_m4(r_modelmat, camera->object_to_world().ptr()); + normalize_m4_m4(r_modelmat, camera->object_to_world); /* translate - no rotation in CAM_S3D_OFFAXIS, CAM_S3D_PARALLEL */ translate_m4(r_modelmat, -interocular_distance * fac_signed, 0.0f, 0.0f); diff --git a/source/blender/blenkernel/intern/cdderivedmesh.cc b/source/blender/blenkernel/intern/cdderivedmesh.cc index dda11c71d08..0d6cf390b7b 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.cc +++ b/source/blender/blenkernel/intern/cdderivedmesh.cc @@ -12,16 +12,23 @@ #include #include +#include "atomic_ops.h" + #include "BLI_utildefines.h" #include "BKE_DerivedMesh.hh" #include "BKE_cdderivedmesh.h" +#include "BKE_curve.hh" #include "BKE_editmesh.hh" +#include "BKE_mesh.hh" #include "BKE_mesh_mapping.hh" +#include "BKE_object.hh" +#include "BKE_paint.hh" #include "BKE_pbvh.hh" #include "DNA_curve_types.h" /* for Curve */ #include "DNA_mesh_types.h" +#include "DNA_object_types.h" #include "MEM_guardedalloc.h" @@ -31,7 +38,7 @@ struct CDDerivedMesh { /* these point to data in the DerivedMesh custom data layers, * they are only here for efficiency and convenience */ float (*vert_positions)[3]; - blender::int2 *medge; + vec2i *medge; MFace *mface; int *corner_verts; int *corner_edges; @@ -72,7 +79,7 @@ static void cdDM_copyVertArray(DerivedMesh *dm, float (*r_positions)[3]) memcpy(r_positions, cddm->vert_positions, sizeof(float[3]) * dm->numVertData); } -static void cdDM_copyEdgeArray(DerivedMesh *dm, blender::int2 *r_edge) +static void cdDM_copyEdgeArray(DerivedMesh *dm, vec2i *r_edge) { CDDerivedMesh *cddm = (CDDerivedMesh *)dm; memcpy(r_edge, cddm->medge, sizeof(*r_edge) * dm->numEdgeData); @@ -168,7 +175,7 @@ static DerivedMesh *cdDM_from_mesh_ex(Mesh *mesh, const CustomData_MeshMasks *ma cddm->vert_positions = static_cast(CustomData_get_layer_named_for_write( &dm->vertData, CD_PROP_FLOAT3, "position", mesh->verts_num)); - cddm->medge = static_cast(CustomData_get_layer_named_for_write( + cddm->medge = static_cast(CustomData_get_layer_named_for_write( &dm->edgeData, CD_PROP_INT32_2D, ".edge_verts", mesh->edges_num)); cddm->corner_verts = static_cast(CustomData_get_layer_named_for_write( &dm->loopData, CD_PROP_INT32, ".corner_vert", mesh->corners_num)); diff --git a/source/blender/blenkernel/intern/cloth.cc b/source/blender/blenkernel/intern/cloth.cc index 58d6ec3226d..199e67634d6 100644 --- a/source/blender/blenkernel/intern/cloth.cc +++ b/source/blender/blenkernel/intern/cloth.cc @@ -29,9 +29,10 @@ #include "BKE_cloth.hh" #include "BKE_customdata.hh" #include "BKE_effect.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_modifier.hh" #include "BKE_pointcache.h" @@ -272,7 +273,7 @@ static int do_step_cloth( /* Get the current position. */ copy_v3_v3(verts->xconst, positions[i]); - mul_m4_v3(ob->object_to_world().ptr(), verts->xconst); + mul_m4_v3(ob->object_to_world, verts->xconst); if (vert_mass_changed) { verts->mass = clmd->sim_parms->mass; @@ -575,11 +576,11 @@ static void cloth_to_object(Object *ob, ClothModifierData *clmd, float (*vertexC if (clmd->clothObject) { /* Inverse matrix is not up to date. */ - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); for (i = 0; i < cloth->mvert_num; i++) { copy_v3_v3(vertexCos[i], cloth->verts[i].x); - mul_m4_v3(ob->world_to_object().ptr(), vertexCos[i]); /* cloth is in global coords */ + mul_m4_v3(ob->world_to_object, vertexCos[i]); /* cloth is in global coords */ } } } @@ -759,11 +760,11 @@ static bool cloth_from_object( if (first) { copy_v3_v3(verts->x, positions[i]); - mul_m4_v3(ob->object_to_world().ptr(), verts->x); + mul_m4_v3(ob->object_to_world, verts->x); if (shapekey_rest) { copy_v3_v3(verts->xrest, shapekey_rest[i]); - mul_m4_v3(ob->object_to_world().ptr(), verts->xrest); + mul_m4_v3(ob->object_to_world, verts->xrest); } else { copy_v3_v3(verts->xrest, verts->x); @@ -1153,7 +1154,7 @@ static void cloth_update_verts(Object *ob, ClothModifierData *clmd, Mesh *mesh) /* vertex count is already ensured to match */ for (i = 0; i < mesh->verts_num; i++, verts++) { copy_v3_v3(verts->xrest, positions[i]); - mul_m4_v3(ob->object_to_world().ptr(), verts->xrest); + mul_m4_v3(ob->object_to_world, verts->xrest); } } diff --git a/source/blender/blenkernel/intern/collection.cc b/source/blender/blenkernel/intern/collection.cc index 50ee88ebab2..21a85fab303 100644 --- a/source/blender/blenkernel/intern/collection.cc +++ b/source/blender/blenkernel/intern/collection.cc @@ -18,10 +18,10 @@ #include "BLI_listbase.h" #include "BLI_math_base.h" #include "BLI_threads.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_anim_data.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_idprop.h" #include "BKE_idtype.hh" #include "BKE_layer.hh" @@ -32,7 +32,7 @@ #include "BKE_object.hh" #include "BKE_preview_image.hh" #include "BKE_rigidbody.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DNA_defaults.h" @@ -352,7 +352,6 @@ static void collection_blend_read_after_liblink(BlendLibReader * /*reader*/, ID IDTypeInfo IDType_ID_GR = { /*id_code*/ ID_GR, /*id_filter*/ FILTER_ID_GR, - /*dependencies_id_types*/ FILTER_ID_OB | FILTER_ID_GR, /*main_listbase_index*/ INDEX_ID_GR, /*struct_size*/ sizeof(Collection), /*name*/ "Collection", diff --git a/source/blender/blenkernel/intern/collision.cc b/source/blender/blenkernel/intern/collision.cc index 08dde5b9bac..d3e6c41f60a 100644 --- a/source/blender/blenkernel/intern/collision.cc +++ b/source/blender/blenkernel/intern/collision.cc @@ -11,10 +11,14 @@ #include "MEM_guardedalloc.h" #include "DNA_cloth_types.h" +#include "DNA_collection_types.h" +#include "DNA_effect_types.h" #include "DNA_object_force_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_blenlib.h" +#include "BLI_linklist.h" #include "BLI_math_geom.h" #include "BLI_math_vector.h" #include "BLI_task.h" @@ -22,8 +26,11 @@ #include "BLI_utildefines.h" #include "BKE_cloth.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" +#include "BKE_effect.h" +#include "BKE_layer.hh" #include "BKE_modifier.hh" +#include "BKE_scene.h" #include "BKE_collision.h" #include "BLI_kdopbvh.h" diff --git a/source/blender/blenkernel/intern/colorband.cc b/source/blender/blenkernel/intern/colorband.cc index f34d65d01ee..d5a8842199e 100644 --- a/source/blender/blenkernel/intern/colorband.cc +++ b/source/blender/blenkernel/intern/colorband.cc @@ -18,6 +18,7 @@ #include "BKE_colorband.hh" #include "BKE_key.hh" +#include "BKE_material.h" void BKE_colorband_init(ColorBand *coba, bool rangetype) { diff --git a/source/blender/blenkernel/intern/constraint.cc b/source/blender/blenkernel/intern/constraint.cc index d64d22b5555..27669a8da92 100644 --- a/source/blender/blenkernel/intern/constraint.cc +++ b/source/blender/blenkernel/intern/constraint.cc @@ -26,7 +26,7 @@ #include "BLI_math_vector.h" #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_action_types.h" #include "DNA_armature_types.h" @@ -49,7 +49,7 @@ #include "BKE_animsys.h" #include "BKE_armature.hh" #include "BKE_bvhutils.hh" -#include "BKE_cachefile.hh" +#include "BKE_cachefile.h" #include "BKE_camera.h" #include "BKE_constraint.h" #include "BKE_curve.hh" @@ -57,7 +57,7 @@ #include "BKE_displist.h" #include "BKE_editmesh.hh" #include "BKE_fcurve_driver.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" @@ -66,7 +66,7 @@ #include "BKE_movieclip.h" #include "BKE_object.hh" #include "BKE_object_types.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_shrinkwrap.hh" #include "BKE_tracking.h" @@ -155,7 +155,7 @@ bConstraintOb *BKE_constraints_make_evalob( /* Quaternion/Axis-Angle, so Eulers should just use default order. */ cob->rotOrder = EULER_ORDER_DEFAULT; } - copy_m4_m4(cob->matrix, ob->object_to_world().ptr()); + copy_m4_m4(cob->matrix, ob->object_to_world); } else { unit_m4(cob->matrix); @@ -181,7 +181,7 @@ bConstraintOb *BKE_constraints_make_evalob( } /* matrix in world-space */ - mul_m4_m4m4(cob->matrix, ob->object_to_world().ptr(), cob->pchan->pose_mat); + mul_m4_m4m4(cob->matrix, ob->object_to_world, cob->pchan->pose_mat); } else { unit_m4(cob->matrix); @@ -222,7 +222,7 @@ void BKE_constraints_clear_evalob(bConstraintOb *cob) /* cob->ob might not exist! */ if (cob->ob) { /* copy new ob-matrix back to owner */ - copy_m4_m4(cob->ob->runtime->object_to_world.ptr(), cob->matrix); + copy_m4_m4(cob->ob->object_to_world, cob->matrix); /* copy inverse of delta back to owner */ invert_m4_m4(cob->ob->constinv, delta); @@ -233,7 +233,7 @@ void BKE_constraints_clear_evalob(bConstraintOb *cob) /* cob->ob or cob->pchan might not exist */ if (cob->ob && cob->pchan) { /* copy new pose-matrix back to owner */ - mul_m4_m4m4(cob->pchan->pose_mat, cob->ob->world_to_object().ptr(), cob->matrix); + mul_m4_m4m4(cob->pchan->pose_mat, cob->ob->world_to_object, cob->matrix); /* copy inverse of delta back to owner */ invert_m4_m4(cob->pchan->constinv, delta); @@ -282,7 +282,7 @@ void BKE_constraint_mat_convertspace(Object *ob, } else { /* World to pose. */ - invert_m4_m4(imat, ob->object_to_world().ptr()); + invert_m4_m4(imat, ob->object_to_world); mul_m4_m4m4(mat, imat, mat); /* Use pose-space as stepping stone for other spaces. */ @@ -326,7 +326,7 @@ void BKE_constraint_mat_convertspace(Object *ob, } else { /* Pose to world. */ - mul_m4_m4m4(mat, ob->object_to_world().ptr(), mat); + mul_m4_m4m4(mat, ob->object_to_world, mat); /* Use world-space as stepping stone for other spaces. */ if (to != CONSTRAINT_SPACE_WORLD) { /* Call self with slightly different values. */ @@ -436,7 +436,7 @@ void BKE_constraint_mat_convertspace(Object *ob, /* Check if object has a parent. */ if (ob->parent) { /* 'subtract' parent's effects from owner. */ - mul_m4_m4m4(diff_mat, ob->parent->object_to_world().ptr(), ob->parentinv); + mul_m4_m4m4(diff_mat, ob->parent->object_to_world, ob->parentinv); invert_m4_m4_safe(imat, diff_mat); mul_m4_m4m4(mat, imat, mat); } @@ -472,7 +472,7 @@ void BKE_constraint_mat_convertspace(Object *ob, /* check that object has a parent - otherwise this won't work */ if (ob->parent) { /* 'add' parent's effect back to owner */ - mul_m4_m4m4(diff_mat, ob->parent->object_to_world().ptr(), ob->parentinv); + mul_m4_m4m4(diff_mat, ob->parent->object_to_world, ob->parentinv); mul_m4_m4m4(mat, diff_mat, mat); } else { @@ -525,7 +525,7 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[ const int defgroup = BKE_object_defgroup_name_index(ob, substring); /* initialize target matrix using target matrix */ - copy_m4_m4(mat, ob->object_to_world().ptr()); + copy_m4_m4(mat, ob->object_to_world); /* get index of vertex group */ if (defgroup == -1) { @@ -591,7 +591,7 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[ * calc_gizmo_stats, V3D_ORIENT_NORMAL case */ /* We need the transpose of the inverse for a normal. */ - copy_m3_m4(imat, ob->object_to_world().ptr()); + copy_m3_m4(imat, ob->object_to_world); invert_m3_m3(tmat, imat); transpose_m3(tmat); @@ -612,7 +612,7 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[ normalize_m4(mat); /* apply the average coordinate as the new location */ - mul_v3_m4v3(mat[3], ob->object_to_world().ptr(), vec); + mul_v3_m4v3(mat[3], ob->object_to_world, vec); } /* function that sets the given matrix based on given vertex group in lattice */ @@ -634,7 +634,7 @@ static void contarget_get_lattice_mat(Object *ob, const char *substring, float m const int defgroup = BKE_object_defgroup_name_index(ob, substring); /* initialize target matrix using target matrix */ - copy_m4_m4(mat, ob->object_to_world().ptr()); + copy_m4_m4(mat, ob->object_to_world); /* get index of vertex group */ if (defgroup == -1) { @@ -668,12 +668,11 @@ static void contarget_get_lattice_mat(Object *ob, const char *substring, float m } } - /* find average location, then multiply by ob->object_to_world().ptr() to find world-space - * location */ + /* find average location, then multiply by ob->object_to_world to find world-space location */ if (grouped) { mul_v3_fl(vec, 1.0f / grouped); } - mul_v3_m4v3(tvec, ob->object_to_world().ptr(), vec); + mul_v3_m4v3(tvec, ob->object_to_world, vec); /* copy new location to matrix */ copy_v3_v3(mat[3], tvec); @@ -692,7 +691,7 @@ static void constraint_target_to_mat4(Object *ob, { /* Case OBJECT */ if (substring[0] == '\0') { - copy_m4_m4(mat, ob->object_to_world().ptr()); + copy_m4_m4(mat, ob->object_to_world); BKE_constraint_mat_convertspace(ob, nullptr, cob, mat, from, to, false); } /* Case VERTEXGROUP */ @@ -727,7 +726,7 @@ static void constraint_target_to_mat4(Object *ob, if (headtail < 0.000001f && !(is_bbone && full_bbone)) { /* skip length interpolation if set to head */ - mul_m4_m4m4(mat, ob->object_to_world().ptr(), pchan->pose_mat); + mul_m4_m4m4(mat, ob->object_to_world, pchan->pose_mat); } else if (is_bbone && pchan->bone->segments == pchan->runtime.bbone_segments) { /* use point along bbone */ @@ -753,7 +752,7 @@ static void constraint_target_to_mat4(Object *ob, mul_v3_m4v3(tempmat[3], pchan->pose_mat, loc); } - mul_m4_m4m4(mat, ob->object_to_world().ptr(), tempmat); + mul_m4_m4m4(mat, ob->object_to_world, tempmat); } else { float tempmat[4][4], loc[3]; @@ -765,11 +764,11 @@ static void constraint_target_to_mat4(Object *ob, copy_m4_m4(tempmat, pchan->pose_mat); copy_v3_v3(tempmat[3], loc); - mul_m4_m4m4(mat, ob->object_to_world().ptr(), tempmat); + mul_m4_m4m4(mat, ob->object_to_world, tempmat); } } else { - copy_m4_m4(mat, ob->object_to_world().ptr()); + copy_m4_m4(mat, ob->object_to_world); } /* convert matrix space as required */ @@ -1079,7 +1078,7 @@ static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar if (data->flag & CHILDOF_SET_INVERSE) { invert_m4_m4(data->invmat, parmat); if (cob->pchan != nullptr) { - mul_m4_series(data->invmat, data->invmat, cob->ob->object_to_world().ptr()); + mul_m4_series(data->invmat, data->invmat, cob->ob->object_to_world); } copy_m4_m4(inverse_matrix, data->invmat); @@ -1399,8 +1398,8 @@ static void kinematic_get_tarmat(Depsgraph * /*depsgraph*/, else { float vec[3]; /* move grabtarget into world space */ - mul_v3_m4v3(vec, ob->object_to_world().ptr(), data->grabtarget); - copy_m4_m4(ct->matrix, ob->object_to_world().ptr()); + mul_v3_m4v3(vec, ob->object_to_world, data->grabtarget); + copy_m4_m4(ct->matrix, ob->object_to_world); copy_v3_v3(ct->matrix[3], vec); } } @@ -1540,7 +1539,7 @@ static void followpath_get_tarmat(Depsgraph * /*depsgraph*/, copy_v3_v3(totmat[3], vec); - mul_m4_m4m4(ct->matrix, ct->tar->object_to_world().ptr(), totmat); + mul_m4_m4m4(ct->matrix, ct->tar->object_to_world, totmat); } } } @@ -2570,7 +2569,7 @@ static void armdef_get_tarmat(Depsgraph * /*depsgraph*/, bPoseChannel *pchan = BKE_pose_channel_find_name(ct->tar->pose, ct->subtarget); if (pchan != nullptr) { - mul_m4_m4m4(ct->matrix, ct->tar->object_to_world().ptr(), pchan->pose_mat); + mul_m4_m4m4(ct->matrix, ct->tar->object_to_world, pchan->pose_mat); return; } } @@ -2627,7 +2626,7 @@ static void armdef_accumulate_bone(const bConstraintTarget *ct, float weight = ct->weight; /* Our object's location in target pose space. */ - invert_m4_m4(iobmat, ct->tar->object_to_world().ptr()); + invert_m4_m4(iobmat, ct->tar->object_to_world); mul_v3_m4v3(co, iobmat, wco); /* Multiply by the envelope weight when appropriate. */ @@ -2652,7 +2651,7 @@ static void armdef_accumulate_bone(const bConstraintTarget *ct, mul_m4_m4m4(basemat, bone->arm_mat, b_bone_rest_mats[index].mat); } - armdef_accumulate_matrix(ct->tar->object_to_world().ptr(), + armdef_accumulate_matrix(ct->tar->object_to_world, iobmat, basemat, b_bone_mats[index + 1].mat, @@ -2666,7 +2665,7 @@ static void armdef_accumulate_bone(const bConstraintTarget *ct, mul_m4_m4m4(basemat, bone->arm_mat, b_bone_rest_mats[index + 1].mat); } - armdef_accumulate_matrix(ct->tar->object_to_world().ptr(), + armdef_accumulate_matrix(ct->tar->object_to_world, iobmat, basemat, b_bone_mats[index + 2].mat, @@ -2677,7 +2676,7 @@ static void armdef_accumulate_bone(const bConstraintTarget *ct, } else { /* Simple bone. This requires DEG_OPCODE_BONE_DONE dependency due to chan_mat. */ - armdef_accumulate_matrix(ct->tar->object_to_world().ptr(), + armdef_accumulate_matrix(ct->tar->object_to_world, iobmat, bone->arm_mat, pchan->chan_mat, @@ -2710,7 +2709,7 @@ static void armdef_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targ /* For constraints on bones, use the rest position to bind b-bone segments * and envelopes, to allow safely changing the bone location as if parented. */ copy_v3_v3(input_co, cob->pchan->bone->arm_head); - mul_m4_v3(cob->ob->object_to_world().ptr(), input_co); + mul_m4_v3(cob->ob->object_to_world, input_co); } else { copy_v3_v3(input_co, cob->matrix[3]); @@ -3942,7 +3941,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar unit_m4(totmat); copy_v3_v3(totmat[3], vec); - mul_m4_m4m4(targetMatrix, ct->tar->object_to_world().ptr(), totmat); + mul_m4_m4m4(targetMatrix, ct->tar->object_to_world, totmat); } } @@ -4243,7 +4242,7 @@ static void shrinkwrap_get_tarmat(Depsgraph * /*depsgraph*/, if (BKE_shrinkwrap_init_tree( &tree, target_eval, scon->shrinkType, scon->shrinkMode, do_track_normal)) { - BLI_space_transform_from_matrices(&transform, cob->matrix, ct->tar->object_to_world().ptr()); + BLI_space_transform_from_matrices(&transform, cob->matrix, ct->tar->object_to_world); switch (scon->shrinkType) { case MOD_SHRINKWRAP_NEAREST_SURFACE: @@ -4917,7 +4916,7 @@ static void followtrack_evaluate_using_3d_position_object(FollowTrackContext *co /* Object matrix of the camera. */ float camera_obmat[4][4]; - copy_m4_m4(camera_obmat, camera_object->object_to_world().ptr()); + copy_m4_m4(camera_obmat, camera_object->object_to_world); /* Calculate inverted matrix of the solved camera at the current time. */ float reconstructed_camera_mat[4][4]; @@ -5069,11 +5068,10 @@ static void followtrack_project_to_depth_object_if_needed(FollowTrackContext *co } float depth_object_mat_inv[4][4]; - invert_m4_m4(depth_object_mat_inv, depth_object->object_to_world().ptr()); + invert_m4_m4(depth_object_mat_inv, depth_object->object_to_world); float ray_start[3], ray_end[3]; - mul_v3_m4v3( - ray_start, depth_object_mat_inv, context->camera_object->object_to_world().location()); + mul_v3_m4v3(ray_start, depth_object_mat_inv, context->camera_object->object_to_world[3]); mul_v3_m4v3(ray_end, depth_object_mat_inv, cob->matrix[3]); float ray_direction[3]; @@ -5096,7 +5094,7 @@ static void followtrack_project_to_depth_object_if_needed(FollowTrackContext *co &tree_data); if (result != -1) { - mul_v3_m4v3(cob->matrix[3], depth_object->object_to_world().ptr(), hit.co); + mul_v3_m4v3(cob->matrix[3], depth_object->object_to_world, hit.co); } free_bvhtree_from_mesh(&tree_data); @@ -5144,9 +5142,9 @@ static void followtrack_evaluate_using_2d_position(FollowTrackContext *context, } float disp[3]; - mul_v3_m4v3(disp, camera_object->object_to_world().ptr(), vec); + mul_v3_m4v3(disp, camera_object->object_to_world, vec); - copy_m4_m4(rmat, camera_object->object_to_world().ptr()); + copy_m4_m4(rmat, camera_object->object_to_world); zero_v3(rmat[3]); mul_m4_m4m4(cob->matrix, cob->matrix, rmat); @@ -5168,10 +5166,10 @@ static void followtrack_evaluate_using_2d_position(FollowTrackContext *context, } float disp[3]; - mul_v3_m4v3(disp, camera_object->object_to_world().ptr(), vec); + mul_v3_m4v3(disp, camera_object->object_to_world, vec); /* apply camera rotation so Z-axis would be co-linear */ - copy_m4_m4(rmat, camera_object->object_to_world().ptr()); + copy_m4_m4(rmat, camera_object->object_to_world); zero_v3(rmat[3]); mul_m4_m4m4(cob->matrix, cob->matrix, rmat); @@ -5317,7 +5315,7 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object, framenr, mat); invert_m4_m4(imat, mat); - mul_m4_m4m4(parmat, camob->object_to_world().ptr(), imat); + mul_m4_m4m4(parmat, camob->object_to_world, imat); copy_m4_m4(obmat, cob->matrix); @@ -5670,7 +5668,7 @@ bool BKE_constraint_apply_for_object(Depsgraph *depsgraph, BLI_freelinkN(&single_con, new_con); /* Apply transform from matrix. */ - BKE_object_apply_mat4(ob, ob_eval->object_to_world().ptr(), true, true); + BKE_object_apply_mat4(ob, ob_eval->object_to_world, true, true); return true; } @@ -6263,7 +6261,7 @@ void BKE_constraint_target_matrix_get(Depsgraph *depsgraph, cob->ob = (Object *)ownerdata; cob->pchan = nullptr; if (cob->ob) { - copy_m4_m4(cob->matrix, cob->ob->object_to_world().ptr()); + copy_m4_m4(cob->matrix, cob->ob->object_to_world); copy_m4_m4(cob->startmat, cob->matrix); } else { diff --git a/source/blender/blenkernel/intern/context.cc b/source/blender/blenkernel/intern/context.cc index 648914b698d..075f20ce57b 100644 --- a/source/blender/blenkernel/intern/context.cc +++ b/source/blender/blenkernel/intern/context.cc @@ -30,15 +30,14 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_layer.hh" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_sound.h" -#include "BKE_wm_runtime.hh" #include "BKE_workspace.h" #include "RE_engine.h" @@ -707,7 +706,7 @@ wmWindowManager *CTX_wm_manager(const bContext *C) bool CTX_wm_interface_locked(const bContext *C) { - return C->wm.manager->runtime->is_interface_locked; + return bool(C->wm.manager->is_interface_locked); } wmWindow *CTX_wm_window(const bContext *C) @@ -767,7 +766,7 @@ wmMsgBus *CTX_wm_message_bus(const bContext *C) ReportList *CTX_wm_reports(const bContext *C) { if (C->wm.manager) { - return &(C->wm.manager->runtime->reports); + return &(C->wm.manager->reports); } return nullptr; diff --git a/source/blender/blenkernel/intern/cpp_types.cc b/source/blender/blenkernel/intern/cpp_types.cc index c78d84020a8..81c23bb6307 100644 --- a/source/blender/blenkernel/intern/cpp_types.cc +++ b/source/blender/blenkernel/intern/cpp_types.cc @@ -6,6 +6,7 @@ #include "BLI_cpp_type_make.hh" #include "BLI_cpp_types_make.hh" #include "BLI_math_matrix_types.hh" +#include "BLI_math_quaternion_types.hh" #include "BLI_math_vector_types.hh" #include "BKE_cpp_types.hh" diff --git a/source/blender/blenkernel/intern/crazyspace.cc b/source/blender/blenkernel/intern/crazyspace.cc index 0171f060639..e76b1ec0709 100644 --- a/source/blender/blenkernel/intern/crazyspace.cc +++ b/source/blender/blenkernel/intern/crazyspace.cc @@ -11,7 +11,9 @@ #include "DNA_mesh_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "BLI_bitmap.h" #include "BLI_linklist.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" @@ -28,8 +30,9 @@ #include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" #include "BKE_multires.hh" +#include "BKE_object.hh" #include "BKE_object_types.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc index 14adcdb2496..391ace21270 100644 --- a/source/blender/blenkernel/intern/curve.cc +++ b/source/blender/blenkernel/intern/curve.cc @@ -25,7 +25,7 @@ #include "BLI_math_vector_types.hh" #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" /* Allow using deprecated functionality for .blend file I/O. */ #define DNA_DEPRECATED_ALLOW @@ -40,18 +40,24 @@ #include "DNA_object_types.h" #include "DNA_vfont_types.h" +#include "BKE_anim_data.h" #include "BKE_curve.hh" #include "BKE_curveprofile.h" +#include "BKE_displist.h" #include "BKE_idtype.hh" #include "BKE_key.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_main.hh" +#include "BKE_object.hh" #include "BKE_object_types.hh" #include "BKE_vfont.hh" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" +#include "CLG_log.h" + #include "BLO_read_write.hh" using blender::float3; @@ -271,7 +277,6 @@ static void curve_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_CU_LEGACY = { /*id_code*/ ID_CU_LEGACY, /*id_filter*/ FILTER_ID_CU_LEGACY, - /*dependencies_id_types*/ FILTER_ID_OB | FILTER_ID_MA | FILTER_ID_VF | FILTER_ID_KE, /*main_listbase_index*/ INDEX_ID_CU_LEGACY, /*struct_size*/ sizeof(Curve), /*name*/ "Curve", diff --git a/source/blender/blenkernel/intern/curve_bevel.cc b/source/blender/blenkernel/intern/curve_bevel.cc index 9240519c032..9a6d59e85ca 100644 --- a/source/blender/blenkernel/intern/curve_bevel.cc +++ b/source/blender/blenkernel/intern/curve_bevel.cc @@ -11,8 +11,9 @@ #include +#include "BLI_alloca.h" #include "BLI_listbase.h" -#include "BLI_math_base.h" /* Needed with MSVC for M_PI & M_PI_2. */ +#include "BLI_math_base.h" #include "MEM_guardedalloc.h" @@ -21,6 +22,7 @@ #include "DNA_object_types.h" #include "BKE_curve.hh" +#include "BKE_curveprofile.h" #include "BKE_displist.h" #include "BKE_object_types.hh" diff --git a/source/blender/blenkernel/intern/curve_convert.cc b/source/blender/blenkernel/intern/curve_convert.cc index 6b64802ccac..7443fba7e32 100644 --- a/source/blender/blenkernel/intern/curve_convert.cc +++ b/source/blender/blenkernel/intern/curve_convert.cc @@ -8,12 +8,14 @@ #include "DNA_curve_types.h" #include "DNA_object_types.h" +#include "DNA_vfont_types.h" #include "BLI_utildefines.h" #include "BKE_curve.hh" #include "BKE_displist.h" #include "BKE_lib_id.hh" +#include "BKE_modifier.hh" #include "BKE_vfont.hh" #include "DEG_depsgraph.hh" diff --git a/source/blender/blenkernel/intern/curve_decimate.cc b/source/blender/blenkernel/intern/curve_decimate.cc index 7b776b3b027..579b01fa07b 100644 --- a/source/blender/blenkernel/intern/curve_decimate.cc +++ b/source/blender/blenkernel/intern/curve_decimate.cc @@ -18,9 +18,9 @@ extern "C" { #include "curve_fit_nd.h" } -#include +#include "BLI_strict_flags.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include struct Knot { Knot *next, *prev; diff --git a/source/blender/blenkernel/intern/curve_deform.cc b/source/blender/blenkernel/intern/curve_deform.cc index 2dc44376258..422f5239b29 100644 --- a/source/blender/blenkernel/intern/curve_deform.cc +++ b/source/blender/blenkernel/intern/curve_deform.cc @@ -25,6 +25,7 @@ #include "BKE_anim_path.h" #include "BKE_curve.hh" #include "BKE_editmesh.hh" +#include "BKE_lattice.hh" #include "BKE_modifier.hh" #include "BKE_object_types.hh" @@ -47,8 +48,8 @@ struct CurveDeform { static void init_curve_deform(const Object *ob_curve, const Object *ob_target, CurveDeform *cd) { float imat[4][4]; - invert_m4_m4(imat, ob_target->object_to_world().ptr()); - mul_m4_m4m4(cd->objectspace, imat, ob_curve->object_to_world().ptr()); + invert_m4_m4(imat, ob_target->object_to_world); + mul_m4_m4m4(cd->objectspace, imat, ob_curve->object_to_world); invert_m4_m4(cd->curvespace, cd->objectspace); copy_m3_m4(cd->objectspace3, cd->objectspace); cd->no_rot_axis = 0; diff --git a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc index 86abea04b4c..a741f9a3c1d 100644 --- a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc +++ b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc @@ -711,7 +711,7 @@ static void copy_indices_to_offset_ranges(const VArray &src, /* This unnecessarily instantiates the "is single" case (which should be handled elsewhere if * it's ever used for attributes), but the alternative is duplicating the function for spans and * other virtual arrays. */ - devirtualize_varray(src, [&](const auto src) { + devirtualize_varray(src, [&](const auto &src) { threading::parallel_for(curve_indices.index_range(), 512, [&](IndexRange range) { for (const int i : range) { dst.slice(mesh_offsets[i]).fill(src[curve_indices[i]]); diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index 38e7d9d9e66..8e0a03b2330 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -17,6 +17,7 @@ #include "DNA_object_types.h" #include "BLI_index_range.hh" +#include "BLI_listbase.h" #include "BLI_math_base.h" #include "BLI_math_matrix.hh" #include "BLI_rand.hh" @@ -27,16 +28,20 @@ #include "BKE_anim_data.h" #include "BKE_curves.hh" +#include "BKE_customdata.hh" #include "BKE_geometry_fields.hh" #include "BKE_geometry_set.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_lib_remap.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph_query.hh" @@ -133,7 +138,6 @@ static void curves_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_CV = { /*id_code*/ ID_CV, /*id_filter*/ FILTER_ID_CV, - /*dependencies_id_types*/ FILTER_ID_MA | FILTER_ID_OB, /*main_listbase_index*/ INDEX_ID_CV, /*struct_size*/ sizeof(Curves), /*name*/ "Curves", @@ -313,11 +317,11 @@ void curves_copy_parameters(const Curves &src, Curves &dst) CurvesSurfaceTransforms::CurvesSurfaceTransforms(const Object &curves_ob, const Object *surface_ob) { - this->curves_to_world = curves_ob.object_to_world(); + this->curves_to_world = float4x4_view(curves_ob.object_to_world); this->world_to_curves = math::invert(this->curves_to_world); if (surface_ob != nullptr) { - this->surface_to_world = surface_ob->object_to_world(); + this->surface_to_world = float4x4_view(surface_ob->object_to_world); this->world_to_surface = math::invert(this->surface_to_world); this->surface_to_curves = this->world_to_curves * this->surface_to_world; this->curves_to_surface = this->world_to_surface * this->curves_to_world; diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc index 14fed9b0a8c..9461d354abf 100644 --- a/source/blender/blenkernel/intern/curves_geometry.cc +++ b/source/blender/blenkernel/intern/curves_geometry.cc @@ -89,85 +89,89 @@ CurvesGeometry::CurvesGeometry(const int point_num, const int curve_num) this->runtime->type_counts[CURVE_TYPE_CATMULL_ROM] = curve_num; } -CurvesGeometry::CurvesGeometry(const CurvesGeometry &other) +/** + * \note Expects `dst` to be initialized, since the original attributes must be freed. + */ +static void copy_curves_geometry(CurvesGeometry &dst, const CurvesGeometry &src) { - this->curve_offsets = other.curve_offsets; - if (other.runtime->curve_offsets_sharing_info) { - other.runtime->curve_offsets_sharing_info->add_user(); + CustomData_free(&dst.point_data, dst.point_num); + CustomData_free(&dst.curve_data, dst.curve_num); + dst.point_num = src.point_num; + dst.curve_num = src.curve_num; + CustomData_copy(&src.point_data, &dst.point_data, CD_MASK_ALL, dst.point_num); + CustomData_copy(&src.curve_data, &dst.curve_data, CD_MASK_ALL, dst.curve_num); + + dst.vertex_group_active_index = src.vertex_group_active_index; + BKE_defgroup_copy_list(&dst.vertex_group_names, &src.vertex_group_names); + + implicit_sharing::copy_shared_pointer(src.curve_offsets, + src.runtime->curve_offsets_sharing_info, + &dst.curve_offsets, + &dst.runtime->curve_offsets_sharing_info); + + dst.tag_topology_changed(); + + /* Though type counts are a cache, they must be copied because they are calculated eagerly. */ + dst.runtime->type_counts = src.runtime->type_counts; + dst.runtime->evaluated_offsets_cache = src.runtime->evaluated_offsets_cache; + dst.runtime->nurbs_basis_cache = src.runtime->nurbs_basis_cache; + dst.runtime->evaluated_position_cache = src.runtime->evaluated_position_cache; + dst.runtime->bounds_cache = src.runtime->bounds_cache; + dst.runtime->evaluated_length_cache = src.runtime->evaluated_length_cache; + dst.runtime->evaluated_tangent_cache = src.runtime->evaluated_tangent_cache; + dst.runtime->evaluated_normal_cache = src.runtime->evaluated_normal_cache; + + if (src.runtime->bake_materials) { + dst.runtime->bake_materials = std::make_unique( + *src.runtime->bake_materials); } +} - CustomData_copy(&other.point_data, &this->point_data, CD_MASK_ALL, other.point_num); - CustomData_copy(&other.curve_data, &this->curve_data, CD_MASK_ALL, other.curve_num); - - this->point_num = other.point_num; - this->curve_num = other.curve_num; - - BKE_defgroup_copy_list(&this->vertex_group_names, &other.vertex_group_names); - this->vertex_group_active_index = other.vertex_group_active_index; - - this->runtime = MEM_new( - __func__, - CurvesGeometryRuntime{other.runtime->curve_offsets_sharing_info, - other.runtime->type_counts, - other.runtime->evaluated_offsets_cache, - other.runtime->nurbs_basis_cache, - other.runtime->evaluated_position_cache, - other.runtime->bounds_cache, - other.runtime->evaluated_length_cache, - other.runtime->evaluated_tangent_cache, - other.runtime->evaluated_normal_cache, - {}}); - - if (other.runtime->bake_materials) { - this->runtime->bake_materials = std::make_unique( - *other.runtime->bake_materials); - } +CurvesGeometry::CurvesGeometry(const CurvesGeometry &other) : CurvesGeometry() +{ + copy_curves_geometry(*this, other); } CurvesGeometry &CurvesGeometry::operator=(const CurvesGeometry &other) { - if (this == &other) { - return *this; + if (this != &other) { + copy_curves_geometry(*this, other); } - std::destroy_at(this); - new (this) CurvesGeometry(other); return *this; } -CurvesGeometry::CurvesGeometry(CurvesGeometry &&other) +/* The source should be empty, but in a valid state so that using it further will work. */ +static void move_curves_geometry(CurvesGeometry &dst, CurvesGeometry &src) { - this->curve_offsets = other.curve_offsets; - other.curve_offsets = nullptr; + dst.point_num = src.point_num; + std::swap(dst.point_data, src.point_data); + CustomData_free(&src.point_data, src.point_num); + src.point_num = 0; - this->point_data = other.point_data; - CustomData_reset(&other.point_data); + dst.curve_num = src.curve_num; + std::swap(dst.curve_data, src.curve_data); + CustomData_free(&src.curve_data, src.curve_num); + src.curve_num = 0; - this->curve_data = other.curve_data; - CustomData_reset(&other.curve_data); + std::swap(dst.curve_offsets, src.curve_offsets); - this->point_num = other.point_num; - other.point_num = 0; + std::swap(dst.vertex_group_names.first, src.vertex_group_names.first); + std::swap(dst.vertex_group_names.last, src.vertex_group_names.last); + std::swap(dst.vertex_group_active_index, src.vertex_group_active_index); - this->curve_num = other.curve_num; - other.curve_num = 0; + std::swap(dst.runtime, src.runtime); +} - this->vertex_group_names = other.vertex_group_names; - BLI_listbase_clear(&other.vertex_group_names); - - this->vertex_group_active_index = other.vertex_group_active_index; - other.vertex_group_active_index = 0; - - this->runtime = other.runtime; - other.runtime = nullptr; +CurvesGeometry::CurvesGeometry(CurvesGeometry &&other) : CurvesGeometry() +{ + move_curves_geometry(*this, other); } CurvesGeometry &CurvesGeometry::operator=(CurvesGeometry &&other) { - if (this == &other) { - return *this; + if (this != &other) { + move_curves_geometry(*this, other); } - std::destroy_at(this); - new (this) CurvesGeometry(std::move(other)); return *this; } @@ -175,12 +179,11 @@ CurvesGeometry::~CurvesGeometry() { CustomData_free(&this->point_data, this->point_num); CustomData_free(&this->curve_data, this->curve_num); + implicit_sharing::free_shared_data(&this->curve_offsets, + &this->runtime->curve_offsets_sharing_info); BLI_freelistN(&this->vertex_group_names); - if (this->runtime) { - implicit_sharing::free_shared_data(&this->curve_offsets, - &this->runtime->curve_offsets_sharing_info); - MEM_delete(this->runtime); - } + MEM_delete(this->runtime); + this->runtime = nullptr; } /** \} */ @@ -207,14 +210,14 @@ static const CustomData &domain_custom_data(const CurvesGeometry &curves, const template static VArray get_varray_attribute(const CurvesGeometry &curves, const AttrDomain domain, - const StringRef name, + const StringRefNull name, const T default_value) { const int num = domain_num(curves, domain); const eCustomDataType type = cpp_type_to_custom_data_type(CPPType::get()); const CustomData &custom_data = domain_custom_data(curves, domain); - const T *data = (const T *)CustomData_get_layer_named(&custom_data, type, name); + const T *data = (const T *)CustomData_get_layer_named(&custom_data, type, name.c_str()); if (data != nullptr) { return VArray::ForSpan(Span(data, num)); } @@ -224,13 +227,13 @@ static VArray get_varray_attribute(const CurvesGeometry &curves, template static Span get_span_attribute(const CurvesGeometry &curves, const AttrDomain domain, - const StringRef name) + const StringRefNull name) { const int num = domain_num(curves, domain); const CustomData &custom_data = domain_custom_data(curves, domain); const eCustomDataType type = cpp_type_to_custom_data_type(CPPType::get()); - T *data = (T *)CustomData_get_layer_named(&custom_data, type, name); + T *data = (T *)CustomData_get_layer_named(&custom_data, type, name.c_str()); if (data == nullptr) { return {}; } @@ -240,18 +243,18 @@ static Span get_span_attribute(const CurvesGeometry &curves, template static MutableSpan get_mutable_attribute(CurvesGeometry &curves, const AttrDomain domain, - const StringRef name, + const StringRefNull name, const T default_value = T()) { const int num = domain_num(curves, domain); const eCustomDataType type = cpp_type_to_custom_data_type(CPPType::get()); CustomData &custom_data = domain_custom_data(curves, domain); - T *data = (T *)CustomData_get_layer_named_for_write(&custom_data, type, name, num); + T *data = (T *)CustomData_get_layer_named_for_write(&custom_data, type, name.c_str(), num); if (data != nullptr) { return {data, num}; } - data = (T *)CustomData_add_layer_named(&custom_data, type, CD_SET_DEFAULT, num, name); + data = (T *)CustomData_add_layer_named(&custom_data, type, CD_SET_DEFAULT, num, name.c_str()); MutableSpan span = {data, num}; if (num > 0 && span.first() != default_value) { span.fill(default_value); diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index 07b927620ca..e5779a2fc48 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -24,7 +24,6 @@ #include "BLI_endian_switch.h" #include "BLI_index_range.hh" #include "BLI_math_color_blend.h" -#include "BLI_math_matrix.hh" #include "BLI_math_quaternion_types.hh" #include "BLI_math_vector.hh" #include "BLI_mempool.h" @@ -41,7 +40,7 @@ # include "BLI_dynstr.h" #endif -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_anonymous_attribute_id.hh" #include "BKE_customdata.hh" @@ -114,7 +113,6 @@ bool CustomData_MeshMasks_are_matching(const CustomData_MeshMasks *mask_ref, struct LayerTypeInfo { int size; /* the memory size of one element of this layer's data */ - int alignment; /** name of the struct used, for file writing */ const char *structname; @@ -1528,16 +1526,6 @@ static void layerDefault_propquaternion(void *data, const int count) MutableSpan(static_cast(data), count).fill(math::Quaternion::identity()); } -/* -------------------------------------------------------------------- */ -/** \name Callbacks for (#math::Quaternion, #CD_PROP_FLOAT4X4) - * \{ */ - -static void layerDefault_propfloat4x4(void *data, const int count) -{ - using namespace blender; - MutableSpan(static_cast(data), count).fill(float4x4::identity()); -} - /** \} */ /* -------------------------------------------------------------------- */ @@ -1546,30 +1534,11 @@ static void layerDefault_propfloat4x4(void *data, const int count) static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { /* 0: CD_MVERT */ /* DEPRECATED */ - {sizeof(MVert), - alignof(MVert), - "MVert", - 1, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(MVert), "MVert", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 1: CD_MSTICKY */ /* DEPRECATED */ - {sizeof(float[2]), - alignof(float2), - "", - 1, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(float[2]), "", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 2: CD_MDEFORMVERT */ {sizeof(MDeformVert), - alignof(MDeformVert), "MDeformVert", 1, nullptr, @@ -1580,30 +1549,11 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { nullptr, layerConstruct_mdeformvert}, /* 3: CD_MEDGE */ /* DEPRECATED */ - {sizeof(MEdge), - alignof(MEdge), - "MEdge", - 1, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(MEdge), "MEdge", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 4: CD_MFACE */ - {sizeof(MFace), - alignof(MFace), - "MFace", - 1, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(MFace), "MFace", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 5: CD_MTFACE */ {sizeof(MTFace), - alignof(MTFace), "MTFace", 1, N_("UVMap"), @@ -1626,31 +1576,18 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerMaxNum_tface}, /* 6: CD_MCOL */ /* 4 MCol structs per face */ - {sizeof(MCol[4]), - alignof(MCol[4]), - "MCol", - 4, - N_("Col"), - nullptr, - nullptr, - layerInterp_mcol, - layerSwap_mcol, - layerDefault_mcol}, + {sizeof(MCol[4]), "MCol", 4, + N_("Col"), nullptr, nullptr, + layerInterp_mcol, layerSwap_mcol, layerDefault_mcol, + nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr}, /* 7: CD_ORIGINDEX */ - {sizeof(int), - alignof(int), - "", - 0, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - layerDefault_origindex}, + {sizeof(int), "", 0, nullptr, nullptr, nullptr, nullptr, nullptr, layerDefault_origindex}, /* 8: CD_NORMAL */ /* 3 floats per normal vector */ {sizeof(float[3]), - alignof(blender::float3), "vec3f", 1, nullptr, @@ -1668,10 +1605,9 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { nullptr, layerCopyValue_normal}, /* 9: CD_FACEMAP */ /* DEPRECATED */ - {sizeof(int), alignof(int), ""}, + {sizeof(int), ""}, /* 10: CD_PROP_FLOAT */ {sizeof(MFloatProperty), - alignof(float), "MFloatProperty", 1, N_("Float"), @@ -1684,7 +1620,6 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerValidate_propFloat}, /* 11: CD_PROP_INT32 */ {sizeof(MIntProperty), - alignof(int), "MIntProperty", 1, N_("Int"), @@ -1694,7 +1629,6 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { nullptr}, /* 12: CD_PROP_STRING */ {sizeof(MStringProperty), - alignof(MStringProperty), "MStringProperty", 1, N_("String"), @@ -1704,7 +1638,6 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { nullptr}, /* 13: CD_ORIGSPACE */ {sizeof(OrigSpaceFace), - alignof(OrigSpaceFace), "OrigSpaceFace", 1, N_("UVMap"), @@ -1714,25 +1647,15 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerSwap_origspace_face, layerDefault_origspace_face}, /* 14: CD_ORCO */ - {sizeof(float[3]), - alignof(blender::float3), - "", - 0, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(float[3]), "", 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 15: CD_MTEXPOLY */ /* DEPRECATED */ /* NOTE: when we expose the UV Map / TexFace split to the user, * change this back to face Texture. */ - {sizeof(int), alignof(int), "", 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, + {sizeof(int), "", 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 16: CD_MLOOPUV */ /* DEPRECATED */ - {sizeof(MLoopUV), alignof(MLoopUV), "MLoopUV", 1, N_("UVMap")}, + {sizeof(MLoopUV), "MLoopUV", 1, N_("UVMap")}, /* 17: CD_PROP_BYTE_COLOR */ {sizeof(MLoopCol), - alignof(MLoopCol), "MLoopCol", 1, N_("Col"), @@ -1754,19 +1677,9 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { nullptr, nullptr}, /* 18: CD_TANGENT */ - {sizeof(float[4][4]), - alignof(float[4][4]), - "", - 0, - N_("Tangent"), - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(float[4][4]), "", 0, N_("Tangent"), nullptr, nullptr, nullptr, nullptr, nullptr}, /* 19: CD_MDISPS */ {sizeof(MDisps), - alignof(MDisps), "MDisps", 1, nullptr, @@ -1787,30 +1700,11 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerWrite_mdisps, layerFilesize_mdisps}, /* 20: CD_PREVIEW_MCOL */ - {sizeof(blender::float4x4), - alignof(blender::float4x4), - "mat4x4f", - 1, - N_("4 by 4 Float Matrix"), - nullptr, - nullptr, - nullptr, - nullptr, - layerDefault_propfloat4x4}, + {}, /* 21: CD_ID_MCOL */ /* DEPRECATED */ - {sizeof(MCol[4]), - alignof(MCol[4]), - "", - 0, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(MCol[4]), "", 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 22: CD_TEXTURE_MCOL */ {sizeof(MCol[4]), - alignof(MCol[4]), "MCol", 4, N_("TexturedCol"), @@ -1820,40 +1714,13 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerSwap_mcol, layerDefault_mcol}, /* 23: CD_CLOTH_ORCO */ - {sizeof(float[3]), - alignof(float[3]), - "", - 0, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(float[3]), "", 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 24: CD_RECAST */ - {sizeof(MRecast), - alignof(MRecast), - "MRecast", - 1, - N_("Recast"), - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(MRecast), "MRecast", 1, N_("Recast"), nullptr, nullptr, nullptr, nullptr}, /* 25: CD_MPOLY */ /* DEPRECATED */ - {sizeof(MPoly), - alignof(MPoly), - "MPoly", - 1, - N_("NGon Face"), - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(MPoly), "MPoly", 1, N_("NGon Face"), nullptr, nullptr, nullptr, nullptr, nullptr}, /* 26: CD_MLOOP */ /* DEPRECATED */ {sizeof(MLoop), - alignof(MLoop), "MLoop", 1, N_("NGon Face-Vertex"), @@ -1863,23 +1730,15 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { nullptr, nullptr}, /* 27: CD_SHAPE_KEYINDEX */ - {sizeof(int), alignof(int), "", 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, + {sizeof(int), "", 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 28: CD_SHAPEKEY */ - {sizeof(float[3]), - alignof(float[3]), - "", - 0, - N_("ShapeKey"), - nullptr, - nullptr, - layerInterp_shapekey}, + {sizeof(float[3]), "", 0, N_("ShapeKey"), nullptr, nullptr, layerInterp_shapekey}, /* 29: CD_BWEIGHT */ /* DEPRECATED */ - {sizeof(MFloatProperty), alignof(MFloatProperty), "MFloatProperty", 1}, + {sizeof(MFloatProperty), "MFloatProperty", 1}, /* 30: CD_CREASE */ /* DEPRECATED */ - {sizeof(float), alignof(float), ""}, + {sizeof(float), ""}, /* 31: CD_ORIGSPACE_MLOOP */ {sizeof(OrigSpaceLoop), - alignof(OrigSpaceLoop), "OrigSpaceLoop", 1, N_("OS Loop"), @@ -1900,7 +1759,6 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { {}, /* 33: CD_BM_ELEM_PYPTR */ {sizeof(void *), - alignof(void *), "", 1, nullptr, @@ -1910,10 +1768,9 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { nullptr, nullptr}, /* 34: CD_PAINT_MASK */ /* DEPRECATED */ - {sizeof(float), alignof(float), "", 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, + {sizeof(float), "", 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 35: CD_GRID_PAINT_MASK */ {sizeof(GridPaintMask), - alignof(GridPaintMask), "GridPaintMask", 1, nullptr, @@ -1925,7 +1782,6 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerConstruct_grid_paint_mask}, /* 36: CD_MVERT_SKIN */ {sizeof(MVertSkin), - alignof(MVertSkin), "MVertSkin", 1, nullptr, @@ -1936,7 +1792,6 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerDefault_mvert_skin}, /* 37: CD_FREESTYLE_EDGE */ {sizeof(FreestyleEdge), - alignof(FreestyleEdge), "FreestyleEdge", 1, nullptr, @@ -1947,7 +1802,6 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { nullptr}, /* 38: CD_FREESTYLE_FACE */ {sizeof(FreestyleFace), - alignof(FreestyleFace), "FreestyleFace", 1, nullptr, @@ -1957,87 +1811,23 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { nullptr, nullptr}, /* 39: CD_MLOOPTANGENT */ - {sizeof(float[4]), - alignof(float[4]), - "", - 0, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(float[4]), "", 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 40: CD_TESSLOOPNORMAL */ - {sizeof(short[4][3]), - alignof(short[4][3]), - "", - 0, - nullptr, - nullptr, - nullptr, - nullptr, - layerSwap_flnor, - nullptr}, + {sizeof(short[4][3]), "", 0, nullptr, nullptr, nullptr, nullptr, layerSwap_flnor, nullptr}, /* 41: CD_CUSTOMLOOPNORMAL */ - {sizeof(short[2]), - alignof(short[2]), - "vec2s", - 1, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(short[2]), "vec2s", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 42: CD_SCULPT_FACE_SETS */ /* DEPRECATED */ - {sizeof(int), alignof(int), ""}, + {sizeof(int), ""}, /* 43: CD_LOCATION */ - {sizeof(float[3]), - alignof(float[3]), - "vec3f", - 1, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(float[3]), "vec3f", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 44: CD_RADIUS */ - {sizeof(float), - alignof(float), - "MFloatProperty", - 1, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(float), "MFloatProperty", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 45: CD_PROP_INT8 */ - {sizeof(int8_t), - alignof(int8_t), - "MInt8Property", - 1, - N_("Int8"), - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(int8_t), "MInt8Property", 1, N_("Int8"), nullptr, nullptr, nullptr, nullptr, nullptr}, /* 46: CD_PROP_INT32_2D */ - {sizeof(blender::int2), - alignof(blender::int2), - "vec2i", - 1, - N_("Int 2D"), - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(vec2i), "vec2i", 1, N_("Int 2D"), nullptr, nullptr, nullptr, nullptr, nullptr}, /* 47: CD_PROP_COLOR */ {sizeof(MPropCol), - alignof(MPropCol), "MPropCol", 1, N_("Color"), @@ -2060,7 +1850,6 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { nullptr}, /* 48: CD_PROP_FLOAT3 */ {sizeof(float[3]), - alignof(blender::float3), "vec3f", 1, N_("Float3"), @@ -2077,7 +1866,6 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerAdd_propfloat3}, /* 49: CD_PROP_FLOAT2 */ {sizeof(float[2]), - alignof(float2), "vec2f", 1, N_("Float2"), @@ -2096,7 +1884,6 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerCopyValue_propfloat2}, /* 50: CD_PROP_BOOL */ {sizeof(bool), - alignof(bool), "bool", 1, N_("Boolean"), @@ -2111,19 +1898,9 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { nullptr, nullptr}, /* 51: CD_HAIRLENGTH */ /* DEPRECATED */ /* UNUSED */ - {sizeof(float), - alignof(float), - "float", - 1, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr}, + {sizeof(float), "float", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}, /* 52: CD_PROP_QUATERNION */ {sizeof(float[4]), - alignof(blender::float4), "vec4f", 1, N_("Quaternion"), @@ -2325,7 +2102,7 @@ static CustomDataLayer *customData_add_layer__internal( void *layer_data_to_assign, const ImplicitSharingInfo *sharing_info_to_assign, int totelem, - const StringRef name); + const char *name); void CustomData_update_typemap(CustomData *data) { @@ -2357,15 +2134,12 @@ static bool customdata_typemap_is_valid(const CustomData *data) static void *copy_layer_data(const eCustomDataType type, const void *data, const int totelem) { const LayerTypeInfo &type_info = *layerType_getInfo(type); - const int64_t size_in_bytes = int64_t(totelem) * type_info.size; - void *new_data = MEM_mallocN_aligned(size_in_bytes, type_info.alignment, __func__); if (type_info.copy) { + void *new_data = MEM_malloc_arrayN(size_t(totelem), type_info.size, __func__); type_info.copy(data, new_data, totelem); + return new_data; } - else { - memcpy(new_data, data, size_in_bytes); - } - return new_data; + return MEM_dupallocN(data); } static void free_layer_data(const eCustomDataType type, const void *data, const int totelem) @@ -2615,7 +2389,7 @@ void CustomData_realloc(CustomData *data, const int64_t old_size_in_bytes = int64_t(old_size) * typeInfo->size; const int64_t new_size_in_bytes = int64_t(new_size) * typeInfo->size; - void *new_layer_data = MEM_mallocN_aligned(new_size_in_bytes, typeInfo->alignment, __func__); + void *new_layer_data = MEM_mallocN(new_size_in_bytes, __func__); /* Copy data to new array. */ if (old_size_in_bytes) { if (typeInfo->copy) { @@ -2806,11 +2580,11 @@ int CustomData_get_layer_index_n(const CustomData *data, const eCustomDataType t int CustomData_get_named_layer_index(const CustomData *data, const eCustomDataType type, - const StringRef name) + const char *name) { for (int i = 0; i < data->totlayer; i++) { if (data->layers[i].type == type) { - if (data->layers[i].name == name) { + if (STREQ(data->layers[i].name, name)) { return i; } } @@ -2819,10 +2593,10 @@ int CustomData_get_named_layer_index(const CustomData *data, return -1; } -int CustomData_get_named_layer_index_notype(const CustomData *data, const StringRef name) +int CustomData_get_named_layer_index_notype(const CustomData *data, const char *name) { for (int i = 0; i < data->totlayer; i++) { - if (data->layers[i].name == name) { + if (STREQ(data->layers[i].name, name)) { return i; } } @@ -2863,7 +2637,7 @@ int CustomData_get_stencil_layer_index(const CustomData *data, const eCustomData int CustomData_get_named_layer(const CustomData *data, const eCustomDataType type, - const StringRef name) + const char *name) { const int named_index = CustomData_get_named_layer_index(data, type, name); const int layer_index = data->typemap[type]; @@ -3071,7 +2845,7 @@ static CustomDataLayer *customData_add_layer__internal( void *layer_data_to_assign, const ImplicitSharingInfo *sharing_info_to_assign, const int totelem, - StringRef name) + const char *name) { const LayerTypeInfo &type_info = *layerType_getInfo(type); int flag = 0; @@ -3103,27 +2877,23 @@ static CustomDataLayer *customData_add_layer__internal( * leaks into the new layer. */ memset(&new_layer, 0, sizeof(CustomDataLayer)); - const int64_t size_in_bytes = int64_t(totelem) * type_info.size; - const char *alloc_name = layerType_getName(type); - if (alloctype.has_value()) { switch (*alloctype) { case CD_SET_DEFAULT: { if (totelem > 0) { - new_layer.data = MEM_mallocN_aligned(size_in_bytes, type_info.alignment, alloc_name); if (type_info.set_default_value) { + new_layer.data = MEM_malloc_arrayN(totelem, type_info.size, layerType_getName(type)); type_info.set_default_value(new_layer.data, totelem); } else { - /* Alternatively, #MEM_calloc_arrayN is faster, but has no aligned version. */ - memset(new_layer.data, 0, size_in_bytes); + new_layer.data = MEM_calloc_arrayN(totelem, type_info.size, layerType_getName(type)); } } break; } case CD_CONSTRUCT: { if (totelem > 0) { - new_layer.data = MEM_mallocN_aligned(size_in_bytes, type_info.alignment, alloc_name); + new_layer.data = MEM_malloc_arrayN(totelem, type_info.size, layerType_getName(type)); if (type_info.construct) { type_info.construct(new_layer.data, totelem); } @@ -3156,12 +2926,12 @@ static CustomDataLayer *customData_add_layer__internal( /* Set default name if none exists. Note we only call DATA_() once * we know there is a default name, to avoid overhead of locale lookups * in the depsgraph. */ - if (name.is_empty() && type_info.defaultname) { + if (!name && type_info.defaultname) { name = DATA_(type_info.defaultname); } - if (!name.is_empty()) { - name.copy(new_layer.name); + if (name) { + STRNCPY(new_layer.name, name); CustomData_set_layer_unique_name(data, index); } else { @@ -3227,7 +2997,7 @@ void *CustomData_add_layer_named(CustomData *data, const eCustomDataType type, const eCDAllocType alloctype, const int totelem, - const StringRef name) + const char *name) { CustomDataLayer *layer = customData_add_layer__internal( data, type, alloctype, nullptr, nullptr, totelem, name); @@ -3243,7 +3013,7 @@ const void *CustomData_add_layer_named_with_data(CustomData *data, eCustomDataType type, void *layer_data, int totelem, - const StringRef name, + const char *name, const ImplicitSharingInfo *sharing_info) { CustomDataLayer *layer = customData_add_layer__internal( @@ -3262,7 +3032,7 @@ void *CustomData_add_layer_anonymous(CustomData *data, const int totelem, const AnonymousAttributeIDHandle *anonymous_id) { - const StringRef name = anonymous_id->name().c_str(); + const char *name = anonymous_id->name().c_str(); CustomDataLayer *layer = customData_add_layer__internal( data, type, alloctype, nullptr, nullptr, totelem, name); CustomData_update_typemap(data); @@ -3284,7 +3054,7 @@ const void *CustomData_add_layer_anonymous_with_data( void *layer_data, const ImplicitSharingInfo *sharing_info) { - const StringRef name = anonymous_id->name().c_str(); + const char *name = anonymous_id->name().c_str(); CustomDataLayer *layer = customData_add_layer__internal( data, type, std::nullopt, layer_data, sharing_info, totelem, name); CustomData_update_typemap(data); @@ -3352,7 +3122,7 @@ bool CustomData_free_layer(CustomData *data, return true; } -bool CustomData_free_layer_named(CustomData *data, const StringRef name, const int totelem) +bool CustomData_free_layer_named(CustomData *data, const char *name, const int totelem) { for (const int i : IndexRange(data->totlayer)) { const CustomDataLayer &layer = data->layers[i]; @@ -3383,7 +3153,7 @@ void CustomData_free_layers(CustomData *data, const eCustomDataType type, const bool CustomData_has_layer_named(const CustomData *data, const eCustomDataType type, - const StringRef name) + const char *name) { return CustomData_get_named_layer_index(data, type, name) != -1; } @@ -3761,7 +3531,7 @@ void *CustomData_get_layer_n_for_write(CustomData *data, const void *CustomData_get_layer_named(const CustomData *data, const eCustomDataType type, - const StringRef name) + const char *name) { int layer_index = CustomData_get_named_layer_index(data, type, name); if (layer_index == -1) { @@ -3772,7 +3542,7 @@ const void *CustomData_get_layer_named(const CustomData *data, void *CustomData_get_layer_named_for_write(CustomData *data, const eCustomDataType type, - const StringRef name, + const char *name, const int totelem) { const int layer_index = CustomData_get_named_layer_index(data, type, name); @@ -3805,7 +3575,7 @@ int CustomData_get_n_offset(const CustomData *data, const eCustomDataType type, int CustomData_get_offset_named(const CustomData *data, const eCustomDataType type, - const StringRef name) + const char *name) { int layer_index = CustomData_get_named_layer_index(data, type, name); if (layer_index == -1) { @@ -3818,14 +3588,15 @@ int CustomData_get_offset_named(const CustomData *data, bool CustomData_set_layer_name(CustomData *data, const eCustomDataType type, const int n, - const StringRef name) + const char *name) { const int layer_index = CustomData_get_layer_index_n(data, type, n); - if (layer_index == -1) { + + if ((layer_index == -1) || !name) { return false; } - name.copy(data->layers[layer_index].name); + STRNCPY(data->layers[layer_index].name, name); return true; } @@ -4510,7 +4281,7 @@ int CustomData_layertype_layers_max(const eCustomDataType type) } static bool cd_layer_find_dupe(CustomData *data, - const StringRef name, + const char *name, const eCustomDataType type, const int index) { @@ -4520,12 +4291,12 @@ static bool cd_layer_find_dupe(CustomData *data, CustomDataLayer *layer = &data->layers[i]; if (CD_TYPE_AS_MASK(type) & CD_MASK_PROP_ALL) { - if ((CD_TYPE_AS_MASK(layer->type) & CD_MASK_PROP_ALL) && layer->name == name) { + if ((CD_TYPE_AS_MASK(layer->type) & CD_MASK_PROP_ALL) && STREQ(layer->name, name)) { return true; } } else { - if (i != index && layer->type == type && layer->name == name) { + if (i != index && layer->type == type && STREQ(layer->name, name)) { return true; } } @@ -4587,7 +4358,7 @@ void CustomData_set_layer_unique_name(CustomData *data, const int index) void CustomData_validate_layer_name(const CustomData *data, const eCustomDataType type, - const StringRef name, + const char *name, char *outname) { int index = -1; @@ -4605,9 +4376,7 @@ void CustomData_validate_layer_name(const CustomData *data, BLI_strncpy_utf8(outname, data->layers[index].name, MAX_CUSTOMDATA_LAYER_NAME); } else { - char name_c_str[MAX_CUSTOMDATA_LAYER_NAME]; - name.copy(name_c_str); - BLI_strncpy_utf8(outname, name_c_str, MAX_CUSTOMDATA_LAYER_NAME); + BLI_strncpy_utf8(outname, name, MAX_CUSTOMDATA_LAYER_NAME); } } diff --git a/source/blender/blenkernel/intern/data_transfer.cc b/source/blender/blenkernel/intern/data_transfer.cc index 889e9263293..713e8106939 100644 --- a/source/blender/blenkernel/intern/data_transfer.cc +++ b/source/blender/blenkernel/intern/data_transfer.cc @@ -30,7 +30,7 @@ #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_deform.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/blenkernel/intern/deform.cc b/source/blender/blenkernel/intern/deform.cc index b89af67c83e..35ae7115e98 100644 --- a/source/blender/blenkernel/intern/deform.cc +++ b/source/blender/blenkernel/intern/deform.cc @@ -28,7 +28,7 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_attribute.hh" #include "BKE_customdata.hh" diff --git a/source/blender/blenkernel/intern/displist.cc b/source/blender/blenkernel/intern/displist.cc index bcd71ea1cec..dfddc7e3221 100644 --- a/source/blender/blenkernel/intern/displist.cc +++ b/source/blender/blenkernel/intern/displist.cc @@ -15,8 +15,12 @@ #include "DNA_curve_types.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "DNA_vfont_types.h" +#include "BLI_bitmap.h" #include "BLI_index_range.hh" +#include "BLI_linklist.h" #include "BLI_listbase.h" #include "BLI_math_rotation.h" #include "BLI_memarena.h" @@ -32,6 +36,7 @@ #include "BKE_geometry_set.hh" #include "BKE_key.hh" #include "BKE_lib_id.hh" +#include "BKE_mball.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" diff --git a/source/blender/blenkernel/intern/dynamicpaint.cc b/source/blender/blenkernel/intern/dynamicpaint.cc index d4d1ec0c472..96d5c6f8c64 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.cc +++ b/source/blender/blenkernel/intern/dynamicpaint.cc @@ -22,7 +22,7 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -40,7 +40,7 @@ #include "BKE_armature.hh" #include "BKE_bvhutils.hh" /* bvh tree */ -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_collision.h" #include "BKE_colorband.hh" #include "BKE_constraint.h" @@ -60,7 +60,7 @@ #include "BKE_object.hh" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" @@ -3760,7 +3760,7 @@ struct DynamicPaintBrushVelocityData { const float (*positions_p)[3]; const float (*positions_c)[3]; - const float (*obmat)[4]; + float (*obmat)[4]; float (*prev_obmat)[4]; float timescale; @@ -3778,7 +3778,7 @@ static void dynamic_paint_brush_velocity_compute_cb(void *__restrict userdata, const float(*positions_p)[3] = data->positions_p; const float(*positions_c)[3] = data->positions_c; - const float(*obmat)[4] = data->obmat; + float(*obmat)[4] = data->obmat; float(*prev_obmat)[4] = data->prev_obmat; const float timescale = data->timescale; @@ -3832,7 +3832,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Depsgraph *depsgraph, float(*positions_p)[3] = reinterpret_cast( mesh_p->vert_positions_for_write().data()); - copy_m4_m4(prev_obmat, ob->object_to_world().ptr()); + copy_m4_m4(prev_obmat, ob->object_to_world); /* current frame mesh */ scene->r.cfra = cur_fra; @@ -3865,7 +3865,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Depsgraph *depsgraph, data.brush_vel = *brushVel; data.positions_p = positions_p; data.positions_c = positions_c; - data.obmat = ob->object_to_world().ptr(); + data.obmat = ob->object_to_world; data.prev_obmat = prev_obmat; data.timescale = timescale; @@ -3905,7 +3905,7 @@ static void dynamicPaint_brushObjectCalculateVelocity( SUBFRAME_RECURSION, BKE_scene_ctime_get(scene), eModifierType_DynamicPaint); - copy_m4_m4(prev_obmat, ob->object_to_world().ptr()); + copy_m4_m4(prev_obmat, ob->object_to_world); /* current frame mesh */ scene->r.cfra = cur_fra; @@ -3920,7 +3920,7 @@ static void dynamicPaint_brushObjectCalculateVelocity( /* calculate speed */ mul_m4_v3(prev_obmat, prev_loc); - mul_m4_v3(ob->object_to_world().ptr(), cur_loc); + mul_m4_v3(ob->object_to_world, cur_loc); sub_v3_v3v3(brushVel->v, cur_loc, prev_loc); mul_v3_fl(brushVel->v, 1.0f / timescale); @@ -4329,14 +4329,14 @@ static bool dynamicPaint_paintMesh(Depsgraph *depsgraph, * (Faster than transforming per surface point * coordinates and normals to object space) */ for (ii = 0; ii < numOfVerts; ii++) { - mul_m4_v3(brushOb->object_to_world().ptr(), positions[ii]); + mul_m4_v3(brushOb->object_to_world, positions[ii]); boundInsert(&mesh_bb, positions[ii]); /* for proximity project calculate average normal */ if (brush->flags & MOD_DPAINT_PROX_PROJECT && brush->collision != MOD_DPAINT_COL_VOLUME) { float nor[3]; copy_v3_v3(nor, vert_normals[ii]); - mul_mat3_m4_v3(brushOb->object_to_world().ptr(), nor); + mul_mat3_m4_v3(brushOb->object_to_world, nor); normalize_v3(nor); add_v3_v3(avg_brushNor, nor); @@ -5933,7 +5933,7 @@ static bool dynamicPaint_surfaceHasMoved(DynamicPaintSurface *surface, Object *o } /* matrix comparison */ - if (!equals_m4m4(bData->prev_obmat, ob->object_to_world().ptr())) { + if (!equals_m4m4(bData->prev_obmat, ob->object_to_world)) { return true; } @@ -6021,7 +6021,7 @@ static void dynamic_paint_generate_bake_data_cb(void *__restrict userdata, mul_v3_v3v3(scaled_nor, temp_nor, ob->scale); bData->bNormal[index].normal_scale = len_v3(scaled_nor); } - mul_mat3_m4_v3(ob->object_to_world().ptr(), temp_nor); + mul_mat3_m4_v3(ob->object_to_world, temp_nor); normalize_v3(temp_nor); negate_v3_v3(bData->bNormal[index].invNorm, temp_nor); } @@ -6059,7 +6059,7 @@ static void dynamic_paint_generate_bake_data_cb(void *__restrict userdata, mul_v3_v3v3(scaled_nor, temp_nor, ob->scale); bData->bNormal[index].normal_scale = len_v3(scaled_nor); } - mul_mat3_m4_v3(ob->object_to_world().ptr(), temp_nor); + mul_mat3_m4_v3(ob->object_to_world, temp_nor); normalize_v3(temp_nor); negate_v3_v3(bData->bNormal[index].invNorm, temp_nor); } @@ -6179,7 +6179,7 @@ static bool dynamicPaint_generateBakeData(DynamicPaintSurface *surface, bData->mesh_bounds.valid = false; for (index = 0; index < canvasNumOfVerts; index++) { copy_v3_v3(canvas_verts[index].v, positions[index]); - mul_m4_v3(ob->object_to_world().ptr(), canvas_verts[index].v); + mul_m4_v3(ob->object_to_world, canvas_verts[index].v); boundInsert(&bData->mesh_bounds, canvas_verts[index].v); } @@ -6209,7 +6209,7 @@ static bool dynamicPaint_generateBakeData(DynamicPaintSurface *surface, dynamicPaint_prepareAdjacencyData(surface, false); /* Copy current frame vertices to check against in next frame */ - copy_m4_m4(bData->prev_obmat, ob->object_to_world().ptr()); + copy_m4_m4(bData->prev_obmat, ob->object_to_world); memcpy(bData->prev_positions, positions.data(), canvasNumOfVerts * sizeof(float[3])); bData->clear = 0; diff --git a/source/blender/blenkernel/intern/editmesh.cc b/source/blender/blenkernel/intern/editmesh.cc index ef486e5e745..9e05b276535 100644 --- a/source/blender/blenkernel/intern/editmesh.cc +++ b/source/blender/blenkernel/intern/editmesh.cc @@ -19,6 +19,8 @@ #include "BKE_DerivedMesh.hh" #include "BKE_customdata.hh" #include "BKE_editmesh.hh" +#include "BKE_editmesh_cache.hh" +#include "BKE_lib_id.hh" #include "BKE_mesh.hh" #include "BKE_mesh_iterators.hh" #include "BKE_mesh_wrapper.hh" diff --git a/source/blender/blenkernel/intern/editmesh_cache.cc b/source/blender/blenkernel/intern/editmesh_cache.cc index fd244aa8d5a..682c8b3f317 100644 --- a/source/blender/blenkernel/intern/editmesh_cache.cc +++ b/source/blender/blenkernel/intern/editmesh_cache.cc @@ -14,6 +14,8 @@ #include "BLI_math_vector.h" #include "BLI_span.hh" +#include "DNA_mesh_types.h" + #include "BKE_editmesh.hh" #include "BKE_editmesh_cache.hh" /* own include */ diff --git a/source/blender/blenkernel/intern/editmesh_tangent.cc b/source/blender/blenkernel/intern/editmesh_tangent.cc index e9cb1aadc7f..eb03fbbb67f 100644 --- a/source/blender/blenkernel/intern/editmesh_tangent.cc +++ b/source/blender/blenkernel/intern/editmesh_tangent.cc @@ -12,6 +12,7 @@ #include "DNA_customdata_types.h" #include "DNA_defs.h" +#include "DNA_meshdata_types.h" #include "BKE_customdata.hh" #include "BKE_editmesh.hh" diff --git a/source/blender/blenkernel/intern/effect.cc b/source/blender/blenkernel/intern/effect.cc index 9b4f125aaa7..59cb6543431 100644 --- a/source/blender/blenkernel/intern/effect.cc +++ b/source/blender/blenkernel/intern/effect.cc @@ -14,9 +14,11 @@ #include "MEM_guardedalloc.h" +#include "DNA_collection_types.h" #include "DNA_curve_types.h" #include "DNA_listBase.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_force_types.h" #include "DNA_object_types.h" #include "DNA_particle_types.h" @@ -36,17 +38,20 @@ #include "BKE_anim_path.h" /* needed for where_on_path */ #include "BKE_bvhutils.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_collision.h" #include "BKE_curve.hh" #include "BKE_displist.h" #include "BKE_effect.h" #include "BKE_fluid.h" -#include "BKE_global.hh" +#include "BKE_global.h" +#include "BKE_layer.hh" +#include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" #include "BKE_particle.h" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_physics.hh" @@ -79,7 +84,7 @@ PartDeflect *BKE_partdeflect_new(int type) pd->pdef_sbift = 0.2f; pd->pdef_sboft = 0.02f; pd->pdef_cfrict = 5.0f; - pd->seed = (uint(ceil(BLI_time_now_seconds())) + 1) % 128; + pd->seed = (uint(ceil(BLI_check_seconds_timer())) + 1) % 128; pd->f_strength = 1.0f; pd->f_damp = 1.0f; @@ -155,8 +160,8 @@ static void precalculate_effector(Depsgraph *depsgraph, EffectorCache *eff) if (eff->ob->runtime->curve_cache->anim_path_accum_length) { BKE_where_on_path( eff->ob, 0.0, eff->guide_loc, eff->guide_dir, nullptr, &eff->guide_radius, nullptr); - mul_m4_v3(eff->ob->object_to_world().ptr(), eff->guide_loc); - mul_mat3_m4_v3(eff->ob->object_to_world().ptr(), eff->guide_dir); + mul_m4_v3(eff->ob->object_to_world, eff->guide_loc); + mul_mat3_m4_v3(eff->ob->object_to_world, eff->guide_dir); } } } @@ -713,8 +718,8 @@ bool get_effector_data(EffectorCache *eff, copy_v3_v3(efd->loc, positions[*efd->index]); copy_v3_v3(efd->nor, vert_normals[*efd->index]); - mul_m4_v3(eff->ob->object_to_world().ptr(), efd->loc); - mul_mat3_m4_v3(eff->ob->object_to_world().ptr(), efd->nor); + mul_m4_v3(eff->ob->object_to_world, efd->loc); + mul_mat3_m4_v3(eff->ob->object_to_world, efd->nor); normalize_v3(efd->nor); @@ -766,23 +771,23 @@ bool get_effector_data(EffectorCache *eff, const Object *ob = eff->ob; /* Use z-axis as normal. */ - normalize_v3_v3(efd->nor, ob->object_to_world().ptr()[2]); + normalize_v3_v3(efd->nor, ob->object_to_world[2]); if (eff->pd && ELEM(eff->pd->shape, PFIELD_SHAPE_PLANE, PFIELD_SHAPE_LINE)) { float temp[3], translate[3]; - sub_v3_v3v3(temp, point->loc, ob->object_to_world().location()); + sub_v3_v3v3(temp, point->loc, ob->object_to_world[3]); project_v3_v3v3(translate, temp, efd->nor); /* for vortex the shape chooses between old / new force */ if (eff->pd->forcefield == PFIELD_VORTEX || eff->pd->shape == PFIELD_SHAPE_LINE) { - add_v3_v3v3(efd->loc, ob->object_to_world().location(), translate); + add_v3_v3v3(efd->loc, ob->object_to_world[3], translate); } else { /* Normally `efd->loc` is closest point on effector XY-plane. */ sub_v3_v3v3(efd->loc, point->loc, translate); } } else { - copy_v3_v3(efd->loc, ob->object_to_world().location()); + copy_v3_v3(efd->loc, ob->object_to_world[3]); } zero_v3(efd->vel); @@ -807,8 +812,8 @@ bool get_effector_data(EffectorCache *eff, } else { /* for some effectors we need the object center every time */ - sub_v3_v3v3(efd->vec_to_point2, point->loc, eff->ob->object_to_world().location()); - normalize_v3_v3(efd->nor2, eff->ob->object_to_world().ptr()[2]); + sub_v3_v3v3(efd->vec_to_point2, point->loc, eff->ob->object_to_world[3]); + normalize_v3_v3(efd->nor2, eff->ob->object_to_world[2]); } } @@ -881,7 +886,7 @@ static void do_texture_effector(EffectorCache *eff, copy_v3_v3(tex_co, point->loc); if (eff->pd->flag & PFIELD_TEX_OBJECT) { - mul_m4_v3(eff->ob->world_to_object().ptr(), tex_co); + mul_m4_v3(eff->ob->world_to_object, tex_co); if (eff->pd->flag & PFIELD_TEX_2D) { tex_co[2] = 0.0f; diff --git a/source/blender/blenkernel/intern/fcurve.cc b/source/blender/blenkernel/intern/fcurve.cc index 82d46921877..3bb8a7faf77 100644 --- a/source/blender/blenkernel/intern/fcurve.cc +++ b/source/blender/blenkernel/intern/fcurve.cc @@ -26,7 +26,7 @@ #include "BLI_sort_utils.h" #include "BLI_string_utils.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_anim_data.h" #include "BKE_animsys.h" @@ -34,7 +34,7 @@ #include "BKE_curve.hh" #include "BKE_fcurve.h" #include "BKE_fcurve_driver.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_lib_query.hh" #include "BKE_nla.h" diff --git a/source/blender/blenkernel/intern/fcurve_driver.cc b/source/blender/blenkernel/intern/fcurve_driver.cc index 463bd999a62..f7c02eabe9a 100644 --- a/source/blender/blenkernel/intern/fcurve_driver.cc +++ b/source/blender/blenkernel/intern/fcurve_driver.cc @@ -25,14 +25,14 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" #include "BKE_animsys.h" #include "BKE_armature.hh" #include "BKE_constraint.h" #include "BKE_fcurve_driver.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_object.hh" #include "RNA_access.hh" @@ -435,7 +435,7 @@ static float dvar_eval_rotDiff(const AnimationEvalContext * /*anim_eval_context* return 0.0f; } - const float(*mat[2])[4]; + float(*mat[2])[4]; /* NOTE: for now, these are all just world-space. */ for (int i = 0; i < 2; i++) { @@ -457,7 +457,7 @@ static float dvar_eval_rotDiff(const AnimationEvalContext * /*anim_eval_context* } else { /* Object. */ - mat[i] = ob->object_to_world().ptr(); + mat[i] = ob->object_to_world; } } @@ -537,7 +537,7 @@ static float dvar_eval_locDiff(const AnimationEvalContext * /*anim_eval_context* else { /* Convert to world-space. */ copy_v3_v3(tmp_loc, pchan->pose_head); - mul_m4_v3(ob->object_to_world().ptr(), tmp_loc); + mul_m4_v3(ob->object_to_world, tmp_loc); } } else { @@ -548,7 +548,7 @@ static float dvar_eval_locDiff(const AnimationEvalContext * /*anim_eval_context* float mat[4][4]; /* Extract transform just like how the constraints do it! */ - copy_m4_m4(mat, ob->object_to_world().ptr()); + copy_m4_m4(mat, ob->object_to_world); BKE_constraint_mat_convertspace( ob, nullptr, nullptr, mat, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL, false); @@ -562,7 +562,7 @@ static float dvar_eval_locDiff(const AnimationEvalContext * /*anim_eval_context* } else { /* World-space. */ - copy_v3_v3(tmp_loc, ob->object_to_world().location()); + copy_v3_v3(tmp_loc, ob->object_to_world[3]); } } @@ -640,7 +640,7 @@ static float dvar_eval_transChan(const AnimationEvalContext * /*anim_eval_contex } else { /* World-space matrix. */ - mul_m4_m4m4(mat, ob->object_to_world().ptr(), pchan->pose_mat); + mul_m4_m4m4(mat, ob->object_to_world, pchan->pose_mat); } } else { @@ -654,7 +654,7 @@ static float dvar_eval_transChan(const AnimationEvalContext * /*anim_eval_contex if (dtar->flag & DTAR_FLAG_LOCALSPACE) { if (dtar->flag & DTAR_FLAG_LOCAL_CONSTS) { /* Just like how the constraints do it! */ - copy_m4_m4(mat, ob->object_to_world().ptr()); + copy_m4_m4(mat, ob->object_to_world); BKE_constraint_mat_convertspace( ob, nullptr, nullptr, mat, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL, false); } @@ -665,7 +665,7 @@ static float dvar_eval_transChan(const AnimationEvalContext * /*anim_eval_contex } else { /* World-space matrix - just the good-old one. */ - copy_m4_m4(mat, ob->object_to_world().ptr()); + copy_m4_m4(mat, ob->object_to_world); } } diff --git a/source/blender/blenkernel/intern/fluid.cc b/source/blender/blenkernel/intern/fluid.cc index 9e708c37573..323c1feec2f 100644 --- a/source/blender/blenkernel/intern/fluid.cc +++ b/source/blender/blenkernel/intern/fluid.cc @@ -29,7 +29,7 @@ #include "BKE_attribute.hh" #include "BKE_effect.h" #include "BKE_fluid.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_modifier.hh" @@ -62,7 +62,7 @@ # include "BKE_mesh_runtime.hh" # include "BKE_object.hh" # include "BKE_particle.h" -# include "BKE_scene.hh" +# include "BKE_scene.h" # include "BKE_texture.h" # include "DEG_depsgraph.hh" @@ -432,7 +432,7 @@ static void manta_set_domain_from_mesh(FluidDomainSettings *fds, copy_v3_v3(fds->global_size, size); copy_v3_v3(fds->dp0, min); - invert_m4_m4(fds->imat, ob->object_to_world().ptr()); + invert_m4_m4(fds->imat, ob->object_to_world); /* Prevent crash when initializing a plane as domain. */ if (!init_resolution || (size[0] < FLT_EPSILON) || (size[1] < FLT_EPSILON) || @@ -498,8 +498,8 @@ static bool fluid_modifier_init( zero_v3(fds->shift_f); add_v3_fl(fds->shift_f, 0.5f); zero_v3(fds->prev_loc); - mul_m4_v3(ob->object_to_world().ptr(), fds->prev_loc); - copy_m4_m4(fds->obmat, ob->object_to_world().ptr()); + mul_m4_v3(ob->object_to_world, fds->prev_loc); + copy_m4_m4(fds->obmat, ob->object_to_world); /* Set resolutions. */ if (fmd->domain->type == FLUID_DOMAIN_TYPE_GAS && @@ -567,11 +567,11 @@ static int get_light(Scene *scene, ViewLayer *view_layer, float *light) Light *la = static_cast(base_tmp->object->data); if (la->type == LA_LOCAL) { - copy_v3_v3(light, base_tmp->object->object_to_world().location()); + copy_v3_v3(light, base_tmp->object->object_to_world[3]); return 1; } if (!found_light) { - copy_v3_v3(light, base_tmp->object->object_to_world().location()); + copy_v3_v3(light, base_tmp->object->object_to_world[3]); found_light = 1; } } @@ -1049,7 +1049,7 @@ static void obstacles_from_mesh(Object *coll_ob, float co[3]; /* Vertex position. */ - mul_m4_v3(coll_ob->object_to_world().ptr(), positions[i]); + mul_m4_v3(coll_ob->object_to_world, positions[i]); manta_pos_to_cell(fds, positions[i]); /* Vertex velocity. */ @@ -2111,7 +2111,7 @@ static void emit_from_mesh( * This is valid because the mesh is copied above. */ for (i = 0; i < numverts; i++) { /* Vertex position. */ - mul_m4_v3(flow_ob->object_to_world().ptr(), positions[i]); + mul_m4_v3(flow_ob->object_to_world, positions[i]); manta_pos_to_cell(fds, positions[i]); /* Vertex velocity. */ @@ -2129,7 +2129,7 @@ static void emit_from_mesh( bb_boundInsert(bb, positions[i]); } mesh->tag_positions_changed(); - mul_m4_v3(flow_ob->object_to_world().ptr(), flow_center); + mul_m4_v3(flow_ob->object_to_world, flow_center); manta_pos_to_cell(fds, flow_center); /* Set emission map. @@ -2198,7 +2198,7 @@ static void adaptive_domain_adjust( float frame_shift_f[3]; float ob_loc[3] = {0}; - mul_m4_v3(ob->object_to_world().ptr(), ob_loc); + mul_m4_v3(ob->object_to_world, ob_loc); sub_v3_v3v3(frame_shift_f, ob_loc, fds->prev_loc); copy_v3_v3(fds->prev_loc, ob_loc); @@ -3488,12 +3488,12 @@ static Mesh *create_smoke_geometry(FluidDomainSettings *fds, Mesh *orgmesh, Obje /* Calculate required shift to match domain's global position * it was originally simulated at (if object moves without manta step). */ - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); - mul_m4_v3(ob->object_to_world().ptr(), ob_loc); + invert_m4_m4(ob->world_to_object, ob->object_to_world); + mul_m4_v3(ob->object_to_world, ob_loc); mul_m4_v3(fds->obmat, ob_cache_loc); sub_v3_v3v3(fds->obj_shift_f, ob_cache_loc, ob_loc); /* Convert shift to local space and apply to vertices. */ - mul_mat3_m4_v3(ob->world_to_object().ptr(), fds->obj_shift_f); + mul_mat3_m4_v3(ob->world_to_object, fds->obj_shift_f); /* Apply shift to vertices. */ for (int i = 0; i < num_verts; i++) { add_v3_v3(positions[i], fds->obj_shift_f); @@ -3518,8 +3518,8 @@ static int manta_step( bool mode_replay = (mode == FLUID_DOMAIN_CACHE_REPLAY); /* Update object state. */ - invert_m4_m4(fds->imat, ob->object_to_world().ptr()); - copy_m4_m4(fds->obmat, ob->object_to_world().ptr()); + invert_m4_m4(fds->imat, ob->object_to_world); + copy_m4_m4(fds->obmat, ob->object_to_world); /* Gas domain might use adaptive domain. */ if (fds->type == FLUID_DOMAIN_TYPE_GAS) { diff --git a/source/blender/blenkernel/intern/fmodifier.cc b/source/blender/blenkernel/intern/fmodifier.cc index 301af997763..da3f3ae90a2 100644 --- a/source/blender/blenkernel/intern/fmodifier.cc +++ b/source/blender/blenkernel/intern/fmodifier.cc @@ -20,7 +20,7 @@ #include "DNA_anim_types.h" #include "DNA_screen_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" diff --git a/source/blender/blenkernel/intern/freestyle.cc b/source/blender/blenkernel/intern/freestyle.cc index b98f346b5a3..41e19cc4a0a 100644 --- a/source/blender/blenkernel/intern/freestyle.cc +++ b/source/blender/blenkernel/intern/freestyle.cc @@ -15,7 +15,7 @@ #include "BLI_math_rotation.h" #include "BLI_string_utils.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_freestyle.h" #include "BKE_lib_id.hh" diff --git a/source/blender/blenkernel/intern/geometry_component_curves.cc b/source/blender/blenkernel/intern/geometry_component_curves.cc index 896480d0ad7..afaae85fa12 100644 --- a/source/blender/blenkernel/intern/geometry_component_curves.cc +++ b/source/blender/blenkernel/intern/geometry_component_curves.cc @@ -8,6 +8,7 @@ #include "DNA_curve_types.h" #include "BKE_attribute_math.hh" +#include "BKE_curve.hh" #include "BKE_curves.hh" #include "BKE_deform.hh" #include "BKE_geometry_fields.hh" diff --git a/source/blender/blenkernel/intern/geometry_component_instances.cc b/source/blender/blenkernel/intern/geometry_component_instances.cc index ed6a0972c8e..a417f29faf4 100644 --- a/source/blender/blenkernel/intern/geometry_component_instances.cc +++ b/source/blender/blenkernel/intern/geometry_component_instances.cc @@ -7,16 +7,23 @@ #include "BLI_index_mask.hh" #include "BLI_map.hh" #include "BLI_math_matrix_types.hh" +#include "BLI_rand.hh" #include "BLI_set.hh" #include "BLI_span.hh" #include "BLI_task.hh" #include "BLI_vector.hh" +#include "DNA_collection_types.h" + +#include "BKE_attribute_math.hh" #include "BKE_geometry_set.hh" +#include "BKE_geometry_set_instances.hh" #include "BKE_instances.hh" #include "attribute_access_intern.hh" +#include "BLI_cpp_type_make.hh" + namespace blender::bke { /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/geometry_component_volume.cc b/source/blender/blenkernel/intern/geometry_component_volume.cc index 9432ad924cf..61fb943d29e 100644 --- a/source/blender/blenkernel/intern/geometry_component_volume.cc +++ b/source/blender/blenkernel/intern/geometry_component_volume.cc @@ -2,6 +2,8 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "DNA_volume_types.h" + #include "BKE_geometry_set.hh" #include "BKE_lib_id.hh" #include "BKE_volume.hh" diff --git a/source/blender/blenkernel/intern/geometry_fields.cc b/source/blender/blenkernel/intern/geometry_fields.cc index 29cf21bc8fb..e9d25f942a9 100644 --- a/source/blender/blenkernel/intern/geometry_fields.cc +++ b/source/blender/blenkernel/intern/geometry_fields.cc @@ -17,7 +17,7 @@ #include "DNA_mesh_types.h" #include "DNA_pointcloud_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 4ec6078443a..a2797f8880f 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -6,7 +6,7 @@ #include "BLI_map.hh" #include "BLI_task.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_attribute.hh" #include "BKE_curves.hh" diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc index 2a92990ca63..b53f711b0ac 100644 --- a/source/blender/blenkernel/intern/geometry_set_instances.cc +++ b/source/blender/blenkernel/intern/geometry_set_instances.cc @@ -2,9 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_geometry_set_instances.hh" #include "BKE_instances.hh" +#include "BKE_mesh.hh" #include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" #include "BKE_object_types.hh" @@ -129,7 +130,7 @@ void Instances::ensure_geometry_instances() Collection &collection = reference.collection(); FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (&collection, object) { const int handle = instances->add_reference(*object); - instances->add_instance(handle, object->object_to_world()); + instances->add_instance(handle, float4x4(object->object_to_world)); float4x4 &transform = instances->transforms().last(); transform.location() -= collection.instance_offset; } diff --git a/source/blender/blenkernel/intern/gpencil_curve_legacy.cc b/source/blender/blenkernel/intern/gpencil_curve_legacy.cc index a313719ca91..3c3bb2402f2 100644 --- a/source/blender/blenkernel/intern/gpencil_curve_legacy.cc +++ b/source/blender/blenkernel/intern/gpencil_curve_legacy.cc @@ -12,12 +12,15 @@ #include #include +#include "CLG_log.h" + #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_math_color.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_collection_types.h" #include "DNA_gpencil_legacy_types.h" @@ -25,12 +28,15 @@ #include "DNA_meshdata_types.h" #include "DNA_scene_types.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" +#include "BKE_context.hh" #include "BKE_curve.hh" #include "BKE_gpencil_curve_legacy.h" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" +#include "BKE_main.hh" #include "BKE_material.h" +#include "BKE_object.hh" extern "C" { #include "curve_fit_nd.h" diff --git a/source/blender/blenkernel/intern/gpencil_geom_legacy.cc b/source/blender/blenkernel/intern/gpencil_geom_legacy.cc index 00a4b223b20..3ce5e8bacd3 100644 --- a/source/blender/blenkernel/intern/gpencil_geom_legacy.cc +++ b/source/blender/blenkernel/intern/gpencil_geom_legacy.cc @@ -13,6 +13,8 @@ #include #include +#include "CLG_log.h" + #include "MEM_guardedalloc.h" #include "BLI_array_utils.h" @@ -36,13 +38,19 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_scene_types.h" +#include "DNA_screen_types.h" + +#include "BLT_translation.h" #include "BKE_attribute.hh" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_curve_legacy.h" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" +#include "BKE_main.hh" #include "BKE_material.h" +#include "BKE_mesh.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" diff --git a/source/blender/blenkernel/intern/gpencil_legacy.cc b/source/blender/blenkernel/intern/gpencil_legacy.cc index a4f38517481..fed98c9344c 100644 --- a/source/blender/blenkernel/intern/gpencil_legacy.cc +++ b/source/blender/blenkernel/intern/gpencil_legacy.cc @@ -21,7 +21,7 @@ #include "BLI_math_vector.h" #include "BLI_string_utils.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "IMB_interp.hh" @@ -35,7 +35,7 @@ #include "BKE_action.h" #include "BKE_anim_data.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_colortools.hh" #include "BKE_deform.hh" #include "BKE_gpencil_geom_legacy.h" @@ -264,7 +264,6 @@ static void greasepencil_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_GD_LEGACY = { /*id_code*/ ID_GD_LEGACY, /*id_filter*/ FILTER_ID_GD_LEGACY, - /*dependencies_id_types*/ FILTER_ID_MA, /*main_listbase_index*/ INDEX_ID_GD_LEGACY, /*struct_size*/ sizeof(bGPdata), /*name*/ "GPencil", @@ -2697,7 +2696,7 @@ void BKE_gpencil_layer_transform_matrix_get(const Depsgraph *depsgraph, /* if not layer parented, try with object parented */ if (obparent_eval == nullptr) { if ((ob_eval != nullptr) && (ob_eval->type == OB_GPENCIL_LEGACY)) { - copy_m4_m4(diff_mat, ob_eval->object_to_world().ptr()); + copy_m4_m4(diff_mat, ob_eval->object_to_world); mul_m4_m4m4(diff_mat, diff_mat, gpl->layer_mat); return; } @@ -2707,8 +2706,8 @@ void BKE_gpencil_layer_transform_matrix_get(const Depsgraph *depsgraph, } if (ELEM(gpl->partype, PAROBJECT, PARSKEL)) { - mul_m4_m4m4(diff_mat, obparent_eval->object_to_world().ptr(), gpl->inverse); - add_v3_v3(diff_mat[3], ob_eval->object_to_world().location()); + mul_m4_m4m4(diff_mat, obparent_eval->object_to_world, gpl->inverse); + add_v3_v3(diff_mat[3], ob_eval->object_to_world[3]); mul_m4_m4m4(diff_mat, diff_mat, gpl->layer_mat); return; } @@ -2716,14 +2715,14 @@ void BKE_gpencil_layer_transform_matrix_get(const Depsgraph *depsgraph, bPoseChannel *pchan = BKE_pose_channel_find_name(obparent_eval->pose, gpl->parsubstr); if (pchan) { float tmp_mat[4][4]; - mul_m4_m4m4(tmp_mat, obparent_eval->object_to_world().ptr(), pchan->pose_mat); + mul_m4_m4m4(tmp_mat, obparent_eval->object_to_world, pchan->pose_mat); mul_m4_m4m4(diff_mat, tmp_mat, gpl->inverse); - add_v3_v3(diff_mat[3], ob_eval->object_to_world().location()); + add_v3_v3(diff_mat[3], ob_eval->object_to_world[3]); } else { /* if bone not found use object (armature) */ - mul_m4_m4m4(diff_mat, obparent_eval->object_to_world().ptr(), gpl->inverse); - add_v3_v3(diff_mat[3], ob_eval->object_to_world().location()); + mul_m4_m4m4(diff_mat, obparent_eval->object_to_world, gpl->inverse); + add_v3_v3(diff_mat[3], ob_eval->object_to_world[3]); } mul_m4_m4m4(diff_mat, diff_mat, gpl->layer_mat); return; @@ -2777,15 +2776,12 @@ void BKE_gpencil_update_layer_transforms(const Depsgraph *depsgraph, Object *ob) Object *ob_parent = DEG_get_evaluated_object(depsgraph, gpl->parent); /* calculate new matrix */ if (ELEM(gpl->partype, PAROBJECT, PARSKEL)) { - mul_m4_m4m4(cur_mat, ob->world_to_object().ptr(), ob_parent->object_to_world().ptr()); + mul_m4_m4m4(cur_mat, ob->world_to_object, ob_parent->object_to_world); } else if (gpl->partype == PARBONE) { bPoseChannel *pchan = BKE_pose_channel_find_name(ob_parent->pose, gpl->parsubstr); if (pchan != nullptr) { - mul_m4_series(cur_mat, - ob->world_to_object().ptr(), - ob_parent->object_to_world().ptr(), - pchan->pose_mat); + mul_m4_series(cur_mat, ob->world_to_object, ob_parent->object_to_world, pchan->pose_mat); } else { unit_m4(cur_mat); diff --git a/source/blender/blenkernel/intern/gpencil_modifier_legacy.cc b/source/blender/blenkernel/intern/gpencil_modifier_legacy.cc index 634d7765ec3..622f60da87e 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier_legacy.cc +++ b/source/blender/blenkernel/intern/gpencil_modifier_legacy.cc @@ -18,7 +18,7 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_armature_types.h" #include "DNA_gpencil_legacy_types.h" diff --git a/source/blender/blenkernel/intern/gpencil_update_cache_legacy.cc b/source/blender/blenkernel/intern/gpencil_update_cache_legacy.cc index 2a5a81909a9..f735cced331 100644 --- a/source/blender/blenkernel/intern/gpencil_update_cache_legacy.cc +++ b/source/blender/blenkernel/intern/gpencil_update_cache_legacy.cc @@ -13,7 +13,10 @@ #include "BLI_dlrbTree.h" #include "BLI_listbase.h" +#include "BKE_gpencil_legacy.h" + #include "DNA_gpencil_legacy_types.h" +#include "DNA_userdef_types.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/grease_pencil.cc b/source/blender/blenkernel/intern/grease_pencil.cc index 95d34e18e70..0a06002de66 100644 --- a/source/blender/blenkernel/intern/grease_pencil.cc +++ b/source/blender/blenkernel/intern/grease_pencil.cc @@ -8,7 +8,6 @@ #include -#include "BKE_action.h" #include "BKE_anim_data.h" #include "BKE_curves.hh" #include "BKE_customdata.hh" @@ -26,10 +25,8 @@ #include "BLI_bounds.hh" #include "BLI_map.hh" -#include "BLI_math_euler_types.hh" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" -#include "BLI_math_matrix_types.hh" #include "BLI_math_vector_types.hh" #include "BLI_memarena.h" #include "BLI_memory_utils.hh" @@ -44,7 +41,7 @@ #include "BLO_read_write.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_ID.h" #include "DNA_ID_enums.h" @@ -52,6 +49,7 @@ #include "DNA_grease_pencil_types.h" #include "DNA_material_types.h" #include "DNA_modifier_types.h" +#include "DNA_scene_types.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" @@ -214,7 +212,6 @@ static void grease_pencil_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_GP = { /*id_code*/ ID_GP, /*id_filter*/ FILTER_ID_GP, - /*dependencies_id_types*/ FILTER_ID_GP | FILTER_ID_MA, /*main_listbase_index*/ INDEX_ID_GP, /*struct_size*/ sizeof(GreasePencil), /*name*/ "GreasePencil", @@ -243,6 +240,14 @@ IDTypeInfo IDType_ID_GP = { namespace blender::bke::greasepencil { +DrawingTransforms::DrawingTransforms(const Object &grease_pencil_ob) +{ + /* TODO: For now layer space = object space. This needs to change once the layers have a + * transform. */ + this->layer_space_to_world_space = float4x4_view(grease_pencil_ob.object_to_world); + this->world_space_to_layer_space = math::invert(this->layer_space_to_world_space); +} + static const std::string ATTR_RADIUS = "radius"; static const std::string ATTR_OPACITY = "opacity"; static const std::string ATTR_VERTEX_COLOR = "vertex_color"; @@ -259,18 +264,18 @@ static CustomData &domain_custom_data(CurvesGeometry &curves, const AttrDomain d template static MutableSpan get_mutable_attribute(CurvesGeometry &curves, const AttrDomain domain, - const StringRef name, + const StringRefNull name, const T default_value = T()) { const int num = domain_num(curves, domain); const eCustomDataType type = cpp_type_to_custom_data_type(CPPType::get()); CustomData &custom_data = domain_custom_data(curves, domain); - T *data = (T *)CustomData_get_layer_named_for_write(&custom_data, type, name, num); + T *data = (T *)CustomData_get_layer_named_for_write(&custom_data, type, name.c_str(), num); if (data != nullptr) { return {data, num}; } - data = (T *)CustomData_add_layer_named(&custom_data, type, CD_SET_DEFAULT, num, name); + data = (T *)CustomData_add_layer_named(&custom_data, type, CD_SET_DEFAULT, num, name.c_str()); MutableSpan span = {data, num}; if (num > 0 && span.first() != default_value) { span.fill(default_value); @@ -659,13 +664,6 @@ Layer::Layer() this->opacity = 1.0f; - this->parent = nullptr; - this->parsubstr = nullptr; - - zero_v3(this->translation); - zero_v3(this->rotation); - copy_v3_fl(this->scale, 1.0f); - BLI_listbase_clear(&this->masks); this->runtime = MEM_new(__func__); @@ -682,18 +680,11 @@ Layer::Layer(const Layer &other) : Layer() /* TODO: duplicate masks. */ - /* Note: We do not duplicate the frame storage since it is only needed for writing to file. */ + /* Note: We do not duplicate the frame storage since it is only needed for writing. */ this->blend_mode = other.blend_mode; this->opacity = other.opacity; - this->parent = other.parent; - this->set_parent_bone_name(other.parsubstr); - - copy_v3_v3(this->translation, other.translation); - copy_v3_v3(this->rotation, other.rotation); - copy_v3_v3(this->scale, other.scale); - this->runtime->frames_ = other.runtime->frames_; this->runtime->sorted_keys_cache_ = other.runtime->sorted_keys_cache_; /* TODO: what about masks cache? */ @@ -711,8 +702,6 @@ Layer::~Layer() MEM_freeN(mask); } - MEM_SAFE_FREE(this->parsubstr); - MEM_delete(this->runtime); this->runtime = nullptr; } @@ -957,56 +946,6 @@ void Layer::update_from_dna_read() } } -float4x4 Layer::to_world_space(const Object &object) const -{ - if (this->parent == nullptr) { - return object.object_to_world() * this->local_transform(); - } - const Object &parent = *this->parent; - return this->parent_to_world(parent) * this->local_transform(); -} - -float4x4 Layer::to_object_space(const Object &object) const -{ - if (this->parent == nullptr) { - return this->local_transform(); - } - const Object &parent = *this->parent; - return object.world_to_object() * this->parent_to_world(parent) * this->local_transform(); -} - -StringRefNull Layer::parent_bone_name() const -{ - return (this->parsubstr != nullptr) ? StringRefNull(this->parsubstr) : StringRefNull(); -} - -void Layer::set_parent_bone_name(const char *new_name) -{ - if (this->parsubstr != nullptr) { - MEM_freeN(this->parsubstr); - } - this->parsubstr = BLI_strdup_null(new_name); -} - -float4x4 Layer::parent_to_world(const Object &parent) const -{ - const float4x4 &parent_object_to_world = parent.object_to_world(); - if (parent.type == OB_ARMATURE && !this->parent_bone_name().is_empty()) { - if (bPoseChannel *channel = BKE_pose_channel_find_name(parent.pose, - this->parent_bone_name().c_str())) - { - return parent_object_to_world * float4x4_view(channel->pose_mat); - } - } - return parent_object_to_world; -} - -float4x4 Layer::local_transform() const -{ - return math::from_loc_rot_scale( - float3(this->translation), float3(this->rotation), float3(this->scale)); -} - LayerGroup::LayerGroup() { new (&this->base) TreeNode(GP_LAYER_TREE_GROUP); @@ -1066,18 +1005,6 @@ LayerGroup::~LayerGroup() this->runtime = nullptr; } -LayerGroup &LayerGroup::operator=(const LayerGroup &other) -{ - if (this == &other) { - return *this; - } - - this->~LayerGroup(); - new (this) LayerGroup(other); - - return *this; -} - Layer &LayerGroup::add_layer(StringRefNull name) { Layer *new_layer = MEM_new(__func__, name); @@ -1728,32 +1655,6 @@ blender::MutableSpan GreasePencil::drawings() this->drawing_array_num}; } -void GreasePencil::resize_drawings(const int new_num) -{ - using namespace blender; - BLI_assert(new_num > 0); - - const int prev_num = int(this->drawings().size()); - if (new_num == prev_num) { - return; - } - if (new_num > prev_num) { - const int add_num = new_num - prev_num; - grow_array(&this->drawing_array, &this->drawing_array_num, add_num); - } - else { /* if (new_num < prev_num) */ - const int shrink_num = prev_num - new_num; - MutableSpan old_drawings = this->drawings().drop_front(new_num); - for (const int64_t i : old_drawings.index_range()) { - if (old_drawings[i]) { - MEM_delete(old_drawings[i]); - } - } - shrink_array( - &this->drawing_array, &this->drawing_array_num, shrink_num); - } -} - void GreasePencil::add_empty_drawings(const int add_num) { using namespace blender; @@ -2177,10 +2078,6 @@ void GreasePencil::set_active_layer(const blender::bke::greasepencil::Layer *lay { this->active_layer = const_cast( reinterpret_cast(layer)); - - if (this->flag & GREASE_PENCIL_AUTOLOCK_LAYERS) { - this->autolock_inactive_layers(); - } } bool GreasePencil::is_layer_active(const blender::bke::greasepencil::Layer *layer) const @@ -2191,19 +2088,6 @@ bool GreasePencil::is_layer_active(const blender::bke::greasepencil::Layer *laye return this->get_active_layer() == layer; } -void GreasePencil::autolock_inactive_layers() -{ - using namespace blender::bke::greasepencil; - - for (Layer *layer : this->layers_for_write()) { - if (this->is_layer_active(layer)) { - layer->set_locked(false); - continue; - } - layer->set_locked(true); - } -} - static blender::VectorSet get_node_names(const GreasePencil &grease_pencil) { using namespace blender; @@ -2634,7 +2518,6 @@ static void read_layer(BlendDataReader *reader, { BLO_read_data_address(reader, &node->base.name); node->base.parent = parent; - BLO_read_data_address(reader, &node->parsubstr); /* Read frames storage. */ BLO_read_int32_array(reader, node->frames_storage.num, &node->frames_storage.keys); @@ -2702,7 +2585,6 @@ static void write_layer(BlendWriter *writer, GreasePencilLayer *node) { BLO_write_struct(writer, GreasePencilLayer, node); BLO_write_string(writer, node->base.name); - BLO_write_string(writer, node->parsubstr); BLO_write_int32_array(writer, node->frames_storage.num, node->frames_storage.keys); BLO_write_struct_array( diff --git a/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc b/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc index c672a95403a..6749724faee 100644 --- a/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc +++ b/source/blender/blenkernel/intern/grease_pencil_convert_legacy.cc @@ -7,36 +7,20 @@ */ #include "BKE_attribute.hh" -#include "BKE_colortools.hh" #include "BKE_curves.hh" #include "BKE_deform.hh" -#include "BKE_gpencil_modifier_legacy.h" #include "BKE_grease_pencil.hh" -#include "BKE_grease_pencil_legacy_convert.hh" -#include "BKE_idprop.hh" -#include "BKE_lib_id.hh" #include "BKE_material.h" -#include "BKE_modifier.hh" -#include "BKE_node.hh" -#include "BKE_node_tree_update.hh" -#include "BKE_object.hh" #include "BLI_color.hh" #include "BLI_listbase.h" #include "BLI_math_vector_types.hh" #include "BLI_string.h" -#include "BLI_string_utf8.h" #include "BLI_vector.hh" -#include "BLT_translation.hh" - #include "DNA_gpencil_legacy_types.h" -#include "DNA_gpencil_modifier_types.h" #include "DNA_grease_pencil_types.h" #include "DNA_meshdata_types.h" -#include "DNA_modifier_types.h" - -#include "DEG_depsgraph_build.hh" namespace blender::bke::greasepencil::convert { @@ -91,23 +75,13 @@ void legacy_gpencil_frame_to_grease_pencil_drawing(const bGPDframe &gpf, /* Get the number of points, number of strokes and the offsets for each stroke. */ Vector offsets; - Vector curve_types; offsets.append(0); int num_strokes = 0; int num_points = 0; - bool has_bezier_stroke = false; LISTBASE_FOREACH (bGPDstroke *, gps, &gpf.strokes) { - if (gps->editcurve != nullptr) { - has_bezier_stroke = true; - num_points += gps->editcurve->tot_curve_points; - curve_types.append(CURVE_TYPE_BEZIER); - } - else { - num_points += gps->totpoints; - curve_types.append(CURVE_TYPE_POLY); - } - num_strokes++; + num_points += gps->totpoints; offsets.append(num_points); + num_strokes++; } /* Resize the CurvesGeometry. */ @@ -120,14 +94,8 @@ void legacy_gpencil_frame_to_grease_pencil_drawing(const bGPDframe &gpf, OffsetIndices points_by_curve = curves.points_by_curve(); MutableAttributeAccessor attributes = curves.attributes_for_write(); - if (!has_bezier_stroke) { - /* All strokes are poly curves. */ - curves.fill_curve_types(CURVE_TYPE_POLY); - } - else { - curves.curve_types_for_write().copy_from(curve_types); - curves.update_curve_types(); - } + /* All strokes are poly curves. */ + curves.fill_curve_types(CURVE_TYPE_POLY); /* Find used vertex groups in this drawing. */ ListBase stroke_vertex_group_names; @@ -150,12 +118,6 @@ void legacy_gpencil_frame_to_grease_pencil_drawing(const bGPDframe &gpf, /* Point Attributes. */ MutableSpan positions = curves.positions_for_write(); - MutableSpan handle_positions_left = has_bezier_stroke ? - curves.handle_positions_left_for_write() : - MutableSpan(); - MutableSpan handle_positions_right = has_bezier_stroke ? - curves.handle_positions_right_for_write() : - MutableSpan(); MutableSpan radii = drawing.radii_for_write(); MutableSpan opacities = drawing.opacities_for_write(); SpanAttributeWriter delta_times = attributes.lookup_or_add_for_write_span( @@ -196,6 +158,9 @@ void legacy_gpencil_frame_to_grease_pencil_drawing(const bGPDframe &gpf, int stroke_i = 0; LISTBASE_FOREACH_INDEX (bGPDstroke *, gps, &gpf.strokes, stroke_i) { + /* TODO: check if `gps->editcurve` is not nullptr and parse bezier curve instead. */ + + /* Write curve attributes. */ stroke_cyclic.span[stroke_i] = (gps->flag & GP_STROKE_CYCLIC) != 0; /* TODO: This should be a `double` attribute. */ stroke_init_times.span[stroke_i] = float(gps->inittime); @@ -210,86 +175,59 @@ void legacy_gpencil_frame_to_grease_pencil_drawing(const bGPDframe &gpf, stroke_fill_colors.span[stroke_i] = ColorGeometry4f(gps->vert_color_fill); stroke_materials.span[stroke_i] = gps->mat_nr; - IndexRange points = points_by_curve[stroke_i]; - if (points.is_empty()) { + /* Write point attributes. */ + IndexRange stroke_points_range = points_by_curve[stroke_i]; + if (stroke_points_range.is_empty()) { continue; } - const Span src_points{gps->points, gps->totpoints}; - /* Previously, Grease Pencil used a radius convention where 1 `px` = 0.001 units. This `px` - * was the brush size which would be stored in the stroke thickness and then scaled by the - * point pressure factor. Finally, the render engine would divide this thickness value by - * 2000 (we're going from a thickness to a radius, hence the factor of two) to convert back - * into blender units. Store the radius now directly in blender units. This makes it - * consistent with how hair curves handle the radius. */ - const float stroke_thickness = float(gps->thickness) / 2000.0f; - MutableSpan dst_positions = positions.slice(points); - MutableSpan dst_handle_positions_left = has_bezier_stroke ? - handle_positions_left.slice(points) : - MutableSpan(); - MutableSpan dst_handle_positions_right = has_bezier_stroke ? - handle_positions_right.slice(points) : - MutableSpan(); - MutableSpan dst_radii = radii.slice(points); - MutableSpan dst_opacities = opacities.slice(points); - MutableSpan dst_deltatimes = delta_times.span.slice(points); - MutableSpan dst_rotations = rotations.span.slice(points); - MutableSpan dst_vertex_colors = vertex_colors.span.slice(points); - MutableSpan dst_selection = selection.span.slice(points); - MutableSpan dst_dverts = use_dverts ? dverts.slice(points) : - MutableSpan(); + Span stroke_points{gps->points, gps->totpoints}; + MutableSpan stroke_positions = positions.slice(stroke_points_range); + MutableSpan stroke_radii = radii.slice(stroke_points_range); + MutableSpan stroke_opacities = opacities.slice(stroke_points_range); + MutableSpan stroke_deltatimes = delta_times.span.slice(stroke_points_range); + MutableSpan stroke_rotations = rotations.span.slice(stroke_points_range); + MutableSpan stroke_vertex_colors = vertex_colors.span.slice( + stroke_points_range); + MutableSpan stroke_selections = selection.span.slice(stroke_points_range); + MutableSpan stroke_dverts = use_dverts ? dverts.slice(stroke_points_range) : + MutableSpan(); - if (curve_types[stroke_i] == CURVE_TYPE_POLY) { - threading::parallel_for(src_points.index_range(), 4096, [&](const IndexRange range) { - for (const int point_i : range) { - const bGPDspoint &pt = src_points[point_i]; - dst_positions[point_i] = float3(pt.x, pt.y, pt.z); - dst_radii[point_i] = stroke_thickness * pt.pressure; - dst_opacities[point_i] = pt.strength; - dst_rotations[point_i] = pt.uv_rot; - dst_vertex_colors[point_i] = ColorGeometry4f(pt.vert_color); - dst_selection[point_i] = (pt.flag & GP_SPOINT_SELECT) != 0; - if (use_dverts && gps->dvert) { - copy_dvert(gps->dvert[point_i], dst_dverts[point_i]); - } - } - }); - - dst_deltatimes.first() = 0; - threading::parallel_for( - src_points.index_range().drop_front(1), 4096, [&](const IndexRange range) { - for (const int point_i : range) { - const bGPDspoint &pt = src_points[point_i]; - const bGPDspoint &pt_prev = src_points[point_i - 1]; - dst_deltatimes[point_i] = pt.time - pt_prev.time; - } - }); + /* Do first point. */ + const bGPDspoint &first_pt = stroke_points.first(); + stroke_positions.first() = float3(first_pt.x, first_pt.y, first_pt.z); + /* Previously, Grease Pencil used a radius convention where 1 `px` = 0.001 units. This `px` was + * the brush size which would be stored in the stroke thickness and then scaled by the point + * pressure factor. Finally, the render engine would divide this thickness value by 2000 (we're + * going from a thickness to a radius, hence the factor of two) to convert back into blender + * units. + * Store the radius now directly in blender units. This makes it consistent with how hair + * curves handle the radius. */ + stroke_radii.first() = gps->thickness * first_pt.pressure / 2000.0f; + stroke_opacities.first() = first_pt.strength; + stroke_deltatimes.first() = 0; + stroke_rotations.first() = first_pt.uv_rot; + stroke_vertex_colors.first() = ColorGeometry4f(first_pt.vert_color); + stroke_selections.first() = (first_pt.flag & GP_SPOINT_SELECT) != 0; + if (use_dverts && gps->dvert) { + copy_dvert(gps->dvert[0], stroke_dverts.first()); } - else if (curve_types[stroke_i] == CURVE_TYPE_BEZIER) { - BLI_assert(gps->editcurve != nullptr); - Span src_curve_points{gps->editcurve->curve_points, - gps->editcurve->tot_curve_points}; - threading::parallel_for(src_curve_points.index_range(), 4096, [&](const IndexRange range) { - for (const int point_i : range) { - const bGPDcurve_point &cpt = src_curve_points[point_i]; - dst_positions[point_i] = float3(cpt.bezt.vec[1]); - dst_handle_positions_left[point_i] = float3(cpt.bezt.vec[0]); - dst_handle_positions_right[point_i] = float3(cpt.bezt.vec[2]); - dst_radii[point_i] = stroke_thickness * cpt.pressure; - dst_opacities[point_i] = cpt.strength; - dst_rotations[point_i] = cpt.uv_rot; - dst_vertex_colors[point_i] = ColorGeometry4f(cpt.vert_color); - dst_selection[point_i] = (cpt.flag & GP_CURVE_POINT_SELECT) != 0; - if (use_dverts && gps->dvert) { - copy_dvert(gps->dvert[point_i], dst_dverts[point_i]); - } - } - }); - } - else { - /* Unknown curve type. */ - BLI_assert_unreachable(); + /* Do the rest of the points. */ + for (const int i : stroke_points.index_range().drop_back(1)) { + const int point_i = i + 1; + const bGPDspoint &pt_prev = stroke_points[point_i - 1]; + const bGPDspoint &pt = stroke_points[point_i]; + stroke_positions[point_i] = float3(pt.x, pt.y, pt.z); + stroke_radii[point_i] = gps->thickness * pt.pressure / 2000.0f; + stroke_opacities[point_i] = pt.strength; + stroke_deltatimes[point_i] = pt.time - pt_prev.time; + stroke_rotations[point_i] = pt.uv_rot; + stroke_vertex_colors[point_i] = ColorGeometry4f(pt.vert_color); + stroke_selections[point_i] = (pt.flag & GP_SPOINT_SELECT) != 0; + if (use_dverts && gps->dvert) { + copy_dvert(gps->dvert[point_i], stroke_dverts[point_i]); + } } } @@ -344,16 +282,9 @@ void legacy_gpencil_to_grease_pencil(Main &bmain, GreasePencil &grease_pencil, b new_layer.blend_mode = int8_t(gpl->blend_mode); - new_layer.parent = gpl->parent; - new_layer.set_parent_bone_name(gpl->parsubstr); - - copy_v3_v3(new_layer.translation, gpl->location); - copy_v3_v3(new_layer.rotation, gpl->rotation); - copy_v3_v3(new_layer.scale, gpl->scale); - /* Convert the layer masks. */ LISTBASE_FOREACH (bGPDlayer_Mask *, mask, &gpl->mask_layers) { - LayerMask *new_mask = MEM_new(mask->name); + LayerMask *new_mask = new LayerMask(mask->name); new_mask->flag = mask->flag; BLI_addtail(&new_layer.masks, new_mask); } @@ -404,358 +335,4 @@ void legacy_gpencil_to_grease_pencil(Main &bmain, GreasePencil &grease_pencil, b BKE_id_materials_copy(&bmain, &gpd.id, &grease_pencil.id); } -static bNodeTree *add_offset_radius_node_tree(Main &bmain) -{ - using namespace blender; - bNodeTree *group = ntreeAddTree(&bmain, DATA_("Offset Radius"), "GeometryNodeTree"); - - if (!group->geometry_node_asset_traits) { - group->geometry_node_asset_traits = MEM_new(__func__); - } - group->geometry_node_asset_traits->flag |= GEO_NODE_ASSET_MODIFIER; - - group->tree_interface.add_socket(DATA_("Geometry"), - "", - "NodeSocketGeometry", - NODE_INTERFACE_SOCKET_INPUT | NODE_INTERFACE_SOCKET_OUTPUT, - nullptr); - - bNodeTreeInterfaceSocket *radius_offset = group->tree_interface.add_socket( - DATA_("Offset"), "", "NodeSocketFloat", NODE_INTERFACE_SOCKET_INPUT, nullptr); - auto &radius_offset_data = *static_cast(radius_offset->socket_data); - radius_offset_data.subtype = PROP_DISTANCE; - radius_offset_data.min = -FLT_MAX; - radius_offset_data.max = FLT_MAX; - - group->tree_interface.add_socket( - DATA_("Layer"), "", "NodeSocketString", NODE_INTERFACE_SOCKET_INPUT, nullptr); - - bNode *group_output = nodeAddNode(nullptr, group, "NodeGroupOutput"); - group_output->locx = 580; - group_output->locy = 160; - bNode *group_input = nodeAddNode(nullptr, group, "NodeGroupInput"); - group_input->locx = 0; - group_input->locy = 160; - - bNode *set_curve_radius = nodeAddNode(nullptr, group, "GeometryNodeSetCurveRadius"); - set_curve_radius->locx = 400; - set_curve_radius->locy = 160; - bNode *named_layer_selection = nodeAddNode( - nullptr, group, "GeometryNodeInputNamedLayerSelection"); - named_layer_selection->locx = 200; - named_layer_selection->locy = 100; - bNode *input_radius = nodeAddNode(nullptr, group, "GeometryNodeInputRadius"); - input_radius->locx = 0; - input_radius->locy = 0; - - bNode *add = nodeAddNode(nullptr, group, "ShaderNodeMath"); - add->custom1 = NODE_MATH_ADD; - add->locx = 200; - add->locy = 0; - - nodeAddLink(group, - group_input, - nodeFindSocket(group_input, SOCK_OUT, "Socket_0"), - set_curve_radius, - nodeFindSocket(set_curve_radius, SOCK_IN, "Curve")); - nodeAddLink(group, - set_curve_radius, - nodeFindSocket(set_curve_radius, SOCK_OUT, "Curve"), - group_output, - nodeFindSocket(group_output, SOCK_IN, "Socket_0")); - - nodeAddLink(group, - group_input, - nodeFindSocket(group_input, SOCK_OUT, "Socket_2"), - named_layer_selection, - nodeFindSocket(named_layer_selection, SOCK_IN, "Name")); - nodeAddLink(group, - named_layer_selection, - nodeFindSocket(named_layer_selection, SOCK_OUT, "Selection"), - set_curve_radius, - nodeFindSocket(set_curve_radius, SOCK_IN, "Selection")); - - nodeAddLink(group, - group_input, - nodeFindSocket(group_input, SOCK_OUT, "Socket_1"), - add, - nodeFindSocket(add, SOCK_IN, "Value")); - nodeAddLink(group, - input_radius, - nodeFindSocket(input_radius, SOCK_OUT, "Radius"), - add, - nodeFindSocket(add, SOCK_IN, "Value_001")); - nodeAddLink(group, - add, - nodeFindSocket(add, SOCK_OUT, "Value"), - set_curve_radius, - nodeFindSocket(set_curve_radius, SOCK_IN, "Radius")); - - LISTBASE_FOREACH (bNode *, node, &group->nodes) { - nodeSetSelected(node, false); - } - - return group; -} - -void thickness_factor_to_modifier(const bGPdata &src_object_data, Object &dst_object) -{ - if (src_object_data.pixfactor == 1.0f) { - return; - } - const float thickness_factor = src_object_data.pixfactor; - - ModifierData *md = BKE_modifier_new(eModifierType_GreasePencilThickness); - GreasePencilThickModifierData *tmd = reinterpret_cast(md); - - tmd->thickness_fac = thickness_factor; - - STRNCPY(md->name, DATA_("Thickness")); - BKE_modifier_unique_name(&dst_object.modifiers, md); - - BLI_addtail(&dst_object.modifiers, md); - BKE_modifiers_persistent_uid_init(dst_object, *md); -} - -void layer_adjustments_to_modifiers(Main &bmain, - const bGPdata &src_object_data, - Object &dst_object) -{ - bNodeTree *offset_radius_node_tree = nullptr; - /* Replace layer adjustments with modifiers. */ - LISTBASE_FOREACH (bGPDlayer *, gpl, &src_object_data.layers) { - const float3 tint_color = float3(gpl->tintcolor); - const float tint_factor = gpl->tintcolor[3]; - const int thickness_px = gpl->line_change; - /* Tint adjustment. */ - if (tint_factor > 0.0f) { - ModifierData *md = BKE_modifier_new(eModifierType_GreasePencilTint); - GreasePencilTintModifierData *tmd = reinterpret_cast(md); - - copy_v3_v3(tmd->color, tint_color); - tmd->factor = tint_factor; - STRNCPY(tmd->influence.layer_name, gpl->info); - - char modifier_name[64]; - BLI_snprintf(modifier_name, 64, "Tint %s", gpl->info); - STRNCPY(md->name, modifier_name); - BKE_modifier_unique_name(&dst_object.modifiers, md); - - BLI_addtail(&dst_object.modifiers, md); - BKE_modifiers_persistent_uid_init(dst_object, *md); - } - /* Thickness adjustment. */ - if (thickness_px != 0) { - /* Convert the "pixel" offset value into a radius value. - * GPv2 used a conversion of 1 "px" = 0.001. */ - /* Note: this offset may be negative. */ - const float radius_offset = float(thickness_px) / 2000.0f; - if (!offset_radius_node_tree) { - offset_radius_node_tree = add_offset_radius_node_tree(bmain); - BKE_ntree_update_main_tree(&bmain, offset_radius_node_tree, nullptr); - } - auto *md = reinterpret_cast(BKE_modifier_new(eModifierType_Nodes)); - - char modifier_name[64]; - BLI_snprintf(modifier_name, 64, "Thickness %s", gpl->info); - STRNCPY(md->modifier.name, modifier_name); - BKE_modifier_unique_name(&dst_object.modifiers, &md->modifier); - md->node_group = offset_radius_node_tree; - - BLI_addtail(&dst_object.modifiers, md); - BKE_modifiers_persistent_uid_init(dst_object, md->modifier); - - md->settings.properties = bke::idprop::create_group("Nodes Modifier Settings").release(); - IDProperty *radius_offset_prop = - bke::idprop::create(DATA_("Socket_1"), radius_offset).release(); - auto *ui_data = reinterpret_cast( - IDP_ui_data_ensure(radius_offset_prop)); - ui_data->soft_min = 0.0f; - ui_data->base.rna_subtype = PROP_TRANSLATION; - IDP_AddToGroup(md->settings.properties, radius_offset_prop); - IDP_AddToGroup(md->settings.properties, - bke::idprop::create(DATA_("Socket_2"), gpl->info).release()); - } - } - - DEG_relations_tag_update(&bmain); -} - -static ModifierData &legacy_object_modifier_common(Object &object, - const ModifierType type, - GpencilModifierData &legacy_md) -{ - /* TODO: Copy of most of #ED_object_modifier_add, this should be a BKE_modifiers function - * actually. */ - const ModifierTypeInfo *mti = BKE_modifier_get_info(type); - - ModifierData &new_md = *BKE_modifier_new(type); - - if (mti->flags & eModifierTypeFlag_RequiresOriginalData) { - ModifierData *md; - for (md = static_cast(object.modifiers.first); - md && BKE_modifier_get_info(ModifierType(md->type))->type == ModifierTypeType::OnlyDeform; - md = md->next) - ; - BLI_insertlinkbefore(&object.modifiers, md, &new_md); - } - else { - BLI_addtail(&object.modifiers, &new_md); - } - - /* Generate new persistent UID and best possible unique name. */ - BKE_modifiers_persistent_uid_init(object, new_md); - if (legacy_md.name[0]) { - STRNCPY_UTF8(new_md.name, legacy_md.name); - } - BKE_modifier_unique_name(&object.modifiers, &new_md); - - /* Handle commom modifier data. */ - new_md.mode = legacy_md.mode; - new_md.flag |= legacy_md.flag & (eModifierFlag_OverrideLibrary_Local | eModifierFlag_Active); - - /* Attempt to copy UI state (panels) as best as possible. */ - new_md.ui_expand_flag = legacy_md.ui_expand_flag; - - return new_md; -} - -static void legacy_object_modifier_noise(GreasePencilNoiseModifierData &gp_md_noise, - NoiseGpencilModifierData &legacy_md_noise) -{ - gp_md_noise.flag = legacy_md_noise.flag; - gp_md_noise.factor = legacy_md_noise.factor; - gp_md_noise.factor_strength = legacy_md_noise.factor_strength; - gp_md_noise.factor_thickness = legacy_md_noise.factor_thickness; - gp_md_noise.factor_uvs = legacy_md_noise.factor_uvs; - gp_md_noise.noise_scale = legacy_md_noise.noise_scale; - gp_md_noise.noise_offset = legacy_md_noise.noise_offset; - gp_md_noise.noise_mode = legacy_md_noise.noise_mode; - gp_md_noise.step = legacy_md_noise.step; - gp_md_noise.seed = legacy_md_noise.seed; - - STRNCPY(gp_md_noise.influence.layer_name, legacy_md_noise.layername); - if (legacy_md_noise.flag & GP_NOISE_INVERT_LAYER) { - gp_md_noise.influence.flag |= GREASE_PENCIL_INFLUENCE_INVERT_LAYER_FILTER; - } - gp_md_noise.influence.layer_pass = legacy_md_noise.layer_pass; - if (gp_md_noise.influence.layer_pass > 0) { - gp_md_noise.influence.flag |= GREASE_PENCIL_INFLUENCE_USE_LAYER_PASS_FILTER; - } - if (legacy_md_noise.flag & GP_NOISE_INVERT_LAYERPASS) { - gp_md_noise.influence.flag |= GREASE_PENCIL_INFLUENCE_INVERT_LAYER_PASS_FILTER; - } - - if (legacy_md_noise.material) { - gp_md_noise.influence.material = legacy_md_noise.material; - legacy_md_noise.material = nullptr; - } - if (legacy_md_noise.flag & GP_NOISE_INVERT_MATERIAL) { - gp_md_noise.influence.flag |= GREASE_PENCIL_INFLUENCE_INVERT_MATERIAL_FILTER; - } - gp_md_noise.influence.material_pass = legacy_md_noise.pass_index; - if (gp_md_noise.influence.material_pass > 0) { - gp_md_noise.influence.flag |= GREASE_PENCIL_INFLUENCE_USE_MATERIAL_PASS_FILTER; - } - if (legacy_md_noise.flag & GP_NOISE_INVERT_PASS) { - gp_md_noise.influence.flag |= GREASE_PENCIL_INFLUENCE_INVERT_MATERIAL_PASS_FILTER; - } - - if (legacy_md_noise.vgname[0] != '\0') { - STRNCPY(gp_md_noise.influence.vertex_group_name, legacy_md_noise.vgname); - } - if (legacy_md_noise.flag & GP_NOISE_INVERT_VGROUP) { - gp_md_noise.influence.flag |= GREASE_PENCIL_INFLUENCE_INVERT_VERTEX_GROUP; - } - - if (legacy_md_noise.curve_intensity) { - if (gp_md_noise.influence.custom_curve) { - BKE_curvemapping_free(gp_md_noise.influence.custom_curve); - } - gp_md_noise.influence.custom_curve = legacy_md_noise.curve_intensity; - legacy_md_noise.curve_intensity = nullptr; - } - if (legacy_md_noise.flag & GP_NOISE_CUSTOM_CURVE) { - gp_md_noise.influence.flag |= GREASE_PENCIL_INFLUENCE_USE_CUSTOM_CURVE; - } -} - -static void legacy_object_modifiers(Main & /*bmain*/, Object &object) -{ - BLI_assert(BLI_listbase_is_empty(&object.modifiers)); - - while (GpencilModifierData *gpd_md = static_cast( - BLI_pophead(&object.greasepencil_modifiers))) - { - switch (gpd_md->type) { - case eGpencilModifierType_None: - /* Unknown type, just ignore. */ - break; - case eGpencilModifierType_Noise: { - NoiseGpencilModifierData &legacy_md_noise = *reinterpret_cast( - gpd_md); - GreasePencilNoiseModifierData &gp_md_noise = - reinterpret_cast( - legacy_object_modifier_common(object, eModifierType_GreasePencilNoise, *gpd_md)); - legacy_object_modifier_noise(gp_md_noise, legacy_md_noise); - break; - } - case eGpencilModifierType_Subdiv: - case eGpencilModifierType_Thick: - case eGpencilModifierType_Tint: - case eGpencilModifierType_Array: - case eGpencilModifierType_Build: - case eGpencilModifierType_Opacity: - case eGpencilModifierType_Color: - case eGpencilModifierType_Lattice: - case eGpencilModifierType_Simplify: - case eGpencilModifierType_Smooth: - case eGpencilModifierType_Hook: - case eGpencilModifierType_Offset: - case eGpencilModifierType_Mirror: - case eGpencilModifierType_Armature: - case eGpencilModifierType_Time: - case eGpencilModifierType_Multiply: - case eGpencilModifierType_Texture: - case eGpencilModifierType_Lineart: - case eGpencilModifierType_Length: - case eGpencilModifierType_WeightProximity: - case eGpencilModifierType_Dash: - case eGpencilModifierType_WeightAngle: - case eGpencilModifierType_Shrinkwrap: - case eGpencilModifierType_Envelope: - case eGpencilModifierType_Outline: - break; - } - - BKE_gpencil_modifier_free_ex(gpd_md, 0); - } -} - -void legacy_gpencil_object(Main &bmain, Object &object) -{ - bGPdata *gpd = static_cast(object.data); - - GreasePencil *new_grease_pencil = static_cast( - BKE_id_new(&bmain, ID_GP, gpd->id.name + 2)); - object.data = new_grease_pencil; - object.type = OB_GREASE_PENCIL; - - /* NOTE: Could also use #BKE_id_free_us, to also free the legacy GP if not used anymore? */ - id_us_min(&gpd->id); - /* No need to increase user-count of `new_grease_pencil`, - * since ID creation already set it to 1. */ - - legacy_gpencil_to_grease_pencil(bmain, *new_grease_pencil, *gpd); - - legacy_object_modifiers(bmain, object); - - /* Layer adjusments should be added after all other modifiers. */ - layer_adjustments_to_modifiers(bmain, *gpd, object); - /* Thickness factor is applied after all other changes to the radii. */ - thickness_factor_to_modifier(*gpd, object); - - BKE_object_free_derived_caches(&object); -} - } // namespace blender::bke::greasepencil::convert diff --git a/source/blender/blenkernel/intern/grease_pencil_vertex_groups.cc b/source/blender/blenkernel/intern/grease_pencil_vertex_groups.cc index 85a326536f5..236a65bb879 100644 --- a/source/blender/blenkernel/intern/grease_pencil_vertex_groups.cc +++ b/source/blender/blenkernel/intern/grease_pencil_vertex_groups.cc @@ -11,12 +11,15 @@ #include "BLI_listbase.h" #include "BLI_set.hh" #include "BLI_string.h" +#include "BLI_string_utils.hh" #include "BKE_curves.hh" #include "BKE_deform.hh" #include "BKE_grease_pencil.hh" #include "BKE_grease_pencil_vertex_groups.hh" +#include "BLT_translation.h" + namespace blender::bke::greasepencil { /* ------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/icons.cc b/source/blender/blenkernel/intern/icons.cc index 94438af63c7..c8ffeadd3f0 100644 --- a/source/blender/blenkernel/intern/icons.cc +++ b/source/blender/blenkernel/intern/icons.cc @@ -25,7 +25,7 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" -#include "BKE_global.hh" /* only for G.background test */ +#include "BKE_global.h" /* only for G.background test */ #include "BKE_icons.h" #include "BKE_preview_image.hh" #include "BKE_studiolight.h" diff --git a/source/blender/blenkernel/intern/icons_rasterize.cc b/source/blender/blenkernel/intern/icons_rasterize.cc index b7b9c79a704..4b7fe6403ec 100644 --- a/source/blender/blenkernel/intern/icons_rasterize.cc +++ b/source/blender/blenkernel/intern/icons_rasterize.cc @@ -5,6 +5,7 @@ /** \file * \ingroup bke */ +#include "MEM_guardedalloc.h" #include "BLI_bitmap_draw_2d.h" #include "BLI_math_color.h" @@ -16,7 +17,7 @@ #include "BKE_icons.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" struct UserRasterInfo { int pt[3][2]; diff --git a/source/blender/blenkernel/intern/idprop.cc b/source/blender/blenkernel/intern/idprop.cc index c8479708d3e..b4316f9e87a 100644 --- a/source/blender/blenkernel/intern/idprop.cc +++ b/source/blender/blenkernel/intern/idprop.cc @@ -22,7 +22,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_lib_id.hh" @@ -32,7 +32,7 @@ #include "BLO_read_write.hh" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* IDPropertyTemplate is a union in DNA_ID.h */ diff --git a/source/blender/blenkernel/intern/idprop_serialize_test.cc b/source/blender/blenkernel/intern/idprop_serialize_test.cc index a61c4d40da5..f431cf56510 100644 --- a/source/blender/blenkernel/intern/idprop_serialize_test.cc +++ b/source/blender/blenkernel/intern/idprop_serialize_test.cc @@ -252,7 +252,7 @@ static void test_idprop(const IDProperty *id_property, static void test_idprop(const IDProperty *id_property, StringRef expected_name, - const Span values) + const Vector &values) { ASSERT_NE(id_property, nullptr); EXPECT_EQ(id_property->type, IDP_ARRAY); @@ -267,7 +267,7 @@ static void test_idprop(const IDProperty *id_property, static void test_idprop(const IDProperty *id_property, StringRef expected_name, - const Span values) + const Vector &values) { ASSERT_NE(id_property, nullptr); EXPECT_EQ(id_property->type, IDP_ARRAY); @@ -282,7 +282,7 @@ static void test_idprop(const IDProperty *id_property, static void test_idprop(const IDProperty *id_property, StringRef expected_name, - const Span values) + const Vector &values) { ASSERT_NE(id_property, nullptr); EXPECT_EQ(id_property->type, IDP_ARRAY); diff --git a/source/blender/blenkernel/intern/idprop_utils.cc b/source/blender/blenkernel/intern/idprop_utils.cc index 80c6f6648cb..c25e253d123 100644 --- a/source/blender/blenkernel/intern/idprop_utils.cc +++ b/source/blender/blenkernel/intern/idprop_utils.cc @@ -22,7 +22,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* -------------------------------------------------------------------- */ /** \name IDProp Repr diff --git a/source/blender/blenkernel/intern/idtype.cc b/source/blender/blenkernel/intern/idtype.cc index 1546156f33b..dc900d9dd37 100644 --- a/source/blender/blenkernel/intern/idtype.cc +++ b/source/blender/blenkernel/intern/idtype.cc @@ -6,7 +6,6 @@ * \ingroup bke */ -#include #include #include "MEM_guardedalloc.h" @@ -16,7 +15,7 @@ #include "CLG_log.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_ID.h" #include "DNA_collection_types.h" @@ -24,7 +23,7 @@ #include "DNA_scene_types.h" #include "BKE_main.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BKE_idtype.hh" @@ -46,17 +45,14 @@ bool BKE_idtype_cache_key_cmp(const void *key_a_v, const void *key_b_v) (key_a->identifier != key_b->identifier); } -static std::array id_types; +static IDTypeInfo *id_types[INDEX_ID_MAX] = {nullptr}; static void id_type_init() { - int init_types_num = 0; - #define INIT_TYPE(_id_code) \ { \ BLI_assert(IDType_##_id_code.main_listbase_index == INDEX_##_id_code); \ id_types[INDEX_##_id_code] = &IDType_##_id_code; \ - init_types_num++; \ } \ (void)0 @@ -101,13 +97,9 @@ static void id_type_init() INIT_TYPE(ID_VO); INIT_TYPE(ID_GP); - /* Special case. */ + /* Special naughty boy... */ BLI_assert(IDType_ID_LINK_PLACEHOLDER.main_listbase_index == INDEX_ID_NULL); id_types[INDEX_ID_NULL] = &IDType_ID_LINK_PLACEHOLDER; - init_types_num++; - - BLI_assert_msg(init_types_num == INDEX_ID_MAX, "Some IDTypeInfo initialization is missing"); - UNUSED_VARS_NDEBUG(init_types_num); #undef INIT_TYPE } @@ -118,23 +110,19 @@ void BKE_idtype_init() id_type_init(); } -const IDTypeInfo *BKE_idtype_get_info_from_idtype_index(const int idtype_index) +const IDTypeInfo *BKE_idtype_get_info_from_idcode(const short id_code) { - if (idtype_index >= 0 && idtype_index < int(id_types.size())) { - const IDTypeInfo *id_type = id_types[size_t(idtype_index)]; - if (id_type && id_type->name[0] != '\0') { - return id_type; - } + int id_index = BKE_idtype_idcode_to_index(id_code); + + if (id_index >= 0 && id_index < ARRAY_SIZE(id_types) && id_types[id_index] != nullptr && + id_types[id_index]->name[0] != '\0') + { + return id_types[id_index]; } return nullptr; } -const IDTypeInfo *BKE_idtype_get_info_from_idcode(const short id_code) -{ - return BKE_idtype_get_info_from_idtype_index(BKE_idtype_idcode_to_index(id_code)); -} - const IDTypeInfo *BKE_idtype_get_info_from_id(const ID *id) { return BKE_idtype_get_info_from_idcode(GS(id->name)); @@ -142,9 +130,9 @@ const IDTypeInfo *BKE_idtype_get_info_from_id(const ID *id) static const IDTypeInfo *idtype_get_info_from_name(const char *idtype_name) { - for (const IDTypeInfo *id_type : id_types) { - if (id_type && STREQ(idtype_name, id_type->name)) { - return id_type; + for (int i = ARRAY_SIZE(id_types); i--;) { + if (id_types[i] != nullptr && STREQ(idtype_name, id_types[i]->name)) { + return id_types[i]; } } @@ -217,6 +205,124 @@ bool BKE_idtype_idcode_append_is_reusable(const short idcode) return false; } +uint64_t BKE_idtype_idcode_to_idfilter(const short idcode) +{ +#define CASE_IDFILTER(_id) \ + case ID_##_id: \ + return FILTER_ID_##_id + +#define CASE_IDFILTER_NONE(_id) \ + case ID_##_id: \ + return 0 + + switch ((ID_Type)idcode) { + CASE_IDFILTER(AC); + CASE_IDFILTER(AR); + CASE_IDFILTER(BR); + CASE_IDFILTER(CA); + CASE_IDFILTER(CF); + CASE_IDFILTER(CU_LEGACY); + CASE_IDFILTER(GD_LEGACY); + CASE_IDFILTER(GP); + CASE_IDFILTER(GR); + CASE_IDFILTER(CV); + CASE_IDFILTER(IM); + CASE_IDFILTER_NONE(IP); + CASE_IDFILTER(KE); + CASE_IDFILTER(LA); + CASE_IDFILTER(LI); + CASE_IDFILTER(LP); + CASE_IDFILTER(LS); + CASE_IDFILTER(LT); + CASE_IDFILTER(MA); + CASE_IDFILTER(MB); + CASE_IDFILTER(MC); + CASE_IDFILTER(ME); + CASE_IDFILTER(MSK); + CASE_IDFILTER(NT); + CASE_IDFILTER(OB); + CASE_IDFILTER(PA); + CASE_IDFILTER(PAL); + CASE_IDFILTER(PC); + CASE_IDFILTER(PT); + CASE_IDFILTER(SCE); + CASE_IDFILTER(SCR); + CASE_IDFILTER(SO); + CASE_IDFILTER(SPK); + CASE_IDFILTER(TE); + CASE_IDFILTER(TXT); + CASE_IDFILTER(VF); + CASE_IDFILTER(VO); + CASE_IDFILTER(WM); + CASE_IDFILTER(WO); + CASE_IDFILTER(WS); + } + + BLI_assert_unreachable(); + return 0; + +#undef CASE_IDFILTER +#undef CASE_IDFILTER_NONE +} + +short BKE_idtype_idcode_from_idfilter(const uint64_t idfilter) +{ +#define CASE_IDFILTER(_id) \ + case FILTER_ID_##_id: \ + return ID_##_id + +#define CASE_IDFILTER_NONE(_id) (void)0 + + switch (idfilter) { + CASE_IDFILTER(AC); + CASE_IDFILTER(AR); + CASE_IDFILTER(BR); + CASE_IDFILTER(CA); + CASE_IDFILTER(CF); + CASE_IDFILTER(CU_LEGACY); + CASE_IDFILTER(GD_LEGACY); + CASE_IDFILTER(GP); + CASE_IDFILTER(GR); + CASE_IDFILTER(CV); + CASE_IDFILTER(IM); + CASE_IDFILTER_NONE(IP); + CASE_IDFILTER(KE); + CASE_IDFILTER(LA); + CASE_IDFILTER(LI); + CASE_IDFILTER(LP); + CASE_IDFILTER(LS); + CASE_IDFILTER(LT); + CASE_IDFILTER(MA); + CASE_IDFILTER(MB); + CASE_IDFILTER(MC); + CASE_IDFILTER(ME); + CASE_IDFILTER(MSK); + CASE_IDFILTER(NT); + CASE_IDFILTER(OB); + CASE_IDFILTER(PA); + CASE_IDFILTER(PAL); + CASE_IDFILTER(PC); + CASE_IDFILTER(PT); + CASE_IDFILTER(SCE); + CASE_IDFILTER(SCR); + CASE_IDFILTER(SO); + CASE_IDFILTER(SPK); + CASE_IDFILTER(TE); + CASE_IDFILTER(TXT); + CASE_IDFILTER(VF); + CASE_IDFILTER(VO); + CASE_IDFILTER(WM); + CASE_IDFILTER(WO); + CASE_IDFILTER(WS); + } + + BLI_assert_unreachable(); + return 0; + +#undef CASE_IDFILTER +#undef CASE_IDFILTER_NONE +} + int BKE_idtype_idcode_to_index(const short idcode) { #define CASE_IDINDEX(_id) \ @@ -276,98 +382,68 @@ int BKE_idtype_idcode_to_index(const short idcode) #undef CASE_IDINDEX } -int BKE_idtype_idfilter_to_index(const uint64_t id_filter) +short BKE_idtype_idcode_from_index(const int index) { -#define CASE_IDINDEX(_id) \ - case FILTER_ID_##_id: \ - return INDEX_ID_##_id +#define CASE_IDCODE(_id) \ + case INDEX_ID_##_id: \ + return ID_##_id - switch (id_filter) { - CASE_IDINDEX(AC); - CASE_IDINDEX(AR); - CASE_IDINDEX(BR); - CASE_IDINDEX(CA); - CASE_IDINDEX(CF); - CASE_IDINDEX(CU_LEGACY); - CASE_IDINDEX(GD_LEGACY); - CASE_IDINDEX(GP); - CASE_IDINDEX(GR); - CASE_IDINDEX(CV); - CASE_IDINDEX(IM); - CASE_IDINDEX(IP); - CASE_IDINDEX(KE); - CASE_IDINDEX(LA); - CASE_IDINDEX(LI); - CASE_IDINDEX(LS); - CASE_IDINDEX(LT); - CASE_IDINDEX(MA); - CASE_IDINDEX(MB); - CASE_IDINDEX(MC); - CASE_IDINDEX(ME); - CASE_IDINDEX(MSK); - CASE_IDINDEX(NT); - CASE_IDINDEX(OB); - CASE_IDINDEX(PA); - CASE_IDINDEX(PAL); - CASE_IDINDEX(PC); - CASE_IDINDEX(PT); - CASE_IDINDEX(LP); - CASE_IDINDEX(SCE); - CASE_IDINDEX(SCR); - CASE_IDINDEX(SPK); - CASE_IDINDEX(SO); - CASE_IDINDEX(TE); - CASE_IDINDEX(TXT); - CASE_IDINDEX(VF); - CASE_IDINDEX(VO); - CASE_IDINDEX(WM); - CASE_IDINDEX(WO); - CASE_IDINDEX(WS); + switch (index) { + CASE_IDCODE(AC); + CASE_IDCODE(AR); + CASE_IDCODE(BR); + CASE_IDCODE(CA); + CASE_IDCODE(CF); + CASE_IDCODE(CU_LEGACY); + CASE_IDCODE(GD_LEGACY); + CASE_IDCODE(GP); + CASE_IDCODE(GR); + CASE_IDCODE(CV); + CASE_IDCODE(IM); + CASE_IDCODE(IP); + CASE_IDCODE(KE); + CASE_IDCODE(LA); + CASE_IDCODE(LI); + CASE_IDCODE(LS); + CASE_IDCODE(LT); + CASE_IDCODE(MA); + CASE_IDCODE(MB); + CASE_IDCODE(MC); + CASE_IDCODE(ME); + CASE_IDCODE(MSK); + CASE_IDCODE(NT); + CASE_IDCODE(OB); + CASE_IDCODE(PA); + CASE_IDCODE(PAL); + CASE_IDCODE(PC); + CASE_IDCODE(PT); + CASE_IDCODE(LP); + CASE_IDCODE(SCE); + CASE_IDCODE(SCR); + CASE_IDCODE(SPK); + CASE_IDCODE(SO); + CASE_IDCODE(TE); + CASE_IDCODE(TXT); + CASE_IDCODE(VF); + CASE_IDCODE(VO); + CASE_IDCODE(WM); + CASE_IDCODE(WO); + CASE_IDCODE(WS); } - /* No handling of #ID_LINK_PLACEHOLDER or #INDEX_ID_NULL here. */ + /* Special naughty boy... */ + if (index == INDEX_ID_NULL) { + return ID_LINK_PLACEHOLDER; + } return -1; -#undef CASE_IDINDEX +#undef CASE_IDCODE } -short BKE_idtype_index_to_idcode(const int idtype_index) +short BKE_idtype_idcode_iter_step(int *index) { - const IDTypeInfo *id_type = BKE_idtype_get_info_from_idtype_index(idtype_index); - if (id_type) { - return id_type->id_code; - } - - BLI_assert_unreachable(); - return -1; -} - -uint64_t BKE_idtype_index_to_idfilter(const int idtype_index) -{ - const IDTypeInfo *id_type = BKE_idtype_get_info_from_idtype_index(idtype_index); - if (id_type) { - return id_type->id_filter; - } - - BLI_assert_unreachable(); - return 0; -} - -uint64_t BKE_idtype_idcode_to_idfilter(const short idcode) -{ - return BKE_idtype_index_to_idfilter(BKE_idtype_idcode_to_index(idcode)); -} - -short BKE_idtype_idfilter_to_idcode(const uint64_t idfilter) -{ - return BKE_idtype_index_to_idcode(BKE_idtype_idfilter_to_index(idfilter)); -} - -short BKE_idtype_idcode_iter_step(int *idtype_index) -{ - return (*idtype_index < int(id_types.size())) ? BKE_idtype_index_to_idcode((*idtype_index)++) : - 0; + return (*index < ARRAY_SIZE(id_types)) ? BKE_idtype_idcode_from_index((*index)++) : 0; } void BKE_idtype_id_foreach_cache(ID *id, diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index 1553233437d..8329beb53e6 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -60,11 +60,11 @@ #include "BLI_timecode.h" /* For stamp time-code format. */ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" -#include "BKE_bpath.hh" +#include "BKE_bpath.h" #include "BKE_colortools.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_icons.h" #include "BKE_idtype.hh" #include "BKE_image.h" @@ -76,8 +76,8 @@ #include "BKE_node_tree_update.hh" #include "BKE_packedFile.h" #include "BKE_preview_image.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_workspace.h" #include "BLF_api.hh" @@ -440,7 +440,6 @@ constexpr IDTypeInfo get_type_info() IDTypeInfo info{}; info.id_code = ID_IM; info.id_filter = FILTER_ID_IM; - info.dependencies_id_types = 0; info.main_listbase_index = INDEX_ID_IM; info.struct_size = sizeof(Image); info.name = "Image"; @@ -1495,7 +1494,7 @@ void BKE_image_packfiles_from_mem(ReportList *reports, void BKE_image_tag_time(Image *ima) { - ima->lastused = BLI_time_now_seconds_i(); + ima->lastused = BLI_check_seconds_timer_i(); } static uintptr_t image_mem_size(Image *image) diff --git a/source/blender/blenkernel/intern/image_format.cc b/source/blender/blenkernel/intern/image_format.cc index e65250e8fb2..4cc6cab8f88 100644 --- a/source/blender/blenkernel/intern/image_format.cc +++ b/source/blender/blenkernel/intern/image_format.cc @@ -16,6 +16,7 @@ #include "BLI_utildefines.h" #include "IMB_colormanagement.hh" +#include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" #include "BKE_colortools.hh" diff --git a/source/blender/blenkernel/intern/image_gpu.cc b/source/blender/blenkernel/intern/image_gpu.cc index 2811a38c676..666215d049c 100644 --- a/source/blender/blenkernel/intern/image_gpu.cc +++ b/source/blender/blenkernel/intern/image_gpu.cc @@ -8,6 +8,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_bitmap.h" #include "BLI_boxpack_2d.h" #include "BLI_linklist.h" #include "BLI_listbase.h" @@ -21,7 +22,7 @@ #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_image_partial_update.hh" #include "BKE_main.hh" @@ -585,7 +586,7 @@ void BKE_image_free_anim_gputextures(Main *bmain) void BKE_image_free_old_gputextures(Main *bmain) { static int lasttime = 0; - int ctime = int(BLI_time_now_seconds()); + int ctime = int(BLI_check_seconds_timer()); /* * Run garbage collector once for every collecting period of time diff --git a/source/blender/blenkernel/intern/image_partial_update.cc b/source/blender/blenkernel/intern/image_partial_update.cc index 2e5d048816e..4e28c204725 100644 --- a/source/blender/blenkernel/intern/image_partial_update.cc +++ b/source/blender/blenkernel/intern/image_partial_update.cc @@ -54,6 +54,7 @@ #include "DNA_image_types.h" +#include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" #include "BLI_listbase.h" diff --git a/source/blender/blenkernel/intern/image_partial_update_test.cc b/source/blender/blenkernel/intern/image_partial_update_test.cc index 3f2d513ae1b..bc2b30a39f2 100644 --- a/source/blender/blenkernel/intern/image_partial_update_test.cc +++ b/source/blender/blenkernel/intern/image_partial_update_test.cc @@ -6,7 +6,7 @@ #include "CLG_log.h" #include "BKE_appdir.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_image.h" #include "BKE_image_partial_update.hh" diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc index 64d81a87886..0615b18c501 100644 --- a/source/blender/blenkernel/intern/image_save.cc +++ b/source/blender/blenkernel/intern/image_save.cc @@ -15,7 +15,7 @@ #include "BLI_string.h" #include "BLI_vector.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_image_types.h" @@ -27,13 +27,13 @@ #include "IMB_openexr.hh" #include "BKE_colortools.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_image_format.h" #include "BKE_image_save.h" #include "BKE_main.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "RE_pipeline.h" diff --git a/source/blender/blenkernel/intern/instances.cc b/source/blender/blenkernel/intern/instances.cc index bd2dcb80323..f43fba35002 100644 --- a/source/blender/blenkernel/intern/instances.cc +++ b/source/blender/blenkernel/intern/instances.cc @@ -6,6 +6,7 @@ #include "BLI_rand.hh" #include "BLI_task.hh" +#include "BKE_attribute_math.hh" #include "BKE_customdata.hh" #include "BKE_geometry_set.hh" #include "BKE_instances.hh" diff --git a/source/blender/blenkernel/intern/ipo.cc b/source/blender/blenkernel/intern/ipo.cc index 19fe229899b..65d34788467 100644 --- a/source/blender/blenkernel/intern/ipo.cc +++ b/source/blender/blenkernel/intern/ipo.cc @@ -41,13 +41,13 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" #include "BKE_anim_data.h" #include "BKE_fcurve.h" #include "BKE_fcurve_driver.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_ipo.h" #include "BKE_key.hh" @@ -156,8 +156,7 @@ static void ipo_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_IP = { /*id_code*/ ID_IP, - /*id_filter*/ FILTER_ID_IP, - /*dependencies_id_types*/ 0, + /*id_filter*/ 0, /*main_listbase_index*/ INDEX_ID_IP, /*struct_size*/ sizeof(Ipo), /*name*/ "Ipo", diff --git a/source/blender/blenkernel/intern/key.cc b/source/blender/blenkernel/intern/key.cc index bc5811abfee..61df48879eb 100644 --- a/source/blender/blenkernel/intern/key.cc +++ b/source/blender/blenkernel/intern/key.cc @@ -19,7 +19,7 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" /* Allow using deprecated functionality for .blend file I/O. */ #define DNA_DEPRECATED_ALLOW @@ -46,7 +46,7 @@ #include "BKE_lib_query.hh" #include "BKE_main.hh" #include "BKE_mesh.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "RNA_access.hh" #include "RNA_path.hh" @@ -191,8 +191,6 @@ static void shapekey_blend_read_after_liblink(BlendLibReader * /*reader*/, ID *i IDTypeInfo IDType_ID_KE = { /*id_code*/ ID_KE, /*id_filter*/ FILTER_ID_KE, - /* Warning! key->from, could be more types in future? */ - /*dependencies_id_types*/ FILTER_ID_ME | FILTER_ID_CU_LEGACY | FILTER_ID_LT, /*main_listbase_index*/ INDEX_ID_KE, /*struct_size*/ sizeof(Key), /*name*/ "Key", diff --git a/source/blender/blenkernel/intern/lattice.cc b/source/blender/blenkernel/intern/lattice.cc index 3865391ef7c..a85339a8b9b 100644 --- a/source/blender/blenkernel/intern/lattice.cc +++ b/source/blender/blenkernel/intern/lattice.cc @@ -19,7 +19,7 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" /* Allow using deprecated functionality for .blend file I/O. */ #define DNA_DEPRECATED_ALLOW @@ -30,7 +30,9 @@ #include "DNA_lattice_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "BKE_anim_data.h" #include "BKE_curve.hh" #include "BKE_deform.hh" #include "BKE_displist.h" @@ -38,10 +40,13 @@ #include "BKE_lattice.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" +#include "DEG_depsgraph_query.hh" + #include "BLO_read_write.hh" static void lattice_init_data(ID *id) @@ -158,7 +163,6 @@ static void lattice_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_LT = { /*id_code*/ ID_LT, /*id_filter*/ FILTER_ID_LT, - /*dependencies_id_types*/ FILTER_ID_KE, /*main_listbase_index*/ INDEX_ID_LT, /*struct_size*/ sizeof(Lattice), /*name*/ "Lattice", @@ -339,10 +343,10 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) BKE_displist_free(<Ob->runtime->curve_cache->disp); } - copy_m4_m4(mat, ltOb->object_to_world().ptr()); - unit_m4(ltOb->runtime->object_to_world.ptr()); + copy_m4_m4(mat, ltOb->object_to_world); + unit_m4(ltOb->object_to_world); BKE_lattice_deform_coords(ltOb, nullptr, vert_coords, uNew * vNew * wNew, 0, nullptr, 1.0f); - copy_m4_m4(ltOb->runtime->object_to_world.ptr(), mat); + copy_m4_m4(ltOb->object_to_world, mat); lt->typeu = typeu; lt->typev = typev; diff --git a/source/blender/blenkernel/intern/lattice_deform.cc b/source/blender/blenkernel/intern/lattice_deform.cc index b67ce7c90da..e6732f05799 100644 --- a/source/blender/blenkernel/intern/lattice_deform.cc +++ b/source/blender/blenkernel/intern/lattice_deform.cc @@ -33,6 +33,7 @@ #include "BKE_editmesh.hh" #include "BKE_key.hh" #include "BKE_lattice.hh" +#include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" @@ -82,15 +83,15 @@ LatticeDeformData *BKE_lattice_deform_data_create(const Object *oblatt, const Ob /* for example with a particle system: (ob == nullptr) */ if (ob == nullptr) { /* In deform-space, calc matrix. */ - invert_m4_m4(latmat, oblatt->object_to_world().ptr()); + invert_m4_m4(latmat, oblatt->object_to_world); /* back: put in deform array */ invert_m4_m4(imat, latmat); } else { /* In deform-space, calc matrix. */ - invert_m4_m4(imat, oblatt->object_to_world().ptr()); - mul_m4_m4m4(latmat, imat, ob->object_to_world().ptr()); + invert_m4_m4(imat, oblatt->object_to_world); + mul_m4_m4m4(latmat, imat, ob->object_to_world); /* back: put in deform array. */ invert_m4_m4(imat, latmat); diff --git a/source/blender/blenkernel/intern/lattice_deform_test.cc b/source/blender/blenkernel/intern/lattice_deform_test.cc index c9e4a1c4ad7..90eee096b11 100644 --- a/source/blender/blenkernel/intern/lattice_deform_test.cc +++ b/source/blender/blenkernel/intern/lattice_deform_test.cc @@ -3,21 +3,20 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "testing/testing.h" +#include "BKE_idtype.hh" +#include "BKE_lattice.hh" + +#include "MEM_guardedalloc.h" + +#include "DNA_lattice_types.h" +#include "DNA_mesh_types.h" +#include "DNA_object_types.h" + +#include "BLI_rand.hh" + #define DO_PERF_TESTS 0 #if DO_PERF_TESTS - -# include "BKE_idtype.hh" -# include "BKE_lattice.hh" - -# include "MEM_guardedalloc.h" - -# include "DNA_lattice_types.h" -# include "DNA_mesh_types.h" -# include "DNA_object_types.h" - -# include "BLI_rand.hh" - namespace blender::bke::tests { struct LatticeDeformTestContext { diff --git a/source/blender/blenkernel/intern/layer.cc b/source/blender/blenkernel/intern/layer.cc index 63324479236..d024b9d9f9d 100644 --- a/source/blender/blenkernel/intern/layer.cc +++ b/source/blender/blenkernel/intern/layer.cc @@ -19,10 +19,10 @@ #include "BLI_string_utf8.h" #include "BLI_string_utils.hh" #include "BLI_threads.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_animsys.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_freestyle.h" #include "BKE_idprop.h" #include "BKE_layer.hh" diff --git a/source/blender/blenkernel/intern/layer_utils.cc b/source/blender/blenkernel/intern/layer_utils.cc index 7d5f071094e..441dfdf71b7 100644 --- a/source/blender/blenkernel/intern/layer_utils.cc +++ b/source/blender/blenkernel/intern/layer_utils.cc @@ -8,7 +8,9 @@ #include -#include "BKE_collection.hh" +#include "BLI_array.h" + +#include "BKE_collection.h" #include "BKE_customdata.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" @@ -17,6 +19,7 @@ #include "DNA_layer_types.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/lib_id.cc b/source/blender/blenkernel/intern/lib_id.cc index 9fb258e8575..5c7d6261c53 100644 --- a/source/blender/blenkernel/intern/lib_id.cc +++ b/source/blender/blenkernel/intern/lib_id.cc @@ -38,14 +38,14 @@ #include "BLI_memarena.h" #include "BLI_string_utils.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_anim_data.h" #include "BKE_armature.hh" #include "BKE_asset.hh" -#include "BKE_bpath.hh" +#include "BKE_bpath.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_legacy.h" #include "BKE_idprop.h" #include "BKE_idtype.hh" @@ -56,7 +56,7 @@ #include "BKE_lib_remap.hh" #include "BKE_main.hh" #include "BKE_main_namemap.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BKE_rigidbody.h" #include "DEG_depsgraph.hh" @@ -77,14 +77,11 @@ # include "BLI_time_utildefines.h" #endif -using namespace blender::bke::id; - static CLG_LogRef LOG = {"bke.lib_id"}; IDTypeInfo IDType_ID_LINK_PLACEHOLDER = { /*id_code*/ ID_LINK_PLACEHOLDER, /*id_filter*/ 0, - /*dependencies_id_types*/ 0, /*main_listbase_index*/ INDEX_ID_NULL, /*struct_size*/ sizeof(ID), /*name*/ "LinkPlaceholder", @@ -806,10 +803,10 @@ static void id_swap(Main *bmain, IDRemapper *remapper_id_b = input_remapper_id_b; if (do_self_remap) { if (remapper_id_a == nullptr) { - remapper_id_a = MEM_new(__func__); + remapper_id_a = BKE_id_remapper_create(); } if (remapper_id_b == nullptr) { - remapper_id_b = MEM_new(__func__); + remapper_id_b = BKE_id_remapper_create(); } } @@ -855,25 +852,25 @@ static void id_swap(Main *bmain, } if (remapper_id_a != nullptr) { - remapper_id_a->add(id_b, id_a); + BKE_id_remapper_add(remapper_id_a, id_b, id_a); } if (remapper_id_b != nullptr) { - remapper_id_b->add(id_a, id_b); + BKE_id_remapper_add(remapper_id_b, id_a, id_b); } /* Finalize remapping of internal references to self broken by swapping, if requested. */ if (do_self_remap) { BKE_libblock_relink_multiple( - bmain, {id_a}, ID_REMAP_TYPE_REMAP, *remapper_id_a, self_remap_flags); + bmain, {id_a}, ID_REMAP_TYPE_REMAP, remapper_id_a, self_remap_flags); BKE_libblock_relink_multiple( - bmain, {id_b}, ID_REMAP_TYPE_REMAP, *remapper_id_b, self_remap_flags); + bmain, {id_b}, ID_REMAP_TYPE_REMAP, remapper_id_b, self_remap_flags); } if (input_remapper_id_a == nullptr && remapper_id_a != nullptr) { - MEM_delete(remapper_id_a); + BKE_id_remapper_free(remapper_id_a); } if (input_remapper_id_b == nullptr && remapper_id_b != nullptr) { - MEM_delete(remapper_id_b); + BKE_id_remapper_free(remapper_id_b); } } @@ -911,10 +908,10 @@ static void id_embedded_swap(ID **embedded_id_a, /* Restore internal pointers to the swapped embedded IDs in their owners' data. This also * includes the potential self-references inside the embedded IDs themselves. */ if (remapper_id_a != nullptr) { - remapper_id_a->add(*embedded_id_b, *embedded_id_a); + BKE_id_remapper_add(remapper_id_a, *embedded_id_b, *embedded_id_a); } if (remapper_id_b != nullptr) { - remapper_id_b->add(*embedded_id_a, *embedded_id_b); + BKE_id_remapper_add(remapper_id_b, *embedded_id_a, *embedded_id_b); } } } diff --git a/source/blender/blenkernel/intern/lib_id_delete.cc b/source/blender/blenkernel/intern/lib_id_delete.cc index 12e3a9591f4..f9ff7f325df 100644 --- a/source/blender/blenkernel/intern/lib_id_delete.cc +++ b/source/blender/blenkernel/intern/lib_id_delete.cc @@ -8,6 +8,8 @@ * Contains management of ID's for freeing & deletion. */ +#include "CLG_log.h" + #include "MEM_guardedalloc.h" /* all types are needed here, in order to do memory operations */ @@ -16,8 +18,8 @@ #include "BLI_utildefines.h" +#include "BLI_linklist.h" #include "BLI_listbase.h" -#include "BLI_set.hh" #include "BLI_vector.hh" #include "BKE_anim_data.h" @@ -40,7 +42,7 @@ # include "BPY_extern.h" #endif -using namespace blender::bke::id; +static CLG_LogRef LOG = {"bke.lib_id_delete"}; void BKE_libblock_free_data(ID *id, const bool do_id_user) { @@ -144,9 +146,10 @@ static int id_free(Main *bmain, void *idv, int flag, const bool use_flag_from_id } if (remap_editor_id_reference_cb) { - IDRemapper remapper; - remapper.add(id, nullptr); + IDRemapper *remapper = BKE_id_remapper_create(); + BKE_id_remapper_add(remapper, id, nullptr); remap_editor_id_reference_cb(remapper); + BKE_id_remapper_free(remapper); } } @@ -210,132 +213,215 @@ void BKE_id_free_us(Main *bmain, void *idv) /* test users */ } if (id->us == 0) { - BKE_libblock_unlink(bmain, id, false); + BKE_libblock_unlink(bmain, id, false, false); BKE_id_free(bmain, id); } } static size_t id_delete(Main *bmain, - blender::Set &ids_to_delete, + const bool do_tagged_deletion, const int extra_remapping_flags) { + const int tag = LIB_TAG_DOIT; + ListBase *lbarray[INDEX_ID_MAX]; + int base_count, i; + /* Used by batch tagged deletion, when we call BKE_id_free then, id is no more in Main database, * and has already properly unlinked its other IDs usages. * UI users are always cleared in BKE_libblock_remap_locked() call, so we can always skip it. */ - const int free_flag = LIB_ID_FREE_NO_UI_USER | LIB_ID_FREE_NO_MAIN | - LIB_ID_FREE_NO_USER_REFCOUNT; - const int remapping_flags = (ID_REMAP_STORE_NEVER_NULL_USAGE | ID_REMAP_FORCE_NEVER_NULL_USAGE | + const int free_flag = LIB_ID_FREE_NO_UI_USER | + (do_tagged_deletion ? LIB_ID_FREE_NO_MAIN | LIB_ID_FREE_NO_USER_REFCOUNT : + 0); + const int remapping_flags = (ID_REMAP_FLAG_NEVER_NULL_USAGE | ID_REMAP_FORCE_NEVER_NULL_USAGE | ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS | extra_remapping_flags); + ListBase tagged_deleted_ids = {nullptr}; - ListBase *lbarray[INDEX_ID_MAX]; - const int base_count = set_listbasepointers(bmain, lbarray); + base_count = set_listbasepointers(bmain, lbarray); BKE_main_lock(bmain); - BKE_layer_collection_resync_forbid(); - IDRemapper id_remapper; + if (do_tagged_deletion) { + IDRemapper *id_remapper = BKE_id_remapper_create(); + BKE_layer_collection_resync_forbid(); - /* Main idea of batch deletion is to remove all IDs to be deleted from Main database. - * This means that we won't have to loop over all deleted IDs to remove usages - * of other deleted IDs. - * This gives tremendous speed-up when deleting a large amount of IDs from a Main - * containing thousands of these. - * This also means that we have to be very careful here, as we by-pass many 'common' - * processing, hence risking to 'corrupt' at least user counts, if not IDs themselves. */ - bool keep_looping = true; - while (keep_looping) { - keep_looping = false; + /* Main idea of batch deletion is to remove all IDs to be deleted from Main database. + * This means that we won't have to loop over all deleted IDs to remove usages + * of other deleted IDs. + * This gives tremendous speed-up when deleting a large amount of IDs from a Main + * containing thousands of those. + * This also means that we have to be very careful here, as we by-pass many 'common' + * processing, hence risking to 'corrupt' at least user counts, if not IDs themselves. */ + bool keep_looping = true; + while (keep_looping) { + ID *id, *id_next; + keep_looping = false; - /* First tag and remove from Main all datablocks directly from target lib. - * Note that we go forward here, since we want to check dependencies before users - * (e.g. meshes before objects). Reduces the chances to have to loop many times in the - * `while (keep_looking)` outer loop. */ - for (int i = 0; i < base_count; i++) { - ListBase *lb = lbarray[i]; - ID *id_iter; + /* First tag and remove from Main all datablocks directly from target lib. + * Note that we go forward here, since we want to check dependencies before users + * (e.g. meshes before objects). Avoids to have to loop twice. */ + for (i = 0; i < base_count; i++) { + ListBase *lb = lbarray[i]; - FOREACH_MAIN_LISTBASE_ID_BEGIN (lb, id_iter) { - /* NOTE: in case we delete a library, we also delete all its datablocks! */ - if (ids_to_delete.contains(id_iter) || - (ID_IS_LINKED(id_iter) && ids_to_delete.contains(&id_iter->lib->id))) - { - BLI_remlink(lb, id_iter); - BKE_main_namemap_remove_name(bmain, id_iter, id_iter->name + 2); - ids_to_delete.add(id_iter); - id_remapper.add(id_iter, nullptr); - /* Do not tag as no_main now, we want to unlink it first (lower-level ID management - * code has some specific handling of 'no main' IDs that would be a problem in that - * case). */ + for (id = static_cast(lb->first); id; id = id_next) { + id_next = static_cast(id->next); + /* NOTE: in case we delete a library, we also delete all its datablocks! */ + if ((id->tag & tag) || (ID_IS_LINKED(id) && (id->lib->id.tag & tag))) { + BLI_remlink(lb, id); + BKE_main_namemap_remove_name(bmain, id, id->name + 2); + BLI_addtail(&tagged_deleted_ids, id); + BKE_id_remapper_add(id_remapper, id, nullptr); + /* Do not tag as no_main now, we want to unlink it first (lower-level ID management + * code has some specific handling of 'no main' IDs that would be a problem in that + * case). */ + id->tag |= tag; - /* Forcefully also delete shapekeys of the deleted ID if any, 'orphaned' shapekeys are - * not allowed in Blender and will cause lots of problem in modern code (liboverrides, - * warning on write & read, etc.). */ - Key *shape_key = BKE_key_from_id(id_iter); - if (shape_key && !ids_to_delete.contains(&shape_key->id)) { - BLI_remlink(&bmain->shapekeys, &shape_key->id); - BKE_main_namemap_remove_name(bmain, &shape_key->id, shape_key->id.name + 2); - ids_to_delete.add(&shape_key->id); - id_remapper.add(&shape_key->id, nullptr); + /* Forcefully also delete shapekeys of the deleted ID if any, 'orphaned' shapekeys are + * not allowed in Blender and will cause lots of problem in modern code (liboverrides, + * warning on write & read, etc.). */ + Key *shape_key = BKE_key_from_id(id); + if (shape_key && (shape_key->id.tag & tag) == 0) { + BLI_remlink(&bmain->shapekeys, &shape_key->id); + BKE_main_namemap_remove_name(bmain, &shape_key->id, shape_key->id.name + 2); + BLI_addtail(&tagged_deleted_ids, &shape_key->id); + BKE_id_remapper_add(id_remapper, &shape_key->id, nullptr); + shape_key->id.tag |= tag; + } + + keep_looping = true; } - - keep_looping = true; } } - FOREACH_MAIN_LISTBASE_ID_END; + + /* Will tag 'never nullptr' users of this ID too. + * + * NOTE: #BKE_libblock_unlink() cannot be used here, since it would ignore indirect + * links, this can lead to nasty crashing here in second, actual deleting loop. + * Also, this will also flag users of deleted data that cannot be unlinked + * (object using deleted obdata, etc.), so that they also get deleted. */ + BKE_libblock_remap_multiple_locked(bmain, id_remapper, remapping_flags); + BKE_id_remapper_clear(id_remapper); } - /* Will tag 'never nullptr' users of this ID too. - * - * NOTE: #BKE_libblock_unlink() cannot be used here, since it would ignore indirect - * links, this can lead to nasty crashing here in second, actual deleting loop. - * Also, this will also flag users of deleted data that cannot be unlinked - * (object using deleted obdata, etc.), so that they also get deleted. */ - BKE_libblock_remap_multiple_locked(bmain, id_remapper, remapping_flags); - for (ID *id_never_null_iter : id_remapper.never_null_users()) { - ids_to_delete.add(id_never_null_iter); + /* Since we removed IDs from Main, their own other IDs usages need to be removed 'manually'. */ + blender::Vector cleanup_ids; + for (ID *id = static_cast(tagged_deleted_ids.first); id; + id = static_cast(id->next)) + { + cleanup_ids.append(id); + } + BKE_libblock_relink_multiple(bmain, + cleanup_ids, + ID_REMAP_TYPE_CLEANUP, + id_remapper, + ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS | + ID_REMAP_SKIP_USER_CLEAR); + cleanup_ids.clear(); + BKE_id_remapper_free(id_remapper); + + BKE_layer_collection_resync_allow(); + BKE_main_collection_sync_remap(bmain); + + /* Now we can safely mark that ID as not being in Main database anymore. */ + /* NOTE: This needs to be done in a separate loop than above, otherwise some user-counts of + * deleted IDs may not be properly decreased by the remappings (since `NO_MAIN` ID user-counts + * is never affected). */ + for (ID *id = static_cast(tagged_deleted_ids.first); id; + id = static_cast(id->next)) + { + id->tag |= LIB_TAG_NO_MAIN; + /* User-count needs to be reset artificially, since some usages may not be cleared in batch + * deletion (typically, if one deleted ID uses another deleted ID, this may not be cleared by + * remapping code, depending on order in which these are handled). */ + id->us = ID_FAKE_USERS(id); } - id_remapper.clear(); } + else { + /* First tag all data-blocks directly from target lib. + * Note that we go forward here, since we want to check dependencies before users + * (e.g. meshes before objects). + * Avoids to have to loop twice. */ + IDRemapper *remapper = BKE_id_remapper_create(); + for (i = 0; i < base_count; i++) { + ListBase *lb = lbarray[i]; + ID *id, *id_next; + BKE_id_remapper_clear(remapper); - /* Since we removed IDs from Main, their own other IDs usages need to be removed 'manually'. */ - blender::Vector cleanup_ids{ids_to_delete.begin(), ids_to_delete.end()}; - BKE_libblock_relink_multiple( - bmain, - cleanup_ids, - ID_REMAP_TYPE_CLEANUP, - id_remapper, - (ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS | ID_REMAP_SKIP_USER_CLEAR)); - cleanup_ids.clear(); + for (id = static_cast(lb->first); id; id = id_next) { + id_next = static_cast(id->next); + /* NOTE: in case we delete a library, we also delete all its datablocks! */ + if ((id->tag & tag) || (ID_IS_LINKED(id) && (id->lib->id.tag & tag))) { + id->tag |= tag; + BKE_id_remapper_add(remapper, id, nullptr); + } + } - /* Now we can safely mark that ID as not being in Main database anymore. */ - /* NOTE: This needs to be done in a separate loop than above, otherwise some user-counts of - * deleted IDs may not be properly decreased by the remappings (since `NO_MAIN` ID user-counts - * is never affected). */ - for (ID *id : ids_to_delete) { - id->tag |= LIB_TAG_NO_MAIN; - /* User-count needs to be reset artificially, since some usages may not be cleared in batch - * deletion (typically, if one deleted ID uses another deleted ID, this may not be cleared by - * remapping code, depending on order in which these are handled). */ - id->us = ID_FAKE_USERS(id); + if (BKE_id_remapper_is_empty(remapper)) { + continue; + } - id_free(bmain, id, free_flag, false); + /* Will tag 'never nullptr' users of this ID too. + * + * NOTE: #BKE_libblock_unlink() cannot be used here, since it would ignore indirect + * links, this can lead to nasty crashing here in second, actual deleting loop. + * Also, this will also flag users of deleted data that cannot be unlinked + * (object using deleted obdata, etc.), so that they also get deleted. */ + BKE_libblock_remap_multiple_locked(bmain, remapper, remapping_flags); + } + BKE_id_remapper_free(remapper); } BKE_main_unlock(bmain); + + /* ViewLayer resync needs to be delayed during Scene freeing, since internal relationships + * between the Scene's master collection and its view_layers become invalid + * (due to remapping). */ + BKE_layer_collection_resync_forbid(); + + /* In usual reversed order, such that all usage of a given ID, even 'never nullptr' ones, + * have been already cleared when we reach it + * (e.g. Objects being processed before meshes, they'll have already released their 'reference' + * over meshes when we come to freeing obdata). */ + size_t num_datablocks_deleted = 0; + for (i = do_tagged_deletion ? 1 : base_count; i--;) { + ListBase *lb = lbarray[i]; + ID *id, *id_next; + + for (id = static_cast(do_tagged_deletion ? tagged_deleted_ids.first : lb->first); id; + id = id_next) + { + id_next = static_cast(id->next); + if (id->tag & tag) { + if (((id->tag & LIB_TAG_EXTRAUSER_SET) == 0 && ID_REAL_USERS(id) != 0) || + ((id->tag & LIB_TAG_EXTRAUSER_SET) != 0 && ID_REAL_USERS(id) != 1)) + { + CLOG_ERROR(&LOG, + "Deleting %s which still has %d users (including %d 'extra' shallow users)\n", + id->name, + ID_REAL_USERS(id), + (id->tag & LIB_TAG_EXTRAUSER_SET) != 0 ? 1 : 0); + } + id_free(bmain, id, free_flag, !do_tagged_deletion); + ++num_datablocks_deleted; + } + } + } + BKE_layer_collection_resync_allow(); BKE_main_collection_sync_remap(bmain); bmain->is_memfile_undo_written = false; - return size_t(ids_to_delete.size()); + return num_datablocks_deleted; } void BKE_id_delete_ex(Main *bmain, void *idv, const int extra_remapping_flags) { - ID *id = static_cast(idv); - BLI_assert_msg((id->tag & LIB_TAG_NO_MAIN) == 0, "Cannot be used with IDs outside of Main"); + BLI_assert_msg((((ID *)idv)->tag & LIB_TAG_NO_MAIN) == 0, + "Cannot be used with IDs outside of Main"); - blender::Set ids_to_delete = {id}; - id_delete(bmain, ids_to_delete, extra_remapping_flags); + BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); + ((ID *)idv)->tag |= LIB_TAG_DOIT; + + id_delete(bmain, false, extra_remapping_flags); } void BKE_id_delete(Main *bmain, void *idv) @@ -345,20 +431,7 @@ void BKE_id_delete(Main *bmain, void *idv) size_t BKE_id_multi_tagged_delete(Main *bmain) { - blender::Set ids_to_delete; - ID *id_iter; - FOREACH_MAIN_ID_BEGIN (bmain, id_iter) { - if (id_iter->tag & LIB_TAG_DOIT) { - ids_to_delete.add(id_iter); - } - } - FOREACH_MAIN_ID_END; - return id_delete(bmain, ids_to_delete, 0); -} - -size_t BKE_id_multi_delete(Main *bmain, blender::Set &ids_to_delete) -{ - return id_delete(bmain, ids_to_delete, 0); + return id_delete(bmain, true, 0); } /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/lib_id_remapper.cc b/source/blender/blenkernel/intern/lib_id_remapper.cc index 7027c4d175d..0a8135fd7c3 100644 --- a/source/blender/blenkernel/intern/lib_id_remapper.cc +++ b/source/blender/blenkernel/intern/lib_id_remapper.cc @@ -10,87 +10,215 @@ #include "MEM_guardedalloc.h" -namespace blender::bke::id { +#include "BLI_map.hh" -void IDRemapper::add(ID *old_id, ID *new_id) +using IDTypeFilter = uint64_t; + +namespace blender::bke::id::remapper { +struct IDRemapper { + private: + Map mappings; + IDTypeFilter source_types = 0; + + public: + void clear() + { + mappings.clear(); + source_types = 0; + } + + bool is_empty() const + { + return mappings.is_empty(); + } + + void add(ID *old_id, ID *new_id) + { + BLI_assert(old_id != nullptr); + BLI_assert(new_id == nullptr || (GS(old_id->name) == GS(new_id->name))); + mappings.add(old_id, new_id); + BLI_assert(BKE_idtype_idcode_to_idfilter(GS(old_id->name)) != 0); + source_types |= BKE_idtype_idcode_to_idfilter(GS(old_id->name)); + } + + void add_overwrite(ID *old_id, ID *new_id) + { + BLI_assert(old_id != nullptr); + BLI_assert(new_id == nullptr || (GS(old_id->name) == GS(new_id->name))); + mappings.add_overwrite(old_id, new_id); + BLI_assert(BKE_idtype_idcode_to_idfilter(GS(old_id->name)) != 0); + source_types |= BKE_idtype_idcode_to_idfilter(GS(old_id->name)); + } + + bool contains_mappings_for_any(IDTypeFilter filter) const + { + return (source_types & filter) != 0; + } + + IDRemapperApplyResult get_mapping_result(ID *id, + IDRemapperApplyOptions options, + const ID *id_self) const + { + if (!mappings.contains(id)) { + return ID_REMAP_RESULT_SOURCE_UNAVAILABLE; + } + const ID *new_id = mappings.lookup(id); + if ((options & ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF) != 0 && id_self == new_id) { + new_id = nullptr; + } + if (new_id == nullptr) { + return ID_REMAP_RESULT_SOURCE_UNASSIGNED; + } + + return ID_REMAP_RESULT_SOURCE_REMAPPED; + } + + IDRemapperApplyResult apply(ID **r_id_ptr, IDRemapperApplyOptions options, ID *id_self) const + { + BLI_assert(r_id_ptr != nullptr); + if (*r_id_ptr == nullptr) { + return ID_REMAP_RESULT_SOURCE_NOT_MAPPABLE; + } + + if (!mappings.contains(*r_id_ptr)) { + return ID_REMAP_RESULT_SOURCE_UNAVAILABLE; + } + + if (options & ID_REMAP_APPLY_UPDATE_REFCOUNT) { + id_us_min(*r_id_ptr); + } + + *r_id_ptr = mappings.lookup(*r_id_ptr); + if (options & ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF && *r_id_ptr == id_self) { + *r_id_ptr = nullptr; + } + if (*r_id_ptr == nullptr) { + return ID_REMAP_RESULT_SOURCE_UNASSIGNED; + } + + if (options & ID_REMAP_APPLY_UPDATE_REFCOUNT) { + /* Do not handle LIB_TAG_INDIRECT/LIB_TAG_EXTERN here. */ + id_us_plus_no_lib(*r_id_ptr); + } + + if (options & ID_REMAP_APPLY_ENSURE_REAL) { + id_us_ensure_real(*r_id_ptr); + } + return ID_REMAP_RESULT_SOURCE_REMAPPED; + } + + void iter(IDRemapperIterFunction func, void *user_data) const + { + for (auto item : mappings.items()) { + func(item.key, item.value, user_data); + } + } +}; + +} // namespace blender::bke::id::remapper + +/** \brief wrap CPP IDRemapper to a C handle. */ +static IDRemapper *wrap(blender::bke::id::remapper::IDRemapper *remapper) { - BLI_assert(old_id != nullptr); - BLI_assert(new_id == nullptr || (GS(old_id->name) == GS(new_id->name))); - BLI_assert(BKE_idtype_idcode_to_idfilter(GS(old_id->name)) != 0); - - mappings_.add(old_id, new_id); - source_types_ |= BKE_idtype_idcode_to_idfilter(GS(old_id->name)); + return static_cast(static_cast(remapper)); } -void IDRemapper::add_overwrite(ID *old_id, ID *new_id) +/** \brief wrap C handle to a CPP IDRemapper. */ +static blender::bke::id::remapper::IDRemapper *unwrap(IDRemapper *remapper) { - BLI_assert(old_id != nullptr); - BLI_assert(new_id == nullptr || (GS(old_id->name) == GS(new_id->name))); - BLI_assert(BKE_idtype_idcode_to_idfilter(GS(old_id->name)) != 0); - - mappings_.add_overwrite(old_id, new_id); - source_types_ |= BKE_idtype_idcode_to_idfilter(GS(old_id->name)); + return static_cast(static_cast(remapper)); } -IDRemapperApplyResult IDRemapper::get_mapping_result(ID *id, - IDRemapperApplyOptions options, - const ID *id_self) const +/** \brief wrap C handle to a CPP IDRemapper. */ +static const blender::bke::id::remapper::IDRemapper *unwrap(const IDRemapper *remapper) { - if (!mappings_.contains(id)) { - return ID_REMAP_RESULT_SOURCE_UNAVAILABLE; - } - const ID *new_id = mappings_.lookup(id); - if ((options & ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF) != 0 && id_self == new_id) { - new_id = nullptr; - } - if (new_id == nullptr) { - return ID_REMAP_RESULT_SOURCE_UNASSIGNED; - } - - return ID_REMAP_RESULT_SOURCE_REMAPPED; + return static_cast( + static_cast(remapper)); } -IDRemapperApplyResult IDRemapper::apply(ID **r_id_ptr, - IDRemapperApplyOptions options, - ID *id_self) const +IDRemapper *BKE_id_remapper_create() { - BLI_assert(r_id_ptr != nullptr); - BLI_assert_msg( - ((options & ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF) == 0 || id_self != nullptr), - "ID_REMAP_APPLY_WHEN_REMAPPING_TO_SELF requires a non-null `id_self` parameter."); - - if (*r_id_ptr == nullptr) { - return ID_REMAP_RESULT_SOURCE_NOT_MAPPABLE; - } - - if (!mappings_.contains(*r_id_ptr)) { - return ID_REMAP_RESULT_SOURCE_UNAVAILABLE; - } - - if (options & ID_REMAP_APPLY_UPDATE_REFCOUNT) { - id_us_min(*r_id_ptr); - } - - *r_id_ptr = mappings_.lookup(*r_id_ptr); - if (options & ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF && *r_id_ptr == id_self) { - *r_id_ptr = nullptr; - } - if (*r_id_ptr == nullptr) { - return ID_REMAP_RESULT_SOURCE_UNASSIGNED; - } - - if (options & ID_REMAP_APPLY_UPDATE_REFCOUNT) { - /* Do not handle LIB_TAG_INDIRECT/LIB_TAG_EXTERN here. */ - id_us_plus_no_lib(*r_id_ptr); - } - - if (options & ID_REMAP_APPLY_ENSURE_REAL) { - id_us_ensure_real(*r_id_ptr); - } - return ID_REMAP_RESULT_SOURCE_REMAPPED; + blender::bke::id::remapper::IDRemapper *remapper = + MEM_new(__func__); + return wrap(remapper); } -const blender::StringRefNull IDRemapper::result_to_string(const IDRemapperApplyResult result) +void BKE_id_remapper_free(IDRemapper *id_remapper) +{ + blender::bke::id::remapper::IDRemapper *remapper = unwrap(id_remapper); + MEM_delete(remapper); +} + +void BKE_id_remapper_clear(IDRemapper *id_remapper) +{ + blender::bke::id::remapper::IDRemapper *remapper = unwrap(id_remapper); + remapper->clear(); +} + +bool BKE_id_remapper_is_empty(const IDRemapper *id_remapper) +{ + const blender::bke::id::remapper::IDRemapper *remapper = unwrap(id_remapper); + return remapper->is_empty(); +} + +void BKE_id_remapper_add(IDRemapper *id_remapper, ID *old_id, ID *new_id) +{ + blender::bke::id::remapper::IDRemapper *remapper = unwrap(id_remapper); + remapper->add(old_id, new_id); +} + +void BKE_id_remapper_add_overwrite(IDRemapper *id_remapper, ID *old_id, ID *new_id) +{ + blender::bke::id::remapper::IDRemapper *remapper = unwrap(id_remapper); + remapper->add_overwrite(old_id, new_id); +} + +bool BKE_id_remapper_has_mapping_for(const IDRemapper *id_remapper, uint64_t type_filter) +{ + const blender::bke::id::remapper::IDRemapper *remapper = unwrap(id_remapper); + return remapper->contains_mappings_for_any(type_filter); +} + +IDRemapperApplyResult BKE_id_remapper_get_mapping_result(const IDRemapper *id_remapper, + ID *id, + IDRemapperApplyOptions options, + const ID *id_self) +{ + const blender::bke::id::remapper::IDRemapper *remapper = unwrap(id_remapper); + return remapper->get_mapping_result(id, options, id_self); +} + +IDRemapperApplyResult BKE_id_remapper_apply_ex(const IDRemapper *id_remapper, + ID **r_id_ptr, + const IDRemapperApplyOptions options, + ID *id_self) +{ + BLI_assert_msg((options & ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF) == 0 || + id_self != nullptr, + "ID_REMAP_APPLY_WHEN_REMAPPING_TO_SELF requires id_self parameter."); + const blender::bke::id::remapper::IDRemapper *remapper = unwrap(id_remapper); + return remapper->apply(r_id_ptr, options, id_self); +} + +IDRemapperApplyResult BKE_id_remapper_apply(const IDRemapper *id_remapper, + ID **r_id_ptr, + const IDRemapperApplyOptions options) +{ + BLI_assert_msg((options & ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF) == 0, + "ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF requires id_self parameter. Use " + "`BKE_id_remapper_apply_ex`."); + return BKE_id_remapper_apply_ex(id_remapper, r_id_ptr, options, nullptr); +} + +void BKE_id_remapper_iter(const IDRemapper *id_remapper, + IDRemapperIterFunction func, + void *user_data) +{ + const blender::bke::id::remapper::IDRemapper *remapper = unwrap(id_remapper); + remapper->iter(func, user_data); +} + +const char *BKE_id_remapper_result_string(const IDRemapperApplyResult result) { switch (result) { case ID_REMAP_RESULT_SOURCE_NOT_MAPPABLE: @@ -101,22 +229,23 @@ const blender::StringRefNull IDRemapper::result_to_string(const IDRemapperApplyR return "unassigned"; case ID_REMAP_RESULT_SOURCE_REMAPPED: return "remapped"; + default: + BLI_assert_unreachable(); } - BLI_assert_unreachable(); return ""; } -void IDRemapper::print(void) const +static void id_remapper_print_item_cb(ID *old_id, ID *new_id, void * /*user_data*/) { - auto print_cb = [](ID *old_id, ID *new_id, void * /*user_data*/) { - if (old_id != nullptr && new_id != nullptr) { - printf("Remap %s(%p) to %s(%p)\n", old_id->name, old_id, new_id->name, new_id); - } - if (old_id != nullptr && new_id == nullptr) { - printf("Unassign %s(%p)\n", old_id->name, old_id); - } - }; - this->iter(print_cb, nullptr); + if (old_id != nullptr && new_id != nullptr) { + printf("Remap %s(%p) to %s(%p)\n", old_id->name, old_id, new_id->name, new_id); + } + if (old_id != nullptr && new_id == nullptr) { + printf("Unassign %s(%p)\n", old_id->name, old_id); + } } -} // namespace blender::bke::id +void BKE_id_remapper_print(const IDRemapper *id_remapper) +{ + BKE_id_remapper_iter(id_remapper, id_remapper_print_item_cb, nullptr); +} diff --git a/source/blender/blenkernel/intern/lib_id_remapper_test.cc b/source/blender/blenkernel/intern/lib_id_remapper_test.cc index 6c7eefa129c..b4928fafd6b 100644 --- a/source/blender/blenkernel/intern/lib_id_remapper_test.cc +++ b/source/blender/blenkernel/intern/lib_id_remapper_test.cc @@ -10,27 +10,29 @@ #include "DNA_ID.h" -using namespace blender::bke::id; - -namespace blender::bke::id::tests { +namespace blender::bke::id::remapper::tests { TEST(lib_id_remapper, unavailable) { ID id1; ID *idp = &id1; - IDRemapper remapper; - IDRemapperApplyResult result = remapper.apply(&idp, ID_REMAP_APPLY_DEFAULT); + IDRemapper *remapper = BKE_id_remapper_create(); + IDRemapperApplyResult result = BKE_id_remapper_apply(remapper, &idp, ID_REMAP_APPLY_DEFAULT); EXPECT_EQ(result, ID_REMAP_RESULT_SOURCE_UNAVAILABLE); + + BKE_id_remapper_free(remapper); } TEST(lib_id_remapper, not_mappable) { ID *idp = nullptr; - IDRemapper remapper; - IDRemapperApplyResult result = remapper.apply(&idp, ID_REMAP_APPLY_DEFAULT); + IDRemapper *remapper = BKE_id_remapper_create(); + IDRemapperApplyResult result = BKE_id_remapper_apply(remapper, &idp, ID_REMAP_APPLY_DEFAULT); EXPECT_EQ(result, ID_REMAP_RESULT_SOURCE_NOT_MAPPABLE); + + BKE_id_remapper_free(remapper); } TEST(lib_id_remapper, mapped) @@ -41,11 +43,13 @@ TEST(lib_id_remapper, mapped) STRNCPY(id1.name, "OB1"); STRNCPY(id2.name, "OB2"); - IDRemapper remapper; - remapper.add(&id1, &id2); - IDRemapperApplyResult result = remapper.apply(&idp, ID_REMAP_APPLY_DEFAULT); + IDRemapper *remapper = BKE_id_remapper_create(); + BKE_id_remapper_add(remapper, &id1, &id2); + IDRemapperApplyResult result = BKE_id_remapper_apply(remapper, &idp, ID_REMAP_APPLY_DEFAULT); EXPECT_EQ(result, ID_REMAP_RESULT_SOURCE_REMAPPED); EXPECT_EQ(idp, &id2); + + BKE_id_remapper_free(remapper); } TEST(lib_id_remapper, unassigned) @@ -54,11 +58,13 @@ TEST(lib_id_remapper, unassigned) ID *idp = &id1; STRNCPY(id1.name, "OB2"); - IDRemapper remapper; - remapper.add(&id1, nullptr); - IDRemapperApplyResult result = remapper.apply(&idp, ID_REMAP_APPLY_DEFAULT); + IDRemapper *remapper = BKE_id_remapper_create(); + BKE_id_remapper_add(remapper, &id1, nullptr); + IDRemapperApplyResult result = BKE_id_remapper_apply(remapper, &idp, ID_REMAP_APPLY_DEFAULT); EXPECT_EQ(result, ID_REMAP_RESULT_SOURCE_UNASSIGNED); EXPECT_EQ(idp, nullptr); + + BKE_id_remapper_free(remapper); } TEST(lib_id_remapper, unassign_when_mapped_to_self) @@ -74,28 +80,31 @@ TEST(lib_id_remapper, unassign_when_mapped_to_self) /* Default mapping behavior. Should just remap to id2. */ idp = &id1; - IDRemapper remapper; - remapper.add(&id1, &id2); - IDRemapperApplyResult result = remapper.apply( - &idp, ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF, &id_self); + IDRemapper *remapper = BKE_id_remapper_create(); + BKE_id_remapper_add(remapper, &id1, &id2); + IDRemapperApplyResult result = BKE_id_remapper_apply_ex( + remapper, &idp, ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF, &id_self); EXPECT_EQ(result, ID_REMAP_RESULT_SOURCE_REMAPPED); EXPECT_EQ(idp, &id2); /* Default mapping behavior. Should unassign. */ idp = &id1; - remapper.clear(); - remapper.add(&id1, nullptr); - result = remapper.apply(&idp, ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF, &id_self); + BKE_id_remapper_clear(remapper); + BKE_id_remapper_add(remapper, &id1, nullptr); + result = BKE_id_remapper_apply_ex( + remapper, &idp, ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF, &id_self); EXPECT_EQ(result, ID_REMAP_RESULT_SOURCE_UNASSIGNED); EXPECT_EQ(idp, nullptr); /* Unmap when remapping to self behavior. Should unassign. */ idp = &id1; - remapper.clear(); - remapper.add(&id1, &id_self); - result = remapper.apply(&idp, ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF, &id_self); + BKE_id_remapper_clear(remapper); + BKE_id_remapper_add(remapper, &id1, &id_self); + result = BKE_id_remapper_apply_ex( + remapper, &idp, ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF, &id_self); EXPECT_EQ(result, ID_REMAP_RESULT_SOURCE_UNASSIGNED); EXPECT_EQ(idp, nullptr); + BKE_id_remapper_free(remapper); } -} // namespace blender::bke::id::tests +} // namespace blender::bke::id::remapper::tests diff --git a/source/blender/blenkernel/intern/lib_override.cc b/source/blender/blenkernel/intern/lib_override.cc index ac8fa836bae..96981a5c45b 100644 --- a/source/blender/blenkernel/intern/lib_override.cc +++ b/source/blender/blenkernel/intern/lib_override.cc @@ -27,10 +27,10 @@ #include "BKE_anim_data.h" #include "BKE_armature.hh" -#include "BKE_blender.hh" -#include "BKE_collection.hh" +#include "BKE_blender.h" +#include "BKE_collection.h" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_key.hh" #include "BKE_layer.hh" @@ -41,10 +41,10 @@ #include "BKE_main.hh" #include "BKE_main_namemap.hh" #include "BKE_node.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "BLI_ghash.h" #include "BLI_linklist.h" @@ -72,8 +72,6 @@ # include "BLI_time_utildefines.h" #endif -using namespace blender::bke; - static CLG_LogRef LOG = {"bke.liboverride"}; static CLG_LogRef LOG_RESYNC = {"bke.liboverride_resync"}; @@ -489,11 +487,11 @@ static void lib_override_prefill_newid_from_existing_overrides(Main *bmain, ID * FOREACH_MAIN_ID_END; } -static void lib_override_remapper_overrides_add(id::IDRemapper &id_remapper, +static void lib_override_remapper_overrides_add(IDRemapper *id_remapper, ID *reference_id, ID *local_id) { - id_remapper.add(reference_id, local_id); + BKE_id_remapper_add(id_remapper, reference_id, local_id); Key *reference_key, *local_key = nullptr; if ((reference_key = BKE_key_from_id(reference_id)) != nullptr) { @@ -502,7 +500,7 @@ static void lib_override_remapper_overrides_add(id::IDRemapper &id_remapper, BLI_assert(local_key != nullptr); } - id_remapper.add(&reference_key->id, &local_key->id); + BKE_id_remapper_add(id_remapper, &reference_key->id, &local_key->id); } } @@ -622,7 +620,7 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, BLI_assert(id_hierarchy_root != nullptr); blender::Vector relinked_ids; - id::IDRemapper id_remapper; + IDRemapper *id_remapper = BKE_id_remapper_create(); /* Still checking the whole Main, that way we can tag other local IDs as needing to be * remapped to use newly created overriding IDs, if needed. */ ID *id; @@ -695,6 +693,7 @@ bool BKE_lib_override_library_create_from_tag(Main *bmain, id_remapper, ID_REMAP_SKIP_OVERRIDE_LIBRARY | ID_REMAP_FORCE_USER_REFCOUNT); + BKE_id_remapper_free(id_remapper); relinked_ids.clear(); } else { @@ -1935,7 +1934,7 @@ static void lib_override_library_remap(Main *bmain, GHash *linkedref_to_old_override) { ID *id; - id::IDRemapper remapper; + IDRemapper *remapper = BKE_id_remapper_create(); blender::Vector nomain_ids; FOREACH_MAIN_ID_BEGIN (bmain, id) { @@ -1945,7 +1944,7 @@ static void lib_override_library_remap(Main *bmain, if (id_override_old == nullptr) { continue; } - remapper.add(id_override_old, id_override_new); + BKE_id_remapper_add(remapper, id_override_old, id_override_new); } } FOREACH_MAIN_ID_END; @@ -1969,6 +1968,7 @@ static void lib_override_library_remap(Main *bmain, ID_REMAP_TYPE_REMAP, remapper, ID_REMAP_FORCE_USER_REFCOUNT | ID_REMAP_FORCE_NEVER_NULL_USAGE); + BKE_id_remapper_free(remapper); } /** @@ -2515,7 +2515,7 @@ static bool lib_override_library_resync(Main *bmain, /* Once overrides have been properly 'transferred' from old to new ID, we can clear ID usages * of the old one. * This is necessary in case said old ID is not in Main anymore. */ - id::IDRemapper id_remapper; + IDRemapper *id_remapper = BKE_id_remapper_create(); BKE_libblock_relink_multiple(bmain, id_override_old_vector, ID_REMAP_TYPE_CLEANUP, @@ -2525,6 +2525,7 @@ static bool lib_override_library_resync(Main *bmain, id_override_old->tag |= LIB_TAG_NO_USER_REFCOUNT; } id_override_old_vector.clear(); + BKE_id_remapper_free(id_remapper); /* Delete old override IDs. * Note that we have to use tagged group deletion here, since ID deletion also uses @@ -3176,7 +3177,7 @@ static bool lib_override_library_main_resync_on_library_indirect_level( BlendFileReadReport *reports) { const bool do_reports_recursive_resync_timing = (library_indirect_level != 0); - const double init_time = do_reports_recursive_resync_timing ? BLI_time_now_seconds() : 0.0; + const double init_time = do_reports_recursive_resync_timing ? BLI_check_seconds_timer() : 0.0; BKE_main_relations_create(bmain, 0); BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); @@ -3482,7 +3483,7 @@ static bool lib_override_library_main_resync_on_library_indirect_level( BKE_lib_override_library_main_hierarchy_root_ensure(bmain); if (do_reports_recursive_resync_timing) { - reports->duration.lib_overrides_recursive_resync += BLI_time_now_seconds() - init_time; + reports->duration.lib_overrides_recursive_resync += BLI_check_seconds_timer() - init_time; } return process_lib_level_again; @@ -4178,7 +4179,7 @@ void BKE_lib_override_library_validate(Main * /*bmain*/, ID *id, ReportList *rep /* NOTE: In code deleting liboverride data below, #BKE_lib_override_library_make_local is used * instead of directly calling #BKE_lib_override_library_free, because the former also handles - * properly 'liboverride embedded' IDs, like root node-trees, or shape-keys. */ + * properly 'liboverride embedded' IDs, like root nodetrees, or shapekeys. */ if (id->override_library->reference == nullptr) { /* This (probably) used to be a template ID, could be linked or local, not an override. */ diff --git a/source/blender/blenkernel/intern/lib_override_proxy_conversion.cc b/source/blender/blenkernel/intern/lib_override_proxy_conversion.cc index 9355e389181..133aeeebabc 100644 --- a/source/blender/blenkernel/intern/lib_override_proxy_conversion.cc +++ b/source/blender/blenkernel/intern/lib_override_proxy_conversion.cc @@ -22,13 +22,13 @@ #include "DEG_depsgraph.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_override.hh" #include "BKE_main.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" static CLG_LogRef LOG = {"bke.liboverride_proxy_conversion"}; diff --git a/source/blender/blenkernel/intern/lib_query.cc b/source/blender/blenkernel/intern/lib_query.cc index 9c480626022..4a70cef8629 100644 --- a/source/blender/blenkernel/intern/lib_query.cc +++ b/source/blender/blenkernel/intern/lib_query.cc @@ -13,7 +13,6 @@ #include "BLI_ghash.h" #include "BLI_linklist_stack.h" #include "BLI_listbase.h" -#include "BLI_set.hh" #include "BLI_utildefines.h" #include "BKE_anim_data.h" @@ -22,7 +21,7 @@ #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_main.hh" -#include "BKE_node.hh" +#include "BKE_node.h" /* status */ enum { @@ -396,24 +395,28 @@ void BKE_library_update_ID_link_user(ID *id_dst, ID *id_src, const int cb_flag) } } -uint64_t BKE_library_id_can_use_filter_id(const ID *owner_id, - const bool include_ui, - const IDTypeInfo *owner_id_type) +uint64_t BKE_library_id_can_use_filter_id(const ID *owner_id, const bool include_ui) { /* any type of ID can be used in custom props. */ if (owner_id->properties) { return FILTER_ID_ALL; } - /* When including UI data (i.e. editors), Screen UI IDs can also link to virtually any ID - * (through e.g. the Outliner). */ - if (include_ui && GS(owner_id->name) == ID_SCR) { + const short id_type_owner = GS(owner_id->name); + + /* IDProps of armature bones and nodes, and bNode->id can use virtually any type of ID. */ + if (ELEM(id_type_owner, ID_NT, ID_AR)) { + return FILTER_ID_ALL; + } + + /* Screen UI IDs can also link to virtually any ID (through e.g. the Outliner). */ + if (include_ui && id_type_owner == ID_SCR) { return FILTER_ID_ALL; } /* Casting to non const. * TODO(jbakker): We should introduce a ntree_id_has_tree function as we are actually not * interested in the result. */ - if (ntreeFromID(const_cast(owner_id))) { + if (ntreeFromID((ID *)owner_id)) { return FILTER_ID_ALL; } @@ -427,21 +430,118 @@ uint64_t BKE_library_id_can_use_filter_id(const ID *owner_id, return FILTER_ID_ALL; } - if (!owner_id_type) { - owner_id_type = BKE_idtype_get_info_from_id(owner_id); - } - if (owner_id_type) { - return owner_id_type->dependencies_id_types; + switch ((ID_Type)id_type_owner) { + case ID_LI: + return FILTER_ID_LI; + case ID_SCE: + return FILTER_ID_OB | FILTER_ID_WO | FILTER_ID_SCE | FILTER_ID_MC | FILTER_ID_MA | + FILTER_ID_GR | FILTER_ID_TXT | FILTER_ID_LS | FILTER_ID_MSK | FILTER_ID_SO | + FILTER_ID_GD_LEGACY | FILTER_ID_BR | FILTER_ID_PAL | FILTER_ID_IM | FILTER_ID_NT; + case ID_OB: + /* Could be more specific, but simpler to just always say 'yes' here. */ + return FILTER_ID_ALL; + case ID_ME: + return FILTER_ID_ME | FILTER_ID_MA | FILTER_ID_IM | FILTER_ID_KE; + case ID_CU_LEGACY: + return FILTER_ID_OB | FILTER_ID_MA | FILTER_ID_VF | FILTER_ID_KE; + case ID_MB: + return FILTER_ID_MA; + case ID_MA: + return FILTER_ID_TE | FILTER_ID_GR; + case ID_TE: + return FILTER_ID_IM | FILTER_ID_OB; + case ID_LT: + return FILTER_ID_KE; + case ID_LA: + return FILTER_ID_TE; + case ID_CA: + return FILTER_ID_OB | FILTER_ID_IM; + case ID_KE: + /* Warning! key->from, could be more types in future? */ + return FILTER_ID_ME | FILTER_ID_CU_LEGACY | FILTER_ID_LT; + case ID_SCR: + return FILTER_ID_SCE; + case ID_WO: + return FILTER_ID_TE; + case ID_SPK: + return FILTER_ID_SO; + case ID_GR: + return FILTER_ID_OB | FILTER_ID_GR; + case ID_NT: + /* Could be more specific, but node.id has no type restriction... */ + return FILTER_ID_ALL; + case ID_BR: + return FILTER_ID_BR | FILTER_ID_IM | FILTER_ID_PC | FILTER_ID_TE | FILTER_ID_MA; + case ID_PA: + return FILTER_ID_OB | FILTER_ID_GR | FILTER_ID_TE; + case ID_MC: + return FILTER_ID_GD_LEGACY | FILTER_ID_IM; + case ID_MSK: + /* WARNING! mask->parent.id, not typed. */ + return FILTER_ID_MC; + case ID_LS: + return FILTER_ID_TE | FILTER_ID_OB; + case ID_LP: + return FILTER_ID_IM; + case ID_GD_LEGACY: + return FILTER_ID_MA; + case ID_GP: + return FILTER_ID_GP | FILTER_ID_MA; + case ID_WS: + return FILTER_ID_SCE; + case ID_CV: + return FILTER_ID_MA | FILTER_ID_OB; + case ID_PT: + return FILTER_ID_MA; + case ID_VO: + return FILTER_ID_MA; + case ID_WM: + return FILTER_ID_SCE | FILTER_ID_WS; + case ID_IM: + case ID_VF: + case ID_TXT: + case ID_SO: + case ID_AR: + case ID_AC: + case ID_PAL: + case ID_PC: + case ID_CF: + /* Those types never use/reference other IDs... */ + return 0; + case ID_IP: + /* Deprecated... */ + return 0; } + BLI_assert_unreachable(); return 0; } bool BKE_library_id_can_use_idtype(ID *owner_id, const short id_type_used) { - const IDTypeInfo *owner_id_type = BKE_idtype_get_info_from_id(owner_id); + /* any type of ID can be used in custom props. */ + if (owner_id->properties) { + return true; + } + + const short id_type_owner = GS(owner_id->name); + /* Exception for ID_LI as they don't exist as a filter. */ + if (id_type_used == ID_LI) { + return id_type_owner == ID_LI; + } + + /* Exception: ID_KE aren't available as filter_id. */ + if (id_type_used == ID_KE) { + return ELEM(id_type_owner, ID_ME, ID_CU_LEGACY, ID_LT); + } + + /* Exception: ID_SCR aren't available as filter_id. */ + if (id_type_used == ID_SCR) { + return ELEM(id_type_owner, ID_WS); + } + const uint64_t filter_id_type_used = BKE_idtype_idcode_to_idfilter(id_type_used); - const uint64_t can_be_used = BKE_library_id_can_use_filter_id(owner_id, false, owner_id_type); + const uint64_t can_be_used = BKE_library_id_can_use_filter_id(owner_id, false); return (can_be_used & filter_id_type_used) != 0; } @@ -592,73 +692,20 @@ void BKE_library_ID_test_usages(Main *bmain, /* ***** IDs usages.checking/tagging. ***** */ -/* Internal data for the common processing of the 'unused IDs' query functions. - * - * While #LibQueryUnusedIDsData is a subset of this internal struct, they need to be kept separate, - * since this struct is used with partially 'enforced' values for some parameters by the - * #BKE_lib_query_unused_ids_amounts code. This allows the computation of predictive amounts for - * user feedback ('what would be the amounts of IDs detected as unused if this option was - * enabled'). - */ -struct UnusedIdsData { - Main *bmain; - - const int id_tag; - - bool do_local_ids; - bool do_linked_ids; - bool do_recursive; - - std::array *num_total; - std::array *num_local; - std::array *num_linked; - - blender::Set unused_ids{}; - - void reset(const bool do_local_ids, - const bool do_linked_ids, - const bool do_recursive, - std::array &num_total, - std::array &num_local, - std::array &num_linked) - { - unused_ids.clear(); - this->do_local_ids = do_local_ids; - this->do_linked_ids = do_linked_ids; - this->do_recursive = do_recursive; - this->num_total = &num_total; - this->num_local = &num_local; - this->num_linked = &num_linked; - } -}; - -static void lib_query_unused_ids_tag_id(ID *id, UnusedIdsData &data) -{ - id->tag |= data.id_tag; - data.unused_ids.add(id); - - const int id_code = BKE_idtype_idcode_to_index(GS(id->name)); - (*data.num_total)[INDEX_ID_NULL]++; - (*data.num_total)[id_code]++; - if (ID_IS_LINKED(id)) { - (*data.num_linked)[INDEX_ID_NULL]++; - (*data.num_linked)[id_code]++; - } - else { - (*data.num_local)[INDEX_ID_NULL]++; - (*data.num_local)[id_code]++; - } -} - /* Returns `true` if given ID is detected as part of at least one dependency loop, false otherwise. */ -static bool lib_query_unused_ids_tag_recurse(ID *id, UnusedIdsData &data) +static bool lib_query_unused_ids_tag_recurse(Main *bmain, + const int tag, + const bool do_local_ids, + const bool do_linked_ids, + ID *id, + int *r_num_tagged) { /* We should never deal with embedded, not-in-main IDs here. */ BLI_assert((id->flag & LIB_EMBEDDED_DATA) == 0); MainIDRelationsEntry *id_relations = static_cast( - BLI_ghash_lookup(data.bmain->relations->relations_from_pointers, id)); + BLI_ghash_lookup(bmain->relations->relations_from_pointers, id)); if ((id_relations->tags & MAINIDRELATIONS_ENTRY_TAGS_PROCESSED) != 0) { return false; @@ -669,12 +716,12 @@ static bool lib_query_unused_ids_tag_recurse(ID *id, UnusedIdsData &data) return true; } - if ((!data.do_linked_ids && ID_IS_LINKED(id)) || (!data.do_local_ids && !ID_IS_LINKED(id))) { + if ((!do_linked_ids && ID_IS_LINKED(id)) || (!do_local_ids && !ID_IS_LINKED(id))) { id_relations->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED; return false; } - if (data.unused_ids.contains(id)) { + if ((id->tag & tag) != 0) { id_relations->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED; return false; } @@ -732,20 +779,26 @@ static bool lib_query_unused_ids_tag_recurse(ID *id, UnusedIdsData &data) BLI_assert(id_from != nullptr); } - if (lib_query_unused_ids_tag_recurse(id_from, data)) { + if (lib_query_unused_ids_tag_recurse( + bmain, tag, do_local_ids, do_linked_ids, id_from, r_num_tagged)) + { /* Dependency loop case, ignore the `id_from` tag value here (as it should not be considered * as valid yet), and presume that this is a 'valid user' case for now. */ is_part_of_dependency_loop = true; continue; } - if (!data.unused_ids.contains(id_from)) { + if ((id_from->tag & tag) == 0) { has_valid_from_users = true; break; } } if (!has_valid_from_users && !is_part_of_dependency_loop) { /* Tag the ID as unused, only in case it is not part of a dependency loop. */ - lib_query_unused_ids_tag_id(id, data); + id->tag |= tag; + if (r_num_tagged != nullptr) { + r_num_tagged[INDEX_ID_NULL]++; + r_num_tagged[BKE_idtype_idcode_to_index(GS(id->name))]++; + } } /* This ID is not being processed anymore. @@ -764,33 +817,42 @@ static bool lib_query_unused_ids_tag_recurse(ID *id, UnusedIdsData &data) return is_part_of_dependency_loop; } -static void lib_query_unused_ids_tag(UnusedIdsData &data) +void BKE_lib_query_unused_ids_tag(Main *bmain, + const int tag, + const bool do_local_ids, + const bool do_linked_ids, + const bool do_tag_recursive, + int *r_num_tagged) { - BKE_main_relations_tag_set(data.bmain, MAINIDRELATIONS_ENTRY_TAGS_PROCESSED, false); - /* First loop, to only check for immediately unused IDs (those with 0 user count). * NOTE: It also takes care of clearing given tag for used IDs. */ ID *id; - FOREACH_MAIN_ID_BEGIN (data.bmain, id) { - if ((!data.do_linked_ids && ID_IS_LINKED(id)) || (!data.do_local_ids && !ID_IS_LINKED(id))) { - id->tag &= ~data.id_tag; + FOREACH_MAIN_ID_BEGIN (bmain, id) { + if ((!do_linked_ids && ID_IS_LINKED(id)) || (!do_local_ids && !ID_IS_LINKED(id))) { + id->tag &= ~tag; } else if (id->us == 0) { - lib_query_unused_ids_tag_id(id, data); + id->tag |= tag; + if (r_num_tagged != nullptr) { + r_num_tagged[INDEX_ID_NULL]++; + r_num_tagged[BKE_idtype_idcode_to_index(GS(id->name))]++; + } } else { - id->tag &= ~data.id_tag; + id->tag &= ~tag; } } FOREACH_MAIN_ID_END; - if (!data.do_recursive) { + if (!do_tag_recursive) { return; } - BLI_assert(data.bmain->relations != nullptr); - FOREACH_MAIN_ID_BEGIN (data.bmain, id) { - if (lib_query_unused_ids_tag_recurse(id, data)) { + BKE_main_relations_create(bmain, 0); + FOREACH_MAIN_ID_BEGIN (bmain, id) { + if (lib_query_unused_ids_tag_recurse( + bmain, tag, do_local_ids, do_linked_ids, id, r_num_tagged)) + { /* This root processed ID is part of one or more dependency loops. * * If it was not tagged, and its matching relations entry is not marked as processed, it @@ -799,12 +861,16 @@ static void lib_query_unused_ids_tag(UnusedIdsData &data) * relations to the current Blender file (like being part of a scene, etc.). * * So the entry can be tagged as processed, and the ID tagged as unused. */ - if (!data.unused_ids.contains(id)) { + if ((id->tag & tag) == 0) { MainIDRelationsEntry *id_relations = static_cast( - BLI_ghash_lookup(data.bmain->relations->relations_from_pointers, id)); + BLI_ghash_lookup(bmain->relations->relations_from_pointers, id)); if ((id_relations->tags & MAINIDRELATIONS_ENTRY_TAGS_PROCESSED) == 0) { id_relations->tags |= MAINIDRELATIONS_ENTRY_TAGS_PROCESSED; - lib_query_unused_ids_tag_id(id, data); + id->tag |= tag; + if (r_num_tagged != nullptr) { + r_num_tagged[INDEX_ID_NULL]++; + r_num_tagged[BKE_idtype_idcode_to_index(GS(id->name))]++; + } } } } @@ -812,97 +878,15 @@ static void lib_query_unused_ids_tag(UnusedIdsData &data) #ifndef NDEBUG /* Relation entry for the root processed ID should always be marked as processed now. */ MainIDRelationsEntry *id_relations = static_cast( - BLI_ghash_lookup(data.bmain->relations->relations_from_pointers, id)); - BLI_assert((id_relations->tags & MAINIDRELATIONS_ENTRY_TAGS_PROCESSED) != 0); + BLI_ghash_lookup(bmain->relations->relations_from_pointers, id)); + if ((id_relations->tags & MAINIDRELATIONS_ENTRY_TAGS_PROCESSED) == 0) { + BLI_assert((id_relations->tags & MAINIDRELATIONS_ENTRY_TAGS_PROCESSED) != 0); + } BLI_assert((id_relations->tags & MAINIDRELATIONS_ENTRY_TAGS_INPROGRESS) == 0); #endif } FOREACH_MAIN_ID_END; -} - -void BKE_lib_query_unused_ids_amounts(Main *bmain, LibQueryUnusedIDsData ¶meters) -{ - std::array num_dummy{0}; - if (parameters.do_recursive) { - BKE_main_relations_create(bmain, 0); - } - - parameters.num_total.fill(0); - parameters.num_local.fill(0); - parameters.num_linked.fill(0); - - /* The complex fiddling with the two calls, which data they each get, based on the `do_local_ids` - * and `do_linked_ids`, is here to reduce as much as possible the extra processing: - * - * If both local and linked options are enabled, a single call with all given parameters gives - * all required data about unused IDs. - * - * If both local and linked options are disabled, total amount is left at zero, and each local - * and linked amounts are computed separately. - * - * If local is disabled and linked is enabled, the first call will compute the amount of local - * IDs that would be unused if the local option was enabled. Therefore, only the local amount can - * be kept from this call. The second call will compute valid values for both linked, and total - * data. - * - * If local is enabled and linked is disabled, the first call will compute valid values for both - * local, and total data. The second call will compute the amount of linked IDs that would be - * unused if the linked option was enabled. Therefore, only the linked amount can be kept from - * this call. - */ - - UnusedIdsData data{ - bmain, - 0, - true, - parameters.do_linked_ids, - parameters.do_recursive, - parameters.do_local_ids ? ¶meters.num_total : &num_dummy, - ¶meters.num_local, - (parameters.do_local_ids && parameters.do_linked_ids) ? ¶meters.num_linked : &num_dummy}; - lib_query_unused_ids_tag(data); - - if (!(parameters.do_local_ids && parameters.do_linked_ids)) { - /* In case a second run is required, clear runtime data and update settings for linked data. */ - data.reset(parameters.do_local_ids, - true, - parameters.do_recursive, - (!parameters.do_local_ids && parameters.do_linked_ids) ? parameters.num_total : - num_dummy, - num_dummy, - parameters.num_linked); - lib_query_unused_ids_tag(data); - } - - if (parameters.do_recursive) { - BKE_main_relations_free(bmain); - } -} - -void BKE_lib_query_unused_ids_tag(Main *bmain, const int tag, LibQueryUnusedIDsData ¶meters) -{ - BLI_assert(tag != 0); - - parameters.num_total.fill(0); - parameters.num_local.fill(0); - parameters.num_linked.fill(0); - - UnusedIdsData data{bmain, - tag, - parameters.do_local_ids, - parameters.do_linked_ids, - parameters.do_recursive, - ¶meters.num_total, - ¶meters.num_local, - ¶meters.num_linked}; - - if (parameters.do_recursive) { - BKE_main_relations_create(bmain, 0); - } - lib_query_unused_ids_tag(data); - if (parameters.do_recursive) { - BKE_main_relations_free(bmain); - } + BKE_main_relations_free(bmain); } static int foreach_libblock_used_linked_data_tag_clear_cb(LibraryIDLinkCallbackData *cb_data) diff --git a/source/blender/blenkernel/intern/lib_remap.cc b/source/blender/blenkernel/intern/lib_remap.cc index f48d5a9da3b..0fc9df39fc8 100644 --- a/source/blender/blenkernel/intern/lib_remap.cc +++ b/source/blender/blenkernel/intern/lib_remap.cc @@ -18,7 +18,7 @@ #include "DNA_object_types.h" #include "BKE_armature.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_curve.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" @@ -29,7 +29,7 @@ #include "BKE_mball.hh" #include "BKE_modifier.hh" #include "BKE_multires.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BKE_node_tree_update.hh" #include "BKE_object.hh" @@ -38,8 +38,6 @@ #include "lib_intern.hh" /* own include */ -using namespace blender::bke::id; - static CLG_LogRef LOG = {"bke.lib_remap"}; BKE_library_free_notifier_reference_cb free_notifier_reference_cb = nullptr; @@ -61,7 +59,7 @@ struct IDRemap { eIDRemapType type; Main *bmain; /* Only used to trigger depsgraph updates in the right bmain. */ - IDRemapper &id_remapper; + IDRemapper *id_remapper; /** The ID in which we are replacing old_id by new_id usages. */ ID *id_owner; @@ -105,7 +103,7 @@ static void foreach_libblock_remap_callback_apply(ID *id_owner, ID *id_self, ID **id_ptr, IDRemap *id_remap_data, - const IDRemapper &mappings, + const IDRemapper *mappings, const IDRemapperApplyOptions id_remapper_options, const int cb_flag, const bool is_indirect, @@ -118,7 +116,7 @@ static void foreach_libblock_remap_callback_apply(ID *id_owner, ID *old_id = *id_ptr; if (!violates_never_null) { - mappings.apply(id_ptr, id_remapper_options, id_self); + BKE_id_remapper_apply_ex(mappings, id_ptr, id_remapper_options, id_self); if (!skip_update_tagging) { if (id_remap_data->bmain != nullptr) { DEG_id_tag_update_ex(id_remap_data->bmain, @@ -197,15 +195,15 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) return IDWALK_RET_NOP; } - IDRemapper &id_remapper = id_remap_data->id_remapper; + IDRemapper *id_remapper = id_remap_data->id_remapper; IDRemapperApplyOptions id_remapper_options = ID_REMAP_APPLY_DEFAULT; /* Used to cleanup all IDs used by a specific one. */ if (id_remap_data->type == ID_REMAP_TYPE_CLEANUP) { /* Clearing existing instance to reduce potential lookup times for IDs referencing many other * IDs. This makes sure that there will only be a single rule in the id_remapper. */ - id_remapper.clear(); - id_remapper.add(*id_p, nullptr); + BKE_id_remapper_clear(id_remapper); + BKE_id_remapper_add(id_remapper, *id_p, nullptr); } /* Better remap to nullptr than not remapping at all, @@ -214,8 +212,8 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) id_remapper_options |= ID_REMAP_APPLY_UNMAP_WHEN_REMAPPING_TO_SELF; } - const IDRemapperApplyResult expected_mapping_result = id_remapper.get_mapping_result( - *id_p, id_remapper_options, id_self); + const IDRemapperApplyResult expected_mapping_result = BKE_id_remapper_get_mapping_result( + id_remapper, *id_p, id_remapper_options, id_self); /* Exit, when no modifications will be done; ensuring id->runtime counters won't changed. */ if (ELEM(expected_mapping_result, ID_REMAP_RESULT_SOURCE_UNAVAILABLE, @@ -249,18 +247,15 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) id_owner->lib, (*id_p)->name, *id_p, - id_remapper.result_to_string(expected_mapping_result).c_str(), + BKE_id_remapper_result_string(expected_mapping_result), is_indirect, skip_indirect, is_reference, skip_reference); #endif - if ((id_remap_data->flag & ID_REMAP_STORE_NEVER_NULL_USAGE) && - (cb_flag & IDWALK_CB_NEVER_NULL) && - (expected_mapping_result == ID_REMAP_RESULT_SOURCE_UNASSIGNED)) - { - id_remapper.never_null_users_add(id_owner); + if ((id_remap_data->flag & ID_REMAP_FLAG_NEVER_NULL_USAGE) && (cb_flag & IDWALK_CB_NEVER_NULL)) { + id_owner->tag |= LIB_TAG_DOIT; } /* Special hack in case it's Object->data and we are in edit mode, and new_id is not nullptr @@ -297,7 +292,7 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data) static void libblock_remap_data_preprocess_ob(Object *ob, eIDRemapType remap_type, - const IDRemapper &id_remapper) + const IDRemapper *id_remapper) { if (ob->type != OB_ARMATURE) { return; @@ -308,7 +303,7 @@ static void libblock_remap_data_preprocess_ob(Object *ob, const bool is_cleanup_type = remap_type == ID_REMAP_TYPE_CLEANUP; /* Early exit when mapping, but no armature mappings present. */ - if (!is_cleanup_type && !id_remapper.contains_mappings_for_any(FILTER_ID_AR)) { + if (!is_cleanup_type && !BKE_id_remapper_has_mapping_for(id_remapper, FILTER_ID_AR)) { return; } @@ -318,8 +313,8 @@ static void libblock_remap_data_preprocess_ob(Object *ob, * Fortunately, this is just a tag, so we can accept to 'over-tag' a bit for pose recalc, * and avoid another complex and risky condition nightmare like the one we have in * foreach_libblock_remap_callback(). */ - const IDRemapperApplyResult expected_mapping_result = id_remapper.get_mapping_result( - static_cast(ob->data), ID_REMAP_APPLY_DEFAULT, nullptr); + const IDRemapperApplyResult expected_mapping_result = BKE_id_remapper_get_mapping_result( + id_remapper, static_cast(ob->data), ID_REMAP_APPLY_DEFAULT, nullptr); if (is_cleanup_type || expected_mapping_result == ID_REMAP_RESULT_SOURCE_REMAPPED) { ob->pose->flag |= POSE_RECALC; /* We need to clear pose bone pointers immediately, some code may access those before @@ -330,7 +325,7 @@ static void libblock_remap_data_preprocess_ob(Object *ob, static void libblock_remap_data_preprocess(ID *id_owner, eIDRemapType remap_type, - const IDRemapper &id_remapper) + const IDRemapper *id_remapper) { switch (GS(id_owner->name)) { case ID_OB: { @@ -488,16 +483,9 @@ static void libblock_remap_reset_remapping_status_callback(ID *old_id, * (useful to retrieve info about remapping process). */ static void libblock_remap_data( - Main *bmain, ID *id, eIDRemapType remap_type, IDRemapper &id_remapper, const int remap_flags) + Main *bmain, ID *id, eIDRemapType remap_type, IDRemapper *id_remapper, const int remap_flags) { - IDRemap id_remap_data = { - /*.type=*/remap_type, - /*.bmain=*/bmain, - /*.id_remapper=*/id_remapper, - /*.id_owner=*/nullptr, - /*.flag=*/remap_flags, - }; - + IDRemap id_remap_data = {eIDRemapType(0)}; const bool include_ui = (remap_flags & ID_REMAP_FORCE_UI_POINTERS) != 0; const int foreach_id_flags = (((remap_flags & ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS) != 0 ? IDWALK_DO_INTERNAL_RUNTIME_POINTERS : @@ -511,7 +499,13 @@ static void libblock_remap_data( IDWALK_DO_LIBRARY_POINTER : IDWALK_NOP)); - id_remapper.iter(libblock_remap_reset_remapping_status_callback, nullptr); + id_remap_data.id_remapper = id_remapper; + id_remap_data.type = remap_type; + id_remap_data.bmain = bmain; + id_remap_data.id_owner = nullptr; + id_remap_data.flag = remap_flags; + + BKE_id_remapper_iter(id_remapper, libblock_remap_reset_remapping_status_callback, nullptr); if (id) { #ifdef DEBUG_PRINT @@ -530,7 +524,7 @@ static void libblock_remap_data( FOREACH_MAIN_ID_BEGIN (bmain, id_curr) { const uint64_t can_use_filter_id = BKE_library_id_can_use_filter_id(id_curr, include_ui); - const bool has_mapping = id_remapper.contains_mappings_for_any(can_use_filter_id); + const bool has_mapping = BKE_id_remapper_has_mapping_for(id_remapper, can_use_filter_id); /* Continue when id_remapper doesn't have any mappings that can be used by id_curr. */ if (!has_mapping) { @@ -550,7 +544,7 @@ static void libblock_remap_data( FOREACH_MAIN_ID_END; } - id_remapper.iter(libblock_remap_data_update_tags, &id_remap_data); + BKE_id_remapper_iter(id_remapper, libblock_remap_data_update_tags, &id_remap_data); } struct LibBlockRemapMultipleUserData { @@ -651,9 +645,9 @@ static void libblock_remap_foreach_idpair_cb(ID *old_id, ID *new_id, void *user_ BKE_libblock_runtime_reset_remapping_status(old_id); } -void BKE_libblock_remap_multiple_locked(Main *bmain, IDRemapper &mappings, const int remap_flags) +void BKE_libblock_remap_multiple_locked(Main *bmain, IDRemapper *mappings, const int remap_flags) { - if (mappings.is_empty()) { + if (BKE_id_remapper_is_empty(mappings)) { /* Early exit nothing to do. */ return; } @@ -664,7 +658,7 @@ void BKE_libblock_remap_multiple_locked(Main *bmain, IDRemapper &mappings, const user_data.bmain = bmain; user_data.remap_flags = remap_flags; - mappings.iter(libblock_remap_foreach_idpair_cb, &user_data); + BKE_id_remapper_iter(mappings, libblock_remap_foreach_idpair_cb, &user_data); /* We assume editors do not hold references to their IDs... This is false in some cases * (Image is especially tricky here), @@ -677,9 +671,9 @@ void BKE_libblock_remap_multiple_locked(Main *bmain, IDRemapper &mappings, const DEG_relations_tag_update(bmain); } -void BKE_libblock_remap_multiple_raw(Main *bmain, IDRemapper &mappings, const int remap_flags) +void BKE_libblock_remap_multiple_raw(Main *bmain, IDRemapper *mappings, const int remap_flags) { - if (mappings.is_empty()) { + if (BKE_id_remapper_is_empty(mappings)) { /* Early exit nothing to do. */ return; } @@ -693,11 +687,12 @@ void BKE_libblock_remap_multiple_raw(Main *bmain, IDRemapper &mappings, const in void BKE_libblock_remap_locked(Main *bmain, void *old_idv, void *new_idv, const int remap_flags) { - IDRemapper remapper; + IDRemapper *remapper = BKE_id_remapper_create(); ID *old_id = static_cast(old_idv); ID *new_id = static_cast(new_idv); - remapper.add(old_id, new_id); + BKE_id_remapper_add(remapper, old_id, new_id); BKE_libblock_remap_multiple_locked(bmain, remapper, remap_flags); + BKE_id_remapper_free(remapper); } void BKE_libblock_remap(Main *bmain, void *old_idv, void *new_idv, const int remap_flags) @@ -709,7 +704,7 @@ void BKE_libblock_remap(Main *bmain, void *old_idv, void *new_idv, const int rem BKE_main_unlock(bmain); } -void BKE_libblock_remap_multiple(Main *bmain, IDRemapper &mappings, const int remap_flags) +void BKE_libblock_remap_multiple(Main *bmain, IDRemapper *mappings, const int remap_flags) { BKE_main_lock(bmain); @@ -718,9 +713,13 @@ void BKE_libblock_remap_multiple(Main *bmain, IDRemapper &mappings, const int re BKE_main_unlock(bmain); } -void BKE_libblock_unlink(Main *bmain, void *idv, const bool do_skip_indirect) +void BKE_libblock_unlink(Main *bmain, + void *idv, + const bool do_flag_never_null, + const bool do_skip_indirect) { - const int remap_flags = (do_skip_indirect ? ID_REMAP_SKIP_INDIRECT_USAGE : 0); + const int remap_flags = (do_skip_indirect ? ID_REMAP_SKIP_INDIRECT_USAGE : 0) | + (do_flag_never_null ? ID_REMAP_FLAG_NEVER_NULL_USAGE : 0); BKE_main_lock(bmain); @@ -799,10 +798,10 @@ static void libblock_relink_foreach_idpair_cb(ID *old_id, ID *new_id, void *user void BKE_libblock_relink_multiple(Main *bmain, const blender::Span ids, const eIDRemapType remap_type, - IDRemapper &id_remapper, + IDRemapper *id_remapper, const int remap_flags) { - BLI_assert(remap_type == ID_REMAP_TYPE_REMAP || id_remapper.is_empty()); + BLI_assert(remap_type == ID_REMAP_TYPE_REMAP || BKE_id_remapper_is_empty(id_remapper)); for (ID *id_iter : ids) { libblock_remap_data(bmain, id_iter, remap_type, id_remapper, remap_flags); @@ -816,7 +815,7 @@ void BKE_libblock_relink_multiple(Main *bmain, case ID_REMAP_TYPE_REMAP: { LibBlockRelinkMultipleUserData user_data = {bmain, ids}; - id_remapper.iter(libblock_relink_foreach_idpair_cb, &user_data); + BKE_id_remapper_iter(id_remapper, libblock_relink_foreach_idpair_cb, &user_data); break; } case ID_REMAP_TYPE_CLEANUP: { @@ -870,7 +869,7 @@ void BKE_libblock_relink_ex( blender::Array ids = {id}; /* No need to lock here, we are only affecting given ID, not bmain database. */ - IDRemapper id_remapper; + IDRemapper *id_remapper = BKE_id_remapper_create(); eIDRemapType remap_type = ID_REMAP_TYPE_REMAP; BLI_assert(id != nullptr); @@ -878,7 +877,7 @@ void BKE_libblock_relink_ex( if (old_id != nullptr) { BLI_assert((new_id == nullptr) || GS(old_id->name) == GS(new_id->name)); BLI_assert(old_id != new_id); - id_remapper.add(old_id, new_id); + BKE_id_remapper_add(id_remapper, old_id, new_id); } else { BLI_assert(new_id == nullptr); @@ -886,11 +885,13 @@ void BKE_libblock_relink_ex( } BKE_libblock_relink_multiple(bmain, ids, remap_type, id_remapper, remap_flags); + + BKE_id_remapper_free(id_remapper); } struct RelinkToNewIDData { blender::Vector ids; - IDRemapper id_remapper; + IDRemapper *id_remapper; }; static void libblock_relink_to_newid_prepare_data(Main *bmain, @@ -907,12 +908,12 @@ static int id_relink_to_newid_looper(LibraryIDLinkCallbackData *cb_data) Main *bmain = cb_data->bmain; ID **id_pointer = cb_data->id_pointer; ID *id = *id_pointer; - RelinkToNewIDData *relink_data = static_cast(cb_data->user_data); + RelinkToNewIDData *relink_data = (RelinkToNewIDData *)cb_data->user_data; if (id) { /* See: NEW_ID macro */ if (id->newid != nullptr) { - relink_data->id_remapper.add(id, id->newid); + BKE_id_remapper_add(relink_data->id_remapper, id, id->newid); id = id->newid; } if (id->tag & LIB_TAG_NEW) { @@ -944,6 +945,7 @@ void BKE_libblock_relink_to_newid(Main *bmain, ID *id, const int remap_flag) BLI_assert(bmain->relations == nullptr); RelinkToNewIDData relink_data{}; + relink_data.id_remapper = BKE_id_remapper_create(); libblock_relink_to_newid_prepare_data(bmain, id, &relink_data); @@ -951,4 +953,6 @@ void BKE_libblock_relink_to_newid(Main *bmain, ID *id, const int remap_flag) ID_REMAP_SKIP_OVERRIDE_LIBRARY; BKE_libblock_relink_multiple( bmain, relink_data.ids, ID_REMAP_TYPE_REMAP, relink_data.id_remapper, remap_flag_final); + + BKE_id_remapper_free(relink_data.id_remapper); } diff --git a/source/blender/blenkernel/intern/lib_remap_test.cc b/source/blender/blenkernel/intern/lib_remap_test.cc index c284fc66a36..a4bb0100094 100644 --- a/source/blender/blenkernel/intern/lib_remap_test.cc +++ b/source/blender/blenkernel/intern/lib_remap_test.cc @@ -16,7 +16,7 @@ #include "BKE_appdir.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_remap.hh" @@ -24,7 +24,7 @@ #include "BKE_mesh.hh" #include "BKE_node.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "IMB_imbuf.hh" @@ -32,8 +32,6 @@ #include "MEM_guardedalloc.h" -using namespace blender::bke::id; - namespace blender::bke::tests { class TestData { @@ -300,7 +298,7 @@ TEST(lib_remap, never_null_usage_flag_not_requested_on_delete) EXPECT_EQ(context.test_data.object->id.tag & LIB_TAG_DOIT, 0); } -TEST(lib_remap, never_null_usage_storage_requested_on_delete) +TEST(lib_remap, never_null_usage_flag_requested_on_delete) { Context context; @@ -308,19 +306,14 @@ TEST(lib_remap, never_null_usage_storage_requested_on_delete) EXPECT_EQ(context.test_data.object->data, context.test_data.mesh); EXPECT_EQ(context.test_data.object->id.tag & LIB_TAG_DOIT, 0); - /* Never null usage is requested so the owner ID (the Object) should be added to the set. */ - IDRemapper remapper; - remapper.add(&context.test_data.mesh->id, nullptr); - BKE_libblock_remap_multiple_locked( - context.test_data.bmain, - remapper, - (ID_REMAP_SKIP_NEVER_NULL_USAGE | ID_REMAP_STORE_NEVER_NULL_USAGE)); - - /* Never null usages un-assignment is not enforced (no #ID_REMAP_FORCE_NEVER_NULL_USAGE), - * so the object-data should still use the original mesh. */ + /* Never null usage is requested so the flag should be set. */ + BKE_libblock_remap(context.test_data.bmain, + context.test_data.mesh, + nullptr, + ID_REMAP_SKIP_NEVER_NULL_USAGE | ID_REMAP_FLAG_NEVER_NULL_USAGE); EXPECT_EQ(context.test_data.object->data, context.test_data.mesh); EXPECT_NE(context.test_data.object->data, nullptr); - EXPECT_TRUE(remapper.never_null_users().contains(&context.test_data.object->id)); + EXPECT_EQ(context.test_data.object->id.tag & LIB_TAG_DOIT, LIB_TAG_DOIT); } TEST(lib_remap, never_null_usage_flag_not_requested_on_remap) @@ -339,7 +332,7 @@ TEST(lib_remap, never_null_usage_flag_not_requested_on_remap) EXPECT_EQ(context.test_data.object->id.tag & LIB_TAG_DOIT, 0); } -TEST(lib_remap, never_null_usage_storage_requested_on_remap) +TEST(lib_remap, never_null_usage_flag_requested_on_remap) { Context context; Mesh *other_mesh = BKE_mesh_add(context.test_data.bmain, nullptr); @@ -348,16 +341,13 @@ TEST(lib_remap, never_null_usage_storage_requested_on_remap) EXPECT_EQ(context.test_data.object->data, context.test_data.mesh); EXPECT_EQ(context.test_data.object->id.tag & LIB_TAG_DOIT, 0); - /* Never null usage is requested, but the obdata is remapped to another Mesh, not to `nullptr`, - * so the `never_null_users` set should remain empty. */ - IDRemapper remapper; - remapper.add(&context.test_data.mesh->id, &other_mesh->id); - BKE_libblock_remap_multiple_locked( - context.test_data.bmain, - remapper, - (ID_REMAP_SKIP_NEVER_NULL_USAGE | ID_REMAP_STORE_NEVER_NULL_USAGE)); + /* Never null usage is requested so the flag should be set. */ + BKE_libblock_remap(context.test_data.bmain, + context.test_data.mesh, + other_mesh, + ID_REMAP_SKIP_NEVER_NULL_USAGE | ID_REMAP_FLAG_NEVER_NULL_USAGE); EXPECT_EQ(context.test_data.object->data, other_mesh); - EXPECT_TRUE(remapper.never_null_users().is_empty()); + EXPECT_EQ(context.test_data.object->id.tag & LIB_TAG_DOIT, LIB_TAG_DOIT); } /** \} */ diff --git a/source/blender/blenkernel/intern/library.cc b/source/blender/blenkernel/intern/library.cc index 8ed3c30fb1a..5b5970fa102 100644 --- a/source/blender/blenkernel/intern/library.cc +++ b/source/blender/blenkernel/intern/library.cc @@ -8,6 +8,10 @@ * Contains code specific to the `Library` ID type. */ +#include "CLG_log.h" + +#include "MEM_guardedalloc.h" + /* all types are needed here, in order to do memory operations */ #include "DNA_ID.h" @@ -15,10 +19,11 @@ #include "BLI_blenlib.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" -#include "BKE_bpath.hh" +#include "BKE_bpath.h" #include "BKE_idtype.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_library.hh" #include "BKE_main.hh" @@ -81,7 +86,6 @@ static void library_blend_read_data(BlendDataReader * /*reader*/, ID *id) IDTypeInfo IDType_ID_LI = { /*id_code*/ ID_LI, /*id_filter*/ FILTER_ID_LI, - /*dependencies_id_types*/ FILTER_ID_LI, /*main_listbase_index*/ INDEX_ID_LI, /*struct_size*/ sizeof(Library), /*name*/ "Library", diff --git a/source/blender/blenkernel/intern/light.cc b/source/blender/blenkernel/intern/light.cc index 7a17c5e0e29..e09eceb2dbf 100644 --- a/source/blender/blenkernel/intern/light.cc +++ b/source/blender/blenkernel/intern/light.cc @@ -13,23 +13,28 @@ /* Allow using deprecated functionality for .blend file I/O. */ #define DNA_DEPRECATED_ALLOW +#include "DNA_anim_types.h" #include "DNA_defaults.h" #include "DNA_light_types.h" +#include "DNA_material_types.h" #include "DNA_node_types.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_texture_types.h" #include "BLI_utildefines.h" +#include "BKE_anim_data.h" #include "BKE_icons.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_light.h" -#include "BKE_node.hh" +#include "BKE_main.hh" +#include "BKE_node.h" #include "BKE_preview_image.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph.hh" @@ -152,7 +157,6 @@ static void light_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_LA = { /*id_code*/ ID_LA, /*id_filter*/ FILTER_ID_LA, - /*dependencies_id_types*/ FILTER_ID_TE, /*main_listbase_index*/ INDEX_ID_LA, /*struct_size*/ sizeof(Light), /*name*/ "Light", diff --git a/source/blender/blenkernel/intern/light_linking.cc b/source/blender/blenkernel/intern/light_linking.cc index 6951591be09..4d8b5c660e4 100644 --- a/source/blender/blenkernel/intern/light_linking.cc +++ b/source/blender/blenkernel/intern/light_linking.cc @@ -16,12 +16,12 @@ #include "BLI_assert.h" #include "BLI_string.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" -#include "BKE_report.hh" +#include "BKE_report.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" diff --git a/source/blender/blenkernel/intern/lightprobe.cc b/source/blender/blenkernel/intern/lightprobe.cc index dc1fe1bd011..a91dea3537a 100644 --- a/source/blender/blenkernel/intern/lightprobe.cc +++ b/source/blender/blenkernel/intern/lightprobe.cc @@ -17,12 +17,14 @@ #include "BLI_span.hh" #include "BLI_utildefines.h" +#include "BKE_anim_data.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_lightprobe.h" +#include "BKE_main.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLO_read_write.hh" @@ -53,7 +55,6 @@ static void lightprobe_blend_write(BlendWriter *writer, ID *id, const void *id_a IDTypeInfo IDType_ID_LP = { /*id_code*/ ID_LP, /*id_filter*/ FILTER_ID_LP, - /*dependencies_id_types*/ FILTER_ID_IM, /*main_listbase_index*/ INDEX_ID_LP, /*struct_size*/ sizeof(LightProbe), /*name*/ "LightProbe", diff --git a/source/blender/blenkernel/intern/linestyle.cc b/source/blender/blenkernel/intern/linestyle.cc index 1891d7d7383..7eb4e081232 100644 --- a/source/blender/blenkernel/intern/linestyle.cc +++ b/source/blender/blenkernel/intern/linestyle.cc @@ -23,8 +23,9 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "BKE_anim_data.h" #include "BKE_colorband.hh" #include "BKE_colortools.hh" #include "BKE_context.hh" @@ -33,6 +34,7 @@ #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_linestyle.h" +#include "BKE_main.hh" #include "BKE_node.hh" #include "BKE_node_tree_update.hh" #include "BKE_texture.h" @@ -643,7 +645,6 @@ static void linestyle_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_LS = { /*id_code*/ ID_LS, /*id_filter*/ FILTER_ID_LS, - /*dependencies_id_types*/ FILTER_ID_TE | FILTER_ID_OB, /*main_listbase_index*/ INDEX_ID_LS, /*struct_size*/ sizeof(FreestyleLineStyle), /*name*/ "FreestyleLineStyle", diff --git a/source/blender/blenkernel/intern/main.cc b/source/blender/blenkernel/intern/main.cc index 29c379aea31..ae4d61fe5bb 100644 --- a/source/blender/blenkernel/intern/main.cc +++ b/source/blender/blenkernel/intern/main.cc @@ -24,8 +24,8 @@ #include "DNA_ID.h" -#include "BKE_bpath.hh" -#include "BKE_global.hh" +#include "BKE_bpath.h" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" @@ -33,13 +33,11 @@ #include "BKE_main.hh" #include "BKE_main_idmap.hh" #include "BKE_main_namemap.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" -using namespace blender::bke; - static CLG_LogRef LOG = {"bke.main"}; Main *BKE_main_new() @@ -260,7 +258,7 @@ static bool are_ids_from_different_mains_matching(Main *bmain_1, ID *id_1, Main static void main_merge_add_id_to_move(Main *bmain_dst, blender::Map> &id_map_dst, ID *id_src, - id::IDRemapper &id_remapper, + IDRemapper *id_remapper, blender::Vector &ids_to_move, const bool is_library, MainMergeReport &reports) @@ -289,7 +287,7 @@ static void main_merge_add_id_to_move(Main *bmain_dst, "found in given destination Main", id_src->name, bmain_dst->filepath); - id_remapper.add(id_src, nullptr); + BKE_id_remapper_add(id_remapper, id_src, nullptr); reports.num_unknown_ids++; } else { @@ -323,8 +321,8 @@ void BKE_main_merge(Main *bmain_dst, Main **r_bmain_src, MainMergeReport &report /* A dedicated remapper for libraries is needed because these need to be remapped _before_ IDs * are moved from `bmain_src` to `bmain_dst`, to avoid having to fix naming and ordering of IDs * afterwards (especially in case some source linked IDs become local in `bmain_dst`). */ - id::IDRemapper id_remapper; - id::IDRemapper id_remapper_libraries; + IDRemapper *id_remapper = BKE_id_remapper_create(); + IDRemapper *id_remapper_libraries = BKE_id_remapper_create(); blender::Vector ids_to_move; FOREACH_MAIN_ID_BEGIN (bmain_src, id_iter_src) { @@ -349,11 +347,11 @@ void BKE_main_merge(Main *bmain_dst, Main **r_bmain_src, MainMergeReport &report BLI_assert(!src_has_match_in_dst); if (!src_has_match_in_dst) { if (is_library) { - id_remapper_libraries.add(id_iter_src, id_iter_dst); + BKE_id_remapper_add(id_remapper_libraries, id_iter_src, id_iter_dst); reports.num_remapped_libraries++; } else { - id_remapper.add(id_iter_src, id_iter_dst); + BKE_id_remapper_add(id_remapper, id_iter_src, id_iter_dst); reports.num_remapped_ids++; } src_has_match_in_dst = true; @@ -428,6 +426,8 @@ void BKE_main_merge(Main *bmain_dst, Main **r_bmain_src, MainMergeReport &report BLI_assert(BKE_main_namemap_validate(bmain_dst)); + BKE_id_remapper_free(id_remapper); + BKE_id_remapper_free(id_remapper_libraries); BKE_main_free(bmain_src); *r_bmain_src = nullptr; } diff --git a/source/blender/blenkernel/intern/main_idmap.cc b/source/blender/blenkernel/intern/main_idmap.cc index ec70c8f0192..8fd262ed4c7 100644 --- a/source/blender/blenkernel/intern/main_idmap.cc +++ b/source/blender/blenkernel/intern/main_idmap.cc @@ -8,6 +8,7 @@ #include "MEM_guardedalloc.h" #include "BLI_ghash.h" +#include "BLI_listbase.h" #include "BLI_mempool.h" #include "BLI_utildefines.h" diff --git a/source/blender/blenkernel/intern/main_test.cc b/source/blender/blenkernel/intern/main_test.cc index b35280e4171..9c83a46e85f 100644 --- a/source/blender/blenkernel/intern/main_test.cc +++ b/source/blender/blenkernel/intern/main_test.cc @@ -11,7 +11,7 @@ #include "BLI_path_util.h" #include "BLI_string.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_library.hh" diff --git a/source/blender/blenkernel/intern/mask.cc b/source/blender/blenkernel/intern/mask.cc index 8947144bd8c..4119d577179 100644 --- a/source/blender/blenkernel/intern/mask.cc +++ b/source/blender/blenkernel/intern/mask.cc @@ -23,7 +23,7 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mask_types.h" @@ -184,7 +184,6 @@ static void mask_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_MSK = { /*id_code*/ ID_MSK, /*id_filter*/ FILTER_ID_MSK, - /*dependencies_id_types*/ FILTER_ID_MC, /* WARNING! mask->parent.id, not typed. */ /*main_listbase_index*/ INDEX_ID_MSK, /*struct_size*/ sizeof(Mask), /*name*/ "Mask", diff --git a/source/blender/blenkernel/intern/mask_rasterize.cc b/source/blender/blenkernel/intern/mask_rasterize.cc index 1c6c6554a6e..5a71d941d36 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.cc +++ b/source/blender/blenkernel/intern/mask_rasterize.cc @@ -71,7 +71,7 @@ #include "BKE_mask.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* this is rather and annoying hack, use define to isolate it. * problem is caused by scanfill removing edges on us. */ diff --git a/source/blender/blenkernel/intern/material.cc b/source/blender/blenkernel/intern/material.cc index a40e1892311..7c79cb46268 100644 --- a/source/blender/blenkernel/intern/material.cc +++ b/source/blender/blenkernel/intern/material.cc @@ -42,7 +42,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_anim_data.h" #include "BKE_attribute.hh" @@ -65,7 +65,7 @@ #include "BKE_object.hh" #include "BKE_object_types.hh" #include "BKE_preview_image.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_vfont.hh" #include "DEG_depsgraph.hh" @@ -231,7 +231,6 @@ static void material_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_MA = { /*id_code*/ ID_MA, /*id_filter*/ FILTER_ID_MA, - /*dependencies_id_types*/ FILTER_ID_TE | FILTER_ID_GR, /*main_listbase_index*/ INDEX_ID_MA, /*struct_size*/ sizeof(Material), /*name*/ "Material", diff --git a/source/blender/blenkernel/intern/mball.cc b/source/blender/blenkernel/intern/mball.cc index 8628846a5b5..35155663890 100644 --- a/source/blender/blenkernel/intern/mball.cc +++ b/source/blender/blenkernel/intern/mball.cc @@ -28,26 +28,33 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_blenlib.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" #include "BLI_math_vector.h" #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_main.hh" +#include "BKE_anim_data.h" +#include "BKE_curve.hh" +#include "BKE_displist.h" #include "BKE_geometry_set.hh" #include "BKE_idtype.hh" #include "BKE_lattice.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_material.h" #include "BKE_mball.hh" #include "BKE_mball_tessellate.hh" +#include "BKE_mesh.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" @@ -140,7 +147,6 @@ static void metaball_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_MB = { /*id_code*/ ID_MB, /*id_filter*/ FILTER_ID_MB, - /*dependencies_id_types*/ FILTER_ID_MA, /*main_listbase_index*/ INDEX_ID_MB, /*struct_size*/ sizeof(MetaBall), /*name*/ "Metaball", diff --git a/source/blender/blenkernel/intern/mball_tessellate.cc b/source/blender/blenkernel/intern/mball_tessellate.cc index b4548913e4b..11e2c999c8f 100644 --- a/source/blender/blenkernel/intern/mball_tessellate.cc +++ b/source/blender/blenkernel/intern/mball_tessellate.cc @@ -19,6 +19,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_listbase.h" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" @@ -28,16 +29,18 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BKE_global.hh" +#include "BKE_displist.h" +#include "BKE_global.h" +#include "BKE_lib_id.hh" #include "BKE_mball_tessellate.hh" /* own include */ #include "BKE_mesh.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* experimental (faster) normal calculation (see #103021) */ #define USE_ACCUM_NORMAL @@ -1178,10 +1181,9 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje const eEvaluationMode deg_eval_mode = DEG_get_mode(depsgraph); const short parenting_dupli_transflag = (OB_DUPLIFACES | OB_DUPLIVERTS); - copy_m4_m4( - obmat, - ob->object_to_world().ptr()); /* to cope with duplicators from BKE_scene_base_iter_next */ - invert_m4_m4(obinv, ob->object_to_world().ptr()); + copy_m4_m4(obmat, + ob->object_to_world); /* to cope with duplicators from BKE_scene_base_iter_next */ + invert_m4_m4(obinv, ob->object_to_world); BLI_string_split_name_number(ob->id.name + 2, '.', obname, &obnr); @@ -1230,13 +1232,13 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje /* when metaball object has zero scale, then MetaElem to this MetaBall * will not be put to mainb array */ - if (has_zero_axis_m4(bob->object_to_world().ptr())) { + if (has_zero_axis_m4(bob->object_to_world)) { zero_size = 1; } else if (bob->parent) { Object *pob = bob->parent; while (pob) { - if (has_zero_axis_m4(pob->object_to_world().ptr())) { + if (has_zero_axis_m4(pob->object_to_world)) { zero_size = 1; break; } @@ -1300,7 +1302,7 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje * rotation -> * ml local space */ - mul_m4_series((float(*)[4])new_ml->mat, obinv, bob->object_to_world().ptr(), pos, rot); + mul_m4_series((float(*)[4])new_ml->mat, obinv, bob->object_to_world, pos, rot); /* ml local space -> basis object space */ invert_m4_m4((float(*)[4])new_ml->imat, (float(*)[4])new_ml->mat); diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index 4d89baea12a..1d08cc667ad 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -40,16 +40,16 @@ #include "BLI_vector.hh" #include "BLI_virtual_array.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_anim_data.h" #include "BKE_attribute.hh" #include "BKE_bake_data_block_id.hh" -#include "BKE_bpath.hh" +#include "BKE_bpath.h" #include "BKE_deform.hh" #include "BKE_editmesh.hh" #include "BKE_editmesh_cache.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_key.hh" #include "BKE_lib_id.hh" @@ -96,7 +96,7 @@ static void mesh_init_data(ID *id) mesh->runtime = new blender::bke::MeshRuntime(); - mesh->face_sets_color_seed = BLI_hash_int(BLI_time_now_seconds_i() & UINT_MAX); + mesh->face_sets_color_seed = BLI_hash_int(BLI_check_seconds_timer_i() & UINT_MAX); } static void mesh_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int flag) @@ -383,7 +383,6 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_ME = { /*id_code*/ ID_ME, /*id_filter*/ FILTER_ID_ME, - /*dependencies_id_types*/ FILTER_ID_ME | FILTER_ID_MA | FILTER_ID_IM | FILTER_ID_KE, /*main_listbase_index*/ INDEX_ID_ME, /*struct_size*/ sizeof(Mesh), /*name*/ "Mesh", @@ -703,26 +702,6 @@ Mesh *BKE_mesh_new_nomain(const int verts_num, return mesh; } -namespace blender::bke { - -Mesh *mesh_new_no_attributes(const int verts_num, - const int edges_num, - const int faces_num, - const int corners_num) -{ - Mesh *mesh = BKE_mesh_new_nomain(0, 0, faces_num, 0); - mesh->verts_num = verts_num; - mesh->edges_num = edges_num; - mesh->corners_num = corners_num; - CustomData_free_layer_named(&mesh->vert_data, "position", 0); - CustomData_free_layer_named(&mesh->edge_data, ".edge_verts", 0); - CustomData_free_layer_named(&mesh->corner_data, ".corner_vert", 0); - CustomData_free_layer_named(&mesh->corner_data, ".corner_edge", 0); - return mesh; -} - -} // namespace blender::bke - static void copy_attribute_names(const Mesh &mesh_src, Mesh &mesh_dst) { if (mesh_src.active_color_attribute) { diff --git a/source/blender/blenkernel/intern/mesh_boolean_convert.cc b/source/blender/blenkernel/intern/mesh_boolean_convert.cc index 3bac225f7f8..c0d7fce42b9 100644 --- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc +++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc @@ -8,8 +8,11 @@ #include +#include "DNA_object_types.h" + #include "BKE_attribute.hh" #include "BKE_customdata.hh" +#include "BKE_material.h" #include "BKE_mesh.hh" #include "BKE_mesh_boolean_convert.hh" diff --git a/source/blender/blenkernel/intern/mesh_compare.cc b/source/blender/blenkernel/intern/mesh_compare.cc index d88ef1f1c48..9f45cf41170 100644 --- a/source/blender/blenkernel/intern/mesh_compare.cc +++ b/source/blender/blenkernel/intern/mesh_compare.cc @@ -132,9 +132,6 @@ static void sort_indices(MutableSpan indices, const Span values, const i const float4 value2_quat = float4(value2); return value1_quat[component_i] < value2_quat[component_i]; } - if constexpr (std::is_same_v) { - return value1.base_ptr()[component_i] < value2.base_ptr()[component_i]; - } if constexpr (std::is_same_v) { for (int i = 0; i < 2; i++) { if (value1[i] != value2[i]) { @@ -251,10 +248,6 @@ static bool values_different(const T value1, const float4 value2_f = float4(value2); return compare_threshold_relative(value1_f[component_i], value2_f[component_i], threshold); } - if constexpr (std::is_same_v) { - return compare_threshold_relative( - value1.base_ptr()[component_i], value2.base_ptr()[component_i], threshold); - } BLI_assert_unreachable(); } @@ -582,9 +575,6 @@ static std::optional sort_domain_using_attributes( else if constexpr (is_same_any_v) { num_loops = 4; } - else if constexpr (is_same_any_v) { - num_loops = 16; - } for (const int component_i : IndexRange(num_loops)) { sort_per_set_based_on_attributes( maps.set_sizes, maps.from_sorted1, maps.from_sorted2, values1, values2, component_i); diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index 8d6b842e81b..e6a9825b0c7 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -24,7 +24,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_DerivedMesh.hh" #include "BKE_curves.hh" diff --git a/source/blender/blenkernel/intern/mesh_evaluate.cc b/source/blender/blenkernel/intern/mesh_evaluate.cc index 16c3e5ff00c..2e5cd85bf07 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.cc +++ b/source/blender/blenkernel/intern/mesh_evaluate.cc @@ -14,8 +14,11 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" +#include "DNA_object_types.h" +#include "BLI_alloca.h" #include "BLI_array_utils.hh" +#include "BLI_bitmap.h" #include "BLI_index_range.hh" #include "BLI_math_geom.h" #include "BLI_span.hh" @@ -23,7 +26,9 @@ #include "BLI_virtual_array.hh" #include "BKE_attribute.hh" +#include "BKE_customdata.hh" #include "BKE_mesh.hh" +#include "BKE_multires.hh" using blender::float3; using blender::int2; diff --git a/source/blender/blenkernel/intern/mesh_fair.cc b/source/blender/blenkernel/intern/mesh_fair.cc index 6cf321646c8..1c11cea840c 100644 --- a/source/blender/blenkernel/intern/mesh_fair.cc +++ b/source/blender/blenkernel/intern/mesh_fair.cc @@ -13,10 +13,16 @@ #include "BLI_math_vector.h" #include "BLI_vector.hh" +#include "DNA_object_types.h" + +#include "BKE_lib_id.hh" +#include "BKE_lib_query.hh" #include "BKE_mesh.hh" #include "BKE_mesh_fair.hh" +#include "BKE_mesh_mapping.hh" #include "bmesh.hh" +#include "bmesh_tools.hh" #include "MEM_guardedalloc.h" #include "eigen_capi.h" diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index 8765eb3a798..89d13d608f2 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -26,13 +26,14 @@ #include "BLI_memarena.h" #include "BLI_multi_value_map.hh" #include "BLI_polyfill_2d.h" +#include "BLI_resource_scope.hh" #include "BLI_string.h" #include "BLI_task.hh" #include "BLI_utildefines.h" #include "BKE_attribute.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.hh" #include "BKE_main.hh" #include "BKE_mesh.hh" @@ -40,9 +41,10 @@ #include "BKE_modifier.hh" #include "BKE_multires.hh" #include "BKE_node.hh" +#include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" using blender::MutableSpan; using blender::Span; @@ -1710,7 +1712,7 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh) for (const int i : uv_names.index_range()) { const MLoopUV *mloopuv = static_cast( - CustomData_get_layer_named(&mesh->corner_data, CD_MLOOPUV, uv_names[i])); + CustomData_get_layer_named(&mesh->corner_data, CD_MLOOPUV, uv_names[i].c_str())); const uint32_t needed_boolean_attributes = threading::parallel_reduce( IndexRange(mesh->corners_num), 4096, @@ -1761,13 +1763,13 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh) } }); - CustomData_free_layer_named(&mesh->corner_data, uv_names[i], mesh->corners_num); + CustomData_free_layer_named(&mesh->corner_data, uv_names[i].c_str(), mesh->corners_num); const std::string new_name = BKE_id_attribute_calc_unique_name(mesh->id, uv_names[i].c_str()); uv_names[i] = new_name; CustomData_add_layer_named_with_data( - &mesh->corner_data, CD_PROP_FLOAT2, coords, mesh->corners_num, new_name, nullptr); + &mesh->corner_data, CD_PROP_FLOAT2, coords, mesh->corners_num, new_name.c_str(), nullptr); char buffer[MAX_CUSTOMDATA_LAYER_NAME]; if (vert_selection) { CustomData_add_layer_named_with_data( @@ -1798,18 +1800,18 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh) } if (active_name_i != -1) { - CustomData_set_layer_active_index(&mesh->corner_data, - CD_PROP_FLOAT2, - CustomData_get_named_layer_index(&mesh->corner_data, - CD_PROP_FLOAT2, - uv_names[active_name_i])); + CustomData_set_layer_active_index( + &mesh->corner_data, + CD_PROP_FLOAT2, + CustomData_get_named_layer_index( + &mesh->corner_data, CD_PROP_FLOAT2, uv_names[active_name_i].c_str())); } if (default_name_i != -1) { - CustomData_set_layer_render_index(&mesh->corner_data, - CD_PROP_FLOAT2, - CustomData_get_named_layer_index(&mesh->corner_data, - CD_PROP_FLOAT2, - uv_names[default_name_i])); + CustomData_set_layer_render_index( + &mesh->corner_data, + CD_PROP_FLOAT2, + CustomData_get_named_layer_index( + &mesh->corner_data, CD_PROP_FLOAT2, uv_names[default_name_i].c_str())); } } diff --git a/source/blender/blenkernel/intern/mesh_mapping.cc b/source/blender/blenkernel/intern/mesh_mapping.cc index 2f9d500950c..daeb3ce7b24 100644 --- a/source/blender/blenkernel/intern/mesh_mapping.cc +++ b/source/blender/blenkernel/intern/mesh_mapping.cc @@ -27,7 +27,7 @@ #include "BKE_mesh_mapping.hh" #include "BLI_memarena.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* -------------------------------------------------------------------- */ /** \name Mesh Connectivity Mapping diff --git a/source/blender/blenkernel/intern/mesh_merge_customdata.cc b/source/blender/blenkernel/intern/mesh_merge_customdata.cc index c76389578f3..25c605b51e5 100644 --- a/source/blender/blenkernel/intern/mesh_merge_customdata.cc +++ b/source/blender/blenkernel/intern/mesh_merge_customdata.cc @@ -14,8 +14,10 @@ #include "BKE_customdata.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_mapping.hh" +#include "BLI_memarena.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" using namespace blender; diff --git a/source/blender/blenkernel/intern/mesh_mirror.cc b/source/blender/blenkernel/intern/mesh_mirror.cc index 3c99f214875..5b96ef07928 100644 --- a/source/blender/blenkernel/intern/mesh_mirror.cc +++ b/source/blender/blenkernel/intern/mesh_mirror.cc @@ -17,6 +17,7 @@ #include "BKE_attribute.hh" #include "BKE_deform.hh" #include "BKE_lib_id.hh" +#include "BKE_lib_query.hh" #include "BKE_mesh.hh" #include "BKE_mesh_mirror.hh" #include "BKE_modifier.hh" @@ -26,6 +27,8 @@ #include "MEM_guardedalloc.h" +#include "MOD_modifiertypes.hh" + Mesh *BKE_mesh_mirror_bisect_on_mirror_plane_for_modifier(MirrorModifierData *mmd, const Mesh *mesh, int axis, @@ -145,8 +148,8 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd, /* tmp is a transform from coords relative to the object's own origin, * to coords relative to the mirror object origin */ - invert_m4_m4(tmp, mirror_ob->object_to_world().ptr()); - mul_m4_m4m4(tmp, tmp, ob->object_to_world().ptr()); + invert_m4_m4(tmp, mirror_ob->object_to_world); + mul_m4_m4m4(tmp, tmp, ob->object_to_world); /* itmp is the reverse transform back to origin-relative coordinates */ invert_m4_m4(itmp, tmp); @@ -162,9 +165,9 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd, /* Account for non-uniform scale in `ob`, see: #87592. */ float ob_scale[3] = { - len_squared_v3(ob->object_to_world().ptr()[0]), - len_squared_v3(ob->object_to_world().ptr()[1]), - len_squared_v3(ob->object_to_world().ptr()[2]), + len_squared_v3(ob->object_to_world[0]), + len_squared_v3(ob->object_to_world[1]), + len_squared_v3(ob->object_to_world[2]), }; /* Scale to avoid precision loss with extreme values. */ const float ob_scale_max = max_fff(UNPACK3(ob_scale)); diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc index 974b0815e17..4519dd72e47 100644 --- a/source/blender/blenkernel/intern/mesh_normals.cc +++ b/source/blender/blenkernel/intern/mesh_normals.cc @@ -25,14 +25,18 @@ #include "BLI_memarena.h" #include "BLI_span.hh" #include "BLI_task.hh" +#include "BLI_timeit.hh" #include "BLI_utildefines.h" #include "BKE_attribute.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_editmesh_cache.hh" +#include "BKE_global.h" #include "BKE_mesh.hh" #include "BKE_mesh_mapping.hh" +#include "atomic_ops.h" + // #define DEBUG_TIME #ifdef DEBUG_TIME @@ -800,48 +804,48 @@ static void corner_manifold_fan_around_vert_next(const Span corner_verts, const Span corner_to_face, const int2 e2lfan_curr, const int vert_pivot, - int *r_fan_corner, - int *r_vert_corner) + int *r_mlfan_curr_index, + int *r_mlfan_vert_index) { - const int fan_corner_orig = *r_fan_corner; - const int vert_fan_orig = corner_verts[fan_corner_orig]; + const int mlfan_curr_orig = *r_mlfan_curr_index; + const int vert_fan_orig = corner_verts[mlfan_curr_orig]; /* WARNING: This is rather complex! * We have to find our next edge around the vertex (fan mode). - * First we find the next corner, which is either previous or next to fan_corner, depending + * First we find the next corner, which is either previous or next to mlfan_curr_index, depending * whether both corners using current edge are in the same direction or not, and whether - * fan_corner actually uses the vertex we are fanning around! - * fan_corner is the index of the next corner here, and the next corner is not the real next one - * (i.e. not the future `fan_corner`). */ - *r_fan_corner = (e2lfan_curr[0] == *r_fan_corner) ? e2lfan_curr[1] : e2lfan_curr[0]; + * mlfan_curr_index actually uses the vertex we are fanning around! + * mlfan_curr_index is the index of mlfan_next here, and mlfan_next is not the real next one + * (i.e. not the future `mlfan_curr`). */ + *r_mlfan_curr_index = (e2lfan_curr[0] == *r_mlfan_curr_index) ? e2lfan_curr[1] : e2lfan_curr[0]; - BLI_assert(*r_fan_corner >= 0); + BLI_assert(*r_mlfan_curr_index >= 0); - const int vert_fan_next = corner_verts[*r_fan_corner]; - const IndexRange face_fan_next = faces[corner_to_face[*r_fan_corner]]; + const int vert_fan_next = corner_verts[*r_mlfan_curr_index]; + const IndexRange face_fan_next = faces[corner_to_face[*r_mlfan_curr_index]]; if ((vert_fan_orig == vert_fan_next && vert_fan_orig == vert_pivot) || !ELEM(vert_fan_orig, vert_fan_next, vert_pivot)) { /* We need the previous corner, but current one is our vertex's corner. */ - *r_vert_corner = *r_fan_corner; - *r_fan_corner = face_corner_prev(face_fan_next, *r_fan_corner); + *r_mlfan_vert_index = *r_mlfan_curr_index; + *r_mlfan_curr_index = face_corner_prev(face_fan_next, *r_mlfan_curr_index); } else { /* We need the next corner, which is also our vertex's corner. */ - *r_fan_corner = face_corner_next(face_fan_next, *r_fan_corner); - *r_vert_corner = *r_fan_corner; + *r_mlfan_curr_index = face_corner_next(face_fan_next, *r_mlfan_curr_index); + *r_mlfan_vert_index = *r_mlfan_curr_index; } } static void lnor_space_for_single_fan(CornerSplitTaskDataCommon *common_data, - const int corner, + const int ml_curr_index, const int space_index) { const Span corner_to_face = common_data->corner_to_face; const Span face_normals = common_data->face_normals; MutableSpan corner_normals = common_data->corner_normals; - corner_normals[corner] = face_normals[corner_to_face[corner]]; + corner_normals[ml_curr_index] = face_normals[corner_to_face[ml_curr_index]]; if (CornerNormalSpaceArray *lnors_spacearr = common_data->lnors_spacearr) { const Span positions = common_data->positions; @@ -851,33 +855,34 @@ static void lnor_space_for_single_fan(CornerSplitTaskDataCommon *common_data, const Span corner_edges = common_data->corner_edges; const Span clnors_data = common_data->clnors_data; - const int face_index = corner_to_face[corner]; - const int corner_prev = mesh::face_corner_prev(faces[face_index], corner); + const int face_index = corner_to_face[ml_curr_index]; + const int ml_prev_index = mesh::face_corner_prev(faces[face_index], ml_curr_index); /* The vertex we are "fanning" around. */ - const int vert_pivot = corner_verts[corner]; - const int vert_2 = edge_other_vert(edges[corner_edges[corner]], vert_pivot); - const int vert_3 = edge_other_vert(edges[corner_edges[corner_prev]], vert_pivot); + const int vert_pivot = corner_verts[ml_curr_index]; + const int vert_2 = edge_other_vert(edges[corner_edges[ml_curr_index]], vert_pivot); + const int vert_3 = edge_other_vert(edges[corner_edges[ml_prev_index]], vert_pivot); const float3 vec_curr = math::normalize(positions[vert_2] - positions[vert_pivot]); const float3 vec_prev = math::normalize(positions[vert_3] - positions[vert_pivot]); CornerNormalSpace &space = lnors_spacearr->spaces[space_index]; - space = corner_fan_space_define(corner_normals[corner], vec_curr, vec_prev, {}); - lnors_spacearr->corner_space_indices[corner] = space_index; + space = corner_fan_space_define(corner_normals[ml_curr_index], vec_curr, vec_prev, {}); + lnors_spacearr->corner_space_indices[ml_curr_index] = space_index; if (!clnors_data.is_empty()) { - corner_normals[corner] = corner_space_custom_data_to_normal(space, clnors_data[corner]); + corner_normals[ml_curr_index] = corner_space_custom_data_to_normal( + space, clnors_data[ml_curr_index]); } if (!lnors_spacearr->corners_by_space.is_empty()) { - lnors_spacearr->corners_by_space[space_index] = {corner}; + lnors_spacearr->corners_by_space[space_index] = {ml_curr_index}; } } } static void split_corner_normal_fan_do(CornerSplitTaskDataCommon *common_data, - const int corner, + const int ml_curr_index, const int space_index, Vector *edge_vectors) { @@ -894,8 +899,8 @@ static void split_corner_normal_fan_do(CornerSplitTaskDataCommon *common_data, const Span face_normals = common_data->face_normals; const Span clnors_data = common_data->clnors_data; - const int face_index = corner_to_face[corner]; - const int corner_prev = face_corner_prev(faces[face_index], corner); + const int face_index = corner_to_face[ml_curr_index]; + const int ml_prev_index = face_corner_prev(faces[face_index], ml_curr_index); /* Sigh! we have to fan around current vertex, until we find the other non-smooth edge, * and accumulate face normals into the vertex! @@ -903,10 +908,10 @@ static void split_corner_normal_fan_do(CornerSplitTaskDataCommon *common_data, * same as the vertex normal, but I do not see any easy way to detect that (would need to count * number of sharp edges per vertex, I doubt the additional memory usage would be worth it, * especially as it should not be a common case in real-life meshes anyway). */ - const int vert_pivot = corner_verts[corner]; /* The vertex we are "fanning" around! */ + const int vert_pivot = corner_verts[ml_curr_index]; /* The vertex we are "fanning" around! */ - /* `corner` would be `corner_prev` if we needed that one. */ - const int2 &edge_orig = edges[corner_edges[corner]]; + /* `ml_curr_index` would be mlfan_prev if we needed that one. */ + const int2 &edge_orig = edges[corner_edges[ml_curr_index]]; float3 vec_curr; float3 vec_prev; @@ -917,14 +922,14 @@ static void split_corner_normal_fan_do(CornerSplitTaskDataCommon *common_data, Vector processed_corners; - /* `vert_corner` the corner of our current edge might not be the corner of our current + /* `mlfan_vert_index` the corner of our current edge might not be the corner of our current * vertex! */ - int fan_corner = corner_prev; - int vert_corner = corner; + int mlfan_curr_index = ml_prev_index; + int mlfan_vert_index = ml_curr_index; - BLI_assert(fan_corner >= 0); - BLI_assert(vert_corner >= 0); + BLI_assert(mlfan_curr_index >= 0); + BLI_assert(mlfan_vert_index >= 0); /* Only need to compute previous edge's vector once, then we can just reuse old current one! */ { @@ -937,8 +942,10 @@ static void split_corner_normal_fan_do(CornerSplitTaskDataCommon *common_data, } } + // printf("FAN: vert %d, start edge %d\n", vert_pivot, ml_curr->e); + while (true) { - const int2 &edge = edges[corner_edges[fan_corner]]; + const int2 &edge = edges[corner_edges[mlfan_curr_index]]; /* Compute edge vectors. * NOTE: We could pre-compute those into an array, in the first iteration, instead of computing * them twice (or more) here. However, time gained is not worth memory and time lost, @@ -949,12 +956,15 @@ static void split_corner_normal_fan_do(CornerSplitTaskDataCommon *common_data, vec_curr = math::normalize(positions[vert_2] - positions[vert_pivot]); } + // printf("\thandling edge %d / corner %d\n", corner_edges[mlfan_curr_index], + // mlfan_curr_index); + /* Code similar to accumulate_vertex_normals_poly_v3. */ /* Calculate angle between the two face edges incident on this vertex. */ - lnor += face_normals[corner_to_face[fan_corner]] * + lnor += face_normals[corner_to_face[mlfan_curr_index]] * math::safe_acos_approx(math::dot(vec_curr, vec_prev)); - processed_corners.append(vert_corner); + processed_corners.append(mlfan_vert_index); if (lnors_spacearr) { if (edge != edge_orig) { @@ -965,11 +975,11 @@ static void split_corner_normal_fan_do(CornerSplitTaskDataCommon *common_data, lnors_spacearr->corners_by_space[space_index] = processed_corners.as_span(); } if (!clnors_data.is_empty()) { - clnors_avg += int2(clnors_data[vert_corner]); + clnors_avg += int2(clnors_data[mlfan_vert_index]); } } - if (IS_EDGE_SHARP(edge_to_corners[corner_edges[fan_corner]]) || (edge == edge_orig)) { + if (IS_EDGE_SHARP(edge_to_corners[corner_edges[mlfan_curr_index]]) || (edge == edge_orig)) { /* Current edge is sharp and we have finished with this fan of faces around this vert, * or this vert is smooth, and we have completed a full turn around it. */ break; @@ -981,10 +991,10 @@ static void split_corner_normal_fan_do(CornerSplitTaskDataCommon *common_data, corner_manifold_fan_around_vert_next(corner_verts, faces, corner_to_face, - edge_to_corners[corner_edges[fan_corner]], + edge_to_corners[corner_edges[mlfan_curr_index]], vert_pivot, - &fan_corner, - &vert_corner); + &mlfan_curr_index, + &mlfan_vert_index); } float length; @@ -996,7 +1006,7 @@ static void split_corner_normal_fan_do(CornerSplitTaskDataCommon *common_data, if (lnors_spacearr) { if (UNLIKELY(length == 0.0f)) { /* Use vertex normal as fallback! */ - lnor = corner_normals[vert_corner]; + lnor = corner_normals[mlfan_vert_index]; length = 1.0f; } @@ -1031,11 +1041,11 @@ static bool corner_split_generator_check_cyclic_smooth_fan(const Span corne const Span corner_to_face, const int2 e2l_prev, MutableBitSpan skip_corners, - const int corner, - const int corner_prev) + const int ml_curr_index, + const int ml_prev_index) { /* The vertex we are "fanning" around. */ - const int vert_pivot = corner_verts[corner]; + const int vert_pivot = corner_verts[ml_curr_index]; int2 e2lfan_curr = e2l_prev; if (IS_EDGE_SHARP(e2lfan_curr)) { @@ -1043,32 +1053,37 @@ static bool corner_split_generator_check_cyclic_smooth_fan(const Span corne return false; } - /* `vert_corner` the corner of our current edge might not be the corner of our current + /* `mlfan_vert_index` the corner of our current edge might not be the corner of our current * vertex! */ - int fan_corner = corner_prev; - int vert_corner = corner; + int mlfan_curr_index = ml_prev_index; + int mlfan_vert_index = ml_curr_index; - BLI_assert(fan_corner >= 0); - BLI_assert(vert_corner >= 0); + BLI_assert(mlfan_curr_index >= 0); + BLI_assert(mlfan_vert_index >= 0); - BLI_assert(!skip_corners[vert_corner]); - skip_corners[vert_corner].set(); + BLI_assert(!skip_corners[mlfan_vert_index]); + skip_corners[mlfan_vert_index].set(); while (true) { /* Find next corner of the smooth fan. */ - corner_manifold_fan_around_vert_next( - corner_verts, faces, corner_to_face, e2lfan_curr, vert_pivot, &fan_corner, &vert_corner); + corner_manifold_fan_around_vert_next(corner_verts, + faces, + corner_to_face, + e2lfan_curr, + vert_pivot, + &mlfan_curr_index, + &mlfan_vert_index); - e2lfan_curr = edge_to_corners[corner_edges[fan_corner]]; + e2lfan_curr = edge_to_corners[corner_edges[mlfan_curr_index]]; if (IS_EDGE_SHARP(e2lfan_curr)) { /* Sharp corner/edge, so not a cyclic smooth fan. */ return false; } /* Smooth corner/edge. */ - if (skip_corners[vert_corner]) { - if (vert_corner == corner) { + if (skip_corners[mlfan_vert_index]) { + if (mlfan_vert_index == ml_curr_index) { /* We walked around a whole cyclic smooth fan without finding any already-processed corner, * means we can use initial current / previous edge as start for this smooth fan. */ return true; @@ -1078,7 +1093,7 @@ static bool corner_split_generator_check_cyclic_smooth_fan(const Span corne } /* We can skip it in future, and keep checking the smooth fan. */ - skip_corners[vert_corner].set(); + skip_corners[mlfan_vert_index].set(); } } @@ -1104,16 +1119,16 @@ static void corner_split_generator(CornerSplitTaskDataCommon *common_data, for (const int face_index : faces.index_range()) { const IndexRange face = faces[face_index]; - for (const int corner : face) { - const int corner_prev = mesh::face_corner_prev(face, corner); + for (const int ml_curr_index : face) { + const int ml_prev_index = mesh::face_corner_prev(face, ml_curr_index); #if 0 printf("Checking corner %d / edge %u / vert %u (sharp edge: %d, skiploop: %d)", - corner, - corner_edges[corner], - corner_verts[corner], - IS_EDGE_SHARP(edge_to_corners[corner_edges[corner]]), - skip_corners[corner]); + ml_curr_index, + corner_edges[ml_curr_index], + corner_verts[ml_curr_index], + IS_EDGE_SHARP(edge_to_corners[corner_edges[ml_curr_index]]), + skip_corners[ml_curr_index]); #endif /* A smooth edge, we have to check for cyclic smooth fan case. @@ -1121,32 +1136,32 @@ static void corner_split_generator(CornerSplitTaskDataCommon *common_data, * corner/edge as 'entry point', otherwise we can skip it. */ /* NOTE: In theory, we could make #corner_split_generator_check_cyclic_smooth_fan() store - * vert_corner'es and edge indexes in two stacks, to avoid having to fan again around + * mlfan_vert_index'es and edge indexes in two stacks, to avoid having to fan again around * the vert during actual computation of `clnor` & `clnorspace`. * However, this would complicate the code, add more memory usage, and despite its logical * complexity, #corner_manifold_fan_around_vert_next() is quite cheap in term of CPU cycles, * so really think it's not worth it. */ - if (!IS_EDGE_SHARP(edge_to_corners[corner_edges[corner]]) && - (skip_corners[corner] || !corner_split_generator_check_cyclic_smooth_fan( - corner_verts, - corner_edges, - faces, - edge_to_corners, - corner_to_face, - edge_to_corners[corner_edges[corner_prev]], - skip_corners, - corner, - corner_prev))) + if (!IS_EDGE_SHARP(edge_to_corners[corner_edges[ml_curr_index]]) && + (skip_corners[ml_curr_index] || !corner_split_generator_check_cyclic_smooth_fan( + corner_verts, + corner_edges, + faces, + edge_to_corners, + corner_to_face, + edge_to_corners[corner_edges[ml_prev_index]], + skip_corners, + ml_curr_index, + ml_prev_index))) { // printf("SKIPPING!\n"); } else { - if (IS_EDGE_SHARP(edge_to_corners[corner_edges[corner]]) && - IS_EDGE_SHARP(edge_to_corners[corner_edges[corner_prev]])) + if (IS_EDGE_SHARP(edge_to_corners[corner_edges[ml_curr_index]]) && + IS_EDGE_SHARP(edge_to_corners[corner_edges[ml_prev_index]])) { /* Simple case (both edges around that vertex are sharp in current face), * this corner just takes its face normal. */ - r_single_corners.append(corner); + r_single_corners.append(ml_curr_index); } else { /* We do not need to check/tag corners as already computed. Due to the fact that a corner @@ -1156,7 +1171,7 @@ static void corner_split_generator(CornerSplitTaskDataCommon *common_data, * current edge, smooth previous edge), and not the alternative (smooth current edge, * sharp previous edge). All this due/thanks to the link between normals and corner * ordering (i.e. winding). */ - r_fan_corners.append(corner); + r_fan_corners.append(ml_curr_index); } } } @@ -1384,11 +1399,11 @@ static void mesh_normals_corner_custom_set(const Span positions, * We know those two corners do not point to the same edge, * since we do not allow reversed winding in a same smooth fan. */ const IndexRange face = faces[corner_to_face[lidx]]; - const int corner_prev = face_corner_prev(face, lidx); + const int mlp = (lidx == face.start()) ? face.start() + face.size() - 1 : lidx - 1; const int edge = corner_edges[lidx]; - const int edge_prev = corner_edges[corner_prev]; + const int edge_p = corner_edges[mlp]; const int prev_edge = corner_edges[prev_corner]; - sharp_edges[prev_edge == edge_prev ? prev_edge : edge] = true; + sharp_edges[prev_edge == edge_p ? prev_edge : edge] = true; org_nor = nor; } @@ -1407,11 +1422,11 @@ static void mesh_normals_corner_custom_set(const Span positions, if (dot_v3v3(org_nor, nor) < LNOR_SPACE_TRIGO_THRESHOLD) { const IndexRange face = faces[corner_to_face[lidx]]; - const int corner_prev = face_corner_prev(face, lidx); + const int mlp = (lidx == face.start()) ? face.start() + face.size() - 1 : lidx - 1; const int edge = corner_edges[lidx]; - const int edge_prev = corner_edges[corner_prev]; + const int edge_p = corner_edges[mlp]; const int prev_edge = corner_edges[prev_corner]; - sharp_edges[prev_edge == edge_prev ? prev_edge : edge] = true; + sharp_edges[prev_edge == edge_p ? prev_edge : edge] = true; } } } diff --git a/source/blender/blenkernel/intern/mesh_remap.cc b/source/blender/blenkernel/intern/mesh_remap.cc index 57df2545736..8b5911338e7 100644 --- a/source/blender/blenkernel/intern/mesh_remap.cc +++ b/source/blender/blenkernel/intern/mesh_remap.cc @@ -34,7 +34,7 @@ #include "BKE_mesh_remap.hh" /* own include */ #include "BKE_mesh_runtime.hh" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" static CLG_LogRef LOG = {"bke.mesh"}; diff --git a/source/blender/blenkernel/intern/mesh_runtime.cc b/source/blender/blenkernel/intern/mesh_runtime.cc index d831d3739f5..6301bc67fd7 100644 --- a/source/blender/blenkernel/intern/mesh_runtime.cc +++ b/source/blender/blenkernel/intern/mesh_runtime.cc @@ -6,11 +6,16 @@ * \ingroup bke */ +#include "atomic_ops.h" + #include "MEM_guardedalloc.h" +#include "DNA_object_types.h" + #include "BLI_array_utils.hh" #include "BLI_math_geom.h" #include "BLI_task.hh" +#include "BLI_timeit.hh" #include "BKE_bake_data_block_id.hh" #include "BKE_bvhutils.hh" diff --git a/source/blender/blenkernel/intern/mesh_sample.cc b/source/blender/blenkernel/intern/mesh_sample.cc index abe85e6ef69..47256dbbab7 100644 --- a/source/blender/blenkernel/intern/mesh_sample.cc +++ b/source/blender/blenkernel/intern/mesh_sample.cc @@ -5,6 +5,7 @@ #include "BKE_attribute_math.hh" #include "BKE_bvhutils.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_mesh_sample.hh" #include "BLI_math_geom.h" diff --git a/source/blender/blenkernel/intern/mesh_tangent.cc b/source/blender/blenkernel/intern/mesh_tangent.cc index f0d8416d6f2..0709318c6f9 100644 --- a/source/blender/blenkernel/intern/mesh_tangent.cc +++ b/source/blender/blenkernel/intern/mesh_tangent.cc @@ -21,13 +21,15 @@ #include "BKE_attribute.hh" #include "BKE_customdata.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_mesh_tangent.hh" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BLI_strict_flags.h" + +#include "atomic_ops.h" #include "mikktspace.hh" -#include "BLI_strict_flags.h" /* Keep last. */ - using blender::float2; /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/mesh_tessellate.cc b/source/blender/blenkernel/intern/mesh_tessellate.cc index 670e2fb92d7..02b7f3bf743 100644 --- a/source/blender/blenkernel/intern/mesh_tessellate.cc +++ b/source/blender/blenkernel/intern/mesh_tessellate.cc @@ -12,6 +12,7 @@ */ #include "BLI_array_utils.hh" +#include "BLI_enumerable_thread_specific.hh" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" @@ -22,7 +23,7 @@ #include "BKE_mesh.hh" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" namespace blender::bke::mesh { diff --git a/source/blender/blenkernel/intern/modifier.cc b/source/blender/blenkernel/intern/modifier.cc index b1edb87591a..19d86a7745b 100644 --- a/source/blender/blenkernel/intern/modifier.cc +++ b/source/blender/blenkernel/intern/modifier.cc @@ -43,7 +43,7 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_DerivedMesh.hh" #include "BKE_appdir.hh" @@ -51,7 +51,7 @@ #include "BKE_editmesh_cache.hh" #include "BKE_effect.h" #include "BKE_fluid.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_idtype.hh" #include "BKE_key.hh" diff --git a/source/blender/blenkernel/intern/movieclip.cc b/source/blender/blenkernel/intern/movieclip.cc index 359192579a2..b1e86e81b78 100644 --- a/source/blender/blenkernel/intern/movieclip.cc +++ b/source/blender/blenkernel/intern/movieclip.cc @@ -25,6 +25,7 @@ #include "DNA_defaults.h" +#include "DNA_constraint_types.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_movieclip_types.h" #include "DNA_node_types.h" @@ -41,16 +42,19 @@ #include "BLI_math_vector.h" #include "BLI_threads.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" -#include "BKE_bpath.hh" +#include "BKE_anim_data.h" +#include "BKE_bpath.h" #include "BKE_colortools.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_image.h" /* openanim */ #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_main.hh" #include "BKE_movieclip.h" +#include "BKE_node.h" #include "BKE_node_tree_update.hh" #include "BKE_tracking.h" @@ -68,6 +72,8 @@ #include "BLO_read_write.hh" +#include "tracking_private.h" + static void free_buffers(MovieClip *clip); static void movie_clip_init_data(ID *id) @@ -279,7 +285,6 @@ static void movieclip_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_MC = { /*id_code*/ ID_MC, /*id_filter*/ FILTER_ID_MC, - /*dependencies_id_types*/ FILTER_ID_GD_LEGACY | FILTER_ID_IM, /*main_listbase_index*/ INDEX_ID_MC, /*struct_size*/ sizeof(MovieClip), /*name*/ "MovieClip", diff --git a/source/blender/blenkernel/intern/multires.cc b/source/blender/blenkernel/intern/multires.cc index 1d7f2902d2f..fb5774b2181 100644 --- a/source/blender/blenkernel/intern/multires.cc +++ b/source/blender/blenkernel/intern/multires.cc @@ -17,6 +17,7 @@ #include "DNA_scene_types.h" #include "BLI_bitmap.h" +#include "BLI_blenlib.h" #include "BLI_math_matrix.h" #include "BLI_task.h" #include "BLI_utildefines.h" @@ -25,12 +26,13 @@ #include "BKE_cdderivedmesh.h" #include "BKE_editmesh.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_mapping.hh" #include "BKE_mesh_runtime.hh" #include "BKE_modifier.hh" #include "BKE_multires.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_subdiv_ccg.hh" #include "BKE_subsurf.hh" @@ -40,6 +42,8 @@ #include "DEG_depsgraph_query.hh" +#include "multires_reshape.hh" + #include #include diff --git a/source/blender/blenkernel/intern/multires_reshape.cc b/source/blender/blenkernel/intern/multires_reshape.cc index 95ffa77489c..852c251ddb7 100644 --- a/source/blender/blenkernel/intern/multires_reshape.cc +++ b/source/blender/blenkernel/intern/multires_reshape.cc @@ -9,13 +9,18 @@ #include "MEM_guardedalloc.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" +#include "DNA_scene_types.h" #include "BKE_customdata.hh" #include "BKE_lib_id.hh" +#include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_modifier.hh" #include "BKE_multires.hh" #include "BKE_object.hh" +#include "BKE_subdiv.hh" #include "BKE_subsurf.hh" #include "BLI_math_vector.h" diff --git a/source/blender/blenkernel/intern/multires_reshape_apply_base.cc b/source/blender/blenkernel/intern/multires_reshape_apply_base.cc index 7a35824a06f..5fce126a424 100644 --- a/source/blender/blenkernel/intern/multires_reshape_apply_base.cc +++ b/source/blender/blenkernel/intern/multires_reshape_apply_base.cc @@ -11,14 +11,24 @@ #include "MEM_guardedalloc.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_modifier_types.h" +#include "DNA_object_types.h" +#include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" +#include "BKE_customdata.hh" +#include "BKE_lib_id.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_mapping.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_multires.hh" #include "BKE_subdiv_eval.hh" +#include "DEG_depsgraph_query.hh" + void multires_reshape_apply_base_update_mesh_coords(MultiresReshapeContext *reshape_context) { Mesh *base_mesh = reshape_context->base_mesh; diff --git a/source/blender/blenkernel/intern/multires_reshape_smooth.cc b/source/blender/blenkernel/intern/multires_reshape_smooth.cc index 9ae7cab5394..3a444f3e1f8 100644 --- a/source/blender/blenkernel/intern/multires_reshape_smooth.cc +++ b/source/blender/blenkernel/intern/multires_reshape_smooth.cc @@ -11,6 +11,8 @@ #include "MEM_guardedalloc.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_modifier_types.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" @@ -27,6 +29,7 @@ #include "opensubdiv_converter_capi.hh" #include "opensubdiv_evaluator_capi.hh" +#include "opensubdiv_topology_refiner_capi.hh" #include "atomic_ops.h" #include "subdiv_converter.hh" diff --git a/source/blender/blenkernel/intern/multires_reshape_subdivide.cc b/source/blender/blenkernel/intern/multires_reshape_subdivide.cc index 4d82b210e40..c6f2f20d8f8 100644 --- a/source/blender/blenkernel/intern/multires_reshape_subdivide.cc +++ b/source/blender/blenkernel/intern/multires_reshape_subdivide.cc @@ -14,11 +14,17 @@ #include "DNA_scene_types.h" #include "BKE_customdata.hh" +#include "BKE_lib_id.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" +#include "BKE_modifier.hh" #include "BKE_multires.hh" +#include "BKE_subdiv.hh" #include "BKE_subsurf.hh" #include "BLI_math_vector.h" +#include "DEG_depsgraph_query.hh" + #include "multires_reshape.hh" static void multires_subdivide_create_object_space_linear_grids(Mesh *mesh) diff --git a/source/blender/blenkernel/intern/multires_reshape_util.cc b/source/blender/blenkernel/intern/multires_reshape_util.cc index b01a4106749..f3b33e5c4c7 100644 --- a/source/blender/blenkernel/intern/multires_reshape_util.cc +++ b/source/blender/blenkernel/intern/multires_reshape_util.cc @@ -14,17 +14,21 @@ #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BLI_math_matrix.h" #include "BLI_task.h" #include "BKE_attribute.hh" #include "BKE_customdata.hh" +#include "BKE_mesh.hh" #include "BKE_mesh_runtime.hh" #include "BKE_multires.hh" #include "BKE_subdiv.hh" #include "BKE_subdiv_ccg.hh" #include "BKE_subdiv_eval.hh" +#include "BKE_subdiv_foreach.hh" +#include "BKE_subdiv_mesh.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/blenkernel/intern/multires_reshape_vertcos.cc b/source/blender/blenkernel/intern/multires_reshape_vertcos.cc index 0d1eb52f09e..8d9d1bdd086 100644 --- a/source/blender/blenkernel/intern/multires_reshape_vertcos.cc +++ b/source/blender/blenkernel/intern/multires_reshape_vertcos.cc @@ -8,6 +8,9 @@ #include "multires_reshape.hh" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" + #include "BLI_math_vector.h" #include "BKE_subdiv_foreach.hh" diff --git a/source/blender/blenkernel/intern/multires_subdiv.cc b/source/blender/blenkernel/intern/multires_subdiv.cc index 685b8fb01f7..c3d1c970857 100644 --- a/source/blender/blenkernel/intern/multires_subdiv.cc +++ b/source/blender/blenkernel/intern/multires_subdiv.cc @@ -8,8 +8,12 @@ #include "MEM_guardedalloc.h" +#include "DNA_mesh_types.h" +#include "DNA_scene_types.h" + #include "BLI_utildefines.h" +#include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_multires.hh" #include "BKE_subdiv.hh" diff --git a/source/blender/blenkernel/intern/multires_unsubdivide.cc b/source/blender/blenkernel/intern/multires_unsubdivide.cc index fd27c74a85e..6fd299a8349 100644 --- a/source/blender/blenkernel/intern/multires_unsubdivide.cc +++ b/source/blender/blenkernel/intern/multires_unsubdivide.cc @@ -20,12 +20,19 @@ #include "BLI_math_vector.h" #include "BKE_customdata.hh" +#include "BKE_lib_id.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_mapping.hh" +#include "BKE_mesh_runtime.hh" +#include "BKE_modifier.hh" #include "BKE_multires.hh" +#include "BKE_subdiv.hh" #include "BKE_subsurf.hh" #include "bmesh.hh" +#include "DEG_depsgraph_query.hh" + #include "multires_reshape.hh" #include "multires_unsubdivide.hh" diff --git a/source/blender/blenkernel/intern/nla.cc b/source/blender/blenkernel/intern/nla.cc index ba5a251099b..9040088dc1c 100644 --- a/source/blender/blenkernel/intern/nla.cc +++ b/source/blender/blenkernel/intern/nla.cc @@ -23,7 +23,7 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_anim_types.h" #include "DNA_scene_types.h" @@ -32,7 +32,7 @@ #include "BKE_action.h" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_main.hh" diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 1ebfb58c53a..6d722807fd9 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -47,18 +47,18 @@ #include "BLI_time.h" #include "BLI_utildefines.h" #include "BLI_vector_set.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "IMB_imbuf.hh" #include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_asset.hh" -#include "BKE_bpath.hh" +#include "BKE_bpath.h" #include "BKE_colortools.hh" #include "BKE_context.hh" #include "BKE_cryptomatte.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_idprop.hh" #include "BKE_idtype.hh" @@ -353,7 +353,6 @@ static void library_foreach_node_socket(LibraryForeachIDData *data, bNodeSocket case SOCK_RGBA: case SOCK_BOOLEAN: case SOCK_ROTATION: - case SOCK_MATRIX: case SOCK_INT: case SOCK_STRING: case SOCK_CUSTOM: @@ -704,12 +703,10 @@ static void write_node_socket_default_value(BlendWriter *writer, const bNodeSock case SOCK_ROTATION: BLO_write_struct(writer, bNodeSocketValueRotation, sock->default_value); break; - case SOCK_MENU: + case SOCK_MENU: { BLO_write_struct(writer, bNodeSocketValueMenu, sock->default_value); break; - case SOCK_MATRIX: - /* Matrix sockets currently have no default value. */ - break; + } case SOCK_CUSTOM: /* Custom node sockets where default_value is defined uses custom properties for storage. */ break; @@ -942,7 +939,6 @@ static bool is_node_socket_supported(const bNodeSocket *sock) case SOCK_MATERIAL: case SOCK_ROTATION: case SOCK_MENU: - case SOCK_MATRIX: return true; } return false; @@ -1272,8 +1268,6 @@ static AssetTypeInfo AssetType_NT = { IDTypeInfo IDType_ID_NT = { /*id_code*/ ID_NT, /*id_filter*/ FILTER_ID_NT, - /* IDProps of nodes, and #bNode.id, can use any type of ID. */ - /*dependencies_id_types*/ FILTER_ID_ALL, /*main_listbase_index*/ INDEX_ID_NT, /*struct_size*/ sizeof(bNodeTree), /*name*/ "NodeTree", @@ -1869,7 +1863,6 @@ static void socket_id_user_increment(bNodeSocket *sock) case SOCK_RGBA: case SOCK_BOOLEAN: case SOCK_ROTATION: - case SOCK_MATRIX: case SOCK_INT: case SOCK_STRING: case SOCK_MENU: @@ -1917,7 +1910,6 @@ static bool socket_id_user_decrement(bNodeSocket *sock) case SOCK_RGBA: case SOCK_BOOLEAN: case SOCK_ROTATION: - case SOCK_MATRIX: case SOCK_INT: case SOCK_STRING: case SOCK_MENU: @@ -1973,7 +1965,6 @@ void nodeModifySocketType(bNodeTree *ntree, case SOCK_SHADER: case SOCK_BOOLEAN: case SOCK_ROTATION: - case SOCK_MATRIX: case SOCK_CUSTOM: case SOCK_OBJECT: case SOCK_IMAGE: @@ -2080,8 +2071,6 @@ const char *nodeStaticSocketType(const int type, const int subtype) return "NodeSocketBool"; case SOCK_ROTATION: return "NodeSocketRotation"; - case SOCK_MATRIX: - return "NodeSocketMatrix"; case SOCK_VECTOR: switch (PropertySubType(subtype)) { case PROP_TRANSLATION: @@ -2165,8 +2154,6 @@ const char *nodeStaticSocketInterfaceTypeNew(const int type, const int subtype) return "NodeTreeInterfaceSocketBool"; case SOCK_ROTATION: return "NodeTreeInterfaceSocketRotation"; - case SOCK_MATRIX: - return "NodeTreeInterfaceSocketMatrix"; case SOCK_VECTOR: switch (PropertySubType(subtype)) { case PROP_TRANSLATION: @@ -2222,8 +2209,6 @@ const char *nodeStaticSocketLabel(const int type, const int /*subtype*/) return "Boolean"; case SOCK_ROTATION: return "Rotation"; - case SOCK_MATRIX: - return "Matrix"; case SOCK_VECTOR: return "Vector"; case SOCK_RGBA: @@ -2541,7 +2526,7 @@ void nodeUniqueName(bNodeTree *ntree, bNode *node) void nodeUniqueID(bNodeTree *ntree, bNode *node) { /* Use a pointer cast to avoid overflow warnings. */ - const double time = BLI_time_now_seconds() * 1000000.0; + const double time = BLI_check_seconds_timer() * 1000000.0; blender::RandomNumberGenerator id_rng{*reinterpret_cast(&time)}; /* In the unlikely case that the random ID doesn't match, choose a new one until it does. */ @@ -2771,9 +2756,6 @@ static void *socket_value_storage(bNodeSocket &socket) return &socket.default_value_typed()->value_euler; case SOCK_MENU: return &socket.default_value_typed()->value; - case SOCK_MATRIX: - /* Matrix sockets currently have no default value. */ - return nullptr; case SOCK_STRING: /* We don't want do this now! */ return nullptr; @@ -4172,7 +4154,7 @@ static void node_replace_undefined_types(bNode *node) /* This type name is arbitrary, it just has to be unique enough to not match a future node * idname. Includes the old type identifier for debugging purposes. */ const std::string old_idname = node->idname; - SNPRINTF(node->idname, "Undefined[%s]", old_idname.c_str()); + BLI_snprintf(node->idname, sizeof(node->idname), "Undefined[%s]", old_idname.c_str()); node->typeinfo = &NodeTypeUndefined; } } @@ -4362,8 +4344,6 @@ std::optional socket_type_to_custom_data_type(eNodeSocketDataty return CD_PROP_BOOL; case SOCK_ROTATION: return CD_PROP_QUATERNION; - case SOCK_MATRIX: - return CD_PROP_FLOAT4X4; case SOCK_INT: return CD_PROP_INT32; case SOCK_STRING: @@ -4392,8 +4372,6 @@ std::optional custom_data_type_to_socket_type(eCustomDataTy return SOCK_RGBA; case CD_PROP_QUATERNION: return SOCK_ROTATION; - case CD_PROP_FLOAT4X4: - return SOCK_MATRIX; default: return std::nullopt; } @@ -4456,9 +4434,6 @@ std::optional geo_nodes_base_cpp_type_to_socket_type(const if (type.is()) { return SOCK_ROTATION; } - if (type.is()) { - return SOCK_MATRIX; - } if (type.is()) { return SOCK_STRING; } diff --git a/source/blender/blenkernel/intern/node_enum_definition.cc b/source/blender/blenkernel/intern/node_enum_definition.cc index 33531cf73be..4ea5362de4f 100644 --- a/source/blender/blenkernel/intern/node_enum_definition.cc +++ b/source/blender/blenkernel/intern/node_enum_definition.cc @@ -8,7 +8,9 @@ #include "DNA_array_utils.hh" #include "DNA_node_types.h" +#include "BKE_node.h" #include "BKE_node_enum.hh" +#include "BKE_node_runtime.hh" using blender::bke::NodeSocketValueMenuRuntimeFlag; diff --git a/source/blender/blenkernel/intern/node_runtime.cc b/source/blender/blenkernel/intern/node_runtime.cc index 105d30bbd50..74054663010 100644 --- a/source/blender/blenkernel/intern/node_runtime.cc +++ b/source/blender/blenkernel/intern/node_runtime.cc @@ -10,6 +10,7 @@ #include "BLI_function_ref.hh" #include "BLI_stack.hh" #include "BLI_task.hh" +#include "BLI_timeit.hh" #include "NOD_geometry_nodes_lazy_function.hh" diff --git a/source/blender/blenkernel/intern/node_socket_value.cc b/source/blender/blenkernel/intern/node_socket_value.cc index b44ccf8f37a..6186de63c8e 100644 --- a/source/blender/blenkernel/intern/node_socket_value.cc +++ b/source/blender/blenkernel/intern/node_socket_value.cc @@ -54,9 +54,6 @@ template static std::optional static_type_to_so if constexpr (is_single_or_field_or_grid_v) { return SOCK_ROTATION; } - if constexpr (is_same_any_v>) { - return SOCK_MATRIX; - } if constexpr (is_same_any_v) { return SOCK_STRING; } @@ -198,10 +195,6 @@ void SocketValueVariant::store_single(const eNodeSocketDatatype socket_type, con value_.emplace(*static_cast(value)); break; } - case SOCK_MATRIX: { - value_.emplace(*static_cast(value)); - break; - } case SOCK_RGBA: { value_.emplace(*static_cast(value)); break; @@ -288,8 +281,6 @@ void *SocketValueVariant::allocate_single(const eNodeSocketDatatype socket_type) return value_.allocate(); case SOCK_ROTATION: return value_.allocate(); - case SOCK_MATRIX: - return value_.allocate(); case SOCK_RGBA: return value_.allocate(); case SOCK_STRING: @@ -353,9 +344,6 @@ INSTANTIATE_SINGLE_AND_FIELD_AND_GRID(blender::math::Quaternion) INSTANTIATE(std::string) INSTANTIATE(fn::GField) -INSTANTIATE(float4x4) -INSTANTIATE(fn::Field) - #ifdef WITH_OPENVDB INSTANTIATE(GVolumeGrid) #endif diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc index aed5ed7f328..9eb8b2b9b59 100644 --- a/source/blender/blenkernel/intern/node_tree_update.cc +++ b/source/blender/blenkernel/intern/node_tree_update.cc @@ -8,6 +8,7 @@ #include "BLI_rand.hh" #include "BLI_set.hh" #include "BLI_stack.hh" +#include "BLI_timeit.hh" #include "BLI_vector_set.hh" #include "DNA_anim_types.h" @@ -30,6 +31,8 @@ #include "NOD_socket.hh" #include "NOD_texture.h" +#include "DEG_depsgraph_query.hh" + using namespace blender::nodes; /** diff --git a/source/blender/blenkernel/intern/node_tree_zones.cc b/source/blender/blenkernel/intern/node_tree_zones.cc index 54288723286..3f00b63c5ad 100644 --- a/source/blender/blenkernel/intern/node_tree_zones.cc +++ b/source/blender/blenkernel/intern/node_tree_zones.cc @@ -12,6 +12,8 @@ #include "BLI_bit_span_ops.hh" #include "BLI_set.hh" #include "BLI_struct_equality_utils.hh" +#include "BLI_task.hh" +#include "BLI_timeit.hh" namespace blender::bke { diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 15bf4f7c570..ae37e27d5bb 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -62,7 +62,7 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_DerivedMesh.hh" #include "BKE_action.h" @@ -72,16 +72,16 @@ #include "BKE_animsys.h" #include "BKE_armature.hh" #include "BKE_asset.hh" -#include "BKE_bpath.hh" +#include "BKE_bpath.h" #include "BKE_camera.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_constraint.h" #include "BKE_crazyspace.hh" #include "BKE_curve.hh" #include "BKE_curves.hh" #include "BKE_deform.hh" #include "BKE_displist.h" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_editmesh.hh" #include "BKE_editmesh_cache.hh" #include "BKE_effect.h" @@ -89,7 +89,7 @@ #include "BKE_fcurve_driver.h" #include "BKE_geometry_set.hh" #include "BKE_geometry_set_instances.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" @@ -123,7 +123,7 @@ #include "BKE_pose_backup.h" #include "BKE_preview_image.hh" #include "BKE_rigidbody.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_shader_fx.h" #include "BKE_softbody.h" #include "BKE_speaker.h" @@ -138,7 +138,7 @@ #include "DRW_engine.hh" #include "BLO_read_write.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "SEQ_sequencer.hh" @@ -1077,8 +1077,6 @@ static AssetTypeInfo AssetType_OB = { IDTypeInfo IDType_ID_OB = { /*id_code*/ ID_OB, /*id_filter*/ FILTER_ID_OB, - /* Could be more specific, but simpler to just always say 'yes' here. */ - /*dependencies_id_types*/ FILTER_ID_ALL, /*main_listbase_index*/ INDEX_ID_OB, /*struct_size*/ sizeof(Object), /*name*/ "Object", @@ -1179,16 +1177,14 @@ void BKE_object_modifier_hook_reset(Object *ob, HookModifierData *hmd) /* Calculate the world-space matrix for the pose-channel target first, * then carry on as usual. */ - mul_m4_m4m4(mat, hmd->object->object_to_world().ptr(), pchan->pose_mat); + mul_m4_m4m4(mat, hmd->object->object_to_world, pchan->pose_mat); invert_m4_m4(imat, mat); - mul_m4_m4m4(hmd->parentinv, imat, ob->object_to_world().ptr()); + mul_m4_m4m4(hmd->parentinv, imat, ob->object_to_world); } else { - invert_m4_m4(hmd->object->runtime->world_to_object.ptr(), - hmd->object->object_to_world().ptr()); - mul_m4_m4m4( - hmd->parentinv, hmd->object->world_to_object().ptr(), ob->object_to_world().ptr()); + invert_m4_m4(hmd->object->world_to_object, hmd->object->object_to_world); + mul_m4_m4m4(hmd->parentinv, hmd->object->world_to_object, ob->object_to_world); } } } @@ -1206,15 +1202,14 @@ void BKE_object_modifier_gpencil_hook_reset(Object *ob, HookGpencilModifierData /* Calculate the world-space matrix for the pose-channel target first, * then carry on as usual. */ - mul_m4_m4m4(mat, hmd->object->object_to_world().ptr(), pchan->pose_mat); + mul_m4_m4m4(mat, hmd->object->object_to_world, pchan->pose_mat); invert_m4_m4(imat, mat); - mul_m4_m4m4(hmd->parentinv, imat, ob->object_to_world().ptr()); + mul_m4_m4m4(hmd->parentinv, imat, ob->object_to_world); } else { - invert_m4_m4(hmd->object->runtime->world_to_object.ptr(), - hmd->object->object_to_world().ptr()); - mul_m4_m4m4(hmd->parentinv, hmd->object->world_to_object().ptr(), ob->object_to_world().ptr()); + invert_m4_m4(hmd->object->world_to_object, hmd->object->object_to_world); + mul_m4_m4m4(hmd->parentinv, hmd->object->world_to_object, ob->object_to_world); } } @@ -2985,10 +2980,10 @@ void BKE_object_matrix_local_get(Object *ob, float r_mat[4][4]) BKE_object_get_parent_matrix(ob, ob->parent, par_imat); invert_m4(par_imat); - mul_m4_m4m4(r_mat, par_imat, ob->object_to_world().ptr()); + mul_m4_m4m4(r_mat, par_imat, ob->object_to_world); } else { - copy_m4_m4(r_mat, ob->object_to_world().ptr()); + copy_m4_m4(r_mat, ob->object_to_world); } } @@ -3245,32 +3240,32 @@ void BKE_object_get_parent_matrix(Object *ob, Object *par, float r_parentmat[4][ } if (ok) { - mul_m4_m4m4(r_parentmat, par->object_to_world().ptr(), tmat); + mul_m4_m4m4(r_parentmat, par->object_to_world, tmat); } else { - copy_m4_m4(r_parentmat, par->object_to_world().ptr()); + copy_m4_m4(r_parentmat, par->object_to_world); } break; } case PARBONE: ob_parbone(ob, par, tmat); - mul_m4_m4m4(r_parentmat, par->object_to_world().ptr(), tmat); + mul_m4_m4m4(r_parentmat, par->object_to_world, tmat); break; case PARVERT1: unit_m4(r_parentmat); give_parvert(par, ob->par1, vec); - mul_v3_m4v3(r_parentmat[3], par->object_to_world().ptr(), vec); + mul_v3_m4v3(r_parentmat[3], par->object_to_world, vec); break; case PARVERT3: ob_parvert3(ob, par, tmat); - mul_m4_m4m4(r_parentmat, par->object_to_world().ptr(), tmat); + mul_m4_m4m4(r_parentmat, par->object_to_world, tmat); break; case PARSKEL: - copy_m4_m4(r_parentmat, par->object_to_world().ptr()); + copy_m4_m4(r_parentmat, par->object_to_world); break; } } @@ -3308,7 +3303,7 @@ static void solve_parenting( /* origin, for help line */ if (set_origin) { if ((ob->partype & PARTYPE) == PARSKEL) { - copy_v3_v3(ob->runtime->parent_display_origin, par->object_to_world().location()); + copy_v3_v3(ob->runtime->parent_display_origin, par->object_to_world[3]); } else { copy_v3_v3(ob->runtime->parent_display_origin, totmat[3]); @@ -3327,10 +3322,10 @@ static void object_where_is_calc_ex(Depsgraph *depsgraph, Object *par = ob->parent; /* calculate parent matrix */ - solve_parenting(ob, par, true, ob->runtime->object_to_world.ptr(), r_originmat); + solve_parenting(ob, par, true, ob->object_to_world, r_originmat); } else { - BKE_object_to_mat4(ob, ob->runtime->object_to_world.ptr()); + BKE_object_to_mat4(ob, ob->object_to_world); } /* try to fall back to the scene rigid body world if none given */ @@ -3347,7 +3342,7 @@ static void object_where_is_calc_ex(Depsgraph *depsgraph, } /* set negative scale flag in object */ - if (is_negative_m4(ob->object_to_world().ptr())) { + if (is_negative_m4(ob->object_to_world)) { ob->transflag |= OB_NEG_SCALE; } else { @@ -3395,7 +3390,7 @@ void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *o BKE_object_workob_clear(workob); workob->runtime = &workob_runtime; - unit_m4(workob->runtime->object_to_world.ptr()); + unit_m4(workob->object_to_world); unit_m4(workob->parentinv); unit_m4(workob->constinv); @@ -3487,8 +3482,8 @@ void BKE_object_apply_parent_inverse(Object *ob) * `inv(parent) @ world = parentinv` * `parentinv = inv(parent) @ world` * - * NOTE: If `ob->object_to_world().ptr()` has shear, then this `parentinv` is insufficient - * because `parent @ parentinv => shearless result` + * NOTE: If `ob->object_to_world` has shear, then this `parentinv` is insufficient because + * `parent @ parentinv => shearless result` * * Thus, local will have shear which cannot be decomposed into TRS: * `local = inv(parent @ parentinv) @ world` @@ -3516,7 +3511,7 @@ void BKE_object_apply_parent_inverse(Object *ob) copy_m4_m4(ob_local, ob->parentinv); invert_m4(ob_local); mul_m4_m4_post(ob_local, par_imat); - mul_m4_m4_post(ob_local, ob->object_to_world().ptr()); + mul_m4_m4_post(ob_local, ob->object_to_world); /* Send use_compat=False so the rotation is predictable. */ BKE_object_apply_mat4(ob, ob_local, false, false); @@ -3618,7 +3613,7 @@ static float3 boundbox_to_dimensions(const Object *ob, const std::optionalobject_to_world()); + const float3 scale = math::to_scale(float4x4(ob->object_to_world)); return scale * (bounds->max - bounds->min); } @@ -3669,8 +3664,10 @@ void BKE_object_minmax(Object *ob, float r_min[3], float r_max[3]) { using namespace blender; if (const std::optional> bounds = BKE_object_boundbox_get(ob)) { - minmax_v3v3_v3(r_min, r_max, math::transform_point(ob->object_to_world(), bounds->min)); - minmax_v3v3_v3(r_min, r_max, math::transform_point(ob->object_to_world(), bounds->max)); + minmax_v3v3_v3( + r_min, r_max, math::transform_point(float4x4(ob->object_to_world), bounds->min)); + minmax_v3v3_v3( + r_min, r_max, math::transform_point(float4x4(ob->object_to_world), bounds->max)); return; } float3 size = ob->scale; @@ -3680,14 +3677,14 @@ void BKE_object_minmax(Object *ob, float r_min[3], float r_max[3]) size *= ob->empty_drawsize; } - minmax_v3v3_v3(r_min, r_max, ob->object_to_world().location()); + minmax_v3v3_v3(r_min, r_max, ob->object_to_world[3]); float3 vec; - copy_v3_v3(vec, ob->object_to_world().location()); + copy_v3_v3(vec, ob->object_to_world[3]); add_v3_v3(vec, size); minmax_v3v3_v3(r_min, r_max, vec); - copy_v3_v3(vec, ob->object_to_world().location()); + copy_v3_v3(vec, ob->object_to_world[3]); sub_v3_v3(vec, size); minmax_v3v3_v3(r_min, r_max, vec); } @@ -3733,12 +3730,12 @@ bool BKE_object_empty_image_data_is_visible_in_view3d(const Object *ob, const Re * however the issue with empty objects being visible when viewed from the side * is only noticeable in orthographic views. */ float3 view_dir; - sub_v3_v3v3(view_dir, rv3d->viewinv[3], ob->object_to_world().location()); - dot = dot_v3v3(ob->object_to_world().ptr()[2], view_dir); + sub_v3_v3v3(view_dir, rv3d->viewinv[3], ob->object_to_world[3]); + dot = dot_v3v3(ob->object_to_world[2], view_dir); eps = 0.0f; } else { - dot = dot_v3v3(ob->object_to_world().ptr()[2], rv3d->viewinv[2]); + dot = dot_v3v3(ob->object_to_world[2], rv3d->viewinv[2]); eps = 1e-5f; } if (visibility_flag & OB_EMPTY_IMAGE_HIDE_BACK) { @@ -3755,7 +3752,7 @@ bool BKE_object_empty_image_data_is_visible_in_view3d(const Object *ob, const Re if (visibility_flag & OB_EMPTY_IMAGE_HIDE_NON_AXIS_ALIGNED) { float3 proj, ob_z_axis; - normalize_v3_v3(ob_z_axis, ob->object_to_world().ptr()[2]); + normalize_v3_v3(ob_z_axis, ob->object_to_world[2]); project_plane_v3_v3v3(proj, ob_z_axis, rv3d->viewinv[2]); const float proj_length_sq = len_squared_v3(proj); if (proj_length_sq > 1e-5f) { @@ -3949,7 +3946,7 @@ void BKE_scene_foreach_display_point(Depsgraph *depsgraph, DEG_ITER_OBJECT_FLAG_DUPLI; DEG_OBJECT_ITER_BEGIN (°_iter_settings, ob) { if ((ob->base_flag & BASE_SELECTED) != 0) { - BKE_object_foreach_display_point(ob, ob->object_to_world().ptr(), func_cb, user_data); + BKE_object_foreach_display_point(ob, ob->object_to_world, func_cb, user_data); } } DEG_OBJECT_ITER_END; @@ -3992,10 +3989,10 @@ void *BKE_object_tfm_backup(Object *ob) copy_v3_v3(obtfm->drotAxis, ob->drotAxis); obtfm->rotAngle = ob->rotAngle; obtfm->drotAngle = ob->drotAngle; - copy_m4_m4(obtfm->obmat, ob->object_to_world().ptr()); + copy_m4_m4(obtfm->obmat, ob->object_to_world); copy_m4_m4(obtfm->parentinv, ob->parentinv); copy_m4_m4(obtfm->constinv, ob->constinv); - copy_m4_m4(obtfm->imat, ob->world_to_object().ptr()); + copy_m4_m4(obtfm->imat, ob->world_to_object); return (void *)obtfm; } @@ -4015,10 +4012,10 @@ void BKE_object_tfm_restore(Object *ob, void *obtfm_pt) copy_v3_v3(ob->drotAxis, obtfm->drotAxis); ob->rotAngle = obtfm->rotAngle; ob->drotAngle = obtfm->drotAngle; - copy_m4_m4(ob->runtime->object_to_world.ptr(), obtfm->obmat); + copy_m4_m4(ob->object_to_world, obtfm->obmat); copy_m4_m4(ob->parentinv, obtfm->parentinv); copy_m4_m4(ob->constinv, obtfm->constinv); - copy_m4_m4(ob->runtime->world_to_object.ptr(), obtfm->imat); + copy_m4_m4(ob->world_to_object, obtfm->imat); } /** \} */ @@ -5061,7 +5058,7 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot) for (i = 0; i < positions.size(); i++) { if (index[i] != ORIGINDEX_NONE) { float co[3]; - mul_v3_m4v3(co, ob->object_to_world().ptr(), positions[i]); + mul_v3_m4v3(co, ob->object_to_world, positions[i]); BLI_kdtree_3d_insert(tree, index[i], co); tot++; } @@ -5075,7 +5072,7 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot) for (i = 0; i < tot; i++) { float co[3]; - mul_v3_m4v3(co, ob->object_to_world().ptr(), positions[i]); + mul_v3_m4v3(co, ob->object_to_world, positions[i]); BLI_kdtree_3d_insert(tree, i, co); } } @@ -5104,7 +5101,7 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot) a = nu->pntsu; while (a--) { float co[3]; - mul_v3_m4v3(co, ob->object_to_world().ptr(), bezt->vec[1]); + mul_v3_m4v3(co, ob->object_to_world, bezt->vec[1]); BLI_kdtree_3d_insert(tree, i++, co); bezt++; } @@ -5116,7 +5113,7 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot) a = nu->pntsu * nu->pntsv; while (a--) { float co[3]; - mul_v3_m4v3(co, ob->object_to_world().ptr(), bp->vec); + mul_v3_m4v3(co, ob->object_to_world, bp->vec); BLI_kdtree_3d_insert(tree, i++, co); bp++; } @@ -5139,7 +5136,7 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot) for (bp = lt->def; i < tot; bp++) { float co[3]; - mul_v3_m4v3(co, ob->object_to_world().ptr(), bp->vec); + mul_v3_m4v3(co, ob->object_to_world, bp->vec); BLI_kdtree_3d_insert(tree, i++, co); } @@ -5360,12 +5357,3 @@ void BKE_object_replace_data_on_shallow_copy(Object *ob, ID *new_data) } /** \} */ - -const blender::float4x4 &Object::object_to_world() const -{ - return this->runtime->object_to_world; -} -const blender::float4x4 &Object::world_to_object() const -{ - return this->runtime->world_to_object; -} diff --git a/source/blender/blenkernel/intern/object_deform.cc b/source/blender/blenkernel/intern/object_deform.cc index f17c90630e8..cbc5c84b300 100644 --- a/source/blender/blenkernel/intern/object_deform.cc +++ b/source/blender/blenkernel/intern/object_deform.cc @@ -11,7 +11,7 @@ #include "MEM_guardedalloc.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLI_ghash.h" #include "BLI_listbase.h" diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc index 161d1a666ab..3338f27847c 100644 --- a/source/blender/blenkernel/intern/object_dupli.cc +++ b/source/blender/blenkernel/intern/object_dupli.cc @@ -17,37 +17,48 @@ #include "BLI_string_utf8.h" #include "BLI_array.hh" +#include "BLI_math_color.hh" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" +#include "BLI_math_matrix.hh" #include "BLI_math_rotation.h" #include "BLI_math_vector.hh" #include "BLI_rand.h" #include "BLI_span.hh" #include "BLI_vector.hh" +#include "DNA_anim_types.h" #include "DNA_collection_types.h" #include "DNA_curves_types.h" #include "DNA_grease_pencil_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_pointcloud_types.h" #include "DNA_scene_types.h" +#include "DNA_vfont_types.h" #include "DNA_volume_types.h" -#include "BKE_collection.hh" -#include "BKE_duplilist.hh" +#include "BKE_collection.h" +#include "BKE_duplilist.h" #include "BKE_editmesh.hh" #include "BKE_editmesh_cache.hh" #include "BKE_geometry_set.hh" #include "BKE_geometry_set_instances.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_instances.hh" +#include "BKE_lattice.hh" #include "BKE_main.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_iterators.hh" +#include "BKE_mesh_runtime.hh" +#include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" #include "BKE_particle.h" +#include "BKE_scene.h" +#include "BKE_type_conversions.hh" #include "BKE_vfont.hh" #include "DEG_depsgraph.hh" @@ -60,6 +71,7 @@ #include "RNA_access.hh" #include "RNA_path.hh" #include "RNA_prototypes.h" +#include "RNA_types.hh" #include "MOD_nodes.hh" @@ -507,8 +519,8 @@ static void make_duplis_collection(const DupliContext *ctx) /* Combine collection offset and `obmat`. */ unit_m4(collection_mat); sub_v3_v3(collection_mat[3], collection->instance_offset); - mul_m4_m4m4(collection_mat, ob->object_to_world().ptr(), collection_mat); - /* Don't access 'ob->object_to_world().ptr()' from now on. */ + mul_m4_m4m4(collection_mat, ob->object_to_world, collection_mat); + /* Don't access 'ob->object_to_world' from now on. */ eEvaluationMode mode = DEG_get_mode(ctx->depsgraph); FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (collection, cob, mode) { @@ -516,7 +528,7 @@ static void make_duplis_collection(const DupliContext *ctx) float mat[4][4]; /* Collection dupli-offset, should apply after everything else. */ - mul_m4_m4m4(mat, collection_mat, cob->object_to_world().ptr()); + mul_m4_m4m4(mat, collection_mat, cob->object_to_world); make_dupli(ctx, cob, mat, _base_id); @@ -622,11 +634,11 @@ static DupliObject *vertex_dupli(const DupliContext *ctx, /* Make offset relative to inst_ob using relative child transform. */ mul_mat3_m4_v3(child_imat, obmat[3]); /* Apply `obmat` _after_ the local vertex transform. */ - mul_m4_m4m4(obmat, inst_ob->object_to_world().ptr(), obmat); + mul_m4_m4m4(obmat, inst_ob->object_to_world, obmat); /* Space matrix is constructed by removing `obmat` transform, * this yields the world-space transform for recursive duplis. */ - mul_m4_m4m4(space_mat, obmat, inst_ob->world_to_object().ptr()); + mul_m4_m4m4(space_mat, obmat, inst_ob->world_to_object); DupliObject *dob = make_dupli(ctx, inst_ob, obmat, index); @@ -645,10 +657,10 @@ static void make_child_duplis_verts_from_mesh(const DupliContext *ctx, const int totvert = vdd->totvert; - invert_m4_m4(inst_ob->runtime->world_to_object.ptr(), inst_ob->object_to_world().ptr()); + invert_m4_m4(inst_ob->world_to_object, inst_ob->object_to_world); /* Relative transform from parent to child space. */ float child_imat[4][4]; - mul_m4_m4m4(child_imat, inst_ob->world_to_object().ptr(), ctx->object->object_to_world().ptr()); + mul_m4_m4m4(child_imat, inst_ob->world_to_object, ctx->object->object_to_world); for (int i = 0; i < totvert; i++) { DupliObject *dob = vertex_dupli(vdd->params.ctx, @@ -672,10 +684,10 @@ static void make_child_duplis_verts_from_editmesh(const DupliContext *ctx, BMEditMesh *em = vdd->em; const bool use_rotation = vdd->params.use_rotation; - invert_m4_m4(inst_ob->runtime->world_to_object.ptr(), inst_ob->object_to_world().ptr()); + invert_m4_m4(inst_ob->world_to_object, inst_ob->object_to_world); /* Relative transform from parent to child space. */ float child_imat[4][4]; - mul_m4_m4m4(child_imat, inst_ob->world_to_object().ptr(), ctx->object->object_to_world().ptr()); + mul_m4_m4m4(child_imat, inst_ob->world_to_object, ctx->object->object_to_world); BMVert *v; BMIter iter; @@ -799,7 +811,7 @@ static void make_duplis_font(const DupliContext *ctx) return; } - copy_m4_m4(pmat, par->object_to_world().ptr()); + copy_m4_m4(pmat, par->object_to_world); /* In `par` the family name is stored, use this to find the other objects. */ @@ -844,7 +856,7 @@ static void make_duplis_font(const DupliContext *ctx) mul_m4_v3(pmat, vec); - copy_m4_m4(obmat, par->object_to_world().ptr()); + copy_m4_m4(obmat, par->object_to_world); if (UNLIKELY(ct->rot != 0.0f)) { float rmat[4][4]; @@ -966,8 +978,7 @@ static void make_duplis_geometry_set_impl(const DupliContext *ctx, make_dupli(ctx_for_instance, &object, matrix, id, &geometry_set, i); float space_matrix[4][4]; - mul_m4_m4m4( - space_matrix, instance_offset_matrices[i].ptr(), object.world_to_object().ptr()); + mul_m4_m4m4(space_matrix, instance_offset_matrices[i].ptr(), object.world_to_object); mul_m4_m4_pre(space_matrix, parent_transform); make_recursive_duplis(ctx_for_instance, &object, space_matrix, id, &geometry_set, i); break; @@ -1000,7 +1011,7 @@ static void make_duplis_geometry_set_impl(const DupliContext *ctx, } float instance_matrix[4][4]; - mul_m4_m4m4(instance_matrix, collection_matrix, object->object_to_world().ptr()); + mul_m4_m4m4(instance_matrix, collection_matrix, object->object_to_world); make_dupli(&sub_ctx, object, instance_matrix, object_id++); make_recursive_duplis(&sub_ctx, object, collection_matrix, object_id++); @@ -1036,8 +1047,7 @@ static void make_duplis_geometry_set_impl(const DupliContext *ctx, static void make_duplis_geometry_set(const DupliContext *ctx) { const GeometrySet *geometry_set = ctx->object->runtime->geometry_set_eval; - make_duplis_geometry_set_impl( - ctx, *geometry_set, ctx->object->object_to_world().ptr(), false, false); + make_duplis_geometry_set_impl(ctx, *geometry_set, ctx->object->object_to_world, false, false); } static const DupliGenerator gen_dupli_geometry_set = { @@ -1143,11 +1153,11 @@ static DupliObject *face_dupli(const DupliContext *ctx, } /* Apply `obmat` _after_ the local face transform. */ - mul_m4_m4m4(obmat, inst_ob->object_to_world().ptr(), obmat); + mul_m4_m4m4(obmat, inst_ob->object_to_world, obmat); /* Space matrix is constructed by removing `obmat` transform, * this yields the world-space transform for recursive duplis. */ - mul_m4_m4m4(space_mat, obmat, inst_ob->world_to_object().ptr()); + mul_m4_m4m4(space_mat, obmat, inst_ob->world_to_object); DupliObject *dob = make_dupli(ctx, inst_ob, obmat, index); @@ -1220,9 +1230,9 @@ static void make_child_duplis_faces_from_mesh(const DupliContext *ctx, float child_imat[4][4]; - invert_m4_m4(inst_ob->runtime->world_to_object.ptr(), inst_ob->object_to_world().ptr()); + invert_m4_m4(inst_ob->world_to_object, inst_ob->object_to_world); /* Relative transform from parent to child space. */ - mul_m4_m4m4(child_imat, inst_ob->world_to_object().ptr(), ctx->object->object_to_world().ptr()); + mul_m4_m4m4(child_imat, inst_ob->world_to_object, ctx->object->object_to_world); const float scale_fac = ctx->object->instance_faces_scale; for (const int a : blender::IndexRange(totface)) { @@ -1267,9 +1277,9 @@ static void make_child_duplis_faces_from_editmesh(const DupliContext *ctx, BLI_assert((vert_positions_deform == nullptr) || (em->bm->elem_index_dirty & BM_VERT) == 0); - invert_m4_m4(inst_ob->runtime->world_to_object.ptr(), inst_ob->object_to_world().ptr()); + invert_m4_m4(inst_ob->world_to_object, inst_ob->object_to_world); /* Relative transform from parent to child space. */ - mul_m4_m4m4(child_imat, inst_ob->world_to_object().ptr(), ctx->object->object_to_world().ptr()); + mul_m4_m4m4(child_imat, inst_ob->world_to_object, ctx->object->object_to_world); const float scale_fac = ctx->object->instance_faces_scale; BM_ITER_MESH_INDEX (f, &iter, em->bm, BM_FACES_OF_MESH, a) { @@ -1402,7 +1412,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem sim.psmd = psys_get_modifier(par, psys); /* Make sure emitter `world_to_object` is in global coordinates instead of render view * coordinates. */ - invert_m4_m4(par->runtime->world_to_object.ptr(), par->object_to_world().ptr()); + invert_m4_m4(par->world_to_object, par->object_to_world); /* First check for loops (particle system object used as dupli-object). */ if (part->ren_as == PART_DRAW_OB) { @@ -1592,7 +1602,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem b = 0; FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (part->instance_collection, object, mode) { - copy_m4_m4(tmat, oblist[b]->object_to_world().ptr()); + copy_m4_m4(tmat, oblist[b]->object_to_world); /* Apply collection instance offset. */ sub_v3_v3(tmat[3], part->instance_collection->instance_offset); @@ -1615,7 +1625,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem } else { float obmat[4][4]; - copy_m4_m4(obmat, ob->object_to_world().ptr()); + copy_m4_m4(obmat, ob->object_to_world); float vec[3]; copy_v3_v3(vec, obmat[3]); @@ -1806,11 +1816,8 @@ ListBase *object_duplilist_preview(Depsgraph *depsgraph, geo_log::GeoModifierLog::find_viewer_node_log_for_path(*viewer_path)) { ctx.preview_base_geometry = &viewer_log->geometry; - make_duplis_geometry_set_impl(&ctx, - viewer_log->geometry, - ob_eval->object_to_world().ptr(), - true, - ob_eval->type == OB_CURVES); + make_duplis_geometry_set_impl( + &ctx, viewer_log->geometry, ob_eval->object_to_world, true, ob_eval->type == OB_CURVES); } } return duplilist; diff --git a/source/blender/blenkernel/intern/object_update.cc b/source/blender/blenkernel/intern/object_update.cc index d23507c2416..4c65e91aea8 100644 --- a/source/blender/blenkernel/intern/object_update.cc +++ b/source/blender/blenkernel/intern/object_update.cc @@ -6,7 +6,12 @@ * \ingroup bke */ +#include "DNA_anim_types.h" +#include "DNA_collection_types.h" #include "DNA_constraint_types.h" +#include "DNA_gpencil_legacy_types.h" +#include "DNA_key_types.h" +#include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_modifier_types.h" #include "DNA_scene_types.h" @@ -14,21 +19,28 @@ #include "BLI_blenlib.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" +#include "BLI_threads.h" #include "BLI_utildefines.h" #include "BKE_DerivedMesh.hh" +#include "BKE_action.h" #include "BKE_armature.hh" #include "BKE_constraint.h" #include "BKE_curve.hh" #include "BKE_curves.h" #include "BKE_displist.h" #include "BKE_editmesh.hh" +#include "BKE_effect.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_grease_pencil.h" #include "BKE_grease_pencil.hh" +#include "BKE_image.h" +#include "BKE_key.hh" #include "BKE_lattice.hh" #include "BKE_layer.hh" +#include "BKE_light.h" +#include "BKE_material.h" #include "BKE_mball.hh" #include "BKE_mesh.hh" #include "BKE_object.hh" @@ -36,7 +48,7 @@ #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_pointcloud.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_volume.hh" #include "MEM_guardedalloc.h" @@ -57,7 +69,7 @@ void BKE_object_eval_local_transform(Depsgraph *depsgraph, Object *ob) DEG_debug_print_eval(depsgraph, __func__, ob->id.name, ob); /* calculate local matrix */ - BKE_object_to_mat4(ob, ob->runtime->object_to_world.ptr()); + BKE_object_to_mat4(ob, ob->object_to_world); } void BKE_object_eval_parent(Depsgraph *depsgraph, Object *ob) @@ -74,18 +86,18 @@ void BKE_object_eval_parent(Depsgraph *depsgraph, Object *ob) /* get local matrix (but don't calculate it, as that was done already!) */ /* XXX: redundant? */ - copy_m4_m4(locmat, ob->object_to_world().ptr()); + copy_m4_m4(locmat, ob->object_to_world); /* get parent effect matrix */ BKE_object_get_parent_matrix(ob, par, totmat); /* total */ mul_m4_m4m4(tmat, totmat, ob->parentinv); - mul_m4_m4m4(ob->runtime->object_to_world.ptr(), tmat, locmat); + mul_m4_m4m4(ob->object_to_world, tmat, locmat); /* origin, for help line */ if ((ob->partype & PARTYPE) == PARSKEL) { - copy_v3_v3(ob->runtime->parent_display_origin, par->object_to_world().location()); + copy_v3_v3(ob->runtime->parent_display_origin, par->object_to_world[3]); } else { copy_v3_v3(ob->runtime->parent_display_origin, totmat[3]); @@ -117,9 +129,9 @@ void BKE_object_eval_transform_final(Depsgraph *depsgraph, Object *ob) DEG_debug_print_eval(depsgraph, __func__, ob->id.name, ob); /* Make sure inverse matrix is always up to date. This way users of it * do not need to worry about recalculating it. */ - invert_m4_m4_safe(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4_safe(ob->world_to_object, ob->object_to_world); /* Set negative scale flag in object. */ - if (is_negative_m4(ob->object_to_world().ptr())) { + if (is_negative_m4(ob->object_to_world)) { ob->transflag |= OB_NEG_SCALE; } else { @@ -240,8 +252,8 @@ void BKE_object_sync_to_original(Depsgraph *depsgraph, Object *object) /* Base flags. */ object_orig->base_flag = object->base_flag; /* Transformation flags. */ - copy_m4_m4(object_orig->runtime->object_to_world.ptr(), object->object_to_world().ptr()); - copy_m4_m4(object_orig->runtime->world_to_object.ptr(), object->world_to_object().ptr()); + copy_m4_m4(object_orig->object_to_world, object->object_to_world); + copy_m4_m4(object_orig->world_to_object, object->world_to_object); copy_m4_m4(object_orig->constinv, object->constinv); object_orig->transflag = object->transflag; object_orig->flag = object->flag; diff --git a/source/blender/blenkernel/intern/packedFile.cc b/source/blender/blenkernel/intern/packedFile.cc index e879f05ac09..9cb1c3c0693 100644 --- a/source/blender/blenkernel/intern/packedFile.cc +++ b/source/blender/blenkernel/intern/packedFile.cc @@ -32,7 +32,7 @@ #include "BKE_image_format.h" #include "BKE_main.hh" #include "BKE_packedFile.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_sound.h" #include "BKE_vfont.hh" #include "BKE_volume.hh" diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index dc26aca972f..e66f1977ef5 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -35,7 +35,7 @@ #include "BLI_utildefines.h" #include "BLI_vector.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_attribute.hh" #include "BKE_brush.hh" @@ -61,7 +61,7 @@ #include "BKE_object_types.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_subdiv_ccg.hh" #include "BKE_subsurf.hh" @@ -144,7 +144,6 @@ static void palette_undo_preserve(BlendLibReader * /*reader*/, ID *id_new, ID *i IDTypeInfo IDType_ID_PAL = { /*id_code*/ ID_PAL, /*id_filter*/ FILTER_ID_PAL, - /*dependencies_id_types*/ 0, /*main_listbase_index*/ INDEX_ID_PAL, /*struct_size*/ sizeof(Palette), /*name*/ "Palette", @@ -212,7 +211,6 @@ static void paint_curve_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_PC = { /*id_code*/ ID_PC, /*id_filter*/ FILTER_ID_PC, - /*dependencies_id_types*/ 0, /*main_listbase_index*/ INDEX_ID_PC, /*struct_size*/ sizeof(PaintCurve), /*name*/ "PaintCurve", @@ -1236,7 +1234,7 @@ void BKE_paint_stroke_get_average(const Scene *scene, const Object *ob, float st mul_v3_v3fl(stroke, ups->average_stroke_accum, fac); } else { - copy_v3_v3(stroke, ob->object_to_world().location()); + copy_v3_v3(stroke, ob->object_to_world[3]); } } diff --git a/source/blender/blenkernel/intern/paint_toolslots.cc b/source/blender/blenkernel/intern/paint_toolslots.cc index 4ab9259de8f..18770584f56 100644 --- a/source/blender/blenkernel/intern/paint_toolslots.cc +++ b/source/blender/blenkernel/intern/paint_toolslots.cc @@ -11,6 +11,7 @@ #include "MEM_guardedalloc.h" #include "DNA_brush_types.h" +#include "DNA_modifier_types.h" #include "DNA_scene_types.h" #include "BLI_utildefines.h" diff --git a/source/blender/blenkernel/intern/particle.cc b/source/blender/blenkernel/intern/particle.cc index 75ae0fd2b0a..ba367151c2c 100644 --- a/source/blender/blenkernel/intern/particle.cc +++ b/source/blender/blenkernel/intern/particle.cc @@ -45,12 +45,13 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "BKE_anim_data.h" #include "BKE_anim_path.h" #include "BKE_boids.h" #include "BKE_cloth.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_colortools.hh" #include "BKE_customdata.hh" #include "BKE_deform.hh" @@ -62,14 +63,16 @@ #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_material.h" #include "BKE_mesh.hh" #include "BKE_mesh_legacy_convert.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_texture.h" #include "DEG_depsgraph.hh" @@ -379,7 +382,6 @@ static void particle_settings_blend_read_after_liblink(BlendLibReader * /*reader IDTypeInfo IDType_ID_PA = { /*id_code*/ ID_PA, /*id_filter*/ FILTER_ID_PA, - /*dependencies_id_types*/ FILTER_ID_OB | FILTER_ID_GR | FILTER_ID_TE, /*main_listbase_index*/ INDEX_ID_PA, /*struct_size*/ sizeof(ParticleSettings), /*name*/ "ParticleSettings", @@ -2300,8 +2302,8 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors) nullptr, nullptr); - mul_m4_v3(sim->ob->object_to_world().ptr(), state.co); - mul_mat3_m4_v3(sim->ob->object_to_world().ptr(), state.vel); + mul_m4_v3(sim->ob->object_to_world, state.co); + mul_mat3_m4_v3(sim->ob->object_to_world, state.vel); pd_point_from_particle(sim, pa, &state, &point); @@ -2389,8 +2391,8 @@ bool do_guides(Depsgraph *depsgraph, } } - mul_m4_v3(eff->ob->object_to_world().ptr(), guidevec); - mul_mat3_m4_v3(eff->ob->object_to_world().ptr(), guidedir); + mul_m4_v3(eff->ob->object_to_world, guidevec); + mul_mat3_m4_v3(eff->ob->object_to_world, guidedir); normalize_v3(guidedir); @@ -2919,7 +2921,7 @@ static void psys_thread_create_path(ParticleTask *task, nullptr, orco); - mul_m4_v3(ob->object_to_world().ptr(), co); + mul_m4_v3(ob->object_to_world, co); for (w = 0; w < 4; w++) { sub_v3_v3v3(off1[w], co, key[w]->co); @@ -3382,7 +3384,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re /* dynamic hair is in object space */ /* keyed and baked are already in global space */ if (hair_mesh) { - mul_m4_v3(sim->ob->object_to_world().ptr(), ca->co); + mul_m4_v3(sim->ob->object_to_world, ca->co); } else if (!keyed && !baked && !(psys->flag & PSYS_GLOBAL_HAIR)) { mul_m4_v3(hairmat, ca->co); @@ -3909,7 +3911,7 @@ void psys_mat_hair_to_global( psys_mat_hair_to_object(ob, mesh, from, pa, facemat); - mul_m4_m4m4(hairmat, ob->object_to_world().ptr(), facemat); + mul_m4_m4m4(hairmat, ob->object_to_world, facemat); } /************************************************/ @@ -4280,7 +4282,7 @@ static void get_cpa_texture(Mesh *mesh, case TEXCO_OBJECT: copy_v3_v3(texvec, par->state.co); if (mtex->object) { - mul_m4_v3(mtex->object->world_to_object().ptr(), texvec); + mul_m4_v3(mtex->object->world_to_object, texvec); } break; case TEXCO_UV: @@ -4370,7 +4372,7 @@ void psys_get_texture( case TEXCO_OBJECT: copy_v3_v3(texvec, pa->state.co); if (mtex->object) { - mul_m4_v3(mtex->object->world_to_object().ptr(), texvec); + mul_m4_v3(mtex->object->world_to_object, texvec); } break; case TEXCO_UV: @@ -4653,8 +4655,8 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, do_particle_interpolation(psys, p, pa, t, &pind, state); if (pind.mesh) { - mul_m4_v3(sim->ob->object_to_world().ptr(), state->co); - mul_mat3_m4_v3(sim->ob->object_to_world().ptr(), state->vel); + mul_m4_v3(sim->ob->object_to_world, state->co); + mul_mat3_m4_v3(sim->ob->object_to_world, state->vel); } else if (!keyed && !cached && !(psys->flag & PSYS_GLOBAL_HAIR)) { if ((pa->flag & PARS_REKEY) == 0) { @@ -4677,7 +4679,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, } } else if (totchild) { - // invert_m4_m4(imat, ob->object_to_world().ptr()); + // invert_m4_m4(imat, ob->object_to_world); /* interpolate childcache directly if it exists */ if (psys->childcache) { @@ -4734,7 +4736,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, * positioning it accurately to the surface of the emitter. */ // copy_v3_v3(cpa_1st, co); - // mul_m4_v3(ob->object_to_world().ptr(), cpa_1st); + // mul_m4_v3(ob->object_to_world, cpa_1st); pa = psys->particles + cpa->parent; @@ -5199,7 +5201,7 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, } if (psys->part->rotmode == PART_ROT_VEL) { - transpose_m3_m4(nmat, ob->world_to_object().ptr()); + transpose_m3_m4(nmat, ob->world_to_object); mul_m3_v3(nmat, nor); normalize_v3(nor); diff --git a/source/blender/blenkernel/intern/particle_child.cc b/source/blender/blenkernel/intern/particle_child.cc index b2032d34683..0ffa82e46bc 100644 --- a/source/blender/blenkernel/intern/particle_child.cc +++ b/source/blender/blenkernel/intern/particle_child.cc @@ -184,7 +184,7 @@ static void do_kink_spiral(ParticleThreadContext *ctx, zero_v3(kink_base); kink_base[part->kink_axis] = 1.0f; - mul_mat3_m4_v3(ctx->sim.ob->object_to_world().ptr(), kink_base); + mul_mat3_m4_v3(ctx->sim.ob->object_to_world, kink_base); /* Fill in invariant part of modifier context. */ ParticleChildModifierContext modifier_ctx = {nullptr}; @@ -393,7 +393,7 @@ void do_kink(ParticleKey *state, float flat, short type, short axis, - const float obmat[4][4], + float obmat[4][4], int smooth_start) { float kink[3] = {1.0f, 0.0f, 0.0f}, par_vec[3]; @@ -872,7 +872,7 @@ void do_child_modifiers(const ParticleChildModifierContext *modifier_ctx, part->kink_flat, part->kink, part->kink_axis, - sim->ob->object_to_world().ptr(), + sim->ob->object_to_world, smooth_start); } } diff --git a/source/blender/blenkernel/intern/particle_distribute.cc b/source/blender/blenkernel/intern/particle_distribute.cc index 21eda684ef0..2834d4f5246 100644 --- a/source/blender/blenkernel/intern/particle_distribute.cc +++ b/source/blender/blenkernel/intern/particle_distribute.cc @@ -22,12 +22,15 @@ #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_particle_types.h" +#include "DNA_scene_types.h" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" #include "BKE_mesh_legacy_convert.hh" +#include "BKE_mesh_runtime.hh" +#include "BKE_object.hh" #include "BKE_particle.h" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/blenkernel/intern/particle_system.cc b/source/blender/blenkernel/intern/particle_system.cc index ce3e10aa146..3e2a86bb516 100644 --- a/source/blender/blenkernel/intern/particle_system.cc +++ b/source/blender/blenkernel/intern/particle_system.cc @@ -15,8 +15,10 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_boid_types.h" #include "DNA_cloth_types.h" +#include "DNA_curve_types.h" #include "DNA_listBase.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -39,6 +41,7 @@ #include "BLI_string_utils.hh" #include "BLI_task.h" #include "BLI_threads.h" +#include "BLI_time.h" #include "BLI_utildefines.h" #include "BKE_animsys.h" @@ -50,19 +53,26 @@ #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_mesh_legacy_convert.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_particle.h" +#include "BKE_bvhutils.hh" #include "BKE_cloth.hh" +#include "BKE_collection.h" +#include "BKE_lattice.hh" #include "BKE_material.h" #include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_pointcache.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" +#include "DEG_depsgraph_physics.hh" #include "DEG_depsgraph_query.hh" +#include "RE_texture.h" + /* FLUID sim particle import */ #ifdef WITH_FLUID # include "DNA_fluid_types.h" @@ -759,10 +769,10 @@ void psys_get_birth_coords( /* particles live in global space so */ /* let's convert: */ /* -location */ - mul_m4_v3(ob->object_to_world().ptr(), loc); + mul_m4_v3(ob->object_to_world, loc); /* -normal */ - mul_mat3_m4_v3(ob->object_to_world().ptr(), nor); + mul_mat3_m4_v3(ob->object_to_world, nor); normalize_v3(nor); /* -tangent */ @@ -780,7 +790,7 @@ void psys_get_birth_coords( fac = -sinf(float(M_PI) * (part->tanphase + phase)); madd_v3_v3fl(vtan, utan, fac); - mul_mat3_m4_v3(ob->object_to_world().ptr(), vtan); + mul_mat3_m4_v3(ob->object_to_world, vtan); copy_v3_v3(utan, nor); mul_v3_fl(utan, dot_v3v3(vtan, nor)); @@ -795,7 +805,7 @@ void psys_get_birth_coords( r_vel[1] = 2.0f * (psys_frand(psys, p + 11) - 0.5f); r_vel[2] = 2.0f * (psys_frand(psys, p + 12) - 0.5f); - mul_mat3_m4_v3(ob->object_to_world().ptr(), r_vel); + mul_mat3_m4_v3(ob->object_to_world, r_vel); normalize_v3(r_vel); } @@ -805,7 +815,7 @@ void psys_get_birth_coords( r_ave[1] = 2.0f * (psys_frand(psys, p + 14) - 0.5f); r_ave[2] = 2.0f * (psys_frand(psys, p + 15) - 0.5f); - mul_mat3_m4_v3(ob->object_to_world().ptr(), r_ave); + mul_mat3_m4_v3(ob->object_to_world, r_ave); normalize_v3(r_ave); } @@ -817,7 +827,7 @@ void psys_get_birth_coords( r_rot[3] = 2.0f * (psys_frand(psys, p + 19) - 0.5f); normalize_qt(r_rot); - mat4_to_quat(rot, ob->object_to_world().ptr()); + mat4_to_quat(rot, ob->object_to_world); mul_qt_qtqt(r_rot, r_rot, rot); } @@ -831,7 +841,7 @@ void psys_get_birth_coords( /* boids store direction in ave */ if (fabsf(nor[2]) == 1.0f) { - sub_v3_v3v3(state->ave, loc, ob->object_to_world().location()); + sub_v3_v3v3(state->ave, loc, ob->object_to_world[3]); normalize_v3(state->ave); } else { @@ -877,15 +887,15 @@ void psys_get_birth_coords( /* *emitter object orientation */ if (part->ob_vel[0] != 0.0f) { - normalize_v3_v3(vec, ob->object_to_world().ptr()[0]); + normalize_v3_v3(vec, ob->object_to_world[0]); madd_v3_v3fl(vel, vec, part->ob_vel[0]); } if (part->ob_vel[1] != 0.0f) { - normalize_v3_v3(vec, ob->object_to_world().ptr()[1]); + normalize_v3_v3(vec, ob->object_to_world[1]); madd_v3_v3fl(vel, vec, part->ob_vel[1]); } if (part->ob_vel[2] != 0.0f) { - normalize_v3_v3(vec, ob->object_to_world().ptr()[2]); + normalize_v3_v3(vec, ob->object_to_world[2]); madd_v3_v3fl(vel, vec, part->ob_vel[2]); } @@ -933,7 +943,7 @@ void psys_get_birth_coords( case PART_ROT_OB_X: case PART_ROT_OB_Y: case PART_ROT_OB_Z: - copy_v3_v3(rot_vec, ob->object_to_world().ptr()[part->rotmode - PART_ROT_OB_X]); + copy_v3_v3(rot_vec, ob->object_to_world[part->rotmode - PART_ROT_OB_X]); use_global_space = false; break; default: @@ -960,7 +970,7 @@ void psys_get_birth_coords( float q_obmat[4]; float q_imat[4]; - mat4_to_quat(q_obmat, ob->object_to_world().ptr()); + mat4_to_quat(q_obmat, ob->object_to_world); invert_qt_qt_normalized(q_imat, q_obmat); if (part->rotmode != PART_ROT_NOR_TAN) { @@ -3384,7 +3394,7 @@ static void hair_create_input_mesh(ParticleSimulationData *sim, use_hair = psys_hair_use_simulation(pa, max_length); psys_mat_hair_to_object(sim->ob, sim->psmd->mesh_final, psys->part->from, pa, hairmat); - mul_m4_m4m4(root_mat, sim->ob->object_to_world().ptr(), hairmat); + mul_m4_m4m4(root_mat, sim->ob->object_to_world, hairmat); normalize_m4(root_mat); bending_stiffness = std::clamp( @@ -3580,7 +3590,7 @@ static void save_hair(ParticleSimulationData *sim, float /*cfra*/) HairKey *key, *root; PARTICLE_P; - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); if (psys->totpart == 0) { return; @@ -3603,7 +3613,7 @@ static void save_hair(ParticleSimulationData *sim, float /*cfra*/) /* convert from global to geometry space */ copy_v3_v3(key->co, pa->state.co); - mul_m4_v3(ob->world_to_object().ptr(), key->co); + mul_m4_v3(ob->world_to_object, key->co); if (pa->totkey) { sub_v3_v3(key->co, root->co); @@ -4414,7 +4424,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, mul_v3_v3(pa->state.co, scaleAbs); /* Match domain scale. */ - mul_m4_v3(ob->object_to_world().ptr(), pa->state.co); + mul_m4_v3(ob->object_to_world, pa->state.co); /* Add origin offset to particle position. */ zero_v3(tmp); @@ -5001,7 +5011,7 @@ void particle_system_update(Depsgraph *depsgraph, /* Save matrix for duplicators, * at render-time the actual dupli-object's matrix is used so don't update! */ - invert_m4_m4(psys->imat, ob->object_to_world().ptr()); + invert_m4_m4(psys->imat, ob->object_to_world); BKE_particle_batch_cache_dirty_tag(psys, BKE_PARTICLE_BATCH_DIRTY_ALL); } diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.cc b/source/blender/blenkernel/intern/pbvh_bmesh.cc index 921f709b2c6..078e4774d21 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.cc +++ b/source/blender/blenkernel/intern/pbvh_bmesh.cc @@ -35,7 +35,7 @@ static CLG_LogRef LOG = {"pbvh.bmesh"}; /* Avoid skinny faces */ #define USE_EDGEQUEUE_EVEN_SUBDIV #ifdef USE_EDGEQUEUE_EVEN_SUBDIV -# include "BKE_global.hh" +# include "BKE_global.h" #endif namespace blender::bke::pbvh { @@ -1224,7 +1224,7 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx, PBVH *pbvh, BMEdge * static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx, PBVH *pbvh) { - const double start_time = BLI_time_now_seconds(); + const double start_time = BLI_check_seconds_timer(); bool any_subdivided = false; @@ -1267,7 +1267,7 @@ static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx, PBVH *pbvh #endif CLOG_INFO( - &LOG, 2, "Long edge subdivision took %f seconds.", BLI_time_now_seconds() - start_time); + &LOG, 2, "Long edge subdivision took %f seconds.", BLI_check_seconds_timer() - start_time); return any_subdivided; } @@ -1701,7 +1701,7 @@ static void pbvh_bmesh_collapse_edge( static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx, PBVH *pbvh) { - const double start_time = BLI_time_now_seconds(); + const double start_time = BLI_check_seconds_timer(); const float min_len_squared = pbvh->bm_min_edge_len * pbvh->bm_min_edge_len; bool any_collapsed = false; @@ -1751,7 +1751,8 @@ static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx, PBVH *pbvh BLI_ghash_free(deleted_verts, nullptr, nullptr); - CLOG_INFO(&LOG, 2, "Short edge collapse took %f seconds.", BLI_time_now_seconds() - start_time); + CLOG_INFO( + &LOG, 2, "Short edge collapse took %f seconds.", BLI_check_seconds_timer() - start_time); return any_collapsed; } diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc index 55906e4abe7..0a4a16f6ed5 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels.cc @@ -5,17 +5,20 @@ #include "BKE_attribute.hh" #include "BKE_customdata.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_mapping.hh" #include "BKE_pbvh_api.hh" #include "BKE_pbvh_pixels.hh" #include "DNA_image_types.h" +#include "DNA_object_types.h" #include "BLI_listbase.h" #include "BLI_math_geom.h" #include "BLI_math_vector.h" #include "BLI_task.h" +#include "BLI_time.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image_wrappers.hh" #include "pbvh_intern.hh" diff --git a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc index ad65e7ab8a4..371cf3e674f 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc @@ -472,7 +472,7 @@ struct Rows { return selected_pixels; } - void pack_into(const Span> selected_pixels, + void pack_into(const Vector> &selected_pixels, CopyPixelTile ©_tile) const { std::optional> last_group = std::nullopt; diff --git a/source/blender/blenkernel/intern/pointcache.cc b/source/blender/blenkernel/intern/pointcache.cc index 13238cbf74e..03490d320e4 100644 --- a/source/blender/blenkernel/intern/pointcache.cc +++ b/source/blender/blenkernel/intern/pointcache.cc @@ -43,21 +43,21 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_appdir.hh" #include "BKE_cloth.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_dynamicpaint.h" #include "BKE_fluid.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_softbody.h" #include "BLO_read_write.hh" @@ -3297,7 +3297,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker) char run[32], cur[32], etd[32]; int cancel = 0; - stime = ptime = BLI_time_now_seconds(); + stime = ptime = BLI_check_seconds_timer(); for (int fr = scene->r.cfra; fr <= endframe; fr += baker->quick_step, scene->r.cfra = fr) { BKE_scene_graph_update_for_newframe(depsgraph); @@ -3311,7 +3311,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker) printf("bake: frame %d :: %d\n", scene->r.cfra, endframe); } else { - ctime = BLI_time_now_seconds(); + ctime = BLI_check_seconds_timer(); fetd = (ctime - ptime) * (endframe - scene->r.cfra) / baker->quick_step; @@ -3343,7 +3343,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker) if (use_timer) { /* start with newline because of \r above */ - ptcache_dt_to_str(run, sizeof(run), BLI_time_now_seconds() - stime); + ptcache_dt_to_str(run, sizeof(run), BLI_check_seconds_timer() - stime); printf("\nBake %s %s (%i frames simulated).\n", (cancel ? "canceled after" : "finished in"), run, diff --git a/source/blender/blenkernel/intern/pointcloud.cc b/source/blender/blenkernel/intern/pointcloud.cc index 36bce76869d..daa2ccc412a 100644 --- a/source/blender/blenkernel/intern/pointcloud.cc +++ b/source/blender/blenkernel/intern/pointcloud.cc @@ -15,9 +15,11 @@ #include "BLI_bounds.hh" #include "BLI_index_range.hh" +#include "BLI_listbase.h" #include "BLI_math_vector.hh" #include "BLI_rand.h" #include "BLI_span.hh" +#include "BLI_string.h" #include "BLI_task.hh" #include "BLI_utildefines.h" #include "BLI_vector.hh" @@ -26,15 +28,19 @@ #include "BKE_bake_data_block_id.hh" #include "BKE_customdata.hh" #include "BKE_geometry_set.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_lib_remap.hh" +#include "BKE_main.hh" +#include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" #include "BKE_pointcloud.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph_query.hh" @@ -146,7 +152,6 @@ static void pointcloud_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_PT = { /*id_code*/ ID_PT, /*id_filter*/ FILTER_ID_PT, - /*dependencies_id_types*/ FILTER_ID_MA, /*main_listbase_index*/ INDEX_ID_PT, /*struct_size*/ sizeof(PointCloud), /*name*/ "PointCloud", diff --git a/source/blender/blenkernel/intern/preferences.cc b/source/blender/blenkernel/intern/preferences.cc index 790c90a6bf6..155b92eb2ca 100644 --- a/source/blender/blenkernel/intern/preferences.cc +++ b/source/blender/blenkernel/intern/preferences.cc @@ -10,6 +10,8 @@ #include +#include "DNA_asset_types.h" + #include "MEM_guardedalloc.h" #include "BLI_fileops.h" @@ -22,7 +24,7 @@ #include "BKE_appdir.hh" #include "BKE_preferences.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_userdef_types.h" diff --git a/source/blender/blenkernel/intern/preview_image.cc b/source/blender/blenkernel/intern/preview_image.cc index f31881840de..6c53b325f64 100644 --- a/source/blender/blenkernel/intern/preview_image.cc +++ b/source/blender/blenkernel/intern/preview_image.cc @@ -25,9 +25,7 @@ #include "BLI_ghash.h" #include "BLI_string.h" #include "BLI_string_ref.hh" -#ifndef NDEBUG -# include "BLI_threads.h" -#endif +#include "BLI_threads.h" #include "BLO_read_write.hh" diff --git a/source/blender/blenkernel/intern/report.cc b/source/blender/blenkernel/intern/report.cc index a40a544c9e3..ae709f0fd56 100644 --- a/source/blender/blenkernel/intern/report.cc +++ b/source/blender/blenkernel/intern/report.cc @@ -20,10 +20,10 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" -#include "BKE_global.hh" /* G.background only */ -#include "BKE_report.hh" +#include "BKE_global.h" /* G.background only */ +#include "BKE_report.h" const char *BKE_report_type_str(eReportType type) { diff --git a/source/blender/blenkernel/intern/rigidbody.cc b/source/blender/blenkernel/intern/rigidbody.cc index ac8aa5cd2eb..6e30868e178 100644 --- a/source/blender/blenkernel/intern/rigidbody.cc +++ b/source/blender/blenkernel/intern/rigidbody.cc @@ -36,9 +36,9 @@ #include "DNA_rigidbody_types.h" #include "DNA_scene_types.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_effect.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_mesh.hh" @@ -46,9 +46,9 @@ #include "BKE_object.hh" #include "BKE_object_types.hh" #include "BKE_pointcache.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_rigidbody.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #ifdef WITH_BULLET # include "BKE_lib_id.hh" # include "BKE_lib_query.hh" @@ -685,7 +685,7 @@ void BKE_rigidbody_calc_volume(Object *ob, float *r_vol) corner_verts.data(), &volume, nullptr); - const float volume_scale = mat4_to_volume_scale(ob->object_to_world().ptr()); + const float volume_scale = mat4_to_volume_scale(ob->object_to_world); volume *= fabsf(volume_scale); } } @@ -811,7 +811,7 @@ static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool return; } - mat4_to_loc_quat(loc, rot, ob->object_to_world().ptr()); + mat4_to_loc_quat(loc, rot, ob->object_to_world); rbo->shared->physics_object = RB_body_new( static_cast(rbo->shared->physics_shape), loc, rot); @@ -1032,7 +1032,7 @@ static void rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, b rbc->physics_constraint = nullptr; } - mat4_to_loc_quat(loc, rot, ob->object_to_world().ptr()); + mat4_to_loc_quat(loc, rot, ob->object_to_world); if (rb1 && rb2) { switch (rbc->type) { @@ -1345,7 +1345,7 @@ RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type) rbo->mesh_source = RBO_MESH_DEFORM; /* set initial transform */ - mat4_to_loc_quat(rbo->pos, rbo->orn, ob->object_to_world().ptr()); + mat4_to_loc_quat(rbo->pos, rbo->orn, ob->object_to_world); /* flag cache as outdated */ BKE_rigidbody_cache_reset(rbw); @@ -1782,7 +1782,7 @@ static void rigidbody_update_sim_ob(Depsgraph *depsgraph, Object *ob, RigidBodyO if (!(rbo->flag & RBO_FLAG_KINEMATIC)) { /* update scale for all non kinematic objects */ float new_scale[3], old_scale[3]; - mat4_to_size(new_scale, ob->object_to_world().ptr()); + mat4_to_size(new_scale, ob->object_to_world); RB_body_get_scale(static_cast(rbo->shared->physics_object), old_scale); /* Avoid updating collision shape AABBs if scale didn't change. */ @@ -1983,7 +1983,7 @@ static ListBase rigidbody_create_substep_data(RigidBodyWorld *rbw) copy_v4_v4(data->old_rot, rot); copy_v3_v3(data->old_scale, scale); - mat4_decompose(loc, rot, scale, ob->object_to_world().ptr()); + mat4_decompose(loc, rot, scale, ob->object_to_world); copy_v3_v3(data->new_pos, loc); copy_v4_v4(data->new_rot, rot); @@ -2158,15 +2158,15 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime) quat_to_mat4(mat, rbo->orn); copy_v3_v3(mat[3], rbo->pos); - mat4_to_size(size, ob->object_to_world().ptr()); + mat4_to_size(size, ob->object_to_world); size_to_mat4(size_mat, size); mul_m4_m4m4(mat, mat, size_mat); - copy_m4_m4(ob->runtime->object_to_world.ptr(), mat); + copy_m4_m4(ob->object_to_world, mat); } /* otherwise set rigid body transform to current obmat */ else { - mat4_to_loc_quat(rbo->pos, rbo->orn, ob->object_to_world().ptr()); + mat4_to_loc_quat(rbo->pos, rbo->orn, ob->object_to_world); } } diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index 8fbce95c2e8..190848c0c1c 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -24,6 +24,7 @@ #include "DNA_mask_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" +#include "DNA_modifier_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_rigidbody_types.h" @@ -36,32 +37,38 @@ #include "DNA_vfont_types.h" #include "DNA_view3d_types.h" #include "DNA_windowmanager_types.h" +#include "DNA_workspace_types.h" #include "DNA_world_types.h" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "BLI_blenlib.h" #include "BLI_math_rotation.h" #include "BLI_string.h" #include "BLI_string_utils.hh" #include "BLI_task.h" #include "BLI_threads.h" +#include "BLI_time.h" #include "BLI_utildefines.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" #include "BKE_anim_data.h" #include "BKE_animsys.h" -#include "BKE_bpath.hh" -#include "BKE_collection.hh" +#include "BKE_armature.hh" +#include "BKE_bpath.h" +#include "BKE_cachefile.h" +#include "BKE_collection.h" #include "BKE_colortools.hh" #include "BKE_curveprofile.h" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_editmesh.hh" #include "BKE_effect.h" #include "BKE_fcurve.h" +#include "BKE_freestyle.h" +#include "BKE_gpencil_legacy.h" #include "BKE_idprop.h" #include "BKE_idtype.hh" #include "BKE_image.h" @@ -70,28 +77,35 @@ #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_lib_remap.hh" +#include "BKE_linestyle.h" #include "BKE_main.hh" +#include "BKE_mask.h" +#include "BKE_modifier.hh" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" +#include "BKE_object.hh" #include "BKE_paint.hh" #include "BKE_pointcache.h" #include "BKE_preview_image.hh" #include "BKE_rigidbody.h" -#include "BKE_scene.hh" -#include "BKE_scene_runtime.hh" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_sound.h" #include "BKE_unit.hh" #include "BKE_workspace.h" +#include "BKE_world.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" #include "DEG_depsgraph_debug.hh" #include "DEG_depsgraph_query.hh" +#include "DEG_depsgraph_writeback_sync.hh" #include "RE_engine.h" #include "RNA_access.hh" +#include "SEQ_edit.hh" #include "SEQ_iterator.hh" #include "SEQ_sequencer.hh" @@ -106,8 +120,6 @@ #include "bmesh.hh" -using blender::bke::SceneRuntime; - CurveMapping *BKE_sculpt_default_cavity_curve() { @@ -237,8 +249,6 @@ static void scene_init_data(ID *id) scene->master_collection = BKE_collection_master_add(scene); BKE_view_layer_add(scene, DATA_("ViewLayer"), nullptr, VIEWLAYER_ADD_NEW); - - scene->runtime = MEM_new(__func__); } static void scene_copy_markers(Scene *scene_dst, const Scene *scene_src, const int flag) @@ -359,8 +369,6 @@ static void scene_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int } BKE_scene_copy_data_eevee(scene_dst, scene_src); - - scene_dst->runtime = MEM_new(__func__); } static void scene_free_markers(Scene *scene, bool do_id_user) @@ -456,8 +464,6 @@ static void scene_free_data(ID *id) /* These are freed on `do_versions`. */ BLI_assert(scene->layer_properties == nullptr); - - MEM_delete(scene->runtime); } static void scene_foreach_rigidbodyworldSceneLooper(RigidBodyWorld * /*rbw*/, @@ -886,7 +892,6 @@ static void scene_foreach_id(ID *id, LibraryForeachIDData *data) LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, view_layer->mat_override, IDWALK_CB_USER); - BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, view_layer->world_override, IDWALK_CB_USER); BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL( data, IDP_foreach_property(view_layer->id_properties, @@ -1254,8 +1259,6 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id) /* set users to one by default, not in lib-link, this will increase it for compo nodes */ id_us_ensure_real(&sce->id); - sce->runtime = MEM_new(__func__); - BLO_read_list(reader, &(sce->base)); BLO_read_list(reader, &sce->keyingsets); @@ -1601,10 +1604,6 @@ constexpr IDTypeInfo get_type_info() IDTypeInfo info{}; info.id_code = ID_SCE; info.id_filter = FILTER_ID_SCE; - info.dependencies_id_types = (FILTER_ID_OB | FILTER_ID_WO | FILTER_ID_SCE | FILTER_ID_MC | - FILTER_ID_MA | FILTER_ID_GR | FILTER_ID_TXT | FILTER_ID_LS | - FILTER_ID_MSK | FILTER_ID_SO | FILTER_ID_GD_LEGACY | FILTER_ID_BR | - FILTER_ID_PAL | FILTER_ID_IM | FILTER_ID_NT); info.main_listbase_index = INDEX_ID_SCE; info.struct_size = sizeof(Scene); info.name = "Scene"; @@ -2171,13 +2170,13 @@ int BKE_scene_base_iter_next( if (iter->dupli_refob != *ob) { if (iter->dupli_refob) { /* Restore previous object's real matrix. */ - copy_m4_m4(iter->dupli_refob->runtime->object_to_world.ptr(), iter->omat); + copy_m4_m4(iter->dupli_refob->object_to_world, iter->omat); } /* Backup new object's real matrix. */ iter->dupli_refob = *ob; - copy_m4_m4(iter->omat, iter->dupli_refob->object_to_world().ptr()); + copy_m4_m4(iter->omat, iter->dupli_refob->object_to_world); } - copy_m4_m4((*ob)->runtime->object_to_world.ptr(), iter->dupob->mat); + copy_m4_m4((*ob)->object_to_world, iter->dupob->mat); iter->dupob = iter->dupob->next; } @@ -2187,7 +2186,7 @@ int BKE_scene_base_iter_next( if (iter->dupli_refob) { /* Restore last object's real matrix. */ - copy_m4_m4(iter->dupli_refob->runtime->object_to_world.ptr(), iter->omat); + copy_m4_m4(iter->dupli_refob->object_to_world, iter->omat); iter->dupli_refob = nullptr; } diff --git a/source/blender/blenkernel/intern/screen.cc b/source/blender/blenkernel/intern/screen.cc index f64f8c9e24b..049de0c1afa 100644 --- a/source/blender/blenkernel/intern/screen.cc +++ b/source/blender/blenkernel/intern/screen.cc @@ -19,28 +19,38 @@ #include "MEM_guardedalloc.h" +#include "DNA_collection_types.h" #include "DNA_defaults.h" +#include "DNA_gpencil_legacy_types.h" +#include "DNA_mask_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "DNA_text_types.h" #include "DNA_view3d_types.h" +#include "DNA_workspace_types.h" #include "BLI_ghash.h" #include "BLI_listbase.h" #include "BLI_math_rotation.h" #include "BLI_math_vector.h" +#include "BLI_mempool.h" #include "BLI_rect.h" #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "BKE_gpencil_legacy.h" #include "BKE_idprop.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_node.h" #include "BKE_preview_image.hh" #include "BKE_screen.hh" +#include "BKE_viewer_path.hh" +#include "BKE_workspace.h" #include "BLO_read_write.hh" @@ -159,9 +169,6 @@ static void screen_blend_read_after_liblink(BlendLibReader *reader, ID *id) IDTypeInfo IDType_ID_SCR = { /*id_code*/ ID_SCR, /*id_filter*/ FILTER_ID_SCR, - /* NOTE: Can actually link to any ID type through UI (e.g. Outliner Editor). This is handled - separately though. */ - /*dependencies_id_types*/ FILTER_ID_SCE, /*main_listbase_index*/ INDEX_ID_SCR, /*struct_size*/ sizeof(bScreen), /*name*/ "Screen", diff --git a/source/blender/blenkernel/intern/shader_fx.cc b/source/blender/blenkernel/intern/shader_fx.cc index 034f4cffd16..c759590b3cf 100644 --- a/source/blender/blenkernel/intern/shader_fx.cc +++ b/source/blender/blenkernel/intern/shader_fx.cc @@ -11,20 +11,28 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_math_vector.h" #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "DNA_gpencil_legacy_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_shader_fx_types.h" +#include "BKE_gpencil_legacy.h" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_object.hh" #include "BKE_screen.hh" #include "BKE_shader_fx.h" +#include "DEG_depsgraph.hh" +#include "DEG_depsgraph_query.hh" + #include "FX_shader_types.h" #include "BLO_read_write.hh" diff --git a/source/blender/blenkernel/intern/shrinkwrap.cc b/source/blender/blenkernel/intern/shrinkwrap.cc index 1baec9458bf..da590a418a4 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.cc +++ b/source/blender/blenkernel/intern/shrinkwrap.cc @@ -15,6 +15,7 @@ #include "DNA_gpencil_modifier_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" @@ -26,13 +27,17 @@ #include "BLI_utildefines.h" #include "BKE_DerivedMesh.hh" +#include "BKE_attribute.hh" #include "BKE_cdderivedmesh.h" +#include "BKE_lattice.hh" +#include "BKE_lib_id.hh" #include "BKE_modifier.hh" #include "BKE_shrinkwrap.hh" #include "BKE_deform.hh" #include "BKE_editmesh.hh" #include "BKE_mesh.hh" /* for OMP limits. */ +#include "BKE_mesh_runtime.hh" #include "BKE_mesh_wrapper.hh" #include "BKE_subsurf.hh" @@ -40,7 +45,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* for timing... */ #if 0 diff --git a/source/blender/blenkernel/intern/softbody.cc b/source/blender/blenkernel/intern/softbody.cc index c9699e08aea..c3ffc6c5209 100644 --- a/source/blender/blenkernel/intern/softbody.cc +++ b/source/blender/blenkernel/intern/softbody.cc @@ -50,18 +50,18 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_collision.h" #include "BKE_curve.hh" #include "BKE_customdata.hh" #include "BKE_deform.hh" #include "BKE_effect.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_pointcache.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_softbody.h" #include "DEG_depsgraph.hh" @@ -2658,7 +2658,7 @@ static void springs_from_mesh(Object *ob) bp = ob->soft->bpoint; for (a = 0; a < mesh->verts_num; a++, bp++) { copy_v3_v3(bp->origS, positions[a]); - mul_m4_v3(ob->object_to_world().ptr(), bp->origS); + mul_m4_v3(ob->object_to_world, bp->origS); } } /* recalculate spring length for meshes here */ @@ -2821,9 +2821,9 @@ static float globallen(float *v1, float *v2, Object *ob) { float p1[3], p2[3]; copy_v3_v3(p1, v1); - mul_m4_v3(ob->object_to_world().ptr(), p1); + mul_m4_v3(ob->object_to_world, p1); copy_v3_v3(p2, v2); - mul_m4_v3(ob->object_to_world().ptr(), p2); + mul_m4_v3(ob->object_to_world, p2); return len_v3v3(p1, p2); } @@ -3085,13 +3085,13 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts, SB_estimate_transform(ob, sb->lcom, sb->lrot, sb->lscale); } /* Inverse matrix is not up to date. */ - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); for (a = 0; a < numVerts; a++, bp++) { copy_v3_v3(vertexCos[a], bp->pos); if (local == 0) { - /* softbody is in global coords, baked optionally not */ - mul_m4_v3(ob->world_to_object().ptr(), vertexCos[a]); + mul_m4_v3(ob->world_to_object, + vertexCos[a]); /* softbody is in global coords, baked optionally not */ } } } @@ -3238,7 +3238,7 @@ static void softbody_update_positions(Object *ob, /* copy the position of the goals at desired end time */ copy_v3_v3(bp->origE, vertexCos[a]); /* vertexCos came from local world, go global */ - mul_m4_v3(ob->object_to_world().ptr(), bp->origE); + mul_m4_v3(ob->object_to_world, bp->origE); /* just to be save give bp->origT a defined value * will be calculated in interpolate_exciter() */ copy_v3_v3(bp->origT, bp->origE); @@ -3295,7 +3295,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int for (a = 0, bp = sb->bpoint; a < numVerts; a++, bp++) { copy_v3_v3(bp->pos, vertexCos[a]); - mul_m4_v3(ob->object_to_world().ptr(), bp->pos); /* Yep, soft-body is global coords. */ + mul_m4_v3(ob->object_to_world, bp->pos); /* Yep, soft-body is global coords. */ copy_v3_v3(bp->origS, bp->pos); copy_v3_v3(bp->origE, bp->pos); copy_v3_v3(bp->origT, bp->pos); @@ -3357,7 +3357,7 @@ static void softbody_step( float forcetime; double sct, sst; - sst = BLI_time_now_seconds(); + sst = BLI_check_seconds_timer(); /* Integration back in time is possible in theory, but pretty useless here. * So we refuse to do so. Since we do not know anything about 'outside' changes * especially colliders we refuse to go more than 10 frames. @@ -3453,7 +3453,7 @@ static void softbody_step( } loops++; if (sb->solverflags & SBSO_MONITOR) { - sct = BLI_time_now_seconds(); + sct = BLI_check_seconds_timer(); if (sct - sst > 0.5) { printf("%3.0f%% \r", 100.0f * timedone / dtime); } @@ -3494,7 +3494,7 @@ static void softbody_step( } if (sb->solverflags & SBSO_MONITOR) { - sct = BLI_time_now_seconds(); + sct = BLI_check_seconds_timer(); if ((sct - sst > 0.5) || (G.debug & G_DEBUG)) { printf(" solver time %f sec %s\n", sct - sst, ob->id.name); } diff --git a/source/blender/blenkernel/intern/sound.cc b/source/blender/blenkernel/intern/sound.cc index 2e21dc1a041..052a0f0a240 100644 --- a/source/blender/blenkernel/intern/sound.cc +++ b/source/blender/blenkernel/intern/sound.cc @@ -14,9 +14,10 @@ #include "BLI_blenlib.h" #include "BLI_iterator.h" #include "BLI_math_rotation.h" +#include "BLI_math_vector.h" #include "BLI_threads.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" /* Allow using deprecated functionality for .blend file I/O. */ #define DNA_DEPRECATED_ALLOW @@ -39,13 +40,14 @@ # include #endif -#include "BKE_bpath.hh" -#include "BKE_global.hh" +#include "BKE_bpath.h" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_main.hh" #include "BKE_packedFile.h" +#include "BKE_scene.h" #include "BKE_sound.h" #include "DEG_depsgraph.hh" @@ -53,6 +55,7 @@ #include "BLO_read_write.hh" +#include "SEQ_sequencer.hh" #include "SEQ_sound.hh" #include "SEQ_time.hh" @@ -189,7 +192,6 @@ static void sound_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_SO = { /*id_code*/ ID_SO, /*id_filter*/ FILTER_ID_SO, - /*dependencies_id_types*/ 0, /*main_listbase_index*/ INDEX_ID_SO, /*struct_size*/ sizeof(bSound), /*name*/ "Sound", @@ -1158,10 +1160,9 @@ static void sound_update_base(Scene *scene, Object *object, void *new_set) AUD_SequenceEntry_setConeAngleInner(strip->speaker_handle, speaker->cone_angle_inner); AUD_SequenceEntry_setConeVolumeOuter(strip->speaker_handle, speaker->cone_volume_outer); - mat4_to_quat(quat, object->object_to_world().ptr()); - blender::float3 location = object->object_to_world().location(); + mat4_to_quat(quat, object->object_to_world); AUD_SequenceEntry_setAnimationData( - strip->speaker_handle, AUD_AP_LOCATION, scene->r.cfra, location, 1); + strip->speaker_handle, AUD_AP_LOCATION, scene->r.cfra, object->object_to_world[3], 1); AUD_SequenceEntry_setAnimationData( strip->speaker_handle, AUD_AP_ORIENTATION, scene->r.cfra, quat, 1); AUD_SequenceEntry_setAnimationData( @@ -1201,9 +1202,9 @@ void BKE_sound_update_scene(Depsgraph *depsgraph, Scene *scene) } if (scene->camera) { - mat4_to_quat(quat, scene->camera->object_to_world().ptr()); - blender::float3 location = scene->camera->object_to_world().location(); - AUD_Sequence_setAnimationData(scene->sound_scene, AUD_AP_LOCATION, scene->r.cfra, location, 1); + mat4_to_quat(quat, scene->camera->object_to_world); + AUD_Sequence_setAnimationData( + scene->sound_scene, AUD_AP_LOCATION, scene->r.cfra, scene->camera->object_to_world[3], 1); AUD_Sequence_setAnimationData(scene->sound_scene, AUD_AP_ORIENTATION, scene->r.cfra, quat, 1); } diff --git a/source/blender/blenkernel/intern/speaker.cc b/source/blender/blenkernel/intern/speaker.cc index 221063267b1..8c78b7b249f 100644 --- a/source/blender/blenkernel/intern/speaker.cc +++ b/source/blender/blenkernel/intern/speaker.cc @@ -7,16 +7,19 @@ */ #include "DNA_defaults.h" +#include "DNA_object_types.h" #include "DNA_sound_types.h" #include "DNA_speaker_types.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "BKE_anim_data.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_speaker.h" #include "BLO_read_write.hh" @@ -51,7 +54,6 @@ static void speaker_blend_write(BlendWriter *writer, ID *id, const void *id_addr IDTypeInfo IDType_ID_SPK = { /*id_code*/ ID_SPK, /*id_filter*/ FILTER_ID_SPK, - /*dependencies_id_types*/ FILTER_ID_SO, /*main_listbase_index*/ INDEX_ID_SPK, /*struct_size*/ sizeof(Speaker), /*name*/ "Speaker", diff --git a/source/blender/blenkernel/intern/studiolight.cc b/source/blender/blenkernel/intern/studiolight.cc index 20566e15c66..d9c8705a99a 100644 --- a/source/blender/blenkernel/intern/studiolight.cc +++ b/source/blender/blenkernel/intern/studiolight.cc @@ -17,9 +17,11 @@ #include "BLI_linklist.h" #include "BLI_listbase.h" #include "BLI_math_color.h" +#include "BLI_math_matrix.h" #include "BLI_math_vector.h" #include "BLI_path_util.h" #include "BLI_string.h" +#include "BLI_string_utils.hh" #include "DNA_listBase.h" diff --git a/source/blender/blenkernel/intern/subdiv.cc b/source/blender/blenkernel/intern/subdiv.cc index c9c931144c1..9cf77debbfb 100644 --- a/source/blender/blenkernel/intern/subdiv.cc +++ b/source/blender/blenkernel/intern/subdiv.cc @@ -13,6 +13,7 @@ #include "BLI_utildefines.h" +#include "BKE_modifier.hh" #include "BKE_subdiv_modifier.hh" #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/subdiv_ccg.cc b/source/blender/blenkernel/intern/subdiv_ccg.cc index c92f8a3e2da..0d3fab20c03 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg.cc +++ b/source/blender/blenkernel/intern/subdiv_ccg.cc @@ -21,6 +21,7 @@ #include "BKE_DerivedMesh.hh" #include "BKE_ccg.h" +#include "BKE_global.h" #include "BKE_mesh.hh" #include "BKE_subdiv.hh" #include "BKE_subdiv_eval.hh" diff --git a/source/blender/blenkernel/intern/subdiv_ccg_mask.cc b/source/blender/blenkernel/intern/subdiv_ccg_mask.cc index 2e24f52bf82..2f7492d3bd8 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg_mask.cc +++ b/source/blender/blenkernel/intern/subdiv_ccg_mask.cc @@ -12,10 +12,13 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" +#include "DNA_modifier_types.h" +#include "DNA_object_types.h" #include "BLI_utildefines.h" #include "BKE_customdata.hh" +#include "BKE_mesh.hh" #include "BKE_subdiv.hh" #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/subdiv_converter.cc b/source/blender/blenkernel/intern/subdiv_converter.cc index 3b741da46ab..202c1c0153a 100644 --- a/source/blender/blenkernel/intern/subdiv_converter.cc +++ b/source/blender/blenkernel/intern/subdiv_converter.cc @@ -8,6 +8,8 @@ #include "subdiv_converter.hh" +#include "BLI_utildefines.h" + #include "opensubdiv_converter_capi.hh" void BKE_subdiv_converter_free(OpenSubdiv_Converter *converter) diff --git a/source/blender/blenkernel/intern/subdiv_converter_mesh.cc b/source/blender/blenkernel/intern/subdiv_converter_mesh.cc index cb90d77a65b..45df57e8e9d 100644 --- a/source/blender/blenkernel/intern/subdiv_converter_mesh.cc +++ b/source/blender/blenkernel/intern/subdiv_converter_mesh.cc @@ -20,8 +20,11 @@ #include "MEM_guardedalloc.h" +#include "opensubdiv_capi.hh" #include "opensubdiv_converter_capi.hh" +#include "bmesh_class.hh" + /* Enable work-around for non-working CPU evaluator when using bilinear scheme. * This forces Catmark scheme with all edges marked as infinitely sharp. */ #define BUGGY_SIMPLE_SCHEME_WORKAROUND 1 diff --git a/source/blender/blenkernel/intern/subdiv_displacement.cc b/source/blender/blenkernel/intern/subdiv_displacement.cc index f45ac7b5faf..e62b402f992 100644 --- a/source/blender/blenkernel/intern/subdiv_displacement.cc +++ b/source/blender/blenkernel/intern/subdiv_displacement.cc @@ -8,6 +8,8 @@ #include "BKE_subdiv.hh" +#include "BLI_utildefines.h" + #include "MEM_guardedalloc.h" void BKE_subdiv_displacement_detach(Subdiv *subdiv) diff --git a/source/blender/blenkernel/intern/subdiv_displacement_multires.cc b/source/blender/blenkernel/intern/subdiv_displacement_multires.cc index 3054dbcd28f..8037991ee56 100644 --- a/source/blender/blenkernel/intern/subdiv_displacement_multires.cc +++ b/source/blender/blenkernel/intern/subdiv_displacement_multires.cc @@ -13,6 +13,7 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" +#include "DNA_object_types.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" diff --git a/source/blender/blenkernel/intern/subdiv_eval.cc b/source/blender/blenkernel/intern/subdiv_eval.cc index c654dba2654..e95ec7e18d9 100644 --- a/source/blender/blenkernel/intern/subdiv_eval.cc +++ b/source/blender/blenkernel/intern/subdiv_eval.cc @@ -10,6 +10,7 @@ #include "BLI_math_vector.h" #include "BLI_task.h" +#include "BLI_timeit.hh" #include "BLI_utildefines.h" #include "BKE_customdata.hh" diff --git a/source/blender/blenkernel/intern/subdiv_foreach.cc b/source/blender/blenkernel/intern/subdiv_foreach.cc index f6938a83980..4f2d90086a4 100644 --- a/source/blender/blenkernel/intern/subdiv_foreach.cc +++ b/source/blender/blenkernel/intern/subdiv_foreach.cc @@ -10,10 +10,13 @@ #include "atomic_ops.h" +#include "DNA_key_types.h" + #include "BLI_bitmap.h" #include "BLI_task.h" #include "BKE_customdata.hh" +#include "BKE_key.hh" #include "BKE_mesh.hh" #include "BKE_subdiv.hh" #include "BKE_subdiv_mesh.hh" diff --git a/source/blender/blenkernel/intern/subdiv_mesh.cc b/source/blender/blenkernel/intern/subdiv_mesh.cc index 1852a2f9584..7740ee0eb5c 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.cc +++ b/source/blender/blenkernel/intern/subdiv_mesh.cc @@ -8,10 +8,13 @@ #include +#include "atomic_ops.h" + #include "DNA_key_types.h" #include "DNA_mesh_types.h" #include "BLI_array.hh" +#include "BLI_bitmap.h" #include "BLI_math_vector.h" #include "BLI_math_vector_types.hh" #include "BLI_task.hh" diff --git a/source/blender/blenkernel/intern/subdiv_modifier.cc b/source/blender/blenkernel/intern/subdiv_modifier.cc index a7f64f1e2d5..c7ecd3af3b4 100644 --- a/source/blender/blenkernel/intern/subdiv_modifier.cc +++ b/source/blender/blenkernel/intern/subdiv_modifier.cc @@ -2,6 +2,7 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BKE_attribute.hh" #include "BKE_subdiv_modifier.hh" #include "MEM_guardedalloc.h" @@ -9,6 +10,7 @@ #include "DNA_mesh_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_userdef_types.h" #include "BKE_mesh.hh" @@ -18,6 +20,8 @@ #include "GPU_capabilities.h" #include "GPU_context.h" +#include "opensubdiv_capi.hh" + SubdivSettings BKE_subsurf_modifier_settings_init(const SubsurfModifierData *smd, const bool use_render_params) { diff --git a/source/blender/blenkernel/intern/subdiv_stats.cc b/source/blender/blenkernel/intern/subdiv_stats.cc index 8986c855c4f..1aa58661f2d 100644 --- a/source/blender/blenkernel/intern/subdiv_stats.cc +++ b/source/blender/blenkernel/intern/subdiv_stats.cc @@ -26,12 +26,12 @@ void BKE_subdiv_stats_init(SubdivStats *stats) void BKE_subdiv_stats_begin(SubdivStats *stats, eSubdivStatsValue value) { - stats->begin_timestamp_[value] = BLI_time_now_seconds(); + stats->begin_timestamp_[value] = BLI_check_seconds_timer(); } void BKE_subdiv_stats_end(SubdivStats *stats, eSubdivStatsValue value) { - stats->values_[value] = BLI_time_now_seconds() - stats->begin_timestamp_[value]; + stats->values_[value] = BLI_check_seconds_timer() - stats->begin_timestamp_[value]; } void BKE_subdiv_stats_reset(SubdivStats *stats, eSubdivStatsValue value) diff --git a/source/blender/blenkernel/intern/subsurf_ccg.cc b/source/blender/blenkernel/intern/subsurf_ccg.cc index c738d7aeb71..67c11e5cac9 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.cc +++ b/source/blender/blenkernel/intern/subsurf_ccg.cc @@ -23,6 +23,7 @@ #include "DNA_scene_types.h" #include "BLI_bitmap.h" +#include "BLI_blenlib.h" #include "BLI_memarena.h" #include "BLI_ordered_edge.hh" #include "BLI_set.hh" @@ -34,9 +35,13 @@ #include "BKE_ccg.h" #include "BKE_cdderivedmesh.h" #include "BKE_customdata.hh" +#include "BKE_mesh.hh" #include "BKE_mesh_mapping.hh" +#include "BKE_modifier.hh" #include "BKE_multires.hh" -#include "BKE_scene.hh" +#include "BKE_object.hh" +#include "BKE_paint.hh" +#include "BKE_scene.h" #include "BKE_subsurf.hh" #include "CCGSubSurf.h" @@ -815,13 +820,13 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, float (*r_positions)[3]) } /* utility function */ -BLI_INLINE void ccgDM_to_MEdge(blender::int2 *edge, const int v1, const int v2) +BLI_INLINE void ccgDM_to_MEdge(vec2i *edge, const int v1, const int v2) { edge->x = v1; edge->y = v2; } -static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, blender::int2 *edges) +static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, vec2i *edges) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; CCGSubSurf *ss = ccgdm->ss; @@ -1292,6 +1297,14 @@ static void ccgDM_getGridKey(DerivedMesh *dm, CCGKey *key) CCG_key_top_level(key, ccgdm->ss); } +static BLI_bitmap **ccgDM_getGridHidden(DerivedMesh *dm) +{ + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; + + ccgdm_create_grids(dm); + return ccgdm->gridHidden; +} + static void set_default_ccgdm_callbacks(CCGDerivedMesh *ccgdm) { ccgdm->dm.getNumVerts = ccgDM_getNumVerts; @@ -1313,6 +1326,7 @@ static void set_default_ccgdm_callbacks(CCGDerivedMesh *ccgdm) ccgdm->dm.getGridData = ccgDM_getGridData; ccgdm->dm.getGridOffset = ccgDM_getGridOffset; ccgdm->dm.getGridKey = ccgDM_getGridKey; + ccgdm->dm.getGridHidden = ccgDM_getGridHidden; ccgdm->dm.release = ccgDM_release; } diff --git a/source/blender/blenkernel/intern/text.cc b/source/blender/blenkernel/intern/text.cc index f32ab16f037..7d9f64af2ae 100644 --- a/source/blender/blenkernel/intern/text.cc +++ b/source/blender/blenkernel/intern/text.cc @@ -22,16 +22,23 @@ #include "BLI_string_utf8.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "DNA_constraint_types.h" +#include "DNA_material_types.h" +#include "DNA_node_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "DNA_text_types.h" #include "DNA_userdef_types.h" -#include "BKE_bpath.hh" +#include "BKE_bpath.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" +#include "BKE_node.h" #include "BKE_text.h" #include "BLO_read_write.hh" @@ -222,7 +229,6 @@ static void text_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_TXT = { /*id_code*/ ID_TXT, /*id_filter*/ FILTER_ID_TXT, - /*dependencies_id_types*/ 0, /*main_listbase_index*/ INDEX_ID_TXT, /*struct_size*/ sizeof(Text), /*name*/ "Text", diff --git a/source/blender/blenkernel/intern/text_suggestions.cc b/source/blender/blenkernel/intern/text_suggestions.cc index f53ae8d2da8..fc0dc7f366a 100644 --- a/source/blender/blenkernel/intern/text_suggestions.cc +++ b/source/blender/blenkernel/intern/text_suggestions.cc @@ -16,6 +16,7 @@ #include "BLI_string.h" #include "BKE_text_suggestions.h" /* Own include. */ +#include "DNA_text_types.h" /**********************/ /* Static definitions */ diff --git a/source/blender/blenkernel/intern/texture.cc b/source/blender/blenkernel/intern/texture.cc index d69e704c948..ca2876a6fe0 100644 --- a/source/blender/blenkernel/intern/texture.cc +++ b/source/blender/blenkernel/intern/texture.cc @@ -21,7 +21,7 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" /* Allow using deprecated functionality for .blend file I/O. */ #define DNA_DEPRECATED_ALLOW @@ -29,21 +29,31 @@ #include "DNA_brush_types.h" #include "DNA_color_types.h" #include "DNA_defaults.h" +#include "DNA_key_types.h" #include "DNA_linestyle_types.h" #include "DNA_material_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_particle_types.h" +#include "IMB_imbuf.hh" + +#include "BKE_main.hh" + +#include "BKE_anim_data.h" #include "BKE_colorband.hh" #include "BKE_colortools.hh" #include "BKE_icons.h" #include "BKE_idtype.hh" #include "BKE_image.h" +#include "BKE_key.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_material.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_preview_image.hh" +#include "BKE_scene.h" #include "BKE_texture.h" #include "NOD_texture.h" @@ -188,7 +198,6 @@ static void texture_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_TE = { /*id_code*/ ID_TE, /*id_filter*/ FILTER_ID_TE, - /*dependencies_id_types*/ FILTER_ID_IM | FILTER_ID_OB, /*main_listbase_index*/ INDEX_ID_TE, /*struct_size*/ sizeof(Tex), /*name*/ "Texture", diff --git a/source/blender/blenkernel/intern/tracking.cc b/source/blender/blenkernel/intern/tracking.cc index 222b9aa7d75..c74cee34160 100644 --- a/source/blender/blenkernel/intern/tracking.cc +++ b/source/blender/blenkernel/intern/tracking.cc @@ -36,14 +36,14 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_fcurve.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_movieclip.h" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_tracking.h" #include "IMB_imbuf.hh" diff --git a/source/blender/blenkernel/intern/tracking_auto.cc b/source/blender/blenkernel/intern/tracking_auto.cc index ab9f294e4fe..d8513a9b298 100644 --- a/source/blender/blenkernel/intern/tracking_auto.cc +++ b/source/blender/blenkernel/intern/tracking_auto.cc @@ -6,6 +6,7 @@ * \ingroup bke */ +#include "atomic_ops.h" #include #include "MEM_guardedalloc.h" @@ -17,8 +18,10 @@ #include "BLI_math_vector.h" #include "BLI_task.h" #include "BLI_threads.h" +#include "BLI_time.h" #include "BLI_utildefines.h" +#include "BKE_global.h" #include "BKE_movieclip.h" #include "BKE_tracking.h" diff --git a/source/blender/blenkernel/intern/tracking_solver.cc b/source/blender/blenkernel/intern/tracking_solver.cc index 3434f85ec77..cd8fd0e0635 100644 --- a/source/blender/blenkernel/intern/tracking_solver.cc +++ b/source/blender/blenkernel/intern/tracking_solver.cc @@ -12,6 +12,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_movieclip_types.h" #include "BLI_listbase.h" @@ -20,12 +21,13 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_fcurve.h" #include "BKE_movieclip.h" #include "BKE_tracking.h" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "libmv-capi.h" diff --git a/source/blender/blenkernel/intern/tracking_stabilize.cc b/source/blender/blenkernel/intern/tracking_stabilize.cc index d3d9b0bdeaa..bf99d21b8f1 100644 --- a/source/blender/blenkernel/intern/tracking_stabilize.cc +++ b/source/blender/blenkernel/intern/tracking_stabilize.cc @@ -10,8 +10,10 @@ #include +#include "DNA_anim_types.h" #include "DNA_movieclip_types.h" #include "DNA_scene_types.h" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "BLI_ghash.h" diff --git a/source/blender/blenkernel/intern/tracking_util.cc b/source/blender/blenkernel/intern/tracking_util.cc index 142324c1442..d6baaa5b2c9 100644 --- a/source/blender/blenkernel/intern/tracking_util.cc +++ b/source/blender/blenkernel/intern/tracking_util.cc @@ -24,13 +24,14 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_movieclip.h" #include "BKE_tracking.h" #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" +#include "IMB_moviecache.hh" #include "tracking_private.h" diff --git a/source/blender/blenkernel/intern/type_conversions.cc b/source/blender/blenkernel/intern/type_conversions.cc index 1e36204ee3a..f42844c62a7 100644 --- a/source/blender/blenkernel/intern/type_conversions.cc +++ b/source/blender/blenkernel/intern/type_conversions.cc @@ -349,21 +349,11 @@ static ColorGeometry4f byte_color_to_color(const ColorGeometry4b &a) return a.decode(); } -static math::Quaternion float4x4_to_quaternion(const float4x4 &a) -{ - return math::to_quaternion(a); -} - static float3 quaternion_to_float3(const math::Quaternion &a) { return float3(math::to_euler(a).xyz()); } -static float4x4 quaternion_to_float4x4(const math::Quaternion &a) -{ - return math::from_rotation(a); -} - static DataTypeConversions create_implicit_conversions() { DataTypeConversions conversions; @@ -451,10 +441,7 @@ static DataTypeConversions create_implicit_conversions() add_implicit_conversion(conversions); add_implicit_conversion(conversions); - add_implicit_conversion(conversions); - add_implicit_conversion(conversions); - add_implicit_conversion(conversions); return conversions; } diff --git a/source/blender/blenkernel/intern/undo_system.cc b/source/blender/blenkernel/intern/undo_system.cc index 700a75d717b..4f94810a5b8 100644 --- a/source/blender/blenkernel/intern/undo_system.cc +++ b/source/blender/blenkernel/intern/undo_system.cc @@ -18,13 +18,13 @@ #include "BLI_sys_types.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_listBase.h" #include "DNA_windowmanager_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_override.hh" #include "BKE_main.hh" #include "BKE_undo_system.hh" diff --git a/source/blender/blenkernel/intern/vfont.cc b/source/blender/blenkernel/intern/vfont.cc index d131afacbcd..27639f1797a 100644 --- a/source/blender/blenkernel/intern/vfont.cc +++ b/source/blender/blenkernel/intern/vfont.cc @@ -29,7 +29,7 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_curve_types.h" #include "DNA_object_types.h" @@ -37,9 +37,9 @@ #include "DNA_vfont_types.h" #include "BKE_anim_path.h" -#include "BKE_bpath.hh" +#include "BKE_bpath.h" #include "BKE_curve.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" @@ -163,7 +163,6 @@ static void vfont_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_VF = { /*id_code*/ ID_VF, /*id_filter*/ FILTER_ID_VF, - /*dependencies_id_types*/ 0, /*main_listbase_index*/ INDEX_ID_VF, /*struct_size*/ sizeof(VFont), /*name*/ "Font", @@ -1424,14 +1423,14 @@ static bool vfont_to_curve(Object *ob, float timeofs, sizefac; if (ob != nullptr) { - invert_m4_m4(imat, ob->object_to_world().ptr()); + invert_m4_m4(imat, ob->object_to_world); } else { unit_m4(imat); } copy_m3_m4(imat3, imat); - copy_m3_m4(cmat, cu->textoncurve->object_to_world().ptr()); + copy_m3_m4(cmat, cu->textoncurve->object_to_world); mul_m3_m3m3(cmat, cmat, imat3); sizefac = normalize_v3(cmat[0]) / font_size; diff --git a/source/blender/blenkernel/intern/viewer_path.cc b/source/blender/blenkernel/intern/viewer_path.cc index 01f9b268ca7..b94c15063e9 100644 --- a/source/blender/blenkernel/intern/viewer_path.cc +++ b/source/blender/blenkernel/intern/viewer_path.cc @@ -142,14 +142,13 @@ void BKE_viewer_path_foreach_id(LibraryForeachIDData *data, ViewerPath *viewer_p } } -void BKE_viewer_path_id_remap(ViewerPath *viewer_path, - const blender::bke::id::IDRemapper &mappings) +void BKE_viewer_path_id_remap(ViewerPath *viewer_path, const IDRemapper *mappings) { LISTBASE_FOREACH (ViewerPathElem *, elem, &viewer_path->path) { switch (ViewerPathElemType(elem->type)) { case VIEWER_PATH_ELEM_TYPE_ID: { auto *typed_elem = reinterpret_cast(elem); - mappings.apply(&typed_elem->id, ID_REMAP_APPLY_DEFAULT); + BKE_id_remapper_apply(mappings, &typed_elem->id, ID_REMAP_APPLY_DEFAULT); break; } case VIEWER_PATH_ELEM_TYPE_MODIFIER: diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index c90e57e65f3..c8ef524ead8 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -31,9 +31,9 @@ #include "BKE_anim_data.h" #include "BKE_bake_data_block_id.hh" -#include "BKE_bpath.hh" +#include "BKE_bpath.h" #include "BKE_geometry_set.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" @@ -43,14 +43,14 @@ #include "BKE_object.hh" #include "BKE_object_types.hh" #include "BKE_packedFile.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_volume.hh" #include "BKE_volume_grid.hh" #include "BKE_volume_grid_file_cache.hh" #include "BKE_volume_openvdb.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph_query.hh" @@ -273,7 +273,6 @@ static void volume_blend_read_after_liblink(BlendLibReader * /*reader*/, ID *id) IDTypeInfo IDType_ID_VO = { /*id_code*/ ID_VO, /*id_filter*/ FILTER_ID_VO, - /*dependencies_id_types*/ FILTER_ID_MA, /*main_listbase_index*/ INDEX_ID_VO, /*struct_size*/ sizeof(Volume), /*name*/ "Volume", diff --git a/source/blender/blenkernel/intern/volume_render.cc b/source/blender/blenkernel/intern/volume_render.cc index ac69dc5d37f..1e97c5623cd 100644 --- a/source/blender/blenkernel/intern/volume_render.cc +++ b/source/blender/blenkernel/intern/volume_render.cc @@ -16,6 +16,7 @@ #include "DNA_volume_types.h" +#include "BKE_volume.hh" #include "BKE_volume_grid.hh" #include "BKE_volume_openvdb.hh" #include "BKE_volume_render.hh" diff --git a/source/blender/blenkernel/intern/volume_to_mesh.cc b/source/blender/blenkernel/intern/volume_to_mesh.cc index 1160e5f0f2d..4bc83392dd8 100644 --- a/source/blender/blenkernel/intern/volume_to_mesh.cc +++ b/source/blender/blenkernel/intern/volume_to_mesh.cc @@ -8,7 +8,10 @@ #include "BLI_span.hh" #include "BLI_utildefines.h" +#include "DNA_volume_types.h" + #include "BKE_mesh.hh" +#include "BKE_volume.hh" #include "BKE_volume_grid.hh" #include "BKE_volume_openvdb.hh" diff --git a/source/blender/blenkernel/intern/wm_runtime.cc b/source/blender/blenkernel/intern/wm_runtime.cc deleted file mode 100644 index 7062527ae5c..00000000000 --- a/source/blender/blenkernel/intern/wm_runtime.cc +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-FileCopyrightText: 2024 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup bke - */ - -#include "BKE_report.hh" -#include "BKE_wm_runtime.hh" - -namespace blender::bke { - -WindowManagerRuntime::WindowManagerRuntime() -{ - BKE_reports_init(&this->reports, RPT_STORE); -} - -WindowManagerRuntime::~WindowManagerRuntime() -{ - BKE_reports_free(&this->reports); -} - -} // namespace blender::bke diff --git a/source/blender/blenkernel/intern/workspace.cc b/source/blender/blenkernel/intern/workspace.cc index a55a3d54970..099120cdf16 100644 --- a/source/blender/blenkernel/intern/workspace.cc +++ b/source/blender/blenkernel/intern/workspace.cc @@ -15,23 +15,28 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_asset.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_main.hh" +#include "BKE_object.hh" +#include "BKE_scene.h" #include "BKE_viewer_path.hh" #include "BKE_workspace.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_windowmanager_types.h" #include "DNA_workspace_types.h" +#include "DEG_depsgraph.hh" + #include "MEM_guardedalloc.h" #include "BLO_read_write.hh" @@ -169,7 +174,6 @@ static void workspace_blend_read_after_liblink(BlendLibReader *reader, ID *id) IDTypeInfo IDType_ID_WS = { /*id_code*/ ID_WS, /*id_filter*/ FILTER_ID_WS, - /*dependencies_id_types*/ FILTER_ID_SCE, /*main_listbase_index*/ INDEX_ID_WS, /*struct_size*/ sizeof(WorkSpace), /*name*/ "WorkSpace", diff --git a/source/blender/blenkernel/intern/world.cc b/source/blender/blenkernel/intern/world.cc index 3f660215df7..1602dc4bb65 100644 --- a/source/blender/blenkernel/intern/world.cc +++ b/source/blender/blenkernel/intern/world.cc @@ -23,15 +23,17 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" +#include "BKE_anim_data.h" #include "BKE_icons.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" -#include "BKE_node.hh" +#include "BKE_main.hh" +#include "BKE_node.h" #include "BKE_preview_image.hh" #include "BKE_world.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DRW_engine.hh" @@ -177,7 +179,6 @@ static void world_blend_read_data(BlendDataReader *reader, ID *id) IDTypeInfo IDType_ID_WO = { /*id_code*/ ID_WO, /*id_filter*/ FILTER_ID_WO, - /*dependencies_id_types*/ FILTER_ID_TE, /*main_listbase_index*/ INDEX_ID_WO, /*struct_size*/ sizeof(World), /*name*/ "World", diff --git a/source/blender/blenkernel/intern/writeavi.cc b/source/blender/blenkernel/intern/writeavi.cc index 804764bcbfe..2e511946b8c 100644 --- a/source/blender/blenkernel/intern/writeavi.cc +++ b/source/blender/blenkernel/intern/writeavi.cc @@ -16,7 +16,7 @@ #include "BLI_utildefines.h" -#include "BKE_report.hh" +#include "BKE_report.h" #ifdef WITH_AVI # include "BLI_blenlib.h" diff --git a/source/blender/blenkernel/intern/writeffmpeg.cc b/source/blender/blenkernel/intern/writeffmpeg.cc index cbac7afa118..6c524182640 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.cc +++ b/source/blender/blenkernel/intern/writeffmpeg.cc @@ -28,12 +28,13 @@ # include "BLI_math_base.h" # include "BLI_threads.h" # include "BLI_utildefines.h" -# include "BLI_vector.hh" -# include "BKE_global.hh" +# include "BKE_global.h" +# include "BKE_idprop.h" # include "BKE_image.h" +# include "BKE_lib_id.hh" # include "BKE_main.hh" -# include "BKE_report.hh" +# include "BKE_report.h" # include "BKE_sound.h" # include "BKE_writeffmpeg.hh" @@ -57,25 +58,6 @@ extern "C" { struct StampData; -/* libswscale context creation and destruction is expensive. - * Maintain a cache of already created contexts. */ - -constexpr int64_t swscale_cache_max_entries = 32; - -struct SwscaleContext { - int width = 0, height = 0; - AVPixelFormat src_format = AV_PIX_FMT_NONE, dst_format = AV_PIX_FMT_NONE; - int flags = 0; - - SwsContext *context = nullptr; - int64_t last_use_timestamp = 0; - bool is_used = false; -}; - -static ThreadMutex swscale_cache_lock = PTHREAD_MUTEX_INITIALIZER; -static int64_t swscale_cache_timestamp = 0; -static blender::Vector *swscale_cache = nullptr; - struct FFMpegContext { int ffmpeg_type; AVCodecID ffmpeg_codec; @@ -685,7 +667,7 @@ static const AVCodec *get_av1_encoder( return codec; } -static SwsContext *sws_create_context( +SwsContext *BKE_ffmpeg_sws_get_context( int width, int height, int av_src_format, int av_dst_format, int sws_flags) { # if defined(FFMPEG_SWSCALE_THREADING) @@ -723,128 +705,6 @@ static SwsContext *sws_create_context( return c; } - -static void init_swscale_cache_if_needed() -{ - if (swscale_cache == nullptr) { - swscale_cache = new blender::Vector(); - swscale_cache_timestamp = 0; - } -} - -static bool remove_oldest_swscale_context() -{ - int64_t oldest_index = -1; - int64_t oldest_time = 0; - for (int64_t index = 0; index < swscale_cache->size(); index++) { - SwscaleContext &ctx = (*swscale_cache)[index]; - if (ctx.is_used) { - continue; - } - int64_t time = swscale_cache_timestamp - ctx.last_use_timestamp; - if (time > oldest_time) { - oldest_time = time; - oldest_index = index; - } - } - - if (oldest_index >= 0) { - SwscaleContext &ctx = (*swscale_cache)[oldest_index]; - sws_freeContext(ctx.context); - swscale_cache->remove_and_reorder(oldest_index); - return true; - } - return false; -} - -static void maintain_swscale_cache_size() -{ - while (swscale_cache->size() > swscale_cache_max_entries) { - if (!remove_oldest_swscale_context()) { - /* Could not remove anything (all contexts are actively used), - * stop trying. */ - break; - } - } -} - -SwsContext *BKE_ffmpeg_sws_get_context( - int width, int height, int av_src_format, int av_dst_format, int sws_flags) -{ - BLI_mutex_lock(&swscale_cache_lock); - - init_swscale_cache_if_needed(); - - swscale_cache_timestamp++; - - /* Search for unused context that has suitable parameters. */ - SwsContext *ctx = nullptr; - for (SwscaleContext &c : *swscale_cache) { - if (!c.is_used && c.width == width && c.height == height && c.src_format == av_src_format && - c.dst_format == av_dst_format && c.flags == sws_flags) - { - ctx = c.context; - /* Mark as used. */ - c.is_used = true; - c.last_use_timestamp = swscale_cache_timestamp; - break; - } - } - if (ctx == nullptr) { - /* No free matching context in cache: create a new one. */ - ctx = sws_create_context(width, height, av_src_format, av_dst_format, sws_flags); - SwscaleContext c; - c.width = width; - c.height = height; - c.src_format = AVPixelFormat(av_src_format); - c.dst_format = AVPixelFormat(av_dst_format); - c.flags = sws_flags; - c.context = ctx; - c.is_used = true; - c.last_use_timestamp = swscale_cache_timestamp; - swscale_cache->append(c); - - maintain_swscale_cache_size(); - } - - BLI_mutex_unlock(&swscale_cache_lock); - return ctx; -} - -void BKE_ffmpeg_sws_release_context(SwsContext *ctx) -{ - BLI_mutex_lock(&swscale_cache_lock); - init_swscale_cache_if_needed(); - - bool found = false; - for (SwscaleContext &c : *swscale_cache) { - if (c.context == ctx) { - BLI_assert_msg(c.is_used, "Releasing ffmpeg swscale context that is not in use"); - c.is_used = false; - found = true; - break; - } - } - BLI_assert_msg(found, "Releasing ffmpeg swscale context that is not in cache"); - UNUSED_VARS_NDEBUG(found); - maintain_swscale_cache_size(); - - BLI_mutex_unlock(&swscale_cache_lock); -} - -void BKE_ffmpeg_exit() -{ - BLI_mutex_lock(&swscale_cache_lock); - if (swscale_cache != nullptr) { - for (SwscaleContext &c : *swscale_cache) { - sws_freeContext(c.context); - } - delete swscale_cache; - swscale_cache = nullptr; - } - BLI_mutex_unlock(&swscale_cache_lock); -} - void BKE_ffmpeg_sws_scale_frame(SwsContext *ctx, AVFrame *dst, const AVFrame *src) { # if defined(FFMPEG_SWSCALE_THREADING) @@ -1819,7 +1679,7 @@ static void end_ffmpeg_impl(FFMpegContext *context, int is_autosplit) } if (context->img_convert_ctx != nullptr) { - BKE_ffmpeg_sws_release_context(context->img_convert_ctx); + sws_freeContext(context->img_convert_ctx); context->img_convert_ctx = nullptr; } } @@ -1835,6 +1695,55 @@ void BKE_ffmpeg_preset_set(RenderData *rd, int preset) bool is_ntsc = (rd->frs_sec != 25); switch (preset) { + case FFMPEG_PRESET_VCD: + rd->ffcodecdata.type = FFMPEG_MPEG1; + rd->ffcodecdata.video_bitrate = 1150; + rd->xsch = 352; + rd->ysch = is_ntsc ? 240 : 288; + rd->ffcodecdata.gop_size = is_ntsc ? 18 : 15; + rd->ffcodecdata.rc_max_rate = 1150; + rd->ffcodecdata.rc_min_rate = 1150; + rd->ffcodecdata.rc_buffer_size = 40 * 8; + rd->ffcodecdata.mux_packet_size = 2324; + rd->ffcodecdata.mux_rate = 2352 * 75 * 8; + break; + + case FFMPEG_PRESET_SVCD: + rd->ffcodecdata.type = FFMPEG_MPEG2; + rd->ffcodecdata.video_bitrate = 2040; + rd->xsch = 480; + rd->ysch = is_ntsc ? 480 : 576; + rd->ffcodecdata.gop_size = is_ntsc ? 18 : 15; + rd->ffcodecdata.rc_max_rate = 2516; + rd->ffcodecdata.rc_min_rate = 0; + rd->ffcodecdata.rc_buffer_size = 224 * 8; + rd->ffcodecdata.mux_packet_size = 2324; + rd->ffcodecdata.mux_rate = 0; + break; + + case FFMPEG_PRESET_DVD: + rd->ffcodecdata.type = FFMPEG_MPEG2; + rd->ffcodecdata.video_bitrate = 6000; + +# if 0 /* Don't set resolution, see #21351. */ + rd->xsch = 720; + rd->ysch = isntsc ? 480 : 576; +# endif + + rd->ffcodecdata.gop_size = is_ntsc ? 18 : 15; + rd->ffcodecdata.rc_max_rate = 9000; + rd->ffcodecdata.rc_min_rate = 0; + rd->ffcodecdata.rc_buffer_size = 224 * 8; + rd->ffcodecdata.mux_packet_size = 2048; + rd->ffcodecdata.mux_rate = 10080000; + break; + + case FFMPEG_PRESET_DV: + rd->ffcodecdata.type = FFMPEG_DV; + rd->xsch = 720; + rd->ysch = is_ntsc ? 480 : 576; + break; + case FFMPEG_PRESET_H264: rd->ffcodecdata.type = FFMPEG_AVI; rd->ffcodecdata.codec = AV_CODEC_ID_H264; @@ -1845,6 +1754,7 @@ void BKE_ffmpeg_preset_set(RenderData *rd, int preset) rd->ffcodecdata.rc_buffer_size = 224 * 8; rd->ffcodecdata.mux_packet_size = 2048; rd->ffcodecdata.mux_rate = 10080000; + break; case FFMPEG_PRESET_THEORA: @@ -1866,7 +1776,6 @@ void BKE_ffmpeg_preset_set(RenderData *rd, int preset) rd->ffcodecdata.mux_packet_size = 2048; rd->ffcodecdata.mux_rate = 10080000; break; - case FFMPEG_PRESET_AV1: rd->ffcodecdata.type = FFMPEG_AV1; rd->ffcodecdata.codec = AV_CODEC_ID_AV1; @@ -1877,6 +1786,7 @@ void BKE_ffmpeg_preset_set(RenderData *rd, int preset) rd->ffcodecdata.rc_buffer_size = 224 * 8; rd->ffcodecdata.mux_packet_size = 2048; rd->ffcodecdata.mux_rate = 10080000; + break; } } diff --git a/source/blender/blenkernel/particle_private.h b/source/blender/blenkernel/particle_private.h index 144c67ef449..551d89e4d47 100644 --- a/source/blender/blenkernel/particle_private.h +++ b/source/blender/blenkernel/particle_private.h @@ -38,7 +38,7 @@ void do_kink(ParticleKey *state, float flat, short type, short axis, - const float obmat[4][4], + float obmat[4][4], int smooth_start); float do_clump(ParticleKey *state, const float par_co[3], diff --git a/source/blender/blenlib/BLI_convexhull_2d.h b/source/blender/blenlib/BLI_convexhull_2d.h index 0871cd5855c..4e2963cabae 100644 --- a/source/blender/blenlib/BLI_convexhull_2d.h +++ b/source/blender/blenlib/BLI_convexhull_2d.h @@ -16,24 +16,22 @@ extern "C" { * Extract 2D convex hull. * * \param points: An array of 2D points. - * \param points_num: The number of points in points. - * \param r_points: An array of the convex hull vertex indices (max is `points_num`). - * Vertices are ordered counter clockwise, the polygons cross product is always negative (or zero). - * + * \param n: The number of points in points. + * \param r_points: An array of the convex hull vertex indices (max is n). * \return The number of indices in r_points. * - * \note Performance is `O(points_num.log(points_num))`, same as `qsort`. + * \note Performance is `O(n.log(n))`, same as `qsort`. */ -int BLI_convexhull_2d(const float (*points)[2], int points_num, int r_points[/*points_num*/]); +int BLI_convexhull_2d(const float (*points)[2], int n, int r_points[/*n*/]); /** * \return The best angle for fitting the points to an axis aligned bounding box. * * \note We could return the index of the best edge too if its needed. * - * \param points: Arbitrary 2D points. + * \param points: Arbitrary 2d points. */ -float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], int points_num); +float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], int n); #ifdef __cplusplus } diff --git a/source/blender/blenlib/BLI_hash_mm2a.hh b/source/blender/blenlib/BLI_hash_mm2a.hh index fc61807371e..a9fcfa6768f 100644 --- a/source/blender/blenlib/BLI_hash_mm2a.hh +++ b/source/blender/blenlib/BLI_hash_mm2a.hh @@ -10,12 +10,12 @@ #include "BLI_sys_types.h" -struct BLI_HashMurmur2A { +typedef struct BLI_HashMurmur2A { uint32_t hash; uint32_t tail; uint32_t count; uint32_t size; -}; +} BLI_HashMurmur2A; void BLI_hash_mm2a_init(BLI_HashMurmur2A *mm2, uint32_t seed); diff --git a/source/blender/blenlib/BLI_index_mask.hh b/source/blender/blenlib/BLI_index_mask.hh index 5611f79e47e..82338992abe 100644 --- a/source/blender/blenlib/BLI_index_mask.hh +++ b/source/blender/blenlib/BLI_index_mask.hh @@ -186,23 +186,6 @@ class IndexMask : private IndexMaskData { static IndexMask from_bools(const IndexMask &universe, const VArray &bools, IndexMaskMemory &memory); - /** - * Constructs a mask by repeating the indices in the given mask with a stride. - * For example, with an input mask containing `{3, 5}` and a stride of 10 the resulting mask - * would contain `{3, 5, 13, 15, 23, 25, ...}`. - */ - static IndexMask from_repeating(const IndexMask &mask_to_repeat, - int64_t repetitions, - int64_t stride, - int64_t initial_offset, - IndexMaskMemory &memory); - /** - * Constructs a mask that contains every nth index the given number of times. - */ - static IndexMask from_every_nth(int64_t n, - int64_t indices_num, - const int64_t initial_offset, - IndexMaskMemory &memory); /** * Construct a mask from the given segments. The provided segments are expected to be * sorted and owned by #memory already. @@ -238,11 +221,6 @@ class IndexMask : private IndexMaskData { int64_t first() const; int64_t last() const; - /** - * Returns the smallest range that contains all indices stored in this mask. - */ - IndexRange bounds() const; - /** * \return Minimum number of elements an array has to have so that it can be indexed by every * index stored in the mask. @@ -290,19 +268,14 @@ class IndexMask : private IndexMaskData { IndexMask slice_content(IndexRange range) const; IndexMask slice_content(int64_t start, int64_t size) const; /** - * Same #slice but can also add an offset to every index in the mask. + * Same as above but can also add an offset to every index in the mask. * Takes O(log n + range.size()) time but with a very small constant factor. */ - IndexMask slice_and_shift(IndexRange range, int64_t offset, IndexMaskMemory &memory) const; - IndexMask slice_and_shift(int64_t start, - int64_t size, - int64_t offset, - IndexMaskMemory &memory) const; - - /** - * Adds an offset to every index in the mask. - */ - IndexMask shift(const int64_t offset, IndexMaskMemory &memory) const; + IndexMask slice_and_offset(IndexRange range, int64_t offset, IndexMaskMemory &memory) const; + IndexMask slice_and_offset(int64_t start, + int64_t size, + int64_t offset, + IndexMaskMemory &memory) const; /** * \return A new index mask that contains all the indices from the universe that are not in the @@ -319,22 +292,6 @@ class IndexMask : private IndexMaskData { */ IndexMaskSegment segment(int64_t segment_i) const; - /** - * Iterate over the indices in multiple masks which have the same size. The given function is - * called for groups of segments where each segment has the same size and comes from a different - * input mask. - * For example, if the input masks are (both have size 18): - * A: [0, 15), {20, 24, 25} - * B: [0, 5), [10, 15], {20, 30, 40, 50, 60, 70, 80, 90} - * Then the function will be called multiple times, each time with two segments: - * 1. [0, 5), [0, 5) - * 2. [5, 10), [10, 15) - * 3. [10, 15), {20, 30, 40, 50, 60} - * 4. {20, 24, 25}, {70, 80, 90} - */ - static void foreach_segment_zipped(Span masks, - FunctionRef segments)> fn); - /** * Calls the function once for every index. * @@ -432,9 +389,6 @@ class IndexMask : private IndexMaskData { * Is used by some functions to get low level access to the mask in order to construct it. */ IndexMaskData &data_for_inplace_construction(); - - friend bool operator==(const IndexMask &a, const IndexMask &b); - friend bool operator!=(const IndexMask &a, const IndexMask &b); }; /** @@ -595,17 +549,6 @@ inline IndexRange IndexMask::index_range() const return IndexRange(indices_num_); } -inline IndexRange IndexMask::bounds() const -{ - if (this->is_empty()) { - return IndexRange(); - } - const int64_t first = this->first(); - const int64_t last = this->last(); - const int64_t range = last - first + 1; - return IndexRange(first, range); -} - inline int64_t IndexMask::first() const { BLI_assert(indices_num_ > 0); @@ -983,11 +926,6 @@ inline Vector, N> IndexMask::to_spans return segments; } -inline bool operator!=(const IndexMask &a, const IndexMask &b) -{ - return !(a == b); -} - } // namespace blender::index_mask namespace blender { diff --git a/source/blender/blenlib/BLI_index_range.hh b/source/blender/blenlib/BLI_index_range.hh index e408b3c0a70..316dda821a1 100644 --- a/source/blender/blenlib/BLI_index_range.hh +++ b/source/blender/blenlib/BLI_index_range.hh @@ -41,7 +41,6 @@ #include #include "BLI_assert.h" -#include "BLI_random_access_iterator_mixin.hh" namespace blender { @@ -66,11 +65,13 @@ class IndexRange { BLI_assert(size >= 0); } - class Iterator : public iterator::RandomAccessIteratorMixin { + class Iterator { public: + using iterator_category = std::forward_iterator_tag; using value_type = int64_t; using pointer = const int64_t *; - using reference = int64_t; + using reference = const int64_t &; + using difference_type = std::ptrdiff_t; private: int64_t current_; @@ -78,12 +79,35 @@ class IndexRange { public: constexpr explicit Iterator(int64_t current) : current_(current) {} - constexpr int64_t operator*() const + constexpr Iterator &operator++() { - return current_; + current_++; + return *this; } - const int64_t &iter_prop() const + constexpr Iterator operator++(int) + { + Iterator copied_iterator = *this; + ++(*this); + return copied_iterator; + } + + constexpr friend bool operator!=(const Iterator &a, const Iterator &b) + { + return a.current_ != b.current_; + } + + constexpr friend bool operator==(const Iterator &a, const Iterator &b) + { + return a.current_ == b.current_; + } + + constexpr friend int64_t operator-(const Iterator &a, const Iterator &b) + { + return a.current_ - b.current_; + } + + constexpr int64_t operator*() const { return current_; } diff --git a/source/blender/blenlib/BLI_math_interp.hh b/source/blender/blenlib/BLI_math_interp.hh index b000b5301dc..2354acfec40 100644 --- a/source/blender/blenlib/BLI_math_interp.hh +++ b/source/blender/blenlib/BLI_math_interp.hh @@ -249,7 +249,7 @@ void interpolate_cubic_mitchell_fl( #define EWA_MAXIDX 255 extern const float EWA_WTS[EWA_MAXIDX + 1]; -using ewa_filter_read_pixel_cb = void (*)(void *userdata, int x, int y, float result[4]); +typedef void (*ewa_filter_read_pixel_cb)(void *userdata, int x, int y, float result[4]); void BLI_ewa_imp2radangle( float A, float B, float C, float F, float *a, float *b, float *th, float *ecc); diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 2b6eb7c5c90..2846d315db4 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -621,8 +621,7 @@ void BLI_space_transform_apply_normal(const struct SpaceTransform *data, float n void BLI_space_transform_invert_normal(const struct SpaceTransform *data, float no[3]); #define BLI_SPACE_TRANSFORM_SETUP(data, local, target) \ - BLI_space_transform_from_matrices( \ - (data), (local)->object_to_world().ptr(), (target)->object_to_world().ptr()) + BLI_space_transform_from_matrices((data), (local)->object_to_world, (target)->object_to_world) /** \} */ diff --git a/source/blender/blenlib/BLI_math_matrix_types.hh b/source/blender/blenlib/BLI_math_matrix_types.hh index 280ac211eda..978d30466f6 100644 --- a/source/blender/blenlib/BLI_math_matrix_types.hh +++ b/source/blender/blenlib/BLI_math_matrix_types.hh @@ -488,17 +488,17 @@ struct alignas(Alignment) MatBase : public vec_struct_base, N friend std::ostream &operator<<(std::ostream &stream, const MatBase &mat) { stream << "(\n"; - unroll([&](auto i) { + unroll([&](auto i) { stream << "("; - unroll([&](auto j) { + unroll([&](auto j) { /** NOTE: j and i are swapped to follow mathematical convention. */ stream << mat[j][i]; - if (j < NumCol - 1) { + if (j < NumRow - 1) { stream << ", "; } }); stream << ")"; - if (i < NumRow - 1) { + if (i < NumCol - 1) { stream << ","; } stream << "\n"; diff --git a/source/blender/blenlib/BLI_offset_span.hh b/source/blender/blenlib/BLI_offset_span.hh index 4978e1e1f60..747d0be3510 100644 --- a/source/blender/blenlib/BLI_offset_span.hh +++ b/source/blender/blenlib/BLI_offset_span.hh @@ -4,7 +4,6 @@ #pragma once -#include "BLI_random_access_iterator_mixin.hh" #include "BLI_span.hh" namespace blender { @@ -71,12 +70,7 @@ template class OffsetSpan { return {offset_, data_.slice(start, size)}; } - class Iterator : public iterator::RandomAccessIteratorMixin { - public: - using value_type = T; - using pointer = const T *; - using reference = T; - + class Iterator { private: T offset_; const BaseT *data_; @@ -84,14 +78,21 @@ template class OffsetSpan { public: Iterator(const T offset, const BaseT *data) : offset_(offset), data_(data) {} + Iterator &operator++() + { + data_++; + return *this; + } + T operator*() const { return T(*data_) + offset_; } - const BaseT *const &iter_prop() const + friend bool operator!=(const Iterator &a, const Iterator &b) { - return data_; + BLI_assert(a.offset_ == b.offset_); + return a.data_ != b.data_; } }; diff --git a/source/blender/blenlib/BLI_random_access_iterator_mixin.hh b/source/blender/blenlib/BLI_random_access_iterator_mixin.hh deleted file mode 100644 index d8ac886a2af..00000000000 --- a/source/blender/blenlib/BLI_random_access_iterator_mixin.hh +++ /dev/null @@ -1,133 +0,0 @@ -/* SPDX-FileCopyrightText: 2024 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#pragma once - -#include - -namespace blender::iterator { - -/** - * Simplifies implementing a random-access-iterator. - * - * The actual iterator should derive from this class publicly. Additionally, it has to provide a - * const `iter_prop` method which returns a reference to the internal property that corresponds to - * the current position. This is typically a pointer or an index. - * - * Implementing some random-access-iterator is generally quite simple but requires a lot of - * boilerplate code because algorithms expect many operators to work on the iterator type. - * They are expected to behave similarly to pointers and thus have to implement many of the same - * operators. - */ -template class RandomAccessIteratorMixin { - public: - using iterator_category = std::random_access_iterator_tag; - using difference_type = std::ptrdiff_t; - - constexpr friend Derived &operator++(Derived &a) - { - ++a.iter_prop_mutable(); - return a; - } - - constexpr friend Derived operator++(Derived &a, int) - { - Derived copy = a; - ++a; - return copy; - } - - constexpr friend Derived &operator--(Derived &a) - { - --a.iter_prop_mutable(); - return a; - } - - constexpr friend Derived operator--(Derived &a, int) - { - Derived copy = a; - --a; - return copy; - } - - constexpr friend Derived &operator+=(Derived &a, const std::ptrdiff_t n) - { - a.iter_prop_mutable() += n; - return a; - } - - constexpr friend Derived &operator-=(Derived &a, const std::ptrdiff_t n) - { - a.iter_prop_mutable() -= n; - return a; - } - - constexpr friend Derived operator+(const Derived &a, const std::ptrdiff_t n) - { - Derived copy = a; - copy.iter_prop_mutable() += n; - return copy; - } - - constexpr friend Derived operator-(const Derived &a, const std::ptrdiff_t n) - { - Derived copy = a; - copy.iter_prop_mutable() -= n; - return copy; - } - - constexpr friend auto operator-(const Derived &a, const Derived &b) - { - return a.iter_prop() - b.iter_prop(); - } - - constexpr friend bool operator!=(const Derived &a, const Derived &b) - { - return a.iter_prop() != b.iter_prop(); - } - - constexpr friend bool operator==(const Derived &a, const Derived &b) - { - return a.iter_prop() == b.iter_prop(); - } - - constexpr friend bool operator<(const Derived &a, const Derived &b) - { - return a.iter_prop() < b.iter_prop(); - } - - constexpr friend bool operator>(const Derived &a, const Derived &b) - { - return a.iter_prop() > b.iter_prop(); - } - - constexpr friend bool operator<=(const Derived &a, const Derived &b) - { - return a.iter_prop() <= b.iter_prop(); - } - - constexpr friend bool operator>=(const Derived &a, const Derived &b) - { - return a.iter_prop() >= b.iter_prop(); - } - - constexpr decltype(auto) operator[](const std::ptrdiff_t i) - { - return *(*static_cast(this) + i); - } - - constexpr decltype(auto) operator[](const std::ptrdiff_t i) const - { - return *(*static_cast(this) + i); - } - - auto &iter_prop_mutable() - { - const auto &const_iter_prop = static_cast(this)->iter_prop(); - return const_cast> &>( - const_iter_prop); - } -}; - -} // namespace blender::iterator diff --git a/source/blender/blenlib/BLI_strict_flags.h b/source/blender/blenlib/BLI_strict_flags.h index 112156c2bc3..e97bd5f0278 100644 --- a/source/blender/blenlib/BLI_strict_flags.h +++ b/source/blender/blenlib/BLI_strict_flags.h @@ -6,12 +6,8 @@ /** \file * \ingroup bli - * Strict compiler flags for areas of code we want + * \brief Strict compiler flags for areas of code we want * to ensure don't do conversions without us knowing about it. - * - * \note Typically this include should be ordered as the last include in a C/C++ file - * otherwise it can cause warnings in any includes after it which aren't expected - * to use strict warnings. */ #ifdef __GNUC__ diff --git a/source/blender/blenlib/BLI_string_search.hh b/source/blender/blenlib/BLI_string_search.hh index fc694d6c093..ccbf766e100 100644 --- a/source/blender/blenlib/BLI_string_search.hh +++ b/source/blender/blenlib/BLI_string_search.hh @@ -98,7 +98,7 @@ template class StringSearch : private StringSearchBase { * \param weight: Can be used to customize the order when multiple items have the same match * score. */ - void add(const StringRef str, T *user_data, const int weight = 0) + void add(const StringRefNull str, T *user_data, const int weight = 0) { this->add_impl(str, (void *)user_data, weight); } diff --git a/source/blender/blenlib/BLI_system.h b/source/blender/blenlib/BLI_system.h index 4d78b425500..ab2ef59ce54 100644 --- a/source/blender/blenlib/BLI_system.h +++ b/source/blender/blenlib/BLI_system.h @@ -15,7 +15,7 @@ extern "C" { */ int BLI_cpu_support_sse2(void); -int BLI_cpu_support_sse42(void); +int BLI_cpu_support_sse41(void); void BLI_system_backtrace(FILE *fp); /** Get CPU brand, result is to be MEM_freeN()-ed. */ diff --git a/source/blender/blenlib/BLI_time.h b/source/blender/blenlib/BLI_time.h index 29613bc3fca..b4529d9c7f3 100644 --- a/source/blender/blenlib/BLI_time.h +++ b/source/blender/blenlib/BLI_time.h @@ -13,20 +13,24 @@ extern "C" { #endif -/** - * Return an indication of time, expressed as seconds since some fixed point. - * Successive calls are guaranteed to generate values greater than or equal to the last call. - */ -extern double BLI_time_now_seconds(void); +extern + /** Return an indication of time, expressed as + * seconds since some fixed point. Successive calls + * are guaranteed to generate values greater than or + * equal to the last call. */ + double + BLI_check_seconds_timer(void); -/** `int` version of #BLI_time_now_seconds. */ -extern long int BLI_time_now_seconds_i(void); +extern + /** `int` version of #BLI_check_seconds_timer. */ + long int + BLI_check_seconds_timer_i(void); /** * Platform-independent sleep function. * \param ms: Number of milliseconds to sleep */ -void BLI_time_sleep_ms(int ms); +void BLI_sleep_ms(int ms); #ifdef __cplusplus } diff --git a/source/blender/blenlib/BLI_time_utildefines.h b/source/blender/blenlib/BLI_time_utildefines.h index cfefca51749..0daa80222a6 100644 --- a/source/blender/blenlib/BLI_time_utildefines.h +++ b/source/blender/blenlib/BLI_time_utildefines.h @@ -9,12 +9,12 @@ #pragma once -#include "BLI_time.h" /* for BLI_time_now_seconds */ +#include "BLI_time.h" /* for BLI_check_seconds_timer */ #include "BLI_utildefines.h" /* for AT */ #define TIMEIT_START(var) \ { \ - double _timeit_##var = BLI_time_now_seconds(); \ + double _timeit_##var = BLI_check_seconds_timer(); \ printf("time start (" #var "): " AT "\n"); \ fflush(stdout); \ { \ @@ -23,7 +23,7 @@ /** * \return the time since TIMEIT_START was called. */ -#define TIMEIT_VALUE(var) (float)(BLI_time_now_seconds() - _timeit_##var) +#define TIMEIT_VALUE(var) (float)(BLI_check_seconds_timer() - _timeit_##var) #define TIMEIT_VALUE_PRINT(var) \ { \ @@ -54,7 +54,7 @@ { \ static float _sum_##var = 0.0f; \ static float _num_##var = 0.0f; \ - double _timeit_##var = BLI_time_now_seconds(); \ + double _timeit_##var = BLI_check_seconds_timer(); \ printf("time start (" #var "): " AT "\n"); \ fflush(stdout); \ { \ @@ -95,13 +95,13 @@ #define TIMEIT_BLOCK_START(id) \ { \ - double _timeit_block_start_##id = BLI_time_now_seconds(); \ + double _timeit_block_start_##id = BLI_check_seconds_timer(); \ { \ (void)0 #define TIMEIT_BLOCK_END(id) \ } \ - _timeit_var_##id += (BLI_time_now_seconds() - _timeit_block_start_##id); \ + _timeit_var_##id += (BLI_check_seconds_timer() - _timeit_block_start_##id); \ } \ (void)0 diff --git a/source/blender/blenlib/BLI_uuid.h b/source/blender/blenlib/BLI_uuid.h index 329e9b3d5a1..91122776ae3 100644 --- a/source/blender/blenlib/BLI_uuid.h +++ b/source/blender/blenlib/BLI_uuid.h @@ -60,8 +60,6 @@ bool BLI_uuid_parse_string(bUUID *uuid, const char *buffer) ATTR_NONNULL(); # include # include -# include "BLI_string_ref.hh" - /** Output the UUID as formatted ASCII string, see #BLI_uuid_format(). */ std::ostream &operator<<(std::ostream &stream, bUUID uuid); @@ -81,7 +79,7 @@ class bUUID : public ::bUUID { bUUID(std::initializer_list field_values); /** Initialize by parsing the string; undefined behavior when the string is invalid. */ - explicit bUUID(const StringRefNull string_formatted_uuid); + explicit bUUID(const std::string &string_formatted_uuid); uint64_t hash() const; }; // namespace blender diff --git a/source/blender/blenlib/BLI_uvproject.h b/source/blender/blenlib/BLI_uvproject.h index 06c34bd09a7..1ee807813c2 100644 --- a/source/blender/blenlib/BLI_uvproject.h +++ b/source/blender/blenlib/BLI_uvproject.h @@ -17,11 +17,11 @@ struct ProjCameraInfo; /** * Create UV info from the camera, needs to be freed. * - * \param rotmat: can be `obedit->object_to_world().ptr()` when uv project is used. + * \param rotmat: can be `obedit->object_to_world` when uv project is used. * \param winx, winy: can be from `scene->r.xsch / ysch`. */ struct ProjCameraInfo *BLI_uvproject_camera_info(struct Object *ob, - const float rotmat[4][4], + float rotmat[4][4], float winx, float winy); diff --git a/source/blender/blenlib/BLI_virtual_array.hh b/source/blender/blenlib/BLI_virtual_array.hh index 69f9018dec8..a74d5aa21c0 100644 --- a/source/blender/blenlib/BLI_virtual_array.hh +++ b/source/blender/blenlib/BLI_virtual_array.hh @@ -1217,19 +1217,6 @@ template class SingleAsSpan { } }; -template class VArrayRef { - private: - const VArray &ref_; - - public: - VArrayRef(const VArray &ref) : ref_(ref) {} - - const T operator[](const int64_t index) const - { - return ref_[index]; - } -}; - /** To be used with #call_with_devirtualized_parameters. */ template struct VArrayDevirtualizer { const VArray &varray; @@ -1270,7 +1257,7 @@ inline void devirtualize_varray(const VArray &varray, const Func &func, bool return; } } - func(VArrayRef(varray)); + func(varray); } /** @@ -1293,7 +1280,7 @@ inline void devirtualize_varray2(const VArray &varray1, return; } } - func(VArrayRef(varray1), VArrayRef(varray2)); + func(varray1, varray2); } } // namespace blender diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index a186ab883af..7f33907e20b 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -56,7 +56,7 @@ set(SRC intern/buffer.c intern/cache_mutex.cc intern/compute_context.cc - intern/convexhull_2d.cc + intern/convexhull_2d.c intern/cpp_type.cc intern/cpp_types.cc intern/delaunay_2d.cc @@ -155,7 +155,7 @@ set(SRC intern/timecode.c intern/timeit.cc intern/uuid.cc - intern/uvproject.cc + intern/uvproject.c intern/vector.cc intern/virtual_array.cc intern/voxel.c @@ -330,7 +330,6 @@ set(SRC BLI_quadric.h BLI_rand.h BLI_rand.hh - BLI_random_access_iterator_mixin.hh BLI_range.h BLI_rect.h BLI_resource_scope.hh @@ -499,7 +498,6 @@ if(WITH_GTESTS) tests/BLI_bitmap_test.cc tests/BLI_bounds_test.cc tests/BLI_color_test.cc - tests/BLI_convexhull_2d_test.cc tests/BLI_cpp_type_test.cc tests/BLI_delaunay_2d_test.cc tests/BLI_disjoint_set_test.cc @@ -546,7 +544,6 @@ if(WITH_GTESTS) tests/BLI_path_util_test.cc tests/BLI_polyfill_2d_test.cc tests/BLI_pool_test.cc - tests/BLI_random_access_iterator_mixin_test.cc tests/BLI_ressource_strings.h tests/BLI_serialize_test.cc tests/BLI_session_uid_test.cc diff --git a/source/blender/blenlib/intern/BLI_assert.c b/source/blender/blenlib/intern/BLI_assert.c index 600e7a2c0ab..deefc847f61 100644 --- a/source/blender/blenlib/intern/BLI_assert.c +++ b/source/blender/blenlib/intern/BLI_assert.c @@ -9,10 +9,7 @@ */ #include "BLI_assert.h" /* Own include. */ - -#ifndef NDEBUG -# include "BLI_system.h" -#endif +#include "BLI_system.h" #include #include diff --git a/source/blender/blenlib/intern/BLI_filelist.cc b/source/blender/blenlib/intern/BLI_filelist.cc index 0dee9390d34..563ed235829 100644 --- a/source/blender/blenlib/intern/BLI_filelist.cc +++ b/source/blender/blenlib/intern/BLI_filelist.cc @@ -42,6 +42,8 @@ #include "BLI_string.h" #include "BLI_string_utils.hh" +#include "../imbuf/IMB_imbuf.hh" + /* * Ordering function for sorting lists of files/directories. Returns -1 if * entry1 belongs before entry2, 0 if they are equal, 1 if they should be swapped. diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 809df575b45..cda177beb35 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -24,7 +24,8 @@ #define GHASH_INTERNAL_API #include "BLI_ghash.h" /* own include */ -#include "BLI_strict_flags.h" /* Keep last. */ +/* keep last */ +#include "BLI_strict_flags.h" /* -------------------------------------------------------------------- */ /** \name Structs & Constants diff --git a/source/blender/blenlib/intern/BLI_ghash_utils.cc b/source/blender/blenlib/intern/BLI_ghash_utils.cc index 9376dae39a3..3d4ce192b46 100644 --- a/source/blender/blenlib/intern/BLI_ghash_utils.cc +++ b/source/blender/blenlib/intern/BLI_ghash_utils.cc @@ -9,7 +9,7 @@ * (not its implementation). */ -#include +#include #include "MEM_guardedalloc.h" @@ -17,7 +17,8 @@ #include "BLI_hash_mm2a.hh" #include "BLI_utildefines.h" -#include "BLI_strict_flags.h" /* Keep last. */ +/* keep last */ +#include "BLI_strict_flags.h" /* -------------------------------------------------------------------- */ /** \name Generic Key Hash & Comparison Functions @@ -34,13 +35,13 @@ uint BLI_ghashutil_ptrhash(const void *key) { /* Based Python3.7's pointer hashing function. */ - size_t y = size_t(key); + size_t y = (size_t)key; /* bottom 3 or 4 bits are likely to be 0; rotate y by 4 to avoid * excessive hash collisions for dictionaries and sets */ /* NOTE: Unlike Python `sizeof(uint)` is used instead of `sizeof(void *)`, * Otherwise casting to 'uint' ignores the upper bits on 64bit platforms. */ - return uint(y >> 4) | (uint(y) << (sizeof(uint[8]) - 4)); + return (uint)(y >> 4) | ((uint)y << (sizeof(uint[8]) - 4)); } #endif bool BLI_ghashutil_ptrcmp(const void *a, const void *b) @@ -85,7 +86,7 @@ uint BLI_ghashutil_uinthash(uint key) uint BLI_ghashutil_inthash_p(const void *ptr) { - uintptr_t key = uintptr_t(ptr); + uintptr_t key = (uintptr_t)ptr; key += ~(key << 16); key ^= (key >> 5); @@ -94,12 +95,12 @@ uint BLI_ghashutil_inthash_p(const void *ptr) key += ~(key << 9); key ^= (key >> 17); - return uint(key & 0xffffffff); + return (uint)(key & 0xffffffff); } uint BLI_ghashutil_inthash_p_murmur(const void *ptr) { - uintptr_t key = uintptr_t(ptr); + uintptr_t key = (uintptr_t)ptr; return BLI_hash_mm2((const uchar *)&key, sizeof(key), 0); } @@ -125,7 +126,7 @@ uint BLI_ghashutil_strhash_n(const char *key, size_t n) uint h = 5381; for (p = (const signed char *)key; n-- && *p != '\0'; p++) { - h = uint((h << 5) + h) + uint(*p); + h = (uint)((h << 5) + h) + (uint)*p; } return h; @@ -136,7 +137,7 @@ uint BLI_ghashutil_strhash_p(const void *ptr) uint h = 5381; for (p = static_cast(ptr); *p != '\0'; p++) { - h = uint((h << 5) + h) + uint(*p); + h = (uint)((h << 5) + h) + (uint)*p; } return h; diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c index 8f596988482..032d439f7b7 100644 --- a/source/blender/blenlib/intern/BLI_heap.c +++ b/source/blender/blenlib/intern/BLI_heap.c @@ -14,10 +14,9 @@ #include "MEM_guardedalloc.h" #include "BLI_heap.h" +#include "BLI_strict_flags.h" #include "BLI_utildefines.h" -#include "BLI_strict_flags.h" /* Keep last. */ - /***/ struct HeapNode { diff --git a/source/blender/blenlib/intern/BLI_heap_simple.c b/source/blender/blenlib/intern/BLI_heap_simple.c index 470ec73af23..9854ffd3ffa 100644 --- a/source/blender/blenlib/intern/BLI_heap_simple.c +++ b/source/blender/blenlib/intern/BLI_heap_simple.c @@ -18,10 +18,9 @@ #include "MEM_guardedalloc.h" #include "BLI_heap_simple.h" +#include "BLI_strict_flags.h" #include "BLI_utildefines.h" -#include "BLI_strict_flags.h" /* Keep last. */ - #define HEAP_PARENT(i) (((i)-1) >> 1) /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenlib/intern/BLI_index_range.cc b/source/blender/blenlib/intern/BLI_index_range.cc index 8a6684f21ce..df2c56f1c0e 100644 --- a/source/blender/blenlib/intern/BLI_index_range.cc +++ b/source/blender/blenlib/intern/BLI_index_range.cc @@ -4,8 +4,11 @@ #include +#include "BLI_array.hh" #include "BLI_index_range.hh" -#include "BLI_utildefines.h" +#include "BLI_span.hh" +#include "BLI_task.hh" +#include "BLI_vector.hh" namespace blender { diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index be3a8aeee6a..b748ea3bfe7 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -33,7 +33,7 @@ #include "BLI_task.h" #include "BLI_utildefines.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* used for iterative_raycast */ // #define USE_SKIP_LINKS diff --git a/source/blender/blenlib/intern/BLI_linklist.c b/source/blender/blenlib/intern/BLI_linklist.c index bb57fc3299f..db400d51234 100644 --- a/source/blender/blenlib/intern/BLI_linklist.c +++ b/source/blender/blenlib/intern/BLI_linklist.c @@ -19,7 +19,7 @@ #include "BLI_mempool.h" #include "BLI_utildefines.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" int BLI_linklist_count(const LinkNode *list) { diff --git a/source/blender/blenlib/intern/BLI_linklist_lockfree.c b/source/blender/blenlib/intern/BLI_linklist_lockfree.c index 88fd1fe0878..992af907266 100644 --- a/source/blender/blenlib/intern/BLI_linklist_lockfree.c +++ b/source/blender/blenlib/intern/BLI_linklist_lockfree.c @@ -9,11 +9,10 @@ #include "MEM_guardedalloc.h" #include "BLI_linklist_lockfree.h" +#include "BLI_strict_flags.h" #include "atomic_ops.h" -#include "BLI_strict_flags.h" /* Keep last. */ - void BLI_linklist_lockfree_init(LockfreeLinkList *list) { list->dummy_node.next = NULL; diff --git a/source/blender/blenlib/intern/BLI_memarena.c b/source/blender/blenlib/intern/BLI_memarena.c index 6f36db18095..5b0a8bd41fb 100644 --- a/source/blender/blenlib/intern/BLI_memarena.c +++ b/source/blender/blenlib/intern/BLI_memarena.c @@ -21,6 +21,7 @@ #include "BLI_asan.h" #include "BLI_memarena.h" +#include "BLI_strict_flags.h" #include "BLI_utildefines.h" #ifdef WITH_MEM_VALGRIND @@ -32,8 +33,6 @@ # define VALGRIND_MOVE_MEMPOOL(pool_a, pool_b) UNUSED_VARS(pool_a, pool_b) #endif -#include "BLI_strict_flags.h" /* Keep last. */ - struct MemBuf { struct MemBuf *next; uchar data[0]; diff --git a/source/blender/blenlib/intern/BLI_memblock.c b/source/blender/blenlib/intern/BLI_memblock.c index 95b375b8be4..595bae69b2f 100644 --- a/source/blender/blenlib/intern/BLI_memblock.c +++ b/source/blender/blenlib/intern/BLI_memblock.c @@ -11,13 +11,15 @@ #include #include +#include "atomic_ops.h" + #include "BLI_utildefines.h" #include "BLI_memblock.h" /* own include */ #include "MEM_guardedalloc.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* keep last */ #define CHUNK_LIST_SIZE 16 diff --git a/source/blender/blenlib/intern/BLI_memiter.c b/source/blender/blenlib/intern/BLI_memiter.c index 11d81373154..a2278176b4c 100644 --- a/source/blender/blenlib/intern/BLI_memiter.c +++ b/source/blender/blenlib/intern/BLI_memiter.c @@ -35,7 +35,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* keep last */ /* TODO: Valgrind. */ diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index 610c39176ed..12569172e97 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -31,12 +31,12 @@ #include "MEM_guardedalloc.h" +#include "BLI_strict_flags.h" /* keep last */ + #ifdef WITH_MEM_VALGRIND # include "valgrind/memcheck.h" #endif -#include "BLI_strict_flags.h" /* Keep last. */ - #ifdef WITH_ASAN # define POISON_REDZONE_SIZE 32 #else diff --git a/source/blender/blenlib/intern/BLI_timer.c b/source/blender/blenlib/intern/BLI_timer.c index 52323be4f8f..2a308207931 100644 --- a/source/blender/blenlib/intern/BLI_timer.c +++ b/source/blender/blenlib/intern/BLI_timer.c @@ -12,7 +12,7 @@ #include "MEM_guardedalloc.h" -#define GET_TIME() BLI_time_now_seconds() +#define GET_TIME() BLI_check_seconds_timer() typedef struct TimedFunction { struct TimedFunction *next, *prev; diff --git a/source/blender/blenlib/intern/array_store.cc b/source/blender/blenlib/intern/array_store.cc index 3cb91941714..b1932ff5fa0 100644 --- a/source/blender/blenlib/intern/array_store.cc +++ b/source/blender/blenlib/intern/array_store.cc @@ -96,10 +96,12 @@ #include "BLI_listbase.h" #include "BLI_mempool.h" -#include "BLI_array_store.h" /* Own include. */ -#include "BLI_ghash.h" /* Only for #BLI_array_store_is_valid. */ +#include "BLI_strict_flags.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_array_store.h" /* Own include. */ + +/* Only for #BLI_array_store_is_valid. */ +#include "BLI_ghash.h" struct BChunkList; diff --git a/source/blender/blenlib/intern/array_store_utils.cc b/source/blender/blenlib/intern/array_store_utils.cc index 2856a92a998..71d67a16038 100644 --- a/source/blender/blenlib/intern/array_store_utils.cc +++ b/source/blender/blenlib/intern/array_store_utils.cc @@ -9,6 +9,8 @@ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" + #include "BLI_array_store.h" #include "BLI_array_store_utils.h" /* own include */ diff --git a/source/blender/blenlib/intern/array_utils.c b/source/blender/blenlib/intern/array_utils.c index cb1ffd47903..9b7544ab94e 100644 --- a/source/blender/blenlib/intern/array_utils.c +++ b/source/blender/blenlib/intern/array_utils.c @@ -17,13 +17,12 @@ #include "BLI_alloca.h" #include "BLI_math_base.h" +#include "BLI_strict_flags.h" #include "BLI_sys_types.h" #include "BLI_utildefines.h" #include "BLI_array_utils.h" -#include "BLI_strict_flags.h" /* Keep last. */ - void _bli_array_reverse(void *arr_v, uint arr_len, size_t arr_stride) { const uint arr_stride_uint = (uint)arr_stride; diff --git a/source/blender/blenlib/intern/bitmap_draw_2d.c b/source/blender/blenlib/intern/bitmap_draw_2d.c index 2a1b58ef742..372bd58a113 100644 --- a/source/blender/blenlib/intern/bitmap_draw_2d.c +++ b/source/blender/blenlib/intern/bitmap_draw_2d.c @@ -18,7 +18,7 @@ #include "BLI_sort.h" #include "BLI_utildefines.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* -------------------------------------------------------------------- */ /** \name Draw Line diff --git a/source/blender/blenlib/intern/boxpack_2d.c b/source/blender/blenlib/intern/boxpack_2d.c index ee67e5ca8e5..cb65e218039 100644 --- a/source/blender/blenlib/intern/boxpack_2d.c +++ b/source/blender/blenlib/intern/boxpack_2d.c @@ -18,7 +18,7 @@ #include "BLI_sort.h" /* qsort_r */ #define qsort_r BLI_qsort_r -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" #ifdef __GNUC__ # pragma GCC diagnostic error "-Wpadded" diff --git a/source/blender/blenlib/intern/buffer.c b/source/blender/blenlib/intern/buffer.c index 61a4c71637d..63492879808 100644 --- a/source/blender/blenlib/intern/buffer.c +++ b/source/blender/blenlib/intern/buffer.c @@ -36,7 +36,7 @@ #include "BLI_buffer.h" #include "BLI_utildefines.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" static void *buffer_alloc(BLI_Buffer *buffer, const size_t len) { diff --git a/source/blender/blenlib/intern/convexhull_2d.c b/source/blender/blenlib/intern/convexhull_2d.c new file mode 100644 index 00000000000..18290597af2 --- /dev/null +++ b/source/blender/blenlib/intern/convexhull_2d.c @@ -0,0 +1,283 @@ +/* SPDX-FileCopyrightText: 2023 Blender Authors + * SPDX-FileCopyrightText: 2001 softSurfer (http://www.softsurfer.com) + * + * SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup bli + */ + +#include +#include + +#include "MEM_guardedalloc.h" + +#include "BLI_convexhull_2d.h" +#include "BLI_math_vector.h" +#include "BLI_strict_flags.h" +#include "BLI_utildefines.h" + +/* Copyright 2001, softSurfer (http://www.softsurfer.com) + * This code may be freely used and modified for any purpose + * providing that this copyright notice is included with it. + * SoftSurfer makes no warranty for this code, and cannot be held + * liable for any real or imagined damage resulting from its use. + * Users of this code must verify correctness for their application. + * http://softsurfer.com/Archive/algorithm_0203/algorithm_0203.htm + */ + +/* -------------------------------------------------------------------- */ +/** \name Main Convex-Hull Calculation + * \{ */ + +/** + * tests if a point is Left|On|Right of an infinite line. + * Input: three points P0, P1, and P2 + * \returns > 0.0 for P2 left of the line through P0 and P1. + * = 0.0 for P2 on the line. + * < 0.0 for P2 right of the line. + */ +static float is_left(const float p0[2], const float p1[2], const float p2[2]) +{ + return (p1[0] - p0[0]) * (p2[1] - p0[1]) - (p2[0] - p0[0]) * (p1[1] - p0[1]); +} + +static int BLI_convexhull_2d_sorted(const float (*points)[2], const int n, int r_points[]) +{ + BLI_assert(n >= 2); /* Doesn't handle trivial cases. */ + /* the output array r_points[] will be used as the stack */ + int bot = 0; + int top = -1; /* indices for bottom and top of the stack */ + int i; /* array scan index */ + int minmin, minmax; + int maxmin, maxmax; + float xmax; + + /* Get the indices of points with min x-coord and min|max y-coord */ + float xmin = points[0][0]; + for (i = 1; i < n; i++) { + if (points[i][0] != xmin) { + break; + } + } + + minmin = 0; + minmax = i - 1; + if (minmax == n - 1) { /* degenerate case: all x-coords == xmin */ + r_points[++top] = minmin; + if (points[minmax][1] != points[minmin][1]) { + /* a nontrivial segment */ + r_points[++top] = minmax; + } + BLI_assert(top + 1 <= n); + return top + 1; + } + + /* Get the indices of points with max x-coord and min|max y-coord */ + + maxmax = n - 1; + xmax = points[n - 1][0]; + for (i = n - 2; i >= 0; i--) { + if (points[i][0] != xmax) { + break; + } + } + maxmin = i + 1; + + /* Compute the lower hull on the stack r_points */ + r_points[++top] = minmin; /* push minmin point onto stack */ + i = minmax; + while (++i <= maxmin) { + /* the lower line joins points[minmin] with points[maxmin] */ + if (is_left(points[minmin], points[maxmin], points[i]) >= 0 && i < maxmin) { + continue; /* ignore points[i] above or on the lower line */ + } + + while (top > 0) { /* there are at least 2 points on the stack */ + /* test if points[i] is left of the line at the stack top */ + if (is_left(points[r_points[top - 1]], points[r_points[top]], points[i]) > 0.0f) { + break; /* points[i] is a new hull vertex */ + } + top--; /* pop top point off stack */ + } + + r_points[++top] = i; /* push points[i] onto stack */ + } + + /* Next, compute the upper hull on the stack r_points above the bottom hull */ + if (maxmax != maxmin) { /* if distinct xmax points */ + r_points[++top] = maxmax; /* push maxmax point onto stack */ + } + + bot = top; /* the bottom point of the upper hull stack */ + i = maxmin; + while (--i >= minmax) { + /* the upper line joins points[maxmax] with points[minmax] */ + if (is_left(points[maxmax], points[minmax], points[i]) >= 0 && i > minmax) { + continue; /* ignore points[i] below or on the upper line */ + } + + while (top > bot) { /* at least 2 points on the upper stack */ + /* test if points[i] is left of the line at the stack top */ + if (is_left(points[r_points[top - 1]], points[r_points[top]], points[i]) > 0.0f) { + break; /* points[i] is a new hull vertex */ + } + top--; /* pop top point off stack */ + } + + if (points[i][0] == points[r_points[0]][0] && points[i][1] == points[r_points[0]][1]) { + BLI_assert(top + 1 <= n); + return top + 1; /* special case (mgomes) */ + } + + r_points[++top] = i; /* push points[i] onto stack */ + } + + if (minmax != minmin && r_points[0] != minmin) { + r_points[++top] = minmin; /* push joining endpoint onto stack */ + } + + BLI_assert(top + 1 <= n); + return top + 1; +} + +struct PointRef { + const float *pt; /* 2d vector */ +}; + +static int pointref_cmp_yx(const void *a_, const void *b_) +{ + const struct PointRef *a = a_; + const struct PointRef *b = b_; + + if (a->pt[1] > b->pt[1]) { + return 1; + } + if (a->pt[1] < b->pt[1]) { + return -1; + } + + if (a->pt[0] > b->pt[0]) { + return 1; + } + if (a->pt[0] < b->pt[0]) { + return -1; + } + return 0; +} + +int BLI_convexhull_2d(const float (*points)[2], const int n, int r_points[]) +{ + BLI_assert(n >= 0); + if (n < 2) { + if (n == 1) { + r_points[0] = 0; + } + return n; + } + struct PointRef *points_ref = MEM_mallocN(sizeof(*points_ref) * (size_t)n, __func__); + float(*points_sort)[2] = MEM_mallocN(sizeof(*points_sort) * (size_t)n, __func__); + + for (int i = 0; i < n; i++) { + points_ref[i].pt = points[i]; + } + + /* Sort the points by X, then by Y. */ + qsort(points_ref, (size_t)n, sizeof(struct PointRef), pointref_cmp_yx); + + for (int i = 0; i < n; i++) { + memcpy(points_sort[i], points_ref[i].pt, sizeof(float[2])); + } + + int points_hull_num = BLI_convexhull_2d_sorted(points_sort, n, r_points); + + /* Map back to the unsorted index values. */ + for (int i = 0; i < points_hull_num; i++) { + r_points[i] = (int)((const float(*)[2])points_ref[r_points[i]].pt - points); + } + + MEM_freeN(points_ref); + MEM_freeN(points_sort); + + BLI_assert(points_hull_num <= n); + return points_hull_num; +} + +/** \} */ + +/* Helper functions */ + +/* -------------------------------------------------------------------- */ +/** \name Utility Convex-Hull Functions + * \{ */ + +static float BLI_convexhull_aabb_fit_hull_2d(const float (*points_hull)[2], int n) +{ + float area_best = FLT_MAX; + float dvec_best[2]; /* best angle, delay atan2 */ + + int i_prev = n - 1; + for (int i = 0; i < n; i++) { + const float *ev_a = points_hull[i]; + const float *ev_b = points_hull[i_prev]; + float dvec[2]; /* 2d rotation matrix */ + + sub_v2_v2v2(dvec, ev_a, ev_b); + if (normalize_v2(dvec) != 0.0f) { + /* rotation matrix */ + float min[2] = {FLT_MAX, FLT_MAX}, max[2] = {-FLT_MAX, -FLT_MAX}; + float area; + + for (int j = 0; j < n; j++) { + float tvec[2]; + mul_v2_v2_cw(tvec, dvec, points_hull[j]); + + min[0] = min_ff(min[0], tvec[0]); + min[1] = min_ff(min[1], tvec[1]); + + max[0] = max_ff(max[0], tvec[0]); + max[1] = max_ff(max[1], tvec[1]); + + area = (max[0] - min[0]) * (max[1] - min[1]); + if (area > area_best) { + break; + } + } + + if (area < area_best) { + area_best = area; + copy_v2_v2(dvec_best, dvec); + } + } + + i_prev = i; + } + + return (area_best != FLT_MAX) ? (float)atan2(dvec_best[0], dvec_best[1]) : 0.0f; +} + +float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], int n) +{ + BLI_assert(n >= 0); + float angle = 0.0f; + + int *index_map = MEM_mallocN(sizeof(*index_map) * (size_t)n, __func__); + + int points_hull_num = BLI_convexhull_2d(points, n, index_map); + + if (points_hull_num > 1) { + float(*points_hull)[2] = MEM_mallocN(sizeof(*points_hull) * (size_t)points_hull_num, __func__); + for (int j = 0; j < points_hull_num; j++) { + copy_v2_v2(points_hull[j], points[index_map[j]]); + } + + angle = BLI_convexhull_aabb_fit_hull_2d(points_hull, points_hull_num); + MEM_freeN(points_hull); + } + + MEM_freeN(index_map); + + return angle; +} + +/** \} */ diff --git a/source/blender/blenlib/intern/convexhull_2d.cc b/source/blender/blenlib/intern/convexhull_2d.cc deleted file mode 100644 index 13e8fe2abf7..00000000000 --- a/source/blender/blenlib/intern/convexhull_2d.cc +++ /dev/null @@ -1,444 +0,0 @@ -/* SPDX-FileCopyrightText: 2023 Blender Authors - * SPDX-FileCopyrightText: 2001 softSurfer (http://www.softsurfer.com) - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup bli - */ - -#include -#include -#include - -#include "MEM_guardedalloc.h" - -#include "BLI_bounds.hh" -#include "BLI_convexhull_2d.h" -#include "BLI_math_vector.h" -#include "BLI_utildefines.h" - -#include "BLI_strict_flags.h" /* Keep last. */ - -/** - * Assert the optimized bounds match a brute force check, - * disable by default is this is slow for dense hulls, using `O(n^2)` complexity. - */ -// #define USE_BRUTE_FORCE_ASSERT - -using namespace blender; - -/* -------------------------------------------------------------------- */ -/** \name Internal Math Functions - * \{ */ - -static float sincos_rotate_cw_x(const float2 &sincos, const float2 &p) -{ - return (sincos[0] * p[0]) + (sincos[1] * p[1]); -} - -static float sincos_rotate_cw_y(const float2 &sincos, const float2 &p) -{ - return (sincos[1] * p[0]) - (sincos[0] * p[1]); -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Main Convex-Hull Calculation - * \{ */ - -/* Copyright 2001, softSurfer (http://www.softsurfer.com) - * This code may be freely used and modified for any purpose - * providing that this copyright notice is included with it. - * SoftSurfer makes no warranty for this code, and cannot be held - * liable for any real or imagined damage resulting from its use. - * Users of this code must verify correctness for their application. - * http://softsurfer.com/Archive/algorithm_0203/algorithm_0203.htm */ - -/** - * tests if a point is Left|On|Right of an infinite line. - * Input: three points P0, P1, and P2 - * \returns > 0.0 for P2 left of the line through P0 and P1. - * = 0.0 for P2 on the line. - * < 0.0 for P2 right of the line. - */ -static float is_left(const float p0[2], const float p1[2], const float p2[2]) -{ - return (p1[0] - p0[0]) * (p2[1] - p0[1]) - (p2[0] - p0[0]) * (p1[1] - p0[1]); -} - -static int convexhull_2d_sorted(const float (*points)[2], const int points_num, int r_points[]) -{ - BLI_assert(points_num >= 2); /* Doesn't handle trivial cases. */ - /* The output array `r_points[]` will be used as the stack. */ - int bot = 0; - /* Indices for bottom and top of the stack. */ - int top = -1; - /* Array scan index. */ - int i; - - const int minmin = 0; - const int maxmax = points_num - 1; - int minmax; - int maxmin; - - float xmax; - - /* Get the indices of points with min X-coord and min|max Y-coord. */ - float xmin = points[0][0]; - for (i = 1; i <= maxmax; i++) { - if (points[i][0] != xmin) { - break; - } - } - - minmax = i - 1; - if (minmax == maxmax) { /* Degenerate case: all x-coords == X-min. */ - r_points[++top] = minmin; - if (points[minmax][1] != points[minmin][1]) { - /* A nontrivial segment. */ - r_points[++top] = minmax; - } - BLI_assert(top + 1 <= points_num); - return top + 1; - } - - /* Get the indices of points with max X-coord and min|max Y-coord. */ - - xmax = points[maxmax][0]; - for (i = maxmax - 1; i >= 0; i--) { - if (points[i][0] != xmax) { - break; - } - } - maxmin = i + 1; - - /* Compute the lower hull on the stack `r_points`. */ - r_points[++top] = minmin; /* Push `minmin` point onto stack. */ - i = minmax; - while (++i <= maxmin) { - /* The lower line joins `points[minmin]` with `points[maxmin]`. */ - if (is_left(points[minmin], points[maxmin], points[i]) >= 0 && i < maxmin) { - continue; /* Ignore `points[i]` above or on the lower line. */ - } - - while (top > 0) { /* There are at least 2 points on the stack. */ - /* Test if `points[i]` is left of the line at the stack top. */ - if (is_left(points[r_points[top - 1]], points[r_points[top]], points[i]) > 0.0f) { - break; /* `points[i]` is a new hull vertex. */ - } - top--; /* Pop top point off stack. */ - } - - r_points[++top] = i; /* Push `points[i]` onto stack. */ - } - - /* Next, compute the upper hull on the stack `r_points` above the bottom hull. */ - if (maxmax != maxmin) { /* If distinct `xmax` points. */ - r_points[++top] = maxmax; /* Push `maxmax` point onto stack. */ - } - - bot = top; /* the bottom point of the upper hull stack */ - i = maxmin; - while (--i >= minmax) { - /* The upper line joins `points[maxmax]` with `points[minmax]`. */ - if (is_left(points[maxmax], points[minmax], points[i]) >= 0 && i > minmax) { - continue; /* Ignore points[i] below or on the upper line. */ - } - - while (top > bot) { /* At least 2 points on the upper stack. */ - /* Test if `points[i]` is left of the line at the stack top. */ - if (is_left(points[r_points[top - 1]], points[r_points[top]], points[i]) > 0.0f) { - break; /* points[i] is a new hull vertex. */ - } - top--; /* Pop top point off stack. */ - } - - if (points[i][0] == points[r_points[0]][0] && points[i][1] == points[r_points[0]][1]) { - BLI_assert(top + 1 <= points_num); - return top + 1; /* Special case (mgomes). */ - } - - r_points[++top] = i; /* Push points[i] onto stack. */ - } - - if (minmax != minmin && r_points[0] != minmin) { - r_points[++top] = minmin; /* Push joining endpoint onto stack. */ - } - - BLI_assert(top + 1 <= points_num); - return top + 1; -} - -int BLI_convexhull_2d(const float (*points)[2], const int points_num, int r_points[]) -{ - BLI_assert(points_num >= 0); - if (points_num < 2) { - if (points_num == 1) { - r_points[0] = 0; - } - return points_num; - } - int *points_map = static_cast(MEM_mallocN(sizeof(int) * size_t(points_num), __func__)); - float(*points_sort)[2] = static_cast( - MEM_mallocN(sizeof(*points_sort) * size_t(points_num), __func__)); - - for (int i = 0; i < points_num; i++) { - points_map[i] = i; - } - - /* Sort the points by X, then by Y. */ - std::sort(points_map, points_map + points_num, [points](const int &a_index, const int &b_index) { - const float *a = points[a_index]; - const float *b = points[b_index]; - if (a[1] > b[1]) { - return false; - } - if (a[1] < b[1]) { - return true; - } - - if (a[0] > b[0]) { - return false; - } - if (a[0] < b[0]) { - return true; - } - return false; - }); - - for (int i = 0; i < points_num; i++) { - copy_v2_v2(points_sort[i], points[points_map[i]]); - } - - int points_hull_num = convexhull_2d_sorted(points_sort, points_num, r_points); - - /* Map back to the unsorted index values. */ - for (int i = 0; i < points_hull_num; i++) { - r_points[i] = points_map[r_points[i]]; - } - - MEM_freeN(points_map); - MEM_freeN(points_sort); - - BLI_assert(points_hull_num <= points_num); - return points_hull_num; -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Comupte AABB Fitting Angle (For Assertion) - * \{ */ - -static float convexhull_aabb_fit_hull_2d_brute_force(const float (*points_hull)[2], - int points_hull_num) -{ - float area_best = FLT_MAX; - float2 sincos_best = {0.0f, 1.0f}; /* Track the best angle as a unit vector, delaying `atan2`. */ - - for (int i = 0, i_prev = points_hull_num - 1; i < points_hull_num; i_prev = i++) { - /* 2D rotation matrix. */ - float dvec_length = 0.0f; - const float2 sincos = math::normalize_and_get_length( - float2(points_hull[i]) - float2(points_hull[i_prev]), dvec_length); - if (UNLIKELY(dvec_length == 0.0f)) { - continue; - } - - blender::Bounds bounds[2] = {{FLT_MAX, -FLT_MAX}, {FLT_MAX, -FLT_MAX}}; - float area_test; - - for (int j = 0; j < points_hull_num; j++) { - const float2 tvec = { - sincos_rotate_cw_x(sincos, points_hull[j]), - sincos_rotate_cw_y(sincos, points_hull[j]), - }; - - bounds[0].min = math::min(bounds[0].min, tvec[0]); - bounds[0].max = math::max(bounds[0].max, tvec[0]); - bounds[1].min = math::min(bounds[1].min, tvec[1]); - bounds[1].max = math::max(bounds[1].max, tvec[1]); - - area_test = (bounds[0].max - bounds[0].min) * (bounds[1].max - bounds[1].min); - if (area_test > area_best) { - break; - } - } - - if (area_test < area_best) { - area_best = area_test; - sincos_best = sincos; - } - } - - return (area_best != FLT_MAX) ? float(atan2(sincos_best[0], sincos_best[1])) : 0.0f; -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Comupte AABB Fitting Angle (Optimized) - * \{ */ - -/** - * When using the rotating calipers, step one half of the caliper to a new index. - * - * Note that this relies on `points_hull` being ordered CCW which #BLI_convexhull_2d ensures. - */ -template -static float convexhull_2d_compute_extent_on_axis(const float (*points_hull)[2], - const int points_hull_num, - const float2 &sincos, - int *index_p) -{ - /* NOTE(@ideasman42): This could be optimized to use a search strategy - * that computes the upper bounds and narrows down the result instead of - * simply checking every point until the new maximum is reached. - * From looking into I couldn't find cases where doing this has significant benefits, - * especially when compared with the complexity of using more involved logic for - * the common case, where only a few steps are needed. - * Typically the number of points to scan is small (around [0..8]). - * And while a high-detail hull with single outliner points will cause stepping over - * many more points, in practice there are rarely more than a few of these in a convex-hull. - * Nevertheless, a high-poly hull that has subtle curves containing many points as well as - * some sharp-corners wont perform as well with this method. */ - - const int index_init = *index_p; - int index_best = index_init; - float value_init = (Axis == 0) ? sincos_rotate_cw_x(sincos, points_hull[index_best]) : - sincos_rotate_cw_y(sincos, points_hull[index_best]); - float value_best = value_init; - /* Simply scan up the array. */ - for (int count = 1; count < points_hull_num; count++) { - const int index_test = (index_init + count) % points_hull_num; - const float value_test = (Axis == 0) ? sincos_rotate_cw_x(sincos, points_hull[index_test]) : - sincos_rotate_cw_y(sincos, points_hull[index_test]); - if ((AxisSign == -1) ? (value_test > value_best) : (value_test < value_best)) { - break; - } - value_best = value_test; - index_best = index_test; - } - - *index_p = index_best; - return value_best; -} - -static float convexhull_aabb_fit_hull_2d(const float (*points_hull)[2], int points_hull_num) -{ - float area_best = FLT_MAX; - float2 sincos_best; /* Track the best angle as a unit vector, delaying `atan2`. */ - bool is_first = true; - - /* Initialize to zero because the first pass uses the first index to set the bounds. */ - blender::Bounds bounds_index[2] = {{0, 0}, {0, 0}}; - - for (int i = 0, i_prev = points_hull_num - 1; i < points_hull_num; i_prev = i++) { - /* 2D rotation matrix. */ - float dvec_length = 0.0f; - const float2 sincos = math::normalize_and_get_length( - float2(points_hull[i]) - float2(points_hull[i_prev]), dvec_length); - if (UNLIKELY(dvec_length == 0.0f)) { - continue; - } - - if (UNLIKELY(is_first)) { - is_first = false; - - blender::Bounds bounds[2]; - - bounds[0].min = bounds[0].max = sincos_rotate_cw_x(sincos, points_hull[0]); - bounds[1].min = bounds[1].max = sincos_rotate_cw_y(sincos, points_hull[0]); - - bounds_index[0].min = bounds_index[0].max = 0; - bounds_index[1].min = bounds_index[1].max = 0; - - for (int j = 1; j < points_hull_num; j++) { - const float2 tvec = { - sincos_rotate_cw_x(sincos, points_hull[j]), - sincos_rotate_cw_y(sincos, points_hull[j]), - }; - for (int axis = 0; axis < 2; axis++) { - if (tvec[axis] < bounds[axis].min) { - bounds[axis].min = tvec[axis]; - bounds_index[axis].min = j; - } - if (tvec[axis] > bounds[axis].max) { - bounds[axis].max = tvec[axis]; - bounds_index[axis].max = j; - } - } - } - - area_best = (bounds[0].max - bounds[0].min) * (bounds[1].max - bounds[1].min); - sincos_best = sincos; - continue; - } - - /* Step the calipers to the new rotation `sincos`, returning the bounds at the same time. */ - blender::Bounds bounds_test[2] = { - {convexhull_2d_compute_extent_on_axis<0, -1>( - points_hull, points_hull_num, sincos, &bounds_index[0].min), - convexhull_2d_compute_extent_on_axis<0, 1>( - points_hull, points_hull_num, sincos, &bounds_index[0].max)}, - {convexhull_2d_compute_extent_on_axis<1, -1>( - points_hull, points_hull_num, sincos, &bounds_index[1].min), - convexhull_2d_compute_extent_on_axis<1, 1>( - points_hull, points_hull_num, sincos, &bounds_index[1].max)}, - - }; - - const float area_test = (bounds_test[0].max - bounds_test[0].min) * - (bounds_test[1].max - bounds_test[1].min); - - if (area_test < area_best) { - area_best = area_test; - sincos_best = sincos; - } - } - - const float angle = (area_best != FLT_MAX) ? float(atan2(sincos_best[0], sincos_best[1])) : 0.0f; - -#ifdef USE_BRUTE_FORCE_ASSERT - if (true) -#else - if (false) -#endif - { - /* Ensure the optimized result matches the brute-force version. */ - const float angle_test = convexhull_aabb_fit_hull_2d_brute_force(points_hull, points_hull_num); - BLI_assert(angle == angle_test); - } - - return angle; -} - -float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], int points_num) -{ - BLI_assert(points_num >= 0); - float angle = 0.0f; - - int *index_map = static_cast( - MEM_mallocN(sizeof(*index_map) * size_t(points_num), __func__)); - - int points_hull_num = BLI_convexhull_2d(points, points_num, index_map); - - if (points_hull_num > 1) { - float(*points_hull)[2] = static_cast( - MEM_mallocN(sizeof(*points_hull) * size_t(points_hull_num), __func__)); - for (int j = 0; j < points_hull_num; j++) { - copy_v2_v2(points_hull[j], points[index_map[j]]); - } - - angle = convexhull_aabb_fit_hull_2d(points_hull, points_hull_num); - MEM_freeN(points_hull); - } - - MEM_freeN(index_map); - - return angle; -} - -/** \} */ diff --git a/source/blender/blenlib/intern/delaunay_2d.cc b/source/blender/blenlib/intern/delaunay_2d.cc index 2282db8cc49..4681e5c86e9 100644 --- a/source/blender/blenlib/intern/delaunay_2d.cc +++ b/source/blender/blenlib/intern/delaunay_2d.cc @@ -1836,7 +1836,9 @@ void get_next_crossing_from_edge(CrossData *cd, } } -template void dump_crossings(const Span> crossings) +constexpr int inline_crossings_size = 128; +template +void dump_crossings(const Vector, inline_crossings_size> &crossings) { std::cout << "CROSSINGS\n"; for (int i = 0; i < crossings.size(); ++i) { @@ -1915,7 +1917,7 @@ void add_edge_constraint( * one hop. Saves a bunch of orient2d tests in that common case. */ int visit = ++cdt_state->visit_count; - Vector, 128> crossings; + Vector, inline_crossings_size> crossings; crossings.append(CrossData(T(0), v1, nullptr, nullptr)); int n; while (!((n = crossings.size()) > 0 && crossings[n - 1].vert == v2)) { @@ -1947,7 +1949,7 @@ void add_edge_constraint( } if (dbg_level > 0) { - dump_crossings(crossings); + dump_crossings(crossings); } /* diff --git a/source/blender/blenlib/intern/easing.c b/source/blender/blenlib/intern/easing.c index aa4c0f8a501..6824da2cf8c 100644 --- a/source/blender/blenlib/intern/easing.c +++ b/source/blender/blenlib/intern/easing.c @@ -10,7 +10,7 @@ #include "BLI_easing.h" /* own include */ -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* blend if (amplitude < fabsf(change) */ #define USE_ELASTIC_BLEND diff --git a/source/blender/blenlib/intern/filereader_zstd.c b/source/blender/blenlib/intern/filereader_zstd.c index 0c14ad2b9de..45ef6dcea43 100644 --- a/source/blender/blenlib/intern/filereader_zstd.c +++ b/source/blender/blenlib/intern/filereader_zstd.c @@ -9,6 +9,8 @@ #include #include +#include "BLI_blenlib.h" +#include "BLI_endian_switch.h" #include "BLI_filereader.h" #include "BLI_math_base.h" diff --git a/source/blender/blenlib/intern/generic_virtual_array.cc b/source/blender/blenlib/intern/generic_virtual_array.cc index 64d4f52a3ed..e0812456da0 100644 --- a/source/blender/blenlib/intern/generic_virtual_array.cc +++ b/source/blender/blenlib/intern/generic_virtual_array.cc @@ -265,33 +265,21 @@ template class GVArrayImpl_For_SmallTrivialSingleValue : public } private: - void get(const int64_t index, void *r_value) const final + void get(const int64_t /*index*/, void *r_value) const override { - this->get_to_uninitialized(index, r_value); + this->copy_value_to(r_value); } - void get_to_uninitialized(const int64_t /*index*/, void *r_value) const final + void get_to_uninitialized(const int64_t /*index*/, void *r_value) const override { - memcpy(r_value, &buffer_, type_->size()); + this->copy_value_to(r_value); } - void materialize(const IndexMask &mask, void *dst) const final + void copy_value_to(void *dst) const { - this->materialize_to_uninitialized(mask, dst); - } - void materialize_to_uninitialized(const IndexMask &mask, void *dst) const final - { - type_->fill_construct_indices(buffer_, dst, mask); - } - void materialize_compressed(const IndexMask &mask, void *dst) const final - { - this->materialize_compressed_to_uninitialized(mask, dst); - } - void materialize_compressed_to_uninitialized(const IndexMask &mask, void *dst) const final - { - type_->fill_construct_n(buffer_, dst, mask.size()); + memcpy(dst, &buffer_, type_->size()); } - CommonVArrayInfo common_info() const final + CommonVArrayInfo common_info() const override { return CommonVArrayInfo{CommonVArrayInfo::Type::Single, true, &buffer_}; } @@ -511,29 +499,15 @@ class GVArrayImpl_For_SlicedGVArray : public GVArrayImpl { return {}; } - void materialize(const IndexMask &mask, void *dst) const final - { - IndexMaskMemory memory; - const IndexMask shifted_mask = mask.shift(offset_, memory); - varray_.materialize(shifted_mask, dst); - } - void materialize_to_uninitialized(const IndexMask &mask, void *dst) const final - { - IndexMaskMemory memory; - const IndexMask shifted_mask = mask.shift(offset_, memory); - varray_.materialize_to_uninitialized(shifted_mask, dst); - } - void materialize_compressed(const IndexMask &mask, void *dst) const final - { - IndexMaskMemory memory; - const IndexMask shifted_mask = mask.shift(offset_, memory); - varray_.materialize_compressed(shifted_mask, dst); - } void materialize_compressed_to_uninitialized(const IndexMask &mask, void *dst) const override { - IndexMaskMemory memory; - const IndexMask shifted_mask = mask.shift(offset_, memory); - varray_.materialize_compressed_to_uninitialized(shifted_mask, dst); + IndexMaskFromSegment mask_from_segment; + mask.foreach_segment([&](const IndexMaskSegment segment, const int64_t start) { + const IndexMask &segment_mask = mask_from_segment.update( + {segment.offset() + offset_, segment.base_span()}); + varray_.materialize_compressed_to_uninitialized(segment_mask, + POINTER_OFFSET(dst, type_->size() * start)); + }); } }; diff --git a/source/blender/blenlib/intern/gsqueue.c b/source/blender/blenlib/intern/gsqueue.c index c53a07d60e2..55cfbd65655 100644 --- a/source/blender/blenlib/intern/gsqueue.c +++ b/source/blender/blenlib/intern/gsqueue.c @@ -14,10 +14,9 @@ #include "MEM_guardedalloc.h" #include "BLI_gsqueue.h" +#include "BLI_strict_flags.h" #include "BLI_utildefines.h" -#include "BLI_strict_flags.h" /* Keep last. */ - /* target chunk size: 64kb */ #define CHUNK_SIZE_DEFAULT (1 << 16) /* ensure we get at least this many elems per chunk */ diff --git a/source/blender/blenlib/intern/hash_md5.cc b/source/blender/blenlib/intern/hash_md5.cc index ed1e105420e..0388cfdd6a9 100644 --- a/source/blender/blenlib/intern/hash_md5.cc +++ b/source/blender/blenlib/intern/hash_md5.cc @@ -10,9 +10,9 @@ * according to the definition of MD5 in RFC 1321 from April 1992. */ -#include -#include -#include +#include +#include +#include #include #include "BLI_hash_md5.hh" /* own include */ @@ -78,7 +78,7 @@ struct md5_ctx { /* This array contains the bytes used to pad the buffer to the next 64-byte boundary. * (RFC 1321, 3.1: Step 1) */ -static const uchar fillbuf[64] = {0x80, 0 /* , 0, 0, ... */}; +static const unsigned char fillbuf[64] = {0x80, 0 /* , 0, 0, ... */}; /** * Initialize structure containing state of computation. @@ -383,12 +383,12 @@ void *BLI_hash_md5_buffer(const char *buffer, size_t len, void *resblock) char *BLI_hash_md5_to_hexdigest(const void *resblock, char r_hex_digest[33]) { static const char hex_map[17] = "0123456789abcdef"; - const uchar *p; + const unsigned char *p; char *q; short len; - for (q = r_hex_digest, p = (const uchar *)resblock, len = 0; len < 16; p++, len++) { - const uchar c = *p; + for (q = r_hex_digest, p = (const unsigned char *)resblock, len = 0; len < 16; p++, len++) { + const unsigned char c = *p; *q++ = hex_map[c >> 4]; *q++ = hex_map[c & 15]; } diff --git a/source/blender/blenlib/intern/hash_mm2a.cc b/source/blender/blenlib/intern/hash_mm2a.cc index f8a26aad932..9af4b60c690 100644 --- a/source/blender/blenlib/intern/hash_mm2a.cc +++ b/source/blender/blenlib/intern/hash_mm2a.cc @@ -45,7 +45,7 @@ static void mm2a_mix_tail(BLI_HashMurmur2A *mm2, const uchar **data, size_t *len) { while (*len && ((*len < 4) || mm2->count)) { - mm2->tail |= uint32_t(**data) << (mm2->count * 8); + mm2->tail |= (uint32_t)(**data) << (mm2->count * 8); mm2->count++; (*len)--; @@ -69,7 +69,7 @@ void BLI_hash_mm2a_init(BLI_HashMurmur2A *mm2, uint32_t seed) void BLI_hash_mm2a_add(BLI_HashMurmur2A *mm2, const uchar *data, size_t len) { - mm2->size += uint32_t(len); + mm2->size += (uint32_t)len; mm2a_mix_tail(mm2, &data, &len); diff --git a/source/blender/blenlib/intern/index_mask.cc b/source/blender/blenlib/intern/index_mask.cc index 2f7ce7a6671..979676e77e5 100644 --- a/source/blender/blenlib/intern/index_mask.cc +++ b/source/blender/blenlib/intern/index_mask.cc @@ -2,7 +2,6 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include #include #include @@ -13,12 +12,12 @@ #include "BLI_math_base.hh" #include "BLI_set.hh" #include "BLI_sort.hh" +#include "BLI_strict_flags.h" #include "BLI_task.hh" #include "BLI_threads.h" +#include "BLI_timeit.hh" #include "BLI_virtual_array.hh" -#include "BLI_strict_flags.h" /* Keep last. */ - namespace blender::index_mask { template void build_reverse_map(const IndexMask &mask, MutableSpan r_map) @@ -95,18 +94,23 @@ std::ostream &operator<<(std::ostream &stream, const IndexMask &mask) mask.to_indices(indices); Vector>> segments; unique_sorted_indices::split_to_ranges_and_spans(indices, 8, segments); - Vector parts; + std::cout << "(Size: " << mask.size() << " | "; for (const std::variant> &segment : segments) { if (std::holds_alternative(segment)) { const IndexRange range = std::get(segment); - parts.append(fmt::format("{}-{}", range.first(), range.last())); + std::cout << range; } else { const Span segment_indices = std::get>(segment); - parts.append(fmt::format("{}", fmt::join(segment_indices, ", "))); + std::cout << "["; + for (const int64_t index : segment_indices) { + std::cout << index << ","; + } + std::cout << "]"; } + std::cout << ", "; } - stream << fmt::format("(Size: {} | {})", mask.size(), fmt::join(parts, ", ")); + std::cout << ")"; return stream; } @@ -169,17 +173,17 @@ IndexMask IndexMask::slice_content(const int64_t start, const int64_t size) cons return this->slice(*first_it, *last_it, sliced_mask_size); } -IndexMask IndexMask::slice_and_shift(const IndexRange range, - const int64_t offset, - IndexMaskMemory &memory) const +IndexMask IndexMask::slice_and_offset(const IndexRange range, + const int64_t offset, + IndexMaskMemory &memory) const { - return this->slice_and_shift(range.start(), range.size(), offset, memory); + return this->slice_and_offset(range.start(), range.size(), offset, memory); } -IndexMask IndexMask::slice_and_shift(const int64_t start, - const int64_t size, - const int64_t offset, - IndexMaskMemory &memory) const +IndexMask IndexMask::slice_and_offset(const int64_t start, + const int64_t size, + const int64_t offset, + IndexMaskMemory &memory) const { if (size == 0) { return {}; @@ -187,28 +191,20 @@ IndexMask IndexMask::slice_and_shift(const int64_t start, if (std::optional range = this->to_range()) { return range->slice(start, size).shift(offset); } - return this->slice(start, size).shift(offset, memory); -} - -IndexMask IndexMask::shift(const int64_t offset, IndexMaskMemory &memory) const -{ - if (indices_num_ == 0) { - return {}; - } - BLI_assert(this->first() + offset >= 0); + IndexMask sliced_mask = this->slice(start, size); if (offset == 0) { - return *this; + return sliced_mask; } - if (std::optional range = this->to_range()) { + if (std::optional range = sliced_mask.to_range()) { return range->shift(offset); } - IndexMask shifted_mask = *this; - MutableSpan new_segment_offsets = memory.allocate_array(segments_num_); - for (const int64_t i : IndexRange(segments_num_)) { - new_segment_offsets[i] = segment_offsets_[i] + offset; + MutableSpan new_segment_offsets = memory.allocate_array( + sliced_mask.segments_num_); + for (const int64_t i : new_segment_offsets.index_range()) { + new_segment_offsets[i] = sliced_mask.segment_offsets_[i] + offset; } - shifted_mask.segment_offsets_ = new_segment_offsets.data(); - return shifted_mask; + sliced_mask.segment_offsets_ = new_segment_offsets.data(); + return sliced_mask; } /** @@ -867,245 +863,6 @@ bool IndexMask::contains(const int64_t query_index) const return this->find(query_index).has_value(); } -static Array build_every_nth_index_array(const int64_t n) -{ - Array data(max_segment_size / n); - for (const int64_t i : data.index_range()) { - const int64_t index = i * n; - BLI_assert(index < max_segment_size); - data[i] = int16_t(index); - } - return data; -} - -/** - * Returns a span containing every nth index. This is optimized for a few special values of n - * which are cached. The returned indices have either static life-time, or they are freed when the - * given memory is feed. - */ -static Span get_every_nth_index(const int64_t n, - const int64_t repetitions, - IndexMaskMemory &memory) -{ - BLI_assert(n >= 2); - BLI_assert(n * repetitions <= max_segment_size); - - switch (n) { - case 2: { - static auto data = build_every_nth_index_array(2); - return data.as_span().take_front(repetitions); - } - case 3: { - static auto data = build_every_nth_index_array(3); - return data.as_span().take_front(repetitions); - } - case 4: { - static auto data = build_every_nth_index_array(4); - return data.as_span().take_front(repetitions); - } - default: { - MutableSpan data = memory.allocate_array(repetitions); - for (const int64_t i : IndexRange(repetitions)) { - const int64_t index = i * n; - BLI_assert(index < max_segment_size); - data[i] = int16_t(index); - } - return data; - } - } -} - -IndexMask IndexMask::from_repeating(const IndexMask &mask_to_repeat, - const int64_t repetitions, - const int64_t stride, - const int64_t initial_offset, - IndexMaskMemory &memory) -{ - if (mask_to_repeat.is_empty()) { - return {}; - } - BLI_assert(mask_to_repeat.last() < stride); - if (repetitions == 0) { - return {}; - } - if (repetitions == 1 && initial_offset == 0) { - /* The output is the same as the input mask. */ - return mask_to_repeat; - } - const std::optional range_to_repeat = mask_to_repeat.to_range(); - if (range_to_repeat && range_to_repeat->first() == 0 && range_to_repeat->size() == stride) { - /* The output is a range. */ - return IndexRange(initial_offset, repetitions * stride); - } - const int64_t segments_num = mask_to_repeat.segments_num(); - const IndexRange bounds = mask_to_repeat.bounds(); - - /* Avoid having many very small segments by creating a single segment that contains the input - * multiple times already. This way, a lower total number of segments is necessary. */ - if (segments_num == 1 && stride <= max_segment_size / 2 && mask_to_repeat.size() <= 256) { - const IndexMaskSegment src_segment = mask_to_repeat.segment(0); - /* Number of repetitions that fit into a single segment. */ - const int64_t inline_repetitions_num = std::min(repetitions, max_segment_size / stride); - Span repeated_indices; - if (src_segment.size() == 1) { - /* Optimize the case when a single index is repeated. */ - repeated_indices = get_every_nth_index(stride, inline_repetitions_num, memory); - } - else { - /* More general case that repeats multiple indices. */ - MutableSpan repeated_indices_mut = memory.allocate_array( - inline_repetitions_num * src_segment.size()); - for (const int64_t repetition : IndexRange(inline_repetitions_num)) { - for (const int64_t i : src_segment.index_range()) { - const int64_t index = src_segment[i] - src_segment[0] + repetition * stride; - BLI_assert(index < max_segment_size); - repeated_indices_mut[repetition * src_segment.size() + i] = int16_t(index); - } - } - repeated_indices = repeated_indices_mut; - } - BLI_assert(repeated_indices[0] == 0); - - Vector repeated_segments; - const int64_t result_segments_num = ceil_division(repetitions, inline_repetitions_num); - for (const int64_t i : IndexRange(result_segments_num)) { - const int64_t used_repetitions = std::min(inline_repetitions_num, - repetitions - i * inline_repetitions_num); - repeated_segments.append( - IndexMaskSegment(initial_offset + bounds.first() + i * stride * inline_repetitions_num, - repeated_indices.take_front(used_repetitions * src_segment.size()))); - } - return IndexMask::from_segments(repeated_segments, memory); - } - - /* Simply repeat and offset the existing segments in the input mask. */ - Vector repeated_segments; - for (const int64_t repetition : IndexRange(repetitions)) { - for (const int64_t segment_i : IndexRange(segments_num)) { - const IndexMaskSegment segment = mask_to_repeat.segment(segment_i); - repeated_segments.append(IndexMaskSegment( - segment.offset() + repetition * stride + initial_offset, segment.base_span())); - } - } - return IndexMask::from_segments(repeated_segments, memory); -} - -IndexMask IndexMask::from_every_nth(const int64_t n, - const int64_t indices_num, - const int64_t initial_offset, - IndexMaskMemory &memory) -{ - BLI_assert(n >= 1); - return IndexMask::from_repeating(IndexRange(1), indices_num, n, initial_offset, memory); -} - -void IndexMask::foreach_segment_zipped(const Span masks, - const FunctionRef segments)> fn) -{ - BLI_assert(!masks.is_empty()); - BLI_assert(std::all_of(masks.begin() + 1, masks.end(), [&](const IndexMask &maks) { - return masks[0].size() == maks.size(); - })); - - Array segment_iter(masks.size(), 0); - Array start_iter(masks.size(), 0); - - Array segments(masks.size()); - Array sequences(masks.size()); - - /* This function only take positions of indices in to account. - * Masks with the same size is fragmented in positions space. - * So, all last segments (index in mask does not matter) of all masks will be ended in the same - * position. All segment iterators will be out of range at the same time. */ - while (segment_iter[0] != masks[0].segments_num()) { - for (const int64_t mask_i : masks.index_range()) { - if (start_iter[mask_i] == 0) { - segments[mask_i] = masks[mask_i].segment(segment_iter[mask_i]); - } - } - - int16_t next_common_sequence_size = std::numeric_limits::max(); - for (const int64_t mask_i : masks.index_range()) { - next_common_sequence_size = math::min(next_common_sequence_size, - int16_t(segments[mask_i].size() - start_iter[mask_i])); - } - - for (const int64_t mask_i : masks.index_range()) { - sequences[mask_i] = segments[mask_i].slice(start_iter[mask_i], next_common_sequence_size); - } - - if (!fn(sequences)) { - break; - } - - for (const int64_t mask_i : masks.index_range()) { - if (segments[mask_i].size() - start_iter[mask_i] == next_common_sequence_size) { - segment_iter[mask_i]++; - start_iter[mask_i] = 0; - } - else { - start_iter[mask_i] += next_common_sequence_size; - } - } - } -} - -static bool segments_is_equal(const IndexMaskSegment &a, const IndexMaskSegment &b) -{ - if (a.size() != b.size()) { - return false; - } - if (a.is_empty()) { - /* Both segments are empty. */ - return true; - } - if (a[0] != b[0]) { - return false; - } - - const bool a_is_range = unique_sorted_indices::non_empty_is_range(a.base_span()); - const bool b_is_range = unique_sorted_indices::non_empty_is_range(b.base_span()); - if (a_is_range || b_is_range) { - return a_is_range && b_is_range; - } - - const Span a_indices = a.base_span(); - [[maybe_unused]] const Span b_indices = b.base_span(); - - const int64_t offset_difference = int16_t(b.offset() - a.offset()); - - BLI_assert(a_indices[0] >= 0 && b_indices[0] >= 0); - BLI_assert(b_indices[0] == a_indices[0] - offset_difference); - - return std::equal(a_indices.begin(), - a_indices.end(), - b.base_span().begin(), - [offset_difference](const int16_t a_index, const int16_t b_index) -> bool { - return a_index - offset_difference == b_index; - }); -} - -bool operator==(const IndexMask &a, const IndexMask &b) -{ - if (a.size() != b.size()) { - return false; - } - - const std::optional a_as_range = a.to_range(); - const std::optional b_as_range = b.to_range(); - if (a_as_range.has_value() || b_as_range.has_value()) { - return a_as_range == b_as_range; - } - - bool equals = true; - IndexMask::foreach_segment_zipped({a, b}, [&](const Span segments) { - equals &= segments_is_equal(segments[0], segments[1]); - return equals; - }); - - return equals; -} - template IndexMask IndexMask::from_indices(Span, IndexMaskMemory &); template IndexMask IndexMask::from_indices(Span, IndexMaskMemory &); template void IndexMask::to_indices(MutableSpan) const; diff --git a/source/blender/blenlib/intern/jitter_2d.c b/source/blender/blenlib/intern/jitter_2d.c index 39007c57874..afd1caa7352 100644 --- a/source/blender/blenlib/intern/jitter_2d.c +++ b/source/blender/blenlib/intern/jitter_2d.c @@ -14,7 +14,7 @@ #include "BLI_jitter_2d.h" #include "BLI_rand.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" void BLI_jitterate1(float (*jit1)[2], float (*jit2)[2], int num, float radius1) { diff --git a/source/blender/blenlib/intern/kdtree_impl.h b/source/blender/blenlib/intern/kdtree_impl.h index 4324f4009b1..6e24ce0be7f 100644 --- a/source/blender/blenlib/intern/kdtree_impl.h +++ b/source/blender/blenlib/intern/kdtree_impl.h @@ -10,12 +10,11 @@ #include "BLI_kdtree_impl.h" #include "BLI_math_base.h" +#include "BLI_strict_flags.h" #include "BLI_utildefines.h" #include -#include "BLI_strict_flags.h" /* Keep last. */ - #define _BLI_KDTREE_CONCAT_AUX(MACRO_ARG1, MACRO_ARG2) MACRO_ARG1##MACRO_ARG2 #define _BLI_KDTREE_CONCAT(MACRO_ARG1, MACRO_ARG2) _BLI_KDTREE_CONCAT_AUX(MACRO_ARG1, MACRO_ARG2) #define BLI_kdtree_nd_(id) _BLI_KDTREE_CONCAT(KDTREE_PREFIX_ID, _##id) diff --git a/source/blender/blenlib/intern/lasso_2d.c b/source/blender/blenlib/intern/lasso_2d.c index a11008f9b96..8a20dbe2c25 100644 --- a/source/blender/blenlib/intern/lasso_2d.c +++ b/source/blender/blenlib/intern/lasso_2d.c @@ -10,11 +10,10 @@ #include "BLI_math_base.h" #include "BLI_math_geom.h" +#include "BLI_strict_flags.h" #include "BLI_lasso_2d.h" /* own include */ -#include "BLI_strict_flags.h" /* Keep last. */ - void BLI_lasso_boundbox(rcti *rect, const int mcoords[][2], const uint mcoords_len) { uint a; diff --git a/source/blender/blenlib/intern/listbase.cc b/source/blender/blenlib/intern/listbase.cc index dac2206ea7f..2919785db6c 100644 --- a/source/blender/blenlib/intern/listbase.cc +++ b/source/blender/blenlib/intern/listbase.cc @@ -19,7 +19,7 @@ #include "BLI_listbase.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" void BLI_movelisttolist(ListBase *dst, ListBase *src) { diff --git a/source/blender/blenlib/intern/math_base.c b/source/blender/blenlib/intern/math_base.c index 73a609d1311..f9a54c2cb80 100644 --- a/source/blender/blenlib/intern/math_base.c +++ b/source/blender/blenlib/intern/math_base.c @@ -7,8 +7,7 @@ */ #include "BLI_math_base.h" - -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" int pow_i(int base, int exp) { diff --git a/source/blender/blenlib/intern/math_boolean.cc b/source/blender/blenlib/intern/math_boolean.cc index 2deff8dc909..be94df8146e 100644 --- a/source/blender/blenlib/intern/math_boolean.cc +++ b/source/blender/blenlib/intern/math_boolean.cc @@ -6,6 +6,7 @@ * \ingroup bli */ +#include "BLI_hash.hh" #include "BLI_math_boolean.hh" #include "BLI_math_mpq.hh" #include "BLI_math_vector_types.hh" diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 9298561ec74..2a1660a9366 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -9,7 +9,7 @@ #include "BLI_math_color.h" #include "BLI_utildefines.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" void hsv_to_rgb(float h, float s, float v, float *r_r, float *r_g, float *r_b) { diff --git a/source/blender/blenlib/intern/math_geom.cc b/source/blender/blenlib/intern/math_geom.cc index 5cc13a0589d..b0da1aad36d 100644 --- a/source/blender/blenlib/intern/math_geom.cc +++ b/source/blender/blenlib/intern/math_geom.cc @@ -11,13 +11,14 @@ #include "BLI_math_base.hh" #include "BLI_math_geom.h" +#include "BLI_math_base_safe.h" #include "BLI_math_bits.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /********************************** Polygons *********************************/ diff --git a/source/blender/blenlib/intern/math_interp.cc b/source/blender/blenlib/intern/math_interp.cc index 90f7347551e..f31b78faa04 100644 --- a/source/blender/blenlib/intern/math_interp.cc +++ b/source/blender/blenlib/intern/math_interp.cc @@ -15,8 +15,7 @@ #include "BLI_math_vector.h" #include "BLI_math_vector_types.hh" #include "BLI_simd.h" - -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" namespace blender::math { diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 53ec86dff97..6ccecfa52a1 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -11,6 +11,7 @@ #include "BLI_math_solvers.h" #include "BLI_math_vector.h" #include "BLI_simd.h" +#include "BLI_strict_flags.h" #ifndef MATH_STANDALONE # include "eigen_capi.h" @@ -18,8 +19,6 @@ #include -#include "BLI_strict_flags.h" /* Keep last. */ - /********************************* Init **************************************/ void zero_m2(float m[2][2]) diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index d3d47dd847a..796554506cd 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -12,8 +12,7 @@ #include "BLI_math_geom.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" - -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /******************************** Quaternions ********************************/ @@ -1034,7 +1033,7 @@ void sin_cos_from_fraction(int numerator, int denominator, float *r_sin, float * BLI_assert(-denominator / 4 <= numerator); /* Numerator may be negative. */ BLI_assert(numerator <= denominator / 4); - BLI_assert(ELEM(cos_sign, -1.0f, 1.0f)); + BLI_assert(cos_sign == -1.0f || cos_sign == 1.0f); const float angle = (float)(2.0 * M_PI) * ((float)numerator / (float)denominator); *r_sin = sinf(angle); diff --git a/source/blender/blenlib/intern/math_solvers.c b/source/blender/blenlib/intern/math_solvers.c index fbae5f6d980..93801d1684e 100644 --- a/source/blender/blenlib/intern/math_solvers.c +++ b/source/blender/blenlib/intern/math_solvers.c @@ -14,12 +14,12 @@ #include "BLI_utildefines.h" +#include "BLI_strict_flags.h" + #include "eigen_capi.h" #include -#include "BLI_strict_flags.h" /* Keep last. */ - /********************************** Eigen Solvers *********************************/ bool BLI_eigen_solve_selfadjoint_m3(const float m3[3][3], diff --git a/source/blender/blenlib/intern/math_statistics.c b/source/blender/blenlib/intern/math_statistics.c index c121c0d9c8b..25f78e19b7d 100644 --- a/source/blender/blenlib/intern/math_statistics.c +++ b/source/blender/blenlib/intern/math_statistics.c @@ -9,11 +9,12 @@ #include "BLI_math_base.h" #include "BLI_math_statistics.h" #include "BLI_math_vector.h" +#include "MEM_guardedalloc.h" #include "BLI_task.h" #include "BLI_utildefines.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /********************************** Covariance Matrices *********************************/ diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 6a9ce1f172d..6fddd30d813 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -11,8 +11,7 @@ #include "BLI_math_base_safe.h" #include "BLI_math_geom.h" #include "BLI_math_rotation.h" - -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* -------------------------------------------------------------------- */ /** \name Interpolation diff --git a/source/blender/blenlib/intern/memory_utils.c b/source/blender/blenlib/intern/memory_utils.c index 6e7d6b95737..e898865ef38 100644 --- a/source/blender/blenlib/intern/memory_utils.c +++ b/source/blender/blenlib/intern/memory_utils.c @@ -16,7 +16,7 @@ #include "BLI_memory_utils.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" bool BLI_memory_is_zero(const void *arr, const size_t arr_size) { diff --git a/source/blender/blenlib/intern/mesh_boolean.cc b/source/blender/blenlib/intern/mesh_boolean.cc index 28ff2bbd18f..69b315aeafe 100644 --- a/source/blender/blenlib/intern/mesh_boolean.cc +++ b/source/blender/blenlib/intern/mesh_boolean.cc @@ -29,7 +29,9 @@ # include "BLI_span.hh" # include "BLI_stack.hh" # include "BLI_task.hh" +# include "BLI_time.h" # include "BLI_vector.hh" +# include "BLI_vector_set.hh" # include "BLI_mesh_boolean.hh" @@ -149,7 +151,7 @@ class TriMeshTopology : NonCopyable { /* Which edges are incident on the given vertex? * We assume v has some incident edges. */ - Span vert_edges(const Vert *v) const + const Vector &vert_edges(const Vert *v) const { return vert_edges_.lookup(v); } @@ -1540,7 +1542,7 @@ static int find_ambient_cell(const IMesh &tm, /* Find edge attached to v_extreme with max absolute slope * when projected onto the XY plane. That edge is guaranteed to * be on the convex hull of the mesh. */ - const Span edges = tmtopo.vert_edges(v_extreme); + const Vector &edges = tmtopo.vert_edges(v_extreme); const mpq_class &extreme_x = v_extreme->co_exact.x; const mpq_class &extreme_y = v_extreme->co_exact.y; Edge ehull; @@ -1625,7 +1627,7 @@ static Edge find_good_sorting_edge(const Vert *testp, mpq_class nlen2 = math::length_squared(normal); mpq_class max_abs_slope = -1; Edge esort; - const Span edges = tmtopo.vert_edges(closestp); + const Vector &edges = tmtopo.vert_edges(closestp); for (Edge e : edges) { const Vert *v_other = (e.v0() == closestp) ? e.v1() : e.v0(); const mpq3 &co_other = v_other->co_exact; @@ -1697,7 +1699,7 @@ static int find_containing_cell(const Vert *v, if (close_edge != -1) { const Vert *v0 = tri[close_edge]; const Vert *v1 = tri[(close_edge + 1) % 3]; - const Span edges = tmtopo.vert_edges(v0); + const Vector &edges = tmtopo.vert_edges(v0); if (dbg_level > 0) { std::cout << "look for edge containing " << v0 << " and " << v1 << "\n"; std::cout << " in edges: "; @@ -1907,7 +1909,7 @@ struct ComponentContainer { * (maybe not directly nested, which is why there can be more than one). */ static Vector find_component_containers(int comp, - const Span> components, + const Vector> &components, const Array &ambient_cell, const IMesh &tm, const PatchesInfo &pinfo, @@ -2022,7 +2024,7 @@ static Vector find_component_containers(int comp, * by an appropriate epsilon so that we conservatively will say * that components could intersect if the BBs overlap. */ -static void populate_comp_bbs(const Span> components, +static void populate_comp_bbs(const Vector> &components, const PatchesInfo &pinfo, const IMesh &im, Array &comp_bb) @@ -2970,7 +2972,7 @@ static std::ostream &operator<<(std::ostream &os, const FaceMergeState &fms) * Hence, try to be tolerant of such unexpected topology. */ static void init_face_merge_state(FaceMergeState *fms, - const Span tris, + const Vector &tris, const IMesh &tm, const double3 &norm) { @@ -3507,7 +3509,7 @@ static IMesh polymesh_from_trimesh_with_dissolve(const IMesh &tm_out, Array face(tot_out_face); int out_f_index = 0; for (int in_f : imesh_in.face_index_range()) { - const Span f_faces = face_output_face[in_f]; + const Vector &f_faces = face_output_face[in_f]; if (f_faces.size() > 0) { std::copy(f_faces.begin(), f_faces.end(), &face[out_f_index]); out_f_index += f_faces.size(); @@ -3557,7 +3559,7 @@ IMesh boolean_trimesh(IMesh &tm_in, return IMesh(tm_in); } # ifdef PERFDEBUG - double start_time = BLI_time_now_seconds(); + double start_time = BLI_check_seconds_timer(); std::cout << " boolean_trimesh, timing begins\n"; # endif @@ -3567,7 +3569,7 @@ IMesh boolean_trimesh(IMesh &tm_in, std::cout << "\nboolean_tm_input after intersection:\n" << tm_si; } # ifdef PERFDEBUG - double intersect_time = BLI_time_now_seconds(); + double intersect_time = BLI_check_seconds_timer(); std::cout << " intersected, time = " << intersect_time - start_time << "\n"; # endif @@ -3578,12 +3580,12 @@ IMesh boolean_trimesh(IMesh &tm_in, auto si_shape_fn = [shape_fn, tm_si](int t) { return shape_fn(tm_si.face(t)->orig); }; TriMeshTopology tm_si_topo(tm_si); # ifdef PERFDEBUG - double topo_time = BLI_time_now_seconds(); + double topo_time = BLI_check_seconds_timer(); std::cout << " topology built, time = " << topo_time - intersect_time << "\n"; # endif bool pwn = is_pwn(tm_si, tm_si_topo); # ifdef PERFDEBUG - double pwn_time = BLI_time_now_seconds(); + double pwn_time = BLI_check_seconds_timer(); std::cout << " pwn checked, time = " << pwn_time - topo_time << "\n"; # endif IMesh tm_out; @@ -3599,14 +3601,14 @@ IMesh boolean_trimesh(IMesh &tm_in, tm_out = raycast_patches_boolean(tm_si, op, nshapes, shape_fn, pinfo, arena); } # ifdef PERFDEBUG - double raycast_time = BLI_time_now_seconds(); + double raycast_time = BLI_check_seconds_timer(); std::cout << " raycast_boolean done, time = " << raycast_time - pwn_time << "\n"; # endif } else { PatchesInfo pinfo = find_patches(tm_si, tm_si_topo); # ifdef PERFDEBUG - double patch_time = BLI_time_now_seconds(); + double patch_time = BLI_check_seconds_timer(); std::cout << " patches found, time = " << patch_time - pwn_time << "\n"; # endif CellsInfo cinfo = find_cells(tm_si, tm_si_topo, pinfo); @@ -3614,12 +3616,12 @@ IMesh boolean_trimesh(IMesh &tm_in, std::cout << "Input is PWN\n"; } # ifdef PERFDEBUG - double cell_time = BLI_time_now_seconds(); + double cell_time = BLI_check_seconds_timer(); std::cout << " cells found, time = " << cell_time - pwn_time << "\n"; # endif finish_patch_cell_graph(tm_si, cinfo, pinfo, tm_si_topo, arena); # ifdef PERFDEBUG - double finish_pc_time = BLI_time_now_seconds(); + double finish_pc_time = BLI_check_seconds_timer(); std::cout << " finished patch-cell graph, time = " << finish_pc_time - cell_time << "\n"; # endif bool pc_ok = patch_cell_graph_ok(cinfo, pinfo); @@ -3631,7 +3633,7 @@ IMesh boolean_trimesh(IMesh &tm_in, cinfo.init_windings(nshapes); int c_ambient = find_ambient_cell(tm_si, nullptr, tm_si_topo, pinfo, arena); # ifdef PERFDEBUG - double amb_time = BLI_time_now_seconds(); + double amb_time = BLI_check_seconds_timer(); std::cout << " ambient cell found, time = " << amb_time - finish_pc_time << "\n"; # endif if (c_ambient == NO_INDEX) { @@ -3641,12 +3643,12 @@ IMesh boolean_trimesh(IMesh &tm_in, } propagate_windings_and_in_output_volume(pinfo, cinfo, c_ambient, op, nshapes, si_shape_fn); # ifdef PERFDEBUG - double propagate_time = BLI_time_now_seconds(); + double propagate_time = BLI_check_seconds_timer(); std::cout << " windings propagated, time = " << propagate_time - amb_time << "\n"; # endif tm_out = extract_from_in_output_volume_diffs(tm_si, pinfo, cinfo, arena); # ifdef PERFDEBUG - double extract_time = BLI_time_now_seconds(); + double extract_time = BLI_check_seconds_timer(); std::cout << " extracted, time = " << extract_time - propagate_time << "\n"; # endif if (dbg_level > 0) { @@ -3662,7 +3664,7 @@ IMesh boolean_trimesh(IMesh &tm_in, std::cout << "boolean tm output:\n" << tm_out; } # ifdef PERFDEBUG - double end_time = BLI_time_now_seconds(); + double end_time = BLI_check_seconds_timer(); std::cout << " boolean_trimesh done, total time = " << end_time - start_time << "\n"; # endif return tm_out; @@ -3708,7 +3710,7 @@ IMesh boolean_mesh(IMesh &imesh, IMesh *tm_in = imesh_triangulated; IMesh our_triangulation; # ifdef PERFDEBUG - double start_time = BLI_time_now_seconds(); + double start_time = BLI_check_seconds_timer(); std::cout << "boolean_mesh, timing begins\n"; # endif if (tm_in == nullptr) { @@ -3716,7 +3718,7 @@ IMesh boolean_mesh(IMesh &imesh, tm_in = &our_triangulation; } # ifdef PERFDEBUG - double tri_time = BLI_time_now_seconds(); + double tri_time = BLI_check_seconds_timer(); std::cout << "triangulated, time = " << tri_time - start_time << "\n"; # endif if (dbg_level > 1) { @@ -3724,7 +3726,7 @@ IMesh boolean_mesh(IMesh &imesh, } IMesh tm_out = boolean_trimesh(*tm_in, op, nshapes, shape_fn, use_self, hole_tolerant, arena); # ifdef PERFDEBUG - double bool_tri_time = BLI_time_now_seconds(); + double bool_tri_time = BLI_check_seconds_timer(); std::cout << "boolean_trimesh done, time = " << bool_tri_time - tri_time << "\n"; # endif if (dbg_level > 1) { @@ -3733,7 +3735,7 @@ IMesh boolean_mesh(IMesh &imesh, } IMesh ans = polymesh_from_trimesh_with_dissolve(tm_out, imesh, arena); # ifdef PERFDEBUG - double dissolve_time = BLI_time_now_seconds(); + double dissolve_time = BLI_check_seconds_timer(); std::cout << "polymesh from dissolving, time = " << dissolve_time - bool_tri_time << "\n"; # endif if (dbg_level > 0) { @@ -3744,7 +3746,7 @@ IMesh boolean_mesh(IMesh &imesh, } } # ifdef PERFDEBUG - double end_time = BLI_time_now_seconds(); + double end_time = BLI_check_seconds_timer(); std::cout << "boolean_mesh done, total time = " << end_time - start_time << "\n"; # endif return ans; diff --git a/source/blender/blenlib/intern/mesh_intersect.cc b/source/blender/blenlib/intern/mesh_intersect.cc index 8a9f72c824e..2e49f598212 100644 --- a/source/blender/blenlib/intern/mesh_intersect.cc +++ b/source/blender/blenlib/intern/mesh_intersect.cc @@ -21,6 +21,7 @@ # include "BLI_hash.hh" # include "BLI_kdopbvh.h" # include "BLI_map.hh" +# include "BLI_math_boolean.hh" # include "BLI_math_geom.h" # include "BLI_math_matrix.h" # include "BLI_math_mpq.hh" @@ -34,6 +35,7 @@ # include "BLI_task.h" # include "BLI_task.hh" # include "BLI_threads.h" +# include "BLI_time.h" # include "BLI_vector.hh" # include "BLI_vector_set.hh" @@ -2954,7 +2956,7 @@ IMesh trimesh_nary_intersect(const IMesh &tm_in, } # ifdef PERFDEBUG perfdata_init(); - double start_time = BLI_time_now_seconds(); + double start_time = BLI_check_seconds_timer(); std::cout << "trimesh_nary_intersect start\n"; # endif /* Usually can use tm_in but if it has degenerate or illegal triangles, @@ -2972,17 +2974,17 @@ IMesh trimesh_nary_intersect(const IMesh &tm_in, } } # ifdef PERFDEBUG - double clean_time = BLI_time_now_seconds(); + double clean_time = BLI_check_seconds_timer(); std::cout << "cleaned, time = " << clean_time - start_time << "\n"; # endif Array tri_bb = calc_face_bounding_boxes(*tm_clean); # ifdef PERFDEBUG - double bb_calc_time = BLI_time_now_seconds(); + double bb_calc_time = BLI_check_seconds_timer(); std::cout << "bbs calculated, time = " << bb_calc_time - clean_time << "\n"; # endif TriOverlaps tri_ov(*tm_clean, tri_bb, nshapes, shape_fn, use_self); # ifdef PERFDEBUG - double overlap_time = BLI_time_now_seconds(); + double overlap_time = BLI_check_seconds_timer(); std::cout << "intersect overlaps calculated, time = " << overlap_time - bb_calc_time << "\n"; # endif Array tri_subdivided(tm_clean->face_size(), NoInitialization()); @@ -2995,7 +2997,7 @@ IMesh trimesh_nary_intersect(const IMesh &tm_in, } }); # ifdef PERFDEBUG - double plane_populate = BLI_time_now_seconds(); + double plane_populate = BLI_check_seconds_timer(); std::cout << "planes populated, time = " << plane_populate - overlap_time << "\n"; # endif /* itt_map((a,b)) will hold the intersection value resulting from intersecting @@ -3004,7 +3006,7 @@ IMesh trimesh_nary_intersect(const IMesh &tm_in, itt_map.reserve(tri_ov.overlap().size()); calc_overlap_itts(itt_map, *tm_clean, tri_ov, arena); # ifdef PERFDEBUG - double itt_time = BLI_time_now_seconds(); + double itt_time = BLI_check_seconds_timer(); std::cout << "itts found, time = " << itt_time - plane_populate << "\n"; # endif CoplanarClusterInfo clinfo = find_clusters(*tm_clean, tri_bb, itt_map); @@ -3012,7 +3014,7 @@ IMesh trimesh_nary_intersect(const IMesh &tm_in, std::cout << clinfo; } # ifdef PERFDEBUG - double find_cluster_time = BLI_time_now_seconds(); + double find_cluster_time = BLI_check_seconds_timer(); std::cout << "clusters found, time = " << find_cluster_time - itt_time << "\n"; doperfmax(0, tm_in.face_size()); doperfmax(1, clinfo.tot_cluster()); @@ -3020,7 +3022,7 @@ IMesh trimesh_nary_intersect(const IMesh &tm_in, # endif calc_subdivided_non_cluster_tris(tri_subdivided, *tm_clean, itt_map, clinfo, tri_ov, arena); # ifdef PERFDEBUG - double subdivided_tris_time = BLI_time_now_seconds(); + double subdivided_tris_time = BLI_check_seconds_timer(); std::cout << "subdivided non-cluster tris found, time = " << subdivided_tris_time - itt_time << "\n"; # endif @@ -3029,13 +3031,13 @@ IMesh trimesh_nary_intersect(const IMesh &tm_in, cluster_subdivided[c] = calc_cluster_subdivided(clinfo, c, *tm_clean, tri_ov, itt_map, arena); } # ifdef PERFDEBUG - double cluster_subdivide_time = BLI_time_now_seconds(); + double cluster_subdivide_time = BLI_check_seconds_timer(); std::cout << "subdivided clusters found, time = " << cluster_subdivide_time - subdivided_tris_time << "\n"; # endif calc_cluster_tris(tri_subdivided, *tm_clean, clinfo, cluster_subdivided, arena); # ifdef PERFDEBUG - double extract_time = BLI_time_now_seconds(); + double extract_time = BLI_check_seconds_timer(); std::cout << "subdivided cluster tris found, time = " << extract_time - cluster_subdivide_time << "\n"; # endif @@ -3045,7 +3047,7 @@ IMesh trimesh_nary_intersect(const IMesh &tm_in, std::cout << combined; } # ifdef PERFDEBUG - double end_time = BLI_time_now_seconds(); + double end_time = BLI_check_seconds_timer(); std::cout << "triangles combined, time = " << end_time - extract_time << "\n"; std::cout << "trimesh_nary_intersect done, total time = " << end_time - start_time << "\n"; dump_perfdata(); diff --git a/source/blender/blenlib/intern/path_util.cc b/source/blender/blenlib/intern/path_util.cc index 46ef7b53396..0a91702897f 100644 --- a/source/blender/blenlib/intern/path_util.cc +++ b/source/blender/blenlib/intern/path_util.cc @@ -12,10 +12,13 @@ #include #include +#include "DNA_listBase.h" + #include "BLI_fileops.h" #include "BLI_fnmatch.h" #include "BLI_path_util.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "BLI_string_utils.hh" #include "BLI_utildefines.h" diff --git a/source/blender/blenlib/intern/polyfill_2d.c b/source/blender/blenlib/intern/polyfill_2d.c index 5b81a947659..7e96defb5e8 100644 --- a/source/blender/blenlib/intern/polyfill_2d.c +++ b/source/blender/blenlib/intern/polyfill_2d.c @@ -40,7 +40,7 @@ #include "BLI_polyfill_2d.h" /* own include */ -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* avoid fan-fill topology */ #define USE_CLIP_EVEN diff --git a/source/blender/blenlib/intern/polyfill_2d_beautify.c b/source/blender/blenlib/intern/polyfill_2d_beautify.c index ae83a487f4c..d9d786ae7eb 100644 --- a/source/blender/blenlib/intern/polyfill_2d_beautify.c +++ b/source/blender/blenlib/intern/polyfill_2d_beautify.c @@ -31,7 +31,7 @@ #include "BLI_polyfill_2d_beautify.h" /* own include */ -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* Used to find matching edges. */ struct OrderEdge { diff --git a/source/blender/blenlib/intern/quadric.c b/source/blender/blenlib/intern/quadric.c index d70e8806ed0..8a999d2c386 100644 --- a/source/blender/blenlib/intern/quadric.c +++ b/source/blender/blenlib/intern/quadric.c @@ -17,14 +17,14 @@ * often need high precision, see #44780. */ -#include +#include "BLI_strict_flags.h" #include "BLI_math_base.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" #include "BLI_quadric.h" /* own include */ -#include "BLI_strict_flags.h" /* Keep last. */ +#include #define QUADRIC_FLT_TOT (sizeof(Quadric) / sizeof(double)) diff --git a/source/blender/blenlib/intern/rand.cc b/source/blender/blenlib/intern/rand.cc index a1ec6550c9b..29cc51d55cd 100644 --- a/source/blender/blenlib/intern/rand.cc +++ b/source/blender/blenlib/intern/rand.cc @@ -19,10 +19,10 @@ #include "BLI_math_vector.h" #include "BLI_rand.h" #include "BLI_rand.hh" -#include "BLI_sys_types.h" #include "BLI_threads.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" +#include "BLI_sys_types.h" extern "C" uchar BLI_noise_hash_uchar_512[512]; /* `noise.cc` */ #define hash BLI_noise_hash_uchar_512 diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index fe6529426ed..af93fb82205 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -32,7 +32,7 @@ #include "BLI_scanfill.h" /* own include */ -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* local types */ typedef struct PolyFill { diff --git a/source/blender/blenlib/intern/scanfill_utils.c b/source/blender/blenlib/intern/scanfill_utils.c index 91859bf259b..279e8856c34 100644 --- a/source/blender/blenlib/intern/scanfill_utils.c +++ b/source/blender/blenlib/intern/scanfill_utils.c @@ -22,7 +22,7 @@ #include "BLI_scanfill.h" /* own include */ -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" typedef struct PolyInfo { ScanFillEdge *edge_first, *edge_last; diff --git a/source/blender/blenlib/intern/session_uid.c b/source/blender/blenlib/intern/session_uid.c index 7aa0731fd6b..d13151e27e9 100644 --- a/source/blender/blenlib/intern/session_uid.c +++ b/source/blender/blenlib/intern/session_uid.c @@ -8,6 +8,8 @@ #include "BLI_session_uid.h" +#include "BLI_utildefines.h" + #include "atomic_ops.h" /* Special value which indicates the UID has not been assigned yet. */ diff --git a/source/blender/blenlib/intern/stack.c b/source/blender/blenlib/intern/stack.c index b771265932a..addb478d4f9 100644 --- a/source/blender/blenlib/intern/stack.c +++ b/source/blender/blenlib/intern/stack.c @@ -14,7 +14,7 @@ #include "BLI_stack.h" /* own include */ -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" #define USE_TOTELEM diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index ea513f63250..1a957fb89fe 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -20,7 +20,7 @@ #include "BLI_utildefines.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* -------------------------------------------------------------------- */ /** \name String Duplicate/Copy diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c index be1977d2a0d..d8c2f40f633 100644 --- a/source/blender/blenlib/intern/string_cursor_utf8.c +++ b/source/blender/blenlib/intern/string_cursor_utf8.c @@ -14,7 +14,7 @@ #include "BLI_string_cursor_utf8.h" /* own include */ -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /** * The category of character as returned by #cursor_delim_type_unicode. diff --git a/source/blender/blenlib/intern/string_search.cc b/source/blender/blenlib/intern/string_search.cc index b6c57a6bba5..73c0e64ba4b 100644 --- a/source/blender/blenlib/intern/string_search.cc +++ b/source/blender/blenlib/intern/string_search.cc @@ -12,6 +12,7 @@ #include "BLI_string_utf8.h" #include "BLI_string_utf8_symbols.h" #include "BLI_task.hh" +#include "BLI_timeit.hh" /* Right arrow, keep in sync with #UI_MENU_ARROW_SEP in `UI_interface.hh`. */ #define UI_MENU_ARROW_SEP BLI_STR_UTF8_BLACK_RIGHT_POINTING_SMALL_TRIANGLE diff --git a/source/blender/blenlib/intern/string_utf8.cc b/source/blender/blenlib/intern/string_utf8.cc index 6402376e103..07d889272cb 100644 --- a/source/blender/blenlib/intern/string_utf8.cc +++ b/source/blender/blenlib/intern/string_utf8.cc @@ -29,7 +29,7 @@ # pragma GCC diagnostic error "-Wsign-conversion" #endif -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* -------------------------------------------------------------------- */ /** \name UTF8 Character Decoding (Skip & Mask Lookup) diff --git a/source/blender/blenlib/intern/string_utils.cc b/source/blender/blenlib/intern/string_utils.cc index 92222b5e0e3..c53a1e62327 100644 --- a/source/blender/blenlib/intern/string_utils.cc +++ b/source/blender/blenlib/intern/string_utils.cc @@ -24,7 +24,7 @@ #include "DNA_listBase.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* -------------------------------------------------------------------- */ /** \name String Replace diff --git a/source/blender/blenlib/intern/system.c b/source/blender/blenlib/intern/system.c index 13cba35106d..0b9fb4b6c9a 100644 --- a/source/blender/blenlib/intern/system.c +++ b/source/blender/blenlib/intern/system.c @@ -13,6 +13,9 @@ #include "BLI_math_base.h" #include "BLI_string.h" #include "BLI_system.h" +#include "BLI_utildefines.h" + +#include "MEM_guardedalloc.h" /* for backtrace and gethostname/GetComputerName */ #if defined(WIN32) @@ -141,7 +144,7 @@ char *BLI_cpu_brand_string(void) return NULL; } -int BLI_cpu_support_sse42(void) +int BLI_cpu_support_sse41(void) { int result[4], num; __cpuid(result, 0); @@ -149,7 +152,7 @@ int BLI_cpu_support_sse42(void) if (num >= 1) { __cpuid(result, 0x00000001); - return (result[2] & ((int)1 << 20)) != 0; + return (result[2] & ((int)1 << 19)) != 0; } return 0; } diff --git a/source/blender/blenlib/intern/task_graph.cc b/source/blender/blenlib/intern/task_graph.cc index cd7e09c31c2..1e46bfebcbc 100644 --- a/source/blender/blenlib/intern/task_graph.cc +++ b/source/blender/blenlib/intern/task_graph.cc @@ -8,9 +8,7 @@ * Task graph. */ -#ifdef WITH_CXX_GUARDEDALLOC -# include "MEM_guardedalloc.h" -#endif +#include "MEM_guardedalloc.h" #include "BLI_task.h" diff --git a/source/blender/blenlib/intern/task_iterator.c b/source/blender/blenlib/intern/task_iterator.c index 05a73ca53d8..3fb95bac1ff 100644 --- a/source/blender/blenlib/intern/task_iterator.c +++ b/source/blender/blenlib/intern/task_iterator.c @@ -12,11 +12,17 @@ #include "MEM_guardedalloc.h" +#include "DNA_listBase.h" + +#include "BLI_listbase.h" +#include "BLI_math_base.h" #include "BLI_mempool.h" #include "BLI_mempool_private.h" #include "BLI_task.h" #include "BLI_threads.h" +#include "atomic_ops.h" + /* -------------------------------------------------------------------- */ /** \name Macros * \{ */ diff --git a/source/blender/blenlib/intern/task_range.cc b/source/blender/blenlib/intern/task_range.cc index 3b750555777..0ff589d929c 100644 --- a/source/blender/blenlib/intern/task_range.cc +++ b/source/blender/blenlib/intern/task_range.cc @@ -12,6 +12,8 @@ #include "MEM_guardedalloc.h" +#include "DNA_listBase.h" + #include "BLI_lazy_threading.hh" #include "BLI_task.h" #include "BLI_task.hh" diff --git a/source/blender/blenlib/intern/threads.cc b/source/blender/blenlib/intern/threads.cc index 959a5671413..1ae433d51d4 100644 --- a/source/blender/blenlib/intern/threads.cc +++ b/source/blender/blenlib/intern/threads.cc @@ -63,7 +63,7 @@ * // tag job 'processed * BLI_threadpool_insert(&lb, job); * } - * else BLI_time_sleep_ms(50); + * else BLI_sleep_ms(50); * * // Find if a job is ready, this the do_something_func() should write in job somewhere. * cont = 0; @@ -687,7 +687,7 @@ void *BLI_thread_queue_pop_timeout(ThreadQueue *queue, int ms) void *work = nullptr; timespec timeout; - t = BLI_time_now_seconds(); + t = BLI_check_seconds_timer(); wait_timeout(&timeout, ms); /* wait until there is work */ @@ -696,7 +696,7 @@ void *BLI_thread_queue_pop_timeout(ThreadQueue *queue, int ms) if (pthread_cond_timedwait(&queue->push_cond, &queue->mutex, &timeout) == ETIMEDOUT) { break; } - if (BLI_time_now_seconds() - t >= ms * 0.001) { + if (BLI_check_seconds_timer() - t >= ms * 0.001) { break; } } diff --git a/source/blender/blenlib/intern/time.c b/source/blender/blenlib/intern/time.c index e8b27f98174..2af01aea92a 100644 --- a/source/blender/blenlib/intern/time.c +++ b/source/blender/blenlib/intern/time.c @@ -12,7 +12,7 @@ # define WIN32_LEAN_AND_MEAN # include -double BLI_time_now_seconds(void) +double BLI_check_seconds_timer(void) { static int hasperfcounter = -1; /* (-1 == unknown) */ static double perffreq; @@ -47,12 +47,12 @@ double BLI_time_now_seconds(void) } } -long int BLI_time_now_seconds_i(void) +long int BLI_check_seconds_timer_i(void) { - return (long int)BLI_time_now_seconds(); + return (long int)BLI_check_seconds_timer(); } -void BLI_time_sleep_ms(int ms) +void BLI_sleep_ms(int ms) { Sleep(ms); } @@ -62,7 +62,7 @@ void BLI_time_sleep_ms(int ms) # include # include -double BLI_time_now_seconds(void) +double BLI_check_seconds_timer(void) { struct timeval tv; struct timezone tz; @@ -72,7 +72,7 @@ double BLI_time_now_seconds(void) return ((double)tv.tv_sec + tv.tv_usec / 1000000.0); } -long int BLI_time_now_seconds_i(void) +long int BLI_check_seconds_timer_i(void) { struct timeval tv; struct timezone tz; @@ -82,7 +82,7 @@ long int BLI_time_now_seconds_i(void) return tv.tv_sec; } -void BLI_time_sleep_ms(int ms) +void BLI_sleep_ms(int ms) { if (ms >= 1000) { sleep(ms / 1000); diff --git a/source/blender/blenlib/intern/timecode.c b/source/blender/blenlib/intern/timecode.c index 5989ae47417..8b4546d82fa 100644 --- a/source/blender/blenlib/intern/timecode.c +++ b/source/blender/blenlib/intern/timecode.c @@ -18,7 +18,7 @@ #include "DNA_userdef_types.h" /* for eTimecodeStyles only */ -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" size_t BLI_timecode_string_from_time(char *str, const size_t maxncpy, diff --git a/source/blender/blenlib/intern/uuid.cc b/source/blender/blenlib/intern/uuid.cc index 0a66b0766b7..49da4804af0 100644 --- a/source/blender/blenlib/intern/uuid.cc +++ b/source/blender/blenlib/intern/uuid.cc @@ -153,7 +153,7 @@ bUUID::bUUID(const std::initializer_list field_values) std::copy(field_iter, field_values.end(), this->node); } -bUUID::bUUID(const StringRefNull string_formatted_uuid) +bUUID::bUUID(const std::string &string_formatted_uuid) { const bool parsed_ok = BLI_uuid_parse_string(this, string_formatted_uuid.c_str()); if (!parsed_ok) { diff --git a/source/blender/blenlib/intern/uvproject.cc b/source/blender/blenlib/intern/uvproject.c similarity index 87% rename from source/blender/blenlib/intern/uvproject.cc rename to source/blender/blenlib/intern/uvproject.c index 5ef767f4648..e2922ed1e76 100644 --- a/source/blender/blenlib/intern/uvproject.cc +++ b/source/blender/blenlib/intern/uvproject.c @@ -6,7 +6,7 @@ * \ingroup bli */ -#include +#include #include "MEM_guardedalloc.h" @@ -18,7 +18,7 @@ #include "BLI_math_vector.h" #include "BLI_uvproject.h" -struct ProjCameraInfo { +typedef struct ProjCameraInfo { float camangle; float camsize; float xasp, yasp; @@ -26,7 +26,7 @@ struct ProjCameraInfo { float rotmat[4][4]; float caminv[4][4]; bool do_persp, do_pano, do_rotmat; -}; +} ProjCameraInfo; void BLI_uvproject_from_camera(float target[2], float source[3], ProjCameraInfo *uci) { @@ -44,7 +44,7 @@ void BLI_uvproject_from_camera(float target[2], float source[3], ProjCameraInfo mul_m4_v4(uci->caminv, pv4); if (uci->do_pano) { - float angle = atan2f(pv4[0], -pv4[2]) / (float(M_PI) * 2.0f); /* angle around the camera */ + float angle = atan2f(pv4[0], -pv4[2]) / ((float)M_PI * 2.0f); /* angle around the camera */ if (uci->do_persp == false) { target[0] = angle; /* no correct method here, just map to 0-1 */ target[1] = pv4[1] / uci->camsize; @@ -53,7 +53,7 @@ void BLI_uvproject_from_camera(float target[2], float source[3], ProjCameraInfo float vec2d[2]; /* 2D position from the camera */ vec2d[0] = pv4[0]; vec2d[1] = pv4[2]; - target[0] = angle * (float(M_PI) / uci->camangle); + target[0] = angle * ((float)M_PI / uci->camangle); target[1] = pv4[1] / (len_v2(vec2d) * (uci->camsize * 2.0f)); } } @@ -121,13 +121,10 @@ void BLI_uvproject_from_view(float target[2], target[1] = (y + target[1]) / winy; } -ProjCameraInfo *BLI_uvproject_camera_info(Object *ob, - const float rotmat[4][4], - float winx, - float winy) +ProjCameraInfo *BLI_uvproject_camera_info(Object *ob, float rotmat[4][4], float winx, float winy) { ProjCameraInfo uci; - Camera *camera = static_cast(ob->data); + Camera *camera = ob->data; uci.do_pano = (camera->type == CAM_PANO); uci.do_persp = (camera->type == CAM_PERSP); @@ -136,7 +133,7 @@ ProjCameraInfo *BLI_uvproject_camera_info(Object *ob, uci.camsize = uci.do_persp ? tanf(uci.camangle) : camera->ortho_scale; /* account for scaled cameras */ - copy_m4_m4(uci.caminv, ob->object_to_world().ptr()); + copy_m4_m4(uci.caminv, ob->object_to_world); normalize_m4(uci.caminv); if (invert_m4(uci.caminv)) { @@ -165,12 +162,12 @@ ProjCameraInfo *BLI_uvproject_camera_info(Object *ob, uci.shiftx = 0.5f - (camera->shiftx * uci.xasp); uci.shifty = 0.5f - (camera->shifty * uci.yasp); - uci_pt = static_cast(MEM_mallocN(sizeof(ProjCameraInfo), __func__)); + uci_pt = MEM_mallocN(sizeof(ProjCameraInfo), "ProjCameraInfo"); *uci_pt = uci; return uci_pt; } - return nullptr; + return NULL; } void BLI_uvproject_from_view_ortho(float target[2], float source[3], const float rotmat[4][4]) diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index 0ea2b1de57a..85e8c9e46f2 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -9,7 +9,7 @@ #include "BLI_utildefines.h" #include "BLI_voxel.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" BLI_INLINE float D(const float *data, const int res[3], int x, int y, int z) { diff --git a/source/blender/blenlib/tests/BLI_array_test.cc b/source/blender/blenlib/tests/BLI_array_test.cc index 44e6c9a2ce8..d4eafdc02a6 100644 --- a/source/blender/blenlib/tests/BLI_array_test.cc +++ b/source/blender/blenlib/tests/BLI_array_test.cc @@ -2,13 +2,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "testing/testing.h" - #include "BLI_array.hh" #include "BLI_exception_safety_test_utils.hh" +#include "BLI_strict_flags.h" #include "BLI_vector.hh" - -#include "BLI_strict_flags.h" /* Keep last. */ +#include "testing/testing.h" namespace blender::tests { diff --git a/source/blender/blenlib/tests/BLI_bit_group_vector_test.cc b/source/blender/blenlib/tests/BLI_bit_group_vector_test.cc index 974a6fd92bd..8885f3d5c00 100644 --- a/source/blender/blenlib/tests/BLI_bit_group_vector_test.cc +++ b/source/blender/blenlib/tests/BLI_bit_group_vector_test.cc @@ -2,11 +2,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "testing/testing.h" - #include "BLI_bit_group_vector.hh" +#include "BLI_strict_flags.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "testing/testing.h" namespace blender::bits::tests { diff --git a/source/blender/blenlib/tests/BLI_bit_vector_test.cc b/source/blender/blenlib/tests/BLI_bit_vector_test.cc index 7efeb6bc832..803ff0f021f 100644 --- a/source/blender/blenlib/tests/BLI_bit_vector_test.cc +++ b/source/blender/blenlib/tests/BLI_bit_vector_test.cc @@ -2,12 +2,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "testing/testing.h" - #include "BLI_bit_vector.hh" #include "BLI_exception_safety_test_utils.hh" +#include "BLI_strict_flags.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "testing/testing.h" namespace blender::bits::tests { diff --git a/source/blender/blenlib/tests/BLI_convexhull_2d_test.cc b/source/blender/blenlib/tests/BLI_convexhull_2d_test.cc deleted file mode 100644 index 36f08e68736..00000000000 --- a/source/blender/blenlib/tests/BLI_convexhull_2d_test.cc +++ /dev/null @@ -1,346 +0,0 @@ -/* SPDX-FileCopyrightText: 2024 Blender Authors - * - * SPDX-License-Identifier: Apache-2.0 */ - -/** \file - * Test that convex hull calculation and fitting convex hulls - * to a bounding box is working properly. - * - * \note Bounding box fitting checks compare against exact values. - * In this case there are multiple correct angles since both - * 45 degrees & -45 degrees will give the desired outcome. - * Keep using exact value matches so any changes to the return values are detected. - * If this becomes a problem for maintaining tests then values could be normalized for comparison. - */ - -#include "testing/testing.h" - -#include "BLI_array.hh" -#include "BLI_convexhull_2d.h" -#include "BLI_math_angle_types.hh" -#include "BLI_math_geom.h" -#include "BLI_math_matrix.h" -#include "BLI_math_matrix_types.hh" -#include "BLI_math_rotation.hh" -#include "BLI_math_vector.h" -#include "BLI_math_vector.hh" -#include "BLI_math_vector_types.hh" -#include "BLI_rand.hh" - -using namespace blender; - -/** - * Increase to a large number (8k or so) to test many permutations, - * too slow for regular tests. - */ -#define DEFAULT_TEST_ITER 8 - -/** The size of a polygon when generating data. */ -#define DEFAULT_TEST_POLY_NUM 12 - -#define DEFAULT_TEST_RANDOM_SEED 123 - -/** The epsilon to use when comparing floating point rotations (as radians). */ -#define ROTATION_EPS 1e-6 - -/* -------------------------------------------------------------------- */ -/** \name Internal Utilities - * \{ */ - -static blender::Array convexhull_points_from_map(blender::Span points, - blender::Span points_map) -{ - blender::Array points_hull(points_map.size()); - int index = 0; - for (int p_index : points_map) { - points_hull[index++] = points[p_index]; - } - return points_hull; -} - -static blender::Array convexhull_2d_as_array(blender::Span points) -{ - blender::Array points_hull_map(points.size()); - int points_hull_map_num = BLI_convexhull_2d( - reinterpret_cast(points.data()), points.size(), points_hull_map.data()); - - blender::Span points_hull_map_span(points_hull_map.data(), points_hull_map_num); - return convexhull_points_from_map(points, points_hull_map_span); -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Wrap Public API's - * \{ */ - -static float convexhull_2d_aabb_fit_points_2d(blender::Span points) -{ - return BLI_convexhull_aabb_fit_points_2d(reinterpret_cast(points.data()), - points.size()); -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Tests - * \{ */ - -TEST(convexhull_2d, IsConvex) -{ - blender::Array points(DEFAULT_TEST_POLY_NUM); - RandomNumberGenerator rng = RandomNumberGenerator(DEFAULT_TEST_RANDOM_SEED); - for (int iter = 0; iter < DEFAULT_TEST_ITER; iter++) { - for (float2 &p : points) { - p = float2(rng.get_float(), rng.get_float()); - } - blender::Array points_hull = convexhull_2d_as_array(points); - if (UNLIKELY(points_hull.size() < 3)) { - continue; - } - - int i_prev = points_hull.size() - 2; - int i_curr = points_hull.size() - 1; - for (int i_next = 0; i_next < points_hull.size(); i_prev = i_curr, i_curr = i_next++) { - EXPECT_GE(cross_tri_v2(points_hull[i_prev], points_hull[i_curr], points_hull[i_next]), 0.0f); - } - } -} - -TEST(convexhull_2d, IsCCW) -{ - blender::Array points(DEFAULT_TEST_POLY_NUM); - RandomNumberGenerator rng = RandomNumberGenerator(DEFAULT_TEST_RANDOM_SEED); - for (int iter = 0; iter < DEFAULT_TEST_ITER; iter++) { - for (float2 &p : points) { - p = float2(rng.get_float(), rng.get_float()); - } - blender::Array points_hull = convexhull_2d_as_array(points); - - EXPECT_GE( - cross_poly_v2(reinterpret_cast(points_hull.data()), points_hull.size()), - 0.0f); - } -} - -TEST(convexhull_2d, NOP) -{ - { /* Single point. */ - blender::Array points = {{0.0f, 0.0f}}; - EXPECT_NEAR(convexhull_2d_aabb_fit_points_2d(points), 0.0f, ROTATION_EPS); - } - - { /* Single point, 2x duplicates. */ - blender::Array points = {{0.0f, 0.0f}, {0.0f, 0.0f}}; - EXPECT_NEAR(convexhull_2d_aabb_fit_points_2d(points), 0.0f, ROTATION_EPS); - } - { /* Single point, 3x duplicates. */ - blender::Array points = {{0.0f, 0.0f}, {0.0f, 0.0f}, {0.0f, 0.0f}}; - EXPECT_NEAR(convexhull_2d_aabb_fit_points_2d(points), 0.0f, ROTATION_EPS); - } -} - -TEST(convexhull_2d, Lines_AxisAligned) -{ - { /* Horizontal line (2 points). */ - for (int sign_x = -1; sign_x <= 2; sign_x += 2) { - blender::Array points = {{0.0f, 0.0f}, {1.0f * sign_x, 0.0}}; - EXPECT_NEAR(convexhull_2d_aabb_fit_points_2d(points), - float(math::AngleRadian::from_degree(-90.0f)), - ROTATION_EPS); - } - } - { /* Horizontal line (3 points). */ - for (int sign_x = -1; sign_x <= 2; sign_x += 2) { - blender::Array points = {{0.0f, 0.0f}, {1.0f * sign_x, 0.0}, {2.0f * sign_x, 0.0}}; - EXPECT_NEAR(convexhull_2d_aabb_fit_points_2d(points), - float(math::AngleRadian::from_degree(-90.0f)), - ROTATION_EPS); - } - } - - { /* Vertical line (2 points). */ - for (int sign_y = -1; sign_y <= 2; sign_y += 2) { - blender::Array points = {{0.0f, 0.0f}, {0.0f, 1.0f * sign_y}}; - EXPECT_NEAR(convexhull_2d_aabb_fit_points_2d(points), - float(math::AngleRadian::from_degree(180.0f)), - ROTATION_EPS); - } - } - { /* Vertical line (3 points). */ - for (int sign_y = -1; sign_y <= 2; sign_y += 2) { - blender::Array points = {{0.0f, 0.0f}, {0.0f, 1.0f * sign_y}, {0.0f, 2.0f * sign_y}}; - EXPECT_NEAR(convexhull_2d_aabb_fit_points_2d(points), - float(math::AngleRadian::from_degree(180.0f)), - ROTATION_EPS); - } - } - - { /* Horizontal line (many points). */ - blender::Array points(8); - RandomNumberGenerator rng = RandomNumberGenerator(DEFAULT_TEST_RANDOM_SEED); - for (int iter = 0; iter < DEFAULT_TEST_ITER; iter++) { - /* Add points, Y is always positive. */ - for (float2 &p : points) { - p = rng.get_unit_float2(); - p[0] = 0.0; - } - - EXPECT_NEAR(convexhull_2d_aabb_fit_points_2d(points), M_PI, ROTATION_EPS); - } - } - - { /* Vertical line (many points). */ - blender::Array points(8); - RandomNumberGenerator rng = RandomNumberGenerator(DEFAULT_TEST_RANDOM_SEED); - for (int iter = 0; iter < DEFAULT_TEST_ITER; iter++) { - /* Add points, Y is always positive. */ - for (float2 &p : points) { - p = rng.get_unit_float2(); - p[0] = 0.0; - } - - blender::Array points_hull = convexhull_2d_as_array(points); - EXPECT_NEAR(convexhull_2d_aabb_fit_points_2d(points_hull), M_PI, ROTATION_EPS); - } - } -} - -TEST(convexhull_2d, Lines_Diagonal) -{ - { /* Diagonal line (2 points). */ - const float expected[4] = {-135, 135, 135, -135}; - int index = 0; - for (int sign_x = -1; sign_x <= 2; sign_x += 2) { - for (int sign_y = -1; sign_y <= 2; sign_y += 2) { - blender::Array points = {{0.0f, 0.0f}, {1.0f * sign_x, 1.0f * sign_y}}; - EXPECT_NEAR(convexhull_2d_aabb_fit_points_2d(points), - float(math::AngleRadian::from_degree(expected[index])), - ROTATION_EPS); - index++; - } - } - } - - { /* Diagonal line (3 points). */ - const float expected[4] = {-135, 135, 135, -135}; - int index = 0; - for (int sign_x = -1; sign_x <= 2; sign_x += 2) { - for (int sign_y = -1; sign_y <= 2; sign_y += 2) { - blender::Array points = { - {0.0f, 0.0f}, - {1.0f * sign_x, 1.0f * sign_y}, - {2.0f * sign_x, 2.0f * sign_y}, - }; - EXPECT_NEAR(convexhull_2d_aabb_fit_points_2d(points), - float(math::AngleRadian::from_degree(expected[index])), - ROTATION_EPS); - index++; - } - } - } -} - -TEST(convexhull_2d, Simple) -{ - { /* 45degree rotated square. */ - blender::Array points = { - {0.0f, -1.0f}, - {-1.0f, 0.0f}, - {0.0f, 1.0f}, - {1.0f, 0.0f}, - }; - EXPECT_NEAR(convexhull_2d_aabb_fit_points_2d(points), - float(math::AngleRadian::from_degree(135.0f)), - ROTATION_EPS); - } - - { /* Axis aligned square. */ - blender::Array points = { - {-1.0f, -1.0f}, - {-1.0f, 1.0f}, - {1.0f, 1.0f}, - {1.0f, -1.0f}, - }; - EXPECT_NEAR(convexhull_2d_aabb_fit_points_2d(points), - float(math::AngleRadian::from_degree(180.0f)), - ROTATION_EPS); - } -} - -/** - * Generate complex rotated/translated shapes with a known size. - * Check the rotation returned by #BLI_convexhull_aabb_fit_points_2d - * rotates the points into a bounding box with an area no larger than generated size. - */ -TEST(convexhull_2d, Complex) -{ - auto shape_generate_fn = [](RandomNumberGenerator &rng, - const float2 &size, - const int points_num) -> blender::Array { - /* Avoid zero area boxes. */ - blender::Array points(points_num); - const int points_num_reserved = 4; - BLI_assert(points_num_reserved >= 4); - - /* Ensure there are always points at the bounds. */ - points[0] = {0.0f, rng.get_float()}; /* Left. */ - points[1] = {1.0f, rng.get_float()}; /* Right. */ - points[2] = {rng.get_float(), 0.0f}; /* Bottom. */ - points[3] = {rng.get_float(), 1.0f}; /* Top. */ - - for (int i = points_num_reserved; i < points_num; i++) { - points[i] = {rng.get_float(), rng.get_float()}; - } - - /* Shuffle to ensure the solution is valid no matter the order of the input, - * Only the first `points_num_reserved` matter as remaining points are random. */ - for (int i = 0; i < points_num_reserved; i++) { - std::swap(points[i], points[rng.get_int32(points_num)]); - } - - /* Map from 0-1 to a random transformation. */ - const float2 translation = { - (rng.get_float() * 2.0f) - 1.0f, - (rng.get_float() * 2.0f) - 1.0f, - }; - - const float2x2 rot_mat = math::from_rotation( - math::AngleRadian(rng.get_float() * M_PI)); - for (float2 &p : points) { - BLI_assert(p[0] >= 0.0 && p[0] <= 1.0f); - BLI_assert(p[1] >= 0.0 && p[1] <= 1.0f); - /* Center from [-0.5..0.5], apply size, rotate & translate. */ - p = (((p - float2(0.5f, 0.5f)) * size) * rot_mat) + translation; - } - - return points; - }; - - RandomNumberGenerator rng = RandomNumberGenerator(DEFAULT_TEST_RANDOM_SEED); - for (int i = 0; i < DEFAULT_TEST_ITER; i++) { - constexpr float size_margin = 0.1; - /* Random size from `[size_margin..2]`. */ - float2 size = { - math::min((rng.get_float() * 2.0f) + size_margin, 2.0f), - math::min((rng.get_float() * 2.0f) + size_margin, 2.0f), - }; - - blender::Array points = shape_generate_fn(rng, size, DEFAULT_TEST_POLY_NUM); - const float angle = convexhull_2d_aabb_fit_points_2d(points); - - const float2x2 rot_mat = math::from_rotation(-angle); - float2 tempmin, tempmax; - INIT_MINMAX2(tempmin, tempmax); - for (const float2 &p : points) { - math::min_max(p * rot_mat, tempmin, tempmax); - } - - const float2 size_result = tempmax - tempmin; - float area_input = size[0] * size[1]; - float area_result = size_result[0] * size_result[1]; - EXPECT_LE(area_result, area_input + 1e-6f); - } -} - -/** \} */ diff --git a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc index 25541cc197e..5e4cf2fd167 100644 --- a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc +++ b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc @@ -1877,9 +1877,9 @@ void text_test( } in.epsilon = b_before_arcs_in.epsilon; in.need_ids = need_ids; - double tstart = BLI_time_now_seconds(); + double tstart = BLI_check_seconds_timer(); CDT_result out = delaunay_2d_calc(in, otype); - double tend = BLI_time_now_seconds(); + double tend = BLI_check_seconds_timer(); if (print_timing) { std::cout << "time = " << tend - tstart << "\n"; } @@ -2190,10 +2190,10 @@ void rand_delaunay_test(int test_kind, } /* Run the test. */ - double tstart = BLI_time_now_seconds(); + double tstart = BLI_check_seconds_timer(); CDT_result out = delaunay_2d_calc(in, otype); EXPECT_NE(out.vert.size(), 0); - times[lg_size] += BLI_time_now_seconds() - tstart; + times[lg_size] += BLI_check_seconds_timer() - tstart; if (DO_DRAW) { graph_draw(test_label, out.vert, out.edge, out.face); } diff --git a/source/blender/blenlib/tests/BLI_disjoint_set_test.cc b/source/blender/blenlib/tests/BLI_disjoint_set_test.cc index 93e0b2e907d..2de71465530 100644 --- a/source/blender/blenlib/tests/BLI_disjoint_set_test.cc +++ b/source/blender/blenlib/tests/BLI_disjoint_set_test.cc @@ -2,11 +2,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "testing/testing.h" - #include "BLI_disjoint_set.hh" +#include "BLI_strict_flags.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "testing/testing.h" namespace blender::tests { diff --git a/source/blender/blenlib/tests/BLI_index_mask_test.cc b/source/blender/blenlib/tests/BLI_index_mask_test.cc index b09e83e18e0..d3d2fa073f3 100644 --- a/source/blender/blenlib/tests/BLI_index_mask_test.cc +++ b/source/blender/blenlib/tests/BLI_index_mask_test.cc @@ -2,15 +2,14 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "testing/testing.h" - #include "BLI_array.hh" #include "BLI_index_mask.hh" #include "BLI_rand.hh" #include "BLI_set.hh" +#include "BLI_strict_flags.h" #include "BLI_timeit.hh" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "testing/testing.h" namespace blender::index_mask::tests { @@ -24,7 +23,6 @@ TEST(index_mask, IndicesToMask) EXPECT_EQ(mask.first(), 5); EXPECT_EQ(mask.last(), 101000); EXPECT_EQ(mask.min_array_size(), 101001); - EXPECT_EQ(mask.bounds(), IndexRange(5, 101001 - 5)); } TEST(index_mask, FromBits) @@ -53,7 +51,6 @@ TEST(index_mask, FromSize) EXPECT_EQ(mask.first(), 0); EXPECT_EQ(mask.last(), 4); EXPECT_EQ(mask.min_array_size(), 5); - EXPECT_EQ(mask.bounds(), IndexRange(5)); } { const IndexMask mask(max_segment_size); @@ -64,7 +61,6 @@ TEST(index_mask, FromSize) EXPECT_EQ(mask.first(), 0); EXPECT_EQ(mask.last(), max_segment_size - 1); EXPECT_EQ(mask.min_array_size(), max_segment_size); - EXPECT_EQ(mask.bounds(), IndexRange(max_segment_size)); } } @@ -109,7 +105,6 @@ TEST(index_mask, DefaultConstructor) IndexMask mask; EXPECT_EQ(mask.size(), 0); EXPECT_EQ(mask.min_array_size(), 0); - EXPECT_EQ(mask.bounds(), IndexRange()); } TEST(index_mask, ForeachRange) @@ -458,398 +453,4 @@ TEST(index_mask, SliceContent) } } -TEST(index_mask, EqualsRangeSelf) -{ - IndexMask mask = IndexRange(16384); - EXPECT_EQ(mask, mask); -} - -TEST(index_mask, EqualsRange) -{ - IndexMask mask_a = IndexRange(16384); - IndexMask mask_b = IndexRange(16384); - EXPECT_EQ(mask_a, mask_b); -} - -TEST(index_mask, EqualsRangeLarge) -{ - IndexMask mask_a = IndexRange(96384); - IndexMask mask_b = IndexRange(96384); - EXPECT_EQ(mask_a, mask_b); -} - -TEST(index_mask, EqualsRangeBegin) -{ - IndexMask mask_a = IndexRange(102, 16384 - 102); - IndexMask mask_b = IndexRange(102, 16384 - 102); - EXPECT_EQ(mask_a, mask_b); -} - -TEST(index_mask, EqualsRangeEnd) -{ - IndexMask mask_a = IndexRange(16384 + 1); - IndexMask mask_b = IndexRange(16384 + 1); - EXPECT_EQ(mask_a, mask_b); -} - -TEST(index_mask, NonEqualsRange) -{ - IndexMask mask_a = IndexRange(16384); - IndexMask mask_b = IndexRange(1, 16384); - EXPECT_NE(mask_a, mask_b); -} - -TEST(index_mask, EqualsSelf) -{ - IndexMaskMemory memory; - IndexMask mask = IndexMask::from_union(IndexRange(16384), IndexRange(16384 * 3, 533), memory); - EXPECT_EQ(mask, mask); -} - -TEST(index_mask, Equals) -{ - IndexMaskMemory memory; - IndexMask mask_a = IndexMask::from_union(IndexRange(16384), IndexRange(16384 * 3, 533), memory); - IndexMask mask_b = IndexMask::from_union(IndexRange(16384), IndexRange(16384 * 3, 533), memory); - EXPECT_EQ(mask_a, mask_b); -} - -TEST(index_mask, NonEquals) -{ - IndexMaskMemory memory; - IndexMask mask_a = IndexMask::from_union(IndexRange(16384), IndexRange(16384 * 3, 533), memory); - IndexMask mask_b = IndexMask::from_union( - IndexRange(55, 16384), IndexRange(16384 * 5, 533), memory); - EXPECT_NE(mask_a, mask_b); -} - -TEST(index_mask, NotEqualsRangeAndIndices) -{ - IndexMaskMemory memory; - IndexMask mask_a = IndexMask::from_union( - IndexRange(2040), IndexMask::from_indices({2072, 2073, 2075}, memory), memory); - IndexMask mask_b = IndexMask::from_union( - IndexRange(2040), IndexMask::from_indices({2072, 2073 + 1, 2075}, memory), memory); - - EXPECT_NE(mask_a, mask_b); -} - -static bool mask_segments_equals(const IndexMaskSegment &a, const IndexMaskSegment &b) -{ - if (a.size() != b.size()) { - return false; - } - for (const int64_t i : a.index_range()) { - if (a[i] != b[i]) { - return false; - } - } - return true; -} - -TEST(index_mask, ZippedForeachSelf) -{ - IndexMaskMemory memory; - IndexMask mask = IndexMask::from_initializers({IndexRange(500), 555, 699, 222, 900, 100}, - memory); - { - int calls_num = 0; - IndexMask::foreach_segment_zipped({mask}, [&](Span segments) { - EXPECT_FALSE(segments.is_empty()); - calls_num++; - return true; - }); - EXPECT_EQ(calls_num, 2); - } - - { - int calls_num = 0; - IndexMask::foreach_segment_zipped({mask, mask}, [&](Span segments) { - EXPECT_FALSE(segments.is_empty()); - EXPECT_TRUE(mask_segments_equals(segments[0], segments[1])); - calls_num++; - return true; - }); - EXPECT_EQ(calls_num, 2); - } - - { - int calls_num = 0; - IndexMask::foreach_segment_zipped({mask, mask, mask}, [&](Span segments) { - EXPECT_FALSE(segments.is_empty()); - EXPECT_TRUE(mask_segments_equals(segments[0], segments[1])); - EXPECT_TRUE(mask_segments_equals(segments[0], segments[2])); - calls_num++; - return true; - }); - EXPECT_EQ(calls_num, 2); - } - - { - int calls_num = 0; - IndexMask::foreach_segment_zipped( - {mask, mask, mask, mask}, [&](Span segments) { - EXPECT_FALSE(segments.is_empty()); - EXPECT_TRUE(mask_segments_equals(segments[0], segments[1])); - EXPECT_TRUE(mask_segments_equals(segments[0], segments[2])); - EXPECT_TRUE(mask_segments_equals(segments[0], segments[3])); - calls_num++; - return true; - }); - EXPECT_EQ(calls_num, 2); - } -} - -TEST(index_mask, ZippedForeachSameSegments) -{ - IndexMaskMemory memory; - IndexMask mask_a = IndexMask::from_initializers({0, 1, 2}, memory); - IndexMask mask_b = IndexMask::from_initializers({3, 4, 5}, memory); - IndexMask mask_c = IndexMask::from_initializers({6, 7, 8}, memory); - { - int calls_num = 0; - IndexMask::foreach_segment_zipped({mask_a}, [&](Span segments) { - EXPECT_FALSE(segments.is_empty()); - calls_num++; - return true; - }); - EXPECT_EQ(calls_num, 1); - } - { - int calls_num = 0; - IndexMask::foreach_segment_zipped({mask_a, mask_b}, [&](Span segments) { - EXPECT_FALSE(segments.is_empty()); - EXPECT_EQ(segments[0].size(), segments[1].size()); - EXPECT_FALSE(mask_segments_equals(segments[0], segments[1])); - calls_num++; - return true; - }); - EXPECT_EQ(calls_num, 1); - } - { - int calls_num = 0; - IndexMask::foreach_segment_zipped( - {mask_a, mask_b, mask_c}, [&](Span segments) { - EXPECT_FALSE(segments.is_empty()); - EXPECT_EQ(segments[0].size(), segments[1].size()); - EXPECT_EQ(segments[0].size(), segments[2].size()); - EXPECT_FALSE(mask_segments_equals(segments[0], segments[1])); - EXPECT_FALSE(mask_segments_equals(segments[0], segments[2])); - EXPECT_FALSE(mask_segments_equals(segments[1], segments[2])); - calls_num++; - return true; - }); - EXPECT_EQ(calls_num, 1); - } -} - -TEST(index_mask, ZippedForeachEqual) -{ - Span indices(get_static_indices_array()); - - IndexMaskMemory memory; - IndexMask mask_a = IndexMask::from_segments( - {{0, indices.take_front(5)}, {5, indices.take_front(5)}}, memory); - IndexMask mask_b = IndexMask::from_segments( - {{0, indices.take_front(3)}, {3, indices.take_front(4)}, {7, indices.take_front(3)}}, - memory); - IndexMask mask_c = IndexMask::from_segments({{0, indices.take_front(10)}}, memory); - - int index = 0; - Array reference_segments{{0, indices.take_front(3)}, - {3, indices.take_front(2)}, - {5, indices.take_front(2)}, - {7, indices.take_front(3)}}; - - IndexMask::foreach_segment_zipped( - {mask_a, mask_b, mask_c}, [&](Span segments) { - EXPECT_TRUE(mask_segments_equals(reference_segments[index], segments[0])); - EXPECT_TRUE(mask_segments_equals(reference_segments[index], segments[1])); - EXPECT_TRUE(mask_segments_equals(reference_segments[index], segments[2])); - index++; - return true; - }); - EXPECT_EQ(index, 4); -} - -TEST(index_mask, FromRepeatingEmpty) -{ - IndexMaskMemory memory; - const IndexMask mask = IndexMask::from_repeating(IndexMask(), 100, 0, 10, memory); - EXPECT_TRUE(mask.is_empty()); -} - -TEST(index_mask, FromRepeatingSingle) -{ - IndexMaskMemory memory; - const IndexMask mask = IndexMask::from_repeating(IndexMask(1), 5, 10, 2, memory); - EXPECT_EQ(mask, IndexMask::from_initializers({2, 12, 22, 32, 42}, memory)); -} - -TEST(index_mask, FromRepeatingSame) -{ - IndexMaskMemory memory; - const IndexMask mask = IndexMask::from_indices({4, 6, 7}, memory); - const IndexMask repeated_mask = IndexMask::from_repeating(mask, 1, 100, 0, memory); - EXPECT_EQ(mask, repeated_mask); -} - -TEST(index_mask, FromRepeatingMultiple) -{ - IndexMaskMemory memory; - const IndexMask mask = IndexMask::from_repeating( - IndexMask::from_indices({5, 6, 7, 50}, memory), 3, 100, 1000, memory); - EXPECT_EQ(mask[0], 1005); - EXPECT_EQ(mask[1], 1006); - EXPECT_EQ(mask[2], 1007); - EXPECT_EQ(mask[3], 1050); - EXPECT_EQ(mask[4], 1105); - EXPECT_EQ(mask[5], 1106); - EXPECT_EQ(mask[6], 1107); - EXPECT_EQ(mask[7], 1150); - EXPECT_EQ(mask[8], 1205); - EXPECT_EQ(mask[9], 1206); - EXPECT_EQ(mask[10], 1207); - EXPECT_EQ(mask[11], 1250); -} - -TEST(index_mask, FromRepeatingRangeFromSingle) -{ - IndexMaskMemory memory; - const IndexMask mask = IndexMask::from_repeating(IndexMask(IndexRange(1)), 50'000, 1, 0, memory); - EXPECT_EQ(*mask.to_range(), IndexRange(50'000)); -} - -TEST(index_mask, FromRepeatingRangeFromRange) -{ - IndexMaskMemory memory; - const IndexMask mask = IndexMask::from_repeating( - IndexMask(IndexRange(100)), 50'000, 100, 100, memory); - EXPECT_EQ(*mask.to_range(), IndexRange(100, 5'000'000)); -} - -TEST(index_mask, FromRepeatingEverySecond) -{ - IndexMaskMemory memory; - const IndexMask mask = IndexMask::from_repeating(IndexMask(1), 500'000, 2, 0, memory); - EXPECT_EQ(mask[0], 0); - EXPECT_EQ(mask[1], 2); - EXPECT_EQ(mask[2], 4); - EXPECT_EQ(mask[3], 6); - EXPECT_EQ(mask[20'000], 40'000); -} - -TEST(index_mask, FromRepeatingMultipleRanges) -{ - IndexMaskMemory memory; - const IndexMask mask = IndexMask::from_repeating( - IndexMask::from_initializers({IndexRange(0, 100), IndexRange(10'000, 100)}, memory), - 5, - 100'000, - 0, - memory); - EXPECT_EQ(mask[0], 0); - EXPECT_EQ(mask[1], 1); - EXPECT_EQ(mask[2], 2); - EXPECT_EQ(mask[100], 10'000); - EXPECT_EQ(mask[101], 10'001); - EXPECT_EQ(mask[102], 10'002); - EXPECT_EQ(mask[200], 100'000); - EXPECT_EQ(mask[201], 100'001); - EXPECT_EQ(mask[202], 100'002); - EXPECT_EQ(mask[300], 110'000); - EXPECT_EQ(mask[301], 110'001); - EXPECT_EQ(mask[302], 110'002); -} - -TEST(index_mask, FromRepeatingNoRepetitions) -{ - IndexMaskMemory memory; - const IndexMask mask = IndexMask::from_repeating(IndexMask(IndexRange(5)), 0, 100, 0, memory); - EXPECT_TRUE(mask.is_empty()); -} - -TEST(index_mask, FromEveryNth) -{ - IndexMaskMemory memory; - { - const IndexMask mask = IndexMask::from_every_nth(2, 5, 0, memory); - EXPECT_EQ(mask, IndexMask::from_initializers({0, 2, 4, 6, 8}, memory)); - } - { - const IndexMask mask = IndexMask::from_every_nth(3, 5, 100, memory); - EXPECT_EQ(mask, IndexMask::from_initializers({100, 103, 106, 109, 112}, memory)); - } - { - const IndexMask mask = IndexMask::from_every_nth(4, 5, 0, memory); - EXPECT_EQ(mask, IndexMask::from_initializers({0, 4, 8, 12, 16}, memory)); - } - { - const IndexMask mask = IndexMask::from_every_nth(10, 5, 100, memory); - EXPECT_EQ(mask, IndexMask::from_initializers({100, 110, 120, 130, 140}, memory)); - } - { - const IndexMask mask = IndexMask::from_every_nth(1, 5, 100, memory); - EXPECT_EQ(mask, IndexMask::from_initializers({100, 101, 102, 103, 104}, memory)); - } - { - const IndexMask mask = IndexMask::from_every_nth(100'000, 5, 0, memory); - EXPECT_EQ(mask, IndexMask::from_initializers({0, 100'000, 200'000, 300'000, 400'000}, memory)); - } -} - -TEST(index_mask, Shift) -{ - IndexMaskMemory memory; - { - const IndexMask mask; - const IndexMask shifted_mask = mask.shift(10, memory); - EXPECT_TRUE(shifted_mask.is_empty()); - EXPECT_EQ(mask, shifted_mask); - } - { - const IndexMask mask{IndexRange(100, 10)}; - const IndexMask shifted_mask = mask.shift(1000, memory); - EXPECT_EQ(shifted_mask.size(), 10); - EXPECT_EQ(shifted_mask[0], 1100); - EXPECT_EQ(shifted_mask[9], 1109); - } - { - const IndexMask mask = IndexMask::from_initializers({4, 6, 7, IndexRange(100, 100)}, memory); - const IndexMask shifted_mask = mask.shift(1000, memory).shift(-1000, memory); - EXPECT_EQ(mask, shifted_mask); - } - { - const IndexMask mask{IndexRange(100, 10)}; - const IndexMask shifted_mask = mask.shift(0, memory); - EXPECT_EQ(mask, shifted_mask); - } -} - -TEST(index_mask, SliceAndShift) -{ - IndexMaskMemory memory; - { - const IndexMask mask{IndexRange(100, 10)}; - const IndexMask new_mask = mask.slice_and_shift(5, 5, 1000, memory); - EXPECT_EQ(new_mask.size(), 5); - EXPECT_EQ(new_mask[0], 1105); - EXPECT_EQ(new_mask[1], 1106); - } - { - const IndexMask mask = IndexMask::from_indices({10, 100, 1'000, 10'000, 100'000}, memory); - const IndexMask new_mask = mask.slice_and_shift(IndexRange(1, 4), -100, memory); - EXPECT_EQ(new_mask.size(), 4); - EXPECT_EQ(new_mask[0], 0); - EXPECT_EQ(new_mask[1], 900); - EXPECT_EQ(new_mask[2], 9'900); - EXPECT_EQ(new_mask[3], 99'900); - } - { - const IndexMask mask = IndexMask::from_indices({10, 100}, memory); - const IndexMask new_mask = mask.slice_and_shift(1, 0, 100, memory); - EXPECT_TRUE(new_mask.is_empty()); - } -} - } // namespace blender::index_mask::tests diff --git a/source/blender/blenlib/tests/BLI_index_range_test.cc b/source/blender/blenlib/tests/BLI_index_range_test.cc index 4241b1fe4b7..57dc9f7bb02 100644 --- a/source/blender/blenlib/tests/BLI_index_range_test.cc +++ b/source/blender/blenlib/tests/BLI_index_range_test.cc @@ -2,12 +2,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "testing/testing.h" - #include "BLI_index_range.hh" +#include "BLI_strict_flags.h" #include "BLI_vector.hh" - -#include "BLI_strict_flags.h" /* Keep last. */ +#include "testing/testing.h" namespace blender::tests { diff --git a/source/blender/blenlib/tests/BLI_linear_allocator_test.cc b/source/blender/blenlib/tests/BLI_linear_allocator_test.cc index 92292901a41..8701fb301d5 100644 --- a/source/blender/blenlib/tests/BLI_linear_allocator_test.cc +++ b/source/blender/blenlib/tests/BLI_linear_allocator_test.cc @@ -2,12 +2,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "testing/testing.h" - #include "BLI_linear_allocator.hh" #include "BLI_rand.hh" - -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" +#include "testing/testing.h" namespace blender::tests { diff --git a/source/blender/blenlib/tests/BLI_map_test.cc b/source/blender/blenlib/tests/BLI_map_test.cc index 43a2ce1b04b..d9b31ea7d16 100644 --- a/source/blender/blenlib/tests/BLI_map_test.cc +++ b/source/blender/blenlib/tests/BLI_map_test.cc @@ -5,16 +5,15 @@ #include #include -#include "testing/testing.h" - #include "BLI_exception_safety_test_utils.hh" #include "BLI_map.hh" #include "BLI_rand.h" #include "BLI_set.hh" +#include "BLI_strict_flags.h" #include "BLI_timeit.hh" #include "BLI_vector.hh" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "testing/testing.h" namespace blender::tests { diff --git a/source/blender/blenlib/tests/BLI_math_interp_test.cc b/source/blender/blenlib/tests/BLI_math_interp_test.cc index fa09dcdc884..0ce66170467 100644 --- a/source/blender/blenlib/tests/BLI_math_interp_test.cc +++ b/source/blender/blenlib/tests/BLI_math_interp_test.cc @@ -13,7 +13,7 @@ using namespace blender::math; static constexpr float float_tolerance = 0.00005f; static constexpr int image_width = 3; static constexpr int image_height = 3; -static constexpr uchar image_char[image_height][image_width][4] = { +static constexpr unsigned char image_char[image_height][image_width][4] = { {{255, 254, 217, 216}, {230, 230, 230, 230}, {240, 160, 90, 20}}, {{0, 1, 2, 3}, {62, 72, 82, 92}, {126, 127, 128, 129}}, {{1, 2, 3, 4}, {73, 108, 153, 251}, {128, 129, 130, 131}}, diff --git a/source/blender/blenlib/tests/BLI_memory_utils_test.cc b/source/blender/blenlib/tests/BLI_memory_utils_test.cc index b4716b55fcb..c6fa3bbd000 100644 --- a/source/blender/blenlib/tests/BLI_memory_utils_test.cc +++ b/source/blender/blenlib/tests/BLI_memory_utils_test.cc @@ -2,12 +2,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "testing/testing.h" - #include "BLI_math_vector_types.hh" #include "BLI_memory_utils.hh" - -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" +#include "testing/testing.h" namespace blender::tests { diff --git a/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc b/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc index 22b3d0f702b..de51be79de8 100644 --- a/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc +++ b/source/blender/blenlib/tests/BLI_mesh_intersect_test.cc @@ -980,7 +980,7 @@ static void spheresphere_test(int nrings, double y_offset, bool use_self) return; } BLI_task_scheduler_init(); /* Without this, no parallelism. */ - double time_start = BLI_time_now_seconds(); + double time_start = BLI_check_seconds_timer(); IMeshArena arena; int nsegs = 2 * nrings; int sphere_verts_num; @@ -1009,7 +1009,7 @@ static void spheresphere_test(int nrings, double y_offset, bool use_self) sphere_verts_num, &arena); IMesh mesh(tris); - double time_create = BLI_time_now_seconds(); + double time_create = BLI_check_seconds_timer(); // write_obj_mesh(mesh, "spheresphere_in"); IMesh out; if (use_self) { @@ -1020,7 +1020,7 @@ static void spheresphere_test(int nrings, double y_offset, bool use_self) out = trimesh_nary_intersect( mesh, 2, [nf](int t) { return t < nf ? 0 : 1; }, false, &arena); } - double time_intersect = BLI_time_now_seconds(); + double time_intersect = BLI_check_seconds_timer(); std::cout << "Create time: " << time_create - time_start << "\n"; std::cout << "Intersect time: " << time_intersect - time_create << "\n"; std::cout << "Total time: " << time_intersect - time_start << "\n"; @@ -1120,7 +1120,7 @@ static void spheregrid_test(int nrings, int grid_level, double z_offset, bool us return; } BLI_task_scheduler_init(); /* Without this, no parallelism. */ - double time_start = BLI_time_now_seconds(); + double time_start = BLI_check_seconds_timer(); IMeshArena arena; int sphere_verts_num; int sphere_tris_num; @@ -1154,7 +1154,7 @@ static void spheregrid_test(int nrings, int grid_level, double z_offset, bool us sphere_tris_num, &arena); IMesh mesh(tris); - double time_create = BLI_time_now_seconds(); + double time_create = BLI_check_seconds_timer(); // write_obj_mesh(mesh, "spheregrid_in"); IMesh out; if (use_self) { @@ -1165,7 +1165,7 @@ static void spheregrid_test(int nrings, int grid_level, double z_offset, bool us out = trimesh_nary_intersect( mesh, 2, [nf](int t) { return t < nf ? 0 : 1; }, false, &arena); } - double time_intersect = BLI_time_now_seconds(); + double time_intersect = BLI_check_seconds_timer(); std::cout << "Create time: " << time_create - time_start << "\n"; std::cout << "Intersect time: " << time_intersect - time_create << "\n"; std::cout << "Total time: " << time_intersect - time_start << "\n"; @@ -1187,7 +1187,7 @@ static void gridgrid_test(int x_level_1, /* Make two grids, each 4x4, with given subdivision levels in x and y, * and the second offset from the first by x_off, y_off, and rotated by rot_deg degrees. */ BLI_task_scheduler_init(); /* Without this, no parallelism. */ - double time_start = BLI_time_now_seconds(); + double time_start = BLI_check_seconds_timer(); IMeshArena arena; int x_subdivs_1 = 1 << x_level_1; int y_subdivs_1 = 1 << y_level_1; @@ -1223,7 +1223,7 @@ static void gridgrid_test(int x_level_1, grid_tris_1_num, &arena); IMesh mesh(tris); - double time_create = BLI_time_now_seconds(); + double time_create = BLI_check_seconds_timer(); // write_obj_mesh(mesh, "gridgrid_in"); IMesh out; if (use_self) { @@ -1234,7 +1234,7 @@ static void gridgrid_test(int x_level_1, out = trimesh_nary_intersect( mesh, 2, [nf](int t) { return t < nf ? 0 : 1; }, false, &arena); } - double time_intersect = BLI_time_now_seconds(); + double time_intersect = BLI_check_seconds_timer(); std::cout << "Create time: " << time_create - time_start << "\n"; std::cout << "Intersect time: " << time_intersect - time_create << "\n"; std::cout << "Total time: " << time_intersect - time_start << "\n"; diff --git a/source/blender/blenlib/tests/BLI_pool_test.cc b/source/blender/blenlib/tests/BLI_pool_test.cc index 5ed775d300a..f00a56be569 100644 --- a/source/blender/blenlib/tests/BLI_pool_test.cc +++ b/source/blender/blenlib/tests/BLI_pool_test.cc @@ -2,12 +2,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "testing/testing.h" - #include "BLI_exception_safety_test_utils.hh" #include "BLI_pool.hh" - -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" +#include "testing/testing.h" namespace blender::tests { diff --git a/source/blender/blenlib/tests/BLI_random_access_iterator_mixin_test.cc b/source/blender/blenlib/tests/BLI_random_access_iterator_mixin_test.cc deleted file mode 100644 index 2de8d82ff2b..00000000000 --- a/source/blender/blenlib/tests/BLI_random_access_iterator_mixin_test.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* SPDX-FileCopyrightText: 2024 Blender Authors - * - * SPDX-License-Identifier: Apache-2.0 */ - -#include - -#include "testing/testing.h" - -#include "BLI_random_access_iterator_mixin.hh" -#include "BLI_vector.hh" - -namespace blender::iterator::tests { - -template -struct DoublingIterator : public RandomAccessIteratorMixin> { - private: - const T *data_; - - public: - DoublingIterator(const T *data) : data_(data) {} - - T operator*() const - { - return *data_ * 2; - } - - const T *const &iter_prop() const - { - return data_; - } -}; - -TEST(random_access_iterator_mixin, DoublingIterator) -{ - std::array my_array = {3, 6, 1, 2}; - - const DoublingIterator begin = DoublingIterator(&*my_array.begin()); - const DoublingIterator end = begin + my_array.size(); - - Vector values; - for (DoublingIterator it = begin; it != end; ++it) { - values.append(*it); - } - - EXPECT_EQ(values.size(), 4); - EXPECT_EQ(values[0], 6); - EXPECT_EQ(values[1], 12); - EXPECT_EQ(values[2], 2); - EXPECT_EQ(values[3], 4); -} - -} // namespace blender::iterator::tests diff --git a/source/blender/blenlib/tests/BLI_set_test.cc b/source/blender/blenlib/tests/BLI_set_test.cc index ee4b9a73ded..082c83f7d4f 100644 --- a/source/blender/blenlib/tests/BLI_set_test.cc +++ b/source/blender/blenlib/tests/BLI_set_test.cc @@ -5,16 +5,14 @@ #include #include -#include "testing/testing.h" - #include "BLI_exception_safety_test_utils.hh" #include "BLI_ghash.h" #include "BLI_rand.h" #include "BLI_set.hh" +#include "BLI_strict_flags.h" #include "BLI_timeit.hh" #include "BLI_vector.hh" - -#include "BLI_strict_flags.h" /* Keep last. */ +#include "testing/testing.h" namespace blender { namespace tests { diff --git a/source/blender/blenlib/tests/BLI_span_test.cc b/source/blender/blenlib/tests/BLI_span_test.cc index fbb964af730..1b98842b819 100644 --- a/source/blender/blenlib/tests/BLI_span_test.cc +++ b/source/blender/blenlib/tests/BLI_span_test.cc @@ -2,12 +2,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "testing/testing.h" - #include "BLI_span.hh" +#include "BLI_strict_flags.h" #include "BLI_vector.hh" - -#include "BLI_strict_flags.h" /* Keep last. */ +#include "testing/testing.h" namespace blender::tests { diff --git a/source/blender/blenlib/tests/BLI_stack_cxx_test.cc b/source/blender/blenlib/tests/BLI_stack_cxx_test.cc index 4461b8bed54..cb8e17ca52f 100644 --- a/source/blender/blenlib/tests/BLI_stack_cxx_test.cc +++ b/source/blender/blenlib/tests/BLI_stack_cxx_test.cc @@ -2,13 +2,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "testing/testing.h" - #include "BLI_exception_safety_test_utils.hh" #include "BLI_stack.hh" +#include "BLI_strict_flags.h" #include "BLI_vector.hh" - -#include "BLI_strict_flags.h" /* Keep last. */ +#include "testing/testing.h" namespace blender::tests { diff --git a/source/blender/blenlib/tests/BLI_string_ref_test.cc b/source/blender/blenlib/tests/BLI_string_ref_test.cc index a59714de08c..2f89c9e37e6 100644 --- a/source/blender/blenlib/tests/BLI_string_ref_test.cc +++ b/source/blender/blenlib/tests/BLI_string_ref_test.cc @@ -2,13 +2,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ +#include "BLI_strict_flags.h" #include "BLI_string_ref.hh" #include "BLI_vector.hh" - #include "testing/testing.h" -#include "BLI_strict_flags.h" /* Keep last. */ - namespace blender::tests { TEST(string_ref_null, DefaultConstructor) diff --git a/source/blender/blenlib/tests/BLI_vector_set_test.cc b/source/blender/blenlib/tests/BLI_vector_set_test.cc index f171ea8d388..7c434830a27 100644 --- a/source/blender/blenlib/tests/BLI_vector_set_test.cc +++ b/source/blender/blenlib/tests/BLI_vector_set_test.cc @@ -3,12 +3,10 @@ * SPDX-License-Identifier: Apache-2.0 */ #include "BLI_exception_safety_test_utils.hh" +#include "BLI_strict_flags.h" #include "BLI_vector_set.hh" - #include "testing/testing.h" -#include "BLI_strict_flags.h" /* Keep last. */ - namespace blender::tests { TEST(vector_set, DefaultConstructor) diff --git a/source/blender/blenlib/tests/BLI_vector_test.cc b/source/blender/blenlib/tests/BLI_vector_test.cc index ab30ebb5b38..18eccce0c1a 100644 --- a/source/blender/blenlib/tests/BLI_vector_test.cc +++ b/source/blender/blenlib/tests/BLI_vector_test.cc @@ -3,12 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ #include "BLI_exception_safety_test_utils.hh" +#include "BLI_strict_flags.h" #include "BLI_vector.hh" #include "testing/testing.h" #include -#include "BLI_strict_flags.h" /* Keep last. */ - namespace blender::tests { TEST(vector, DefaultConstructor) diff --git a/source/blender/blenlib/tests/BLI_virtual_array_test.cc b/source/blender/blenlib/tests/BLI_virtual_array_test.cc index 397037822f3..2f4f5093584 100644 --- a/source/blender/blenlib/tests/BLI_virtual_array_test.cc +++ b/source/blender/blenlib/tests/BLI_virtual_array_test.cc @@ -4,13 +4,12 @@ #include "BLI_array.hh" #include "BLI_generic_virtual_array.hh" +#include "BLI_strict_flags.h" #include "BLI_vector.hh" #include "BLI_vector_set.hh" #include "BLI_virtual_array.hh" #include "testing/testing.h" -#include "BLI_strict_flags.h" /* Keep last. */ - namespace blender::tests { TEST(virtual_array, Span) diff --git a/source/blender/blenloader/BLO_readfile.hh b/source/blender/blenloader/BLO_readfile.h similarity index 75% rename from source/blender/blenloader/BLO_readfile.hh rename to source/blender/blenloader/BLO_readfile.h index 192455b0943..3d3f9dea74b 100644 --- a/source/blender/blenloader/BLO_readfile.hh +++ b/source/blender/blenloader/BLO_readfile.h @@ -11,18 +11,17 @@ * \brief external readfile function prototypes. */ -struct AssetMetaData; +#ifdef __cplusplus +extern "C" { +#endif + struct BHead; -struct BlendHandle; struct BlendThumbnail; struct FileData; -struct ID; -struct Library; struct LinkNode; struct ListBase; struct Main; struct MemFile; -struct PreviewImage; struct ReportList; struct Scene; struct UserDef; @@ -32,11 +31,13 @@ struct WorkSpace; struct bScreen; struct wmWindowManager; -struct WorkspaceConfigFileData { - Main *main; /* has to be freed when done reading file data */ +typedef struct BlendHandle BlendHandle; - ListBase workspaces; -}; +typedef struct WorkspaceConfigFileData { + struct Main *main; /* has to be freed when done reading file data */ + + struct ListBase workspaces; +} WorkspaceConfigFileData; /* -------------------------------------------------------------------- */ /** \name BLO Read File API @@ -44,15 +45,15 @@ struct WorkspaceConfigFileData { * \see #BLO_write_file for file writing. * \{ */ -enum eBlenFileType { +typedef enum eBlenFileType { BLENFILETYPE_BLEND = 1, // BLENFILETYPE_PUB = 2, /* UNUSED */ // BLENFILETYPE_RUNTIME = 3, /* UNUSED */ -}; +} eBlenFileType; -struct BlendFileData { - Main *main; - UserDef *user; +typedef struct BlendFileData { + struct Main *main; + struct UserDef *user; int fileflags; int globalf; @@ -64,27 +65,27 @@ struct BlendFileData { char filepath[1024]; /* 1024 = FILE_MAX */ /** TODO: think this isn't needed anymore? */ - bScreen *curscreen; - Scene *curscene; + struct bScreen *curscreen; + struct Scene *curscene; /** Layer to activate in workspaces when reading without UI. */ - ViewLayer *cur_view_layer; + struct ViewLayer *cur_view_layer; eBlenFileType type; -}; +} BlendFileData; /** * Data used by WM readfile code and BKE's setup_app_data to handle the complex preservation logic * of WindowManager and other UI data-blocks across blend-file reading process. */ -struct BlendFileReadWMSetupData { - /** The existing WM when file-reading process is started. */ - wmWindowManager *old_wm; +typedef struct BlendFileReadWMSetupData { + /** The existing WM when filereading process is started. */ + struct wmWindowManager *old_wm; /** The startup file is being read. */ bool is_read_homefile; /** The factory startup file is being read. */ bool is_factory_startup; -}; +} BlendFileReadWMSetupData; struct BlendFileReadParams { uint skip_flags : 3; /* #eBLOReadSkip */ @@ -94,9 +95,9 @@ struct BlendFileReadParams { int undo_direction; /* #eUndoStepDir */ }; -struct BlendFileReadReport { +typedef struct BlendFileReadReport { /** General reports handling. */ - ReportList *reports; + struct ReportList *reports; /** Timing information. */ struct { @@ -136,11 +137,11 @@ struct BlendFileReadReport { */ int resynced_lib_overrides_libraries_count; bool do_resynced_lib_overrides_libraries_list; - LinkNode *resynced_lib_overrides_libraries; -}; + struct LinkNode *resynced_lib_overrides_libraries; +} BlendFileReadReport; /** Skip reading some data-block types (may want to skip screen data too). */ -enum eBLOReadSkip { +typedef enum eBLOReadSkip { BLO_READ_SKIP_NONE = 0, /** Skip #BLO_CODE_USER blocks. */ BLO_READ_SKIP_USERDEF = (1 << 0), @@ -148,7 +149,7 @@ enum eBLOReadSkip { BLO_READ_SKIP_DATA = (1 << 1), /** Do not attempt to re-use IDs from old bmain for unchanged ones in case of undo. */ BLO_READ_SKIP_UNDO_OLD_MAIN = (1 << 2), -}; +} eBLOReadSkip; ENUM_OPERATORS(eBLOReadSkip, BLO_READ_SKIP_UNDO_OLD_MAIN) #define BLO_READ_SKIP_ALL (BLO_READ_SKIP_USERDEF | BLO_READ_SKIP_DATA) @@ -162,7 +163,7 @@ ENUM_OPERATORS(eBLOReadSkip, BLO_READ_SKIP_UNDO_OLD_MAIN) */ BlendFileData *BLO_read_from_file(const char *filepath, eBLOReadSkip skip_flags, - BlendFileReadReport *reports); + struct BlendFileReadReport *reports); /** * Open a blender file from memory. The function returns NULL * and sets a report in the list if it cannot open the file. @@ -175,7 +176,7 @@ BlendFileData *BLO_read_from_file(const char *filepath, BlendFileData *BLO_read_from_memory(const void *mem, int memsize, eBLOReadSkip skip_flags, - ReportList *reports); + struct ReportList *reports); /** * Used for undo/redo, skips part of libraries reading * (assuming their data are already loaded & valid). @@ -185,11 +186,11 @@ BlendFileData *BLO_read_from_memory(const void *mem, * \param filepath: current file, only for retrieving library data. * Typically `BKE_main_blendfile_path(oldmain)`. */ -BlendFileData *BLO_read_from_memfile(Main *oldmain, +BlendFileData *BLO_read_from_memfile(struct Main *oldmain, const char *filepath, - MemFile *memfile, - const BlendFileReadParams *params, - ReportList *reports); + struct MemFile *memfile, + const struct BlendFileReadParams *params, + struct ReportList *reports); /** * Frees a BlendFileData structure and *all* the data associated with it @@ -209,7 +210,7 @@ void BLO_blendfiledata_free(BlendFileData *bfd); * * \param new_bmain: the newly read Main data-base. */ -void BLO_read_do_version_after_setup(Main *new_bmain, BlendFileReadReport *reports); +void BLO_read_do_version_after_setup(struct Main *new_bmain, struct BlendFileReadReport *reports); /** \} */ @@ -217,9 +218,9 @@ void BLO_read_do_version_after_setup(Main *new_bmain, BlendFileReadReport *repor /** \name BLO Blend File Handle API * \{ */ -struct BLODataBlockInfo { +typedef struct BLODataBlockInfo { char name[64]; /* MAX_NAME */ - AssetMetaData *asset_data; + struct AssetMetaData *asset_data; /** Ownership over #asset_data above can be "stolen out" of this struct, for more permanent * storage. In that case, set this to false to avoid double freeing of the stolen data. */ bool free_asset_data; @@ -230,7 +231,7 @@ struct BLODataBlockInfo { * either no preview was found, or that it wasn't looked for in the first place. */ bool no_preview_found; -}; +} BLODataBlockInfo; /** * Frees contained data, not \a datablock_info itself. @@ -239,7 +240,7 @@ void BLO_datablock_info_free(BLODataBlockInfo *datablock_info); /** * Can be used to free the list returned by #BLO_blendhandle_get_datablock_info(). */ -void BLO_datablock_info_linklist_free(LinkNode * /*BLODataBlockInfo*/ datablock_infos); +void BLO_datablock_info_linklist_free(struct LinkNode * /*BLODataBlockInfo*/ datablock_infos); /** * Open a blendhandle from a file path. @@ -248,7 +249,7 @@ void BLO_datablock_info_linklist_free(LinkNode * /*BLODataBlockInfo*/ datablock_ * \param reports: Report errors in opening the file (can be NULL). * \return A handle on success, or NULL on failure. */ -BlendHandle *BLO_blendhandle_from_file(const char *filepath, BlendFileReadReport *reports); +BlendHandle *BLO_blendhandle_from_file(const char *filepath, struct BlendFileReadReport *reports); /** * Open a blendhandle from memory. * @@ -258,7 +259,7 @@ BlendHandle *BLO_blendhandle_from_file(const char *filepath, BlendFileReadReport */ BlendHandle *BLO_blendhandle_from_memory(const void *mem, int memsize, - BlendFileReadReport *reports); + struct BlendFileReadReport *reports); /** * Gets the names of all the data-blocks in a file of a certain type @@ -270,11 +271,11 @@ BlendHandle *BLO_blendhandle_from_memory(const void *mem, * \param r_tot_names: The length of the returned list. * \return A BLI_linklist of strings. The string links should be freed with #MEM_freeN(). */ -LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, - int ofblocktype, +struct LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, + int ofblocktype, - bool use_assets_only, - int *r_tot_names); + bool use_assets_only, + int *r_tot_names); /** * Gets the names and asset-data (if ID is an asset) of data-blocks in a file of a certain type. * The data-blocks can be limited to assets. @@ -289,10 +290,10 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, * \note The links should be freed using #BLO_datablock_info_free() or the entire list using * #BLO_datablock_info_linklist_free(). */ -LinkNode * /*BLODataBlockInfo*/ BLO_blendhandle_get_datablock_info(BlendHandle *bh, - int ofblocktype, - bool use_assets_only, - int *r_tot_info_items); +struct LinkNode * /*BLODataBlockInfo*/ BLO_blendhandle_get_datablock_info(BlendHandle *bh, + int ofblocktype, + bool use_assets_only, + int *r_tot_info_items); /** * Gets the previews of all the data-blocks in a file of a certain type * (e.g. all the scene previews in a file). @@ -302,7 +303,7 @@ LinkNode * /*BLODataBlockInfo*/ BLO_blendhandle_get_datablock_info(BlendHandle * * \param r_tot_prev: The length of the returned list. * \return A BLI_linklist of #PreviewImage. The #PreviewImage links should be freed with malloc. */ -LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *r_tot_prev); +struct LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *r_tot_prev); /** * Get the PreviewImage of a single data block in a file. * (e.g. all the scene previews in a file). @@ -312,9 +313,9 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *r_ * \param name: Name of the block without the ID_ prefix, to read the preview image from. * \return PreviewImage or NULL when no preview Images have been found. Caller owns the returned */ -PreviewImage *BLO_blendhandle_get_preview_for_id(BlendHandle *bh, - int ofblocktype, - const char *name); +struct PreviewImage *BLO_blendhandle_get_preview_for_id(BlendHandle *bh, + int ofblocktype, + const char *name); /** * Gets the names of all the linkable data-block types available in a file. * (e.g. "Scene", "Mesh", "Light", etc.). @@ -322,7 +323,7 @@ PreviewImage *BLO_blendhandle_get_preview_for_id(BlendHandle *bh, * \param bh: The blendhandle to access. * \return A BLI_linklist of strings. The string links should be freed with #MEM_freeN(). */ -LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh); +struct LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh); /** * Close and free a blendhandle. The handle becomes invalid after this call. @@ -335,7 +336,7 @@ void BLO_blendhandle_close(BlendHandle *bh); * Mark the given Main (and the 'root' local one in case of lib-split Mains) as invalid, and * generate an error report containing given `message`. */ -void BLO_read_invalidate_message(BlendHandle *bh, Main *bmain, const char *message); +void BLO_read_invalidate_message(BlendHandle *bh, struct Main *bmain, const char *message); /** * BLI_assert-like macro to check a condition, and if `false`, fail the whole .blend reading @@ -367,7 +368,7 @@ void BLO_read_invalidate_message(BlendHandle *bh, Main *bmain, const char *messa * \note merged with 'user-level' options from operators etc. in 16 lower bits * (see #eFileSel_Params_Flag in DNA_space_types.h). */ -enum eBLOLibLinkFlags { +typedef enum eBLOLibLinkFlags { /** Generate a placeholder (empty ID) if not found in current lib file. */ BLO_LIBLINK_USE_PLACEHOLDERS = 1 << 16, /** Force loaded ID to be tagged as #LIB_TAG_INDIRECT (used in reload context only). */ @@ -388,16 +389,16 @@ enum eBLOLibLinkFlags { BLO_LIBLINK_OBDATA_INSTANCE = 1 << 24, /** Instantiate collections as empties, instead of linking them into current view layer. */ BLO_LIBLINK_COLLECTION_INSTANCE = 1 << 25, -}; +} eBLOLibLinkFlags; /** * Struct for passing arguments to * #BLO_library_link_begin, #BLO_library_link_named_part & #BLO_library_link_end. * Wrap these in parameters since it's important both functions receive matching values. */ -struct LibraryLink_Params { +typedef struct LibraryLink_Params { /** The current main database, e.g. #G_MAIN or `CTX_data_main(C)`. */ - Main *bmain; + struct Main *bmain; /** Options for linking, used for instantiating. */ int flag; /** Additional tag for #ID.tag. */ @@ -405,25 +406,25 @@ struct LibraryLink_Params { /** Context for instancing objects (optional, no instantiation will be performed when NULL). */ struct { /** The scene in which to instantiate objects/collections. */ - Scene *scene; + struct Scene *scene; /** The scene layer in which to instantiate objects/collections. */ - ViewLayer *view_layer; + struct ViewLayer *view_layer; /** The active 3D viewport (only used to define local-view). */ - const View3D *v3d; + const struct View3D *v3d; } context; -}; +} LibraryLink_Params; -void BLO_library_link_params_init(LibraryLink_Params *params, - Main *bmain, +void BLO_library_link_params_init(struct LibraryLink_Params *params, + struct Main *bmain, int flag, int id_tag_extra); -void BLO_library_link_params_init_with_context(LibraryLink_Params *params, - Main *bmain, +void BLO_library_link_params_init_with_context(struct LibraryLink_Params *params, + struct Main *bmain, int flag, int id_tag_extra, - Scene *scene, - ViewLayer *view_layer, - const View3D *v3d); + struct Scene *scene, + struct ViewLayer *view_layer, + const struct View3D *v3d); /** * Initialize the #BlendHandle for linking library data. @@ -434,9 +435,9 @@ void BLO_library_link_params_init_with_context(LibraryLink_Params *params, * \param params: Settings for linking that don't change from beginning to end of linking. * \return the library #Main, to be passed to #BLO_library_link_named_part as \a mainl. */ -Main *BLO_library_link_begin(BlendHandle **bh, - const char *filepath, - const LibraryLink_Params *params); +struct Main *BLO_library_link_begin(BlendHandle **bh, + const char *filepath, + const struct LibraryLink_Params *params); /** * Link a named data-block from an external blend file. * @@ -446,11 +447,11 @@ Main *BLO_library_link_begin(BlendHandle **bh, * \param name: The name of the data-block (without the 2 char ID prefix). * \return the linked ID when found. */ -ID *BLO_library_link_named_part(Main *mainl, - BlendHandle **bh, - short idcode, - const char *name, - const LibraryLink_Params *params); +struct ID *BLO_library_link_named_part(struct Main *mainl, + BlendHandle **bh, + short idcode, + const char *name, + const struct LibraryLink_Params *params); /** * Finalize linking from a given .blend file (library). * Optionally instance the indirect object/collection in the scene when the flags are set. @@ -460,37 +461,39 @@ ID *BLO_library_link_named_part(Main *mainl, * \param bh: The blender file handle (WARNING! may be freed by this function!). * \param params: Settings for linking that don't change from beginning to end of linking. */ -void BLO_library_link_end(Main *mainl, BlendHandle **bh, const LibraryLink_Params *params); +void BLO_library_link_end(struct Main *mainl, + BlendHandle **bh, + const struct LibraryLink_Params *params); /** * Struct for temporarily loading datablocks from a blend file. */ -struct TempLibraryContext { +typedef struct TempLibraryContext { /** Temporary main used for library data. */ - Main *bmain_lib; + struct Main *bmain_lib; /** Temporary main used to load data into (currently initialized from `real_main`). */ - Main *bmain_base; - BlendHandle *blendhandle; - BlendFileReadReport bf_reports; - LibraryLink_Params liblink_params; - Library *lib; + struct Main *bmain_base; + struct BlendHandle *blendhandle; + struct BlendFileReadReport bf_reports; + struct LibraryLink_Params liblink_params; + struct Library *lib; /** The ID datablock that was loaded. Is NULL if loading failed. */ - ID *temp_id; -}; + struct ID *temp_id; +} TempLibraryContext; -TempLibraryContext *BLO_library_temp_load_id(Main *real_main, +TempLibraryContext *BLO_library_temp_load_id(struct Main *real_main, const char *blend_file_path, short idcode, const char *idname, - ReportList *reports); + struct ReportList *reports); void BLO_library_temp_free(TempLibraryContext *temp_lib_ctx); /** \} */ -void *BLO_library_read_struct(FileData *fd, BHead *bh, const char *blockname); +void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname); -using BLOExpandDoitCallback = void (*)(void *fdhandle, Main *mainvar, void *idv); +typedef void (*BLOExpandDoitCallback)(void *fdhandle, struct Main *mainvar, void *idv); /** * Set the callback func used over all ID data found by \a BLO_expand_main func. @@ -505,7 +508,7 @@ void BLO_main_expander(BLOExpandDoitCallback expand_doit_func); * \param fdhandle: usually file-data, or own handle. May be nullptr. * \param mainvar: the Main database to expand. */ -void BLO_expand_main(void *fdhandle, Main *mainvar); +void BLO_expand_main(void *fdhandle, struct Main *mainvar); /** * Update defaults in startup.blend, without having to save and embed it. @@ -520,11 +523,11 @@ void BLO_expand_main(void *fdhandle, Main *mainvar); * Versioning the screen data can be safely skipped without "Load UI" since the screen data * will have been versioned when it was first loaded. */ -void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template); -void BLO_update_defaults_workspace(WorkSpace *workspace, const char *app_template); +void BLO_update_defaults_startup_blend(struct Main *bmain, const char *app_template); +void BLO_update_defaults_workspace(struct WorkSpace *workspace, const char *app_template); /** Disable unwanted experimental feature settings on startup. */ -void BLO_sanitize_experimental_features_userpref_blend(UserDef *userdef); +void BLO_sanitize_experimental_features_userpref_blend(struct UserDef *userdef); /** * Does a very light reading of given .blend file to extract its stored thumbnail. @@ -534,7 +537,7 @@ void BLO_sanitize_experimental_features_userpref_blend(UserDef *userdef); * (MEM-allocated, as stored in file, use #BKE_main_thumbnail_to_imbuf() * to convert it to ImBuf image). */ -BlendThumbnail *BLO_thumbnail_from_file(const char *filepath); +struct BlendThumbnail *BLO_thumbnail_from_file(const char *filepath); /** * Does a very light reading of given .blend file to extract its version. @@ -543,3 +546,12 @@ BlendThumbnail *BLO_thumbnail_from_file(const char *filepath); * \return The file version */ short BLO_version_from_file(const char *filepath); + +/** Default theme, see: `release/datafiles/userdef/userdef_default_theme.c`. */ +extern const struct bTheme U_theme_default; +/** Default preferences, defined by: `release/datafiles/userdef/userdef_default.c`. */ +extern const struct UserDef U_default; + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenloader/BLO_userdef_default.h b/source/blender/blenloader/BLO_userdef_default.h deleted file mode 100644 index be92fb8b7e3..00000000000 --- a/source/blender/blenloader/BLO_userdef_default.h +++ /dev/null @@ -1,20 +0,0 @@ -/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved. - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#pragma once - -#include "DNA_userdef_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Default theme, see: `release/datafiles/userdef/userdef_default_theme.c`. */ -extern const bTheme U_theme_default; -/** Default preferences, defined by: `release/datafiles/userdef/userdef_default.c`. */ -extern const UserDef U_default; - -#ifdef __cplusplus -} -#endif diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index 634fba706a8..1496ce79c2e 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -49,9 +49,8 @@ set(SRC BLO_blend_defs.hh BLO_blend_validate.hh BLO_read_write.hh - BLO_readfile.hh + BLO_readfile.h BLO_undofile.hh - BLO_userdef_default.h BLO_writefile.hh intern/readfile.hh intern/versioning_common.hh @@ -59,6 +58,7 @@ set(SRC set(LIB PRIVATE bf::animrig + PRIVATE bf::blenfont bf_blenkernel PRIVATE bf::blenlib PRIVATE bf::depsgraph @@ -117,7 +117,6 @@ if(WITH_GTESTS) ) set(TEST_UTIL_LIB ${LIB} - PRIVATE bf::blenfont bf_blenloader ) blender_add_lib(bf_blenloader_test_util "${TEST_UTIL_SRC}" "${TEST_UTIL_INC}" "${TEST_UTIL_INC_SYS}" "${TEST_UTIL_LIB}") diff --git a/source/blender/blenloader/intern/blend_validate.cc b/source/blender/blenloader/intern/blend_validate.cc index 1dfe4cdce3d..db04b65fece 100644 --- a/source/blender/blenloader/intern/blend_validate.cc +++ b/source/blender/blenloader/intern/blend_validate.cc @@ -15,6 +15,7 @@ #include "BLI_utildefines.h" +#include "BLI_blenlib.h" #include "BLI_linklist.h" #include "MEM_guardedalloc.h" @@ -28,10 +29,10 @@ #include "BKE_lib_remap.hh" #include "BKE_library.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BLO_blend_validate.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "readfile.hh" diff --git a/source/blender/blenloader/intern/readblenentry.cc b/source/blender/blenloader/intern/readblenentry.cc index f5b353ae24b..2a92e86fc16 100644 --- a/source/blender/blenloader/intern/readblenentry.cc +++ b/source/blender/blenloader/intern/readblenentry.cc @@ -17,6 +17,7 @@ #include "BLI_ghash.h" #include "BLI_linklist.h" +#include "BLI_listbase.h" #include "BLI_path_util.h" /* Only for assertions. */ #include "BLI_string.h" #include "BLI_utildefines.h" @@ -30,7 +31,8 @@ #include "BKE_preview_image.hh" #include "BLO_blend_defs.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" +#include "BLO_undofile.hh" #include "readfile.hh" diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc index e94d3e26e63..d2a8b87540b 100644 --- a/source/blender/blenloader/intern/readfile.cc +++ b/source/blender/blenloader/intern/readfile.cc @@ -58,14 +58,14 @@ #include "BLI_threads.h" #include "BLI_time.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_asset.hh" #include "BKE_blender_version.h" -#include "BKE_collection.hh" -#include "BKE_global.hh" /* for G */ +#include "BKE_collection.h" +#include "BKE_global.h" /* for G */ #include "BKE_idprop.h" #include "BKE_idtype.hh" #include "BKE_layer.hh" @@ -82,8 +82,8 @@ #include "BKE_node.hh" /* for tree type defines */ #include "BKE_object.hh" #include "BKE_packedFile.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_undo_system.hh" #include "BKE_workspace.h" @@ -95,7 +95,7 @@ #include "BLO_blend_defs.hh" #include "BLO_blend_validate.hh" #include "BLO_read_write.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "BLO_undofile.hh" #include "SEQ_iterator.hh" @@ -2401,30 +2401,91 @@ static void placeholders_ensure_valid(Main *bmain) } } -static const char *idtype_alloc_name_get(short id_code) +static const char *dataname(short id_code) { - static const std::array id_alloc_names = [] { - auto n = decltype(id_alloc_names)(); - for (int idtype_index = 0; idtype_index < INDEX_ID_MAX; idtype_index++) { - const IDTypeInfo *idtype_info = BKE_idtype_get_info_from_idtype_index(idtype_index); - BLI_assert(idtype_info); - if (idtype_index == INDEX_ID_NULL) { - /* #INDEX_ID_NULL returns the #IDType_ID_LINK_PLACEHOLDER type info, here we will rather - * use it for unknown/invalid ID types. */ - n[size_t(idtype_index)] = "Data from UNKNWOWN ID Type"; - } - else { - n[size_t(idtype_index)] = std::string("Data from '") + idtype_info->name + "'"; - } - } - return n; - }(); - - const int idtype_index = BKE_idtype_idcode_to_index(id_code); - if (LIKELY(idtype_index >= 0 && idtype_index < INDEX_ID_MAX)) { - return id_alloc_names[size_t(idtype_index)].c_str(); + switch ((ID_Type)id_code) { + case ID_OB: + return "Data from OB"; + case ID_ME: + return "Data from ME"; + case ID_IP: + return "Data from IP"; + case ID_SCE: + return "Data from SCE"; + case ID_MA: + return "Data from MA"; + case ID_TE: + return "Data from TE"; + case ID_CU_LEGACY: + return "Data from CU"; + case ID_GR: + return "Data from GR"; + case ID_AR: + return "Data from AR"; + case ID_AC: + return "Data from AC"; + case ID_LI: + return "Data from LI"; + case ID_MB: + return "Data from MB"; + case ID_IM: + return "Data from IM"; + case ID_LT: + return "Data from LT"; + case ID_LA: + return "Data from LA"; + case ID_CA: + return "Data from CA"; + case ID_KE: + return "Data from KE"; + case ID_WO: + return "Data from WO"; + case ID_SCR: + return "Data from SCR"; + case ID_VF: + return "Data from VF"; + case ID_TXT: + return "Data from TXT"; + case ID_SPK: + return "Data from SPK"; + case ID_LP: + return "Data from LP"; + case ID_SO: + return "Data from SO"; + case ID_NT: + return "Data from NT"; + case ID_BR: + return "Data from BR"; + case ID_PA: + return "Data from PA"; + case ID_PAL: + return "Data from PAL"; + case ID_PC: + return "Data from PCRV"; + case ID_GD_LEGACY: + return "Data from GD"; + case ID_WM: + return "Data from WM"; + case ID_MC: + return "Data from MC"; + case ID_MSK: + return "Data from MSK"; + case ID_LS: + return "Data from LS"; + case ID_CF: + return "Data from CF"; + case ID_WS: + return "Data from WS"; + case ID_CV: + return "Data from HA"; + case ID_PT: + return "Data from PT"; + case ID_VO: + return "Data from VO"; + case ID_GP: + return "Data from GP"; } - return id_alloc_names[INDEX_ID_NULL].c_str(); + return "Data from Lib Block"; } static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *id_old) @@ -2970,7 +3031,7 @@ static BHead *read_libblock(FileData *fd, /* Read datablock contents. * Use convenient malloc name for debugging and better memory link prints. */ - const char *allocname = idtype_alloc_name_get(idcode); + const char *allocname = dataname(idcode); bhead = read_data_into_datamap(fd, bhead, allocname); const bool success = direct_link_id(fd, main, id_tag, id, id_old); oldnewmap_clear(fd->datamap); @@ -3658,7 +3719,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) } if ((fd->skip_flags & BLO_READ_SKIP_DATA) == 0) { - fd->reports->duration.libraries = BLI_time_now_seconds(); + fd->reports->duration.libraries = BLI_check_seconds_timer(); read_libraries(fd, &mainlist); blo_join_main(&mainlist); @@ -3673,7 +3734,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) read_undo_remap_noundo_data(fd); } - fd->reports->duration.libraries = BLI_time_now_seconds() - fd->reports->duration.libraries; + fd->reports->duration.libraries = BLI_check_seconds_timer() - fd->reports->duration.libraries; /* Skip in undo case. */ if ((fd->flags & FD_FLAGS_IS_MEMFILE) == 0) { @@ -3731,7 +3792,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) * we can re-generate overrides from their references. */ if ((fd->flags & FD_FLAGS_IS_MEMFILE) == 0) { /* Do not apply in undo case! */ - fd->reports->duration.lib_overrides = BLI_time_now_seconds(); + fd->reports->duration.lib_overrides = BLI_check_seconds_timer(); std::string cur_view_layer_name = bfd->cur_view_layer != nullptr ? bfd->cur_view_layer->name : @@ -3752,7 +3813,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) * Proper fix involves first addressing #90610. */ BKE_main_collections_parent_relations_rebuild(bfd->main); - fd->reports->duration.lib_overrides = BLI_time_now_seconds() - + fd->reports->duration.lib_overrides = BLI_check_seconds_timer() - fd->reports->duration.lib_overrides; } diff --git a/source/blender/blenloader/intern/readfile.hh b/source/blender/blenloader/intern/readfile.hh index f13db6d9005..6bc5566d6c6 100644 --- a/source/blender/blenloader/intern/readfile.hh +++ b/source/blender/blenloader/intern/readfile.hh @@ -20,7 +20,7 @@ #include "DNA_space_types.h" #include "DNA_windowmanager_types.h" /* for eReportType */ -#include "BLO_readfile.hh" +#include "BLO_readfile.h" struct BlendFileData; struct BlendFileReadParams; diff --git a/source/blender/blenloader/intern/readfile_tempload.cc b/source/blender/blenloader/intern/readfile_tempload.cc index 3b636a8424d..d20424e480d 100644 --- a/source/blender/blenloader/intern/readfile_tempload.cc +++ b/source/blender/blenloader/intern/readfile_tempload.cc @@ -5,13 +5,14 @@ /** \file * \ingroup blenloader */ -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "MEM_guardedalloc.h" #include "BLI_string.h" #include "BKE_main.hh" +#include "BKE_report.h" #include "DNA_ID.h" diff --git a/source/blender/blenloader/intern/undofile.cc b/source/blender/blenloader/intern/undofile.cc index 0bf3e884ce9..d7b101eeded 100644 --- a/source/blender/blenloader/intern/undofile.cc +++ b/source/blender/blenloader/intern/undofile.cc @@ -26,14 +26,15 @@ #include "BLI_blenlib.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "BLO_undofile.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_undo_system.hh" -#include "BLI_strict_flags.h" /* Keep last. */ +/* keep last */ +#include "BLI_strict_flags.h" /* **************** support for memory-write, for undo buffers *************** */ diff --git a/source/blender/blenloader/intern/versioning_250.cc b/source/blender/blenloader/intern/versioning_250.cc index 22c97333369..0ca8f91f420 100644 --- a/source/blender/blenloader/intern/versioning_250.cc +++ b/source/blender/blenloader/intern/versioning_250.cc @@ -24,8 +24,10 @@ #include "DNA_cloth_types.h" #include "DNA_constraint_types.h" #include "DNA_fluid_types.h" +#include "DNA_ipo_types.h" #include "DNA_key_types.h" #include "DNA_lattice_types.h" +#include "DNA_light_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -39,6 +41,7 @@ #include "DNA_sound_types.h" #include "DNA_space_types.h" #include "DNA_view3d_types.h" +#include "DNA_world_types.h" #include "MEM_guardedalloc.h" @@ -53,20 +56,23 @@ #include "BKE_armature.hh" #include "BKE_colortools.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" /* for G */ +#include "BKE_global.h" /* for G */ #include "BKE_lib_id.hh" #include "BKE_main.hh" +#include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_multires.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BKE_node_tree_update.hh" #include "BKE_particle.h" +#include "BKE_pointcache.h" #include "BKE_screen.hh" +#include "BKE_sound.h" #include "BKE_texture.h" #include "SEQ_iterator.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "readfile.hh" diff --git a/source/blender/blenloader/intern/versioning_260.cc b/source/blender/blenloader/intern/versioning_260.cc index 89e0cc44a41..ed9553ac075 100644 --- a/source/blender/blenloader/intern/versioning_260.cc +++ b/source/blender/blenloader/intern/versioning_260.cc @@ -23,6 +23,7 @@ #include "DNA_dynamicpaint_types.h" #include "DNA_fluid_types.h" #include "DNA_genfile.h" +#include "DNA_key_types.h" #include "DNA_light_types.h" #include "DNA_linestyle_types.h" #include "DNA_material_types.h" @@ -32,6 +33,7 @@ #include "DNA_object_fluidsim_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "DNA_sdna_types.h" #include "DNA_sequence_types.h" #include "DNA_space_types.h" #include "DNA_text_types.h" @@ -48,16 +50,20 @@ #include "BLI_math_vector.h" #include "BLI_string_utils.hh" +#include "BLT_translation.h" + #include "BKE_anim_visualization.h" #include "BKE_customdata.hh" #include "BKE_image.h" #include "BKE_main.hh" /* for Main */ +#include "BKE_mesh.hh" /* for ME_ defines (patching) */ #include "BKE_mesh_legacy_convert.hh" #include "BKE_modifier.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" #include "BKE_particle.h" -#include "BKE_scene.hh" +#include "BKE_pointcache.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_text.h" /* for txt_extended_ascii_as_utf8 */ #include "BKE_texture.h" @@ -75,8 +81,9 @@ #include "NOD_common.h" #include "NOD_composite.hh" +#include "NOD_texture.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "readfile.hh" @@ -1726,6 +1733,14 @@ void blo_do_versions_260(FileData *fd, Library * /*lib*/, Main *bmain) if (!MAIN_VERSION_FILE_ATLEAST(bmain, 263, 10)) { { /* composite redesign */ + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + if (scene->nodetree) { + if (scene->nodetree->chunksize == 0) { + scene->nodetree->chunksize = 256; + } + } + } + FOREACH_NODETREE_BEGIN (bmain, ntree, id) { if (ntree->type == NTREE_COMPOSIT) { LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { diff --git a/source/blender/blenloader/intern/versioning_270.cc b/source/blender/blenloader/intern/versioning_270.cc index 27625bca6c7..fbc877f3b25 100644 --- a/source/blender/blenloader/intern/versioning_270.cc +++ b/source/blender/blenloader/intern/versioning_270.cc @@ -33,11 +33,13 @@ #include "DNA_mask_types.h" #include "DNA_mesh_types.h" #include "DNA_modifier_types.h" +#include "DNA_object_force_types.h" #include "DNA_object_types.h" #include "DNA_particle_types.h" #include "DNA_pointcache_types.h" #include "DNA_rigidbody_types.h" #include "DNA_screen_types.h" +#include "DNA_sdna_types.h" #include "DNA_sequence_types.h" #include "DNA_space_types.h" #include "DNA_view3d_types.h" @@ -54,9 +56,10 @@ #include "BKE_main.hh" #include "BKE_mask.h" #include "BKE_modifier.hh" -#include "BKE_node.hh" -#include "BKE_scene.hh" +#include "BKE_node.h" +#include "BKE_scene.h" #include "BKE_screen.hh" +#include "BKE_tracking.h" #include "DNA_material_types.h" #include "SEQ_effects.hh" @@ -69,10 +72,11 @@ #include "BLI_string.h" #include "BLI_string_utils.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" +#include "NOD_common.h" #include "NOD_composite.hh" #include "NOD_socket.hh" diff --git a/source/blender/blenloader/intern/versioning_280.cc b/source/blender/blenloader/intern/versioning_280.cc index 88eb387df74..af3773f2a97 100644 --- a/source/blender/blenloader/intern/versioning_280.cc +++ b/source/blender/blenloader/intern/versioning_280.cc @@ -62,8 +62,10 @@ #undef DNA_GENFILE_VERSIONING_MACROS #include "BKE_animsys.h" -#include "BKE_blender.hh" -#include "BKE_collection.hh" +#include "BKE_blender.h" +#include "BKE_brush.hh" +#include "BKE_cloth.hh" +#include "BKE_collection.h" #include "BKE_colortools.hh" #include "BKE_constraint.h" #include "BKE_curveprofile.h" @@ -71,7 +73,10 @@ #include "BKE_fcurve.h" #include "BKE_fcurve_driver.h" #include "BKE_freestyle.h" +#include "BKE_global.h" #include "BKE_gpencil_geom_legacy.h" +#include "BKE_gpencil_legacy.h" +#include "BKE_gpencil_modifier_legacy.h" #include "BKE_idprop.h" #include "BKE_key.hh" #include "BKE_layer.hh" @@ -79,10 +84,11 @@ #include "BKE_main.hh" #include "BKE_mesh.hh" #include "BKE_mesh_legacy_convert.hh" -#include "BKE_node.hh" +#include "BKE_node.h" +#include "BKE_node_tree_update.hh" #include "BKE_paint.hh" #include "BKE_pointcache.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_rigidbody.h" #include "BKE_screen.hh" #include "BKE_studiolight.h" @@ -98,10 +104,12 @@ #include "IMB_colormanagement.hh" #include "IMB_imbuf.hh" -#include "BLT_translation.hh" +#include "DEG_depsgraph.hh" + +#include "BLT_translation.h" #include "BLO_read_write.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "readfile.hh" #include "versioning_common.hh" @@ -322,7 +330,6 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) view_layer->pass_alpha_threshold = srl->pass_alpha_threshold; view_layer->samples = srl->samples; view_layer->mat_override = srl->mat_override; - view_layer->world_override = srl->world_override; BKE_freestyle_config_free(&view_layer->freestyle_config, true); view_layer->freestyle_config = srl->freestyleConfig; @@ -3460,7 +3467,7 @@ void blo_do_versions_280(FileData *fd, Library * /*lib*/, Main *bmain) scene->eevee.bloom_clamp = 0.0f; scene->eevee.motion_blur_samples = 8; - scene->eevee.motion_blur_shutter_deprecated = 0.5f; + scene->eevee.motion_blur_shutter = 0.5f; scene->eevee.shadow_method = SHADOW_ESM; scene->eevee.shadow_cube_size = 512; @@ -3531,7 +3538,7 @@ void blo_do_versions_280(FileData *fd, Library * /*lib*/, Main *bmain) EEVEE_GET_BOOL(props, gtao_bounce, SCE_EEVEE_GTAO_BOUNCE); EEVEE_GET_BOOL(props, dof_enable, SCE_EEVEE_DOF_ENABLED); EEVEE_GET_BOOL(props, bloom_enable, SCE_EEVEE_BLOOM_ENABLED); - EEVEE_GET_BOOL(props, motion_blur_enable, SCE_EEVEE_MOTION_BLUR_ENABLED_DEPRECATED); + EEVEE_GET_BOOL(props, motion_blur_enable, SCE_EEVEE_MOTION_BLUR_ENABLED); EEVEE_GET_BOOL(props, shadow_high_bitdepth, SCE_EEVEE_SHADOW_HIGH_BITDEPTH); EEVEE_GET_BOOL(props, taa_reprojection, SCE_EEVEE_TAA_REPROJECTION); // EEVEE_GET_BOOL(props, sss_enable, SCE_EEVEE_SSS_ENABLED); @@ -3580,7 +3587,7 @@ void blo_do_versions_280(FileData *fd, Library * /*lib*/, Main *bmain) EEVEE_GET_FLOAT(props, bloom_clamp); EEVEE_GET_INT(props, motion_blur_samples); - EEVEE_GET_FLOAT(props, motion_blur_shutter_deprecated); + EEVEE_GET_FLOAT(props, motion_blur_shutter); EEVEE_GET_INT(props, shadow_method); EEVEE_GET_INT(props, shadow_cube_size); diff --git a/source/blender/blenloader/intern/versioning_290.cc b/source/blender/blenloader/intern/versioning_290.cc index b64df04255b..03d07c483e8 100644 --- a/source/blender/blenloader/intern/versioning_290.cc +++ b/source/blender/blenloader/intern/versioning_290.cc @@ -25,6 +25,7 @@ #include "DNA_cachefile_types.h" #include "DNA_collection_types.h" #include "DNA_constraint_types.h" +#include "DNA_curves_types.h" #include "DNA_fluid_types.h" #include "DNA_genfile.h" #include "DNA_gpencil_legacy_types.h" @@ -47,8 +48,10 @@ #undef DNA_GENFILE_VERSIONING_MACROS +#include "BKE_animsys.h" #include "BKE_armature.hh" -#include "BKE_collection.hh" +#include "BKE_attribute.hh" +#include "BKE_collection.h" #include "BKE_colortools.hh" #include "BKE_cryptomatte.h" #include "BKE_curve.hh" @@ -65,11 +68,15 @@ #include "IMB_imbuf.hh" #include "MEM_guardedalloc.h" +#include "RNA_access.hh" + #include "SEQ_proxy.hh" +#include "SEQ_render.hh" #include "SEQ_sequencer.hh" #include "SEQ_time.hh" +#include "SEQ_transform.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "readfile.hh" #include "versioning_common.hh" diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index ebb6c73861e..ec8dda52171 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -60,7 +60,7 @@ #include "BKE_armature.hh" #include "BKE_asset.hh" #include "BKE_attribute.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_colortools.hh" #include "BKE_curve.hh" #include "BKE_curves.hh" @@ -86,7 +86,7 @@ #include "RNA_enum_types.hh" #include "RNA_prototypes.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "readfile.hh" diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index c8b1e093736..d0f43d41bbc 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -11,6 +11,8 @@ #include #include +#include "CLG_log.h" + /* Define macros in `DNA_genfile.h`. */ #define DNA_GENFILE_VERSIONING_MACROS @@ -47,6 +49,7 @@ #include "BKE_animsys.h" #include "BKE_armature.hh" #include "BKE_attribute.hh" +#include "BKE_collection.h" #include "BKE_curve.hh" #include "BKE_effect.h" #include "BKE_grease_pencil.hh" @@ -54,19 +57,24 @@ #include "BKE_main.hh" #include "BKE_material.h" #include "BKE_mesh_legacy_convert.hh" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_tracking.h" #include "SEQ_iterator.hh" +#include "SEQ_retiming.hh" +#include "SEQ_sequencer.hh" #include "ANIM_armature_iter.hh" #include "ANIM_bone_collections.hh" -#include "BLT_translation.hh" +#include "ED_armature.hh" + +#include "BLT_translation.h" #include "BLO_read_write.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "readfile.hh" @@ -2882,62 +2890,12 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) /* Keep point/spot light soft falloff for files created before 4.0. */ if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 0)) { LISTBASE_FOREACH (Light *, light, &bmain->lights) { - if (ELEM(light->type, LA_LOCAL, LA_SPOT)) { + if (light->type == LA_LOCAL || light->type == LA_SPOT) { light->mode |= LA_USE_SOFT_FALLOFF; } } } - if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 1)) { - using namespace blender::bke::greasepencil; - /* Initialize newly added scale layer transform to one. */ - LISTBASE_FOREACH (GreasePencil *, grease_pencil, &bmain->grease_pencils) { - for (Layer *layer : grease_pencil->layers_for_write()) { - copy_v3_fl(layer->scale, 1.0f); - } - } - } - - if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 2)) { - LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { - bool is_cycles = scene && STREQ(scene->r.engine, RE_engine_id_CYCLES); - if (is_cycles) { - if (IDProperty *cscene = version_cycles_properties_from_ID(&scene->id)) { - int cposition = version_cycles_property_int(cscene, "motion_blur_position", 1); - BLI_assert(cposition >= 0 && cposition < 3); - int order_conversion[3] = {SCE_MB_START, SCE_MB_CENTER, SCE_MB_END}; - scene->r.motion_blur_position = order_conversion[std::clamp(cposition, 0, 2)]; - } - } - else { - SET_FLAG_FROM_TEST( - scene->r.mode, scene->eevee.flag & SCE_EEVEE_MOTION_BLUR_ENABLED_DEPRECATED, R_MBLUR); - scene->r.motion_blur_position = scene->eevee.motion_blur_position_deprecated; - scene->r.motion_blur_shutter = scene->eevee.motion_blur_shutter_deprecated; - } - } - } - - if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 3)) { - constexpr int NTREE_EXECUTION_MODE_FULL_FRAME = 1; - - constexpr int NTREE_COM_GROUPNODE_BUFFER = 1 << 3; - constexpr int NTREE_COM_OPENCL = 1 << 1; - - FOREACH_NODETREE_BEGIN (bmain, ntree, id) { - if (ntree->type != NTREE_COMPOSIT) { - continue; - } - - ntree->flag &= ~(NTREE_COM_GROUPNODE_BUFFER | NTREE_COM_OPENCL); - - if (ntree->execution_mode == NTREE_EXECUTION_MODE_FULL_FRAME) { - ntree->execution_mode = NTREE_EXECUTION_MODE_CPU; - } - } - FOREACH_NODETREE_END; - } - /** * Always bump subversion in BKE_blender_version.h when adding versioning * code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check. diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc index a1f0d4e8582..1e428e3c975 100644 --- a/source/blender/blenloader/intern/versioning_common.cc +++ b/source/blender/blenloader/intern/versioning_common.cc @@ -26,13 +26,14 @@ #include "BKE_main.hh" #include "BKE_main_namemap.hh" #include "BKE_mesh_legacy_convert.hh" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "SEQ_sequencer.hh" #include "MEM_guardedalloc.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "readfile.hh" #include "versioning_common.hh" diff --git a/source/blender/blenloader/intern/versioning_defaults.cc b/source/blender/blenloader/intern/versioning_defaults.cc index 30faaf52eb0..dea58b06018 100644 --- a/source/blender/blenloader/intern/versioning_defaults.cc +++ b/source/blender/blenloader/intern/versioning_defaults.cc @@ -22,6 +22,7 @@ #include "BLI_math_vector.h" #include "BLI_math_vector_types.hh" #include "BLI_string.h" +#include "BLI_system.h" #include "BLI_utildefines.h" #include "DNA_camera_types.h" @@ -32,6 +33,7 @@ #include "DNA_mask_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" @@ -54,15 +56,16 @@ #include "BKE_main_namemap.hh" #include "BKE_material.h" #include "BKE_mesh.hh" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" #include "BKE_paint.hh" #include "BKE_screen.hh" #include "BKE_workspace.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "versioning_common.hh" @@ -317,7 +320,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene) /* New EEVEE defaults. */ scene->eevee.bloom_intensity = 0.05f; scene->eevee.bloom_clamp = 0.0f; - scene->eevee.motion_blur_shutter_deprecated = 0.5f; + scene->eevee.motion_blur_shutter = 0.5f; copy_v3_v3(scene->display.light_direction, blender::float3(M_SQRT1_3)); copy_v2_fl2(scene->safe_areas.title, 0.1f, 0.05f); diff --git a/source/blender/blenloader/intern/versioning_dna.cc b/source/blender/blenloader/intern/versioning_dna.cc index ebe8fb710ff..5700442591d 100644 --- a/source/blender/blenloader/intern/versioning_dna.cc +++ b/source/blender/blenloader/intern/versioning_dna.cc @@ -14,7 +14,7 @@ #include "DNA_genfile.h" #include "DNA_listBase.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "readfile.hh" void blo_do_versions_dna(SDNA *sdna, const int versionfile, const int subversionfile) diff --git a/source/blender/blenloader/intern/versioning_legacy.cc b/source/blender/blenloader/intern/versioning_legacy.cc index 61f4cb0a04b..c17403bd3df 100644 --- a/source/blender/blenloader/intern/versioning_legacy.cc +++ b/source/blender/blenloader/intern/versioning_legacy.cc @@ -27,6 +27,7 @@ #include "DNA_effect_types.h" #include "DNA_key_types.h" #include "DNA_lattice_types.h" +#include "DNA_light_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -63,7 +64,7 @@ #include "BKE_mesh.hh" /* for ME_ defines (patching) */ #include "BKE_mesh_legacy_convert.hh" #include "BKE_modifier.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BKE_object.hh" #include "BKE_particle.h" #include "BKE_pointcache.h" @@ -71,7 +72,7 @@ #include "SEQ_iterator.hh" #include "SEQ_sequencer.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "readfile.hh" @@ -617,8 +618,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile <= 153) { Scene *sce = static_cast(bmain->scenes.first); while (sce) { - if (sce->r.motion_blur_shutter == 0.0f) { - sce->r.motion_blur_shutter = 1.0f; + if (sce->r.blurfac == 0.0f) { + sce->r.blurfac = 1.0f; } sce = static_cast(sce->id.next); } @@ -2592,7 +2593,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) ob = static_cast(ob->id.next)) { if (ob->pd) { - ob->pd->seed = (uint(ceil(BLI_time_now_seconds())) + 1) % 128; + ob->pd->seed = (uint(ceil(BLI_check_seconds_timer())) + 1) % 128; } } } diff --git a/source/blender/blenloader/intern/versioning_userdef.cc b/source/blender/blenloader/intern/versioning_userdef.cc index 2e4206c546f..606ac28fa57 100644 --- a/source/blender/blenloader/intern/versioning_userdef.cc +++ b/source/blender/blenloader/intern/versioning_userdef.cc @@ -19,6 +19,7 @@ #include "BLI_utildefines.h" #include "DNA_anim_types.h" +#include "DNA_collection_types.h" #include "DNA_curve_types.h" #include "DNA_scene_types.h" #include "DNA_space_types.h" @@ -33,10 +34,9 @@ #include "BKE_main.hh" #include "BKE_preferences.h" -#include "BLO_readfile.hh" -#include "BLO_userdef_default.h" +#include "BLO_readfile.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "GPU_platform.h" @@ -52,7 +52,7 @@ * If this is important we can set the translations as part of versioning preferences, * however that should only be done if there are important use-cases. */ #if 0 -# include "BLT_translation.hh" +# include "BLT_translation.h" #else # define N_(msgid) msgid #endif diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc index 09637b8a6aa..e1640a18f69 100644 --- a/source/blender/blenloader/intern/writefile.cc +++ b/source/blender/blenloader/intern/writefile.cc @@ -100,8 +100,8 @@ #include "MEM_guardedalloc.h" /* MEM_freeN */ #include "BKE_blender_version.h" -#include "BKE_bpath.hh" -#include "BKE_global.hh" /* For #Global `G`. */ +#include "BKE_bpath.h" +#include "BKE_global.h" /* For #Global `G`. */ #include "BKE_idprop.h" #include "BKE_idtype.hh" #include "BKE_layer.hh" @@ -112,13 +112,13 @@ #include "BKE_main_namemap.hh" #include "BKE_node.hh" #include "BKE_packedFile.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_workspace.h" #include "BLO_blend_defs.hh" #include "BLO_blend_validate.hh" #include "BLO_read_write.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "BLO_undofile.hh" #include "BLO_writefile.hh" diff --git a/source/blender/blenloader/tests/blendfile_loading_base_test.cc b/source/blender/blenloader/tests/blendfile_loading_base_test.cc index ef07b240032..d50168523e8 100644 --- a/source/blender/blenloader/tests/blendfile_loading_base_test.cc +++ b/source/blender/blenloader/tests/blendfile_loading_base_test.cc @@ -6,10 +6,10 @@ #include "MEM_guardedalloc.h" #include "BKE_appdir.hh" -#include "BKE_blender.hh" -#include "BKE_callbacks.hh" +#include "BKE_blender.h" +#include "BKE_callbacks.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_image.h" #include "BKE_layer.hh" @@ -17,7 +17,7 @@ #include "BKE_mball_tessellate.hh" #include "BKE_modifier.hh" #include "BKE_node.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_vfont.hh" #include "BLF_api.hh" @@ -25,7 +25,7 @@ #include "BLI_path_util.h" #include "BLI_threads.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" diff --git a/source/blender/blentranslation/BLT_lang.hh b/source/blender/blentranslation/BLT_lang.h similarity index 92% rename from source/blender/blentranslation/BLT_lang.hh rename to source/blender/blentranslation/BLT_lang.h index aec72895605..c15ffb7e27b 100644 --- a/source/blender/blentranslation/BLT_lang.hh +++ b/source/blender/blentranslation/BLT_lang.h @@ -8,7 +8,9 @@ #pragma once -struct EnumPropertyItem; +#ifdef __cplusplus +extern "C" { +#endif /* Search the path directory to the locale files, this try all * the case for Linux, Win and Mac. @@ -46,4 +48,8 @@ void BLT_lang_locale_explode(const char *locale, char **language_variant); /* Get EnumPropertyItem's for translations menu. */ -EnumPropertyItem *BLT_lang_RNA_enum_properties(void); +struct EnumPropertyItem *BLT_lang_RNA_enum_properties(void); + +#ifdef __cplusplus +}; +#endif diff --git a/source/blender/blentranslation/BLT_translation.hh b/source/blender/blentranslation/BLT_translation.h similarity index 98% rename from source/blender/blentranslation/BLT_translation.hh rename to source/blender/blentranslation/BLT_translation.h index 677ee3ce9b2..ccdd69ed278 100644 --- a/source/blender/blentranslation/BLT_translation.hh +++ b/source/blender/blentranslation/BLT_translation.h @@ -12,6 +12,10 @@ #define TEXT_DOMAIN_NAME "blender" +#ifdef __cplusplus +extern "C" { +#endif + bool BLT_is_default_context(const char *msgctxt); const char *BLT_pgettext(const char *msgctxt, const char *msgid); @@ -84,7 +88,7 @@ const char *BLT_translate_do_new_dataname(const char *msgctxt, const char *msgid #define BLT_I18NCONTEXT_PLURAL "Plural" /* ID-types contexts. */ -/* WARNING! Keep it in sync with ID-types in `blenkernel/intern/idtype.cc`. */ +/* WARNING! Keep it in sync with idtypes in blenkernel/intern/idcode.c */ #define BLT_I18NCONTEXT_ID_ACTION "Action" #define BLT_I18NCONTEXT_ID_ARMATURE "Armature" #define BLT_I18NCONTEXT_ID_BRUSH "Brush" @@ -141,11 +145,11 @@ const char *BLT_translate_do_new_dataname(const char *msgctxt, const char *msgid #define BLT_I18NCONTEXT_UNIT "Unit" /* Helper for bpy.app.i18n object... */ -struct BLT_i18n_contexts_descriptor { +typedef struct { const char *c_id; const char *py_id; const char *value; -}; +} BLT_i18n_contexts_descriptor; #define BLT_I18NCONTEXTS_ITEM(ctxt_id, py_id) \ { \ @@ -214,3 +218,7 @@ struct BLT_i18n_contexts_descriptor { NULL, NULL, NULL \ } \ } + +#ifdef __cplusplus +}; +#endif diff --git a/source/blender/blentranslation/CMakeLists.txt b/source/blender/blentranslation/CMakeLists.txt index af0aaf3974b..841bc181912 100644 --- a/source/blender/blentranslation/CMakeLists.txt +++ b/source/blender/blentranslation/CMakeLists.txt @@ -17,8 +17,8 @@ set(SRC intern/blt_lang.cc intern/blt_translation.cc - BLT_lang.hh - BLT_translation.hh + BLT_lang.h + BLT_translation.h ) set(LIB diff --git a/source/blender/blentranslation/intern/blt_lang.cc b/source/blender/blentranslation/intern/blt_lang.cc index efdf8f09848..6da6d929aa8 100644 --- a/source/blender/blentranslation/intern/blt_lang.cc +++ b/source/blender/blentranslation/intern/blt_lang.cc @@ -18,8 +18,8 @@ #include "RNA_types.hh" -#include "BLT_lang.hh" /* own include */ -#include "BLT_translation.hh" +#include "BLT_lang.h" /* own include */ +#include "BLT_translation.h" #include "BLI_path_util.h" #include "BLI_string.h" diff --git a/source/blender/blentranslation/intern/blt_translation.cc b/source/blender/blentranslation/intern/blt_translation.cc index 257be744cdd..b7e9cf38094 100644 --- a/source/blender/blentranslation/intern/blt_translation.cc +++ b/source/blender/blentranslation/intern/blt_translation.cc @@ -12,7 +12,7 @@ #include #include -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/bmesh/intern/bmesh_core.cc b/source/blender/bmesh/intern/bmesh_core.cc index 1d5b116b2d6..8b8c370a015 100644 --- a/source/blender/bmesh/intern/bmesh_core.cc +++ b/source/blender/bmesh/intern/bmesh_core.cc @@ -16,7 +16,7 @@ #include "BLI_utildefines_stack.h" #include "BLI_vector.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_customdata.hh" #include "BKE_mesh.hh" diff --git a/source/blender/bmesh/intern/bmesh_delete.cc b/source/blender/bmesh/intern/bmesh_delete.cc index fe6bc94b353..afe0b4a8e3a 100644 --- a/source/blender/bmesh/intern/bmesh_delete.cc +++ b/source/blender/bmesh/intern/bmesh_delete.cc @@ -11,6 +11,7 @@ #include "BLI_utildefines.h" #include "bmesh.hh" +#include "intern/bmesh_private.hh" /* BMO functions */ diff --git a/source/blender/bmesh/intern/bmesh_interp.cc b/source/blender/bmesh/intern/bmesh_interp.cc index e78c011d531..a2deece1932 100644 --- a/source/blender/bmesh/intern/bmesh_interp.cc +++ b/source/blender/bmesh/intern/bmesh_interp.cc @@ -18,6 +18,7 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" #include "BLI_memarena.h" +#include "BLI_string.h" #include "BLI_task.h" #include "BKE_attribute.hh" diff --git a/source/blender/bmesh/intern/bmesh_iterators.cc b/source/blender/bmesh/intern/bmesh_iterators.cc index 1fcc11f2700..9e914e79a03 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.cc +++ b/source/blender/bmesh/intern/bmesh_iterators.cc @@ -12,6 +12,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_bitmap.h" #include "BLI_utildefines.h" #include "bmesh.hh" diff --git a/source/blender/bmesh/intern/bmesh_log.cc b/source/blender/bmesh/intern/bmesh_log.cc index 1c3bef8a079..c4f95e7f6a9 100644 --- a/source/blender/bmesh/intern/bmesh_log.cc +++ b/source/blender/bmesh/intern/bmesh_log.cc @@ -31,7 +31,7 @@ #include "bmesh_log.hh" #include "range_tree.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" struct BMLogEntry { BMLogEntry *next, *prev; diff --git a/source/blender/bmesh/intern/bmesh_mesh.cc b/source/blender/bmesh/intern/bmesh_mesh.cc index 747fa97d37b..5474003ea74 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.cc +++ b/source/blender/bmesh/intern/bmesh_mesh.cc @@ -11,6 +11,7 @@ #include "MEM_guardedalloc.h" #include "DNA_listBase.h" +#include "DNA_scene_types.h" #include "BLI_listbase.h" #include "BLI_math_matrix.h" diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc index fd9bd4d0e13..42c81157513 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc @@ -265,7 +265,7 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams * BLI_SCOPED_DEFER([&]() { for (const std::string &name : temporary_layers_to_delete) { - CustomData_free_layer_named(&mesh_ldata, name, mesh->corners_num); + CustomData_free_layer_named(&mesh_ldata, name.c_str(), mesh->corners_num); } MEM_SAFE_FREE(mesh_vdata.layers); @@ -1618,10 +1618,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *mesh, const BMeshToMeshParam material_index.finish(); } -void BM_mesh_bm_to_me_compact(BMesh &bm, - Mesh &mesh, - const CustomData_MeshMasks *mask, - const bool add_mesh_attributes) +void BM_mesh_bm_to_me_for_eval(BMesh &bm, Mesh &mesh, const CustomData_MeshMasks *cd_mask_extra) { /* NOTE: The function is called from multiple threads with the same input BMesh and different * mesh objects. */ @@ -1629,6 +1626,7 @@ void BM_mesh_bm_to_me_compact(BMesh &bm, using namespace blender; /* Must be an empty mesh. */ BLI_assert(mesh.verts_num == 0); + BLI_assert(cd_mask_extra == nullptr || (cd_mask_extra->vmask & CD_MASK_SHAPEKEY) == 0); /* Just in case, clear the derived geometry caches from the input mesh. */ BKE_mesh_runtime_clear_geometry(&mesh); @@ -1640,8 +1638,6 @@ void BM_mesh_bm_to_me_compact(BMesh &bm, mesh.runtime->deformed_only = true; - const bool use_threading = (mesh.faces_num + mesh.edges_num) > 1024; - /* In a first pass, update indices of BMesh elements and build tables for easy iteration later. * Also check if some optional mesh attributes should be added in the next step. Since each * domain has no effect on others, process the independent domains on separate threads. */ @@ -1655,14 +1651,13 @@ void BM_mesh_bm_to_me_compact(BMesh &bm, bool need_sharp_edge = false; bool need_sharp_face = false; bool need_uv_seams = false; - Array vert_table; Array edge_table; Array face_table; Array loop_table; Vector loop_layers_not_to_copy; threading::parallel_invoke( - use_threading, + (mesh.faces_num + mesh.edges_num) > 1024, [&]() { vert_table.reinitialize(bm.totvert); bm_vert_table_build(bm, vert_table, need_select_vert, need_hide_vert); @@ -1689,16 +1684,22 @@ void BM_mesh_bm_to_me_compact(BMesh &bm, }); bm.elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE | BM_LOOP); - if (mask) { - CustomData_merge_layout(&bm.vdata, &mesh.vert_data, mask->vmask, CD_CONSTRUCT, mesh.verts_num); - CustomData_merge_layout(&bm.edata, &mesh.edge_data, mask->emask, CD_CONSTRUCT, mesh.edges_num); - CustomData_merge_layout( - &bm.ldata, &mesh.corner_data, mask->lmask, CD_CONSTRUCT, mesh.corners_num); - CustomData_merge_layout(&bm.pdata, &mesh.face_data, mask->pmask, CD_CONSTRUCT, mesh.faces_num); + /* Don't process shape-keys. We only feed them through the modifier stack as needed, + * e.g. for applying modifiers or the like. */ + CustomData_MeshMasks mask = CD_MASK_DERIVEDMESH; + if (cd_mask_extra != nullptr) { + CustomData_MeshMasks_update(&mask, cd_mask_extra); } + mask.vmask &= ~CD_MASK_SHAPEKEY; + CustomData_merge_layout(&bm.vdata, &mesh.vert_data, mask.vmask, CD_CONSTRUCT, mesh.verts_num); + CustomData_merge_layout(&bm.edata, &mesh.edge_data, mask.emask, CD_CONSTRUCT, mesh.edges_num); + CustomData_merge_layout( + &bm.ldata, &mesh.corner_data, mask.lmask, CD_CONSTRUCT, mesh.corners_num); + CustomData_merge_layout(&bm.pdata, &mesh.face_data, mask.pmask, CD_CONSTRUCT, mesh.faces_num); /* Add optional mesh attributes before parallel iteration. */ assert_bmesh_has_no_mesh_only_attributes(bm); + bke::MutableAttributeAccessor attrs = mesh.attributes_for_write(); bke::SpanAttributeWriter select_vert; bke::SpanAttributeWriter hide_vert; bke::SpanAttributeWriter select_edge; @@ -1709,48 +1710,41 @@ void BM_mesh_bm_to_me_compact(BMesh &bm, bke::SpanAttributeWriter hide_poly; bke::SpanAttributeWriter sharp_face; bke::SpanAttributeWriter material_index; - - if (add_mesh_attributes) { - bke::MutableAttributeAccessor attrs = mesh.attributes_for_write(); - if (need_select_vert) { - select_vert = attrs.lookup_or_add_for_write_only_span(".select_vert", - AttrDomain::Point); - } - if (need_hide_vert) { - hide_vert = attrs.lookup_or_add_for_write_only_span(".hide_vert", AttrDomain::Point); - } - if (need_select_edge) { - select_edge = attrs.lookup_or_add_for_write_only_span(".select_edge", - AttrDomain::Edge); - } - if (need_sharp_edge) { - sharp_edge = attrs.lookup_or_add_for_write_only_span("sharp_edge", AttrDomain::Edge); - } - if (need_uv_seams) { - uv_seams = attrs.lookup_or_add_for_write_only_span(".uv_seam", AttrDomain::Edge); - } - if (need_hide_edge) { - hide_edge = attrs.lookup_or_add_for_write_only_span(".hide_edge", AttrDomain::Edge); - } - if (need_select_poly) { - select_poly = attrs.lookup_or_add_for_write_only_span(".select_poly", + if (need_select_vert) { + select_vert = attrs.lookup_or_add_for_write_only_span(".select_vert", AttrDomain::Point); + } + if (need_hide_vert) { + hide_vert = attrs.lookup_or_add_for_write_only_span(".hide_vert", AttrDomain::Point); + } + if (need_select_edge) { + select_edge = attrs.lookup_or_add_for_write_only_span(".select_edge", AttrDomain::Edge); + } + if (need_sharp_edge) { + sharp_edge = attrs.lookup_or_add_for_write_only_span("sharp_edge", AttrDomain::Edge); + } + if (need_uv_seams) { + uv_seams = attrs.lookup_or_add_for_write_only_span(".uv_seam", AttrDomain::Edge); + } + if (need_hide_edge) { + hide_edge = attrs.lookup_or_add_for_write_only_span(".hide_edge", AttrDomain::Edge); + } + if (need_select_poly) { + select_poly = attrs.lookup_or_add_for_write_only_span(".select_poly", AttrDomain::Face); + } + if (need_hide_poly) { + hide_poly = attrs.lookup_or_add_for_write_only_span(".hide_poly", AttrDomain::Face); + } + if (need_sharp_face) { + sharp_face = attrs.lookup_or_add_for_write_only_span("sharp_face", AttrDomain::Face); + } + if (need_material_index) { + material_index = attrs.lookup_or_add_for_write_only_span("material_index", AttrDomain::Face); - } - if (need_hide_poly) { - hide_poly = attrs.lookup_or_add_for_write_only_span(".hide_poly", AttrDomain::Face); - } - if (need_sharp_face) { - sharp_face = attrs.lookup_or_add_for_write_only_span("sharp_face", AttrDomain::Face); - } - if (need_material_index) { - material_index = attrs.lookup_or_add_for_write_only_span("material_index", - AttrDomain::Face); - } } /* Loop over all elements in parallel, copying attributes and building the Mesh topology. */ threading::parallel_invoke( - use_threading, + (mesh.faces_num + mesh.edges_num) > 1024, [&]() { bm_to_mesh_verts(bm, vert_table, mesh, select_vert.span, hide_vert.span); }, [&]() { bm_to_mesh_edges(bm, @@ -1769,9 +1763,6 @@ void BM_mesh_bm_to_me_compact(BMesh &bm, hide_poly.span, sharp_face.span, material_index.span); - if (bm.act_face) { - mesh.act_face = BM_elem_index_get(bm.act_face); - } }, [&]() { bm_to_mesh_loops(bm, loop_table, mesh); @@ -1780,29 +1771,14 @@ void BM_mesh_bm_to_me_compact(BMesh &bm, } }); - if (add_mesh_attributes) { - select_vert.finish(); - hide_vert.finish(); - select_edge.finish(); - hide_edge.finish(); - sharp_edge.finish(); - uv_seams.finish(); - select_poly.finish(); - hide_poly.finish(); - sharp_face.finish(); - material_index.finish(); - } -} - -void BM_mesh_bm_to_me_for_eval(BMesh &bm, Mesh &mesh, const CustomData_MeshMasks *cd_mask_extra) -{ - /* Don't process shape-keys. We only feed them through the modifier stack as needed, - * e.g. for applying modifiers or the like. */ - CustomData_MeshMasks mask = CD_MASK_DERIVEDMESH; - if (cd_mask_extra != nullptr) { - CustomData_MeshMasks_update(&mask, cd_mask_extra); - } - mask.vmask &= ~CD_MASK_SHAPEKEY; - - BM_mesh_bm_to_me_compact(bm, mesh, &mask, true); + select_vert.finish(); + hide_vert.finish(); + select_edge.finish(); + hide_edge.finish(); + sharp_edge.finish(); + uv_seams.finish(); + select_poly.finish(); + hide_poly.finish(); + sharp_face.finish(); + material_index.finish(); } diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.hh b/source/blender/bmesh/intern/bmesh_mesh_convert.hh index e36bbc77b79..44249e0deba 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.hh +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.hh @@ -90,16 +90,3 @@ void BM_mesh_bm_to_me(struct Main *bmain, BMesh *bm, Mesh *mesh, const BMeshToMe * \note Was `cddm_from_bmesh_ex` in 2.7x, removed `MFace` support. */ void BM_mesh_bm_to_me_for_eval(BMesh &bm, Mesh &mesh, const CustomData_MeshMasks *cd_mask_extra); - -/** - * A version of #BM_mesh_bm_to_me_for_eval but copying data layers and Mesh attributes is optional. - * It also allows shape-keys but don't re-assigns shape-key indices. - * - * \param mask Custom data masks to control which layers are copied. - * If nullptr, no layer data is copied. - * \param add_mesh_attributes If true, adds mesh attributes during the conversion. - */ -void BM_mesh_bm_to_me_compact(BMesh &bm, - Mesh &mesh, - const CustomData_MeshMasks *mask, - bool add_mesh_attributes); diff --git a/source/blender/bmesh/intern/bmesh_mesh_debug.cc b/source/blender/bmesh/intern/bmesh_mesh_debug.cc index de4a81e52ce..b3671991886 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_debug.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_debug.cc @@ -13,7 +13,7 @@ #ifndef NDEBUG -# include +# include # include "MEM_guardedalloc.h" diff --git a/source/blender/bmesh/intern/bmesh_mesh_duplicate.cc b/source/blender/bmesh/intern/bmesh_mesh_duplicate.cc index f2b76cc6e16..6d2221e8b8a 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_duplicate.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_duplicate.cc @@ -8,11 +8,15 @@ * Duplicate geometry from one mesh from another. */ +#include "DNA_object_types.h" + #include "MEM_guardedalloc.h" #include "BLI_alloca.h" +#include "BLI_math_vector.h" #include "bmesh.hh" +#include "intern/bmesh_private.hh" /* for element checking */ static BMVert *bm_vert_copy(BMesh *bm_dst, const std::optional &cd_vert_map, diff --git a/source/blender/bmesh/intern/bmesh_mesh_normals.cc b/source/blender/bmesh/intern/bmesh_mesh_normals.cc index f2571d0ae3c..5acf31e3e62 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_normals.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_normals.cc @@ -24,7 +24,7 @@ #include "BKE_customdata.hh" #include "BKE_editmesh.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_mesh.hh" #include "intern/bmesh_private.hh" diff --git a/source/blender/bmesh/intern/bmesh_mesh_partial_update.cc b/source/blender/bmesh/intern/bmesh_mesh_partial_update.cc index 70ec7a4dedb..3ea4551b6c7 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_partial_update.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_partial_update.cc @@ -35,9 +35,13 @@ * \note Others can be added as needed. */ +#include "DNA_object_types.h" + #include "MEM_guardedalloc.h" +#include "BLI_alloca.h" #include "BLI_bitmap.h" +#include "BLI_math_vector.h" #include "bmesh.hh" diff --git a/source/blender/bmesh/intern/bmesh_mesh_tessellate.cc b/source/blender/bmesh/intern/bmesh_mesh_tessellate.cc index 518f2b93521..b8494e25d0b 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_tessellate.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_tessellate.cc @@ -13,7 +13,9 @@ #include "MEM_guardedalloc.h" +#include "BLI_alloca.h" #include "BLI_heap.h" +#include "BLI_linklist.h" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" #include "BLI_memarena.h" @@ -22,6 +24,7 @@ #include "BLI_task.h" #include "bmesh.hh" +#include "bmesh_tools.hh" /** * On systems with 32+ cores, diff --git a/source/blender/bmesh/intern/bmesh_operators.cc b/source/blender/bmesh/intern/bmesh_operators.cc index d45466122d6..dc4493acc70 100644 --- a/source/blender/bmesh/intern/bmesh_operators.cc +++ b/source/blender/bmesh/intern/bmesh_operators.cc @@ -18,7 +18,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "bmesh.hh" #include "intern/bmesh_private.hh" diff --git a/source/blender/bmesh/intern/bmesh_polygon.cc b/source/blender/bmesh/intern/bmesh_polygon.cc index bfc889d30b0..b5c6c88a48c 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.cc +++ b/source/blender/bmesh/intern/bmesh_polygon.cc @@ -15,6 +15,7 @@ #include "MEM_guardedalloc.h" #include "BLI_alloca.h" +#include "BLI_heap.h" #include "BLI_linklist.h" #include "BLI_math_base.hh" #include "BLI_math_geom.h" diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.cc b/source/blender/bmesh/intern/bmesh_polygon_edgenet.cc index 5e5aa0fbfd7..0351f136050 100644 --- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.cc +++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.cc @@ -1642,7 +1642,7 @@ finally: /* Sanity check: ensure we don't have connecting edges before splicing begins. */ # ifndef NDEBUG { - TempVertPair *tvp = temp_vert_pairs.list; + struct TempVertPair *tvp = temp_vert_pairs.list; do { /* We must _never_ create connections here * (in case the islands can't have a connection at all). */ diff --git a/source/blender/bmesh/intern/bmesh_query_uv.cc b/source/blender/bmesh/intern/bmesh_query_uv.cc index a22c3ae8365..7c94997eb7d 100644 --- a/source/blender/bmesh/intern/bmesh_query_uv.cc +++ b/source/blender/bmesh/intern/bmesh_query_uv.cc @@ -9,14 +9,17 @@ #include "MEM_guardedalloc.h" #include "BLI_array.hh" +#include "BLI_linklist.h" #include "BLI_math_geom.h" #include "BLI_math_vector.h" #include "BLI_math_vector_types.hh" +#include "BLI_utildefines_stack.h" #include "BKE_attribute.hh" #include "BKE_customdata.hh" #include "bmesh.hh" +#include "intern/bmesh_private.hh" BMUVOffsets BM_uv_map_get_offsets_from_layer(const BMesh *bm, const int layer) { diff --git a/source/blender/bmesh/operators/bmo_bevel.cc b/source/blender/bmesh/operators/bmo_bevel.cc index 4812d287c45..c46a7b33195 100644 --- a/source/blender/bmesh/operators/bmo_bevel.cc +++ b/source/blender/bmesh/operators/bmo_bevel.cc @@ -10,6 +10,7 @@ #include "BLI_utildefines.h" +#include "BKE_curveprofile.h" #include "DNA_curveprofile_types.h" #include "bmesh.hh" #include "bmesh_tools.hh" diff --git a/source/blender/bmesh/operators/bmo_fill_edgeloop.cc b/source/blender/bmesh/operators/bmo_fill_edgeloop.cc index 6c1913f8634..0da0393e2d0 100644 --- a/source/blender/bmesh/operators/bmo_fill_edgeloop.cc +++ b/source/blender/bmesh/operators/bmo_fill_edgeloop.cc @@ -10,6 +10,8 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" + #include "bmesh.hh" #include "intern/bmesh_operators_private.hh" /* own include */ diff --git a/source/blender/bmesh/operators/bmo_fill_grid.cc b/source/blender/bmesh/operators/bmo_fill_grid.cc index d1a6c9d1351..864df11a05a 100644 --- a/source/blender/bmesh/operators/bmo_fill_grid.cc +++ b/source/blender/bmesh/operators/bmo_fill_grid.cc @@ -20,7 +20,7 @@ #include "intern/bmesh_operators_private.hh" /* own include */ -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" #define EDGE_MARK 4 #define FACE_OUT 16 diff --git a/source/blender/bmesh/operators/bmo_mesh_convert.cc b/source/blender/bmesh/operators/bmo_mesh_convert.cc index 98cc5efc2ac..9619e5869bb 100644 --- a/source/blender/bmesh/operators/bmo_mesh_convert.cc +++ b/source/blender/bmesh/operators/bmo_mesh_convert.cc @@ -17,7 +17,7 @@ #include "bmesh.hh" #include "intern/bmesh_operators_private.hh" -#include "BKE_global.hh" +#include "BKE_global.h" void bmo_mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { diff --git a/source/blender/bmesh/operators/bmo_utils.cc b/source/blender/bmesh/operators/bmo_utils.cc index 7268d50c930..4045c34d64a 100644 --- a/source/blender/bmesh/operators/bmo_utils.cc +++ b/source/blender/bmesh/operators/bmo_utils.cc @@ -13,6 +13,7 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" +#include "DNA_object_types.h" #include "BLI_alloca.h" #include "BLI_math_matrix.h" @@ -20,6 +21,7 @@ #include "BKE_attribute.hh" #include "BKE_customdata.hh" +#include "BKE_object.hh" #include "bmesh.hh" diff --git a/source/blender/bmesh/tools/bmesh_bevel.cc b/source/blender/bmesh/tools/bmesh_bevel.cc index ba342d82f6d..2f73e4943d7 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.cc +++ b/source/blender/bmesh/tools/bmesh_bevel.cc @@ -13,6 +13,7 @@ #include "DNA_curveprofile_types.h" #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" +#include "DNA_scene_types.h" #include "BLI_alloca.h" #include "BLI_math_geom.h" @@ -7763,7 +7764,7 @@ void BM_mesh_bevel(BMesh *bm, } #ifdef BEVEL_DEBUG_TIME - double start_time = BLI_time_now_seconds(); + double start_time = BLI_check_seconds_timer(); #endif /* Disable the miters with the cutoff vertex mesh method, the combination isn't useful anyway. */ @@ -7931,7 +7932,7 @@ void BM_mesh_bevel(BMesh *bm, BLI_memarena_free(bp.mem_arena); #ifdef BEVEL_DEBUG_TIME - double end_time = BLI_time_now_seconds(); + double end_time = BLI_check_seconds_timer(); printf("BMESH BEVEL TIME = %.3f\n", end_time - start_time); #endif } diff --git a/source/blender/bmesh/tools/bmesh_bisect_plane.cc b/source/blender/bmesh/tools/bmesh_bisect_plane.cc index 915c571d1eb..545c8c2a0ea 100644 --- a/source/blender/bmesh/tools/bmesh_bisect_plane.cc +++ b/source/blender/bmesh/tools/bmesh_bisect_plane.cc @@ -23,6 +23,7 @@ #include "BLI_linklist.h" #include "BLI_linklist_stack.h" #include "BLI_math_geom.h" +#include "BLI_math_matrix.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" #include "BLI_utildefines_stack.h" diff --git a/source/blender/bmesh/tools/bmesh_boolean.cc b/source/blender/bmesh/tools/bmesh_boolean.cc index 47403cf383a..7d776390481 100644 --- a/source/blender/bmesh/tools/bmesh_boolean.cc +++ b/source/blender/bmesh/tools/bmesh_boolean.cc @@ -14,6 +14,7 @@ #include "BLI_math_mpq.hh" #include "BLI_mesh_boolean.hh" #include "BLI_mesh_intersect.hh" +#include "BLI_time.h" #include "bmesh.hh" #include "bmesh_boolean.hh" @@ -350,11 +351,11 @@ static bool bmesh_boolean(BMesh *bm, IMeshArena arena; IMesh m_triangulated; # ifdef PERF_DEBUG - double start_time = BLI_time_now_seconds(); + double start_time = BLI_check_seconds_timer(); # endif IMesh m_in = mesh_from_bm(bm, looptris, looptris_tot, &m_triangulated, &arena); # ifdef PERF_DEBUG - double mesh_time = BLI_time_now_seconds(); + double mesh_time = BLI_check_seconds_timer(); std::cout << "bmesh_boolean, imesh_from_bm done, time = " << mesh_time - start_time << "\n"; # endif std::function shape_fn; @@ -382,12 +383,12 @@ static bool bmesh_boolean(BMesh *bm, IMesh m_out = boolean_mesh( m_in, boolean_mode, nshapes, shape_fn, use_self, hole_tolerant, &m_triangulated, &arena); # ifdef PERF_DEBUG - double boolean_time = BLI_time_now_seconds(); + double boolean_time = BLI_check_seconds_timer(); std::cout << "boolean done, time = " << boolean_time - mesh_time << "\n"; # endif bool any_change = apply_mesh_output_to_bmesh(bm, m_out, keep_hidden); # ifdef PERF_DEBUG - double apply_mesh_time = BLI_time_now_seconds(); + double apply_mesh_time = BLI_check_seconds_timer(); std::cout << "applied boolean output to bmesh, time = " << apply_mesh_time - boolean_time << "\n"; # endif diff --git a/source/blender/bmesh/tools/bmesh_edgenet.cc b/source/blender/bmesh/tools/bmesh_edgenet.cc index 87493b24425..4136dadff3f 100644 --- a/source/blender/bmesh/tools/bmesh_edgenet.cc +++ b/source/blender/bmesh/tools/bmesh_edgenet.cc @@ -20,7 +20,7 @@ #include "bmesh.hh" #include "bmesh_edgenet.hh" /* own include */ -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* keep last */ /* Struct for storing a path of verts walked over */ struct VertNetInfo { diff --git a/source/blender/bmesh/tools/bmesh_intersect.cc b/source/blender/bmesh/tools/bmesh_intersect.cc index 0090464d1c3..f45f29c6718 100644 --- a/source/blender/bmesh/tools/bmesh_intersect.cc +++ b/source/blender/bmesh/tools/bmesh_intersect.cc @@ -41,7 +41,7 @@ #include "tools/bmesh_edgesplit.hh" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* * Some of these depend on each other: diff --git a/source/blender/bmesh/tools/bmesh_path_uv.cc b/source/blender/bmesh/tools/bmesh_path_uv.cc index b0551727ef8..9b0c6261135 100644 --- a/source/blender/bmesh/tools/bmesh_path_uv.cc +++ b/source/blender/bmesh/tools/bmesh_path_uv.cc @@ -15,6 +15,8 @@ #include "BLI_math_geom.h" #include "BLI_math_vector.h" +#include "DNA_meshdata_types.h" + #include "bmesh.hh" #include "bmesh_path_uv.hh" /* own include */ #include "intern/bmesh_query.hh" diff --git a/source/blender/bmesh/tools/bmesh_region_match.cc b/source/blender/bmesh/tools/bmesh_region_match.cc index 1f723faffef..ad4c002111e 100644 --- a/source/blender/bmesh/tools/bmesh_region_match.cc +++ b/source/blender/bmesh/tools/bmesh_region_match.cc @@ -52,7 +52,7 @@ # include "BLI_time_utildefines.h" #endif -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* -------------------------------------------------------------------- */ /** \name Internal UIDWalk API diff --git a/source/blender/bmesh/tools/bmesh_wireframe.cc b/source/blender/bmesh/tools/bmesh_wireframe.cc index 8edfb203f57..fada3432fd3 100644 --- a/source/blender/bmesh/tools/bmesh_wireframe.cc +++ b/source/blender/bmesh/tools/bmesh_wireframe.cc @@ -12,6 +12,8 @@ #include "MEM_guardedalloc.h" +#include "DNA_meshdata_types.h" + #include "bmesh.hh" #include "BLI_math_geom.h" diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index c2c22f141bc..6a034ef2e06 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -35,7 +35,6 @@ if(WITH_COMPOSITOR_CPU) set(SRC COM_compositor.hh COM_defines.h - COM_profile.hh intern/COM_BufferArea.h intern/COM_BufferOperation.cc @@ -101,7 +100,6 @@ if(WITH_COMPOSITOR_CPU) intern/COM_WorkScheduler.cc intern/COM_WorkScheduler.h intern/COM_compositor.cc - intern/COM_profile.cc operations/COM_QualityStepHelper.cc operations/COM_QualityStepHelper.h diff --git a/source/blender/compositor/COM_compositor.hh b/source/blender/compositor/COM_compositor.hh index a70edbb5d02..896da42a0c7 100644 --- a/source/blender/compositor/COM_compositor.hh +++ b/source/blender/compositor/COM_compositor.hh @@ -10,9 +10,6 @@ namespace blender::realtime_compositor { class RenderContext; } -namespace blender::compositor { -class ProfilerData; -} struct Render; @@ -328,7 +325,7 @@ struct Render; * should be checked further, probably it'll be also needed for preview * generation in display space */ -/* clang-format on */ +/* clang-format off */ void COM_execute(Render *render, RenderData *render_data, @@ -336,8 +333,7 @@ void COM_execute(Render *render, bNodeTree *node_tree, bool rendering, const char *view_name, - blender::realtime_compositor::RenderContext *render_context, - blender::compositor::ProfilerData &profiler_data); + blender::realtime_compositor::RenderContext *render_context); /** * \brief Deinitialize the compositor caches and allocated memory. diff --git a/source/blender/compositor/COM_profile.hh b/source/blender/compositor/COM_profile.hh deleted file mode 100644 index c71274eda9a..00000000000 --- a/source/blender/compositor/COM_profile.hh +++ /dev/null @@ -1,58 +0,0 @@ -/* SPDX-FileCopyrightText: 2024 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#pragma once - -#include "BLI_map.hh" -#include "BLI_timeit.hh" - -#include "DNA_node_types.h" - -#include "BKE_node.hh" - -struct bNodeTree; - -namespace blender::compositor { - -class NodeOperation; - -/* Profiling data gathered during execution of a compositing node tree. */ -class ProfilerData { - public: - /* Per-node accumulated execution time. Includes execution time of all operations the node was - * broken down into. */ - Map per_node_execution_time; -}; - -/* Profiler implementation which is used by the node execution system. */ -class Profiler { - /* Local copy of the profiling data, which is known to not cause threading conflicts with the - * interface thread while the compositing tree is evaluated in the background. */ - ProfilerData data_; - - public: - void add_operation_execution_time(const NodeOperation &operation, - const timeit::TimePoint &start, - const timeit::TimePoint &end); - - void finalize(const bNodeTree &node_tree); - - const ProfilerData &get_data() const - { - return data_; - } - - private: - /* Add execution time to the node denoted by its key. */ - void add_execution_time(const bNodeInstanceKey parent_key, - const timeit::Nanoseconds &execution_time); - - /* Accumulate execution time of the group node instances, and store their execution time in the - * per_node_execution_time_. - * Returns total execution time of the given node tree. */ - timeit::Nanoseconds accumulate_node_group_times( - const bNodeTree &node_tree, const bNodeInstanceKey parent_key = NODE_INSTANCE_KEY_BASE); -}; - -} // namespace blender::compositor diff --git a/source/blender/compositor/intern/COM_CompositorContext.cc b/source/blender/compositor/intern/COM_CompositorContext.cc index cd8d83c727f..816fcf60397 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.cc +++ b/source/blender/compositor/intern/COM_CompositorContext.cc @@ -30,7 +30,18 @@ Size2f CompositorContext::get_render_size() const eExecutionModel CompositorContext::get_execution_model() const { - return eExecutionModel::FullFrame; + if (U.experimental.use_full_frame_compositor) { + BLI_assert(bnodetree_ != nullptr); + switch (bnodetree_->execution_mode) { + case 1: + return eExecutionModel::FullFrame; + case 0: + return eExecutionModel::Tiled; + default: + BLI_assert_msg(0, "Invalid execution mode"); + } + } + return eExecutionModel::Tiled; } } // namespace blender::compositor diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h index acc4af1d23d..dbe3851aede 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.h +++ b/source/blender/compositor/intern/COM_CompositorContext.h @@ -236,7 +236,7 @@ class CompositorContext { int get_chunksize() const { - return 256; + return this->get_bnodetree()->chunksize; } void set_fast_calculation(bool fast_calculation) @@ -249,7 +249,7 @@ class CompositorContext { } bool is_groupnode_buffer_enabled() const { - return false; + return (this->get_bnodetree()->flag & NTREE_COM_GROUPNODE_BUFFER) != 0; } /** diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cc b/source/blender/compositor/intern/COM_ExecutionGroup.cc index d4535a95dc1..12ad6a0be57 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cc +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc @@ -15,7 +15,7 @@ #include "BLI_string.h" #include "BLI_time.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" namespace blender::compositor { @@ -304,7 +304,7 @@ void ExecutionGroup::execute(ExecutionSystem *graph) } /** \note Early break out. */ uint chunk_index; - execution_start_time_ = BLI_time_now_seconds(); + execution_start_time_ = BLI_check_seconds_timer(); chunks_finished_ = 0; bTree_ = bTree; diff --git a/source/blender/compositor/intern/COM_ExecutionModel.h b/source/blender/compositor/intern/COM_ExecutionModel.h index d08699da5cd..2ce24e5e06b 100644 --- a/source/blender/compositor/intern/COM_ExecutionModel.h +++ b/source/blender/compositor/intern/COM_ExecutionModel.h @@ -12,14 +12,11 @@ # include "MEM_guardedalloc.h" #endif -#include "COM_profile.hh" - namespace blender::compositor { class CompositorContext; class ExecutionSystem; class NodeOperation; -class ProfilerData; /** * Base class for execution models. Contains shared implementation. @@ -46,8 +43,6 @@ class ExecutionModel { */ Span operations_; - Profiler profiler_; - public: ExecutionModel(CompositorContext &context, Span operations); @@ -55,11 +50,6 @@ class ExecutionModel { virtual void execute(ExecutionSystem &exec_system) = 0; - const ProfilerData &get_profiler_data() const - { - return profiler_.get_data(); - } - #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("COM:BaseExecutionModel") #endif diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cc b/source/blender/compositor/intern/COM_ExecutionSystem.cc index dc334b85c3c..5740ec26333 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cc +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cc @@ -25,9 +25,7 @@ ExecutionSystem::ExecutionSystem(RenderData *rd, bool rendering, bool fastcalculation, const char *view_name, - realtime_compositor::RenderContext *render_context, - ProfilerData &profiler_data) - : profiler_data_(profiler_data) + realtime_compositor::RenderContext *render_context) { num_work_threads_ = WorkScheduler::get_num_cpu_threads(); context_.set_render_context(render_context); @@ -44,7 +42,8 @@ ExecutionSystem::ExecutionSystem(RenderData *rd, context_.set_quality((eCompositorQuality)editingtree->edit_quality); } context_.set_rendering(rendering); - context_.setHasActiveOpenCLDevices(WorkScheduler::has_gpu_devices() && false); + context_.setHasActiveOpenCLDevices(WorkScheduler::has_gpu_devices() && + (editingtree->flag & NTREE_COM_OPENCL)); context_.set_render_data(rd); @@ -87,8 +86,8 @@ ExecutionSystem::~ExecutionSystem() groups_.clear(); } -void ExecutionSystem::set_operations(const Span operations, - const Span groups) +void ExecutionSystem::set_operations(const Vector &operations, + const Vector &groups) { operations_ = operations; groups_ = groups; @@ -101,8 +100,6 @@ void ExecutionSystem::execute() op->init_data(); } execution_model_->execute(*this); - - profiler_data_ = execution_model_->get_profiler_data(); } void ExecutionSystem::execute_work(const rcti &work_rect, diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h index 3c3c8b63aa0..4e367a73248 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.h +++ b/source/blender/compositor/intern/COM_ExecutionSystem.h @@ -26,8 +26,6 @@ class RenderContext; namespace blender::compositor { -class ProfilerData; - /** * \page execution Execution model * In order to get to an efficient model for execution, several steps are being done. these steps @@ -154,8 +152,6 @@ class ExecutionSystem { ThreadMutex work_mutex_; ThreadCondition work_finished_cond_; - ProfilerData &profiler_data_; - public: /** * \brief Create a new ExecutionSystem and initialize it with the @@ -170,15 +166,15 @@ class ExecutionSystem { bool rendering, bool fastcalculation, const char *view_name, - realtime_compositor::RenderContext *render_context, - ProfilerData &profiler_data); + realtime_compositor::RenderContext *render_context); /** * Destructor */ ~ExecutionSystem(); - void set_operations(Span operations, Span groups); + void set_operations(const Vector &operations, + const Vector &groups); /** * \brief execute this system diff --git a/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc b/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc index 0f5af05d28f..1ac1d2d4be7 100644 --- a/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc +++ b/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc @@ -6,14 +6,12 @@ #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "COM_Debug.h" #include "COM_ViewerOperation.h" #include "COM_WorkScheduler.h" -#include "BLI_timeit.hh" - #ifdef WITH_CXX_GUARDEDALLOC # include "MEM_guardedalloc.h" #endif @@ -44,8 +42,6 @@ void FullFrameExecutionModel::execute(ExecutionSystem &exec_system) determine_areas_to_render_and_reads(); render_operations(); - - profiler_.finalize(*node_tree); } void FullFrameExecutionModel::determine_areas_to_render_and_reads() @@ -105,8 +101,6 @@ void FullFrameExecutionModel::render_operation(NodeOperation *op) constexpr int output_x = 0; constexpr int output_y = 0; - const timeit::TimePoint time_start = timeit::Clock::now(); - const bool has_outputs = op->get_number_of_output_sockets() > 0; MemoryBuffer *op_buf = has_outputs ? create_operation_buffer(op, output_x, output_y) : nullptr; if (op->get_width() > 0 && op->get_height() > 0) { @@ -126,8 +120,6 @@ void FullFrameExecutionModel::render_operation(NodeOperation *op) active_buffers_.set_rendered_buffer(op, std::unique_ptr(op_buf)); operation_finished(op); - - profiler_.add_operation_execution_time(*op, time_start, timeit::Clock::now()); } void FullFrameExecutionModel::render_operations() diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h index 7d79b342870..b957fbf3eba 100644 --- a/source/blender/compositor/intern/COM_Node.h +++ b/source/blender/compositor/intern/COM_Node.h @@ -98,7 +98,7 @@ class Node { /** * \brief get access to the vector of input sockets */ - Span get_input_sockets() const + const Vector &get_input_sockets() const { return inputs_; } @@ -106,7 +106,7 @@ class Node { /** * \brief get access to the vector of input sockets */ - Span get_output_sockets() const + const Vector &get_output_sockets() const { return outputs_; } diff --git a/source/blender/compositor/intern/COM_NodeGraph.h b/source/blender/compositor/intern/COM_NodeGraph.h index b4d9a9a94e8..6a0592e66e1 100644 --- a/source/blender/compositor/intern/COM_NodeGraph.h +++ b/source/blender/compositor/intern/COM_NodeGraph.h @@ -37,11 +37,11 @@ class NodeGraph { public: ~NodeGraph(); - Span nodes() const + const Vector &nodes() const { return nodes_; } - Span links() const + const Vector &links() const { return links_; } diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index 9062602c32e..82c002e1852 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -19,7 +19,6 @@ #include "COM_MemoryBuffer.h" #include "COM_MetaData.h" -#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "clew.h" @@ -311,8 +310,6 @@ class NodeOperation { private: int id_; std::string name_; - bNodeInstanceKey node_instance_key_{NODE_INSTANCE_KEY_NONE}; - Vector inputs_; Vector outputs_; @@ -380,15 +377,6 @@ class NodeOperation { return id_; } - const void set_node_instance_key(const bNodeInstanceKey &node_instance_key) - { - node_instance_key_ = node_instance_key; - } - const bNodeInstanceKey get_node_instance_key() const - { - return node_instance_key_; - } - /** Get constant value when operation is constant, otherwise return default_value. */ float get_constant_value_default(float default_value); /** Get constant elem when operation is constant, otherwise return default_elem. */ diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc index c3174c351eb..70a2fbbe12f 100644 --- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc +++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc @@ -124,7 +124,6 @@ void NodeOperationBuilder::add_operation(NodeOperation *operation) operations_.append(operation); if (current_node_) { operation->set_name(current_node_->get_bnode()->name); - operation->set_node_instance_key(current_node_->get_instance_key()); } operation->set_execution_model(context_->get_execution_model()); operation->set_execution_system(exec_system_); diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.h b/source/blender/compositor/intern/COM_NodeOperationBuilder.h index 2d9f4a2ce4e..e8319ede17b 100644 --- a/source/blender/compositor/intern/COM_NodeOperationBuilder.h +++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.h @@ -107,12 +107,12 @@ class NodeOperationBuilder { return active_viewer_; } - Span get_operations() const + const Vector &get_operations() const { return operations_; } - Span get_links() const + const Vector &get_links() const { return links_; } diff --git a/source/blender/compositor/intern/COM_TiledExecutionModel.cc b/source/blender/compositor/intern/COM_TiledExecutionModel.cc index 024673af965..62d4b1e0189 100644 --- a/source/blender/compositor/intern/COM_TiledExecutionModel.cc +++ b/source/blender/compositor/intern/COM_TiledExecutionModel.cc @@ -8,7 +8,7 @@ #include "COM_ReadBufferOperation.h" #include "COM_WorkScheduler.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #ifdef WITH_CXX_GUARDEDALLOC # include "MEM_guardedalloc.h" diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cc b/source/blender/compositor/intern/COM_WorkScheduler.cc index 7661fe9938a..484794f1722 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cc +++ b/source/blender/compositor/intern/COM_WorkScheduler.cc @@ -19,7 +19,7 @@ #include "BLI_threads.h" #include "BLI_vector.hh" -#include "BKE_global.hh" +#include "BKE_global.h" namespace blender::compositor { diff --git a/source/blender/compositor/intern/COM_compositor.cc b/source/blender/compositor/intern/COM_compositor.cc index 48659aad115..ea73f8c87d2 100644 --- a/source/blender/compositor/intern/COM_compositor.cc +++ b/source/blender/compositor/intern/COM_compositor.cc @@ -4,11 +4,11 @@ #include "BLI_threads.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_node.hh" #include "BKE_node_runtime.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "COM_ExecutionSystem.h" #include "COM_WorkScheduler.h" @@ -55,8 +55,7 @@ void COM_execute(Render *render, bNodeTree *node_tree, bool rendering, const char *view_name, - blender::realtime_compositor::RenderContext *render_context, - blender::compositor::ProfilerData &profiler_data) + blender::realtime_compositor::RenderContext *render_context) { /* Initialize mutex, TODO: this mutex init is actually not thread safe and * should be done somewhere as part of blender startup, all the other @@ -79,29 +78,25 @@ void COM_execute(Render *render, compositor_reset_node_tree_status(node_tree); if (U.experimental.use_full_frame_compositor && - node_tree->execution_mode == NTREE_EXECUTION_MODE_GPU) + node_tree->execution_mode == NTREE_EXECUTION_MODE_REALTIME) { - /* GPU compositor. */ + /* Realtime GPU compositor. */ RE_compositor_execute( *render, *scene, *render_data, *node_tree, rendering, view_name, render_context); } else { - /* CPU compositor. */ + /* Tiled and Full Frame compositors. */ /* Initialize workscheduler. */ - blender::compositor::WorkScheduler::initialize(false, BKE_render_num_threads(render_data)); + const bool use_opencl = (node_tree->flag & NTREE_COM_OPENCL) != 0; + blender::compositor::WorkScheduler::initialize(use_opencl, + BKE_render_num_threads(render_data)); /* Execute. */ const bool twopass = (node_tree->flag & NTREE_TWO_PASS) && !rendering; if (twopass) { - blender::compositor::ExecutionSystem fast_pass(render_data, - scene, - node_tree, - rendering, - true, - view_name, - render_context, - profiler_data); + blender::compositor::ExecutionSystem fast_pass( + render_data, scene, node_tree, rendering, true, view_name, render_context); fast_pass.execute(); if (node_tree->runtime->test_break(node_tree->runtime->tbh)) { @@ -111,7 +106,7 @@ void COM_execute(Render *render, } blender::compositor::ExecutionSystem system( - render_data, scene, node_tree, rendering, false, view_name, render_context, profiler_data); + render_data, scene, node_tree, rendering, false, view_name, render_context); system.execute(); } diff --git a/source/blender/compositor/intern/COM_profile.cc b/source/blender/compositor/intern/COM_profile.cc deleted file mode 100644 index 5bfee3b269d..00000000000 --- a/source/blender/compositor/intern/COM_profile.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* SPDX-FileCopyrightText: 2024 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#include "COM_profile.hh" - -#include "BKE_node_runtime.hh" - -#include "COM_NodeOperation.h" - -#include "DNA_node_types.h" - -namespace blender::compositor { - -void Profiler::add_operation_execution_time(const NodeOperation &operation, - const timeit::TimePoint &start, - const timeit::TimePoint &end) -{ - const timeit::Nanoseconds execution_time = end - start; - - const bNodeInstanceKey key = operation.get_node_instance_key(); - if (key.value == NODE_INSTANCE_KEY_NONE.value) { - /* The operation does not come from any node. It was, for example, added to convert data type. - * Do not accumulate time from its execution. */ - return; - } - - this->add_execution_time(key, execution_time); -} - -void Profiler::add_execution_time(const bNodeInstanceKey key, - const timeit::Nanoseconds &execution_time) -{ - data_.per_node_execution_time.lookup_or_add(key, timeit::Nanoseconds(0)) += execution_time; -} - -void Profiler::finalize(const bNodeTree &node_tree) -{ - this->accumulate_node_group_times(node_tree); -} - -timeit::Nanoseconds Profiler::accumulate_node_group_times(const bNodeTree &node_tree, - const bNodeInstanceKey parent_key) -{ - timeit::Nanoseconds tree_execution_time(0); - - for (const bNode *node : node_tree.all_nodes()) { - const bNodeInstanceKey key = BKE_node_instance_key(parent_key, &node_tree, node); - - if (node->type != NODE_GROUP) { - /* Non-group node, no need to recurse into. Simply accumulate the node's execution time to - * the current tree's execution time. */ - tree_execution_time += data_.per_node_execution_time.lookup_default(key, - timeit::Nanoseconds(0)); - continue; - } - - if (node->id == nullptr) { - /* Node group has lost link to its node tree. For example, due to missing linked file. */ - continue; - } - - const timeit::Nanoseconds group_execution_time = this->accumulate_node_group_times( - *reinterpret_cast(node->id), key); - - /* Store execution time of the group node. */ - this->add_execution_time(key, group_execution_time); - - /* Add group execution time to the overall tree execution time. */ - tree_execution_time += group_execution_time; - } - - return tree_execution_time; -} - -} // namespace blender::compositor diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cc b/source/blender/compositor/nodes/COM_BokehBlurNode.cc index 43099ab4333..b685b212e7e 100644 --- a/source/blender/compositor/nodes/COM_BokehBlurNode.cc +++ b/source/blender/compositor/nodes/COM_BokehBlurNode.cc @@ -34,7 +34,6 @@ void BokehBlurNode::convert_to_operations(NodeConverter &converter, converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0)); converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1)); converter.map_input_socket(get_input_socket(2), operation->get_input_socket(2)); - converter.map_input_socket(get_input_socket(3), operation->get_input_socket(3)); converter.map_output_socket(get_output_socket(0), operation->get_output_socket()); } else { diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cc b/source/blender/compositor/nodes/COM_DefocusNode.cc index 239924d7dd6..5330766f71b 100644 --- a/source/blender/compositor/nodes/COM_DefocusNode.cc +++ b/source/blender/compositor/nodes/COM_DefocusNode.cc @@ -94,10 +94,6 @@ void DefocusNode::convert_to_operations(NodeConverter &converter, bokeh->delete_data_on_finish(); converter.add_operation(bokeh); - SetValueOperation *bounding_box_operation = new SetValueOperation(); - bounding_box_operation->set_value(1.0f); - converter.add_operation(bounding_box_operation); - VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); operation->set_quality(eCompositorQuality::High); operation->set_max_blur(data->maxblur); @@ -106,7 +102,6 @@ void DefocusNode::convert_to_operations(NodeConverter &converter, converter.add_link(bokeh->get_output_socket(), operation->get_input_socket(1)); converter.add_link(radius_operation->get_output_socket(), operation->get_input_socket(2)); - converter.add_link(bounding_box_operation->get_output_socket(), operation->get_input_socket(3)); if (data->gamco) { GammaCorrectOperation *correct = new GammaCorrectOperation(); diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cc b/source/blender/compositor/operations/COM_CalculateMeanOperation.cc index 23450b20246..89f6020a177 100644 --- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cc +++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cc @@ -15,24 +15,20 @@ CalculateMeanOperation::CalculateMeanOperation() this->add_input_socket(DataType::Color, ResizeMode::Align); this->add_output_socket(DataType::Value); image_reader_ = nullptr; - is_calculated_ = false; + iscalculated_ = false; setting_ = 1; flags_.complex = true; - flags_.is_constant_operation = true; - - needs_canvas_to_get_constant_ = true; } - void CalculateMeanOperation::init_execution() { image_reader_ = this->get_input_socket_reader(0); - is_calculated_ = false; + iscalculated_ = false; NodeOperation::init_mutex(); } void CalculateMeanOperation::execute_pixel(float output[4], int /*x*/, int /*y*/, void * /*data*/) { - output[0] = constant_value_; + output[0] = result_; } void CalculateMeanOperation::deinit_execution() @@ -45,7 +41,7 @@ bool CalculateMeanOperation::determine_depending_area_of_interest( rcti * /*input*/, ReadBufferOperation *read_operation, rcti *output) { rcti image_input; - if (is_calculated_) { + if (iscalculated_) { return false; } NodeOperation *operation = get_input_operation(0); @@ -62,17 +58,18 @@ bool CalculateMeanOperation::determine_depending_area_of_interest( void *CalculateMeanOperation::initialize_tile_data(rcti *rect) { lock_mutex(); - if (!is_calculated_) { + if (!iscalculated_) { MemoryBuffer *tile = (MemoryBuffer *)image_reader_->initialize_tile_data(rect); - constant_value_ = calculate_mean_tile(tile); - is_calculated_ = true; + calculate_mean(tile); + iscalculated_ = true; } unlock_mutex(); return nullptr; } -float CalculateMeanOperation::calculate_mean_tile(MemoryBuffer *tile) const +void CalculateMeanOperation::calculate_mean(MemoryBuffer *tile) { + result_ = 0.0f; float *buffer = tile->get_buffer(); int size = tile->get_width() * tile->get_height(); int pixels = 0; @@ -113,7 +110,7 @@ float CalculateMeanOperation::calculate_mean_tile(MemoryBuffer *tile) const } } } - return sum / pixels; + result_ = sum / pixels; } void CalculateMeanOperation::set_setting(int setting) @@ -155,41 +152,25 @@ void CalculateMeanOperation::get_area_of_interest(int input_idx, r_input_area = get_input_operation(input_idx)->get_canvas(); } -void CalculateMeanOperation::determine_canvas(const rcti &preferred_area, rcti &r_area) +void CalculateMeanOperation::update_memory_buffer_started(MemoryBuffer * /*output*/, + const rcti & /*area*/, + Span inputs) { - ConstantOperation::determine_canvas(preferred_area, r_area); - r_area = preferred_area; -} - -const float *CalculateMeanOperation::get_constant_elem() -{ - /* Node de-duplication uses the constant value as part of a hash for constant operations. - * The constant is not known in advance here, but need to return something. The value does - * not really matter, because if two CalculateMean operations are connected to different - * inputs it will be handled via hash of the input subtree. */ - static float f = 0; - return &f; -} - -void CalculateMeanOperation::update_memory_buffer(MemoryBuffer *output, - const rcti &area, - Span inputs) -{ - if (!is_calculated_) { + if (!iscalculated_) { MemoryBuffer *input = inputs[0]; - constant_value_ = calculate_value(input); - is_calculated_ = true; + result_ = calc_mean(input); + iscalculated_ = true; } - - output->fill(area, &constant_value_); } -float CalculateMeanOperation::calculate_value(const MemoryBuffer *input) const +void CalculateMeanOperation::update_memory_buffer_partial(MemoryBuffer *output, + const rcti &area, + Span /*inputs*/) { - return calculate_mean(input); + output->fill(area, &result_); } -float CalculateMeanOperation::calculate_mean(const MemoryBuffer *input) const +float CalculateMeanOperation::calc_mean(const MemoryBuffer *input) { PixelsSum total = {0}; exec_system_->execute_work( @@ -204,7 +185,7 @@ float CalculateMeanOperation::calculate_mean(const MemoryBuffer *input) const } using PixelsSum = CalculateMeanOperation::PixelsSum; -PixelsSum CalculateMeanOperation::calc_area_sum(const MemoryBuffer *input, const rcti &area) const +PixelsSum CalculateMeanOperation::calc_area_sum(const MemoryBuffer *input, const rcti &area) { PixelsSum result = {0}; for (const float *elem : input->get_buffer_area(area)) { diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.h b/source/blender/compositor/operations/COM_CalculateMeanOperation.h index 4649e7f3c53..ff176c2a129 100644 --- a/source/blender/compositor/operations/COM_CalculateMeanOperation.h +++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.h @@ -4,7 +4,7 @@ #pragma once -#include "COM_ConstantOperation.h" +#include "COM_MultiThreadedOperation.h" #include "DNA_node_types.h" #include @@ -14,7 +14,7 @@ namespace blender::compositor { * \brief base class of CalculateMean, implementing the simple CalculateMean * \ingroup operation */ -class CalculateMeanOperation : public ConstantOperation { +class CalculateMeanOperation : public MultiThreadedOperation { public: struct PixelsSum { float sum; @@ -27,8 +27,8 @@ class CalculateMeanOperation : public ConstantOperation { */ SocketReader *image_reader_; - bool is_calculated_; - float constant_value_; + bool iscalculated_; + float result_; int setting_; std::function setting_func_; @@ -58,24 +58,21 @@ class CalculateMeanOperation : public ConstantOperation { void set_setting(int setting); void get_area_of_interest(int input_idx, const rcti &output_area, rcti &r_input_area) override; - void determine_canvas(const rcti &preferred_area, rcti &r_area) override; - const float *get_constant_elem() override; - void update_memory_buffer(MemoryBuffer *output, - const rcti &area, - Span inputs) override; + virtual void update_memory_buffer_started(MemoryBuffer *output, + const rcti &area, + Span inputs) override; + + virtual void update_memory_buffer_partial(MemoryBuffer *output, + const rcti &area, + Span inputs) override; protected: - /* Calculate value which will be written to the single-element output in the - * update_memory_buffer(). - * The caller takes care of checking the value is only calculated once. */ - virtual float calculate_value(const MemoryBuffer *input) const; - - float calculate_mean_tile(MemoryBuffer *tile) const; - float calculate_mean(const MemoryBuffer *input) const; + void calculate_mean(MemoryBuffer *tile); + float calc_mean(const MemoryBuffer *input); private: - PixelsSum calc_area_sum(const MemoryBuffer *input, const rcti &area) const; + PixelsSum calc_area_sum(const MemoryBuffer *input, const rcti &area); }; } // namespace blender::compositor diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cc b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cc index b67b890bc77..733064755d7 100644 --- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cc +++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cc @@ -21,14 +21,15 @@ void CalculateStandardDeviationOperation::execute_pixel(float output[4], void *CalculateStandardDeviationOperation::initialize_tile_data(rcti *rect) { lock_mutex(); - if (!is_calculated_) { + if (!iscalculated_) { MemoryBuffer *tile = (MemoryBuffer *)image_reader_->initialize_tile_data(rect); + CalculateMeanOperation::calculate_mean(tile); standard_deviation_ = 0.0f; float *buffer = tile->get_buffer(); int size = tile->get_width() * tile->get_height(); int pixels = 0; float sum = 0.0f; - const float mean = this->calculate_mean_tile(tile); + float mean = result_; for (int i = 0, offset = 0; i < size; i++, offset += 4) { if (buffer[offset + 3] > 0) { pixels++; @@ -75,33 +76,45 @@ void *CalculateStandardDeviationOperation::initialize_tile_data(rcti *rect) } } standard_deviation_ = sqrt(sum / float(pixels - 1)); - is_calculated_ = true; + iscalculated_ = true; } unlock_mutex(); return nullptr; } -float CalculateStandardDeviationOperation::calculate_value(const MemoryBuffer *input) const +void CalculateStandardDeviationOperation::update_memory_buffer_started(MemoryBuffer * /*output*/, + const rcti & /*area*/, + Span inputs) { - const float mean = this->calculate_mean(input); + if (!iscalculated_) { + const MemoryBuffer *input = inputs[0]; + const float mean = CalculateMeanOperation::calc_mean(input); - PixelsSum total = {0}; - exec_system_->execute_work( - input->get_rect(), - [=](const rcti &split) { return this->calc_area_sum(input, split, mean); }, - total, - [](PixelsSum &join, const PixelsSum &chunk) { - join.sum += chunk.sum; - join.num_pixels += chunk.num_pixels; - }); + PixelsSum total = {0}; + exec_system_->execute_work( + input->get_rect(), + [=](const rcti &split) { return calc_area_sum(input, split, mean); }, + total, + [](PixelsSum &join, const PixelsSum &chunk) { + join.sum += chunk.sum; + join.num_pixels += chunk.num_pixels; + }); + standard_deviation_ = total.num_pixels <= 1 ? 0.0f : + sqrt(total.sum / float(total.num_pixels - 1)); + iscalculated_ = true; + } +} - return total.num_pixels <= 1 ? 0.0f : sqrt(total.sum / float(total.num_pixels - 1)); +void CalculateStandardDeviationOperation::update_memory_buffer_partial( + MemoryBuffer *output, const rcti &area, Span /*inputs*/) +{ + output->fill(area, &standard_deviation_); } using PixelsSum = CalculateMeanOperation::PixelsSum; PixelsSum CalculateStandardDeviationOperation::calc_area_sum(const MemoryBuffer *input, const rcti &area, - const float mean) const + const float mean) { PixelsSum result = {0}; for (const float *elem : input->get_buffer_area(area)) { diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h index 1ba42786e5a..bfc71cbbf19 100644 --- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h +++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h @@ -27,11 +27,16 @@ class CalculateStandardDeviationOperation : public CalculateMeanOperation { void *initialize_tile_data(rcti *rect) override; - protected: - float calculate_value(const MemoryBuffer *input) const override; + void update_memory_buffer_started(MemoryBuffer *output, + const rcti &area, + Span inputs) override; + + void update_memory_buffer_partial(MemoryBuffer *output, + const rcti &area, + Span inputs) override; private: - PixelsSum calc_area_sum(const MemoryBuffer *input, const rcti &area, float mean) const; + PixelsSum calc_area_sum(const MemoryBuffer *input, const rcti &area, float mean); }; } // namespace blender::compositor diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cc b/source/blender/compositor/operations/COM_CompositorOperation.cc index 496a3307754..6ca2f8bac14 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.cc +++ b/source/blender/compositor/operations/COM_CompositorOperation.cc @@ -6,9 +6,9 @@ #include "BLI_string.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "IMB_imbuf.hh" diff --git a/source/blender/compositor/operations/COM_ConstantOperation.h b/source/blender/compositor/operations/COM_ConstantOperation.h index 2c5e976ddbc..a5a384c64dd 100644 --- a/source/blender/compositor/operations/COM_ConstantOperation.h +++ b/source/blender/compositor/operations/COM_ConstantOperation.h @@ -26,7 +26,9 @@ class ConstantOperation : public NodeOperation { virtual const float *get_constant_elem() = 0; bool can_get_constant_elem() const; - void update_memory_buffer(MemoryBuffer *output, const rcti &area, Span inputs); + void update_memory_buffer(MemoryBuffer *output, + const rcti &area, + Span inputs) final; }; } // namespace blender::compositor diff --git a/source/blender/compositor/operations/COM_DenoiseOperation.cc b/source/blender/compositor/operations/COM_DenoiseOperation.cc index d6315e2dbf8..52f09d4e79f 100644 --- a/source/blender/compositor/operations/COM_DenoiseOperation.cc +++ b/source/blender/compositor/operations/COM_DenoiseOperation.cc @@ -19,7 +19,7 @@ bool COM_is_denoise_supported() # ifdef __APPLE__ return true; # else - return BLI_cpu_support_sse42(); + return BLI_cpu_support_sse41(); # endif #else diff --git a/source/blender/compositor/operations/COM_FileOutputOperation.cc b/source/blender/compositor/operations/COM_FileOutputOperation.cc index a0c6d6295f7..01c33d995c8 100644 --- a/source/blender/compositor/operations/COM_FileOutputOperation.cc +++ b/source/blender/compositor/operations/COM_FileOutputOperation.cc @@ -16,7 +16,7 @@ #include "BKE_image.h" #include "BKE_image_format.h" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "RE_pipeline.h" diff --git a/source/blender/compositor/operations/COM_ImageOperation.cc b/source/blender/compositor/operations/COM_ImageOperation.cc index 8cff2ad0910..c9415306ebf 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.cc +++ b/source/blender/compositor/operations/COM_ImageOperation.cc @@ -4,7 +4,7 @@ #include "COM_ImageOperation.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "IMB_colormanagement.hh" #include "IMB_interp.hh" diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h index bcf60f0ab2e..9f74c893786 100644 --- a/source/blender/compositor/operations/COM_PreviewOperation.h +++ b/source/blender/compositor/operations/COM_PreviewOperation.h @@ -4,7 +4,7 @@ #pragma once -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_rect.h" #include "COM_MultiThreadedOperation.h" #include "DNA_color_types.h" diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc index 0fcf13bbbc9..488b7c2fb9f 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cc @@ -73,7 +73,7 @@ void ScreenLensDistortionOperation::init_execution() input_program_ = this->get_input_socket_reader(0); this->init_mutex(); - uint rng_seed = uint(BLI_time_now_seconds_i() & UINT_MAX); + uint rng_seed = uint(BLI_check_seconds_timer_i() & UINT_MAX); rng_seed ^= uint(POINTER_AS_INT(input_program_)); rng_ = BLI_rng_new(rng_seed); } diff --git a/source/blender/compositor/operations/COM_TextureOperation.cc b/source/blender/compositor/operations/COM_TextureOperation.cc index a2bd8a63297..890e4d5ed2c 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.cc +++ b/source/blender/compositor/operations/COM_TextureOperation.cc @@ -7,7 +7,7 @@ #include "BKE_image.h" #include "BKE_node.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "NOD_texture.h" @@ -134,34 +134,51 @@ void TextureBaseOperation::update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span inputs) { - const float3 offset = inputs[0]->get_elem(0, 0); - const float3 scale = inputs[1]->get_elem(0, 0); - const int2 size = int2(this->get_width(), this->get_height()); + const int op_width = this->get_width(); + const int op_height = this->get_height(); + const float center_x = op_width / 2; + const float center_y = op_height / 2; + TexResult tex_result = {0}; + float vec[3]; + const int thread_id = WorkScheduler::current_thread_id(); for (BuffersIterator it = output->iterate_with(inputs, area); !it.is_end(); ++it) { - /* Compute the coordinates in the [-1, 1] range and add 0.5 to evaluate the texture at the - * center of pixels in case it was interpolated. */ - const float2 pixel_coordinates = ((float2(it.x, it.y) + 0.5f) / float2(size)) * 2.0f - 1.0f; - /* Note that it is expected that the offset is scaled by the scale. */ - const float3 coordinates = (float3(pixel_coordinates, 0.0f) + offset) * scale; + const float *tex_offset = it.in(0); + const float *tex_size = it.in(1); + float u = (it.x - center_x) / op_width * 2; + float v = (it.y - center_y) / op_height * 2; - TexResult texture_result; - const int result_type = multitex_ext(texture_, - coordinates, - nullptr, - nullptr, - 0, - &texture_result, - WorkScheduler::current_thread_id(), - pool_, - scene_color_manage_, - false); - - float4 color = float4(texture_result.trgba); - color.w = texture_result.talpha ? color.w : texture_result.tin; - if (!(result_type & TEX_RGB)) { - copy_v3_fl(color, color.w); + /* When no interpolation/filtering happens in multitex() force nearest interpolation. + * We do it here because (a) we can't easily say multitex() that we want nearest + * interpolation and (b) in such configuration multitex() simply floor's the value + * which often produces artifacts. + */ + if (texture_ != nullptr && (texture_->imaflag & TEX_INTERPOL) == 0) { + u += 0.5f / center_x; + v += 0.5f / center_y; + } + + vec[0] = tex_size[0] * (u + tex_offset[0]); + vec[1] = tex_size[1] * (v + tex_offset[1]); + vec[2] = tex_size[2] * tex_offset[2]; + + const int retval = multitex_ext(texture_, + vec, + nullptr, + nullptr, + 0, + &tex_result, + thread_id, + pool_, + scene_color_manage_, + false); + + it.out[3] = tex_result.talpha ? tex_result.trgba[3] : tex_result.tin; + if (retval & TEX_RGB) { + copy_v3_v3(it.out, tex_result.trgba); + } + else { + it.out[0] = it.out[1] = it.out[2] = it.out[3]; } - copy_v4_v4(it.out, color); } } diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cc b/source/blender/compositor/operations/COM_TranslateOperation.cc index 223817bfec3..242e098004b 100644 --- a/source/blender/compositor/operations/COM_TranslateOperation.cc +++ b/source/blender/compositor/operations/COM_TranslateOperation.cc @@ -112,23 +112,6 @@ void TranslateOperation::update_memory_buffer_partial(MemoryBuffer *output, Span inputs) { MemoryBuffer *input = inputs[0]; - if (input->is_a_single_elem()) { - copy_v4_v4(output->get_elem(0, 0), input->get_elem(0, 0)); - return; - } - - /* Some compositor operations produce an empty output buffer by specifying a COM_AREA_NONE canvas - * to indicate an invalid output, for instance, when the Mask operation reference an invalid - * mask. The intention is that this buffer would signal that a fallback value would fill the - * canvas of consumer operations. Since the aforementioned filling is achieved through the - * Translate operation as part of canvas conversion in COM_convert_canvas, we handle the empty - * buffer case here and fill the output using a fallback black color. */ - if (BLI_rcti_is_empty(&input->get_rect())) { - const float value[4] = {0.0f, 0.0f, 0.0f, 1.0f}; - output->fill(area, value); - return; - } - const int delta_x = this->get_delta_x(); const int delta_y = this->get_delta_y(); for (int y = area.ymin; y < area.ymax; y++) { diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc index ebe2cd454f3..3d76d41442c 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cc @@ -2,11 +2,8 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BLI_math_base.hh" -#include "BLI_math_vector.hh" - -#include "COM_OpenCLDevice.h" #include "COM_VariableSizeBokehBlurOperation.h" +#include "COM_OpenCLDevice.h" namespace blender::compositor { @@ -15,7 +12,6 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() this->add_input_socket(DataType::Color); this->add_input_socket(DataType::Color, ResizeMode::Align); /* Do not resize the bokeh image. */ this->add_input_socket(DataType::Value); /* Radius. */ - this->add_input_socket(DataType::Value); /* Bounding Box. */ #ifdef COM_DEFOCUS_SEARCH /* Inverse search radius optimization structure. */ this->add_input_socket(DataType::Color, ResizeMode::None); @@ -28,7 +24,6 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() input_program_ = nullptr; input_bokeh_program_ = nullptr; input_size_program_ = nullptr; - input_mask_program_ = nullptr; max_blur_ = 32.0f; threshold_ = 1.0f; do_size_scale_ = false; @@ -42,9 +37,8 @@ void VariableSizeBokehBlurOperation::init_execution() input_program_ = get_input_socket_reader(0); input_bokeh_program_ = get_input_socket_reader(1); input_size_program_ = get_input_socket_reader(2); - input_mask_program_ = get_input_socket_reader(3); #ifdef COM_DEFOCUS_SEARCH - input_search_program_ = get_input_socket_reader(4); + input_search_program_ = get_input_socket_reader(3); #endif QualityStepHelper::init_execution(COM_QH_INCREASE); } @@ -52,7 +46,6 @@ struct VariableSizeBokehBlurTileData { MemoryBuffer *color; MemoryBuffer *bokeh; MemoryBuffer *size; - MemoryBuffer *mask; int max_blur_scalar; }; @@ -62,7 +55,6 @@ void *VariableSizeBokehBlurOperation::initialize_tile_data(rcti *rect) data->color = (MemoryBuffer *)input_program_->initialize_tile_data(rect); data->bokeh = (MemoryBuffer *)input_bokeh_program_->initialize_tile_data(rect); data->size = (MemoryBuffer *)input_size_program_->initialize_tile_data(rect); - data->mask = (MemoryBuffer *)input_mask_program_->initialize_tile_data(rect); rcti rect2 = COM_AREA_NONE; this->determine_depending_area_of_interest( @@ -72,7 +64,7 @@ void *VariableSizeBokehBlurOperation::initialize_tile_data(rcti *rect) const float scalar = do_size_scale_ ? (max_dim / 100.0f) : 1.0f; data->max_blur_scalar = int(data->size->get_max_value(rect2) * scalar); - CLAMP(data->max_blur_scalar, 0, max_blur_); + CLAMP(data->max_blur_scalar, 1.0f, max_blur_); return data; } @@ -85,56 +77,94 @@ void VariableSizeBokehBlurOperation::deinitialize_tile_data(rcti * /*rect*/, voi void VariableSizeBokehBlurOperation::execute_pixel(float output[4], int x, int y, void *data) { VariableSizeBokehBlurTileData *tile_data = (VariableSizeBokehBlurTileData *)data; - MemoryBuffer *input_buffer = tile_data->color; - MemoryBuffer *bokeh_buffer = tile_data->bokeh; - MemoryBuffer *size_buffer = tile_data->size; - MemoryBuffer *mask_buffer = tile_data->mask; - - if (*mask_buffer->get_elem(x, y) <= 0.0f) { - copy_v4_v4(output, input_buffer->get_elem(x, y)); - return; - } + MemoryBuffer *input_program_buffer = tile_data->color; + MemoryBuffer *input_bokeh_buffer = tile_data->bokeh; + MemoryBuffer *input_size_buffer = tile_data->size; + float *input_size_float_buffer = input_size_buffer->get_buffer(); + float *input_program_float_buffer = input_program_buffer->get_buffer(); + float read_color[4]; + float bokeh[4]; + float temp_size[4]; + float multiplier_accum[4]; + float color_accum[4]; const float max_dim = std::max(get_width(), get_height()); - const float base_size = do_size_scale_ ? (max_dim / 100.0f) : 1.0f; - const int search_radius = tile_data->max_blur_scalar; - const int2 bokeh_size = int2(bokeh_buffer->get_width(), bokeh_buffer->get_height()); - const float center_size = math::max(0.0f, *size_buffer->get_elem(x, y) * base_size); + const float scalar = do_size_scale_ ? (max_dim / 100.0f) : 1.0f; + int max_blur_scalar = tile_data->max_blur_scalar; - float4 accumulated_color = float4(input_buffer->get_elem(x, y)); - float4 accumulated_weight = float4(1.0f); - const int step = get_step(); - if (center_size >= threshold_) { - for (int yi = -search_radius; yi <= search_radius; yi += step) { - for (int xi = -search_radius; xi <= search_radius; xi += step) { - if (xi == 0 && yi == 0) { - continue; - } - const float candidate_size = math::max( - 0.0f, *size_buffer->get_elem_clamped(x + xi, y + yi) * base_size); - const float size = math::min(center_size, candidate_size); - if (size < threshold_ || math::max(math::abs(xi), math::abs(yi)) > size) { - continue; - } + BLI_assert(input_bokeh_buffer->get_width() == COM_BLUR_BOKEH_PIXELS); + BLI_assert(input_bokeh_buffer->get_height() == COM_BLUR_BOKEH_PIXELS); - const float2 normalized_texel = (float2(xi, yi) + size + 0.5f) / (size * 2.0f + 1.0f); - const float2 weight_texel = (1.0f - normalized_texel) * float2(bokeh_size - 1); - const float4 weight = bokeh_buffer->get_elem(int(weight_texel.x), int(weight_texel.y)); - const float4 color = input_buffer->get_elem_clamped(x + xi, y + yi); - accumulated_color += color * weight; - accumulated_weight += weight; +#ifdef COM_DEFOCUS_SEARCH + float search[4]; + input_search_program_->read(search, + x / InverseSearchRadiusOperation::DIVIDER, + y / InverseSearchRadiusOperation::DIVIDER, + nullptr); + int minx = search[0]; + int miny = search[1]; + int maxx = search[2]; + int maxy = search[3]; +#else + int minx = std::max(x - max_blur_scalar, 0); + int miny = std::max(y - max_blur_scalar, 0); + int maxx = std::min(x + max_blur_scalar, int(get_width())); + int maxy = std::min(y + max_blur_scalar, int(get_height())); +#endif + { + input_size_buffer->read_no_check(temp_size, x, y); + input_program_buffer->read_no_check(read_color, x, y); + + copy_v4_v4(color_accum, read_color); + copy_v4_fl(multiplier_accum, 1.0f); + float size_center = temp_size[0] * scalar; + + const int add_xstep_value = QualityStepHelper::get_step(); + const int add_ystep_value = add_xstep_value; + const int add_xstep_color = add_xstep_value * COM_DATA_TYPE_COLOR_CHANNELS; + + if (size_center > threshold_) { + for (int ny = miny; ny < maxy; ny += add_ystep_value) { + float dy = ny - y; + int offset_value_ny = ny * input_size_buffer->get_width(); + int offset_value_nx_ny = offset_value_ny + (minx); + int offset_color_nx_ny = offset_value_nx_ny * COM_DATA_TYPE_COLOR_CHANNELS; + for (int nx = minx; nx < maxx; nx += add_xstep_value) { + if (nx != x || ny != y) { + float size = std::min(input_size_float_buffer[offset_value_nx_ny] * scalar, + size_center); + if (size > threshold_) { + float dx = nx - x; + if (size > fabsf(dx) && size > fabsf(dy)) { + float uv[2] = { + float(COM_BLUR_BOKEH_PIXELS / 2) + + (dx / size) * float((COM_BLUR_BOKEH_PIXELS / 2) - 1), + float(COM_BLUR_BOKEH_PIXELS / 2) + + (dy / size) * float((COM_BLUR_BOKEH_PIXELS / 2) - 1), + }; + input_bokeh_buffer->read(bokeh, uv[0], uv[1]); + madd_v4_v4v4(color_accum, bokeh, &input_program_float_buffer[offset_color_nx_ny]); + add_v4_v4(multiplier_accum, bokeh); + } + } + } + offset_color_nx_ny += add_xstep_color; + offset_value_nx_ny += add_xstep_value; + } } } - } - const float4 final_color = math::safe_divide(accumulated_color, accumulated_weight); - copy_v4_v4(output, final_color); + output[0] = color_accum[0] / multiplier_accum[0]; + output[1] = color_accum[1] / multiplier_accum[1]; + output[2] = color_accum[2] / multiplier_accum[2]; + output[3] = color_accum[3] / multiplier_accum[3]; - /* blend in out values over the threshold, otherwise we get sharp, ugly transitions */ - if ((center_size > threshold_) && (center_size < threshold_ * 2.0f)) { - /* factor from 0-1 */ - float fac = (center_size - threshold_) / threshold_; - interp_v4_v4v4(output, input_buffer->get_elem(x, y), output, fac); + /* blend in out values over the threshold, otherwise we get sharp, ugly transitions */ + if ((size_center > threshold_) && (size_center < threshold_ * 2.0f)) { + /* factor from 0-1 */ + float fac = (size_center - threshold_) / threshold_; + interp_v4_v4v4(output, read_color, output, fac); + } } } @@ -184,7 +214,6 @@ void VariableSizeBokehBlurOperation::deinit_execution() input_program_ = nullptr; input_bokeh_program_ = nullptr; input_size_program_ = nullptr; - input_mask_program_ = nullptr; #ifdef COM_DEFOCUS_SEARCH input_search_program_ = nullptr; #endif @@ -193,52 +222,45 @@ void VariableSizeBokehBlurOperation::deinit_execution() bool VariableSizeBokehBlurOperation::determine_depending_area_of_interest( rcti *input, ReadBufferOperation *read_operation, rcti *output) { - if (read_operation == (ReadBufferOperation *)get_input_operation(BOKEH_INPUT_INDEX)) { - rcti bokeh_input; - bokeh_input.xmax = COM_BLUR_BOKEH_PIXELS; - bokeh_input.xmin = 0; - bokeh_input.ymax = COM_BLUR_BOKEH_PIXELS; - bokeh_input.ymin = 0; - - NodeOperation *operation = get_input_operation(BOKEH_INPUT_INDEX); - return operation->determine_depending_area_of_interest(&bokeh_input, read_operation, output); - } + rcti new_input; + rcti bokeh_input; const float max_dim = std::max(get_width(), get_height()); const float scalar = do_size_scale_ ? (max_dim / 100.0f) : 1.0f; int max_blur_scalar = max_blur_ * scalar; - rcti new_input; new_input.xmax = input->xmax + max_blur_scalar + 2; new_input.xmin = input->xmin - max_blur_scalar + 2; new_input.ymax = input->ymax + max_blur_scalar - 2; new_input.ymin = input->ymin - max_blur_scalar - 2; + bokeh_input.xmax = COM_BLUR_BOKEH_PIXELS; + bokeh_input.xmin = 0; + bokeh_input.ymax = COM_BLUR_BOKEH_PIXELS; + bokeh_input.ymin = 0; - NodeOperation *operation = get_input_operation(SIZE_INPUT_INDEX); + NodeOperation *operation = get_input_operation(2); if (operation->determine_depending_area_of_interest(&new_input, read_operation, output)) { return true; } + operation = get_input_operation(1); + if (operation->determine_depending_area_of_interest(&bokeh_input, read_operation, output)) { + return true; + } #ifdef COM_DEFOCUS_SEARCH rcti search_input; search_input.xmax = (input->xmax / InverseSearchRadiusOperation::DIVIDER) + 1; search_input.xmin = (input->xmin / InverseSearchRadiusOperation::DIVIDER) - 1; search_input.ymax = (input->ymax / InverseSearchRadiusOperation::DIVIDER) + 1; search_input.ymin = (input->ymin / InverseSearchRadiusOperation::DIVIDER) - 1; - operation = get_input_operation(DEFOCUS_INPUT_INDEX); + operation = get_input_operation(3); if (operation->determine_depending_area_of_interest(&search_input, read_operation, output)) { return true; } #endif - operation = get_input_operation(IMAGE_INPUT_INDEX); + operation = get_input_operation(0); if (operation->determine_depending_area_of_interest(&new_input, read_operation, output)) { return true; } - - operation = get_input_operation(BOUNDING_BOX_INPUT_INDEX); - if (operation->determine_depending_area_of_interest(&new_input, read_operation, output)) { - return true; - } - return false; } @@ -248,7 +270,6 @@ void VariableSizeBokehBlurOperation::get_area_of_interest(const int input_idx, { switch (input_idx) { case IMAGE_INPUT_INDEX: - case BOUNDING_BOX_INPUT_INDEX: case SIZE_INPUT_INDEX: { const float max_dim = std::max(get_width(), get_height()); const float scalar = do_size_scale_ ? (max_dim / 100.0f) : 1.0f; @@ -277,64 +298,130 @@ void VariableSizeBokehBlurOperation::get_area_of_interest(const int input_idx, } } +struct PixelData { + float multiplier_accum[4]; + float color_accum[4]; + float threshold; + float scalar; + float size_center; + int max_blur_scalar; + int step; + MemoryBuffer *bokeh_input; + MemoryBuffer *size_input; + MemoryBuffer *image_input; + int image_width; + int image_height; +}; + +static void blur_pixel(int x, int y, PixelData &p) +{ + BLI_assert(p.bokeh_input->get_width() == COM_BLUR_BOKEH_PIXELS); + BLI_assert(p.bokeh_input->get_height() == COM_BLUR_BOKEH_PIXELS); + +#ifdef COM_DEFOCUS_SEARCH + float search[4]; + inputs[DEFOCUS_INPUT_INDEX]->read_elem_checked(x / InverseSearchRadiusOperation::DIVIDER, + y / InverseSearchRadiusOperation::DIVIDER, + search); + const int minx = search[0]; + const int miny = search[1]; + const int maxx = search[2]; + const int maxy = search[3]; +#else + const int minx = std::max(x - p.max_blur_scalar, 0); + const int miny = std::max(y - p.max_blur_scalar, 0); + const int maxx = std::min(x + p.max_blur_scalar, p.image_width); + const int maxy = std::min(y + p.max_blur_scalar, p.image_height); +#endif + + const int color_row_stride = p.image_input->row_stride * p.step; + const int color_elem_stride = p.image_input->elem_stride * p.step; + const int size_row_stride = p.size_input->row_stride * p.step; + const int size_elem_stride = p.size_input->elem_stride * p.step; + const float *row_color = p.image_input->get_elem(minx, miny); + const float *row_size = p.size_input->get_elem(minx, miny); + for (int ny = miny; ny < maxy; + ny += p.step, row_size += size_row_stride, row_color += color_row_stride) + { + const float dy = ny - y; + const float *size_elem = row_size; + const float *color = row_color; + for (int nx = minx; nx < maxx; + nx += p.step, size_elem += size_elem_stride, color += color_elem_stride) + { + if (nx == x && ny == y) { + continue; + } + const float size = std::min(size_elem[0] * p.scalar, p.size_center); + if (size <= p.threshold) { + continue; + } + const float dx = nx - x; + if (size <= fabsf(dx) || size <= fabsf(dy)) { + continue; + } + + /* XXX: There is no way to ensure bokeh input is an actual bokeh with #COM_BLUR_BOKEH_PIXELS + * size, anything may be connected. Use the real input size and remove asserts? */ + const float u = float(COM_BLUR_BOKEH_PIXELS / 2) + + (dx / size) * float((COM_BLUR_BOKEH_PIXELS / 2) - 1); + const float v = float(COM_BLUR_BOKEH_PIXELS / 2) + + (dy / size) * float((COM_BLUR_BOKEH_PIXELS / 2) - 1); + float bokeh[4]; + p.bokeh_input->read_elem_checked(u, v, bokeh); + madd_v4_v4v4(p.color_accum, bokeh, color); + add_v4_v4(p.multiplier_accum, bokeh); + } + } +} + void VariableSizeBokehBlurOperation::update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span inputs) { - MemoryBuffer *input_buffer = inputs[0]; - MemoryBuffer *bokeh_buffer = inputs[1]; - MemoryBuffer *size_buffer = inputs[2]; - MemoryBuffer *mask_buffer = inputs[3]; + PixelData p; + p.bokeh_input = inputs[BOKEH_INPUT_INDEX]; + p.size_input = inputs[SIZE_INPUT_INDEX]; + p.image_input = inputs[IMAGE_INPUT_INDEX]; + p.step = QualityStepHelper::get_step(); + p.threshold = threshold_; + p.image_width = this->get_width(); + p.image_height = this->get_height(); - const float max_dim = std::max(get_width(), get_height()); - const float base_size = do_size_scale_ ? (max_dim / 100.0f) : 1.0f; - const float maximum_size = size_buffer->get_max_value(); - const int search_radius = math::clamp(int(maximum_size * base_size), 0, max_blur_); - const int2 bokeh_size = int2(bokeh_buffer->get_width(), bokeh_buffer->get_height()); + rcti scalar_area = COM_AREA_NONE; + this->get_area_of_interest(SIZE_INPUT_INDEX, area, scalar_area); + BLI_rcti_isect(&scalar_area, &p.size_input->get_rect(), &scalar_area); + const float max_size = p.size_input->get_max_value(scalar_area); - BuffersIterator it = output->iterate_with({}, area); - for (; !it.is_end(); ++it) { - if (*mask_buffer->get_elem(it.x, it.y) <= 0.0f) { - copy_v4_v4(it.out, input_buffer->get_elem(it.x, it.y)); - continue; + const float max_dim = std::max(this->get_width(), this->get_height()); + p.scalar = do_size_scale_ ? (max_dim / 100.0f) : 1.0f; + p.max_blur_scalar = int(max_size * p.scalar); + CLAMP(p.max_blur_scalar, 1, max_blur_); + + for (BuffersIterator it = output->iterate_with({p.image_input, p.size_input}, area); + !it.is_end(); + ++it) + { + const float *color = it.in(0); + const float size = *it.in(1); + copy_v4_v4(p.color_accum, color); + copy_v4_fl(p.multiplier_accum, 1.0f); + p.size_center = size * p.scalar; + + if (p.size_center > p.threshold) { + blur_pixel(it.x, it.y, p); } - const float center_size = math::max(0.0f, *size_buffer->get_elem(it.x, it.y) * base_size); + it.out[0] = p.color_accum[0] / p.multiplier_accum[0]; + it.out[1] = p.color_accum[1] / p.multiplier_accum[1]; + it.out[2] = p.color_accum[2] / p.multiplier_accum[2]; + it.out[3] = p.color_accum[3] / p.multiplier_accum[3]; - float4 accumulated_color = float4(input_buffer->get_elem(it.x, it.y)); - float4 accumulated_weight = float4(1.0f); - const int step = get_step(); - if (center_size >= threshold_) { - for (int yi = -search_radius; yi <= search_radius; yi += step) { - for (int xi = -search_radius; xi <= search_radius; xi += step) { - if (xi == 0 && yi == 0) { - continue; - } - const float candidate_size = math::max( - 0.0f, *size_buffer->get_elem_clamped(it.x + xi, it.y + yi) * base_size); - const float size = math::min(center_size, candidate_size); - if (size < threshold_ || math::max(math::abs(xi), math::abs(yi)) > size) { - continue; - } - - const float2 normalized_texel = (float2(xi, yi) + size + 0.5f) / (size * 2.0f + 1.0f); - const float2 weight_texel = (1.0f - normalized_texel) * float2(bokeh_size - 1); - const float4 weight = bokeh_buffer->get_elem(int(weight_texel.x), int(weight_texel.y)); - const float4 color = input_buffer->get_elem_clamped(it.x + xi, it.y + yi); - accumulated_color += color * weight; - accumulated_weight += weight; - } - } - } - - const float4 final_color = math::safe_divide(accumulated_color, accumulated_weight); - copy_v4_v4(it.out, final_color); - - /* blend in out values over the threshold, otherwise we get sharp, ugly transitions */ - if ((center_size > threshold_) && (center_size < threshold_ * 2.0f)) { - /* factor from 0-1 */ - float fac = (center_size - threshold_) / threshold_; - interp_v4_v4v4(it.out, input_buffer->get_elem(it.x, it.y), it.out, fac); + /* Blend in out values over the threshold, otherwise we get sharp, ugly transitions. */ + if ((p.size_center > p.threshold) && (p.size_center < p.threshold * 2.0f)) { + /* Factor from 0-1. */ + const float fac = (p.size_center - p.threshold) / p.threshold; + interp_v4_v4v4(it.out, color, it.out, fac); } } } diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h index bd1184f5b11..e239a916afe 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h @@ -16,9 +16,8 @@ class VariableSizeBokehBlurOperation : public MultiThreadedOperation, public Qua static constexpr int IMAGE_INPUT_INDEX = 0; static constexpr int BOKEH_INPUT_INDEX = 1; static constexpr int SIZE_INPUT_INDEX = 2; - static constexpr int BOUNDING_BOX_INPUT_INDEX = 3; #ifdef COM_DEFOCUS_SEARCH - static constexpr int DEFOCUS_INPUT_INDEX = 4; + static constexpr int DEFOCUS_INPUT_INDEX = 3; #endif int max_blur_; @@ -27,7 +26,6 @@ class VariableSizeBokehBlurOperation : public MultiThreadedOperation, public Qua SocketReader *input_program_; SocketReader *input_bokeh_program_; SocketReader *input_size_program_; - SocketReader *input_mask_program_; #ifdef COM_DEFOCUS_SEARCH SocketReader *input_search_program_; #endif diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cc b/source/blender/compositor/operations/COM_ViewerOperation.cc index 51498b3a27a..0e9aa56bd06 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.cc +++ b/source/blender/compositor/operations/COM_ViewerOperation.cc @@ -4,7 +4,7 @@ #include "COM_ViewerOperation.h" #include "BKE_image.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "COM_ExecutionSystem.h" #include "IMB_colormanagement.hh" diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h index 83f98049997..3c7c5e971a2 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.h +++ b/source/blender/compositor/operations/COM_ViewerOperation.h @@ -4,7 +4,7 @@ #pragma once -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_rect.h" #include "COM_MultiThreadedOperation.h" #include "DNA_image_types.h" diff --git a/source/blender/compositor/realtime_compositor/COM_context.hh b/source/blender/compositor/realtime_compositor/COM_context.hh index 90900e79970..bf4e70c621c 100644 --- a/source/blender/compositor/realtime_compositor/COM_context.hh +++ b/source/blender/compositor/realtime_compositor/COM_context.hh @@ -112,10 +112,6 @@ class Context { * render pipeline. */ virtual RenderContext *render_context() const; - /* Returns true if the compositor evaluation is canceled and that the evaluator should stop - * executing as soon as possible. */ - virtual bool is_canceled() const; - /* Get the size of the compositing region. See get_compositing_region(). The output size is * sanitized such that it is at least 1 in both dimensions. However, the developer is expected to * gracefully handled zero sizes regions by checking the is_valid_compositing_region method. */ diff --git a/source/blender/compositor/realtime_compositor/algorithms/COM_algorithm_parallel_reduction.hh b/source/blender/compositor/realtime_compositor/algorithms/COM_algorithm_parallel_reduction.hh index 23b52a2894a..d6d7dab321a 100644 --- a/source/blender/compositor/realtime_compositor/algorithms/COM_algorithm_parallel_reduction.hh +++ b/source/blender/compositor/realtime_compositor/algorithms/COM_algorithm_parallel_reduction.hh @@ -72,9 +72,6 @@ float sum_luminance_squared_difference(Context &context, * coefficients to compute the luminance. */ float maximum_luminance(Context &context, GPUTexture *texture, float3 luminance_coefficients); -/* Computes the maximum float value of all pixels in the given texture. */ -float maximum_float(Context &context, GPUTexture *texture); - /* Computes the maximum float of all pixels in the given float texture, limited to the given range. * Values outside of the given range are ignored. If non of the pixel values are in the range, the * lower bound of the range is returned. For instance, if the given range is [-10, 10] and the @@ -94,9 +91,6 @@ float maximum_float_in_range(Context &context, * coefficients to compute the luminance. */ float minimum_luminance(Context &context, GPUTexture *texture, float3 luminance_coefficients); -/* Computes the minimum float value of all pixels in the given texture. */ -float minimum_float(Context &context, GPUTexture *texture); - /* Computes the minimum float of all pixels in the given float texture, limited to the given range. * Values outside of the given range are ignored. If non of the pixel values are in the range, the * upper bound of the range is returned. For instance, if the given range is [-10, 10] and the diff --git a/source/blender/compositor/realtime_compositor/algorithms/intern/morphological_distance_feather.cc b/source/blender/compositor/realtime_compositor/algorithms/intern/morphological_distance_feather.cc index 74ee0c75e3d..4f25c766260 100644 --- a/source/blender/compositor/realtime_compositor/algorithms/intern/morphological_distance_feather.cc +++ b/source/blender/compositor/realtime_compositor/algorithms/intern/morphological_distance_feather.cc @@ -9,6 +9,7 @@ #include "GPU_texture.h" #include "COM_algorithm_morphological_distance_feather.hh" /* Own include. */ +#include "COM_algorithm_symmetric_separable_blur.hh" #include "COM_context.hh" #include "COM_morphological_distance_feather_weights.hh" #include "COM_result.hh" diff --git a/source/blender/compositor/realtime_compositor/algorithms/intern/parallel_reduction.cc b/source/blender/compositor/realtime_compositor/algorithms/intern/parallel_reduction.cc index b62118bc3d6..933fecde44a 100644 --- a/source/blender/compositor/realtime_compositor/algorithms/intern/parallel_reduction.cc +++ b/source/blender/compositor/realtime_compositor/algorithms/intern/parallel_reduction.cc @@ -12,6 +12,7 @@ #include "GPU_texture.h" #include "COM_context.hh" +#include "COM_utilities.hh" #include "COM_algorithm_parallel_reduction.hh" @@ -265,20 +266,6 @@ float maximum_luminance(Context &context, GPUTexture *texture, float3 luminance_ return maximum; } -float maximum_float(Context &context, GPUTexture *texture) -{ - GPUShader *shader = context.get_shader("compositor_maximum_float", ResultPrecision::Full); - GPU_shader_bind(shader); - - float *reduced_value = parallel_reduction_dispatch( - context, texture, shader, Result::texture_format(ResultType::Float, ResultPrecision::Full)); - const float maximum = *reduced_value; - MEM_freeN(reduced_value); - GPU_shader_unbind(); - - return maximum; -} - float maximum_float_in_range(Context &context, GPUTexture *texture, float lower_bound, @@ -320,20 +307,6 @@ float minimum_luminance(Context &context, GPUTexture *texture, float3 luminance_ return minimum; } -float minimum_float(Context &context, GPUTexture *texture) -{ - GPUShader *shader = context.get_shader("compositor_minimum_float", ResultPrecision::Full); - GPU_shader_bind(shader); - - float *reduced_value = parallel_reduction_dispatch( - context, texture, shader, Result::texture_format(ResultType::Float, ResultPrecision::Full)); - const float minimum = *reduced_value; - MEM_freeN(reduced_value); - GPU_shader_unbind(); - - return minimum; -} - float minimum_float_in_range(Context &context, GPUTexture *texture, float lower_bound, diff --git a/source/blender/compositor/realtime_compositor/cached_resources/intern/cached_mask.cc b/source/blender/compositor/realtime_compositor/cached_resources/intern/cached_mask.cc index 58c8daa239a..68277554f80 100644 --- a/source/blender/compositor/realtime_compositor/cached_resources/intern/cached_mask.cc +++ b/source/blender/compositor/realtime_compositor/cached_resources/intern/cached_mask.cc @@ -8,6 +8,7 @@ #include "BLI_array.hh" #include "BLI_hash.hh" #include "BLI_index_range.hh" +#include "BLI_listbase.h" #include "BLI_math_vector_types.hh" #include "BLI_task.hh" diff --git a/source/blender/compositor/realtime_compositor/intern/context.cc b/source/blender/compositor/realtime_compositor/intern/context.cc index 2b49705b895..61cb7939232 100644 --- a/source/blender/compositor/realtime_compositor/intern/context.cc +++ b/source/blender/compositor/realtime_compositor/intern/context.cc @@ -5,13 +5,10 @@ #include "BLI_math_vector.hh" #include "BLI_rect.h" -#include "DNA_node_types.h" #include "DNA_vec_types.h" #include "GPU_shader.h" -#include "BKE_node_runtime.hh" - #include "COM_context.hh" #include "COM_render_context.hh" #include "COM_static_cache_manager.hh" @@ -26,14 +23,6 @@ RenderContext *Context::render_context() const return nullptr; } -bool Context::is_canceled() const -{ - if (!this->get_node_tree().runtime->test_break) { - return false; - } - return this->get_node_tree().runtime->test_break(get_node_tree().runtime->tbh); -} - int2 Context::get_compositing_region_size() const { const rcti compositing_region = get_compositing_region(); diff --git a/source/blender/compositor/realtime_compositor/intern/node_operation.cc b/source/blender/compositor/realtime_compositor/intern/node_operation.cc index 19fb8e40630..1b17845fba7 100644 --- a/source/blender/compositor/realtime_compositor/intern/node_operation.cc +++ b/source/blender/compositor/realtime_compositor/intern/node_operation.cc @@ -20,7 +20,7 @@ #include "NOD_derived_node_tree.hh" #include "NOD_node_declaration.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "COM_context.hh" #include "COM_input_descriptor.hh" diff --git a/source/blender/compositor/realtime_compositor/intern/render_context.cc b/source/blender/compositor/realtime_compositor/intern/render_context.cc index 6bd7a7b8656..86dc5bb6d3c 100644 --- a/source/blender/compositor/realtime_compositor/intern/render_context.cc +++ b/source/blender/compositor/realtime_compositor/intern/render_context.cc @@ -8,6 +8,7 @@ #include "BLI_assert.h" #include "BLI_listbase.h" #include "BLI_map.hh" +#include "BLI_math_base.hh" #include "BLI_math_vector_types.hh" #include "BLI_string.h" #include "BLI_utildefines.h" @@ -22,7 +23,7 @@ #include "BKE_image.h" #include "BKE_image_save.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "RE_pipeline.h" diff --git a/source/blender/compositor/realtime_compositor/intern/scheduler.cc b/source/blender/compositor/realtime_compositor/intern/scheduler.cc index 9e7e3fc5f00..70d8c05ff2b 100644 --- a/source/blender/compositor/realtime_compositor/intern/scheduler.cc +++ b/source/blender/compositor/realtime_compositor/intern/scheduler.cc @@ -10,6 +10,7 @@ #include "NOD_derived_node_tree.hh" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "COM_context.hh" diff --git a/source/blender/compositor/realtime_compositor/shaders/compositor_write_output.glsl b/source/blender/compositor/realtime_compositor/shaders/compositor_write_output.glsl index 1cc526bf574..0f53afec776 100644 --- a/source/blender/compositor/realtime_compositor/shaders/compositor_write_output.glsl +++ b/source/blender/compositor/realtime_compositor/shaders/compositor_write_output.glsl @@ -7,11 +7,6 @@ void main() { ivec2 texel = ivec2(gl_GlobalInvocationID.xy); - ivec2 output_texel = texel + lower_bound; - if (any(greaterThan(output_texel, upper_bound))) { - return; - } - vec4 input_color = texture_load(input_tx, texel); #if defined(DIRECT_OUTPUT) diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_parallel_reduction_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_parallel_reduction_info.hh index b0859269a99..c3201d1fcc2 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_parallel_reduction_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_parallel_reduction_info.hh @@ -111,17 +111,6 @@ GPU_SHADER_CREATE_INFO(compositor_maximum_luminance) .define("REDUCE(lhs, rhs)", "max(lhs, rhs)") .do_static_compilation(true); -GPU_SHADER_CREATE_INFO(compositor_maximum_float) - .additional_info("compositor_parallel_reduction_shared") - .typedef_source("common_math_lib.glsl") - .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("TYPE", "float") - .define("IDENTITY", "FLT_MIN") - .define("INITIALIZE(value)", "value.x") - .define("LOAD(value)", "value.x") - .define("REDUCE(lhs, rhs)", "max(rhs, lhs)") - .do_static_compilation(true); - GPU_SHADER_CREATE_INFO(compositor_maximum_float_in_range) .additional_info("compositor_parallel_reduction_shared") .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") @@ -150,17 +139,6 @@ GPU_SHADER_CREATE_INFO(compositor_minimum_luminance) .define("REDUCE(lhs, rhs)", "min(lhs, rhs)") .do_static_compilation(true); -GPU_SHADER_CREATE_INFO(compositor_minimum_float) - .additional_info("compositor_parallel_reduction_shared") - .typedef_source("common_math_lib.glsl") - .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") - .define("TYPE", "float") - .define("IDENTITY", "FLT_MAX") - .define("INITIALIZE(value)", "value.x") - .define("LOAD(value)", "value.x") - .define("REDUCE(lhs, rhs)", "min(rhs, lhs)") - .do_static_compilation(true); - GPU_SHADER_CREATE_INFO(compositor_minimum_float_in_range) .additional_info("compositor_parallel_reduction_shared") .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") diff --git a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_write_output_info.hh b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_write_output_info.hh index cf4b32d5a8e..9a4c5a5beee 100644 --- a/source/blender/compositor/realtime_compositor/shaders/infos/compositor_write_output_info.hh +++ b/source/blender/compositor/realtime_compositor/shaders/infos/compositor_write_output_info.hh @@ -7,7 +7,6 @@ GPU_SHADER_CREATE_INFO(compositor_write_output_shared) .local_group_size(16, 16) .push_constant(Type::IVEC2, "lower_bound") - .push_constant(Type::IVEC2, "upper_bound") .sampler(0, ImageType::FLOAT_2D, "input_tx") .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img") .compute_source("compositor_write_output.glsl"); diff --git a/source/blender/datatoc/datatoc_icon_split.py b/source/blender/datatoc/datatoc_icon_split.py index 73900e1f117..dea590acc97 100755 --- a/source/blender/datatoc/datatoc_icon_split.py +++ b/source/blender/datatoc/datatoc_icon_split.py @@ -8,7 +8,7 @@ This script dices up PNG into small files to store in version control. Example: ./blender.bin \ - --background \ + --background -noaudio \ --python ./release/datafiles/icon_dice.py -- \ --image=./release/datafiles/blender_icons16.png \ --output=./release/datafiles/blender_icons16 diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index d45ff2ab2c0..b171061cb4d 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -21,7 +21,7 @@ #include "BLI_utildefines.h" #include "BKE_action.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_lib_id.hh" #include "RNA_prototypes.h" diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 1c25779d102..76a2c5ddefd 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -57,8 +57,8 @@ #include "BKE_animsys.h" #include "BKE_armature.hh" #include "BKE_bake_geometry_nodes_modifier.hh" -#include "BKE_cachefile.hh" -#include "BKE_collection.hh" +#include "BKE_cachefile.h" +#include "BKE_collection.h" #include "BKE_constraint.h" #include "BKE_curve.hh" #include "BKE_effect.h" @@ -87,7 +87,7 @@ #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_rigidbody.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_shader_fx.h" #include "BKE_sound.h" #include "BKE_tracking.h" @@ -973,10 +973,8 @@ void DepsgraphNodeBuilder::build_object_data(Object *object) case OB_CURVES: case OB_POINTCLOUD: case OB_VOLUME: - build_object_data_geometry(object); - break; case OB_GREASE_PENCIL: - build_object_data_grease_pencil(object); + build_object_data_geometry(object); break; case OB_ARMATURE: build_rig(object); @@ -1028,20 +1026,6 @@ void DepsgraphNodeBuilder::build_object_data_lightprobe(Object *object) add_operation_node(&object->id, NodeType::PARAMETERS, OperationCode::LIGHT_PROBE_EVAL); } -void DepsgraphNodeBuilder::build_object_data_grease_pencil(Object *object) -{ - GreasePencil &grease_pencil = *static_cast(object->data); - /* Build the layer parents. */ - for (const bke::greasepencil::Layer *layer : grease_pencil.layers()) { - Object *parent = layer->parent; - if (parent == nullptr) { - continue; - } - build_object(-1, parent, DEG_ID_LINKED_INDIRECTLY, false); - } - build_object_data_geometry(object); -} - void DepsgraphNodeBuilder::build_object_data_speaker(Object *object) { Speaker *speaker = (Speaker *)object->data; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index 7b7b6a49f84..f8a14854726 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -194,7 +194,6 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder { virtual void build_object_data_light(Object *object); virtual void build_object_data_lightprobe(Object *object); virtual void build_object_data_speaker(Object *object); - virtual void build_object_data_grease_pencil(Object *object); virtual void build_object_transform(Object *object); virtual void build_object_constraints(Object *object); virtual void build_object_pointcache(Object *object); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc index db5692d4756..f8f65f852f4 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc @@ -143,10 +143,6 @@ void DepsgraphNodeBuilder::build_view_layer(Scene *scene, if (view_layer->mat_override != nullptr) { build_material(view_layer->mat_override); } - /* World override */ - if (view_layer->world_override != nullptr) { - build_world(view_layer->world_override); - } /* Freestyle linesets. */ LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) { build_freestyle_lineset(fls); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 4ef0cbfc140..7fcbb3d6f9e 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -58,14 +58,13 @@ #include "BKE_action.h" #include "BKE_anim_data.h" #include "BKE_armature.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_collision.h" #include "BKE_constraint.h" #include "BKE_curve.hh" #include "BKE_effect.h" #include "BKE_fcurve_driver.h" #include "BKE_gpencil_modifier_legacy.h" -#include "BKE_grease_pencil.hh" #include "BKE_idprop.h" #include "BKE_image.h" #include "BKE_key.hh" @@ -2729,32 +2728,9 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata) break; } case ID_GP: { - GreasePencil &grease_pencil = *reinterpret_cast(obdata); - - /* Update geometry when time is changed. */ TimeSourceKey time_key; - ComponentKey geometry_key(&grease_pencil.id, NodeType::GEOMETRY); + ComponentKey geometry_key(obdata, NodeType::GEOMETRY); add_relation(time_key, geometry_key, "Grease Pencil Frame Change"); - - /* Add relations for layer parents. */ - for (const bke::greasepencil::Layer *layer : grease_pencil.layers()) { - Object *parent = layer->parent; - if (parent == nullptr) { - continue; - } - if (parent->type == OB_ARMATURE && !layer->parent_bone_name().is_empty()) { - ComponentKey bone_key(&parent->id, NodeType::BONE, layer->parent_bone_name().c_str()); - OperationKey armature_key( - &parent->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_FINAL); - - add_relation(bone_key, geometry_key, "Grease Pencil Layer Bone Parent"); - add_relation(armature_key, geometry_key, "Grease Pencil Layer Armature Parent"); - } - else { - ComponentKey transform_key(&parent->id, NodeType::TRANSFORM); - add_relation(transform_key, geometry_key, "Grease Pencil Layer Object Parent"); - } - } break; } default: diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc index d514f33c542..5770d64749e 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc @@ -144,10 +144,6 @@ void DepsgraphRelationBuilder::build_view_layer(Scene *scene, if (view_layer->mat_override != nullptr) { build_material(view_layer->mat_override); } - /* World override */ - if (view_layer->world_override != nullptr) { - build_world(view_layer->world_override); - } /* Freestyle linesets. */ LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) { build_freestyle_lineset(fls); diff --git a/source/blender/depsgraph/intern/builder/pipeline.cc b/source/blender/depsgraph/intern/builder/pipeline.cc index abe5d772e30..dd75f4e216f 100644 --- a/source/blender/depsgraph/intern/builder/pipeline.cc +++ b/source/blender/depsgraph/intern/builder/pipeline.cc @@ -6,7 +6,7 @@ #include "BLI_time.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "DNA_scene_types.h" @@ -29,7 +29,7 @@ void AbstractBuilderPipeline::build() { double start_time = 0.0; if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) { - start_time = BLI_time_now_seconds(); + start_time = BLI_check_seconds_timer(); } build_step_sanity_check(); @@ -38,7 +38,7 @@ void AbstractBuilderPipeline::build() build_step_finalize(); if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) { - printf("Depsgraph built in %f seconds.\n", BLI_time_now_seconds() - start_time); + printf("Depsgraph built in %f seconds.\n", BLI_check_seconds_timer() - start_time); } } diff --git a/source/blender/depsgraph/intern/debug/deg_debug.cc b/source/blender/depsgraph/intern/debug/deg_debug.cc index 5ec2fdedb94..5f5cfc065f8 100644 --- a/source/blender/depsgraph/intern/debug/deg_debug.cc +++ b/source/blender/depsgraph/intern/debug/deg_debug.cc @@ -14,7 +14,7 @@ #include "BLI_time_utildefines.h" #include "BLI_utildefines.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "intern/depsgraph.hh" @@ -33,7 +33,7 @@ void DepsgraphDebug::begin_graph_evaluation() return; } - const double current_time = BLI_time_now_seconds(); + const double current_time = BLI_check_seconds_timer(); graph_evaluation_start_time_ = current_time; } @@ -44,7 +44,7 @@ void DepsgraphDebug::end_graph_evaluation() return; } - const double graph_eval_end_time = BLI_time_now_seconds(); + const double graph_eval_end_time = BLI_check_seconds_timer(); const double graph_eval_time = graph_eval_end_time - graph_evaluation_start_time_; if (name.empty()) { diff --git a/source/blender/depsgraph/intern/debug/deg_debug.h b/source/blender/depsgraph/intern/debug/deg_debug.h index 29ac35dab67..3eceb76943d 100644 --- a/source/blender/depsgraph/intern/debug/deg_debug.h +++ b/source/blender/depsgraph/intern/debug/deg_debug.h @@ -10,7 +10,7 @@ #include "intern/depsgraph_type.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "DEG_depsgraph_debug.hh" diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index 21bcd14aa70..88db9136951 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -19,9 +19,9 @@ #include "BLI_hash.h" #include "BLI_utildefines.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_debug.hh" diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index dac99ccabeb..822fe1e5f81 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -22,9 +22,9 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc index b55a2e35cbe..3ed12e3a39d 100644 --- a/source/blender/depsgraph/intern/depsgraph_eval.cc +++ b/source/blender/depsgraph/intern/depsgraph_eval.cc @@ -13,7 +13,7 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/depsgraph/intern/depsgraph_light_linking.cc b/source/blender/depsgraph/intern/depsgraph_light_linking.cc index 30afc4e5cec..758eceb340c 100644 --- a/source/blender/depsgraph/intern/depsgraph_light_linking.cc +++ b/source/blender/depsgraph/intern/depsgraph_light_linking.cc @@ -16,7 +16,7 @@ #include "BLI_map.hh" #include "BLI_utildefines.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "DNA_collection_types.h" #include "DNA_layer_types.h" diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc index bb6d530483a..c7665dccfc0 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc @@ -13,7 +13,7 @@ #include "MEM_guardedalloc.h" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_geometry_set.hh" #include "BKE_idprop.h" #include "BKE_layer.hh" @@ -180,9 +180,8 @@ bool deg_iterator_duplis_step(DEGObjectIterData *data) bool is_neg_scale = is_negative_m4(dob->mat); SET_FLAG_FROM_TEST(data->temp_dupli_object.transflag, is_neg_scale, OB_NEG_SCALE); - copy_m4_m4(data->temp_dupli_object.runtime->object_to_world.ptr(), dob->mat); - invert_m4_m4(data->temp_dupli_object.runtime->world_to_object.ptr(), - data->temp_dupli_object.object_to_world().ptr()); + copy_m4_m4(data->temp_dupli_object.object_to_world, dob->mat); + invert_m4_m4(data->temp_dupli_object.world_to_object, data->temp_dupli_object.object_to_world); data->next_object = &data->temp_dupli_object; BLI_assert(deg::deg_validate_copy_on_write_datablock(&data->temp_dupli_object.id)); return true; diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index aec567019e7..385a53b0bdf 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -29,11 +29,11 @@ #include "DNA_windowmanager_types.h" #include "BKE_anim_data.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_lib_override.hh" #include "BKE_node.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_workspace.h" @@ -840,7 +840,7 @@ void DEG_id_tag_update_ex(Main *bmain, ID *id, uint flags) deg::id_tag_update(bmain, id, flags, deg::DEG_UPDATE_SOURCE_USER_EDIT); } -void DEG_id_tag_update_for_side_effect_request(Depsgraph *depsgraph, ID *id, uint flags) +void DEG_id_tag_update_for_side_effect_request(Depsgraph *depsgraph, ID *id, unsigned int flags) { BLI_assert(depsgraph != nullptr); BLI_assert(id != nullptr); diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc index 312c1d2bed2..218a6eccacf 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval.cc @@ -17,7 +17,7 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "DNA_node_types.h" #include "DNA_object_types.h" @@ -93,9 +93,9 @@ void evaluate_node(const DepsgraphEvalState *state, OperationNode *operation_nod BLI_assert_msg(!operation_node->is_noop(), "NOOP nodes should not actually be scheduled"); /* Perform operation. */ if (state->do_stats) { - const double start_time = BLI_time_now_seconds(); + const double start_time = BLI_check_seconds_timer(); operation_node->evaluate(depsgraph); - operation_node->stats.current_time += BLI_time_now_seconds() - start_time; + operation_node->stats.current_time += BLI_check_seconds_timer() - start_time; } else { operation_node->evaluate(depsgraph); diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 14a9779e304..43b8f64eb26 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -26,14 +26,14 @@ #include "BLI_utildefines.h" #include "BKE_curve.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_update_cache_legacy.h" #include "BKE_idprop.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_object_types.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index 7b9d81a7ca2..3f9960b82da 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -19,7 +19,7 @@ #include "BKE_key.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DNA_key_types.h" #include "DNA_object_types.h" @@ -262,7 +262,7 @@ void invalidate_tagged_evaluated_transform(ID *id) switch (id_type) { case ID_OB: { Object *object = (Object *)id; - copy_vn_fl((float *)object->object_to_world().ptr(), 16, NAN); + copy_vn_fl((float *)object->object_to_world, 16, NAN); break; } default: diff --git a/source/blender/depsgraph/intern/node/deg_node_component.cc b/source/blender/depsgraph/intern/node/deg_node_component.cc index f05d056d143..311dd5500a9 100644 --- a/source/blender/depsgraph/intern/node/deg_node_component.cc +++ b/source/blender/depsgraph/intern/node/deg_node_component.cc @@ -323,7 +323,7 @@ DEG_COMPONENT_NODE_DEFINE(CopyOnWrite, COPY_ON_WRITE, ID_RECALC_COPY_ON_WRITE); DEG_COMPONENT_NODE_DEFINE(ImageAnimation, IMAGE_ANIMATION, 0); DEG_COMPONENT_NODE_DEFINE(Geometry, GEOMETRY, ID_RECALC_GEOMETRY); DEG_COMPONENT_NODE_DEFINE(LayerCollections, LAYER_COLLECTIONS, 0); -DEG_COMPONENT_NODE_DEFINE(Parameters, PARAMETERS, ID_RECALC_PARAMETERS); +DEG_COMPONENT_NODE_DEFINE(Parameters, PARAMETERS, 0); DEG_COMPONENT_NODE_DEFINE(Particles, PARTICLE_SYSTEM, ID_RECALC_GEOMETRY); DEG_COMPONENT_NODE_DEFINE(ParticleSettings, PARTICLE_SETTINGS, 0); DEG_COMPONENT_NODE_DEFINE(PointCache, POINT_CACHE, 0); diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index dac81b40fe7..9bc077432bf 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -564,7 +564,6 @@ set(GLSL_SRC engines/eevee_next/shaders/eevee_ray_trace_screen_comp.glsl engines/eevee_next/shaders/eevee_ray_trace_screen_lib.glsl engines/eevee_next/shaders/eevee_ray_types_lib.glsl - engines/eevee_next/shaders/eevee_reflection_probe_convolve_comp.glsl engines/eevee_next/shaders/eevee_reflection_probe_eval_lib.glsl engines/eevee_next/shaders/eevee_reflection_probe_lib.glsl engines/eevee_next/shaders/eevee_reflection_probe_remap_comp.glsl diff --git a/source/blender/draw/DRW_engine.hh b/source/blender/draw/DRW_engine.hh index c0537efe2b7..ea1d53ceaf8 100644 --- a/source/blender/draw/DRW_engine.hh +++ b/source/blender/draw/DRW_engine.hh @@ -57,12 +57,12 @@ struct DRWUpdateContext { }; void DRW_notify_view_update(const DRWUpdateContext *update_ctx); -enum eDRWSelectStage { +typedef enum eDRWSelectStage { DRW_SELECT_PASS_PRE = 1, DRW_SELECT_PASS_POST, -}; -using DRW_SelectPassFn = bool (*)(eDRWSelectStage stage, void *user_data); -using DRW_ObjectFilterFn = bool (*)(Object *ob, void *user_data); +} eDRWSelectStage; +typedef bool (*DRW_SelectPassFn)(eDRWSelectStage stage, void *user_data); +typedef bool (*DRW_ObjectFilterFn)(Object *ob, void *user_data); /** * Everything starts here. diff --git a/source/blender/draw/engines/basic/basic_engine.cc b/source/blender/draw/engines/basic/basic_engine.cc index 07c77f9c5ea..0fbf8c3bc9c 100644 --- a/source/blender/draw/engines/basic/basic_engine.cc +++ b/source/blender/draw/engines/basic/basic_engine.cc @@ -11,7 +11,7 @@ #include "DRW_render.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_object.hh" #include "BKE_object_types.hh" #include "BKE_paint.hh" @@ -233,7 +233,7 @@ static void basic_cache_populate(void *vedata, Object *ob) if (G.debug_value == 889 && ob->sculpt && BKE_object_sculpt_pbvh_get(ob)) { int debug_node_nr = 0; - DRW_debug_modelmat(ob->object_to_world().ptr()); + DRW_debug_modelmat(ob->object_to_world); BKE_pbvh_draw_debug_cb(BKE_object_sculpt_pbvh_get(ob), DRW_sculpt_debug_cb, &debug_node_nr); } } diff --git a/source/blender/draw/engines/compositor/compositor_engine.cc b/source/blender/draw/engines/compositor/compositor_engine.cc index ffa5e0584a5..afb1cbca255 100644 --- a/source/blender/draw/engines/compositor/compositor_engine.cc +++ b/source/blender/draw/engines/compositor/compositor_engine.cc @@ -8,7 +8,7 @@ #include "BLI_string_ref.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_ID.h" #include "DNA_ID_enums.h" @@ -91,14 +91,42 @@ class Context : public realtime_compositor::Context { return int2(float2(DRW_viewport_size_get())); } - /* We limit the compositing region to the camera region if in camera view, while we use the - * entire viewport otherwise. */ + /* Returns true if the viewport is in camera view and has an opaque passepartout, that is, the + * area outside of the camera border is not visible. */ + bool is_opaque_camera_view() const + { + /* Check if the viewport is in camera view. */ + if (DRW_context_state_get()->rv3d->persp != RV3D_CAMOB) { + return false; + } + + /* Check if the camera object that is currently in view is an actual camera. It is possible for + * a non camera object to be used as a camera, in which case, there will be no passepartout or + * any other camera setting, so those pseudo cameras can be ignored. */ + Object *camera_object = DRW_context_state_get()->v3d->camera; + if (camera_object->type != OB_CAMERA) { + return false; + } + + /* Check if the camera has passepartout active and is totally opaque. */ + Camera *cam = static_cast(camera_object->data); + if (!(cam->flag & CAM_SHOWPASSEPARTOUT) || cam->passepartalpha != 1.0f) { + return false; + } + + return true; + } + rcti get_compositing_region() const override { const int2 viewport_size = int2(float2(DRW_viewport_size_get())); const rcti render_region = rcti{0, viewport_size.x, 0, viewport_size.y}; - if (DRW_context_state_get()->rv3d->persp != RV3D_CAMOB) { + /* If the camera view is not opaque, that means the content outside of the camera region is + * visible to some extent, so it would make sense to include them in the compositing region. + * Otherwise, we limit the compositing region to the visible camera region because anything + * outside of the camera region will not be visible anyways. */ + if (!is_opaque_camera_view()) { return render_region; } diff --git a/source/blender/draw/engines/eevee/eevee_data.cc b/source/blender/draw/engines/eevee/eevee_data.cc index 3c31bbfbdeb..14f4eb47cd3 100644 --- a/source/blender/draw/engines/eevee/eevee_data.cc +++ b/source/blender/draw/engines/eevee/eevee_data.cc @@ -13,7 +13,7 @@ #include "BLI_ghash.h" #include "BLI_memblock.h" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_modifier.hh" #include "BKE_object.hh" diff --git a/source/blender/draw/engines/eevee/eevee_effects.cc b/source/blender/draw/engines/eevee/eevee_effects.cc index edfea89a4b4..3cd4ca94d23 100644 --- a/source/blender/draw/engines/eevee/eevee_effects.cc +++ b/source/blender/draw/engines/eevee/eevee_effects.cc @@ -10,7 +10,7 @@ #include "DRW_render.hh" -#include "BKE_global.hh" /* for G.debug_value */ +#include "BKE_global.h" /* for G.debug_value */ #include "GPU_capabilities.h" #include "GPU_platform.h" diff --git a/source/blender/draw/engines/eevee/eevee_engine.cc b/source/blender/draw/engines/eevee/eevee_engine.cc index f54cecb3430..b5d774fc0d6 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.cc +++ b/source/blender/draw/engines/eevee/eevee_engine.cc @@ -12,7 +12,7 @@ #include "BLI_rand.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_object.hh" @@ -472,7 +472,7 @@ static void eevee_render_to_image(void *vedata, Depsgraph *depsgraph = draw_ctx->depsgraph; Scene *scene = DEG_get_evaluated_scene(depsgraph); EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); - const bool do_motion_blur = (scene->r.mode & R_MBLUR) != 0; + const bool do_motion_blur = (scene->eevee.flag & SCE_EEVEE_MOTION_BLUR_ENABLED) != 0; const bool do_motion_blur_fx = do_motion_blur && (scene->eevee.motion_blur_max > 0); if (!EEVEE_render_init(static_cast(vedata), engine, depsgraph)) { @@ -482,7 +482,7 @@ static void eevee_render_to_image(void *vedata, int initial_frame = scene->r.cfra; float initial_subframe = scene->r.subframe; - float shuttertime = (do_motion_blur) ? scene->r.motion_blur_shutter : 0.0f; + float shuttertime = (do_motion_blur) ? scene->eevee.motion_blur_shutter : 0.0f; int time_steps_tot = (do_motion_blur) ? max_ii(1, scene->eevee.motion_blur_steps) : 1; g_data->render_timesteps = time_steps_tot; @@ -496,14 +496,14 @@ static void eevee_render_to_image(void *vedata, /* Compute start time. The motion blur will cover `[time ...time + shuttertime]`. */ float time = initial_frame + initial_subframe; - switch (scene->r.motion_blur_position) { - case SCE_MB_START: + switch (scene->eevee.motion_blur_position) { + case SCE_EEVEE_MB_START: /* No offset. */ break; - case SCE_MB_CENTER: + case SCE_EEVEE_MB_CENTER: time -= shuttertime * 0.5f; break; - case SCE_MB_END: + case SCE_EEVEE_MB_END: time -= shuttertime; break; default: diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.cc b/source/blender/draw/engines/eevee/eevee_lightcache.cc index 06cecaac3a2..02d8d20d059 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.cc +++ b/source/blender/draw/engines/eevee/eevee_lightcache.cc @@ -10,7 +10,7 @@ #include "DRW_render.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_endian_switch.h" #include "BLI_threads.h" @@ -1453,7 +1453,7 @@ void EEVEE_lightbake_job(void *custom_data, wmJobWorkerStatus *worker_status) * because this step is locking at this moment. */ /* TODO: remove this. */ if (lbake->delay) { - BLI_time_sleep_ms(lbake->delay); + BLI_sleep_ms(lbake->delay); } /* Render world irradiance and reflection first */ diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.cc b/source/blender/draw/engines/eevee/eevee_lightprobes.cc index 6bb442c89f0..19849acd0f0 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.cc +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.cc @@ -18,7 +18,7 @@ #include "DNA_view3d_types.h" #include "DNA_world_types.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_object.hh" #include "MEM_guardedalloc.h" @@ -424,7 +424,7 @@ static bool eevee_lightprobes_culling_test(Object *ob) const float max[3] = {1.0f, 1.0f, 1.0f}; BKE_boundbox_init_from_minmax(&bbox, min, max); - copy_m4_m4(tmp, ob->object_to_world().ptr()); + copy_m4_m4(tmp, ob->object_to_world); normalize_v3(tmp[2]); mul_v3_fl(tmp[2], probe->distinf); @@ -467,7 +467,7 @@ void EEVEE_lightprobes_cache_add(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata /* Debug Display */ DRWCallBuffer *grp = vedata->stl->g_data->planar_display_shgrp; if (grp && (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA)) { - DRW_buffer_add_entry(grp, &pinfo->num_planar, ob->object_to_world().ptr()); + DRW_buffer_add_entry(grp, &pinfo->num_planar, ob->object_to_world); } pinfo->num_planar++; @@ -510,30 +510,30 @@ void EEVEE_lightprobes_grid_data_from_object(Object *ob, EEVEE_LightGrid *egrid, mul_v3_v3fl(half_cell_dim, cell_dim, 0.5f); /* Matrix converting world space to cell ranges. */ - invert_m4_m4(egrid->mat, ob->object_to_world().ptr()); + invert_m4_m4(egrid->mat, ob->object_to_world); /* First cell. */ copy_v3_fl(egrid->corner, -1.0f); add_v3_v3(egrid->corner, half_cell_dim); - mul_m4_v3(ob->object_to_world().ptr(), egrid->corner); + mul_m4_v3(ob->object_to_world, egrid->corner); /* Opposite neighbor cell. */ copy_v3_fl3(egrid->increment_x, cell_dim[0], 0.0f, 0.0f); add_v3_v3(egrid->increment_x, half_cell_dim); add_v3_fl(egrid->increment_x, -1.0f); - mul_m4_v3(ob->object_to_world().ptr(), egrid->increment_x); + mul_m4_v3(ob->object_to_world, egrid->increment_x); sub_v3_v3(egrid->increment_x, egrid->corner); copy_v3_fl3(egrid->increment_y, 0.0f, cell_dim[1], 0.0f); add_v3_v3(egrid->increment_y, half_cell_dim); add_v3_fl(egrid->increment_y, -1.0f); - mul_m4_v3(ob->object_to_world().ptr(), egrid->increment_y); + mul_m4_v3(ob->object_to_world, egrid->increment_y); sub_v3_v3(egrid->increment_y, egrid->corner); copy_v3_fl3(egrid->increment_z, 0.0f, 0.0f, cell_dim[2]); add_v3_v3(egrid->increment_z, half_cell_dim); add_v3_fl(egrid->increment_z, -1.0f); - mul_m4_v3(ob->object_to_world().ptr(), egrid->increment_z); + mul_m4_v3(ob->object_to_world, egrid->increment_z); sub_v3_v3(egrid->increment_z, egrid->corner); /* Visibility bias */ @@ -549,7 +549,7 @@ void EEVEE_lightprobes_cube_data_from_object(Object *ob, EEVEE_LightProbe *eprob LightProbe *probe = (LightProbe *)ob->data; /* Update transforms */ - copy_v3_v3(eprobe->position, ob->object_to_world().location()); + copy_v3_v3(eprobe->position, ob->object_to_world[3]); /* Attenuation */ eprobe->attenuation_type = probe->attenuation_type; @@ -557,7 +557,7 @@ void EEVEE_lightprobes_cube_data_from_object(Object *ob, EEVEE_LightProbe *eprob unit_m4(eprobe->attenuationmat); scale_m4_fl(eprobe->attenuationmat, probe->distinf); - mul_m4_m4m4(eprobe->attenuationmat, ob->object_to_world().ptr(), eprobe->attenuationmat); + mul_m4_m4m4(eprobe->attenuationmat, ob->object_to_world, eprobe->attenuationmat); invert_m4(eprobe->attenuationmat); /* Parallax */ @@ -572,7 +572,7 @@ void EEVEE_lightprobes_cube_data_from_object(Object *ob, EEVEE_LightProbe *eprob scale_m4_fl(eprobe->parallaxmat, probe->distinf); } - mul_m4_m4m4(eprobe->parallaxmat, ob->object_to_world().ptr(), eprobe->parallaxmat); + mul_m4_m4m4(eprobe->parallaxmat, ob->object_to_world, eprobe->parallaxmat); invert_m4(eprobe->parallaxmat); } @@ -588,8 +588,8 @@ void EEVEE_lightprobes_planar_data_from_object(Object *ob, vis_test->cached = false; /* Computing mtx : matrix that mirror position around object's XY plane. */ - normalize_m4_m4(normat, ob->object_to_world().ptr()); /* object > world */ - invert_m4_m4(imat, normat); /* world > object */ + normalize_m4_m4(normat, ob->object_to_world); /* object > world */ + invert_m4_m4(imat, normat); /* world > object */ /* XY reflection plane */ imat[0][2] = -imat[0][2]; imat[1][2] = -imat[1][2]; @@ -598,39 +598,38 @@ void EEVEE_lightprobes_planar_data_from_object(Object *ob, mul_m4_m4m4(eplanar->mtx, normat, imat); /* world > object > mirrored obj > world */ /* Compute clip plane equation / normal. */ - copy_v3_v3(eplanar->plane_equation, ob->object_to_world().ptr()[2]); + copy_v3_v3(eplanar->plane_equation, ob->object_to_world[2]); normalize_v3(eplanar->plane_equation); /* plane normal */ - eplanar->plane_equation[3] = -dot_v3v3(eplanar->plane_equation, - ob->object_to_world().location()); + eplanar->plane_equation[3] = -dot_v3v3(eplanar->plane_equation, ob->object_to_world[3]); eplanar->clipsta = probe->clipsta; /* Compute XY clip planes. */ - normalize_v3_v3(eplanar->clip_vec_x, ob->object_to_world().ptr()[0]); - normalize_v3_v3(eplanar->clip_vec_y, ob->object_to_world().ptr()[1]); + normalize_v3_v3(eplanar->clip_vec_x, ob->object_to_world[0]); + normalize_v3_v3(eplanar->clip_vec_y, ob->object_to_world[1]); float vec[3] = {0.0f, 0.0f, 0.0f}; vec[0] = 1.0f; vec[1] = 0.0f; vec[2] = 0.0f; - mul_m4_v3(ob->object_to_world().ptr(), vec); /* Point on the edge */ + mul_m4_v3(ob->object_to_world, vec); /* Point on the edge */ eplanar->clip_edge_x_pos = dot_v3v3(eplanar->clip_vec_x, vec); vec[0] = 0.0f; vec[1] = 1.0f; vec[2] = 0.0f; - mul_m4_v3(ob->object_to_world().ptr(), vec); /* Point on the edge */ + mul_m4_v3(ob->object_to_world, vec); /* Point on the edge */ eplanar->clip_edge_y_pos = dot_v3v3(eplanar->clip_vec_y, vec); vec[0] = -1.0f; vec[1] = 0.0f; vec[2] = 0.0f; - mul_m4_v3(ob->object_to_world().ptr(), vec); /* Point on the edge */ + mul_m4_v3(ob->object_to_world, vec); /* Point on the edge */ eplanar->clip_edge_x_neg = dot_v3v3(eplanar->clip_vec_x, vec); vec[0] = 0.0f; vec[1] = -1.0f; vec[2] = 0.0f; - mul_m4_v3(ob->object_to_world().ptr(), vec); /* Point on the edge */ + mul_m4_v3(ob->object_to_world, vec); /* Point on the edge */ eplanar->clip_edge_y_neg = dot_v3v3(eplanar->clip_vec_y, vec); /* Facing factors */ diff --git a/source/blender/draw/engines/eevee/eevee_lights.cc b/source/blender/draw/engines/eevee/eevee_lights.cc index cb21b6c4b2a..b4fdc7bfa0f 100644 --- a/source/blender/draw/engines/eevee/eevee_lights.cc +++ b/source/blender/draw/engines/eevee/eevee_lights.cc @@ -144,7 +144,7 @@ static void eevee_light_setup(Object *ob, EEVEE_Light *evli) const float light_threshold = draw_ctx->scene->eevee.light_threshold; /* Position */ - copy_v3_v3(evli->position, ob->object_to_world().location()); + copy_v3_v3(evli->position, ob->object_to_world[3]); /* Color */ copy_v3_v3(evli->color, &la->r); @@ -165,7 +165,7 @@ static void eevee_light_setup(Object *ob, EEVEE_Light *evli) evli->invsqrdist_volume = 1.0f / max_ff(1e-4f, square_f(att_radius_volume)); /* Vectors */ - normalize_m4_m4_ex(mat, ob->object_to_world().ptr(), scale); + normalize_m4_m4_ex(mat, ob->object_to_world, scale); copy_v3_v3(evli->forwardvec, mat[2]); normalize_v3(evli->forwardvec); negate_v3(evli->forwardvec); diff --git a/source/blender/draw/engines/eevee/eevee_materials.cc b/source/blender/draw/engines/eevee/eevee_materials.cc index 0664301f9f4..e5404860f36 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.cc +++ b/source/blender/draw/engines/eevee/eevee_materials.cc @@ -16,7 +16,7 @@ #include "BLI_rand.h" #include "BLI_string_utils.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_paint.hh" #include "BKE_particle.h" @@ -904,7 +904,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, if (G.debug_value == 889 && ob->sculpt && BKE_object_sculpt_pbvh_get(ob)) { int debug_node_nr = 0; - DRW_debug_modelmat(ob->object_to_world().ptr()); + DRW_debug_modelmat(ob->object_to_world); BKE_pbvh_draw_debug_cb( BKE_object_sculpt_pbvh_get(ob), DRW_sculpt_debug_cb, &debug_node_nr); } diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.cc b/source/blender/draw/engines/eevee/eevee_motion_blur.cc index 43521c76b41..7dd874115c3 100644 --- a/source/blender/draw/engines/eevee/eevee_motion_blur.cc +++ b/source/blender/draw/engines/eevee/eevee_motion_blur.cc @@ -15,7 +15,7 @@ #include "BKE_animsys.h" #include "BKE_camera.h" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_object.hh" #include "BKE_screen.hh" @@ -52,7 +52,7 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData * /*sldata*/, EEVEE_Data *vedata) effects->motion_blur_max = max_ii(0, scene->eevee.motion_blur_max); - if ((effects->motion_blur_max > 0) && (scene->r.mode & R_MBLUR)) { + if ((effects->motion_blur_max > 0) && (scene->eevee.flag & SCE_EEVEE_MOTION_BLUR_ENABLED)) { if (DRW_state_is_scene_render()) { int mb_step = effects->motion_blur_step; DRW_view_viewmat_get(nullptr, effects->motion_blur.camera[mb_step].viewmat, false); @@ -296,7 +296,7 @@ void EEVEE_motion_blur_curves_cache_populate(EEVEE_ViewLayerData * /*sldata*/, int mb_step = effects->motion_blur_step; /* Store transform. */ - copy_m4_m4(mb_data->obmat[mb_step], ob->object_to_world().ptr()); + copy_m4_m4(mb_data->obmat[mb_step], ob->object_to_world); EEVEE_HairMotionData *mb_curves = EEVEE_motion_blur_curves_data_get(mb_data); @@ -367,7 +367,7 @@ void EEVEE_motion_blur_cache_populate(EEVEE_ViewLayerData * /*sldata*/, if (mb_data) { int mb_step = effects->motion_blur_step; /* Store transform. */ - copy_m4_m4(mb_data->obmat[mb_step], ob->object_to_world().ptr()); + copy_m4_m4(mb_data->obmat[mb_step], ob->object_to_world); EEVEE_GeometryMotionData *mb_geom = EEVEE_motion_blur_geometry_data_get(mb_data); diff --git a/source/blender/draw/engines/eevee/eevee_occlusion.cc b/source/blender/draw/engines/eevee/eevee_occlusion.cc index c8691033b61..8e7c832f39a 100644 --- a/source/blender/draw/engines/eevee/eevee_occlusion.cc +++ b/source/blender/draw/engines/eevee/eevee_occlusion.cc @@ -14,7 +14,7 @@ #include "DEG_depsgraph_query.hh" -#include "BKE_global.hh" /* for G.debug_value */ +#include "BKE_global.h" /* for G.debug_value */ #include "eevee_private.h" diff --git a/source/blender/draw/engines/eevee/eevee_render.cc b/source/blender/draw/engines/eevee/eevee_render.cc index d9d6ada0f61..78fd8554410 100644 --- a/source/blender/draw/engines/eevee/eevee_render.cc +++ b/source/blender/draw/engines/eevee/eevee_render.cc @@ -16,7 +16,7 @@ #include "DNA_node_types.h" #include "DNA_object_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_object.hh" #include "BLI_rand.h" diff --git a/source/blender/draw/engines/eevee/eevee_renderpasses.cc b/source/blender/draw/engines/eevee/eevee_renderpasses.cc index b249d83f9af..649d0092fcb 100644 --- a/source/blender/draw/engines/eevee/eevee_renderpasses.cc +++ b/source/blender/draw/engines/eevee/eevee_renderpasses.cc @@ -11,7 +11,7 @@ #include "draw_color_management.h" /* TODO: remove dependency. */ -#include "BKE_global.hh" /* for G.debug_value */ +#include "BKE_global.h" /* for G.debug_value */ #include "BLI_hash.h" #include "BLI_string_utils.hh" diff --git a/source/blender/draw/engines/eevee/eevee_shaders_extra.cc b/source/blender/draw/engines/eevee/eevee_shaders_extra.cc index 4fadcb51946..7d5fedf4926 100644 --- a/source/blender/draw/engines/eevee/eevee_shaders_extra.cc +++ b/source/blender/draw/engines/eevee/eevee_shaders_extra.cc @@ -131,7 +131,7 @@ void eevee_shader_material_create_info_amend(GPUMaterial *gpumat, attr_load << "void attrib_load()\n"; attr_load << "{\n"; - attr_load << ((!codegen.attr_load.empty()) ? codegen.attr_load : ""); + attr_load << ((codegen.attr_load) ? codegen.attr_load : ""); attr_load << "}\n\n"; std::stringstream vert_gen, frag_gen, geom_gen; @@ -152,18 +152,20 @@ void eevee_shader_material_create_info_amend(GPUMaterial *gpumat, { frag_gen << frag; - frag_gen << codegen.material_functions; + if (codegen.material_functions) { + frag_gen << codegen.material_functions; + } frag_gen << "Closure nodetree_exec()\n"; frag_gen << "{\n"; if (is_volume) { - frag_gen << ((!codegen.volume.empty()) ? codegen.volume : "return CLOSURE_DEFAULT;\n"); + frag_gen << ((codegen.volume) ? codegen.volume : "return CLOSURE_DEFAULT;\n"); } else { - frag_gen << ((!codegen.surface.empty()) ? codegen.surface : "return CLOSURE_DEFAULT;\n"); + frag_gen << ((codegen.surface) ? codegen.surface : "return CLOSURE_DEFAULT;\n"); } frag_gen << "}\n\n"; - if (!codegen.displacement.empty() && (is_hair || is_mesh)) { + if (codegen.displacement && (is_hair || is_mesh)) { info.define("EEVEE_DISPLACEMENT_BUMP"); frag_gen << "vec3 displacement_exec()\n"; diff --git a/source/blender/draw/engines/eevee/eevee_shadows.cc b/source/blender/draw/engines/eevee/eevee_shadows.cc index 1b875eace72..5c21a8cceee 100644 --- a/source/blender/draw/engines/eevee/eevee_shadows.cc +++ b/source/blender/draw/engines/eevee/eevee_shadows.cc @@ -163,7 +163,7 @@ void EEVEE_shadows_caster_register(EEVEE_ViewLayerData *sldata, Object *ob) for (int i = 0; i < 8; i++) { float vec[3]; copy_v3_v3(vec, bb.vec[i]); - mul_m4_v3(ob->object_to_world().ptr(), vec); + mul_m4_v3(ob->object_to_world, vec); minmax_v3v3_v3(min, max, vec); } diff --git a/source/blender/draw/engines/eevee/eevee_shadows_cube.cc b/source/blender/draw/engines/eevee/eevee_shadows_cube.cc index 091ee9b527f..846d33c5f6a 100644 --- a/source/blender/draw/engines/eevee/eevee_shadows_cube.cc +++ b/source/blender/draw/engines/eevee/eevee_shadows_cube.cc @@ -189,13 +189,13 @@ void EEVEE_shadows_draw_cubemap(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, for (int j = 0; j < 6; j++) { /* Optimization: Only render the needed faces. */ /* Skip all but -Z face. */ - if ((ELEM(evli->light_type, LA_SPOT, LAMPTYPE_SPOT_DISK)) && j != 5 && + if ((evli->light_type == LA_SPOT || evli->light_type == LAMPTYPE_SPOT_DISK) && j != 5 && spot_angle_fit_single_face(evli)) { continue; } /* Skip +Z face. */ - if (!(ELEM(evli->light_type, LA_LOCAL, LAMPTYPE_OMNI_DISK)) && j == 4) { + if (!(evli->light_type == LA_LOCAL || evli->light_type == LAMPTYPE_OMNI_DISK) && j == 4) { continue; } /* TODO(fclem): some cube sides can be invisible in the main views. Cull them. */ diff --git a/source/blender/draw/engines/eevee/eevee_volumes.cc b/source/blender/draw/engines/eevee/eevee_volumes.cc index ef942a2e0b8..eb42b810bfd 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.cc +++ b/source/blender/draw/engines/eevee/eevee_volumes.cc @@ -20,7 +20,7 @@ #include "DNA_world_types.h" #include "BKE_fluid.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_volume.hh" @@ -305,7 +305,7 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata, } float size[3]; - mat4_to_size(size, ob->object_to_world().ptr()); + mat4_to_size(size, ob->object_to_world); /* Check if any of the axes have 0 length. (see #69070) */ const float epsilon = 1e-8f; if ((size[0] < epsilon) || (size[1] < epsilon) || (size[2] < epsilon)) { diff --git a/source/blender/draw/engines/eevee_next/eevee_camera.cc b/source/blender/draw/engines/eevee_next/eevee_camera.cc index bba33b0085f..1184f202fcd 100644 --- a/source/blender/draw/engines/eevee_next/eevee_camera.cc +++ b/source/blender/draw/engines/eevee_next/eevee_camera.cc @@ -110,7 +110,7 @@ void Camera::sync() if (inst_.is_baking()) { /* Any view so that shadows and light culling works during irradiance bake. */ - draw::View &view = inst_.volume_probes.bake.view_z_; + draw::View &view = inst_.irradiance_cache.bake.view_z_; data.viewmat = view.viewmat(); data.viewinv = view.viewinv(); data.winmat = view.winmat(); diff --git a/source/blender/draw/engines/eevee_next/eevee_defines.hh b/source/blender/draw/engines/eevee_next/eevee_defines.hh index 4eb54f9802c..36341f45938 100644 --- a/source/blender/draw/engines/eevee_next/eevee_defines.hh +++ b/source/blender/draw/engines/eevee_next/eevee_defines.hh @@ -30,24 +30,16 @@ #define CULLING_TILE_GROUP_SIZE 256 /* Reflection Probes. */ -#define SPHERE_PROBE_GROUP_SIZE 16 -#define SPHERE_PROBE_SELECT_GROUP_SIZE 64 +#define REFLECTION_PROBES_MAX 128 +#define REFLECTION_PROBE_GROUP_SIZE 16 +#define REFLECTION_PROBE_SELECT_GROUP_SIZE 64 /* Number of additional pixels on the border of an octahedral map to reserve for fixing seams. * Border size requires depends on the max number of mipmap levels. */ -#define SPHERE_PROBE_MIPMAP_LEVELS 5 -#define SPHERE_PROBE_SH_GROUP_SIZE 512 -#define SPHERE_PROBE_SH_SAMPLES_PER_GROUP 64 -/** - * Limited by the UBO size limit `(16384 bytes / sizeof(SphereProbeData))`. - */ -#define SPHERE_PROBE_MAX 128 +#define REFLECTION_PROBE_MIPMAP_LEVELS 5 +#define REFLECTION_PROBE_SH_GROUP_SIZE 512 +#define REFLECTION_PROBE_SH_SAMPLES_PER_GROUP 64 -/** - * Limited by the performance impact it can cause. - * Limited by the max layer count supported by a hardware (256). - * Limited by the UBO size limit `(16384 bytes / sizeof(PlanarProbeData))`. - */ -#define PLANAR_PROBE_MAX 16 +#define PLANAR_PROBES_MAX 16 /** * IMPORTANT: Some data packing are tweaked for these values. @@ -178,8 +170,8 @@ /* Only during surface shading (forward and deferred eval). */ #define SHADOW_TILEMAPS_TEX_SLOT 4 #define SHADOW_ATLAS_TEX_SLOT 5 -#define VOLUME_PROBE_TEX_SLOT 6 -#define SPHERE_PROBE_TEX_SLOT 7 +#define IRRADIANCE_ATLAS_TEX_SLOT 6 +#define REFLECTION_PROBE_TEX_SLOT 7 #define VOLUME_SCATTERING_TEX_SLOT 8 #define VOLUME_TRANSMITTANCE_TEX_SLOT 9 /* Currently only used by ray-tracing, but might become used by forward too. */ @@ -210,7 +202,7 @@ #define UNIFORM_BUF_SLOT 1 /* Only during surface shading (forward and deferred eval). */ #define IRRADIANCE_GRID_BUF_SLOT 2 -#define SPHERE_PROBE_BUF_SLOT 3 +#define REFLECTION_PROBE_BUF_SLOT 3 #define PLANAR_PROBE_BUF_SLOT 4 /* Only during pre-pass. */ #define VELOCITY_CAMERA_PREV_BUF 2 diff --git a/source/blender/draw/engines/eevee_next/eevee_engine.cc b/source/blender/draw/engines/eevee_next/eevee_engine.cc index 039f41a1490..0967eccc1fb 100644 --- a/source/blender/draw/engines/eevee_next/eevee_engine.cc +++ b/source/blender/draw/engines/eevee_next/eevee_engine.cc @@ -2,7 +2,7 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_rect.h" #include "GPU_capabilities.h" diff --git a/source/blender/draw/engines/eevee_next/eevee_film.cc b/source/blender/draw/engines/eevee_next/eevee_film.cc index 80b4abdd298..bf3c8d427a3 100644 --- a/source/blender/draw/engines/eevee_next/eevee_film.cc +++ b/source/blender/draw/engines/eevee_next/eevee_film.cc @@ -231,7 +231,7 @@ void Film::init(const int2 &extent, const rcti *output_rect) /* Filter obsolete passes. */ enabled_passes_ &= ~(EEVEE_RENDER_PASS_UNUSED_8 | EEVEE_RENDER_PASS_BLOOM); - if (scene.r.mode & R_MBLUR) { + if (scene_eevee.flag & SCE_EEVEE_MOTION_BLUR_ENABLED) { /* Disable motion vector pass if motion blur is enabled. */ enabled_passes_ &= ~EEVEE_RENDER_PASS_VECTOR; } diff --git a/source/blender/draw/engines/eevee_next/eevee_gbuffer.hh b/source/blender/draw/engines/eevee_next/eevee_gbuffer.hh index 9b9eb36bcc5..7a8e5f04d23 100644 --- a/source/blender/draw/engines/eevee_next/eevee_gbuffer.hh +++ b/source/blender/draw/engines/eevee_next/eevee_gbuffer.hh @@ -11,7 +11,6 @@ #pragma once #include "DRW_render.hh" -#include "GPU_capabilities.h" #include "eevee_material.hh" #include "eevee_shader_shared.hh" @@ -152,41 +151,6 @@ struct GBuffer { normal_img_tx = normal_tx.layer_range_view(1, normal_count - 1); } - /* Bind the GBuffer frame-buffer correctly using the correct workarounds. */ - void bind(Framebuffer &gbuffer_fb) - { - if (/* FIXME(fclem): Vulkan doesn't implement load / store config yet. */ - GPU_backend_get_type() == GPU_BACKEND_VULKAN || - /* FIXME(fclem): Metal has bug in backend. */ - GPU_backend_get_type() == GPU_BACKEND_METAL) - { - header_tx.clear(uint4(0)); - } - - if (GPU_backend_get_type() == GPU_BACKEND_METAL) { - /* TODO(fclem): Load/store action is broken on Metal. */ - GPU_framebuffer_bind(gbuffer_fb); - } - else { - if (!GPU_stencil_export_support()) { - /* Clearing custom load-store frame-buffers is invalid, - * clear the stencil as a regular frame-buffer first. */ - GPU_framebuffer_bind(gbuffer_fb); - GPU_framebuffer_clear_stencil(gbuffer_fb, 0x0u); - } - GPU_framebuffer_bind_ex( - gbuffer_fb, - { - {GPU_LOADACTION_LOAD, GPU_STOREACTION_STORE}, /* Depth */ - {GPU_LOADACTION_LOAD, GPU_STOREACTION_STORE}, /* Combined */ - {GPU_LOADACTION_CLEAR, GPU_STOREACTION_STORE, {0}}, /* GBuf Header */ - {GPU_LOADACTION_DONT_CARE, GPU_STOREACTION_STORE}, /* GBuf Normal*/ - {GPU_LOADACTION_DONT_CARE, GPU_STOREACTION_STORE}, /* GBuf Closure */ - {GPU_LOADACTION_DONT_CARE, GPU_STOREACTION_STORE}, /* GBuf Closure 2*/ - }); - } - } - void release() { /* TODO(fclem): Use texture from pool once they support texture array. */ diff --git a/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc b/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc index 303982fda0e..be07e299ad4 100644 --- a/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc +++ b/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc @@ -2,7 +2,7 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "eevee_instance.hh" @@ -18,8 +18,8 @@ namespace blender::eevee { void HiZBuffer::sync() { int2 render_extent = inst_.film.render_extent_get(); - int2 probe_extent = int2(inst_.sphere_probes.probe_render_extent()); /* Padding to avoid complexity during down-sampling and screen tracing. */ + int2 probe_extent = int2(inst_.reflection_probes.probe_render_extent()); int2 hiz_extent = math::ceil_to_multiple(math::max(render_extent, probe_extent), int2(1u << (HIZ_MIP_COUNT - 1))); int2 dispatch_size = math::divide_ceil(hiz_extent, int2(HIZ_GROUP_SIZE)); diff --git a/source/blender/draw/engines/eevee_next/eevee_instance.cc b/source/blender/draw/engines/eevee_next/eevee_instance.cc index 695db83bbb5..d98b48d3953 100644 --- a/source/blender/draw/engines/eevee_next/eevee_instance.cc +++ b/source/blender/draw/engines/eevee_next/eevee_instance.cc @@ -10,7 +10,7 @@ #include -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_object.hh" #include "BLI_rect.h" #include "DEG_depsgraph_query.hh" @@ -90,11 +90,10 @@ void Instance::init(const int2 &output_res, shadows.init(); motion_blur.init(); main_view.init(); - light_probes.init(); planar_probes.init(); /* Irradiance Cache needs reflection probes to be initialized. */ - sphere_probes.init(); - volume_probes.init(); + reflection_probes.init(); + irradiance_cache.init(); volume.init(); lookdev.init(visible_rect); } @@ -125,11 +124,10 @@ void Instance::init_light_bake(Depsgraph *depsgraph, draw::Manager *manager) depth_of_field.init(); shadows.init(); main_view.init(); - light_probes.init(); planar_probes.init(); /* Irradiance Cache needs reflection probes to be initialized. */ - sphere_probes.init(); - volume_probes.init(); + reflection_probes.init(); + irradiance_cache.init(); volume.init(); lookdev.init(&empty_rect); } @@ -175,7 +173,8 @@ void Instance::begin_sync() volume.begin_sync(); pipelines.begin_sync(); cryptomatte.begin_sync(); - sphere_probes.begin_sync(); + reflection_probes.begin_sync(); + planar_probes.begin_sync(); light_probes.begin_sync(); gpencil_engine_enabled = false; @@ -189,7 +188,7 @@ void Instance::begin_sync() film.sync(); render_buffers.sync(); ambient_occlusion.sync(); - volume_probes.sync(); + irradiance_cache.sync(); lookdev.sync(); use_surfaces = (view_layer->layflag & SCE_LAY_SOLID) != 0; @@ -239,7 +238,7 @@ void Instance::object_sync(Object *ob) if (partsys_is_visible && ob != DRW_context_state_get()->object_edit) { auto sync_hair = [&](ObjectHandle hair_handle, ModifierData &md, ParticleSystem &particle_sys) { - ResourceHandle _res_handle = manager->resource_handle(ob->object_to_world()); + ResourceHandle _res_handle = manager->resource_handle(float4x4(ob->object_to_world)); sync.sync_curves(ob, hair_handle, _res_handle, ob_ref, &md, &particle_sys); }; foreach_hair_particle_handle(ob, ob_handle, sync_hair); @@ -268,7 +267,7 @@ void Instance::object_sync(Object *ob) sync.sync_gpencil(ob, ob_handle, res_handle); break; case OB_LIGHTPROBE: - light_probes.sync_probe(ob, ob_handle); + sync.sync_light_probe(ob, ob_handle); break; default: break; @@ -304,7 +303,7 @@ void Instance::end_sync() cryptomatte.end_sync(); pipelines.end_sync(); light_probes.end_sync(); - sphere_probes.end_sync(); + reflection_probes.end_sync(); planar_probes.end_sync(); uniform_data.push_update(); @@ -345,7 +344,7 @@ void Instance::render_sync() bool Instance::do_reflection_probe_sync() const { - if (!sphere_probes.update_probes_this_sample_) { + if (!reflection_probes.update_probes_this_sample_) { return false; } if (materials.queued_shaders_count > 0) { @@ -479,6 +478,12 @@ void Instance::render_read_result(RenderLayer *render_layer, const char *view_na void Instance::render_frame(RenderLayer *render_layer, const char *view_name) { + /* TODO(jbakker): should we check on the subtype as well? Now it also populates even when there + * are other light probes in the scene. */ + if (DEG_id_type_any_exists(this->depsgraph, ID_LP)) { + reflection_probes.update_probes_next_sample_ = true; + planar_probes.update_probes_ = true; + } while (!sampling.finished()) { this->render_sample(); @@ -630,7 +635,7 @@ void Instance::light_bake_irradiance( context_disable(); }; - volume_probes.bake.init(probe); + irradiance_cache.bake.init(probe); custom_pipeline_wrapper([&]() { manager->begin_sync(); @@ -641,19 +646,19 @@ void Instance::light_bake_irradiance( capture_view.render_world(); - volume_probes.bake.surfels_create(probe); + irradiance_cache.bake.surfels_create(probe); - if (volume_probes.bake.should_break()) { + if (irradiance_cache.bake.should_break()) { return; } - volume_probes.bake.surfels_lights_eval(); + irradiance_cache.bake.surfels_lights_eval(); - volume_probes.bake.clusters_build(); - volume_probes.bake.irradiance_offset(); + irradiance_cache.bake.clusters_build(); + irradiance_cache.bake.irradiance_offset(); }); - if (volume_probes.bake.should_break()) { + if (irradiance_cache.bake.should_break()) { return; } @@ -668,9 +673,9 @@ void Instance::light_bake_irradiance( for (int i = 0; i < 16 && !sampling.finished(); i++) { sampling.step(); - volume_probes.bake.raylists_build(); - volume_probes.bake.propagate_light(); - volume_probes.bake.irradiance_capture(); + irradiance_cache.bake.raylists_build(); + irradiance_cache.bake.propagate_light(); + irradiance_cache.bake.irradiance_capture(); } if (sampling.finished()) { @@ -680,11 +685,11 @@ void Instance::light_bake_irradiance( LightProbeGridCacheFrame *cache_frame; if (sampling.finished()) { - cache_frame = volume_probes.bake.read_result_packed(); + cache_frame = irradiance_cache.bake.read_result_packed(); } else { /* TODO(fclem): Only do this read-back if needed. But it might be tricky to know when. */ - cache_frame = volume_probes.bake.read_result_unpacked(); + cache_frame = irradiance_cache.bake.read_result_unpacked(); } float progress = sampling.sample_index() / float(sampling.sample_count()); diff --git a/source/blender/draw/engines/eevee_next/eevee_instance.hh b/source/blender/draw/engines/eevee_next/eevee_instance.hh index c52b5d9caf8..691b92b869e 100644 --- a/source/blender/draw/engines/eevee_next/eevee_instance.hh +++ b/source/blender/draw/engines/eevee_next/eevee_instance.hh @@ -86,6 +86,8 @@ class Instance { LightModule lights; AmbientOcclusion ambient_occlusion; RayTraceModule raytracing; + ReflectionProbeModule reflection_probes; + PlanarProbeModule planar_probes; VelocityModule velocity; MotionBlurModule motion_blur; DepthOfField depth_of_field; @@ -101,10 +103,8 @@ class Instance { World world; LookdevView lookdev_view; LookdevModule lookdev; - SphereProbeModule sphere_probes; - PlanarProbeModule planar_probes; - VolumeProbeModule volume_probes; LightProbeModule light_probes; + IrradianceCache irradiance_cache; VolumeModule volume; /** Input data. */ @@ -149,6 +149,8 @@ class Instance { lights(*this), ambient_occlusion(*this, uniform_data.data.ao), raytracing(*this, uniform_data.data.raytrace), + reflection_probes(*this), + planar_probes(*this), velocity(*this), motion_blur(*this), depth_of_field(*this), @@ -163,11 +165,12 @@ class Instance { world(*this), lookdev_view(*this), lookdev(*this), - sphere_probes(*this), - planar_probes(*this), - volume_probes(*this), light_probes(*this), - volume(*this, uniform_data.data.volumes){}; + irradiance_cache(*this), + volume(*this, uniform_data.data.volumes) + { + BLI_assert_unreachable(); + }; ~Instance(){}; /* Render & Viewport. */ diff --git a/source/blender/draw/engines/eevee_next/eevee_irradiance_cache.cc b/source/blender/draw/engines/eevee_next/eevee_irradiance_cache.cc index 5ce1336846a..cb17109df08 100644 --- a/source/blender/draw/engines/eevee_next/eevee_irradiance_cache.cc +++ b/source/blender/draw/engines/eevee_next/eevee_irradiance_cache.cc @@ -21,7 +21,7 @@ namespace blender::eevee { /** \name Interface * \{ */ -void VolumeProbeModule::init() +void IrradianceCache::init() { display_grids_enabled_ = DRW_state_draw_support(); @@ -48,7 +48,7 @@ void VolumeProbeModule::init() if (do_full_update_) { /* Delete all references to existing bricks. */ - for (VolumeProbe &grid : inst_.light_probes.volume_map_.values()) { + for (IrradianceGrid &grid : inst_.light_probes.grid_map_.values()) { grid.bricks.clear(); } brick_pool_.clear(); @@ -71,7 +71,7 @@ void VolumeProbeModule::init() irradiance_atlas_tx_.clear(float4(0.0f)); } - inst_.sphere_probes.tag_world_irradiance_for_update(); + inst_.reflection_probes.do_world_update_irradiance_set(true); } if (irradiance_atlas_tx_.is_valid() == false) { @@ -79,14 +79,14 @@ void VolumeProbeModule::init() } } -void VolumeProbeModule::sync() +void IrradianceCache::sync() { if (inst_.is_baking()) { bake.sync(); } } -Vector VolumeProbeModule::bricks_alloc(int brick_len) +Vector IrradianceCache::bricks_alloc(int brick_len) { if (brick_pool_.size() < brick_len) { /* Fail allocation. Not enough brick in the atlas. */ @@ -101,20 +101,20 @@ Vector VolumeProbeModule::bricks_alloc(int brick_len) return allocated; } -void VolumeProbeModule::bricks_free(Vector &bricks) +void IrradianceCache::bricks_free(Vector &bricks) { brick_pool_.extend(bricks.as_span()); bricks.clear(); } -void VolumeProbeModule::set_view(View & /*view*/) +void IrradianceCache::set_view(View & /*view*/) { - Vector grid_loaded; + Vector grid_loaded; bool any_update = false; /* First allocate the needed bricks and populate the brick buffer. */ bricks_infos_buf_.clear(); - for (VolumeProbe &grid : inst_.light_probes.volume_map_.values()) { + for (IrradianceGrid &grid : inst_.light_probes.grid_map_.values()) { LightProbeGridCacheFrame *cache = grid.cache ? grid.cache->grid_static_cache : nullptr; if (cache == nullptr) { continue; @@ -182,7 +182,7 @@ void VolumeProbeModule::set_view(View & /*view*/) * before tagging update. But this is a bit too complex and update is quite cheap. So we update * everything if there is any update on any grid. */ if (any_update) { - for (VolumeProbe *grid : grid_loaded) { + for (IrradianceGrid *grid : grid_loaded) { grid->do_update = true; } } @@ -190,43 +190,44 @@ void VolumeProbeModule::set_view(View & /*view*/) /* Then create brick & grid infos UBOs content. */ { /* Stable sorting of grids. */ - std::sort( - grid_loaded.begin(), grid_loaded.end(), [](const VolumeProbe *a, const VolumeProbe *b) { - float volume_a = math::determinant(float3x3(a->object_to_world)); - float volume_b = math::determinant(float3x3(b->object_to_world)); - if (volume_a != volume_b) { - /* Smallest first. */ - return volume_a < volume_b; - } - /* Volumes are identical. Any arbitrary criteria can be used to sort them. - * Use position to avoid unstable result caused by depsgraph non deterministic eval - * order. This could also become a priority parameter. */ - float3 _a = a->object_to_world.location(); - float3 _b = b->object_to_world.location(); - if (_a.x != _b.x) { - return _a.x < _b.x; - } - else if (_a.y != _b.y) { - return _a.y < _b.y; - } - else if (_a.z != _b.z) { - return _a.z < _b.z; - } - else { - /* Fallback to memory address, since there's no good alternative. */ - return a < b; - } - }); + std::sort(grid_loaded.begin(), + grid_loaded.end(), + [](const IrradianceGrid *a, const IrradianceGrid *b) { + float volume_a = math::determinant(float3x3(a->object_to_world)); + float volume_b = math::determinant(float3x3(b->object_to_world)); + if (volume_a != volume_b) { + /* Smallest first. */ + return volume_a < volume_b; + } + /* Volumes are identical. Any arbitrary criteria can be used to sort them. + * Use position to avoid unstable result caused by depsgraph non deterministic eval + * order. This could also become a priority parameter. */ + float3 _a = a->object_to_world.location(); + float3 _b = b->object_to_world.location(); + if (_a.x != _b.x) { + return _a.x < _b.x; + } + else if (_a.y != _b.y) { + return _a.y < _b.y; + } + else if (_a.z != _b.z) { + return _a.z < _b.z; + } + else { + /* Fallback to memory address, since there's no good alternative. */ + return a < b; + } + }); /* Insert grids in UBO in sorted order. */ int grids_len = 0; - for (VolumeProbe *grid : grid_loaded) { + for (IrradianceGrid *grid : grid_loaded) { grid->grid_index = grids_len; grids_infos_buf_[grids_len++] = *grid; } /* Insert world grid last. */ - VolumeProbeData grid; + IrradianceGridData grid; grid.world_to_grid_transposed = float3x4::identity(); grid.grid_size = int3(1); grid.brick_offset = bricks_infos_buf_.size(); @@ -252,7 +253,7 @@ void VolumeProbeModule::set_view(View & /*view*/) for (auto it = grid_loaded.rbegin(); it != grid_loaded.rend(); ++it) { grid_start_index--; - VolumeProbe *grid = *it; + IrradianceGrid *grid = *it; if (!grid->do_update) { continue; } @@ -390,7 +391,7 @@ void VolumeProbeModule::set_view(View & /*view*/) do_update_world_ = false; } -void VolumeProbeModule::viewport_draw(View &view, GPUFrameBuffer *view_fb) +void IrradianceCache::viewport_draw(View &view, GPUFrameBuffer *view_fb) { if (!inst_.is_baking()) { debug_pass_draw(view, view_fb); @@ -398,7 +399,7 @@ void VolumeProbeModule::viewport_draw(View &view, GPUFrameBuffer *view_fb) } } -void VolumeProbeModule::debug_pass_draw(View &view, GPUFrameBuffer *view_fb) +void IrradianceCache::debug_pass_draw(View &view, GPUFrameBuffer *view_fb) { switch (inst_.debug_mode) { case eDebugMode::DEBUG_IRRADIANCE_CACHE_SURFELS_NORMAL: @@ -424,7 +425,7 @@ void VolumeProbeModule::debug_pass_draw(View &view, GPUFrameBuffer *view_fb) return; } - for (const VolumeProbe &grid : inst_.light_probes.volume_map_.values()) { + for (const IrradianceGrid &grid : inst_.light_probes.grid_map_.values()) { if (grid.cache == nullptr) { continue; } @@ -526,13 +527,13 @@ void VolumeProbeModule::debug_pass_draw(View &view, GPUFrameBuffer *view_fb) } } -void VolumeProbeModule::display_pass_draw(View &view, GPUFrameBuffer *view_fb) +void IrradianceCache::display_pass_draw(View &view, GPUFrameBuffer *view_fb) { if (!display_grids_enabled_) { return; } - for (const VolumeProbe &grid : inst_.light_probes.volume_map_.values()) { + for (const IrradianceGrid &grid : inst_.light_probes.grid_map_.values()) { if (!grid.viewport_display || grid.viewport_display_size == 0.0f || !grid.cache || !grid.cache->grid_static_cache) { @@ -700,7 +701,7 @@ void IrradianceBake::sync() sub.shader_set(inst_.shaders.static_shader_get(SURFEL_RAY)); sub.bind_ssbo(SURFEL_BUF_SLOT, &surfels_buf_); sub.bind_ssbo(CAPTURE_BUF_SLOT, &capture_info_buf_); - sub.bind_resources(inst_.sphere_probes); + sub.bind_resources(inst_.reflection_probes); sub.push_constant("radiance_src", &radiance_src_); sub.push_constant("radiance_dst", &radiance_dst_); sub.barrier(GPU_BARRIER_SHADER_STORAGE); @@ -713,7 +714,7 @@ void IrradianceBake::sync() pass.shader_set(inst_.shaders.static_shader_get(LIGHTPROBE_IRRADIANCE_RAY)); pass.bind_ssbo(SURFEL_BUF_SLOT, &surfels_buf_); pass.bind_ssbo(CAPTURE_BUF_SLOT, &capture_info_buf_); - pass.bind_resources(inst_.sphere_probes); + pass.bind_resources(inst_.reflection_probes); pass.bind_ssbo("list_start_buf", &list_start_buf_); pass.bind_ssbo("list_info_buf", &list_info_buf_); pass.push_constant("radiance_src", &radiance_src_); @@ -814,7 +815,7 @@ void IrradianceBake::surfels_create(const Object &probe_object) const ::LightProbe *lightprobe = static_cast<::LightProbe *>(probe_object.data); int3 grid_resolution = int3(&lightprobe->grid_resolution_x); - float4x4 grid_local_to_world = invert(probe_object.world_to_object()); + float4x4 grid_local_to_world = invert(float4x4(probe_object.world_to_object)); /* TODO(fclem): Options. */ capture_info_buf_.capture_world_direct = capture_world_; @@ -824,14 +825,15 @@ void IrradianceBake::surfels_create(const Object &probe_object) capture_info_buf_.capture_indirect = capture_indirect_; capture_info_buf_.capture_emission = capture_emission_; - LightProbeModule &light_probes = inst_.light_probes; - SphereProbeData &world_data = *static_cast(&light_probes.world_sphere_); - capture_info_buf_.world_atlas_coord = world_data.atlas_coord; + ReflectionProbeModule &reflections = inst_.reflection_probes; + ReflectionProbeAtlasCoordinate atlas_coord = reflections.world_atlas_coord_get(); + ReflectionProbeCoordinate coord = atlas_coord.as_sampling_coord(reflections.atlas_extent()); + capture_info_buf_.world_atlas_coord = coord; dispatch_per_grid_sample_ = math::divide_ceil(grid_resolution, int3(IRRADIANCE_GRID_GROUP_SIZE)); capture_info_buf_.irradiance_grid_size = grid_resolution; capture_info_buf_.irradiance_grid_local_to_world = grid_local_to_world; - capture_info_buf_.irradiance_grid_world_to_local = probe_object.world_to_object(); + capture_info_buf_.irradiance_grid_world_to_local = float4x4(probe_object.world_to_object); capture_info_buf_.irradiance_grid_world_to_local_rotation = float4x4( invert(normalize(float3x3(grid_local_to_world)))); @@ -927,7 +929,7 @@ void IrradianceBake::surfels_create(const Object &probe_object) float epsilon = 1.0f / surfel_density_; scene_min -= epsilon; scene_max += epsilon; - surfel_raster_views_sync(scene_min, scene_max, probe_object.object_to_world()); + surfel_raster_views_sync(scene_min, scene_max, float4x4(probe_object.object_to_world)); DRW_stats_group_end(); diff --git a/source/blender/draw/engines/eevee_next/eevee_irradiance_cache.hh b/source/blender/draw/engines/eevee_next/eevee_irradiance_cache.hh index f045b17a53c..a8cd1a6750f 100644 --- a/source/blender/draw/engines/eevee_next/eevee_irradiance_cache.hh +++ b/source/blender/draw/engines/eevee_next/eevee_irradiance_cache.hh @@ -24,7 +24,7 @@ class Instance; class CapturePipeline; class ShadowModule; class Camera; -class SphereProbeModule; +class ReflectionProbeModule; /** * Baking related pass and data. Not used at runtime. @@ -186,7 +186,7 @@ class IrradianceBake { * Runtime container of diffuse indirect lighting. * Also have debug and baking components. */ -class VolumeProbeModule { +class IrradianceCache { public: IrradianceBake bake; @@ -202,27 +202,27 @@ class VolumeProbeModule { /** Reserved atlas brick for world irradiance. */ int world_brick_index_ = 0; /** Data structure used to index irradiance cache pages inside the atlas. */ - VolumeProbeDataBuf grids_infos_buf_ = {"grids_infos_buf_"}; + IrradianceGridDataBuf grids_infos_buf_ = {"grids_infos_buf_"}; IrradianceBrickBuf bricks_infos_buf_ = {"bricks_infos_buf_"}; /** Pool of atlas regions to allocate to different grids. */ Vector brick_pool_; /** Stream data into the irradiance atlas texture. */ - PassSimple grid_upload_ps_ = {"VolumeProbeModule.Upload"}; + PassSimple grid_upload_ps_ = {"IrradianceCache.Upload"}; /** If true, will trigger the reupload of all grid data instead of just streaming new ones. */ bool do_full_update_ = true; /** Display debug data. */ - PassSimple debug_ps_ = {"VolumeProbeModule.Debug"}; + PassSimple debug_ps_ = {"IrradianceCache.Debug"}; /** Debug surfel elements copied from the light cache. */ draw::StorageArrayBuffer debug_surfels_buf_; /** Display grid cache data. */ bool display_grids_enabled_ = false; - PassSimple display_grids_ps_ = {"VolumeProbeModule.Display Grids"}; + PassSimple display_grids_ps_ = {"IrradianceCache.Display Grids"}; public: - VolumeProbeModule(Instance &inst) : bake(inst), inst_(inst){}; - ~VolumeProbeModule(){}; + IrradianceCache(Instance &inst) : bake(inst), inst_(inst){}; + ~IrradianceCache(){}; void init(); void sync(); @@ -236,14 +236,14 @@ class VolumeProbeModule { { pass.bind_ubo(IRRADIANCE_GRID_BUF_SLOT, &grids_infos_buf_); pass.bind_ssbo(IRRADIANCE_BRICK_BUF_SLOT, &bricks_infos_buf_); - pass.bind_texture(VOLUME_PROBE_TEX_SLOT, &irradiance_atlas_tx_); + pass.bind_texture(IRRADIANCE_ATLAS_TEX_SLOT, &irradiance_atlas_tx_); } private: void debug_pass_draw(View &view, GPUFrameBuffer *view_fb); void display_pass_draw(View &view, GPUFrameBuffer *view_fb); - friend class SphereProbeModule; + friend class ReflectionProbeModule; }; } // namespace blender::eevee diff --git a/source/blender/draw/engines/eevee_next/eevee_light.cc b/source/blender/draw/engines/eevee_next/eevee_light.cc index 4a9d8d09321..26ee49d5e45 100644 --- a/source/blender/draw/engines/eevee_next/eevee_light.cc +++ b/source/blender/draw/engines/eevee_next/eevee_light.cc @@ -62,7 +62,7 @@ void Light::sync(ShadowModule &shadows, const Object *ob, float threshold) this->influence_radius_invsqr_volume = 1.0f / square_f(max_ff(influence_radius_volume, 1e-8f)); this->color = float3(&la->r) * la->energy; - normalize_m4_m4_ex(this->object_mat.ptr(), ob->object_to_world().ptr(), scale); + normalize_m4_m4_ex(this->object_mat.ptr(), ob->object_to_world, scale); /* Make sure we have consistent handedness (in case of negatively scaled Z axis). */ float3 cross = math::cross(float3(this->_right), float3(this->_up)); if (math::dot(cross, float3(this->_back)) < 0.0f) { diff --git a/source/blender/draw/engines/eevee_next/eevee_lightcache.cc b/source/blender/draw/engines/eevee_next/eevee_lightcache.cc index d97c8a9cade..420d403def0 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lightcache.cc +++ b/source/blender/draw/engines/eevee_next/eevee_lightcache.cc @@ -12,7 +12,7 @@ #include "DRW_render.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lightprobe.h" #include "DNA_lightprobe_types.h" @@ -142,7 +142,7 @@ class LightBake { DEG_evaluate_on_framechange(depsgraph_, frame_); if (delay_ms_ > 0) { - BLI_time_sleep_ms(delay_ms_); + BLI_sleep_ms(delay_ms_); } context_enable(); diff --git a/source/blender/draw/engines/eevee_next/eevee_lightprobe.cc b/source/blender/draw/engines/eevee_next/eevee_lightprobe.cc index 82e1bbde9d6..404b8246d75 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lightprobe.cc +++ b/source/blender/draw/engines/eevee_next/eevee_lightprobe.cc @@ -6,8 +6,7 @@ * \ingroup eevee * * Module that handles light probe update tagging. - * Lighting data is contained in their respective module `VolumeProbeModule`, `SphereProbeModule` - * and `PlanarProbeModule`. + * Lighting data is contained in their respective module `IrradianceCache` and `ReflectionProbes`. */ #include "DNA_lightprobe_types.h" @@ -18,64 +17,17 @@ #include "draw_debug.hh" -#include - namespace blender::eevee { -/* -------------------------------------------------------------------- */ -/** \name Light-Probe Module - * \{ */ - -LightProbeModule::LightProbeModule(Instance &inst) : inst_(inst) -{ - /* Initialize the world probe. */ - world_sphere_.clipping_distances = float2(1.0f, 10.0f); - world_sphere_.world_to_probe_transposed = float3x4::identity(); - world_sphere_.influence_shape = SHAPE_ELIPSOID; - world_sphere_.parallax_shape = SHAPE_ELIPSOID; - /* Full influence. */ - world_sphere_.influence_scale = 0.0f; - world_sphere_.influence_bias = 1.0f; - world_sphere_.parallax_distance = 1e10f; - /* In any case, the world must always be up to valid and used for render. */ - world_sphere_.use_for_render = true; -} - -static eLightProbeResolution resolution_to_probe_resolution_enum(int resolution) -{ - switch (resolution) { - case 64: - return LIGHT_PROBE_RESOLUTION_64; - case 128: - return LIGHT_PROBE_RESOLUTION_128; - case 256: - return LIGHT_PROBE_RESOLUTION_256; - case 512: - return LIGHT_PROBE_RESOLUTION_512; - case 1024: - return LIGHT_PROBE_RESOLUTION_1024; - default: - /* Default to maximum resolution because the old max was 4K for Legacy-EEVEE. */ - case 2048: - return LIGHT_PROBE_RESOLUTION_2048; - } -} - -void LightProbeModule::init() -{ - const SceneEEVEE &sce_eevee = inst_.scene->eevee; - sphere_object_resolution_ = resolution_to_probe_resolution_enum(sce_eevee.gi_cubemap_resolution); -} - void LightProbeModule::begin_sync() { auto_bake_enabled_ = inst_.is_viewport() && (inst_.scene->eevee.flag & SCE_EEVEE_GI_AUTOBAKE) != 0; } -void LightProbeModule::sync_volume(const Object *ob, ObjectHandle &handle) +void LightProbeModule::sync_grid(const Object *ob, ObjectHandle &handle) { - VolumeProbe &grid = volume_map_.lookup_or_add_default(handle.object_key); + IrradianceGrid &grid = grid_map_.lookup_or_add_default(handle.object_key); grid.used = true; if (handle.recalc != 0 || grid.initialized == false) { const ::LightProbe *lightprobe = static_cast(ob->data); @@ -83,7 +35,7 @@ void LightProbeModule::sync_volume(const Object *ob, ObjectHandle &handle) grid.initialized = true; grid.updated = true; grid.surfel_density = static_cast(ob->data)->surfel_density; - grid.object_to_world = ob->object_to_world(); + grid.object_to_world = float4x4(ob->object_to_world); grid.world_to_object = float4x4( math::normalize(math::transpose(float3x3(grid.object_to_world)))); @@ -101,77 +53,17 @@ void LightProbeModule::sync_volume(const Object *ob, ObjectHandle &handle) grid.viewport_display_size = lightprobe->data_display_size; /* Force reupload. */ - inst_.volume_probes.bricks_free(grid.bricks); + inst_.irradiance_cache.bricks_free(grid.bricks); } } -void LightProbeModule::sync_sphere(const Object *ob, ObjectHandle &handle) +void LightProbeModule::sync_cube(ObjectHandle &handle) { - SphereProbe &cube = sphere_map_.lookup_or_add_default(handle.object_key); + ReflectionCube &cube = cube_map_.lookup_or_add_default(handle.object_key); cube.used = true; if (handle.recalc != 0 || cube.initialized == false) { - const ::LightProbe &light_probe = *(::LightProbe *)ob->data; - cube.initialized = true; - cube.updated = true; - cube.do_render = true; - - SphereProbeModule &probe_module = inst_.sphere_probes; - eLightProbeResolution probe_resolution = sphere_object_resolution_; - int subdivision_lvl = probe_module.subdivision_level_get(probe_resolution); - - if (cube.atlas_coord.subdivision_lvl != subdivision_lvl) { - cube.atlas_coord.free(); - cube.atlas_coord = find_empty_atlas_region(subdivision_lvl); - SphereProbeData &cube_data = *static_cast(&cube); - /* Update gpu data sampling coordinates. */ - cube_data.atlas_coord = cube.atlas_coord.as_sampling_coord(probe_module.max_resolution_); - /* Coordinates have changed. Area might contain random data. Do not use for rendering. */ - cube.use_for_render = false; - } - - bool use_custom_parallax = (light_probe.flag & LIGHTPROBE_FLAG_CUSTOM_PARALLAX) != 0; - float influence_distance = light_probe.distinf; - float influence_falloff = light_probe.falloff; - float parallax_distance = light_probe.distpar; - parallax_distance = use_custom_parallax ? max_ff(parallax_distance, influence_distance) : - influence_distance; - - auto to_eevee_shape = [](int bl_shape_type) { - return (bl_shape_type == LIGHTPROBE_SHAPE_BOX) ? SHAPE_CUBOID : SHAPE_ELIPSOID; - }; - cube.influence_shape = to_eevee_shape(light_probe.attenuation_type); - cube.parallax_shape = to_eevee_shape(light_probe.parallax_type); - - float4x4 object_to_world = math::scale(ob->object_to_world(), float3(influence_distance)); - cube.location = object_to_world.location(); - cube.volume = math::abs(math::determinant(object_to_world)); - cube.world_to_probe_transposed = float3x4(math::transpose(math::invert(object_to_world))); - cube.influence_scale = 1.0 / max_ff(1e-8f, influence_falloff); - cube.influence_bias = cube.influence_scale; - cube.parallax_distance = parallax_distance / influence_distance; - cube.clipping_distances = float2(light_probe.clipsta, light_probe.clipend); - - cube.viewport_display = light_probe.flag & LIGHTPROBE_FLAG_SHOW_DATA; - cube.viewport_display_size = light_probe.data_display_size; - } -} - -void LightProbeModule::sync_planar(const Object *ob, ObjectHandle &handle) -{ - PlanarProbe &plane = planar_map_.lookup_or_add_default(handle.object_key); - plane.used = true; - if (handle.recalc != 0 || plane.initialized == false) { - const ::LightProbe *light_probe = (::LightProbe *)ob->data; - - plane.initialized = true; - plane.updated = true; - plane.plane_to_world = ob->object_to_world(); - plane.plane_to_world.z_axis() = math::normalize(plane.plane_to_world.z_axis()) * - light_probe->distinf; - plane.world_to_plane = math::invert(plane.plane_to_world); - plane.clipping_offset = light_probe->clipsta; - plane.viewport_display = (light_probe->flag & LIGHTPROBE_FLAG_SHOW_DATA) != 0; + cube_update_ = true; } } @@ -180,185 +72,84 @@ void LightProbeModule::sync_probe(const Object *ob, ObjectHandle &handle) const ::LightProbe *lightprobe = static_cast(ob->data); switch (lightprobe->type) { case LIGHTPROBE_TYPE_SPHERE: - sync_sphere(ob, handle); + sync_cube(handle); return; case LIGHTPROBE_TYPE_PLANE: - sync_planar(ob, handle); + /* TODO(fclem): Remove support? Add support? */ return; case LIGHTPROBE_TYPE_VOLUME: - sync_volume(ob, handle); + sync_grid(ob, handle); return; } BLI_assert_unreachable(); } -void LightProbeModule::sync_world(const ::World *world, bool has_update) -{ - const eLightProbeResolution probe_resolution = static_cast( - world->probe_resolution); - - SphereProbeModule &sph_module = inst_.sphere_probes; - int subdivision_lvl = sph_module.subdivision_level_get(probe_resolution); - - if (subdivision_lvl != world_sphere_.atlas_coord.subdivision_lvl) { - world_sphere_.atlas_coord.free(); - world_sphere_.atlas_coord = find_empty_atlas_region(subdivision_lvl); - SphereProbeData &world_data = *static_cast(&world_sphere_); - world_data.atlas_coord = world_sphere_.atlas_coord.as_sampling_coord( - sph_module.max_resolution_); - has_update = true; - } - - if (has_update) { - world_sphere_.do_render = true; - sph_module.tag_world_irradiance_for_update(); - } -} - void LightProbeModule::end_sync() { - /* Check for deleted or updated grid. */ - volume_update_ = false; - volume_map_.remove_if([&](const Map::MutableItem &item) { - VolumeProbe &grid = item.value; - bool remove_grid = !grid.used; - if (grid.updated || remove_grid) { - volume_update_ = true; - } - grid.updated = false; - grid.used = false; - return remove_grid; - }); - - /* Check for deleted or updated cube. */ - sphere_update_ = false; - sphere_map_.remove_if([&](const Map::MutableItem &item) { - SphereProbe &cube = item.value; - bool remove_cube = !cube.used; - if (cube.updated || remove_cube) { - sphere_update_ = true; - } - cube.updated = false; - cube.used = false; - return remove_cube; - }); - - /* Check for deleted or updated plane. */ - planar_update_ = false; - planar_map_.remove_if([&](const Map::MutableItem &item) { - PlanarProbe &plane = item.value; - bool remove_plane = !plane.used; - if (plane.updated || remove_plane) { - planar_update_ = true; - } - plane.updated = false; - plane.used = false; - return remove_plane; - }); -} - -SphereProbeAtlasCoord LightProbeModule::find_empty_atlas_region(int subdivision_level) const -{ - int layer_count = sphere_layer_count(); - SphereProbeAtlasCoord::LocationFinder location_finder(layer_count, subdivision_level); - - location_finder.mark_space_used(world_sphere_.atlas_coord); - for (const SphereProbe &probe : sphere_map_.values()) { - location_finder.mark_space_used(probe.atlas_coord); - } - return location_finder.first_free_spot(); -} - -int LightProbeModule::sphere_layer_count() const -{ - int max_layer = world_sphere_.atlas_coord.atlas_layer; - for (const SphereProbe &probe : sphere_map_.values()) { - max_layer = max_ii(max_layer, probe.atlas_coord.atlas_layer); - } - int layer_count = max_layer + 1; - return layer_count; -} - -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name SphereProbeAtlasCoord - * \{ */ - -SphereProbeAtlasCoord::LocationFinder::LocationFinder(int allocated_layer_count, - int subdivision_level) -{ - subdivision_level_ = subdivision_level; - areas_per_dimension_ = 1 << subdivision_level_; - areas_per_layer_ = square_i(areas_per_dimension_); - /* Always add an additional layer to make sure that there is always a free area. - * If this area is chosen the atlas will grow. */ - int area_len = (allocated_layer_count + 1) * areas_per_layer_; - areas_occupancy_.resize(area_len, false); -} - -void SphereProbeAtlasCoord::LocationFinder::mark_space_used(const SphereProbeAtlasCoord &coord) -{ - if (coord.atlas_layer == -1) { - /* Coordinate not allocated yet. */ - return; - } - /* The input probe data can be stored in a different subdivision level and should tag all areas - * of the target subdivision level. Shift right if subdivision is higher, left if lower. */ - const int shift_right = max_ii(coord.subdivision_lvl - subdivision_level_, 0); - const int shift_left = max_ii(subdivision_level_ - coord.subdivision_lvl, 0); - const int2 pos_in_location_finder = (coord.area_location() >> shift_right) << shift_left; - /* Tag all areas this probe overlaps. */ - const int layer_offset = coord.atlas_layer * areas_per_layer_; - const int areas_overlapped_per_dim = 1 << shift_left; - for (const int y : IndexRange(areas_overlapped_per_dim)) { - for (const int x : IndexRange(areas_overlapped_per_dim)) { - const int2 pos = pos_in_location_finder + int2(x, y); - const int area_index = pos.x + pos.y * areas_per_dimension_; - areas_occupancy_[area_index + layer_offset].set(); + { + /* Check for deleted or updated grid. */ + grid_update_ = false; + auto it_end = grid_map_.items().end(); + for (auto it = grid_map_.items().begin(); it != it_end; ++it) { + IrradianceGrid &grid = (*it).value; + if (grid.updated) { + grid.updated = false; + grid_update_ = true; + } + if (!grid.used) { + inst_.irradiance_cache.bricks_free(grid.bricks); + grid_map_.remove(it); + grid_update_ = true; + continue; + } + /* Untag for next sync. */ + grid.used = false; } } -} - -SphereProbeAtlasCoord SphereProbeAtlasCoord::LocationFinder::first_free_spot() const -{ - SphereProbeAtlasCoord result; - result.subdivision_lvl = subdivision_level_; - for (int index : areas_occupancy_.index_range()) { - if (!areas_occupancy_[index]) { - result.atlas_layer = index / areas_per_layer_; - result.area_index = index % areas_per_layer_; - return result; + { + /* Check for deleted or updated cube. */ + cube_update_ = false; + auto it_end = cube_map_.items().end(); + for (auto it = cube_map_.items().begin(); it != it_end; ++it) { + ReflectionCube &cube = (*it).value; + if (cube.updated) { + cube.updated = false; + cube_update_ = true; + } + if (!cube.used) { + cube_map_.remove(it); + cube_update_ = true; + continue; + } + /* Untag for next sync. */ + cube.used = false; } } - /* There should always be a free area. See constructor. */ - BLI_assert_unreachable(); - return result; -} -void SphereProbeAtlasCoord::LocationFinder::print_debug() const -{ - std::ostream &os = std::cout; - int layer = 0, row = 0, column = 0; - os << "subdivision " << subdivision_level_ << "\n"; - for (bool spot_taken : areas_occupancy_) { - if (row == 0 && column == 0) { - os << "layer " << layer << "\n"; - } - os << (spot_taken ? 'X' : '-'); - column++; - if (column == areas_per_dimension_) { - os << "\n"; - column = 0; - row++; - } - if (row == areas_per_dimension_) { - row = 0; - layer++; +#if 0 /* TODO make this work with new per object light cache. */ + /* If light-cache auto-update is enable we tag the relevant part + * of the cache to update and fire up a baking job. */ + if (auto_bake_enabled_ && (grid_update_ || cube_update_)) { + Scene *original_scene = DEG_get_input_scene(inst_.depsgraph); + LightCache *light_cache = original_scene->eevee.light_cache_data; + + if (light_cache != nullptr) { + if (grid_update_) { + light_cache->flag |= LIGHTCACHE_UPDATE_GRID; + } + /* TODO(fclem): Reflection Cube-map should capture albedo + normal and be + * relit at runtime. So no dependency like in the old system. */ + if (cube_update_) { + light_cache->flag |= LIGHTCACHE_UPDATE_CUBE; + } + /* Tag the lightcache to auto update. */ + light_cache->flag |= LIGHTCACHE_UPDATE_AUTO; + /* Use a notifier to trigger the operator after drawing. */ + /* TODO(fclem): Avoid usage of global DRW. */ + WM_event_add_notifier(DRW_context_state_get()->evil_C, NC_LIGHTPROBE, original_scene); } } +#endif } -/** \} */ - } // namespace blender::eevee diff --git a/source/blender/draw/engines/eevee_next/eevee_lightprobe.hh b/source/blender/draw/engines/eevee_next/eevee_lightprobe.hh index 2fa785850ec..0d047729d7d 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lightprobe.hh +++ b/source/blender/draw/engines/eevee_next/eevee_lightprobe.hh @@ -6,13 +6,11 @@ * \ingroup eevee * * Module that handles light probe update tagging. - * Lighting data is contained in their respective module `VolumeProbeModule`, `SphereProbeModule` - * and `PlanarProbeModule`. + * Lighting data is contained in their respective module `IrradianceCache` and `ReflectionProbes`. */ #pragma once -#include "BLI_bit_vector.hh" #include "BLI_map.hh" #include "eevee_sync.hh" @@ -20,130 +18,15 @@ namespace blender::eevee { class Instance; -class VolumeProbeModule; - -/* -------------------------------------------------------------------- */ -/** \name SphereProbeAtlasCoord - * \{ */ - -struct SphereProbeAtlasCoord { - /** On which layer of the texture array is this reflection probe stored. */ - int atlas_layer = -1; - /** Gives the extent of this probe relative to the atlas size. */ - int subdivision_lvl = -1; - /** Area index within the layer with the according subdivision level. */ - int area_index = -1; - - /** Release the current atlas space held by this probe. */ - void free() - { - atlas_layer = -1; - } - - /* Return the area extent in pixel. */ - int area_extent(int atlas_extent) const - { - return atlas_extent >> subdivision_lvl; - } - - /* Coordinate of the area in [0..area_count_per_dimension[ range. */ - int2 area_location() const - { - const int area_count_per_dimension = 1 << subdivision_lvl; - return int2(area_index % area_count_per_dimension, area_index / area_count_per_dimension); - } - - /* Coordinate of the bottom left corner of the area in [0..atlas_extent[ range. */ - int2 area_offset(int atlas_extent) const - { - return area_location() * area_extent(atlas_extent); - } - - SphereProbeUvArea as_sampling_coord(int atlas_extent) const - { - /** - * We want to cover the last mip exactly at the pixel center to reduce padding texels and - * interpolation artifacts. - * This is a diagram of a 2px^2 map with `c` being the texels corners and `x` the pixels - * centers. - * - * c-------c-------c - * | | | - * | x | x | < - * | | | | - * c-------c-------c | sampling area - * | | | | - * | x | x | < - * | | | - * c-------c-------c - * ^-------^ - * sampling area - */ - /* Max level only need half a pixel of padding around the sampling area. */ - const int mip_max_lvl_padding = 1; - const int mip_min_lvl_padding = mip_max_lvl_padding << SPHERE_PROBE_MIPMAP_LEVELS; - /* Extent and offset in mip 0 texels. */ - const int sampling_area_extent = area_extent(atlas_extent) - mip_min_lvl_padding; - const int2 sampling_area_offset = area_offset(atlas_extent) + mip_min_lvl_padding / 2; - /* Convert to atlas UVs. */ - SphereProbeUvArea coord; - coord.scale = sampling_area_extent / float(atlas_extent); - coord.offset = float2(sampling_area_offset) / float(atlas_extent); - coord.layer = atlas_layer; - return coord; - } - - SphereProbePixelArea as_write_coord(int atlas_extent, int mip_lvl) const - { - SphereProbePixelArea coord; - coord.extent = atlas_extent >> (subdivision_lvl + mip_lvl); - coord.offset = area_location() * coord.extent; - coord.layer = atlas_layer; - return coord; - } - - /** - * Utility class to find a location in the probe atlas that can be used to store a new probe in - * a specified subdivision level. - * - * The allocation space is subdivided in target subdivision level and is multi layered. - * A layer has `(2 ^ subdivision_lvl) ^ 2` areas. - * - * All allocated probe areas are then process and the candidate areas containing allocated probes - * are marked as occupied. The location finder then return the first available area. - */ - class LocationFinder { - BitVector<> areas_occupancy_; - int subdivision_level_; - /* Area count for the given subdivision level. */ - int areas_per_dimension_; - int areas_per_layer_; - - public: - LocationFinder(int allocated_layer_count, int subdivision_level); - - /* Mark space to be occupied by the given probe_data. */ - void mark_space_used(const SphereProbeAtlasCoord &coord); - - SphereProbeAtlasCoord first_free_spot() const; - - void print_debug() const; - }; -}; - -/** \} */ +class IrradianceCache; struct LightProbe { bool used = false; bool initialized = false; - /* NOTE: Might be not needed if depsgraph updates work as intended. */ bool updated = false; - /** Display debug visuals in the viewport. */ - bool viewport_display = false; - float viewport_display_size = 0.0f; }; -struct VolumeProbe : public LightProbe, VolumeProbeData { +struct IrradianceGrid : public LightProbe, IrradianceGridData { /** Copy of the transform matrix. */ float4x4 object_to_world; /** Precomputed inverse transform with normalized axes. No position. Used for rotating SH. */ @@ -168,104 +51,41 @@ struct VolumeProbe : public LightProbe, VolumeProbeData { float dilation_threshold; float dilation_radius; float intensity; + /** Display irradiance samples in the viewport. */ + bool viewport_display; + float viewport_display_size; }; -struct SphereProbe : public LightProbe, SphereProbeData { - /** Used to sort the probes by priority. */ - float volume; - /** True if the area in the atlas needs to be updated. */ - bool do_render = true; - /** False if the area in the atlas contains undefined data. */ - bool use_for_render = false; - /** Far and near clipping distances for rendering. */ - float2 clipping_distances; - /** Atlas region this probe is rendered at (or will be rendered at). */ - SphereProbeAtlasCoord atlas_coord; -}; - -struct PlanarProbe : public LightProbe, PlanarProbeData { - /* Copy of object matrices. */ - float4x4 plane_to_world; - float4x4 world_to_plane; - /* Offset to the clipping plane in the normal direction. */ - float clipping_offset; - /* Index in the resource array. */ - int resource_index; - - public: - /** - * Update the PlanarProbeData part of the struct. - * `view` is the view we want to render this probe with. - */ - void set_view(const draw::View &view, int layer_id); - - /** - * Create the reflection clip plane equation that clips along the XY plane of the given - * transform. The `clip_offset` will push the clip plane a bit further to avoid missing pixels in - * reflections. The transform does not need to be normalized but is expected to be orthogonal. - * \note Only works after `set_view` was called. - */ - float4 reflection_clip_plane_get() - { - return float4(-normal, math::dot(normal, plane_to_world.location()) - clipping_offset); - } - - private: - /** - * Create the reflection matrix that reflect along the XY plane of the given transform. - * The transform does not need to be normalized but is expected to be orthogonal. - */ - float4x4 reflection_matrix_get() - { - return plane_to_world * math::from_scale(float3(1, 1, -1)) * world_to_plane; - } -}; +struct ReflectionCube : public LightProbe {}; class LightProbeModule { - friend class IrradianceBake; - friend class VolumeProbeModule; - friend class PlanarProbeModule; - friend class SphereProbeModule; + friend class IrradianceCache; private: Instance &inst_; /** Light Probe map to detect deletion and store associated data. */ - Map volume_map_; - Map sphere_map_; - Map planar_map_; - /* World probe is stored separately. */ - SphereProbe world_sphere_; - /** True if a light-probe update was detected. */ - bool volume_update_; - bool sphere_update_; - bool planar_update_; + Map grid_map_; + Map cube_map_; + /** True if a grid update was detected. It will trigger a bake if auto bake is enabled. */ + bool grid_update_; + /** True if a grid update was detected. It will trigger a bake if auto bake is enabled. */ + bool cube_update_; /** True if the auto bake feature is enabled & available in this context. */ bool auto_bake_enabled_; - eLightProbeResolution sphere_object_resolution_ = LIGHT_PROBE_RESOLUTION_64; - public: - LightProbeModule(Instance &inst); + LightProbeModule(Instance &inst) : inst_(inst){}; ~LightProbeModule(){}; - void init(); - void begin_sync(); + + void sync_cube(ObjectHandle &handle); + void sync_grid(const Object *ob, ObjectHandle &handle); + void sync_probe(const Object *ob, ObjectHandle &handle); - void sync_world(const ::World *world, bool has_update); + void end_sync(); - - private: - void sync_sphere(const Object *ob, ObjectHandle &handle); - void sync_volume(const Object *ob, ObjectHandle &handle); - void sync_planar(const Object *ob, ObjectHandle &handle); - - /** Get the number of atlas layers needed to store light probe spheres. */ - int sphere_layer_count() const; - - /** Returns coordinates of an area in the atlas for a probe with the given subdivision level. */ - SphereProbeAtlasCoord find_empty_atlas_region(int subdivision_level) const; }; } // namespace blender::eevee diff --git a/source/blender/draw/engines/eevee_next/eevee_lookdev.cc b/source/blender/draw/engines/eevee_next/eevee_lookdev.cc index bc8dce3c04c..b3caa771c55 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lookdev.cc +++ b/source/blender/draw/engines/eevee_next/eevee_lookdev.cc @@ -235,8 +235,8 @@ void LookdevModule::sync_pass(PassSimple &pass, pass.bind_image("aov_value_img", dummy_aov_value_tx_); pass.bind_resources(inst_.uniform_data); pass.bind_resources(inst_.hiz_buffer.front); - pass.bind_resources(inst_.sphere_probes); - pass.bind_resources(inst_.volume_probes); + pass.bind_resources(inst_.reflection_probes); + pass.bind_resources(inst_.irradiance_cache); pass.bind_resources(inst_.shadows); pass.bind_resources(inst_.volume.result); pass.bind_resources(inst_.cryptomatte); diff --git a/source/blender/draw/engines/eevee_next/eevee_motion_blur.cc b/source/blender/draw/engines/eevee_next/eevee_motion_blur.cc index ee889ea0913..ca9891c0e1c 100644 --- a/source/blender/draw/engines/eevee_next/eevee_motion_blur.cc +++ b/source/blender/draw/engines/eevee_next/eevee_motion_blur.cc @@ -28,7 +28,7 @@ void MotionBlurModule::init() const Scene *scene = inst_.scene; const ViewLayer *view_layer = inst_.view_layer; - enabled_ = (scene->r.mode & R_MBLUR) != 0; + enabled_ = (scene->eevee.flag & SCE_EEVEE_MOTION_BLUR_ENABLED) != 0; if (enabled_) { enabled_ = (view_layer->layflag & SCE_LAY_MOTION_BLUR) != 0; } @@ -46,8 +46,8 @@ void MotionBlurModule::init() initial_frame_ = scene->r.cfra; initial_subframe_ = scene->r.subframe; frame_time_ = initial_frame_ + initial_subframe_; - shutter_position_ = scene->r.motion_blur_position; - shutter_time_ = scene->r.motion_blur_shutter; + shutter_position_ = scene->eevee.motion_blur_position; + shutter_time_ = scene->eevee.motion_blur_shutter; data_.depth_scale = scene->eevee.motion_blur_depth_scale; motion_blur_fx_enabled_ = true; /* TODO(fclem): UI option. */ @@ -108,13 +108,13 @@ void MotionBlurModule::step() float MotionBlurModule::shutter_time_to_scene_time(float time) { switch (shutter_position_) { - case SCE_MB_START: + case SCE_EEVEE_MB_START: /* No offset. */ break; - case SCE_MB_CENTER: + case SCE_EEVEE_MB_CENTER: time -= 0.5f; break; - case SCE_MB_END: + case SCE_EEVEE_MB_END: time -= 1.0; break; default: diff --git a/source/blender/draw/engines/eevee_next/eevee_motion_blur.hh b/source/blender/draw/engines/eevee_next/eevee_motion_blur.hh index 1bb4921d9d3..290facd368a 100644 --- a/source/blender/draw/engines/eevee_next/eevee_motion_blur.hh +++ b/source/blender/draw/engines/eevee_next/eevee_motion_blur.hh @@ -75,7 +75,7 @@ class MotionBlurModule { float initial_subframe_; /** Time of the frame we are rendering. */ float frame_time_; - /** Enum controlling when the shutter opens. See RenderData.motion_blur_position. */ + /** Enum controlling when the shutter opens. See SceneEEVEE.motion_blur_position. */ int shutter_position_; /** Time in scene frame the shutter is open. Controls the amount of blur. */ float shutter_time_; diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc index 95c66a4eb21..29aed713e79 100644 --- a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc +++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc @@ -10,8 +10,12 @@ * This file is only for shading passes. Other passes are declared in their own module. */ -#include "eevee_pipeline.hh" +#include "GPU_capabilities.h" + #include "eevee_instance.hh" + +#include "eevee_pipeline.hh" + #include "eevee_shadow.hh" #include "draw_common.hh" @@ -291,8 +295,8 @@ void ForwardPipeline::sync() opaque_ps_.bind_resources(inst_.volume.result); opaque_ps_.bind_resources(inst_.sampling); opaque_ps_.bind_resources(inst_.hiz_buffer.front); - opaque_ps_.bind_resources(inst_.volume_probes); - opaque_ps_.bind_resources(inst_.sphere_probes); + opaque_ps_.bind_resources(inst_.irradiance_cache); + opaque_ps_.bind_resources(inst_.reflection_probes); } opaque_single_sided_ps_ = &opaque_ps_.sub("SingleSided"); @@ -319,8 +323,8 @@ void ForwardPipeline::sync() sub.bind_resources(inst_.volume.result); sub.bind_resources(inst_.sampling); sub.bind_resources(inst_.hiz_buffer.front); - sub.bind_resources(inst_.volume_probes); - sub.bind_resources(inst_.sphere_probes); + sub.bind_resources(inst_.irradiance_cache); + sub.bind_resources(inst_.reflection_probes); } } @@ -368,7 +372,7 @@ PassMain::Sub *ForwardPipeline::prepass_transparent_add(const Object *ob, state |= DRW_STATE_CULL_BACK; } has_transparent_ = true; - float sorting_value = math::dot(float3(ob->object_to_world().location()), camera_forward_); + float sorting_value = math::dot(float3(ob->object_to_world[3]), camera_forward_); PassMain::Sub *pass = &transparent_ps_.sub(GPU_material_get_name(gpumat), sorting_value); pass->state_set(state); pass->material_set(*inst_.manager, gpumat); @@ -384,7 +388,7 @@ PassMain::Sub *ForwardPipeline::material_transparent_add(const Object *ob, state |= DRW_STATE_CULL_BACK; } has_transparent_ = true; - float sorting_value = math::dot(float3(ob->object_to_world().location()), camera_forward_); + float sorting_value = math::dot(float3(ob->object_to_world[3]), camera_forward_); PassMain::Sub *pass = &transparent_ps_.sub(GPU_material_get_name(gpumat), sorting_value); pass->state_set(state); pass->material_set(*inst_.manager, gpumat); @@ -406,7 +410,7 @@ void ForwardPipeline::render(View &view, Framebuffer &prepass_fb, Framebuffer &c inst_.hiz_buffer.set_dirty(); inst_.shadows.set_view(view, inst_.render_buffers.depth_tx); - inst_.volume_probes.set_view(view); + inst_.irradiance_cache.set_view(view); if (has_opaque_) { combined_fb.bind(); @@ -459,8 +463,8 @@ void DeferredLayerBase::gbuffer_pass_sync(Instance &inst) * Non-NPR shaders will override these resource bindings. */ gbuffer_ps_.bind_resources(inst.lights); gbuffer_ps_.bind_resources(inst.shadows); - gbuffer_ps_.bind_resources(inst.sphere_probes); - gbuffer_ps_.bind_resources(inst.volume_probes); + gbuffer_ps_.bind_resources(inst.reflection_probes); + gbuffer_ps_.bind_resources(inst.irradiance_cache); DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL; @@ -587,8 +591,8 @@ void DeferredLayer::end_sync() sub.bind_resources(inst_.shadows); sub.bind_resources(inst_.sampling); sub.bind_resources(inst_.hiz_buffer.front); - sub.bind_resources(inst_.sphere_probes); - sub.bind_resources(inst_.volume_probes); + sub.bind_resources(inst_.reflection_probes); + sub.bind_resources(inst_.irradiance_cache); sub.state_stencil(0xFFu, i + 1, 0xFFu); sub.draw_procedural(GPU_PRIM_TRIS, 1, 3); } @@ -715,10 +719,40 @@ void DeferredLayer::render(View &main_view, /* Update for lighting pass or AO node. */ inst_.hiz_buffer.update(); - inst_.volume_probes.set_view(render_view); + inst_.irradiance_cache.set_view(render_view); inst_.shadows.set_view(render_view, inst_.render_buffers.depth_tx); - inst_.gbuffer.bind(gbuffer_fb); + if (/* FIXME(fclem): Vulkan doesn't implement load / store config yet. */ + GPU_backend_get_type() == GPU_BACKEND_VULKAN || + /* FIXME(fclem): Metal has bug in backend. */ + GPU_backend_get_type() == GPU_BACKEND_METAL) + { + inst_.gbuffer.header_tx.clear(uint4(0)); + } + + if (GPU_backend_get_type() == GPU_BACKEND_METAL) { + /* TODO(fclem): Load/store action is broken on Metal. */ + GPU_framebuffer_bind(gbuffer_fb); + } + else { + if (!GPU_stencil_export_support()) { + /* Clearing custom load-store frame-buffers is invalid, + * clear the stencil as a regular frame-buffer first. */ + GPU_framebuffer_bind(gbuffer_fb); + GPU_framebuffer_clear_stencil(gbuffer_fb, 0x0u); + } + GPU_framebuffer_bind_ex( + gbuffer_fb, + { + {GPU_LOADACTION_LOAD, GPU_STOREACTION_STORE}, /* Depth */ + {GPU_LOADACTION_LOAD, GPU_STOREACTION_STORE}, /* Combined */ + {GPU_LOADACTION_CLEAR, GPU_STOREACTION_STORE, {0}}, /* GBuf Header */ + {GPU_LOADACTION_DONT_CARE, GPU_STOREACTION_STORE}, /* GBuf Normal*/ + {GPU_LOADACTION_DONT_CARE, GPU_STOREACTION_STORE}, /* GBuf Closure */ + {GPU_LOADACTION_DONT_CARE, GPU_STOREACTION_STORE}, /* GBuf Closure 2*/ + }); + } + inst_.manager->submit(gbuffer_ps_, render_view); for (int i = 0; i < ARRAY_SIZE(direct_radiance_txs_); i++) { @@ -1040,7 +1074,7 @@ GridAABB VolumePipeline::grid_aabb_from_object(Object *ob) BoundBox bb; BKE_boundbox_init_from_minmax(&bb, bounds.min, bounds.max); for (float3 l_corner : bb.vec) { - float3 w_corner = math::transform_point(ob->object_to_world(), l_corner); + float3 w_corner = math::transform_point(float4x4(ob->object_to_world), l_corner); /* Note that this returns the nearest cell corner coordinate. * So sub-froxel AABB will effectively return the same coordinate * for each corner (making it empty and skipped) unless it @@ -1126,39 +1160,38 @@ bool VolumePipeline::use_hit_list() const /** \} */ /* -------------------------------------------------------------------- */ -/** \name Deferred Probe Pipeline - * - * Closure data are written to intermediate buffer allowing screen space processing. +/** \name Deferred Probe Layer * \{ */ -void DeferredProbePipeline::begin_sync() +void DeferredProbeLayer::begin_sync() { - draw::PassMain &pass = opaque_layer_.prepass_ps_; - pass.init(); { - /* Common resources. */ + prepass_ps_.init(); + { + /* Common resources. */ - /* Textures. */ - pass.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); + /* Textures. */ + prepass_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); - pass.bind_resources(inst_.uniform_data); - pass.bind_resources(inst_.velocity); - pass.bind_resources(inst_.sampling); + prepass_ps_.bind_resources(inst_.uniform_data); + prepass_ps_.bind_resources(inst_.velocity); + prepass_ps_.bind_resources(inst_.sampling); + } + + DRWState state_depth_only = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS; + /* Only setting up static pass because we don't use motion vectors for light-probes. */ + prepass_double_sided_static_ps_ = &prepass_ps_.sub("DoubleSided"); + prepass_double_sided_static_ps_->state_set(state_depth_only); + prepass_single_sided_static_ps_ = &prepass_ps_.sub("SingleSided"); + prepass_single_sided_static_ps_->state_set(state_depth_only | DRW_STATE_CULL_BACK); } - DRWState state_depth_only = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS; - /* Only setting up static pass because we don't use motion vectors for light-probes. */ - opaque_layer_.prepass_double_sided_static_ps_ = &pass.sub("DoubleSided"); - opaque_layer_.prepass_double_sided_static_ps_->state_set(state_depth_only); - opaque_layer_.prepass_single_sided_static_ps_ = &pass.sub("SingleSided"); - opaque_layer_.prepass_single_sided_static_ps_->state_set(state_depth_only | DRW_STATE_CULL_BACK); - - opaque_layer_.gbuffer_pass_sync(inst_); + this->gbuffer_pass_sync(inst_); } -void DeferredProbePipeline::end_sync() +void DeferredProbeLayer::end_sync() { - if (opaque_layer_.closure_bits_ & (CLOSURE_DIFFUSE | CLOSURE_REFLECTION)) { + if (closure_bits_ & (CLOSURE_DIFFUSE | CLOSURE_REFLECTION)) { PassSimple &pass = eval_light_ps_; pass.init(); /* Use depth test to reject background pixels. */ @@ -1173,39 +1206,97 @@ void DeferredProbePipeline::end_sync() pass.bind_resources(inst_.shadows); pass.bind_resources(inst_.sampling); pass.bind_resources(inst_.hiz_buffer.front); - pass.bind_resources(inst_.volume_probes); + pass.bind_resources(inst_.irradiance_cache); pass.barrier(GPU_BARRIER_TEXTURE_FETCH | GPU_BARRIER_SHADER_IMAGE_ACCESS); pass.draw_procedural(GPU_PRIM_TRIS, 1, 3); } } -PassMain::Sub *DeferredProbePipeline::prepass_add(::Material *blender_mat, GPUMaterial *gpumat) +PassMain::Sub *DeferredProbeLayer::prepass_add(::Material *blender_mat, GPUMaterial *gpumat) { PassMain::Sub *pass = (blender_mat->blend_flag & MA_BL_CULL_BACKFACE) ? - opaque_layer_.prepass_single_sided_static_ps_ : - opaque_layer_.prepass_double_sided_static_ps_; + prepass_single_sided_static_ps_ : + prepass_double_sided_static_ps_; return &pass->sub(GPU_material_get_name(gpumat)); } -PassMain::Sub *DeferredProbePipeline::material_add(::Material *blender_mat, GPUMaterial *gpumat) +PassMain::Sub *DeferredProbeLayer::material_add(::Material *blender_mat, GPUMaterial *gpumat) { eClosureBits closure_bits = shader_closure_bits_from_flag(gpumat); - opaque_layer_.closure_bits_ |= closure_bits; - opaque_layer_.closure_count_ = max_ii(opaque_layer_.closure_count_, count_bits_i(closure_bits)); + closure_bits_ |= closure_bits; + closure_count_ = max_ii(closure_count_, count_bits_i(closure_bits)); bool has_shader_to_rgba = (closure_bits & CLOSURE_SHADER_TO_RGBA) != 0; bool backface_culling = (blender_mat->blend_flag & MA_BL_CULL_BACKFACE) != 0; PassMain::Sub *pass = (has_shader_to_rgba) ? - ((backface_culling) ? opaque_layer_.gbuffer_single_sided_hybrid_ps_ : - opaque_layer_.gbuffer_double_sided_hybrid_ps_) : - ((backface_culling) ? opaque_layer_.gbuffer_single_sided_ps_ : - opaque_layer_.gbuffer_double_sided_ps_); + ((backface_culling) ? gbuffer_single_sided_hybrid_ps_ : + gbuffer_double_sided_hybrid_ps_) : + ((backface_culling) ? gbuffer_single_sided_ps_ : + gbuffer_double_sided_ps_); return &pass->sub(GPU_material_get_name(gpumat)); } +void DeferredProbeLayer::render(View &view, + Framebuffer &prepass_fb, + Framebuffer &combined_fb, + Framebuffer &gbuffer_fb, + int2 extent) +{ + inst_.pipelines.data.is_probe_reflection = true; + inst_.uniform_data.push_update(); + + GPU_framebuffer_bind(prepass_fb); + inst_.manager->submit(prepass_ps_, view); + + inst_.hiz_buffer.set_source(&inst_.render_buffers.depth_tx); + inst_.lights.set_view(view, extent); + inst_.shadows.set_view(view, inst_.render_buffers.depth_tx); + inst_.irradiance_cache.set_view(view); + + /* Update for lighting pass. */ + inst_.hiz_buffer.update(); + + GPU_framebuffer_bind(gbuffer_fb); + inst_.manager->submit(gbuffer_ps_, view); + + GPU_framebuffer_bind(combined_fb); + inst_.manager->submit(eval_light_ps_, view); + + inst_.pipelines.data.is_probe_reflection = false; + inst_.uniform_data.push_update(); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Deferred Probe Pipeline + * + * Closure data are written to intermediate buffer allowing screen space processing. + * \{ */ + +void DeferredProbePipeline::begin_sync() +{ + opaque_layer_.begin_sync(); +} + +void DeferredProbePipeline::end_sync() +{ + opaque_layer_.end_sync(); +} + +PassMain::Sub *DeferredProbePipeline::prepass_add(::Material *blender_mat, GPUMaterial *gpumat) +{ + return opaque_layer_.prepass_add(blender_mat, gpumat); +} + +PassMain::Sub *DeferredProbePipeline::material_add(::Material *blender_mat, GPUMaterial *gpumat) +{ + return opaque_layer_.material_add(blender_mat, gpumat); +} + void DeferredProbePipeline::render(View &view, Framebuffer &prepass_fb, Framebuffer &combined_fb, @@ -1213,24 +1304,7 @@ void DeferredProbePipeline::render(View &view, int2 extent) { GPU_debug_group_begin("Probe.Render"); - - GPU_framebuffer_bind(prepass_fb); - inst_.manager->submit(opaque_layer_.prepass_ps_, view); - - inst_.hiz_buffer.set_source(&inst_.render_buffers.depth_tx); - inst_.lights.set_view(view, extent); - inst_.shadows.set_view(view, inst_.render_buffers.depth_tx); - inst_.volume_probes.set_view(view); - - /* Update for lighting pass. */ - inst_.hiz_buffer.update(); - - inst_.gbuffer.bind(gbuffer_fb); - inst_.manager->submit(opaque_layer_.gbuffer_ps_, view); - - GPU_framebuffer_bind(combined_fb); - inst_.manager->submit(eval_light_ps_, view); - + opaque_layer_.render(view, prepass_fb, combined_fb, gbuffer_fb, extent); GPU_debug_group_end(); } @@ -1273,8 +1347,8 @@ void PlanarProbePipeline::begin_sync() pass.bind_resources(inst_.shadows); pass.bind_resources(inst_.sampling); pass.bind_resources(inst_.hiz_buffer.front); - pass.bind_resources(inst_.sphere_probes); - pass.bind_resources(inst_.volume_probes); + pass.bind_resources(inst_.reflection_probes); + pass.bind_resources(inst_.irradiance_cache); pass.barrier(GPU_BARRIER_TEXTURE_FETCH | GPU_BARRIER_SHADER_IMAGE_ACCESS); pass.draw_procedural(GPU_PRIM_TRIS, 1, 3); } @@ -1334,12 +1408,22 @@ void PlanarProbePipeline::render(View &view, inst_.hiz_buffer.set_source(&depth_layer_tx, 0); inst_.lights.set_view(view, extent); inst_.shadows.set_view(view, depth_layer_tx); - inst_.volume_probes.set_view(view); + inst_.irradiance_cache.set_view(view); /* Update for lighting pass. */ inst_.hiz_buffer.update(); - inst_.gbuffer.bind(gbuffer_fb); + GPU_framebuffer_bind_ex( + gbuffer_fb, + { + {GPU_LOADACTION_LOAD, GPU_STOREACTION_STORE}, /* Depth */ + {GPU_LOADACTION_CLEAR, GPU_STOREACTION_STORE, {0.0f}}, /* Combined */ + {GPU_LOADACTION_CLEAR, GPU_STOREACTION_STORE, {0}}, /* GBuf Header */ + {GPU_LOADACTION_DONT_CARE, GPU_STOREACTION_STORE}, /* GBuf Normal*/ + {GPU_LOADACTION_DONT_CARE, GPU_STOREACTION_STORE}, /* GBuf Closure */ + {GPU_LOADACTION_DONT_CARE, GPU_STOREACTION_STORE}, /* GBuf Closure 2*/ + }); + inst_.manager->submit(gbuffer_ps_, view); GPU_framebuffer_bind(combined_fb); @@ -1364,10 +1448,10 @@ void CapturePipeline::sync() /* Surfel output is done using a SSBO, so no need for a fragment shader output color or depth. */ /* WORKAROUND: Avoid rasterizer discard, but the shaders actually use no fragment output. */ surface_ps_.state_set(DRW_STATE_WRITE_STENCIL); - surface_ps_.framebuffer_set(&inst_.volume_probes.bake.empty_raster_fb_); + surface_ps_.framebuffer_set(&inst_.irradiance_cache.bake.empty_raster_fb_); - surface_ps_.bind_ssbo(SURFEL_BUF_SLOT, &inst_.volume_probes.bake.surfels_buf_); - surface_ps_.bind_ssbo(CAPTURE_BUF_SLOT, &inst_.volume_probes.bake.capture_info_buf_); + surface_ps_.bind_ssbo(SURFEL_BUF_SLOT, &inst_.irradiance_cache.bake.surfels_buf_); + surface_ps_.bind_ssbo(CAPTURE_BUF_SLOT, &inst_.irradiance_cache.bake.capture_info_buf_); surface_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx); /* TODO(fclem): Remove. Bind to get the camera data, diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.hh b/source/blender/draw/engines/eevee_next/eevee_pipeline.hh index 966d281f1b0..dcbab759b26 100644 --- a/source/blender/draw/engines/eevee_next/eevee_pipeline.hh +++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.hh @@ -485,16 +485,38 @@ class VolumePipeline { /** \name Deferred Probe Capture. * \{ */ -class DeferredProbePipeline { +class DeferredProbePipeline; + +class DeferredProbeLayer : DeferredLayerBase { + friend DeferredProbePipeline; + private: Instance &inst_; - DeferredLayerBase opaque_layer_; - PassSimple eval_light_ps_ = {"EvalLights"}; public: - DeferredProbePipeline(Instance &inst) : inst_(inst){}; + DeferredProbeLayer(Instance &inst) : inst_(inst){}; + + void begin_sync(); + void end_sync(); + + PassMain::Sub *prepass_add(::Material *blender_mat, GPUMaterial *gpumat); + PassMain::Sub *material_add(::Material *blender_mat, GPUMaterial *gpumat); + + void render(View &view, + Framebuffer &prepass_fb, + Framebuffer &combined_fb, + Framebuffer &gbuffer_fb, + int2 extent); +}; + +class DeferredProbePipeline { + private: + DeferredProbeLayer opaque_layer_; + + public: + DeferredProbePipeline(Instance &inst) : opaque_layer_(inst){}; void begin_sync(); void end_sync(); diff --git a/source/blender/draw/engines/eevee_next/eevee_planar_probes.cc b/source/blender/draw/engines/eevee_next/eevee_planar_probes.cc index 0e746dd81d9..3c9a7e62d0a 100644 --- a/source/blender/draw/engines/eevee_next/eevee_planar_probes.cc +++ b/source/blender/draw/engines/eevee_next/eevee_planar_probes.cc @@ -13,6 +13,18 @@ using namespace blender::math; /** \name Planar Probe * \{ */ +void PlanarProbe::sync(const float4x4 &world_to_object, + float clipping_offset, + float influence_distance, + bool viewport_display) +{ + this->plane_to_world = float4x4(world_to_object); + this->plane_to_world.z_axis() = normalize(this->plane_to_world.z_axis()) * influence_distance; + this->world_to_plane = invert(this->plane_to_world); + this->clipping_offset = clipping_offset; + this->viewport_display = viewport_display; +} + void PlanarProbe::set_view(const draw::View &view, int layer_id) { this->viewmat = view.viewmat() * reflection_matrix_get(); @@ -28,6 +40,16 @@ void PlanarProbe::set_view(const draw::View &view, int layer_id) this->layer_id = layer_id; } +float4x4 PlanarProbe::reflection_matrix_get() +{ + return plane_to_world * from_scale(float3(1, 1, -1)) * world_to_plane; +} + +float4 PlanarProbe::reflection_clip_plane_get() +{ + return float4(-normal, dot(normal, plane_to_world.location()) - clipping_offset); +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -36,33 +58,47 @@ void PlanarProbe::set_view(const draw::View &view, int layer_id) void PlanarProbeModule::init() { - /* This triggers the compilation of clipped shader only if we can detect light-probe planes. */ - if (inst_.is_viewport()) { - /* This check needs to happen upfront before sync, so we use the previous sync result. */ - update_probes_ = !inst_.light_probes.planar_map_.is_empty(); + update_probes_ = !probes_.is_empty(); + do_display_draw_ = false; +} + +void PlanarProbeModule::begin_sync() +{ + for (PlanarProbe &probe : probes_.values()) { + probe.is_probe_used = false; } - else { - /* TODO(jbakker): should we check on the subtype as well? Now it also populates even when - * there are other light probes in the scene. */ - update_probes_ = DEG_id_type_any_exists(inst_.depsgraph, ID_LP); +} + +void PlanarProbeModule::sync_object(Object *ob, ObjectHandle &ob_handle) +{ + const ::LightProbe *light_probe = (::LightProbe *)ob->data; + if (light_probe->type != LIGHTPROBE_TYPE_PLANE) { + return; } - do_display_draw_ = false; + PlanarProbe &probe = find_or_insert(ob_handle); + probe.sync(float4x4(ob->object_to_world), + light_probe->clipsta, + light_probe->distinf, + light_probe->flag & LIGHTPROBE_FLAG_SHOW_DATA); + probe.is_probe_used = true; } void PlanarProbeModule::end_sync() { + probes_.remove_if([](const PlanarProbes::Item &item) { return !item.value.is_probe_used; }); + /* When first planar probes are enabled it can happen that the first sample is off. */ - if (!update_probes_ && !inst_.light_probes.planar_map_.is_empty()) { + if (!update_probes_ && !probes_.is_empty()) { DRW_viewport_request_redraw(); } } void PlanarProbeModule::set_view(const draw::View &main_view, int2 main_view_extent) { - GBuffer &gbuf = inst_.gbuffer; + GBuffer &gbuf = instance_.gbuffer; - const int64_t num_probes = inst_.light_probes.planar_map_.size(); + const int64_t num_probes = probes_.size(); /* TODO resolution percentage. */ int2 extent = main_view_extent; @@ -83,12 +119,12 @@ void PlanarProbeModule::set_view(const draw::View &main_view, int2 main_view_ext int resource_index = 0; int display_index = 0; - for (PlanarProbe &probe : inst_.light_probes.planar_map_.values()) { - if (resource_index == PLANAR_PROBE_MAX) { + for (PlanarProbe &probe : probes_.values()) { + if (resource_index == PLANAR_PROBES_MAX) { break; } - PlanarResources &res = resources_[resource_index]; + PlanarProbeResources &res = resources_[resource_index]; /* TODO Cull out of view planars. */ @@ -101,8 +137,8 @@ void PlanarProbeModule::set_view(const draw::View &main_view, int2 main_view_ext world_clip_buf_.push_update(); gbuf.acquire(extent, - inst_.pipelines.deferred.closure_layer_count(), - inst_.pipelines.deferred.normal_layer_count()); + instance_.pipelines.deferred.closure_layer_count(), + instance_.pipelines.deferred.normal_layer_count()); res.combined_fb.ensure(GPU_ATTACHMENT_TEXTURE_LAYER(depth_tx_, resource_index), GPU_ATTACHMENT_TEXTURE_LAYER(radiance_tx_, resource_index)); @@ -114,7 +150,7 @@ void PlanarProbeModule::set_view(const draw::View &main_view, int2 main_view_ext GPU_ATTACHMENT_TEXTURE_LAYER(gbuf.closure_tx.layer_view(0), 0), GPU_ATTACHMENT_TEXTURE_LAYER(gbuf.closure_tx.layer_view(1), 0)); - inst_.pipelines.planar.render( + instance_.pipelines.planar.render( res.view, depth_tx_.layer_view(resource_index), res.gbuffer_fb, res.combined_fb, extent); if (do_display_draw_ && probe.viewport_display) { @@ -126,7 +162,7 @@ void PlanarProbeModule::set_view(const draw::View &main_view, int2 main_view_ext gbuf.release(); - if (resource_index < PLANAR_PROBE_MAX) { + if (resource_index < PLANAR_PROBES_MAX) { /* Tag the end of the array. */ probe_planar_buf_[resource_index].layer_id = -1; } @@ -139,6 +175,12 @@ void PlanarProbeModule::set_view(const draw::View &main_view, int2 main_view_ext } } +PlanarProbe &PlanarProbeModule::find_or_insert(ObjectHandle &ob_handle) +{ + PlanarProbe &planar_probe = probes_.lookup_or_add_default(ob_handle.object_key.hash()); + return planar_probe; +} + void PlanarProbeModule::viewport_draw(View &view, GPUFrameBuffer *view_fb) { if (!do_display_draw_) { @@ -149,12 +191,12 @@ void PlanarProbeModule::viewport_draw(View &view, GPUFrameBuffer *view_fb) viewport_display_ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK); viewport_display_ps_.framebuffer_set(&view_fb); - viewport_display_ps_.shader_set(inst_.shaders.static_shader_get(DISPLAY_PROBE_PLANAR)); + viewport_display_ps_.shader_set(instance_.shaders.static_shader_get(DISPLAY_PROBE_PLANAR)); bind_resources(viewport_display_ps_); viewport_display_ps_.bind_ssbo("display_data_buf", display_data_buf_); viewport_display_ps_.draw_procedural(GPU_PRIM_TRIS, 1, display_data_buf_.size() * 6); - inst_.manager->submit(viewport_display_ps_, view); + instance_.manager->submit(viewport_display_ps_, view); } /** \} */ diff --git a/source/blender/draw/engines/eevee_next/eevee_planar_probes.hh b/source/blender/draw/engines/eevee_next/eevee_planar_probes.hh index e467a39ef2e..147ccac991e 100644 --- a/source/blender/draw/engines/eevee_next/eevee_planar_probes.hh +++ b/source/blender/draw/engines/eevee_next/eevee_planar_probes.hh @@ -22,43 +22,91 @@ class Instance; class HiZBuffer; struct ObjectHandle; +/* -------------------------------------------------------------------- */ +/** \name Planar Probe + * \{ */ + +struct PlanarProbe : ProbePlanarData { + /* Copy of object matrices. */ + float4x4 plane_to_world; + float4x4 world_to_plane; + /* Offset to the clipping plane in the normal direction. */ + float clipping_offset; + /* Index in the resource array. */ + int resource_index; + /* Pruning flag. */ + bool is_probe_used = false; + /** Display a debug plane in the viewport. */ + bool viewport_display = false; + + public: + void sync(const float4x4 &world_to_object, + float clipping_offset, + float influence_distance, + bool viewport_display); + + /** + * Update the ProbePlanarData part of the struct. + * `view` is the view we want to render this probe with. + */ + void set_view(const draw::View &view, int layer_id); + + /** + * Create the reflection clip plane equation that clips along the XY plane of the given + * transform. The `clip_offset` will push the clip plane a bit further to avoid missing pixels in + * reflections. The transform does not need to be normalized but is expected to be orthogonal. + * \note Only works after `set_view` was called. + */ + float4 reflection_clip_plane_get(); + + private: + /** + * Create the reflection matrix that reflect along the XY plane of the given transform. + * The transform does not need to be normalized but is expected to be orthogonal. + */ + float4x4 reflection_matrix_get(); +}; + +struct PlanarProbeResources : NonCopyable { + Framebuffer combined_fb = {"planar.combined_fb"}; + Framebuffer gbuffer_fb = {"planar.gbuffer_fb"}; + draw::View view = {"planar.view"}; +}; + +/** \} */ + /* -------------------------------------------------------------------- */ /** \name Planar Probe Module * \{ */ class PlanarProbeModule { - friend class Instance; - friend class HiZBuffer; - friend class PlanarProbePipeline; + using PlanarProbes = Map; private: - Instance &inst_; + Instance &instance_; - struct PlanarResources : NonCopyable { - Framebuffer combined_fb = {"planar.combined_fb"}; - Framebuffer gbuffer_fb = {"planar.gbuffer_fb"}; - draw::View view = {"planar.view"}; - }; - - std::array resources_; + PlanarProbes probes_; + std::array resources_; Texture radiance_tx_ = {"planar.radiance_tx"}; Texture depth_tx_ = {"planar.depth_tx"}; ClipPlaneBuf world_clip_buf_ = {"world_clip_buf"}; - PlanarProbeDataBuf probe_planar_buf_ = {"probe_planar_buf"}; + ProbePlanarDataBuf probe_planar_buf_ = {"probe_planar_buf"}; bool update_probes_ = false; /** Viewport data display drawing. */ bool do_display_draw_ = false; - PlanarProbeDisplayDataBuf display_data_buf_; + ProbePlanarDisplayDataBuf display_data_buf_; PassSimple viewport_display_ps_ = {"PlanarProbeModule.Viewport Display"}; public: - PlanarProbeModule(Instance &instance) : inst_(instance) {} + PlanarProbeModule(Instance &instance) : instance_(instance) {} void init(); + void begin_sync(); + void sync_object(Object *ob, ObjectHandle &ob_handle); void end_sync(); void set_view(const draw::View &main_view, int2 main_view_extent); @@ -78,6 +126,13 @@ class PlanarProbeModule { { return update_probes_; } + + private: + PlanarProbe &find_or_insert(ObjectHandle &ob_handle); + + friend class Instance; + friend class HiZBuffer; + friend class PlanarProbePipeline; }; /** \} */ diff --git a/source/blender/draw/engines/eevee_next/eevee_raytrace.cc b/source/blender/draw/engines/eevee_next/eevee_raytrace.cc index e46e6e254cc..1d5a2748c08 100644 --- a/source/blender/draw/engines/eevee_next/eevee_raytrace.cc +++ b/source/blender/draw/engines/eevee_next/eevee_raytrace.cc @@ -11,7 +11,7 @@ #include #include -#include "BKE_global.hh" +#include "BKE_global.h" #include "eevee_instance.hh" @@ -106,8 +106,8 @@ void RayTraceModule::sync() pass.bind_texture("depth_tx", &depth_tx); pass.bind_resources(inst_.uniform_data); pass.bind_resources(inst_.planar_probes); - pass.bind_resources(inst_.volume_probes); - pass.bind_resources(inst_.sphere_probes); + pass.bind_resources(inst_.irradiance_cache); + pass.bind_resources(inst_.reflection_probes); pass.bind_resources(inst_.gbuffer); /* TODO(@fclem): Use another dispatch with only tiles that touches planar captures. */ pass.dispatch(raytrace_tracing_dispatch_buf_); @@ -134,8 +134,8 @@ void RayTraceModule::sync() pass.bind_image("ray_radiance_img", &ray_radiance_tx_); pass.bind_resources(inst_.uniform_data); pass.bind_resources(inst_.sampling); - pass.bind_resources(inst_.volume_probes); - pass.bind_resources(inst_.sphere_probes); + pass.bind_resources(inst_.irradiance_cache); + pass.bind_resources(inst_.reflection_probes); pass.bind_resources(inst_.gbuffer); pass.dispatch(raytrace_tracing_dispatch_buf_); pass.barrier(GPU_BARRIER_SHADER_IMAGE_ACCESS); @@ -150,8 +150,8 @@ void RayTraceModule::sync() pass.bind_image("ray_radiance_img", &ray_radiance_tx_); pass.bind_texture("depth_tx", &depth_tx); pass.bind_resources(inst_.uniform_data); - pass.bind_resources(inst_.volume_probes); - pass.bind_resources(inst_.sphere_probes); + pass.bind_resources(inst_.irradiance_cache); + pass.bind_resources(inst_.reflection_probes); pass.bind_resources(inst_.sampling); pass.dispatch(raytrace_tracing_dispatch_buf_); pass.barrier(GPU_BARRIER_SHADER_IMAGE_ACCESS); @@ -269,8 +269,8 @@ void RayTraceModule::sync() pass.bind_resources(inst_.uniform_data); pass.bind_resources(inst_.sampling); pass.bind_resources(inst_.gbuffer); - pass.bind_resources(inst_.volume_probes); - pass.bind_resources(inst_.sphere_probes); + pass.bind_resources(inst_.irradiance_cache); + pass.bind_resources(inst_.reflection_probes); pass.dispatch(horizon_denoise_dispatch_buf_); pass.barrier(GPU_BARRIER_SHADER_IMAGE_ACCESS); } diff --git a/source/blender/draw/engines/eevee_next/eevee_reflection_probes.cc b/source/blender/draw/engines/eevee_next/eevee_reflection_probes.cc index 114ade5eb16..e5408cb8f34 100644 --- a/source/blender/draw/engines/eevee_next/eevee_reflection_probes.cc +++ b/source/blender/draw/engines/eevee_next/eevee_reflection_probes.cc @@ -2,229 +2,512 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "eevee_reflection_probes.hh" +#include "BLI_bit_vector.hh" + #include "eevee_instance.hh" +#include "eevee_reflection_probes.hh" + +#include namespace blender::eevee { +/* -------------------------------------------------------------------- */ +/** \name ProbeLocationFinder + * \{ */ + +/** + * Utility class to find a location in the probes_tx_ that can be used to store a new probe in + * a specified subdivision level. + */ +class ProbeLocationFinder { + BitVector<> taken_spots_; + int probes_per_dimension_; + int probes_per_layer_; + int subdivision_level_; + + public: + ProbeLocationFinder(int num_layers, int subdivision_level) + { + subdivision_level_ = subdivision_level; + probes_per_dimension_ = 1 << subdivision_level_; + probes_per_layer_ = probes_per_dimension_ * probes_per_dimension_; + int num_spots = num_layers * probes_per_layer_; + taken_spots_.resize(num_spots, false); + } + + void print_debug() const + { + std::ostream &os = std::cout; + int layer = 0; + int row = 0; + int column = 0; + + os << "subdivision " << subdivision_level_ << "\n"; + + for (bool spot_taken : taken_spots_) { + if (row == 0 && column == 0) { + os << "layer " << layer << "\n"; + } + + os << (spot_taken ? '1' : '0'); + + column++; + if (column == probes_per_dimension_) { + os << "\n"; + column = 0; + row++; + } + if (row == probes_per_dimension_) { + row = 0; + layer++; + } + } + } + + /** + * Mark space to be occupied by the given probe_data. + * + * The input probe data can be stored in a different subdivision level and should be converted to + * the subdivision level what we are looking for. + */ + void mark_space_used(const ReflectionProbeAtlasCoordinate &coord) + { + const int shift_right = max_ii(coord.layer_subdivision - subdivision_level_, 0); + const int shift_left = max_ii(subdivision_level_ - coord.layer_subdivision, 0); + const int spots_per_dimension = 1 << shift_left; + const int probes_per_dimension_in_probe_data = 1 << coord.layer_subdivision; + const int2 pos_in_probe_data = int2(coord.area_index % probes_per_dimension_in_probe_data, + coord.area_index / probes_per_dimension_in_probe_data); + const int2 pos_in_location_finder = int2((pos_in_probe_data.x >> shift_right) << shift_left, + (pos_in_probe_data.y >> shift_right) << shift_left); + const int layer_offset = coord.layer * probes_per_layer_; + for (const int y : IndexRange(spots_per_dimension)) { + for (const int x : IndexRange(spots_per_dimension)) { + const int2 pos = pos_in_location_finder + int2(x, y); + const int area_index = pos.x + pos.y * probes_per_dimension_; + taken_spots_[area_index + layer_offset].set(); + } + } + } + + /** + * Get the first free spot. + * + * .x contains the layer the first free spot was detected. + * .y contains the area_index to use. + * + * Asserts when no free spot is found. ProbeLocationFinder should always be initialized with an + * additional layer to make sure that there is always a free spot. + */ + ReflectionProbeAtlasCoordinate first_free_spot() const + { + ReflectionProbeAtlasCoordinate result; + result.layer_subdivision = subdivision_level_; + for (int index : taken_spots_.index_range()) { + if (!taken_spots_[index]) { + result.layer = index / probes_per_layer_; + result.area_index = index % probes_per_layer_; + return result; + } + } + BLI_assert_unreachable(); + return result; + } +}; + +/** \} */ + /* -------------------------------------------------------------------- */ /** \name Reflection Probe Module * \{ */ -int SphereProbeModule::probe_render_extent() const +eLightProbeResolution ReflectionProbeModule::reflection_probe_resolution() const +{ + switch (instance_.scene->eevee.gi_cubemap_resolution) { + case 64: + return LIGHT_PROBE_RESOLUTION_64; + case 128: + return LIGHT_PROBE_RESOLUTION_128; + case 256: + return LIGHT_PROBE_RESOLUTION_256; + case 512: + return LIGHT_PROBE_RESOLUTION_512; + case 1024: + return LIGHT_PROBE_RESOLUTION_1024; + default: + return LIGHT_PROBE_RESOLUTION_2048; + } + return LIGHT_PROBE_RESOLUTION_2048; +} + +int ReflectionProbeModule::probe_render_extent() const { return instance_.scene->eevee.gi_cubemap_resolution / 2; } -void SphereProbeModule::init() +void ReflectionProbeModule::init() { - if (!instance_.is_viewport()) { - /* TODO(jbakker): should we check on the subtype as well? Now it also populates even when - * there are other light probes in the scene. */ - update_probes_next_sample_ = DEG_id_type_any_exists(instance_.depsgraph, ID_LP); + if (!is_initialized) { + is_initialized = true; + + /* Initialize the world probe. */ + + ReflectionProbe world_probe = {}; + world_probe.type = ReflectionProbe::Type::WORLD; + world_probe.is_probe_used = true; + world_probe.do_render = true; + world_probe.clipping_distances = float2(1.0f, 10.0f); + world_probe.world_to_probe_transposed = float3x4::identity(); + world_probe.influence_shape = SHAPE_ELIPSOID; + world_probe.parallax_shape = SHAPE_ELIPSOID; + /* Full influence. */ + world_probe.influence_scale = 0.0f; + world_probe.influence_bias = 1.0f; + world_probe.parallax_distance = 1e10f; + + probes_.add(world_object_key_, world_probe); + + probes_tx_.ensure_2d_array(GPU_RGBA16F, + int2(max_resolution_), + 1, + GPU_TEXTURE_USAGE_SHADER_WRITE | GPU_TEXTURE_USAGE_SHADER_READ, + nullptr, + REFLECTION_PROBE_MIPMAP_LEVELS); + GPU_texture_mipmap_mode(probes_tx_, true, true); + probes_tx_.clear(float4(0.0f)); } - do_display_draw_ = false; -} - -void SphereProbeModule::begin_sync() -{ - update_probes_this_sample_ = update_probes_next_sample_; - - LightProbeModule &light_probes = instance_.light_probes; - SphereProbeData &world_data = *static_cast(&light_probes.world_sphere_); { const RaytraceEEVEE &options = instance_.scene->eevee.ray_tracing_options; float probe_brightness_clamp = (options.sample_clamp > 0.0) ? options.sample_clamp : 1e20; PassSimple &pass = remap_ps_; pass.init(); - pass.shader_set(instance_.shaders.static_shader_get(SPHERE_PROBE_REMAP)); + pass.shader_set(instance_.shaders.static_shader_get(REFLECTION_PROBE_REMAP)); pass.bind_texture("cubemap_tx", &cubemap_tx_); pass.bind_texture("atlas_tx", &probes_tx_); pass.bind_image("atlas_img", &probes_tx_); pass.push_constant("probe_coord_packed", reinterpret_cast(&probe_sampling_coord_)); pass.push_constant("write_coord_packed", reinterpret_cast(&probe_write_coord_)); - pass.push_constant("world_coord_packed", reinterpret_cast(&world_data.atlas_coord)); + pass.push_constant("world_coord_packed", reinterpret_cast(&world_sampling_coord_)); + pass.push_constant("mip_level", &probe_mip_level_); pass.push_constant("probe_brightness_clamp", probe_brightness_clamp); pass.dispatch(&dispatch_probe_pack_); } - { - PassSimple &pass = convolve_ps_; - pass.init(); - pass.shader_set(instance_.shaders.static_shader_get(SPHERE_PROBE_CONVOLVE)); - pass.bind_image("in_atlas_mip_img", &convolve_input_); - pass.bind_image("out_atlas_mip_img", &convolve_output_); - pass.push_constant("write_coord_packed", reinterpret_cast(&probe_write_coord_)); - pass.barrier(GPU_BARRIER_SHADER_IMAGE_ACCESS); - pass.dispatch(&dispatch_probe_convolve_); - pass.barrier(GPU_BARRIER_SHADER_IMAGE_ACCESS); - } + { PassSimple &pass = update_irradiance_ps_; pass.init(); - pass.shader_set(instance_.shaders.static_shader_get(SPHERE_PROBE_UPDATE_IRRADIANCE)); - pass.push_constant("world_coord_packed", reinterpret_cast(&world_data.atlas_coord)); - pass.bind_image("irradiance_atlas_img", &instance_.volume_probes.irradiance_atlas_tx_); + pass.shader_set(instance_.shaders.static_shader_get(REFLECTION_PROBE_UPDATE_IRRADIANCE)); + pass.push_constant("world_coord_packed", reinterpret_cast(&world_sampling_coord_)); + pass.bind_image("irradiance_atlas_img", &instance_.irradiance_cache.irradiance_atlas_tx_); pass.bind_texture("reflection_probes_tx", &probes_tx_); pass.dispatch(int2(1, 1)); } + + do_display_draw_ = false; +} + +void ReflectionProbeModule::begin_sync() +{ + for (ReflectionProbe &reflection_probe : probes_.values()) { + if (reflection_probe.type == ReflectionProbe::Type::PROBE) { + reflection_probe.is_probe_used = false; + } + } + + update_probes_this_sample_ = false; + if (update_probes_next_sample_) { + update_probes_this_sample_ = true; + } + { PassSimple &pass = select_ps_; pass.init(); - pass.shader_set(instance_.shaders.static_shader_get(SPHERE_PROBE_SELECT)); + pass.shader_set(instance_.shaders.static_shader_get(REFLECTION_PROBE_SELECT)); pass.push_constant("reflection_probe_count", &reflection_probe_count_); pass.bind_ssbo("reflection_probe_buf", &data_buf_); - instance_.volume_probes.bind_resources(pass); + instance_.irradiance_cache.bind_resources(pass); instance_.sampling.bind_resources(pass); pass.dispatch(&dispatch_probe_select_); pass.barrier(GPU_BARRIER_UNIFORM); } } -bool SphereProbeModule::ensure_atlas() +int ReflectionProbeModule::needed_layers_get() const { - /* Make sure the atlas is always initialized even if there is nothing to render to it to fulfill - * the resource bindings. */ - eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_WRITE | GPU_TEXTURE_USAGE_SHADER_READ; - - if (probes_tx_.ensure_2d_array(GPU_RGBA16F, - int2(max_resolution_), - instance_.light_probes.sphere_layer_count(), - usage, - nullptr, - SPHERE_PROBE_MIPMAP_LEVELS)) - { - probes_tx_.ensure_mip_views(); - /* TODO(fclem): Clearing means that we need to render all probes again. - * If existing data exists, copy it using `CopyImageSubData`. */ - probes_tx_.clear(float4(0.0f)); - GPU_texture_mipmap_mode(probes_tx_, true, true); - /* Avoid undefined pixel data. Update all mips. */ - GPU_texture_update_mipmap_chain(probes_tx_); - return true; + int max_layer = 0; + for (const ReflectionProbe &probe : probes_.values()) { + max_layer = max_ii(max_layer, probe.atlas_coord.layer); } - return false; + return max_layer + 1; } -void SphereProbeModule::end_sync() +static int layer_subdivision_for(const int max_resolution, + const eLightProbeResolution probe_resolution) { - const bool world_updated = instance_.light_probes.world_sphere_.do_render; - const bool atlas_resized = ensure_atlas(); - /* Detect if we need to render probe objects. */ - update_probes_next_sample_ = false; - for (SphereProbe &probe : instance_.light_probes.sphere_map_.values()) { - if (atlas_resized || world_updated) { - /* Last minute tagging. */ + int i_probe_resolution = int(probe_resolution); + return max_ii(int(log2(max_resolution)) - i_probe_resolution, 0); +} + +void ReflectionProbeModule::sync_world(::World *world) +{ + ReflectionProbe &probe = probes_.lookup(world_object_key_); + + eLightProbeResolution resolution = static_cast(world->probe_resolution); + int layer_subdivision = layer_subdivision_for(max_resolution_, resolution); + if (layer_subdivision != probe.atlas_coord.layer_subdivision) { + probe.atlas_coord = find_empty_atlas_region(layer_subdivision); + do_world_update_set(true); + } + world_sampling_coord_ = probe.atlas_coord.as_sampling_coord(atlas_extent()); +} + +void ReflectionProbeModule::sync_world_lookdev() +{ + ReflectionProbe &probe = probes_.lookup(world_object_key_); + + const eLightProbeResolution resolution = reflection_probe_resolution(); + int layer_subdivision = layer_subdivision_for(max_resolution_, resolution); + if (layer_subdivision != probe.atlas_coord.layer_subdivision) { + probe.atlas_coord = find_empty_atlas_region(layer_subdivision); + } + world_sampling_coord_ = probe.atlas_coord.as_sampling_coord(atlas_extent()); + + do_world_update_set(true); +} + +void ReflectionProbeModule::sync_object(Object *ob, ObjectHandle &ob_handle) +{ + const ::LightProbe &light_probe = *(::LightProbe *)ob->data; + if (light_probe.type != LIGHTPROBE_TYPE_SPHERE) { + return; + } + + ReflectionProbe &probe = probes_.lookup_or_add_cb(ob_handle.object_key.hash(), [&]() { + ReflectionProbe probe = {}; + probe.do_render = true; + probe.type = ReflectionProbe::Type::PROBE; + return probe; + }); + + probe.do_render |= (ob_handle.recalc != 0); + probe.is_probe_used = true; + + const bool probe_sync_active = instance_.do_reflection_probe_sync(); + if (!probe_sync_active && probe.do_render) { + update_probes_next_sample_ = true; + } + + /* Only update data when rerendering the probes to reduce flickering. */ + if (!probe_sync_active) { + return; + } + + probe.clipping_distances = float2(light_probe.clipsta, light_probe.clipend); + + int subdivision = layer_subdivision_for(max_resolution_, reflection_probe_resolution()); + if (probe.atlas_coord.layer_subdivision != subdivision) { + probe.atlas_coord = find_empty_atlas_region(subdivision); + } + + bool use_custom_parallax = (light_probe.flag & LIGHTPROBE_FLAG_CUSTOM_PARALLAX) != 0; + float parallax_distance = use_custom_parallax ? + max_ff(light_probe.distpar, light_probe.distinf) : + light_probe.distinf; + float influence_distance = light_probe.distinf; + float influence_falloff = light_probe.falloff; + probe.influence_shape = (light_probe.attenuation_type == LIGHTPROBE_SHAPE_BOX) ? SHAPE_CUBOID : + SHAPE_ELIPSOID; + probe.parallax_shape = (light_probe.parallax_type == LIGHTPROBE_SHAPE_BOX) ? SHAPE_CUBOID : + SHAPE_ELIPSOID; + + float4x4 object_to_world = math::scale(float4x4(ob->object_to_world), + float3(influence_distance)); + probe.location = object_to_world.location(); + probe.volume = math::abs(math::determinant(object_to_world)); + probe.world_to_probe_transposed = float3x4(math::transpose(math::invert(object_to_world))); + probe.influence_scale = 1.0 / max_ff(1e-8f, influence_falloff); + probe.influence_bias = probe.influence_scale; + probe.parallax_distance = parallax_distance / influence_distance; + + probe.viewport_display = light_probe.flag & LIGHTPROBE_FLAG_SHOW_DATA; + probe.viewport_display_size = light_probe.data_display_size; +} + +ReflectionProbeAtlasCoordinate ReflectionProbeModule::find_empty_atlas_region( + int subdivision_level) const +{ + ProbeLocationFinder location_finder(needed_layers_get() + 1, subdivision_level); + for (const ReflectionProbe &probe : probes_.values()) { + if (probe.atlas_coord.layer != -1) { + location_finder.mark_space_used(probe.atlas_coord); + } + } + return location_finder.first_free_spot(); +} + +void ReflectionProbeModule::end_sync() +{ + const bool probes_removed = remove_unused_probes(); + const bool world_updated = do_world_update_get(); + const bool only_world = has_only_world_probe(); + const int number_layers_needed = needed_layers_get(); + const int current_layers = probes_tx_.depth(); + const bool resize_layers = current_layers < number_layers_needed; + + const bool rerender_all_probes = resize_layers || world_updated; + if (rerender_all_probes) { + for (ReflectionProbe &probe : probes_.values()) { probe.do_render = true; } - if (probe.do_render) { - /* Tag the next redraw to warm up the probe pipeline. - * Keep doing this until there is no update. - * This avoids stuttering when moving a light-probe. */ + } + + const bool do_update = instance_.do_reflection_probe_sync() || (only_world && world_updated); + if (!do_update) { + /* World has changed this sample, but probe update isn't initialized this sample. */ + if (world_updated && !only_world) { update_probes_next_sample_ = true; } + if (update_probes_next_sample_ && !update_probes_this_sample_) { + DRW_viewport_request_redraw(); + } + + if (!update_probes_next_sample_ && probes_removed) { + data_buf_.push_update(); + } + return; } - /* If we cannot render probes this redraw make sure we request another redraw. */ - if (update_probes_next_sample_ && (instance_.do_reflection_probe_sync() == false)) { - DRW_viewport_request_redraw(); + + if (resize_layers) { + probes_tx_.ensure_2d_array(GPU_RGBA16F, + int2(max_resolution_), + number_layers_needed, + GPU_TEXTURE_USAGE_SHADER_WRITE | GPU_TEXTURE_USAGE_SHADER_READ, + nullptr, + 9999); + GPU_texture_mipmap_mode(probes_tx_, true, true); + probes_tx_.clear(float4(0.0f)); } + + /* Check reset probe updating as we will rendering probes. */ + if (update_probes_this_sample_ || only_world) { + update_probes_next_sample_ = false; + } + data_buf_.push_update(); } -void SphereProbeModule::ensure_cubemap_render_target(int resolution) +bool ReflectionProbeModule::remove_unused_probes() { - eGPUTextureUsage usage = GPU_TEXTURE_USAGE_ATTACHMENT | GPU_TEXTURE_USAGE_SHADER_READ; - cubemap_tx_.ensure_cube(GPU_RGBA16F, resolution, usage); - /* TODO(fclem): deallocate it. */ + const int64_t removed_count = probes_.remove_if( + [](const ReflectionProbes::Item &item) { return !item.value.is_probe_used; }); + return removed_count > 0; } -SphereProbeModule::UpdateInfo SphereProbeModule::update_info_from_probe(const SphereProbe &probe) +bool ReflectionProbeModule::do_world_update_get() const { + const ReflectionProbe &world_probe = probes_.lookup(world_object_key_); + return world_probe.do_render; +} + +void ReflectionProbeModule::do_world_update_set(bool value) +{ + ReflectionProbe &world_probe = probes_.lookup(world_object_key_); + world_probe.do_render = value; + do_world_update_irradiance_set(value); +} + +void ReflectionProbeModule::do_world_update_irradiance_set(bool value) +{ + ReflectionProbe &world_probe = probes_.lookup(world_object_key_); + world_probe.do_world_irradiance_update = value; +} + +bool ReflectionProbeModule::has_only_world_probe() const +{ + return probes_.size() == 1; +} + +std::optional ReflectionProbeModule::update_info_pop( + const ReflectionProbe::Type probe_type) +{ + const bool do_probe_sync = instance_.do_reflection_probe_sync(); + const bool only_world = has_only_world_probe(); const int max_shift = int(log2(max_resolution_)); - - SphereProbeModule::UpdateInfo info = {}; - info.atlas_coord = probe.atlas_coord; - info.resolution = 1 << (max_shift - probe.atlas_coord.subdivision_lvl - 1); - info.clipping_distances = probe.clipping_distances; - info.probe_pos = probe.location; - info.do_render = probe.do_render; - info.do_world_irradiance_update = false; - return info; -} - -std::optional SphereProbeModule::world_update_info_pop() -{ - SphereProbe &world_probe = instance_.light_probes.world_sphere_; - if (!world_probe.do_render && !do_world_irradiance_update) { - return std::nullopt; - } - SphereProbeModule::UpdateInfo info = update_info_from_probe(world_probe); - info.do_world_irradiance_update = do_world_irradiance_update; - world_probe.do_render = false; - do_world_irradiance_update = false; - ensure_cubemap_render_target(info.resolution); - return info; -} - -std::optional SphereProbeModule::probe_update_info_pop() -{ - if (!instance_.do_reflection_probe_sync()) { - /* Do not update probes during this sample as we did not sync the draw::Passes. */ - return std::nullopt; - } - - for (SphereProbe &probe : instance_.light_probes.sphere_map_.values()) { - if (!probe.do_render) { + for (ReflectionProbe &probe : probes_.values()) { + if (!probe.do_render && !probe.do_world_irradiance_update) { continue; } - SphereProbeModule::UpdateInfo info = update_info_from_probe(probe); + if (probe.type != probe_type) { + continue; + } + /* Do not update this probe during this sample. */ + if (probe.type == ReflectionProbe::Type::WORLD && !only_world && !do_probe_sync) { + continue; + } + if (probe.type == ReflectionProbe::Type::PROBE && !do_probe_sync) { + continue; + } + + ReflectionProbeUpdateInfo info = {}; + info.probe_type = probe.type; + info.atlas_coord = probe.atlas_coord; + info.resolution = 1 << (max_shift - probe.atlas_coord.layer_subdivision - 1); + info.clipping_distances = probe.clipping_distances; + info.probe_pos = probe.location; + info.do_render = probe.do_render; + info.do_world_irradiance_update = probe.do_world_irradiance_update; + probe.do_render = false; - probe.use_for_render = true; - ensure_cubemap_render_target(info.resolution); + probe.do_world_irradiance_update = false; + + if (cubemap_tx_.ensure_cube(GPU_RGBA16F, + info.resolution, + GPU_TEXTURE_USAGE_ATTACHMENT | GPU_TEXTURE_USAGE_SHADER_READ)) + { + GPU_texture_mipmap_mode(cubemap_tx_, false, true); + } + return info; } return std::nullopt; } -void SphereProbeModule::remap_to_octahedral_projection(const SphereProbeAtlasCoord &atlas_coord) +void ReflectionProbeModule::remap_to_octahedral_projection( + const ReflectionProbeAtlasCoordinate &atlas_coord) { - int resolution = max_resolution_ >> atlas_coord.subdivision_lvl; + int resolution = max_resolution_ >> atlas_coord.layer_subdivision; /* Update shader parameters that change per dispatch. */ - probe_sampling_coord_ = atlas_coord.as_sampling_coord(max_resolution_); - probe_write_coord_ = atlas_coord.as_write_coord(max_resolution_, 0); - dispatch_probe_pack_ = int3(int2(ceil_division(resolution, SPHERE_PROBE_GROUP_SIZE)), 1); - instance_.manager->submit(remap_ps_); + probe_sampling_coord_ = atlas_coord.as_sampling_coord(atlas_extent()); + probe_write_coord_ = atlas_coord.as_write_coord(atlas_extent(), 0); + probe_mip_level_ = atlas_coord.layer_subdivision; + dispatch_probe_pack_ = int3(int2(ceil_division(resolution, REFLECTION_PROBE_GROUP_SIZE)), 1); - /* Populate the mip levels */ - for (auto i : IndexRange(SPHERE_PROBE_MIPMAP_LEVELS - 1)) { - convolve_input_ = probes_tx_.mip_view(i); - convolve_output_ = probes_tx_.mip_view(i + 1); - probe_write_coord_ = atlas_coord.as_write_coord(max_resolution_, i + 1); - int out_mip_res = resolution >> (i + 1); - dispatch_probe_convolve_ = int3(int2(ceil_division(out_mip_res, SPHERE_PROBE_GROUP_SIZE)), 1); - instance_.manager->submit(convolve_ps_); - } - /* Sync with atlas usage for shading. */ - GPU_memory_barrier(GPU_BARRIER_TEXTURE_FETCH); + instance_.manager->submit(remap_ps_); } -void SphereProbeModule::update_world_irradiance() +void ReflectionProbeModule::update_world_irradiance() { instance_.manager->submit(update_irradiance_ps_); - /* All volume probe that needs to composite the world probe need to be updated. */ - instance_.volume_probes.do_update_world_ = true; } -void SphereProbeModule::set_view(View & /*view*/) +void ReflectionProbeModule::update_probes_texture_mipmaps() { - Vector probe_active; - for (auto &probe : instance_.light_probes.sphere_map_.values()) { + GPU_texture_update_mipmap_chain(probes_tx_); +} + +void ReflectionProbeModule::set_view(View & /*view*/) +{ + Vector probe_active; + for (auto &probe : probes_.values()) { /* Last slot is reserved for the world probe. */ - if (reflection_probe_count_ >= SPHERE_PROBE_MAX - 1) { + if (reflection_probe_count_ >= REFLECTION_PROBES_MAX - 1) { break; } - if (!probe.use_for_render) { + probe.prepare_for_upload(atlas_extent()); + /* World is always considered active and added last. */ + if (probe.type == ReflectionProbe::Type::WORLD) { continue; } /* TODO(fclem): Culling. */ @@ -232,29 +515,32 @@ void SphereProbeModule::set_view(View & /*view*/) } /* Stable sorting of probes. */ - std::sort( - probe_active.begin(), probe_active.end(), [](const SphereProbe *a, const SphereProbe *b) { - if (a->volume != b->volume) { - /* Smallest first. */ - return a->volume < b->volume; - } - /* Volumes are identical. Any arbitrary criteria can be used to sort them. - * Use position to avoid unstable result caused by depsgraph non deterministic eval - * order. This could also become a priority parameter. */ - float3 _a = a->location; - float3 _b = b->location; - if (_a.x != _b.x) { - return _a.x < _b.x; - } - if (_a.y != _b.y) { - return _a.y < _b.y; - } - if (_a.z != _b.z) { - return _a.z < _b.z; - } - /* Fallback to memory address, since there's no good alternative. */ - return a < b; - }); + std::sort(probe_active.begin(), + probe_active.end(), + [](const ReflectionProbe *a, const ReflectionProbe *b) { + if (a->volume != b->volume) { + /* Smallest first. */ + return a->volume < b->volume; + } + /* Volumes are identical. Any arbitrary criteria can be used to sort them. + * Use position to avoid unstable result caused by depsgraph non deterministic eval + * order. This could also become a priority parameter. */ + float3 _a = a->location; + float3 _b = b->location; + if (_a.x != _b.x) { + return _a.x < _b.x; + } + else if (_a.y != _b.y) { + return _a.y < _b.y; + } + else if (_a.z != _b.z) { + return _a.z < _b.z; + } + else { + /* Fallback to memory address, since there's no good alternative. */ + return a < b; + } + }); /* Push all sorted data to the UBO. */ int probe_id = 0; @@ -262,46 +548,42 @@ void SphereProbeModule::set_view(View & /*view*/) data_buf_[probe_id++] = *probe; } /* Add world probe at the end. */ - data_buf_[probe_id++] = instance_.light_probes.world_sphere_; + data_buf_[probe_id++] = probes_.lookup(world_object_key_); /* Tag the end of the array. */ - if (probe_id < SPHERE_PROBE_MAX) { + if (probe_id < REFLECTION_PROBES_MAX) { data_buf_[probe_id].atlas_coord.layer = -1; } data_buf_.push_update(); - reflection_probe_count_ = probe_id; - dispatch_probe_select_.x = divide_ceil_u(reflection_probe_count_, - SPHERE_PROBE_SELECT_GROUP_SIZE); - instance_.manager->submit(select_ps_); - - sync_display(probe_active); -} - -void SphereProbeModule::sync_display(Vector &probe_active) -{ - do_display_draw_ = false; - if (!DRW_state_draw_support()) { - return; - } - - int display_index = 0; - for (int i : probe_active.index_range()) { - if (probe_active[i]->viewport_display) { - SphereProbeDisplayData &sph_data = display_data_buf_.get_or_resize(display_index++); - sph_data.probe_index = i; - sph_data.display_size = probe_active[i]->viewport_display_size; + do_display_draw_ = DRW_state_draw_support() && probe_active.size() > 0; + if (do_display_draw_) { + int display_index = 0; + for (int i : probe_active.index_range()) { + if (probe_active[i]->viewport_display) { + display_data_buf_.get_or_resize(display_index++) = { + i, probe_active[i]->viewport_display_size}; + } + } + do_display_draw_ = display_index > 0; + if (do_display_draw_) { + display_data_buf_.resize(display_index); + display_data_buf_.push_update(); } } - if (display_index == 0) { - return; - } - do_display_draw_ = true; - display_data_buf_.resize(display_index); - display_data_buf_.push_update(); + /* Add one for world probe. */ + reflection_probe_count_ = probe_active.size() + 1; + dispatch_probe_select_.x = divide_ceil_u(reflection_probe_count_, + REFLECTION_PROBE_SELECT_GROUP_SIZE); + instance_.manager->submit(select_ps_); } -void SphereProbeModule::viewport_draw(View &view, GPUFrameBuffer *view_fb) +ReflectionProbeAtlasCoordinate ReflectionProbeModule::world_atlas_coord_get() const +{ + return probes_.lookup(world_object_key_).atlas_coord; +} + +void ReflectionProbeModule::viewport_draw(View &view, GPUFrameBuffer *view_fb) { if (!do_display_draw_) { return; @@ -312,7 +594,7 @@ void SphereProbeModule::viewport_draw(View &view, GPUFrameBuffer *view_fb) DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK); viewport_display_ps_.framebuffer_set(&view_fb); viewport_display_ps_.shader_set(instance_.shaders.static_shader_get(DISPLAY_PROBE_REFLECTION)); - viewport_display_ps_.bind_resources(*this); + bind_resources(viewport_display_ps_); viewport_display_ps_.bind_ssbo("display_data_buf", display_data_buf_); viewport_display_ps_.draw_procedural(GPU_PRIM_TRIS, 1, display_data_buf_.size() * 6); @@ -321,4 +603,37 @@ void SphereProbeModule::viewport_draw(View &view, GPUFrameBuffer *view_fb) /** \} */ +/* -------------------------------------------------------------------- */ +/** \name Debugging + * + * \{ */ + +void ReflectionProbeModule::debug_print() const +{ + std::ostream &os = std::cout; + for (const ReflectionProbe &probe : probes_.values()) { + switch (probe.type) { + case ReflectionProbe::Type::WORLD: { + os << "WORLD"; + os << " do_render: " << probe.do_render; + os << "\n"; + break; + } + case ReflectionProbe::Type::PROBE: { + os << "PROBE"; + os << " do_render: " << probe.do_render; + os << " is_used: " << probe.is_probe_used; + os << "\n"; + break; + } + } + os << " - layer: " << probe.atlas_coord.layer; + os << " subdivision: " << probe.atlas_coord.layer_subdivision; + os << " area: " << probe.atlas_coord.area_index; + os << "\n"; + } +} + +/** \} */ + } // namespace blender::eevee diff --git a/source/blender/draw/engines/eevee_next/eevee_reflection_probes.hh b/source/blender/draw/engines/eevee_next/eevee_reflection_probes.hh index b1ad8a06a93..164d75accc9 100644 --- a/source/blender/draw/engines/eevee_next/eevee_reflection_probes.hh +++ b/source/blender/draw/engines/eevee_next/eevee_reflection_probes.hh @@ -8,7 +8,6 @@ #pragma once -#include "eevee_lightprobe.hh" #include "eevee_shader_shared.hh" #include "BKE_cryptomatte.hh" @@ -23,17 +22,144 @@ class Instance; struct ObjectHandle; struct WorldHandle; class CaptureView; +struct ReflectionProbeUpdateInfo; + +/* -------------------------------------------------------------------- */ +/** \name Reflection Probe + * \{ */ + +struct ReflectionProbeAtlasCoordinate { + /** On which layer of the texture array is this reflection probe stored. */ + int layer = -1; + /** + * Subdivision of the layer. 0 = no subdivision and resolution would be + * ReflectionProbeModule::MAX_RESOLUTION. + */ + int layer_subdivision = -1; + /** + * Which area of the subdivided layer is the reflection probe located. + * + * A layer has (2^layer_subdivision)^2 areas. + */ + int area_index = -1; + + /* Return the area extent in pixel. */ + int area_extent(int atlas_extent) const + { + return atlas_extent >> layer_subdivision; + } + + /* Coordinate of the area in [0..area_count_per_dimension[ range. */ + int2 area_location() const + { + const int area_count_per_dimension = 1 << layer_subdivision; + return int2(area_index % area_count_per_dimension, area_index / area_count_per_dimension); + } + + /* Coordinate of the bottom left corner of the area in [0..atlas_extent[ range. */ + int2 area_offset(int atlas_extent) const + { + return area_location() * area_extent(atlas_extent); + } + + ReflectionProbeCoordinate as_sampling_coord(int atlas_extent) const + { + /** + * We want to cover the last mip exactly at the pixel center to reduce padding texels and + * interpolation artifacts. + * This is a diagram of a 2px^2 map with `c` being the texels corners and `x` the pixels + * centers. + * + * c-------c-------c + * | | | + * | x | x | < + * | | | | + * c-------c-------c | sampling area + * | | | | + * | x | x | < + * | | | + * c-------c-------c + * ^-------^ + * sampling area + */ + /* First level only need half a pixel of padding around the sampling area. */ + const int mip_max_lvl_padding = 1; + const int mip_min_lvl_padding = mip_max_lvl_padding << REFLECTION_PROBE_MIPMAP_LEVELS; + /* Extent and offset in mip 0 texels. */ + const int sampling_area_extent = area_extent(atlas_extent) - mip_min_lvl_padding; + const int2 sampling_area_offset = area_offset(atlas_extent) + mip_min_lvl_padding / 2; + /* Convert to atlas UVs. */ + ReflectionProbeCoordinate coord; + coord.scale = sampling_area_extent / float(atlas_extent); + coord.offset = float2(sampling_area_offset) / float(atlas_extent); + coord.layer = layer; + return coord; + } + + ReflectionProbeWriteCoordinate as_write_coord(int atlas_extent, int mip_lvl) const + { + ReflectionProbeWriteCoordinate coord; + coord.extent = atlas_extent >> (layer_subdivision + mip_lvl); + coord.offset = (area_location() * coord.extent) >> mip_lvl; + coord.layer = layer; + return coord; + } +}; + +struct ReflectionProbe : ReflectionProbeData { + public: + enum class Type { + WORLD, + PROBE, + } type; + + /* Used to sort the probes by priority. */ + float volume; + + /* Should the area in the probes_tx_ be updated? */ + bool do_render = false; + bool do_world_irradiance_update = false; + + /** + * Probes that aren't used during a draw can be cleared. + * + * Only valid when type == Type::Probe. + */ + bool is_probe_used = false; + + /** + * Far and near clipping distances for rendering + */ + float2 clipping_distances; + + /** Display debug spheres in the viewport. */ + bool viewport_display; + float viewport_display_size; + + ReflectionProbeAtlasCoordinate atlas_coord; + + void prepare_for_upload(int atlas_extent) + { + /* Compute LOD factor. */ + const int probe_resolution = atlas_coord.area_extent(atlas_extent); + const float bias = 0.0; + const float lod_factor = bias + 0.5 * log2f(square_i(probe_resolution)); + this->lod_factor = lod_factor; + + /* Compute sampling offset and scale. */ + static_cast(this)->atlas_coord = atlas_coord.as_sampling_coord( + atlas_extent); + } +}; + +/** \} */ /* -------------------------------------------------------------------- */ /** \name Reflection Probe Module * \{ */ -class SphereProbeModule { - friend LightProbeModule; - /* Capture View requires access to the cube-maps texture for frame-buffer configuration. */ - friend class CaptureView; - /* Instance requires access to #update_probes_this_sample_ */ - friend class Instance; +class ReflectionProbeModule { + using ReflectionProbes = Map; private: /** @@ -43,27 +169,21 @@ class SphereProbeModule { */ static constexpr int max_resolution_ = 2048; + static constexpr uint64_t world_object_key_ = 0; + + bool is_initialized = false; Instance &instance_; - SphereProbeDataBuf data_buf_; + ReflectionProbeDataBuf data_buf_; + ReflectionProbes probes_; /** Probes texture stored in octahedral mapping. */ Texture probes_tx_ = {"Probes"}; - /** Copy the rendered cube-map to the atlas texture. */ PassSimple remap_ps_ = {"Probe.CubemapToOctahedral"}; - /** Extract irradiance information from the world. */ PassSimple update_irradiance_ps_ = {"Probe.UpdateIrradiance"}; - /** Copy volume probe irradiance for the center of sphere probes. */ PassSimple select_ps_ = {"Probe.Select"}; - /** Convolve the octahedral map to fill the Mip-map levels. */ - PassSimple convolve_ps_ = {"Probe.Convolve"}; - /** Input mip level for the convolution. */ - GPUTexture *convolve_input_ = nullptr; - /** Output mip level for the convolution. */ - GPUTexture *convolve_output_ = nullptr; int3 dispatch_probe_pack_ = int3(1); - int3 dispatch_probe_convolve_ = int3(1); int3 dispatch_probe_select_ = int3(1); /** @@ -74,49 +194,55 @@ class SphereProbeModule { Texture cubemap_tx_ = {"Probe.Cubemap"}; /** Index of the probe being updated. */ int probe_index_ = 0; + /** Mip level being sampled for remapping. */ + int probe_mip_level_ = 0; /** Updated Probe coordinates in the atlas. */ - SphereProbeUvArea probe_sampling_coord_; - SphereProbePixelArea probe_write_coord_; + ReflectionProbeCoordinate probe_sampling_coord_; + ReflectionProbeWriteCoordinate probe_write_coord_; /** World coordinates in the atlas. */ - SphereProbeUvArea world_sampling_coord_; + ReflectionProbeCoordinate world_sampling_coord_; /** Number of the probe to process in the select phase. */ int reflection_probe_count_ = 0; - /** - * True if the next redraw will trigger a light-probe sphere update. - * As syncing the draw passes for rendering has a significant overhead, - * we only trigger this sync path if we detect updates. But we only know - * this after `end_sync` which is too late to sync objects for light-probe - * rendering. So we tag the next redraw (or sample) to do the sync. - */ bool update_probes_next_sample_ = false; - /** True if the this redraw will trigger a light-probe sphere update. */ bool update_probes_this_sample_ = false; - /** Compute world irradiance coefficient and store them into the volume probe atlas. */ - bool do_world_irradiance_update = true; /** Viewport data display drawing. */ bool do_display_draw_ = false; - SphereProbeDisplayDataBuf display_data_buf_; - PassSimple viewport_display_ps_ = {"ProbeSphereModule.Viewport Display"}; + ReflectionProbeDisplayDataBuf display_data_buf_; + PassSimple viewport_display_ps_ = {"ReflectionProbeModule.Viewport Display"}; public: - SphereProbeModule(Instance &instance) : instance_(instance){}; + ReflectionProbeModule(Instance &instance) : instance_(instance) {} void init(); void begin_sync(); + void sync_world(::World *world); + void sync_world_lookdev(); + void sync_object(Object *ob, ObjectHandle &ob_handle); void end_sync(); void viewport_draw(View &view, GPUFrameBuffer *view_fb); template void bind_resources(PassType &pass) { - pass.bind_texture(SPHERE_PROBE_TEX_SLOT, &probes_tx_); - pass.bind_ubo(SPHERE_PROBE_BUF_SLOT, &data_buf_); + pass.bind_texture(REFLECTION_PROBE_TEX_SLOT, &probes_tx_); + pass.bind_ubo(REFLECTION_PROBE_BUF_SLOT, &data_buf_); } + bool do_world_update_get() const; + void do_world_update_set(bool value); + void do_world_update_irradiance_set(bool value); + void set_view(View &view); + void debug_print() const; + + int atlas_extent() const + { + return probes_tx_.width(); + } + /** * Get the resolution of a single cube-map side when rendering probes. * @@ -124,58 +250,59 @@ class SphereProbeModule { */ int probe_render_extent() const; - void tag_world_irradiance_for_update() - { - do_world_irradiance_update = true; - } + ReflectionProbeAtlasCoordinate world_atlas_coord_get() const; private: - /* Return the subdivision level for the requested probe resolution. - * Result is safely clamped to max resolution. */ - int subdivision_level_get(const eLightProbeResolution probe_resolution) - { - return max_ii(int(log2(max_resolution_)) - int(probe_resolution), 0); - } + /** Get the number of layers that is needed to store probes. */ + int needed_layers_get() const; + + bool remove_unused_probes(); /** - * Ensure atlas texture is the right size. - * Returns true if the texture has been cleared and all probes needs to be rendered again. + * Create a reflection probe data element that points to an empty spot in the cubemap that can + * hold a texture with the given subdivision_level. */ - bool ensure_atlas(); - - /** - * Ensure the cube-map target texture for rendering the probe is allocated. - */ - void ensure_cubemap_render_target(int resolution); - - struct UpdateInfo { - float3 probe_pos; - /** Resolution of the cube-map to be rendered. */ - int resolution; - - float2 clipping_distances; - - SphereProbeAtlasCoord atlas_coord; - - bool do_render; - bool do_world_irradiance_update; - }; - - UpdateInfo update_info_from_probe(const SphereProbe &probe); + ReflectionProbeAtlasCoordinate find_empty_atlas_region(int subdivision_level) const; /** * Pop the next reflection probe that requires to be updated. */ - std::optional world_update_info_pop(); - std::optional probe_update_info_pop(); + std::optional update_info_pop(ReflectionProbe::Type probe_type); - /** - * Internal processing passes. - */ - void remap_to_octahedral_projection(const SphereProbeAtlasCoord &atlas_coord); + void remap_to_octahedral_projection(const ReflectionProbeAtlasCoordinate &atlas_coord); + void update_probes_texture_mipmaps(); void update_world_irradiance(); - void sync_display(Vector &probe_active); + bool has_only_world_probe() const; + + eLightProbeResolution reflection_probe_resolution() const; + + /* Capture View requires access to the cube-maps texture for frame-buffer configuration. */ + friend class CaptureView; + /* Instance requires access to #update_probes_this_sample_ */ + friend class Instance; +}; + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Reflection Probe Update Info + * \{ */ + +struct ReflectionProbeUpdateInfo { + float3 probe_pos; + ReflectionProbe::Type probe_type; + /** + * Resolution of the cubemap to be rendered. + */ + int resolution; + + float2 clipping_distances; + + ReflectionProbeAtlasCoordinate atlas_coord; + + bool do_render; + bool do_world_irradiance_update; }; /** \} */ diff --git a/source/blender/draw/engines/eevee_next/eevee_shader.cc b/source/blender/draw/engines/eevee_next/eevee_shader.cc index 317f2bd87be..5cc66249a25 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shader.cc +++ b/source/blender/draw/engines/eevee_next/eevee_shader.cc @@ -214,13 +214,11 @@ const char *ShaderModule::static_shader_create_info_name_get(eShaderType shader_ return "eevee_lightprobe_irradiance_ray"; case LIGHTPROBE_IRRADIANCE_LOAD: return "eevee_lightprobe_irradiance_load"; - case SPHERE_PROBE_CONVOLVE: - return "eevee_reflection_probe_convolve"; - case SPHERE_PROBE_REMAP: + case REFLECTION_PROBE_REMAP: return "eevee_reflection_probe_remap"; - case SPHERE_PROBE_UPDATE_IRRADIANCE: + case REFLECTION_PROBE_UPDATE_IRRADIANCE: return "eevee_reflection_probe_update_irradiance"; - case SPHERE_PROBE_SELECT: + case REFLECTION_PROBE_SELECT: return "eevee_reflection_probe_select"; case SHADOW_CLIPMAP_CLEAR: return "eevee_shadow_clipmap_clear"; @@ -528,7 +526,7 @@ void ShaderModule::material_create_info_ammend(GPUMaterial *gpumat, GPUCodegenOu std::stringstream attr_load; attr_load << "void attrib_load()\n"; attr_load << "{\n"; - attr_load << ((!codegen.attr_load.empty()) ? codegen.attr_load : ""); + attr_load << ((codegen.attr_load) ? codegen.attr_load : ""); attr_load << "}\n\n"; std::stringstream vert_gen, frag_gen, comp_gen; @@ -546,7 +544,7 @@ void ShaderModule::material_create_info_ammend(GPUMaterial *gpumat, GPUCodegenOu } if (!is_compute) { - const bool use_vertex_displacement = (!codegen.displacement.empty()) && + const bool use_vertex_displacement = (codegen.displacement != nullptr) && (displacement_type != MAT_DISPLACEMENT_BUMP) && (!ELEM(geometry_type, MAT_GEOM_WORLD, @@ -563,9 +561,9 @@ void ShaderModule::material_create_info_ammend(GPUMaterial *gpumat, GPUCodegenOu } if (!is_compute && pipeline_type != MAT_PIPE_VOLUME_OCCUPANCY) { - frag_gen << ((!codegen.material_functions.empty()) ? codegen.material_functions : "\n"); + frag_gen << ((codegen.material_functions) ? codegen.material_functions : "\n"); - if (!codegen.displacement.empty()) { + if (codegen.displacement) { /* Bump displacement. Needed to recompute normals after displacement. */ info.define("MAT_DISPLACEMENT_BUMP"); @@ -578,25 +576,25 @@ void ShaderModule::material_create_info_ammend(GPUMaterial *gpumat, GPUCodegenOu frag_gen << "Closure nodetree_surface()\n"; frag_gen << "{\n"; frag_gen << " closure_weights_reset();\n"; - frag_gen << ((!codegen.surface.empty()) ? codegen.surface : "return Closure(0);\n"); + frag_gen << ((codegen.surface) ? codegen.surface : "return Closure(0);\n"); frag_gen << "}\n\n"; frag_gen << "float nodetree_thickness()\n"; frag_gen << "{\n"; /* TODO(fclem): Better default. */ - frag_gen << ((!codegen.thickness.empty()) ? codegen.thickness : "return 0.1;\n"); + frag_gen << ((codegen.thickness) ? codegen.thickness : "return 0.1;\n"); frag_gen << "}\n\n"; info.fragment_source_generated = frag_gen.str(); } if (is_compute) { - comp_gen << ((!codegen.material_functions.empty()) ? codegen.material_functions : "\n"); + comp_gen << ((codegen.material_functions) ? codegen.material_functions : "\n"); comp_gen << "Closure nodetree_volume()\n"; comp_gen << "{\n"; comp_gen << " closure_weights_reset();\n"; - comp_gen << ((!codegen.volume.empty()) ? codegen.volume : "return Closure(0);\n"); + comp_gen << ((codegen.volume) ? codegen.volume : "return Closure(0);\n"); comp_gen << "}\n\n"; info.compute_source_generated = comp_gen.str(); diff --git a/source/blender/draw/engines/eevee_next/eevee_shader.hh b/source/blender/draw/engines/eevee_next/eevee_shader.hh index 119ccb40aa5..b52efbaa379 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shader.hh +++ b/source/blender/draw/engines/eevee_next/eevee_shader.hh @@ -104,10 +104,9 @@ enum eShaderType { RAY_TRACE_PLANAR, RAY_TRACE_SCREEN, - SPHERE_PROBE_CONVOLVE, - SPHERE_PROBE_REMAP, - SPHERE_PROBE_SELECT, - SPHERE_PROBE_UPDATE_IRRADIANCE, + REFLECTION_PROBE_REMAP, + REFLECTION_PROBE_UPDATE_IRRADIANCE, + REFLECTION_PROBE_SELECT, SHADOW_CLIPMAP_CLEAR, SHADOW_DEBUG, diff --git a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh index 6267a7453d4..ec08d71c7cc 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh +++ b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh @@ -1043,8 +1043,7 @@ enum LightProbeShape : uint32_t { SHAPE_CUBOID = 1u, }; -/* Sampling coordinates using UV space. */ -struct SphereProbeUvArea { +struct ReflectionProbeCoordinate { /* Offset in UV space to the start of the sampling space of the octahedron map. */ float2 offset; /* Scaling of the squared UV space of the octahedron map. */ @@ -1052,10 +1051,9 @@ struct SphereProbeUvArea { /* Layer of the atlas where the octahedron map is stored. */ float layer; }; -BLI_STATIC_ASSERT_ALIGN(SphereProbeUvArea, 16) +BLI_STATIC_ASSERT_ALIGN(ReflectionProbeCoordinate, 16) -/* Pixel read/write coordinates using pixel space. */ -struct SphereProbePixelArea { +struct ReflectionProbeWriteCoordinate { /* Offset in pixel space to the start of the writing space of the octahedron map. * Note that the writing space is not the same as the sampling space as we have borders. */ int2 offset; @@ -1064,23 +1062,29 @@ struct SphereProbePixelArea { /* Layer of the atlas where the octahedron map is stored. */ int layer; }; -BLI_STATIC_ASSERT_ALIGN(SphereProbePixelArea, 16) +BLI_STATIC_ASSERT_ALIGN(ReflectionProbeWriteCoordinate, 16) /** Mapping data to locate a reflection probe in texture. */ -struct SphereProbeData { +struct ReflectionProbeData { /** Transform to probe local position with non-uniform scaling. */ float3x4 world_to_probe_transposed; packed_float3 location; + float _pad2; + /** Shape of the parallax projection. */ - float parallax_distance; LightProbeShape parallax_shape; LightProbeShape influence_shape; + float parallax_distance; /** Influence factor based on the distance to the parallax shape. */ float influence_scale; float influence_bias; + /** LOD factor for mipmap selection. */ + float lod_factor; + float _pad0; + float _pad1; - SphereProbeUvArea atlas_coord; + ReflectionProbeCoordinate atlas_coord; /** * Irradiance at the probe location encoded as spherical harmonics. @@ -1088,21 +1092,21 @@ struct SphereProbeData { */ ReflectionProbeLowFreqLight low_freq_light; }; -BLI_STATIC_ASSERT_ALIGN(SphereProbeData, 16) +BLI_STATIC_ASSERT_ALIGN(ReflectionProbeData, 16) /** Viewport Display Pass. */ -struct SphereProbeDisplayData { +struct ReflectionProbeDisplayData { int probe_index; float display_size; float _pad0; float _pad1; }; -BLI_STATIC_ASSERT_ALIGN(SphereProbeDisplayData, 16) +BLI_STATIC_ASSERT_ALIGN(ReflectionProbeDisplayData, 16) /** \} */ /* -------------------------------------------------------------------- */ -/** \name Volume Probe Cache +/** \name Irradiance Cache * \{ */ struct SurfelRadiance { @@ -1193,7 +1197,7 @@ struct CaptureInfoData { bool1 capture_emission; int _pad0; /* World light probe atlas coordinate. */ - SphereProbeUvArea world_atlas_coord; + ReflectionProbeCoordinate world_atlas_coord; }; BLI_STATIC_ASSERT_ALIGN(CaptureInfoData, 16) @@ -1207,7 +1211,7 @@ struct SurfelListInfoData { }; BLI_STATIC_ASSERT_ALIGN(SurfelListInfoData, 16) -struct VolumeProbeData { +struct IrradianceGridData { /** World to non-normalized local grid space [0..size-1]. Stored transposed for compactness. */ float3x4 world_to_grid_transposed; /** Number of bricks for this grid. */ @@ -1220,7 +1224,7 @@ struct VolumeProbeData { float facing_bias; int _pad1; }; -BLI_STATIC_ASSERT_ALIGN(VolumeProbeData, 16) +BLI_STATIC_ASSERT_ALIGN(IrradianceGridData, 16) struct IrradianceBrick { /* Offset in pixel to the start of the data inside the atlas texture. */ @@ -1416,7 +1420,7 @@ static inline float3 burley_eval(float3 d, float r) /** \name Light-probe Planar Data * \{ */ -struct PlanarProbeData { +struct ProbePlanarData { /** Matrices used to render the planar capture. */ float4x4 viewmat; float4x4 winmat; @@ -1427,7 +1431,7 @@ struct PlanarProbeData { /** Layer in the planar capture textures used by this probe. */ int layer_id; }; -BLI_STATIC_ASSERT_ALIGN(PlanarProbeData, 16) +BLI_STATIC_ASSERT_ALIGN(ProbePlanarData, 16) struct ClipPlaneData { /** World space clip plane equation. Used to render planar light-probes. */ @@ -1436,14 +1440,14 @@ struct ClipPlaneData { BLI_STATIC_ASSERT_ALIGN(ClipPlaneData, 16) /** Viewport Display Pass. */ -struct PlanarProbeDisplayData { +struct ProbePlanarDisplayData { float4x4 plane_to_world; int probe_index; float _pad0; float _pad1; float _pad2; }; -BLI_STATIC_ASSERT_ALIGN(PlanarProbeDisplayData, 16) +BLI_STATIC_ASSERT_ALIGN(ProbePlanarDisplayData, 16) /** \} */ @@ -1573,7 +1577,7 @@ using DepthOfFieldScatterListBuf = draw::StorageArrayBuffer; using DispatchIndirectBuf = draw::StorageBuffer; using UniformDataBuf = draw::UniformBuffer; -using VolumeProbeDataBuf = draw::UniformArrayBuffer; +using IrradianceGridDataBuf = draw::UniformArrayBuffer; using IrradianceBrickBuf = draw::StorageVectorBuffer; using LightCullingDataBuf = draw::StorageBuffer; using LightCullingKeyBuf = draw::StorageArrayBuffer; @@ -1585,10 +1589,11 @@ using MotionBlurDataBuf = draw::UniformBuffer; using MotionBlurTileIndirectionBuf = draw::StorageBuffer; using RayTraceTileBuf = draw::StorageArrayBuffer; using SubsurfaceTileBuf = RayTraceTileBuf; -using SphereProbeDataBuf = draw::UniformArrayBuffer; -using SphereProbeDisplayDataBuf = draw::StorageArrayBuffer; -using PlanarProbeDataBuf = draw::UniformArrayBuffer; -using PlanarProbeDisplayDataBuf = draw::StorageArrayBuffer; +using ReflectionProbeDataBuf = + draw::UniformArrayBuffer; +using ReflectionProbeDisplayDataBuf = draw::StorageArrayBuffer; +using ProbePlanarDataBuf = draw::UniformArrayBuffer; +using ProbePlanarDisplayDataBuf = draw::StorageArrayBuffer; using SamplingDataBuf = draw::StorageBuffer; using ShadowStatisticsBuf = draw::StorageBuffer; using ShadowPagesInfoDataBuf = draw::StorageBuffer; diff --git a/source/blender/draw/engines/eevee_next/eevee_shadow.cc b/source/blender/draw/engines/eevee_next/eevee_shadow.cc index 0bfa7e7cf50..27545efa8f8 100644 --- a/source/blender/draw/engines/eevee_next/eevee_shadow.cc +++ b/source/blender/draw/engines/eevee_next/eevee_shadow.cc @@ -8,7 +8,7 @@ * The shadow module manages shadow update tagging & shadow rendering. */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_math_rotation.h" #include "BLI_rect.h" @@ -831,9 +831,9 @@ void ShadowModule::begin_sync() pass.init(); if (inst_.is_baking()) { - SurfelBuf &surfels_buf = inst_.volume_probes.bake.surfels_buf_; - CaptureInfoBuf &capture_info_buf = inst_.volume_probes.bake.capture_info_buf_; - float surfel_coverage_area = inst_.volume_probes.bake.surfel_density_; + SurfelBuf &surfels_buf = inst_.irradiance_cache.bake.surfels_buf_; + CaptureInfoBuf &capture_info_buf = inst_.irradiance_cache.bake.capture_info_buf_; + float surfel_coverage_area = inst_.irradiance_cache.bake.surfel_density_; /* Directional shadows. */ float texel_size = ShadowDirectional::tile_size_get(0) / float(SHADOW_PAGE_RES); @@ -850,7 +850,7 @@ void ShadowModule::begin_sync() sub.push_constant("directional_level", directional_level); sub.push_constant("tilemap_projection_ratio", projection_ratio); sub.bind_resources(inst_.lights); - sub.dispatch(&inst_.volume_probes.bake.dispatch_per_surfel_); + sub.dispatch(&inst_.irradiance_cache.bake.dispatch_per_surfel_); /* Skip opaque and transparent tagging for light baking. */ return; diff --git a/source/blender/draw/engines/eevee_next/eevee_sync.cc b/source/blender/draw/engines/eevee_next/eevee_sync.cc index 2a9a83f3e5c..fa6bc345c50 100644 --- a/source/blender/draw/engines/eevee_next/eevee_sync.cc +++ b/source/blender/draw/engines/eevee_next/eevee_sync.cc @@ -571,6 +571,19 @@ void SyncModule::sync_curves(Object *ob, /** \} */ +/* -------------------------------------------------------------------- */ +/** \name Light Probes + * \{ */ + +void SyncModule::sync_light_probe(Object *ob, ObjectHandle &ob_handle) +{ + inst_.light_probes.sync_probe(ob, ob_handle); + inst_.reflection_probes.sync_object(ob, ob_handle); + inst_.planar_probes.sync_object(ob, ob_handle); +} + +/** \} */ + void foreach_hair_particle_handle(Object *ob, ObjectHandle ob_handle, HairHandleCallback callback) { int sub_key = 1; diff --git a/source/blender/draw/engines/eevee_next/eevee_sync.hh b/source/blender/draw/engines/eevee_next/eevee_sync.hh index ac958087e8b..60e25df44ab 100644 --- a/source/blender/draw/engines/eevee_next/eevee_sync.hh +++ b/source/blender/draw/engines/eevee_next/eevee_sync.hh @@ -11,7 +11,7 @@ #pragma once -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BLI_ghash.h" #include "BLI_map.hh" #include "DEG_depsgraph_query.hh" @@ -186,6 +186,7 @@ class SyncModule { const ObjectRef &ob_ref, ModifierData *modifier_data = nullptr, ParticleSystem *particle_sys = nullptr); + void sync_light_probe(Object *ob, ObjectHandle &ob_handle); }; using HairHandleCallback = FunctionRef; diff --git a/source/blender/draw/engines/eevee_next/eevee_velocity.cc b/source/blender/draw/engines/eevee_next/eevee_velocity.cc index 323079c377f..db070b8e8d3 100644 --- a/source/blender/draw/engines/eevee_next/eevee_velocity.cc +++ b/source/blender/draw/engines/eevee_next/eevee_velocity.cc @@ -11,7 +11,7 @@ * It is the module that tracks the objects between frames updates. */ -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_object.hh" #include "BLI_map.hh" #include "DEG_depsgraph_query.hh" @@ -38,8 +38,7 @@ namespace blender::eevee { void VelocityModule::init() { - if (!inst_.is_viewport() && !inst_.is_baking() && - (inst_.film.enabled_passes_get() & EEVEE_RENDER_PASS_VECTOR) && + if (!inst_.is_viewport() && (inst_.film.enabled_passes_get() & EEVEE_RENDER_PASS_VECTOR) && !inst_.motion_blur.postfx_enabled()) { /* No motion blur and the vector pass was requested. Do the steps sync here. */ @@ -54,7 +53,7 @@ void VelocityModule::init() /* For viewport, only previous motion is supported. * Still bind previous step to avoid undefined behavior. */ - next_step_ = (inst_.is_viewport() || inst_.is_baking()) ? STEP_PREVIOUS : STEP_NEXT; + next_step_ = inst_.is_viewport() ? STEP_PREVIOUS : STEP_NEXT; } /* Similar to Instance::object_sync, but only syncs velocity. */ @@ -154,17 +153,18 @@ bool VelocityModule::step_object_sync(Object *ob, vel.obj.ofs[step_] = object_steps_usage[step_]++; vel.obj.resource_id = resource_handle.resource_index(); vel.id = object_key.hash(); - object_steps[step_]->get_or_resize(vel.obj.ofs[step_]) = ob->object_to_world(); + object_steps[step_]->get_or_resize(vel.obj.ofs[step_]) = float4x4_view(ob->object_to_world); if (step_ == STEP_CURRENT) { /* Replace invalid steps. Can happen if object was hidden in one of those steps. */ if (vel.obj.ofs[STEP_PREVIOUS] == -1) { vel.obj.ofs[STEP_PREVIOUS] = object_steps_usage[STEP_PREVIOUS]++; - object_steps[STEP_PREVIOUS]->get_or_resize( - vel.obj.ofs[STEP_PREVIOUS]) = ob->object_to_world(); + object_steps[STEP_PREVIOUS]->get_or_resize(vel.obj.ofs[STEP_PREVIOUS]) = float4x4_view( + ob->object_to_world); } if (vel.obj.ofs[STEP_NEXT] == -1) { vel.obj.ofs[STEP_NEXT] = object_steps_usage[STEP_NEXT]++; - object_steps[STEP_NEXT]->get_or_resize(vel.obj.ofs[STEP_NEXT]) = ob->object_to_world(); + object_steps[STEP_NEXT]->get_or_resize(vel.obj.ofs[STEP_NEXT]) = float4x4_view( + ob->object_to_world); } } diff --git a/source/blender/draw/engines/eevee_next/eevee_view.cc b/source/blender/draw/engines/eevee_next/eevee_view.cc index c1a7f8558b6..af51fe40add 100644 --- a/source/blender/draw/engines/eevee_next/eevee_view.cc +++ b/source/blender/draw/engines/eevee_next/eevee_view.cc @@ -15,7 +15,7 @@ * its type. Passes are shared between views. */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "DRW_render.hh" #include "eevee_instance.hh" @@ -120,7 +120,7 @@ void ShadingView::render() /* TODO(fclem): Move it after the first prepass (and hiz update) once pipeline is stabilized. */ inst_.lights.set_view(render_view_, extent_); - inst_.sphere_probes.set_view(render_view_); + inst_.reflection_probes.set_view(render_view_); inst_.pipelines.background.render(render_view_); @@ -151,8 +151,8 @@ void ShadingView::render() inst_.lights.debug_draw(render_view_, combined_fb_); inst_.hiz_buffer.debug_draw(render_view_, combined_fb_); inst_.shadows.debug_draw(render_view_, combined_fb_); - inst_.volume_probes.viewport_draw(render_view_, combined_fb_); - inst_.sphere_probes.viewport_draw(render_view_, combined_fb_); + inst_.irradiance_cache.viewport_draw(render_view_, combined_fb_); + inst_.reflection_probes.viewport_draw(render_view_, combined_fb_); inst_.planar_probes.viewport_draw(render_view_, combined_fb_); inst_.ambient_occlusion.render_pass(render_view_); @@ -237,7 +237,8 @@ void ShadingView::update_view() void CaptureView::render_world() { - const auto update_info = inst_.sphere_probes.world_update_info_pop(); + const std::optional update_info = + inst_.reflection_probes.update_info_pop(ReflectionProbe::Type::WORLD); if (!update_info.has_value()) { return; } @@ -256,17 +257,19 @@ void CaptureView::render_world() update_info->clipping_distances.y); view.sync(view_m4, win_m4); - combined_fb_.ensure(GPU_ATTACHMENT_NONE, - GPU_ATTACHMENT_TEXTURE_CUBEFACE(inst_.sphere_probes.cubemap_tx_, face)); + combined_fb_.ensure( + GPU_ATTACHMENT_NONE, + GPU_ATTACHMENT_TEXTURE_CUBEFACE(inst_.reflection_probes.cubemap_tx_, face)); GPU_framebuffer_bind(combined_fb_); inst_.pipelines.world.render(view); } - inst_.sphere_probes.remap_to_octahedral_projection(update_info->atlas_coord); + inst_.reflection_probes.remap_to_octahedral_projection(update_info->atlas_coord); + inst_.reflection_probes.update_probes_texture_mipmaps(); } if (update_info->do_world_irradiance_update) { - inst_.sphere_probes.update_world_irradiance(); + inst_.reflection_probes.update_world_irradiance(); } GPU_debug_group_end(); @@ -276,13 +279,12 @@ void CaptureView::render_probes() { Framebuffer prepass_fb; View view = {"Capture.View"}; - while (const auto update_info = inst_.sphere_probes.probe_update_info_pop()) { + bool do_update_mipmap_chain = false; + while (const std::optional update_info = + inst_.reflection_probes.update_info_pop(ReflectionProbe::Type::PROBE)) + { GPU_debug_group_begin("Probe.Capture"); - - if (!inst_.pipelines.data.is_probe_reflection) { - inst_.pipelines.data.is_probe_reflection = true; - inst_.uniform_data.push_update(); - } + do_update_mipmap_chain = true; int2 extent = int2(update_info->resolution); inst_.render_buffers.acquire(extent); @@ -306,15 +308,17 @@ void CaptureView::render_probes() update_info->clipping_distances.y); view.sync(view_m4, win_m4); - combined_fb_.ensure(GPU_ATTACHMENT_TEXTURE(inst_.render_buffers.depth_tx), - GPU_ATTACHMENT_TEXTURE_CUBEFACE(inst_.sphere_probes.cubemap_tx_, face)); + combined_fb_.ensure( + GPU_ATTACHMENT_TEXTURE(inst_.render_buffers.depth_tx), + GPU_ATTACHMENT_TEXTURE_CUBEFACE(inst_.reflection_probes.cubemap_tx_, face)); - gbuffer_fb_.ensure(GPU_ATTACHMENT_TEXTURE(inst_.render_buffers.depth_tx), - GPU_ATTACHMENT_TEXTURE_CUBEFACE(inst_.sphere_probes.cubemap_tx_, face), - GPU_ATTACHMENT_TEXTURE(inst_.gbuffer.header_tx), - GPU_ATTACHMENT_TEXTURE_LAYER(inst_.gbuffer.normal_tx.layer_view(0), 0), - GPU_ATTACHMENT_TEXTURE_LAYER(inst_.gbuffer.closure_tx.layer_view(0), 0), - GPU_ATTACHMENT_TEXTURE_LAYER(inst_.gbuffer.closure_tx.layer_view(1), 0)); + gbuffer_fb_.ensure( + GPU_ATTACHMENT_TEXTURE(inst_.render_buffers.depth_tx), + GPU_ATTACHMENT_TEXTURE_CUBEFACE(inst_.reflection_probes.cubemap_tx_, face), + GPU_ATTACHMENT_TEXTURE(inst_.gbuffer.header_tx), + GPU_ATTACHMENT_TEXTURE_LAYER(inst_.gbuffer.normal_tx.layer_view(0), 0), + GPU_ATTACHMENT_TEXTURE_LAYER(inst_.gbuffer.closure_tx.layer_view(0), 0), + GPU_ATTACHMENT_TEXTURE_LAYER(inst_.gbuffer.closure_tx.layer_view(1), 0)); GPU_framebuffer_bind(combined_fb_); GPU_framebuffer_clear_color_depth(combined_fb_, float4(0.0f, 0.0f, 0.0f, 1.0f), 1.0f); @@ -324,12 +328,12 @@ void CaptureView::render_probes() inst_.render_buffers.release(); inst_.gbuffer.release(); GPU_debug_group_end(); - inst_.sphere_probes.remap_to_octahedral_projection(update_info->atlas_coord); + inst_.reflection_probes.remap_to_octahedral_projection(update_info->atlas_coord); } - if (inst_.pipelines.data.is_probe_reflection) { - inst_.pipelines.data.is_probe_reflection = false; - inst_.uniform_data.push_update(); + if (do_update_mipmap_chain) { + /* TODO: only update the regions that have been updated. */ + inst_.reflection_probes.update_probes_texture_mipmaps(); } } diff --git a/source/blender/draw/engines/eevee_next/eevee_volume.cc b/source/blender/draw/engines/eevee_next/eevee_volume.cc index bf357b511e0..d4c70292a05 100644 --- a/source/blender/draw/engines/eevee_next/eevee_volume.cc +++ b/source/blender/draw/engines/eevee_next/eevee_volume.cc @@ -192,8 +192,8 @@ void VolumeModule::end_sync() scatter_ps_.shader_set( inst_.shaders.static_shader_get(use_lights_ ? VOLUME_SCATTER_WITH_LIGHTS : VOLUME_SCATTER)); inst_.lights.bind_resources(scatter_ps_); - inst_.sphere_probes.bind_resources(scatter_ps_); - inst_.volume_probes.bind_resources(scatter_ps_); + inst_.reflection_probes.bind_resources(scatter_ps_); + inst_.irradiance_cache.bind_resources(scatter_ps_); inst_.shadows.bind_resources(scatter_ps_); inst_.sampling.bind_resources(scatter_ps_); scatter_ps_.bind_image("in_scattering_img", &prop_scattering_tx_); diff --git a/source/blender/draw/engines/eevee_next/eevee_world.cc b/source/blender/draw/engines/eevee_next/eevee_world.cc index a263795c2b8..6e9618a0900 100644 --- a/source/blender/draw/engines/eevee_next/eevee_world.cc +++ b/source/blender/draw/engines/eevee_next/eevee_world.cc @@ -119,14 +119,17 @@ void World::sync() } } + inst_.reflection_probes.sync_world(bl_world); + if (has_update) { + inst_.reflection_probes.do_world_update_set(true); + } + /* We have to manually test here because we have overrides. */ ::World *orig_world = (::World *)DEG_get_original_id(&bl_world->id); if (assign_if_different(prev_original_world, orig_world)) { - has_update = true; + inst_.reflection_probes.do_world_update_set(true); } - inst_.light_probes.sync_world(bl_world, has_update); - GPUMaterial *gpumat = inst_.shaders.world_shader_get(bl_world, ntree, MAT_PIPE_DEFERRED); inst_.manager->register_layer_attributes(gpumat); diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_deferred_capture_frag.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_deferred_capture_frag.glsl index 0109600d790..8329ac48e94 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_deferred_capture_frag.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_deferred_capture_frag.glsl @@ -20,7 +20,6 @@ void main() GBufferReader gbuf = gbuffer_read(gbuf_header_tx, gbuf_closure_tx, gbuf_normal_tx, texel); if (gbuf.closure_count == 0) { - out_radiance = vec4(0.0); return; } diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_light_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_light_lib.glsl index f4e64f26263..4f8762975a3 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_light_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_light_lib.glsl @@ -118,39 +118,24 @@ float light_attenuation_common(LightData light, const bool is_directional, vec3 /** * Fade light influence when surface is not facing the light. - * This is needed because LTC leaks light at roughness not 0 or 1 - * when the light is below the horizon. * L is normalized vector to light shape center. * Ng is ideally the geometric normal. */ -float light_attenuation_facing( - LightData light, vec3 L, float distance_to_light, vec3 Ng, bool use_subsurface) +float light_attenuation_facing(LightData light, vec3 L, vec3 Ng, bool use_subsurface) { if (use_subsurface) { return 1.0; } - - float radius; - if (is_area_light(light.type)) { - radius = length(vec2(light._area_size_x, light._area_size_y)); - } - else { - radius = light._radius; - } - /* Sine of angle between light center and light edge. */ - float sin_solid_angle = radius / distance_to_light; - /* Sine of angle between light center and shading plane. */ - float sin_light_angle = dot(L, Ng); - /* Do attenuation after the horizon line to avoid harsh cut - * or biasing of surfaces without light bleeding. */ - return saturate((sin_light_angle + sin_solid_angle + 0.1) * 10.0); + /* TODO(fclem): Take into consideration the light radius. */ + return float(dot(L, Ng) > 0.0); } float light_attenuation_surface( LightData light, const bool is_directional, vec3 Ng, bool use_subsurface, LightVector lv) { + /* TODO(fclem): add cutoff attenuation when back-facing. For now do nothing with Ng. */ return light_attenuation_common(light, is_directional, lv.L) * - light_attenuation_facing(light, lv.L, lv.dist, Ng, use_subsurface) * + light_attenuation_facing(light, lv.L, Ng, use_subsurface) * light_influence_attenuation(lv.dist, light.influence_radius_invsqr_surface); } diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_eval_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_eval_lib.glsl index 446870fc586..074f9549b5d 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_eval_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_eval_lib.glsl @@ -11,7 +11,7 @@ #pragma BLENDER_REQUIRE(eevee_sampling_lib.glsl) #pragma BLENDER_REQUIRE(eevee_spherical_harmonics_lib.glsl) -#ifdef SPHERE_PROBE +#ifdef REFLECTION_PROBE struct LightProbeSample { SphericalHarmonicL1 volume_irradiance; @@ -34,7 +34,7 @@ LightProbeSample lightprobe_load(vec3 P, vec3 Ng, vec3 V) } /* Return the best parallax corrected ray direction from the probe center. */ -vec3 lightprobe_sphere_parallax(SphereProbeData probe, vec3 P, vec3 L) +vec3 lightprobe_sphere_parallax(ReflectionProbeData probe, vec3 P, vec3 L) { bool is_world = (probe.influence_scale == 0.0); if (is_world) { @@ -63,7 +63,7 @@ vec3 lightprobe_sphere_parallax(SphereProbeData probe, vec3 P, vec3 L) vec3 lightprobe_spherical_sample_normalized_with_parallax( int probe_index, vec3 P, vec3 L, float lod, SphericalHarmonicL1 P_sh) { - SphereProbeData probe = reflection_probe_buf[probe_index]; + ReflectionProbeData probe = reflection_probe_buf[probe_index]; ReflectionProbeLowFreqLight shading_sh = reflection_probes_extract_low_freq(P_sh); vec3 normalization_factor = reflection_probes_normalization_eval( L, shading_sh, probe.low_freq_light); @@ -93,7 +93,7 @@ float lightprobe_roughness_to_cube_sh_mix_fac(float roughness) float lightprobe_roughness_to_lod(float roughness) { /* Temporary. Do something better. */ - return sqrt(roughness) * SPHERE_PROBE_MIPMAP_LEVELS; + return sqrt(roughness) * REFLECTION_PROBE_MIPMAP_LEVELS; } vec3 lightprobe_eval(LightProbeSample samp, ClosureDiffuse cl, vec3 P, vec3 V) @@ -150,4 +150,4 @@ vec3 lightprobe_eval(LightProbeSample samp, ClosureRefraction cl, vec3 P, vec3 V return mix(radiance_cube, radiance_sh, fac); } -#endif /* SPHERE_PROBE */ +#endif /* REFLECTION_PROBE */ diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_irradiance_ray_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_irradiance_ray_comp.glsl index c50fe6b5bc7..3c7f33f5826 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_irradiance_ray_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_irradiance_ray_comp.glsl @@ -67,7 +67,7 @@ void irradiance_capture_world(vec3 L, inout SphericalHarmonicL1 sh) float visibility = 0.0; if (capture_info_buf.capture_world_direct) { - SphereProbeUvArea atlas_coord = capture_info_buf.world_atlas_coord; + ReflectionProbeCoordinate atlas_coord = capture_info_buf.world_atlas_coord; radiance = reflection_probes_sample(L, 0.0, atlas_coord).rgb; /* Clamped brightness. */ diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_lib.glsl index 8815448cc1e..3ae4db73cc7 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_lib.glsl @@ -19,7 +19,7 @@ vec3 lightprobe_irradiance_grid_sample_position(mat4 grid_local_to_world_mat, * Return true if sample position is valid. * \a r_lP is the local position in grid units [0..grid_size). */ -bool lightprobe_irradiance_grid_local_coord(VolumeProbeData grid_data, vec3 P, out vec3 r_lP) +bool lightprobe_irradiance_grid_local_coord(IrradianceGridData grid_data, vec3 P, out vec3 r_lP) { /* Position in cell units. */ /* NOTE: The vector-matrix multiplication swapped on purpose to cancel the matrix transpose. */ @@ -29,7 +29,7 @@ bool lightprobe_irradiance_grid_local_coord(VolumeProbeData grid_data, vec3 P, o return all(equal(lP, r_lP)); } -int lightprobe_irradiance_grid_brick_index_get(VolumeProbeData grid_data, ivec3 brick_coord) +int lightprobe_irradiance_grid_brick_index_get(IrradianceGridData grid_data, ivec3 brick_coord) { int3 grid_size_in_bricks = divide_ceil(grid_data.grid_size, int3(IRRADIANCE_GRID_BRICK_SIZE - 1)); @@ -46,7 +46,7 @@ ivec3 lightprobe_irradiance_grid_cell_corner(int cell_corner_id) return (ivec3(cell_corner_id) >> ivec3(0, 1, 2)) & 1; } -float lightprobe_planar_score(PlanarProbeData planar, vec3 P, vec3 V, vec3 L) +float lightprobe_planar_score(ProbePlanarData planar, vec3 P, vec3 V, vec3 L) { vec3 lP = vec4(P, 1.0) * planar.world_to_object_transposed; if (any(greaterThan(abs(lP), vec3(1.0)))) { @@ -68,9 +68,9 @@ int lightprobe_planar_select(vec3 P, vec3 V, vec3 L) float best_score = saturate(dot(L, -V)); int best_index = -1; - for (int index = 0; index < PLANAR_PROBE_MAX; index++) { + for (int index = 0; index < PLANAR_PROBES_MAX; index++) { if (probe_planar_buf[index].layer_id == -1) { - /* PlanarProbeData doesn't contain any gap, exit at first item that is invalid. */ + /* ProbePlanarData doesn't contain any gap, exit at first item that is invalid. */ break; } float score = lightprobe_planar_score(probe_planar_buf[index], P, V, L); diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_volume_eval_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_volume_eval_lib.glsl index a53b018c2ae..23dacca97b8 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_volume_eval_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_volume_eval_lib.glsl @@ -30,7 +30,7 @@ ivec3 lightprobe_irradiance_grid_brick_coord(vec3 lP) /** * Return the local coordinated of the shading point inside the brick in unnormalized coordinate. */ -vec3 lightprobe_irradiance_grid_brick_local_coord(VolumeProbeData grid_data, +vec3 lightprobe_irradiance_grid_brick_local_coord(IrradianceGridData grid_data, vec3 lP, ivec3 brick_coord) { @@ -44,7 +44,7 @@ vec3 lightprobe_irradiance_grid_brick_local_coord(VolumeProbeData grid_data, /** * Return the biased local brick local coordinated. */ -vec3 lightprobe_irradiance_grid_bias_sample_coord(VolumeProbeData grid_data, +vec3 lightprobe_irradiance_grid_bias_sample_coord(IrradianceGridData grid_data, uvec2 brick_atlas_coord, vec3 brick_lP, vec3 lNg) @@ -161,7 +161,7 @@ SphericalHarmonicL1 lightprobe_irradiance_sample( } } - VolumeProbeData grid_data = grids_infos_buf[index]; + IrradianceGridData grid_data = grids_infos_buf[index]; /* TODO(fclem): Make sure this is working as expected. */ mat3x3 world_to_grid_transposed = mat3x3(grid_data.world_to_grid_transposed); diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_trace_planar_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_trace_planar_comp.glsl index 4699e8038a8..617205ec9de 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_trace_planar_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_trace_planar_comp.glsl @@ -58,7 +58,7 @@ void main() return; } - PlanarProbeData planar = probe_planar_buf[planar_id]; + ProbePlanarData planar = probe_planar_buf[planar_id]; /* Tag the ray data so that screen trace will not try to evaluate it and override the result. */ imageStore(ray_data_img, texel, vec4(ray_data.xyz, -ray_data.w)); diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_trace_screen_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_trace_screen_lib.glsl index cf84c85d605..c2a230b6d3b 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_ray_trace_screen_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_ray_trace_screen_lib.glsl @@ -164,7 +164,7 @@ METAL_ATTR ScreenTraceHitData raytrace_screen(RayTraceData rt_data, ScreenTraceHitData raytrace_planar(RayTraceData rt_data, depth2DArray planar_depth_tx, - PlanarProbeData planar, + ProbePlanarData planar, float stride_rand, Ray ray) { diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_convolve_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_convolve_comp.glsl deleted file mode 100644 index 5ac8cee29a0..00000000000 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_convolve_comp.glsl +++ /dev/null @@ -1,39 +0,0 @@ -/* SPDX-FileCopyrightText: 2023 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/* Shader to convert cube-map to octahedral projection. */ - -#pragma BLENDER_REQUIRE(eevee_octahedron_lib.glsl) - -SphereProbePixelArea reinterpret_as_write_coord(ivec4 packed_coord) -{ - SphereProbePixelArea unpacked; - unpacked.offset = packed_coord.xy; - unpacked.extent = packed_coord.z; - unpacked.layer = packed_coord.w; - return unpacked; -} - -void main() -{ - SphereProbePixelArea write_coord = reinterpret_as_write_coord(write_coord_packed); - - /* Texel in probe. */ - ivec2 local_texel = ivec2(gl_GlobalInvocationID.xy); - - /* Exit when pixel being written doesn't fit in the area reserved for the probe. */ - if (any(greaterThanEqual(local_texel, ivec2(write_coord.extent)))) { - return; - } - - ivec2 texel_out = write_coord.offset + local_texel; - vec4 color = vec4(0.0); - color += imageLoad(in_atlas_mip_img, ivec3(texel_out * 2 + ivec2(0, 0), write_coord.layer)); - color += imageLoad(in_atlas_mip_img, ivec3(texel_out * 2 + ivec2(1, 0), write_coord.layer)); - color += imageLoad(in_atlas_mip_img, ivec3(texel_out * 2 + ivec2(0, 1), write_coord.layer)); - color += imageLoad(in_atlas_mip_img, ivec3(texel_out * 2 + ivec2(1, 1), write_coord.layer)); - color *= 0.25; - - imageStore(out_atlas_mip_img, ivec3(texel_out, write_coord.layer), color); -} diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_eval_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_eval_lib.glsl index e14e73b44e0..91234a1c22b 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_eval_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_eval_lib.glsl @@ -8,12 +8,12 @@ #pragma BLENDER_REQUIRE(eevee_bxdf_sampling_lib.glsl) #pragma BLENDER_REQUIRE(eevee_reflection_probe_lib.glsl) -#ifdef SPHERE_PROBE +#ifdef REFLECTION_PROBE int reflection_probes_select(vec3 P, float random_probe) { - for (int index = 0; index < SPHERE_PROBE_MAX; index++) { - SphereProbeData probe_data = reflection_probe_buf[index]; - /* SphereProbeData doesn't contain any gap, exit at first item that is invalid. */ + for (int index = 0; index < REFLECTION_PROBES_MAX; index++) { + ReflectionProbeData probe_data = reflection_probe_buf[index]; + /* ReflectionProbeData doesn't contain any gap, exit at first item that is invalid. */ if (probe_data.atlas_coord.layer == -1) { /* We hit the end of the array. Return last valid index. */ return index - 1; @@ -29,6 +29,6 @@ int reflection_probes_select(vec3 P, float random_probe) } } /* This should never happen (world probe is always last). */ - return SPHERE_PROBE_MAX - 1; + return REFLECTION_PROBES_MAX - 1; } -#endif /* SPHERE_PROBE */ +#endif /* REFLECTION_PROBE */ diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_lib.glsl index 9d6a0810592..3541b44dd16 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_lib.glsl @@ -6,8 +6,8 @@ #pragma BLENDER_REQUIRE(eevee_octahedron_lib.glsl) #pragma BLENDER_REQUIRE(eevee_spherical_harmonics_lib.glsl) -#ifdef SPHERE_PROBE -vec4 reflection_probes_sample(vec3 L, float lod, SphereProbeUvArea atlas_coord) +#ifdef REFLECTION_PROBE +vec4 reflection_probes_sample(vec3 L, float lod, ReflectionProbeCoordinate atlas_coord) { vec2 octahedral_uv = octahedral_uv_from_direction(L) * atlas_coord.scale + atlas_coord.offset; return textureLod(reflection_probes_tx, vec3(octahedral_uv, atlas_coord.layer), lod); diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_remap_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_remap_comp.glsl index d5bf9eaa60d..1830e07494e 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_remap_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_remap_comp.glsl @@ -7,18 +7,18 @@ #pragma BLENDER_REQUIRE(eevee_octahedron_lib.glsl) #pragma BLENDER_REQUIRE(eevee_colorspace_lib.glsl) -SphereProbeUvArea reinterpret_as_atlas_coord(ivec4 packed_coord) +ReflectionProbeCoordinate reinterpret_as_atlas_coord(ivec4 packed_coord) { - SphereProbeUvArea unpacked; + ReflectionProbeCoordinate unpacked; unpacked.offset = intBitsToFloat(packed_coord.xy); unpacked.scale = intBitsToFloat(packed_coord.z); unpacked.layer = intBitsToFloat(packed_coord.w); return unpacked; } -SphereProbePixelArea reinterpret_as_write_coord(ivec4 packed_coord) +ReflectionProbeWriteCoordinate reinterpret_as_write_coord(ivec4 packed_coord) { - SphereProbePixelArea unpacked; + ReflectionProbeWriteCoordinate unpacked; unpacked.offset = packed_coord.xy; unpacked.extent = packed_coord.z; unpacked.layer = packed_coord.w; @@ -40,9 +40,9 @@ vec2 mirror_repeat_uv(vec2 uv) void main() { - SphereProbeUvArea world_coord = reinterpret_as_atlas_coord(world_coord_packed); - SphereProbeUvArea sample_coord = reinterpret_as_atlas_coord(probe_coord_packed); - SphereProbePixelArea write_coord = reinterpret_as_write_coord(write_coord_packed); + ReflectionProbeCoordinate world_coord = reinterpret_as_atlas_coord(world_coord_packed); + ReflectionProbeCoordinate sample_coord = reinterpret_as_atlas_coord(probe_coord_packed); + ReflectionProbeWriteCoordinate write_coord = reinterpret_as_write_coord(write_coord_packed); /* Texel in probe. */ ivec2 local_texel = ivec2(gl_GlobalInvocationID.xy); @@ -61,7 +61,7 @@ void main() vec2 wrapped_uv = mirror_repeat_uv(sampling_uv); /* Direction in world space. */ vec3 direction = octahedral_uv_to_direction(wrapped_uv); - vec4 radiance_and_transmittance = texture(cubemap_tx, direction); + vec4 radiance_and_transmittance = textureLod(cubemap_tx, direction, float(mip_level)); vec3 radiance = radiance_and_transmittance.xyz; float opacity = 1.0 - radiance_and_transmittance.a; diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_select_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_select_comp.glsl index b70fc8c16e4..8acae79c16b 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_select_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_select_comp.glsl @@ -18,7 +18,7 @@ void main() } SphericalHarmonicL1 sh; - if (idx == reflection_probe_count - 1) { + if (idx == 0) { sh = lightprobe_irradiance_world(); } else { diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_update_irradiance_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_update_irradiance_comp.glsl index 983862cb7f5..28cb99d3f4a 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_update_irradiance_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_reflection_probe_update_irradiance_comp.glsl @@ -9,9 +9,9 @@ #pragma BLENDER_REQUIRE(eevee_octahedron_lib.glsl) #pragma BLENDER_REQUIRE(eevee_sampling_lib.glsl) -SphereProbeUvArea reinterpret_as_atlas_coord(ivec4 packed_coord) +ReflectionProbeCoordinate reinterpret_as_atlas_coord(ivec4 packed_coord) { - SphereProbeUvArea unpacked; + ReflectionProbeCoordinate unpacked; unpacked.offset = intBitsToFloat(packed_coord.xy); unpacked.scale = intBitsToFloat(packed_coord.z); unpacked.layer = intBitsToFloat(packed_coord.w); @@ -42,14 +42,15 @@ void main() cooef.L1.M0 = vec4(0.0); cooef.L1.Mp1 = vec4(0.0); - SphereProbeUvArea atlas_coord = reinterpret_as_atlas_coord(world_coord_packed); + ReflectionProbeCoordinate atlas_coord = reinterpret_as_atlas_coord(world_coord_packed); float layer_mipmap = 5; /* Perform multiple sample. */ uint store_index = gl_LocalInvocationID.x; - float total_samples = float(gl_WorkGroupSize.x * SPHERE_PROBE_SH_SAMPLES_PER_GROUP); + float total_samples = float(gl_WorkGroupSize.x * REFLECTION_PROBE_SH_SAMPLES_PER_GROUP); float sample_weight = 4.0 * M_PI / total_samples; - float sample_offset = float(gl_LocalInvocationID.x * SPHERE_PROBE_SH_SAMPLES_PER_GROUP); - for (int sample_index = 0; sample_index < SPHERE_PROBE_SH_SAMPLES_PER_GROUP; sample_index++) { + float sample_offset = float(gl_LocalInvocationID.x * REFLECTION_PROBE_SH_SAMPLES_PER_GROUP); + for (int sample_index = 0; sample_index < REFLECTION_PROBE_SH_SAMPLES_PER_GROUP; sample_index++) + { vec2 rand = fract(hammersley_2d(sample_index + sample_offset, total_samples)); vec3 direction = sample_sphere(rand); vec4 light = reflection_probes_sample(direction, layer_mipmap, atlas_coord); diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_spherical_harmonics_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_spherical_harmonics_lib.glsl index 2aa6a2ca201..682c84c91e6 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_spherical_harmonics_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_spherical_harmonics_lib.glsl @@ -375,11 +375,12 @@ SphericalHarmonicL1 spherical_harmonics_triple_product(SphericalHarmonicL1 a, vec4 tb = 0.282094791 * b.L0.M0; sh.L1.Mn1 = ta * b.L1.Mn1 + tb * a.L1.Mn1; - sh.L1.M0 = ta * b.L1.M0 + tb * a.L1.M0; - sh.L1.Mp1 = ta * b.L1.Mp1 + tb * a.L1.Mp1; - sh.L0.M0 += 0.282094791 * (a.L1.Mn1 * b.L1.Mn1); + + sh.L1.M0 += ta * b.L1.M0 + tb * a.L1.M0; sh.L0.M0 += 0.282094795 * (a.L1.M0 * b.L1.M0); + + sh.L1.Mp1 += ta * b.L1.Mp1 + tb * a.L1.Mp1; sh.L0.M0 += 0.282094791 * (a.L1.Mp1 * b.L1.Mp1); return sh; } diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_surfel_light_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_surfel_light_comp.glsl index c2adf0529cf..1febad8adb5 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_surfel_light_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_surfel_light_comp.glsl @@ -33,8 +33,6 @@ void main() surfel.albedo_front; } - V = -surfel.normal; - Ng = -surfel.normal; stack.cl[0].N = -surfel.normal; light_eval(stack, P, Ng, V); diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_surfel_ray_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_surfel_ray_comp.glsl index 71175ce37c5..815171aadf2 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_surfel_ray_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_surfel_ray_comp.glsl @@ -88,7 +88,7 @@ void radiance_transfer_world(inout Surfel receiver, vec3 L) float visibility = 0.0; if (capture_info_buf.capture_world_indirect) { - SphereProbeUvArea atlas_coord = capture_info_buf.world_atlas_coord; + ReflectionProbeCoordinate atlas_coord = capture_info_buf.world_atlas_coord; radiance = reflection_probes_sample(L, 0.0, atlas_coord).rgb; } diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_vertex_copy_comp.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_vertex_copy_comp.glsl index 4135716455a..61841343c55 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_vertex_copy_comp.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_vertex_copy_comp.glsl @@ -5,7 +5,7 @@ void main() { uint vertex_id = gl_GlobalInvocationID.x; - if (vertex_id >= uint(vertex_count)) { + if (vertex_id >= vertex_count) { return; } out_buf[start_offset + vertex_id] = vec4(in_buf[vertex_id * vertex_stride + 0], diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_deferred_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_deferred_info.hh index 3de0d44b6bf..c86e2f4c619 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_deferred_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_deferred_info.hh @@ -144,7 +144,7 @@ GPU_SHADER_CREATE_INFO(eevee_deferred_planar_eval) .early_fragment_test(true) /* Inputs. */ .fragment_out(0, Type::VEC4, "out_radiance") - .define("SPHERE_PROBE") + .define("REFLECTION_PROBE") .define("SHADOW_SUBSURFACE") .define("LIGHT_CLOSURE_EVAL_COUNT", "2") .additional_info("eevee_shared", diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_irradiance_cache_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_irradiance_cache_info.hh index e6eac533fe1..33559612601 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_irradiance_cache_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_irradiance_cache_info.hh @@ -182,7 +182,7 @@ GPU_SHADER_CREATE_INFO(eevee_lightprobe_irradiance_load) .push_constant(Type::FLOAT, "dilation_threshold") .push_constant(Type::FLOAT, "dilation_radius") .push_constant(Type::FLOAT, "grid_intensity_factor") - .uniform_buf(0, "VolumeProbeData", "grids_infos_buf[IRRADIANCE_GRID_MAX]") + .uniform_buf(0, "IrradianceGridData", "grids_infos_buf[IRRADIANCE_GRID_MAX]") .storage_buf(0, Qualifier::READ, "uint", "bricks_infos_buf[]") .sampler(0, ImageType::FLOAT_3D, "irradiance_a_tx") .sampler(1, ImageType::FLOAT_3D, "irradiance_b_tx") @@ -200,20 +200,20 @@ GPU_SHADER_CREATE_INFO(eevee_lightprobe_irradiance_load) GPU_SHADER_CREATE_INFO(eevee_volume_probe_data) .uniform_buf(IRRADIANCE_GRID_BUF_SLOT, - "VolumeProbeData", + "IrradianceGridData", "grids_infos_buf[IRRADIANCE_GRID_MAX]") /* NOTE: Use uint instead of IrradianceBrickPacked because Metal needs to know the exact type. */ .storage_buf(IRRADIANCE_BRICK_BUF_SLOT, Qualifier::READ, "uint", "bricks_infos_buf[]") - .sampler(VOLUME_PROBE_TEX_SLOT, ImageType::FLOAT_3D, "irradiance_atlas_tx") + .sampler(IRRADIANCE_ATLAS_TEX_SLOT, ImageType::FLOAT_3D, "irradiance_atlas_tx") .define("IRRADIANCE_GRID_SAMPLING"); GPU_SHADER_CREATE_INFO(eevee_lightprobe_data) .additional_info("eevee_reflection_probe_data", "eevee_volume_probe_data"); GPU_SHADER_CREATE_INFO(eevee_lightprobe_planar_data) - .define("SPHERE_PROBE") - .uniform_buf(PLANAR_PROBE_BUF_SLOT, "PlanarProbeData", "probe_planar_buf[PLANAR_PROBE_MAX]") + .define("REFLECTION_PROBE") + .uniform_buf(PLANAR_PROBE_BUF_SLOT, "ProbePlanarData", "probe_planar_buf[PLANAR_PROBES_MAX]") .sampler(PLANAR_PROBE_RADIANCE_TEX_SLOT, ImageType::FLOAT_2D_ARRAY, "planar_radiance_tx") .sampler(PLANAR_PROBE_DEPTH_TEX_SLOT, ImageType::DEPTH_2D_ARRAY, "planar_depth_tx"); diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_reflection_probe_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_reflection_probe_info.hh index e1093a50b99..6ee1ae84905 100644 --- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_reflection_probe_info.hh +++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_reflection_probe_info.hh @@ -10,18 +10,19 @@ * \{ */ GPU_SHADER_CREATE_INFO(eevee_reflection_probe_data) - .define("SPHERE_PROBE") - .uniform_buf(SPHERE_PROBE_BUF_SLOT, - "SphereProbeData", - "reflection_probe_buf[SPHERE_PROBE_MAX]") - .sampler(SPHERE_PROBE_TEX_SLOT, ImageType::FLOAT_2D_ARRAY, "reflection_probes_tx"); + .define("REFLECTION_PROBE") + .uniform_buf(REFLECTION_PROBE_BUF_SLOT, + "ReflectionProbeData", + "reflection_probe_buf[REFLECTION_PROBES_MAX]") + .sampler(REFLECTION_PROBE_TEX_SLOT, ImageType::FLOAT_2D_ARRAY, "reflection_probes_tx"); /* Sample cubemap and remap into an octahedral texture. */ GPU_SHADER_CREATE_INFO(eevee_reflection_probe_remap) - .local_group_size(SPHERE_PROBE_GROUP_SIZE, SPHERE_PROBE_GROUP_SIZE) + .local_group_size(REFLECTION_PROBE_GROUP_SIZE, REFLECTION_PROBE_GROUP_SIZE) .push_constant(Type::IVEC4, "probe_coord_packed") .push_constant(Type::IVEC4, "write_coord_packed") .push_constant(Type::IVEC4, "world_coord_packed") + .push_constant(Type::INT, "mip_level") .push_constant(Type::FLOAT, "probe_brightness_clamp") .sampler(0, ImageType::FLOAT_CUBE, "cubemap_tx") .sampler(1, ImageType::FLOAT_2D_ARRAY, "atlas_tx") @@ -33,8 +34,8 @@ GPU_SHADER_CREATE_INFO(eevee_reflection_probe_remap) /* Extract spherical harmonics band L0 + L1 from octahedral mapped reflection probe and update the * world brick of the irradiance cache. */ GPU_SHADER_CREATE_INFO(eevee_reflection_probe_update_irradiance) - .local_group_size(SPHERE_PROBE_SH_GROUP_SIZE, 1) - .define("SPHERE_PROBE") + .local_group_size(REFLECTION_PROBE_SH_GROUP_SIZE, 1) + .define("REFLECTION_PROBE") .push_constant(Type::IVEC4, "world_coord_packed") .sampler(0, ImageType::FLOAT_2D_ARRAY, "reflection_probes_tx") .image(0, GPU_RGBA16F, Qualifier::READ_WRITE, ImageType::FLOAT_3D, "irradiance_atlas_img") @@ -43,32 +44,23 @@ GPU_SHADER_CREATE_INFO(eevee_reflection_probe_update_irradiance) .do_static_compilation(true); GPU_SHADER_CREATE_INFO(eevee_reflection_probe_select) - .local_group_size(SPHERE_PROBE_SELECT_GROUP_SIZE) + .local_group_size(REFLECTION_PROBE_SELECT_GROUP_SIZE) .storage_buf(0, Qualifier::READ_WRITE, - "SphereProbeData", - "reflection_probe_buf[SPHERE_PROBE_MAX]") + "ReflectionProbeData", + "reflection_probe_buf[REFLECTION_PROBES_MAX]") .push_constant(Type::INT, "reflection_probe_count") .additional_info("eevee_shared", "eevee_sampling_data", "eevee_volume_probe_data") .compute_source("eevee_reflection_probe_select_comp.glsl") .do_static_compilation(true); -GPU_SHADER_CREATE_INFO(eevee_reflection_probe_convolve) - .local_group_size(SPHERE_PROBE_GROUP_SIZE, SPHERE_PROBE_GROUP_SIZE) - .additional_info("eevee_shared") - .push_constant(Type::IVEC4, "write_coord_packed") - .image(0, GPU_RGBA16F, Qualifier::READ, ImageType::FLOAT_2D_ARRAY, "in_atlas_mip_img") - .image(1, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_atlas_mip_img") - .compute_source("eevee_reflection_probe_convolve_comp.glsl") - .do_static_compilation(true); - GPU_SHADER_INTERFACE_INFO(eevee_display_probe_reflection_iface, "") .smooth(Type::VEC2, "lP") .flat(Type::INT, "probe_index"); GPU_SHADER_CREATE_INFO(eevee_display_probe_reflection) .additional_info("eevee_shared", "draw_view", "eevee_reflection_probe_data") - .storage_buf(0, Qualifier::READ, "SphereProbeDisplayData", "display_data_buf[]") + .storage_buf(0, Qualifier::READ, "ReflectionProbeDisplayData", "display_data_buf[]") .vertex_source("eevee_display_probe_reflection_vert.glsl") .vertex_out(eevee_display_probe_reflection_iface) .fragment_source("eevee_display_probe_reflection_frag.glsl") @@ -79,7 +71,7 @@ GPU_SHADER_INTERFACE_INFO(eevee_display_probe_planar_iface, "").flat(Type::INT, GPU_SHADER_CREATE_INFO(eevee_display_probe_planar) .additional_info("eevee_shared", "draw_view", "eevee_lightprobe_planar_data") - .storage_buf(0, Qualifier::READ, "PlanarProbeDisplayData", "display_data_buf[]") + .storage_buf(0, Qualifier::READ, "ProbePlanarDisplayData", "display_data_buf[]") .vertex_source("eevee_display_probe_planar_vert.glsl") .vertex_out(eevee_display_probe_planar_iface) .fragment_source("eevee_display_probe_planar_frag.glsl") diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc b/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc index dd7c151b93e..906dc37a07e 100644 --- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc +++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc @@ -44,9 +44,9 @@ GPENCIL_tObject *gpencil_object_cache_add(GPENCIL_PrivateData *pd, Object *ob) tgp_ob->layers.first = tgp_ob->layers.last = nullptr; tgp_ob->vfx.first = tgp_ob->vfx.last = nullptr; - tgp_ob->camera_z = dot_v3v3(pd->camera_z_axis, ob->object_to_world().location()); + tgp_ob->camera_z = dot_v3v3(pd->camera_z_axis, ob->object_to_world[3]); tgp_ob->is_drawmode3d = (gpd->draw_mode == GP_DRAWMODE_3D) || pd->draw_depth_only; - tgp_ob->object_scale = mat4_to_scale(ob->object_to_world().ptr()); + tgp_ob->object_scale = mat4_to_scale(ob->object_to_world); /* Check if any material with holdout flag enabled. */ tgp_ob->do_mat_holdout = false; @@ -78,7 +78,7 @@ GPENCIL_tObject *gpencil_object_cache_add(GPENCIL_PrivateData *pd, Object *ob) add_v3_fl(size, 1e-8f); rescale_m4(mat, size); /* BBox space to World. */ - mul_m4_m4m4(mat, ob->object_to_world().ptr(), mat); + mul_m4_m4m4(mat, ob->object_to_world, mat); if (DRW_view_is_persp_get(nullptr)) { /* BBox center to camera vector. */ sub_v3_v3v3(tgp_ob->plane_normal, pd->camera_pos, mat[3]); @@ -103,9 +103,9 @@ GPENCIL_tObject *gpencil_object_cache_add(GPENCIL_PrivateData *pd, Object *ob) unit_m4(tgp_ob->plane_mat); copy_v3_v3(tgp_ob->plane_mat[2], tgp_ob->plane_normal); orthogonalize_m4(tgp_ob->plane_mat, 2); - mul_mat3_m4_v3(ob->object_to_world().ptr(), size); + mul_mat3_m4_v3(ob->object_to_world, size); float radius = len_v3(size); - mul_m4_v3(ob->object_to_world().ptr(), center); + mul_m4_v3(ob->object_to_world, center); rescale_m4(tgp_ob->plane_mat, blender::float3{radius, radius, radius}); copy_v3_v3(tgp_ob->plane_mat[3], center); diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_data.cc b/source/blender/draw/engines/gpencil/gpencil_draw_data.cc index d84dfc44612..4b45b53e355 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_data.cc +++ b/source/blender/draw/engines/gpencil/gpencil_draw_data.cc @@ -378,27 +378,27 @@ void gpencil_light_pool_populate(GPENCIL_LightPool *lightpool, Object *ob) float(*mat)[4] = reinterpret_cast(&gp_light->right); if (la->type == LA_SPOT) { - copy_m4_m4(mat, ob->world_to_object().ptr()); + copy_m4_m4(mat, ob->world_to_object); gp_light->type = GP_LIGHT_TYPE_SPOT; gp_light->spot_size = cosf(la->spotsize * 0.5f); gp_light->spot_blend = (1.0f - gp_light->spot_size) * la->spotblend; } else if (la->type == LA_AREA) { /* Simulate area lights using a spot light. */ - normalize_m4_m4(mat, ob->object_to_world().ptr()); + normalize_m4_m4(mat, ob->object_to_world); invert_m4(mat); gp_light->type = GP_LIGHT_TYPE_SPOT; gp_light->spot_size = cosf(M_PI_2); gp_light->spot_blend = (1.0f - gp_light->spot_size) * 1.0f; } else if (la->type == LA_SUN) { - normalize_v3_v3(gp_light->forward, ob->object_to_world().ptr()[2]); + normalize_v3_v3(gp_light->forward, ob->object_to_world[2]); gp_light->type = GP_LIGHT_TYPE_SUN; } else { gp_light->type = GP_LIGHT_TYPE_POINT; } - copy_v4_v4(gp_light->position, ob->object_to_world().location()); + copy_v4_v4(gp_light->position, ob->object_to_world[3]); copy_v3_v3(gp_light->color, &la->r); mul_v3_fl(gp_light->color, la->energy * light_power_get(la)); diff --git a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc index a3a6c8766cd..37594d3049d 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc +++ b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc @@ -17,7 +17,7 @@ #include "BKE_shader_fx.h" #include "BKE_camera.h" -#include "BKE_global.hh" /* for G.debug */ +#include "BKE_global.h" /* for G.debug */ #include "BLI_link_utils.h" #include "BLI_listbase.h" diff --git a/source/blender/draw/engines/gpencil/gpencil_light.hh b/source/blender/draw/engines/gpencil/gpencil_light.hh index 45eb0434513..7b4f4cc2308 100644 --- a/source/blender/draw/engines/gpencil/gpencil_light.hh +++ b/source/blender/draw/engines/gpencil/gpencil_light.hh @@ -78,25 +78,25 @@ class LightModule { light.type = GP_LIGHT_TYPE_SPOT; light.spot_size = cosf(la->spotsize * 0.5f); light.spot_blend = (1.0f - light.spot_size) * la->spotblend; - mat = ob->world_to_object(); + mat = float4x4(ob->world_to_object); break; case LA_AREA: /* Simulate area lights using a spot light. */ light.type = GP_LIGHT_TYPE_SPOT; light.spot_size = cosf(M_PI_2); light.spot_blend = (1.0f - light.spot_size) * 1.0f; - normalize_m4_m4(mat.ptr(), ob->object_to_world().ptr()); + normalize_m4_m4(mat.ptr(), ob->object_to_world); invert_m4(mat.ptr()); break; case LA_SUN: - light.forward = math::normalize(float3(ob->object_to_world().ptr()[2])); + light.forward = math::normalize(float3(ob->object_to_world[2])); light.type = GP_LIGHT_TYPE_SUN; break; default: light.type = GP_LIGHT_TYPE_POINT; break; } - light.position = float3(object_ref.object->object_to_world().location()); + light.position = float3(object_ref.object->object_to_world[3]); light.color = float3(la->r, la->g, la->b) * (la->energy * light_power); lights_buf_.append(light); diff --git a/source/blender/draw/engines/gpencil/gpencil_object.hh b/source/blender/draw/engines/gpencil/gpencil_object.hh index 71f3963cdad..dc172957694 100644 --- a/source/blender/draw/engines/gpencil/gpencil_object.hh +++ b/source/blender/draw/engines/gpencil/gpencil_object.hh @@ -139,7 +139,7 @@ class ObjectModule { } /* Order rendering using camera Z distance. */ - float3 position = float3(object->object_to_world().location()); + float3 position = float3(object->object_to_world[3]); float camera_z = math::dot(position, camera_forward_); PassMain::Sub &object_subpass = main_ps.sub("GPObject", camera_z); @@ -292,7 +292,7 @@ class ObjectModule { const float3 center = midpoint(bounds->min, bounds->max); /* BBox space to World. */ - const float4x4 object_to_world = object.object_to_world(); + const float4x4 object_to_world = float4x4(object.object_to_world); float4x4 bbox_mat = object_to_world * from_loc_rot_scale(center, Quaternion::identity(), size); float3 plane_normal; diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc b/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc index 65fa3a1ccfc..8de719e3517 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc +++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc @@ -100,7 +100,7 @@ static void gpencil_vfx_blur(BlurShaderFxData *fx, Object *ob, gpIterVfxData *it float winmat[4][4], persmat[4][4]; float blur_size[2] = {fx->radius[0], fx->radius[1]}; DRW_view_persmat_get(nullptr, persmat, false); - const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world().location())); + const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world[3])); if (fx->flag & FX_BLUR_DOF_MODE) { /* Compute circle of confusion size. */ @@ -112,7 +112,7 @@ static void gpencil_vfx_blur(BlurShaderFxData *fx, Object *ob, gpIterVfxData *it DRW_view_winmat_get(nullptr, winmat, false); const float *vp_size = DRW_viewport_size_get(); float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; - float scale = mat4_to_scale(ob->object_to_world().ptr()); + float scale = mat4_to_scale(ob->object_to_world); float distance_factor = world_pixel_scale * scale * winmat[1][1] * vp_size[1] / w; mul_v2_fl(blur_size, distance_factor); } @@ -181,11 +181,11 @@ static void gpencil_vfx_rim(RimShaderFxData *fx, Object *ob, gpIterVfxData *iter const float *vp_size = DRW_viewport_size_get(); const float *vp_size_inv = DRW_viewport_invert_size_get(); - const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world().location())); + const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world[3])); /* Modify by distance to camera and object scale. */ float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; - float scale = mat4_to_scale(ob->object_to_world().ptr()); + float scale = mat4_to_scale(ob->object_to_world); float distance_factor = (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w; mul_v2_fl(offset, distance_factor); mul_v2_v2(offset, vp_size_inv); @@ -256,8 +256,8 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat mul_v2_v2(pixel_size, vp_size_inv); /* Fixed pixelisation center from object center. */ - const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world().location())); - mul_v3_m4v3(ob_center, persmat, ob->object_to_world().location()); + const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world[3])); + mul_v3_m4v3(ob_center, persmat, ob->object_to_world[3]); mul_v3_fl(ob_center, 1.0f / w); const bool use_antialiasing = ((fx->flag & FX_PIXEL_FILTER_NEAREST) == 0); @@ -268,7 +268,7 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat /* Modify by distance to camera and object scale. */ float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; - float scale = mat4_to_scale(ob->object_to_world().ptr()); + float scale = mat4_to_scale(ob->object_to_world); mul_v2_fl(pixel_size, (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w); /* Center to texel */ @@ -324,8 +324,8 @@ static void gpencil_vfx_shadow(ShadowShaderFxData *fx, Object *ob, gpIterVfxData const float ratio = vp_size_inv[1] / vp_size_inv[0]; copy_v3_v3(rot_center, - (use_obj_pivot && fx->object) ? fx->object->object_to_world().location() : - ob->object_to_world().location()); + (use_obj_pivot && fx->object) ? fx->object->object_to_world[3] : + ob->object_to_world[3]); const float w = fabsf(mul_project_m4_v3_zfac(persmat, rot_center)); mul_v3_m4v3(rot_center, persmat, rot_center); @@ -333,7 +333,7 @@ static void gpencil_vfx_shadow(ShadowShaderFxData *fx, Object *ob, gpIterVfxData /* Modify by distance to camera and object scale. */ float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; - float scale = mat4_to_scale(ob->object_to_world().ptr()); + float scale = mat4_to_scale(ob->object_to_world); float distance_factor = (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w; mul_v2_fl(offset, distance_factor); mul_v2_v2(offset, vp_size_inv); @@ -501,13 +501,13 @@ static void gpencil_vfx_wave(WaveShaderFxData *fx, Object *ob, gpIterVfxData *it const float *vp_size = DRW_viewport_size_get(); const float *vp_size_inv = DRW_viewport_invert_size_get(); - const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world().location())); - mul_v3_m4v3(wave_center, persmat, ob->object_to_world().location()); + const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world[3])); + mul_v3_m4v3(wave_center, persmat, ob->object_to_world[3]); mul_v3_fl(wave_center, 1.0f / w); /* Modify by distance to camera and object scale. */ float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; - float scale = mat4_to_scale(ob->object_to_world().ptr()); + float scale = mat4_to_scale(ob->object_to_world); float distance_factor = (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w; wave_center[0] = wave_center[0] * 0.5f + 0.5f; @@ -558,7 +558,7 @@ static void gpencil_vfx_swirl(SwirlShaderFxData *fx, Object * /*ob*/, gpIterVfxD DRW_view_persmat_get(nullptr, persmat, false); const float *vp_size = DRW_viewport_size_get(); - copy_v3_v3(swirl_center, fx->object->object_to_world().location()); + copy_v3_v3(swirl_center, fx->object->object_to_world[3]); const float w = fabsf(mul_project_m4_v3_zfac(persmat, swirl_center)); mul_v3_m4v3(swirl_center, persmat, swirl_center); @@ -566,7 +566,7 @@ static void gpencil_vfx_swirl(SwirlShaderFxData *fx, Object * /*ob*/, gpIterVfxD /* Modify by distance to camera and object scale. */ float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; - float scale = mat4_to_scale(fx->object->object_to_world().ptr()); + float scale = mat4_to_scale(fx->object->object_to_world); float distance_factor = (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w; mul_v2_fl(swirl_center, 0.5f); diff --git a/source/blender/draw/engines/gpencil/gpencil_vfx.hh b/source/blender/draw/engines/gpencil/gpencil_vfx.hh index eacbc8617f1..2b22173f974 100644 --- a/source/blender/draw/engines/gpencil/gpencil_vfx.hh +++ b/source/blender/draw/engines/gpencil/gpencil_vfx.hh @@ -217,7 +217,7 @@ class VfxModule { /* TODO(fclem): Replace by draw::View. */ DRW_view_persmat_get(nullptr, persmat, false); - const float w = fabsf(mul_project_m4_v3_zfac(persmat, object->object_to_world().location())); + const float w = fabsf(mul_project_m4_v3_zfac(persmat, object->object_to_world[3])); if (fx.flag & FX_BLUR_DOF_MODE) { /* Compute circle of confusion size. */ @@ -232,7 +232,7 @@ class VfxModule { const float *vp_size = DRW_viewport_size_get(); float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; - float scale = mat4_to_scale(object->object_to_world().ptr()); + float scale = mat4_to_scale(object->object_to_world); float distance_factor = world_pixel_scale * scale * winmat[1][1] * vp_size[1] / w; blur_size *= distance_factor; } diff --git a/source/blender/draw/engines/overlay/overlay_armature.cc b/source/blender/draw/engines/overlay/overlay_armature.cc index 0d2350bf0c6..c1a3771f544 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.cc +++ b/source/blender/draw/engines/overlay/overlay_armature.cc @@ -653,7 +653,7 @@ static void drw_shgroup_bone_octahedral(const ArmatureDrawContext *ctx, const float outline_color[4]) { BoneInstanceData inst_data; - mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world().ptr(), bone_mat); + mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world, bone_mat); if (ctx->solid) { OVERLAY_bone_instance_data_set_color(&inst_data, bone_color); OVERLAY_bone_instance_data_set_color_hint(&inst_data, hint_color); @@ -673,7 +673,7 @@ static void drw_shgroup_bone_box(const ArmatureDrawContext *ctx, const float outline_color[4]) { BoneInstanceData inst_data; - mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world().ptr(), bone_mat); + mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world, bone_mat); if (ctx->solid) { OVERLAY_bone_instance_data_set_color(&inst_data, bone_color); OVERLAY_bone_instance_data_set_color_hint(&inst_data, hint_color); @@ -691,9 +691,9 @@ static void drw_shgroup_bone_wire(const ArmatureDrawContext *ctx, const float color[4]) { float head[3], tail[3]; - mul_v3_m4v3(head, ctx->ob->object_to_world().ptr(), bone_mat[3]); + mul_v3_m4v3(head, ctx->ob->object_to_world, bone_mat[3]); add_v3_v3v3(tail, bone_mat[3], bone_mat[1]); - mul_m4_v3(ctx->ob->object_to_world().ptr(), tail); + mul_m4_v3(ctx->ob->object_to_world, tail); DRW_buffer_add_entry(ctx->wire, head, color); DRW_buffer_add_entry(ctx->wire, tail, color); @@ -708,9 +708,9 @@ static void drw_shgroup_bone_stick(const ArmatureDrawContext *ctx, const float col_tail[4]) { float head[3], tail[3]; - mul_v3_m4v3(head, ctx->ob->object_to_world().ptr(), bone_mat[3]); + mul_v3_m4v3(head, ctx->ob->object_to_world, bone_mat[3]); add_v3_v3v3(tail, bone_mat[3], bone_mat[1]); - mul_m4_v3(ctx->ob->object_to_world().ptr(), tail); + mul_m4_v3(ctx->ob->object_to_world, tail); DRW_buffer_add_entry(ctx->stick, head, tail, col_wire, col_bone, col_head, col_tail); } @@ -729,11 +729,11 @@ static void drw_shgroup_bone_envelope_distance(const ArmatureDrawContext *ctx, mul_m4_v4(bone_mat, head_sph); mul_m4_v4(bone_mat, tail_sph); mul_m4_v4(bone_mat, xaxis); - mul_m4_v4(ctx->ob->object_to_world().ptr(), head_sph); - mul_m4_v4(ctx->ob->object_to_world().ptr(), tail_sph); - mul_m4_v4(ctx->ob->object_to_world().ptr(), xaxis); + mul_m4_v4(ctx->ob->object_to_world, head_sph); + mul_m4_v4(ctx->ob->object_to_world, tail_sph); + mul_m4_v4(ctx->ob->object_to_world, xaxis); sub_v3_v3(xaxis, head_sph); - float obscale = mat4_to_scale(ctx->ob->object_to_world().ptr()); + float obscale = mat4_to_scale(ctx->ob->object_to_world); head_sph[3] = *radius_head * obscale; head_sph[3] += *distance * obscale; tail_sph[3] = *radius_tail * obscale; @@ -756,10 +756,10 @@ static void drw_shgroup_bone_envelope(const ArmatureDrawContext *ctx, mul_m4_v4(bone_mat, head_sph); mul_m4_v4(bone_mat, tail_sph); mul_m4_v4(bone_mat, xaxis); - mul_m4_v4(ctx->ob->object_to_world().ptr(), head_sph); - mul_m4_v4(ctx->ob->object_to_world().ptr(), tail_sph); - mul_m4_v4(ctx->ob->object_to_world().ptr(), xaxis); - float obscale = mat4_to_scale(ctx->ob->object_to_world().ptr()); + mul_m4_v4(ctx->ob->object_to_world, head_sph); + mul_m4_v4(ctx->ob->object_to_world, tail_sph); + mul_m4_v4(ctx->ob->object_to_world, xaxis); + float obscale = mat4_to_scale(ctx->ob->object_to_world); head_sph[3] = *radius_head * obscale; tail_sph[3] = *radius_tail * obscale; @@ -861,7 +861,7 @@ static void drw_shgroup_bone_custom_solid_mesh(const ArmatureDrawContext *ctx, DRWCallBuffer *buf; if (surf || edges || loose_edges) { - mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world().ptr(), bone_mat); + mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world, bone_mat); } if (surf && ctx->custom_solid) { @@ -903,7 +903,7 @@ static void drw_shgroup_bone_custom_mesh_wire(const ArmatureDrawContext *ctx, if (geom) { DRWCallBuffer *buf = custom_bone_instance_shgroup(ctx, ctx->custom_wire, geom); BoneInstanceData inst_data; - mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world().ptr(), bone_mat); + mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world, bone_mat); OVERLAY_bone_instance_data_set_color_hint(&inst_data, color); OVERLAY_bone_instance_data_set_color(&inst_data, color); DRW_buffer_add_entry_struct(buf, inst_data.mat); @@ -936,7 +936,7 @@ static void drw_shgroup_custom_bone_curve(const ArmatureDrawContext *ctx, if (loose_edges) { BoneInstanceData inst_data; - mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world().ptr(), bone_mat); + mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world, bone_mat); DRWCallBuffer *buf = custom_bone_instance_shgroup(ctx, ctx->custom_wire, loose_edges); OVERLAY_bone_instance_data_set_color_hint(&inst_data, outline_color); @@ -997,7 +997,7 @@ static void drw_shgroup_bone_custom_empty(const ArmatureDrawContext *ctx, { const float final_color[4] = {color[0], color[1], color[2], 1.0f}; float mat[4][4]; - mul_m4_m4m4(mat, ctx->ob->object_to_world().ptr(), bone_mat); + mul_m4_m4m4(mat, ctx->ob->object_to_world, bone_mat); switch (custom->empty_drawtype) { case OB_PLAINAXES: @@ -1023,7 +1023,7 @@ static void drw_shgroup_bone_point(const ArmatureDrawContext *ctx, const float outline_color[4]) { BoneInstanceData inst_data; - mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world().ptr(), bone_mat); + mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world, bone_mat); if (ctx->point_solid) { OVERLAY_bone_instance_data_set_color(&inst_data, bone_color); OVERLAY_bone_instance_data_set_color_hint(&inst_data, hint_color); @@ -1041,7 +1041,7 @@ static void drw_shgroup_bone_axes(const ArmatureDrawContext *ctx, const float color[4]) { float mat[4][4]; - mul_m4_m4m4(mat, ctx->ob->object_to_world().ptr(), bone_mat); + mul_m4_m4m4(mat, ctx->ob->object_to_world, bone_mat); /* Move to bone tail. */ add_v3_v3(mat[3], mat[1]); OVERLAY_empty_shape(ctx->extras, mat, 0.25f, OB_ARROWS, color); @@ -1054,8 +1054,8 @@ static void drw_shgroup_bone_relationship_lines_ex(const ArmatureDrawContext *ct const float color[4]) { float s[3], e[3]; - mul_v3_m4v3(s, ctx->ob->object_to_world().ptr(), start); - mul_v3_m4v3(e, ctx->ob->object_to_world().ptr(), end); + mul_v3_m4v3(s, ctx->ob->object_to_world, start); + mul_v3_m4v3(e, ctx->ob->object_to_world, end); /* reverse order to have less stipple overlap */ OVERLAY_extra_line_dashed(ctx->extras, s, e, color); } @@ -1763,7 +1763,7 @@ static void draw_bone_degrees_of_freedom(const ArmatureDrawContext *ctx, const b mul_m4_m4m4(posetrans, posetrans, tmp); /* into world space. */ - mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world().ptr(), posetrans); + mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world, posetrans); if ((pchan->ikflag & BONE_IK_XLIMIT) && (pchan->ikflag & BONE_IK_ZLIMIT)) { bone_instance_data_set_angle_minmax( @@ -1944,7 +1944,7 @@ static void draw_bone_name(const ArmatureDrawContext *ctx, const float *head = is_pose ? pchan->pose_head : eBone->head; const float *tail = is_pose ? pchan->pose_tail : eBone->tail; mid_v3_v3v3(vec, head, tail); - mul_m4_v3(ctx->ob->object_to_world().ptr(), vec); + mul_m4_v3(ctx->ob->object_to_world, vec); DRW_text_cache_add(dt, vec, @@ -2284,13 +2284,13 @@ class ArmatureBoneDrawStrategyBBone : public ArmatureBoneDrawStrategy { const bArmature *arm = static_cast(ob->data); BLI_assert(arm->drawtype == ARM_B_BONE); UNUSED_VARS_NDEBUG(arm); - const float ob_scale = mat4_to_size_max_axis(ob->object_to_world().ptr()); + const float ob_scale = mat4_to_size_max_axis(ob->object_to_world); const Mat4 *bbones_mat = (const Mat4 *)pchan->draw_data->bbone_matrix; for (int i = pchan->bone->segments; i--; bbones_mat++) { BoundSphere bsphere; float size[3]; mat4_to_size(size, bbones_mat->mat); - mul_v3_m4v3(bsphere.center, ob->object_to_world().ptr(), bbones_mat->mat[3]); + mul_v3_m4v3(bsphere.center, ob->object_to_world, bbones_mat->mat[3]); bsphere.radius = len_v3(size) * ob_scale; if (DRW_culling_sphere_test(view, &bsphere)) { return true; @@ -2365,7 +2365,7 @@ class ArmatureBoneDrawStrategyEnvelope : public ArmatureBoneDrawStrategy { BoundSphere bsphere; pchan_culling_calc_bsphere(ob, pchan, &bsphere); bsphere.radius += max_ff(pchan->bone->rad_head, pchan->bone->rad_tail) * - mat4_to_size_max_axis(ob->object_to_world().ptr()) * + mat4_to_size_max_axis(ob->object_to_world) * mat4_to_size_max_axis(pchan->disp_mat); return DRW_culling_sphere_test(view, &bsphere); } diff --git a/source/blender/draw/engines/overlay/overlay_edit_text.cc b/source/blender/draw/engines/overlay/overlay_edit_text.cc index 8b83db20235..adc3478b1be 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_text.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_text.cc @@ -123,7 +123,7 @@ static void edit_text_cache_populate_select(OVERLAY_Data *vedata, Object *ob) add_v2_v2(box[3], &sb->x); } v2_quad_corners_to_mat4(box, final_mat); - mul_m4_m4m4(final_mat, ob->object_to_world().ptr(), final_mat); + mul_m4_m4m4(final_mat, ob->object_to_world, final_mat); DRW_shgroup_call_obmat(pd->edit_text_selection_grp, geom, final_mat); } @@ -138,7 +138,7 @@ static void edit_text_cache_populate_cursor(OVERLAY_Data *vedata, Object *ob) float mat[4][4]; v2_quad_corners_to_mat4(cursor, mat); - mul_m4_m4m4(mat, ob->object_to_world().ptr(), mat); + mul_m4_m4m4(mat, ob->object_to_world, mat); GPUBatch *geom = DRW_cache_quad_get(); DRW_shgroup_call_obmat(pd->edit_text_cursor_grp, geom, mat); @@ -166,7 +166,7 @@ static void edit_text_cache_populate_boxes(OVERLAY_Data *vedata, Object *ob) vecs[3][1] -= tb->h; for (int j = 0; j < 4; j++) { - mul_v3_m4v3(vecs[j], ob->object_to_world().ptr(), vecs[j]); + mul_v3_m4v3(vecs[j], ob->object_to_world, vecs[j]); } for (int j = 0; j < 4; j++) { OVERLAY_extra_line_dashed(cb, vecs[j], vecs[(j + 1) % 4], color); diff --git a/source/blender/draw/engines/overlay/overlay_engine.cc b/source/blender/draw/engines/overlay/overlay_engine.cc index 6a7b586ca07..ae719cf97e1 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.cc +++ b/source/blender/draw/engines/overlay/overlay_engine.cc @@ -17,7 +17,7 @@ #include "UI_interface.hh" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_object.hh" #include "BKE_paint.hh" diff --git a/source/blender/draw/engines/overlay/overlay_extra.cc b/source/blender/draw/engines/overlay/overlay_extra.cc index 09fe549d8a1..02697587fb0 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.cc +++ b/source/blender/draw/engines/overlay/overlay_extra.cc @@ -18,7 +18,7 @@ #include "BKE_camera.h" #include "BKE_constraint.h" #include "BKE_curve.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_mball.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" @@ -342,8 +342,7 @@ void OVERLAY_empty_cache_populate(OVERLAY_Data *vedata, Object *ob) case OB_EMPTY_CONE: case OB_ARROWS: DRW_object_wire_theme_get(ob, view_layer, &color); - OVERLAY_empty_shape( - cb, ob->object_to_world().ptr(), ob->empty_drawsize, ob->empty_drawtype, color); + OVERLAY_empty_shape(cb, ob->object_to_world, ob->empty_drawsize, ob->empty_drawtype, color); break; case OB_EMPTY_IMAGE: OVERLAY_image_empty_cache_populate(vedata, ob); @@ -374,7 +373,7 @@ static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb, case OB_BOUND_BOX: size_to_mat4(tmp, size); copy_v3_v3(tmp[3], center); - mul_m4_m4m4(tmp, ob->object_to_world().ptr(), tmp); + mul_m4_m4m4(tmp, ob->object_to_world, tmp); DRW_buffer_add_entry(cb->empty_cube, color, tmp); break; case OB_BOUND_SPHERE: @@ -382,7 +381,7 @@ static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb, size[1] = size[2] = size[0]; size_to_mat4(tmp, size); copy_v3_v3(tmp[3], center); - mul_m4_m4m4(tmp, ob->object_to_world().ptr(), tmp); + mul_m4_m4m4(tmp, ob->object_to_world, tmp); DRW_buffer_add_entry(cb->empty_sphere, color, tmp); break; case OB_BOUND_CYLINDER: @@ -390,7 +389,7 @@ static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb, size[1] = size[0]; size_to_mat4(tmp, size); copy_v3_v3(tmp[3], center); - mul_m4_m4m4(tmp, ob->object_to_world().ptr(), tmp); + mul_m4_m4m4(tmp, ob->object_to_world, tmp); DRW_buffer_add_entry(cb->empty_cylinder, color, tmp); break; case OB_BOUND_CONE: @@ -401,7 +400,7 @@ static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb, /* Cone batch has base at 0 and is pointing towards +Y. */ swap_v3_v3(tmp[1], tmp[2]); tmp[3][2] -= size[2]; - mul_m4_m4m4(tmp, ob->object_to_world().ptr(), tmp); + mul_m4_m4m4(tmp, ob->object_to_world, tmp); DRW_buffer_add_entry(cb->empty_cone, color, tmp); break; case OB_BOUND_CAPSULE: @@ -410,14 +409,14 @@ static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb, scale_m4_fl(tmp, size[0]); copy_v2_v2(tmp[3], center); tmp[3][2] = center[2] + max_ff(0.0f, size[2] - size[0]); - mul_m4_m4m4(final_mat, ob->object_to_world().ptr(), tmp); + mul_m4_m4m4(final_mat, ob->object_to_world, tmp); DRW_buffer_add_entry(cb->empty_capsule_cap, color, final_mat); negate_v3(tmp[2]); tmp[3][2] = center[2] - max_ff(0.0f, size[2] - size[0]); - mul_m4_m4m4(final_mat, ob->object_to_world().ptr(), tmp); + mul_m4_m4m4(final_mat, ob->object_to_world, tmp); DRW_buffer_add_entry(cb->empty_capsule_cap, color, final_mat); tmp[2][2] = max_ff(0.0f, size[2] * 2.0f - size[0] * 2.0f); - mul_m4_m4m4(final_mat, ob->object_to_world().ptr(), tmp); + mul_m4_m4m4(final_mat, ob->object_to_world, tmp); DRW_buffer_add_entry(cb->empty_capsule_body, color, final_mat); break; } @@ -491,7 +490,7 @@ static void OVERLAY_texture_space(OVERLAY_ExtraCallBuffers *cb, Object *ob, cons unit_m4(mat); } - mul_m4_m4m4(mat, ob->object_to_world().ptr(), mat); + mul_m4_m4m4(mat, ob->object_to_world, mat); DRW_buffer_add_entry(cb->empty_cube, color, mat); } @@ -513,7 +512,7 @@ static void OVERLAY_forcefield(OVERLAY_ExtraCallBuffers *cb, Object *ob, ViewLay }; } instdata; - copy_m4_m4(instdata.mat, ob->object_to_world().ptr()); + copy_m4_m4(instdata.mat, ob->object_to_world); instdata.size_x = instdata.size_y = instdata.size_z = ob->empty_drawsize; switch (pd->forcefield) { @@ -533,16 +532,16 @@ static void OVERLAY_forcefield(OVERLAY_ExtraCallBuffers *cb, Object *ob, ViewLay instdata.size_x = instdata.size_y = instdata.size_z = pd->f_strength; float pos[4]; BKE_where_on_path(ob, 0.0f, pos, nullptr, nullptr, nullptr, nullptr); - copy_v3_v3(instdata.pos, ob->object_to_world().location()); + copy_v3_v3(instdata.pos, ob->object_to_world[3]); translate_m4(instdata.mat, pos[0], pos[1], pos[2]); DRW_buffer_add_entry(cb->field_curve, color, &instdata); BKE_where_on_path(ob, 1.0f, pos, nullptr, nullptr, nullptr, nullptr); - copy_v3_v3(instdata.pos, ob->object_to_world().location()); + copy_v3_v3(instdata.pos, ob->object_to_world[3]); translate_m4(instdata.mat, pos[0], pos[1], pos[2]); DRW_buffer_add_entry(cb->field_sphere_limit, color, &instdata); /* Restore */ - copy_v3_v3(instdata.pos, ob->object_to_world().location()); + copy_v3_v3(instdata.pos, ob->object_to_world[3]); } break; } @@ -628,7 +627,7 @@ void OVERLAY_light_cache_populate(OVERLAY_Data *vedata, Object *ob) }; } instdata; - copy_m4_m4(instdata.mat, ob->object_to_world().ptr()); + copy_m4_m4(instdata.mat, ob->object_to_world); /* FIXME / TODO: clip_end has no meaning nowadays. * In EEVEE, Only clip_sta is used shadow-mapping. * Clip end is computed automatically based on light power. @@ -727,7 +726,7 @@ void OVERLAY_lightprobe_cache_populate(OVERLAY_Data *vedata, Object *ob) }; } instdata; - copy_m4_m4(instdata.mat, ob->object_to_world().ptr()); + copy_m4_m4(instdata.mat, ob->object_to_world); switch (prb->type) { case LIGHTPROBE_TYPE_SPHERE: @@ -739,15 +738,15 @@ void OVERLAY_lightprobe_cache_populate(OVERLAY_Data *vedata, Object *ob) if (show_influence) { char shape = (prb->attenuation_type == LIGHTPROBE_SHAPE_BOX) ? OB_CUBE : OB_EMPTY_SPHERE; float f = 1.0f - prb->falloff; - OVERLAY_empty_shape(cb, ob->object_to_world().ptr(), prb->distinf, shape, color_p); - OVERLAY_empty_shape(cb, ob->object_to_world().ptr(), prb->distinf * f, shape, color_p); + OVERLAY_empty_shape(cb, ob->object_to_world, prb->distinf, shape, color_p); + OVERLAY_empty_shape(cb, ob->object_to_world, prb->distinf * f, shape, color_p); } if (show_parallax) { char shape = (prb->parallax_type == LIGHTPROBE_SHAPE_BOX) ? OB_CUBE : OB_EMPTY_SPHERE; float dist = ((prb->flag & LIGHTPROBE_FLAG_CUSTOM_PARALLAX) != 0) ? prb->distpar : prb->distinf; - OVERLAY_empty_shape(cb, ob->object_to_world().ptr(), dist, shape, color_p); + OVERLAY_empty_shape(cb, ob->object_to_world, dist, shape, color_p); } break; case LIGHTPROBE_TYPE_VOLUME: @@ -757,9 +756,8 @@ void OVERLAY_lightprobe_cache_populate(OVERLAY_Data *vedata, Object *ob) if (show_influence) { float f = 1.0f - prb->falloff; - OVERLAY_empty_shape(cb, ob->object_to_world().ptr(), 1.0 + prb->distinf, OB_CUBE, color_p); - OVERLAY_empty_shape( - cb, ob->object_to_world().ptr(), 1.0 + prb->distinf * f, OB_CUBE, color_p); + OVERLAY_empty_shape(cb, ob->object_to_world, 1.0 + prb->distinf, OB_CUBE, color_p); + OVERLAY_empty_shape(cb, ob->object_to_world, 1.0 + prb->distinf * f, OB_CUBE, color_p); } /* Data dots */ @@ -797,7 +795,7 @@ void OVERLAY_lightprobe_cache_populate(OVERLAY_Data *vedata, Object *ob) zero_v3(instdata.mat[2]); DRW_buffer_add_entry(cb->empty_cube, color_p, &instdata); - normalize_m4_m4(instdata.mat, ob->object_to_world().ptr()); + normalize_m4_m4(instdata.mat, ob->object_to_world); OVERLAY_empty_shape(cb, instdata.mat, ob->empty_drawsize, OB_SINGLE_ARROW, color_p); break; } @@ -817,7 +815,7 @@ void OVERLAY_speaker_cache_populate(OVERLAY_Data *vedata, Object *ob) float *color_p; DRW_object_wire_theme_get(ob, view_layer, &color_p); - DRW_buffer_add_entry(cb->speaker, color_p, ob->object_to_world().ptr()); + DRW_buffer_add_entry(cb->speaker, color_p, ob->object_to_world); } /** \} */ @@ -910,7 +908,7 @@ static void camera_view3d_reconstruction( float object_imat[4][4]; invert_m4_m4(object_imat, object_mat); - mul_m4_m4m4(tracking_object_mat, ob->object_to_world().ptr(), object_imat); + mul_m4_m4m4(tracking_object_mat, ob->object_to_world, object_imat); } LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) { @@ -1153,7 +1151,7 @@ void OVERLAY_camera_cache_populate(OVERLAY_Data *vedata, Object *ob) DRW_object_wire_theme_get(ob, view_layer, &color_p); copy_v4_v4(instdata.color, color_p); - normalize_m4_m4(instdata.mat, ob->object_to_world().ptr()); + normalize_m4_m4(instdata.mat, ob->object_to_world); /* BKE_camera_multiview_model_matrix already accounts for scale, don't do it here. */ if (is_selection_camera_stereo) { @@ -1161,9 +1159,9 @@ void OVERLAY_camera_cache_populate(OVERLAY_Data *vedata, Object *ob) } else { copy_v3_fl3(scale, - len_v3(ob->object_to_world().ptr()[0]), - len_v3(ob->object_to_world().ptr()[1]), - len_v3(ob->object_to_world().ptr()[2])); + len_v3(ob->object_to_world[0]), + len_v3(ob->object_to_world[1]), + len_v3(ob->object_to_world[2])); /* Avoid division by 0. */ if (ELEM(0.0f, scale[0], scale[1], scale[2])) { return; @@ -1279,7 +1277,7 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, if (ob->parent && (DRW_object_visibility_in_active_context(ob->parent) & OB_VISIBLE_SELF)) { float *parent_pos = ob->runtime->parent_display_origin; - OVERLAY_extra_line_dashed(cb, parent_pos, ob->object_to_world().location(), relation_color); + OVERLAY_extra_line_dashed(cb, parent_pos, ob->object_to_world[3], relation_color); } /* Drawing the hook lines. */ @@ -1287,10 +1285,9 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, if (md->type == eModifierType_Hook) { HookModifierData *hmd = (HookModifierData *)md; float center[3]; - mul_v3_m4v3(center, ob->object_to_world().ptr(), hmd->cent); + mul_v3_m4v3(center, ob->object_to_world, hmd->cent); if (hmd->object) { - OVERLAY_extra_line_dashed( - cb, hmd->object->object_to_world().location(), center, relation_color); + OVERLAY_extra_line_dashed(cb, hmd->object->object_to_world[3], center, relation_color); } OVERLAY_extra_point(cb, center, relation_color); } @@ -1299,10 +1296,9 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, if (md->type == eGpencilModifierType_Hook) { HookGpencilModifierData *hmd = (HookGpencilModifierData *)md; float center[3]; - mul_v3_m4v3(center, ob->object_to_world().ptr(), hmd->cent); + mul_v3_m4v3(center, ob->object_to_world, hmd->cent); if (hmd->object) { - OVERLAY_extra_line_dashed( - cb, hmd->object->object_to_world().location(), center, relation_color); + OVERLAY_extra_line_dashed(cb, hmd->object->object_to_world[3], center, relation_color); } OVERLAY_extra_point(cb, center, relation_color); } @@ -1312,16 +1308,12 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, Object *rbc_ob1 = ob->rigidbody_constraint->ob1; Object *rbc_ob2 = ob->rigidbody_constraint->ob2; if (rbc_ob1 && (DRW_object_visibility_in_active_context(rbc_ob1) & OB_VISIBLE_SELF)) { - OVERLAY_extra_line_dashed(cb, - rbc_ob1->object_to_world().location(), - ob->object_to_world().location(), - relation_color); + OVERLAY_extra_line_dashed( + cb, rbc_ob1->object_to_world[3], ob->object_to_world[3], relation_color); } if (rbc_ob2 && (DRW_object_visibility_in_active_context(rbc_ob2) & OB_VISIBLE_SELF)) { - OVERLAY_extra_line_dashed(cb, - rbc_ob2->object_to_world().location(), - ob->object_to_world().location(), - relation_color); + OVERLAY_extra_line_dashed( + cb, rbc_ob2->object_to_world[3], ob->object_to_world[3], relation_color); } } @@ -1348,10 +1340,8 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, } if (camob) { - OVERLAY_extra_line_dashed(cb, - camob->object_to_world().location(), - ob->object_to_world().location(), - constraint_color); + OVERLAY_extra_line_dashed( + cb, camob->object_to_world[3], ob->object_to_world[3], constraint_color); } } else { @@ -1372,8 +1362,7 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, else { unit_m4(ct->matrix); } - OVERLAY_extra_line_dashed( - cb, ct->matrix[3], ob->object_to_world().location(), constraint_color); + OVERLAY_extra_line_dashed(cb, ct->matrix[3], ob->object_to_world[3], constraint_color); } BKE_constraint_targets_flush(curcon, &targets, true); @@ -1430,7 +1419,7 @@ static void OVERLAY_volume_extra(OVERLAY_ExtraCallBuffers *cb, copy_v3_v3(voxel_cubemat[3], min); /* move small cube into the domain (otherwise its centered on vertex of domain object) */ translate_m4(voxel_cubemat, 1.0f, 1.0f, 1.0f); - mul_m4_m4m4(voxel_cubemat, ob->object_to_world().ptr(), voxel_cubemat); + mul_m4_m4m4(voxel_cubemat, ob->object_to_world, voxel_cubemat); DRW_buffer_add_entry(cb->empty_cube, color, voxel_cubemat); } @@ -1536,15 +1525,15 @@ static void OVERLAY_object_center(OVERLAY_ExtraCallBuffers *cb, const bool is_library = ID_REAL_USERS(&ob->id) > 1 || ID_IS_LINKED(ob); BKE_view_layer_synced_ensure(scene, view_layer); if (ob == BKE_view_layer_active_object_get(view_layer)) { - DRW_buffer_add_entry(cb->center_active, ob->object_to_world().location()); + DRW_buffer_add_entry(cb->center_active, ob->object_to_world[3]); } else if (ob->base_flag & BASE_SELECTED) { DRWCallBuffer *cbuf = (is_library) ? cb->center_selected_lib : cb->center_selected; - DRW_buffer_add_entry(cbuf, ob->object_to_world().location()); + DRW_buffer_add_entry(cbuf, ob->object_to_world[3]); } else if (pd->v3d_flag & V3D_DRAW_CENTERS) { DRWCallBuffer *cbuf = (is_library) ? cb->center_deselected_lib : cb->center_deselected; - DRW_buffer_add_entry(cbuf, ob->object_to_world().location()); + DRW_buffer_add_entry(cbuf, ob->object_to_world[3]); } } @@ -1556,7 +1545,7 @@ static void OVERLAY_object_name(Object *ob, int theme_id) UI_GetThemeColor4ubv(theme_id, color); DRW_text_cache_add(dt, - ob->object_to_world().location(), + ob->object_to_world[3], ob->id.name + 2, strlen(ob->id.name + 2), 10, @@ -1615,7 +1604,7 @@ void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, Object *ob) /* Helpers for when we're transforming origins. */ if (draw_xform) { const float color_xform[4] = {0.15f, 0.15f, 0.15f, 0.7f}; - DRW_buffer_add_entry(cb->origin_xform, color_xform, ob->object_to_world().ptr()); + DRW_buffer_add_entry(cb->origin_xform, color_xform, ob->object_to_world); } /* don't show object extras in set's */ if (!from_dupli) { @@ -1635,7 +1624,7 @@ void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, Object *ob) OVERLAY_collision(cb, ob, color); } if (ob->dtx & OB_AXIS) { - DRW_buffer_add_entry(cb->empty_axes, color, ob->object_to_world().ptr()); + DRW_buffer_add_entry(cb->empty_axes, color, ob->object_to_world); } if (draw_volume) { OVERLAY_volume_extra(cb, vedata, ob, md, scene, color); diff --git a/source/blender/draw/engines/overlay/overlay_gpencil_legacy.cc b/source/blender/draw/engines/overlay/overlay_gpencil_legacy.cc index d18c8731564..745b759285e 100644 --- a/source/blender/draw/engines/overlay/overlay_gpencil_legacy.cc +++ b/source/blender/draw/engines/overlay/overlay_gpencil_legacy.cc @@ -246,7 +246,7 @@ void OVERLAY_gpencil_legacy_cache_init(OVERLAY_Data *vedata) copy_v3_v3(col_grid, gpd->grid.color); col_grid[3] = max_ff(v3d->overlay.gpencil_grid_opacity, 0.01f); - copy_m4_m4(mat, ob->object_to_world().ptr()); + copy_m4_m4(mat, ob->object_to_world); /* Rotate and scale except align to cursor. */ bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd); @@ -289,7 +289,7 @@ void OVERLAY_gpencil_legacy_cache_init(OVERLAY_Data *vedata) copy_v3_v3(mat[3], cursor->location); } else if (ts->gpencil_v3d_align & GP_PROJECT_VIEWSPACE) { - copy_v3_v3(mat[3], ob->object_to_world().location()); + copy_v3_v3(mat[3], ob->object_to_world[3]); } translate_m4(mat, gpd->grid.offset[0], gpd->grid.offset[1], 0.0f); @@ -401,7 +401,7 @@ static void overlay_gpencil_draw_stroke_color_name(bGPDlayer * /*gpl*/, UI_GetThemeColor4ubv(theme_id, color); float fpt[3]; - mul_v3_m4v3(fpt, ob->object_to_world().ptr(), &pt->x); + mul_v3_m4v3(fpt, ob->object_to_world, &pt->x); DRWTextStore *dt = DRW_text_cache_ensure(); DRW_text_cache_add(dt, diff --git a/source/blender/draw/engines/overlay/overlay_image.cc b/source/blender/draw/engines/overlay/overlay_image.cc index bc00980ebf7..60d14bdbb10 100644 --- a/source/blender/draw/engines/overlay/overlay_image.cc +++ b/source/blender/draw/engines/overlay/overlay_image.cc @@ -386,7 +386,7 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob) float image_aspect[2]; overlay_image_calc_aspect(ima, size, image_aspect); - copy_m4_m4(mat, ob->object_to_world().ptr()); + copy_m4_m4(mat, ob->object_to_world); mul_v3_fl(mat[0], image_aspect[0] * 0.5f * ob->empty_drawsize); mul_v3_fl(mat[1], image_aspect[1] * 0.5f * ob->empty_drawsize); madd_v3_v3fl(mat[3], mat[0], ob->ima_ofs[0] * 2.0f + 1.0f); diff --git a/source/blender/draw/engines/overlay/overlay_lattice.cc b/source/blender/draw/engines/overlay/overlay_lattice.cc index c9c70cc20c2..7359bf9a955 100644 --- a/source/blender/draw/engines/overlay/overlay_lattice.cc +++ b/source/blender/draw/engines/overlay/overlay_lattice.cc @@ -53,7 +53,7 @@ void OVERLAY_lattice_cache_populate(OVERLAY_Data *vedata, Object *ob) DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color); GPUBatch *geom = DRW_cache_lattice_wire_get(ob, false); - OVERLAY_extra_wire(cb, geom, ob->object_to_world().ptr(), color); + OVERLAY_extra_wire(cb, geom, ob->object_to_world, color); } void OVERLAY_edit_lattice_draw(OVERLAY_Data *vedata) diff --git a/source/blender/draw/engines/overlay/overlay_metaball.cc b/source/blender/draw/engines/overlay/overlay_metaball.cc index bc6c5b64ce2..56ce3d5ec05 100644 --- a/source/blender/draw/engines/overlay/overlay_metaball.cc +++ b/source/blender/draw/engines/overlay/overlay_metaball.cc @@ -47,10 +47,10 @@ static void metaball_instance_data_set( BoneInstanceData *data, Object *ob, const float *pos, const float radius, const float color[4]) { /* Bone point radius is 0.05. Compensate for that. */ - mul_v3_v3fl(data->mat[0], ob->object_to_world().ptr()[0], radius / 0.05f); - mul_v3_v3fl(data->mat[1], ob->object_to_world().ptr()[1], radius / 0.05f); - mul_v3_v3fl(data->mat[2], ob->object_to_world().ptr()[2], radius / 0.05f); - mul_v3_m4v3(data->mat[3], ob->object_to_world().ptr(), pos); + mul_v3_v3fl(data->mat[0], ob->object_to_world[0], radius / 0.05f); + mul_v3_v3fl(data->mat[1], ob->object_to_world[1], radius / 0.05f); + mul_v3_v3fl(data->mat[2], ob->object_to_world[2], radius / 0.05f); + mul_v3_m4v3(data->mat[3], ob->object_to_world, pos); /* WATCH: Reminder, alpha is wire-size. */ OVERLAY_bone_instance_data_set_color(data, color); } diff --git a/source/blender/draw/engines/overlay/overlay_mode_transfer.cc b/source/blender/draw/engines/overlay/overlay_mode_transfer.cc index b8a38465892..710a19389d4 100644 --- a/source/blender/draw/engines/overlay/overlay_mode_transfer.cc +++ b/source/blender/draw/engines/overlay/overlay_mode_transfer.cc @@ -25,7 +25,7 @@ void OVERLAY_mode_transfer_cache_init(OVERLAY_Data *vedata) OVERLAY_PassList *psl = vedata->psl; OVERLAY_PrivateData *pd = vedata->stl->pd; - pd->mode_transfer.time = BLI_time_now_seconds(); + pd->mode_transfer.time = BLI_check_seconds_timer(); for (int i = 0; i < 2; i++) { /* Non Meshes Pass (Camera, empties, lights ...) */ diff --git a/source/blender/draw/engines/overlay/overlay_motion_path.cc b/source/blender/draw/engines/overlay/overlay_motion_path.cc index 62ae88800eb..0968d76bac5 100644 --- a/source/blender/draw/engines/overlay/overlay_motion_path.cc +++ b/source/blender/draw/engines/overlay/overlay_motion_path.cc @@ -150,7 +150,7 @@ static void motion_path_cache(OVERLAY_Data *vedata, Object *motion_path_camera = get_camera_for_motion_path( draw_ctx, eMotionPath_BakeFlag(avs->path_bakeflag)); if (motion_path_camera) { - copy_m4_m4(camera_matrix, motion_path_camera->object_to_world().ptr()); + copy_m4_m4(camera_matrix, motion_path_camera->object_to_world); } else { unit_m4(camera_matrix); @@ -205,8 +205,9 @@ static void motion_path_cache(OVERLAY_Data *vedata, float3 vert_coordinate; copy_v3_v3(vert_coordinate, mpv->co); if (cam_eval) { - /* Projecting the point into world space from the camera's POV. */ - vert_coordinate = math::transform_point(cam_eval->object_to_world(), vert_coordinate); + /* Projecting the point into world space from the cameras pov. */ + vert_coordinate = math::transform_point(float4x4(cam_eval->object_to_world), + vert_coordinate); } if ((show_keyframes && show_keyframes_no && is_keyframe) || (show_frame_no && (i == 0))) { diff --git a/source/blender/draw/engines/overlay/overlay_next_empty.hh b/source/blender/draw/engines/overlay/overlay_next_empty.hh index ab9f42c8d76..b97ba0025e2 100644 --- a/source/blender/draw/engines/overlay/overlay_next_empty.hh +++ b/source/blender/draw/engines/overlay/overlay_next_empty.hh @@ -55,7 +55,8 @@ class Empties { CallBuffers &call_bufs = call_buffers_[int((ob_ref.object->dtx & OB_DRAW_IN_FRONT) != 0)]; float4 color = res.object_wire_color(ob_ref, state); - ExtraInstanceData data(ob_ref.object->object_to_world(), color, ob_ref.object->empty_drawsize); + ExtraInstanceData data( + float4x4(ob_ref.object->object_to_world), color, ob_ref.object->empty_drawsize); const select::ID select_id = res.select_id(ob_ref); diff --git a/source/blender/draw/engines/overlay/overlay_next_engine.cc b/source/blender/draw/engines/overlay/overlay_next_engine.cc index 1e5325b1b43..9ac1c80bdc0 100644 --- a/source/blender/draw/engines/overlay/overlay_next_engine.cc +++ b/source/blender/draw/engines/overlay/overlay_next_engine.cc @@ -17,7 +17,7 @@ #include "UI_interface.hh" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_object.hh" #include "BKE_paint.hh" diff --git a/source/blender/draw/engines/overlay/overlay_next_instance.cc b/source/blender/draw/engines/overlay/overlay_next_instance.cc index e991978b352..ceefef9cb95 100644 --- a/source/blender/draw/engines/overlay/overlay_next_instance.cc +++ b/source/blender/draw/engines/overlay/overlay_next_instance.cc @@ -269,10 +269,10 @@ BoneInstanceData::BoneInstanceData(Object *ob, const float color[4]) { /* TODO(fclem): Use C++ math API. */ - mul_v3_v3fl(this->mat[0], ob->object_to_world().ptr()[0], radius); - mul_v3_v3fl(this->mat[1], ob->object_to_world().ptr()[1], radius); - mul_v3_v3fl(this->mat[2], ob->object_to_world().ptr()[2], radius); - mul_v3_m4v3(this->mat[3], ob->object_to_world().ptr(), pos); + mul_v3_v3fl(this->mat[0], ob->object_to_world[0], radius); + mul_v3_v3fl(this->mat[1], ob->object_to_world[1], radius); + mul_v3_v3fl(this->mat[2], ob->object_to_world[2], radius); + mul_v3_m4v3(this->mat[3], ob->object_to_world, pos); /* WATCH: Reminder, alpha is wire-size. */ OVERLAY_bone_instance_data_set_color(this, color); } diff --git a/source/blender/draw/engines/overlay/overlay_outline.cc b/source/blender/draw/engines/overlay/overlay_outline.cc index ca7be6f6ff6..4e411dc8c76 100644 --- a/source/blender/draw/engines/overlay/overlay_outline.cc +++ b/source/blender/draw/engines/overlay/overlay_outline.cc @@ -10,7 +10,7 @@ #include "DRW_render.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_legacy.h" #include "BKE_object.hh" @@ -48,7 +48,7 @@ static void gpencil_depth_plane(Object *ob, float r_plane[4]) add_v3_fl(size, 1e-8f); rescale_m4(mat, size); /* BBox space to World. */ - mul_m4_m4m4(mat, ob->object_to_world().ptr(), mat); + mul_m4_m4m4(mat, ob->object_to_world, mat); /* BBox center in world space. */ copy_v3_v3(center, mat[3]); /* View Vector. */ @@ -194,7 +194,7 @@ static void gpencil_layer_cache_populate(bGPDlayer *gpl, const bool is_screenspace = (gpd->flag & GP_DATA_STROKE_KEEPTHICKNESS) != 0; const bool is_stroke_order_3d = (gpd->draw_mode == GP_DRAWMODE_3D); - float object_scale = mat4_to_scale(iter->ob->object_to_world().ptr()); + float object_scale = mat4_to_scale(iter->ob->object_to_world); /* Negate thickness sign to tag that strokes are in screen space. * Convert to world units (by default, 1 meter = 2000 pixels). */ float thickness_scale = (is_screenspace) ? -1.0f : (gpd->pixfactor / 2000.0f); diff --git a/source/blender/draw/engines/overlay/overlay_paint.cc b/source/blender/draw/engines/overlay/overlay_paint.cc index eb9fed3562e..da5168862ca 100644 --- a/source/blender/draw/engines/overlay/overlay_paint.cc +++ b/source/blender/draw/engines/overlay/overlay_paint.cc @@ -249,16 +249,7 @@ void OVERLAY_paint_vertex_cache_populate(OVERLAY_Data *vedata, Object *ob) void OVERLAY_paint_weight_cache_populate(OVERLAY_Data *vedata, Object *ob) { - switch (ob->type) { - case OB_MESH: - OVERLAY_paint_vertex_cache_populate(vedata, ob); - break; - case OB_GREASE_PENCIL: - /* TODO */ - break; - default: - BLI_assert_unreachable(); - } + OVERLAY_paint_vertex_cache_populate(vedata, ob); } void OVERLAY_paint_draw(OVERLAY_Data *vedata) diff --git a/source/blender/draw/engines/overlay/overlay_private.hh b/source/blender/draw/engines/overlay/overlay_private.hh index 24d6abe8c66..e528b779211 100644 --- a/source/blender/draw/engines/overlay/overlay_private.hh +++ b/source/blender/draw/engines/overlay/overlay_private.hh @@ -8,7 +8,7 @@ #pragma once -#include "BKE_global.hh" +#include "BKE_global.h" #include "DRW_gpu_wrapper.hh" #include "DRW_render.hh" diff --git a/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc b/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc index 46be7fe5a4e..37d80f3a173 100644 --- a/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc +++ b/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc @@ -18,7 +18,7 @@ #include "BKE_attribute.hh" #include "BKE_curves.hh" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_geometry_set.hh" #include "draw_cache_extract.hh" @@ -92,7 +92,7 @@ static void populate_cache_for_instance(Object &object, DRWShadingGroup *sub_grp = DRW_shgroup_create_sub(pd.viewer_attribute_instance_grp); DRW_shgroup_uniform_vec4_copy(sub_grp, "ucolor", color); GPUBatch *batch = DRW_cache_curve_edge_wire_get(&object); - DRW_shgroup_call_obmat(sub_grp, batch, object.object_to_world().ptr()); + DRW_shgroup_call_obmat(sub_grp, batch, object.object_to_world); break; } case OB_CURVES: { @@ -139,8 +139,7 @@ static void populate_cache_for_geometry(Object &object, if (curves.attributes().contains(".viewer")) { GPUBatch *batch = DRW_cache_curve_edge_wire_viewer_attribute_get(&object); DRW_shgroup_uniform_float_copy(pd.viewer_attribute_curve_grp, "opacity", opacity); - DRW_shgroup_call_obmat( - pd.viewer_attribute_curve_grp, batch, object.object_to_world().ptr()); + DRW_shgroup_call_obmat(pd.viewer_attribute_curve_grp, batch, object.object_to_world); } } break; diff --git a/source/blender/draw/engines/overlay/overlay_viewer_text.cc b/source/blender/draw/engines/overlay/overlay_viewer_text.cc index 633fb8bf7bc..8e56d309c5f 100644 --- a/source/blender/draw/engines/overlay/overlay_viewer_text.cc +++ b/source/blender/draw/engines/overlay/overlay_viewer_text.cc @@ -12,7 +12,7 @@ #include "BKE_attribute.hh" #include "BKE_curves.hh" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_geometry_set.hh" #include "BKE_instances.hh" #include "BKE_mesh.hh" @@ -122,7 +122,7 @@ void OVERLAY_viewer_attribute_text(const Object &object) { using namespace blender; using namespace blender::draw::overlay; - const float4x4 &object_to_world = object.object_to_world(); + const float4x4 object_to_world = float4x4(object.object_to_world); DupliObject *dupli_object = DRW_object_get_dupli(&object); if (dupli_object->preview_instance_index >= 0) { diff --git a/source/blender/draw/engines/overlay/overlay_wireframe.cc b/source/blender/draw/engines/overlay/overlay_wireframe.cc index e77e319bb99..68198091baf 100644 --- a/source/blender/draw/engines/overlay/overlay_wireframe.cc +++ b/source/blender/draw/engines/overlay/overlay_wireframe.cc @@ -14,9 +14,9 @@ #include "BKE_curve.hh" #include "BKE_displist.h" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_editmesh.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_object.hh" #include "BKE_paint.hh" #include "BKE_particle.h" @@ -141,12 +141,12 @@ static void wireframe_hair_cache_populate(OVERLAY_Data *vedata, Object *ob, Part if (collection != nullptr) { sub_v3_v3(dupli_mat[3], collection->instance_offset); } - mul_m4_m4m4(dupli_mat, dupli_parent->object_to_world().ptr(), dupli_mat); + mul_m4_m4m4(dupli_mat, dupli_parent->object_to_world, dupli_mat); } else { - copy_m4_m4(dupli_mat, dupli_object->ob->object_to_world().ptr()); + copy_m4_m4(dupli_mat, dupli_object->ob->object_to_world); invert_m4(dupli_mat); - mul_m4_m4m4(dupli_mat, ob->object_to_world().ptr(), dupli_mat); + mul_m4_m4m4(dupli_mat, ob->object_to_world, dupli_mat); } } else { @@ -227,7 +227,7 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, } if (geom) { - OVERLAY_extra_wire(cb, geom, ob->object_to_world().ptr(), color); + OVERLAY_extra_wire(cb, geom, ob->object_to_world, color); } } @@ -240,12 +240,12 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, if (dupli->wire_shgrp == cb->extra_loose_points) { float *color; DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color); - OVERLAY_extra_loose_points(cb, dupli->wire_geom, ob->object_to_world().ptr(), color); + OVERLAY_extra_loose_points(cb, dupli->wire_geom, ob->object_to_world, color); } else if (dupli->wire_shgrp == cb->extra_wire) { float *color; DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color); - OVERLAY_extra_wire(cb, dupli->wire_geom, ob->object_to_world().ptr(), color); + OVERLAY_extra_wire(cb, dupli->wire_geom, ob->object_to_world, color); } else { DRW_shgroup_call(dupli->wire_shgrp, dupli->wire_geom, ob); @@ -274,7 +274,7 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, GPUBatch *geom = DRW_cache_object_face_wireframe_get(ob); if (geom) { - OVERLAY_extra_loose_points(cb, geom, ob->object_to_world().ptr(), color); + OVERLAY_extra_loose_points(cb, geom, ob->object_to_world, color); } return; } @@ -328,14 +328,14 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, if (is_mesh_verts_only) { geom = DRW_cache_mesh_all_verts_get(ob); if (geom) { - OVERLAY_extra_loose_points(cb, geom, ob->object_to_world().ptr(), color); + OVERLAY_extra_loose_points(cb, geom, ob->object_to_world, color); shgrp = cb->extra_loose_points; } } else { geom = DRW_cache_mesh_loose_edges_get(ob); if (geom) { - OVERLAY_extra_wire(cb, geom, ob->object_to_world().ptr(), color); + OVERLAY_extra_wire(cb, geom, ob->object_to_world, color); shgrp = cb->extra_wire; } } diff --git a/source/blender/draw/engines/select/select_engine.cc b/source/blender/draw/engines/select/select_engine.cc index 3a3900f8c88..ce497a7fa92 100644 --- a/source/blender/draw/engines/select/select_engine.cc +++ b/source/blender/draw/engines/select/select_engine.cc @@ -217,7 +217,7 @@ static void select_cache_populate(void *vedata, Object *ob) /* This object is not in the array. It is here to participate in the depth buffer. */ if (ob->dt >= OB_SOLID) { GPUBatch *geom_faces = DRW_mesh_batch_cache_get_surface(static_cast(ob->data)); - DRW_shgroup_call_obmat(stl->g_data->shgrp_occlude, geom_faces, ob->object_to_world().ptr()); + DRW_shgroup_call_obmat(stl->g_data->shgrp_occlude, geom_faces, ob->object_to_world); } } else if (!sel_data->in_pass) { diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc index 7650cafd02c..c8e01c58261 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc @@ -111,6 +111,12 @@ static void setup_taa_weights(const float2 offset, float r_weights[9], float &r_ AntiAliasingPass::AntiAliasingPass() { + taa_accumulation_sh_ = GPU_shader_create_from_info_name("workbench_taa"); + smaa_edge_detect_sh_ = GPU_shader_create_from_info_name("workbench_smaa_stage_0"); + smaa_aa_weight_sh_ = GPU_shader_create_from_info_name("workbench_smaa_stage_1"); + smaa_resolve_sh_ = GPU_shader_create_from_info_name("workbench_smaa_stage_2"); + overlay_depth_sh_ = GPU_shader_create_from_info_name("workbench_overlay_depth"); + smaa_search_tx_.ensure_2d( GPU_R8, {SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT}, GPU_TEXTURE_USAGE_SHADER_READ); GPU_texture_update(smaa_search_tx_, GPU_DATA_UBYTE, searchTexBytes); @@ -121,6 +127,15 @@ AntiAliasingPass::AntiAliasingPass() GPU_texture_filter_mode(smaa_area_tx_, true); } +AntiAliasingPass::~AntiAliasingPass() +{ + DRW_SHADER_FREE_SAFE(taa_accumulation_sh_); + DRW_SHADER_FREE_SAFE(smaa_edge_detect_sh_); + DRW_SHADER_FREE_SAFE(smaa_aa_weight_sh_); + DRW_SHADER_FREE_SAFE(smaa_resolve_sh_); + DRW_SHADER_FREE_SAFE(overlay_depth_sh_); +} + void AntiAliasingPass::init(const SceneState &scene_state) { enabled_ = scene_state.draw_aa; @@ -132,7 +147,7 @@ void AntiAliasingPass::sync(const SceneState &scene_state, SceneResources &resou overlay_depth_ps_.state_set(DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS | DRW_STATE_STENCIL_EQUAL); overlay_depth_ps_.state_stencil(0x00, 0xFF, uint8_t(StencilBits::OBJECT_IN_FRONT)); - overlay_depth_ps_.shader_set(ShaderCache::get().overlay_depth.get()); + overlay_depth_ps_.shader_set(overlay_depth_sh_); overlay_depth_ps_.draw_procedural(GPU_PRIM_TRIS, 1, 3); if (!enabled_) { @@ -156,14 +171,14 @@ void AntiAliasingPass::sync(const SceneState &scene_state, SceneResources &resou taa_accumulation_ps_.state_set(scene_state.sample == 0 ? DRW_STATE_WRITE_COLOR : DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ADD_FULL); - taa_accumulation_ps_.shader_set(ShaderCache::get().taa_accumulation.get()); + taa_accumulation_ps_.shader_set(taa_accumulation_sh_); taa_accumulation_ps_.bind_texture("colorBuffer", &resources.color_tx); taa_accumulation_ps_.push_constant("samplesWeights", weights_, 9); taa_accumulation_ps_.draw_procedural(GPU_PRIM_TRIS, 1, 3); smaa_edge_detect_ps_.init(); smaa_edge_detect_ps_.state_set(DRW_STATE_WRITE_COLOR); - smaa_edge_detect_ps_.shader_set(ShaderCache::get().smaa_edge_detect.get()); + smaa_edge_detect_ps_.shader_set(smaa_edge_detect_sh_); smaa_edge_detect_ps_.bind_texture("colorTex", &taa_accumulation_tx_); smaa_edge_detect_ps_.push_constant("viewportMetrics", &smaa_viewport_metrics_, 1); smaa_edge_detect_ps_.clear_color(float4(0.0f)); @@ -171,7 +186,7 @@ void AntiAliasingPass::sync(const SceneState &scene_state, SceneResources &resou smaa_aa_weight_ps_.init(); smaa_aa_weight_ps_.state_set(DRW_STATE_WRITE_COLOR); - smaa_aa_weight_ps_.shader_set(ShaderCache::get().smaa_aa_weight.get()); + smaa_aa_weight_ps_.shader_set(smaa_aa_weight_sh_); smaa_aa_weight_ps_.bind_texture("edgesTex", &smaa_edge_tx_); smaa_aa_weight_ps_.bind_texture("areaTex", smaa_area_tx_); smaa_aa_weight_ps_.bind_texture("searchTex", smaa_search_tx_); @@ -181,7 +196,7 @@ void AntiAliasingPass::sync(const SceneState &scene_state, SceneResources &resou smaa_resolve_ps_.init(); smaa_resolve_ps_.state_set(DRW_STATE_WRITE_COLOR); - smaa_resolve_ps_.shader_set(ShaderCache::get().smaa_resolve.get()); + smaa_resolve_ps_.shader_set(smaa_resolve_sh_); smaa_resolve_ps_.bind_texture("blendTex", &smaa_weight_tx_); smaa_resolve_ps_.bind_texture("colorTex", &taa_accumulation_tx_); smaa_resolve_ps_.push_constant("viewportMetrics", &smaa_viewport_metrics_, 1); diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc b/source/blender/draw/engines/workbench/workbench_effect_dof.cc index f1c51fdd915..d0960e02c91 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc @@ -55,6 +55,15 @@ static void square_to_circle(float x, float y, float &r, float &T) } } +DofPass::~DofPass() +{ + DRW_SHADER_FREE_SAFE(prepare_sh_); + DRW_SHADER_FREE_SAFE(downsample_sh_); + DRW_SHADER_FREE_SAFE(blur1_sh_); + DRW_SHADER_FREE_SAFE(blur2_sh_); + DRW_SHADER_FREE_SAFE(resolve_sh_); +} + void DofPass::setup_samples() { float4 *sample = samples_buf_.begin(); @@ -102,6 +111,14 @@ void DofPass::init(const SceneState &scene_state) return; } + if (prepare_sh_ == nullptr) { + prepare_sh_ = GPU_shader_create_from_info_name("workbench_effect_dof_prepare"); + downsample_sh_ = GPU_shader_create_from_info_name("workbench_effect_dof_downsample"); + blur1_sh_ = GPU_shader_create_from_info_name("workbench_effect_dof_blur1"); + blur2_sh_ = GPU_shader_create_from_info_name("workbench_effect_dof_blur2"); + resolve_sh_ = GPU_shader_create_from_info_name("workbench_effect_dof_resolve"); + } + offset_ = scene_state.sample / float(scene_state.samples_len); int2 half_res = scene_state.resolution / 2; @@ -163,7 +180,7 @@ void DofPass::sync(SceneResources &resources) down_ps_.init(); down_ps_.state_set(DRW_STATE_WRITE_COLOR); - down_ps_.shader_set(ShaderCache::get().dof_prepare.get()); + down_ps_.shader_set(prepare_sh_); down_ps_.bind_texture("sceneColorTex", &resources.color_tx); down_ps_.bind_texture("sceneDepthTex", &resources.depth_tx); down_ps_.push_constant("invertedViewportSize", float2(DRW_viewport_invert_size_get())); @@ -173,14 +190,14 @@ void DofPass::sync(SceneResources &resources) down2_ps_.init(); down2_ps_.state_set(DRW_STATE_WRITE_COLOR); - down2_ps_.shader_set(ShaderCache::get().dof_downsample.get()); + down2_ps_.shader_set(downsample_sh_); down2_ps_.bind_texture("sceneColorTex", &source_tx_, sampler_state); down2_ps_.bind_texture("inputCocTex", &coc_halfres_tx_, sampler_state); down2_ps_.draw_procedural(GPU_PRIM_TRIS, 1, 3); blur_ps_.init(); blur_ps_.state_set(DRW_STATE_WRITE_COLOR); - blur_ps_.shader_set(ShaderCache::get().dof_blur1.get()); + blur_ps_.shader_set(blur1_sh_); blur_ps_.bind_ubo("samples", samples_buf_); blur_ps_.bind_texture("noiseTex", resources.jitter_tx); blur_ps_.bind_texture("inputCocTex", &coc_halfres_tx_, sampler_state); @@ -191,7 +208,7 @@ void DofPass::sync(SceneResources &resources) blur2_ps_.init(); blur2_ps_.state_set(DRW_STATE_WRITE_COLOR); - blur2_ps_.shader_set(ShaderCache::get().dof_blur2.get()); + blur2_ps_.shader_set(blur2_sh_); blur2_ps_.bind_texture("inputCocTex", &coc_halfres_tx_, sampler_state); blur2_ps_.bind_texture("blurTex", &blur_tx_); blur2_ps_.push_constant("invertedViewportSize", float2(DRW_viewport_invert_size_get())); @@ -199,7 +216,7 @@ void DofPass::sync(SceneResources &resources) resolve_ps_.init(); resolve_ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_CUSTOM); - resolve_ps_.shader_set(ShaderCache::get().dof_resolve.get()); + resolve_ps_.shader_set(resolve_sh_); resolve_ps_.bind_texture("halfResColorTex", &source_tx_, sampler_state); resolve_ps_.bind_texture("sceneDepthTex", &resources.depth_tx); resolve_ps_.push_constant("invertedViewportSize", float2(DRW_viewport_invert_size_get())); diff --git a/source/blender/draw/engines/workbench/workbench_effect_outline.cc b/source/blender/draw/engines/workbench/workbench_effect_outline.cc index 16f85513f85..88e70050078 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_outline.cc +++ b/source/blender/draw/engines/workbench/workbench_effect_outline.cc @@ -14,12 +14,21 @@ namespace blender::workbench { +OutlinePass::~OutlinePass() +{ + DRW_SHADER_FREE_SAFE(sh_); +} + void OutlinePass::init(const SceneState &scene_state) { enabled_ = scene_state.draw_outline; if (!enabled_) { return; } + + if (sh_ == nullptr) { + sh_ = GPU_shader_create_from_info_name("workbench_effect_outline"); + } } void OutlinePass::sync(SceneResources &resources) @@ -30,7 +39,7 @@ void OutlinePass::sync(SceneResources &resources) ps_.init(); ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_PREMUL); - ps_.shader_set(ShaderCache::get().outline.get()); + ps_.shader_set(sh_); ps_.bind_ubo("world_data", resources.world_buf); ps_.bind_texture("objectIdBuffer", &resources.object_id_tx); ps_.draw_procedural(GPU_PRIM_TRIS, 1, 3); diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index 016667d7114..2df5e5f0b0b 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -8,7 +8,7 @@ #include "BKE_paint.hh" #include "BKE_particle.h" #include "BKE_pbvh_api.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph_query.hh" #include "DNA_fluid_types.h" #include "ED_paint.hh" @@ -157,7 +157,7 @@ class Instance { if (object_state.sculpt_pbvh) { /* Disable frustum culling for sculpt meshes. */ /* TODO(@pragma37): Implement a cleaner way to disable frustum culling. */ - ResourceHandle handle = manager.resource_handle(ob_ref.object->object_to_world()); + ResourceHandle handle = manager.resource_handle(float4x4(ob_ref.object->object_to_world)); handle = ResourceHandle(handle.resource_index(), ob_ref.object->transflag & OB_NEG_SCALE); sculpt_sync(ob_ref, handle, object_state); emitter_handle = handle; @@ -385,7 +385,7 @@ class Instance { ModifierData *md) { /* Skip frustum culling. */ - ResourceHandle handle = manager.resource_handle(ob_ref.object->object_to_world()); + ResourceHandle handle = manager.resource_handle(float4x4(ob_ref.object->object_to_world)); Material mat = get_material(ob_ref, object_state.color_type, psys->part->omat - 1); ::Image *image = nullptr; @@ -410,7 +410,7 @@ class Instance { void curves_sync(Manager &manager, ObjectRef &ob_ref, const ObjectState &object_state) { /* Skip frustum culling. */ - ResourceHandle handle = manager.resource_handle(ob_ref.object->object_to_world()); + ResourceHandle handle = manager.resource_handle(float4x4(ob_ref.object->object_to_world)); Material mat = get_material(ob_ref, object_state.color_type); resources.material_buf.append(mat); @@ -495,17 +495,13 @@ class Instance { } } - void draw_image_render(Manager &manager, - GPUTexture *depth_tx, - GPUTexture *depth_in_front_tx, - GPUTexture *color_tx, - RenderEngine *engine = nullptr) + void draw_viewport_image_render(Manager &manager, + GPUTexture *depth_tx, + GPUTexture *depth_in_front_tx, + GPUTexture *color_tx) { BLI_assert(scene_state.sample == 0); for (auto i : IndexRange(scene_state.samples_len)) { - if (engine && RE_engine_test_break(engine)) { - break; - } if (i != 0) { scene_state.sample = i; /* Re-sync anything dependent on scene_state.sample. */ @@ -514,12 +510,6 @@ class Instance { anti_aliasing_ps.sync(scene_state, resources); } this->draw(manager, depth_tx, depth_in_front_tx, color_tx); - /* Perform render step between samples to allow - * flushing of freed GPUBackend resources. */ - if (GPU_backend_get_type() == GPU_BACKEND_METAL) { - GPU_flush(); - } - GPU_render_step(); } } }; @@ -581,7 +571,8 @@ static void workbench_draw_scene(void *vedata) DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); draw::Manager *manager = DRW_manager_get(); if (DRW_state_is_viewport_image_render()) { - ved->instance->draw_image_render(*manager, dtxl->depth, dtxl->depth_in_front, dtxl->color); + ved->instance->draw_viewport_image_render( + *manager, dtxl->depth, dtxl->depth_in_front, dtxl->color); } else { ved->instance->draw_viewport(*manager, dtxl->depth, dtxl->depth_in_front, dtxl->color); @@ -593,11 +584,6 @@ static void workbench_instance_free(void *instance) delete reinterpret_cast(instance); } -static void workbench_engine_free() -{ - workbench::ShaderCache::release(); -} - static void workbench_view_update(void *vedata) { WORKBENCH_Data *ved = reinterpret_cast(vedata); @@ -655,6 +641,13 @@ static bool workbench_render_framebuffers_init() GPU_framebuffer_check_valid(dfbl->depth_only_fb, nullptr); } +#ifdef _DEBUG +/* This is just to ease GPU debugging when the frame delimiter is set to Finish */ +# define GPU_FINISH_DELIMITER() GPU_finish() +#else +# define GPU_FINISH_DELIMITER() +#endif + static void write_render_color_output(RenderLayer *layer, const char *viewname, GPUFrameBuffer *fb, @@ -735,7 +728,10 @@ static void workbench_render_to_image(void *vedata, return; } + GPU_FINISH_DELIMITER(); + /* Setup */ + DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); const DRWContextState *draw_ctx = DRW_context_state_get(); Depsgraph *depsgraph = draw_ctx->depsgraph; @@ -755,35 +751,46 @@ static void workbench_render_to_image(void *vedata, viewmat = math::invert(viewinv); /* Render */ - /* TODO: Remove old draw manager calls. */ - DRW_cache_restart(); - DRWView *view = DRW_view_create(viewmat.ptr(), winmat.ptr(), nullptr, nullptr, nullptr); - DRW_view_default_set(view); - DRW_view_set_active(view); + do { + if (RE_engine_test_break(engine)) { + break; + } - ved->instance->init(camera_ob); + /* TODO: Remove old draw manager calls. */ + DRW_cache_restart(); + DRWView *view = DRW_view_create(viewmat.ptr(), winmat.ptr(), nullptr, nullptr, nullptr); + DRW_view_default_set(view); + DRW_view_set_active(view); - draw::Manager &manager = *DRW_manager_get(); - manager.begin_sync(); + ved->instance->init(camera_ob); - workbench_cache_init(vedata); - auto workbench_render_cache = - [](void *vedata, Object *ob, RenderEngine * /*engine*/, Depsgraph * /*depsgraph*/) { - workbench_cache_populate(vedata, ob); - }; - DRW_render_object_iter(vedata, engine, depsgraph, workbench_render_cache); - workbench_cache_finish(vedata); + DRW_manager_get()->begin_sync(); - manager.end_sync(); + workbench_cache_init(vedata); + auto workbench_render_cache = + [](void *vedata, Object *ob, RenderEngine * /*engine*/, Depsgraph * /*depsgraph*/) { + workbench_cache_populate(vedata, ob); + }; + DRW_render_object_iter(vedata, engine, depsgraph, workbench_render_cache); + workbench_cache_finish(vedata); - /* TODO: Remove old draw manager calls. */ - DRW_render_instance_buffer_finish(); - DRW_curves_update(); + DRW_manager_get()->end_sync(); - DefaultTextureList &dtxl = *DRW_viewport_texture_list_get(); - ved->instance->draw_image_render(manager, dtxl.depth, dtxl.depth_in_front, dtxl.color, engine); + /* TODO: Remove old draw manager calls. */ + DRW_render_instance_buffer_finish(); + DRW_curves_update(); + + workbench_draw_scene(vedata); + + /* Perform render step between samples to allow + * flushing of freed GPUBackend resources. */ + if (GPU_backend_get_type() == GPU_BACKEND_METAL) { + GPU_flush(); + } + GPU_render_step(); + GPU_FINISH_DELIMITER(); + } while (ved->instance->scene_state.sample + 1 < ved->instance->scene_state.samples_len); - /* Write image */ const char *viewname = RE_GetActiveRenderView(engine->re); write_render_color_output(layer, viewname, dfbl->default_fb, rect); write_render_z_output(layer, viewname, dfbl->default_fb, rect, winmat); @@ -811,7 +818,7 @@ DrawEngineType draw_engine_workbench = { /*idname*/ N_("Workbench"), /*vedata_size*/ &workbench_data_size, /*engine_init*/ &workbench_engine_init, - /*engine_free*/ &workbench_engine_free, + /*engine_free*/ nullptr, /*instance_free*/ &workbench_instance_free, /*cache_init*/ &workbench_cache_init, /*cache_populate*/ &workbench_cache_populate, diff --git a/source/blender/draw/engines/workbench/workbench_enums.hh b/source/blender/draw/engines/workbench/workbench_enums.hh index 379f3378a58..63ba54b4b3b 100644 --- a/source/blender/draw/engines/workbench/workbench_enums.hh +++ b/source/blender/draw/engines/workbench/workbench_enums.hh @@ -45,8 +45,9 @@ static inline eGeometryType geometry_type_from_object(Object *ob) enum class ePipelineType { OPAQUE = 0, TRANSPARENT, + SHADOW, }; -static constexpr int pipeline_type_len = static_cast(ePipelineType::TRANSPARENT) + 1; +static constexpr int pipeline_type_len = static_cast(ePipelineType::SHADOW) + 1; enum class eLightingType { FLAT = 0, diff --git a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc index 750e491e116..71ce659385a 100644 --- a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc +++ b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc @@ -32,7 +32,10 @@ void MeshPass::init_pass(SceneResources &resources, DRWState state, int clip_pla } } -void MeshPass::init_subpasses(ePipelineType pipeline, eLightingType lighting, bool clip) +void MeshPass::init_subpasses(ePipelineType pipeline, + eLightingType lighting, + bool clip, + ShaderCache &shaders) { texture_subpass_map_.clear(); @@ -46,9 +49,9 @@ void MeshPass::init_subpasses(ePipelineType pipeline, eLightingType lighting, bo pass_names[geom][shader] = std::string(get_name(geom_type)) + std::string(get_name(shader_type)); } + GPUShader *sh = shaders.prepass_shader_get(pipeline, geom_type, shader_type, lighting, clip); PassMain::Sub *pass = &sub(pass_names[geom][shader].c_str()); - pass->shader_set( - ShaderCache::get().prepass_get(geom_type, pipeline, lighting, shader_type, clip)); + pass->shader_set(sh); passes_[geom][shader] = pass; } } @@ -112,20 +115,23 @@ void OpaquePass::sync(const SceneState &scene_state, SceneResources &resources) DRWState in_front_state = state | DRW_STATE_STENCIL_ALWAYS; gbuffer_in_front_ps_.init_pass(resources, in_front_state, scene_state.clip_planes.size()); gbuffer_in_front_ps_.state_stencil(uint8_t(StencilBits::OBJECT_IN_FRONT), 0xFF, 0x00); - gbuffer_in_front_ps_.init_subpasses(ePipelineType::OPAQUE, scene_state.lighting_type, clip); + gbuffer_in_front_ps_.init_subpasses( + ePipelineType::OPAQUE, scene_state.lighting_type, clip, resources.shader_cache); state |= DRW_STATE_STENCIL_NEQUAL; gbuffer_ps_.init_pass(resources, state, scene_state.clip_planes.size()); gbuffer_ps_.state_stencil( uint8_t(StencilBits::OBJECT), 0xFF, uint8_t(StencilBits::OBJECT_IN_FRONT)); - gbuffer_ps_.init_subpasses(ePipelineType::OPAQUE, scene_state.lighting_type, clip); + gbuffer_ps_.init_subpasses( + ePipelineType::OPAQUE, scene_state.lighting_type, clip, resources.shader_cache); deferred_ps_.init(); deferred_ps_.state_set(DRW_STATE_WRITE_COLOR); - deferred_ps_.shader_set(ShaderCache::get().resolve_get(scene_state.lighting_type, - scene_state.draw_cavity, - scene_state.draw_curvature, - scene_state.draw_shadows)); + deferred_ps_.shader_set(resources.shader_cache.resolve_shader_get(ePipelineType::OPAQUE, + scene_state.lighting_type, + scene_state.draw_cavity, + scene_state.draw_curvature, + scene_state.draw_shadows)); deferred_ps_.push_constant("forceShadowing", false); deferred_ps_.bind_ubo(WB_WORLD_SLOT, resources.world_buf); deferred_ps_.bind_texture(WB_MATCAP_SLOT, resources.matcap_tx); @@ -223,6 +229,11 @@ bool OpaquePass::is_empty() const /** \name TransparentPass * \{ */ +TransparentPass::~TransparentPass() +{ + DRW_SHADER_FREE_SAFE(resolve_sh_); +} + void TransparentPass::sync(const SceneState &scene_state, SceneResources &resources) { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_OIT | @@ -235,16 +246,20 @@ void TransparentPass::sync(const SceneState &scene_state, SceneResources &resour accumulation_ps_.state_stencil( uint8_t(StencilBits::OBJECT), 0xFF, uint8_t(StencilBits::OBJECT_IN_FRONT)); accumulation_ps_.clear_color(float4(0.0f, 0.0f, 0.0f, 1.0f)); - accumulation_ps_.init_subpasses(ePipelineType::TRANSPARENT, scene_state.lighting_type, clip); + accumulation_ps_.init_subpasses( + ePipelineType::TRANSPARENT, scene_state.lighting_type, clip, resources.shader_cache); accumulation_in_front_ps_.init_pass(resources, state, scene_state.clip_planes.size()); accumulation_in_front_ps_.clear_color(float4(0.0f, 0.0f, 0.0f, 1.0f)); accumulation_in_front_ps_.init_subpasses( - ePipelineType::TRANSPARENT, scene_state.lighting_type, clip); + ePipelineType::TRANSPARENT, scene_state.lighting_type, clip, resources.shader_cache); + if (resolve_sh_ == nullptr) { + resolve_sh_ = GPU_shader_create_from_info_name("workbench_transparent_resolve"); + } resolve_ps_.init(); resolve_ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA); - resolve_ps_.shader_set(ShaderCache::get().transparent_resolve.get()); + resolve_ps_.shader_set(resolve_sh_); resolve_ps_.bind_texture("transparentAccum", &accumulation_tx); resolve_ps_.bind_texture("transparentRevealage", &reveal_tx); resolve_ps_.draw_procedural(GPU_PRIM_TRIS, 1, 3); @@ -299,6 +314,11 @@ bool TransparentPass::is_empty() const /** \name TransparentDepthPass * \{ */ +TransparentDepthPass::~TransparentDepthPass() +{ + DRW_SHADER_FREE_SAFE(merge_sh_); +} + void TransparentDepthPass::sync(const SceneState &scene_state, SceneResources &resources) { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | @@ -309,10 +329,14 @@ void TransparentDepthPass::sync(const SceneState &scene_state, SceneResources &r DRWState in_front_state = state | DRW_STATE_STENCIL_ALWAYS; in_front_ps_.init_pass(resources, in_front_state, scene_state.clip_planes.size()); in_front_ps_.state_stencil(uint8_t(StencilBits::OBJECT_IN_FRONT), 0xFF, 0x00); - in_front_ps_.init_subpasses(ePipelineType::OPAQUE, eLightingType::FLAT, clip); + in_front_ps_.init_subpasses( + ePipelineType::OPAQUE, eLightingType::FLAT, clip, resources.shader_cache); + if (merge_sh_ == nullptr) { + merge_sh_ = GPU_shader_create_from_info_name("workbench_merge_depth"); + } merge_ps_.init(); - merge_ps_.shader_set(ShaderCache::get().merge_depth.get()); + merge_ps_.shader_set(merge_sh_); merge_ps_.state_set(DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_EQUAL); merge_ps_.state_stencil( @@ -324,7 +348,8 @@ void TransparentDepthPass::sync(const SceneState &scene_state, SceneResources &r main_ps_.init_pass(resources, state, scene_state.clip_planes.size()); main_ps_.state_stencil( uint8_t(StencilBits::OBJECT), 0xFF, uint8_t(StencilBits::OBJECT_IN_FRONT)); - main_ps_.init_subpasses(ePipelineType::OPAQUE, eLightingType::FLAT, clip); + main_ps_.init_subpasses( + ePipelineType::OPAQUE, eLightingType::FLAT, clip, resources.shader_cache); } void TransparentDepthPass::draw(Manager &manager, View &view, SceneResources &resources) diff --git a/source/blender/draw/engines/workbench/workbench_private.hh b/source/blender/draw/engines/workbench/workbench_private.hh index 401a4428f15..732834c459e 100644 --- a/source/blender/draw/engines/workbench/workbench_private.hh +++ b/source/blender/draw/engines/workbench/workbench_private.hh @@ -19,107 +19,28 @@ namespace blender::workbench { using namespace draw; -class StaticShader : NonCopyable { - private: - std::string info_name_; - GPUShader *shader_ = nullptr; - - public: - StaticShader(std::string info_name) : info_name_(info_name) {} - - StaticShader() = default; - StaticShader(StaticShader &&other) = default; - StaticShader &operator=(StaticShader &&other) = default; - - ~StaticShader() - { - DRW_SHADER_FREE_SAFE(shader_); - } - - GPUShader *get() - { - if (!shader_) { - BLI_assert(!info_name_.empty()); - shader_ = GPU_shader_create_from_info_name(info_name_.c_str()); - } - return shader_; - } -}; - class ShaderCache { - private: - static ShaderCache *static_cache; - - StaticShader prepass_[geometry_type_len][pipeline_type_len][lighting_type_len][shader_type_len] - [2 /*clip*/]; - StaticShader resolve_[lighting_type_len][2 /*cavity*/][2 /*curvature*/][2 /*shadow*/]; - - StaticShader shadow_[2 /*depth_pass*/][2 /*manifold*/][2 /*cap*/]; - - StaticShader volume_[2 /*smoke*/][3 /*interpolation*/][2 /*coba*/][2 /*slice*/]; - public: - static ShaderCache &get(); - static void release(); + ~ShaderCache(); - ShaderCache(); + GPUShader *prepass_shader_get(ePipelineType pipeline_type, + eGeometryType geometry_type, + eShaderType shader_type, + eLightingType lighting_type, + bool clip); - GPUShader *prepass_get(eGeometryType geometry_type, - ePipelineType pipeline_type, - eLightingType lighting_type, - eShaderType shader_type, - bool clip) - { - return prepass_[int(geometry_type)][int(pipeline_type)][int(lighting_type)][int(shader_type)] - [clip] - .get(); - } + GPUShader *resolve_shader_get(ePipelineType pipeline_type, + eLightingType lighting_type, + bool cavity = false, + bool curvature = false, + bool shadow = false); - GPUShader *resolve_get(eLightingType lighting_type, - bool cavity = false, - bool curvature = false, - bool shadow = false) - { - return resolve_[int(lighting_type)][cavity][curvature][shadow].get(); - } - - GPUShader *shadow_get(bool depth_pass, bool manifold, bool cap = false) - { - return shadow_[depth_pass][manifold][cap].get(); - } - - GPUShader *volume_get(bool smoke, int interpolation, bool coba, bool slice) - { - return volume_[smoke][interpolation][coba][slice].get(); - } - - StaticShader extract_stencil = {"workbench_extract_stencil"}; - - /* Transparency */ - StaticShader transparent_resolve = {"workbench_transparent_resolve"}; - StaticShader merge_depth = {"workbench_merge_depth"}; - - /* ShadowView */ - StaticShader shadow_visibility_dynamic = { - "workbench_shadow_visibility_compute_dynamic_pass_type"}; - StaticShader shadow_visibility_static = {"workbench_shadow_visibility_compute_static_pass_type"}; - - /* Outline */ - StaticShader outline = {"workbench_effect_outline"}; - - /* Dof */ - StaticShader dof_prepare = {"workbench_effect_dof_prepare"}; - StaticShader dof_downsample = {"workbench_effect_dof_downsample"}; - StaticShader dof_blur1 = {"workbench_effect_dof_blur1"}; - StaticShader dof_blur2 = {"workbench_effect_dof_blur2"}; - StaticShader dof_resolve = {"workbench_effect_dof_resolve"}; - - /* AA */ - StaticShader taa_accumulation = {"workbench_taa"}; - StaticShader smaa_edge_detect = {"workbench_smaa_stage_0"}; - StaticShader smaa_aa_weight = {"workbench_smaa_stage_1"}; - StaticShader smaa_resolve = {"workbench_smaa_stage_2"}; - StaticShader overlay_depth = {"workbench_overlay_depth"}; + private: + /* TODO(fclem): We might want to change to a Map since most shader will never be compiled. */ + GPUShader *prepass_shader_cache_[pipeline_type_len][geometry_type_len][shader_type_len] + [lighting_type_len][2 /*clip*/] = {{{{{nullptr}}}}}; + GPUShader *resolve_shader_cache_[pipeline_type_len][lighting_type_len][2 /*cavity*/] + [2 /*curvature*/][2 /*shadow*/] = {{{{{nullptr}}}}}; }; struct Material { @@ -224,8 +145,18 @@ class CavityEffect { class StencilViewWorkaround { private: Texture stencil_copy_tx_ = "stencil_copy_tx"; + GPUShader *stencil_copy_sh_ = nullptr; public: + StencilViewWorkaround() + { + stencil_copy_sh_ = GPU_shader_create_from_info_name("workbench_extract_stencil"); + } + ~StencilViewWorkaround() + { + DRW_SHADER_FREE_SAFE(stencil_copy_sh_); + } + /** WARNING: Should only be called at render time. * When the workaround path is active, * the returned texture won't stay in sync with the stencil_src, @@ -247,7 +178,7 @@ class StencilViewWorkaround { ps.clear_color(float4(0)); ps.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_STENCIL_NEQUAL); ps.state_stencil(0x00, 0x00, 0xFF); - ps.shader_set(ShaderCache::get().extract_stencil.get()); + ps.shader_set(stencil_copy_sh_); ps.draw_procedural(GPU_PRIM_TRIS, 1, 3); Framebuffer fb; @@ -263,6 +194,8 @@ class StencilViewWorkaround { struct SceneResources { static const int jitter_tx_size = 64; + ShaderCache shader_cache = {}; + StringRefNull current_matcap = {}; Texture matcap_tx = "matcap_tx"; @@ -306,7 +239,10 @@ class MeshPass : public PassMain { bool is_empty() const; void init_pass(SceneResources &resources, DRWState state, int clip_planes); - void init_subpasses(ePipelineType pipeline, eLightingType lighting, bool clip); + void init_subpasses(ePipelineType pipeline, + eLightingType lighting, + bool clip, + ShaderCache &shaders); PassMain::Sub &get_subpass(eGeometryType geometry_type, ::Image *image = nullptr, @@ -347,6 +283,9 @@ class OpaquePass { }; class TransparentPass { + private: + GPUShader *resolve_sh_ = nullptr; + public: TextureFromPool accumulation_tx = {"accumulation_accumulation_tx"}; TextureFromPool reveal_tx = {"accumulation_reveal_tx"}; @@ -357,12 +296,17 @@ class TransparentPass { PassSimple resolve_ps_ = {"Transparent.Resolve"}; Framebuffer resolve_fb = {}; + ~TransparentPass(); + void sync(const SceneState &scene_state, SceneResources &resources); void draw(Manager &manager, View &view, SceneResources &resources, int2 resolution); bool is_empty() const; }; class TransparentDepthPass { + private: + GPUShader *merge_sh_ = nullptr; + public: MeshPass main_ps_ = {"TransparentDepth.Main"}; Framebuffer main_fb = {"TransparentDepth.Main"}; @@ -371,13 +315,13 @@ class TransparentDepthPass { PassSimple merge_ps_ = {"TransparentDepth.Merge"}; Framebuffer merge_fb = {"TransparentDepth.Merge"}; + ~TransparentDepthPass(); + void sync(const SceneState &scene_state, SceneResources &resources); void draw(Manager &manager, View &view, SceneResources &resources); bool is_empty() const; }; -#define DEBUG_SHADOW_VOLUME 0 - class ShadowPass { private: enum PassType { PASS = 0, FAIL, FORCED_FAIL, MAX }; @@ -391,8 +335,12 @@ class ShadowPass { VisibilityBuf pass_visibility_buf_ = {}; VisibilityBuf fail_visibility_buf_ = {}; + GPUShader *dynamic_pass_type_shader_; + GPUShader *static_pass_type_shader_; + public: - ShadowView() : View("ShadowPass.View"){}; + ShadowView(); + ~ShadowView(); void setup(View &view, float3 light_direction, bool force_fail_method); bool debug_object_culling(Object *ob); @@ -420,10 +368,16 @@ class ShadowPass { PassMain::Sub *passes_[PassType::MAX][2][2] = {{{nullptr}}}; PassMain::Sub *&get_pass_ptr(PassType type, bool manifold, bool cap = false); + /* [Is Pass Technique][Is Manifold][Is Cap] */ + GPUShader *shaders_[2][2][2] = {{{nullptr}}}; + GPUShader *get_shader(bool depth_pass, bool manifold, bool cap = false); + TextureFromPool depth_tx_ = {}; Framebuffer fb_ = {}; public: + ~ShadowPass(); + void init(const SceneState &scene_state, SceneResources &resources); void update(); void sync(); @@ -453,7 +407,11 @@ class VolumePass { GPUTexture *stencil_tx_ = nullptr; + GPUShader *shaders_[2 /*slice*/][2 /*coba*/][3 /*interpolation*/][2 /*smoke*/]; + public: + ~VolumePass(); + void sync(SceneResources &resources); void object_sync_volume(Manager &manager, @@ -471,6 +429,8 @@ class VolumePass { void draw(Manager &manager, View &view, SceneResources &resources); private: + GPUShader *get_shader(bool slice, bool coba, int interpolation, bool smoke); + void draw_slice_ps(Manager &manager, PassMain::Sub &ps, ObjectRef &ob_ref, @@ -490,9 +450,12 @@ class OutlinePass { bool enabled_ = false; PassSimple ps_ = PassSimple("Workbench.Outline"); + GPUShader *sh_ = nullptr; Framebuffer fb_ = Framebuffer("Workbench.Outline"); public: + ~OutlinePass(); + void init(const SceneState &scene_state); void sync(SceneResources &resources); void draw(Manager &manager, SceneResources &resources); @@ -518,6 +481,12 @@ class DofPass { Framebuffer blur2_fb_ = {}; Framebuffer resolve_fb_ = {}; + GPUShader *prepare_sh_ = nullptr; + GPUShader *downsample_sh_ = nullptr; + GPUShader *blur1_sh_ = nullptr; + GPUShader *blur2_sh_ = nullptr; + GPUShader *resolve_sh_ = nullptr; + PassSimple down_ps_ = {"Workbench.DoF.DownSample"}; PassSimple down2_ps_ = {"Workbench.DoF.DownSample2"}; PassSimple blur_ps_ = {"Workbench.DoF.Blur"}; @@ -534,6 +503,8 @@ class DofPass { float ratio_ = 0; public: + ~DofPass(); + void init(const SceneState &scene_state); void sync(SceneResources &resources); void draw(Manager &manager, View &view, SceneResources &resources, int2 resolution); @@ -571,6 +542,12 @@ class AntiAliasingPass { float4 smaa_viewport_metrics_ = float4(0); float smaa_mix_factor_ = 0; + GPUShader *taa_accumulation_sh_ = nullptr; + GPUShader *smaa_edge_detect_sh_ = nullptr; + GPUShader *smaa_aa_weight_sh_ = nullptr; + GPUShader *smaa_resolve_sh_ = nullptr; + GPUShader *overlay_depth_sh_ = nullptr; + PassSimple taa_accumulation_ps_ = {"TAA.Accumulation"}; PassSimple smaa_edge_detect_ps_ = {"SMAA.EdgeDetect"}; PassSimple smaa_aa_weight_ps_ = {"SMAA.BlendWeights"}; @@ -579,6 +556,7 @@ class AntiAliasingPass { public: AntiAliasingPass(); + ~AntiAliasingPass(); void init(const SceneState &scene_state); void sync(const SceneState &scene_state, SceneResources &resources); diff --git a/source/blender/draw/engines/workbench/workbench_shader_cache.cc b/source/blender/draw/engines/workbench/workbench_shader_cache.cc index 003e4931339..d814323a2bb 100644 --- a/source/blender/draw/engines/workbench/workbench_shader_cache.cc +++ b/source/blender/draw/engines/workbench/workbench_shader_cache.cc @@ -6,92 +6,132 @@ namespace blender::workbench { -ShaderCache *ShaderCache::static_cache = nullptr; - -ShaderCache &ShaderCache::get() +ShaderCache::~ShaderCache() { - if (!ShaderCache::static_cache) { - ShaderCache::static_cache = new ShaderCache(); - } - return *ShaderCache::static_cache; -} - -void ShaderCache::release() -{ - if (ShaderCache::static_cache) { - delete ShaderCache::static_cache; - ShaderCache::static_cache = nullptr; - } -} - -ShaderCache::ShaderCache() -{ - std::string geometries[] = {"_mesh", "_curves", "_ptcloud"}; - std::string pipelines[] = {"_opaque", "_transparent"}; - std::string lightings[] = {"_flat", "_studio", "_matcap"}; - std::string shaders[] = {"_material", "_texture"}; - std::string clip[] = {"_no_clip", "_clip"}; - static_assert(std::size(geometries) == geometry_type_len); - static_assert(std::size(pipelines) == pipeline_type_len); - static_assert(std::size(lightings) == lighting_type_len); - static_assert(std::size(shaders) == shader_type_len); - - for (auto g : IndexRange(geometry_type_len)) { - for (auto p : IndexRange(pipeline_type_len)) { - for (auto l : IndexRange(lighting_type_len)) { - for (auto s : IndexRange(shader_type_len)) { - for (auto c : IndexRange(2) /*clip*/) { - prepass_[g][p][l][s][c] = {"workbench_prepass" + geometries[g] + pipelines[p] + - lightings[l] + shaders[s] + clip[c]}; + for (auto i : IndexRange(pipeline_type_len)) { + for (auto j : IndexRange(geometry_type_len)) { + for (auto k : IndexRange(shader_type_len)) { + for (auto l : IndexRange(lighting_type_len)) { + for (auto m : IndexRange(2) /*clip*/) { + DRW_SHADER_FREE_SAFE(prepass_shader_cache_[i][j][k][l][m]); } } } } } - - std::string cavity[] = {"_no_cavity", "_cavity"}; - std::string curvature[] = {"_no_curvature", "_curvature"}; - std::string shadow[] = {"_no_shadow", "_shadow"}; - - for (auto l : IndexRange(lighting_type_len)) { - for (auto ca : IndexRange(2) /*cavity*/) { - for (auto cu : IndexRange(2) /*curvature*/) { - for (auto s : IndexRange(2) /*shadow*/) { - resolve_[l][ca][cu][s] = {"workbench_resolve_opaque" + lightings[l] + cavity[ca] + - curvature[cu] + shadow[s]}; - } - } - } - } - - std::string pass[] = {"_fail", "_pass"}; - std::string manifold[] = {"_no_manifold", "_manifold"}; - std::string caps[] = {"_no_caps", "_caps"}; - - for (auto p : IndexRange(2) /*pass*/) { - for (auto m : IndexRange(2) /*manifold*/) { - for (auto c : IndexRange(2) /*caps*/) { - shadow_[p][m][c] = {"workbench_shadow" + pass[p] + manifold[m] + caps[c] + - (DEBUG_SHADOW_VOLUME ? "_debug" : "")}; - } - } - } - - std::string smoke[] = {"_object", "_smoke"}; - std::string interpolation[] = {"_linear", "_cubic", "_closest"}; - std::string coba[] = {"_no_coba", "_coba"}; - std::string slice[] = {"_no_slice", "_slice"}; - - for (auto sm : IndexRange(2) /*smoke*/) { - for (auto i : IndexRange(3) /*interpolation*/) { - for (auto c : IndexRange(2) /*coba*/) { - for (auto sl : IndexRange(2) /*slice*/) { - volume_[sm][i][c][sl] = {"workbench_volume" + smoke[sm] + interpolation[i] + coba[c] + - slice[sl]}; + for (auto i : IndexRange(pipeline_type_len)) { + for (auto j : IndexRange(lighting_type_len)) { + for (auto k : IndexRange(2) /*cavity*/) { + for (auto l : IndexRange(2) /*curvature*/) { + for (auto m : IndexRange(2) /*shadow*/) { + DRW_SHADER_FREE_SAFE(resolve_shader_cache_[i][j][k][l][m]); + } } } } } } +GPUShader *ShaderCache::prepass_shader_get(ePipelineType pipeline_type, + eGeometryType geometry_type, + eShaderType shader_type, + eLightingType lighting_type, + bool clip) +{ + GPUShader *&shader_ptr = prepass_shader_cache_[int(pipeline_type)][int(geometry_type)][int( + shader_type)][int(lighting_type)][clip ? 1 : 0]; + + if (shader_ptr != nullptr) { + return shader_ptr; + } + std::string info_name = "workbench_prepass_"; + switch (geometry_type) { + case eGeometryType::MESH: + info_name += "mesh_"; + break; + case eGeometryType::CURVES: + info_name += "curves_"; + break; + case eGeometryType::POINTCLOUD: + info_name += "ptcloud_"; + break; + } + switch (pipeline_type) { + case ePipelineType::OPAQUE: + info_name += "opaque_"; + break; + case ePipelineType::TRANSPARENT: + info_name += "transparent_"; + break; + case ePipelineType::SHADOW: + info_name += "shadow_"; + break; + } + switch (lighting_type) { + case eLightingType::FLAT: + info_name += "flat_"; + break; + case eLightingType::STUDIO: + info_name += "studio_"; + break; + case eLightingType::MATCAP: + info_name += "matcap_"; + break; + } + switch (shader_type) { + case eShaderType::MATERIAL: + info_name += "material"; + break; + case eShaderType::TEXTURE: + info_name += "texture"; + break; + } + info_name += clip ? "_clip" : "_no_clip"; + shader_ptr = GPU_shader_create_from_info_name(info_name.c_str()); + return shader_ptr; +} + +GPUShader *ShaderCache::resolve_shader_get(ePipelineType pipeline_type, + eLightingType lighting_type, + bool cavity, + bool curvature, + bool shadow) +{ + GPUShader *&shader_ptr = + resolve_shader_cache_[int(pipeline_type)][int(lighting_type)][cavity][curvature][shadow]; + + if (shader_ptr != nullptr) { + return shader_ptr; + } + std::string info_name = "workbench_resolve_"; + switch (pipeline_type) { + case ePipelineType::OPAQUE: + info_name += "opaque_"; + break; + case ePipelineType::TRANSPARENT: + info_name += "transparent_"; + break; + case ePipelineType::SHADOW: + BLI_assert_unreachable(); + break; + } + switch (lighting_type) { + case eLightingType::FLAT: + info_name += "flat"; + break; + case eLightingType::STUDIO: + info_name += "studio"; + break; + case eLightingType::MATCAP: + info_name += "matcap"; + break; + } + info_name += cavity ? "_cavity" : "_no_cavity"; + info_name += curvature ? "_curvature" : "_no_curvature"; + info_name += shadow ? "_shadow" : "_no_shadow"; + + shader_ptr = GPU_shader_create_from_info_name(info_name.c_str()); + return shader_ptr; +} + } // namespace blender::workbench diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index c8ba56067e1..96651b1da8b 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -21,8 +21,17 @@ #include "workbench_private.hh" +#define DEBUG_SHADOW_VOLUME 0 + namespace blender::workbench { +ShadowPass::ShadowView::ShadowView() : View("ShadowPass.View"){}; +ShadowPass::ShadowView::~ShadowView() +{ + DRW_SHADER_FREE_SAFE(dynamic_pass_type_shader_); + DRW_SHADER_FREE_SAFE(static_pass_type_shader_); +} + void ShadowPass::ShadowView::setup(View &view, float3 light_direction, bool force_fail_method) { force_fail_method_ = force_fail_method; @@ -181,7 +190,7 @@ bool ShadowPass::ShadowView::debug_object_culling(Object *ob) float4 plane = extruded_frustum_.planes[p]; bool separating_axis = true; for (float3 corner : bb.vec) { - corner = math::transform_point(ob->object_to_world(), corner); + corner = math::transform_point(float4x4(ob->object_to_world), corner); float signed_distance = math::dot(corner, float3(plane)) - plane.w; if (signed_distance <= 0) { separating_axis = false; @@ -235,9 +244,18 @@ void ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf &bounds, if (do_visibility_) { /* TODO(@pragma37): Use regular culling for the caps pass. */ - GPUShader *shader = current_pass_type_ == ShadowPass::FORCED_FAIL ? - ShaderCache::get().shadow_visibility_static.get() : - ShaderCache::get().shadow_visibility_dynamic.get(); + + if (dynamic_pass_type_shader_ == nullptr) { + dynamic_pass_type_shader_ = GPU_shader_create_from_info_name( + "workbench_shadow_visibility_compute_dynamic_pass_type"); + } + if (static_pass_type_shader_ == nullptr) { + static_pass_type_shader_ = GPU_shader_create_from_info_name( + "workbench_shadow_visibility_compute_static_pass_type"); + } + + GPUShader *shader = current_pass_type_ == ShadowPass::FORCED_FAIL ? static_pass_type_shader_ : + dynamic_pass_type_shader_; GPU_shader_bind(shader); GPU_shader_uniform_1i(shader, "resource_len", resource_len); GPU_shader_uniform_1i(shader, "view_len", view_len_); @@ -278,11 +296,39 @@ VisibilityBuf &ShadowPass::ShadowView::get_visibility_buffer() return visibility_buf_; } +ShadowPass::~ShadowPass() +{ + for (int depth_pass : IndexRange(2)) { + for (int manifold : IndexRange(2)) { + for (int cap : IndexRange(2)) { + DRW_SHADER_FREE_SAFE(shaders_[depth_pass][manifold][cap]); + } + } + } +} + PassMain::Sub *&ShadowPass::get_pass_ptr(PassType type, bool manifold, bool cap /*=false*/) { return passes_[type][manifold][cap]; } +GPUShader *ShadowPass::get_shader(bool depth_pass, bool manifold, bool cap /*=false*/) +{ + GPUShader *&shader = shaders_[depth_pass][manifold][cap]; + + if (shader == nullptr) { + std::string create_info_name = "workbench_shadow"; + create_info_name += (depth_pass) ? "_pass" : "_fail"; + create_info_name += (manifold) ? "_manifold" : "_no_manifold"; + create_info_name += (cap) ? "_caps" : "_no_caps"; +#if DEBUG_SHADOW_VOLUME + create_info_name += "_debug"; +#endif + shader = GPU_shader_create_from_info_name(create_info_name.c_str()); + } + return shader; +} + void ShadowPass::init(const SceneState &scene_state, SceneResources &resources) { enabled_ = scene_state.draw_shadows; @@ -351,7 +397,7 @@ void ShadowPass::sync() for (bool manifold : {false, true}) { PassMain::Sub *&ps = get_pass_ptr(PASS, manifold); ps = &pass_ps_.sub(manifold ? "manifold" : "non_manifold"); - ps->shader_set(ShaderCache::get().shadow_get(true, manifold)); + ps->shader_set(get_shader(true, manifold)); ps->bind_ubo("pass_data", pass_data_); for (PassType fail_type : {FAIL, FORCED_FAIL}) { @@ -359,12 +405,12 @@ void ShadowPass::sync() PassMain::Sub *&ps = get_pass_ptr(fail_type, manifold, false); ps = &ps_main.sub(manifold ? "NoCaps.manifold" : "NoCaps.non_manifold"); - ps->shader_set(ShaderCache::get().shadow_get(false, manifold, false)); + ps->shader_set(get_shader(false, manifold, false)); ps->bind_ubo("pass_data", pass_data_); PassMain::Sub *&caps_ps = get_pass_ptr(fail_type, manifold, true); caps_ps = &ps_main.sub(manifold ? "Caps.manifold" : "Caps.non_manifold"); - caps_ps->shader_set(ShaderCache::get().shadow_get(false, manifold, true)); + caps_ps->shader_set(get_shader(false, manifold, true)); caps_ps->bind_ubo("pass_data", pass_data_); } } diff --git a/source/blender/draw/engines/workbench/workbench_volume.cc b/source/blender/draw/engines/workbench/workbench_volume.cc index b05173a984b..5b66fdeb203 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.cc +++ b/source/blender/draw/engines/workbench/workbench_volume.cc @@ -12,6 +12,18 @@ namespace blender::workbench { +VolumePass::~VolumePass() +{ + GPUShader **sh_p = &shaders_[0][0][0][0]; + const int n = ARRAY_SIZE(shaders_); + for (int i = 0; i < n; i++, sh_p++) { + GPUShader *sh = *sh_p; + if (sh) { + GPU_shader_free(sh); + } + } +} + void VolumePass::sync(SceneResources &resources) { active_ = false; @@ -49,12 +61,11 @@ void VolumePass::object_sync_volume(Manager &manager, const bool use_slice = (volume->display.axis_slice_method == AXIS_SLICE_SINGLE); - sub_ps.shader_set(ShaderCache::get().volume_get( - false, volume->display.interpolation_method, false, use_slice)); + sub_ps.shader_set(get_shader(use_slice, false, volume->display.interpolation_method, false)); sub_ps.push_constant("do_depth_test", scene_state.shading.type >= OB_SOLID); const float density_scale = volume->display.density * - BKE_volume_density_scale(volume, ob->object_to_world().ptr()); + BKE_volume_density_scale(volume, ob->object_to_world); sub_ps.bind_texture("depthBuffer", &resources.depth_tx); sub_ps.bind_texture("stencil_tx", &stencil_tx_); @@ -71,7 +82,7 @@ void VolumePass::object_sync_volume(Manager &manager, manager, sub_ps, ob_ref, volume->display.slice_axis, volume->display.slice_depth); } else { - float4x4 texture_to_world = ob->object_to_world() * float4x4(grid->texture_to_object); + float4x4 texture_to_world = float4x4(ob->object_to_world) * float4x4(grid->texture_to_object); float3 world_size = math::to_scale(texture_to_world); int3 resolution; @@ -117,8 +128,7 @@ void VolumePass::object_sync_modifier(Manager &manager, const bool use_slice = settings.axis_slice_method == AXIS_SLICE_SINGLE; - sub_ps.shader_set( - ShaderCache::get().volume_get(true, settings.interp_method, settings.use_coba, use_slice)); + sub_ps.shader_set(get_shader(use_slice, settings.use_coba, settings.interp_method, true)); sub_ps.push_constant("do_depth_test", scene_state.shading.type >= OB_SOLID); if (settings.use_coba) { @@ -192,6 +202,33 @@ void VolumePass::draw(Manager &manager, View &view, SceneResources &resources) manager.submit(ps_, view); } +GPUShader *VolumePass::get_shader(bool slice, bool coba, int interpolation, bool smoke) +{ + GPUShader *&shader = shaders_[slice][coba][interpolation][smoke]; + + if (shader == nullptr) { + std::string create_info_name = "workbench_volume"; + create_info_name += (smoke) ? "_smoke" : "_object"; + switch (interpolation) { + case VOLUME_DISPLAY_INTERP_LINEAR: + create_info_name += "_linear"; + break; + case VOLUME_DISPLAY_INTERP_CUBIC: + create_info_name += "_cubic"; + break; + case VOLUME_DISPLAY_INTERP_CLOSEST: + create_info_name += "_closest"; + break; + default: + BLI_assert_unreachable(); + } + create_info_name += (coba) ? "_coba" : "_no_coba"; + create_info_name += (slice) ? "_slice" : "_no_slice"; + shader = GPU_shader_create_from_info_name(create_info_name.c_str()); + } + return shader; +} + void VolumePass::draw_slice_ps( Manager &manager, PassMain::Sub &ps, ObjectRef &ob_ref, int slice_axis_enum, float slice_depth) { diff --git a/source/blender/draw/intern/DRW_gpu_wrapper.hh b/source/blender/draw/intern/DRW_gpu_wrapper.hh index 19ea58c259f..2947eb60dac 100644 --- a/source/blender/draw/intern/DRW_gpu_wrapper.hh +++ b/source/blender/draw/intern/DRW_gpu_wrapper.hh @@ -64,7 +64,7 @@ #include "draw_manager.h" #include "draw_texture_pool.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_math_vector_types.hh" #include "BLI_span.hh" diff --git a/source/blender/draw/intern/DRW_render.hh b/source/blender/draw/intern/DRW_render.hh index d8a50f2a0d6..6ac95de8866 100644 --- a/source/blender/draw/intern/DRW_render.hh +++ b/source/blender/draw/intern/DRW_render.hh @@ -19,9 +19,9 @@ #include "BKE_layer.hh" #include "BKE_material.h" #include "BKE_pbvh.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_light_types.h" #include "DNA_material_types.h" diff --git a/source/blender/draw/intern/attribute_convert.cc b/source/blender/draw/intern/attribute_convert.cc index b6adb38a9c5..45e4e2cf4af 100644 --- a/source/blender/draw/intern/attribute_convert.cc +++ b/source/blender/draw/intern/attribute_convert.cc @@ -23,13 +23,11 @@ GPUVertFormat init_format_for_attribute(const eCustomDataType data_type, bke::attribute_math::convert_to_static_type(data_type, [&](auto dummy) { using T = decltype(dummy); using Converter = AttributeConverter; - if constexpr (!std::is_void_v) { - GPU_vertformat_attr_add(&format, - vbo_name.c_str(), - Converter::gpu_component_type, - Converter::gpu_component_len, - Converter::gpu_fetch_mode); - } + GPU_vertformat_attr_add(&format, + vbo_name.c_str(), + Converter::gpu_component_type, + Converter::gpu_component_len, + Converter::gpu_fetch_mode); }); return format; } @@ -40,20 +38,18 @@ void vertbuf_data_extract_direct(const GSpan attribute, GPUVertBuf &vbo) using T = decltype(dummy); using Converter = AttributeConverter; using VBOType = typename Converter::VBOType; - if constexpr (!std::is_void_v) { - const Span src = attribute.typed(); - MutableSpan data(static_cast(GPU_vertbuf_get_data(&vbo)), - attribute.size()); - if constexpr (std::is_same_v) { - array_utils::copy(src, data); - } - else { - threading::parallel_for(src.index_range(), 8192, [&](const IndexRange range) { - for (const int i : range) { - data[i] = Converter::convert(src[i]); - } - }); - } + const Span src = attribute.typed(); + MutableSpan data(static_cast(GPU_vertbuf_get_data(&vbo)), + attribute.size()); + if constexpr (std::is_same_v) { + array_utils::copy(src, data); + } + else { + threading::parallel_for(src.index_range(), 8192, [&](const IndexRange range) { + for (const int i : range) { + data[i] = Converter::convert(src[i]); + } + }); } }); } diff --git a/source/blender/draw/intern/draw_cache.hh b/source/blender/draw/intern/draw_cache.hh index 65b21b752ba..920dbbe886e 100644 --- a/source/blender/draw/intern/draw_cache.hh +++ b/source/blender/draw/intern/draw_cache.hh @@ -25,13 +25,13 @@ struct Scene; /** * Shape resolution level of detail. */ -enum eDRWLevelOfDetail { +typedef enum eDRWLevelOfDetail { DRW_LOD_LOW = 0, DRW_LOD_MEDIUM = 1, DRW_LOD_HIGH = 2, DRW_LOD_MAX, /* Max number of level of detail */ -}; +} eDRWLevelOfDetail; void DRW_shape_cache_free(); diff --git a/source/blender/draw/intern/draw_cache_extract.hh b/source/blender/draw/intern/draw_cache_extract.hh index c1339984023..12661be7d00 100644 --- a/source/blender/draw/intern/draw_cache_extract.hh +++ b/source/blender/draw/intern/draw_cache_extract.hh @@ -117,7 +117,7 @@ struct MeshBufferList { /* no loose edges. */ GPUIndexBuf *lines_paint_mask; GPUIndexBuf *lines_adjacency; - /** UV overlays. (visibility can differ from 3D view). */ + /* Uv overlays. (visibility can differ from 3D view) */ GPUIndexBuf *edituv_tris; GPUIndexBuf *edituv_lines; GPUIndexBuf *edituv_points; diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc b/source/blender/draw/intern/draw_cache_extract_mesh.cc index e32db24685b..986801fbc92 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc @@ -692,7 +692,7 @@ void mesh_buffer_cache_create_requested(TaskGraph *task_graph, } #ifdef DEBUG_TIME - double rdata_start = BLI_time_now_seconds(); + double rdata_start = BLI_check_seconds_timer(); #endif MeshRenderData *mr = mesh_render_data_create( @@ -703,7 +703,7 @@ void mesh_buffer_cache_create_requested(TaskGraph *task_graph, mr->use_simplify_normals = (scene->r.mode & R_SIMPLIFY) && (scene->r.mode & R_SIMPLIFY_NORMALS); #ifdef DEBUG_TIME - double rdata_end = BLI_time_now_seconds(); + double rdata_end = BLI_check_seconds_timer(); #endif eMRIterType iter_type = extractors.iter_types(); @@ -757,7 +757,7 @@ void mesh_buffer_cache_create_requested(TaskGraph *task_graph, #ifdef DEBUG_TIME BLI_task_graph_work_and_wait(task_graph); - double end = BLI_time_now_seconds(); + double end = BLI_check_seconds_timer(); static double avg = 0; static double avg_fps = 0; diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil_legacy.cc b/source/blender/draw/intern/draw_cache_impl_gpencil_legacy.cc index 01b9bf378a7..a7a89d7aed1 100644 --- a/source/blender/draw/intern/draw_cache_impl_gpencil_legacy.cc +++ b/source/blender/draw/intern/draw_cache_impl_gpencil_legacy.cc @@ -615,7 +615,7 @@ static void gpencil_sbuffer_stroke_ensure(bGPdata *gpd, bool do_fill) for (int i = 0; i < vert_len; i++) { ED_gpencil_tpoint_to_point(region, origin, &tpoints[i], &gps->points[i]); - mul_m4_v3(ob->world_to_object().ptr(), &gps->points[i].x); + mul_m4_v3(ob->world_to_object, &gps->points[i].x); bGPDspoint *pt = &gps->points[i]; copy_v4_v4(pt->vert_color, tpoints[i].vert_color); } diff --git a/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc b/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc index cfe42561d38..b1a4f056f30 100644 --- a/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc +++ b/source/blender/draw/intern/draw_cache_impl_grease_pencil.cc @@ -199,16 +199,6 @@ BLI_INLINE int32_t pack_rotation_aspect_hardness(float rot, float asp, float har return packed; } -static void copy_transformed_positions(const Span src_positions, - const IndexRange range, - const float4x4 &transform, - MutableSpan dst_positions) -{ - for (const int point_i : range) { - dst_positions[point_i] = math::transform_point(transform, src_positions[point_i]); - } -} - static void grease_pencil_edit_batch_ensure(Object &object, const GreasePencil &grease_pencil, const Scene &scene) @@ -228,7 +218,7 @@ static void grease_pencil_edit_batch_ensure(Object &object, BLI_assert(cache->edit_points == nullptr && cache->edit_lines == nullptr); /* Get the visible drawings. */ - const Vector drawings = + const Array drawings = ed::greasepencil::retrieve_visible_drawings(scene, grease_pencil); const Span layers = grease_pencil.layers(); @@ -269,8 +259,7 @@ static void grease_pencil_edit_batch_ensure(Object &object, int total_line_ids_num = 0; int drawing_start_offset = 0; for (const ed::greasepencil::DrawingInfo &info : drawings) { - const Layer &layer = *layers[info.layer_index]; - const float4x4 layer_space_to_object_space = layer.to_object_space(object); + const Layer *layer = layers[info.layer_index]; const bke::CurvesGeometry &curves = info.drawing.strokes(); const bke::AttributeAccessor attributes = curves.attributes(); const OffsetIndices points_by_curve = curves.points_by_curve(); @@ -283,15 +272,11 @@ static void grease_pencil_edit_batch_ensure(Object &object, const VArray selection_float = *attributes.lookup_or_default( ".selection", bke::AttrDomain::Point, true); - const IndexRange points(drawing_start_offset, curves.points_num()); - const Span positions = curves.positions(); - MutableSpan positions_slice = edit_points.slice(points); - threading::parallel_for(curves.points_range(), 1024, [&](const IndexRange range) { - copy_transformed_positions(positions, range, layer_space_to_object_space, positions_slice); - }); - MutableSpan selection_slice = edit_points_selection.slice(points); + edit_points.slice(drawing_start_offset, curves.points_num()).copy_from(curves.positions()); + MutableSpan selection_slice = edit_points_selection.slice(drawing_start_offset, + curves.points_num()); /* Do not show selection for locked layers. */ - if (layer.is_locked()) { + if (layer->is_locked()) { selection_slice.fill(0.0f); } else { @@ -311,7 +296,7 @@ static void grease_pencil_edit_batch_ensure(Object &object, total_line_ids_num += array_utils::count_booleans(curves.cyclic(), editable_strokes); /* Do not show points for locked layers. */ - if (layer.is_locked()) { + if (layer->is_locked()) { continue; } @@ -422,7 +407,7 @@ static void grease_pencil_geom_batch_ensure(Object &object, BLI_assert(cache->geom_batch == nullptr); /* Get the visible drawings. */ - const Vector drawings = + const Array drawings = ed::greasepencil::retrieve_visible_drawings(scene, grease_pencil); /* First, count how many vertices and triangles are needed for the whole object. Also record the @@ -508,8 +493,6 @@ static void grease_pencil_geom_batch_ensure(Object &object, /* Fill buffers with data. */ for (const int drawing_i : drawings.index_range()) { const ed::greasepencil::DrawingInfo &info = drawings[drawing_i]; - const Layer &layer = *grease_pencil.layers()[info.layer_index]; - const float4x4 layer_space_to_object_space = layer.to_object_space(object); const bke::CurvesGeometry &curves = info.drawing.strokes(); const bke::AttributeAccessor attributes = curves.attributes(); const OffsetIndices points_by_curve = curves.points_by_curve(); @@ -555,8 +538,7 @@ static void grease_pencil_geom_batch_ensure(Object &object, float length, GreasePencilStrokeVert &s_vert, GreasePencilColorVert &c_vert) { - copy_v3_v3(s_vert.pos, - math::transform_point(layer_space_to_object_space, positions[point_i])); + copy_v3_v3(s_vert.pos, positions[point_i]); s_vert.radius = radii[point_i] * ((end_cap == GP_STROKE_CAP_TYPE_ROUND) ? 1.0f : -1.0f); s_vert.opacity = opacities[point_i] * ((start_cap == GP_STROKE_CAP_TYPE_ROUND) ? 1.0f : -1.0f); diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.cc b/source/blender/draw/intern/draw_cache_impl_mesh.cc index a968dba97b6..d78916dc14e 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.cc +++ b/source/blender/draw/intern/draw_cache_impl_mesh.cc @@ -1868,7 +1868,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph, is_editmode, is_paint_mode, is_mode_active, - ob->object_to_world().ptr(), + ob->object_to_world, false, true, scene, @@ -1885,7 +1885,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph, is_editmode, is_paint_mode, is_mode_active, - ob->object_to_world().ptr(), + ob->object_to_world, false, false, scene, @@ -1901,7 +1901,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph, is_editmode, is_paint_mode, is_mode_active, - ob->object_to_world().ptr(), + ob->object_to_world, true, false, do_cage, @@ -1922,7 +1922,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph, is_editmode, is_paint_mode, is_mode_active, - ob->object_to_world().ptr(), + ob->object_to_world, true, false, scene, diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index e0517c89363..806181eeee7 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -14,7 +14,7 @@ #include "BKE_mesh_mapping.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_subdiv.hh" #include "BKE_subdiv_eval.hh" #include "BKE_subdiv_foreach.hh" @@ -2323,7 +2323,7 @@ void DRW_create_subdivision(Object *ob, #undef TIME_SUBDIV #ifdef TIME_SUBDIV - const double begin_time = BLI_time_now_seconds(); + const double begin_time = BLI_check_seconds_timer(); #endif if (!draw_subdiv_create_requested_buffers(ob, @@ -2345,7 +2345,7 @@ void DRW_create_subdivision(Object *ob, } #ifdef TIME_SUBDIV - const double end_time = BLI_time_now_seconds(); + const double end_time = BLI_check_seconds_timer(); fprintf(stderr, "Time to update subdivision: %f\n", end_time - begin_time); fprintf(stderr, "Maximum FPS: %f\n", 1.0 / (end_time - begin_time)); #endif diff --git a/source/blender/draw/intern/draw_cache_impl_volume.cc b/source/blender/draw/intern/draw_cache_impl_volume.cc index b6f937e4756..42126cf48b9 100644 --- a/source/blender/draw/intern/draw_cache_impl_volume.cc +++ b/source/blender/draw/intern/draw_cache_impl_volume.cc @@ -20,7 +20,7 @@ #include "DNA_object_types.h" #include "DNA_volume_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_volume.hh" #include "BKE_volume_grid_fwd.hh" #include "BKE_volume_render.hh" diff --git a/source/blender/draw/intern/draw_command.hh b/source/blender/draw/intern/draw_command.hh index 419929e2704..ea23b5726d9 100644 --- a/source/blender/draw/intern/draw_command.hh +++ b/source/blender/draw/intern/draw_command.hh @@ -13,7 +13,7 @@ * `DrawMultiBuf`. See implementation details at their definition. */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_map.hh" #include "DRW_gpu_wrapper.hh" diff --git a/source/blender/draw/intern/draw_common.cc b/source/blender/draw/intern/draw_common.cc index c0b5374af38..bc58015016d 100644 --- a/source/blender/draw/intern/draw_common.cc +++ b/source/blender/draw/intern/draw_common.cc @@ -17,7 +17,7 @@ #include "BLI_math_color.h" #include "BKE_colorband.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_object.hh" #include "draw_common.h" diff --git a/source/blender/draw/intern/draw_curves.cc b/source/blender/draw/intern/draw_curves.cc index c05a8373078..f9182ff215f 100644 --- a/source/blender/draw/intern/draw_curves.cc +++ b/source/blender/draw/intern/draw_curves.cc @@ -314,7 +314,7 @@ DRWShadingGroup *DRW_shgroup_curves_create_sub(Object *object, DRW_shgroup_uniform_int(shgrp, "hairStrandsRes", &curves_cache->final[subdiv].strands_res, 1); DRW_shgroup_uniform_int_copy(shgrp, "hairThicknessRes", thickness_res); DRW_shgroup_uniform_float_copy(shgrp, "hairRadShape", hair_rad_shape); - DRW_shgroup_uniform_mat4_copy(shgrp, "hairDupliMatrix", object->object_to_world().ptr()); + DRW_shgroup_uniform_mat4_copy(shgrp, "hairDupliMatrix", object->object_to_world); DRW_shgroup_uniform_float_copy(shgrp, "hairRadRoot", hair_rad_root); DRW_shgroup_uniform_float_copy(shgrp, "hairRadTip", hair_rad_tip); DRW_shgroup_uniform_bool_copy(shgrp, "hairCloseTip", hair_close_tip); @@ -540,7 +540,7 @@ GPUBatch *curves_sub_pass_setup_implementation(PassT &sub_ps, sub_ps.push_constant("hairStrandsRes", &curves_cache->final[subdiv].strands_res, 1); sub_ps.push_constant("hairThicknessRes", thickness_res); sub_ps.push_constant("hairRadShape", hair_rad_shape); - sub_ps.push_constant("hairDupliMatrix", ob->object_to_world()); + sub_ps.push_constant("hairDupliMatrix", float4x4(ob->object_to_world)); sub_ps.push_constant("hairRadRoot", hair_rad_root); sub_ps.push_constant("hairRadTip", hair_rad_tip); sub_ps.push_constant("hairCloseTip", hair_close_tip); diff --git a/source/blender/draw/intern/draw_hair.cc b/source/blender/draw/intern/draw_hair.cc index 71870adad11..5c0539c75cb 100644 --- a/source/blender/draw/intern/draw_hair.cc +++ b/source/blender/draw/intern/draw_hair.cc @@ -18,7 +18,7 @@ #include "DNA_modifier_types.h" #include "DNA_particle_types.h" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "GPU_batch.h" #include "GPU_capabilities.h" @@ -161,12 +161,12 @@ void DRW_hair_duplimat_get(Object *object, if (collection != nullptr) { sub_v3_v3(dupli_mat[3], collection->instance_offset); } - mul_m4_m4m4(dupli_mat, dupli_parent->object_to_world().ptr(), dupli_mat); + mul_m4_m4m4(dupli_mat, dupli_parent->object_to_world, dupli_mat); } else { - copy_m4_m4(dupli_mat, dupli_object->ob->object_to_world().ptr()); + copy_m4_m4(dupli_mat, dupli_object->ob->object_to_world); invert_m4(dupli_mat); - mul_m4_m4m4(dupli_mat, object->object_to_world().ptr(), dupli_mat); + mul_m4_m4m4(dupli_mat, object->object_to_world, dupli_mat); } } else { diff --git a/source/blender/draw/intern/draw_instance_data.cc b/source/blender/draw/intern/draw_instance_data.cc index d4c7ac6f855..7e94622de17 100644 --- a/source/blender/draw/intern/draw_instance_data.cc +++ b/source/blender/draw/intern/draw_instance_data.cc @@ -25,7 +25,7 @@ #include "DNA_particle_types.h" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "RNA_access.hh" #include "RNA_path.hh" diff --git a/source/blender/draw/intern/draw_manager.cc b/source/blender/draw/intern/draw_manager.cc index 4b4250069f7..3b9e3d51e1c 100644 --- a/source/blender/draw/intern/draw_manager.cc +++ b/source/blender/draw/intern/draw_manager.cc @@ -6,7 +6,7 @@ * \ingroup draw */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "GPU_compute.h" #include "draw_debug.hh" diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index 78cf38eac31..cc970456aa7 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -58,19 +58,19 @@ struct CurvesUniformBufPool; # define PROFILE_TIMER_FALLOFF 0.04 # define PROFILE_START(time_start) \ - double time_start = BLI_time_now_seconds(); \ + double time_start = BLI_check_seconds_timer(); \ ((void)0) # define PROFILE_END_ACCUM(time_accum, time_start) \ { \ - time_accum += (BLI_time_now_seconds() - time_start) * 1e3; \ + time_accum += (BLI_check_seconds_timer() - time_start) * 1e3; \ } \ ((void)0) /* exp average */ # define PROFILE_END_UPDATE(time_update, time_start) \ { \ - double _time_delta = (BLI_time_now_seconds() - time_start) * 1e3; \ + double _time_delta = (BLI_check_seconds_timer() - time_start) * 1e3; \ time_update = (time_update * (1.0 - PROFILE_TIMER_FALLOFF)) + \ (_time_delta * PROFILE_TIMER_FALLOFF); \ } \ diff --git a/source/blender/draw/intern/draw_manager_c.cc b/source/blender/draw/intern/draw_manager_c.cc index effb0f1b873..7b60df28feb 100644 --- a/source/blender/draw/intern/draw_manager_c.cc +++ b/source/blender/draw/intern/draw_manager_c.cc @@ -18,14 +18,14 @@ #include "BLF_api.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_curve.hh" #include "BKE_curves.h" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_editmesh.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_legacy.h" #include "BKE_grease_pencil.h" #include "BKE_lattice.hh" @@ -976,7 +976,7 @@ void DRW_cache_free_old_batches(Main *bmain) using namespace blender::draw; Scene *scene; static int lasttime = 0; - int ctime = int(BLI_time_now_seconds()); + int ctime = int(BLI_check_seconds_timer()); if (U.vbotimeout == 0 || (ctime - lasttime) < U.vbocollectrate || ctime == lasttime) { return; @@ -2854,7 +2854,7 @@ void DRW_draw_depth_object( GPU_matrix_projection_set(rv3d->winmat); GPU_matrix_set(rv3d->viewmat); - GPU_matrix_mul(object->object_to_world().ptr()); + GPU_matrix_mul(object->object_to_world); /* Setup frame-buffer. */ GPUTexture *depth_tx = GPU_viewport_depth_texture(viewport); @@ -2874,11 +2874,11 @@ void DRW_draw_depth_object( const bool use_clipping_planes = RV3D_CLIPPING_ENABLED(v3d, rv3d); if (use_clipping_planes) { GPU_clip_distances(6); - ED_view3d_clipping_local(rv3d, object->object_to_world().ptr()); + ED_view3d_clipping_local(rv3d, object->object_to_world); for (int i = 0; i < 6; i++) { copy_v4_v4(planes.world[i], rv3d->clip_local[i]); } - copy_m4_m4(planes.ClipModelMatrix.ptr(), object->object_to_world().ptr()); + copy_m4_m4(planes.ClipModelMatrix.ptr(), object->object_to_world); } drw_batch_cache_validate(object); @@ -3045,7 +3045,7 @@ void DRW_engines_register() RE_engines_register(&DRW_engine_viewport_eevee_type); /* Always register EEVEE Next so it can be used in background mode with `--factory-startup`. * (Needed for tests). */ - RE_engines_register(&DRW_engine_viewport_eevee_next_type); + // RE_engines_register(&DRW_engine_viewport_eevee_next_type); RE_engines_register(&DRW_engine_viewport_workbench_type); diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc index d19d4e4a484..e18af1b917f 100644 --- a/source/blender/draw/intern/draw_manager_data.cc +++ b/source/blender/draw/intern/draw_manager_data.cc @@ -14,8 +14,8 @@ #include "BKE_attribute.hh" #include "BKE_curve.hh" -#include "BKE_duplilist.hh" -#include "BKE_global.hh" +#include "BKE_duplilist.h" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_mesh.hh" #include "BKE_object.hh" @@ -698,7 +698,7 @@ BLI_INLINE void drw_call_matrix_init(DRWObjectMatrix *ob_mats, { copy_m4_m4(ob_mats->model, obmat); if (ob) { - copy_m4_m4(ob_mats->modelinverse, ob->world_to_object().ptr()); + copy_m4_m4(ob_mats->modelinverse, ob->world_to_object); } else { /* WATCH: Can be costly. */ @@ -745,8 +745,8 @@ static void drw_call_culling_init(DRWCullingState *cull, const Object *ob) float corner[3]; /* Get BoundSphere center and radius from the BoundBox. */ mid_v3_v3v3(cull->bsphere.center, bounds->max, bounds->min); - mul_v3_m4v3(corner, ob->object_to_world().ptr(), bounds->max); - mul_m4_v3(ob->object_to_world().ptr(), cull->bsphere.center); + mul_v3_m4v3(corner, ob->object_to_world, bounds->max); + mul_m4_v3(ob->object_to_world, cull->bsphere.center); cull->bsphere.radius = len_v3v3(cull->bsphere.center, corner); /* Bypass test for very large objects (see #67319). */ @@ -1038,8 +1038,7 @@ void DRW_shgroup_call_ex(DRWShadingGroup *shgroup, if (G.f & G_FLAG_PICKSEL) { drw_command_set_select_id(shgroup, nullptr, DST.select_id); } - DRWResourceHandle handle = drw_resource_handle( - shgroup, ob ? ob->object_to_world().ptr() : obmat, ob); + DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->object_to_world : obmat, ob); drw_command_draw(shgroup, geom, handle); /* Culling data. */ @@ -1064,8 +1063,7 @@ void DRW_shgroup_call_range( if (G.f & G_FLAG_PICKSEL) { drw_command_set_select_id(shgroup, nullptr, DST.select_id); } - DRWResourceHandle handle = drw_resource_handle( - shgroup, ob ? ob->object_to_world().ptr() : nullptr, ob); + DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->object_to_world : nullptr, ob); drw_command_draw_range(shgroup, geom, handle, v_sta, v_num); } @@ -1076,8 +1074,7 @@ void DRW_shgroup_call_instance_range( if (G.f & G_FLAG_PICKSEL) { drw_command_set_select_id(shgroup, nullptr, DST.select_id); } - DRWResourceHandle handle = drw_resource_handle( - shgroup, ob ? ob->object_to_world().ptr() : nullptr, ob); + DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->object_to_world : nullptr, ob); drw_command_draw_intance_range(shgroup, geom, handle, i_sta, i_num); } @@ -1123,8 +1120,7 @@ static void drw_shgroup_call_procedural_add_ex(DRWShadingGroup *shgroup, if (G.f & G_FLAG_PICKSEL) { drw_command_set_select_id(shgroup, nullptr, DST.select_id); } - DRWResourceHandle handle = drw_resource_handle( - shgroup, ob ? ob->object_to_world().ptr() : nullptr, ob); + DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->object_to_world : nullptr, ob); drw_command_draw_procedural(shgroup, geom, handle, vert_count); } @@ -1178,8 +1174,7 @@ void DRW_shgroup_call_procedural_indirect(DRWShadingGroup *shgroup, if (G.f & G_FLAG_PICKSEL) { drw_command_set_select_id(shgroup, nullptr, DST.select_id); } - DRWResourceHandle handle = drw_resource_handle( - shgroup, ob ? ob->object_to_world().ptr() : nullptr, ob); + DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->object_to_world : nullptr, ob); drw_command_draw_indirect(shgroup, geom, handle, indirect_buf); } @@ -1192,8 +1187,7 @@ void DRW_shgroup_call_instances(DRWShadingGroup *shgroup, if (G.f & G_FLAG_PICKSEL) { drw_command_set_select_id(shgroup, nullptr, DST.select_id); } - DRWResourceHandle handle = drw_resource_handle( - shgroup, ob ? ob->object_to_world().ptr() : nullptr, ob); + DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->object_to_world : nullptr, ob); drw_command_draw_instance(shgroup, geom, handle, count, false); } @@ -1207,8 +1201,7 @@ void DRW_shgroup_call_instances_with_attrs(DRWShadingGroup *shgroup, if (G.f & G_FLAG_PICKSEL) { drw_command_set_select_id(shgroup, nullptr, DST.select_id); } - DRWResourceHandle handle = drw_resource_handle( - shgroup, ob ? ob->object_to_world().ptr() : nullptr, ob); + DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->object_to_world : nullptr, ob); GPUBatch *batch = DRW_temp_batch_instance_request( DST.vmempool->idatalist, nullptr, inst_attributes, geom); drw_command_draw_instance(shgroup, batch, handle, 0, true); @@ -1312,7 +1305,7 @@ static void drw_sculpt_get_frustum_planes(const Object *ob, float planes[6][4]) * 4x4 matrix is done by multiplying with the transpose inverse. * The inverse cancels out here since we transform by inverse(obmat). */ float tmat[4][4]; - transpose_m4_m4(tmat, ob->object_to_world().ptr()); + transpose_m4_m4(tmat, ob->object_to_world); for (int i = 0; i < 6; i++) { mul_m4_v4(tmat, planes[i]); } @@ -1390,7 +1383,7 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd) if (SCULPT_DEBUG_BUFFERS) { int debug_node_nr = 0; - DRW_debug_modelmat(scd->ob->object_to_world().ptr()); + DRW_debug_modelmat(scd->ob->object_to_world); BKE_pbvh_draw_debug_cb( pbvh, (void (*)(PBVHNode *n, void *d, const float min[3], const float max[3], PBVHNodeFlags f)) diff --git a/source/blender/draw/intern/draw_manager_exec.cc b/source/blender/draw/intern/draw_manager_exec.cc index aa8dc9c835d..491a864a18c 100644 --- a/source/blender/draw/intern/draw_manager_exec.cc +++ b/source/blender/draw/intern/draw_manager_exec.cc @@ -12,7 +12,7 @@ #include "BLI_math_bits.h" #include "BLI_memblock.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "GPU_compute.h" #include "GPU_platform.h" diff --git a/source/blender/draw/intern/draw_manager_profiling.cc b/source/blender/draw/intern/draw_manager_profiling.cc index 54d560610a4..c0f7b9600c2 100644 --- a/source/blender/draw/intern/draw_manager_profiling.cc +++ b/source/blender/draw/intern/draw_manager_profiling.cc @@ -12,7 +12,7 @@ #include "BLI_rect.h" #include "BLI_string.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLF_api.hh" diff --git a/source/blender/draw/intern/draw_manager_shader.cc b/source/blender/draw/intern/draw_manager_shader.cc index 02a49d74266..769bb5c5594 100644 --- a/source/blender/draw/intern/draw_manager_shader.cc +++ b/source/blender/draw/intern/draw_manager_shader.cc @@ -17,7 +17,7 @@ #include "BLI_time.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_main.hh" #include "DEG_depsgraph_query.hh" @@ -270,7 +270,7 @@ static void drw_deferred_shader_add(GPUMaterial *mat, bool deferred) DRW_deferred_shader_remove(mat); /* Shaders could already be compiling. Have to wait for compilation to finish. */ while (GPU_material_status(mat) == GPU_MAT_QUEUED) { - BLI_time_sleep_ms(20); + BLI_sleep_ms(20); } if (GPU_material_status(mat) == GPU_MAT_CREATED) { GPU_material_compile(mat); @@ -568,7 +568,7 @@ void DRW_shader_queue_optimize_material(GPUMaterial *mat) DRW_deferred_shader_optimize_remove(mat); /* If optimization job had already started, wait for it to complete. */ while (GPU_material_optimization_status(mat) == GPU_MAT_OPTIMIZATION_QUEUED) { - BLI_time_sleep_ms(20); + BLI_sleep_ms(20); } } return; diff --git a/source/blender/draw/intern/draw_manager_text.cc b/source/blender/draw/intern/draw_manager_text.cc index 234c82972da..b02dda327a0 100644 --- a/source/blender/draw/intern/draw_manager_text.cc +++ b/source/blender/draw/intern/draw_manager_text.cc @@ -18,7 +18,7 @@ #include "BKE_editmesh.hh" #include "BKE_editmesh_cache.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_mesh.hh" #include "BKE_mesh_wrapper.hh" #include "BKE_object.hh" @@ -340,11 +340,11 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4, v1_clip, v2_clip)) { mid_v3_v3v3(vmid, v1_clip, v2_clip); - mul_m4_v3(ob->object_to_world().ptr(), vmid); + mul_m4_v3(ob->object_to_world, vmid); if (do_global) { - mul_mat3_m4_v3(ob->object_to_world().ptr(), v1); - mul_mat3_m4_v3(ob->object_to_world().ptr(), v2); + mul_mat3_m4_v3(ob->object_to_world, v1); + mul_mat3_m4_v3(ob->object_to_world, v2); } if (unit->system) { @@ -408,7 +408,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, float angle; mid_v3_v3v3(vmid, v1_clip, v2_clip); - mul_m4_v3(ob->object_to_world().ptr(), vmid); + mul_m4_v3(ob->object_to_world, vmid); if (use_coords) { copy_v3_v3(no_a, face_normals[BM_elem_index_get(l_a->f)]); @@ -420,8 +420,8 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, } if (do_global) { - mul_mat3_m4_v3(ob->world_to_object().ptr(), no_a); - mul_mat3_m4_v3(ob->world_to_object().ptr(), no_b); + mul_mat3_m4_v3(ob->world_to_object, no_a); + mul_mat3_m4_v3(ob->world_to_object, no_b); normalize_v3(no_a); normalize_v3(no_b); } @@ -477,16 +477,16 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, n += 3; if (do_global) { - mul_mat3_m4_v3(ob->object_to_world().ptr(), v1); - mul_mat3_m4_v3(ob->object_to_world().ptr(), v2); - mul_mat3_m4_v3(ob->object_to_world().ptr(), v3); + mul_mat3_m4_v3(ob->object_to_world, v1); + mul_mat3_m4_v3(ob->object_to_world, v2); + mul_mat3_m4_v3(ob->object_to_world, v3); } area += area_tri_v3(v1, v2, v3); } mul_v3_fl(vmid, 1.0f / float(n)); - mul_m4_v3(ob->object_to_world().ptr(), vmid); + mul_m4_v3(ob->object_to_world, vmid); if (unit->system) { numstr_len = BKE_unit_value_as_string( @@ -557,9 +557,9 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, copy_v3_v3(v2_local, v2); if (do_global) { - mul_mat3_m4_v3(ob->object_to_world().ptr(), v1); - mul_mat3_m4_v3(ob->object_to_world().ptr(), v2); - mul_mat3_m4_v3(ob->object_to_world().ptr(), v3); + mul_mat3_m4_v3(ob->object_to_world, v1); + mul_mat3_m4_v3(ob->object_to_world, v2); + mul_mat3_m4_v3(ob->object_to_world, v3); } float angle = angle_v3v3v3(v1, v2, v3); @@ -569,7 +569,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, (is_rad) ? angle : RAD2DEGF(angle), (is_rad) ? "r" : BLI_STR_UTF8_DEGREE_SIGN); interp_v3_v3v3(fvec, vmid, v2_local, 0.8f); - mul_m4_v3(ob->object_to_world().ptr(), fvec); + mul_m4_v3(ob->object_to_world, fvec); DRW_text_cache_add(dt, fvec, numstr, numstr_len, 0, 0, txt_flag, col); } } @@ -600,7 +600,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, copy_v3_v3(v1, v->co); } - mul_m4_v3(ob->object_to_world().ptr(), v1); + mul_m4_v3(ob->object_to_world, v1); numstr_len = SNPRINTF_RLEN(numstr, "%d", i); DRW_text_cache_add(dt, v1, numstr, numstr_len, 0, 0, txt_flag, col); @@ -629,7 +629,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4, v1_clip, v2_clip)) { mid_v3_v3v3(vmid, v1_clip, v2_clip); - mul_m4_v3(ob->object_to_world().ptr(), vmid); + mul_m4_v3(ob->object_to_world, vmid); numstr_len = SNPRINTF_RLEN(numstr, "%d", i); DRW_text_cache_add( @@ -663,7 +663,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, BM_face_calc_center_median(f, v1); } - mul_m4_v3(ob->object_to_world().ptr(), v1); + mul_m4_v3(ob->object_to_world, v1); numstr_len = SNPRINTF_RLEN(numstr, "%d", i); DRW_text_cache_add(dt, v1, numstr, numstr_len, 0, 0, txt_flag, col); diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc index ba4d3f44675..c103969987a 100644 --- a/source/blender/draw/intern/draw_pbvh.cc +++ b/source/blender/draw/intern/draw_pbvh.cc @@ -582,11 +582,9 @@ struct PBVHBatches { using T = decltype(dummy); using Converter = AttributeConverter; using VBOType = typename Converter::VBOType; - if constexpr (!std::is_void_v) { - std::fill_n(static_cast(GPU_vertbuf_get_data(vbo.vert_buf)), - GPU_vertbuf_get_vertex_len(vbo.vert_buf), - VBOType()); - } + std::fill_n(static_cast(GPU_vertbuf_get_data(vbo.vert_buf)), + GPU_vertbuf_get_vertex_len(vbo.vert_buf), + VBOType()); }); } } @@ -756,20 +754,18 @@ struct PBVHBatches { const GVArraySpan attribute = *attributes.lookup_or_default(name, domain, data_type); bke::attribute_math::convert_to_static_type(data_type, [&](auto dummy) { using T = decltype(dummy); - if constexpr (!std::is_void_v::VBOType>) { - switch (domain) { - case bke::AttrDomain::Point: - extract_data_vert_faces(args, attribute.typed(), vert_buf); - break; - case bke::AttrDomain::Face: - extract_data_face_faces(args, attribute.typed(), vert_buf); - break; - case bke::AttrDomain::Corner: - extract_data_corner_faces(args, attribute.typed(), vert_buf); - break; - default: - BLI_assert_unreachable(); - } + switch (domain) { + case bke::AttrDomain::Point: + extract_data_vert_faces(args, attribute.typed(), vert_buf); + break; + case bke::AttrDomain::Face: + extract_data_face_faces(args, attribute.typed(), vert_buf); + break; + case bke::AttrDomain::Corner: + extract_data_corner_faces(args, attribute.typed(), vert_buf); + break; + default: + BLI_assert_unreachable(); } }); } @@ -918,26 +914,25 @@ struct PBVHBatches { } else { const GenericRequest &request = std::get(vbo.request); + const StringRefNull name = request.name; const bke::AttrDomain domain = request.domain; const eCustomDataType data_type = request.type; const CustomData &custom_data = *get_cdata(domain, args); - const int cd_offset = CustomData_get_offset_named(&custom_data, data_type, request.name); + const int cd_offset = CustomData_get_offset_named(&custom_data, data_type, name.c_str()); bke::attribute_math::convert_to_static_type(data_type, [&](auto dummy) { using T = decltype(dummy); - if constexpr (!std::is_void_v::VBOType>) { - switch (domain) { - case bke::AttrDomain::Point: - extract_data_vert_bmesh(args, cd_offset, *vbo.vert_buf); - break; - case bke::AttrDomain::Face: - extract_data_face_bmesh(args, cd_offset, *vbo.vert_buf); - break; - case bke::AttrDomain::Corner: - extract_data_corner_bmesh(args, cd_offset, *vbo.vert_buf); - break; - default: - BLI_assert_unreachable(); - } + switch (domain) { + case bke::AttrDomain::Point: + extract_data_vert_bmesh(args, cd_offset, *vbo.vert_buf); + break; + case bke::AttrDomain::Face: + extract_data_face_bmesh(args, cd_offset, *vbo.vert_buf); + break; + case bke::AttrDomain::Corner: + extract_data_corner_bmesh(args, cd_offset, *vbo.vert_buf); + break; + default: + BLI_assert_unreachable(); } }); } diff --git a/source/blender/draw/intern/draw_resource.hh b/source/blender/draw/intern/draw_resource.hh index 64a4603d909..56520094adc 100644 --- a/source/blender/draw/intern/draw_resource.hh +++ b/source/blender/draw/intern/draw_resource.hh @@ -14,7 +14,7 @@ #include "BLI_math_matrix.hh" #include "BKE_curve.hh" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_mesh.h" #include "BKE_object.hh" #include "BKE_volume.hh" @@ -34,8 +34,8 @@ inline void ObjectMatrices::sync(const Object &object) { - model = object.object_to_world(); - model_inverse = object.world_to_object(); + model.view() = blender::float4x4_view(object.object_to_world); + model_inverse.view() = blender::float4x4_view(object.world_to_object); } inline void ObjectMatrices::sync(const float4x4 &model_matrix) diff --git a/source/blender/draw/intern/draw_sculpt.cc b/source/blender/draw/intern/draw_sculpt.cc index 869eefd77a1..0559879dab4 100644 --- a/source/blender/draw/intern/draw_sculpt.cc +++ b/source/blender/draw/intern/draw_sculpt.cc @@ -68,7 +68,7 @@ static Vector sculpt_batches_get_ex(const Object *ob, /* Transform clipping planes to object space. Transforming a plane with a * 4x4 matrix is done by multiplying with the transpose inverse. * The inverse cancels out here since we transform by inverse(obmat). */ - float4x4 tmat = math::transpose(ob->object_to_world()); + float4x4 tmat = math::transpose(float4x4(ob->object_to_world)); for (int i : IndexRange(6)) { draw_planes[i] = tmat * draw_planes[i]; update_planes[i] = draw_planes[i]; diff --git a/source/blender/draw/intern/draw_texture_pool.cc b/source/blender/draw/intern/draw_texture_pool.cc index 29638a8644f..7254b15a425 100644 --- a/source/blender/draw/intern/draw_texture_pool.cc +++ b/source/blender/draw/intern/draw_texture_pool.cc @@ -6,7 +6,7 @@ * \ingroup draw */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_string.h" #include "BLI_vector.hh" diff --git a/source/blender/draw/intern/draw_view_c.cc b/source/blender/draw/intern/draw_view_c.cc index a982282c5d4..8200dca4e63 100644 --- a/source/blender/draw/intern/draw_view_c.cc +++ b/source/blender/draw/intern/draw_view_c.cc @@ -29,7 +29,7 @@ #include "BLI_math_rotation.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_object.hh" #include "BKE_paint.hh" diff --git a/source/blender/draw/intern/draw_volume.cc b/source/blender/draw/intern/draw_volume.cc index efb6ddf1365..e9a18aa4faf 100644 --- a/source/blender/draw/intern/draw_volume.cc +++ b/source/blender/draw/intern/draw_volume.cc @@ -15,7 +15,7 @@ #include "DNA_volume_types.h" #include "BKE_fluid.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_volume.hh" @@ -129,7 +129,7 @@ static DRWShadingGroup *drw_volume_object_grids_init(Object *ob, grp = DRW_shgroup_create_sub(grp); - volume_infos.density_scale = BKE_volume_density_scale(volume, ob->object_to_world().ptr()); + volume_infos.density_scale = BKE_volume_density_scale(volume, ob->object_to_world); volume_infos.color_mul = float4(1.0f); volume_infos.temperature_mul = 1.0f; volume_infos.temperature_bias = 0.0f; @@ -305,7 +305,7 @@ PassType *volume_object_grids_init(PassType &ps, Volume *volume = (Volume *)ob->data; BKE_volume_load(volume, G.main); - volume_infos.density_scale = BKE_volume_density_scale(volume, ob->object_to_world().ptr()); + volume_infos.density_scale = BKE_volume_density_scale(volume, ob->object_to_world); volume_infos.color_mul = float4(1.0f); volume_infos.temperature_mul = 1.0f; volume_infos.temperature_bias = 0.0f; diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc index ebf4eb90796..3273aee43a7 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc @@ -199,23 +199,21 @@ static void extract_attribute(const MeshRenderData &mr, bke::attribute_math::convert_to_static_type(request.cd_type, [&](auto dummy) { using T = decltype(dummy); - if constexpr (!std::is_void_v::VBOType>) { - switch (request.domain) { - case bke::AttrDomain::Point: - extract_data_bmesh_vert(*mr.bm, cd_offset, vbo); - break; - case bke::AttrDomain::Edge: - extract_data_bmesh_edge(*mr.bm, cd_offset, vbo); - break; - case bke::AttrDomain::Face: - extract_data_bmesh_face(*mr.bm, cd_offset, vbo); - break; - case bke::AttrDomain::Corner: - extract_data_bmesh_loop(*mr.bm, cd_offset, vbo); - break; - default: - BLI_assert_unreachable(); - } + switch (request.domain) { + case bke::AttrDomain::Point: + extract_data_bmesh_vert(*mr.bm, cd_offset, vbo); + break; + case bke::AttrDomain::Edge: + extract_data_bmesh_edge(*mr.bm, cd_offset, vbo); + break; + case bke::AttrDomain::Face: + extract_data_bmesh_face(*mr.bm, cd_offset, vbo); + break; + case bke::AttrDomain::Corner: + extract_data_bmesh_loop(*mr.bm, cd_offset, vbo); + break; + default: + BLI_assert_unreachable(); } }); } @@ -227,23 +225,21 @@ static void extract_attribute(const MeshRenderData &mr, bke::attribute_math::convert_to_static_type(request.cd_type, [&](auto dummy) { using T = decltype(dummy); - if constexpr (!std::is_void_v::VBOType>) { - switch (request.domain) { - case bke::AttrDomain::Point: - extract_data_mesh_mapped_corner(attribute.typed(), mr.corner_verts, vbo); - break; - case bke::AttrDomain::Edge: - extract_data_mesh_mapped_corner(attribute.typed(), mr.corner_edges, vbo); - break; - case bke::AttrDomain::Face: - extract_data_mesh_face(mr.faces, attribute.typed(), vbo); - break; - case bke::AttrDomain::Corner: - vertbuf_data_extract_direct(attribute.typed(), vbo); - break; - default: - BLI_assert_unreachable(); - } + switch (request.domain) { + case bke::AttrDomain::Point: + extract_data_mesh_mapped_corner(attribute.typed(), mr.corner_verts, vbo); + break; + case bke::AttrDomain::Edge: + extract_data_mesh_mapped_corner(attribute.typed(), mr.corner_edges, vbo); + break; + case bke::AttrDomain::Face: + extract_data_mesh_face(mr.faces, attribute.typed(), vbo); + break; + case bke::AttrDomain::Corner: + vertbuf_data_extract_direct(attribute.typed(), vbo); + break; + default: + BLI_assert_unreachable(); } }); } @@ -286,14 +282,12 @@ static void extract_attr_init_subdiv(const DRWSubdivCache &subdiv_cache, bke::attribute_math::convert_to_static_type(request.cd_type, [&](auto dummy) { using T = decltype(dummy); using Converter = AttributeConverter; - if constexpr (!std::is_void_v) { - draw_subdiv_interp_custom_data(subdiv_cache, - src_data, - dst_buffer, - Converter::gpu_component_type, - Converter::gpu_component_len, - 0); - } + draw_subdiv_interp_custom_data(subdiv_cache, + src_data, + dst_buffer, + Converter::gpu_component_type, + Converter::gpu_component_len, + 0); }); GPU_vertbuf_discard(src_data); diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc index a9ebe9b5c7e..8c971a72c34 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc @@ -456,13 +456,14 @@ static void statvis_calc_distort(const MeshRenderData &mr, float *r_distort) const float *f_no = mr.face_normals[face_index]; fac = 0.0f; - for (const int corner : face.drop_front(1)) { - const int corner_prev = bke::mesh::face_corner_prev(face, corner); - const int corner_next = bke::mesh::face_corner_next(face, corner); + for (int i = 1; i <= face.size(); i++) { + const int corner_prev = face.start() + (i - 1) % face.size(); + const int corner_curr = face.start() + (i + 0) % face.size(); + const int corner_next = face.start() + (i + 1) % face.size(); float no_corner[3]; normal_tri_v3(no_corner, mr.vert_positions[mr.corner_verts[corner_prev]], - mr.vert_positions[mr.corner_verts[corner]], + mr.vert_positions[mr.corner_verts[corner_curr]], mr.vert_positions[mr.corner_verts[corner_next]]); /* simple way to detect (what is most likely) concave */ if (dot_v3v3(f_no, no_corner) < 0.0f) { @@ -539,9 +540,9 @@ static void statvis_calc_sharp(const MeshRenderData &mr, float *r_sharp) for (int face_index = 0; face_index < mr.face_len; face_index++) { const IndexRange face = mr.faces[face_index]; - for (const int corner : face) { - const int vert_curr = mr.corner_verts[corner]; - const int vert_next = mr.corner_verts[bke::mesh::face_corner_next(face, corner)]; + for (int i = 0; i < face.size(); i++) { + const int vert_curr = mr.corner_verts[face.start() + (i + 0) % face.size()]; + const int vert_next = mr.corner_verts[face.start() + (i + 1) % face.size()]; float angle; eh.add_or_modify( {vert_curr, vert_next}, diff --git a/source/blender/editors/animation/anim_channels_defines.cc b/source/blender/editors/animation/anim_channels_defines.cc index 34b169c3d44..68aa12e7f9d 100644 --- a/source/blender/editors/animation/anim_channels_defines.cc +++ b/source/blender/editors/animation/anim_channels_defines.cc @@ -18,7 +18,7 @@ #include "BLI_math_color.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -55,9 +55,11 @@ #include "BKE_animsys.h" #include "BKE_context.hh" #include "BKE_curve.hh" +#include "BKE_gpencil_legacy.h" #include "BKE_grease_pencil.hh" #include "BKE_key.hh" #include "BKE_lib_id.hh" +#include "BKE_main.hh" #include "BKE_nla.h" #include "GPU_immediate.h" diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index 5da8e81e907..3c968f19df8 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -32,13 +32,14 @@ #include "BKE_anim_data.h" #include "BKE_context.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_legacy.h" #include "BKE_grease_pencil.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_mask.h" #include "BKE_nla.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_workspace.h" diff --git a/source/blender/editors/animation/anim_deps.cc b/source/blender/editors/animation/anim_deps.cc index 4c700981911..0c5ac66592e 100644 --- a/source/blender/editors/animation/anim_deps.cc +++ b/source/blender/editors/animation/anim_deps.cc @@ -15,6 +15,7 @@ #include "DNA_gpencil_legacy_types.h" #include "DNA_grease_pencil_types.h" #include "DNA_mask_types.h" +#include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_sequence_types.h" @@ -24,9 +25,12 @@ #include "BKE_action.h" #include "BKE_anim_data.h" +#include "BKE_context.hh" #include "BKE_fcurve.h" #include "BKE_gpencil_legacy.h" #include "BKE_grease_pencil.hh" +#include "BKE_main.hh" +#include "BKE_node.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/animation/anim_draw.cc b/source/blender/editors/animation/anim_draw.cc index 9d6481768b1..8c6e1ddd608 100644 --- a/source/blender/editors/animation/anim_draw.cc +++ b/source/blender/editors/animation/anim_draw.cc @@ -9,34 +9,41 @@ #include "BLI_sys_types.h" #include "DNA_anim_types.h" +#include "DNA_gpencil_legacy_types.h" +#include "DNA_mask_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_userdef_types.h" +#include "BLI_dlrbTree.h" #include "BLI_math_rotation.h" #include "BLI_rect.h" +#include "BLI_timecode.h" #include "BLI_utildefines.h" #include "BKE_context.hh" #include "BKE_curve.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_mask.h" #include "BKE_nla.h" #include "ED_anim_api.hh" +#include "ED_keyframes_draw.hh" #include "ED_keyframes_edit.hh" #include "ED_keyframes_keylist.hh" #include "RNA_access.hh" #include "RNA_path.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "UI_view2d.hh" #include "GPU_immediate.h" +#include "GPU_matrix.h" #include "GPU_state.h" /* *************************************************** */ diff --git a/source/blender/editors/animation/anim_filter.cc b/source/blender/editors/animation/anim_filter.cc index 1a4fb0404cc..46c6c653183 100644 --- a/source/blender/editors/animation/anim_filter.cc +++ b/source/blender/editors/animation/anim_filter.cc @@ -62,17 +62,18 @@ #include "MEM_guardedalloc.h" #include "BLI_alloca.h" +#include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_string.h" #include "BLI_utildefines.h" #include "BKE_action.h" #include "BKE_anim_data.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_context.hh" #include "BKE_fcurve.h" #include "BKE_fcurve_driver.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_grease_pencil.hh" #include "BKE_key.hh" #include "BKE_layer.hh" @@ -80,7 +81,7 @@ #include "BKE_mask.h" #include "BKE_material.h" #include "BKE_modifier.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "ED_anim_api.hh" #include "ED_markers.hh" @@ -90,6 +91,8 @@ #include "ANIM_bone_collections.hh" +#include "UI_resources.hh" /* for TH_KEYFRAME_SCALE lookup */ + /* ************************************************************ */ /* Blender Context <-> Animation Context mapping */ diff --git a/source/blender/editors/animation/anim_ipo_utils.cc b/source/blender/editors/animation/anim_ipo_utils.cc index 1212870f192..c2da8147791 100644 --- a/source/blender/editors/animation/anim_ipo_utils.cc +++ b/source/blender/editors/animation/anim_ipo_utils.cc @@ -18,7 +18,7 @@ #include "BLI_math_color.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_anim_types.h" diff --git a/source/blender/editors/animation/anim_markers.cc b/source/blender/editors/animation/anim_markers.cc index 5c703389aac..b05667494f6 100644 --- a/source/blender/editors/animation/anim_markers.cc +++ b/source/blender/editors/animation/anim_markers.cc @@ -16,14 +16,15 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" +#include "BKE_fcurve.h" #include "BKE_idprop.h" #include "BKE_layer.hh" #include "BKE_main.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_unit.hh" diff --git a/source/blender/editors/animation/anim_motion_paths.cc b/source/blender/editors/animation/anim_motion_paths.cc index be5fe2c4d9e..7d0c365a57a 100644 --- a/source/blender/editors/animation/anim_motion_paths.cc +++ b/source/blender/editors/animation/anim_motion_paths.cc @@ -22,7 +22,7 @@ #include "BKE_action.h" #include "BKE_anim_data.h" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" @@ -168,17 +168,18 @@ static void motionpaths_calc_bake_targets(ListBase *targets, } /* Result must be in world-space. */ - mul_m4_v3(ob_eval->object_to_world().ptr(), mpv->co); + mul_m4_v3(ob_eval->object_to_world, mpv->co); } else { /* World-space object location. */ - copy_v3_v3(mpv->co, ob_eval->object_to_world().location()); + copy_v3_v3(mpv->co, ob_eval->object_to_world[3]); } if (mpath->flag & MOTIONPATH_FLAG_BAKE_CAMERA && camera) { Object *cam_eval = DEG_get_evaluated_object(depsgraph, camera); /* Convert point to camera space. */ - float3 co_camera_space = math::transform_point(cam_eval->world_to_object(), float3(mpv->co)); + float3 co_camera_space = math::transform_point(float4x4(cam_eval->world_to_object), + float3(mpv->co)); copy_v3_v3(mpv->co, co_camera_space); } diff --git a/source/blender/editors/animation/anim_ops.cc b/source/blender/editors/animation/anim_ops.cc index c6d13a9e1fb..6d673e8090a 100644 --- a/source/blender/editors/animation/anim_ops.cc +++ b/source/blender/editors/animation/anim_ops.cc @@ -17,9 +17,9 @@ #include "DNA_scene_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_global.h" +#include "BKE_report.h" +#include "BKE_scene.h" #include "UI_view2d.hh" diff --git a/source/blender/editors/animation/drivers.cc b/source/blender/editors/animation/drivers.cc index e3fc95489c0..8565f779e55 100644 --- a/source/blender/editors/animation/drivers.cc +++ b/source/blender/editors/animation/drivers.cc @@ -12,17 +12,20 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_string.h" #include "BLI_utildefines.h" #include "DNA_anim_types.h" +#include "DNA_object_types.h" #include "DNA_texture_types.h" #include "BKE_anim_data.h" +#include "BKE_animsys.h" #include "BKE_context.hh" #include "BKE_fcurve.h" #include "BKE_fcurve_driver.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" diff --git a/source/blender/editors/animation/fmodifier_ui.cc b/source/blender/editors/animation/fmodifier_ui.cc index 4e2255c26a2..f7826409744 100644 --- a/source/blender/editors/animation/fmodifier_ui.cc +++ b/source/blender/editors/animation/fmodifier_ui.cc @@ -21,7 +21,7 @@ #include "MEM_guardedalloc.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" diff --git a/source/blender/editors/animation/keyframes_draw.cc b/source/blender/editors/animation/keyframes_draw.cc index 38a8ad8dbc6..1f7e1c9af9d 100644 --- a/source/blender/editors/animation/keyframes_draw.cc +++ b/source/blender/editors/animation/keyframes_draw.cc @@ -14,6 +14,7 @@ #include "BKE_grease_pencil.hh" +#include "BLI_dlrbTree.h" #include "BLI_listbase.h" #include "BLI_rect.h" @@ -21,6 +22,8 @@ #include "DNA_gpencil_legacy_types.h" #include "DNA_grease_pencil_types.h" #include "DNA_mask_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "GPU_immediate.h" #include "GPU_shader_shared.h" @@ -30,6 +33,7 @@ #include "UI_resources.hh" #include "UI_view2d.hh" +#include "ED_anim_api.hh" #include "ED_keyframes_draw.hh" #include "ED_keyframes_keylist.hh" diff --git a/source/blender/editors/animation/keyframes_general.cc b/source/blender/editors/animation/keyframes_general.cc index 5abeefe4ffe..afebe744b3e 100644 --- a/source/blender/editors/animation/keyframes_general.cc +++ b/source/blender/editors/animation/keyframes_general.cc @@ -28,7 +28,8 @@ #include "BKE_curve.hh" #include "BKE_fcurve.h" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "RNA_access.hh" #include "RNA_enum_types.hh" diff --git a/source/blender/editors/animation/keyframes_keylist.cc b/source/blender/editors/animation/keyframes_keylist.cc index 4864cf76b4b..089ed42b567 100644 --- a/source/blender/editors/animation/keyframes_keylist.cc +++ b/source/blender/editors/animation/keyframes_keylist.cc @@ -19,6 +19,7 @@ #include "MEM_guardedalloc.h" #include "BLI_array.hh" +#include "BLI_dlrbTree.h" #include "BLI_listbase.h" #include "BLI_range.h" #include "BLI_utildefines.h" diff --git a/source/blender/editors/animation/keyframing.cc b/source/blender/editors/animation/keyframing.cc index 6e93c05e290..273018eb274 100644 --- a/source/blender/editors/animation/keyframing.cc +++ b/source/blender/editors/animation/keyframing.cc @@ -13,12 +13,15 @@ #include "BLI_blenlib.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_ID.h" #include "DNA_action_types.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" +#include "DNA_constraint_types.h" +#include "DNA_key_types.h" +#include "DNA_material_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -28,14 +31,15 @@ #include "BKE_armature.hh" #include "BKE_context.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_nla.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" +#include "DEG_depsgraph_build.hh" #include "ED_keyframing.hh" #include "ED_object.hh" @@ -47,6 +51,7 @@ #include "ANIM_fcurve.hh" #include "ANIM_keyframing.hh" #include "ANIM_rna.hh" +#include "ANIM_visualkey.hh" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/editors/animation/keyingsets.cc b/source/blender/editors/animation/keyingsets.cc index ca16f76b171..eb5b9c8b960 100644 --- a/source/blender/editors/animation/keyingsets.cc +++ b/source/blender/editors/animation/keyingsets.cc @@ -24,7 +24,7 @@ #include "BKE_animsys.h" #include "BKE_context.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" @@ -744,10 +744,10 @@ KeyingSet *ANIM_get_keyingset_for_autokeying(const Scene *scene, const char *tra return ANIM_builtin_keyingset_get_named(transformKSName); } -static void anim_keyingset_visit_for_search_impl( - const bContext *C, - blender::FunctionRef visit_fn, - const bool use_poll) +static void anim_keyingset_visit_for_search_impl(const bContext *C, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data, + const bool use_poll) { /* Poll requires context. */ if (use_poll && (C == nullptr)) { @@ -758,10 +758,10 @@ static void anim_keyingset_visit_for_search_impl( /* Active Keying Set. */ if (!use_poll || (scene && scene->active_keyingset)) { - StringPropertySearchVisitParams visit_params{}; + StringPropertySearchVisitParams visit_params = {nullptr}; visit_params.text = "__ACTIVE__"; visit_params.info = "Active Keying Set"; - visit_fn(visit_params); + visit_fn(visit_user_data, &visit_params); } /* User-defined Keying Sets. */ @@ -770,10 +770,10 @@ static void anim_keyingset_visit_for_search_impl( if (use_poll && !ANIM_keyingset_context_ok_poll((bContext *)C, keyingset)) { continue; } - StringPropertySearchVisitParams visit_params{}; + StringPropertySearchVisitParams visit_params = {nullptr}; visit_params.text = keyingset->idname; visit_params.info = keyingset->name; - visit_fn(visit_params); + visit_fn(visit_user_data, &visit_params); } } @@ -782,31 +782,31 @@ static void anim_keyingset_visit_for_search_impl( if (use_poll && !ANIM_keyingset_context_ok_poll((bContext *)C, keyingset)) { continue; } - StringPropertySearchVisitParams visit_params{}; + StringPropertySearchVisitParams visit_params = {nullptr}; visit_params.text = keyingset->idname; visit_params.info = keyingset->name; - visit_fn(visit_params); + visit_fn(visit_user_data, &visit_params); } } -void ANIM_keyingset_visit_for_search( - const bContext *C, - PointerRNA * /*ptr*/, - PropertyRNA * /*prop*/, - const char * /*edit_text*/, - blender::FunctionRef visit_fn) +void ANIM_keyingset_visit_for_search(const bContext *C, + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, + const char * /*edit_text*/, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data) { - anim_keyingset_visit_for_search_impl(C, visit_fn, false); + anim_keyingset_visit_for_search_impl(C, visit_fn, visit_user_data, false); } -void ANIM_keyingset_visit_for_search_no_poll( - const bContext *C, - PointerRNA * /*ptr*/, - PropertyRNA * /*prop*/, - const char * /*edit_text*/, - blender::FunctionRef visit_fn) +void ANIM_keyingset_visit_for_search_no_poll(const bContext *C, + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, + const char * /*edit_text*/, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data) { - anim_keyingset_visit_for_search_impl(C, visit_fn, true); + anim_keyingset_visit_for_search_impl(C, visit_fn, visit_user_data, true); } /* Menu of All Keying Sets ----------------------------- */ diff --git a/source/blender/editors/animation/time_scrub_ui.cc b/source/blender/editors/animation/time_scrub_ui.cc index a427261f757..bffcd738167 100644 --- a/source/blender/editors/animation/time_scrub_ui.cc +++ b/source/blender/editors/animation/time_scrub_ui.cc @@ -7,7 +7,7 @@ */ #include "BKE_context.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "GPU_immediate.h" #include "GPU_matrix.h" diff --git a/source/blender/editors/armature/armature_add.cc b/source/blender/editors/armature/armature_add.cc index 8d309177621..a5041effe01 100644 --- a/source/blender/editors/armature/armature_add.cc +++ b/source/blender/editors/armature/armature_add.cc @@ -22,17 +22,19 @@ #include "BLI_math_vector.h" #include "BLI_string_utils.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" #include "BKE_armature.hh" #include "BKE_constraint.h" #include "BKE_context.hh" +#include "BKE_deform.hh" #include "BKE_fcurve.h" #include "BKE_idprop.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" -#include "BKE_object_types.hh" +#include "BKE_library.hh" +#include "BKE_main.hh" #include "RNA_access.hh" #include "RNA_define.hh" @@ -197,13 +199,13 @@ static int armature_click_extrude_exec(bContext *C, wmOperator * /*op*/) const View3DCursor *curs = &scene->cursor; copy_v3_v3(newbone->tail, curs->location); - sub_v3_v3v3(newbone->tail, newbone->tail, obedit->object_to_world().location()); + sub_v3_v3v3(newbone->tail, newbone->tail, obedit->object_to_world[3]); if (a == 1) { newbone->tail[0] = -newbone->tail[0]; } - copy_m3_m4(mat, obedit->object_to_world().ptr()); + copy_m3_m4(mat, obedit->object_to_world); invert_m3_m3(imat, mat); mul_m3_v3(imat, newbone->tail); @@ -1639,8 +1641,8 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) copy_v3_v3(curs, CTX_data_scene(C)->cursor.location); /* Get inverse point for head and orientation for tail */ - invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); - mul_m4_v3(obedit->world_to_object().ptr(), curs); + invert_m4_m4(obedit->world_to_object, obedit->object_to_world); + mul_m4_v3(obedit->world_to_object, curs); if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) { copy_m3_m4(obmat, rv3d->viewmat); @@ -1649,7 +1651,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) unit_m3(obmat); } - copy_m3_m4(viewmat, obedit->object_to_world().ptr()); + copy_m3_m4(viewmat, obedit->object_to_world); mul_m3_m3m3(totmat, obmat, viewmat); invert_m3_m3(imat, totmat); diff --git a/source/blender/editors/armature/armature_edit.cc b/source/blender/editors/armature/armature_edit.cc index 233bea92607..984f47d171f 100644 --- a/source/blender/editors/armature/armature_edit.cc +++ b/source/blender/editors/armature/armature_edit.cc @@ -14,7 +14,7 @@ #include "MEM_guardedalloc.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" @@ -26,12 +26,11 @@ #include "BKE_armature.hh" #include "BKE_constraint.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_object_types.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -119,8 +118,8 @@ void ED_armature_origin_set( /* Find the center-point. */ if (centermode == 2) { copy_v3_v3(cent, cursor); - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); - mul_m4_v3(ob->world_to_object().ptr(), cent); + invert_m4_m4(ob->world_to_object, ob->object_to_world); + mul_m4_v3(ob->world_to_object, cent); } else { if (around == V3D_AROUND_CENTER_BOUNDS) { @@ -160,7 +159,7 @@ void ED_armature_origin_set( /* Adjust object location for new center-point. */ if (centermode && (is_editmode == false)) { - mul_mat3_m4_v3(ob->object_to_world().ptr(), cent); /* omit translation part */ + mul_mat3_m4_v3(ob->object_to_world, cent); /* omit translation part */ add_v3_v3(ob->loc, cent); } } @@ -286,16 +285,16 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) axis_flip = true; } - copy_m3_m4(imat, ob->object_to_world().ptr()); + copy_m3_m4(imat, ob->object_to_world); invert_m3(imat); if (type == CALC_ROLL_CURSOR) { /* Cursor */ float cursor_local[3]; const View3DCursor *cursor = &scene->cursor; - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); copy_v3_v3(cursor_local, cursor->location); - mul_m4_v3(ob->world_to_object().ptr(), cursor_local); + mul_m4_v3(ob->world_to_object, cursor_local); /* cursor */ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { @@ -731,8 +730,8 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) ebp = static_cast(points.first); /* Get points - cursor (tail) */ - invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); - mul_v3_m4v3(curs, obedit->world_to_object().ptr(), scene->cursor.location); + invert_m4_m4(obedit->world_to_object, obedit->object_to_world); + mul_v3_m4v3(curs, obedit->world_to_object, scene->cursor.location); /* Create a bone */ newbone = add_points_bone(obedit, ebp->vec, curs); @@ -769,8 +768,8 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) float dist_sq_a, dist_sq_b; /* get cursor location */ - invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); - mul_v3_m4v3(curs, obedit->world_to_object().ptr(), scene->cursor.location); + invert_m4_m4(obedit->world_to_object, obedit->object_to_world); + mul_v3_m4v3(curs, obedit->world_to_object, scene->cursor.location); /* get distances */ dist_sq_a = len_squared_v3v3(ebp_a->vec, curs); diff --git a/source/blender/editors/armature/armature_naming.cc b/source/blender/editors/armature/armature_naming.cc index 2d7ed5c2296..6ff758f7add 100644 --- a/source/blender/editors/armature/armature_naming.cc +++ b/source/blender/editors/armature/armature_naming.cc @@ -25,7 +25,7 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" #include "BKE_animsys.h" @@ -33,7 +33,7 @@ #include "BKE_constraint.h" #include "BKE_context.hh" #include "BKE_deform.hh" -#include "BKE_grease_pencil.hh" +#include "BKE_gpencil_modifier_legacy.h" #include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_modifier.hh" @@ -336,22 +336,6 @@ void ED_armature_bone_rename(Main *bmain, } } } - - if (ob->type == OB_GREASE_PENCIL) { - using namespace blender; - GreasePencil &grease_pencil = *static_cast(ob->data); - for (bke::greasepencil::Layer *layer : grease_pencil.layers_for_write()) { - Object *parent = layer->parent; - if (parent == nullptr) { - continue; - } - StringRefNull bone_name = layer->parent_bone_name(); - if (!bone_name.is_empty() && bone_name == StringRef(oldname)) { - layer->set_parent_bone_name(newname); - } - } - } - DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); } diff --git a/source/blender/editors/armature/armature_relations.cc b/source/blender/editors/armature/armature_relations.cc index 349733e9db7..86b98d54802 100644 --- a/source/blender/editors/armature/armature_relations.cc +++ b/source/blender/editors/armature/armature_relations.cc @@ -21,7 +21,7 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" #include "BKE_anim_data.h" @@ -33,7 +33,7 @@ #include "BKE_idprop.h" #include "BKE_layer.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" @@ -340,7 +340,7 @@ int ED_armature_join_objects_exec(bContext *C, wmOperator *op) /* Inverse transform for all selected armatures in this object, * See #object_join_exec for detailed comment on why the safe version is used. */ - invert_m4_m4_safe_ortho(oimat, ob_active->object_to_world().ptr()); + invert_m4_m4_safe_ortho(oimat, ob_active->object_to_world); /* Index bone collections by name. This is also used later to keep track * of collections added from other armatures. */ @@ -391,7 +391,7 @@ int ED_armature_join_objects_exec(bContext *C, wmOperator *op) // BASACT->flag &= ~OB_MODE_POSE; /* Find the difference matrix */ - mul_m4_m4m4(mat, oimat, ob_iter->object_to_world().ptr()); + mul_m4_m4m4(mat, oimat, ob_iter->object_to_world); /* Copy bones and posechannels from the object to the edit armature */ for (pchan = static_cast(opose->chanbase.first); pchan; pchan = pchann) { diff --git a/source/blender/editors/armature/armature_select.cc b/source/blender/editors/armature/armature_select.cc index f27972cf1ca..c9f7a40d4b6 100644 --- a/source/blender/editors/armature/armature_select.cc +++ b/source/blender/editors/armature/armature_select.cc @@ -25,7 +25,7 @@ #include "BKE_layer.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -1580,8 +1580,8 @@ static const EnumPropertyItem prop_similar_types[] = { static float bone_length_squared_worldspace_get(Object *ob, EditBone *ebone) { float v1[3], v2[3]; - mul_v3_mat3_m4v3(v1, ob->object_to_world().ptr(), ebone->head); - mul_v3_mat3_m4v3(v2, ob->object_to_world().ptr(), ebone->tail); + mul_v3_mat3_m4v3(v1, ob->object_to_world, ebone->head); + mul_v3_mat3_m4v3(v2, ob->object_to_world, ebone->tail); return len_squared_v3v3(v1, v2); } @@ -1626,8 +1626,8 @@ static void bone_direction_worldspace_get(Object *ob, EditBone *ebone, float *r_ copy_v3_v3(v1, ebone->head); copy_v3_v3(v2, ebone->tail); - mul_m4_v3(ob->object_to_world().ptr(), v1); - mul_m4_v3(ob->object_to_world().ptr(), v2); + mul_m4_v3(ob->object_to_world, v1); + mul_m4_v3(ob->object_to_world, v2); sub_v3_v3v3(r_dir, v1, v2); normalize_v3(r_dir); diff --git a/source/blender/editors/armature/armature_skinning.cc b/source/blender/editors/armature/armature_skinning.cc index 1c0d2674929..de2b825022b 100644 --- a/source/blender/editors/armature/armature_skinning.cc +++ b/source/blender/editors/armature/armature_skinning.cc @@ -10,7 +10,9 @@ #include "DNA_armature_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "MEM_guardedalloc.h" @@ -22,11 +24,13 @@ #include "BKE_armature.hh" #include "BKE_attribute.hh" #include "BKE_deform.hh" +#include "BKE_mesh.hh" #include "BKE_mesh_iterators.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_deform.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_subsurf.hh" #include "DEG_depsgraph.hh" @@ -376,8 +380,8 @@ static void add_verts_to_dgroups(ReportList *reports, copy_v3_v3(tip[j], bone->arm_tail); } - mul_m4_v3(par->object_to_world().ptr(), root[j]); - mul_m4_v3(par->object_to_world().ptr(), tip[j]); + mul_m4_v3(par->object_to_world, root[j]); + mul_m4_v3(par->object_to_world, tip[j]); /* set selected */ if (wpmode) { @@ -426,7 +430,7 @@ static void add_verts_to_dgroups(ReportList *reports, if (!vertsfilled) { copy_v3_v3(verts[i], positions[i]); } - mul_m4_v3(ob->object_to_world().ptr(), verts[i]); + mul_m4_v3(ob->object_to_world, verts[i]); } /* compute the weights based on gathered vertices and bones */ @@ -450,7 +454,7 @@ static void add_verts_to_dgroups(ReportList *reports, root, tip, selected, - mat4_to_scale(par->object_to_world().ptr())); + mat4_to_scale(par->object_to_world)); } /* only generated in some cases but can call anyway */ diff --git a/source/blender/editors/armature/armature_utils.cc b/source/blender/editors/armature/armature_utils.cc index a6722e092aa..9e52097e3e9 100644 --- a/source/blender/editors/armature/armature_utils.cc +++ b/source/blender/editors/armature/armature_utils.cc @@ -17,7 +17,9 @@ #include "BLI_string_utils.hh" #include "BKE_armature.hh" -#include "BKE_global.hh" +#include "BKE_context.hh" +#include "BKE_deform.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" @@ -25,6 +27,7 @@ #include "DEG_depsgraph.hh" #include "ED_armature.hh" +#include "ED_util.hh" #include "ANIM_bone_collections.hh" diff --git a/source/blender/editors/armature/bone_collections.cc b/source/blender/editors/armature/bone_collections.cc index c20cc8ad3c5..41a7407d388 100644 --- a/source/blender/editors/armature/bone_collections.cc +++ b/source/blender/editors/armature/bone_collections.cc @@ -9,6 +9,8 @@ #include +#include "BLI_string.h" + #include "ANIM_bone_collections.hh" #include "DNA_ID.h" @@ -16,15 +18,17 @@ #include "BKE_action.h" #include "BKE_context.hh" +#include "BKE_layer.hh" #include "BKE_lib_override.hh" -#include "BKE_report.hh" +#include "BKE_report.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph.hh" #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "WM_api.hh" #include "WM_types.hh" @@ -32,6 +36,7 @@ #include "ED_armature.hh" #include "ED_object.hh" #include "ED_outliner.hh" +#include "ED_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/editors/armature/meshlaplacian.cc b/source/blender/editors/armature/meshlaplacian.cc index cfb777e833d..11368cff1ea 100644 --- a/source/blender/editors/armature/meshlaplacian.cc +++ b/source/blender/editors/armature/meshlaplacian.cc @@ -10,7 +10,9 @@ #include "MEM_guardedalloc.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BLI_map.hh" #include "BLI_math_geom.h" @@ -21,17 +23,20 @@ #include "BLI_ordered_edge.hh" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_attribute.hh" #include "BKE_bvhutils.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" #include "ED_armature.hh" #include "ED_mesh.hh" +#include "DEG_depsgraph.hh" + #include "eigen_capi.h" #include "meshlaplacian.h" @@ -1795,11 +1800,11 @@ void ED_mesh_deform_bind_callback(Object *object, mmd_orig->bindcagecos = (float *)mdb.cagecos; mmd_orig->verts_num = mdb.verts_num; mmd_orig->cage_verts_num = mdb.cage_verts_num; - copy_m4_m4(mmd_orig->bindmat, mmd_orig->object->object_to_world().ptr()); + copy_m4_m4(mmd_orig->bindmat, mmd_orig->object->object_to_world); /* transform bindcagecos to world space */ for (a = 0; a < mdb.cage_verts_num; a++) { - mul_m4_v3(mmd_orig->object->object_to_world().ptr(), mmd_orig->bindcagecos + a * 3); + mul_m4_v3(mmd_orig->object->object_to_world, mmd_orig->bindcagecos + a * 3); } /* free */ diff --git a/source/blender/editors/armature/pose_edit.cc b/source/blender/editors/armature/pose_edit.cc index 9cc8869a11d..b65e95c1edd 100644 --- a/source/blender/editors/armature/pose_edit.cc +++ b/source/blender/editors/armature/pose_edit.cc @@ -12,22 +12,28 @@ #include "BLI_blenlib.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BKE_action.h" #include "BKE_anim_visualization.h" #include "BKE_armature.hh" #include "BKE_context.hh" +#include "BKE_deform.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" +#include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" +#include "DEG_depsgraph_query.hh" #include "RNA_access.hh" #include "RNA_define.hh" @@ -42,14 +48,18 @@ #include "ED_keyframing.hh" #include "ED_object.hh" #include "ED_screen.hh" +#include "ED_view3d.hh" #include "ANIM_bone_collections.hh" #include "ANIM_keyframing.hh" +#include "UI_interface.hh" + #include "armature_intern.hh" #undef DEBUG_TIME +#include "BLI_time.h" #ifdef DEBUG_TIME # include "BLI_time_utildefines.h" #endif diff --git a/source/blender/editors/armature/pose_lib_2.cc b/source/blender/editors/armature/pose_lib_2.cc index f5919a58f1d..96d6dd5981c 100644 --- a/source/blender/editors/armature/pose_lib_2.cc +++ b/source/blender/editors/armature/pose_lib_2.cc @@ -15,7 +15,7 @@ #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_armature_types.h" @@ -27,7 +27,7 @@ #include "BKE_lib_id.hh" #include "BKE_object.hh" #include "BKE_pose_backup.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/armature/pose_select.cc b/source/blender/editors/armature/pose_select.cc index 9a767f88e76..94cc576d72d 100644 --- a/source/blender/editors/armature/pose_select.cc +++ b/source/blender/editors/armature/pose_select.cc @@ -27,7 +27,7 @@ #include "BKE_layer.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/armature/pose_slide.cc b/source/blender/editors/armature/pose_slide.cc index 556b49122bc..d2c80ba0bef 100644 --- a/source/blender/editors/armature/pose_slide.cc +++ b/source/blender/editors/armature/pose_slide.cc @@ -32,9 +32,10 @@ #include "BLI_array.hh" #include "BLI_blenlib.h" +#include "BLI_dlrbTree.h" #include "BLI_math_rotation.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -47,12 +48,15 @@ #include "BKE_context.hh" #include "BKE_layer.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_object.hh" +#include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "BKE_unit.hh" #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_path.hh" #include "RNA_prototypes.h" #include "WM_api.hh" @@ -61,17 +65,26 @@ #include "UI_interface.hh" #include "UI_resources.hh" +#include "ED_armature.hh" #include "ED_keyframes_edit.hh" #include "ED_keyframes_keylist.hh" #include "ED_markers.hh" #include "ED_numinput.hh" #include "ED_screen.hh" +#include "ED_space_api.hh" #include "ED_util.hh" #include "ANIM_fcurve.hh" +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_matrix.h" +#include "GPU_state.h" + #include "armature_intern.hh" +#include "BLF_api.hh" + using blender::Vector; /* Pixel distance from 0% to 100%. */ diff --git a/source/blender/editors/armature/pose_transform.cc b/source/blender/editors/armature/pose_transform.cc index 5e3af8f446c..fb1ad0f021e 100644 --- a/source/blender/editors/armature/pose_transform.cc +++ b/source/blender/editors/armature/pose_transform.cc @@ -26,11 +26,12 @@ #include "BKE_armature.hh" #include "BKE_blender_copybuffer.hh" #include "BKE_context.hh" +#include "BKE_deform.hh" #include "BKE_idprop.h" #include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" @@ -45,6 +46,7 @@ #include "ED_armature.hh" #include "ED_keyframing.hh" #include "ED_screen.hh" +#include "ED_util.hh" #include "ANIM_bone_collections.hh" #include "ANIM_keyframing.hh" @@ -94,10 +96,10 @@ static void applyarmature_fix_boneparents(const bContext *C, Scene *scene, Objec /* apply current transform from parent (not yet destroyed), * then calculate new parent inverse matrix */ - BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), false, false); + BKE_object_apply_mat4(ob, ob->object_to_world, false, false); BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); - invert_m4_m4(ob->parentinv, workob.object_to_world().ptr()); + invert_m4_m4(ob->parentinv, workob.object_to_world); } } } diff --git a/source/blender/editors/armature/pose_utils.cc b/source/blender/editors/armature/pose_utils.cc index f6630306d35..c4fe0d4c50e 100644 --- a/source/blender/editors/armature/pose_utils.cc +++ b/source/blender/editors/armature/pose_utils.cc @@ -15,6 +15,7 @@ #include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BKE_action.h" #include "BKE_anim_data.h" diff --git a/source/blender/editors/asset/intern/asset_catalog.cc b/source/blender/editors/asset/intern/asset_catalog.cc index 41339e51135..0e1aae38920 100644 --- a/source/blender/editors/asset/intern/asset_catalog.cc +++ b/source/blender/editors/asset/intern/asset_catalog.cc @@ -28,7 +28,8 @@ using namespace blender::asset_system; bool catalogs_read_only(const AssetLibrary &library) { - asset_system::AssetCatalogService *catalog_service = library.catalog_service.get(); + asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service( + &library); return catalog_service->is_read_only(); } @@ -61,11 +62,12 @@ asset_system::AssetCatalog *catalog_add(AssetLibrary *library, StringRefNull name, StringRef parent_path) { - asset_system::AssetCatalogService *catalog_service = library->catalog_service.get(); + asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service( + library); if (!catalog_service) { return nullptr; } - if (catalog_service->is_read_only()) { + if (catalogs_read_only(*library)) { return nullptr; } @@ -85,12 +87,13 @@ asset_system::AssetCatalog *catalog_add(AssetLibrary *library, void catalog_remove(AssetLibrary *library, const CatalogID &catalog_id) { - asset_system::AssetCatalogService *catalog_service = library->catalog_service.get(); + asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service( + library); if (!catalog_service) { BLI_assert_unreachable(); return; } - if (catalog_service->is_read_only()) { + if (catalogs_read_only(*library)) { return; } @@ -104,12 +107,13 @@ void catalog_rename(AssetLibrary *library, const CatalogID catalog_id, const StringRefNull new_name) { - asset_system::AssetCatalogService *catalog_service = library->catalog_service.get(); + asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service( + library); if (!catalog_service) { BLI_assert_unreachable(); return; } - if (catalog_service->is_read_only()) { + if (catalogs_read_only(*library)) { return; } @@ -133,12 +137,13 @@ void catalog_move(AssetLibrary *library, const CatalogID src_catalog_id, const std::optional dst_parent_catalog_id) { - asset_system::AssetCatalogService *catalog_service = library->catalog_service.get(); + asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service( + library); if (!catalog_service) { BLI_assert_unreachable(); return; } - if (catalog_service->is_read_only()) { + if (catalogs_read_only(*library)) { return; } @@ -176,12 +181,13 @@ void catalog_move(AssetLibrary *library, void catalogs_save_from_main_path(AssetLibrary *library, const Main *bmain) { - asset_system::AssetCatalogService *catalog_service = library->catalog_service.get(); + asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service( + library); if (!catalog_service) { BLI_assert_unreachable(); return; } - if (catalog_service->is_read_only()) { + if (catalogs_read_only(*library)) { return; } diff --git a/source/blender/editors/asset/intern/asset_filter.cc b/source/blender/editors/asset/intern/asset_filter.cc index 615586e630a..3cd1183680b 100644 --- a/source/blender/editors/asset/intern/asset_filter.cc +++ b/source/blender/editors/asset/intern/asset_filter.cc @@ -8,6 +8,7 @@ #include "AS_asset_representation.hh" +#include "BKE_asset.hh" #include "BKE_idtype.hh" #include "BLI_listbase.h" @@ -18,6 +19,8 @@ #include "AS_asset_library.hh" #include "ED_asset_filter.hh" +#include "ED_asset_handle.hh" +#include "ED_asset_library.hh" #include "ED_asset_list.hh" namespace blender::ed::asset { diff --git a/source/blender/editors/asset/intern/asset_handle.cc b/source/blender/editors/asset/intern/asset_handle.cc index 32a030466f5..3b0e0a6a1d7 100644 --- a/source/blender/editors/asset/intern/asset_handle.cc +++ b/source/blender/editors/asset/intern/asset_handle.cc @@ -8,12 +8,20 @@ #include +#include "AS_asset_representation.hh" + +#include "BKE_blendfile.hh" + +#include "BLI_string.h" + #include "DNA_space_types.h" #include "DNA_space_types.h" #include "ED_fileselect.hh" +#include "RNA_prototypes.h" + #include "ED_asset_handle.hh" namespace blender::ed::asset { diff --git a/source/blender/editors/asset/intern/asset_import.cc b/source/blender/editors/asset/intern/asset_import.cc index 44802848222..25258c0cb6f 100644 --- a/source/blender/editors/asset/intern/asset_import.cc +++ b/source/blender/editors/asset/intern/asset_import.cc @@ -10,7 +10,7 @@ #include "DNA_space_types.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "WM_api.hh" diff --git a/source/blender/editors/asset/intern/asset_indexer.cc b/source/blender/editors/asset/intern/asset_indexer.cc index 420482c4aa8..117c5aa544d 100644 --- a/source/blender/editors/asset/intern/asset_indexer.cc +++ b/source/blender/editors/asset/intern/asset_indexer.cc @@ -145,7 +145,7 @@ struct AssetEntryReader { */ DictionaryValue::Lookup lookup; - StringRef get_name_with_idcode() const + StringRefNull get_name_with_idcode() const { return lookup.lookup(ATTRIBUTE_ENTRIES_NAME)->as_string_value()->value(); } @@ -155,13 +155,13 @@ struct AssetEntryReader { ID_Type get_idcode() const { - const StringRef name_with_idcode = get_name_with_idcode(); - return GS(name_with_idcode.data()); + const StringRefNull name_with_idcode = get_name_with_idcode(); + return GS(name_with_idcode.c_str()); } StringRef get_name() const { - const StringRef name_with_idcode = get_name_with_idcode(); + const StringRefNull name_with_idcode = get_name_with_idcode(); return name_with_idcode.substr(2); } @@ -170,7 +170,7 @@ struct AssetEntryReader { return lookup.contains(ATTRIBUTE_ENTRIES_DESCRIPTION); } - StringRef get_description() const + StringRefNull get_description() const { return lookup.lookup(ATTRIBUTE_ENTRIES_DESCRIPTION)->as_string_value()->value(); } @@ -180,7 +180,7 @@ struct AssetEntryReader { return lookup.contains(ATTRIBUTE_ENTRIES_AUTHOR); } - StringRef get_author() const + StringRefNull get_author() const { return lookup.lookup(ATTRIBUTE_ENTRIES_AUTHOR)->as_string_value()->value(); } @@ -190,7 +190,7 @@ struct AssetEntryReader { return lookup.contains(ATTRIBUTE_ENTRIES_COPYRIGHT); } - StringRef get_copyright() const + StringRefNull get_copyright() const { return lookup.lookup(ATTRIBUTE_ENTRIES_COPYRIGHT)->as_string_value()->value(); } @@ -200,7 +200,7 @@ struct AssetEntryReader { return lookup.contains(ATTRIBUTE_ENTRIES_LICENSE); } - StringRef get_license() const + StringRefNull get_license() const { return lookup.lookup(ATTRIBUTE_ENTRIES_LICENSE)->as_string_value()->value(); } @@ -212,7 +212,7 @@ struct AssetEntryReader { CatalogID get_catalog_id() const { - const StringRefNull catalog_id = + const std::string &catalog_id = lookup.lookup(ATTRIBUTE_ENTRIES_CATALOG_ID)->as_string_value()->value(); CatalogID catalog_uuid(catalog_id); return catalog_uuid; @@ -401,20 +401,32 @@ static void init_indexer_entry_from_value(FileIndexerEntry &indexer_entry, indexer_entry.datablock_info.free_asset_data = true; if (entry.has_description()) { - const StringRef description = entry.get_description(); - asset_data->description = BLI_strdupn(description.data(), description.size()); + const StringRefNull description = entry.get_description(); + const size_t c_str_size = description.size() + 1; + char *description_c_str = static_cast(MEM_mallocN(c_str_size, __func__)); + memcpy(description_c_str, description.c_str(), c_str_size); + asset_data->description = description_c_str; } if (entry.has_author()) { - const StringRef author = entry.get_author(); - asset_data->author = BLI_strdupn(author.data(), author.size()); + const StringRefNull author = entry.get_author(); + const size_t c_str_size = author.size() + 1; + char *author_c_str = static_cast(MEM_mallocN(c_str_size, __func__)); + memcpy(author_c_str, author.c_str(), c_str_size); + asset_data->author = author_c_str; } if (entry.has_copyright()) { - const StringRef copyright = entry.get_copyright(); - asset_data->copyright = BLI_strdupn(copyright.data(), copyright.size()); + const StringRefNull copyright = entry.get_copyright(); + const size_t c_str_size = copyright.size() + 1; + char *copyright_c_str = static_cast(MEM_mallocN(c_str_size, __func__)); + memcpy(copyright_c_str, copyright.c_str(), c_str_size); + asset_data->copyright = copyright_c_str; } if (entry.has_license()) { - const StringRef license = entry.get_license(); - asset_data->license = BLI_strdupn(license.data(), license.size()); + const StringRefNull license = entry.get_license(); + const size_t c_str_size = license.size() + 1; + char *license_c_str = static_cast(MEM_mallocN(c_str_size, __func__)); + memcpy(license_c_str, license.c_str(), c_str_size); + asset_data->license = license_c_str; } const StringRefNull catalog_name = entry.get_catalog_name(); diff --git a/source/blender/editors/asset/intern/asset_library_reference_enum.cc b/source/blender/editors/asset/intern/asset_library_reference_enum.cc index 1bdd61d618e..8c1fccb71f3 100644 --- a/source/blender/editors/asset/intern/asset_library_reference_enum.cc +++ b/source/blender/editors/asset/intern/asset_library_reference_enum.cc @@ -21,6 +21,7 @@ #include "RNA_define.hh" #include "RNA_enum_types.hh" +#include "RNA_prototypes.h" #include "ED_asset_library.hh" diff --git a/source/blender/editors/asset/intern/asset_list.cc b/source/blender/editors/asset/intern/asset_list.cc index a79e27ca14f..00e7dbd2e0f 100644 --- a/source/blender/editors/asset/intern/asset_list.cc +++ b/source/blender/editors/asset/intern/asset_list.cc @@ -26,6 +26,8 @@ #include "DNA_space_types.h" +#include "BKE_preferences.h" + #include "WM_api.hh" /* XXX uses private header of file-space. */ diff --git a/source/blender/editors/asset/intern/asset_mark_clear.cc b/source/blender/editors/asset/intern/asset_mark_clear.cc index 9fcfc8e7a5e..3ae7b9a8caf 100644 --- a/source/blender/editors/asset/intern/asset_mark_clear.cc +++ b/source/blender/editors/asset/intern/asset_mark_clear.cc @@ -12,7 +12,7 @@ #include "BKE_asset.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" @@ -20,12 +20,14 @@ #include "UI_interface_icons.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "ED_asset_list.hh" #include "ED_asset_mark_clear.hh" #include "ED_asset_type.hh" +#include "WM_api.hh" #include "WM_types.hh" namespace blender::ed::asset { diff --git a/source/blender/editors/asset/intern/asset_menu_utils.cc b/source/blender/editors/asset/intern/asset_menu_utils.cc index ed66b85e585..6c24be87d7c 100644 --- a/source/blender/editors/asset/intern/asset_menu_utils.cc +++ b/source/blender/editors/asset/intern/asset_menu_utils.cc @@ -14,9 +14,11 @@ #include "DNA_screen_types.h" #include "BKE_asset.hh" -#include "BKE_report.hh" +#include "BKE_report.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" + +#include "WM_api.hh" #include "RNA_access.hh" #include "RNA_define.hh" @@ -51,10 +53,11 @@ void operator_asset_reference_props_register(StructRNA &srna) void operator_asset_reference_props_set(const asset_system::AssetRepresentation &asset, PointerRNA &ptr) { - const AssetWeakReference weak_ref = asset.make_weak_reference(); - RNA_enum_set(&ptr, "asset_library_type", weak_ref.asset_library_type); - RNA_string_set(&ptr, "asset_library_identifier", weak_ref.asset_library_identifier); - RNA_string_set(&ptr, "relative_asset_identifier", weak_ref.relative_asset_identifier); + AssetWeakReference *weak_ref = asset.make_weak_reference(); + RNA_enum_set(&ptr, "asset_library_type", weak_ref->asset_library_type); + RNA_string_set(&ptr, "asset_library_identifier", weak_ref->asset_library_identifier); + RNA_string_set(&ptr, "relative_asset_identifier", weak_ref->relative_asset_identifier); + BKE_asset_weak_reference_free(&weak_ref); } /** diff --git a/source/blender/editors/asset/intern/asset_ops.cc b/source/blender/editors/asset/intern/asset_ops.cc index b0d6af97711..6a1ce9b7789 100644 --- a/source/blender/editors/asset/intern/asset_ops.cc +++ b/source/blender/editors/asset/intern/asset_ops.cc @@ -9,26 +9,30 @@ #include "AS_asset_library.hh" #include "AS_asset_representation.hh" -#include "BKE_bpath.hh" +#include "BKE_asset.hh" +#include "BKE_bpath.h" #include "BKE_context.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_preferences.h" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BLI_fileops.h" /* MSVC needs this for `PATH_MAX` */ #include "BLI_fnmatch.h" #include "BLI_path_util.h" #include "BLI_set.hh" #include "ED_asset.hh" #include "ED_screen.hh" +#include "ED_util.hh" /* XXX needs access to the file list, should all be done via the asset system in future. */ #include "ED_fileselect.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "RNA_prototypes.h" #include "WM_api.hh" @@ -89,7 +93,7 @@ struct IDVecStats { * Helper to report stats about the IDs in context. Operator polls use this, also to report a * helpful disabled hint to the user. */ -static IDVecStats asset_operation_get_id_vec_stats_from_ids(const Span id_pointers) +static IDVecStats asset_operation_get_id_vec_stats_from_ids(const Vector &id_pointers) { IDVecStats stats; @@ -125,7 +129,7 @@ static const char *asset_operation_unsupported_type_msg(const bool is_single) class AssetMarkHelper { public: - void operator()(const bContext &C, Span ids); + void operator()(const bContext &C, const Vector &ids); void reportResults(ReportList &reports) const; bool wasSuccessful() const; @@ -140,7 +144,7 @@ class AssetMarkHelper { Stats stats; }; -void AssetMarkHelper::operator()(const bContext &C, const Span ids) +void AssetMarkHelper::operator()(const bContext &C, const Vector &ids) { for (const PointerRNA &ptr : ids) { BLI_assert(RNA_struct_is_ID(ptr.type)); @@ -190,7 +194,7 @@ void AssetMarkHelper::reportResults(ReportList &reports) const } } -static int asset_mark_exec(const bContext *C, const wmOperator *op, const Span ids) +static int asset_mark_exec(const bContext *C, const wmOperator *op, const Vector &ids) { AssetMarkHelper mark_helper; mark_helper(*C, ids); @@ -206,7 +210,7 @@ static int asset_mark_exec(const bContext *C, const wmOperator *op, const Span

ids) +static bool asset_mark_poll(bContext *C, const Vector &ids) { IDVecStats ctx_stats = asset_operation_get_id_vec_stats_from_ids(ids); @@ -265,7 +269,7 @@ class AssetClearHelper { public: AssetClearHelper(const bool set_fake_user) : set_fake_user_(set_fake_user) {} - void operator()(Span ids); + void operator()(const Vector &ids); void reportResults(const bContext *C, ReportList &reports) const; bool wasSuccessful() const; @@ -279,7 +283,7 @@ class AssetClearHelper { Stats stats; }; -void AssetClearHelper::operator()(const Span ids) +void AssetClearHelper::operator()(const Vector &ids) { for (const PointerRNA &ptr : ids) { BLI_assert(RNA_struct_is_ID(ptr.type)); @@ -332,7 +336,7 @@ bool AssetClearHelper::wasSuccessful() const return stats.tot_cleared > 0; } -static int asset_clear_exec(const bContext *C, const wmOperator *op, const Span ids) +static int asset_clear_exec(const bContext *C, const wmOperator *op, const Vector &ids) { const bool set_fake_user = RNA_boolean_get(op->ptr, "set_fake_user"); AssetClearHelper clear_helper(set_fake_user); @@ -349,7 +353,7 @@ static int asset_clear_exec(const bContext *C, const wmOperator *op, const Span< return OPERATOR_FINISHED; } -static bool asset_clear_poll(bContext *C, const Span ids) +static bool asset_clear_poll(bContext *C, const Vector &ids) { IDVecStats ctx_stats = asset_operation_get_id_vec_stats_from_ids(ids); @@ -587,7 +591,7 @@ static asset_system::AssetCatalogService *get_catalog_service(bContext *C) } asset_system::AssetLibrary *asset_lib = ED_fileselect_active_asset_library_get(sfile); - return asset_lib->catalog_service.get(); + return AS_asset_library_get_catalog_service(asset_lib); } static int asset_catalog_undo_exec(bContext *C, wmOperator * /*op*/) @@ -789,7 +793,7 @@ static int asset_bundle_install_exec(bContext *C, wmOperator *op) } /* Check file path, copied from #wm_file_write(). */ - char filepath[FILE_MAX]; + char filepath[PATH_MAX]; RNA_string_get(op->ptr, "filepath", filepath); const size_t len = strlen(filepath); @@ -921,7 +925,7 @@ static bool set_filepath_for_asset_lib(const Main *bmain, wmOperator *op) return false; } - char file_path[FILE_MAX]; + char file_path[PATH_MAX]; BLI_path_join(file_path, sizeof(file_path), lib->dirpath, blend_filename); RNA_string_set(op->ptr, "filepath", file_path); diff --git a/source/blender/editors/asset/intern/asset_shelf.cc b/source/blender/editors/asset/intern/asset_shelf.cc index b942d8c76e6..2f38901ca51 100644 --- a/source/blender/editors/asset/intern/asset_shelf.cc +++ b/source/blender/editors/asset/intern/asset_shelf.cc @@ -19,7 +19,7 @@ #include "BKE_main.hh" #include "BKE_screen.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_screen_types.h" diff --git a/source/blender/editors/asset/intern/asset_shelf_asset_view.cc b/source/blender/editors/asset/intern/asset_shelf_asset_view.cc index 6724ab09318..9d958d62896 100644 --- a/source/blender/editors/asset/intern/asset_shelf_asset_view.cc +++ b/source/blender/editors/asset/intern/asset_shelf_asset_view.cc @@ -18,6 +18,7 @@ #include "DNA_asset_types.h" #include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "ED_asset_handle.hh" #include "ED_asset_list.hh" @@ -25,6 +26,7 @@ #include "UI_grid_view.hh" #include "UI_interface.hh" +#include "UI_view2d.hh" #include "RNA_access.hh" #include "RNA_prototypes.h" diff --git a/source/blender/editors/asset/intern/asset_shelf_catalog_selector.cc b/source/blender/editors/asset/intern/asset_shelf_catalog_selector.cc index 37e1d2f8b32..4011de16e54 100644 --- a/source/blender/editors/asset/intern/asset_shelf_catalog_selector.cc +++ b/source/blender/editors/asset/intern/asset_shelf_catalog_selector.cc @@ -10,6 +10,7 @@ #include "AS_asset_catalog.hh" #include "AS_asset_catalog_tree.hh" +#include "AS_asset_library.hh" #include "BLI_string.h" @@ -18,7 +19,7 @@ #include "BKE_context.hh" #include "BKE_screen.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "ED_asset_filter.hh" #include "ED_asset_list.hh" diff --git a/source/blender/editors/asset/intern/asset_temp_id_consumer.cc b/source/blender/editors/asset/intern/asset_temp_id_consumer.cc index 51f4a16bcf8..51f2833be90 100644 --- a/source/blender/editors/asset/intern/asset_temp_id_consumer.cc +++ b/source/blender/editors/asset/intern/asset_temp_id_consumer.cc @@ -14,11 +14,11 @@ #include "AS_asset_representation.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BLI_utility_mixins.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/curve/curve_ops.cc b/source/blender/editors/curve/curve_ops.cc index ae5d5b03209..0a9993ccd37 100644 --- a/source/blender/editors/curve/curve_ops.cc +++ b/source/blender/editors/curve/curve_ops.cc @@ -9,6 +9,7 @@ #include #include +#include "DNA_curve_types.h" #include "DNA_scene_types.h" #include "RNA_access.hh" diff --git a/source/blender/editors/curve/editcurve.cc b/source/blender/editors/curve/editcurve.cc index 582a505dcf5..ca9136712d4 100644 --- a/source/blender/editors/curve/editcurve.cc +++ b/source/blender/editors/curve/editcurve.cc @@ -21,7 +21,7 @@ #include "BLI_math_rotation.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" #include "BKE_anim_data.h" @@ -29,14 +29,14 @@ #include "BKE_curve.hh" #include "BKE_displist.h" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_key.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_modifier.hh" #include "BKE_object_types.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" @@ -5016,7 +5016,7 @@ bool ed_editnurb_spin( invert_m3_m3(persinv, persmat); /* imat and center and size */ - copy_m3_m4(bmat, obedit->object_to_world().ptr()); + copy_m3_m4(bmat, obedit->object_to_world); invert_m3_m3(imat, bmat); axis_angle_to_mat3(cmat, axis, M_PI_4); @@ -5110,8 +5110,8 @@ static int spin_exec(bContext *C, wmOperator *op) continue; } - invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); - mul_m4_v3(obedit->world_to_object().ptr(), cent); + invert_m4_m4(obedit->world_to_object, obedit->object_to_world); + mul_m4_v3(obedit->world_to_object, cent); if (!ed_editnurb_spin(viewmat, v3d, obedit, axis, cent)) { count_failed += 1; @@ -5589,7 +5589,7 @@ static int add_vertex_exec(bContext *C, wmOperator *op) RNA_float_get_array(op->ptr, "location", location); - invert_m4_m4(imat, obedit->object_to_world().ptr()); + invert_m4_m4(imat, obedit->object_to_world); mul_m4_v3(imat, location); if (ed_editcurve_addvert(cu, editnurb, v3d, location)) { @@ -5628,10 +5628,10 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) ED_curve_nurb_vert_selected_find(cu, vc.v3d, &nu, &bezt, &bp); if (bezt) { - mul_v3_m4v3(location, vc.obedit->object_to_world().ptr(), bezt->vec[1]); + mul_v3_m4v3(location, vc.obedit->object_to_world, bezt->vec[1]); } else if (bp) { - mul_v3_m4v3(location, vc.obedit->object_to_world().ptr(), bp->vec); + mul_v3_m4v3(location, vc.obedit->object_to_world, bp->vec); } else { copy_v3_v3(location, vc.scene->cursor.location); @@ -5672,17 +5672,17 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) ED_view3d_global_to_vector(vc.rv3d, location, view_dir); /* get the plane */ - const float *plane_co = vc.obedit->object_to_world().location(); - float plane_no[3]; + float plane[4]; /* only normalize to avoid precision errors */ - normalize_v3_v3(plane_no, vc.obedit->object_to_world()[2]); + normalize_v3_v3(plane, vc.obedit->object_to_world[2]); + plane[3] = -dot_v3v3(plane, vc.obedit->object_to_world[3]); - if (fabsf(dot_v3v3(view_dir, plane_no)) < eps) { + if (fabsf(dot_v3v3(view_dir, plane)) < eps) { /* can't project on an aligned plane. */ } else { float lambda; - if (isect_ray_plane_v3_factor(location, view_dir, plane_co, plane_no, &lambda)) { + if (isect_ray_plane_v3(location, view_dir, plane, &lambda, false)) { /* check if we're behind the viewport */ float location_test[3]; madd_v3_v3v3fl(location_test, location, view_dir, lambda); @@ -6922,7 +6922,7 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op) /* Inverse transform for all selected curves in this object, * See object_join_exec for detailed comment on why the safe version is used. */ - invert_m4_m4_safe_ortho(imat, ob_active->object_to_world().ptr()); + invert_m4_m4_safe_ortho(imat, ob_active->object_to_world); Curve *cu_active = static_cast(ob_active->data); @@ -6934,7 +6934,7 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op) if (cu->nurb.first) { /* watch it: switch order here really goes wrong */ - mul_m4_m4m4(cmat, imat, ob_iter->object_to_world().ptr()); + mul_m4_m4m4(cmat, imat, ob_iter->object_to_world); /* Compensate for different bevel depth. */ bool do_radius = false; diff --git a/source/blender/editors/curve/editcurve_add.cc b/source/blender/editors/curve/editcurve_add.cc index b9c78fa0cdd..e18710c5135 100644 --- a/source/blender/editors/curve/editcurve_add.cc +++ b/source/blender/editors/curve/editcurve_add.cc @@ -12,10 +12,11 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_curve.hh" diff --git a/source/blender/editors/curve/editcurve_paint.cc b/source/blender/editors/curve/editcurve_paint.cc index a44314f33cf..a942c83ec34 100644 --- a/source/blender/editors/curve/editcurve_paint.cc +++ b/source/blender/editors/curve/editcurve_paint.cc @@ -11,6 +11,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" #include "BLI_mempool.h" @@ -18,8 +19,7 @@ #include "BKE_context.hh" #include "BKE_curve.hh" #include "BKE_fcurve.h" -#include "BKE_object_types.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" @@ -153,8 +153,7 @@ static void stroke_elem_pressure_set(const CurveDrawData *cdd, StrokeElem *selem const float adjust = stroke_elem_radius_from_pressure(cdd, pressure) - stroke_elem_radius_from_pressure(cdd, selem->pressure); madd_v3_v3fl(selem->location_local, selem->normal_local, adjust); - mul_v3_m4v3( - selem->location_world, cdd->vc.obedit->object_to_world().ptr(), selem->location_local); + mul_v3_m4v3(selem->location_world, cdd->vc.obedit->object_to_world, selem->location_local); } selem->pressure = pressure; } @@ -251,11 +250,11 @@ static bool stroke_elem_project_fallback(const CurveDrawData *cdd, cdd->vc.v3d, cdd->vc.region, location_fallback_depth, mval_fl, r_location_world); zero_v3(r_normal_local); } - mul_v3_m4v3(r_location_local, cdd->vc.obedit->world_to_object().ptr(), r_location_world); + mul_v3_m4v3(r_location_local, cdd->vc.obedit->world_to_object, r_location_world); if (!is_zero_v3(r_normal_world)) { copy_v3_v3(r_normal_local, r_normal_world); - mul_transposed_mat3_m4_v3(cdd->vc.obedit->object_to_world().ptr(), r_normal_local); + mul_transposed_mat3_m4_v3(cdd->vc.obedit->object_to_world, r_normal_local); normalize_v3(r_normal_local); } else { @@ -310,8 +309,7 @@ static void curve_draw_stroke_from_operator_elem(wmOperator *op, PointerRNA *ite RNA_float_get_array(itemptr, "mouse", selem->mval); RNA_float_get_array(itemptr, "location", selem->location_world); - mul_v3_m4v3( - selem->location_local, cdd->vc.obedit->world_to_object().ptr(), selem->location_world); + mul_v3_m4v3(selem->location_local, cdd->vc.obedit->world_to_object, selem->location_world); selem->pressure = RNA_float_get(itemptr, "pressure"); } @@ -374,7 +372,7 @@ static void curve_draw_stroke_3d(const bContext * /*C*/, ARegion * /*region*/, v /* scale to edit-mode space */ GPU_matrix_push(); - GPU_matrix_mul(obedit->object_to_world().ptr()); + GPU_matrix_mul(obedit->object_to_world); BLI_mempool_iternew(cdd->stroke_elem_pool, &iter); for (selem = static_cast(BLI_mempool_iterstep(&iter)); selem; @@ -456,7 +454,7 @@ static void curve_draw_event_add(wmOperator *op, const wmEvent *event) CurveDrawData *cdd = static_cast(op->customdata); Object *obedit = cdd->vc.obedit; - invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); + invert_m4_m4(obedit->world_to_object, obedit->object_to_world); StrokeElem *selem = static_cast(BLI_mempool_calloc(cdd->stroke_elem_pool)); @@ -779,7 +777,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op) int stroke_len = BLI_mempool_len(cdd->stroke_elem_pool); const bool is_3d = (cu->flag & CU_3D) != 0; - invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); + invert_m4_m4(obedit->world_to_object, obedit->object_to_world); if (BLI_mempool_len(cdd->stroke_elem_pool) == 0) { curve_draw_stroke_from_operator(op); @@ -1098,8 +1096,8 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (CU_IS_2D(cu)) { /* 2D overrides other options */ - plane_co = obedit->object_to_world().location(); - plane_no = obedit->object_to_world().ptr()[2]; + plane_co = obedit->object_to_world[3]; + plane_no = obedit->object_to_world[2]; cdd->project.use_plane = true; } else { diff --git a/source/blender/editors/curve/editcurve_pen.cc b/source/blender/editors/curve/editcurve_pen.cc index cb1d2b72982..b10ccb31260 100644 --- a/source/blender/editors/curve/editcurve_pen.cc +++ b/source/blender/editors/curve/editcurve_pen.cc @@ -28,6 +28,8 @@ #include "ED_select_utils.hh" #include "ED_view3d.hh" +#include "BKE_object.hh" + #include "curve_intern.h" #include "RNA_access.hh" @@ -151,17 +153,17 @@ static void update_location_for_2d_curve(const ViewContext *vc, float location[3 ED_view3d_global_to_vector(vc->rv3d, location, view_dir); /* Get the plane. */ - const float *plane_co = vc->obedit->object_to_world().location(); - float plane_no[3]; + float plane[4]; /* Only normalize to avoid precision errors. */ - normalize_v3_v3(plane_no, vc->obedit->object_to_world()[2]); + normalize_v3_v3(plane, vc->obedit->object_to_world[2]); + plane[3] = -dot_v3v3(plane, vc->obedit->object_to_world[3]); - if (fabsf(dot_v3v3(view_dir, plane_no)) < eps) { + if (fabsf(dot_v3v3(view_dir, plane)) < eps) { /* Can't project on an aligned plane. */ } else { float lambda; - if (isect_ray_plane_v3_factor(location, view_dir, plane_co, plane_no, &lambda)) { + if (isect_ray_plane_v3(location, view_dir, plane, &lambda, false)) { /* Check if we're behind the viewport */ float location_test[3]; madd_v3_v3v3fl(location_test, location, view_dir, lambda); @@ -175,7 +177,7 @@ static void update_location_for_2d_curve(const ViewContext *vc, float location[3 } float imat[4][4]; - invert_m4_m4(imat, vc->obedit->object_to_world().ptr()); + invert_m4_m4(imat, vc->obedit->object_to_world); mul_m4_v3(imat, location); if (CU_IS_2D(cu)) { @@ -188,7 +190,7 @@ static void screenspace_to_worldspace(const ViewContext *vc, const float depth[3], float r_pos_3d[3]) { - mul_v3_m4v3(r_pos_3d, vc->obedit->object_to_world().ptr(), depth); + mul_v3_m4v3(r_pos_3d, vc->obedit->object_to_world, depth); ED_view3d_win_to_3d(vc->v3d, vc->region, r_pos_3d, pos_2d, r_pos_3d); update_location_for_2d_curve(vc, r_pos_3d); } @@ -1102,7 +1104,7 @@ static void extrude_points_from_selected_vertices(const ViewContext *vc, float location[3]; if (sel_exists) { - mul_v3_m4v3(location, vc->obedit->object_to_world().ptr(), center); + mul_v3_m4v3(location, vc->obedit->object_to_world, center); } else { copy_v3_v3(location, vc->scene->cursor.location); diff --git a/source/blender/editors/curve/editcurve_query.cc b/source/blender/editors/curve/editcurve_query.cc index 4619c974354..b604cf275c2 100644 --- a/source/blender/editors/curve/editcurve_query.cc +++ b/source/blender/editors/curve/editcurve_query.cc @@ -18,6 +18,9 @@ #include "BKE_fcurve.h" #include "BKE_layer.hh" +#include "DEG_depsgraph.hh" +#include "DEG_depsgraph_build.hh" + #include "ED_curve.hh" #include "ED_view3d.hh" diff --git a/source/blender/editors/curve/editcurve_select.cc b/source/blender/editors/curve/editcurve_select.cc index e0cf34b5e78..5061500d3b1 100644 --- a/source/blender/editors/curve/editcurve_select.cc +++ b/source/blender/editors/curve/editcurve_select.cc @@ -23,7 +23,7 @@ #include "BKE_curve.hh" #include "BKE_fcurve.h" #include "BKE_layer.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "WM_api.hh" #include "WM_types.hh" @@ -1508,7 +1508,7 @@ static void nurb_bezt_direction_worldspace_get(Object *ob, { float rsmat[3][3]; BKE_nurb_bezt_calc_normal(nu, bezt, r_dir); - copy_m3_m4(rsmat, ob->object_to_world().ptr()); + copy_m3_m4(rsmat, ob->object_to_world); mul_m3_v3(rsmat, r_dir); normalize_v3(r_dir); } @@ -1517,7 +1517,7 @@ static void nurb_bpoint_direction_worldspace_get(Object *ob, Nurb *nu, BPoint *b { float rsmat[3][3]; BKE_nurb_bpoint_calc_normal(nu, bp, r_dir); - copy_m3_m4(rsmat, ob->object_to_world().ptr()); + copy_m3_m4(rsmat, ob->object_to_world); mul_m3_v3(rsmat, r_dir); normalize_v3(r_dir); } diff --git a/source/blender/editors/curve/editfont.cc b/source/blender/editors/curve/editfont.cc index 9494f0c8e76..c08f66eafa1 100644 --- a/source/blender/editors/curve/editfont.cc +++ b/source/blender/editors/curve/editfont.cc @@ -33,12 +33,12 @@ #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_vfont.hh" #include "BLI_string_utf8.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" @@ -1956,8 +1956,7 @@ static int font_cursor_text_index_from_event(bContext *C, Object *obedit, const { /* Calculate a plane from the text object's orientation. */ float plane[4]; - plane_from_point_normal_v3( - plane, obedit->object_to_world().location(), obedit->object_to_world().ptr()[2]); + plane_from_point_normal_v3(plane, obedit->object_to_world[3], obedit->object_to_world[2]); /* Convert Mouse location in region to 3D location in world space. */ float mal_fl[2] = {float(event->mval[0]), float(event->mval[1])}; @@ -1965,7 +1964,7 @@ static int font_cursor_text_index_from_event(bContext *C, Object *obedit, const ED_view3d_win_to_3d_on_plane(CTX_wm_region(C), plane, mal_fl, true, mouse_loc); /* Convert to object space and scale by font size. */ - mul_m4_v3(obedit->world_to_object().ptr(), mouse_loc); + mul_m4_v3(obedit->world_to_object, mouse_loc); float curs_loc[2] = {mouse_loc[0], mouse_loc[1]}; return BKE_vfont_cursor_to_text_index(obedit, curs_loc); diff --git a/source/blender/editors/curve/editfont_undo.cc b/source/blender/editors/curve/editfont_undo.cc index 68954f8e1c5..bc8ed2a85b3 100644 --- a/source/blender/editors/curve/editfont_undo.cc +++ b/source/blender/editors/curve/editfont_undo.cc @@ -13,11 +13,12 @@ #include "CLG_log.h" -#include "BLI_array_utils.h" /* For `BLI_array_is_zeroed`. */ +#include "BLI_array_utils.h" #include "BLI_utildefines.h" #include "DNA_curve_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BKE_context.hh" #include "BKE_layer.hh" @@ -28,6 +29,7 @@ #include "DEG_depsgraph.hh" #include "ED_curve.hh" +#include "ED_object.hh" #include "ED_undo.hh" #include "WM_api.hh" diff --git a/source/blender/editors/curves/intern/curves_add.cc b/source/blender/editors/curves/intern/curves_add.cc index 027a0faa126..980ec5765f3 100644 --- a/source/blender/editors/curves/intern/curves_add.cc +++ b/source/blender/editors/curves/intern/curves_add.cc @@ -12,9 +12,10 @@ #include "BKE_attribute.hh" #include "BKE_context.hh" #include "BKE_curves.hh" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "ED_curves.hh" #include "ED_node.hh" diff --git a/source/blender/editors/curves/intern/curves_attribute_set.cc b/source/blender/editors/curves/intern/curves_attribute_set.cc index ea31169b749..5e35b12b6e8 100644 --- a/source/blender/editors/curves/intern/curves_attribute_set.cc +++ b/source/blender/editors/curves/intern/curves_attribute_set.cc @@ -11,7 +11,7 @@ #include "BKE_attribute.hh" #include "BKE_attribute_math.hh" #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_type_conversions.hh" #include "WM_api.hh" @@ -26,7 +26,7 @@ #include "RNA_access.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/editors/curves/intern/curves_draw.cc b/source/blender/editors/curves/intern/curves_draw.cc index ff440721594..593e94d7717 100644 --- a/source/blender/editors/curves/intern/curves_draw.cc +++ b/source/blender/editors/curves/intern/curves_draw.cc @@ -12,8 +12,7 @@ #include "BKE_attribute.hh" #include "BKE_context.hh" #include "BKE_curves.hh" -#include "BKE_object_types.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" @@ -141,8 +140,7 @@ static void stroke_elem_pressure_set(const CurveDrawData *cdd, StrokeElem *selem const float adjust = stroke_elem_radius_from_pressure(cdd, pressure) - stroke_elem_radius_from_pressure(cdd, selem->pressure); madd_v3_v3fl(selem->location_local, selem->normal_local, adjust); - mul_v3_m4v3( - selem->location_world, cdd->vc.obedit->object_to_world().ptr(), selem->location_local); + mul_v3_m4v3(selem->location_world, cdd->vc.obedit->object_to_world, selem->location_local); } selem->pressure = pressure; } @@ -239,11 +237,11 @@ static bool stroke_elem_project_fallback(const CurveDrawData *cdd, cdd->vc.v3d, cdd->vc.region, location_fallback_depth, mval_fl, r_location_world); zero_v3(r_normal_local); } - mul_v3_m4v3(r_location_local, cdd->vc.obedit->world_to_object().ptr(), r_location_world); + mul_v3_m4v3(r_location_local, cdd->vc.obedit->world_to_object, r_location_world); if (!is_zero_v3(r_normal_world)) { copy_v3_v3(r_normal_local, r_normal_world); - mul_transposed_mat3_m4_v3(cdd->vc.obedit->object_to_world().ptr(), r_normal_local); + mul_transposed_mat3_m4_v3(cdd->vc.obedit->object_to_world, r_normal_local); normalize_v3(r_normal_local); } else { @@ -298,8 +296,7 @@ static void curve_draw_stroke_from_operator_elem(wmOperator *op, PointerRNA *ite RNA_float_get_array(itemptr, "mouse", selem->mval); RNA_float_get_array(itemptr, "location", selem->location_world); - mul_v3_m4v3( - selem->location_local, cdd->vc.obedit->world_to_object().ptr(), selem->location_world); + mul_v3_m4v3(selem->location_local, cdd->vc.obedit->world_to_object, selem->location_world); selem->pressure = RNA_float_get(itemptr, "pressure"); } @@ -357,7 +354,7 @@ static void curve_draw_stroke_3d(const bContext * /*C*/, ARegion * /*region*/, v /* scale to edit-mode space */ GPU_matrix_push(); - GPU_matrix_mul(obedit->object_to_world().ptr()); + GPU_matrix_mul(obedit->object_to_world); BLI_mempool_iternew(cdd->stroke_elem_pool, &iter); for (selem = static_cast(BLI_mempool_iterstep(&iter)); selem; @@ -439,7 +436,7 @@ static void curve_draw_event_add(wmOperator *op, const wmEvent *event) CurveDrawData *cdd = static_cast(op->customdata); Object *obedit = cdd->vc.obedit; - invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); + invert_m4_m4(obedit->world_to_object, obedit->object_to_world); StrokeElem *selem = static_cast(BLI_mempool_calloc(cdd->stroke_elem_pool)); @@ -743,7 +740,7 @@ static int curves_draw_exec(bContext *C, wmOperator *op) int stroke_len = BLI_mempool_len(cdd->stroke_elem_pool); - invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); + invert_m4_m4(obedit->world_to_object, obedit->object_to_world); if (BLI_mempool_len(cdd->stroke_elem_pool) == 0) { curve_draw_stroke_from_operator(op); @@ -1043,8 +1040,8 @@ static int curves_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (cdd->is_curve_2d) { /* 2D overrides other options */ - plane_co = obedit->object_to_world().location(); - plane_no = obedit->object_to_world().ptr()[2]; + plane_co = obedit->object_to_world[3]; + plane_no = obedit->object_to_world[2]; cdd->project.use_plane = true; } else { diff --git a/source/blender/editors/curves/intern/curves_extrude.cc b/source/blender/editors/curves/intern/curves_extrude.cc index acf32fbc43d..1ad9896b2e3 100644 --- a/source/blender/editors/curves/intern/curves_extrude.cc +++ b/source/blender/editors/curves/intern/curves_extrude.cc @@ -3,6 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "BKE_attribute.hh" +#include "BKE_context.hh" #include "BKE_curves_utils.hh" #include "WM_api.hh" diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index 553e073cbc0..c685ee546b2 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -18,7 +18,7 @@ #include "BLI_utildefines.h" #include "BLI_vector_set.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "ED_curves.hh" #include "ED_object.hh" @@ -43,7 +43,7 @@ #include "BKE_object.hh" #include "BKE_paint.hh" #include "BKE_particle.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -485,7 +485,7 @@ static bke::CurvesGeometry particles_to_curves(Object &object, ParticleSystem &p bke::CurvesGeometry curves(points_num, curves_num); curves.offsets_for_write().copy_from(curve_offsets); - const float4x4 object_to_world_mat = object.object_to_world(); + const float4x4 object_to_world_mat(object.object_to_world); const float4x4 world_to_object_mat = math::invert(object_to_world_mat); MutableSpan positions = curves.positions_for_write(); @@ -548,7 +548,7 @@ static int curves_convert_from_particle_system_exec(bContext *C, wmOperator * /* Object *ob_new = BKE_object_add(&bmain, &scene, &view_layer, OB_CURVES, psys_eval->name); Curves *curves_id = static_cast(ob_new->data); - BKE_object_apply_mat4(ob_new, ob_from_orig->object_to_world().ptr(), true, false); + BKE_object_apply_mat4(ob_new, ob_from_orig->object_to_world, true, false); curves_id->geometry.wrap() = particles_to_curves(*ob_from_eval, *psys_eval); DEG_relations_tag_update(&bmain); diff --git a/source/blender/editors/curves/intern/curves_selection.cc b/source/blender/editors/curves/intern/curves_selection.cc index 31ce47e9398..8844b0bc30f 100644 --- a/source/blender/editors/curves/intern/curves_selection.cc +++ b/source/blender/editors/curves/intern/curves_selection.cc @@ -525,13 +525,16 @@ void apply_selection_operation_at_index(GMutableSpan selection, static std::optional find_closest_point_to_screen_co( const ARegion *region, + const RegionView3D *rv3d, + const Object &object, const Span positions, - const float4x4 &projection, const IndexMask &points_mask, const float2 mouse_pos, float radius, const FindClosestData &initial_closest) { + const float4x4 projection = ED_view3d_ob_project_mat_get(rv3d, &object); + const float radius_sq = pow2f(radius); const FindClosestData new_closest_data = threading::parallel_reduce( points_mask.index_range(), @@ -578,14 +581,17 @@ static std::optional find_closest_point_to_screen_co( static std::optional find_closest_curve_to_screen_co( const ARegion *region, + const RegionView3D *rv3d, + const Object &object, const OffsetIndices points_by_curve, const Span positions, - const float4x4 &projection, const IndexMask &curves_mask, const float2 mouse_pos, float radius, const FindClosestData &initial_closest) { + const float4x4 projection = ED_view3d_ob_project_mat_get(rv3d, &object); + const float radius_sq = pow2f(radius); const FindClosestData new_closest_data = threading::parallel_reduce( @@ -661,9 +667,9 @@ static std::optional find_closest_curve_to_screen_co( std::optional closest_elem_find_screen_space( const ViewContext &vc, + const Object &object, const OffsetIndices points_by_curve, const Span positions, - const float4x4 &projection, const IndexMask &mask, const bke::AttrDomain domain, const int2 coord, @@ -672,17 +678,19 @@ std::optional closest_elem_find_screen_space( switch (domain) { case bke::AttrDomain::Point: return find_closest_point_to_screen_co(vc.region, + vc.rv3d, + object, positions, - projection, mask, float2(coord), ED_view3d_select_dist_px(), initial_closest); case bke::AttrDomain::Curve: return find_closest_curve_to_screen_co(vc.region, + vc.rv3d, + object, points_by_curve, positions, - projection, mask, float2(coord), ED_view3d_select_dist_px(), @@ -696,7 +704,6 @@ std::optional closest_elem_find_screen_space( bool select_box(const ViewContext &vc, bke::CurvesGeometry &curves, const Span positions, - const float4x4 &projection, const IndexMask &mask, const bke::AttrDomain selection_domain, const rcti &rect, @@ -711,6 +718,8 @@ bool select_box(const ViewContext &vc, changed = true; } + const float4x4 projection = ED_view3d_ob_project_mat_get(vc.rv3d, vc.obact); + const OffsetIndices points_by_curve = curves.points_by_curve(); if (selection_domain == bke::AttrDomain::Point) { mask.foreach_index(GrainSize(1024), [&](const int point_i) { @@ -757,15 +766,14 @@ bool select_box(const ViewContext &vc, bool select_lasso(const ViewContext &vc, bke::CurvesGeometry &curves, const Span positions, - const float4x4 &projection_matrix, const IndexMask &mask, const bke::AttrDomain selection_domain, - const Span lasso_coords, + const Span coords, const eSelectOp sel_op) { rcti bbox; - const int(*coord_array)[2] = reinterpret_cast(lasso_coords.data()); - BLI_lasso_boundbox(&bbox, coord_array, lasso_coords.size()); + const int(*coord_array)[2] = reinterpret_cast(coords.data()); + BLI_lasso_boundbox(&bbox, coord_array, coords.size()); bke::GSpanAttributeWriter selection = ensure_selection_attribute( curves, selection_domain, CD_PROP_BOOL); @@ -776,15 +784,17 @@ bool select_lasso(const ViewContext &vc, changed = true; } + const float4x4 projection = ED_view3d_ob_project_mat_get(vc.rv3d, vc.obact); + const OffsetIndices points_by_curve = curves.points_by_curve(); if (selection_domain == bke::AttrDomain::Point) { mask.foreach_index(GrainSize(1024), [&](const int point_i) { const float2 pos_proj = ED_view3d_project_float_v2_m4( - vc.region, positions[point_i], projection_matrix); + vc.region, positions[point_i], projection); /* Check the lasso bounding box first as an optimization. */ if (BLI_rcti_isect_pt_v(&bbox, int2(pos_proj)) && BLI_lasso_is_point_inside( - coord_array, lasso_coords.size(), int(pos_proj.x), int(pos_proj.y), IS_CLIPPED)) + coord_array, coords.size(), int(pos_proj.x), int(pos_proj.y), IS_CLIPPED)) { apply_selection_operation_at_index(selection.span, point_i, sel_op); changed = true; @@ -796,11 +806,11 @@ bool select_lasso(const ViewContext &vc, const IndexRange points = points_by_curve[curve_i]; if (points.size() == 1) { const float2 pos_proj = ED_view3d_project_float_v2_m4( - vc.region, positions[points.first()], projection_matrix); + vc.region, positions[points.first()], projection); /* Check the lasso bounding box first as an optimization. */ if (BLI_rcti_isect_pt_v(&bbox, int2(pos_proj)) && BLI_lasso_is_point_inside( - coord_array, lasso_coords.size(), int(pos_proj.x), int(pos_proj.y), IS_CLIPPED)) + coord_array, coords.size(), int(pos_proj.x), int(pos_proj.y), IS_CLIPPED)) { apply_selection_operation_at_index(selection.span, curve_i, sel_op); changed = true; @@ -811,13 +821,13 @@ bool select_lasso(const ViewContext &vc, const float3 pos1 = positions[segment_i]; const float3 pos2 = positions[segment_i + 1]; - const float2 pos1_proj = ED_view3d_project_float_v2_m4(vc.region, pos1, projection_matrix); - const float2 pos2_proj = ED_view3d_project_float_v2_m4(vc.region, pos2, projection_matrix); + const float2 pos1_proj = ED_view3d_project_float_v2_m4(vc.region, pos1, projection); + const float2 pos2_proj = ED_view3d_project_float_v2_m4(vc.region, pos2, projection); /* Check the lasso bounding box first as an optimization. */ if (BLI_rcti_isect_segment(&bbox, int2(pos1_proj), int2(pos2_proj)) && BLI_lasso_is_edge_inside(coord_array, - lasso_coords.size(), + coords.size(), int(pos1_proj.x), int(pos1_proj.y), int(pos2_proj.x), @@ -839,7 +849,6 @@ bool select_lasso(const ViewContext &vc, bool select_circle(const ViewContext &vc, bke::CurvesGeometry &curves, const Span positions, - const float4x4 &projection, const IndexMask &mask, const bke::AttrDomain selection_domain, const int2 coord, @@ -856,6 +865,8 @@ bool select_circle(const ViewContext &vc, changed = true; } + const float4x4 projection = ED_view3d_ob_project_mat_get(vc.rv3d, vc.obact); + const OffsetIndices points_by_curve = curves.points_by_curve(); if (selection_domain == bke::AttrDomain::Point) { mask.foreach_index(GrainSize(1024), [&](const int point_i) { diff --git a/source/blender/editors/geometry/geometry_attributes.cc b/source/blender/editors/geometry/geometry_attributes.cc index 1ba0b37d8dd..33b2128cfc3 100644 --- a/source/blender/editors/geometry/geometry_attributes.cc +++ b/source/blender/editors/geometry/geometry_attributes.cc @@ -23,11 +23,11 @@ #include "BKE_mesh.hh" #include "BKE_object_deform.h" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/editors/geometry/geometry_randomization.cc b/source/blender/editors/geometry/geometry_randomization.cc index a67e5db341f..050ea5c6cc1 100644 --- a/source/blender/editors/geometry/geometry_randomization.cc +++ b/source/blender/editors/geometry/geometry_randomization.cc @@ -5,7 +5,7 @@ #include "WM_api.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_main.hh" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/geometry/node_group_operator.cc b/source/blender/editors/geometry/node_group_operator.cc index 61638d51c66..f4f1f5aaa48 100644 --- a/source/blender/editors/geometry/node_group_operator.cc +++ b/source/blender/editors/geometry/node_group_operator.cc @@ -34,7 +34,7 @@ #include "BKE_node_runtime.hh" #include "BKE_object.hh" #include "BKE_pointcloud.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "DNA_object_types.h" @@ -56,7 +56,7 @@ #include "ED_mesh.hh" #include "ED_sculpt.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "FN_lazy_function_execute.hh" diff --git a/source/blender/editors/gizmo_library/gizmo_draw_utils.cc b/source/blender/editors/gizmo_library/gizmo_draw_utils.cc index e75cdb6af7a..019d2431a97 100644 --- a/source/blender/editors/gizmo_library/gizmo_draw_utils.cc +++ b/source/blender/editors/gizmo_library/gizmo_draw_utils.cc @@ -6,14 +6,25 @@ * \ingroup edgizmolib */ +#include "BLI_listbase.h" + +#include "BKE_context.hh" + +#include "ED_screen.hh" +#include "ED_view3d.hh" + #include "GPU_batch.h" #include "GPU_immediate.h" #include "MEM_guardedalloc.h" +#include "RNA_access.hh" + +#include "WM_api.hh" #include "WM_types.hh" /* only for own init/exit calls (wm_gizmotype_init/wm_gizmotype_free) */ +#include "wm.hh" /* own includes */ #include "gizmo_library_intern.h" diff --git a/source/blender/editors/gizmo_library/gizmo_library_presets.cc b/source/blender/editors/gizmo_library/gizmo_library_presets.cc index 22953a49ce2..0ab4879537e 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_presets.cc +++ b/source/blender/editors/gizmo_library/gizmo_library_presets.cc @@ -14,12 +14,19 @@ #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" +#include "BLI_math_vector.h" + +#include "BKE_context.hh" #include "GPU_matrix.h" #include "GPU_select.hh" +#include "DEG_depsgraph.hh" + #include "WM_types.hh" +#include "ED_view3d.hh" + /* own includes */ #include "ED_gizmo_library.hh" /* own include */ #include "gizmo_library_intern.h" /* own include */ diff --git a/source/blender/editors/gizmo_library/gizmo_library_utils.cc b/source/blender/editors/gizmo_library/gizmo_library_utils.cc index aa4b73bb55c..6cc2f4562ab 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_utils.cc +++ b/source/blender/editors/gizmo_library/gizmo_library_utils.cc @@ -14,7 +14,7 @@ #include "DNA_view3d_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_main.hh" #include "BLI_math_geom.h" diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.cc b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.cc index c5f244ed45d..47226d16863 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.cc +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.cc @@ -44,6 +44,8 @@ #include "ED_screen.hh" #include "ED_view3d.hh" +#include "UI_interface.hh" + /* own includes */ #include "../gizmo_geometry.h" #include "../gizmo_library_intern.h" @@ -363,11 +365,14 @@ static int gizmo_arrow_modal(bContext *C, float arrow_no_proj[3]; project_plane_v3_v3v3(arrow_no_proj, arrow_no, proj[j].ray_direction); + normalize_v3(arrow_no_proj); + float plane[4]; + plane_from_point_normal_v3(plane, proj[j].ray_origin, arrow_no_proj); + float lambda; - if (isect_ray_plane_v3_factor(arrow_co, arrow_no, proj[j].ray_origin, arrow_no_proj, &lambda)) - { + if (isect_ray_plane_v3(arrow_co, arrow_no, plane, &lambda, false)) { madd_v3_v3v3fl(proj[j].location, arrow_co, arrow_no, lambda); ok++; } diff --git a/source/blender/editors/gizmo_library/gizmo_types/blank3d_gizmo.cc b/source/blender/editors/gizmo_library/gizmo_types/blank3d_gizmo.cc index e0b7bf775b6..b9866614cc2 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/blank3d_gizmo.cc +++ b/source/blender/editors/gizmo_library/gizmo_types/blank3d_gizmo.cc @@ -10,6 +10,8 @@ * \brief Gizmo to use as a fallback (catch events). */ +#include "BKE_context.hh" + #include "ED_gizmo_library.hh" #include "WM_api.hh" diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.cc b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.cc index 99f9e258a07..1f46fc38ee7 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.cc +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.cc @@ -38,11 +38,15 @@ #include "WM_types.hh" #include "ED_gizmo_library.hh" +#include "ED_screen.hh" #include "ED_view3d.hh" +#include "UI_interface.hh" #include "UI_interface_icons.hh" +#include "UI_resources.hh" /* own includes */ +#include "../gizmo_geometry.h" #include "../gizmo_library_intern.h" /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.cc b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.cc index 544cb92296e..d6a68547db8 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.cc +++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.cc @@ -38,6 +38,7 @@ #include "ED_gizmo_library.hh" #include "ED_screen.hh" +#include "ED_view3d.hh" /* own includes */ #include "../gizmo_library_intern.h" diff --git a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.cc b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.cc index a7b086e2b28..af562be8fee 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.cc +++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.cc @@ -42,6 +42,7 @@ #include "ED_view3d.hh" /* own includes */ +#include "../gizmo_geometry.h" #include "../gizmo_library_intern.h" // /** To use custom dials exported to `geom_dial_gizmo.cc`. */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.cc b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.cc index 61ea403cd70..fb1c25bdeb2 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.cc +++ b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.cc @@ -41,6 +41,7 @@ #include "ED_view3d.hh" /* own includes */ +#include "../gizmo_geometry.h" #include "../gizmo_library_intern.h" #define MVAL_MAX_PX_DIST 12.0f diff --git a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.cc b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.cc index 700dc7c7fdf..d352b851caf 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.cc +++ b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.cc @@ -19,11 +19,14 @@ #include "DNA_space_types.h" #include "DNA_view3d_types.h" +#include "BKE_context.hh" + #include "GPU_immediate.h" #include "GPU_matrix.h" #include "GPU_select.hh" #include "GPU_state.h" +#include "RNA_access.hh" #include "RNA_define.hh" #include "WM_api.hh" diff --git a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.cc b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.cc index 78752d6d5ad..30b294326cf 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.cc +++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.cc @@ -14,15 +14,21 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" #include "BLI_math_color.h" #include "BLI_math_vector.h" #include "BKE_context.hh" +#include "BKE_global.h" +#include "BKE_main.hh" #include "ED_gizmo_library.hh" #include "ED_screen.hh" +#include "ED_transform_snap_object_context.hh" #include "ED_view3d.hh" +#include "UI_resources.hh" + #include "RNA_access.hh" #include "RNA_define.hh" #include "RNA_prototypes.h" diff --git a/source/blender/editors/gpencil_legacy/annotate_draw.cc b/source/blender/editors/gpencil_legacy/annotate_draw.cc index 700a1c80edd..67fb51dc7ad 100644 --- a/source/blender/editors/gpencil_legacy/annotate_draw.cc +++ b/source/blender/editors/gpencil_legacy/annotate_draw.cc @@ -20,7 +20,11 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" +#include "BLF_api.hh" +#include "BLT_translation.h" + #include "DNA_gpencil_legacy_types.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" @@ -28,7 +32,7 @@ #include "DNA_view3d_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_legacy.h" #include "WM_api.hh" @@ -39,8 +43,12 @@ #include "ED_gpencil_legacy.hh" #include "ED_screen.hh" +#include "ED_space_api.hh" #include "ED_view3d.hh" +#include "UI_interface_icons.hh" +#include "UI_resources.hh" + /* ************************************************** */ /* GREASE PENCIL DRAWING */ diff --git a/source/blender/editors/gpencil_legacy/annotate_paint.cc b/source/blender/editors/gpencil_legacy/annotate_paint.cc index 8831ed7608f..f5701212b6f 100644 --- a/source/blender/editors/gpencil_legacy/annotate_paint.cc +++ b/source/blender/editors/gpencil_legacy/annotate_paint.cc @@ -18,13 +18,16 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "BKE_context.hh" +#include "BKE_global.h" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" -#include "BKE_report.hh" +#include "BKE_layer.hh" +#include "BKE_main.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "BKE_tracking.h" @@ -51,6 +54,8 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "DEG_depsgraph.hh" + #include "gpencil_intern.h" /* ******************************************* */ @@ -2146,7 +2151,7 @@ static void annotation_draw_apply_event( } } - p->curtime = BLI_time_now_seconds(); + p->curtime = BLI_check_seconds_timer(); /* handle pressure sensitivity (which is supplied by tablets or otherwise 1.0) */ p->pressure = event->tablet.pressure; diff --git a/source/blender/editors/gpencil_legacy/drawgpencil.cc b/source/blender/editors/gpencil_legacy/drawgpencil.cc index 135bc184497..efcfde326c3 100644 --- a/source/blender/editors/gpencil_legacy/drawgpencil.cc +++ b/source/blender/editors/gpencil_legacy/drawgpencil.cc @@ -18,17 +18,33 @@ #include "BLI_sys_types.h" #include "BLI_math_matrix.h" +#include "BLI_polyfill_2d.h" #include "BLI_utildefines.h" +#include "BLF_api.hh" +#include "BLT_translation.h" + #include "DNA_brush_types.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_material_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "DNA_userdef_types.h" #include "DNA_view3d_types.h" +#include "BKE_brush.hh" +#include "BKE_context.hh" +#include "BKE_global.h" #include "BKE_gpencil_legacy.h" +#include "BKE_image.h" #include "BKE_material.h" +#include "BKE_paint.hh" + +#include "DEG_depsgraph.hh" + +#include "WM_api.hh" #include "GPU_batch.h" #include "GPU_immediate.h" @@ -38,6 +54,14 @@ #include "GPU_uniform_buffer.h" #include "ED_gpencil_legacy.hh" +#include "ED_screen.hh" +#include "ED_space_api.hh" +#include "ED_view3d.hh" + +#include "UI_interface_icons.hh" +#include "UI_resources.hh" + +#include "IMB_imbuf_types.hh" #include "gpencil_intern.h" diff --git a/source/blender/editors/gpencil_legacy/editaction_gpencil.cc b/source/blender/editors/gpencil_legacy/editaction_gpencil.cc index e3960e77d34..5c022634aa2 100644 --- a/source/blender/editors/gpencil_legacy/editaction_gpencil.cc +++ b/source/blender/editors/gpencil_legacy/editaction_gpencil.cc @@ -20,7 +20,9 @@ #include "DNA_gpencil_legacy_types.h" #include "DNA_scene_types.h" +#include "BKE_fcurve.h" #include "BKE_gpencil_legacy.h" +#include "BKE_report.h" #include "ED_anim_api.hh" #include "ED_gpencil_legacy.hh" diff --git a/source/blender/editors/gpencil_legacy/gpencil_add_blank.cc b/source/blender/editors/gpencil_legacy/gpencil_add_blank.cc index 045f0f8cf28..8d6a7ffa9ff 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_add_blank.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_add_blank.cc @@ -16,9 +16,12 @@ #include "DNA_scene_types.h" #include "BKE_context.hh" +#include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" +#include "BKE_main.hh" +#include "BKE_material.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/gpencil_legacy/gpencil_add_lineart.cc b/source/blender/editors/gpencil_legacy/gpencil_add_lineart.cc index b4477c79d46..25e3dee5de9 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_add_lineart.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_add_lineart.cc @@ -11,16 +11,23 @@ #include "DNA_gpencil_legacy_types.h" #include "DNA_material_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "BKE_brush.hh" #include "BKE_context.hh" +#include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" +#include "BKE_lib_id.hh" +#include "BKE_main.hh" +#include "BKE_material.h" #include "BLI_math_color.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph.hh" +#include "DEG_depsgraph_query.hh" #include "ED_gpencil_legacy.hh" diff --git a/source/blender/editors/gpencil_legacy/gpencil_add_monkey.cc b/source/blender/editors/gpencil_legacy/gpencil_add_monkey.cc index 152ea8adbe7..2a99e53bb1c 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_add_monkey.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_add_monkey.cc @@ -19,8 +19,10 @@ #include "BKE_context.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" +#include "BKE_main.hh" +#include "BKE_material.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/gpencil_legacy/gpencil_add_stroke.cc b/source/blender/editors/gpencil_legacy/gpencil_add_stroke.cc index 1ce5a2f51fd..57c9fb85a49 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_add_stroke.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_add_stroke.cc @@ -18,8 +18,10 @@ #include "BKE_context.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" +#include "BKE_main.hh" +#include "BKE_material.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/gpencil_legacy/gpencil_armature.cc b/source/blender/editors/gpencil_legacy/gpencil_armature.cc index 3d818b9416f..0c979105485 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_armature.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_armature.cc @@ -24,6 +24,7 @@ #include "DNA_armature_types.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_meshdata_types.h" +#include "DNA_scene_types.h" #include "BKE_action.h" #include "BKE_armature.hh" @@ -32,8 +33,9 @@ #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_layer.hh" +#include "BKE_main.hh" #include "BKE_object_deform.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "WM_api.hh" #include "WM_types.hh" @@ -338,8 +340,8 @@ static void gpencil_add_verts_to_dgroups( copy_v3_v3(tip[j], bone->arm_tail); } - mul_m4_v3(ob_arm->object_to_world().ptr(), root[j]); - mul_m4_v3(ob_arm->object_to_world().ptr(), tip[j]); + mul_m4_v3(ob_arm->object_to_world, root[j]); + mul_m4_v3(ob_arm->object_to_world, tip[j]); selected[j] = 1; @@ -374,7 +376,7 @@ static void gpencil_add_verts_to_dgroups( /* transform stroke points to global space */ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { copy_v3_v3(verts[i], &pt->x); - mul_m4_v3(ob->object_to_world().ptr(), verts[i]); + mul_m4_v3(ob->object_to_world, verts[i]); } /* loop groups and assign weight */ diff --git a/source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc b/source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc index b1e35ab659f..353b230c552 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc @@ -11,20 +11,26 @@ #include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_math_matrix.h" +#include "BLI_math_vector.h" #include "DNA_anim_types.h" #include "DNA_gpencil_legacy_types.h" +#include "DNA_material_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BKE_anim_data.h" #include "BKE_context.hh" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" +#include "BKE_layer.hh" +#include "BKE_main.hh" #include "BKE_material.h" -#include "BKE_scene.hh" +#include "BKE_object.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" @@ -216,7 +222,7 @@ static int gpencil_bake_grease_pencil_animation_exec(bContext *C, wmOperator *op ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0; ob_gpencil = ED_gpencil_add_object(C, scene->cursor.location, local_view_bits); float invmat[4][4]; - invert_m4_m4(invmat, ob_gpencil->object_to_world().ptr()); + invert_m4_m4(invmat, ob_gpencil->object_to_world); bGPdata *gpd_dst = (bGPdata *)ob_gpencil->data; gpd_dst->draw_mode = GP_DRAWMODE_2D; @@ -317,7 +323,7 @@ static int gpencil_bake_grease_pencil_animation_exec(bContext *C, wmOperator *op bGPDspoint *pt = &gps->points[j]; pt->runtime.idx_orig = 0; pt->runtime.pt_orig = nullptr; - mul_m4_v3(ob_eval->object_to_world().ptr(), &pt->x); + mul_m4_v3(ob_eval->object_to_world, &pt->x); mul_m4_v3(invmat, &pt->x); } diff --git a/source/blender/editors/gpencil_legacy/gpencil_convert.cc b/source/blender/editors/gpencil_legacy/gpencil_convert.cc index fa9315ba36c..bf5704057b6 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_convert.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_convert.cc @@ -21,7 +21,10 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" +#include "BLT_translation.h" + #include "DNA_anim_types.h" +#include "DNA_collection_types.h" #include "DNA_curve_types.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_material_types.h" @@ -33,21 +36,27 @@ #include "DNA_view3d_types.h" #include "BKE_animsys.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_context.hh" #include "BKE_curve.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_image.h" #include "BKE_layer.hh" +#include "BKE_main.hh" +#include "BKE_material.h" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_tracking.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" +#include "UI_interface.hh" + #include "WM_api.hh" #include "WM_types.hh" @@ -61,7 +70,9 @@ #include "ANIM_animdata.hh" #include "ANIM_keyframing.hh" +#include "ED_clip.hh" #include "ED_gpencil_legacy.hh" +#include "ED_keyframing.hh" #include "ED_object.hh" #include "ED_view3d.hh" diff --git a/source/blender/editors/gpencil_legacy/gpencil_data.cc b/source/blender/editors/gpencil_legacy/gpencil_data.cc index 312c8bd2f08..5aee0c140bf 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_data.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_data.cc @@ -25,16 +25,18 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_anim_types.h" #include "DNA_brush_types.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_material_types.h" #include "DNA_meshdata_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "DNA_view3d_types.h" #include "BKE_anim_data.h" @@ -48,8 +50,11 @@ #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_material.h" +#include "BKE_modifier.hh" +#include "BKE_object.hh" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "UI_interface.hh" #include "UI_resources.hh" @@ -66,6 +71,7 @@ #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" +#include "DEG_depsgraph_query.hh" #include "gpencil_intern.h" @@ -2972,8 +2978,8 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op) float offset_global[3]; float offset_local[3]; - sub_v3_v3v3(offset_global, ob_active->loc, ob_iter->object_to_world().location()); - copy_m3_m4(bmat, ob_active->object_to_world().ptr()); + sub_v3_v3v3(offset_global, ob_active->loc, ob_iter->object_to_world[3]); + copy_m3_m4(bmat, ob_active->object_to_world); /* Inverse transform for all selected curves in this object, * See #object_join_exec for detailed comment on why the safe version is used. */ diff --git a/source/blender/editors/gpencil_legacy/gpencil_edit.cc b/source/blender/editors/gpencil_legacy/gpencil_edit.cc index 43b10639880..d2bb28d8088 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_edit.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_edit.cc @@ -15,6 +15,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_lasso_2d.h" #include "BLI_math_matrix.h" @@ -22,9 +23,10 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_gpencil_legacy_types.h" +#include "DNA_gpencil_modifier_types.h" #include "DNA_material_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" @@ -36,16 +38,20 @@ #include "BKE_brush.hh" #include "BKE_context.hh" #include "BKE_deform.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_curve_legacy.h" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" +#include "BKE_layer.hh" #include "BKE_lib_id.hh" +#include "BKE_library.hh" #include "BKE_main.hh" #include "BKE_material.h" +#include "BKE_object.hh" #include "BKE_paint.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_workspace.h" #include "UI_interface.hh" #include "UI_resources.hh" @@ -57,13 +63,17 @@ #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "UI_view2d.hh" +#include "ED_armature.hh" #include "ED_gpencil_legacy.hh" #include "ED_object.hh" #include "ED_outliner.hh" #include "ED_screen.hh" +#include "ED_select_utils.hh" +#include "ED_space_api.hh" #include "ED_transform_snap_object_context.hh" #include "ED_view3d.hh" @@ -4184,7 +4194,7 @@ static int gpencil_stroke_outline_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *cam_ob = scene->camera; if (cam_ob != nullptr) { - invert_m4_m4(viewmat, cam_ob->object_to_world().ptr()); + invert_m4_m4(viewmat, cam_ob->object_to_world); } break; } @@ -4252,7 +4262,7 @@ static int gpencil_stroke_outline_exec(bContext *C, wmOperator *op) /* Apply layer thickness change. */ gps_duplicate->thickness += gpl->line_change; /* Apply object scale to thickness. */ - gps_duplicate->thickness *= mat4_to_scale(ob->object_to_world().ptr()); + gps_duplicate->thickness *= mat4_to_scale(ob->object_to_world); CLAMP_MIN(gps_duplicate->thickness, 1.0f); /* Stroke. */ diff --git a/source/blender/editors/gpencil_legacy/gpencil_edit_curve.cc b/source/blender/editors/gpencil_legacy/gpencil_edit_curve.cc index 3211aa5112c..34ae4cb554e 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_edit_curve.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_edit_curve.cc @@ -23,6 +23,7 @@ #include "BLI_listbase.h" #include "BLI_math_matrix.h" +#include "BLI_math_vector.h" #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/editors/gpencil_legacy/gpencil_fill.cc b/source/blender/editors/gpencil_legacy/gpencil_fill.cc index ca8d6fcd961..9a8e3f5e1fc 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_fill.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_fill.cc @@ -16,7 +16,7 @@ #include "BLI_stack.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_brush_types.h" #include "DNA_gpencil_legacy_types.h" @@ -26,15 +26,17 @@ #include "DNA_object_types.h" #include "DNA_windowmanager_types.h" +#include "BKE_brush.hh" #include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_image.h" #include "BKE_lib_id.hh" +#include "BKE_main.hh" #include "BKE_material.h" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "ED_gpencil_legacy.hh" @@ -61,6 +63,7 @@ #include "WM_types.hh" #include "DEG_depsgraph.hh" +#include "DEG_depsgraph_query.hh" #include "gpencil_intern.h" diff --git a/source/blender/editors/gpencil_legacy/gpencil_interpolate.cc b/source/blender/editors/gpencil_legacy/gpencil_interpolate.cc index 0c0661de1ef..7bc0cea1134 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_interpolate.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_interpolate.cc @@ -23,10 +23,11 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_color_types.h" #include "DNA_gpencil_legacy_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" @@ -37,7 +38,7 @@ #include "BKE_context.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/editors/gpencil_legacy/gpencil_merge.cc b/source/blender/editors/gpencil_legacy/gpencil_merge.cc index be5403af4aa..99c4e6b1bf6 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_merge.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_merge.cc @@ -11,6 +11,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_math_vector.h" @@ -21,8 +22,9 @@ #include "BKE_context.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" +#include "BKE_main.hh" #include "BKE_material.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "WM_api.hh" #include "WM_types.hh" @@ -30,6 +32,7 @@ #include "RNA_access.hh" #include "RNA_define.hh" +#include "ED_gpencil_legacy.hh" #include "ED_screen.hh" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/gpencil_legacy/gpencil_mesh.cc b/source/blender/editors/gpencil_legacy/gpencil_mesh.cc index c3e995562ba..976c4c8786d 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_mesh.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_mesh.cc @@ -9,6 +9,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_math_rotation.h" @@ -19,13 +20,14 @@ #include "BKE_anim_data.h" #include "BKE_context.hh" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_gpencil_geom_legacy.h" #include "BKE_layer.hh" +#include "BKE_main.hh" #include "BKE_material.h" #include "BKE_object.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" @@ -296,7 +298,7 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op) angle, thickness, offset, - ob_eval->object_to_world().ptr(), + ob_eval->object_to_world, frame_offset, use_seams, use_faces, diff --git a/source/blender/editors/gpencil_legacy/gpencil_ops_versioning.cc b/source/blender/editors/gpencil_legacy/gpencil_ops_versioning.cc index e056880d93f..b8a891f9a25 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_ops_versioning.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_ops_versioning.cc @@ -24,6 +24,7 @@ #include "BKE_context.hh" #include "BKE_gpencil_legacy.h" +#include "BKE_main.hh" #include "BKE_object.hh" #include "WM_api.hh" diff --git a/source/blender/editors/gpencil_legacy/gpencil_paint.cc b/source/blender/editors/gpencil_legacy/gpencil_paint.cc index fec2615c335..cc9bf609adb 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_paint.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_paint.cc @@ -14,6 +14,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_hash.h" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" @@ -22,7 +23,7 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_brush_types.h" #include "DNA_gpencil_legacy_types.h" @@ -36,19 +37,24 @@ #include "BKE_colortools.hh" #include "BKE_context.hh" #include "BKE_deform.hh" +#include "BKE_global.h" #include "BKE_gpencil_curve_legacy.h" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_update_cache_legacy.h" +#include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_material.h" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" +#include "BKE_tracking.h" #include "UI_view2d.hh" +#include "ED_clip.hh" #include "ED_gpencil_legacy.hh" +#include "ED_object.hh" #include "ED_screen.hh" #include "ED_view3d.hh" @@ -937,7 +943,7 @@ static bGPDstroke *gpencil_stroke_to_outline(tGPsdata *p, bGPDstroke *gps) /* Apply layer thickness change. */ gps_duplicate->thickness += gpl->line_change; /* Apply object scale to thickness. */ - gps_duplicate->thickness *= mat4_to_scale(p->ob->object_to_world().ptr()); + gps_duplicate->thickness *= mat4_to_scale(p->ob->object_to_world); CLAMP_MIN(gps_duplicate->thickness, 1.0f); /* Stroke. */ @@ -2159,7 +2165,7 @@ static tGPsdata *gpencil_session_initpaint(bContext *C, wmOperator *op) } /* Random generator, only init once. */ - uint rng_seed = uint(BLI_time_now_seconds_i() & UINT_MAX); + uint rng_seed = uint(BLI_check_seconds_timer_i() & UINT_MAX); rng_seed ^= POINTER_AS_UINT(p); p->rng = BLI_rng_new(rng_seed); @@ -2961,7 +2967,7 @@ static void gpencil_draw_apply_event(bContext *C, } } - p->curtime = BLI_time_now_seconds(); + p->curtime = BLI_check_seconds_timer(); /* handle pressure sensitivity (which is supplied by tablets or otherwise 1.0) */ p->pressure = event->tablet.pressure; diff --git a/source/blender/editors/gpencil_legacy/gpencil_primitive.cc b/source/blender/editors/gpencil_legacy/gpencil_primitive.cc index e30c25cd0ea..3ade731e97f 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_primitive.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_primitive.cc @@ -23,7 +23,7 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_brush_types.h" #include "DNA_gpencil_legacy_types.h" @@ -38,11 +38,13 @@ #include "BKE_colortools.hh" #include "BKE_context.hh" #include "BKE_deform.hh" +#include "BKE_global.h" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" +#include "BKE_main.hh" #include "BKE_material.h" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "UI_interface.hh" #include "UI_resources.hh" @@ -52,9 +54,12 @@ #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "ED_gpencil_legacy.hh" +#include "ED_object.hh" #include "ED_screen.hh" +#include "ED_space_api.hh" #include "ED_view3d.hh" #include "ANIM_keyframing.hh" @@ -363,7 +368,7 @@ static void gpencil_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi) gpencil_primitive_allocate_memory(tgpi); /* Random generator, only init once. */ - uint rng_seed = uint(BLI_time_now_seconds_i() & UINT_MAX); + uint rng_seed = uint(BLI_check_seconds_timer_i() & UINT_MAX); tgpi->rng = BLI_rng_new(rng_seed); DEG_id_tag_update(&tgpi->gpd->id, ID_RECALC_COPY_ON_WRITE); diff --git a/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc b/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc index d68567fbfc5..89767ecd6cc 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc @@ -25,10 +25,11 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_material_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" @@ -38,12 +39,15 @@ #include "BKE_brush.hh" #include "BKE_colortools.hh" #include "BKE_context.hh" +#include "BKE_deform.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" +#include "BKE_gpencil_update_cache_legacy.h" #include "BKE_main.hh" #include "BKE_material.h" -#include "BKE_report.hh" +#include "BKE_object_deform.h" +#include "BKE_report.h" #include "UI_interface.hh" @@ -52,6 +56,7 @@ #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "RNA_prototypes.h" #include "UI_view2d.hh" @@ -677,7 +682,7 @@ static bool gpencil_brush_pinch_apply(tGP_BrushEditData *gso, /* 1) Make this point relative to the cursor/midpoint (dvec) */ float fpt[3]; - mul_v3_m4v3(fpt, gso->object->object_to_world().ptr(), &pt->x); + mul_v3_m4v3(fpt, gso->object->object_to_world, &pt->x); sub_v3_v3v3(vec, fpt, gso->dvec); /* 2) Shrink the distance by pulling the point towards the midpoint @@ -697,7 +702,7 @@ static bool gpencil_brush_pinch_apply(tGP_BrushEditData *gso, /* 3) Translate back to original space, with the shrinkage applied */ add_v3_v3v3(fpt, gso->dvec, vec); - mul_v3_m4v3(&pt->x, gso->object->world_to_object().ptr(), fpt); + mul_v3_m4v3(&pt->x, gso->object->world_to_object, fpt); /* compute lock axis */ gpencil_sculpt_compute_lock_axis(gso, pt, save_pt); @@ -749,12 +754,12 @@ static bool gpencil_brush_twist_apply(tGP_BrushEditData *gso, /* Rotate point */ float fpt[3]; - mul_v3_m4v3(fpt, gso->object->object_to_world().ptr(), &pt->x); + mul_v3_m4v3(fpt, gso->object->object_to_world, &pt->x); sub_v3_v3v3(vec, fpt, gso->dvec); /* make relative to center * (center is stored in dvec) */ mul_m3_v3(rmat, vec); add_v3_v3v3(fpt, vec, gso->dvec); /* restore */ - mul_v3_m4v3(&pt->x, gso->object->world_to_object().ptr(), fpt); + mul_v3_m4v3(&pt->x, gso->object->world_to_object, fpt); /* compute lock axis */ gpencil_sculpt_compute_lock_axis(gso, pt, save_pt); @@ -1045,11 +1050,11 @@ static void gpencil_brush_clone_add(bContext *C, tGP_BrushEditData *gso) */ for (i = 0, pt = new_stroke->points; i < new_stroke->totpoints; i++, pt++) { /* Rotate around center new position */ - mul_mat3_m4_v3(gso->object->object_to_world().ptr(), &pt->x); /* only rotation component */ + mul_mat3_m4_v3(gso->object->object_to_world, &pt->x); /* only rotation component */ /* assume that the delta can just be applied, and then everything works */ add_v3_v3(&pt->x, delta); - mul_m4_v3(gso->object->world_to_object().ptr(), &pt->x); + mul_m4_v3(gso->object->world_to_object, &pt->x); } /* Store ref for later */ @@ -1165,7 +1170,7 @@ static bool gpencil_sculpt_brush_init(bContext *C, wmOperator *op) gso->settings = gpencil_sculpt_get_settings(scene); /* Random generator, only init once. */ - uint rng_seed = uint(BLI_time_now_seconds_i() & UINT_MAX); + uint rng_seed = uint(BLI_check_seconds_timer_i() & UINT_MAX); rng_seed ^= POINTER_AS_UINT(gso); gso->rng = BLI_rng_new(rng_seed); @@ -1180,7 +1185,7 @@ static bool gpencil_sculpt_brush_init(bContext *C, wmOperator *op) gso->object = ob; if (ob) { float matrix[4][4]; - copy_m4_m4(matrix, ob->object_to_world().ptr()); + copy_m4_m4(matrix, ob->object_to_world); zero_axis_bias_m4(matrix); invert_m4_m4(gso->inv_mat, matrix); gso->vrgroup = gso->gpd->vertex_group_active_index - 1; diff --git a/source/blender/editors/gpencil_legacy/gpencil_select.cc b/source/blender/editors/gpencil_legacy/gpencil_select.cc index a64d525802b..2f13a9a0859 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_select.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_select.cc @@ -14,6 +14,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_lasso_2d.h" #include "BLI_math_color.h" @@ -27,13 +28,17 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "BKE_context.hh" #include "BKE_gpencil_curve_legacy.h" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_material.h" -#include "BKE_report.hh" +#include "BKE_report.h" + +#include "UI_interface.hh" +#include "UI_resources.hh" #include "WM_api.hh" #include "WM_types.hh" @@ -2052,7 +2057,7 @@ static bool gpencil_generic_stroke_select(bContext *C, Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob_eval = depsgraph != nullptr ? DEG_get_evaluated_object(depsgraph, ob) : ob; float select_mat[4][4]; - copy_m4_m4(select_mat, ob_eval->object_to_world().ptr()); + copy_m4_m4(select_mat, ob_eval->object_to_world); /* deselect all strokes first? */ if (SEL_OP_USE_PRE_DESELECT(sel_op)) { diff --git a/source/blender/editors/gpencil_legacy/gpencil_trace_ops.cc b/source/blender/editors/gpencil_legacy/gpencil_trace_ops.cc index b684a0f90e2..aa9269db787 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_trace_ops.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_trace_ops.cc @@ -11,20 +11,21 @@ #include "BLI_math_rotation.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_legacy.h" #include "BKE_image.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" +#include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/editors/gpencil_legacy/gpencil_trace_utils.cc b/source/blender/editors/gpencil_legacy/gpencil_trace_utils.cc index b3382603f92..d60b0a0a28d 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_trace_utils.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_trace_utils.cc @@ -17,12 +17,16 @@ #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" +#include "BKE_image.h" +#include "BKE_main.hh" +#include "BKE_material.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_image_types.h" #include "DNA_material_types.h" #include "DNA_object_types.h" +#include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" #include "gpencil_trace.h" diff --git a/source/blender/editors/gpencil_legacy/gpencil_undo.cc b/source/blender/editors/gpencil_legacy/gpencil_undo.cc index de8efb20ec7..0fd0ad2186b 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_undo.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_undo.cc @@ -19,6 +19,7 @@ #include "BLI_listbase.h" #include "BKE_blender_undo.hh" +#include "BKE_context.hh" #include "BKE_gpencil_legacy.h" #include "BKE_undo_system.hh" diff --git a/source/blender/editors/gpencil_legacy/gpencil_utils.cc b/source/blender/editors/gpencil_legacy/gpencil_utils.cc index ce190164009..770054da0f8 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_utils.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_utils.cc @@ -22,10 +22,14 @@ #include "BLI_math_color.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.hh" +#include "BLI_rand.h" #include "BLI_time.h" #include "BLI_utildefines.h" +#include "BLT_translation.h" + #include "DNA_brush_types.h" +#include "DNA_collection_types.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_material_types.h" #include "DNA_meshdata_types.h" @@ -37,7 +41,7 @@ #include "BKE_action.h" #include "BKE_brush.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_colortools.hh" #include "BKE_context.hh" #include "BKE_deform.hh" @@ -65,6 +69,7 @@ #include "ED_clip.hh" #include "ED_gpencil_legacy.hh" #include "ED_object.hh" +#include "ED_screen.hh" #include "ED_select_utils.hh" #include "ED_transform_snap_object_context.hh" #include "ED_view3d.hh" @@ -906,7 +911,7 @@ void ED_gpencil_drawing_reference_get(const Scene *scene, } else { /* use object location */ - copy_v3_v3(r_vec, ob->object_to_world().location()); + copy_v3_v3(r_vec, ob->object_to_world[3]); /* Apply layer offset. */ bGPdata *gpd = static_cast(ob->data); bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd); @@ -990,7 +995,7 @@ void ED_gpencil_project_stroke_to_plane(const Scene *scene, /* if object, apply object rotation */ if (ob && (ob->type == OB_GPENCIL_LEGACY)) { float mat[4][4]; - copy_m4_m4(mat, ob->object_to_world().ptr()); + copy_m4_m4(mat, ob->object_to_world); /* move origin to cursor */ if ((ts->gpencil_v3d_align & GP_PROJECT_CURSOR) == 0) { @@ -1213,7 +1218,7 @@ void ED_gpencil_project_point_to_plane(const Scene *scene, /* if object, apply object rotation */ if (ob && (ob->type == OB_GPENCIL_LEGACY)) { float mat[4][4]; - copy_m4_m4(mat, ob->object_to_world().ptr()); + copy_m4_m4(mat, ob->object_to_world); if ((ts->gpencil_v3d_align & GP_PROJECT_CURSOR) == 0) { if (gpl != nullptr) { add_v3_v3(mat[3], gpl->location); @@ -1240,7 +1245,7 @@ void ED_gpencil_project_point_to_plane(const Scene *scene, /* move origin to object */ if ((ts->gpencil_v3d_align & GP_PROJECT_CURSOR) == 0) { - copy_v3_v3(mat[3], ob->object_to_world().location()); + copy_v3_v3(mat[3], ob->object_to_world[3]); } mul_mat3_m4_v3(mat, plane_normal); @@ -1374,16 +1379,16 @@ void ED_gpencil_reset_layers_parent(Depsgraph *depsgraph, Object *obact, bGPdata if (gpl->parent != nullptr) { /* calculate new matrix */ if (ELEM(gpl->partype, PAROBJECT, PARSKEL)) { - invert_m4_m4(cur_mat, gpl->parent->object_to_world().ptr()); - copy_v3_v3(gpl_loc, obact->object_to_world().location()); + invert_m4_m4(cur_mat, gpl->parent->object_to_world); + copy_v3_v3(gpl_loc, obact->object_to_world[3]); } else if (gpl->partype == PARBONE) { bPoseChannel *pchan = BKE_pose_channel_find_name(gpl->parent->pose, gpl->parsubstr); if (pchan) { float tmp_mat[4][4]; - mul_m4_m4m4(tmp_mat, gpl->parent->object_to_world().ptr(), pchan->pose_mat); + mul_m4_m4m4(tmp_mat, gpl->parent->object_to_world, pchan->pose_mat); invert_m4_m4(cur_mat, tmp_mat); - copy_v3_v3(gpl_loc, obact->object_to_world().location()); + copy_v3_v3(gpl_loc, obact->object_to_world[3]); } } @@ -2838,7 +2843,7 @@ void ED_gpencil_init_random_settings(Brush *brush, const int mval[2], GpRandomSettings *random_settings) { - int seed = (uint(ceil(BLI_time_now_seconds())) + 1) % 128; + int seed = (uint(ceil(BLI_check_seconds_timer())) + 1) % 128; /* Use mouse position to get randomness. */ int ix = mval[0] * seed; int iy = mval[1] * seed; @@ -2884,7 +2889,7 @@ static void gpencil_sbuffer_vertex_color_random( { BrushGpencilSettings *brush_settings = brush->gpencil_settings; if (brush_settings->flag & GP_BRUSH_GROUP_RANDOM) { - int seed = (uint(ceil(BLI_time_now_seconds())) + 1) % 128; + int seed = (uint(ceil(BLI_check_seconds_timer())) + 1) % 128; int ix = int(tpt->m_xy[0] * seed); int iy = int(tpt->m_xy[1] * seed); diff --git a/source/blender/editors/gpencil_legacy/gpencil_uv.cc b/source/blender/editors/gpencil_legacy/gpencil_uv.cc index 527d7133452..bd8fd7ec82f 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_uv.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_uv.cc @@ -10,12 +10,13 @@ #include "DNA_gpencil_legacy_types.h" +#include "BLI_blenlib.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" #include "BLI_math_vector.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_gpencil_geom_legacy.h" @@ -143,7 +144,7 @@ static bool gpencil_uv_transform_init(bContext *C, wmOperator *op) opdata->array_loc = nullptr; opdata->array_rot = nullptr; opdata->array_scale = nullptr; - opdata->ob_scale = mat4_to_scale(opdata->ob->object_to_world().ptr()); + opdata->ob_scale = mat4_to_scale(opdata->ob->object_to_world); opdata->vinit_rotation[0] = 1.0f; opdata->vinit_rotation[1] = 0.0f; @@ -163,7 +164,7 @@ static bool gpencil_uv_transform_init(bContext *C, wmOperator *op) float r_center[3]; gpencil_stroke_center(gps, r_center); /* Add object location. */ - add_v3_v3(r_center, opdata->ob->object_to_world().location()); + add_v3_v3(r_center, opdata->ob->object_to_world[3]); add_v3_v3(center, r_center); i++; } diff --git a/source/blender/editors/gpencil_legacy/gpencil_vertex_ops.cc b/source/blender/editors/gpencil_legacy/gpencil_vertex_ops.cc index 56f824784e0..6648cab4f49 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_vertex_ops.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_vertex_ops.cc @@ -19,9 +19,10 @@ #include "DNA_material_types.h" #include "BKE_context.hh" +#include "BKE_main.hh" #include "BKE_material.h" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "WM_api.hh" #include "WM_types.hh" diff --git a/source/blender/editors/gpencil_legacy/gpencil_vertex_paint.cc b/source/blender/editors/gpencil_legacy/gpencil_vertex_paint.cc index 69e4433a2ff..a6d73a2a5ca 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_vertex_paint.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_vertex_paint.cc @@ -9,11 +9,12 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_math_color.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_brush_types.h" #include "DNA_gpencil_legacy_types.h" @@ -24,7 +25,7 @@ #include "BKE_context.hh" #include "BKE_gpencil_legacy.h" #include "BKE_material.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "WM_api.hh" #include "WM_types.hh" @@ -37,6 +38,7 @@ #include "ED_gpencil_legacy.hh" #include "ED_screen.hh" +#include "ED_view3d.hh" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/editors/gpencil_legacy/gpencil_weight_paint.cc b/source/blender/editors/gpencil_legacy/gpencil_weight_paint.cc index 15b35b856c9..fa811bbaa71 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_weight_paint.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_weight_paint.cc @@ -9,13 +9,14 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_kdtree.h" #include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_armature_types.h" #include "DNA_brush_types.h" @@ -28,9 +29,10 @@ #include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_legacy.h" +#include "BKE_main.hh" #include "BKE_modifier.hh" #include "BKE_object_deform.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DNA_meshdata_types.h" #include "WM_api.hh" @@ -44,6 +46,7 @@ #include "ED_gpencil_legacy.hh" #include "ED_screen.hh" +#include "ED_view3d.hh" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/editors/grease_pencil/CMakeLists.txt b/source/blender/editors/grease_pencil/CMakeLists.txt index 3e9ed92c995..4da4d090537 100644 --- a/source/blender/editors/grease_pencil/CMakeLists.txt +++ b/source/blender/editors/grease_pencil/CMakeLists.txt @@ -29,7 +29,6 @@ set(SRC intern/grease_pencil_material.cc intern/grease_pencil_ops.cc intern/grease_pencil_select.cc - intern/grease_pencil_undo.cc intern/grease_pencil_utils.cc ) @@ -39,7 +38,6 @@ set(LIB PRIVATE bf::depsgraph PRIVATE bf::dna PRIVATE bf::intern::guardedalloc - PRIVATE bf::intern::clog extern_curve_fit_nd ) diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_add.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_add.cc index 180e67c301c..03da46592e0 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_add.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_add.cc @@ -15,9 +15,10 @@ #include "BLI_math_matrix.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_material_types.h" +#include "DNA_scene_types.h" #include "ED_grease_pencil.hh" diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc index 7b358c83c3c..11daacf6388 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc @@ -12,7 +12,9 @@ #include "BLI_math_geom.h" #include "BLI_math_vector_types.hh" #include "BLI_span.hh" -#include "BLT_translation.hh" +#include "BLI_stack.hh" +#include "BLI_string.h" +#include "BLT_translation.h" #include "DNA_material_types.h" #include "DNA_scene_types.h" @@ -23,7 +25,7 @@ #include "BKE_grease_pencil.hh" #include "BKE_lib_id.hh" #include "BKE_material.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -34,6 +36,7 @@ #include "ED_curves.hh" #include "ED_grease_pencil.hh" #include "ED_object.hh" +#include "ED_screen.hh" #include "GEO_join_geometries.hh" #include "GEO_reorder.hh" @@ -69,7 +72,7 @@ static int grease_pencil_stroke_smooth_exec(bContext *C, wmOperator *op) } bool changed = false; - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { bke::CurvesGeometry &curves = info.drawing.strokes_for_write(); if (curves.points_num() == 0) { @@ -231,7 +234,7 @@ static int grease_pencil_stroke_simplify_exec(bContext *C, wmOperator *op) const float epsilon = RNA_float_get(op->ptr, "factor"); bool changed = false; - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { bke::CurvesGeometry &curves = info.drawing.strokes_for_write(); if (curves.points_num() == 0) { @@ -444,7 +447,7 @@ static int grease_pencil_delete_exec(bContext *C, wmOperator * /*op*/) scene->toolsettings); bool changed = false; - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { IndexMaskMemory memory; const IndexMask elements = ed::greasepencil::retrieve_editable_and_selected_elements( @@ -587,7 +590,7 @@ static int grease_pencil_dissolve_exec(bContext *C, wmOperator *op) const DissolveMode mode = DissolveMode(RNA_enum_get(op->ptr, "type")); bool changed = false; - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { bke::CurvesGeometry &curves = info.drawing.strokes_for_write(); if (curves.points_num() == 0) { @@ -760,7 +763,7 @@ static int grease_pencil_stroke_material_set_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { IndexMaskMemory memory; IndexMask strokes = ed::greasepencil::retrieve_editable_and_selected_strokes( @@ -829,7 +832,7 @@ static int grease_pencil_cyclical_set_exec(bContext *C, wmOperator *op) const CyclicalMode mode = CyclicalMode(RNA_enum_get(op->ptr, "type")); bool changed = false; - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { bke::CurvesGeometry &curves = info.drawing.strokes_for_write(); if (mode == CyclicalMode::OPEN && !curves.attributes().contains("cyclic")) { @@ -910,7 +913,7 @@ static int grease_pencil_set_active_material_exec(bContext *C, wmOperator * /*op return OPERATOR_CANCELLED; } - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); for (const MutableDrawingInfo &info : drawings) { IndexMaskMemory memory; const IndexMask strokes = ed::greasepencil::retrieve_editable_and_selected_strokes( @@ -958,7 +961,7 @@ static int grease_pencil_set_uniform_thickness_exec(bContext *C, wmOperator *op) const float radius = RNA_float_get(op->ptr, "thickness") * 0.5f; bool changed = false; - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { IndexMaskMemory memory; const IndexMask strokes = ed::greasepencil::retrieve_editable_and_selected_strokes( @@ -1015,7 +1018,7 @@ static int grease_pencil_set_uniform_opacity_exec(bContext *C, wmOperator *op) const float opacity = RNA_float_get(op->ptr, "opacity"); bool changed = false; - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { IndexMaskMemory memory; const IndexMask strokes = ed::greasepencil::retrieve_editable_and_selected_strokes( @@ -1070,7 +1073,7 @@ static int grease_pencil_stroke_switch_direction_exec(bContext *C, wmOperator * GreasePencil &grease_pencil = *static_cast(object->data); bool changed = false; - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { IndexMaskMemory memory; const IndexMask strokes = ed::greasepencil::retrieve_editable_and_selected_strokes( @@ -1146,7 +1149,7 @@ static int grease_pencil_caps_set_exec(bContext *C, wmOperator *op) const CapsMode mode = CapsMode(RNA_enum_get(op->ptr, "type")); bool changed = false; - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { bke::CurvesGeometry &curves = info.drawing.strokes_for_write(); IndexMaskMemory memory; @@ -1322,7 +1325,7 @@ static int grease_pencil_duplicate_exec(bContext *C, wmOperator * /*op*/) scene->toolsettings); std::atomic changed = false; - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { IndexMaskMemory memory; const IndexMask elements = retrieve_editable_and_selected_elements( @@ -1370,9 +1373,9 @@ static int grease_pencil_clean_loose_exec(bContext *C, wmOperator *op) const int limit = RNA_int_get(op->ptr, "limit"); GreasePencil &grease_pencil = *static_cast(object->data); - const Vector drawings = retrieve_editable_drawings(scene, grease_pencil); + Array drawings = retrieve_editable_drawings(scene, grease_pencil); - threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { + threading::parallel_for_each(drawings, [&](MutableDrawingInfo &info) { bke::CurvesGeometry &curves = info.drawing.strokes_for_write(); const OffsetIndices points_by_curve = curves.points_by_curve(); @@ -1436,7 +1439,7 @@ static int gpencil_stroke_subdivide_exec(bContext *C, wmOperator *op) const bke::AttrDomain selection_domain = ED_grease_pencil_selection_domain_get( scene->toolsettings); - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { IndexMaskMemory memory; @@ -1633,7 +1636,7 @@ static int grease_pencil_stroke_reorder_exec(bContext *C, wmOperator *op) const ReorderDirection direction = ReorderDirection(RNA_enum_get(op->ptr, "direction")); std::atomic changed = false; - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { IndexMaskMemory memory; const IndexMask strokes = ed::greasepencil::retrieve_editable_and_selected_strokes( @@ -1736,8 +1739,7 @@ static int grease_pencil_move_to_layer_exec(bContext *C, wmOperator *op) } /* Iterate through all the drawings at current scene frame. */ - const Vector drawings_src = retrieve_editable_drawings(*scene, - grease_pencil); + const Array drawings_src = retrieve_editable_drawings(*scene, grease_pencil); for (const MutableDrawingInfo &info : drawings_src) { bke::CurvesGeometry &curves_src = info.drawing.strokes_for_write(); IndexMaskMemory memory; @@ -1904,8 +1906,8 @@ static bool grease_pencil_separate_selected(bContext &C, GreasePencil &grease_pencil_dst = *static_cast(object_dst->data); /* Iterate through all the drawings at current scene frame. */ - const Vector drawings_src = retrieve_editable_drawings(scene, - grease_pencil_src); + const Array drawings_src = retrieve_editable_drawings(scene, + grease_pencil_src); for (const MutableDrawingInfo &info : drawings_src) { bke::CurvesGeometry &curves_src = info.drawing.strokes_for_write(); IndexMaskMemory memory; @@ -1974,7 +1976,7 @@ static bool grease_pencil_separate_layer(bContext &C, grease_pencil_src.layers().first_index(layer_src), grease_pencil_src, grease_pencil_dst); /* Iterate through all the drawings at current frame. */ - const Vector drawings_src = retrieve_editable_drawings_from_layer( + const Array drawings_src = retrieve_editable_drawings_from_layer( scene, grease_pencil_src, *layer_src); for (const MutableDrawingInfo &info : drawings_src) { bke::CurvesGeometry &curves_src = info.drawing.strokes_for_write(); @@ -2042,8 +2044,8 @@ static bool grease_pencil_separate_material(bContext &C, false); /* Iterate through all the drawings at current scene frame. */ - const Vector drawings_src = retrieve_editable_drawings(scene, - grease_pencil_src); + const Array drawings_src = retrieve_editable_drawings(scene, + grease_pencil_src); for (const MutableDrawingInfo &info : drawings_src) { bke::CurvesGeometry &curves_src = info.drawing.strokes_for_write(); IndexMaskMemory memory; @@ -2102,8 +2104,8 @@ static int grease_pencil_separate_exec(bContext *C, wmOperator *op) switch (mode) { case SeparateMode::SELECTED: { /* Cancel if nothing selected. */ - const Vector drawings = retrieve_editable_drawings(*scene, - grease_pencil_src); + const Array drawings = retrieve_editable_drawings(*scene, + grease_pencil_src); const bool has_selection = std::any_of( drawings.begin(), drawings.end(), [&](const MutableDrawingInfo &info) { return ed::curves::has_anything_selected(info.drawing.strokes()); diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_layers.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_layers.cc index 8d2b5c2bfb7..658b50e04ad 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_layers.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_layers.cc @@ -8,7 +8,6 @@ #include "BKE_context.hh" #include "BKE_grease_pencil.hh" -#include "BKE_report.hh" #include "DEG_depsgraph.hh" @@ -308,7 +307,6 @@ static int grease_pencil_layer_hide_exec(bContext *C, wmOperator *op) /* notifiers */ DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GEOM | ND_DATA, &grease_pencil); - WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, nullptr); return OPERATOR_FINISHED; } @@ -351,7 +349,6 @@ static int grease_pencil_layer_reveal_exec(bContext *C, wmOperator * /*op*/) /* notifiers */ DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GEOM | ND_DATA, &grease_pencil); - WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, nullptr); return OPERATOR_FINISHED; } @@ -373,7 +370,7 @@ static void GREASE_PENCIL_OT_layer_reveal(wmOperatorType *ot) static int grease_pencil_layer_isolate_exec(bContext *C, wmOperator *op) { - using namespace blender::bke::greasepencil; + using namespace ::blender::bke::greasepencil; Object *object = CTX_data_active_object(C); GreasePencil &grease_pencil = *static_cast(object->data); const int affect_visibility = RNA_boolean_get(op->ptr, "affect_visibility"); @@ -429,101 +426,6 @@ static void GREASE_PENCIL_OT_layer_isolate(wmOperatorType *ot) RNA_def_boolean( ot->srna, "affect_visibility", false, "Affect Visibility", "Also affect the visibility"); } - -static int grease_pencil_layer_lock_all_exec(bContext *C, wmOperator *op) -{ - using namespace blender::bke::greasepencil; - Object *object = CTX_data_active_object(C); - GreasePencil &grease_pencil = *static_cast(object->data); - const bool lock_value = RNA_boolean_get(op->ptr, "lock"); - - if (grease_pencil.layers().is_empty()) { - return OPERATOR_CANCELLED; - } - - for (Layer *layer : grease_pencil.layers_for_write()) { - layer->set_locked(lock_value); - } - - DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, &grease_pencil); - WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, nullptr); - - return OPERATOR_FINISHED; -} - -static void GREASE_PENCIL_OT_layer_lock_all(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Lock All Layers"; - ot->idname = "GREASE_PENCIL_OT_layer_lock_all"; - ot->description = - "Lock all Grease Pencil layers to prevent them from being accidentally modified"; - - /* callbacks */ - ot->exec = grease_pencil_layer_lock_all_exec; - ot->poll = active_grease_pencil_poll; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* properties */ - RNA_def_boolean(ot->srna, "lock", true, "Lock Value", "Lock/Unlock all layers"); -} - -static int grease_pencil_layer_duplicate_exec(bContext *C, wmOperator *op) -{ - using namespace ::blender::bke::greasepencil; - Object *object = CTX_data_active_object(C); - GreasePencil &grease_pencil = *static_cast(object->data); - const bool empty_keyframes = RNA_boolean_get(op->ptr, "empty_keyframes"); - - if (!grease_pencil.has_active_layer()) { - BKE_reportf(op->reports, RPT_ERROR, "No active layer to duplicate"); - return OPERATOR_CANCELLED; - } - - Layer &active_layer = *grease_pencil.get_active_layer(); - Layer &new_layer = grease_pencil.add_layer(active_layer.name()); - - for (auto [key, frame] : active_layer.frames().items()) { - const int duration = frame.is_implicit_hold() ? 0 : active_layer.get_frame_duration_at(key); - const int drawing_index = grease_pencil.drawings().size(); - GreasePencilFrame *new_frame = new_layer.add_frame(key, drawing_index, duration); - new_frame->type = frame.type; - if (empty_keyframes) { - grease_pencil.add_empty_drawings(1); - } - else { - const Drawing &drawing = *grease_pencil.get_drawing_at(active_layer, key); - grease_pencil.add_duplicate_drawings(1, drawing); - } - } - - grease_pencil.move_node_after(new_layer.as_node(), active_layer.as_node()); - grease_pencil.set_active_layer(&new_layer); - DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY); - WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, nullptr); - return OPERATOR_FINISHED; -} - -static void GREASE_PENCIL_OT_layer_duplicate(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Duplicate Layer"; - ot->idname = "GREASE_PENCIL_OT_layer_duplicate"; - ot->description = "Make a copy of the active Grease Pencil layer"; - - /* callbacks */ - ot->exec = grease_pencil_layer_duplicate_exec; - ot->poll = active_grease_pencil_poll; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* properties */ - RNA_def_boolean(ot->srna, "empty_keyframes", false, "Empty Keyframes", "Add Empty Keyframes"); -} } // namespace blender::ed::greasepencil void ED_operatortypes_grease_pencil_layers() @@ -536,8 +438,6 @@ void ED_operatortypes_grease_pencil_layers() WM_operatortype_append(GREASE_PENCIL_OT_layer_hide); WM_operatortype_append(GREASE_PENCIL_OT_layer_reveal); WM_operatortype_append(GREASE_PENCIL_OT_layer_isolate); - WM_operatortype_append(GREASE_PENCIL_OT_layer_lock_all); - WM_operatortype_append(GREASE_PENCIL_OT_layer_duplicate); WM_operatortype_append(GREASE_PENCIL_OT_layer_group_add); } diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_material.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_material.cc index 6924c748d5e..7b1214ee25b 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_material.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_material.cc @@ -15,6 +15,7 @@ #include "BKE_material.h" #include "BLI_vector.hh" +#include "BLI_vector_set.hh" #include "DEG_depsgraph.hh" @@ -271,7 +272,7 @@ static int grease_pencil_material_lock_unselected_exec(bContext *C, wmOperator * GreasePencil &grease_pencil = *static_cast(object->data); bool changed = false; - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); Set materials_used; diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc index f997e4db3d0..70e9cc41137 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_select.cc @@ -19,6 +19,7 @@ #include "ED_curves.hh" #include "ED_grease_pencil.hh" #include "ED_screen.hh" +#include "ED_view3d.hh" #include "RNA_access.hh" #include "RNA_define.hh" @@ -36,7 +37,7 @@ static int select_all_exec(bContext *C, wmOperator *op) GreasePencil &grease_pencil = *static_cast(object->data); bke::AttrDomain selection_domain = ED_grease_pencil_selection_domain_get(scene->toolsettings); - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { IndexMaskMemory memory; const IndexMask selectable_elements = retrieve_editable_elements( @@ -76,7 +77,7 @@ static int select_more_exec(bContext *C, wmOperator * /*op*/) Object *object = CTX_data_active_object(C); GreasePencil &grease_pencil = *static_cast(object->data); - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { IndexMaskMemory memory; const IndexMask selectable_strokes = ed::greasepencil::retrieve_editable_strokes( @@ -114,7 +115,7 @@ static int select_less_exec(bContext *C, wmOperator * /*op*/) Object *object = CTX_data_active_object(C); GreasePencil &grease_pencil = *static_cast(object->data); - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { IndexMaskMemory memory; const IndexMask selectable_strokes = ed::greasepencil::retrieve_editable_strokes( @@ -152,7 +153,7 @@ static int select_linked_exec(bContext *C, wmOperator * /*op*/) Object *object = CTX_data_active_object(C); GreasePencil &grease_pencil = *static_cast(object->data); - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { IndexMaskMemory memory; const IndexMask selectable_strokes = ed::greasepencil::retrieve_editable_strokes( @@ -193,7 +194,7 @@ static int select_random_exec(bContext *C, wmOperator *op) GreasePencil &grease_pencil = *static_cast(object->data); bke::AttrDomain selection_domain = ED_grease_pencil_selection_domain_get(scene->toolsettings); - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { bke::CurvesGeometry &curves = info.drawing.strokes_for_write(); @@ -253,7 +254,7 @@ static int select_alternate_exec(bContext *C, wmOperator *op) Object *object = CTX_data_active_object(C); GreasePencil &grease_pencil = *static_cast(object->data); - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { blender::ed::curves::select_alternate(info.drawing.strokes_for_write(), deselect_ends); }); @@ -292,7 +293,7 @@ static int select_ends_exec(bContext *C, wmOperator *op) Object *object = CTX_data_active_object(C); GreasePencil &grease_pencil = *static_cast(object->data); - const Vector drawings = retrieve_editable_drawings(*scene, grease_pencil); + const Array drawings = retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each(drawings, [&](const MutableDrawingInfo &info) { bke::CurvesGeometry &curves = info.drawing.strokes_for_write(); diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_undo.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_undo.cc deleted file mode 100644 index fe34595df72..00000000000 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_undo.cc +++ /dev/null @@ -1,426 +0,0 @@ -/* SPDX-FileCopyrightText: 2023 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup edgrease_pencil - */ - -#include "BLI_string.h" -#include "BLI_task.hh" - -#include "BKE_context.hh" -#include "BKE_curves.hh" -#include "BKE_customdata.hh" -#include "BKE_grease_pencil.hh" -#include "BKE_lib_id.hh" -#include "BKE_main.hh" -#include "BKE_object.hh" -#include "BKE_undo_system.hh" - -#include "CLG_log.h" - -#include "DEG_depsgraph.hh" -#include "DEG_depsgraph_build.hh" - -#include "ED_grease_pencil.hh" -#include "ED_undo.hh" - -#include "MEM_guardedalloc.h" - -#include "WM_api.hh" -#include "WM_types.hh" - -#include -#include - -static CLG_LogRef LOG = {"ed.undo.greasepencil"}; - -namespace blender::ed::greasepencil::undo { - -/* -------------------------------------------------------------------- */ -/** \name Implements ED Undo System - * - * \note This is similar for all edit-mode types. - * \{ */ - -/** - * Store all drawings, layers and layers data, in each undo step. - * - * Each drawing type has its own array in the undo #StepObject data. - * - * NOTE: Storing Reference drawings is also needed, since drawings can be added or removed, data - * from Reference ones also needs to be stored. - */ - -/* Store contextual data and status info during undo step encoding or decoding. */ -struct StepEncodeStatus {}; - -struct StepDecodeStatus { - /** - * In case some reference drawing needs to be re-created, the GreasePencil ID gets a new - * relation to another GreasePencil ID. - */ - bool needs_relationships_update = false; -}; - -class StepDrawingGeometryBase { - protected: - /* Index of this drawing in the original combined array of all drawings in GreasePencil ID. */ - int index_; - - /* Data from #GreasePencilDrawingBase that needs to be saved in undo steps. */ - uint32_t flag_; - - protected: - /** - * Ensures that the drawing from the given array at the current index exists, - * and has the proposer type. - * - * Non-existing drawings can happen after extending the drawings array. - * - * Mismatch in drawing types can happen when some drawings have been deleted between the undo - * step storage, and the current state of the GreasePencil data. - */ - void decode_valid_drawingtype_at_index_ensure(MutableSpan &drawings, - const GreasePencilDrawingType drawing_type) const - { - /* TODO: Maybe that code should rather be part of GreasePencil:: API, together with - * `add_empty_drawings` and such? */ - GreasePencilDrawingBase *drawing = drawings[index_]; - if (drawing != nullptr) { - if (drawing->type == drawing_type) { - return; - } - switch (drawing->type) { - case GP_DRAWING: - MEM_delete(&reinterpret_cast(drawing)->wrap()); - break; - case GP_DRAWING_REFERENCE: - MEM_delete(&reinterpret_cast(drawing)->wrap()); - break; - } - drawing = nullptr; - } - if (drawing == nullptr) { - switch (drawing_type) { - case GP_DRAWING: - drawings[index_] = reinterpret_cast( - MEM_new(__func__)); - break; - case GP_DRAWING_REFERENCE: - drawings[index_] = reinterpret_cast( - MEM_new(__func__)); - break; - } - } - } -}; - -class StepDrawingGeometry : public StepDrawingGeometryBase { - bke::CurvesGeometry geometry_; - - public: - void encode(const GreasePencilDrawing &drawing_geometry, - const int64_t drawing_index, - StepEncodeStatus & /* encode_status */) - { - BLI_assert(drawing_index >= 0 && drawing_index < INT32_MAX); - index_ = int(drawing_index); - - flag_ = drawing_geometry.base.flag; - geometry_ = drawing_geometry.geometry.wrap(); - } - - void decode(GreasePencil &grease_pencil, StepDecodeStatus & /*decode_status*/) const - { - MutableSpan drawings = grease_pencil.drawings(); - this->decode_valid_drawingtype_at_index_ensure(drawings, GP_DRAWING); - BLI_assert(drawings[index_]->type == GP_DRAWING); - - GreasePencilDrawing &drawing_geometry = *reinterpret_cast( - drawings[index_]); - - drawing_geometry.base.flag = flag_; - drawing_geometry.geometry.wrap() = geometry_; - - /* TODO: Check if there is a way to tell if both stored and current geometry are still the - * same, to avoid recomputing the cache all the time for all drawings? */ - drawing_geometry.runtime->triangles_cache.tag_dirty(); - } -}; - -class StepDrawingReference : public StepDrawingGeometryBase { - UndoRefID_GreasePencil grease_pencil_ref_ = {}; - - public: - void encode(const GreasePencilDrawingReference &drawing_reference, - const int64_t drawing_index, - StepEncodeStatus & /* encode_status */) - { - BLI_assert(drawing_index >= 0 && drawing_index < INT32_MAX); - index_ = int(drawing_index); - - flag_ = drawing_reference.base.flag; - grease_pencil_ref_.ptr = drawing_reference.id_reference; - } - - void decode(GreasePencil &grease_pencil, StepDecodeStatus &decode_status) const - { - MutableSpan drawings = grease_pencil.drawings(); - this->decode_valid_drawingtype_at_index_ensure(drawings, GP_DRAWING_REFERENCE); - BLI_assert(drawings[index_]->type == GP_DRAWING_REFERENCE); - - GreasePencilDrawingReference &drawing_reference = - *reinterpret_cast(drawings[index_]); - drawing_reference.base.flag = flag_; - - if (drawing_reference.id_reference != grease_pencil_ref_.ptr) { - id_us_min(reinterpret_cast(drawing_reference.id_reference)); - drawing_reference.id_reference = grease_pencil_ref_.ptr; - id_us_plus(reinterpret_cast(drawing_reference.id_reference)); - decode_status.needs_relationships_update = true; - } - } - - void foreach_id_ref(UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data) - { - foreach_ID_ref_fn(user_data, reinterpret_cast(&grease_pencil_ref_)); - } -}; - -class StepObject { - public: - UndoRefID_Object obedit_ref = {}; - - private: - Array drawings_geometry_; - Array drawings_reference_; - - int layers_num_ = 0; - bke::greasepencil::LayerGroup root_group_; - std::string active_layer_name_; - CustomData layers_data_ = {}; - - private: - void encode_drawings(const GreasePencil &grease_pencil, StepEncodeStatus &encode_status) - { - const Span drawings = grease_pencil.drawings(); - - int64_t drawings_geometry_num = 0; - int64_t drawings_reference_num = 0; - for (const int64_t idx : drawings.index_range()) { - const GreasePencilDrawingBase &drawing = *drawings[idx]; - switch (drawing.type) { - case GP_DRAWING: - drawings_geometry_num++; - break; - case GP_DRAWING_REFERENCE: - drawings_reference_num++; - break; - } - } - - drawings_geometry_.reinitialize(drawings_geometry_num); - drawings_reference_.reinitialize(drawings_reference_num); - - int drawings_geometry_idx = 0; - int drawings_reference_idx = 0; - for (const int64_t idx : drawings.index_range()) { - const GreasePencilDrawingBase &drawing = *drawings[idx]; - switch (drawing.type) { - case GP_DRAWING: - drawings_geometry_[drawings_geometry_idx++].encode( - reinterpret_cast(drawing), idx, encode_status); - break; - case GP_DRAWING_REFERENCE: - drawings_reference_[drawings_reference_idx++].encode( - reinterpret_cast(drawing), idx, encode_status); - break; - } - } - } - - void decode_drawings(GreasePencil &grease_pencil, StepDecodeStatus &decode_status) const - { - const int drawing_array_num = int(drawings_geometry_.size() + drawings_reference_.size()); - grease_pencil.resize_drawings(drawing_array_num); - - for (const StepDrawingGeometry &drawing : drawings_geometry_) { - drawing.decode(grease_pencil, decode_status); - } - for (const StepDrawingReference &drawing : drawings_reference_) { - drawing.decode(grease_pencil, decode_status); - } - } - - void encode_layers(const GreasePencil &grease_pencil, StepEncodeStatus & /*encode_status*/) - { - layers_num_ = int(grease_pencil.layers().size()); - - CustomData_copy( - &grease_pencil.layers_data, &layers_data_, eCustomDataMask(CD_MASK_ALL), layers_num_); - - if (grease_pencil.has_active_layer()) { - active_layer_name_ = grease_pencil.get_active_layer()->name(); - } - - root_group_ = grease_pencil.root_group(); - } - - void decode_layers(GreasePencil &grease_pencil, StepDecodeStatus & /*decode_status*/) const - { - if (grease_pencil.root_group_ptr) { - MEM_delete(&grease_pencil.root_group()); - } - - grease_pencil.root_group_ptr = MEM_new(__func__, root_group_); - BLI_assert(layers_num_ == grease_pencil.layers().size()); - - if (!active_layer_name_.empty()) { - const bke::greasepencil::TreeNode *active_node = - grease_pencil.root_group().find_node_by_name(active_layer_name_); - if (active_node && active_node->is_layer()) { - grease_pencil.set_active_layer(&active_node->as_layer()); - } - } - - CustomData_copy( - &layers_data_, &grease_pencil.layers_data, eCustomDataMask(CD_MASK_ALL), layers_num_); - } - - public: - void encode(Object *ob, StepEncodeStatus &encode_status) - { - const GreasePencil &grease_pencil = *static_cast(ob->data); - this->obedit_ref.ptr = ob; - - this->encode_drawings(grease_pencil, encode_status); - this->encode_layers(grease_pencil, encode_status); - } - - void decode(StepDecodeStatus &decode_status) const - { - GreasePencil &grease_pencil = *static_cast(this->obedit_ref.ptr->data); - - this->decode_drawings(grease_pencil, decode_status); - this->decode_layers(grease_pencil, decode_status); - - DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY); - } - - void foreach_id_ref(UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data) - { - foreach_ID_ref_fn(user_data, reinterpret_cast(&this->obedit_ref)); - for (StepDrawingReference &drawing_ref : drawings_reference_) { - drawing_ref.foreach_id_ref(foreach_ID_ref_fn, user_data); - } - } -}; - -struct GreasePencilUndoStep { - UndoStep step; - /** See #ED_undo_object_editmode_validate_scene_from_windows code comment for details. */ - UndoRefID_Scene scene_ref = {}; - Array objects; -}; - -static bool step_encode(bContext *C, Main *bmain, UndoStep *us_p) -{ - GreasePencilUndoStep *us = reinterpret_cast(us_p); - StepEncodeStatus encode_status; - - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - uint objects_num = 0; - Object **objects = ED_undo_editmode_objects_from_view_layer(scene, view_layer, &objects_num); - BLI_SCOPED_DEFER([&]() { MEM_SAFE_FREE(objects); }) - - us->scene_ref.ptr = scene; - new (&us->objects) Array(objects_num); - - threading::parallel_for(us->objects.index_range(), 8, [&](const IndexRange range) { - for (const int64_t i : range) { - Object *ob = objects[i]; - us->objects[i].encode(ob, encode_status); - } - }); - - bmain->is_memfile_undo_flush_needed = true; - - return true; -} - -static void step_decode( - bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir /*dir*/, bool /*is_final*/) -{ - GreasePencilUndoStep *us = reinterpret_cast(us_p); - StepDecodeStatus decode_status; - - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - - ED_undo_object_editmode_validate_scene_from_windows( - CTX_wm_manager(C), us->scene_ref.ptr, &scene, &view_layer); - ED_undo_object_editmode_restore_helper(scene, - view_layer, - &us->objects.first().obedit_ref.ptr, - uint(us->objects.size()), - sizeof(decltype(us->objects)::value_type)); - - BLI_assert(BKE_object_is_in_editmode(us->objects.first().obedit_ref.ptr)); - - for (const StepObject &step_object : us->objects) { - step_object.decode(decode_status); - } - - if (decode_status.needs_relationships_update) { - DEG_relations_tag_update(bmain); - } - - ED_undo_object_set_active_or_warn( - scene, view_layer, us->objects.first().obedit_ref.ptr, us_p->name, &LOG); - - bmain->is_memfile_undo_flush_needed = true; - - WM_event_add_notifier(C, NC_GEOM | ND_DATA, nullptr); -} - -static void step_free(UndoStep *us_p) -{ - GreasePencilUndoStep *us = reinterpret_cast(us_p); - us->objects.~Array(); -} - -static void foreach_ID_ref(UndoStep *us_p, - UndoTypeForEachIDRefFn foreach_ID_ref_fn, - void *user_data) -{ - GreasePencilUndoStep *us = reinterpret_cast(us_p); - - foreach_ID_ref_fn(user_data, reinterpret_cast(&us->scene_ref)); - for (StepObject &object : us->objects) { - object.foreach_id_ref(foreach_ID_ref_fn, user_data); - } -} - -/** \} */ - -} // namespace blender::ed::greasepencil::undo - -void ED_undosys_type_grease_pencil(UndoType *ut) -{ - using namespace blender::ed; - - ut->name = "Edit GreasePencil"; - ut->poll = greasepencil::editable_grease_pencil_poll; - ut->step_encode = greasepencil::undo::step_encode; - ut->step_decode = greasepencil::undo::step_decode; - ut->step_free = greasepencil::undo::step_free; - - ut->step_foreach_ID_ref = greasepencil::undo::foreach_ID_ref; - - ut->flags = UNDOTYPE_FLAG_NEED_CONTEXT_FOR_ENCODE; - - ut->step_size = sizeof(greasepencil::undo::GreasePencilUndoStep); -} diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc index 42210b2f21e..4e93799c1cd 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc @@ -7,10 +7,11 @@ */ #include "BKE_attribute.hh" -#include "BKE_colortools.hh" +#include "BKE_brush.hh" +#include "BKE_context.hh" #include "BKE_grease_pencil.hh" #include "BKE_material.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BLI_bit_span_ops.hh" #include "BLI_bit_vector.hh" @@ -33,12 +34,9 @@ namespace blender::ed::greasepencil { DrawingPlacement::DrawingPlacement(const Scene &scene, const ARegion ®ion, const View3D &view3d, - const Object &eval_object, - const bke::greasepencil::Layer &layer) - : region_(®ion), view3d_(&view3d) + const Object &object) + : region_(®ion), view3d_(&view3d), transforms_(object) { - layer_space_to_world_space_ = layer.to_world_space(eval_object); - world_space_to_layer_space_ = math::invert(layer_space_to_world_space_); /* Initialize DrawingPlacementPlane from toolsettings. */ switch (scene.toolsettings->gp_sculpt.lock_axis) { case GP_LOCKAXIS_VIEW: @@ -68,7 +66,7 @@ DrawingPlacement::DrawingPlacement(const Scene &scene, switch (scene.toolsettings->gpencil_v3d_align) { case GP_PROJECT_VIEWSPACE: depth_ = DrawingPlacementDepth::ObjectOrigin; - placement_loc_ = layer_space_to_world_space_.location(); + placement_loc_ = transforms_.layer_space_to_world_space.location(); break; case (GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR): depth_ = DrawingPlacementDepth::Cursor; @@ -78,12 +76,12 @@ DrawingPlacement::DrawingPlacement(const Scene &scene, depth_ = DrawingPlacementDepth::Surface; surface_offset_ = scene.toolsettings->gpencil_surface_offset; /* Default to view placement with the object origin if we don't hit a surface. */ - placement_loc_ = layer_space_to_world_space_.location(); + placement_loc_ = transforms_.layer_space_to_world_space.location(); break; case (GP_PROJECT_VIEWSPACE | GP_PROJECT_DEPTH_STROKE): depth_ = DrawingPlacementDepth::NearestStroke; /* Default to view placement with the object origin if we don't hit a stroke. */ - placement_loc_ = layer_space_to_world_space_.location(); + placement_loc_ = transforms_.layer_space_to_world_space.location(); break; } @@ -135,7 +133,7 @@ void DrawingPlacement::set_origin_to_nearest_stroke(const float2 co) } else { /* If nothing was hit, use origin. */ - placement_loc_ = layer_space_to_world_space_.location(); + placement_loc_ = transforms_.layer_space_to_world_space.location(); } plane_from_point_normal_v3(placement_plane_, placement_loc_, placement_normal_); } @@ -171,7 +169,7 @@ float3 DrawingPlacement::project(const float2 co) const ED_view3d_win_to_3d(view3d_, region_, placement_loc_, co, proj_point); } } - return math::transform_point(world_space_to_layer_space_, proj_point); + return math::transform_point(transforms_.world_space_to_layer_space, proj_point); } void DrawingPlacement::project(const Span src, MutableSpan dst) const @@ -183,53 +181,6 @@ void DrawingPlacement::project(const Span src, MutableSpan dst) }); } -static float get_multi_frame_falloff(const int frame_number, - const int center_frame, - const int min_frame, - const int max_frame, - const CurveMapping *falloff_curve) -{ - if (falloff_curve == nullptr) { - return 1.0f; - } - - /* Frame right of the center frame. */ - if (frame_number > center_frame) { - const float frame_factor = 0.5f * float(center_frame - min_frame) / (frame_number - min_frame); - return BKE_curvemapping_evaluateF(falloff_curve, 0, frame_factor); - } - /* Frame left of the center frame. */ - if (frame_number < center_frame) { - const float frame_factor = 0.5f * float(center_frame - frame_number) / - (max_frame - frame_number); - return BKE_curvemapping_evaluateF(falloff_curve, 0, frame_factor + 0.5f); - } - /* Frame at center. */ - return BKE_curvemapping_evaluateF(falloff_curve, 0, 0.5f); -} - -static std::pair get_minmax_selected_frame_numbers(const GreasePencil &grease_pencil, - const int current_frame) -{ - using namespace blender::bke::greasepencil; - int frame_min = current_frame; - int frame_max = current_frame; - Span layers = grease_pencil.layers(); - for (const int layer_i : layers.index_range()) { - const Layer &layer = *layers[layer_i]; - if (!layer.is_editable()) { - continue; - } - for (const auto [frame_number, frame] : layer.frames().items()) { - if (frame_number != current_frame && frame.is_selected()) { - frame_min = math::min(frame_min, frame_number); - frame_max = math::min(frame_max, frame_number); - } - } - } - return std::pair(frame_min, frame_max); -} - static Array get_frame_numbers_for_layer(const bke::greasepencil::Layer &layer, const int current_frame, const bool use_multi_frame_editing) @@ -245,8 +196,8 @@ static Array get_frame_numbers_for_layer(const bke::greasepencil::Layer &la return frame_numbers.as_span(); } -Vector retrieve_editable_drawings(const Scene &scene, - GreasePencil &grease_pencil) +Array retrieve_editable_drawings(const Scene &scene, + GreasePencil &grease_pencil) { using namespace blender::bke::greasepencil; const int current_frame = scene.r.cfra; @@ -265,60 +216,15 @@ Vector retrieve_editable_drawings(const Scene &scene, layer, current_frame, use_multi_frame_editing); for (const int frame_number : frame_numbers) { if (Drawing *drawing = grease_pencil.get_editable_drawing_at(layer, frame_number)) { - editable_drawings.append({*drawing, layer_i, frame_number, 1.0f}); + editable_drawings.append({*drawing, layer_i, frame_number}); } } } - return editable_drawings; + return editable_drawings.as_span(); } -Vector retrieve_editable_drawings_with_falloff(const Scene &scene, - GreasePencil &grease_pencil) -{ - using namespace blender::bke::greasepencil; - const int current_frame = scene.r.cfra; - const ToolSettings *toolsettings = scene.toolsettings; - const bool use_multi_frame_editing = (toolsettings->gpencil_flags & - GP_USE_MULTI_FRAME_EDITING) != 0; - const bool use_multi_frame_falloff = use_multi_frame_editing && - (toolsettings->gp_sculpt.flag & - GP_SCULPT_SETT_FLAG_FRAME_FALLOFF) != 0; - int center_frame; - std::pair minmax_frame; - if (use_multi_frame_falloff) { - BKE_curvemapping_init(toolsettings->gp_sculpt.cur_falloff); - minmax_frame = get_minmax_selected_frame_numbers(grease_pencil, current_frame); - center_frame = math::clamp(current_frame, minmax_frame.first, minmax_frame.second); - } - - Vector editable_drawings; - Span layers = grease_pencil.layers(); - for (const int layer_i : layers.index_range()) { - const Layer &layer = *layers[layer_i]; - if (!layer.is_editable()) { - continue; - } - const Array frame_numbers = get_frame_numbers_for_layer( - layer, current_frame, use_multi_frame_editing); - for (const int frame_number : frame_numbers) { - if (Drawing *drawing = grease_pencil.get_editable_drawing_at(layer, frame_number)) { - const float falloff = use_multi_frame_falloff ? - get_multi_frame_falloff(frame_number, - center_frame, - minmax_frame.first, - minmax_frame.second, - toolsettings->gp_sculpt.cur_falloff) : - 1.0f; - editable_drawings.append({*drawing, layer_i, frame_number, falloff}); - } - } - } - - return editable_drawings; -} - -Vector retrieve_editable_drawings_from_layer( +Array retrieve_editable_drawings_from_layer( const Scene &scene, GreasePencil &grease_pencil, const blender::bke::greasepencil::Layer &layer) @@ -334,16 +240,14 @@ Vector retrieve_editable_drawings_from_layer( layer, current_frame, use_multi_frame_editing); for (const int frame_number : frame_numbers) { if (Drawing *drawing = grease_pencil.get_editable_drawing_at(layer, frame_number)) { - editable_drawings.append( - {*drawing, layer.drawing_index_at(frame_number), frame_number, 1.0f}); + editable_drawings.append({*drawing, layer.drawing_index_at(frame_number), frame_number}); } } - return editable_drawings; + return editable_drawings.as_span(); } -Vector retrieve_visible_drawings(const Scene &scene, - const GreasePencil &grease_pencil) +Array retrieve_visible_drawings(const Scene &scene, const GreasePencil &grease_pencil) { using namespace blender::bke::greasepencil; const int current_frame = scene.r.cfra; @@ -367,7 +271,7 @@ Vector retrieve_visible_drawings(const Scene &scene, } } - return visible_drawings; + return visible_drawings.as_span(); } static VectorSet get_editable_material_indices(Object &object) diff --git a/source/blender/editors/include/ED_curves.hh b/source/blender/editors/include/ED_curves.hh index 696cb6ae6c1..5fc662160d8 100644 --- a/source/blender/editors/include/ED_curves.hh +++ b/source/blender/editors/include/ED_curves.hh @@ -239,9 +239,9 @@ struct FindClosestData { * \return A new point or curve closer than the \a initial input, if one exists. */ std::optional closest_elem_find_screen_space(const ViewContext &vc, + const Object &object, OffsetIndices points_by_curve, Span deformed_positions, - const float4x4 &projection, const IndexMask &mask, bke::AttrDomain domain, int2 coord, @@ -253,7 +253,6 @@ std::optional closest_elem_find_screen_space(const ViewContext bool select_box(const ViewContext &vc, bke::CurvesGeometry &curves, Span deformed_positions, - const float4x4 &projection, const IndexMask &mask, bke::AttrDomain selection_domain, const rcti &rect, @@ -265,10 +264,9 @@ bool select_box(const ViewContext &vc, bool select_lasso(const ViewContext &vc, bke::CurvesGeometry &curves, Span deformed_positions, - const float4x4 &projection_matrix, const IndexMask &mask, bke::AttrDomain selection_domain, - Span lasso_coords, + Span coords, eSelectOp sel_op); /** @@ -277,7 +275,6 @@ bool select_lasso(const ViewContext &vc, bool select_circle(const ViewContext &vc, bke::CurvesGeometry &curves, Span deformed_positions, - const float4x4 &projection, const IndexMask &mask, bke::AttrDomain selection_domain, int2 coord, diff --git a/source/blender/editors/include/ED_file_indexer.hh b/source/blender/editors/include/ED_file_indexer.hh index 35bb877f4cd..1944aefbd52 100644 --- a/source/blender/editors/include/ED_file_indexer.hh +++ b/source/blender/editors/include/ED_file_indexer.hh @@ -8,7 +8,7 @@ #pragma once -#include "BLO_readfile.hh" +#include "BLO_readfile.h" /** * File indexing for the file/asset browser. diff --git a/source/blender/editors/include/ED_grease_pencil.hh b/source/blender/editors/include/ED_grease_pencil.hh index b2776194a50..046d911cc69 100644 --- a/source/blender/editors/include/ED_grease_pencil.hh +++ b/source/blender/editors/include/ED_grease_pencil.hh @@ -25,7 +25,6 @@ struct KeyframeEditData; struct wmKeyConfig; struct ToolSettings; struct Scene; -struct UndoType; struct ViewDepths; struct View3D; namespace blender { @@ -52,8 +51,6 @@ void ED_operatortypes_grease_pencil_edit(); void ED_operatortypes_grease_pencil_material(); void ED_operatormacros_grease_pencil(); void ED_keymap_grease_pencil(wmKeyConfig *keyconf); - -void ED_undosys_type_grease_pencil(UndoType *undo_type); /** * Get the selection mode for Grease Pencil selection operators: point, stroke, segment. */ @@ -73,6 +70,7 @@ class DrawingPlacement { DrawingPlacementDepth depth_; DrawingPlacementPlane plane_; + bke::greasepencil::DrawingTransforms transforms_; ViewDepths *depth_cache_ = nullptr; float surface_offset_; @@ -80,16 +78,12 @@ class DrawingPlacement { float3 placement_normal_; float4 placement_plane_; - float4x4 layer_space_to_world_space_; - float4x4 world_space_to_layer_space_; - public: DrawingPlacement() = default; DrawingPlacement(const Scene &scene, const ARegion ®ion, const View3D &view3d, - const Object &eval_object, - const bke::greasepencil::Layer &layer); + const Object &object); ~DrawingPlacement(); public: @@ -174,16 +168,13 @@ struct MutableDrawingInfo { bke::greasepencil::Drawing &drawing; const int layer_index; const int frame_number; - const float multi_frame_falloff; }; -Vector retrieve_editable_drawings(const Scene &scene, - GreasePencil &grease_pencil); -Vector retrieve_editable_drawings_with_falloff(const Scene &scene, - GreasePencil &grease_pencil); -Vector retrieve_editable_drawings_from_layer( +Array retrieve_editable_drawings(const Scene &scene, + GreasePencil &grease_pencil); +Array retrieve_editable_drawings_from_layer( const Scene &scene, GreasePencil &grease_pencil, const bke::greasepencil::Layer &layer); -Vector retrieve_visible_drawings(const Scene &scene, - const GreasePencil &grease_pencil); +Array retrieve_visible_drawings(const Scene &scene, + const GreasePencil &grease_pencil); IndexMask retrieve_editable_strokes(Object &grease_pencil_object, const bke::greasepencil::Drawing &drawing, diff --git a/source/blender/editors/include/ED_keyframing.hh b/source/blender/editors/include/ED_keyframing.hh index 713393dd06a..765c7cd121f 100644 --- a/source/blender/editors/include/ED_keyframing.hh +++ b/source/blender/editors/include/ED_keyframing.hh @@ -225,19 +225,19 @@ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks); */ KeyingSet *ANIM_get_keyingset_for_autokeying(const Scene *scene, const char *transformKSName); -void ANIM_keyingset_visit_for_search( - const bContext *C, - PointerRNA *ptr, - PropertyRNA *prop, - const char *edit_text, - blender::FunctionRef visit_fn); +void ANIM_keyingset_visit_for_search(const bContext *C, + PointerRNA *ptr, + PropertyRNA *prop, + const char *edit_text, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data); -void ANIM_keyingset_visit_for_search_no_poll( - const bContext *C, - PointerRNA *ptr, - PropertyRNA *prop, - const char *edit_text, - blender::FunctionRef visit_fn); +void ANIM_keyingset_visit_for_search_no_poll(const bContext *C, + PointerRNA *ptr, + PropertyRNA *prop, + const char *edit_text, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data); /** * Dynamically populate an enum of Keying Sets. */ diff --git a/source/blender/editors/include/ED_scene.hh b/source/blender/editors/include/ED_scene.hh index 94c627ea248..208743e794f 100644 --- a/source/blender/editors/include/ED_scene.hh +++ b/source/blender/editors/include/ED_scene.hh @@ -10,7 +10,7 @@ #include "BLI_compiler_attrs.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" struct ReportList; struct bContext; @@ -54,7 +54,7 @@ struct SceneFPS_State { /** * Update frame rate info for viewport drawing. * \param ltime: Time since the last update, - * compatible with the result of #BLI_time_now_seconds. + * compatible with the result of #BLI_check_seconds_timer. */ void ED_scene_fps_average_accumulate(Scene *scene, short fps_samples, double ltime) ATTR_NONNULL(1); diff --git a/source/blender/editors/include/ED_undo.hh b/source/blender/editors/include/ED_undo.hh index ca9bdcee49b..26ac9dbed01 100644 --- a/source/blender/editors/include/ED_undo.hh +++ b/source/blender/editors/include/ED_undo.hh @@ -113,7 +113,7 @@ Base **ED_undo_editmode_bases_from_view_layer(const Scene *scene, * this is needed for modes which handle undo themselves (bypassing #ED_undo_push). * * Using global isn't great, this just avoids doing inline, - * causing 'BKE_global.hh' & 'BKE_main.hh' includes. + * causing 'BKE_global.h' & 'BKE_main.hh' includes. */ UndoStack *ED_undo_stack_get(); diff --git a/source/blender/editors/include/ED_util.hh b/source/blender/editors/include/ED_util.hh index 087bc87766f..8450cc3d72e 100644 --- a/source/blender/editors/include/ED_util.hh +++ b/source/blender/editors/include/ED_util.hh @@ -11,13 +11,10 @@ #include "BLI_compiler_attrs.h" #include "WM_types.hh" +struct IDRemapper; struct Main; struct bContext; -namespace blender::bke::id { -class IDRemapper; -} - /* ed_util.cc */ void ED_editors_init_for_undo(Main *bmain); @@ -45,9 +42,7 @@ bool ED_editors_flush_edits(Main *bmain); * \param new_id: may be NULL to unlink \a old_id. */ void ED_spacedata_id_remap_single(ScrArea *area, SpaceLink *sl, ID *old_id, ID *new_id); -void ED_spacedata_id_remap(ScrArea *area, - SpaceLink *sl, - const blender::bke::id::IDRemapper &mappings); +void ED_spacedata_id_remap(ScrArea *area, SpaceLink *sl, const IDRemapper *mappings); void ED_operatortypes_edutils(); diff --git a/source/blender/editors/include/ED_view3d.hh b/source/blender/editors/include/ED_view3d.hh index bdef261cc54..d3cd26de431 100644 --- a/source/blender/editors/include/ED_view3d.hh +++ b/source/blender/editors/include/ED_view3d.hh @@ -708,8 +708,9 @@ bool ED_view3d_win_to_segment_clipped(const Depsgraph *depsgraph, float r_ray_end[3], bool do_clip_planes); blender::float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const Object *ob); -blender::float4x4 ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d, - const blender::float4x4 &obmat); +void ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d, + const float obmat[4][4], + float r_pmat[4][4]); /** * Convert between region relative coordinates (x,y) and depth component z and @@ -826,6 +827,10 @@ float ED_view3d_radius_to_dist(const View3D *v3d, bool use_aspect, float radius); +/** + * Back-buffer select and draw support. + */ +void ED_view3d_backbuf_depth_validate(ViewContext *vc); /** * allow for small values [0.5 - 2.5], * and large values, FLT_MAX by clamping by the area size diff --git a/source/blender/editors/include/UI_interface_c.hh b/source/blender/editors/include/UI_interface_c.hh index c4b6a9887bc..a57b32f6e6d 100644 --- a/source/blender/editors/include/UI_interface_c.hh +++ b/source/blender/editors/include/UI_interface_c.hh @@ -967,9 +967,12 @@ bool UI_block_active_only_flagged_buttons(const bContext *C, ARegion *region, ui */ void UI_but_execute(const bContext *C, ARegion *region, uiBut *but); -std::optional UI_but_online_manual_id(const uiBut *but) ATTR_WARN_UNUSED_RESULT; -std::optional UI_but_online_manual_id_from_active(const bContext *C) - ATTR_WARN_UNUSED_RESULT; +bool UI_but_online_manual_id(const uiBut *but, + char *r_str, + size_t str_maxncpy) ATTR_WARN_UNUSED_RESULT; +bool UI_but_online_manual_id_from_active(const bContext *C, + char *r_str, + size_t str_maxncpy) ATTR_WARN_UNUSED_RESULT; bool UI_but_is_userdef(const uiBut *but); /* Buttons @@ -1460,12 +1463,6 @@ enum eButProgressType { UI_BUT_PROGRESS_TYPE_RING = 1, }; -enum class LayoutSeparatorType : int8_t { - Auto, - Space, - Line, -}; - /***************************** ID Utilities *******************************/ int UI_icon_from_id(const ID *id); @@ -1872,6 +1869,10 @@ void UI_but_drag_set_rna(uiBut *but, PointerRNA *ptr); */ void UI_but_drag_set_path(uiBut *but, const char *path); void UI_but_drag_set_name(uiBut *but, const char *name); +/** + * Value from button itself. + */ +void UI_but_drag_set_value(uiBut *but); /** * Sets #UI_BUT_DRAG_FULL_BUT so the full button can be dragged. @@ -2960,9 +2961,7 @@ void uiItemV(uiLayout *layout, const char *name, int icon, int argval); /** Separator item */ void uiItemS(uiLayout *layout); /** Separator item */ -void uiItemS_ex(uiLayout *layout, - float factor, - LayoutSeparatorType type = LayoutSeparatorType::Auto); +void uiItemS_ex(uiLayout *layout, float factor); /** Flexible spacing. */ void uiItemSpacer(uiLayout *layout); @@ -3275,10 +3274,12 @@ void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p); * for actions that can also be activated using shortcuts while the cursor is over the button. * Without this those shortcuts aren't discoverable for users. */ -std::optional UI_key_event_operator_string(const bContext *C, - const char *opname, - IDProperty *properties, - bool is_strict); +const char *UI_key_event_operator_string(const bContext *C, + const char *opname, + IDProperty *properties, + const bool is_strict, + char *result, + const int result_maxncpy); /* ui_interface_region_tooltip.c */ diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_color.cc b/source/blender/editors/interface/eyedroppers/eyedropper_color.cc index 4bf40f8d7b6..84a61579ae7 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_color.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_color.cc @@ -23,6 +23,8 @@ #include "BKE_context.hh" #include "BKE_cryptomatte.h" #include "BKE_image.h" +#include "BKE_main.hh" +#include "BKE_node.hh" #include "BKE_screen.hh" #include "NOD_composite.hh" @@ -38,6 +40,8 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "RNA_define.hh" + #include "interface_intern.hh" #include "ED_clip.hh" diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_datablock.cc b/source/blender/editors/interface/eyedroppers/eyedropper_datablock.cc index 78a6b0d1b86..ae79f25fd4e 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_datablock.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_datablock.cc @@ -20,11 +20,11 @@ #include "BLI_math_vector.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_idtype.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "RNA_access.hh" diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc b/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc index e7a80eb41e0..face51ccd0a 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc @@ -163,8 +163,7 @@ static void depthdropper_depth_sample_pt(bContext *C, View3D *v3d = static_cast(area->spacedata.first); RegionView3D *rv3d = static_cast(region->regiondata); /* weak, we could pass in some reference point */ - const float *view_co = v3d->camera ? v3d->camera->object_to_world().location() : - rv3d->viewinv[3]; + const float *view_co = v3d->camera ? v3d->camera->object_to_world[3] : rv3d->viewinv[3]; const int mval[2] = {m_xy[0] - region->winrct.xmin, m_xy[1] - region->winrct.ymin}; copy_v2_v2_int(ddr->name_pos, mval); diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_driver.cc b/source/blender/editors/interface/eyedroppers/eyedropper_driver.cc index af615d3587f..f4127fe2c24 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_driver.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_driver.cc @@ -14,8 +14,10 @@ #include "MEM_guardedalloc.h" #include "DNA_anim_types.h" +#include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_animsys.h" #include "BKE_context.hh" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_gpencil_color.cc b/source/blender/editors/interface/eyedroppers/eyedropper_gpencil_color.cc index ac75464fcc9..1e7f0aaf8d2 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_gpencil_color.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_gpencil_color.cc @@ -16,7 +16,7 @@ #include "BLI_listbase.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_material_types.h" @@ -25,8 +25,10 @@ #include "BKE_context.hh" #include "BKE_gpencil_legacy.h" #include "BKE_lib_id.hh" +#include "BKE_main.hh" #include "BKE_material.h" #include "BKE_paint.hh" +#include "BKE_report.h" #include "UI_interface.hh" @@ -38,9 +40,11 @@ #include "RNA_access.hh" #include "RNA_define.hh" +#include "ED_gpencil_legacy.hh" #include "ED_screen.hh" #include "ED_undo.hh" +#include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" #include "eyedropper_intern.hh" diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 14da09df2aa..716c92ecad4 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -21,6 +21,7 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_userdef_types.h" +#include "DNA_workspace_types.h" #include "BLI_ghash.h" #include "BLI_listbase.h" @@ -31,19 +32,24 @@ #include "BLI_utildefines.h" +#include "BLO_readfile.h" + #include "BKE_animsys.h" #include "BKE_context.hh" #include "BKE_idprop.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_main.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_unit.hh" +#include "ED_asset.hh" + #include "GPU_matrix.h" #include "GPU_state.h" #include "BLF_api.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "UI_interface.hh" #include "UI_interface_icons.hh" @@ -68,6 +74,8 @@ #include "IMB_colormanagement.hh" +#include "DEG_depsgraph_query.hh" + #include "interface_intern.hh" using blender::StringRef; @@ -1096,17 +1104,21 @@ void UI_but_execute(const bContext *C, ARegion *region, uiBut *but) * returns false if undo needs to be disabled. */ static bool ui_but_is_rna_undo(const uiBut *but) { - if (but->rnaprop == nullptr) { - return true; + if (but->rnapoin.owner_id) { + /* avoid undo push for buttons who's ID are screen or wm level + * we could disable undo for buttons with no ID too but may have + * unforeseen consequences, so best check for ID's we _know_ are not + * handled by undo - campbell */ + ID *id = but->rnapoin.owner_id; + if (ID_CHECK_UNDO(id) == false) { + return false; + } } - - /* No owner or type known. Assume we do not undo push as it may be a property from - * the preferences stored outside datablocks. */ - if (but->rnapoin.owner_id == nullptr || but->rnapoin.type == nullptr) { + if (but->rnapoin.type && !RNA_struct_undo_check(but->rnapoin.type)) { return false; } - return ID_CHECK_UNDO(but->rnapoin.owner_id) && RNA_struct_undo_check(but->rnapoin.type); + return true; } /* assigns automatic keybindings to menu items for fast access @@ -1220,43 +1232,66 @@ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_str * - #ui_but_event_property_operator_string * \{ */ -static std::optional ui_but_event_operator_string_from_operator( - const bContext *C, wmOperatorCallParams *op_call_params) +static bool ui_but_event_operator_string_from_operator(const bContext *C, + wmOperatorCallParams *op_call_params, + char *buf, + const size_t buf_maxncpy) { BLI_assert(op_call_params->optype != nullptr); + bool found = false; IDProperty *prop = reinterpret_cast(op_call_params->opptr) ? static_cast(op_call_params->opptr->data) : nullptr; - return WM_key_event_operator_string( - C, op_call_params->optype->idname, op_call_params->opcontext, prop, true); + if (WM_key_event_operator_string(C, + op_call_params->optype->idname, + op_call_params->opcontext, + prop, + true, + buf, + buf_maxncpy)) + { + found = true; + } + return found; } -static std::optional ui_but_event_operator_string_from_menu(const bContext *C, - uiBut *but) +static bool ui_but_event_operator_string_from_menu(const bContext *C, + uiBut *but, + char *buf, + const size_t buf_maxncpy) { MenuType *mt = UI_but_menutype_get(but); BLI_assert(mt != nullptr); + bool found = false; + /* annoying, create a property */ const IDPropertyTemplate val = {0}; IDProperty *prop_menu = IDP_New(IDP_GROUP, &val, __func__); /* Dummy, name is unimportant. */ IDP_AddToGroup(prop_menu, IDP_NewStringMaxSize(mt->idname, sizeof(mt->idname), "name")); - const std::optional result = WM_key_event_operator_string( - C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, true); + if (WM_key_event_operator_string( + C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, true, buf, buf_maxncpy)) + { + found = true; + } IDP_FreeProperty(prop_menu); - return result; + return found; } -static std::optional ui_but_event_operator_string_from_panel(const bContext *C, - uiBut *but) +static bool ui_but_event_operator_string_from_panel(const bContext *C, + uiBut *but, + char *buf, + const size_t buf_maxncpy) { /** Nearly exact copy of #ui_but_event_operator_string_from_menu */ PanelType *pt = UI_but_paneltype_get(but); BLI_assert(pt != nullptr); + bool found = false; + /* annoying, create a property */ const IDPropertyTemplate group_val = {0}; IDProperty *prop_panel = IDP_New( @@ -1268,7 +1303,6 @@ static std::optional ui_but_event_operator_string_from_panel(const IDPropertyTemplate region_type_val = {0}; region_type_val.i = pt->region_type; IDP_AddToGroup(prop_panel, IDP_New(IDP_INT, ®ion_type_val, "region_type")); - BLI_SCOPED_DEFER([&]() { IDP_FreeProperty(prop_panel); }); for (int i = 0; i < 2; i++) { /* FIXME(@ideasman42): We can't reasonably search all configurations - long term. */ @@ -1276,49 +1310,61 @@ static std::optional ui_but_event_operator_string_from_panel(const val.i = i; IDP_ReplaceInGroup(prop_panel, IDP_New(IDP_INT, &val, "keep_open")); - if (std::optional result = WM_key_event_operator_string( - C, "WM_OT_call_panel", WM_OP_INVOKE_REGION_WIN, prop_panel, true)) + if (WM_key_event_operator_string( + C, "WM_OT_call_panel", WM_OP_INVOKE_REGION_WIN, prop_panel, true, buf, buf_maxncpy)) { - return result; + found = true; + break; } } - return std::nullopt; + IDP_FreeProperty(prop_panel); + return found; } -static std::optional ui_but_event_operator_string(const bContext *C, uiBut *but) +static bool ui_but_event_operator_string(const bContext *C, + uiBut *but, + char *buf, + const size_t buf_maxncpy) { + bool found = false; + if (but->optype != nullptr) { wmOperatorCallParams params = {}; params.optype = but->optype; params.opptr = but->opptr; params.opcontext = but->opcontext; - return ui_but_event_operator_string_from_operator(C, ¶ms); + found = ui_but_event_operator_string_from_operator(C, ¶ms, buf, buf_maxncpy); } - if (UI_but_menutype_get(but) != nullptr) { - return ui_but_event_operator_string_from_menu(C, but); + else if (UI_but_menutype_get(but) != nullptr) { + found = ui_but_event_operator_string_from_menu(C, but, buf, buf_maxncpy); } - if (UI_but_paneltype_get(but) != nullptr) { - return ui_but_event_operator_string_from_panel(C, but); + else if (UI_but_paneltype_get(but) != nullptr) { + found = ui_but_event_operator_string_from_panel(C, but, buf, buf_maxncpy); } - return std::nullopt; + return found; } -static std::optional ui_but_extra_icon_event_operator_string( - const bContext *C, const uiButExtraOpIcon *extra_icon) +static bool ui_but_extra_icon_event_operator_string(const bContext *C, + const uiButExtraOpIcon *extra_icon, + char *buf, + const size_t buf_maxncpy) { wmOperatorType *extra_icon_optype = UI_but_extra_operator_icon_optype_get(extra_icon); if (extra_icon_optype) { - return ui_but_event_operator_string_from_operator(C, extra_icon->optype_params); + return ui_but_event_operator_string_from_operator( + C, extra_icon->optype_params, buf, buf_maxncpy); } - return std::nullopt; + return false; } -static std::optional ui_but_event_property_operator_string(const bContext *C, - uiBut *but) +static bool ui_but_event_property_operator_string(const bContext *C, + uiBut *but, + char *buf, + const size_t buf_maxncpy) { using namespace blender; /* Context toggle operator names to check. */ @@ -1377,7 +1423,7 @@ static std::optional ui_but_event_property_operator_string(const bC but = nullptr; if (prop == nullptr) { - return std::nullopt; + return false; } /* This version is only for finding hotkeys for properties. @@ -1417,7 +1463,7 @@ static std::optional ui_but_event_property_operator_string(const bC C, ptr, prop, prop_index); /* Always iterate once, even if data-path isn't set. */ - data_path_variations.append(data_path.value_or("")); + data_path_variations.append(data_path.has_value() ? data_path.value() : ""); if (data_path.has_value()) { StringRef data_path_ref = StringRef(data_path.value()); @@ -1440,7 +1486,6 @@ static std::optional ui_but_event_property_operator_string(const bC const IDPropertyTemplate group_val = {0}; prop_path = IDP_New(IDP_GROUP, &group_val, __func__); - BLI_SCOPED_DEFER([&]() { IDP_FreeProperty(prop_path); }); if (!data_path.is_empty()) { IDP_AddToGroup(prop_path, IDP_NewString(data_path.c_str(), "data_path")); } @@ -1474,16 +1519,19 @@ static std::optional ui_but_event_property_operator_string(const bC /* check each until one works... */ for (int i = 0; (i < opnames_len) && (opnames[i]); i++) { - if (const std::optional str = WM_key_event_operator_string( - C, opnames[i], WM_OP_INVOKE_REGION_WIN, prop_path, false)) + if (WM_key_event_operator_string( + C, opnames[i], WM_OP_INVOKE_REGION_WIN, prop_path, false, buf, buf_maxncpy)) { - return str; + found = true; + break; } } + /* cleanup */ + IDP_FreeProperty(prop_path); } } - return std::nullopt; + return found; } /** \} */ @@ -1530,16 +1578,18 @@ const char ui_radial_dir_order[8] = { const char ui_radial_dir_to_numpad[8] = {8, 9, 6, 3, 2, 1, 4, 7}; const short ui_radial_dir_to_angle[8] = {90, 45, 0, 315, 270, 225, 180, 135}; -static std::string ui_but_pie_direction_string(const uiBut *but) +static void ui_but_pie_direction_string(uiBut *but, char *buf, int size) { BLI_assert(but->pie_dir < ARRAY_SIZE(ui_radial_dir_to_numpad)); - return fmt::to_string(int(ui_radial_dir_to_numpad[but->pie_dir])); + BLI_snprintf(buf, size, "%d", ui_radial_dir_to_numpad[but->pie_dir]); } /** \} */ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) { + char buf[128]; + BLI_assert(block->flag & (UI_BLOCK_LOOP | UI_BLOCK_SHOW_SHORTCUT_ALWAYS)); /* only do it before bounding */ @@ -1553,8 +1603,8 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) if (block->flag & UI_BLOCK_RADIAL) { LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->pie_dir != UI_RADIAL_NONE) { - const std::string str = ui_but_pie_direction_string(but); - ui_but_add_shortcut(but, str.c_str(), false); + ui_but_pie_direction_string(but, buf, sizeof(buf)); + ui_but_add_shortcut(but, buf, false); } } } @@ -1575,13 +1625,11 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) continue; } - if (const std::optional str = ui_but_event_operator_string(C, but)) { - ui_but_add_shortcut(but, str->c_str(), false); + if (ui_but_event_operator_string(C, but, buf, sizeof(buf))) { + ui_but_add_shortcut(but, buf, false); } - else if (const std::optional str = ui_but_event_property_operator_string(C, - but)) - { - ui_but_add_shortcut(but, str->c_str(), false); + else if (ui_but_event_property_operator_string(C, but, buf, sizeof(buf))) { + ui_but_add_shortcut(but, buf, false); } } } @@ -3841,7 +3889,9 @@ static void ui_but_update_ex(uiBut *but, const bool validate) kmi_dummy.alt = (hotkey_but->modifier_key & KM_ALT) ? KM_PRESS : KM_NOTHING; kmi_dummy.oskey = (hotkey_but->modifier_key & KM_OSKEY) ? KM_PRESS : KM_NOTHING; - but->drawstr = WM_keymap_item_to_string(&kmi_dummy, true).value_or(""); + char kmi_str[128]; + WM_keymap_item_to_string(&kmi_dummy, true, kmi_str, sizeof(kmi_str)); + but->drawstr = kmi_str; } else { but->drawstr = IFACE_("Press a key"); @@ -6618,12 +6668,20 @@ std::string UI_but_string_get_rna_tooltip(bContext &C, uiBut &but) std::string UI_but_string_get_operator_keymap(bContext &C, uiBut &but) { - return ui_but_event_operator_string(&C, &but).value_or(""); + char buf[128]; + if (!ui_but_event_operator_string(&C, &but, buf, sizeof(buf))) { + return {}; + } + return buf; } std::string UI_but_string_get_property_keymap(bContext &C, uiBut &but) { - return ui_but_event_property_operator_string(&C, &but).value_or(""); + char buf[128]; + if (!ui_but_event_property_operator_string(&C, &but, buf, sizeof(buf))) { + return {}; + } + return buf; } std::string UI_but_extra_icon_string_get_label(const uiButExtraOpIcon &extra_icon) @@ -6643,7 +6701,11 @@ std::string UI_but_extra_icon_string_get_tooltip(bContext &C, const uiButExtraOp std::string UI_but_extra_icon_string_get_operator_keymap(const bContext &C, const uiButExtraOpIcon &extra_icon) { - return ui_but_extra_icon_event_operator_string(&C, &extra_icon).value_or(""); + char buf[128]; + if (!ui_but_extra_icon_event_operator_string(&C, &extra_icon, buf, sizeof(buf))) { + return {}; + } + return buf; } /* Program Init/Exit */ diff --git a/source/blender/editors/interface/interface_anim.cc b/source/blender/editors/interface/interface_anim.cc index a5f12094772..1c8eb8b0fb7 100644 --- a/source/blender/editors/interface/interface_anim.cc +++ b/source/blender/editors/interface/interface_anim.cc @@ -13,6 +13,7 @@ #include "MEM_guardedalloc.h" #include "DNA_anim_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BLI_listbase.h" @@ -24,9 +25,11 @@ #include "BKE_context.hh" #include "BKE_fcurve.h" #include "BKE_fcurve_driver.h" -#include "BKE_global.hh" +#include "BKE_global.h" +#include "BKE_main.hh" #include "BKE_nla.h" +#include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" #include "ED_keyframing.hh" diff --git a/source/blender/editors/interface/interface_button_group.cc b/source/blender/editors/interface/interface_button_group.cc index e0c55808d0e..79c44240e02 100644 --- a/source/blender/editors/interface/interface_button_group.cc +++ b/source/blender/editors/interface/interface_button_group.cc @@ -6,6 +6,8 @@ * \ingroup edinterface */ +#include "BLI_listbase.h" + #include "MEM_guardedalloc.h" #include "interface_intern.hh" diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index 43c1c6e1dbb..80acd1798e2 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -20,7 +20,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_addon.h" #include "BKE_context.hh" @@ -136,6 +136,7 @@ static void shortcut_free_operator_property(IDProperty *prop) static void but_shortcut_name_func(bContext *C, void *arg1, int /*event*/) { uiBut *but = (uiBut *)arg1; + char shortcut_str[128]; IDProperty *prop; const char *idname = shortcut_get_operator_property(C, but, &prop); @@ -144,10 +145,10 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int /*event*/) } /* complex code to change name of button */ - if (std::optional shortcut_str = WM_key_event_operator_string( - C, idname, but->opcontext, prop, true)) + if (WM_key_event_operator_string( + C, idname, but->opcontext, prop, true, shortcut_str, sizeof(shortcut_str))) { - ui_but_add_shortcut(but, shortcut_str->c_str(), true); + ui_but_add_shortcut(but, shortcut_str, true); } else { /* simply strip the shortcut */ @@ -1265,7 +1266,9 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev } { /* Docs */ - if (std::optional manual_id = UI_but_online_manual_id(but)) { + char buf[512]; + + if (UI_but_online_manual_id(but, buf, sizeof(buf))) { PointerRNA ptr_props; uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Online Manual"), @@ -1281,7 +1284,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev WM_OP_EXEC_DEFAULT, UI_ITEM_NONE, &ptr_props); - RNA_string_set(&ptr_props, "doc_id", manual_id.value().c_str()); + RNA_string_set(&ptr_props, "doc_id", buf); } } } diff --git a/source/blender/editors/interface/interface_context_path.cc b/source/blender/editors/interface/interface_context_path.cc index 3238b0fdb9a..5d319284db9 100644 --- a/source/blender/editors/interface/interface_context_path.cc +++ b/source/blender/editors/interface/interface_context_path.cc @@ -8,13 +8,19 @@ #include "BLI_vector.hh" +#include "BKE_screen.hh" + #include "RNA_access.hh" +#include "ED_screen.hh" + #include "UI_interface.hh" #include "UI_resources.hh" #include "RNA_prototypes.h" +#include "WM_api.hh" + namespace blender::ui { void context_path_add_generic(Vector &path, diff --git a/source/blender/editors/interface/interface_drag.cc b/source/blender/editors/interface/interface_drag.cc index 425cc49163c..10800a2b34d 100644 --- a/source/blender/editors/interface/interface_drag.cc +++ b/source/blender/editors/interface/interface_drag.cc @@ -78,6 +78,11 @@ void UI_but_drag_set_name(uiBut *but, const char *name) but->dragpoin = (void *)name; } +void UI_but_drag_set_value(uiBut *but) +{ + but->dragtype = WM_DRAG_VALUE; +} + void UI_but_drag_set_image(uiBut *but, const char *path, int icon, const ImBuf *imb, float scale) { ui_def_but_icon(but, icon, 0); /* no flag UI_HAS_ICON, so icon doesn't draw in button */ @@ -103,6 +108,7 @@ void ui_but_drag_start(bContext *C, uiBut *but) but->icon, but->dragtype, but->dragpoin, + ui_but_value_get(but), (but->dragflag & UI_BUT_DRAGPOIN_FREE) ? WM_DRAG_FREE_DATA : WM_DRAG_NOP); /* wmDrag has ownership over dragpoin now, stop messing with it. */ @@ -117,6 +123,6 @@ void ui_but_drag_start(bContext *C, uiBut *but) /* Special feature for assets: We add another drag item that supports multiple assets. It * gets the assets from context. */ if (ELEM(but->dragtype, WM_DRAG_ASSET, WM_DRAG_ID)) { - WM_event_start_drag(C, ICON_NONE, WM_DRAG_ASSET_LIST, nullptr, WM_DRAG_NOP); + WM_event_start_drag(C, ICON_NONE, WM_DRAG_ASSET_LIST, nullptr, 0, WM_DRAG_NOP); } } diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index 864d4e1bde0..8682723c1e3 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -26,6 +26,7 @@ #include "BKE_colorband.hh" #include "BKE_colortools.hh" #include "BKE_curveprofile.h" +#include "BKE_node.hh" #include "BKE_tracking.h" #include "IMB_colormanagement.hh" @@ -38,6 +39,7 @@ #include "GPU_batch.h" #include "GPU_batch_presets.h" +#include "GPU_context.h" #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_matrix.h" diff --git a/source/blender/editors/interface/interface_drop.cc b/source/blender/editors/interface/interface_drop.cc index b1d9fce9fdc..4d539fb4b13 100644 --- a/source/blender/editors/interface/interface_drop.cc +++ b/source/blender/editors/interface/interface_drop.cc @@ -8,6 +8,8 @@ #include "UI_interface.hh" +#include "BLI_string.h" + namespace blender::ui { DragInfo::DragInfo(const wmDrag &drag, const wmEvent &event, const DropLocation drop_location) diff --git a/source/blender/editors/interface/interface_dropboxes.cc b/source/blender/editors/interface/interface_dropboxes.cc index 9eeacfe27fd..d43522cb392 100644 --- a/source/blender/editors/interface/interface_dropboxes.cc +++ b/source/blender/editors/interface/interface_dropboxes.cc @@ -10,7 +10,8 @@ #include "BKE_context.hh" -#include "BLT_translation.hh" +#include "BLI_string.h" +#include "BLT_translation.h" #include "DNA_material_types.h" #include "DNA_space_types.h" diff --git a/source/blender/editors/interface/interface_handlers.cc b/source/blender/editors/interface/interface_handlers.cc index b3198517951..493c73479c1 100644 --- a/source/blender/editors/interface/interface_handlers.cc +++ b/source/blender/editors/interface/interface_handlers.cc @@ -42,7 +42,7 @@ #include "BKE_curveprofile.h" #include "BKE_movieclip.h" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "BKE_tracking.h" #include "BKE_unit.hh" @@ -56,6 +56,7 @@ #include "UI_interface.hh" #include "UI_string_search.hh" +#include "UI_view2d.hh" #include "BLF_api.hh" @@ -69,6 +70,8 @@ #include "wm_event_system.hh" #ifdef WITH_INPUT_IME +# include "BLT_lang.h" +# include "BLT_translation.h" # include "wm_window.hh" #endif @@ -414,6 +417,8 @@ struct uiHandleButtonData { /* coords are Window/uiBlock relative (depends on the button) */ int draglastx, draglasty; int dragstartx, dragstarty; + int draglastvalue; + int dragstartvalue; bool dragchange, draglock; int dragsel; float dragf, dragfstart; @@ -433,6 +438,7 @@ struct uiHandleButtonData { /* Menu open, see: #UI_screen_free_active_but_highlight. */ uiPopupBlockHandle *menu; + int menuretval; /* Search box see: #UI_screen_free_active_but_highlight. */ ARegion *searchbox; @@ -2171,7 +2177,7 @@ static bool ui_but_drag_init(bContext *C, } if (valid) { - WM_event_start_drag(C, ICON_COLOR, WM_DRAG_COLOR, drag_info, WM_DRAG_FREE_DATA); + WM_event_start_drag(C, ICON_COLOR, WM_DRAG_COLOR, drag_info, 0.0, WM_DRAG_FREE_DATA); } else { MEM_freeN(drag_info); @@ -4394,7 +4400,7 @@ static void ui_block_open_end(bContext *C, uiBut *but, uiHandleButtonData *data) but->editval = nullptr; but->editvec = nullptr; - but->block->auto_open_last = BLI_time_now_seconds(); + but->block->auto_open_last = BLI_check_seconds_timer(); } if (data->menu) { @@ -8646,7 +8652,7 @@ static void button_activate_init(bContext *C, * want to allow auto opening adjacent menus even if no button is activated * in between going over to the other button, but only for a short while */ if (type == BUTTON_ACTIVATE_OVER && but->block->auto_open == true) { - if (but->block->auto_open_last + BUTTON_AUTO_OPEN_THRESH < BLI_time_now_seconds()) { + if (but->block->auto_open_last + BUTTON_AUTO_OPEN_THRESH < BLI_check_seconds_timer()) { but->block->auto_open = false; } } @@ -8692,7 +8698,7 @@ static void button_activate_init(bContext *C, if (UI_but_has_tooltip_label(but)) { /* Show a label for this button. */ bScreen *screen = WM_window_get_active_screen(data->window); - if ((BLI_time_now_seconds() - WM_tooltip_time_closed()) < 0.1) { + if ((BLI_check_seconds_timer() - WM_tooltip_time_closed()) < 0.1) { WM_tooltip_immediate_init(C, CTX_wm_window(C), data->area, region, ui_but_tooltip_init); if (screen->tool_tip) { screen->tool_tip->pass = 1; @@ -9973,7 +9979,7 @@ static void ui_mouse_motion_towards_init_ex(uiPopupBlockHandle *menu, menu->towardstime = DBL_MAX; /* unlimited time */ } else { - menu->towardstime = BLI_time_now_seconds(); + menu->towardstime = BLI_check_seconds_timer(); } } } @@ -10053,7 +10059,7 @@ static bool ui_mouse_motion_towards_check(uiBlock *block, } /* 1 second timer */ - if (BLI_time_now_seconds() - menu->towardstime > BUTTON_MOUSE_TOWARDS_THRESH) { + if (BLI_check_seconds_timer() - menu->towardstime > BUTTON_MOUSE_TOWARDS_THRESH) { menu->dotowards = false; } diff --git a/source/blender/editors/interface/interface_icons.cc b/source/blender/editors/interface/interface_icons.cc index 80fc5484850..7b1fd247e1b 100644 --- a/source/blender/editors/interface/interface_icons.cc +++ b/source/blender/editors/interface/interface_icons.cc @@ -42,7 +42,7 @@ #include "BKE_appdir.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_icons.h" #include "BKE_paint.hh" #include "BKE_preview_image.hh" diff --git a/source/blender/editors/interface/interface_icons_event.cc b/source/blender/editors/interface/interface_icons_event.cc index 90769a8cf2c..99d4611d53f 100644 --- a/source/blender/editors/interface/interface_icons_event.cc +++ b/source/blender/editors/interface/interface_icons_event.cc @@ -11,6 +11,7 @@ * Event codes are used as identifiers. */ +#include "GPU_batch.h" #include "GPU_state.h" #include "BLI_string.h" diff --git a/source/blender/editors/interface/interface_intern.hh b/source/blender/editors/interface/interface_intern.hh index 9710701a3b2..914b6a51a86 100644 --- a/source/blender/editors/interface/interface_intern.hh +++ b/source/blender/editors/interface/interface_intern.hh @@ -198,7 +198,6 @@ struct uiBut { * - UI_BTYPE_LABEL: Use `(a1 == 1.0f)` to use a2 as a blending factor (imaginative!). * - UI_BTYPE_SCROLL: Use as scroll size. * - UI_BTYPE_SEARCH_MENU: Use as number or rows. - * - UI_BTYPE_SEPR_LINE: 1.0 = vertical */ float a1 = 0; diff --git a/source/blender/editors/interface/interface_layout.cc b/source/blender/editors/interface/interface_layout.cc index f84d2cd0a82..6300cf1d6f8 100644 --- a/source/blender/editors/interface/interface_layout.cc +++ b/source/blender/editors/interface/interface_layout.cc @@ -27,10 +27,12 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "BKE_anim_data.h" +#include "BKE_armature.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_screen.hh" @@ -1094,13 +1096,15 @@ static uiBut *ui_item_with_label(uiLayout *layout, nullptr); } else if ((flag & UI_ITEM_R_FULL_EVENT) && is_keymapitem_ptr) { - std::string kmi_str = - WM_keymap_item_to_string(static_cast(ptr->data), false).value_or(""); + char buf[128]; + + WM_keymap_item_to_string( + static_cast(ptr->data), false, buf, sizeof(buf)); but = uiDefButR_prop(block, UI_BTYPE_HOTKEY_EVENT, 0, - kmi_str.c_str(), + buf, x, y, prop_but_width, @@ -3438,45 +3442,29 @@ void uiItemV(uiLayout *layout, const char *name, int icon, int argval) } } -void uiItemS_ex(uiLayout *layout, float factor, const LayoutSeparatorType type) +void uiItemS_ex(uiLayout *layout, float factor) { uiBlock *block = layout->root->block; const bool is_menu = ui_block_is_menu(block); if (is_menu && !UI_block_can_add_separator(block)) { return; } - int space = (is_menu) ? int(0.35f * UI_UNIT_X) : int(0.3f * UI_UNIT_X); space *= factor; - eButType but_type; - - switch (type) { - case LayoutSeparatorType::Line: - but_type = UI_BTYPE_SEPR_LINE; - break; - case LayoutSeparatorType::Auto: - but_type = is_menu ? UI_BTYPE_SEPR_LINE : UI_BTYPE_SEPR; - break; - default: - but_type = UI_BTYPE_SEPR; - } - - bool is_vertical_bar = (layout->w == 0) && but_type == UI_BTYPE_SEPR_LINE; - UI_block_layout_set_current(block, layout); uiDefBut(block, - but_type, + (is_menu) ? UI_BTYPE_SEPR_LINE : UI_BTYPE_SEPR, 0, "", 0, 0, space, - is_vertical_bar ? UI_UNIT_Y : space, + space, nullptr, 0.0, 0.0, - is_vertical_bar ? 1.0f : 0.0f, + 0, 0, ""); } @@ -3679,10 +3667,11 @@ void uiItemMenuEnumFullO_ptr(uiLayout *layout, /* add hotkey here, lower UI code can't detect it */ if ((layout->root->block->flag & UI_BLOCK_LOOP) && (ot->prop && ot->invoke)) { - if (std::optional shortcut_str = WM_key_event_operator_string( - C, ot->idname, layout->root->opcontext, nullptr, false)) + char keybuf[128]; + if (WM_key_event_operator_string( + C, ot->idname, layout->root->opcontext, nullptr, false, keybuf, sizeof(keybuf))) { - ui_but_add_shortcut(but, shortcut_str->c_str(), false); + ui_but_add_shortcut(but, keybuf, false); } } } diff --git a/source/blender/editors/interface/interface_ops.cc b/source/blender/editors/interface/interface_ops.cc index 653b6226d85..f7073c30e8e 100644 --- a/source/blender/editors/interface/interface_ops.cc +++ b/source/blender/editors/interface/interface_ops.cc @@ -17,15 +17,18 @@ #include "DNA_modifier_types.h" /* for handling geometry nodes properties */ #include "DNA_object_types.h" /* for OB_DATA_SUPPORT_ID */ #include "DNA_screen_types.h" +#include "DNA_text_types.h" #include "BLI_blenlib.h" #include "BLI_math_color.h" #include "BLF_api.hh" -#include "BLT_lang.hh" -#include "BLT_translation.hh" +#include "BLT_lang.h" +#include "BLT_translation.h" #include "BKE_context.hh" +#include "BKE_global.h" +#include "BKE_idprop.h" #include "BKE_idtype.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" @@ -33,8 +36,9 @@ #include "BKE_lib_remap.hh" #include "BKE_material.h" #include "BKE_node.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" +#include "BKE_text.h" #include "IMB_colormanagement.hh" @@ -42,8 +46,10 @@ #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "RNA_path.hh" #include "RNA_prototypes.h" +#include "RNA_types.hh" #include "UI_interface.hh" @@ -60,8 +66,10 @@ #include "ED_keyframing.hh" /* only for UI_OT_editsource */ +#include "BKE_main.hh" #include "BLI_ghash.h" #include "ED_screen.hh" +#include "ED_text.hh" using namespace blender::ui; diff --git a/source/blender/editors/interface/interface_panel.cc b/source/blender/editors/interface/interface_panel.cc index 18a5f9c6939..72c73fc6124 100644 --- a/source/blender/editors/interface/interface_panel.cc +++ b/source/blender/editors/interface/interface_panel.cc @@ -20,7 +20,7 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_screen_types.h" #include "DNA_userdef_types.h" @@ -1797,7 +1797,7 @@ static void ui_do_animate(bContext *C, Panel *panel) uiHandlePanelData *data = static_cast(panel->activedata); ARegion *region = CTX_wm_region(C); - float fac = (BLI_time_now_seconds() - data->starttime) / ANIMATION_TIME; + float fac = (BLI_check_seconds_timer() - data->starttime) / ANIMATION_TIME; fac = min_ff(sqrtf(fac), 1.0f); if (uiAlignPanelStep(region, fac, false)) { @@ -2655,7 +2655,7 @@ static void panel_handle_data_ensure(const bContext *C, data->startofsy = panel->ofsy; data->start_cur_xmin = region->v2d.cur.xmin; data->start_cur_ymin = region->v2d.cur.ymin; - data->starttime = BLI_time_now_seconds(); + data->starttime = BLI_check_seconds_timer(); } /** diff --git a/source/blender/editors/interface/interface_region_color_picker.cc b/source/blender/editors/interface/interface_region_color_picker.cc index c58df572830..cda1f33427c 100644 --- a/source/blender/editors/interface/interface_region_color_picker.cc +++ b/source/blender/editors/interface/interface_region_color_picker.cc @@ -20,13 +20,17 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BKE_context.hh" + #include "WM_types.hh" #include "RNA_access.hh" #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" + +#include "ED_screen.hh" #include "IMB_colormanagement.hh" diff --git a/source/blender/editors/interface/interface_region_hud.cc b/source/blender/editors/interface/interface_region_hud.cc index 5a2978263fd..6f4e4afee63 100644 --- a/source/blender/editors/interface/interface_region_hud.cc +++ b/source/blender/editors/interface/interface_region_hud.cc @@ -26,12 +26,15 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "RNA_access.hh" + #include "UI_interface.hh" #include "UI_view2d.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "ED_screen.hh" +#include "ED_undo.hh" #include "GPU_framebuffer.h" #include "interface_intern.hh" diff --git a/source/blender/editors/interface/interface_region_menu_pie.cc b/source/blender/editors/interface/interface_region_menu_pie.cc index b8af07e6e71..9d30ef3a4af 100644 --- a/source/blender/editors/interface/interface_region_menu_pie.cc +++ b/source/blender/editors/interface/interface_region_menu_pie.cc @@ -32,7 +32,9 @@ #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" + +#include "ED_screen.hh" #include "interface_intern.hh" #include "interface_regions_intern.hh" @@ -191,7 +193,7 @@ void UI_pie_menu_end(bContext *C, uiPieMenu *pie) menu = ui_popup_block_create(C, nullptr, nullptr, nullptr, ui_block_func_PIE, pie, nullptr); menu->popup = true; - menu->towardstime = BLI_time_now_seconds(); + menu->towardstime = BLI_check_seconds_timer(); UI_popup_handlers_add(C, &window->modalhandlers, menu, WM_HANDLER_ACCEPT_DBL_CLICK); WM_event_add_mousemove(window); diff --git a/source/blender/editors/interface/interface_region_menu_popup.cc b/source/blender/editors/interface/interface_region_menu_popup.cc index 7cd6ec31583..223703f904b 100644 --- a/source/blender/editors/interface/interface_region_menu_popup.cc +++ b/source/blender/editors/interface/interface_region_menu_popup.cc @@ -18,6 +18,7 @@ #include "DNA_userdef_types.h" +#include "BLI_ghash.h" #include "BLI_hash.hh" #include "BLI_listbase.h" #include "BLI_math_vector.h" @@ -26,7 +27,7 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "WM_api.hh" @@ -36,7 +37,7 @@ #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "ED_screen.hh" diff --git a/source/blender/editors/interface/interface_region_popover.cc b/source/blender/editors/interface/interface_region_popover.cc index ab9c0baf2bf..73f85e8776c 100644 --- a/source/blender/editors/interface/interface_region_popover.cc +++ b/source/blender/editors/interface/interface_region_popover.cc @@ -36,15 +36,18 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" +#include "ED_screen.hh" + #include "WM_api.hh" #include "WM_types.hh" #include "UI_interface.hh" #include "interface_intern.hh" +#include "interface_regions_intern.hh" /* -------------------------------------------------------------------- */ /** \name Popup Menu with Callback or String diff --git a/source/blender/editors/interface/interface_region_search.cc b/source/blender/editors/interface/interface_region_search.cc index 90445130d04..8aaf3fdbb49 100644 --- a/source/blender/editors/interface/interface_region_search.cc +++ b/source/blender/editors/interface/interface_region_search.cc @@ -35,7 +35,7 @@ #include "UI_interface_icons.hh" #include "UI_view2d.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "ED_screen.hh" diff --git a/source/blender/editors/interface/interface_region_tooltip.cc b/source/blender/editors/interface/interface_region_tooltip.cc index 23f78aa1d59..24df87b22a7 100644 --- a/source/blender/editors/interface/interface_region_tooltip.cc +++ b/source/blender/editors/interface/interface_region_tooltip.cc @@ -26,6 +26,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_brush_types.h" #include "DNA_userdef_types.h" #include "BLI_listbase.h" @@ -57,7 +58,7 @@ #include "UI_interface.hh" #include "BLF_api.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #ifdef WITH_PYTHON # include "BPY_extern_run.h" @@ -367,6 +368,7 @@ static std::string ui_tooltip_text_python_from_op(bContext *C, static bool ui_tooltip_data_append_from_keymap(bContext *C, uiTooltipData *data, wmKeyMap *keymap) { const int fields_len_init = data->fields.size(); + char buf[512]; LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { wmOperatorType *ot = WM_operatortype_find(kmi->idname, true); @@ -382,9 +384,12 @@ static bool ui_tooltip_data_append_from_keymap(bContext *C, uiTooltipData *data, true); /* Shortcut. */ - const std::string kmi_str = WM_keymap_item_to_string(kmi, false).value_or("None"); + bool found = false; + if (WM_keymap_item_to_string(kmi, false, buf, sizeof(buf))) { + found = true; + } UI_tooltip_text_field_add(data, - fmt::format(TIP_("Shortcut: {}"), kmi_str), + fmt::format(TIP_("Shortcut: {}"), found ? buf : "None"), {}, UI_TIP_STYLE_NORMAL, UI_TIP_LC_NORMAL); @@ -583,14 +588,16 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is RNA_enum_set(&op_props, tool_attr, items[i].value); /* Check for direct access to the tool. */ - if (std::optional shortcut_brush = WM_key_event_operator_string( - C, - ot->idname, - WM_OP_INVOKE_REGION_WIN, - static_cast(op_props.data), - true)) + char shortcut_brush[128] = ""; + if (WM_key_event_operator_string(C, + ot->idname, + WM_OP_INVOKE_REGION_WIN, + static_cast(op_props.data), + true, + shortcut_brush, + ARRAY_SIZE(shortcut_brush))) { - shortcut = *shortcut_brush; + shortcut = shortcut_brush; } WM_operator_properties_free(&op_props); } @@ -599,8 +606,14 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is if (shortcut.empty()) { /* Check for direct access to the tool. */ - if (std::optional shortcut_toolbar = WM_key_event_operator_string( - C, "WM_OT_toolbar", WM_OP_INVOKE_REGION_WIN, nullptr, true)) + char shortcut_toolbar[128] = ""; + if (WM_key_event_operator_string(C, + "WM_OT_toolbar", + WM_OP_INVOKE_REGION_WIN, + nullptr, + true, + shortcut_toolbar, + ARRAY_SIZE(shortcut_toolbar))) { /* Generate keymap in order to inspect it. * NOTE: we could make a utility to avoid the keymap generation part of this. */ @@ -626,8 +639,9 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is char tool_id_test[MAX_NAME]; RNA_string_get(kmi->ptr, "name", tool_id_test); if (STREQ(tool_id, tool_id_test)) { - std::string kmi_str = WM_keymap_item_to_string(kmi, false).value_or(""); - shortcut = fmt::format("{}, {}", *shortcut_toolbar, kmi_str); + char buf[128]; + WM_keymap_item_to_string(kmi, false, buf, sizeof(buf)); + shortcut = fmt::format("{}, {}", shortcut_toolbar, buf); break; } } @@ -691,19 +705,21 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is WM_operator_properties_create_ptr(&op_props, but->optype); RNA_boolean_set(&op_props, "cycle", true); - std::optional shortcut; + char shortcut[128] = ""; const char *item_end = expr_result + expr_result_len; const char *item_step = expr_result; while (item_step < item_end) { RNA_string_set(&op_props, "name", item_step); - shortcut = WM_key_event_operator_string(C, - but->optype->idname, - WM_OP_INVOKE_REGION_WIN, - static_cast(op_props.data), - true); - if (shortcut) { + if (WM_key_event_operator_string(C, + but->optype->idname, + WM_OP_INVOKE_REGION_WIN, + static_cast(op_props.data), + true, + shortcut, + ARRAY_SIZE(shortcut))) + { break; } item_step += strlen(item_step) + 1; @@ -712,9 +728,9 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is WM_operator_properties_free(&op_props); MEM_freeN(expr_result); - if (shortcut) { + if (shortcut[0] != '\0') { UI_tooltip_text_field_add(data, - fmt::format(TIP_("Shortcut Cycle: {}"), *shortcut), + fmt::format(TIP_("Shortcut Cycle: {}"), shortcut), {}, UI_TIP_STYLE_NORMAL, UI_TIP_LC_VALUE, @@ -1083,11 +1099,12 @@ static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *gz) /* Shortcut */ { IDProperty *prop = static_cast(gzop->ptr.data); - if (std::optional shortcut_str = WM_key_event_operator_string( - C, gzop->type->idname, WM_OP_INVOKE_DEFAULT, prop, true)) + char buf[128]; + if (WM_key_event_operator_string( + C, gzop->type->idname, WM_OP_INVOKE_DEFAULT, prop, true, buf, ARRAY_SIZE(buf))) { UI_tooltip_text_field_add(data, - fmt::format(TIP_("Shortcut: {}"), *shortcut_str), + fmt::format(TIP_("Shortcut: {}"), buf), {}, UI_TIP_STYLE_NORMAL, UI_TIP_LC_VALUE, diff --git a/source/blender/editors/interface/interface_regions.cc b/source/blender/editors/interface/interface_regions.cc index 2c75e6d6740..cf099a1a04b 100644 --- a/source/blender/editors/interface/interface_regions.cc +++ b/source/blender/editors/interface/interface_regions.cc @@ -17,6 +17,7 @@ #include "BKE_context.hh" #include "BKE_screen.hh" +#include "WM_api.hh" #include "wm_draw.hh" #include "ED_screen.hh" diff --git a/source/blender/editors/interface/interface_style.cc b/source/blender/editors/interface/interface_style.cc index e3fc95ba12c..dac14248452 100644 --- a/source/blender/editors/interface/interface_style.cc +++ b/source/blender/editors/interface/interface_style.cc @@ -21,12 +21,16 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLF_api.hh" +#include "BLT_translation.h" + #include "UI_interface.hh" +#include "ED_datafiles.h" + #include "interface_intern.hh" #ifdef WIN32 diff --git a/source/blender/editors/interface/interface_template_asset_view.cc b/source/blender/editors/interface/interface_template_asset_view.cc index 632c31f84cb..d7a564b51b5 100644 --- a/source/blender/editors/interface/interface_template_asset_view.cc +++ b/source/blender/editors/interface/interface_template_asset_view.cc @@ -13,9 +13,12 @@ #include "BKE_screen.hh" +#include "BLI_path_util.h" #include "BLI_string.h" #include "BLI_string_ref.hh" +#include "BLO_readfile.h" + #include "ED_asset.hh" #include "ED_screen.hh" @@ -26,6 +29,7 @@ #include "UI_interface.hh" +#include "WM_api.hh" #include "WM_types.hh" #include "interface_intern.hh" diff --git a/source/blender/editors/interface/interface_template_attribute_search.cc b/source/blender/editors/interface/interface_template_attribute_search.cc index a9675b64089..434f9c53bb0 100644 --- a/source/blender/editors/interface/interface_template_attribute_search.cc +++ b/source/blender/editors/interface/interface_template_attribute_search.cc @@ -13,7 +13,7 @@ #include "RNA_access.hh" #include "RNA_enum_types.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_attribute.hh" diff --git a/source/blender/editors/interface/interface_template_bone_collection_tree.cc b/source/blender/editors/interface/interface_template_bone_collection_tree.cc index 4e168e1a4c4..93a73485445 100644 --- a/source/blender/editors/interface/interface_template_bone_collection_tree.cc +++ b/source/blender/editors/interface/interface_template_bone_collection_tree.cc @@ -8,7 +8,7 @@ #include "BKE_context.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "ANIM_armature_iter.hh" #include "ANIM_bone_collections.hh" diff --git a/source/blender/editors/interface/interface_template_grease_pencil_layer_tree.cc b/source/blender/editors/interface/interface_template_grease_pencil_layer_tree.cc index d4acbd2c305..79c96601185 100644 --- a/source/blender/editors/interface/interface_template_grease_pencil_layer_tree.cc +++ b/source/blender/editors/interface/interface_template_grease_pencil_layer_tree.cc @@ -9,7 +9,7 @@ #include "BKE_context.hh" #include "BKE_grease_pencil.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/interface/interface_template_light_linking.cc b/source/blender/editors/interface/interface_template_light_linking.cc index 77bda54c236..e7b773676c8 100644 --- a/source/blender/editors/interface/interface_template_light_linking.cc +++ b/source/blender/editors/interface/interface_template_light_linking.cc @@ -13,7 +13,7 @@ #include -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_collection_types.h" #include "DNA_object_types.h" diff --git a/source/blender/editors/interface/interface_template_list.cc b/source/blender/editors/interface/interface_template_list.cc index e2b509816b6..af6c7f7a577 100644 --- a/source/blender/editors/interface/interface_template_list.cc +++ b/source/blender/editors/interface/interface_template_list.cc @@ -20,8 +20,9 @@ #include "BKE_screen.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "ED_asset.hh" #include "ED_screen.hh" #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/interface/interface_template_node_inputs.cc b/source/blender/editors/interface/interface_template_node_inputs.cc index 8a3b187b189..d93c5385043 100644 --- a/source/blender/editors/interface/interface_template_node_inputs.cc +++ b/source/blender/editors/interface/interface_template_node_inputs.cc @@ -13,7 +13,7 @@ #include "BKE_node_runtime.hh" #include "BKE_screen.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "NOD_node_declaration.hh" @@ -43,9 +43,7 @@ static void draw_node_input(bContext *C, { BLI_assert(socket.typeinfo != nullptr); /* Ignore disabled sockets and linked sockets and sockets without a `draw` callback. */ - if (!socket.is_available() || (socket.flag & (SOCK_IS_LINKED | SOCK_HIDE_VALUE)) || - socket.typeinfo->draw == nullptr || - ELEM(socket.type, SOCK_GEOMETRY, SOCK_MATRIX, SOCK_SHADER)) + if (!socket.is_available() || (socket.flag & SOCK_IS_LINKED) || socket.typeinfo->draw == nullptr) { return; } diff --git a/source/blender/editors/interface/interface_template_node_tree_interface.cc b/source/blender/editors/interface/interface_template_node_tree_interface.cc index 5d0b2c4e00a..6a2112b6e76 100644 --- a/source/blender/editors/interface/interface_template_node_tree_interface.cc +++ b/source/blender/editors/interface/interface_template_node_tree_interface.cc @@ -13,7 +13,7 @@ #include "BLI_color.hh" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_node_tree_interface_types.h" diff --git a/source/blender/editors/interface/interface_template_search_menu.cc b/source/blender/editors/interface/interface_template_search_menu.cc index 61afd2df1dd..c7c407f303b 100644 --- a/source/blender/editors/interface/interface_template_search_menu.cc +++ b/source/blender/editors/interface/interface_template_search_menu.cc @@ -15,8 +15,11 @@ #include "MEM_guardedalloc.h" #include "DNA_action_types.h" +#include "DNA_gpencil_modifier_types.h" #include "DNA_node_types.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_shader_fx_types.h" #include "DNA_texture_types.h" #include "BLI_dynstr.h" @@ -28,12 +31,13 @@ #include "BLI_set.hh" #include "BLI_stack.hh" #include "BLI_string.h" +#include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_screen.hh" #include "ED_screen.hh" @@ -861,8 +865,9 @@ static MenuSearch_Data *menu_items_from_ui_create(bContext *C, wmKeyMapItem *kmi = menu_to_kmi.lookup_default(item->mt, nullptr); if (kmi != nullptr) { - std::string kmi_str = WM_keymap_item_to_string(kmi, false).value_or(""); - BLI_dynstr_appendf(dyn_str, " (%s)", kmi_str.c_str()); + char kmi_str[128]; + WM_keymap_item_to_string(kmi, false, kmi_str, sizeof(kmi_str)); + BLI_dynstr_appendf(dyn_str, " (%s)", kmi_str); } BLI_dynstr_append(dyn_str, " " UI_MENU_ARROW_SEP " "); diff --git a/source/blender/editors/interface/interface_template_search_operator.cc b/source/blender/editors/interface/interface_template_search_operator.cc index ea5b537f517..7568ee0eb75 100644 --- a/source/blender/editors/interface/interface_template_search_operator.cc +++ b/source/blender/editors/interface/interface_template_search_operator.cc @@ -10,9 +10,9 @@ */ #include -#include #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_texture_types.h" #include "BLI_array.hh" @@ -21,9 +21,10 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" -#include "BKE_global.hh" +#include "BKE_context.hh" +#include "BKE_global.h" #include "WM_api.hh" #include "WM_types.hh" @@ -70,15 +71,27 @@ static void operator_search_update_fn(const bContext *C, if (BLI_string_all_words_matched(ot_ui_name, str, (int(*)[2])words.data(), words_len)) { if (WM_operator_poll((bContext *)C, ot)) { - std::string name = ot_ui_name; - if (const std::optional kmi_str = WM_key_event_operator_string( - C, ot->idname, WM_OP_EXEC_DEFAULT, nullptr, true)) - { - name += UI_SEP_CHAR; - name += *kmi_str; + char name[256]; + const int len = strlen(ot_ui_name); + + /* display name for menu, can hold hotkey */ + STRNCPY(name, ot_ui_name); + + /* check for hotkey */ + if (len < sizeof(name) - 6) { + if (WM_key_event_operator_string(C, + ot->idname, + WM_OP_EXEC_DEFAULT, + nullptr, + true, + &name[len + 1], + sizeof(name) - len - 1)) + { + name[len] = UI_SEP_CHAR; + } } - if (!UI_search_item_add(items, name.c_str(), ot, ICON_NONE, 0, 0)) { + if (!UI_search_item_add(items, name, ot, ICON_NONE, 0, 0)) { break; } } diff --git a/source/blender/editors/interface/interface_templates.cc b/source/blender/editors/interface/interface_templates.cc index 7999207842b..a71d4215890 100644 --- a/source/blender/editors/interface/interface_templates.cc +++ b/source/blender/editors/interface/interface_templates.cc @@ -23,12 +23,15 @@ #include "DNA_curveprofile_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_node_types.h" +#include "DNA_object_force_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_shader_fx_types.h" #include "DNA_texture_types.h" +#include "BLI_alloca.h" #include "BLI_fileops.h" +#include "BLI_fnmatch.h" #include "BLI_listbase.h" #include "BLI_math_color.h" #include "BLI_math_vector.h" @@ -41,16 +44,18 @@ #include "BLI_utildefines.h" #include "BLF_api.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "BKE_action.h" #include "BKE_blender_version.h" #include "BKE_blendfile.hh" +#include "BKE_cachefile.h" #include "BKE_colorband.hh" #include "BKE_colortools.hh" #include "BKE_constraint.h" #include "BKE_context.hh" #include "BKE_curveprofile.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_idprop.h" #include "BKE_idtype.hh" @@ -60,13 +65,15 @@ #include "BKE_linestyle.h" #include "BKE_main.hh" #include "BKE_modifier.hh" +#include "BKE_object.hh" #include "BKE_packedFile.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_particle.h" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_shader_fx.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" @@ -95,6 +102,7 @@ #include "UI_interface.hh" #include "UI_interface_icons.hh" #include "UI_string_search.hh" +#include "UI_view2d.hh" #include "interface_intern.hh" /* we may want to make this optional, disable for now. */ @@ -6091,7 +6099,7 @@ static std::string progress_tooltip_func(bContext * /*C*/, void *argN, const cha /* create tooltip text and associate it with the job */ char elapsed_str[32]; char remaining_str[32] = "Unknown"; - const double elapsed = BLI_time_now_seconds() - WM_jobs_starttime(wm, owner); + const double elapsed = BLI_check_seconds_timer() - WM_jobs_starttime(wm, owner); BLI_timecode_string_from_time_simple(elapsed_str, sizeof(elapsed_str), elapsed); if (progress) { @@ -6299,7 +6307,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) UI_but_func_tooltip_set(but_progress, progress_tooltip_func, tip_arg, MEM_freeN); } - if (!wm->runtime->is_interface_locked) { + if (!wm->is_interface_locked) { uiDefIconTextBut(block, UI_BTYPE_BUT, handle_event, diff --git a/source/blender/editors/interface/interface_utils.cc b/source/blender/editors/interface/interface_utils.cc index 60a3275f1c5..3d5aaac5fdd 100644 --- a/source/blender/editors/interface/interface_utils.cc +++ b/source/blender/editors/interface/interface_utils.cc @@ -10,7 +10,6 @@ #include #include #include -#include #include "DNA_object_types.h" #include "DNA_screen_types.h" @@ -21,12 +20,13 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_lib_id.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "MEM_guardedalloc.h" @@ -366,46 +366,51 @@ void UI_but_func_identity_compare_set(uiBut *but, uiButIdentityCompareFunc cmp_f /* *** RNA collection search menu *** */ struct CollItemSearch { + CollItemSearch *next, *prev; void *data; - std::string name; + char *name; int index; int iconid; - int name_prefix_offset; bool is_id; - bool has_sep_char; + int name_prefix_offset; + uint has_sep_char : 1; }; -static bool add_collection_search_item(CollItemSearch &cis, +static bool add_collection_search_item(CollItemSearch *cis, const bool requires_exact_data_name, const bool has_id_icon, uiSearchItems *items) { + char name_buf[UI_MAX_DRAW_STR]; /* If no item has an own icon to display, libraries can use the library icons rather than the * name prefix for showing the library status. */ - int name_prefix_offset = cis.name_prefix_offset; - if (!has_id_icon && cis.is_id && !requires_exact_data_name) { - cis.iconid = UI_icon_from_library(static_cast(cis.data)); - char name_buf[UI_MAX_DRAW_STR]; + int name_prefix_offset = cis->name_prefix_offset; + if (!has_id_icon && cis->is_id && !requires_exact_data_name) { + cis->iconid = UI_icon_from_library(static_cast(cis->data)); + /* No need to re-allocate, string should be shorter than before (lib status prefix is + * removed). */ BKE_id_full_name_ui_prefix_get( - name_buf, static_cast(cis.data), false, UI_SEP_CHAR, &name_prefix_offset); - cis.name = name_buf; + name_buf, static_cast(cis->data), false, UI_SEP_CHAR, &name_prefix_offset); + const int name_buf_len = strlen(name_buf); + BLI_assert(name_buf_len <= strlen(cis->name)); + memcpy(cis->name, name_buf, name_buf_len + 1); } return UI_search_item_add(items, - cis.name.c_str(), - cis.data, - cis.iconid, - cis.has_sep_char ? int(UI_BUT_HAS_SEP_CHAR) : 0, + cis->name, + cis->data, + cis->iconid, + cis->has_sep_char ? int(UI_BUT_HAS_SEP_CHAR) : 0, name_prefix_offset); } void ui_rna_collection_search_update_fn( const bContext *C, void *arg, const char *str, uiSearchItems *items, const bool is_first) { - using namespace blender; uiRNACollectionSearch *data = static_cast(arg); const int flag = RNA_property_flag(data->target_prop); + ListBase *items_list = MEM_cnew("items_list"); const bool is_ptr_target = (RNA_property_type(data->target_prop) == PROP_POINTER); /* For non-pointer properties, UI code acts entirely based on the item's name. So the name has to * match the RNA name exactly. So only for pointer properties, the name can be modified to add @@ -413,14 +418,16 @@ void ui_rna_collection_search_update_fn( const bool requires_exact_data_name = !is_ptr_target; const bool skip_filter = is_first; char name_buf[UI_MAX_DRAW_STR]; + char *name; bool has_id_icon = false; - /* The string search API requires pointer stability. */ - Vector> items_list; + blender::ui::string_search::StringSearch search; if (data->search_prop != nullptr) { /* build a temporary list of relevant items first */ + int item_index = 0; RNA_PROP_BEGIN (&data->search_ptr, itemptr, data->search_prop) { + if (flag & PROP_ID_SELF_CHECK) { if (itemptr.data == data->target_ptr.owner_id) { continue; @@ -439,7 +446,6 @@ void ui_rna_collection_search_update_fn( bool has_sep_char = false; const bool is_id = itemptr.type && RNA_struct_is_ID(itemptr.type); - char *name; if (is_id) { iconid = ui_id_icon_get(C, static_cast(itemptr.data), false); if (!ELEM(iconid, 0, ICON_BLANK1)) { @@ -463,19 +469,24 @@ void ui_rna_collection_search_update_fn( } if (name) { - auto cis = std::make_unique(); + CollItemSearch *cis = MEM_cnew(__func__); cis->data = itemptr.data; - cis->name = name; - cis->index = items_list.size(); + cis->name = BLI_strdup(name); + cis->index = item_index; cis->iconid = iconid; cis->is_id = is_id; cis->name_prefix_offset = name_prefix_offset; cis->has_sep_char = has_sep_char; - items_list.append(std::move(cis)); + if (!skip_filter) { + search.add(name, cis); + } + BLI_addtail(items_list, cis); if (name != name_buf) { MEM_freeN(name); } } + + item_index++; } RNA_PROP_END; } @@ -485,66 +496,85 @@ void ui_rna_collection_search_update_fn( data->target_prop); BLI_assert(search_flag & PROP_STRING_SEARCH_SUPPORTED); - const bool show_extra_info = (G.debug_value == 102); + struct SearchVisitUserData { + blender::string_search::StringSearch *search; + bool skip_filter; + int item_index; + ListBase *items_list; + const char *func_id; + } user_data = {nullptr}; - RNA_property_string_search(C, - &data->target_ptr, - data->target_prop, - str, - [&](StringPropertySearchVisitParams visit_params) { - auto cis = std::make_unique(); + user_data.search = &search; + user_data.skip_filter = skip_filter; + user_data.items_list = items_list; + user_data.func_id = __func__; - cis->data = nullptr; - if (visit_params.info && show_extra_info) { - cis->name = fmt::format("{}" UI_SEP_CHAR_S "{}", - visit_params.text, - *visit_params.info); - } - else { - cis->name = std::move(visit_params.text); - } + RNA_property_string_search( + C, + &data->target_ptr, + data->target_prop, + str, + [](void *user_data, const StringPropertySearchVisitParams *visit_params) { + const bool show_extra_info = (G.debug_value == 102); - cis->index = items_list.size(); - cis->iconid = ICON_NONE; - cis->is_id = false; - cis->name_prefix_offset = 0; - cis->has_sep_char = visit_params.info.has_value(); - items_list.append(std::move(cis)); - }); + SearchVisitUserData *search_data = (SearchVisitUserData *)user_data; + CollItemSearch *cis = MEM_cnew(search_data->func_id); + cis->data = nullptr; + if (visit_params->info && show_extra_info) { + cis->name = BLI_sprintfN( + "%s" UI_SEP_CHAR_S "%s", visit_params->text, visit_params->info); + } + else { + cis->name = BLI_strdup(visit_params->text); + } + cis->index = search_data->item_index; + cis->iconid = ICON_NONE; + cis->is_id = false; + cis->name_prefix_offset = 0; + cis->has_sep_char = visit_params->info != nullptr; + if (!search_data->skip_filter) { + search_data->search->add(visit_params->text, cis); + } + BLI_addtail(search_data->items_list, cis); + search_data->item_index++; + }, + (void *)&user_data); if (search_flag & PROP_STRING_SEARCH_SORT) { - std::sort( - items_list.begin(), - items_list.end(), - [](const std::unique_ptr &a, const std::unique_ptr &b) { - return BLI_strcasecmp_natural(a->name.c_str(), b->name.c_str()) <= 0; - }); - for (const int i : items_list.index_range()) { - items_list[i]->index = i; + BLI_listbase_sort(items_list, [](const void *a_, const void *b_) -> int { + const CollItemSearch *cis_a = (const CollItemSearch *)a_; + const CollItemSearch *cis_b = (const CollItemSearch *)b_; + return BLI_strcasecmp_natural(cis_a->name, cis_b->name); + }); + int i = 0; + LISTBASE_FOREACH (CollItemSearch *, cis, items_list) { + cis->index = i; + i++; } } } if (skip_filter) { - for (std::unique_ptr &cis : items_list) { - if (!add_collection_search_item(*cis, requires_exact_data_name, has_id_icon, items)) { + LISTBASE_FOREACH (CollItemSearch *, cis, items_list) { + if (!add_collection_search_item(cis, requires_exact_data_name, has_id_icon, items)) { break; } } } else { - ui::string_search::StringSearch search; - for (std::unique_ptr &cis : items_list) { - search.add(cis->name, cis.get()); - } - - const Vector filtered_items = search.query(str); + const blender::Vector filtered_items = search.query(str); for (CollItemSearch *cis : filtered_items) { - if (!add_collection_search_item(*cis, requires_exact_data_name, has_id_icon, items)) { + if (!add_collection_search_item(cis, requires_exact_data_name, has_id_icon, items)) { break; } } } + + LISTBASE_FOREACH (CollItemSearch *, cis, items_list) { + MEM_freeN(cis->name); + } + BLI_freelistN(items_list); + MEM_freeN(items_list); } int UI_icon_from_id(const ID *id) @@ -693,27 +723,35 @@ int UI_calc_float_precision(int prec, double value) return prec; } -std::optional UI_but_online_manual_id(const uiBut *but) +bool UI_but_online_manual_id(const uiBut *but, char *r_str, size_t str_maxncpy) { if (but->rnapoin.data && but->rnaprop) { - return fmt::format( - "{}.{}", RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop)); + BLI_snprintf(r_str, + str_maxncpy, + "%s.%s", + RNA_struct_identifier(but->rnapoin.type), + RNA_property_identifier(but->rnaprop)); + return true; } if (but->optype) { - char idname[OP_MAX_TYPENAME]; - const size_t idname_len = WM_operator_py_idname(idname, but->optype->idname); - return std::string(idname, idname_len); + WM_operator_py_idname(r_str, but->optype->idname); + return true; } - return std::nullopt; + *r_str = '\0'; + return false; } -std::optional UI_but_online_manual_id_from_active(const bContext *C) +bool UI_but_online_manual_id_from_active(const bContext *C, char *r_str, size_t str_maxncpy) { - if (uiBut *but = UI_context_active_but_get(C)) { - return UI_but_online_manual_id(but); + uiBut *but = UI_context_active_but_get(C); + + if (but) { + return UI_but_online_manual_id(but, r_str, str_maxncpy); } - return std::nullopt; + + *r_str = '\0'; + return false; } /* -------------------------------------------------------------------- */ @@ -986,31 +1024,33 @@ static bool ui_key_event_property_match(const char *opname, return match; } -std::optional UI_key_event_operator_string(const bContext *C, - const char *opname, - IDProperty *properties, - const bool is_strict) +const char *UI_key_event_operator_string(const bContext *C, + const char *opname, + IDProperty *properties, + const bool is_strict, + char *result, + const int result_maxncpy) { /* NOTE: currently only actions on UI Lists are supported (for the asset manager). * Other kinds of events can be supported as needed. */ ARegion *region = CTX_wm_region(C); if (region == nullptr) { - return std::nullopt; + return nullptr; } /* Early exit regions which don't have UI-Lists. */ if ((region->type->keymapflag & ED_KEYMAP_UI) == 0) { - return std::nullopt; + return nullptr; } uiBut *but = UI_region_active_but_get(region); if (but == nullptr) { - return std::nullopt; + return nullptr; } if (but->type != UI_BTYPE_PREVIEW_TILE) { - return std::nullopt; + return nullptr; } short event_val = KM_NOTHING; @@ -1050,11 +1090,12 @@ std::optional UI_key_event_operator_string(const bContext *C, } if ((event_val != KM_NOTHING) && (event_type != KM_NOTHING)) { - return WM_keymap_item_raw_to_string( - false, false, false, false, 0, event_val, event_type, false); + WM_keymap_item_raw_to_string( + false, false, false, false, 0, event_val, event_type, false, result, result_maxncpy); + return result; } - return std::nullopt; + return nullptr; } /** \} */ diff --git a/source/blender/editors/interface/interface_widgets.cc b/source/blender/editors/interface/interface_widgets.cc index 4d330075b68..056a423c298 100644 --- a/source/blender/editors/interface/interface_widgets.cc +++ b/source/blender/editors/interface/interface_widgets.cc @@ -3357,11 +3357,10 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect) UI_draw_roundbox_4fv_ex(&rectf, col2, nullptr, 0.0f, inner1, U.pixelsize, 0.0f); } -/** Separator line. */ -static void ui_draw_separator(const uiWidgetColors *wcol, uiBut *but, const rcti *rect) +/** Separator for menus. */ +static void ui_draw_separator(const rcti *rect, const uiWidgetColors *wcol) { - const bool vertical = but->a1 == 1.0f; - const int mid = vertical ? BLI_rcti_cent_x(rect) : BLI_rcti_cent_y(rect); + const int y = rect->ymin + BLI_rcti_size_y(rect) / 2; const uchar col[4] = { wcol->text[0], wcol->text[1], @@ -3378,16 +3377,8 @@ static void ui_draw_separator(const uiWidgetColors *wcol, uiBut *but, const rcti GPU_line_width(1.0f); immBegin(GPU_PRIM_LINES, 2); - - if (vertical) { - immVertex2f(pos, mid, rect->ymin); - immVertex2f(pos, mid, rect->ymax); - } - else { - immVertex2f(pos, rect->xmin, mid); - immVertex2f(pos, rect->xmax, mid); - } - + immVertex2f(pos, rect->xmin, y); + immVertex2f(pos, rect->xmax, y); immEnd(); GPU_blend(GPU_BLEND_NONE); @@ -4846,9 +4837,7 @@ void ui_draw_but(const bContext *C, ARegion *region, uiStyle *style, uiBut *but, case UI_BTYPE_SEPR: break; case UI_BTYPE_SEPR_LINE: - /* Add horizontal padding between the line and menu sides. */ - BLI_rcti_pad(rect, int(-7.0f * UI_SCALE_FAC), 0); - ui_draw_separator(&tui->wcol_menu_item, but, rect); + ui_draw_separator(rect, &tui->wcol_menu_item); break; default: { const bool use_unpadded = (but->flag & UI_BUT_ICON_PREVIEW) || @@ -4900,10 +4889,8 @@ void ui_draw_but(const bContext *C, ARegion *region, uiStyle *style, uiBut *but, break; case UI_BTYPE_SEPR: - case UI_BTYPE_SEPR_SPACER: - break; case UI_BTYPE_SEPR_LINE: - ui_draw_separator(&tui->wcol_menu_item, but, rect); + case UI_BTYPE_SEPR_SPACER: break; case UI_BTYPE_BUT: diff --git a/source/blender/editors/interface/resources.cc b/source/blender/editors/interface/resources.cc index 390eff0c935..66eb3b8a3dd 100644 --- a/source/blender/editors/interface/resources.cc +++ b/source/blender/editors/interface/resources.cc @@ -25,7 +25,7 @@ #include "BKE_main.hh" #include "BKE_mesh_runtime.hh" -#include "BLO_userdef_default.h" +#include "BLO_readfile.h" /* for UserDef version patching. */ #include "BLF_api.hh" diff --git a/source/blender/editors/interface/view2d.cc b/source/blender/editors/interface/view2d.cc index 5dd2fbfc0b7..569ef81c7d2 100644 --- a/source/blender/editors/interface/view2d.cc +++ b/source/blender/editors/interface/view2d.cc @@ -16,15 +16,18 @@ #include "DNA_scene_types.h" #include "DNA_userdef_types.h" +#include "BLI_easing.h" #include "BLI_link_utils.h" #include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_memarena.h" #include "BLI_rect.h" +#include "BLI_string.h" +#include "BLI_timecode.h" #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_screen.hh" #include "GPU_immediate.h" @@ -40,6 +43,7 @@ #include "UI_interface.hh" #include "UI_view2d.hh" +#include "interface_intern.hh" #include "view2d_intern.hh" static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize); diff --git a/source/blender/editors/interface/view2d_draw.cc b/source/blender/editors/interface/view2d_draw.cc index 1d4e730ab5b..d44972456f1 100644 --- a/source/blender/editors/interface/view2d_draw.cc +++ b/source/blender/editors/interface/view2d_draw.cc @@ -34,6 +34,8 @@ #include "UI_interface.hh" #include "UI_view2d.hh" +#include "interface_intern.hh" + /* Compute display grid resolution ********************************************************/ diff --git a/source/blender/editors/interface/view2d_edge_pan.cc b/source/blender/editors/interface/view2d_edge_pan.cc index f9aa4e39c65..7fd47133647 100644 --- a/source/blender/editors/interface/view2d_edge_pan.cc +++ b/source/blender/editors/interface/view2d_edge_pan.cc @@ -18,6 +18,7 @@ #include "RNA_access.hh" #include "RNA_define.hh" +#include "UI_interface.hh" #include "UI_view2d.hh" #include "WM_api.hh" @@ -98,7 +99,7 @@ void UI_view2d_edge_pan_reset(View2DEdgePanData *vpd) { vpd->edge_pan_start_time_x = 0.0; vpd->edge_pan_start_time_y = 0.0; - vpd->edge_pan_last_time = BLI_time_now_seconds(); + vpd->edge_pan_last_time = BLI_check_seconds_timer(); vpd->initial_rect = vpd->region->v2d.cur; } @@ -250,7 +251,7 @@ void UI_view2d_edge_pan_apply(bContext *C, View2DEdgePanData *vpd, const int xy[ } } - const double current_time = BLI_time_now_seconds(); + const double current_time = BLI_check_seconds_timer(); edge_pan_manage_delay_timers(vpd, pan_dir_x, pan_dir_y, current_time); /* Calculate the delta since the last time the operator was called. */ diff --git a/source/blender/editors/interface/view2d_gizmo_navigate.cc b/source/blender/editors/interface/view2d_gizmo_navigate.cc index 3a13616a0e2..c94f316df58 100644 --- a/source/blender/editors/interface/view2d_gizmo_navigate.cc +++ b/source/blender/editors/interface/view2d_gizmo_navigate.cc @@ -13,6 +13,7 @@ #include "ED_gizmo_library.hh" #include "ED_screen.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "MEM_guardedalloc.h" diff --git a/source/blender/editors/interface/view2d_ops.cc b/source/blender/editors/interface/view2d_ops.cc index 907d8caa265..f63e8c480ac 100644 --- a/source/blender/editors/interface/view2d_ops.cc +++ b/source/blender/editors/interface/view2d_ops.cc @@ -13,6 +13,7 @@ #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" +#include "BLI_blenlib.h" #include "BLI_math_base.h" #include "BLI_math_vector.h" #include "BLI_time.h" /* USER_ZOOM_CONTINUE */ @@ -1031,7 +1032,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) /* Check if the 'timer' is initialized, as zooming with the trackpad * never uses the "Continuous" zoom method, and the 'timer' is not initialized. */ if ((U.viewzoom == USER_ZOOM_CONTINUE) && vzd->timer) { /* XXX store this setting as RNA prop? */ - const double time = BLI_time_now_seconds(); + const double time = BLI_check_seconds_timer(); const float time_step = float(time - vzd->timer_lastdraw); dx *= time_step * 5.0f; @@ -1231,7 +1232,7 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even if (U.viewzoom == USER_ZOOM_CONTINUE) { /* needs a timer to continue redrawing */ vzd->timer = WM_event_timer_add(CTX_wm_manager(C), window, TIMER, 0.01f); - vzd->timer_lastdraw = BLI_time_now_seconds(); + vzd->timer_lastdraw = BLI_check_seconds_timer(); } return OPERATOR_RUNNING_MODAL; diff --git a/source/blender/editors/interface/views/abstract_view_item.cc b/source/blender/editors/interface/views/abstract_view_item.cc index db60846e319..3dcbe3bc748 100644 --- a/source/blender/editors/interface/views/abstract_view_item.cc +++ b/source/blender/editors/interface/views/abstract_view_item.cc @@ -9,6 +9,7 @@ #include "BKE_context.hh" #include "BLI_listbase.h" +#include "BLI_string.h" #include "WM_api.hh" @@ -381,6 +382,7 @@ class ViewItemAPIWrapper { ICON_NONE, drag_controller->get_drag_type(), drag_controller->create_drag_data(), + 0, WM_DRAG_FREE_DATA); drag_controller->on_drag_start(); diff --git a/source/blender/editors/interface/views/grid_view.cc b/source/blender/editors/interface/views/grid_view.cc index 5ce1739139c..a92d3ff875f 100644 --- a/source/blender/editors/interface/views/grid_view.cc +++ b/source/blender/editors/interface/views/grid_view.cc @@ -417,7 +417,7 @@ void PreviewGridItem::build_grid_tile(uiLayout &layout) const uiBut *but = uiDefBut(block, UI_BTYPE_PREVIEW_TILE, 0, - hide_label_ ? "" : label, + hide_label_ ? "" : label.c_str(), 0, 0, style.tile_width, diff --git a/source/blender/editors/interface/views/tree_view.cc b/source/blender/editors/interface/views/tree_view.cc index f9cd8da1e3f..7093c129584 100644 --- a/source/blender/editors/interface/views/tree_view.cc +++ b/source/blender/editors/interface/views/tree_view.cc @@ -11,7 +11,7 @@ #include "BKE_context.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "GPU_immediate.h" diff --git a/source/blender/editors/io/io_alembic.cc b/source/blender/editors/io/io_alembic.cc index 4f1b45d88d9..ab77075e48f 100644 --- a/source/blender/editors/io/io_alembic.cc +++ b/source/blender/editors/io/io_alembic.cc @@ -28,14 +28,14 @@ # include "BKE_context.hh" # include "BKE_file_handler.hh" # include "BKE_main.hh" -# include "BKE_report.hh" +# include "BKE_report.h" # include "BLI_path_util.h" # include "BLI_string.h" # include "BLI_utildefines.h" # include "BLI_vector.hh" -# include "BLT_translation.hh" +# include "BLT_translation.h" # include "RNA_access.hh" # include "RNA_define.hh" diff --git a/source/blender/editors/io/io_cache.cc b/source/blender/editors/io/io_cache.cc index b31ba6f801c..824b403657a 100644 --- a/source/blender/editors/io/io_cache.cc +++ b/source/blender/editors/io/io_cache.cc @@ -15,11 +15,11 @@ #include "BLI_path_util.h" #include "BLI_string.h" -#include "BKE_cachefile.hh" +#include "BKE_cachefile.h" #include "BKE_context.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/editors/io/io_collada.cc b/source/blender/editors/io/io_collada.cc index cdb62504cf2..6a2aee68c25 100644 --- a/source/blender/editors/io/io_collada.cc +++ b/source/blender/editors/io/io_collada.cc @@ -8,7 +8,7 @@ #ifdef WITH_COLLADA # include "DNA_space_types.h" -# include "BLT_translation.hh" +# include "BLT_translation.h" # include "BLI_blenlib.h" # include "BLI_string.h" @@ -16,7 +16,9 @@ # include "BKE_context.hh" # include "BKE_file_handler.hh" -# include "BKE_report.hh" +# include "BKE_main.hh" +# include "BKE_object.hh" +# include "BKE_report.h" # include "DEG_depsgraph.hh" diff --git a/source/blender/editors/io/io_drop_import_file.cc b/source/blender/editors/io/io_drop_import_file.cc index 923d6fe654b..b5480bf2cfc 100644 --- a/source/blender/editors/io/io_drop_import_file.cc +++ b/source/blender/editors/io/io_drop_import_file.cc @@ -5,7 +5,7 @@ #include "BLI_path_util.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_file_handler.hh" diff --git a/source/blender/editors/io/io_gpencil_export.cc b/source/blender/editors/io/io_gpencil_export.cc index eb4956b401b..79e8b9800c5 100644 --- a/source/blender/editors/io/io_gpencil_export.cc +++ b/source/blender/editors/io/io_gpencil_export.cc @@ -9,13 +9,17 @@ #ifdef WITH_IO_GPENCIL # include "BLI_path_util.h" +# include "BLI_string.h" +# include "DNA_gpencil_legacy_types.h" # include "DNA_space_types.h" -# include "BKE_report.hh" +# include "BKE_gpencil_legacy.h" +# include "BKE_main.hh" +# include "BKE_report.h" # include "BKE_screen.hh" -# include "BLT_translation.hh" +# include "BLT_translation.h" # include "ED_fileselect.hh" @@ -28,6 +32,9 @@ # include "WM_api.hh" # include "WM_types.hh" +# include "DEG_depsgraph.hh" +# include "DEG_depsgraph_query.hh" + # include "io_gpencil.hh" # include "gpencil_io.h" diff --git a/source/blender/editors/io/io_gpencil_import.cc b/source/blender/editors/io/io_gpencil_import.cc index 6bc8537a669..a5bd481f0f5 100644 --- a/source/blender/editors/io/io_gpencil_import.cc +++ b/source/blender/editors/io/io_gpencil_import.cc @@ -13,11 +13,15 @@ # include "MEM_guardedalloc.h" +# include "DNA_gpencil_legacy_types.h" # include "DNA_space_types.h" # include "BKE_context.hh" # include "BKE_file_handler.hh" -# include "BKE_report.hh" +# include "BKE_gpencil_legacy.h" +# include "BKE_report.h" + +# include "BLT_translation.h" # include "RNA_access.hh" # include "RNA_define.hh" @@ -28,6 +32,11 @@ # include "WM_api.hh" # include "WM_types.hh" +# include "DEG_depsgraph.hh" +# include "DEG_depsgraph_query.hh" + +# include "ED_gpencil_legacy.hh" + # include "io_gpencil.hh" # include "io_utils.hh" diff --git a/source/blender/editors/io/io_obj.cc b/source/blender/editors/io/io_obj.cc index 0508be15247..7fb310a5494 100644 --- a/source/blender/editors/io/io_obj.cc +++ b/source/blender/editors/io/io_obj.cc @@ -13,13 +13,13 @@ # include "BKE_context.hh" # include "BKE_file_handler.hh" # include "BKE_main.hh" -# include "BKE_report.hh" +# include "BKE_report.h" # include "BLI_path_util.h" # include "BLI_string.h" # include "BLI_utildefines.h" -# include "BLT_translation.hh" +# include "BLT_translation.h" # include "ED_fileselect.hh" # include "ED_outliner.hh" diff --git a/source/blender/editors/io/io_ply_ops.cc b/source/blender/editors/io/io_ply_ops.cc index 3d598a79213..646f54befec 100644 --- a/source/blender/editors/io/io_ply_ops.cc +++ b/source/blender/editors/io/io_ply_ops.cc @@ -11,7 +11,7 @@ # include "BKE_context.hh" # include "BKE_file_handler.hh" # include "BKE_main.hh" -# include "BKE_report.hh" +# include "BKE_report.h" # include "BLI_string.h" @@ -26,14 +26,17 @@ # include "RNA_access.hh" # include "RNA_define.hh" -# include "BLT_translation.hh" +# include "BLT_translation.h" # include "MEM_guardedalloc.h" # include "UI_interface.hh" # include "UI_resources.hh" +# include "DEG_depsgraph.hh" + # include "IO_orientation.hh" +# include "IO_path_util_types.hh" # include "IO_ply.hh" # include "io_ply_ops.hh" diff --git a/source/blender/editors/io/io_stl_ops.cc b/source/blender/editors/io/io_stl_ops.cc index 2af90bb4aba..76258d555ae 100644 --- a/source/blender/editors/io/io_stl_ops.cc +++ b/source/blender/editors/io/io_stl_ops.cc @@ -10,7 +10,7 @@ # include "BKE_context.hh" # include "BKE_file_handler.hh" -# include "BKE_report.hh" +# include "BKE_report.h" # include "BLI_string.h" @@ -25,7 +25,7 @@ # include "RNA_access.hh" # include "RNA_define.hh" -# include "BLT_translation.hh" +# include "BLT_translation.h" # include "UI_interface.hh" # include "UI_resources.hh" diff --git a/source/blender/editors/io/io_usd.cc b/source/blender/editors/io/io_usd.cc index 2c9eb914243..7f1d3aa55d2 100644 --- a/source/blender/editors/io/io_usd.cc +++ b/source/blender/editors/io/io_usd.cc @@ -14,13 +14,15 @@ # include "BKE_context.hh" # include "BKE_file_handler.hh" -# include "BKE_report.hh" +# include "BKE_main.hh" +# include "BKE_report.h" +# include "BLI_blenlib.h" # include "BLI_path_util.h" # include "BLI_string.h" # include "BLI_utildefines.h" -# include "BLT_translation.hh" +# include "BLT_translation.h" # include "ED_fileselect.hh" # include "ED_object.hh" @@ -30,6 +32,8 @@ # include "RNA_access.hh" # include "RNA_define.hh" +# include "RNA_enum_types.hh" + # include "UI_interface.hh" # include "UI_resources.hh" diff --git a/source/blender/editors/io/io_utils.cc b/source/blender/editors/io/io_utils.cc index f0124edbf90..c494b64c92d 100644 --- a/source/blender/editors/io/io_utils.cc +++ b/source/blender/editors/io/io_utils.cc @@ -6,12 +6,14 @@ #include "BLI_path_util.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "DNA_space_types.h" +#include "ED_fileselect.hh" + #include "RNA_access.hh" #include "RNA_prototypes.h" @@ -45,8 +47,8 @@ int filesel_drop_import_invoke(bContext *C, wmOperator *op, const wmEvent * /* e RNA_string_get(op->ptr, "filepath", filepath); title = filepath; } - return WM_operator_props_dialog_popup( - C, op, 350, std::move(title), WM_operatortype_name(op->type, op->ptr)); + const std::string operator_name = WM_operatortype_name(op->type, op->ptr); + return WM_operator_props_dialog_popup(C, op, 350, title.c_str(), operator_name.c_str()); } WM_event_add_fileselect(C, op); diff --git a/source/blender/editors/lattice/editlattice_select.cc b/source/blender/editors/lattice/editlattice_select.cc index aefc285b796..48caa5689a5 100644 --- a/source/blender/editors/lattice/editlattice_select.cc +++ b/source/blender/editors/lattice/editlattice_select.cc @@ -29,7 +29,7 @@ #include "BKE_context.hh" #include "BKE_lattice.hh" #include "BKE_layer.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "ED_lattice.hh" #include "ED_object.hh" diff --git a/source/blender/editors/mask/mask_add.cc b/source/blender/editors/mask/mask_add.cc index 0f9fa3649ec..e731303aa0d 100644 --- a/source/blender/editors/mask/mask_add.cc +++ b/source/blender/editors/mask/mask_add.cc @@ -27,6 +27,7 @@ #include "WM_types.hh" #include "ED_mask.hh" /* own include */ +#include "ED_screen.hh" #include "ED_select_utils.hh" #include "RNA_access.hh" diff --git a/source/blender/editors/mask/mask_draw.cc b/source/blender/editors/mask/mask_draw.cc index 136d62c786b..e058c81111d 100644 --- a/source/blender/editors/mask/mask_draw.cc +++ b/source/blender/editors/mask/mask_draw.cc @@ -33,6 +33,7 @@ #include "GPU_shader.h" #include "GPU_state.h" +#include "UI_interface.hh" #include "UI_resources.hh" #include "UI_view2d.hh" diff --git a/source/blender/editors/mask/mask_editaction.cc b/source/blender/editors/mask/mask_editaction.cc index 054636e8f6d..ec240ffb9f8 100644 --- a/source/blender/editors/mask/mask_editaction.cc +++ b/source/blender/editors/mask/mask_editaction.cc @@ -14,11 +14,13 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "DNA_mask_types.h" #include "DNA_scene_types.h" +#include "BKE_fcurve.h" #include "BKE_mask.h" #include "ED_anim_api.hh" diff --git a/source/blender/editors/mask/mask_ops.cc b/source/blender/editors/mask/mask_ops.cc index d4c89bbffd0..d0b8561f233 100644 --- a/source/blender/editors/mask/mask_ops.cc +++ b/source/blender/editors/mask/mask_ops.cc @@ -13,6 +13,7 @@ #include "BLI_math_vector.h" #include "BKE_context.hh" +#include "BKE_main.hh" #include "BKE_mask.h" #include "DEG_depsgraph.hh" @@ -28,6 +29,7 @@ #include "ED_clip.hh" #include "ED_image.hh" #include "ED_mask.hh" +#include "ED_screen.hh" #include "ED_select_utils.hh" #include "ANIM_keyframing.hh" diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index 12efd559990..94dd500377d 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -67,7 +67,6 @@ set(LIB PRIVATE bf::blenlib PRIVATE bf::depsgraph PRIVATE bf::dna - PRIVATE bf::extern::fmtlib PRIVATE bf::intern::clog PRIVATE bf::intern::guardedalloc bf_windowmanager diff --git a/source/blender/editors/mesh/editface.cc b/source/blender/editors/mesh/editface.cc index cfdf9e51022..ffcb8e96426 100644 --- a/source/blender/editors/mesh/editface.cc +++ b/source/blender/editors/mesh/editface.cc @@ -27,7 +27,7 @@ #include "BKE_attribute.hh" #include "BKE_context.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_mesh.hh" #include "BKE_mesh_mapping.hh" #include "BKE_object.hh" @@ -725,7 +725,7 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3]) return ok; } - copy_m3_m4(bmat, ob->object_to_world().ptr()); + copy_m3_m4(bmat, ob->object_to_world); const Span positions = mesh->vert_positions(); const OffsetIndices faces = mesh->faces(); @@ -743,7 +743,7 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3]) for (const int vert : corner_verts.slice(faces[i])) { mul_v3_m3v3(vec, bmat, positions[vert]); - add_v3_v3v3(vec, vec, ob->object_to_world().location()); + add_v3_v3v3(vec, vec, ob->object_to_world[3]); minmax_v3v3_v3(r_min, r_max, vec); } diff --git a/source/blender/editors/mesh/editmesh_add.cc b/source/blender/editors/mesh/editmesh_add.cc index 2c8bd97de0f..f6d90a15664 100644 --- a/source/blender/editors/mesh/editmesh_add.cc +++ b/source/blender/editors/mesh/editmesh_add.cc @@ -7,12 +7,13 @@ */ #include "BLI_math_matrix.h" +#include "BLI_math_vector.h" #include "BLI_sys_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_editmesh.hh" diff --git a/source/blender/editors/mesh/editmesh_add_gizmo.cc b/source/blender/editors/mesh/editmesh_add_gizmo.cc index 0b13e4d090b..1fb203b77cd 100644 --- a/source/blender/editors/mesh/editmesh_add_gizmo.cc +++ b/source/blender/editors/mesh/editmesh_add_gizmo.cc @@ -15,8 +15,7 @@ #include "BKE_context.hh" #include "BKE_editmesh.hh" -#include "BKE_object_types.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" @@ -38,6 +37,8 @@ #include "UI_resources.hh" +#include "BLT_translation.h" + #include "mesh_intern.hh" /* own include */ /* -------------------------------------------------------------------- */ @@ -317,8 +318,8 @@ static int add_primitive_cube_gizmo_exec(bContext *C, wmOperator *op) PropertyRNA *prop_matrix = RNA_struct_find_property(op->ptr, "matrix"); if (RNA_property_is_set(op->ptr, prop_matrix)) { RNA_property_float_get_array(op->ptr, prop_matrix, &matrix[0][0]); - invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); - mul_m4_m4m4(matrix, obedit->world_to_object().ptr(), matrix); + invert_m4_m4(obedit->world_to_object, obedit->object_to_world); + mul_m4_m4m4(matrix, obedit->world_to_object, matrix); } else { /* For the first update the widget may not set the matrix. */ diff --git a/source/blender/editors/mesh/editmesh_attribute.cc b/source/blender/editors/mesh/editmesh_attribute.cc index c31fd640c9a..7e3f464bf97 100644 --- a/source/blender/editors/mesh/editmesh_attribute.cc +++ b/source/blender/editors/mesh/editmesh_attribute.cc @@ -15,7 +15,7 @@ #include "BKE_editmesh.hh" #include "BKE_layer.hh" #include "BKE_mesh.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_type_conversions.hh" #include "WM_api.hh" @@ -32,7 +32,7 @@ #include "ED_transform.hh" #include "ED_view3d.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_object_types.h" diff --git a/source/blender/editors/mesh/editmesh_automerge.cc b/source/blender/editors/mesh/editmesh_automerge.cc index 93ca967ab92..c71bae4e9b9 100644 --- a/source/blender/editors/mesh/editmesh_automerge.cc +++ b/source/blender/editors/mesh/editmesh_automerge.cc @@ -92,13 +92,13 @@ void EDBM_automerge_and_split(Object *obedit, #ifdef DEBUG_TIME em->bm = BM_mesh_copy(bm); - double t1 = BLI_time_now_seconds(); + double t1 = BLI_check_seconds_timer(); EDBM_automerge(obedit, false, hflag, dist); - t1 = BLI_time_now_seconds() - t1; + t1 = BLI_check_seconds_timer() - t1; BM_mesh_free(em->bm); em->bm = bm; - double t2 = BLI_time_now_seconds(); + double t2 = BLI_check_seconds_timer(); #endif BMOperator weldop; @@ -118,7 +118,7 @@ void EDBM_automerge_and_split(Object *obedit, BMO_op_finish(bm, &weldop); #ifdef DEBUG_TIME - t2 = BLI_time_now_seconds() - t2; + t2 = BLI_check_seconds_timer() - t2; printf("t1: %lf; t2: %lf; fac: %lf\n", t1, t2, t1 / t2); #endif diff --git a/source/blender/editors/mesh/editmesh_bevel.cc b/source/blender/editors/mesh/editmesh_bevel.cc index 85624c9aab5..f024e0751b8 100644 --- a/source/blender/editors/mesh/editmesh_bevel.cc +++ b/source/blender/editors/mesh/editmesh_bevel.cc @@ -6,8 +6,6 @@ * \ingroup edmesh */ -#include - #include "MEM_guardedalloc.h" #include "DNA_object_types.h" @@ -16,14 +14,17 @@ #include "BLI_math_vector.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_editmesh.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_unit.hh" +#include "DNA_curveprofile_types.h" +#include "DNA_mesh_types.h" + #include "RNA_access.hh" #include "RNA_define.hh" #include "RNA_prototypes.h" @@ -123,11 +124,15 @@ static float get_bevel_offset(wmOperator *op) static void edbm_bevel_update_status_text(bContext *C, wmOperator *op) { + char status_text[UI_MAX_DRAW_STR]; + char buf[UI_MAX_DRAW_STR]; + char *p = buf; + int available_len = sizeof(buf); Scene *sce = CTX_data_scene(C); - auto get_modal_key_str = [&](int id) { - return WM_modalkeymap_operator_items_to_string(op->type, id, true).value_or(""); - }; +#define WM_MODALKEY(_id) \ + WM_modalkeymap_operator_items_to_string_buf( \ + op->type, (_id), true, UI_MAX_SHORTCUT_STR, &available_len, &p) char offset_str[NUM_STR_REP_LEN]; if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) { @@ -165,52 +170,54 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op) RNA_property_enum_name_gettexted( C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &affect_str); - const std::string status_text = fmt::format( - IFACE_("{}: Confirm, " - "{}: Cancel, " - "{}: Width Type ({}), " - "{}: Width ({}), " - "{}: Segments ({}), " - "{}: Profile ({:.3f}), " - "{}: Clamp Overlap ({}), " - "{}: Affect ({}), " - "{}: Outer Miter ({}), " - "{}: Inner Miter ({}), " - "{}: Harden Normals ({}), " - "{}: Mark Seam ({}), " - "{}: Mark Sharp ({}), " - "{}: Profile Type ({}), " - "{}: Intersection ({})"), - get_modal_key_str(BEV_MODAL_CONFIRM), - get_modal_key_str(BEV_MODAL_CANCEL), - get_modal_key_str(BEV_MODAL_OFFSET_MODE_CHANGE), - mode_str, - get_modal_key_str(BEV_MODAL_VALUE_OFFSET), - offset_str, - get_modal_key_str(BEV_MODAL_VALUE_SEGMENTS), - RNA_int_get(op->ptr, "segments"), - get_modal_key_str(BEV_MODAL_VALUE_PROFILE), - RNA_float_get(op->ptr, "profile"), - get_modal_key_str(BEV_MODAL_CLAMP_OVERLAP_TOGGLE), - WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")), - get_modal_key_str(BEV_MODAL_AFFECT_CHANGE), - affect_str, - get_modal_key_str(BEV_MODAL_OUTER_MITER_CHANGE), - omiter_str, - get_modal_key_str(BEV_MODAL_INNER_MITER_CHANGE), - imiter_str, - get_modal_key_str(BEV_MODAL_HARDEN_NORMALS_TOGGLE), - WM_bool_as_string(RNA_boolean_get(op->ptr, "harden_normals")), - get_modal_key_str(BEV_MODAL_MARK_SEAM_TOGGLE), - WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_seam")), - get_modal_key_str(BEV_MODAL_MARK_SHARP_TOGGLE), - WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_sharp")), - get_modal_key_str(BEV_MODAL_PROFILE_TYPE_CHANGE), - profile_type_str, - get_modal_key_str(BEV_MODAL_VERTEX_MESH_CHANGE), - vmesh_str); + SNPRINTF(status_text, + IFACE_("%s: Confirm, " + "%s: Cancel, " + "%s: Width Type (%s), " + "%s: Width (%s), " + "%s: Segments (%d), " + "%s: Profile (%.3f), " + "%s: Clamp Overlap (%s), " + "%s: Affect (%s), " + "%s: Outer Miter (%s), " + "%s: Inner Miter (%s), " + "%s: Harden Normals (%s), " + "%s: Mark Seam (%s), " + "%s: Mark Sharp (%s), " + "%s: Profile Type (%s), " + "%s: Intersection (%s)"), + WM_MODALKEY(BEV_MODAL_CONFIRM), + WM_MODALKEY(BEV_MODAL_CANCEL), + WM_MODALKEY(BEV_MODAL_OFFSET_MODE_CHANGE), + mode_str, + WM_MODALKEY(BEV_MODAL_VALUE_OFFSET), + offset_str, + WM_MODALKEY(BEV_MODAL_VALUE_SEGMENTS), + RNA_int_get(op->ptr, "segments"), + WM_MODALKEY(BEV_MODAL_VALUE_PROFILE), + RNA_float_get(op->ptr, "profile"), + WM_MODALKEY(BEV_MODAL_CLAMP_OVERLAP_TOGGLE), + WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")), + WM_MODALKEY(BEV_MODAL_AFFECT_CHANGE), + affect_str, + WM_MODALKEY(BEV_MODAL_OUTER_MITER_CHANGE), + omiter_str, + WM_MODALKEY(BEV_MODAL_INNER_MITER_CHANGE), + imiter_str, + WM_MODALKEY(BEV_MODAL_HARDEN_NORMALS_TOGGLE), + WM_bool_as_string(RNA_boolean_get(op->ptr, "harden_normals")), + WM_MODALKEY(BEV_MODAL_MARK_SEAM_TOGGLE), + WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_seam")), + WM_MODALKEY(BEV_MODAL_MARK_SHARP_TOGGLE), + WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_sharp")), + WM_MODALKEY(BEV_MODAL_PROFILE_TYPE_CHANGE), + profile_type_str, + WM_MODALKEY(BEV_MODAL_VERTEX_MESH_CHANGE), + vmesh_str); - ED_workspace_status_text(C, status_text.c_str()); +#undef WM_MODALKEY + + ED_workspace_status_text(C, status_text); } static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) @@ -236,7 +243,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) const Vector objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( scene, view_layer, v3d); for (Object *obedit : objects) { - float scale = mat4_to_scale(obedit->object_to_world().ptr()); + float scale = mat4_to_scale(obedit->object_to_world); opdata->max_obj_scale = max_ff(opdata->max_obj_scale, scale); BMEditMesh *em = BKE_editmesh_from_object(obedit); if (em->bm->totvertsel > 0) { diff --git a/source/blender/editors/mesh/editmesh_bisect.cc b/source/blender/editors/mesh/editmesh_bisect.cc index 410227a0514..4c25f9ec506 100644 --- a/source/blender/editors/mesh/editmesh_bisect.cc +++ b/source/blender/editors/mesh/editmesh_bisect.cc @@ -10,13 +10,13 @@ #include "DNA_object_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_editmesh.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" @@ -320,9 +320,9 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op) copy_v3_v3(plane_co_local, plane_co); copy_v3_v3(plane_no_local, plane_no); - invert_m4_m4(imat, obedit->object_to_world().ptr()); + invert_m4_m4(imat, obedit->object_to_world); mul_m4_v3(imat, plane_co_local); - mul_transposed_mat3_m4_v3(obedit->object_to_world().ptr(), plane_no_local); + mul_transposed_mat3_m4_v3(obedit->object_to_world, plane_no_local); BMOperator bmop; EDBM_op_init( diff --git a/source/blender/editors/mesh/editmesh_extrude.cc b/source/blender/editors/mesh/editmesh_extrude.cc index f58ff0c0699..69f81fa7c2b 100644 --- a/source/blender/editors/mesh/editmesh_extrude.cc +++ b/source/blender/editors/mesh/editmesh_extrude.cc @@ -17,8 +17,7 @@ #include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" -#include "BKE_object_types.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -60,8 +59,8 @@ static void edbm_extrude_edge_exclude_mirror( float mtx[4][4]; if (mmd->mirror_ob) { float imtx[4][4]; - invert_m4_m4(imtx, mmd->mirror_ob->object_to_world().ptr()); - mul_m4_m4m4(mtx, imtx, obedit->object_to_world().ptr()); + invert_m4_m4(imtx, mmd->mirror_ob->object_to_world); + mul_m4_m4m4(mtx, imtx, obedit->object_to_world); } BM_ITER_MESH (edge, &iter, bm, BM_EDGES_OF_MESH) { @@ -298,7 +297,7 @@ static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op) BMEditMesh *em = BKE_editmesh_from_object(obedit); - copy_m3_m4(tmat, obedit->object_to_world().ptr()); + copy_m3_m4(tmat, obedit->object_to_world); invert_m3(tmat); mul_v3_m3v3(offset_local, tmat, offset); @@ -724,7 +723,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w } mul_v3_fl(local_center, 1.0f / float(local_verts_len)); - mul_m4_v3(vc.obedit->object_to_world().ptr(), local_center); + mul_m4_v3(vc.obedit->object_to_world, local_center); mul_v3_fl(local_center, float(local_verts_len)); add_v3_v3(center, local_center); @@ -748,11 +747,11 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w continue; } - invert_m4_m4(vc.obedit->runtime->world_to_object.ptr(), vc.obedit->object_to_world().ptr()); + invert_m4_m4(vc.obedit->world_to_object, vc.obedit->object_to_world); ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); float local_center[3]; - mul_v3_m4v3(local_center, vc.obedit->world_to_object().ptr(), center); + mul_v3_m4v3(local_center, vc.obedit->world_to_object, center); /* call extrude? */ if (verts_len != 0) { @@ -798,11 +797,11 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w float view_vec[3], cross[3]; /* convert the 2D normal into 3D */ - mul_mat3_m4_v3(vc.rv3d->viewinv, nor); /* World-space. */ - mul_mat3_m4_v3(vc.obedit->world_to_object().ptr(), nor); /* Local-space. */ + mul_mat3_m4_v3(vc.rv3d->viewinv, nor); /* World-space. */ + mul_mat3_m4_v3(vc.obedit->world_to_object, nor); /* Local-space. */ /* correct the normal to be aligned on the view plane */ - mul_v3_mat3_m4v3(view_vec, vc.obedit->world_to_object().ptr(), vc.rv3d->viewinv[2]); + mul_v3_mat3_m4v3(view_vec, vc.obedit->world_to_object, vc.rv3d->viewinv[2]); cross_v3_v3v3(cross, nor, view_vec); cross_v3_v3v3(nor, view_vec, cross); normalize_v3(nor); @@ -811,9 +810,9 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w /* center */ copy_v3_v3(ofs, local_center); - mul_m4_v3(vc.obedit->object_to_world().ptr(), ofs); /* view space */ + mul_m4_v3(vc.obedit->object_to_world, ofs); /* view space */ ED_view3d_win_to_3d_int(vc.v3d, vc.region, ofs, event->mval, ofs); - mul_m4_v3(vc.obedit->world_to_object().ptr(), ofs); /* back in object space */ + mul_m4_v3(vc.obedit->world_to_object, ofs); /* back in object space */ sub_v3_v3(ofs, local_center); @@ -864,7 +863,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w copy_v3_v3(local_center, cursor); ED_view3d_win_to_3d_int(vc.v3d, vc.region, local_center, event->mval, local_center); - mul_m4_v3(vc.obedit->world_to_object().ptr(), local_center); /* back in object space */ + mul_m4_v3(vc.obedit->world_to_object, local_center); /* back in object space */ EDBM_op_init(vc.em, &bmop, op, "create_vert co=%v", local_center); BMO_op_exec(vc.em->bm, &bmop); diff --git a/source/blender/editors/mesh/editmesh_extrude_screw.cc b/source/blender/editors/mesh/editmesh_extrude_screw.cc index eb3dbff238e..5fcc36570db 100644 --- a/source/blender/editors/mesh/editmesh_extrude_screw.cc +++ b/source/blender/editors/mesh/editmesh_extrude_screw.cc @@ -13,7 +13,7 @@ #include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" @@ -105,11 +105,11 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) continue; } - copy_v3_v3(nor, obedit->object_to_world().ptr()[2]); + copy_v3_v3(nor, obedit->object_to_world[2]); /* calculate dvec */ - mul_v3_m4v3(v1_co_global, obedit->object_to_world().ptr(), v1->co); - mul_v3_m4v3(v2_co_global, obedit->object_to_world().ptr(), v2->co); + mul_v3_m4v3(v1_co_global, obedit->object_to_world, v1->co); + mul_v3_m4v3(v2_co_global, obedit->object_to_world, v2->co); sub_v3_v3v3(dvec, v1_co_global, v2_co_global); mul_v3_fl(dvec, 1.0f / steps); @@ -129,7 +129,7 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) dvec, turns * steps, DEG2RADF(360.0f * turns), - obedit->object_to_world().ptr(), + obedit->object_to_world, false)) { continue; diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.cc b/source/blender/editors/mesh/editmesh_extrude_spin.cc index 03e92109dca..c0c3f92bbca 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin.cc +++ b/source/blender/editors/mesh/editmesh_extrude_spin.cc @@ -15,7 +15,7 @@ #include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -79,7 +79,7 @@ static int edbm_spin_exec(bContext *C, wmOperator *op) d, steps, -angle, - obedit->object_to_world().ptr(), + obedit->object_to_world, use_normal_flip, dupli, use_auto_merge)) diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.cc b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.cc index d5eb42a608a..f9bf3b1d2d3 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.cc +++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.cc @@ -13,7 +13,7 @@ #include "BLI_math_vector.h" #include "BKE_context.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -367,7 +367,7 @@ static void gizmo_mesh_spin_init_refresh(const bContext *C, wmGizmoGroup *gzgrou } if (totsel) { mul_v3_fl(select_center, 1.0f / totsel); - mul_m4_v3(obedit->object_to_world().ptr(), select_center); + mul_m4_v3(obedit->object_to_world, select_center); copy_v3_v3(ggd->data.select_center, select_center); ggd->data.use_select_center = true; } diff --git a/source/blender/editors/mesh/editmesh_inset.cc b/source/blender/editors/mesh/editmesh_inset.cc index ded43533212..0b6d9f9ae62 100644 --- a/source/blender/editors/mesh/editmesh_inset.cc +++ b/source/blender/editors/mesh/editmesh_inset.cc @@ -14,11 +14,11 @@ #include "BLI_math_vector.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_editmesh.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_unit.hh" @@ -141,7 +141,7 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal) MEM_malloc_arrayN(objects.size(), sizeof(*opdata->ob_store), __func__)); for (uint ob_index = 0; ob_index < objects.size(); ob_index++) { Object *obedit = objects[ob_index]; - float scale = mat4_to_scale(obedit->object_to_world().ptr()); + float scale = mat4_to_scale(obedit->object_to_world); opdata->max_obj_scale = max_ff(opdata->max_obj_scale, scale); BMEditMesh *em = BKE_editmesh_from_object(obedit); if (em->bm->totvertsel > 0) { diff --git a/source/blender/editors/mesh/editmesh_intersect.cc b/source/blender/editors/mesh/editmesh_intersect.cc index af7ceef1e76..eeb7342430f 100644 --- a/source/blender/editors/mesh/editmesh_intersect.cc +++ b/source/blender/editors/mesh/editmesh_intersect.cc @@ -21,7 +21,7 @@ #include "BKE_editmesh.hh" #include "BKE_editmesh_bvh.h" #include "BKE_layer.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -34,6 +34,8 @@ #include "ED_mesh.hh" #include "ED_screen.hh" +#include "intern/bmesh_private.hh" + #include "mesh_intern.hh" /* own include */ #include "tools/bmesh_boolean.hh" diff --git a/source/blender/editors/mesh/editmesh_knife.cc b/source/blender/editors/mesh/editmesh_knife.cc index 9a0ccff84a0..ac5caf5b34a 100644 --- a/source/blender/editors/mesh/editmesh_knife.cc +++ b/source/blender/editors/mesh/editmesh_knife.cc @@ -12,8 +12,6 @@ # define _USE_MATH_DEFINES #endif -#include - #include "MEM_guardedalloc.h" #include "BLF_api.hh" @@ -32,14 +30,15 @@ #include "BLI_stack.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_bvhutils.hh" #include "BKE_context.hh" #include "BKE_editmesh.hh" +#include "BKE_editmesh_bvh.h" #include "BKE_layer.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_unit.hh" #include "GPU_immediate.h" @@ -592,9 +591,9 @@ static void knifetool_draw_angle(const KnifeTool_OpData *kcd, float axis[3]; float arc_angle; - const float inverse_average_scale = 1 / (kcd->curr.ob->object_to_world().ptr()[0][0] + - kcd->curr.ob->object_to_world().ptr()[1][1] + - kcd->curr.ob->object_to_world().ptr()[2][2]); + const float inverse_average_scale = 1 / (kcd->curr.ob->object_to_world[0][0] + + kcd->curr.ob->object_to_world[1][1] + + kcd->curr.ob->object_to_world[2][2]); const float px_scale = 3.0f * inverse_average_scale * @@ -1099,29 +1098,37 @@ static void knifetool_draw(const bContext * /*C*/, ARegion * /*region*/, void *a static void knife_update_header(bContext *C, wmOperator *op, KnifeTool_OpData *kcd) { - auto get_modal_key_str = [&](int id) { - return WM_modalkeymap_operator_items_to_string(op->type, id, true).value_or(""); - }; + char header[UI_MAX_DRAW_STR]; + char buf[UI_MAX_DRAW_STR]; - const std::string header = fmt::format( - IFACE_("{}: confirm, {}: cancel, {}: undo, " - "{}: start/define cut, {}: close cut, {}: new cut, " - "{}: midpoint snap ({}), {}: ignore snap ({}), " - "{}: angle constraint {:.2f}({:.2f}) ({}{}{}{}), {}: cut through ({}), " - "{}: panning, {}{}{}: orientation lock ({}), " - "{}: distance/angle measurements ({}), " - "{}: x-ray ({})"), - get_modal_key_str(KNF_MODAL_CONFIRM), - get_modal_key_str(KNF_MODAL_CANCEL), - get_modal_key_str(KNF_MODAL_UNDO), - get_modal_key_str(KNF_MODAL_ADD_CUT), - get_modal_key_str(KNF_MODAL_ADD_CUT_CLOSED), - get_modal_key_str(KNF_MODAL_NEW_CUT), - get_modal_key_str(KNF_MODAL_MIDPOINT_ON), + char *p = buf; + int available_len = sizeof(buf); + +#define WM_MODALKEY(_id) \ +\ + WM_modalkeymap_operator_items_to_string_buf( \ + op->type, (_id), true, UI_MAX_SHORTCUT_STR, &available_len, &p) + + SNPRINTF( + header, + IFACE_("%s: confirm, %s: cancel, %s: undo, " + "%s: start/define cut, %s: close cut, %s: new cut, " + "%s: midpoint snap (%s), %s: ignore snap (%s), " + "%s: angle constraint %.2f(%.2f) (%s%s%s%s), %s: cut through (%s), " + "%s: panning, %s%s%s: orientation lock (%s), " + "%s: distance/angle measurements (%s), " + "%s: x-ray (%s)"), + WM_MODALKEY(KNF_MODAL_CONFIRM), + WM_MODALKEY(KNF_MODAL_CANCEL), + WM_MODALKEY(KNF_MODAL_UNDO), + WM_MODALKEY(KNF_MODAL_ADD_CUT), + WM_MODALKEY(KNF_MODAL_ADD_CUT_CLOSED), + WM_MODALKEY(KNF_MODAL_NEW_CUT), + WM_MODALKEY(KNF_MODAL_MIDPOINT_ON), WM_bool_as_string(kcd->snap_midpoints), - get_modal_key_str(KNF_MODAL_IGNORE_SNAP_ON), + WM_MODALKEY(KNF_MODAL_IGNORE_SNAP_ON), WM_bool_as_string(kcd->ignore_edge_snapping), - get_modal_key_str(KNF_MODAL_ANGLE_SNAP_TOGGLE), + WM_MODALKEY(KNF_MODAL_ANGLE_SNAP_TOGGLE), (kcd->angle >= 0.0f) ? RAD2DEGF(kcd->angle) : 360.0f + RAD2DEGF(kcd->angle), (kcd->angle_snapping_increment > KNIFE_MIN_ANGLE_SNAPPING_INCREMENT && kcd->angle_snapping_increment <= KNIFE_MAX_ANGLE_SNAPPING_INCREMENT) ? @@ -1132,22 +1139,24 @@ static void knife_update_header(bContext *C, wmOperator *op, KnifeTool_OpData *k "OFF", /* TODO: Can this be simplified? */ (kcd->angle_snapping_mode == KNF_CONSTRAIN_ANGLE_MODE_RELATIVE) ? " - " : "", (kcd->angle_snapping_mode == KNF_CONSTRAIN_ANGLE_MODE_RELATIVE) ? - get_modal_key_str(KNF_MODAL_CYCLE_ANGLE_SNAP_EDGE) : + WM_MODALKEY(KNF_MODAL_CYCLE_ANGLE_SNAP_EDGE) : "", (kcd->angle_snapping_mode == KNF_CONSTRAIN_ANGLE_MODE_RELATIVE) ? ": cycle edge" : "", /**/ - get_modal_key_str(KNF_MODAL_CUT_THROUGH_TOGGLE), + WM_MODALKEY(KNF_MODAL_CUT_THROUGH_TOGGLE), WM_bool_as_string(kcd->cut_through), - get_modal_key_str(KNF_MODAL_PANNING), - get_modal_key_str(KNF_MODAL_X_AXIS), - get_modal_key_str(KNF_MODAL_Y_AXIS), - get_modal_key_str(KNF_MODAL_Z_AXIS), + WM_MODALKEY(KNF_MODAL_PANNING), + WM_MODALKEY(KNF_MODAL_X_AXIS), + WM_MODALKEY(KNF_MODAL_Y_AXIS), + WM_MODALKEY(KNF_MODAL_Z_AXIS), (kcd->axis_constrained ? kcd->axis_string : WM_bool_as_string(kcd->axis_constrained)), - get_modal_key_str(KNF_MODAL_SHOW_DISTANCE_ANGLE_TOGGLE), + WM_MODALKEY(KNF_MODAL_SHOW_DISTANCE_ANGLE_TOGGLE), WM_bool_as_string(kcd->show_dist_angle), - get_modal_key_str(KNF_MODAL_DEPTH_TEST_TOGGLE), + WM_MODALKEY(KNF_MODAL_DEPTH_TEST_TOGGLE), WM_bool_as_string(!kcd->depth_test)); - ED_workspace_status_text(C, header.c_str()); +#undef WM_MODALKEY + + ED_workspace_status_text(C, header); } /** \} */ @@ -1192,7 +1201,7 @@ static void knife_bm_tri_cagecos_get_worldspace(const KnifeTool_OpData *kcd, knife_bm_tri_cagecos_get(kcd, ob_index, tri_index, cos); const Object *ob = kcd->objects[ob_index]; for (int i = 0; i < 3; i++) { - mul_m4_v3(ob->object_to_world().ptr(), cos[i]); + mul_m4_v3(ob->object_to_world, cos[i]); } } @@ -1735,7 +1744,7 @@ static KnifeVert *get_bm_knife_vert(KnifeTool_OpData *kcd, BMVert *v, Object *ob } float cageco_ws[3]; - mul_v3_m4v3(cageco_ws, ob->object_to_world().ptr(), cageco); + mul_v3_m4v3(cageco_ws, ob->object_to_world, cageco); kfv = new_knife_vert(kcd, v->co, cageco_ws); kfv->v = v; @@ -2638,14 +2647,14 @@ static void calc_ortho_extent(KnifeTool_OpData *kcd) if (cagecos) { for (int i = 0; i < em->bm->totvert; i++) { copy_v3_v3(ws, cagecos[i]); - mul_m4_v3(ob->object_to_world().ptr(), ws); + mul_m4_v3(ob->object_to_world, ws); minmax_v3v3_v3(min, max, ws); } } else { BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { copy_v3_v3(ws, v->co); - mul_m4_v3(ob->object_to_world().ptr(), ws); + mul_m4_v3(ob->object_to_world, ws); minmax_v3v3_v3(min, max, ws); } } @@ -3593,6 +3602,7 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd) float curr_ray[3], curr_ray_normal[3]; float curr_co[3], curr_cage[3]; /* Unused. */ + float plane[4]; float ray_hit[3]; float lambda; @@ -3683,11 +3693,12 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd) /* Use normal global direction. */ float no_global[3]; copy_v3_v3(no_global, fprev->no); - mul_transposed_mat3_m4_v3(kcd->curr.ob->world_to_object().ptr(), no_global); + mul_transposed_mat3_m4_v3(kcd->curr.ob->world_to_object, no_global); normalize_v3(no_global); - if (isect_ray_plane_v3_factor(curr_origin, curr_ray_normal, kcd->prev.cage, no_global, &lambda)) - { + plane_from_point_normal_v3(plane, kcd->prev.cage, no_global); + + if (isect_ray_plane_v3(curr_origin, curr_ray_normal, plane, &lambda, false)) { madd_v3_v3v3fl(ray_hit, curr_origin, curr_ray_normal, lambda); /* Calculate snap step. */ @@ -5010,7 +5021,7 @@ void EDBM_mesh_knife( BM_ITER_ELEM (f, &fiter, e, BM_FACES_OF_EDGE) { float cent[3], cent_ss[2]; BM_face_calc_point_in_face(f, cent); - mul_m4_v3(ob->object_to_world().ptr(), cent); + mul_m4_v3(ob->object_to_world, cent); knife_project_v2(kcd, cent, cent_ss); if (edbm_mesh_knife_point_isect(polys, cent_ss)) { BM_elem_flag_enable(f, BM_ELEM_TAG); @@ -5051,7 +5062,7 @@ void EDBM_mesh_knife( if (found) { float cent[3], cent_ss[2]; BM_face_calc_point_in_face(f, cent); - mul_m4_v3(ob->object_to_world().ptr(), cent); + mul_m4_v3(ob->object_to_world, cent); knife_project_v2(kcd, cent, cent_ss); if ((kcd->cut_through || point_is_visible(kcd, cent, cent_ss, (BMElem *)f)) && edbm_mesh_knife_point_isect(polys, cent_ss)) diff --git a/source/blender/editors/mesh/editmesh_knife_project.cc b/source/blender/editors/mesh/editmesh_knife_project.cc index b1dd4d488cc..75c34e4bc93 100644 --- a/source/blender/editors/mesh/editmesh_knife_project.cc +++ b/source/blender/editors/mesh/editmesh_knife_project.cc @@ -20,9 +20,10 @@ #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/editors/mesh/editmesh_loopcut.cc b/source/blender/editors/mesh/editmesh_loopcut.cc index 7aefc404337..9c86d97622b 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.cc +++ b/source/blender/editors/mesh/editmesh_loopcut.cc @@ -13,13 +13,15 @@ #include "BLI_math_vector.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" + +#include "DNA_mesh_types.h" #include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" #include "BKE_modifier.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_unit.hh" #include "UI_interface.hh" @@ -88,7 +90,7 @@ struct RingSelOpData { static void ringsel_draw(const bContext * /*C*/, ARegion * /*region*/, void *arg) { RingSelOpData *lcd = static_cast(arg); - EDBM_preselect_edgering_draw(lcd->presel_edgering, lcd->ob->object_to_world().ptr()); + EDBM_preselect_edgering_draw(lcd->presel_edgering, lcd->ob->object_to_world); } static void edgering_select(RingSelOpData *lcd) diff --git a/source/blender/editors/mesh/editmesh_mask_extract.cc b/source/blender/editors/mesh/editmesh_mask_extract.cc index c872cd5ebe8..59eacec2622 100644 --- a/source/blender/editors/mesh/editmesh_mask_extract.cc +++ b/source/blender/editors/mesh/editmesh_mask_extract.cc @@ -10,14 +10,19 @@ #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "BLT_translation.h" + #include "BKE_attribute.hh" #include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_editmesh.hh" +#include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_paint.hh" +#include "BKE_report.h" +#include "BKE_screen.hh" #include "BKE_shrinkwrap.hh" #include "BLI_math_vector.h" @@ -31,10 +36,12 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "ED_mesh.hh" #include "ED_object.hh" #include "ED_screen.hh" #include "ED_sculpt.hh" #include "ED_undo.hh" +#include "ED_view3d.hh" #include "bmesh_tools.hh" diff --git a/source/blender/editors/mesh/editmesh_path.cc b/source/blender/editors/mesh/editmesh_path.cc index 6c8df7aac8c..e48e106e3e8 100644 --- a/source/blender/editors/mesh/editmesh_path.cc +++ b/source/blender/editors/mesh/editmesh_path.cc @@ -24,7 +24,7 @@ #include "BKE_customdata.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "ED_mesh.hh" #include "ED_object.hh" diff --git a/source/blender/editors/mesh/editmesh_polybuild.cc b/source/blender/editors/mesh/editmesh_polybuild.cc index 76592ff17fc..e84bd7b34d9 100644 --- a/source/blender/editors/mesh/editmesh_polybuild.cc +++ b/source/blender/editors/mesh/editmesh_polybuild.cc @@ -18,7 +18,8 @@ #include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" -#include "BKE_object_types.hh" +#include "BKE_mesh.hh" +#include "BKE_report.h" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" @@ -28,6 +29,8 @@ #include "ED_mesh.hh" #include "ED_object.hh" +#include "ED_scene.hh" +#include "ED_screen.hh" #include "ED_transform.hh" #include "ED_view3d.hh" @@ -124,7 +127,7 @@ static int edbm_polybuild_transform_at_cursor_invoke(bContext *C, BMEditMesh *em = vc.em; BMesh *bm = em->bm; - invert_m4_m4(vc.obedit->runtime->world_to_object.ptr(), vc.obedit->object_to_world().ptr()); + invert_m4_m4(vc.obedit->world_to_object, vc.obedit->object_to_world); ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); if (!ele_act) { @@ -189,7 +192,7 @@ static int edbm_polybuild_delete_at_cursor_invoke(bContext *C, BMEditMesh *em = vc.em; BMesh *bm = em->bm; - invert_m4_m4(vc.obedit->runtime->world_to_object.ptr(), vc.obedit->object_to_world().ptr()); + invert_m4_m4(vc.obedit->world_to_object, vc.obedit->object_to_world); ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); if (!ele_act) { @@ -282,7 +285,7 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con BMEditMesh *em = vc.em; BMesh *bm = em->bm; - invert_m4_m4(vc.obedit->runtime->world_to_object.ptr(), vc.obedit->object_to_world().ptr()); + invert_m4_m4(vc.obedit->world_to_object, vc.obedit->object_to_world); ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); edbm_selectmode_ensure(vc.scene, vc.em, SCE_SELECT_VERTEX); @@ -290,9 +293,9 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con if (ele_act == nullptr || ele_act->head.htype == BM_FACE) { /* Just add vert */ copy_v3_v3(center, vc.scene->cursor.location); - mul_v3_m4v3(center, vc.obedit->object_to_world().ptr(), center); + mul_v3_m4v3(center, vc.obedit->object_to_world, center); ED_view3d_win_to_3d_int(vc.v3d, vc.region, center, event->mval, center); - mul_m4_v3(vc.obedit->world_to_object().ptr(), center); + mul_m4_v3(vc.obedit->world_to_object, center); BMVert *v_new = BM_vert_create(bm, center, nullptr, BM_CREATE_NOP); edbm_flag_disable_all_multi(vc.scene, vc.view_layer, vc.v3d, BM_ELEM_SELECT); @@ -305,9 +308,9 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con BMFace *f_reference = e_act->l ? e_act->l->f : nullptr; mid_v3_v3v3(center, e_act->v1->co, e_act->v2->co); - mul_m4_v3(vc.obedit->object_to_world().ptr(), center); + mul_m4_v3(vc.obedit->object_to_world, center); ED_view3d_win_to_3d_int(vc.v3d, vc.region, center, event->mval, center); - mul_m4_v3(vc.obedit->world_to_object().ptr(), center); + mul_m4_v3(vc.obedit->world_to_object, center); if (f_reference->len == 3 && RNA_boolean_get(op->ptr, "create_quads")) { const float fac = line_point_factor_v3(center, e_act->v1->co, e_act->v2->co); BMVert *v_new = BM_edge_split(bm, e_act, e_act->v1, nullptr, std::clamp(fac, 0.0f, 1.0f)); @@ -361,9 +364,9 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con BMFace *f_reference = e_pair[0]->l ? e_pair[0]->l->f : nullptr; - mul_v3_m4v3(center, vc.obedit->object_to_world().ptr(), v_act->co); + mul_v3_m4v3(center, vc.obedit->object_to_world, v_act->co); ED_view3d_win_to_3d_int(vc.v3d, vc.region, center, event->mval, center); - mul_m4_v3(vc.obedit->world_to_object().ptr(), center); + mul_m4_v3(vc.obedit->world_to_object, center); BMVert *v_quad[4]; v_quad[0] = v_act; @@ -383,9 +386,9 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con } else { /* Just add edge */ - mul_m4_v3(vc.obedit->object_to_world().ptr(), center); + mul_m4_v3(vc.obedit->object_to_world, center); ED_view3d_win_to_3d_int(vc.v3d, vc.region, v_act->co, event->mval, center); - mul_m4_v3(vc.obedit->world_to_object().ptr(), center); + mul_m4_v3(vc.obedit->world_to_object, center); BMVert *v_new = BM_vert_create(bm, center, nullptr, BM_CREATE_NOP); @@ -459,7 +462,7 @@ static int edbm_polybuild_split_at_cursor_invoke(bContext *C, BMEditMesh *em = vc.em; BMesh *bm = em->bm; - invert_m4_m4(vc.obedit->runtime->world_to_object.ptr(), vc.obedit->object_to_world().ptr()); + invert_m4_m4(vc.obedit->world_to_object, vc.obedit->object_to_world); ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); edbm_selectmode_ensure(vc.scene, vc.em, SCE_SELECT_VERTEX); @@ -470,9 +473,9 @@ static int edbm_polybuild_split_at_cursor_invoke(bContext *C, if (ele_act->head.htype == BM_EDGE) { BMEdge *e_act = (BMEdge *)ele_act; mid_v3_v3v3(center, e_act->v1->co, e_act->v2->co); - mul_m4_v3(vc.obedit->object_to_world().ptr(), center); + mul_m4_v3(vc.obedit->object_to_world, center); ED_view3d_win_to_3d_int(vc.v3d, vc.region, center, event->mval, center); - mul_m4_v3(vc.obedit->world_to_object().ptr(), center); + mul_m4_v3(vc.obedit->world_to_object, center); const float fac = line_point_factor_v3(center, e_act->v1->co, e_act->v2->co); BMVert *v_new = BM_edge_split(bm, e_act, e_act->v1, nullptr, std::clamp(fac, 0.0f, 1.0f)); diff --git a/source/blender/editors/mesh/editmesh_preselect_elem.cc b/source/blender/editors/mesh/editmesh_preselect_elem.cc index 651c2052f2a..b09c5611807 100644 --- a/source/blender/editors/mesh/editmesh_preselect_elem.cc +++ b/source/blender/editors/mesh/editmesh_preselect_elem.cc @@ -243,9 +243,9 @@ static void view3d_preselect_update_preview_triangle_from_vert( } if (e_pair[1] != nullptr) { - mul_v3_m4v3(center, vc->obedit->object_to_world().ptr(), v_act->co); + mul_v3_m4v3(center, vc->obedit->object_to_world, v_act->co); ED_view3d_win_to_3d_int(vc->v3d, vc->region, center, mval, center); - mul_m4_v3(vc->obedit->world_to_object().ptr(), center); + mul_m4_v3(vc->obedit->world_to_object, center); psel->preview_tris = static_cast( MEM_mallocN(sizeof(*psel->preview_tris) * 2, __func__)); @@ -313,9 +313,9 @@ static void view3d_preselect_update_preview_triangle_from_edge( psel->preview_lines = static_cast( MEM_mallocN(sizeof(*psel->preview_lines) * 3, __func__)); mid_v3_v3v3(center, eed->v1->co, eed->v2->co); - mul_m4_v3(vc->obedit->object_to_world().ptr(), center); + mul_m4_v3(vc->obedit->object_to_world, center); ED_view3d_win_to_3d_int(vc->v3d, vc->region, center, mval, center); - mul_m4_v3(vc->obedit->world_to_object().ptr(), center); + mul_m4_v3(vc->obedit->world_to_object, center); copy_v3_v3(psel->preview_tris[0][0], eed->v1->co); copy_v3_v3(psel->preview_tris[0][1], eed->v2->co); diff --git a/source/blender/editors/mesh/editmesh_rip.cc b/source/blender/editors/mesh/editmesh_rip.cc index 707949a618f..efefd2a90a7 100644 --- a/source/blender/editors/mesh/editmesh_rip.cc +++ b/source/blender/editors/mesh/editmesh_rip.cc @@ -19,9 +19,9 @@ #include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" -#include "BKE_report.hh" +#include "BKE_report.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -29,6 +29,7 @@ #include "WM_types.hh" #include "ED_mesh.hh" +#include "ED_screen.hh" #include "ED_transform.hh" #include "ED_view3d.hh" diff --git a/source/blender/editors/mesh/editmesh_rip_edge.cc b/source/blender/editors/mesh/editmesh_rip_edge.cc index 87f1f60c0b3..5c06465b108 100644 --- a/source/blender/editors/mesh/editmesh_rip_edge.cc +++ b/source/blender/editors/mesh/editmesh_rip_edge.cc @@ -15,7 +15,7 @@ #include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BLI_math_geom.h" #include "BLI_math_vector.h" @@ -24,6 +24,7 @@ #include "WM_types.hh" #include "ED_mesh.hh" +#include "ED_screen.hh" #include "ED_transform.hh" #include "ED_view3d.hh" diff --git a/source/blender/editors/mesh/editmesh_select.cc b/source/blender/editors/mesh/editmesh_select.cc index cc67963312a..5b84b92b22f 100644 --- a/source/blender/editors/mesh/editmesh_select.cc +++ b/source/blender/editors/mesh/editmesh_select.cc @@ -33,7 +33,7 @@ #include "BKE_mesh.hh" #include "BKE_mesh_wrapper.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "WM_api.hh" #include "WM_types.hh" @@ -49,7 +49,7 @@ #include "ED_transform.hh" #include "ED_view3d.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -1076,7 +1076,7 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc, float imat3[3][3]; ED_view3d_viewcontext_init_object(vc, obedit); - copy_m3_m4(imat3, obedit->object_to_world().ptr()); + copy_m3_m4(imat3, obedit->object_to_world); invert_m3(imat3); const float(*coords)[3] = nullptr; @@ -1101,9 +1101,8 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc, for (uint j = 0; j < 2; j++) { BMVert *v = *((&e->v1) + j); float point[3]; - mul_v3_m4v3(point, - obedit->object_to_world().ptr(), - coords ? coords[BM_elem_index_get(v)] : v->co); + mul_v3_m4v3( + point, obedit->object_to_world, coords ? coords[BM_elem_index_get(v)] : v->co); const float dist_sq_test = dist_squared_to_ray_v3_normalized( ray_origin, ray_direction, point); if (dist_sq_test < dist_sq_best_vert) { @@ -1132,7 +1131,7 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc, else { mid_v3_v3v3(point, e->v1->co, e->v2->co); } - mul_m4_v3(obedit->object_to_world().ptr(), point); + mul_m4_v3(obedit->object_to_world, point); const float dist_sq_test = dist_squared_to_ray_v3_normalized( ray_origin, ray_direction, point); if (dist_sq_test < dist_sq_best_edge) { @@ -1157,9 +1156,8 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc, BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_HIDDEN) == false) { float point[3]; - mul_v3_m4v3(point, - obedit->object_to_world().ptr(), - coords ? coords[BM_elem_index_get(v)] : v->co); + mul_v3_m4v3( + point, obedit->object_to_world, coords ? coords[BM_elem_index_get(v)] : v->co); const float dist_sq_test = dist_squared_to_ray_v3_normalized( ray_origin, ray_direction, point); if (dist_sq_test < dist_sq_best_vert) { @@ -1189,7 +1187,7 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc, else { mid_v3_v3v3(point, e->v1->co, e->v2->co); } - mul_m4_v3(obedit->object_to_world().ptr(), point); + mul_m4_v3(obedit->object_to_world, point); const float dist_sq_test = dist_squared_to_ray_v3_normalized( ray_origin, ray_direction, point); if (dist_sq_test < dist_sq_best_edge) { @@ -1218,7 +1216,7 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc, else { BM_face_calc_center_median(f, point); } - mul_m4_v3(obedit->object_to_world().ptr(), point); + mul_m4_v3(obedit->object_to_world, point); const float dist_sq_test = dist_squared_to_ray_v3_normalized( ray_origin, ray_direction, point); if (dist_sq_test < dist_sq_best_face) { @@ -4871,7 +4869,7 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op) { float vertex_world[3]; - mul_v3_m4v3(vertex_world, obedit->object_to_world().ptr(), v_act->co); + mul_v3_m4v3(vertex_world, obedit->object_to_world, v_act->co); value = dot_v3v3(axis_vector, vertex_world); } @@ -4899,7 +4897,7 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op) BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN | BM_ELEM_SELECT)) { float v_iter_world[3]; - mul_v3_m4v3(v_iter_world, obedit_iter->object_to_world().ptr(), v->co); + mul_v3_m4v3(v_iter_world, obedit_iter->object_to_world, v->co); const float value_iter = dot_v3v3(axis_vector, v_iter_world); switch (sign) { case SELECT_AXIS_ALIGN: diff --git a/source/blender/editors/mesh/editmesh_select_similar.cc b/source/blender/editors/mesh/editmesh_select_similar.cc index ab7b64a2755..222e4c9b9dd 100644 --- a/source/blender/editors/mesh/editmesh_select_similar.cc +++ b/source/blender/editors/mesh/editmesh_select_similar.cc @@ -15,7 +15,7 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_customdata.hh" @@ -23,9 +23,9 @@ #include "BKE_editmesh.hh" #include "BKE_layer.hh" #include "BKE_material.h" -#include "BKE_object_types.hh" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "DNA_material_types.h" #include "DNA_meshdata_types.h" #include "WM_api.hh" @@ -138,9 +138,9 @@ static void face_to_plane(const Object *ob, BMFace *face, float r_plane[4]) { float normal[3], co[3]; copy_v3_v3(normal, face->no); - mul_transposed_mat3_m4_v3(ob->world_to_object().ptr(), normal); + mul_transposed_mat3_m4_v3(ob->world_to_object, normal); normalize_v3(normal); - mul_v3_m4v3(co, ob->object_to_world().ptr(), BM_FACE_FIRST_LOOP(face)->v->co); + mul_v3_m4v3(co, ob->object_to_world, BM_FACE_FIRST_LOOP(face)->v->co); plane_from_point_normal_v3(r_plane, co, normal); } @@ -200,14 +200,14 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) BMEditMesh *em = BKE_editmesh_from_object(ob); BMesh *bm = em->bm; Material ***material_array = nullptr; - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); if (bm->totfacesel == 0) { continue; } float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world().ptr()); + copy_m3_m4(ob_m3, ob->object_to_world); switch (type) { case SIMFACE_MATERIAL: { @@ -255,7 +255,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) case SIMFACE_NORMAL: { float normal[3]; copy_v3_v3(normal, face->no); - mul_transposed_mat3_m4_v3(ob->world_to_object().ptr(), normal); + mul_transposed_mat3_m4_v3(ob->world_to_object, normal); normalize_v3(normal); BLI_kdtree_3d_insert(tree_3d, tree_index++, normal); break; @@ -314,7 +314,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) Material ***material_array = nullptr; float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world().ptr()); + copy_m3_m4(ob_m3, ob->object_to_world); bool has_custom_data_layer = false; switch (type) { @@ -391,7 +391,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) case SIMFACE_NORMAL: { float normal[3]; copy_v3_v3(normal, face->no); - mul_transposed_mat3_m4_v3(ob->world_to_object().ptr(), normal); + mul_transposed_mat3_m4_v3(ob->world_to_object, normal); normalize_v3(normal); /* We are treating the normals as coordinates, the "nearest" one will @@ -511,8 +511,8 @@ static void edge_pos_direction_worldspace_get(Object *ob, BMEdge *edge, float *r copy_v3_v3(v1, edge->v1->co); copy_v3_v3(v2, edge->v2->co); - mul_m4_v3(ob->object_to_world().ptr(), v1); - mul_m4_v3(ob->object_to_world().ptr(), v2); + mul_m4_v3(ob->object_to_world, v1); + mul_m4_v3(ob->object_to_world, v2); sub_v3_v3v3(r_dir, v1, v2); normalize_v3(r_dir); @@ -522,8 +522,8 @@ static float edge_length_squared_worldspace_get(Object *ob, BMEdge *edge) { float v1[3], v2[3]; - mul_v3_mat3_m4v3(v1, ob->object_to_world().ptr(), edge->v1->co); - mul_v3_mat3_m4v3(v2, ob->object_to_world().ptr(), edge->v2->co); + mul_v3_mat3_m4v3(v1, ob->object_to_world, edge->v1->co); + mul_v3_mat3_m4v3(v2, ob->object_to_world, edge->v2->co); return len_squared_v3v3(v1, v2); } @@ -646,7 +646,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) } float ob_m3[3][3], ob_m3_inv[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world().ptr()); + copy_m3_m4(ob_m3, ob->object_to_world); invert_m3_m3(ob_m3_inv, ob_m3); BMEdge *edge; /* Mesh edge. */ @@ -770,7 +770,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) } float ob_m3[3][3], ob_m3_inv[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world().ptr()); + copy_m3_m4(ob_m3, ob->object_to_world); invert_m3_m3(ob_m3_inv, ob_m3); int custom_data_offset; @@ -997,7 +997,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) BLI_bitmap *defbase_selected = nullptr; int defbase_len = 0; - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); if (bm->totvertsel == 0) { continue; @@ -1038,7 +1038,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) case SIMVERT_NORMAL: { float normal[3]; copy_v3_v3(normal, vert->no); - mul_transposed_mat3_m4_v3(ob->world_to_object().ptr(), normal); + mul_transposed_mat3_m4_v3(ob->world_to_object, normal); normalize_v3(normal); BLI_kdtree_3d_insert(tree_3d, normal_tree_index++, normal); @@ -1190,7 +1190,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) case SIMVERT_NORMAL: { float normal[3]; copy_v3_v3(normal, vert->no); - mul_transposed_mat3_m4_v3(ob->world_to_object().ptr(), normal); + mul_transposed_mat3_m4_v3(ob->world_to_object, normal); normalize_v3(normal); /* We are treating the normals as coordinates, the "nearest" one will diff --git a/source/blender/editors/mesh/editmesh_set_sharpness_by_angle.cc b/source/blender/editors/mesh/editmesh_set_sharpness_by_angle.cc index 3128ffbcd3a..9814534f7ec 100644 --- a/source/blender/editors/mesh/editmesh_set_sharpness_by_angle.cc +++ b/source/blender/editors/mesh/editmesh_set_sharpness_by_angle.cc @@ -23,6 +23,7 @@ #include "WM_api.hh" +#include "ED_mesh.hh" #include "ED_screen.hh" #include "mesh_intern.hh" diff --git a/source/blender/editors/mesh/editmesh_tools.cc b/source/blender/editors/mesh/editmesh_tools.cc index 393252fc856..d75622a8bc5 100644 --- a/source/blender/editors/mesh/editmesh_tools.cc +++ b/source/blender/editors/mesh/editmesh_tools.cc @@ -7,7 +7,6 @@ */ #include -#include #include "MEM_guardedalloc.h" @@ -31,6 +30,7 @@ #include "BLI_math_vector.h" #include "BLI_rand.h" #include "BLI_sort_utils.h" +#include "BLI_string.h" #include "BKE_attribute.hh" #include "BKE_context.hh" @@ -40,16 +40,17 @@ #include "BKE_key.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" +#include "BKE_main.hh" #include "BKE_material.h" #include "BKE_mesh.hh" #include "BKE_object.hh" -#include "BKE_object_types.hh" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BKE_texture.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -68,6 +69,8 @@ #include "ED_uvedit.hh" #include "ED_view3d.hh" +#include "RE_texture.h" + #include "UI_interface.hh" #include "UI_resources.hh" @@ -3305,8 +3308,8 @@ static bool merge_target(BMEditMesh *em, if (use_cursor) { vco = scene->cursor.location; copy_v3_v3(co, vco); - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); - mul_m4_v3(ob->world_to_object().ptr(), co); + invert_m4_m4(ob->world_to_object, ob->object_to_world); + mul_m4_v3(ob->world_to_object, co); } else { float fac; @@ -6605,7 +6608,7 @@ static void sort_bmelem_flag(bContext *C, int coidx = (action == SRT_VIEW_ZAXIS) ? 2 : 0; /* Apply the view matrix to the object matrix. */ - mul_m4_m4m4(mat, rv3d->viewmat, ob->object_to_world().ptr()); + mul_m4_m4m4(mat, rv3d->viewmat, ob->object_to_world); if (totelem[0]) { pb = pblock[0] = static_cast(MEM_callocN(sizeof(char) * totelem[0], __func__)); @@ -6677,7 +6680,7 @@ static void sort_bmelem_flag(bContext *C, copy_v3_v3(cur, scene->cursor.location); - invert_m4_m4(mat, ob->object_to_world().ptr()); + invert_m4_m4(mat, ob->object_to_world); mul_m4_v3(mat, cur); if (totelem[0]) { @@ -8349,33 +8352,41 @@ static void point_normals_cancel(bContext *C, wmOperator *op) static void point_normals_update_header(bContext *C, wmOperator *op) { - auto get_modal_key_str = [&](int id) { - return WM_modalkeymap_operator_items_to_string(op->type, id, true).value_or(""); - }; + char header[UI_MAX_DRAW_STR]; + char buf[UI_MAX_DRAW_STR]; - const std::string header = fmt::format( - IFACE_("{}: confirm, {}: cancel, " - "{}: point to mouse ({}), {}: point to Pivot, " - "{}: point to object origin, {}: reset normals, " - "{}: set & point to 3D cursor, {}: select & point to mesh item, " - "{}: invert normals ({}), {}: spherize ({}), {}: align ({})"), - get_modal_key_str(EDBM_CLNOR_MODAL_CONFIRM), - get_modal_key_str(EDBM_CLNOR_MODAL_CANCEL), - get_modal_key_str(EDBM_CLNOR_MODAL_POINTTO_USE_MOUSE), - WM_bool_as_string(RNA_enum_get(op->ptr, "mode") == EDBM_CLNOR_POINTTO_MODE_MOUSE), - get_modal_key_str(EDBM_CLNOR_MODAL_POINTTO_USE_PIVOT), - get_modal_key_str(EDBM_CLNOR_MODAL_POINTTO_USE_OBJECT), - get_modal_key_str(EDBM_CLNOR_MODAL_POINTTO_RESET), - get_modal_key_str(EDBM_CLNOR_MODAL_POINTTO_SET_USE_3DCURSOR), - get_modal_key_str(EDBM_CLNOR_MODAL_POINTTO_SET_USE_SELECTED), - get_modal_key_str(EDBM_CLNOR_MODAL_POINTTO_INVERT), - WM_bool_as_string(RNA_boolean_get(op->ptr, "invert")), - get_modal_key_str(EDBM_CLNOR_MODAL_POINTTO_SPHERIZE), - WM_bool_as_string(RNA_boolean_get(op->ptr, "spherize")), - get_modal_key_str(EDBM_CLNOR_MODAL_POINTTO_ALIGN), - WM_bool_as_string(RNA_boolean_get(op->ptr, "align"))); + char *p = buf; + int available_len = sizeof(buf); - ED_area_status_text(CTX_wm_area(C), header.c_str()); +#define WM_MODALKEY(_id) \ + WM_modalkeymap_operator_items_to_string_buf( \ + op->type, (_id), true, UI_MAX_SHORTCUT_STR, &available_len, &p) + + SNPRINTF(header, + IFACE_("%s: confirm, %s: cancel, " + "%s: point to mouse (%s), %s: point to Pivot, " + "%s: point to object origin, %s: reset normals, " + "%s: set & point to 3D cursor, %s: select & point to mesh item, " + "%s: invert normals (%s), %s: spherize (%s), %s: align (%s)"), + WM_MODALKEY(EDBM_CLNOR_MODAL_CONFIRM), + WM_MODALKEY(EDBM_CLNOR_MODAL_CANCEL), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_USE_MOUSE), + WM_bool_as_string(RNA_enum_get(op->ptr, "mode") == EDBM_CLNOR_POINTTO_MODE_MOUSE), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_USE_PIVOT), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_USE_OBJECT), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_RESET), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_SET_USE_3DCURSOR), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_SET_USE_SELECTED), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_INVERT), + WM_bool_as_string(RNA_boolean_get(op->ptr, "invert")), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_SPHERIZE), + WM_bool_as_string(RNA_boolean_get(op->ptr, "spherize")), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_ALIGN), + WM_bool_as_string(RNA_boolean_get(op->ptr, "align"))); + +#undef WM_MODALKEY + + ED_area_status_text(CTX_wm_area(C), header); } /* TODO: move that to generic function in BMesh? */ diff --git a/source/blender/editors/mesh/editmesh_utils.cc b/source/blender/editors/mesh/editmesh_utils.cc index ac73fca05f4..3936caaf293 100644 --- a/source/blender/editors/mesh/editmesh_utils.cc +++ b/source/blender/editors/mesh/editmesh_utils.cc @@ -13,19 +13,23 @@ #include "DNA_object_types.h" #include "BLI_array.hh" +#include "BLI_buffer.h" #include "BLI_kdtree.h" #include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" +#include "BKE_DerivedMesh.hh" #include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_editmesh.hh" #include "BKE_editmesh_bvh.h" +#include "BKE_global.h" #include "BKE_layer.hh" +#include "BKE_main.hh" #include "BKE_mesh.hh" #include "BKE_mesh_mapping.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" @@ -1858,7 +1862,7 @@ bool BMBVH_EdgeVisible( ED_view3d_win_to_segment_clipped(depsgraph, region, v3d, mval_f, origin, end, false); - invert_m4_m4(invmat, obedit->object_to_world().ptr()); + invert_m4_m4(invmat, obedit->object_to_world); mul_m4_v3(invmat, origin); copy_v3_v3(co1, e->v1->co); @@ -1953,7 +1957,7 @@ void EDBM_project_snap_verts( co_proj, nullptr)) { - mul_v3_m4v3(eve->co, obedit->world_to_object().ptr(), co_proj); + mul_v3_m4v3(eve->co, obedit->world_to_object, co_proj); } } } diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc index a359a80d026..38741dc4493 100644 --- a/source/blender/editors/mesh/mesh_data.cc +++ b/source/blender/editors/mesh/mesh_data.cc @@ -22,21 +22,25 @@ #include "BKE_key.hh" #include "BKE_mesh.hh" #include "BKE_mesh_runtime.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" +#include "RNA_access.hh" +#include "RNA_define.hh" #include "RNA_prototypes.h" #include "WM_api.hh" #include "WM_types.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "ED_mesh.hh" #include "ED_object.hh" #include "ED_paint.hh" #include "ED_screen.hh" +#include "ED_uvedit.hh" +#include "ED_view3d.hh" #include "GEO_mesh_split_edges.hh" @@ -270,14 +274,17 @@ int ED_mesh_uv_add( CD_PROP_FLOAT2, MEM_dupallocN(CustomData_get_layer(&mesh->corner_data, CD_PROP_FLOAT2)), mesh->corners_num, - unique_name, + unique_name.c_str(), nullptr); is_init = true; } else { - CustomData_add_layer_named( - &mesh->corner_data, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->corners_num, unique_name); + CustomData_add_layer_named(&mesh->corner_data, + CD_PROP_FLOAT2, + CD_SET_DEFAULT, + mesh->corners_num, + unique_name.c_str()); } if (active_set || layernum_dst == 0) { @@ -334,10 +341,10 @@ const bool *ED_mesh_uv_map_pin_layer_get(const Mesh *mesh, const int uv_index) static bool *ensure_corner_boolean_attribute(Mesh &mesh, const blender::StringRefNull name) { bool *data = static_cast(CustomData_get_layer_named_for_write( - &mesh.corner_data, CD_PROP_BOOL, name, mesh.corners_num)); + &mesh.corner_data, CD_PROP_BOOL, name.c_str(), mesh.corners_num)); if (!data) { data = static_cast(CustomData_add_layer_named( - &mesh.corner_data, CD_PROP_BOOL, CD_SET_DEFAULT, mesh.faces_num, name)); + &mesh.corner_data, CD_PROP_BOOL, CD_SET_DEFAULT, mesh.faces_num, name.c_str())); } return data; } diff --git a/source/blender/editors/mesh/meshtools.cc b/source/blender/editors/mesh/meshtools.cc index 5e5d2becab1..3fea0b1f0c0 100644 --- a/source/blender/editors/mesh/meshtools.cc +++ b/source/blender/editors/mesh/meshtools.cc @@ -25,6 +25,7 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_view3d_types.h" +#include "DNA_workspace_types.h" #include "BKE_attribute.hh" #include "BKE_context.hh" @@ -32,7 +33,9 @@ #include "BKE_deform.hh" #include "BKE_editmesh.hh" #include "BKE_key.hh" +#include "BKE_layer.hh" #include "BKE_lib_id.hh" +#include "BKE_main.hh" #include "BKE_material.h" #include "BKE_mesh.hh" #include "BKE_mesh_iterators.hh" @@ -40,7 +43,7 @@ #include "BKE_multires.hh" #include "BKE_object.hh" #include "BKE_object_deform.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" @@ -137,7 +140,7 @@ static void join_mesh_single(Depsgraph *depsgraph, float cmat[4][4]; /* Watch this: switch matrix multiplication order really goes wrong. */ - mul_m4_m4m4(cmat, imat, ob_src->object_to_world().ptr()); + mul_m4_m4m4(cmat, imat, ob_src->object_to_world); /* transform vertex coordinates into new space */ for (a = 0; a < mesh->verts_num; a++) { @@ -374,7 +377,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) * NOTE: This doesn't apply recursive parenting. */ if (join_parent) { ob->parent = nullptr; - BKE_object_apply_mat4_ex(ob, ob->object_to_world().ptr(), ob->parent, ob->parentinv, false); + BKE_object_apply_mat4_ex(ob, ob->object_to_world, ob->parent, ob->parentinv, false); } /* that way the active object is always selected */ @@ -567,7 +570,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) /* Inverse transform for all selected meshes in this object, * See #object_join_exec for detailed comment on why the safe version is used. */ - invert_m4_m4_safe_ortho(imat, ob->object_to_world().ptr()); + invert_m4_m4_safe_ortho(imat, ob->object_to_world); /* Add back active mesh first. * This allows to keep things similar as they were, as much as possible diff --git a/source/blender/editors/object/add_modifier_assets.cc b/source/blender/editors/object/add_modifier_assets.cc index 792d5b755be..9d578975581 100644 --- a/source/blender/editors/object/add_modifier_assets.cc +++ b/source/blender/editors/object/add_modifier_assets.cc @@ -20,10 +20,10 @@ #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_modifier.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index d00467c94d3..8deb8b1e1a5 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -42,13 +42,13 @@ #include "BLI_utildefines.h" #include "BLI_vector.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" #include "BKE_anim_data.h" #include "BKE_armature.hh" #include "BKE_camera.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_constraint.h" #include "BKE_context.hh" #include "BKE_curve.hh" @@ -56,7 +56,7 @@ #include "BKE_curves.h" #include "BKE_customdata.hh" #include "BKE_displist.h" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_effect.h" #include "BKE_geometry_set.hh" #include "BKE_geometry_set_instances.hh" @@ -65,7 +65,6 @@ #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_grease_pencil.hh" -#include "BKE_grease_pencil_legacy_convert.hh" #include "BKE_key.hh" #include "BKE_lattice.hh" #include "BKE_layer.hh" @@ -86,8 +85,8 @@ #include "BKE_object_types.hh" #include "BKE_particle.h" #include "BKE_pointcloud.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_speaker.h" #include "BKE_vfont.hh" #include "BKE_volume.hh" @@ -335,7 +334,7 @@ void ED_object_base_init_transform_on_add(Object *object, const float loc[3], co copy_v3_v3(object->rot, rot); } - BKE_object_to_mat4(object, object->runtime->object_to_world.ptr()); + BKE_object_to_mat4(object, object->object_to_world); } float ED_object_new_primitive_matrix(bContext *C, @@ -355,14 +354,14 @@ float ED_object_new_primitive_matrix(bContext *C, invert_m3(rmat); /* inverse transform for initial rotation and object */ - copy_m3_m4(mat, obedit->object_to_world().ptr()); + copy_m3_m4(mat, obedit->object_to_world); mul_m3_m3m3(cmat, rmat, mat); invert_m3_m3(imat, cmat); copy_m4_m3(r_primmat, imat); /* center */ copy_v3_v3(r_primmat[3], loc); - sub_v3_v3v3(r_primmat[3], r_primmat[3], obedit->object_to_world().location()); + sub_v3_v3v3(r_primmat[3], r_primmat[3], obedit->object_to_world[3]); invert_m3_m3(imat, mat); mul_m3_v3(imat, r_primmat[3]); @@ -2228,7 +2227,7 @@ static int object_curves_empty_hair_add_exec(bContext *C, wmOperator *op) Object *curves_ob = ED_object_add_type( C, OB_CURVES, nullptr, nullptr, nullptr, false, local_view_bits); - BKE_object_apply_mat4(curves_ob, surface_ob->object_to_world().ptr(), false, false); + BKE_object_apply_mat4(curves_ob, surface_ob->object_to_world, false, false); /* Set surface object. */ Curves *curves_id = static_cast(curves_ob->data); @@ -2712,8 +2711,8 @@ static void make_object_duplilist_real(bContext *C, id_us_min((ID *)ob_dst->instance_collection); ob_dst->instance_collection = nullptr; - copy_m4_m4(ob_dst->runtime->object_to_world.ptr(), dob->mat); - BKE_object_apply_mat4(ob_dst, ob_dst->object_to_world().ptr(), false, false); + copy_m4_m4(ob_dst->object_to_world, dob->mat); + BKE_object_apply_mat4(ob_dst, ob_dst->object_to_world, false, false); BLI_ghash_insert(dupli_gh, dob, ob_dst); if (parent_gh) { @@ -3178,7 +3177,7 @@ static int object_convert_exec(bContext *C, wmOperator *op) ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0; float loc[3], size[3], rot[3][3], eul[3]; float matrix[4][4]; - mat4_to_loc_rot_size(loc, rot, size, ob->object_to_world().ptr()); + mat4_to_loc_rot_size(loc, rot, size, ob->object_to_world); mat3_to_eul(eul, rot); Object *ob_gpencil = ED_gpencil_add_object(C, loc, local_view_bits); @@ -3223,6 +3222,8 @@ static int object_convert_exec(bContext *C, wmOperator *op) { ob->flag |= OB_DONE; + bGPdata *gpd = static_cast(ob->data); + if (keep_original) { BLI_assert_unreachable(); } @@ -3230,7 +3231,16 @@ static int object_convert_exec(bContext *C, wmOperator *op) newob = ob; } - bke::greasepencil::convert::legacy_gpencil_object(*bmain, *newob); + GreasePencil *new_grease_pencil = static_cast( + BKE_id_new(bmain, ID_GP, newob->id.name + 2)); + newob->data = new_grease_pencil; + newob->type = OB_GREASE_PENCIL; + + bke::greasepencil::convert::legacy_gpencil_to_grease_pencil( + *bmain, *new_grease_pencil, *gpd); + + BKE_object_free_derived_caches(newob); + BKE_object_free_modifiers(newob, 0); } else if (target == OB_CURVES) { ob->flag |= OB_DONE; @@ -4092,9 +4102,8 @@ static int object_add_named_exec(bContext *C, wmOperator *op) PropertyRNA *prop_matrix = RNA_struct_find_property(op->ptr, "matrix"); if (RNA_property_is_set(op->ptr, prop_matrix)) { Object *ob_add = basen->object; - RNA_property_float_get_array( - op->ptr, prop_matrix, ob_add->runtime->object_to_world.base_ptr()); - BKE_object_apply_mat4(ob_add, ob_add->object_to_world().ptr(), true, true); + RNA_property_float_get_array(op->ptr, prop_matrix, &ob_add->object_to_world[0][0]); + BKE_object_apply_mat4(ob_add, ob_add->object_to_world, true, true); DEG_id_tag_update(&ob_add->id, ID_RECALC_TRANSFORM); } @@ -4190,7 +4199,7 @@ static int object_transform_to_mouse_exec(bContext *C, wmOperator *op) float mat_dst_unit[4][4]; float final_delta[4][4]; - normalize_m4_m4(mat_src_unit, ob->object_to_world().ptr()); + normalize_m4_m4(mat_src_unit, ob->object_to_world); normalize_m4_m4(mat_dst_unit, matrix); invert_m4(mat_src_unit); mul_m4_m4m4(final_delta, mat_dst_unit, mat_src_unit); @@ -4344,7 +4353,7 @@ static int object_join_exec(bContext *C, wmOperator *op) * If the zero scale is removed, the data on this axis remains un-scaled * (something that wouldn't work for #invert_m4_m4_safe). */ float imat_test[4][4]; - if (!invert_m4_m4(imat_test, ob->object_to_world().ptr())) { + if (!invert_m4_m4(imat_test, ob->object_to_world)) { BKE_report(op->reports, RPT_WARNING, "Active object final transform has one or more zero scaled axes"); diff --git a/source/blender/editors/object/object_bake.cc b/source/blender/editors/object/object_bake.cc index 0caf025b1ac..799bd216768 100644 --- a/source/blender/editors/object/object_bake.cc +++ b/source/blender/editors/object/object_bake.cc @@ -10,28 +10,38 @@ #include "MEM_guardedalloc.h" +#include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "DNA_world_types.h" +#include "BLI_blenlib.h" +#include "BLI_time.h" #include "BLI_utildefines.h" #include "BKE_DerivedMesh.hh" #include "BKE_attribute.hh" +#include "BKE_blender.h" #include "BKE_cdderivedmesh.h" #include "BKE_context.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" +#include "BKE_material.h" +#include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_multires.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" + +#include "DEG_depsgraph.hh" #include "RE_multires_bake.h" #include "RE_pipeline.h" +#include "RE_texture.h" #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" @@ -39,6 +49,7 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "ED_object.hh" #include "ED_screen.hh" #include "ED_uvedit.hh" diff --git a/source/blender/editors/object/object_bake_api.cc b/source/blender/editors/object/object_bake_api.cc index c4be875f7d8..0b7e1727244 100644 --- a/source/blender/editors/object/object_bake_api.cc +++ b/source/blender/editors/object/object_bake_api.cc @@ -24,10 +24,10 @@ #include "BLI_string.h" #include "BKE_attribute.hh" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "BKE_context.hh" #include "BKE_editmesh.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_image_format.h" #include "BKE_layer.hh" @@ -35,11 +35,12 @@ #include "BKE_main.hh" #include "BKE_material.h" #include "BKE_mesh.hh" +#include "BKE_mesh_mapping.hh" #include "BKE_modifier.hh" #include "BKE_node.hh" #include "BKE_object.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "DEG_depsgraph.hh" @@ -1578,10 +1579,10 @@ static int bake(const BakeAPIRender *bkr, highpoly[i].mesh = BKE_mesh_new_from_object(nullptr, highpoly[i].ob_eval, false, false); /* Low-poly to high-poly transformation matrix. */ - copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->object_to_world().ptr()); + copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->object_to_world); invert_m4_m4(highpoly[i].imat, highpoly[i].obmat); - highpoly[i].is_flip_object = is_negative_m4(highpoly[i].ob->object_to_world().ptr()); + highpoly[i].is_flip_object = is_negative_m4(highpoly[i].ob->object_to_world); i++; } @@ -1610,8 +1611,8 @@ static int bake(const BakeAPIRender *bkr, ob_cage != nullptr, bkr->cage_extrusion, bkr->max_ray_distance, - ob_low_eval->object_to_world().ptr(), - (ob_cage ? ob_cage->object_to_world().ptr() : ob_low_eval->object_to_world().ptr()), + ob_low_eval->object_to_world, + (ob_cage ? ob_cage->object_to_world : ob_low_eval->object_to_world), me_cage_eval)) { BKE_report(reports, RPT_ERROR, "Error handling selected objects"); @@ -1692,7 +1693,7 @@ static int bake(const BakeAPIRender *bkr, targets.result, me_low_eval, bkr->normal_swizzle, - ob_low_eval->object_to_world().ptr()); + ob_low_eval->object_to_world); } else { /* From multi-resolution. */ @@ -1718,7 +1719,7 @@ static int bake(const BakeAPIRender *bkr, targets.result, (me_nores) ? me_nores : me_low_eval, bkr->normal_swizzle, - ob_low_eval->object_to_world().ptr()); + ob_low_eval->object_to_world); if (md) { BKE_id_free(nullptr, &me_nores->id); diff --git a/source/blender/editors/object/object_bake_simulation.cc b/source/blender/editors/object/object_bake_simulation.cc index fdcfb3d65bb..feaead2faf7 100644 --- a/source/blender/editors/object/object_bake_simulation.cc +++ b/source/blender/editors/object/object_bake_simulation.cc @@ -6,10 +6,14 @@ #include #include +#include "BLI_endian_defines.h" +#include "BLI_endian_switch.h" #include "BLI_fileops.hh" #include "BLI_path_util.h" #include "BLI_serialize.hh" #include "BLI_string.h" +#include "BLI_string_utils.hh" +#include "BLI_time.h" #include "BLI_vector.hh" #include "WM_api.hh" @@ -18,23 +22,36 @@ #include "ED_screen.hh" #include "DNA_array_utils.hh" +#include "DNA_curves_types.h" +#include "DNA_material_types.h" +#include "DNA_mesh_types.h" #include "DNA_modifier_types.h" +#include "DNA_pointcloud_types.h" #include "DNA_windowmanager_types.h" #include "BKE_bake_geometry_nodes_modifier.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_curves.hh" +#include "BKE_global.h" +#include "BKE_instances.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" +#include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_node_runtime.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_object.hh" +#include "BKE_pointcloud.hh" +#include "BKE_report.h" +#include "BKE_scene.h" + +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "DEG_depsgraph.hh" +#include "DEG_depsgraph_build.hh" #include "MOD_nodes.hh" diff --git a/source/blender/editors/object/object_collection.cc b/source/blender/editors/object/object_collection.cc index 18c345f0ab0..20f25a81eb5 100644 --- a/source/blender/editors/object/object_collection.cc +++ b/source/blender/editors/object/object_collection.cc @@ -8,19 +8,20 @@ #include +#include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "DNA_collection_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_context.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" diff --git a/source/blender/editors/object/object_constraint.cc b/source/blender/editors/object/object_constraint.cc index 0ba189059a3..9be32e10d69 100644 --- a/source/blender/editors/object/object_constraint.cc +++ b/source/blender/editors/object/object_constraint.cc @@ -17,7 +17,7 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" @@ -36,7 +36,7 @@ #include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_tracking.h" #include "DEG_depsgraph.hh" @@ -56,6 +56,7 @@ #include "RNA_path.hh" #include "RNA_prototypes.h" +#include "ED_keyframing.hh" #include "ED_object.hh" #include "ED_screen.hh" @@ -2324,14 +2325,14 @@ static bool get_new_constraint_target( /* Since by default, IK targets the tip of the last bone, * use the tip of the active PoseChannel if adding a target for an IK Constraint. */ if (con_type == CONSTRAINT_TYPE_KINEMATIC) { - mul_v3_m4v3(obt->loc, obact->object_to_world().ptr(), pchanact->pose_tail); + mul_v3_m4v3(obt->loc, obact->object_to_world, pchanact->pose_tail); } else { - mul_v3_m4v3(obt->loc, obact->object_to_world().ptr(), pchanact->pose_head); + mul_v3_m4v3(obt->loc, obact->object_to_world, pchanact->pose_head); } } else { - copy_v3_v3(obt->loc, obact->object_to_world().location()); + copy_v3_v3(obt->loc, obact->object_to_world[3]); } /* restore, BKE_object_add sets active */ diff --git a/source/blender/editors/object/object_data_transfer.cc b/source/blender/editors/object/object_data_transfer.cc index 0b1a57f2ab1..50e1cfcf131 100644 --- a/source/blender/editors/object/object_data_transfer.cc +++ b/source/blender/editors/object/object_data_transfer.cc @@ -9,7 +9,9 @@ #include "DNA_mesh_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "BLI_blenlib.h" #include "BLI_math_matrix.h" #include "BLI_string.h" #include "BLI_utildefines.h" @@ -20,13 +22,14 @@ #include "BKE_deform.hh" #include "BKE_mesh_mapping.hh" #include "BKE_mesh_remap.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/editors/object/object_data_transform.cc b/source/blender/editors/object/object_data_transform.cc index 9285183df35..0859871a54f 100644 --- a/source/blender/editors/object/object_data_transform.cc +++ b/source/blender/editors/object/object_data_transform.cc @@ -15,12 +15,15 @@ #include #include +#include "DNA_anim_types.h" #include "DNA_armature_types.h" +#include "DNA_collection_types.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_lattice_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BLI_listbase.h" #include "BLI_math_matrix.h" @@ -35,10 +38,15 @@ #include "BKE_key.hh" #include "BKE_lattice.hh" #include "BKE_mball.hh" +#include "BKE_mesh.hh" +#include "BKE_scene.h" #include "bmesh.hh" #include "DEG_depsgraph.hh" +#include "DEG_depsgraph_query.hh" + +#include "WM_types.hh" #include "ED_armature.hh" #include "ED_mesh.hh" diff --git a/source/blender/editors/object/object_edit.cc b/source/blender/editors/object/object_edit.cc index 9cfba09186b..67bd12550fb 100644 --- a/source/blender/editors/object/object_edit.cc +++ b/source/blender/editors/object/object_edit.cc @@ -21,7 +21,7 @@ #include "BLI_math_rotation.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_armature_types.h" #include "DNA_collection_types.h" @@ -41,14 +41,14 @@ #include "BKE_anim_visualization.h" #include "BKE_armature.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_constraint.h" #include "BKE_context.hh" #include "BKE_curve.hh" #include "BKE_editlattice.h" #include "BKE_editmesh.hh" #include "BKE_effect.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_lattice.hh" #include "BKE_layer.hh" @@ -62,8 +62,8 @@ #include "BKE_paint.hh" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_softbody.h" #include "BKE_workspace.h" diff --git a/source/blender/editors/object/object_gpencil_modifier.cc b/source/blender/editors/object/object_gpencil_modifier.cc index c64f1e1d5c7..efa37cfff2a 100644 --- a/source/blender/editors/object/object_gpencil_modifier.cc +++ b/source/blender/editors/object/object_gpencil_modifier.cc @@ -26,13 +26,16 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" +#include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_id.hh" +#include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" +#include "DEG_depsgraph_query.hh" #include "RNA_access.hh" #include "RNA_define.hh" @@ -42,7 +45,7 @@ #include "ED_object.hh" #include "ED_screen.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "UI_interface.hh" diff --git a/source/blender/editors/object/object_hook.cc b/source/blender/editors/object/object_hook.cc index 6a13c3f77d9..13e40fd403e 100644 --- a/source/blender/editors/object/object_hook.cc +++ b/source/blender/editors/object/object_hook.cc @@ -21,6 +21,7 @@ #include "DNA_curve_types.h" #include "DNA_lattice_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -29,9 +30,11 @@ #include "BKE_deform.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" @@ -535,7 +538,7 @@ static int add_hook_object(const bContext *C, ob = add_hook_object_new(bmain, scene, view_layer, v3d, obedit); /* transform cent to global coords for loc */ - mul_v3_m4v3(ob->loc, obedit->object_to_world().ptr(), cent); + mul_v3_m4v3(ob->loc, obedit->object_to_world, cent); } md = static_cast(obedit->modifiers.first); @@ -558,13 +561,13 @@ static int add_hook_object(const bContext *C, unit_m4(pose_mat); - invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); + invert_m4_m4(obedit->world_to_object, obedit->object_to_world); if (mode == OBJECT_ADDHOOK_NEWOB) { /* pass */ } else { /* may overwrite with pose-bone location, below */ - mul_v3_m4v3(cent, obedit->world_to_object().ptr(), ob->object_to_world().location()); + mul_v3_m4v3(cent, obedit->world_to_object, ob->object_to_world[3]); } if (mode == OBJECT_ADDHOOK_SELOB_BONE) { @@ -578,8 +581,8 @@ static int add_hook_object(const bContext *C, pchan_act = BKE_pose_channel_active_if_bonecoll_visible(ob); if (LIKELY(pchan_act)) { invert_m4_m4(pose_mat, pchan_act->pose_mat); - mul_v3_m4v3(cent, ob->object_to_world().ptr(), pchan_act->pose_mat[3]); - mul_v3_m4v3(cent, obedit->world_to_object().ptr(), cent); + mul_v3_m4v3(cent, ob->object_to_world, pchan_act->pose_mat[3]); + mul_v3_m4v3(cent, obedit->world_to_object, cent); } } else { @@ -590,20 +593,16 @@ static int add_hook_object(const bContext *C, copy_v3_v3(hmd->cent, cent); /* matrix calculus */ - /* vert x (obmat x hook->world_to_object) x hook->object_to_world().ptr() x ob->world_to_object - */ + /* vert x (obmat x hook->world_to_object) x hook->object_to_world x ob->world_to_object */ /* (parentinv) */ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); BKE_object_transform_copy(object_eval, ob); BKE_object_where_is_calc(depsgraph, scene_eval, object_eval); - invert_m4_m4(object_eval->runtime->world_to_object.ptr(), object_eval->object_to_world().ptr()); + invert_m4_m4(object_eval->world_to_object, object_eval->object_to_world); /* apparently this call goes from right to left... */ - mul_m4_series(hmd->parentinv, - pose_mat, - object_eval->world_to_object().ptr(), - obedit->object_to_world().ptr()); + mul_m4_series(hmd->parentinv, pose_mat, object_eval->world_to_object, obedit->object_to_world); DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY); DEG_relations_tag_update(bmain); @@ -846,10 +845,10 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op) } /* recenter functionality */ - copy_m3_m4(bmat, ob->object_to_world().ptr()); + copy_m3_m4(bmat, ob->object_to_world); invert_m3_m3(imat, bmat); - sub_v3_v3v3(hmd->cent, scene->cursor.location, ob->object_to_world().location()); + sub_v3_v3v3(hmd->cent, scene->cursor.location, ob->object_to_world[3]); mul_m3_v3(imat, hmd->cent); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 8fdf98b3d4f..1d0c62c5300 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -225,9 +225,6 @@ void OBJECT_OT_laplaciandeform_bind(struct wmOperatorType *ot); void OBJECT_OT_surfacedeform_bind(struct wmOperatorType *ot); void OBJECT_OT_geometry_nodes_input_attribute_toggle(struct wmOperatorType *ot); void OBJECT_OT_geometry_node_tree_copy_assign(struct wmOperatorType *ot); -void OBJECT_OT_grease_pencil_dash_modifier_segment_add(struct wmOperatorType *ot); -void OBJECT_OT_grease_pencil_dash_modifier_segment_remove(struct wmOperatorType *ot); -void OBJECT_OT_grease_pencil_dash_modifier_segment_move(struct wmOperatorType *ot); /* object_gpencil_modifiers.c */ diff --git a/source/blender/editors/object/object_light_linking_ops.cc b/source/blender/editors/object/object_light_linking_ops.cc index 5f552733de2..3dfe1588975 100644 --- a/source/blender/editors/object/object_light_linking_ops.cc +++ b/source/blender/editors/object/object_light_linking_ops.cc @@ -25,6 +25,8 @@ #include "RNA_define.hh" #include "RNA_prototypes.h" +#include "DEG_depsgraph.hh" + /* -------------------------------------------------------------------- */ /** \name Create New Light Linking Receiver/Blocker Collection Operators * \{ */ diff --git a/source/blender/editors/object/object_modes.cc b/source/blender/editors/object/object_modes.cc index 0be928861fe..d474bab1bf6 100644 --- a/source/blender/editors/object/object_modes.cc +++ b/source/blender/editors/object/object_modes.cc @@ -9,20 +9,28 @@ * actual mode switching logic is per-object type. */ +#include "DNA_gpencil_legacy_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_workspace_types.h" +#include "BLI_kdopbvh.h" #include "BLI_time.h" #include "BLI_utildefines.h" +#include "BLT_translation.h" + #include "BKE_context.hh" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_layer.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "BLI_math_vector.h" @@ -38,6 +46,8 @@ #include "ED_armature.hh" #include "ED_gpencil_legacy.hh" #include "ED_outliner.hh" +#include "ED_screen.hh" +#include "ED_transform_snap_object_context.hh" #include "ED_undo.hh" #include "ED_view3d.hh" @@ -142,7 +152,7 @@ bool ED_object_mode_compat_test(const Object *ob, eObjectMode mode) } break; case OB_GREASE_PENCIL: - if (mode & (OB_MODE_EDIT | OB_MODE_PAINT_GREASE_PENCIL | OB_MODE_WEIGHT_PAINT)) { + if (mode & (OB_MODE_EDIT | OB_MODE_PAINT_GREASE_PENCIL)) { return true; } break; @@ -433,7 +443,7 @@ static void object_overlay_mode_transfer_animation_start(bContext *C, Object *ob { Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Object *ob_dst_eval = DEG_get_evaluated_object(depsgraph, ob_dst); - ob_dst_eval->runtime->overlay_mode_transfer_start_time = BLI_time_now_seconds(); + ob_dst_eval->runtime->overlay_mode_transfer_start_time = BLI_check_seconds_timer(); } static bool object_transfer_mode_to_base(bContext *C, wmOperator *op, Base *base_dst) diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index 0d17ba4e70f..a68325aeb2f 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -18,7 +18,6 @@ #include "DNA_armature_types.h" #include "DNA_array_utils.hh" #include "DNA_curve_types.h" -#include "DNA_defaults.h" #include "DNA_dynamicpaint_types.h" #include "DNA_fluid_types.h" #include "DNA_key_types.h" @@ -35,7 +34,6 @@ #include "BLI_path_util.h" #include "BLI_string.h" #include "BLI_string_utf8.h" -#include "BLI_string_utils.hh" #include "BLI_utildefines.h" #include "BKE_DerivedMesh.hh" @@ -49,7 +47,7 @@ #include "BKE_editmesh.hh" #include "BKE_effect.h" #include "BKE_geometry_set.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_idprop.h" #include "BKE_key.hh" @@ -71,8 +69,8 @@ #include "BKE_paint.hh" #include "BKE_particle.h" #include "BKE_pointcloud.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_softbody.h" #include "BKE_volume.hh" @@ -80,7 +78,7 @@ #include "DEG_depsgraph_build.hh" #include "DEG_depsgraph_query.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -742,8 +740,8 @@ static void add_shapekey_layers(Mesh &mesh_dest, const Mesh &mesh_src) memcpy(array, kb->data, sizeof(float[3]) * size_t(mesh_src.verts_num)); } - CustomData_add_layer_with_data( - &mesh_dest.vert_data, CD_SHAPEKEY, array, mesh_dest.verts_num, nullptr); + CustomData_add_layer_named_with_data( + &mesh_dest.vert_data, CD_SHAPEKEY, array, mesh_dest.verts_num, kb->name, nullptr); const int ci = CustomData_get_layer_index_n(&mesh_dest.vert_data, CD_SHAPEKEY, i); mesh_dest.vert_data.layers[ci].uid = kb->uid; @@ -3730,251 +3728,3 @@ void OBJECT_OT_geometry_node_tree_copy_assign(wmOperatorType *ot) } /** \} */ - -/* ------------------------------------------------------------------- */ -/** \name Dash Modifier - * \{ */ - -namespace blender::ed::greasepencil { - -static bool dash_modifier_segment_poll(bContext *C) -{ - return edit_modifier_poll_generic(C, &RNA_GreasePencilDashModifierData, 0, false, false); -} - -static int dash_modifier_segment_add_exec(bContext *C, wmOperator *op) -{ - Object *ob = ED_object_active_context(C); - auto *dmd = reinterpret_cast( - edit_modifier_property_get(op, ob, eModifierType_GreasePencilDash)); - - if (dmd == nullptr) { - return OPERATOR_CANCELLED; - } - - GreasePencilDashModifierSegment *new_segments = static_cast( - MEM_malloc_arrayN(dmd->segments_num + 1, sizeof(GreasePencilDashModifierSegment), __func__)); - - const int new_active_index = std::clamp(dmd->segment_active_index + 1, 0, dmd->segments_num); - if (dmd->segments_num != 0) { - /* Copy the segments before the new segment. */ - memcpy(new_segments, - dmd->segments_array, - sizeof(GreasePencilDashModifierSegment) * new_active_index); - /* Copy the segments after the new segment. */ - memcpy(new_segments + new_active_index + 1, - dmd->segments_array + new_active_index, - sizeof(GreasePencilDashModifierSegment) * (dmd->segments_num - new_active_index)); - } - - /* Create the new segment. */ - GreasePencilDashModifierSegment *ds = &new_segments[new_active_index]; - memcpy(ds, - DNA_struct_default_get(GreasePencilDashModifierSegment), - sizeof(GreasePencilDashModifierSegment)); - BLI_uniquename_cb( - [&](const blender::StringRef name) { - for (const GreasePencilDashModifierSegment &ds : dmd->segments()) { - if (STREQ(ds.name, name.data())) { - return true; - } - } - return false; - }, - '.', - ds->name); - - MEM_SAFE_FREE(dmd->segments_array); - dmd->segments_array = new_segments; - dmd->segments_num++; - dmd->segment_active_index++; - - DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE); - WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - - return OPERATOR_FINISHED; -} - -static int dash_modifier_segment_add_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) -{ - if (edit_modifier_invoke_properties(C, op)) { - return dash_modifier_segment_add_exec(C, op); - } - return OPERATOR_CANCELLED; -} - -} // namespace blender::ed::greasepencil - -void OBJECT_OT_grease_pencil_dash_modifier_segment_add(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Add Segment"; - ot->description = "Add a segment to the dash modifier"; - ot->idname = "OBJECT_OT_grease_pencil_dash_modifier_segment_add"; - - /* api callbacks */ - ot->poll = blender::ed::greasepencil::dash_modifier_segment_poll; - ot->invoke = blender::ed::greasepencil::dash_modifier_segment_add_invoke; - ot->exec = blender::ed::greasepencil::dash_modifier_segment_add_exec; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; - edit_modifier_properties(ot); -} - -namespace blender::ed::greasepencil { - -static void dash_modifier_segment_free(GreasePencilDashModifierSegment * /*ds*/) {} - -static int dash_modifier_segment_remove_exec(bContext *C, wmOperator *op) -{ - Object *ob = ED_object_active_context(C); - auto *dmd = reinterpret_cast( - edit_modifier_property_get(op, ob, eModifierType_GreasePencilDash)); - - if (dmd == nullptr) { - return OPERATOR_CANCELLED; - } - - if (!dmd->segments().index_range().contains(dmd->segment_active_index)) { - return OPERATOR_CANCELLED; - } - - blender::dna::array::remove_index(&dmd->segments_array, - &dmd->segments_num, - &dmd->segment_active_index, - dmd->segment_active_index, - dash_modifier_segment_free); - - DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE); - WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - - return OPERATOR_FINISHED; -} - -static int dash_modifier_segment_remove_invoke(bContext *C, - wmOperator *op, - const wmEvent * /*event*/) -{ - if (edit_modifier_invoke_properties(C, op)) { - return dash_modifier_segment_remove_exec(C, op); - } - return OPERATOR_CANCELLED; -} - -} // namespace blender::ed::greasepencil - -void OBJECT_OT_grease_pencil_dash_modifier_segment_remove(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Remove Dash Segment"; - ot->description = "Remove the active segment from the dash modifier"; - ot->idname = "OBJECT_OT_grease_pencil_dash_modifier_segment_remove"; - - /* api callbacks */ - ot->poll = blender::ed::greasepencil::dash_modifier_segment_poll; - ot->invoke = blender::ed::greasepencil::dash_modifier_segment_remove_invoke; - ot->exec = blender::ed::greasepencil::dash_modifier_segment_remove_exec; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; - edit_modifier_properties(ot); - - RNA_def_int( - ot->srna, "index", 0, 0, INT_MAX, "Index", "Index of the segment to remove", 0, INT_MAX); -} - -namespace blender::ed::greasepencil { - -enum class DashSegmentMoveDirection { - Up = -1, - Down = 1, -}; - -static int dash_modifier_segment_move_exec(bContext *C, wmOperator *op) -{ - Object *ob = ED_object_active_context(C); - auto *dmd = reinterpret_cast( - edit_modifier_property_get(op, ob, eModifierType_GreasePencilDash)); - - if (dmd == nullptr) { - return OPERATOR_CANCELLED; - } - - if (dmd->segments_num < 2) { - return OPERATOR_CANCELLED; - } - - const DashSegmentMoveDirection direction = DashSegmentMoveDirection( - RNA_enum_get(op->ptr, "type")); - switch (direction) { - case DashSegmentMoveDirection::Up: - if (dmd->segment_active_index == 0) { - return OPERATOR_CANCELLED; - } - - std::swap(dmd->segments_array[dmd->segment_active_index], - dmd->segments_array[dmd->segment_active_index - 1]); - - dmd->segment_active_index--; - break; - case DashSegmentMoveDirection::Down: - if (dmd->segment_active_index == dmd->segments_num - 1) { - return OPERATOR_CANCELLED; - } - - std::swap(dmd->segments_array[dmd->segment_active_index], - dmd->segments_array[dmd->segment_active_index + 1]); - - dmd->segment_active_index++; - break; - default: - return OPERATOR_CANCELLED; - } - - DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE); - WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - - return OPERATOR_FINISHED; -} - -static int dash_modifier_segment_move_invoke(bContext *C, - wmOperator *op, - const wmEvent * /*event*/) -{ - if (edit_modifier_invoke_properties(C, op)) { - return dash_modifier_segment_move_exec(C, op); - } - return OPERATOR_CANCELLED; -} - -} // namespace blender::ed::greasepencil - -void OBJECT_OT_grease_pencil_dash_modifier_segment_move(wmOperatorType *ot) -{ - using blender::ed::greasepencil::DashSegmentMoveDirection; - - static const EnumPropertyItem segment_move[] = { - {int(DashSegmentMoveDirection::Up), "UP", 0, "Up", ""}, - {int(DashSegmentMoveDirection::Down), "DOWN", 0, "Down", ""}, - {0, nullptr, 0, nullptr, nullptr}, - }; - - /* identifiers */ - ot->name = "Move Dash Segment"; - ot->description = "Move the active dash segment up or down"; - ot->idname = "OBJECT_OT_grease_pencil_dash_modifier_segment_move"; - - /* api callbacks */ - ot->poll = blender::ed::greasepencil::dash_modifier_segment_poll; - ot->invoke = blender::ed::greasepencil::dash_modifier_segment_move_invoke; - ot->exec = blender::ed::greasepencil::dash_modifier_segment_move_exec; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; - edit_modifier_properties(ot); - - ot->prop = RNA_def_enum(ot->srna, "type", segment_move, 0, "Type", ""); -} - -/** \} */ diff --git a/source/blender/editors/object/object_ops.cc b/source/blender/editors/object/object_ops.cc index 7956c1957c9..df916ed2f34 100644 --- a/source/blender/editors/object/object_ops.cc +++ b/source/blender/editors/object/object_ops.cc @@ -141,9 +141,6 @@ void ED_operatortypes_object() WM_operatortype_append(OBJECT_OT_skin_armature_create); WM_operatortype_append(OBJECT_OT_geometry_nodes_input_attribute_toggle); WM_operatortype_append(OBJECT_OT_geometry_node_tree_copy_assign); - WM_operatortype_append(OBJECT_OT_grease_pencil_dash_modifier_segment_add); - WM_operatortype_append(OBJECT_OT_grease_pencil_dash_modifier_segment_remove); - WM_operatortype_append(OBJECT_OT_grease_pencil_dash_modifier_segment_move); /* grease pencil modifiers */ WM_operatortype_append(OBJECT_OT_gpencil_modifier_add); diff --git a/source/blender/editors/object/object_random.cc b/source/blender/editors/object/object_random.cc index e8f048e41aa..f5641e13e10 100644 --- a/source/blender/editors/object/object_random.cc +++ b/source/blender/editors/object/object_random.cc @@ -10,6 +10,7 @@ #include "DNA_layer_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BLI_math_vector.h" #include "BLI_rand.h" diff --git a/source/blender/editors/object/object_relations.cc b/source/blender/editors/object/object_relations.cc index 8303bd243ee..e44b79d4c7c 100644 --- a/source/blender/editors/object/object_relations.cc +++ b/source/blender/editors/object/object_relations.cc @@ -19,13 +19,18 @@ #include "DNA_camera_types.h" #include "DNA_collection_types.h" #include "DNA_constraint_types.h" +#include "DNA_gpencil_legacy_types.h" +#include "DNA_key_types.h" #include "DNA_lattice_types.h" +#include "DNA_light_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" +#include "DNA_meta_types.h" #include "DNA_object_types.h" #include "DNA_particle_types.h" #include "DNA_scene_types.h" #include "DNA_vfont_types.h" +#include "DNA_world_types.h" #include "BLI_kdtree.h" #include "BLI_linklist.h" @@ -36,34 +41,48 @@ #include "BLI_utildefines.h" #include "BLI_vector_set.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "BKE_DerivedMesh.hh" #include "BKE_action.h" #include "BKE_anim_data.h" #include "BKE_armature.hh" -#include "BKE_collection.hh" +#include "BKE_camera.h" +#include "BKE_collection.h" #include "BKE_constraint.h" #include "BKE_context.hh" #include "BKE_curve.hh" +#include "BKE_curves.h" #include "BKE_displist.h" #include "BKE_editmesh.hh" #include "BKE_fcurve.h" +#include "BKE_gpencil_legacy.h" +#include "BKE_idprop.h" #include "BKE_idtype.hh" +#include "BKE_lattice.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_lib_override.hh" #include "BKE_lib_query.hh" #include "BKE_lib_remap.hh" +#include "BKE_light.h" +#include "BKE_lightprobe.h" #include "BKE_main.hh" #include "BKE_material.h" +#include "BKE_mball.hh" +#include "BKE_mesh.hh" #include "BKE_modifier.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BKE_node_runtime.hh" #include "BKE_node_tree_interface.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_pointcloud.hh" +#include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_speaker.h" +#include "BKE_texture.h" +#include "BKE_volume.hh" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" @@ -82,6 +101,7 @@ #include "ED_armature.hh" #include "ED_curve.hh" #include "ED_gpencil_legacy.hh" +#include "ED_keyframing.hh" #include "ED_mesh.hh" #include "ED_object.hh" #include "ED_screen.hh" @@ -265,7 +285,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) /* inverse parent matrix */ BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); - invert_m4_m4(ob->parentinv, workob.object_to_world().ptr()); + invert_m4_m4(ob->parentinv, workob.object_to_world); } else { ob->partype = PARVERT1; @@ -273,7 +293,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) /* inverse parent matrix */ BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); - invert_m4_m4(ob->parentinv, workob.object_to_world().ptr()); + invert_m4_m4(ob->parentinv, workob.object_to_world); } } } @@ -395,7 +415,7 @@ void ED_object_parent_clear(Object *ob, const int type) /* remove parent, and apply the parented transform * result as object's local transforms */ ob->parent = nullptr; - BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), true, false); + BKE_object_apply_mat4(ob, ob->object_to_world, true, false); /* Don't recalculate the animation because it would change the transform * instead of keeping it. */ flags &= ~ID_RECALC_ANIMATION; @@ -581,7 +601,7 @@ bool ED_object_parent_set(ReportList *reports, if (keep_transform) { /* Was removed because of bug #23577, * but this can be handy in some cases too #32616, so * make optional. */ - BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), false, false); + BKE_object_apply_mat4(ob, ob->object_to_world, false, false); } /* Set the parent (except for follow-path constraint option). */ @@ -706,7 +726,7 @@ bool ED_object_parent_set(ReportList *reports, BKE_constraint_target_matrix_get( depsgraph, scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, nullptr, cmat, scene->r.cfra); - sub_v3_v3v3(vec, ob->object_to_world().location(), cmat[3]); + sub_v3_v3v3(vec, ob->object_to_world[3], cmat[3]); copy_v3_v3(ob->loc, vec); } @@ -729,7 +749,7 @@ bool ED_object_parent_set(ReportList *reports, ob->partype = PAROBJECT; BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); - invert_m4_m4(ob->parentinv, workob.object_to_world().ptr()); + invert_m4_m4(ob->parentinv, workob.object_to_world); } else if (is_armature_parent && (ob->type == OB_GPENCIL_LEGACY) && (par->type == OB_ARMATURE)) { if (partype == PAR_ARMATURE) { @@ -747,7 +767,7 @@ bool ED_object_parent_set(ReportList *reports, ob->partype = PAROBJECT; BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); - invert_m4_m4(ob->parentinv, workob.object_to_world().ptr()); + invert_m4_m4(ob->parentinv, workob.object_to_world); } else if ((ob->type == OB_GPENCIL_LEGACY) && (par->type == OB_LATTICE)) { /* Add Lattice modifier */ @@ -758,12 +778,12 @@ bool ED_object_parent_set(ReportList *reports, ob->partype = PAROBJECT; BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); - invert_m4_m4(ob->parentinv, workob.object_to_world().ptr()); + invert_m4_m4(ob->parentinv, workob.object_to_world); } else { /* calculate inverse parent matrix */ BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); - invert_m4_m4(ob->parentinv, workob.object_to_world().ptr()); + invert_m4_m4(ob->parentinv, workob.object_to_world); } DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); @@ -772,7 +792,7 @@ bool ED_object_parent_set(ReportList *reports, static void parent_set_vert_find(KDTree_3d *tree, Object *child, int vert_par[3], bool is_tri) { - const float *co_find = child->object_to_world().location(); + const float *co_find = child->object_to_world[3]; if (is_tri) { KDTreeNearest_3d nearest[3]; int tot; @@ -1190,7 +1210,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) } if (type == CLEAR_TRACK_KEEP_TRANSFORM) { - BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), true, true); + BKE_object_apply_mat4(ob, ob->object_to_world, true, true); } } CTX_DATA_END; diff --git a/source/blender/editors/object/object_remesh.cc b/source/blender/editors/object/object_remesh.cc index be7a6488b0d..4b716f86986 100644 --- a/source/blender/editors/object/object_remesh.cc +++ b/source/blender/editors/object/object_remesh.cc @@ -15,45 +15,56 @@ #include "MEM_guardedalloc.h" #include "BLI_math_matrix.h" +#include "BLI_string.h" #include "BLI_string_utf8.h" #include "BLI_utildefines.h" #include "DNA_object_types.h" #include "DNA_userdef_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_attribute.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_customdata.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_mesh.hh" #include "BKE_mesh_mirror.hh" #include "BKE_mesh_remesh_voxel.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" -#include "BKE_object_types.hh" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_shrinkwrap.hh" #include "BKE_unit.hh" #include "DEG_depsgraph.hh" +#include "DEG_depsgraph_build.hh" +#include "ED_mesh.hh" +#include "ED_object.hh" #include "ED_screen.hh" #include "ED_sculpt.hh" #include "ED_space_api.hh" +#include "ED_undo.hh" #include "ED_view3d.hh" #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "GPU_immediate.h" +#include "GPU_immediate_util.h" #include "GPU_matrix.h" #include "GPU_state.h" #include "WM_api.hh" +#include "WM_message.hh" +#include "WM_toolsystem.hh" #include "WM_types.hh" #include "UI_interface.hh" @@ -271,7 +282,7 @@ static void voxel_size_edit_draw(const bContext *C, ARegion * /*region*/, void * uint pos3d = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); GPU_matrix_push(); - GPU_matrix_mul(cd->active_object->object_to_world().ptr()); + GPU_matrix_mul(cd->active_object->object_to_world); /* Draw Rect */ immUniformColor4f(0.9f, 0.9f, 0.9f, 0.8f); @@ -473,11 +484,10 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev float view_normal[3] = {0.0f, 0.0f, 1.0f}; /* Calculate the view normal. */ - invert_m4_m4(active_object->runtime->world_to_object.ptr(), - active_object->object_to_world().ptr()); + invert_m4_m4(active_object->world_to_object, active_object->object_to_world); copy_m3_m4(mat, rv3d->viewinv); mul_m3_v3(mat, view_normal); - copy_m3_m4(mat, active_object->world_to_object().ptr()); + copy_m3_m4(mat, active_object->world_to_object); mul_m3_v3(mat, view_normal); normalize_v3(view_normal); @@ -515,8 +525,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev /* Project the selected face in the previous step of the Bounding Box. */ for (int i = 0; i < 4; i++) { float preview_plane_world_space[3]; - mul_v3_m4v3( - preview_plane_world_space, active_object->object_to_world().ptr(), cd->preview_plane[i]); + mul_v3_m4v3(preview_plane_world_space, active_object->object_to_world, cd->preview_plane[i]); ED_view3d_project_v2(region, preview_plane_world_space, preview_plane_proj[i]); } @@ -563,7 +572,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev /* Invert object scale. */ float scale[3]; - mat4_to_size(scale, active_object->object_to_world().ptr()); + mat4_to_size(scale, active_object->object_to_world); invert_v3(scale); size_to_mat4(scale_mat, scale); @@ -574,7 +583,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev /* Scale the text to constant viewport size. */ float text_pos_word_space[3]; - mul_v3_m4v3(text_pos_word_space, active_object->object_to_world().ptr(), text_pos); + mul_v3_m4v3(text_pos_word_space, active_object->object_to_world, text_pos); const float pixelsize = ED_view3d_pixel_size(rv3d, text_pos_word_space); scale_m4_fl(scale_mat, pixelsize * 0.5f); mul_m4_m4_post(cd->text_mat, scale_mat); diff --git a/source/blender/editors/object/object_select.cc b/source/blender/editors/object/object_select.cc index 454300357d7..dc6a6ed0e19 100644 --- a/source/blender/editors/object/object_select.cc +++ b/source/blender/editors/object/object_select.cc @@ -16,29 +16,37 @@ #include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_collection_types.h" +#include "DNA_gpencil_legacy_types.h" #include "DNA_light_types.h" +#include "DNA_material_types.h" #include "DNA_modifier_types.h" #include "DNA_scene_types.h" +#include "DNA_workspace_types.h" #include "BLI_listbase.h" +#include "BLI_math_bits.h" #include "BLI_math_vector.h" #include "BLI_rand.h" #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" #include "BKE_armature.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_context.hh" +#include "BKE_deform.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_material.h" +#include "BKE_object.hh" +#include "BKE_paint.hh" #include "BKE_particle.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_workspace.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/object/object_shader_fx.cc b/source/blender/editors/object/object_shader_fx.cc index d75a25aed20..48ae3b51038 100644 --- a/source/blender/editors/object/object_shader_fx.cc +++ b/source/blender/editors/object/object_shader_fx.cc @@ -23,16 +23,18 @@ #include "BLI_string_utf8.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_lib_id.hh" +#include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_shader_fx.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" +#include "DEG_depsgraph_query.hh" #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/editors/object/object_shapekey.cc b/source/blender/editors/object/object_shapekey.cc index 733907de47f..0ac00bb05aa 100644 --- a/source/blender/editors/object/object_shapekey.cc +++ b/source/blender/editors/object/object_shapekey.cc @@ -17,10 +17,11 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_key_types.h" #include "DNA_lattice_types.h" @@ -28,13 +29,16 @@ #include "DNA_object_types.h" #include "BKE_context.hh" +#include "BKE_crazyspace.hh" #include "BKE_key.hh" #include "BKE_lattice.hh" +#include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" +#include "DEG_depsgraph_query.hh" #include "BLI_sys_types.h" /* for intptr_t support */ diff --git a/source/blender/editors/object/object_transform.cc b/source/blender/editors/object/object_transform.cc index 75ec8c90579..ec94cb4d1b0 100644 --- a/source/blender/editors/object/object_transform.cc +++ b/source/blender/editors/object/object_transform.cc @@ -50,8 +50,9 @@ #include "BKE_multires.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_pointcloud.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_tracking.h" #include "DEG_depsgraph.hh" @@ -66,6 +67,7 @@ #include "ANIM_keyframing.hh" #include "ED_armature.hh" +#include "ED_gpencil_legacy.hh" #include "ED_keyframing.hh" #include "ED_mesh.hh" #include "ED_object.hh" @@ -536,9 +538,9 @@ static void ignore_parent_tx(Main *bmain, Depsgraph *depsgraph, Scene *scene, Ob LISTBASE_FOREACH (Object *, ob_child, &bmain->objects) { if (ob_child->parent == ob) { Object *ob_child_eval = DEG_get_evaluated_object(depsgraph, ob_child); - BKE_object_apply_mat4(ob_child_eval, ob_child_eval->object_to_world().ptr(), true, false); + BKE_object_apply_mat4(ob_child_eval, ob_child_eval->object_to_world, true, false); BKE_object_workob_calc_parent(depsgraph, scene, ob_child_eval, &workob); - invert_m4_m4(ob_child->parentinv, workob.object_to_world().ptr()); + invert_m4_m4(ob_child->parentinv, workob.object_to_world); /* Copy result of BKE_object_apply_mat4(). */ BKE_object_transform_copy(ob_child, ob_child_eval); /* Make sure evaluated object is in a consistent state with the original one. @@ -681,11 +683,11 @@ static int apply_objects_internal(bContext *C, if (do_multi_user) { obact = CTX_data_active_object(C); - invert_m4_m4(obact_invmat, obact->object_to_world().ptr()); + invert_m4_m4(obact_invmat, obact->object_to_world); Object workob; BKE_object_workob_calc_parent(depsgraph, scene, obact, &workob); - copy_m4_m4(obact_parent, workob.object_to_world().ptr()); + copy_m4_m4(obact_parent, workob.object_to_world); copy_m4_m4(obact_parentinv, obact->parentinv); if (apply_objects_internal_need_single_user(C)) { @@ -1019,7 +1021,7 @@ static int apply_objects_internal(bContext *C, float _obmat[4][4], _iobmat[4][4]; float _mat[4][4]; - copy_m4_m4(_obmat, ob->object_to_world().ptr()); + copy_m4_m4(_obmat, ob->object_to_world); invert_m4_m4(_iobmat, _obmat); copy_m4_m4(_mat, _obmat); @@ -1105,7 +1107,7 @@ static int visual_transform_apply_exec(bContext *C, wmOperator * /*op*/) CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); BKE_object_where_is_calc(depsgraph, scene, ob_eval); - BKE_object_apply_mat4(ob_eval, ob_eval->object_to_world().ptr(), true, true); + BKE_object_apply_mat4(ob_eval, ob_eval->object_to_world, true, true); BKE_object_transform_copy(ob, ob_eval); /* update for any children that may get moved */ @@ -1325,8 +1327,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (centermode == ORIGIN_TO_CURSOR) { copy_v3_v3(cent, cursor); - invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); - mul_m4_v3(obedit->world_to_object().ptr(), cent); + invert_m4_m4(obedit->world_to_object, obedit->object_to_world); + mul_m4_v3(obedit->world_to_object, cent); } else { if (around == V3D_AROUND_CENTER_BOUNDS) { @@ -1393,8 +1395,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (centermode == ORIGIN_TO_CURSOR) { copy_v3_v3(cent, cursor); - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); - mul_m4_v3(ob->world_to_object().ptr(), cent); + invert_m4_m4(ob->world_to_object, ob->object_to_world); + mul_m4_v3(ob->world_to_object, cent); } if (ob->data == nullptr) { @@ -1415,8 +1417,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) INIT_MINMAX(min, max); BKE_object_minmax_dupli(depsgraph, scene, ob, min, max, true); mid_v3_v3v3(cent, min, max); - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); - mul_m4_v3(ob->world_to_object().ptr(), cent); + invert_m4_m4(ob->world_to_object, ob->object_to_world); + mul_m4_v3(ob->world_to_object, cent); } add_v3_v3(ob->instance_collection->instance_offset, cent); @@ -1612,7 +1614,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (centermode == ORIGIN_TO_GEOMETRY) { zero_v3(gpcenter); BKE_gpencil_centroid_3d(gpd, gpcenter); - add_v3_v3(gpcenter, ob->object_to_world().location()); + add_v3_v3(gpcenter, ob->object_to_world[3]); } if (centermode == ORIGIN_TO_CURSOR) { copy_v3_v3(gpcenter, cursor); @@ -1624,8 +1626,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) float offset_local[3]; int i; - sub_v3_v3v3(offset_global, gpcenter, ob->object_to_world().location()); - copy_m3_m4(bmat, obact->object_to_world().ptr()); + sub_v3_v3v3(offset_global, gpcenter, ob->object_to_world[3]); + copy_m3_m4(bmat, obact->object_to_world); invert_m3_m3(imat, bmat); mul_m3_v3(imat, offset_global); mul_v3_m3v3(offset_local, imat, offset_global); @@ -1784,8 +1786,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) ob_other->flag |= OB_DONE; DEG_id_tag_update(&ob_other->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); - mul_v3_mat3_m4v3( - centn, ob_other->object_to_world().ptr(), cent); /* omit translation part */ + mul_v3_mat3_m4v3(centn, ob_other->object_to_world, cent); /* omit translation part */ add_v3_v3(ob_other->loc, centn); Object *ob_other_eval = DEG_get_evaluated_object(depsgraph, ob_other); @@ -1959,9 +1960,9 @@ static void object_transform_axis_target_calc_depth_init(XFormAxisData *xfd, con int center_tot = 0; for (XFormAxisItem &item : xfd->object_data) { const Object *ob = item.ob; - const float *ob_co_a = ob->object_to_world().location(); + const float *ob_co_a = ob->object_to_world[3]; float ob_co_b[3]; - add_v3_v3v3(ob_co_b, ob->object_to_world().location(), ob->object_to_world().ptr()[2]); + add_v3_v3v3(ob_co_b, ob->object_to_world[3], ob->object_to_world[2]); float view_isect[3], ob_isect[3]; if (isect_line_line_v3(view_co_a, view_co_b, ob_co_a, ob_co_b, view_isect, ob_isect)) { add_v3_v3(center, view_isect); @@ -2032,7 +2033,7 @@ static void object_apply_location(Object *ob, const float loc[3]) /* quick but weak */ Object ob_prev = blender::dna::shallow_copy(*ob); float mat[4][4]; - copy_m4_m4(mat, ob->object_to_world().ptr()); + copy_m4_m4(mat, ob->object_to_world); copy_v3_v3(mat[3], loc); BKE_object_apply_mat4(ob, mat, true, true); copy_v3_v3(mat[3], ob->loc); @@ -2047,7 +2048,7 @@ static bool object_orient_to_location(Object *ob, const bool z_flip) { float delta[3]; - sub_v3_v3v3(delta, ob->object_to_world().location(), location); + sub_v3_v3v3(delta, ob->object_to_world[3], location); if (normalize_v3(delta) != 0.0f) { if (z_flip) { negate_v3(delta); @@ -2224,7 +2225,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const float xform_rot_offset_inv_first[3][3]; for (const int i : xfd->object_data.index_range()) { XFormAxisItem &item = xfd->object_data[i]; - copy_m3_m4(item.xform_rot_offset, item.ob->object_to_world().ptr()); + copy_m3_m4(item.xform_rot_offset, item.ob->object_to_world); normalize_m3(item.xform_rot_offset); if (i == 0) { @@ -2243,9 +2244,8 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const XFormAxisItem &item = xfd->object_data[i]; if (is_translate_init) { float ob_axis[3]; - item.xform_dist = len_v3v3(item.ob->object_to_world().location(), - location_world); - normalize_v3_v3(ob_axis, item.ob->object_to_world().ptr()[2]); + item.xform_dist = len_v3v3(item.ob->object_to_world[3], location_world); + normalize_v3_v3(ob_axis, item.ob->object_to_world[2]); /* Scale to avoid adding distance when moving between surfaces. */ if (normal_found) { float scale = fabsf(dot_v3v3(ob_axis, normal)); @@ -2259,7 +2259,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const copy_v3_v3(target_normal, normal); } else { - normalize_v3_v3(target_normal, item.ob->object_to_world().ptr()[2]); + normalize_v3_v3(target_normal, item.ob->object_to_world[2]); } #ifdef USE_RELATIVE_ROTATION @@ -2276,7 +2276,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const madd_v3_v3fl(loc, target_normal, item.xform_dist); object_apply_location(item.ob, loc); /* so orient behaves as expected */ - copy_v3_v3(item.ob->runtime->object_to_world.location(), loc); + copy_v3_v3(item.ob->object_to_world[3], loc); } object_orient_to_location( diff --git a/source/blender/editors/object/object_utils.cc b/source/blender/editors/object/object_utils.cc index 998a6e3b133..dcaabc2c399 100644 --- a/source/blender/editors/object/object_utils.cc +++ b/source/blender/editors/object/object_utils.cc @@ -11,8 +11,10 @@ #include "DNA_anim_types.h" #include "DNA_armature_types.h" +#include "DNA_collection_types.h" #include "DNA_meta_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BLI_listbase.h" #include "BLI_math_matrix.h" @@ -25,10 +27,12 @@ #include "BKE_lattice.hh" #include "BKE_layer.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph_query.hh" +#include "WM_types.hh" + #include "ED_curve.hh" #include "ED_object.hh" /* own include */ @@ -113,20 +117,20 @@ bool ED_object_calc_active_center(Object *ob, const bool select_only, float r_ce { if (ob->mode & OB_MODE_EDIT) { if (ED_object_calc_active_center_for_editmode(ob, select_only, r_center)) { - mul_m4_v3(ob->object_to_world().ptr(), r_center); + mul_m4_v3(ob->object_to_world, r_center); return true; } return false; } if (ob->mode & OB_MODE_POSE) { if (ED_object_calc_active_center_for_posemode(ob, select_only, r_center)) { - mul_m4_v3(ob->object_to_world().ptr(), r_center); + mul_m4_v3(ob->object_to_world, r_center); return true; } return false; } if (!select_only || (ob->base_flag & BASE_SELECTED)) { - copy_v3_v3(r_center, ob->object_to_world().location()); + copy_v3_v3(r_center, ob->object_to_world[3]); return true; } return false; @@ -246,11 +250,11 @@ void ED_object_xform_skip_child_container_item_ensure(XFormObjectSkipChild_Conta XFormObjectSkipChild *xf = static_cast( MEM_mallocN(sizeof(*xf), __func__)); copy_m4_m4(xf->parentinv_orig, ob->parentinv); - copy_m4_m4(xf->obmat_orig, ob->object_to_world().ptr()); - copy_m4_m4(xf->parent_obmat_orig, ob->parent->object_to_world().ptr()); - invert_m4_m4(xf->parent_obmat_inv_orig, ob->parent->object_to_world().ptr()); + copy_m4_m4(xf->obmat_orig, ob->object_to_world); + copy_m4_m4(xf->parent_obmat_orig, ob->parent->object_to_world); + invert_m4_m4(xf->parent_obmat_inv_orig, ob->parent->object_to_world); if (ob_parent_recurse) { - copy_m4_m4(xf->parent_recurse_obmat_orig, ob_parent_recurse->object_to_world().ptr()); + copy_m4_m4(xf->parent_recurse_obmat_orig, ob_parent_recurse->object_to_world); } xf->mode = mode; xf->ob_parent_recurse = ob_parent_recurse; @@ -276,14 +280,14 @@ void ED_object_xform_skip_child_container_update_all(XFormObjectSkipChild_Contai if (xf->mode == XFORM_OB_SKIP_CHILD_PARENT_IS_XFORM) { /* Parent is transformed, this isn't so compensate. */ Object *ob_parent_eval = DEG_get_evaluated_object(depsgraph, ob->parent); - mul_m4_m4m4(dmat, xf->parent_obmat_inv_orig, ob_parent_eval->object_to_world().ptr()); + mul_m4_m4m4(dmat, xf->parent_obmat_inv_orig, ob_parent_eval->object_to_world); invert_m4(dmat); } else if (xf->mode == XFORM_OB_SKIP_CHILD_PARENT_IS_XFORM_INDIRECT) { /* Calculate parent matrix (from the root transform). */ Object *ob_parent_recurse_eval = DEG_get_evaluated_object(depsgraph, xf->ob_parent_recurse); float parent_recurse_obmat_inv[4][4]; - invert_m4_m4(parent_recurse_obmat_inv, ob_parent_recurse_eval->object_to_world().ptr()); + invert_m4_m4(parent_recurse_obmat_inv, ob_parent_recurse_eval->object_to_world); mul_m4_m4m4(dmat, xf->parent_recurse_obmat_orig, parent_recurse_obmat_inv); invert_m4(dmat); float parent_obmat_calc[4][4]; @@ -298,7 +302,7 @@ void ED_object_xform_skip_child_container_update_all(XFormObjectSkipChild_Contai /* Transform this - without transform data. */ Object *ob_parent_recurse_eval = DEG_get_evaluated_object(depsgraph, xf->ob_parent_recurse); float parent_recurse_obmat_inv[4][4]; - invert_m4_m4(parent_recurse_obmat_inv, ob_parent_recurse_eval->object_to_world().ptr()); + invert_m4_m4(parent_recurse_obmat_inv, ob_parent_recurse_eval->object_to_world); mul_m4_m4m4(dmat, xf->parent_recurse_obmat_orig, parent_recurse_obmat_inv); invert_m4(dmat); float obmat_calc[4][4]; @@ -353,7 +357,7 @@ void ED_object_data_xform_container_item_ensure(XFormObjectData_Container *xds, if (!BLI_ghash_ensure_p(xds->obdata_in_obmode_map, ob->data, &xf_p)) { XFormObjectData_Extra *xf = static_cast( MEM_mallocN(sizeof(*xf), __func__)); - copy_m4_m4(xf->obmat_orig, ob->object_to_world().ptr()); + copy_m4_m4(xf->obmat_orig, ob->object_to_world); xf->ob = ob; /* Result may be nullptr, that's OK. */ xf->xod = ED_object_data_xform_create(static_cast(ob->data)); @@ -382,7 +386,7 @@ void ED_object_data_xform_container_update_all(XFormObjectData_Container *xds, Object *ob_eval = DEG_get_evaluated_object(depsgraph, xf->ob); float imat[4][4], dmat[4][4]; invert_m4_m4(imat, xf->obmat_orig); - mul_m4_m4m4(dmat, imat, ob_eval->object_to_world().ptr()); + mul_m4_m4m4(dmat, imat, ob_eval->object_to_world); invert_m4(dmat); ED_object_data_xform_by_mat4(xf->xod, dmat); diff --git a/source/blender/editors/object/object_vgroup.cc b/source/blender/editors/object/object_vgroup.cc index eb1e1597e57..1af599161f1 100644 --- a/source/blender/editors/object/object_vgroup.cc +++ b/source/blender/editors/object/object_vgroup.cc @@ -20,6 +20,7 @@ #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_workspace_types.h" #include "BLI_array.hh" #include "BLI_bitmap.h" @@ -36,17 +37,20 @@ #include "BKE_editmesh.hh" #include "BKE_grease_pencil_vertex_groups.hh" #include "BKE_lattice.hh" +#include "BKE_layer.hh" #include "BKE_mesh.hh" #include "BKE_mesh_mapping.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_deform.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" +#include "DEG_depsgraph_query.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_armature_types.h" #include "RNA_access.hh" diff --git a/source/blender/editors/object/object_volume.cc b/source/blender/editors/object/object_volume.cc index 2f0cba7537a..94f1eab2fc6 100644 --- a/source/blender/editors/object/object_volume.cc +++ b/source/blender/editors/object/object_volume.cc @@ -22,7 +22,7 @@ #include "BKE_context.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_volume.hh" #include "WM_api.hh" diff --git a/source/blender/editors/object/object_warp.cc b/source/blender/editors/object/object_warp.cc index 00cd0583cb8..dd70ad1993c 100644 --- a/source/blender/editors/object/object_warp.cc +++ b/source/blender/editors/object/object_warp.cc @@ -42,7 +42,7 @@ static void object_warp_calc_view_matrix(float r_mat_view[4][4], mul_m4_m4m4(viewmat_roll, mat_offset, viewmat); /* apply the view and the object matrix */ - mul_m4_m4m4(r_mat_view, viewmat_roll, obedit->object_to_world().ptr()); + mul_m4_m4m4(r_mat_view, viewmat_roll, obedit->object_to_world); /* get the view-space cursor */ mul_v3_m4v3(r_center_view, viewmat_roll, center); diff --git a/source/blender/editors/physics/dynamicpaint_ops.cc b/source/blender/editors/physics/dynamicpaint_ops.cc index e0e438cee31..94d2d721dd2 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.cc +++ b/source/blender/editors/physics/dynamicpaint_ops.cc @@ -17,7 +17,7 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_dynamicpaint_types.h" #include "DNA_modifier_types.h" @@ -28,11 +28,11 @@ #include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_dynamicpaint.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_main.hh" #include "BKE_modifier.hh" #include "BKE_object_deform.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "DEG_depsgraph.hh" @@ -327,7 +327,7 @@ static void dpaint_bake_endjob(void *customdata) if (job->success) { /* Show bake info */ WM_reportf( - RPT_INFO, "DynamicPaint: Bake complete! (%.2f)", BLI_time_now_seconds() - job->start); + RPT_INFO, "DynamicPaint: Bake complete! (%.2f)", BLI_check_seconds_timer() - job->start); } else { if (strlen(canvas->error)) { /* If an error occurred */ @@ -438,7 +438,7 @@ static void dpaint_bake_startjob(void *customdata, wmJobWorkerStatus *worker_sta job->stop = &worker_status->stop; job->do_update = &worker_status->do_update; job->progress = &worker_status->progress; - job->start = BLI_time_now_seconds(); + job->start = BLI_check_seconds_timer(); job->success = 1; G.is_break = false; diff --git a/source/blender/editors/physics/particle_boids.cc b/source/blender/editors/physics/particle_boids.cc index f0f7450ceb6..e978344eb88 100644 --- a/source/blender/editors/physics/particle_boids.cc +++ b/source/blender/editors/physics/particle_boids.cc @@ -17,6 +17,7 @@ #include "BKE_boids.h" #include "BKE_context.hh" +#include "BKE_main.hh" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" diff --git a/source/blender/editors/physics/particle_edit.cc b/source/blender/editors/physics/particle_edit.cc index 9c4190d6530..85b44e1aa7e 100644 --- a/source/blender/editors/physics/particle_edit.cc +++ b/source/blender/editors/physics/particle_edit.cc @@ -33,7 +33,7 @@ #include "BKE_bvhutils.hh" #include "BKE_context.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_mesh.hh" @@ -43,8 +43,8 @@ #include "BKE_object.hh" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" @@ -550,7 +550,7 @@ static void PE_free_shape_tree(PEData *data) static void PE_create_random_generator(PEData *data) { - uint rng_seed = uint(BLI_time_now_seconds_i() & UINT_MAX); + uint rng_seed = uint(BLI_check_seconds_timer_i() & UINT_MAX); rng_seed ^= POINTER_AS_UINT(data->ob); rng_seed ^= POINTER_AS_UINT(data->edit); data->rng = BLI_rng_new(rng_seed); @@ -3940,7 +3940,7 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance) /* Use `kco` as the object space version of world-space `co`, * `ob->world_to_object` is set before calling. */ - mul_v3_m4v3(kco, data->ob->world_to_object().ptr(), co); + mul_v3_m4v3(kco, data->ob->world_to_object, co); point_index = BLI_kdtree_3d_find_nearest(edit->emitter_field, kco, nullptr); if (point_index == -1) { @@ -3949,7 +3949,7 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance) copy_v3_v3(co_root, co); copy_v3_v3(no_root, &edit->emitter_cosnos[point_index * 6 + 3]); - mul_mat3_m4_v3(data->ob->object_to_world().ptr(), no_root); /* normal into global-space */ + mul_mat3_m4_v3(data->ob->object_to_world, no_root); /* normal into global-space */ normalize_v3(no_root); if (puff_volume) { @@ -4030,13 +4030,12 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance) /* Use `kco` as the object space version of world-space `co`, * `ob->world_to_object` is set before calling. */ - mul_v3_m4v3(kco, data->ob->world_to_object().ptr(), oco); + mul_v3_m4v3(kco, data->ob->world_to_object, oco); point_index = BLI_kdtree_3d_find_nearest(edit->emitter_field, kco, nullptr); if (point_index != -1) { copy_v3_v3(onor, &edit->emitter_cosnos[point_index * 6 + 3]); - mul_mat3_m4_v3(data->ob->object_to_world().ptr(), - onor); /* Normal into world-space. */ + mul_mat3_m4_v3(data->ob->object_to_world, onor); /* Normal into world-space. */ mul_mat3_m4_v3(imat, onor); /* World-space into particle-space. */ normalize_v3(onor); } @@ -4432,7 +4431,7 @@ static int brush_add(const bContext *C, PEData *data, short number) short size = pset->brush[PE_BRUSH_ADD].size; RNG *rng; - invert_m4_m4(imat, ob->object_to_world().ptr()); + invert_m4_m4(imat, ob->object_to_world); if (psys->flag & PSYS_GLOBAL_HAIR) { return 0; @@ -4821,7 +4820,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) data.combfac = 1.0f - data.combfac; } - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); ED_view3d_win_to_delta(region, xy_delta, bedit->zfac, vec); data.dvec = vec; @@ -4889,7 +4888,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } data.invert = (brush->invert ^ flip); - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); foreach_mouse_hit_point(&data, brush_puff, selected); } @@ -4919,7 +4918,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) data.smoothfac = brush->strength; - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); foreach_mouse_hit_key(&data, brush_smooth_get, selected); @@ -5136,7 +5135,7 @@ static bool shape_cut_test_point(PEData *data, ParticleEditSettings *pset, Parti userdata.num_hits = 0; float co_shape[3]; - mul_v3_m4v3(co_shape, pset->shape_object->world_to_object().ptr(), key->co); + mul_v3_m4v3(co_shape, pset->shape_object->world_to_object, key->co); BLI_bvhtree_ray_cast_all( shape_bvh->tree, co_shape, dir, 0.0f, BVH_RAYCAST_DIST_MAX, point_inside_bvh_cb, &userdata); @@ -5177,8 +5176,8 @@ static void shape_cut(PEData *data, int pa_index) float dir_shape[3]; float len_shape; - mul_v3_m4v3(co_curr_shape, pset->shape_object->world_to_object().ptr(), key->co); - mul_v3_m4v3(co_next_shape, pset->shape_object->world_to_object().ptr(), (key + 1)->co); + mul_v3_m4v3(co_curr_shape, pset->shape_object->world_to_object, key->co); + mul_v3_m4v3(co_next_shape, pset->shape_object->world_to_object, (key + 1)->co); sub_v3_v3v3(dir_shape, co_next_shape, co_curr_shape); len_shape = normalize_v3(dir_shape); diff --git a/source/blender/editors/physics/particle_edit_undo.cc b/source/blender/editors/physics/particle_edit_undo.cc index d4baf944fd9..074a81248bd 100644 --- a/source/blender/editors/physics/particle_edit_undo.cc +++ b/source/blender/editors/physics/particle_edit_undo.cc @@ -14,6 +14,7 @@ #include "CLG_log.h" +#include "DNA_meshdata_types.h" #include "DNA_scene_types.h" #include "DNA_windowmanager_types.h" @@ -30,10 +31,13 @@ #include "ED_object.hh" #include "ED_particle.hh" +#include "ED_physics.hh" #include "ED_undo.hh" #include "particle_edit_utildefines.h" +#include "physics_intern.h" + /** Only needed this locally. */ static CLG_LogRef LOG = {"ed.undo.particle_edit"}; diff --git a/source/blender/editors/physics/particle_object.cc b/source/blender/editors/physics/particle_object.cc index 0b498b59cca..96ee99149fc 100644 --- a/source/blender/editors/physics/particle_object.cc +++ b/source/blender/editors/physics/particle_object.cc @@ -26,16 +26,18 @@ #include "BKE_bvhutils.hh" #include "BKE_context.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" +#include "BKE_main.hh" #include "BKE_mesh.hh" #include "BKE_mesh_legacy_convert.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_particle.h" #include "BKE_pointcache.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" @@ -52,6 +54,8 @@ #include "ED_particle.hh" #include "ED_screen.hh" +#include "UI_resources.hh" + #include "particle_edit_utildefines.h" #include "physics_intern.h" @@ -702,7 +706,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph, PTCacheEditKey *ekey; BVHTreeFromMesh bvhtree = {nullptr}; const MFace *mface = nullptr, *mf; - const blender::int2 *edges = nullptr, *edge; + const vec2i *edges = nullptr, *edge; Mesh *mesh, *target_mesh; int numverts; int k; @@ -721,8 +725,8 @@ static bool remap_hair_emitter(Depsgraph *depsgraph, edit_point = target_edit ? target_edit->points : nullptr; - invert_m4_m4(from_ob_imat, ob->object_to_world().ptr()); - invert_m4_m4(to_ob_imat, target_ob->object_to_world().ptr()); + invert_m4_m4(from_ob_imat, ob->object_to_world); + invert_m4_m4(to_ob_imat, target_ob->object_to_world); invert_m4_m4(from_imat, from_mat); invert_m4_m4(to_imat, to_mat); @@ -759,7 +763,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph, BKE_bvhtree_from_mesh_get(&bvhtree, mesh, BVHTREE_FROM_FACES, 2); } else if (mesh->edges_num != 0) { - edges = static_cast( + edges = static_cast( CustomData_get_layer_named(&mesh->edge_data, CD_PROP_INT32_2D, ".edge_verts")); BKE_bvhtree_from_mesh_get(&bvhtree, mesh, BVHTREE_FROM_EDGES, 2); } @@ -840,7 +844,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph, float offset[3]; if (to_global) { - copy_m4_m4(imat, target_ob->object_to_world().ptr()); + copy_m4_m4(imat, target_ob->object_to_world); } else { /* NOTE: using target_dm here, which is in target_ob object space and has full modifiers. @@ -921,8 +925,8 @@ static bool connect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Particl ob, psys, psys->edit, - ob->object_to_world().ptr(), - ob->object_to_world().ptr(), + ob->object_to_world, + ob->object_to_world, psys->flag & PSYS_GLOBAL_HAIR, false); if (ok) { @@ -1171,7 +1175,7 @@ static bool copy_particle_systems_to_object(const bContext *C, for (psys = psys_start, psys_from = PSYS_FROM_FIRST, i = 0; psys; psys = psys->next, psys_from = PSYS_FROM_NEXT(psys_from), i++) { - const float(*from_mat)[4], (*to_mat)[4]; + float(*from_mat)[4], (*to_mat)[4]; switch (space) { case PAR_COPY_SPACE_OBJECT: @@ -1179,8 +1183,8 @@ static bool copy_particle_systems_to_object(const bContext *C, to_mat = I; break; case PAR_COPY_SPACE_WORLD: - from_mat = ob_from->object_to_world().ptr(); - to_mat = ob_to->object_to_world().ptr(); + from_mat = ob_from->object_to_world; + to_mat = ob_to->object_to_world; break; default: /* should not happen */ diff --git a/source/blender/editors/physics/physics_fluid.cc b/source/blender/editors/physics/physics_fluid.cc index 780cd6693dc..79f181801f2 100644 --- a/source/blender/editors/physics/physics_fluid.cc +++ b/source/blender/editors/physics/physics_fluid.cc @@ -22,14 +22,14 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_fluid.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_main.hh" #include "BKE_modifier.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "DEG_depsgraph.hh" @@ -338,7 +338,7 @@ static void fluid_bake_endjob(void *customdata) if (job->success) { /* Show bake info. */ WM_reportf( - RPT_INFO, "Fluid: %s complete! (%.2f)", job->name, BLI_time_now_seconds() - job->start); + RPT_INFO, "Fluid: %s complete! (%.2f)", job->name, BLI_check_seconds_timer() - job->start); } else { if (fds->error[0] != '\0') { @@ -361,7 +361,7 @@ static void fluid_bake_startjob(void *customdata, wmJobWorkerStatus *worker_stat job->stop = &worker_status->stop; job->do_update = &worker_status->do_update; job->progress = &worker_status->progress; - job->start = BLI_time_now_seconds(); + job->start = BLI_check_seconds_timer(); job->success = 1; G.is_break = false; @@ -446,7 +446,7 @@ static void fluid_free_endjob(void *customdata) if (job->success) { /* Show free job info */ WM_reportf( - RPT_INFO, "Fluid: %s complete! (%.2f)", job->name, BLI_time_now_seconds() - job->start); + RPT_INFO, "Fluid: %s complete! (%.2f)", job->name, BLI_check_seconds_timer() - job->start); } else { if (fds->error[0] != '\0') { @@ -466,7 +466,7 @@ static void fluid_free_startjob(void *customdata, wmJobWorkerStatus *worker_stat job->stop = &worker_status->stop; job->do_update = &worker_status->do_update; job->progress = &worker_status->progress; - job->start = BLI_time_now_seconds(); + job->start = BLI_check_seconds_timer(); job->success = 1; G.is_break = false; diff --git a/source/blender/editors/physics/physics_pointcache.cc b/source/blender/editors/physics/physics_pointcache.cc index 2ce5d287478..a3bd9764b61 100644 --- a/source/blender/editors/physics/physics_pointcache.cc +++ b/source/blender/editors/physics/physics_pointcache.cc @@ -11,10 +11,13 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_utildefines.h" +#include "DNA_scene_types.h" + #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_pointcache.h" diff --git a/source/blender/editors/physics/rigidbody_constraint.cc b/source/blender/editors/physics/rigidbody_constraint.cc index 9a7296597c4..dbad490c437 100644 --- a/source/blender/editors/physics/rigidbody_constraint.cc +++ b/source/blender/editors/physics/rigidbody_constraint.cc @@ -15,11 +15,12 @@ #include "DNA_rigidbody_types.h" #include "DNA_scene_types.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_context.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" -#include "BKE_report.hh" +#include "BKE_main.hh" +#include "BKE_report.h" #include "BKE_rigidbody.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/physics/rigidbody_object.cc b/source/blender/editors/physics/rigidbody_object.cc index 69a2eacb1d0..b44659dd9f2 100644 --- a/source/blender/editors/physics/rigidbody_object.cc +++ b/source/blender/editors/physics/rigidbody_object.cc @@ -10,14 +10,18 @@ #include #include +#include "DNA_collection_types.h" #include "DNA_object_types.h" #include "DNA_rigidbody_types.h" #include "DNA_scene_types.h" -#include "BLT_translation.hh" +#include "BLI_blenlib.h" + +#include "BLT_translation.h" #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_main.hh" +#include "BKE_report.h" #include "BKE_rigidbody.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/physics/rigidbody_world.cc b/source/blender/editors/physics/rigidbody_world.cc index 83e10c94baf..2536f8908a2 100644 --- a/source/blender/editors/physics/rigidbody_world.cc +++ b/source/blender/editors/physics/rigidbody_world.cc @@ -19,7 +19,8 @@ #endif #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_main.hh" +#include "BKE_report.h" #include "BKE_rigidbody.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/render/render_internal.cc b/source/blender/editors/render/render_internal.cc index 68ea64cf5f6..63febd665e7 100644 --- a/source/blender/editors/render/render_internal.cc +++ b/source/blender/editors/render/render_internal.cc @@ -21,7 +21,7 @@ #include "BLI_timecode.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -30,16 +30,17 @@ #include "BKE_colortools.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_image_format.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" +#include "BKE_node.hh" #include "BKE_node_tree_update.hh" #include "BKE_object.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "NOD_composite.hh" @@ -459,7 +460,7 @@ static void make_renderinfo_string(const RenderStats *rs, info_time = info_buffers.time_elapsed; BLI_timecode_string_from_time_simple(info_buffers.time_elapsed, sizeof(info_buffers.time_elapsed), - BLI_time_now_seconds() - rs->starttime); + BLI_check_seconds_timer() - rs->starttime); } ret_array[i++] = RPT_("Time:"); diff --git a/source/blender/editors/render/render_opengl.cc b/source/blender/editors/render/render_opengl.cc index 279760eb2c9..5b439f65d91 100644 --- a/source/blender/editors/render/render_opengl.cc +++ b/source/blender/editors/render/render_opengl.cc @@ -19,6 +19,7 @@ #include "BLI_task.hh" #include "BLI_threads.h" #include "BLI_utildefines.h" +#include "DNA_camera_types.h" #include "DNA_action_types.h" #include "DNA_anim_types.h" @@ -32,14 +33,14 @@ #include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_image_format.h" #include "BKE_image_save.h" #include "BKE_lib_query.hh" #include "BKE_main.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_writeavi.h" #include "DEG_depsgraph.hh" @@ -60,7 +61,7 @@ #include "RE_pipeline.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -858,7 +859,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) BLI_condition_init(&oglrender->task_condition); #ifdef DEBUG_TIME - oglrender->time_start = BLI_time_now_seconds(); + oglrender->time_start = BLI_check_seconds_timer(); #endif return true; @@ -894,7 +895,7 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender) BLI_condition_end(&oglrender->task_condition); #ifdef DEBUG_TIME - printf("Total render time: %f\n", BLI_time_now_seconds() - oglrender->time_start); + printf("Total render time: %f\n", BLI_check_seconds_timer() - oglrender->time_start); #endif MEM_SAFE_FREE(oglrender->render_frames); diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc index aada0c80c49..007a284cde2 100644 --- a/source/blender/editors/render/render_preview.cc +++ b/source/blender/editors/render/render_preview.cc @@ -27,7 +27,7 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "DNA_brush_types.h" #include "DNA_camera_types.h" @@ -48,7 +48,7 @@ #include "BKE_brush.hh" #include "BKE_colortools.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_icons.h" #include "BKE_idprop.h" #include "BKE_image.h" @@ -61,7 +61,7 @@ #include "BKE_object.hh" #include "BKE_pose_backup.h" #include "BKE_preview_image.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_texture.h" #include "BKE_world.h" @@ -793,7 +793,7 @@ static Object *object_preview_camera_create(Main *preview_main, float rotmat[3][3]; float dummy_scale[3]; - mat4_to_loc_rot_size(camera->loc, rotmat, dummy_scale, preview_object->object_to_world().ptr()); + mat4_to_loc_rot_size(camera->loc, rotmat, dummy_scale, preview_object->object_to_world); /* Camera is Y up, so needs additional rotations to obliquely face the front. */ float drotmat[3][3]; diff --git a/source/blender/editors/render/render_shading.cc b/source/blender/editors/render/render_shading.cc index a438f0fa318..86303f94c2a 100644 --- a/source/blender/editors/render/render_shading.cc +++ b/source/blender/editors/render/render_shading.cc @@ -30,7 +30,7 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_anim_data.h" #include "BKE_animsys.h" @@ -40,7 +40,7 @@ #include "BKE_context.hh" #include "BKE_curve.hh" #include "BKE_editmesh.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" @@ -52,8 +52,8 @@ #include "BKE_material.h" #include "BKE_node.hh" #include "BKE_object.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_texture.h" #include "BKE_vfont.hh" #include "BKE_workspace.h" @@ -1642,8 +1642,6 @@ static int lightprobe_cache_bake_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - G.is_break = false; - blender::Vector probes = lightprobe_cache_irradiance_volume_subset_get(C, op); /* TODO: abort if selected engine is not eevee. */ @@ -1651,8 +1649,7 @@ static int lightprobe_cache_bake_exec(bContext *C, wmOperator *op) /* Do the job. */ wmJobWorkerStatus worker_status = {}; EEVEE_NEXT_lightbake_job(rj, &worker_status); - /* Move baking data to original object and then free it. */ - EEVEE_NEXT_lightbake_update(rj); + /* Free baking data. Result is already stored in the scene data. */ EEVEE_NEXT_lightbake_job_data_free(rj); return OPERATOR_FINISHED; diff --git a/source/blender/editors/render/render_update.cc b/source/blender/editors/render/render_update.cc index e81838ff5e3..04f15595eeb 100644 --- a/source/blender/editors/render/render_update.cc +++ b/source/blender/editors/render/render_update.cc @@ -31,8 +31,9 @@ #include "BKE_icons.h" #include "BKE_main.hh" #include "BKE_material.h" +#include "BKE_node.hh" #include "BKE_paint.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "NOD_composite.hh" diff --git a/source/blender/editors/render/render_view.cc b/source/blender/editors/render/render_view.cc index adb7f5c409a..6faf55763a6 100644 --- a/source/blender/editors/render/render_view.cc +++ b/source/blender/editors/render/render_view.cc @@ -16,18 +16,20 @@ #include "DNA_userdef_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_main.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "WM_api.hh" #include "WM_types.hh" #include "ED_screen.hh" +#include "UI_interface.hh" #include "wm_window.hh" diff --git a/source/blender/editors/scene/scene_edit.cc b/source/blender/editors/scene/scene_edit.cc index aefbad41b5c..100c8ada9fb 100644 --- a/source/blender/editors/scene/scene_edit.cc +++ b/source/blender/editors/scene/scene_edit.cc @@ -16,19 +16,20 @@ #include "DNA_sequence_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" -#include "BKE_node.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_node.h" +#include "BKE_report.h" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "ED_object.hh" #include "ED_render.hh" #include "ED_scene.hh" #include "ED_screen.hh" @@ -39,6 +40,7 @@ #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "WM_api.hh" #include "WM_types.hh" diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index 1e9cbc29693..cb1bb332dc5 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -20,17 +20,20 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" +#include "BKE_image.h" #include "BKE_screen.hh" #include "BKE_workspace.h" #include "RNA_access.hh" +#include "RNA_types.hh" #include "WM_api.hh" #include "WM_message.hh" #include "WM_toolsystem.hh" #include "WM_types.hh" +#include "ED_asset.hh" #include "ED_asset_shelf.hh" #include "ED_buttons.hh" #include "ED_screen.hh" @@ -46,6 +49,7 @@ #include "BLF_api.hh" +#include "IMB_imbuf_types.hh" #include "IMB_metadata.hh" #include "UI_interface.hh" diff --git a/source/blender/editors/screen/area_query.cc b/source/blender/editors/screen/area_query.cc index 9d477fe706e..00e0447d37c 100644 --- a/source/blender/editors/screen/area_query.cc +++ b/source/blender/editors/screen/area_query.cc @@ -10,9 +10,12 @@ #include "DNA_userdef_types.h" +#include "BLI_blenlib.h" #include "BLI_math_base.h" #include "BLI_utildefines.h" +#include "RNA_types.hh" + #include "ED_screen.hh" #include "UI_interface.hh" diff --git a/source/blender/editors/screen/area_utils.cc b/source/blender/editors/screen/area_utils.cc index f512e090904..585192d76be 100644 --- a/source/blender/editors/screen/area_utils.cc +++ b/source/blender/editors/screen/area_utils.cc @@ -15,6 +15,9 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" +#include "RNA_access.hh" +#include "RNA_types.hh" + #include "WM_message.hh" #include "ED_screen.hh" diff --git a/source/blender/editors/screen/glutil.cc b/source/blender/editors/screen/glutil.cc index 33e4aeee62a..d8624853096 100644 --- a/source/blender/editors/screen/glutil.cc +++ b/source/blender/editors/screen/glutil.cc @@ -14,6 +14,8 @@ #include "BLI_utildefines.h" +#include "BKE_context.hh" + #include "BIF_glutil.hh" #include "IMB_colormanagement.hh" @@ -21,12 +23,15 @@ #include "GPU_context.h" #include "GPU_immediate.h" +#include "GPU_matrix.h" #include "GPU_texture.h" #ifdef __APPLE__ # include "GPU_state.h" #endif +#include "UI_interface.hh" + /* ******************************************** */ static void immDrawPixelsTexSetupAttributes(IMMDrawPixelsTexState *state) diff --git a/source/blender/editors/screen/screen_context.cc b/source/blender/editors/screen/screen_context.cc index ad5bbd2d9a9..cdcf3b145d8 100644 --- a/source/blender/editors/screen/screen_context.cc +++ b/source/blender/editors/screen/screen_context.cc @@ -29,7 +29,7 @@ #include "BKE_action.h" #include "BKE_armature.hh" -#include "BKE_blender.hh" +#include "BKE_blender.h" #include "BKE_context.hh" #include "BKE_gpencil_legacy.h" #include "BKE_layer.hh" diff --git a/source/blender/editors/screen/screen_draw.cc b/source/blender/editors/screen/screen_draw.cc index 922914b67cb..e0d13a3a8a7 100644 --- a/source/blender/editors/screen/screen_draw.cc +++ b/source/blender/editors/screen/screen_draw.cc @@ -9,7 +9,9 @@ #include "ED_screen.hh" #include "GPU_batch_presets.h" +#include "GPU_framebuffer.h" #include "GPU_immediate.h" +#include "GPU_matrix.h" #include "GPU_platform.h" #include "GPU_state.h" diff --git a/source/blender/editors/screen/screen_edit.cc b/source/blender/editors/screen/screen_edit.cc index 9a426038add..5fb23b3386f 100644 --- a/source/blender/editors/screen/screen_edit.cc +++ b/source/blender/editors/screen/screen_edit.cc @@ -14,18 +14,19 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_userdef_types.h" +#include "DNA_workspace_types.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_icons.h" #include "BKE_image.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_sound.h" #include "BKE_workspace.h" diff --git a/source/blender/editors/screen/screen_ops.cc b/source/blender/editors/screen/screen_ops.cc index e9ac556a7cf..6ba5c27a49f 100644 --- a/source/blender/editors/screen/screen_ops.cc +++ b/source/blender/editors/screen/screen_ops.cc @@ -11,16 +11,20 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" +#include "BLI_dlrbTree.h" #include "BLI_math_rotation.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_curve_types.h" #include "DNA_lattice_types.h" +#include "DNA_mask_types.h" +#include "DNA_mesh_types.h" #include "DNA_meta_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" @@ -28,18 +32,18 @@ #include "DNA_userdef_types.h" #include "DNA_workspace_types.h" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_icons.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_mask.h" #include "BKE_object.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_sound.h" #include "BKE_workspace.h" @@ -52,6 +56,7 @@ #include "ED_anim_api.hh" #include "ED_armature.hh" +#include "ED_clip.hh" #include "ED_fileselect.hh" #include "ED_image.hh" #include "ED_keyframes_keylist.hh" @@ -61,6 +66,8 @@ #include "ED_screen.hh" #include "ED_screen_types.hh" #include "ED_sequencer.hh" +#include "ED_undo.hh" +#include "ED_util.hh" #include "ED_view3d.hh" #include "RNA_access.hh" diff --git a/source/blender/editors/screen/screen_user_menu.cc b/source/blender/editors/screen/screen_user_menu.cc index f140ea75850..cee7d3fd146 100644 --- a/source/blender/editors/screen/screen_user_menu.cc +++ b/source/blender/editors/screen/screen_user_menu.cc @@ -19,7 +19,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_blender_user_menu.hh" #include "BKE_context.hh" diff --git a/source/blender/editors/screen/screendump.cc b/source/blender/editors/screen/screendump.cc index 9e3c2b37627..924d4a7e229 100644 --- a/source/blender/editors/screen/screendump.cc +++ b/source/blender/editors/screen/screendump.cc @@ -23,16 +23,17 @@ #include "DNA_space_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_image_format.h" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" +#include "RNA_define.hh" #include "RNA_prototypes.h" #include "UI_interface.hh" diff --git a/source/blender/editors/screen/workspace_edit.cc b/source/blender/editors/screen/workspace_edit.cc index a3b52f6d479..c73b8f90e56 100644 --- a/source/blender/editors/screen/workspace_edit.cc +++ b/source/blender/editors/screen/workspace_edit.cc @@ -22,7 +22,7 @@ #include "BKE_screen.hh" #include "BKE_workspace.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "DNA_screen_types.h" #include "DNA_windowmanager_types.h" @@ -38,7 +38,7 @@ #include "UI_interface.hh" #include "UI_resources.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "WM_api.hh" #include "WM_types.hh" diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index aceb59c56ff..56c73553576 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -99,7 +99,6 @@ set(LIB PRIVATE bf::blenlib PRIVATE bf::depsgraph PRIVATE bf::dna - PRIVATE bf::extern::fmtlib PRIVATE bf::intern::atomic PRIVATE bf::intern::clog PRIVATE bf::intern::guardedalloc diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc index 38af1f52802..ce1a993b2b6 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc @@ -27,7 +27,7 @@ #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DNA_brush_enums.h" #include "DNA_brush_types.h" diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc index 4bf3e0103e0..8a5ef3d9588 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc @@ -13,7 +13,7 @@ #include "BKE_context.hh" #include "BKE_curves.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "ED_view3d.hh" @@ -24,6 +24,8 @@ #include "DEG_depsgraph_query.hh" +#include "BLT_translation.h" + #include "GEO_curve_constraints.hh" /** @@ -186,7 +188,7 @@ std::optional sample_curves_3d_brush(const Depsgraph &depsgraph, /* Shorten ray when the surface object is hit. */ if (surface_object_eval != nullptr) { - const float4x4 surface_to_world_mat(surface_object->object_to_world().ptr()); + const float4x4 surface_to_world_mat(surface_object->object_to_world); const float4x4 world_to_surface_mat = math::invert(surface_to_world_mat); Mesh *surface_eval = BKE_object_get_evaluated_mesh(surface_object_eval); @@ -221,7 +223,7 @@ std::optional sample_curves_3d_brush(const Depsgraph &depsgraph, } } - const float4x4 curves_to_world_mat = curves_object.object_to_world(); + const float4x4 curves_to_world_mat(curves_object.object_to_world); const float4x4 world_to_curves_mat = math::invert(curves_to_world_mat); const float3 center_ray_start_cu = math::transform_point(world_to_curves_mat, diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_density.cc b/source/blender/editors/sculpt_paint/curves_sculpt_density.cc index 5e26beba3c9..b6d1c851994 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_density.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_density.cc @@ -14,7 +14,7 @@ #include "BKE_mesh_sample.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "ED_screen.hh" #include "ED_view3d.hh" diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc b/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc index ad87d68bf92..ba40fe7b491 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc @@ -6,6 +6,7 @@ #include "BLI_math_vector.hh" +#include "BLI_enumerable_thread_specific.hh" #include "BLI_length_parameterize.hh" #include "BLI_math_geom.h" #include "BLI_math_matrix_types.hh" diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index babf2d2c4cd..b7aea67600d 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -679,7 +679,7 @@ static void select_grow_invoke_per_curve(const Curves &curves_id, }); }); - float4x4 curves_to_world_mat = curves_ob.object_to_world(); + float4x4 curves_to_world_mat = float4x4(curves_ob.object_to_world); float4x4 world_to_curves_mat = math::invert(curves_to_world_mat); const float4x4 projection = ED_view3d_ob_project_mat_get(&rv3d, &curves_ob); diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_selection.cc b/source/blender/editors/sculpt_paint/curves_sculpt_selection.cc index 7be1c60d678..6bda4751388 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_selection.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_selection.cc @@ -6,6 +6,8 @@ #include "curves_sculpt_intern.hh" +#include "ED_curves_sculpt.hh" + namespace blender::ed::sculpt_paint { bke::SpanAttributeWriter float_selection_ensure(Curves &curves_id) diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc index 3b415e7ad7c..302b317a502 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc @@ -21,7 +21,7 @@ #include "BKE_mesh_sample.hh" #include "BKE_object.hh" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DNA_brush_enums.h" #include "DNA_curves_types.h" @@ -38,6 +38,8 @@ #include "GEO_add_curves_on_mesh.hh" #include "GEO_reverse_uv_sampler.hh" +#include "BLT_translation.h" + namespace blender::ed::sculpt_paint { using geometry::ReverseUVSampler; diff --git a/source/blender/editors/sculpt_paint/grease_pencil_draw_ops.cc b/source/blender/editors/sculpt_paint/grease_pencil_draw_ops.cc index 72968564aad..e5bc90f7759 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_draw_ops.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_draw_ops.cc @@ -4,7 +4,7 @@ #include "BKE_context.hh" #include "BKE_grease_pencil.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph_query.hh" @@ -19,6 +19,8 @@ #include "ANIM_keyframing.hh" #include "RNA_access.hh" +#include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "WM_api.hh" #include "WM_message.hh" @@ -165,12 +167,9 @@ static int grease_pencil_brush_stroke_invoke(bContext *C, wmOperator *op, const /* If auto-key is on and the drawing at the current frame starts before the current frame a new * keyframe needs to be inserted. */ - const bool is_first = active_layer.sorted_keys().is_empty() || - (active_layer.sorted_keys().first() > current_frame); - const bool needs_new_drawing = is_first || - (*active_layer.frame_key_at(current_frame) < current_frame); - - if (blender::animrig::is_autokey_on(scene) && needs_new_drawing) { + if (blender::animrig::is_autokey_on(scene) && active_layer.frame_key_at(current_frame) && + *active_layer.frame_key_at(current_frame) < current_frame) + { const ToolSettings *ts = CTX_data_tool_settings(C); if ((ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) != 0) { /* For additive drawing, we duplicate the frame that's currently visible and insert it at the diff --git a/source/blender/editors/sculpt_paint/grease_pencil_erase.cc b/source/blender/editors/sculpt_paint/grease_pencil_erase.cc index 65f6d9dcffe..71f648f9ee3 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_erase.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_erase.cc @@ -16,7 +16,10 @@ #include "BKE_context.hh" #include "BKE_crazyspace.hh" #include "BKE_curves.hh" +#include "BKE_curves_utils.hh" +#include "BKE_grease_pencil.h" #include "BKE_grease_pencil.hh" +#include "BKE_scene.h" #include "DEG_depsgraph_query.hh" #include "DNA_brush_enums.h" @@ -58,7 +61,13 @@ struct EraseOperationExecutor { int2 mouse_position_pixels{}; int64_t eraser_squared_radius_pixels{}; - EraseOperationExecutor(const bContext & /*C*/) {} + bke::greasepencil::DrawingTransforms transforms_; + + EraseOperationExecutor(const bContext &C) + { + Object *object = CTX_data_active_object(&C); + transforms_ = bke::greasepencil::DrawingTransforms(*object); + } /** * Computes the intersections between a 2D line segment and a circle with integer values. @@ -750,51 +759,50 @@ struct EraseOperationExecutor { GreasePencil &grease_pencil = *static_cast(obact->data); bool changed = false; - const auto execute_eraser_on_drawing = [&](const int layer_index, - const int frame_number, - Drawing &drawing) { - const Layer &layer = *grease_pencil.layers()[layer_index]; - const bke::CurvesGeometry &src = drawing.strokes(); + const auto execute_eraser_on_drawing = + [&](const int layer_index, const int frame_number, Drawing &drawing) { + const bke::CurvesGeometry &src = drawing.strokes(); - /* Evaluated geometry. */ - bke::crazyspace::GeometryDeformation deformation = - bke::crazyspace::get_evaluated_grease_pencil_drawing_deformation( - ob_eval, *obact, layer_index, frame_number); + /* Evaluated geometry. */ + bke::crazyspace::GeometryDeformation deformation = + bke::crazyspace::get_evaluated_grease_pencil_drawing_deformation( + ob_eval, *obact, layer_index, frame_number); - /* Compute screen space positions. */ - Array screen_space_positions(src.points_num()); - threading::parallel_for(src.points_range(), 4096, [&](const IndexRange src_points) { - for (const int src_point : src_points) { - ED_view3d_project_float_global(region, - math::transform_point(layer.to_world_space(*ob_eval), - deformation.positions[src_point]), - screen_space_positions[src_point], - V3D_PROJ_TEST_NOP); - } - }); + /* Compute screen space positions. */ + Array screen_space_positions(src.points_num()); + threading::parallel_for(src.points_range(), 4096, [&](const IndexRange src_points) { + for (const int src_point : src_points) { + ED_view3d_project_float_global( + region, + math::transform_point(transforms_.layer_space_to_world_space, + deformation.positions[src_point]), + screen_space_positions[src_point], + V3D_PROJ_TEST_NOP); + } + }); - /* Erasing operator. */ - bke::CurvesGeometry dst; - bool erased = false; - switch (self.eraser_mode) { - case GP_BRUSH_ERASER_STROKE: - erased = stroke_eraser(src, screen_space_positions, dst); - break; - case GP_BRUSH_ERASER_HARD: - erased = hard_eraser(src, screen_space_positions, dst, self.keep_caps); - break; - case GP_BRUSH_ERASER_SOFT: - // To be implemented - return; - } + /* Erasing operator. */ + bke::CurvesGeometry dst; + bool erased = false; + switch (self.eraser_mode) { + case GP_BRUSH_ERASER_STROKE: + erased = stroke_eraser(src, screen_space_positions, dst); + break; + case GP_BRUSH_ERASER_HARD: + erased = hard_eraser(src, screen_space_positions, dst, self.keep_caps); + break; + case GP_BRUSH_ERASER_SOFT: + // To be implemented + return; + } - if (erased) { - /* Set the new geometry. */ - drawing.geometry.wrap() = std::move(dst); - drawing.tag_topology_changed(); - changed = true; - } - }; + if (erased) { + /* Set the new geometry. */ + drawing.geometry.wrap() = std::move(dst); + drawing.tag_topology_changed(); + changed = true; + } + }; if (self.active_layer_only) { /* Erase only on the drawing at the current frame of the active layer. */ @@ -810,7 +818,7 @@ struct EraseOperationExecutor { } else { /* Erase on all editable drawings. */ - const Vector drawings = + const Array drawings = ed::greasepencil::retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each( drawings, [&](const ed::greasepencil::MutableDrawingInfo &info) { diff --git a/source/blender/editors/sculpt_paint/grease_pencil_paint.cc b/source/blender/editors/sculpt_paint/grease_pencil_paint.cc index 1517f73ae68..d3611e4a90b 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_paint.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_paint.cc @@ -7,8 +7,10 @@ #include "BKE_colortools.hh" #include "BKE_context.hh" #include "BKE_curves.hh" +#include "BKE_grease_pencil.h" #include "BKE_grease_pencil.hh" #include "BKE_material.h" +#include "BKE_scene.h" #include "BLI_length_parameterize.hh" #include "BLI_math_color.h" @@ -144,7 +146,6 @@ struct PaintOperationExecutor { BrushGpencilSettings *settings_; float4 vertex_color_; - float hardness_; bke::greasepencil::Drawing *drawing_; @@ -169,8 +170,6 @@ struct PaintOperationExecutor { settings_->vertex_factor) : float4(0.0f); srgb_to_linearrgb_v4(vertex_color_, vertex_color_); - /* TODO: UI setting. */ - hardness_ = 1.0f; // const bool use_vertex_color_fill = use_vertex_color && ELEM( // brush->gpencil_settings->vertex_mode, GPPAINT_MODE_STROKE, GPPAINT_MODE_BOTH); @@ -234,17 +233,11 @@ struct PaintOperationExecutor { "material_index", bke::AttrDomain::Curve); bke::SpanAttributeWriter cyclic = attributes.lookup_or_add_for_write_span( "cyclic", bke::AttrDomain::Curve); - bke::SpanAttributeWriter hardnesses = attributes.lookup_or_add_for_write_span( - "hardness", - bke::AttrDomain::Curve, - bke::AttributeInitVArray(VArray::ForSingle(1.0f, curves.curves_num()))); cyclic.span.last() = false; materials.span.last() = material_index; - hardnesses.span.last() = hardness_; cyclic.finish(); materials.finish(); - hardnesses.finish(); curves.curve_types_for_write().last() = CURVE_TYPE_POLY; curves.update_curve_types(); @@ -256,7 +249,7 @@ struct PaintOperationExecutor { curves.points_range().take_back(1)); bke::fill_attribute_range_default(attributes, bke::AttrDomain::Curve, - {"curve_type", "material_index", "cyclic", "hardness"}, + {"curve_type", "material_index", "cyclic"}, curves.curves_range().take_back(1)); drawing_->tag_topology_changed(); @@ -431,12 +424,10 @@ struct PaintOperationExecutor { void PaintOperation::on_stroke_begin(const bContext &C, const InputSample &start_sample) { - Depsgraph *depsgraph = CTX_data_depsgraph_pointer(&C); ARegion *region = CTX_wm_region(&C); View3D *view3d = CTX_wm_view3d(&C); Scene *scene = CTX_data_scene(&C); Object *object = CTX_data_active_object(&C); - Object *eval_object = DEG_get_evaluated_object(depsgraph, object); GreasePencil *grease_pencil = static_cast(object->data); Paint *paint = &scene->toolsettings->gp_paint->paint; @@ -453,8 +444,7 @@ void PaintOperation::on_stroke_begin(const bContext &C, const InputSample &start BKE_curvemapping_init(brush->gpencil_settings->curve_rand_value); /* Initialize helper class for projecting screen space coordinates. */ - placement_ = ed::greasepencil::DrawingPlacement( - *scene, *region, *view3d, *eval_object, *grease_pencil->get_active_layer()); + placement_ = ed::greasepencil::DrawingPlacement(*scene, *region, *view3d, *object); if (placement_.use_project_to_surface()) { placement_.cache_viewport_depths(CTX_data_depsgraph_pointer(&C), region, view3d); } diff --git a/source/blender/editors/sculpt_paint/paint_cursor.cc b/source/blender/editors/sculpt_paint/paint_cursor.cc index ca9db0a0c16..8c5a37aece4 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.cc +++ b/source/blender/editors/sculpt_paint/paint_cursor.cc @@ -1098,7 +1098,7 @@ static void cursor_draw_tiling_preview(const uint gpuattr, for (int dim = 0; dim < 3; dim++) { location[dim] = cur[dim] * step[dim] + orgLoc[dim]; } - cursor_draw_point_screen_space(gpuattr, region, location, ob->object_to_world().ptr(), 3); + cursor_draw_point_screen_space(gpuattr, region, location, ob->object_to_world, 3); } } } @@ -1120,7 +1120,7 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr, /* Axis Symmetry. */ flip_v3_v3(location, true_location, ePaintSymmetryFlags(i)); - cursor_draw_point_screen_space(gpuattr, region, location, ob->object_to_world().ptr(), 3); + cursor_draw_point_screen_space(gpuattr, region, location, ob->object_to_world, 3); /* Tiling. */ cursor_draw_tiling_preview(gpuattr, region, location, sd, ob, radius); @@ -1135,8 +1135,7 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr, mul_m4_v3(symm_rot_mat, location); cursor_draw_tiling_preview(gpuattr, region, location, sd, ob, radius); - cursor_draw_point_screen_space( - gpuattr, region, location, ob->object_to_world().ptr(), 3); + cursor_draw_point_screen_space(gpuattr, region, location, ob->object_to_world, 3); } } } @@ -1377,7 +1376,7 @@ static void paint_cursor_update_pixel_radius(PaintCursorContext *pcontext) } copy_v3_v3(pcontext->scene_space_location, pcontext->location); - mul_m4_v3(pcontext->vc.obact->object_to_world().ptr(), pcontext->scene_space_location); + mul_m4_v3(pcontext->vc.obact->object_to_world, pcontext->scene_space_location); } else { Sculpt *sd = CTX_data_tool_settings(pcontext->C)->sculpt; @@ -1658,7 +1657,7 @@ static void paint_cursor_drawing_setup_cursor_space(PaintCursorContext *pcontext float cursor_trans[4][4], cursor_rot[4][4]; const float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f}; float quat[4]; - copy_m4_m4(cursor_trans, pcontext->vc.obact->object_to_world().ptr()); + copy_m4_m4(cursor_trans, pcontext->vc.obact->object_to_world); translate_m4(cursor_trans, pcontext->location[0], pcontext->location[1], pcontext->location[2]); rotation_between_vecs_to_quat(quat, z_axis, pcontext->normal); quat_to_mat4(cursor_rot, quat); @@ -1702,7 +1701,7 @@ static void paint_cursor_pose_brush_origins_draw(PaintCursorContext *pcontext) cursor_draw_point_screen_space(pcontext->pos, pcontext->region, ss->pose_ik_chain_preview->segments[i].initial_orig, - pcontext->vc.obact->object_to_world().ptr(), + pcontext->vc.obact->object_to_world, 3); } } @@ -1720,7 +1719,7 @@ static void paint_cursor_preview_boundary_data_pivot_draw(PaintCursorContext *pc pcontext->pos, pcontext->region, SCULPT_vertex_co_get(pcontext->ss, pcontext->ss->boundary_preview->pivot_vertex), - pcontext->vc.obact->object_to_world().ptr(), + pcontext->vc.obact->object_to_world, 3); } @@ -1829,7 +1828,7 @@ static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext * pcontext->pos, pcontext->region, SCULPT_vertex_co_get(pcontext->ss, pcontext->ss->expand_cache->initial_active_vertex), - pcontext->vc.obact->object_to_world().ptr(), + pcontext->vc.obact->object_to_world, 2); } @@ -1851,7 +1850,7 @@ static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext * nullptr); GPU_matrix_push(); - GPU_matrix_mul(pcontext->vc.obact->object_to_world().ptr()); + GPU_matrix_mul(pcontext->vc.obact->object_to_world); /* Drawing Cursor overlays in 3D object space. */ if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_GRAB && @@ -1945,7 +1944,7 @@ static void paint_cursor_cursor_draw_3d_view_brush_cursor_active(PaintCursorCont nullptr, nullptr); GPU_matrix_push(); - GPU_matrix_mul(pcontext->vc.obact->object_to_world().ptr()); + GPU_matrix_mul(pcontext->vc.obact->object_to_world); /* Draw the special active cursors different tools may have. */ diff --git a/source/blender/editors/sculpt_paint/paint_curve.cc b/source/blender/editors/sculpt_paint/paint_curve.cc index 107ded2d8f0..7c5e0c34a6e 100644 --- a/source/blender/editors/sculpt_paint/paint_curve.cc +++ b/source/blender/editors/sculpt_paint/paint_curve.cc @@ -19,9 +19,10 @@ #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" +#include "BKE_main.hh" #include "BKE_paint.hh" #include "ED_paint.hh" diff --git a/source/blender/editors/sculpt_paint/paint_curve_undo.cc b/source/blender/editors/sculpt_paint/paint_curve_undo.cc index cf4fa3649d3..b33cfbee5e4 100644 --- a/source/blender/editors/sculpt_paint/paint_curve_undo.cc +++ b/source/blender/editors/sculpt_paint/paint_curve_undo.cc @@ -12,6 +12,7 @@ #include "DNA_brush_types.h" +#include "BKE_context.hh" #include "BKE_paint.hh" #include "BKE_undo_system.hh" diff --git a/source/blender/editors/sculpt_paint/paint_image.cc b/source/blender/editors/sculpt_paint/paint_image.cc index f6b79b5bd27..472f9687958 100644 --- a/source/blender/editors/sculpt_paint/paint_image.cc +++ b/source/blender/editors/sculpt_paint/paint_image.cc @@ -18,7 +18,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" @@ -42,7 +42,7 @@ #include "BKE_node_runtime.hh" #include "BKE_object.hh" #include "BKE_paint.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "NOD_texture.h" @@ -859,7 +859,7 @@ void paint_init_pivot(Object *ob, Scene *scene) return; } - mul_m4_v3(ob->object_to_world().ptr(), location); + mul_m4_v3(ob->object_to_world, location); ups->last_stroke_valid = true; ups->average_stroke_counter = 1; diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.cc b/source/blender/editors/sculpt_paint/paint_image_2d.cc index f8f2735aa5f..4ec5527136d 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.cc +++ b/source/blender/editors/sculpt_paint/paint_image_2d.cc @@ -26,7 +26,7 @@ #include "BKE_context.hh" #include "BKE_image.h" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.cc b/source/blender/editors/sculpt_paint/paint_image_proj.cc index 3876ec8c77e..17eee751a2a 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.cc +++ b/source/blender/editors/sculpt_paint/paint_image_proj.cc @@ -35,7 +35,7 @@ #include "atomic_ops.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "IMB_imbuf.hh" #include "IMB_interp.hh" @@ -57,7 +57,7 @@ #include "BKE_colortools.hh" #include "BKE_context.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_image.h" #include "BKE_layer.hh" @@ -71,8 +71,8 @@ #include "BKE_node_runtime.hh" #include "BKE_object.hh" #include "BKE_paint.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "DNA_screen_types.h" #include "DNA_space_types.h" @@ -3690,7 +3690,7 @@ static void proj_paint_state_viewport_init(ProjPaintState *ps, const char symmet ps->viewDir[1] = 0.0f; ps->viewDir[2] = 1.0f; - copy_m4_m4(ps->obmat, ps->ob->object_to_world().ptr()); + copy_m4_m4(ps->obmat, ps->ob->object_to_world); if (symmetry_flag) { int i; @@ -3712,9 +3712,7 @@ static void proj_paint_state_viewport_init(ProjPaintState *ps, const char symmet copy_m4_m4(viewmat, ps->rv3d->viewmat); copy_m4_m4(viewinv, ps->rv3d->viewinv); - blender::float4x4 projection = ED_view3d_ob_project_mat_get_from_obmat( - ps->rv3d, blender::float4x4(ps->obmat)); - copy_m4_m4(ps->projectMat, projection.ptr()); + ED_view3d_ob_project_mat_get_from_obmat(ps->rv3d, ps->obmat, ps->projectMat); ps->is_ortho = ED_view3d_clip_range_get( ps->depsgraph, ps->v3d, ps->rv3d, &ps->clip_start, &ps->clip_end, true); @@ -3750,7 +3748,7 @@ static void proj_paint_state_viewport_init(ProjPaintState *ps, const char symmet CameraParams params; /* viewmat & viewinv */ - copy_m4_m4(viewinv, cam_ob_eval->object_to_world().ptr()); + copy_m4_m4(viewinv, cam_ob_eval->object_to_world); normalize_m4(viewinv); invert_m4_m4(viewmat, viewinv); @@ -4495,7 +4493,7 @@ static void project_paint_begin(const bContext *C, if (ps->source == PROJ_SRC_VIEW) { /* faster clipping lookups */ - ED_view3d_clipping_local(ps->rv3d, ps->ob->object_to_world().ptr()); + ED_view3d_clipping_local(ps->rv3d, ps->ob->object_to_world); } ps->do_face_sel = ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_FACE_SEL) != 0); diff --git a/source/blender/editors/sculpt_paint/paint_mask.cc b/source/blender/editors/sculpt_paint/paint_mask.cc index a4bd5805791..99272543602 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.cc +++ b/source/blender/editors/sculpt_paint/paint_mask.cc @@ -38,7 +38,7 @@ #include "BKE_multires.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_subdiv_ccg.hh" #include "BKE_subsurf.hh" @@ -695,7 +695,7 @@ static void sculpt_gesture_context_init_common(bContext *C, copy_m3_m4(mat, sgcontext->vc.rv3d->viewinv); mul_m3_v3(mat, view_dir); normalize_v3_v3(sgcontext->world_space_view_normal, view_dir); - copy_m3_m4(mat, ob->world_to_object().ptr()); + copy_m3_m4(mat, ob->world_to_object); mul_m3_v3(mat, view_dir); normalize_v3_v3(sgcontext->true_view_normal, view_dir); @@ -807,12 +807,12 @@ static void sculpt_gesture_line_plane_from_tri(float *r_plane, { float normal[3]; normal_tri_v3(normal, p1, p2, p3); - mul_v3_mat3_m4v3(normal, sgcontext->vc.obact->world_to_object().ptr(), normal); + mul_v3_mat3_m4v3(normal, sgcontext->vc.obact->world_to_object, normal); if (flip) { mul_v3_fl(normal, -1.0f); } float plane_point_object_space[3]; - mul_v3_m4v3(plane_point_object_space, sgcontext->vc.obact->world_to_object().ptr(), p1); + mul_v3_m4v3(plane_point_object_space, sgcontext->vc.obact->world_to_object, p1); plane_from_point_normal_v3(r_plane, plane_point_object_space, normal); } @@ -1422,20 +1422,18 @@ static void sculpt_gesture_trim_shape_origin_normal_get(SculptGestureContext *sg */ switch (trim_operation->orientation) { case SCULPT_GESTURE_TRIM_ORIENTATION_VIEW: - mul_v3_m4v3(r_origin, - sgcontext->vc.obact->object_to_world().ptr(), - sgcontext->ss->gesture_initial_location); + mul_v3_m4v3( + r_origin, sgcontext->vc.obact->object_to_world, sgcontext->ss->gesture_initial_location); copy_v3_v3(r_normal, sgcontext->world_space_view_normal); negate_v3(r_normal); break; case SCULPT_GESTURE_TRIM_ORIENTATION_SURFACE: - mul_v3_m4v3(r_origin, - sgcontext->vc.obact->object_to_world().ptr(), - sgcontext->ss->gesture_initial_location); + mul_v3_m4v3( + r_origin, sgcontext->vc.obact->object_to_world, sgcontext->ss->gesture_initial_location); /* Transforming the normal does not take non uniform scaling into account. Sculpt mode is not * expected to work on object with non uniform scaling. */ copy_v3_v3(r_normal, sgcontext->ss->gesture_initial_normal); - mul_mat3_m4_v3(sgcontext->vc.obact->object_to_world().ptr(), r_normal); + mul_mat3_m4_v3(sgcontext->vc.obact->object_to_world, r_normal); break; } } @@ -1466,7 +1464,7 @@ static void sculpt_gesture_trim_calculate_depth(SculptGestureContext *sgcontext) * mesh, coordinates are first calculated in world space, then converted to object space to * store them. */ float world_space_vco[3]; - mul_v3_m4v3(world_space_vco, vc->obact->object_to_world().ptr(), vco); + mul_v3_m4v3(world_space_vco, vc->obact->object_to_world, vco); const float dist = dist_signed_to_plane_v3(world_space_vco, shape_plane); trim_operation->depth_front = min_ff(dist, trim_operation->depth_front); trim_operation->depth_back = max_ff(dist, trim_operation->depth_back); @@ -1475,7 +1473,7 @@ static void sculpt_gesture_trim_calculate_depth(SculptGestureContext *sgcontext) if (trim_operation->use_cursor_depth) { float world_space_gesture_initial_location[3]; mul_v3_m4v3(world_space_gesture_initial_location, - vc->obact->object_to_world().ptr(), + vc->obact->object_to_world, ss->gesture_initial_location); float mid_point_depth; @@ -1559,7 +1557,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex sculpt_gesture_trim_shape_origin_normal_get(sgcontext, shape_origin, shape_normal); plane_from_point_normal_v3(shape_plane, shape_origin, shape_normal); - const float(*ob_imat)[4] = vc->obact->world_to_object().ptr(); + const float(*ob_imat)[4] = vc->obact->world_to_object; /* Write vertices coordinatesSCULPT_GESTURE_TRIM_DIFFERENCE for the front face. */ MutableSpan positions = trim_operation->mesh->vert_positions_for_write(); diff --git a/source/blender/editors/sculpt_paint/paint_ops.cc b/source/blender/editors/sculpt_paint/paint_ops.cc index 63c89aee326..2a7028a2aab 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.cc +++ b/source/blender/editors/sculpt_paint/paint_ops.cc @@ -17,6 +17,8 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BLT_translation.h" + #include "IMB_interp.hh" #include "DNA_brush_types.h" @@ -30,7 +32,7 @@ #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "ED_image.hh" #include "ED_paint.hh" diff --git a/source/blender/editors/sculpt_paint/paint_stroke.cc b/source/blender/editors/sculpt_paint/paint_stroke.cc index 6bde9707c8b..48ce84c1346 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.cc +++ b/source/blender/editors/sculpt_paint/paint_stroke.cc @@ -12,6 +12,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_rand.hh" #include "BLI_utildefines.h" @@ -550,7 +551,7 @@ static void paint_brush_stroke_add_step( C, world_space_position, stroke->last_mouse_position, stroke->original)) { copy_v3_v3(stroke->last_world_space_position, world_space_position); - mul_m4_v3(stroke->vc.obact->object_to_world().ptr(), stroke->last_world_space_position); + mul_m4_v3(stroke->vc.obact->object_to_world, stroke->last_world_space_position); } else { add_v3_v3(stroke->last_world_space_position, stroke->last_scene_spacing_delta); @@ -668,7 +669,7 @@ static float paint_space_stroke_spacing(bContext *C, if (!BKE_brush_use_locked_size(scene, brush)) { float last_object_space_position[3]; mul_v3_m4v3(last_object_space_position, - stroke->vc.obact->world_to_object().ptr(), + stroke->vc.obact->world_to_object, stroke->last_world_space_position); size_clamp = paint_calc_object_space_radius(&stroke->vc, last_object_space_position, size); } @@ -818,7 +819,7 @@ static int paint_space_stroke(bContext *C, if (use_scene_spacing) { float world_space_position[3]; bool hit = SCULPT_stroke_get_location(C, world_space_position, final_mouse, stroke->original); - mul_m4_v3(stroke->vc.obact->object_to_world().ptr(), world_space_position); + mul_m4_v3(stroke->vc.obact->object_to_world, world_space_position); if (hit && stroke->stroke_over_mesh) { sub_v3_v3v3(d_world_space_position, world_space_position, stroke->last_world_space_position); length = len_v3(d_world_space_position); @@ -1224,8 +1225,8 @@ static void paint_line_strokes_spacing(bContext *C, C, world_space_position_old, old_pos, stroke->original); bool hit_new = SCULPT_stroke_get_location( C, world_space_position_new, new_pos, stroke->original); - mul_m4_v3(stroke->vc.obact->object_to_world().ptr(), world_space_position_old); - mul_m4_v3(stroke->vc.obact->object_to_world().ptr(), world_space_position_new); + mul_m4_v3(stroke->vc.obact->object_to_world, world_space_position_old); + mul_m4_v3(stroke->vc.obact->object_to_world, world_space_position_new); if (hit_old && hit_new && stroke->stroke_over_mesh) { sub_v3_v3v3(d_world_space_position, world_space_position_new, world_space_position_old); length = len_v3(d_world_space_position); @@ -1369,8 +1370,7 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str if (paint_stroke_use_scene_spacing(br, BKE_paintmode_get_active_from_context(C))) { stroke->stroke_over_mesh = SCULPT_stroke_get_location( C, stroke->last_world_space_position, data + 2 * j, stroke->original); - mul_m4_v3(stroke->vc.obact->object_to_world().ptr(), - stroke->last_world_space_position); + mul_m4_v3(stroke->vc.obact->object_to_world, stroke->last_world_space_position); } stroke->stroke_started = stroke->test_start(C, op, stroke->last_mouse_position); @@ -1504,7 +1504,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event, PaintS if (paint_stroke_use_scene_spacing(br, mode)) { stroke->stroke_over_mesh = SCULPT_stroke_get_location( C, stroke->last_world_space_position, sample_average.mouse, stroke->original); - mul_m4_v3(stroke->vc.obact->object_to_world().ptr(), stroke->last_world_space_position); + mul_m4_v3(stroke->vc.obact->object_to_world, stroke->last_world_space_position); } stroke->stroke_started = stroke->test_start(C, op, sample_average.mouse); diff --git a/source/blender/editors/sculpt_paint/paint_utils.cc b/source/blender/editors/sculpt_paint/paint_utils.cc index 3b3f5e7f512..e7980ea4a14 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.cc +++ b/source/blender/editors/sculpt_paint/paint_utils.cc @@ -23,7 +23,7 @@ #include "BLI_rect.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_brush.hh" #include "BKE_colortools.hh" @@ -33,9 +33,10 @@ #include "BKE_layer.hh" #include "BKE_material.h" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_object.hh" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" @@ -44,9 +45,12 @@ #include "RNA_define.hh" #include "RNA_prototypes.h" +#include "GPU_framebuffer.h" #include "GPU_matrix.h" #include "GPU_state.h" +#include "GPU_texture.h" +#include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" #include "IMB_interp.hh" @@ -133,12 +137,12 @@ float paint_calc_object_space_radius(ViewContext *vc, const float center[3], flo float delta[3], scale, loc[3]; const float xy_delta[2] = {pixel_radius, 0.0f}; - mul_v3_m4v3(loc, ob->object_to_world().ptr(), center); + mul_v3_m4v3(loc, ob->object_to_world, center); const float zfac = ED_view3d_calc_zfac(vc->rv3d, loc); ED_view3d_win_to_delta(vc->region, xy_delta, zfac, delta); - scale = fabsf(mat4_to_scale(ob->object_to_world().ptr())); + scale = fabsf(mat4_to_scale(ob->object_to_world)); scale = (scale == 0.0f) ? 1.0f : scale; return len_v3(delta) / scale; @@ -284,7 +288,7 @@ static void imapaint_pick_uv(const Mesh *me_eval, GPU_matrix_model_view_get(matrix); GPU_matrix_projection_get(proj); view[0] = view[1] = 0; - mul_m4_m4m4(matrix, matrix, ob_eval->object_to_world().ptr()); + mul_m4_m4m4(matrix, matrix, ob_eval->object_to_world); mul_m4_m4m4(matrix, proj, matrix); minabsw = 1e10; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index 9527dc6091e..ebccb4b6f21 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -47,9 +47,8 @@ #include "BKE_mesh_mapping.hh" #include "BKE_object.hh" #include "BKE_object_deform.h" -#include "BKE_object_types.hh" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" @@ -405,7 +404,7 @@ void mode_exit_generic(Object *ob, const eObjectMode mode_flag) bool mode_toggle_poll_test(bContext *C) { Object *ob = CTX_data_active_object(C); - if (ob == nullptr || !ELEM(ob->type, OB_MESH, OB_GREASE_PENCIL)) { + if (ob == nullptr || ob->type != OB_MESH) { return false; } if (!ob->data || ID_IS_LINKED(ob->data)) { @@ -487,10 +486,10 @@ void update_cache_invariants( /* cache projection matrix */ cache->projection_mat = ED_view3d_ob_project_mat_get(cache->vc->rv3d, ob); - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); copy_m3_m4(mat, cache->vc->rv3d->viewinv); mul_m3_v3(mat, view_dir); - copy_m3_m4(mat, ob->world_to_object().ptr()); + copy_m3_m4(mat, ob->world_to_object); mul_m3_v3(mat, view_dir); normalize_v3_v3(cache->true_view_normal, view_dir); @@ -1922,7 +1921,7 @@ static void vpaint_stroke_update_step(bContext *C, ED_view3d_init_mats_rv3d(ob, vc->rv3d); /* load projection matrix */ - mul_m4_m4m4(mat, vc->rv3d->persmat, ob->object_to_world().ptr()); + mul_m4_m4m4(mat, vc->rv3d->persmat, ob->object_to_world); swap_m4m4(vc->rv3d->persmat, mat); @@ -1939,7 +1938,7 @@ static void vpaint_stroke_update_step(bContext *C, /* Calculate pivot for rotation around selection if needed. * also needed for "Frame Selected" on last stroke. */ float loc_world[3]; - mul_v3_m4v3(loc_world, ob->object_to_world().ptr(), ss->cache->true_location); + mul_v3_m4v3(loc_world, ob->object_to_world, ss->cache->true_location); vwpaint::last_stroke_update(scene, loc_world); ED_region_tag_redraw(vc->region); diff --git a/source/blender/editors/sculpt_paint/paint_vertex_proj.cc b/source/blender/editors/sculpt_paint/paint_vertex_proj.cc index fa5f570e364..40dff35e97c 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_proj.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex_proj.cc @@ -14,7 +14,10 @@ #include "DNA_mesh_types.h" #include "DNA_object_types.h" +#include "BKE_context.hh" +#include "BKE_customdata.hh" #include "BKE_mesh_iterators.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_object.hh" #include "BLI_math_vector.h" @@ -22,6 +25,7 @@ #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" +#include "ED_screen.hh" #include "ED_view3d.hh" #include "paint_intern.hh" /* own include */ diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.cc b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.cc index 1c2d2062a28..5fad5b07c6d 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.cc @@ -20,6 +20,7 @@ #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "BKE_attribute.hh" #include "BKE_brush.hh" @@ -28,11 +29,12 @@ #include "BKE_deform.hh" #include "BKE_mesh.hh" #include "BKE_mesh_iterators.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_deform.h" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.cc b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.cc index 2524fc08f09..7c88776c45b 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.cc @@ -22,7 +22,7 @@ #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_deform.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph_build.hh" diff --git a/source/blender/editors/sculpt_paint/paint_weight.cc b/source/blender/editors/sculpt_paint/paint_weight.cc index 2cfec9434dd..3958c42fcc0 100644 --- a/source/blender/editors/sculpt_paint/paint_weight.cc +++ b/source/blender/editors/sculpt_paint/paint_weight.cc @@ -43,7 +43,7 @@ #include "BKE_object.hh" #include "BKE_object_deform.h" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" @@ -1538,31 +1538,9 @@ static void wpaint_paint_leaves(bContext *C, /** \name Enter Weight Paint Mode * \{ */ -static void grease_pencil_wpaintmode_enter(Scene *scene, Object *ob) -{ - const PaintMode paint_mode = PaintMode::Weight; - Paint *weight_paint = BKE_paint_get_active_from_paintmode(scene, paint_mode); - BKE_paint_ensure(scene->toolsettings, &weight_paint); - - ob->mode |= OB_MODE_WEIGHT_PAINT; - - /* Flush object mode. */ - DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); -} - void ED_object_wpaintmode_enter_ex(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob) { - switch (ob->type) { - case OB_MESH: - vwpaint::mode_enter_generic(bmain, depsgraph, scene, ob, OB_MODE_WEIGHT_PAINT); - break; - case OB_GREASE_PENCIL: - grease_pencil_wpaintmode_enter(scene, ob); - break; - default: - BLI_assert_unreachable(); - break; - } + vwpaint::mode_enter_generic(bmain, depsgraph, scene, ob, OB_MODE_WEIGHT_PAINT); } void ED_object_wpaintmode_enter(bContext *C, Depsgraph *depsgraph) { @@ -1579,18 +1557,7 @@ void ED_object_wpaintmode_enter(bContext *C, Depsgraph *depsgraph) void ED_object_wpaintmode_exit_ex(Object *ob) { - switch (ob->type) { - case OB_MESH: - vwpaint::mode_exit_generic(ob, OB_MODE_WEIGHT_PAINT); - break; - case OB_GREASE_PENCIL: { - ob->mode &= ~OB_MODE_WEIGHT_PAINT; - break; - } - default: - BLI_assert_unreachable(); - break; - } + vwpaint::mode_exit_generic(ob, OB_MODE_WEIGHT_PAINT); } void ED_object_wpaintmode_exit(bContext *C) { @@ -1663,6 +1630,8 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) } } + Mesh *mesh = BKE_mesh_from_object(ob); + if (is_mode_set) { ED_object_wpaintmode_exit_ex(ob); } @@ -1678,15 +1647,12 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) /* Prepare armature posemode. */ ED_object_posemode_set_for_weight_paint(C, bmain, ob, is_mode_set); - if (ob->type == OB_MESH) { - /* Weight-paint works by overriding colors in mesh, - * so need to make sure we recalculate on enter and - * exit (exit needs doing regardless because we - * should re-deform). - */ - Mesh *mesh = BKE_mesh_from_object(ob); - DEG_id_tag_update(&mesh->id, 0); - } + /* Weight-paint works by overriding colors in mesh, + * so need to make sure we recalculate on enter and + * exit (exit needs doing regardless because we + * should re-deform). + */ + DEG_id_tag_update(&mesh->id, 0); WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene); @@ -1849,7 +1815,7 @@ static void wpaint_stroke_update_step(bContext *C, ED_view3d_init_mats_rv3d(ob, vc->rv3d); /* load projection matrix */ - mul_m4_m4m4(mat, vc->rv3d->persmat, ob->object_to_world().ptr()); + mul_m4_m4m4(mat, vc->rv3d->persmat, ob->object_to_world); Mesh *mesh = static_cast(ob->data); @@ -1887,7 +1853,7 @@ static void wpaint_stroke_update_step(bContext *C, /* Calculate pivot for rotation around selection if needed. * also needed for "Frame Selected" on last stroke. */ float loc_world[3]; - mul_v3_m4v3(loc_world, ob->object_to_world().ptr(), ss->cache->true_location); + mul_v3_m4v3(loc_world, ob->object_to_world, ss->cache->true_location); vwpaint::last_stroke_update(scene, loc_world); BKE_mesh_batch_cache_dirty_tag(mesh, BKE_MESH_BATCH_DIRTY_ALL); diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index d737cd0f899..56b12ce6716 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -56,8 +56,8 @@ #include "BKE_object_types.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_subdiv_ccg.hh" #include "BKE_subsurf.hh" #include "BLI_math_vector.hh" @@ -69,7 +69,6 @@ #include "WM_api.hh" #include "WM_types.hh" -#include "ED_gpencil_legacy.hh" #include "ED_paint.hh" #include "ED_screen.hh" #include "ED_sculpt.hh" @@ -2687,14 +2686,14 @@ static void calc_local_from_screen(ViewContext *vc, Object *ob = vc->obact; float loc[3]; - mul_v3_m4v3(loc, ob->object_to_world().ptr(), center); + mul_v3_m4v3(loc, ob->object_to_world, center); const float zfac = ED_view3d_calc_zfac(vc->rv3d, loc); ED_view3d_win_to_delta(vc->region, screen_dir, zfac, r_local_dir); normalize_v3(r_local_dir); add_v3_v3(r_local_dir, ob->loc); - mul_m4_v3(ob->world_to_object().ptr(), r_local_dir); + mul_m4_v3(ob->world_to_object, r_local_dir); } static void calc_brush_local_mat(const float rotation, @@ -2709,7 +2708,7 @@ static void calc_brush_local_mat(const float rotation, float angle, v[3]; /* Ensure `ob->world_to_object` is up to date. */ - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); /* Initialize last column of matrix. */ mat[0][3] = 0.0f; @@ -2773,13 +2772,13 @@ void SCULPT_tilt_apply_to_normal(float r_normal[3], return; } const float rot_max = M_PI_2 * tilt_strength * SCULPT_TILT_SENSITIVITY; - mul_v3_mat3_m4v3(r_normal, cache->vc->obact->object_to_world().ptr(), r_normal); + mul_v3_mat3_m4v3(r_normal, cache->vc->obact->object_to_world, r_normal); float normal_tilt_y[3]; rotate_v3_v3v3fl(normal_tilt_y, r_normal, cache->vc->rv3d->viewinv[0], cache->y_tilt * rot_max); float normal_tilt_xy[3]; rotate_v3_v3v3fl( normal_tilt_xy, normal_tilt_y, cache->vc->rv3d->viewinv[1], cache->x_tilt * rot_max); - mul_v3_mat3_m4v3(r_normal, cache->vc->obact->world_to_object().ptr(), normal_tilt_xy); + mul_v3_mat3_m4v3(r_normal, cache->vc->obact->world_to_object, normal_tilt_xy); normalize_v3(r_normal); } @@ -3240,7 +3239,7 @@ static void sculpt_topology_update(Sculpt *sd, /* Update average stroke position. */ copy_v3_v3(location, ss->cache->true_location); - mul_m4_v3(ob->object_to_world().ptr(), location); + mul_m4_v3(ob->object_to_world, location); } static void do_brush_action_task(Object *ob, const Brush *brush, PBVHNode *node) @@ -3571,7 +3570,7 @@ static void do_brush_action(Sculpt *sd, /* Update average stroke position. */ copy_v3_v3(location, ss->cache->true_location); - mul_m4_v3(ob->object_to_world().ptr(), location); + mul_m4_v3(ob->object_to_world, location); add_v3_v3(ups->average_stroke_accum, location); ups->average_stroke_counter++; @@ -3959,7 +3958,7 @@ bool SCULPT_mode_poll(bContext *C) bool SCULPT_mode_poll_view3d(bContext *C) { - return (SCULPT_mode_poll(C) && CTX_wm_region_view3d(C) && !ED_gpencil_session_active()); + return (SCULPT_mode_poll(C) && CTX_wm_region_view3d(C)); } bool SCULPT_poll(bContext *C) @@ -4103,8 +4102,8 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss) /* Store matrix for mirror object clipping. */ if (mmd->mirror_ob) { float imtx_mirror_ob[4][4]; - invert_m4_m4(imtx_mirror_ob, mmd->mirror_ob->object_to_world().ptr()); - mul_m4_m4m4(ss->cache->clip_mirror_mtx.ptr(), imtx_mirror_ob, ob->object_to_world().ptr()); + invert_m4_m4(imtx_mirror_ob, mmd->mirror_ob->object_to_world); + mul_m4_m4m4(ss->cache->clip_mirror_mtx.ptr(), imtx_mirror_ob, ob->object_to_world); } } } @@ -4271,10 +4270,10 @@ static void sculpt_update_cache_invariants( /* Cache projection matrix. */ cache->projection_mat = ED_view3d_ob_project_mat_get(cache->vc->rv3d, ob); - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); copy_m3_m4(mat, cache->vc->rv3d->viewinv); mul_m3_v3(mat, viewDir); - copy_m3_m4(mat, ob->world_to_object().ptr()); + copy_m3_m4(mat, ob->world_to_object); mul_m3_v3(mat, viewDir); normalize_v3_v3(cache->true_view_normal, viewDir); @@ -4290,7 +4289,7 @@ static void sculpt_update_cache_invariants( if (sd->gravity_object) { Object *gravity_object = sd->gravity_object; - copy_v3_v3(cache->true_gravity_direction, gravity_object->object_to_world().ptr()[2]); + copy_v3_v3(cache->true_gravity_direction, gravity_object->object_to_world[2]); } else { cache->true_gravity_direction[0] = cache->true_gravity_direction[1] = 0.0f; @@ -4450,27 +4449,27 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru } /* Compute 3d coordinate at same z from original location + mval. */ - mul_v3_m4v3(loc, ob->object_to_world().ptr(), cache->orig_grab_location); + mul_v3_m4v3(loc, ob->object_to_world, cache->orig_grab_location); ED_view3d_win_to_3d(cache->vc->v3d, cache->vc->region, loc, mval, grab_location); /* Compute delta to move verts by. */ if (!SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache)) { if (sculpt_needs_delta_from_anchored_origin(brush)) { sub_v3_v3v3(delta, grab_location, cache->old_grab_location); - invert_m4_m4(imat, ob->object_to_world().ptr()); + invert_m4_m4(imat, ob->object_to_world); mul_mat3_m4_v3(imat, delta); add_v3_v3(cache->grab_delta, delta); } else if (sculpt_needs_delta_for_tip_orientation(brush)) { if (brush->flag & BRUSH_ANCHORED) { float orig[3]; - mul_v3_m4v3(orig, ob->object_to_world().ptr(), cache->orig_grab_location); + mul_v3_m4v3(orig, ob->object_to_world, cache->orig_grab_location); sub_v3_v3v3(cache->grab_delta, grab_location, orig); } else { sub_v3_v3v3(cache->grab_delta, grab_location, cache->old_grab_location); } - invert_m4_m4(imat, ob->object_to_world().ptr()); + invert_m4_m4(imat, ob->object_to_world); mul_mat3_m4_v3(imat, cache->grab_delta); } else { @@ -4515,7 +4514,7 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru /* Handle 'rake' */ cache->is_rake_rotation_valid = false; - invert_m4_m4(imat, ob->object_to_world().ptr()); + invert_m4_m4(imat, ob->object_to_world); mul_mat3_m4_v3(imat, grab_location); if (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache)) { @@ -4852,7 +4851,7 @@ float SCULPT_raycast_init(ViewContext *vc, ED_view3d_win_to_segment_clipped( vc->depsgraph, vc->region, vc->v3d, mval, ray_start, ray_end, true); - invert_m4_m4(obimat, ob->object_to_world().ptr()); + invert_m4_m4(obimat, ob->object_to_world); mul_m4_v3(obimat, ray_start); mul_m4_v3(obimat, ray_end); @@ -4977,10 +4976,10 @@ bool SCULPT_cursor_geometry_info_update(bContext *C, float radius; /* Update cursor data in SculptSession. */ - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); copy_m3_m4(mat, vc.rv3d->viewinv); mul_m3_v3(mat, viewDir); - copy_m3_m4(mat, ob->world_to_object().ptr()); + copy_m3_m4(mat, ob->world_to_object); mul_m3_v3(mat, viewDir); normalize_v3_v3(ss->cursor_view_normal, viewDir); copy_v3_v3(ss->cursor_normal, srd.face_normal); @@ -5514,7 +5513,7 @@ static void sculpt_stroke_update_step(bContext *C, if (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)) { float object_space_constant_detail = 1.0f / (sd->constant_detail * - mat4_to_scale(ob->object_to_world().ptr())); + mat4_to_scale(ob->object_to_world)); BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail); } else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) { diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc b/source/blender/editors/sculpt_paint/sculpt_automasking.cc index 78b2598c8cc..6ac743f0dbc 100644 --- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc +++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc @@ -9,6 +9,7 @@ #include "MEM_guardedalloc.h" #include "BLI_array.hh" +#include "BLI_blenlib.h" #include "BLI_hash.h" #include "BLI_index_range.hh" #include "BLI_math_base_safe.h" @@ -18,13 +19,32 @@ #include "DNA_brush_types.h" +#include "BKE_brush.hh" #include "BKE_colortools.hh" +#include "BKE_context.hh" +#include "BKE_mesh.hh" +#include "BKE_mesh_mapping.hh" +#include "BKE_object.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" +#include "BKE_scene.h" +#include "DEG_depsgraph.hh" + +#include "WM_api.hh" +#include "WM_message.hh" +#include "WM_toolsystem.hh" +#include "WM_types.hh" + +#include "ED_object.hh" +#include "ED_screen.hh" +#include "ED_sculpt.hh" #include "paint_intern.hh" #include "sculpt_intern.hh" +#include "RNA_access.hh" +#include "RNA_define.hh" + #include "bmesh.hh" #include diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.cc b/source/blender/editors/sculpt_paint/sculpt_boundary.cc index 161f8cc43f3..5f80fed3f46 100644 --- a/source/blender/editors/sculpt_paint/sculpt_boundary.cc +++ b/source/blender/editors/sculpt_paint/sculpt_boundary.cc @@ -16,6 +16,7 @@ #include "BKE_brush.hh" #include "BKE_ccg.h" #include "BKE_colortools.hh" +#include "BKE_context.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" diff --git a/source/blender/editors/sculpt_paint/sculpt_brush_types.cc b/source/blender/editors/sculpt_paint/sculpt_brush_types.cc index ac4b955853d..4e58d7a45b9 100644 --- a/source/blender/editors/sculpt_paint/sculpt_brush_types.cc +++ b/source/blender/editors/sculpt_paint/sculpt_brush_types.cc @@ -20,12 +20,14 @@ #include "DNA_brush_types.h" #include "DNA_customdata_types.h" +#include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "BKE_brush.hh" #include "BKE_ccg.h" #include "BKE_colortools.hh" +#include "BKE_context.hh" #include "BKE_kelvinlet.h" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.cc b/source/blender/editors/sculpt_paint/sculpt_cloth.cc index 052319187fe..f693f655934 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.cc +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.cc @@ -670,15 +670,14 @@ static void cloth_brush_solve_collision(Object *object, SimulationData *cloth_si BVHTreeRayHit hit; float obmat_inv[4][4]; - invert_m4_m4(obmat_inv, object->object_to_world().ptr()); + invert_m4_m4(obmat_inv, object->object_to_world); LISTBASE_FOREACH (ColliderCache *, collider_cache, cloth_sim->collider_list) { float ray_start[3], ray_normal[3]; float pos_world_space[3], prev_pos_world_space[3]; - mul_v3_m4v3(pos_world_space, object->object_to_world().ptr(), cloth_sim->pos[i]); - mul_v3_m4v3( - prev_pos_world_space, object->object_to_world().ptr(), cloth_sim->last_iteration_pos[i]); + mul_v3_m4v3(pos_world_space, object->object_to_world, cloth_sim->pos[i]); + mul_v3_m4v3(prev_pos_world_space, object->object_to_world, cloth_sim->last_iteration_pos[i]); sub_v3_v3v3(ray_normal, pos_world_space, prev_pos_world_space); copy_v3_v3(ray_start, prev_pos_world_space); hit.index = -1; @@ -1390,7 +1389,7 @@ static void cloth_filter_apply_forces_task(Object *ob, float sculpt_gravity[3] = {0.0f}; if (sd->gravity_object) { - copy_v3_v3(sculpt_gravity, sd->gravity_object->object_to_world().ptr()[2]); + copy_v3_v3(sculpt_gravity, sd->gravity_object->object_to_world[2]); } else { sculpt_gravity[2] = -1.0f; diff --git a/source/blender/editors/sculpt_paint/sculpt_detail.cc b/source/blender/editors/sculpt_paint/sculpt_detail.cc index 975a4a6a4c7..05a9b33dfee 100644 --- a/source/blender/editors/sculpt_paint/sculpt_detail.cc +++ b/source/blender/editors/sculpt_paint/sculpt_detail.cc @@ -14,7 +14,7 @@ #include "BLI_math_vector.hh" #include "BLI_time.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_brush_types.h" #include "DNA_mesh_types.h" @@ -109,14 +109,14 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *op) const float size = math::reduce_max(dim); /* Update topology size. */ - float object_space_constant_detail = 1.0f / (sd->constant_detail * - mat4_to_scale(ob->object_to_world().ptr())); + float object_space_constant_detail = 1.0f / + (sd->constant_detail * mat4_to_scale(ob->object_to_world)); BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail); undo::push_begin(ob, op); undo::push_node(ob, nullptr, undo::Type::Position); - const double start_time = BLI_time_now_seconds(); + const double start_time = BLI_check_seconds_timer(); while (bke::pbvh::bmesh_update_topology( ss->pbvh, PBVH_Collapse | PBVH_Subdivide, center, nullptr, size, false, false)) @@ -126,7 +126,7 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *op) } } - CLOG_INFO(&LOG, 2, "Detail flood fill took %f seconds.", BLI_time_now_seconds() - start_time); + CLOG_INFO(&LOG, 2, "Detail flood fill took %f seconds.", BLI_check_seconds_timer() - start_time); undo::push_end(ob); @@ -240,7 +240,7 @@ static void sample_detail_dyntopo(bContext *C, ViewContext *vc, const int mval[2 if (srd.hit && srd.edge_length > 0.0f) { /* Convert edge length to world space detail resolution. */ - sd->constant_detail = 1 / (srd.edge_length * mat4_to_scale(ob->object_to_world().ptr())); + sd->constant_detail = 1 / (srd.edge_length * mat4_to_scale(ob->object_to_world)); } } @@ -495,9 +495,8 @@ static void dyntopo_detail_size_parallel_lines_draw(uint pos3d, bool flip, const float angle) { - float object_space_constant_detail = 1.0f / - (cd->detail_size * - mat4_to_scale(cd->active_object->object_to_world().ptr())); + float object_space_constant_detail = 1.0f / (cd->detail_size * + mat4_to_scale(cd->active_object->object_to_world)); /* The constant detail represents the maximum edge length allowed before subdividing it. If the * triangle grid preview is created with this value it will represent an ideal mesh density where @@ -614,8 +613,8 @@ static void dyntopo_detail_size_sample_from_surface(Object *ob, if (num_neighbors > 0) { const float avg_edge_len = len_accum / num_neighbors; /* Use 0.7 as the average of min and max dyntopo edge length. */ - const float detail_size = 0.7f / (avg_edge_len * - mat4_to_scale(cd->active_object->object_to_world().ptr())); + const float detail_size = 0.7f / + (avg_edge_len * mat4_to_scale(cd->active_object->object_to_world)); cd->detail_size = clamp_f(detail_size, 1.0f, 500.0f); } } @@ -741,7 +740,7 @@ static int dyntopo_detail_size_edit_invoke(bContext *C, wmOperator *op, const wm float cursor_trans[4][4], cursor_rot[4][4]; const float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f}; float quat[4]; - copy_m4_m4(cursor_trans, active_object->object_to_world().ptr()); + copy_m4_m4(cursor_trans, active_object->object_to_world); translate_m4( cursor_trans, ss->cursor_location[0], ss->cursor_location[1], ss->cursor_location[2]); diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.cc b/source/blender/editors/sculpt_paint/sculpt_dyntopo.cc index a7659d360f2..1d4d19a3d84 100644 --- a/source/blender/editors/sculpt_paint/sculpt_dyntopo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.cc @@ -11,12 +11,13 @@ #include "MEM_guardedalloc.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_modifier_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" +#include "BKE_main.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" @@ -24,7 +25,7 @@ #include "BKE_particle.h" #include "BKE_pbvh_api.hh" #include "BKE_pointcache.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BLI_index_range.hh" diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.cc b/source/blender/editors/sculpt_paint/sculpt_expand.cc index d86bd417ff7..e72f7ec97ca 100644 --- a/source/blender/editors/sculpt_paint/sculpt_expand.cc +++ b/source/blender/editors/sculpt_paint/sculpt_expand.cc @@ -16,6 +16,7 @@ #include "BLI_task.h" #include "DNA_brush_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "BKE_attribute.hh" @@ -26,11 +27,15 @@ #include "BKE_image.h" #include "BKE_layer.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_mapping.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_subdiv_ccg.hh" +#include "DEG_depsgraph.hh" + #include "WM_api.hh" #include "WM_types.hh" diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index 96566d81ea3..7e701a1d082 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -1115,7 +1115,7 @@ static int sculpt_face_set_change_visibility_exec(bContext *C, wmOperator *op) UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings; float location[3]; copy_v3_v3(location, SCULPT_active_vertex_co_get(ss)); - mul_m4_v3(object.object_to_world().ptr(), location); + mul_m4_v3(object.object_to_world, location); copy_v3_v3(ups->average_stroke_accum, location); ups->average_stroke_counter = 1; ups->last_stroke_valid = true; diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_color.cc b/source/blender/editors/sculpt_paint/sculpt_filter_color.cc index 9876e011184..743658151f6 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_color.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_color.cc @@ -13,7 +13,7 @@ #include "BLI_math_vector.hh" #include "BLI_task.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_userdef_types.h" @@ -24,6 +24,8 @@ #include "IMB_colormanagement.hh" +#include "DEG_depsgraph.hh" + #include "WM_api.hh" #include "WM_types.hh" diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc b/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc index d9e3d9f7ba3..28be463b2a3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc @@ -10,10 +10,16 @@ #include "BLI_task.h" +#include "DNA_mesh_types.h" +#include "DNA_modifier_types.h" + #include "BKE_context.hh" #include "BKE_layer.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" +#include "BKE_scene.h" + +#include "DEG_depsgraph.hh" #include "WM_api.hh" #include "WM_types.hh" diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc index a4d5e7308fc..614878d9be7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc @@ -6,8 +6,7 @@ * \ingroup edsculpt */ -#include - +#include "DNA_modifier_types.h" #include "DNA_windowmanager_types.h" #include "MEM_guardedalloc.h" @@ -18,23 +17,26 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" #include "BLI_math_vector_types.hh" +#include "BLI_string.h" #include "BLI_task.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_brush.hh" #include "BKE_context.hh" #include "BKE_layer.hh" #include "BKE_modifier.hh" -#include "BKE_object_types.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" +#include "DEG_depsgraph.hh" + #include "WM_api.hh" #include "WM_types.hh" #include "ED_screen.hh" #include "ED_sculpt.hh" +#include "ED_util.hh" #include "ED_view3d.hh" #include "paint_intern.hh" @@ -134,8 +136,8 @@ void cache_init(bContext *C, } /* Setup orientation matrices. */ - copy_m4_m4(ss->filter_cache->obmat.ptr(), ob->object_to_world().ptr()); - invert_m4_m4(ss->filter_cache->obmat_inv.ptr(), ob->object_to_world().ptr()); + copy_m4_m4(ss->filter_cache->obmat.ptr(), ob->object_to_world); + invert_m4_m4(ss->filter_cache->obmat_inv.ptr(), ob->object_to_world); Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewContext vc = ED_view3d_viewcontext_init(C, depsgraph); @@ -187,7 +189,7 @@ void cache_init(bContext *C, /* Update last stroke location */ - mul_m4_v3(ob->object_to_world().ptr(), co); + mul_m4_v3(ob->object_to_world, co); add_v3_v3(ups->average_stroke_accum, co); ups->average_stroke_counter++; @@ -202,10 +204,10 @@ void cache_init(bContext *C, float mat[3][3]; float viewDir[3] = {0.0f, 0.0f, 1.0f}; if (vc.rv3d) { - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); copy_m3_m4(mat, vc.rv3d->viewinv); mul_m3_v3(mat, viewDir); - copy_m3_m4(mat, ob->world_to_object().ptr()); + copy_m3_m4(mat, ob->world_to_object); mul_m3_v3(mat, viewDir); normalize_v3_v3(ss->filter_cache->view_normal, viewDir); } @@ -693,15 +695,23 @@ wmKeyMap *modal_keymap(wmKeyConfig *keyconf) static void sculpt_mesh_update_status_bar(bContext *C, wmOperator *op) { - auto get_modal_key_str = [&](int id) { - return WM_modalkeymap_operator_items_to_string(op->type, id, true).value_or(""); - }; + char header[UI_MAX_DRAW_STR]; + char buf[UI_MAX_DRAW_STR]; + int available_len = sizeof(buf); - const std::string header = fmt::format(IFACE_("{}: Confirm, {}: Cancel"), - get_modal_key_str(FILTER_MESH_MODAL_CONFIRM), - get_modal_key_str(FILTER_MESH_MODAL_CANCEL)); + char *p = buf; +#define WM_MODALKEY(_id) \ + WM_modalkeymap_operator_items_to_string_buf( \ + op->type, (_id), true, UI_MAX_SHORTCUT_STR, &available_len, &p) - ED_workspace_status_text(C, header.c_str()); + SNPRINTF(header, + IFACE_("%s: Confirm, %s: Cancel"), + WM_MODALKEY(FILTER_MESH_MODAL_CONFIRM), + WM_MODALKEY(FILTER_MESH_MODAL_CANCEL)); + +#undef WM_MODALKEY + + ED_workspace_status_text(C, header); } static void sculpt_mesh_filter_apply(bContext *C, wmOperator *op) diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_init.cc b/source/blender/editors/sculpt_paint/sculpt_mask_init.cc index 0efd49e3877..6ed8b76a0b6 100644 --- a/source/blender/editors/sculpt_paint/sculpt_mask_init.cc +++ b/source/blender/editors/sculpt_paint/sculpt_mask_init.cc @@ -12,6 +12,9 @@ #include "BLI_task.h" #include "BLI_time.h" +#include "DNA_brush_types.h" +#include "DNA_mesh_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "BKE_ccg.h" @@ -21,6 +24,8 @@ #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" +#include "DEG_depsgraph.hh" + #include "WM_api.hh" #include "WM_types.hh" @@ -107,7 +112,7 @@ static int sculpt_mask_init_exec(bContext *C, wmOperator *op) SCULPT_topology_islands_ensure(ob); } - const int mask_init_seed = BLI_time_now_seconds(); + const int mask_init_seed = BLI_check_seconds_timer(); const SculptMaskWriteInfo mask_write = SCULPT_mask_get_for_write(ss); threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) { diff --git a/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.cc b/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.cc index cb198a77aa6..aae52719077 100644 --- a/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.cc +++ b/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.cc @@ -17,6 +17,7 @@ #include "DNA_object_types.h" #include "BKE_ccg.h" +#include "BKE_context.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.cc b/source/blender/editors/sculpt_paint/sculpt_ops.cc index 7c4366fe819..15893210704 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/sculpt_ops.cc @@ -15,11 +15,12 @@ #include "BLI_task.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_brush_types.h" #include "DNA_customdata_types.h" #include "DNA_listBase.h" +#include "DNA_modifier_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -32,12 +33,13 @@ #include "BKE_main.hh" #include "BKE_mesh.hh" #include "BKE_mesh_mirror.hh" +#include "BKE_modifier.hh" #include "BKE_multires.hh" #include "BKE_object.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" @@ -319,7 +321,7 @@ void ensure_valid_pivot(const Object *ob, Scene *scene) if (ups->average_stroke_counter == 0 || !ups->last_stroke_valid) { const Bounds bounds = BKE_pbvh_bounding_box(ob->sculpt->pbvh); const float3 center = math::midpoint(bounds.min, bounds.max); - const float3 location = math::transform_point(ob->object_to_world(), center); + const float3 location = math::transform_point(float4x4(ob->object_to_world), center); copy_v3_v3(ups->average_stroke_accum, location); ups->average_stroke_counter = 1; @@ -352,7 +354,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain, BKE_report( reports, RPT_WARNING, "Object has non-uniform scale, sculpting may be unpredictable"); } - else if (is_negative_m4(ob->object_to_world().ptr())) { + else if (is_negative_m4(ob->object_to_world)) { BKE_report(reports, RPT_WARNING, "Object has negative scale, sculpting may be unpredictable"); } diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.cc b/source/blender/editors/sculpt_paint/sculpt_paint_color.cc index 27e6da8805a..8975f454c3b 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_color.cc +++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.cc @@ -19,6 +19,7 @@ #include "BKE_brush.hh" #include "BKE_colorband.hh" #include "BKE_colortools.hh" +#include "BKE_context.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" @@ -190,8 +191,7 @@ static void do_paint_brush_task(Object *ob, * at this point to avoid washing out non-binary masking modes like cavity masking. */ float automasking = auto_mask::factor_get( ss->cache->automasking.get(), ss, vd.vertex, &automask_data); - const float alpha = BKE_brush_alpha_get(ss->scene, brush); - mul_v4_v4fl(buffer_color, color_buffer->color[vd.i], alpha * automasking); + mul_v4_v4fl(buffer_color, color_buffer->color[vd.i], brush->alpha * automasking); float4 col; SCULPT_vertex_color_get(ss, vd.vertex, col); diff --git a/source/blender/editors/sculpt_paint/sculpt_pose.cc b/source/blender/editors/sculpt_paint/sculpt_pose.cc index 3a4383f976e..5c0bb7406a4 100644 --- a/source/blender/editors/sculpt_paint/sculpt_pose.cc +++ b/source/blender/editors/sculpt_paint/sculpt_pose.cc @@ -19,6 +19,7 @@ #include "BKE_brush.hh" #include "BKE_ccg.h" #include "BKE_colortools.hh" +#include "BKE_context.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.cc b/source/blender/editors/sculpt_paint/sculpt_smooth.cc index f771756fdc9..43812de7df9 100644 --- a/source/blender/editors/sculpt_paint/sculpt_smooth.cc +++ b/source/blender/editors/sculpt_paint/sculpt_smooth.cc @@ -13,6 +13,7 @@ #include "DNA_brush_types.h" +#include "BKE_context.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" diff --git a/source/blender/editors/sculpt_paint/sculpt_transform.cc b/source/blender/editors/sculpt_paint/sculpt_transform.cc index c61eebcaf05..541577f85cf 100644 --- a/source/blender/editors/sculpt_paint/sculpt_transform.cc +++ b/source/blender/editors/sculpt_paint/sculpt_transform.cc @@ -20,6 +20,8 @@ #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" +#include "DEG_depsgraph.hh" + #include "WM_api.hh" #include "WM_types.hh" diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index f704cb434fb..7ca75c38271 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -49,7 +49,7 @@ #include "BKE_ccg.h" #include "BKE_context.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_key.hh" #include "BKE_layer.hh" #include "BKE_main.hh" @@ -57,7 +57,7 @@ #include "BKE_multires.hh" #include "BKE_object.hh" #include "BKE_paint.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_subdiv_ccg.hh" #include "BKE_subsurf.hh" #include "BKE_undo_system.hh" diff --git a/source/blender/editors/sound/sound_ops.cc b/source/blender/editors/sound/sound_ops.cc index 1f7d0dcbc07..8d4cba9e658 100644 --- a/source/blender/editors/sound/sound_ops.cc +++ b/source/blender/editors/sound/sound_ops.cc @@ -24,12 +24,12 @@ #include "BKE_context.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_packedFile.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_sound.h" #include "RNA_access.hh" @@ -38,6 +38,7 @@ #include "RNA_prototypes.h" #include "SEQ_iterator.hh" +#include "SEQ_utils.hh" #include "UI_interface.hh" diff --git a/source/blender/editors/space_action/action_data.cc b/source/blender/editors/space_action/action_data.cc index ffa7db5e4df..6464b6967d4 100644 --- a/source/blender/editors/space_action/action_data.cc +++ b/source/blender/editors/space_action/action_data.cc @@ -13,26 +13,37 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_anim_types.h" +#include "DNA_gpencil_legacy_types.h" #include "DNA_key_types.h" +#include "DNA_mask_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "RNA_prototypes.h" #include "BKE_action.h" #include "BKE_context.hh" +#include "BKE_fcurve.h" #include "BKE_key.hh" #include "BKE_lib_id.hh" #include "BKE_nla.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" + +#include "UI_view2d.hh" #include "ED_anim_api.hh" +#include "ED_gpencil_legacy.hh" +#include "ED_keyframes_edit.hh" +#include "ED_keyframing.hh" +#include "ED_markers.hh" +#include "ED_mask.hh" #include "ED_screen.hh" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/space_action/action_draw.cc b/source/blender/editors/space_action/action_draw.cc index b6892365e59..6645396e780 100644 --- a/source/blender/editors/space_action/action_draw.cc +++ b/source/blender/editors/space_action/action_draw.cc @@ -13,18 +13,25 @@ #include #include +#include "BLI_blenlib.h" #include "BLI_math_color.h" #include "BLI_utildefines.h" /* Types --------------------------------------------------------------- */ +#include "DNA_anim_types.h" +#include "DNA_cachefile_types.h" +#include "DNA_gpencil_legacy_types.h" #include "DNA_modifier_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_action.h" #include "BKE_bake_geometry_nodes_modifier.hh" +#include "BKE_context.hh" +#include "BKE_node_runtime.hh" #include "BKE_pointcache.h" /* Everything from source (BIF, BDR, BSE) ------------------------------ */ diff --git a/source/blender/editors/space_action/action_edit.cc b/source/blender/editors/space_action/action_edit.cc index 7d459cae107..f5f1d76b160 100644 --- a/source/blender/editors/space_action/action_edit.cc +++ b/source/blender/editors/space_action/action_edit.cc @@ -15,27 +15,31 @@ #include "BLI_map.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph.hh" #include "DNA_anim_types.h" #include "DNA_gpencil_legacy_types.h" +#include "DNA_key_types.h" #include "DNA_mask_types.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "RNA_access.hh" #include "RNA_define.hh" #include "RNA_enum_types.hh" +#include "BKE_action.h" #include "BKE_animsys.h" #include "BKE_context.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_legacy.h" #include "BKE_grease_pencil.hh" +#include "BKE_key.hh" #include "BKE_nla.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "UI_view2d.hh" @@ -54,6 +58,8 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "UI_interface.hh" + #include "action_intern.hh" /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/space_action/space_action.cc b/source/blender/editors/space_action/space_action.cc index 829cdf0aa40..a42574bdfc2 100644 --- a/source/blender/editors/space_action/space_action.cc +++ b/source/blender/editors/space_action/space_action.cc @@ -10,7 +10,9 @@ #include #include "DNA_action_types.h" +#include "DNA_anim_types.h" #include "DNA_collection_types.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "MEM_guardedalloc.h" @@ -21,6 +23,7 @@ #include "BKE_context.hh" #include "BKE_lib_query.hh" #include "BKE_lib_remap.hh" +#include "BKE_nla.h" #include "BKE_screen.hh" #include "RNA_access.hh" @@ -783,15 +786,13 @@ static void action_refresh(const bContext *C, ScrArea *area) /* XXX re-sizing y-extents of tot should go here? */ } -static void action_id_remap(ScrArea * /*area*/, - SpaceLink *slink, - const blender::bke::id::IDRemapper &mappings) +static void action_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings) { SpaceAction *sact = (SpaceAction *)slink; - mappings.apply((ID **)&sact->action, ID_REMAP_APPLY_DEFAULT); - mappings.apply((ID **)&sact->ads.filter_grp, ID_REMAP_APPLY_DEFAULT); - mappings.apply(&sact->ads.source, ID_REMAP_APPLY_DEFAULT); + BKE_id_remapper_apply(mappings, (ID **)&sact->action, ID_REMAP_APPLY_DEFAULT); + BKE_id_remapper_apply(mappings, (ID **)&sact->ads.filter_grp, ID_REMAP_APPLY_DEFAULT); + BKE_id_remapper_apply(mappings, &sact->ads.source, ID_REMAP_APPLY_DEFAULT); } static void action_foreach_id(SpaceLink *space_link, LibraryForeachIDData *data) diff --git a/source/blender/editors/space_api/spacetypes.cc b/source/blender/editors/space_api/spacetypes.cc index 5b8994b8c21..853aba26f6e 100644 --- a/source/blender/editors/space_api/spacetypes.cc +++ b/source/blender/editors/space_api/spacetypes.cc @@ -10,6 +10,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "DNA_scene_types.h" diff --git a/source/blender/editors/space_buttons/buttons_context.cc b/source/blender/editors/space_buttons/buttons_context.cc index 741d09b26eb..afb4ca39136 100644 --- a/source/blender/editors/space_buttons/buttons_context.cc +++ b/source/blender/editors/space_buttons/buttons_context.cc @@ -15,9 +15,10 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_armature_types.h" +#include "DNA_brush_types.h" #include "DNA_collection_types.h" #include "DNA_linestyle_types.h" #include "DNA_material_types.h" @@ -27,6 +28,7 @@ #include "DNA_world_types.h" #include "BKE_action.h" +#include "BKE_armature.hh" #include "BKE_context.hh" #include "BKE_layer.hh" #include "BKE_linestyle.h" diff --git a/source/blender/editors/space_buttons/buttons_ops.cc b/source/blender/editors/space_buttons/buttons_ops.cc index f554f0d5a7a..56192022de0 100644 --- a/source/blender/editors/space_buttons/buttons_ops.cc +++ b/source/blender/editors/space_buttons/buttons_ops.cc @@ -18,12 +18,12 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_appdir.hh" #include "BKE_context.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "WM_api.hh" diff --git a/source/blender/editors/space_buttons/buttons_texture.cc b/source/blender/editors/space_buttons/buttons_texture.cc index c9bb13fed0d..afc0e35029b 100644 --- a/source/blender/editors/space_buttons/buttons_texture.cc +++ b/source/blender/editors/space_buttons/buttons_texture.cc @@ -15,7 +15,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_ID.h" #include "DNA_brush_types.h" @@ -34,6 +34,7 @@ #include "BKE_layer.hh" #include "BKE_linestyle.h" #include "BKE_modifier.hh" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_paint.hh" #include "BKE_particle.h" diff --git a/source/blender/editors/space_buttons/space_buttons.cc b/source/blender/editors/space_buttons/space_buttons.cc index 5ba94eca019..8c0442c2502 100644 --- a/source/blender/editors/space_buttons/space_buttons.cc +++ b/source/blender/editors/space_buttons/space_buttons.cc @@ -33,6 +33,8 @@ #include "WM_types.hh" #include "RNA_access.hh" +#include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -854,20 +856,20 @@ static void buttons_area_listener(const wmSpaceTypeListenerParams *params) } } -static void buttons_id_remap(ScrArea * /*area*/, - SpaceLink *slink, - const blender::bke::id::IDRemapper &mappings) +static void buttons_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings) { SpaceProperties *sbuts = (SpaceProperties *)slink; - if (mappings.apply(&sbuts->pinid, ID_REMAP_APPLY_DEFAULT) == ID_REMAP_RESULT_SOURCE_UNASSIGNED) { + if (BKE_id_remapper_apply(mappings, &sbuts->pinid, ID_REMAP_APPLY_DEFAULT) == + ID_REMAP_RESULT_SOURCE_UNASSIGNED) + { sbuts->flag &= ~SB_PIN_CONTEXT; } if (sbuts->path) { ButsContextPath *path = static_cast(sbuts->path); for (int i = 0; i < path->len; i++) { - switch (mappings.apply(&path->ptr[i].owner_id, ID_REMAP_APPLY_DEFAULT)) { + switch (BKE_id_remapper_apply(mappings, &path->ptr[i].owner_id, ID_REMAP_APPLY_DEFAULT)) { case ID_REMAP_RESULT_SOURCE_UNASSIGNED: { path->len = i; if (i != 0) { @@ -901,7 +903,7 @@ static void buttons_id_remap(ScrArea * /*area*/, if (sbuts->texuser) { ButsContextTexture *ct = static_cast(sbuts->texuser); - mappings.apply((ID **)&ct->texture, ID_REMAP_APPLY_DEFAULT); + BKE_id_remapper_apply(mappings, (ID **)&ct->texture, ID_REMAP_APPLY_DEFAULT); BLI_freelistN(&ct->users); ct->user = nullptr; } diff --git a/source/blender/editors/space_clip/clip_buttons.cc b/source/blender/editors/space_clip/clip_buttons.cc index 0161d98f1d4..dc305bcad23 100644 --- a/source/blender/editors/space_clip/clip_buttons.cc +++ b/source/blender/editors/space_clip/clip_buttons.cc @@ -21,7 +21,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_movieclip.h" diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.cc b/source/blender/editors/space_clip/clip_dopesheet_ops.cc index 2fb3488fbe9..d753e23e19e 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_ops.cc +++ b/source/blender/editors/space_clip/clip_dopesheet_ops.cc @@ -20,6 +20,8 @@ #include "ED_clip.hh" #include "ED_screen.hh" +#include "UI_interface.hh" + #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/editors/space_clip/clip_draw.cc b/source/blender/editors/space_clip/clip_draw.cc index 7061c4136dd..36988c6cf3f 100644 --- a/source/blender/editors/space_clip/clip_draw.cc +++ b/source/blender/editors/space_clip/clip_draw.cc @@ -41,6 +41,7 @@ #include "WM_types.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "UI_view2d.hh" diff --git a/source/blender/editors/space_clip/clip_editor.cc b/source/blender/editors/space_clip/clip_editor.cc index 44e00193e88..92c299133e1 100644 --- a/source/blender/editors/space_clip/clip_editor.cc +++ b/source/blender/editors/space_clip/clip_editor.cc @@ -26,12 +26,14 @@ #include "BLI_listbase.h" #include "BLI_rect.h" #include "BLI_task.h" +#include "BLI_time.h" #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" +#include "BKE_mask.h" #include "BKE_movieclip.h" #include "BKE_tracking.h" @@ -40,6 +42,8 @@ #include "IMB_imbuf_types.hh" #include "ED_clip.hh" +#include "ED_mask.hh" +#include "ED_screen.hh" #include "ED_select_utils.hh" #include "WM_api.hh" diff --git a/source/blender/editors/space_clip/clip_graph_draw.cc b/source/blender/editors/space_clip/clip_graph_draw.cc index 56e8c268ec4..06ec3cb732c 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.cc +++ b/source/blender/editors/space_clip/clip_graph_draw.cc @@ -11,6 +11,7 @@ #include "BLI_utildefines.h" +#include "BKE_context.hh" #include "BKE_movieclip.h" #include "BKE_tracking.h" @@ -24,6 +25,7 @@ #include "WM_types.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "UI_view2d.hh" diff --git a/source/blender/editors/space_clip/clip_ops.cc b/source/blender/editors/space_clip/clip_ops.cc index d0f08776662..6ed2441e89a 100644 --- a/source/blender/editors/space_clip/clip_ops.cc +++ b/source/blender/editors/space_clip/clip_ops.cc @@ -31,14 +31,14 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_movieclip.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_tracking.h" #include "WM_api.hh" @@ -556,7 +556,7 @@ static void view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event) if (U.viewzoom == USER_ZOOM_CONTINUE) { /* needs a timer to continue redrawing */ vpd->timer = WM_event_timer_add(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f); - vpd->timer_lastdraw = BLI_time_now_seconds(); + vpd->timer_lastdraw = BLI_check_seconds_timer(); } vpd->x = event->xy[0]; @@ -648,7 +648,7 @@ static void view_zoom_apply( if (U.viewzoom == USER_ZOOM_CONTINUE) { SpaceClip *sclip = CTX_wm_space_clip(C); - double time = BLI_time_now_seconds(); + double time = BLI_check_seconds_timer(); float time_step = float(time - vpd->timer_lastdraw); float zfac; diff --git a/source/blender/editors/space_clip/clip_utils.cc b/source/blender/editors/space_clip/clip_utils.cc index 86ea1f7bd2f..eb1e89b3bbf 100644 --- a/source/blender/editors/space_clip/clip_utils.cc +++ b/source/blender/editors/space_clip/clip_utils.cc @@ -32,7 +32,9 @@ #include "ED_clip.hh" #include "ED_mask.hh" +#include "ED_screen.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "UI_view2d.hh" diff --git a/source/blender/editors/space_clip/space_clip.cc b/source/blender/editors/space_clip/space_clip.cc index 8e0529ae45d..08ddd3c89d2 100644 --- a/source/blender/editors/space_clip/space_clip.cc +++ b/source/blender/editors/space_clip/space_clip.cc @@ -22,6 +22,7 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_lib_remap.hh" #include "BKE_movieclip.h" @@ -1151,18 +1152,16 @@ static void clip_properties_region_listener(const wmRegionListenerParams *params /** \name IO Callbacks * \{ */ -static void clip_id_remap(ScrArea * /*area*/, - SpaceLink *slink, - const blender::bke::id::IDRemapper &mappings) +static void clip_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings) { SpaceClip *sclip = (SpaceClip *)slink; - if (!mappings.contains_mappings_for_any(FILTER_ID_MC | FILTER_ID_MSK)) { + if (!BKE_id_remapper_has_mapping_for(mappings, FILTER_ID_MC | FILTER_ID_MSK)) { return; } - mappings.apply((ID **)&sclip->clip, ID_REMAP_APPLY_ENSURE_REAL); - mappings.apply((ID **)&sclip->mask_info.mask, ID_REMAP_APPLY_ENSURE_REAL); + BKE_id_remapper_apply(mappings, (ID **)&sclip->clip, ID_REMAP_APPLY_ENSURE_REAL); + BKE_id_remapper_apply(mappings, (ID **)&sclip->mask_info.mask, ID_REMAP_APPLY_ENSURE_REAL); } static void clip_foreach_id(SpaceLink *space_link, LibraryForeachIDData *data) diff --git a/source/blender/editors/space_clip/tracking_ops.cc b/source/blender/editors/space_clip/tracking_ops.cc index c5e1a2a40be..dc2d2334bb8 100644 --- a/source/blender/editors/space_clip/tracking_ops.cc +++ b/source/blender/editors/space_clip/tracking_ops.cc @@ -11,6 +11,7 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "BLI_blenlib.h" #include "BLI_ghash.h" #include "BLI_math_geom.h" #include "BLI_math_vector.h" @@ -19,7 +20,7 @@ #include "BKE_context.hh" #include "BKE_image.h" #include "BKE_movieclip.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_tracking.h" #include "DEG_depsgraph.hh" @@ -33,7 +34,7 @@ #include "RNA_access.hh" #include "RNA_define.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" diff --git a/source/blender/editors/space_clip/tracking_ops_detect.cc b/source/blender/editors/space_clip/tracking_ops_detect.cc index 1bda33d1cb3..b3fd318bb03 100644 --- a/source/blender/editors/space_clip/tracking_ops_detect.cc +++ b/source/blender/editors/space_clip/tracking_ops_detect.cc @@ -12,7 +12,7 @@ #include "BKE_context.hh" #include "BKE_movieclip.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_tracking.h" #include "WM_api.hh" diff --git a/source/blender/editors/space_clip/tracking_ops_orient.cc b/source/blender/editors/space_clip/tracking_ops_orient.cc index 04a4850a02c..d18b67bf0a2 100644 --- a/source/blender/editors/space_clip/tracking_ops_orient.cc +++ b/source/blender/editors/space_clip/tracking_ops_orient.cc @@ -21,7 +21,7 @@ #include "BKE_context.hh" #include "BKE_layer.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_tracking.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/space_clip/tracking_ops_plane.cc b/source/blender/editors/space_clip/tracking_ops_plane.cc index 4c021a24a2d..d2a00c0d115 100644 --- a/source/blender/editors/space_clip/tracking_ops_plane.cc +++ b/source/blender/editors/space_clip/tracking_ops_plane.cc @@ -16,7 +16,7 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_tracking.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/space_clip/tracking_ops_solve.cc b/source/blender/editors/space_clip/tracking_ops_solve.cc index 16769c18e4c..27dc8a0b853 100644 --- a/source/blender/editors/space_clip/tracking_ops_solve.cc +++ b/source/blender/editors/space_clip/tracking_ops_solve.cc @@ -17,10 +17,10 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_movieclip.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_tracking.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/space_clip/tracking_ops_track.cc b/source/blender/editors/space_clip/tracking_ops_track.cc index 608fdabb225..91bed25ea3d 100644 --- a/source/blender/editors/space_clip/tracking_ops_track.cc +++ b/source/blender/editors/space_clip/tracking_ops_track.cc @@ -8,13 +8,14 @@ #include "MEM_guardedalloc.h" +#include "BLI_string.h" #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_main.hh" #include "BKE_movieclip.h" #include "BKE_tracking.h" @@ -23,6 +24,7 @@ #include "WM_types.hh" #include "ED_clip.hh" +#include "ED_screen.hh" #include "RNA_access.hh" #include "RNA_define.hh" @@ -216,15 +218,15 @@ static void track_markers_startjob(void *tmv, wmJobWorkerStatus *worker_status) * exec_time for "Fastest" tracking */ - double start_time = BLI_time_now_seconds(), exec_time; + double start_time = BLI_check_seconds_timer(), exec_time; if (!BKE_autotrack_context_step(tmj->context)) { break; } - exec_time = BLI_time_now_seconds() - start_time; + exec_time = BLI_check_seconds_timer() - start_time; if (tmj->delay > float(exec_time)) { - BLI_time_sleep_ms(tmj->delay - float(exec_time)); + BLI_sleep_ms(tmj->delay - float(exec_time)); } } else if (!BKE_autotrack_context_step(tmj->context)) { diff --git a/source/blender/editors/space_clip/tracking_select.cc b/source/blender/editors/space_clip/tracking_select.cc index 5568aca0a96..d244d9b17a2 100644 --- a/source/blender/editors/space_clip/tracking_select.cc +++ b/source/blender/editors/space_clip/tracking_select.cc @@ -25,6 +25,8 @@ #include "WM_types.hh" #include "ED_clip.hh" +#include "ED_mask.hh" +#include "ED_screen.hh" #include "ED_select_utils.hh" #include "RNA_access.hh" diff --git a/source/blender/editors/space_console/console_draw.cc b/source/blender/editors/space_console/console_draw.cc index 0c6a706eedc..1fef1b2c471 100644 --- a/source/blender/editors/space_console/console_draw.cc +++ b/source/blender/editors/space_console/console_draw.cc @@ -18,6 +18,7 @@ #include "GPU_immediate.h" +#include "UI_interface.hh" #include "UI_resources.hh" #include "UI_view2d.hh" diff --git a/source/blender/editors/space_console/console_ops.cc b/source/blender/editors/space_console/console_ops.cc index 51b8b4618da..9bb5e08b491 100644 --- a/source/blender/editors/space_console/console_ops.cc +++ b/source/blender/editors/space_console/console_ops.cc @@ -23,7 +23,7 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "WM_api.hh" #include "WM_types.hh" diff --git a/source/blender/editors/space_console/space_console.cc b/source/blender/editors/space_console/space_console.cc index ac40af94170..f4485f428ad 100644 --- a/source/blender/editors/space_console/space_console.cc +++ b/source/blender/editors/space_console/space_console.cc @@ -15,6 +15,7 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" +#include "BKE_global.h" #include "BKE_screen.hh" #include "ED_screen.hh" @@ -150,12 +151,12 @@ static void console_cursor(wmWindow *win, ScrArea * /*area*/, ARegion *region) /* ************* dropboxes ************* */ -static bool console_drop_id_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/) +static bool id_drop_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/) { return WM_drag_get_local_ID(drag, 0) != nullptr; } -static void console_drop_id_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop) +static void id_drop_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop) { ID *id = WM_drag_get_local_ID(drag, 0); @@ -164,47 +165,25 @@ static void console_drop_id_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop RNA_string_set(drop->ptr, "text", text.c_str()); } -static bool console_drop_path_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/) +static bool path_drop_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/) { return (drag->type == WM_DRAG_PATH); } -static void console_drop_path_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop) +static void path_drop_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop) { char pathname[FILE_MAX + 2]; SNPRINTF(pathname, "\"%s\"", WM_drag_get_single_path(drag)); RNA_string_set(drop->ptr, "text", pathname); } -static bool console_drop_string_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/) -{ - return (drag->type == WM_DRAG_STRING); -} - -static void console_drop_string_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop) -{ - /* NOTE(@ideasman42): Only a single line is supported, multiple lines could be supported - * but this implies executing all lines except for the last. While we could consider that, - * there are some security implications for this, so just drop one line for now. */ - std::string str = WM_drag_get_string_firstline(drag); - RNA_string_set(drop->ptr, "text", str.c_str()); -} - /* this region dropbox definition */ static void console_dropboxes() { ListBase *lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW); - WM_dropbox_add( - lb, "CONSOLE_OT_insert", console_drop_id_poll, console_drop_id_copy, nullptr, nullptr); - WM_dropbox_add( - lb, "CONSOLE_OT_insert", console_drop_path_poll, console_drop_path_copy, nullptr, nullptr); - WM_dropbox_add(lb, - "CONSOLE_OT_insert", - console_drop_string_poll, - console_drop_string_copy, - nullptr, - nullptr); + WM_dropbox_add(lb, "CONSOLE_OT_insert", id_drop_poll, id_drop_copy, nullptr, nullptr); + WM_dropbox_add(lb, "CONSOLE_OT_insert", path_drop_poll, path_drop_copy, nullptr, nullptr); } /* ************* end drop *********** */ diff --git a/source/blender/editors/space_file/asset_catalog_tree_view.cc b/source/blender/editors/space_file/asset_catalog_tree_view.cc index a87d9fe46ac..555fe12b36f 100644 --- a/source/blender/editors/space_file/asset_catalog_tree_view.cc +++ b/source/blender/editors/space_file/asset_catalog_tree_view.cc @@ -16,7 +16,7 @@ #include "BLI_string_ref.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "ED_asset.hh" #include "ED_fileselect.hh" @@ -181,14 +181,11 @@ class AssetCatalogTreeViewUnassignedItem : public ui::BasicTreeViewItem { AssetCatalogTreeView::AssetCatalogTreeView(asset_system::AssetLibrary *library, FileAssetSelectParams *params, SpaceFile &space_file) - : asset_library_(library), params_(params), space_file_(space_file) + : asset_library_(library), + catalog_tree_(AS_asset_library_get_catalog_tree(library)), + params_(params), + space_file_(space_file) { - if (library && library->catalog_service) { - catalog_tree_ = library->catalog_service->get_catalog_tree(); - } - else { - catalog_tree_ = nullptr; - } } void AssetCatalogTreeView::build_tree() @@ -278,7 +275,7 @@ void AssetCatalogTreeViewItem::on_activate(bContext & /*C*/) void AssetCatalogTreeViewItem::build_row(uiLayout &row) { const std::string label_override = catalog_item_.has_unsaved_changes() ? (label_ + "*") : label_; - this->add_label(row, label_override); + add_label(row, label_override); if (!is_hovered()) { return; @@ -332,7 +329,7 @@ void AssetCatalogTreeViewItem::build_context_menu(bContext &C, uiLayout &column) bool AssetCatalogTreeViewItem::supports_renaming() const { const AssetCatalogTreeView &tree_view = static_cast( - this->get_tree_view()); + get_tree_view()); return !asset::catalogs_read_only(*tree_view.asset_library_); } @@ -342,7 +339,7 @@ bool AssetCatalogTreeViewItem::rename(const bContext &C, StringRefNull new_name) BasicTreeViewItem::rename(C, new_name); const AssetCatalogTreeView &tree_view = static_cast( - this->get_tree_view()); + get_tree_view()); asset::catalog_rename(tree_view.asset_library_, catalog_item_.get_catalog_id(), new_name); return true; } @@ -356,7 +353,7 @@ std::unique_ptr AssetCatalogTreeViewItem:: create_drag_controller() const { return std::make_unique( - static_cast(this->get_tree_view()), catalog_item_); + static_cast(get_tree_view()), catalog_item_); } /* ---------------------------------------------------------------------- */ @@ -371,11 +368,11 @@ bool AssetCatalogDropTarget::can_drop(const wmDrag &drag, const char **r_disable { if (drag.type == WM_DRAG_ASSET_CATALOG) { const asset_system::AssetLibrary &library = get_asset_library(); - if (!this->can_modify_catalogs(library, r_disabled_hint)) { + if (!can_modify_catalogs(library, r_disabled_hint)) { return false; } - const AssetCatalog *drag_catalog = this->get_drag_catalog(drag, library); + const AssetCatalog *drag_catalog = get_drag_catalog(drag, library); /* NOTE: Technically it's not an issue to allow this (the catalog will just receive a new * path and the catalog system will generate missing parents from the path). But it does * appear broken to users, so disabling entirely. */ @@ -399,15 +396,15 @@ bool AssetCatalogDropTarget::can_drop(const wmDrag &drag, const char **r_disable std::string AssetCatalogDropTarget::drop_tooltip(const ui::DragInfo &drag_info) const { if (drag_info.drag_data.type == WM_DRAG_ASSET_CATALOG) { - return this->drop_tooltip_asset_catalog(drag_info.drag_data); + return drop_tooltip_asset_catalog(drag_info.drag_data); } - return this->drop_tooltip_asset_list(drag_info.drag_data); + return drop_tooltip_asset_list(drag_info.drag_data); } std::string AssetCatalogDropTarget::drop_tooltip_asset_catalog(const wmDrag &drag) const { BLI_assert(drag.type == WM_DRAG_ASSET_CATALOG); - const AssetCatalog *src_catalog = this->get_drag_catalog(drag, get_asset_library()); + const AssetCatalog *src_catalog = get_drag_catalog(drag, get_asset_library()); return fmt::format( TIP_("Move catalog {} into {}"), src_catalog->path.name(), catalog_item_.get_name()); @@ -439,14 +436,14 @@ std::string AssetCatalogDropTarget::drop_tooltip_asset_list(const wmDrag &drag) bool AssetCatalogDropTarget::on_drop(bContext *C, const ui::DragInfo &drag) const { if (drag.drag_data.type == WM_DRAG_ASSET_CATALOG) { - return this->drop_asset_catalog_into_catalog( - drag.drag_data, this->get_view(), catalog_item_.get_catalog_id()); + return drop_asset_catalog_into_catalog( + drag.drag_data, get_view(), catalog_item_.get_catalog_id()); } - return this->drop_assets_into_catalog(C, - this->get_view(), - drag.drag_data, - catalog_item_.get_catalog_id(), - catalog_item_.get_simple_name()); + return drop_assets_into_catalog(C, + get_view(), + drag.drag_data, + catalog_item_.get_catalog_id(), + catalog_item_.get_simple_name()); } bool AssetCatalogDropTarget::drop_asset_catalog_into_catalog( @@ -505,7 +502,8 @@ AssetCatalog *AssetCatalogDropTarget::get_drag_catalog( if (drag.type != WM_DRAG_ASSET_CATALOG) { return nullptr; } - const AssetCatalogService *catalog_service = asset_library.catalog_service.get(); + const AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service( + &asset_library); const wmDragAssetCatalog *catalog_drag = WM_drag_get_asset_catalog_data(&drag); return catalog_service->find_catalog(catalog_drag->drag_catalog_id); @@ -539,7 +537,7 @@ bool AssetCatalogDropTarget::can_modify_catalogs(const asset_system::AssetLibrar asset_system::AssetLibrary &AssetCatalogDropTarget::get_asset_library() const { - return *this->get_view().asset_library_; + return *get_view().asset_library_; } /* ---------------------------------------------------------------------- */ @@ -565,7 +563,7 @@ void *AssetCatalogDragController::create_drag_data() const void AssetCatalogDragController::on_drag_start() { - AssetCatalogTreeView &tree_view_ = this->get_view(); + AssetCatalogTreeView &tree_view_ = get_view(); tree_view_.activate_catalog_by_id(catalog_item_.get_catalog_id()); } @@ -577,15 +575,11 @@ void AssetCatalogTreeViewAllItem::build_row(uiLayout &row) PointerRNA *props; - UI_but_extra_operator_icon_add(reinterpret_cast(this->view_item_button()), - "ASSET_OT_catalogs_save", - WM_OP_INVOKE_DEFAULT, - ICON_FILE_TICK); + UI_but_extra_operator_icon_add( + (uiBut *)view_item_button(), "ASSET_OT_catalogs_save", WM_OP_INVOKE_DEFAULT, ICON_FILE_TICK); - props = UI_but_extra_operator_icon_add(reinterpret_cast(this->view_item_button()), - "ASSET_OT_catalog_new", - WM_OP_INVOKE_DEFAULT, - ICON_ADD); + props = UI_but_extra_operator_icon_add( + (uiBut *)view_item_button(), "ASSET_OT_catalog_new", WM_OP_INVOKE_DEFAULT, ICON_ADD); /* No parent path to use the root level. */ RNA_string_set(props, "parent_path", nullptr); } @@ -606,7 +600,7 @@ bool AssetCatalogTreeViewAllItem::DropTarget::can_drop(const wmDrag &drag, if (drag.type != WM_DRAG_ASSET_CATALOG) { return false; } - asset_system::AssetLibrary &library = *this->get_view().asset_library_; + asset_system::AssetLibrary &library = *get_view().asset_library_; if (!AssetCatalogDropTarget::can_modify_catalogs(library, r_disabled_hint)) { return false; } @@ -625,7 +619,7 @@ std::string AssetCatalogTreeViewAllItem::DropTarget::drop_tooltip( { BLI_assert(drag_info.drag_data.type == WM_DRAG_ASSET_CATALOG); const AssetCatalog *drag_catalog = AssetCatalogDropTarget::get_drag_catalog( - drag_info.drag_data, *this->get_view().asset_library_); + drag_info.drag_data, *get_view().asset_library_); return fmt::format(TIP_("Move catalog {} to the top level of the tree"), drag_catalog->path.name()); @@ -637,7 +631,7 @@ bool AssetCatalogTreeViewAllItem::DropTarget::on_drop(bContext * /*C*/, BLI_assert(drag.drag_data.type == WM_DRAG_ASSET_CATALOG); return AssetCatalogDropTarget::drop_asset_catalog_into_catalog( drag.drag_data, - this->get_view(), + get_view(), /* No value to drop into the root level. */ std::nullopt); } @@ -680,7 +674,7 @@ bool AssetCatalogTreeViewUnassignedItem::DropTarget::on_drop(bContext *C, { /* Assign to nil catalog ID. */ return AssetCatalogDropTarget::drop_assets_into_catalog( - C, this->get_view(), drag.drag_data, CatalogID{}); + C, get_view(), drag.drag_data, CatalogID{}); } } // namespace blender::ed::asset_browser diff --git a/source/blender/editors/space_file/file_draw.cc b/source/blender/editors/space_file/file_draw.cc index 752db114acc..f96168dfb61 100644 --- a/source/blender/editors/space_file/file_draw.cc +++ b/source/blender/editors/space_file/file_draw.cc @@ -30,11 +30,11 @@ #include "BKE_blendfile.hh" #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_report.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLF_api.hh" @@ -1421,7 +1421,7 @@ static void file_draw_invalid_asset_library_hint(const bContext *C, ARegion *region, FileAssetSelectParams *asset_params) { - char library_ui_path[FILE_MAX_LIBEXTRA]; + char library_ui_path[PATH_MAX]; file_path_to_ui_path(asset_params->base_params.dir, library_ui_path, sizeof(library_ui_path)); uchar text_col[4]; diff --git a/source/blender/editors/space_file/file_indexer.cc b/source/blender/editors/space_file/file_indexer.cc index d004a0b6d62..78d29856466 100644 --- a/source/blender/editors/space_file/file_indexer.cc +++ b/source/blender/editors/space_file/file_indexer.cc @@ -14,6 +14,7 @@ #include "BLI_linklist.h" #include "BLI_listbase.h" +#include "BLI_string.h" #include "BLI_utildefines.h" namespace blender::ed::file::indexer { diff --git a/source/blender/editors/space_file/file_ops.cc b/source/blender/editors/space_file/file_ops.cc index 92aff90b03e..589fabec3fd 100644 --- a/source/blender/editors/space_file/file_ops.cc +++ b/source/blender/editors/space_file/file_ops.cc @@ -14,16 +14,18 @@ #include "BKE_appdir.hh" #include "BKE_blendfile.hh" #include "BKE_context.hh" +#include "BKE_global.h" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #ifdef WIN32 # include "BLI_winstuff.h" #endif +#include "ED_asset.hh" #include "ED_fileselect.hh" #include "ED_screen.hh" #include "ED_select_utils.hh" diff --git a/source/blender/editors/space_file/file_panels.cc b/source/blender/editors/space_file/file_panels.cc index 47f110077bd..ba1a436f48a 100644 --- a/source/blender/editors/space_file/file_panels.cc +++ b/source/blender/editors/space_file/file_panels.cc @@ -12,7 +12,7 @@ #include "BKE_context.hh" #include "BKE_screen.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" @@ -35,6 +35,7 @@ #include "file_intern.hh" #include "filelist.hh" +#include "fsmenu.h" #include diff --git a/source/blender/editors/space_file/file_utils.cc b/source/blender/editors/space_file/file_utils.cc index 6b5d7501728..7b5cab46a85 100644 --- a/source/blender/editors/space_file/file_utils.cc +++ b/source/blender/editors/space_file/file_utils.cc @@ -6,13 +6,18 @@ * \ingroup spfile */ +#include "BLI_fileops.h" #include "BLI_path_util.h" #include "BLI_rect.h" #include "BLI_string.h" #include "BKE_blendfile.hh" +#include "BKE_context.hh" #include "ED_fileselect.hh" +#include "ED_screen.hh" + +#include "WM_types.hh" #include "file_intern.hh" @@ -31,7 +36,7 @@ void file_tile_boundbox(const ARegion *region, FileLayout *layout, const int fil void file_path_to_ui_path(const char *path, char *r_path, int max_size) { - char tmp_path[FILE_MAX_LIBEXTRA]; + char tmp_path[PATH_MAX]; STRNCPY(tmp_path, path); BLI_path_slash_rstrip(tmp_path); BLI_strncpy(r_path, BKE_blendfile_extension_check(tmp_path) ? tmp_path : path, max_size); diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index 956adb0fc99..04fcd9217c6 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -40,6 +40,7 @@ #include "BLI_string_utils.hh" #include "BLI_task.h" #include "BLI_threads.h" +#include "BLI_time.h" #include "BLI_utildefines.h" #include "BLI_uuid.h" @@ -50,10 +51,12 @@ #include "BKE_asset.hh" #include "BKE_blendfile.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_icons.h" #include "BKE_idtype.hh" +#include "BKE_lib_id.hh" #include "BKE_main.hh" +#include "BKE_main_idmap.hh" #include "BKE_preferences.h" #include "BKE_preview_image.hh" @@ -62,6 +65,7 @@ #include "ED_datafiles.h" #include "ED_fileselect.hh" +#include "ED_screen.hh" #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" diff --git a/source/blender/editors/space_file/filesel.cc b/source/blender/editors/space_file/filesel.cc index dda186661c2..9d6de11346d 100644 --- a/source/blender/editors/space_file/filesel.cc +++ b/source/blender/editors/space_file/filesel.cc @@ -37,9 +37,9 @@ #include "BLI_math_base.h" #include "BLI_utildefines.h" -#include "BLO_userdef_default.h" +#include "BLO_readfile.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_appdir.hh" #include "BKE_context.hh" diff --git a/source/blender/editors/space_file/fsmenu.cc b/source/blender/editors/space_file/fsmenu.cc index 03fc3ca87ff..2d70206177e 100644 --- a/source/blender/editors/space_file/fsmenu.cc +++ b/source/blender/editors/space_file/fsmenu.cc @@ -15,15 +15,17 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_ghash.h" #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_appdir.hh" #include "ED_fileselect.hh" +#include "UI_interface_icons.hh" #include "UI_resources.hh" #include "WM_api.hh" #include "WM_types.hh" diff --git a/source/blender/editors/space_file/fsmenu_system.cc b/source/blender/editors/space_file/fsmenu_system.cc index bb5f0c70eea..3d2213f087b 100644 --- a/source/blender/editors/space_file/fsmenu_system.cc +++ b/source/blender/editors/space_file/fsmenu_system.cc @@ -18,17 +18,18 @@ #include "BLI_listbase.h" #include "BLI_path_util.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" #include "BLI_utildefines.h" #include "DNA_userdef_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" + +#include "BKE_appdir.hh" #include "ED_fileselect.hh" #ifdef WIN32 -# include "BLI_string_utf8.h" /* For `BLI_strncpy_wchar_as_utf8`. */ - /* Need to include windows.h so _WIN32_IE is defined. */ # include /* For SHGetSpecialFolderPath, has to be done before BLI_winstuff diff --git a/source/blender/editors/space_file/space_file.cc b/source/blender/editors/space_file/space_file.cc index 6c0d65a2c97..ba3ddcaa44c 100644 --- a/source/blender/editors/space_file/space_file.cc +++ b/source/blender/editors/space_file/space_file.cc @@ -12,14 +12,16 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_linklist.h" #include "BLI_utildefines.h" #include "BKE_appdir.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_query.hh" +#include "BKE_lib_remap.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "RNA_access.hh" @@ -36,6 +38,7 @@ #include "ED_screen.hh" #include "ED_space_api.hh" +#include "IMB_imbuf_types.hh" #include "IMB_thumbs.hh" #include "UI_resources.hh" @@ -43,6 +46,7 @@ #include "BLO_read_write.hh" +#include "GPU_framebuffer.h" #include "file_indexer.hh" #include "file_intern.hh" /* own include */ #include "filelist.hh" @@ -827,9 +831,7 @@ static void file_space_subtype_item_extend(bContext * /*C*/, EnumPropertyItem ** RNA_enum_items_add(item, totitem, rna_enum_space_file_browse_mode_items); } -static void file_id_remap(ScrArea *area, - SpaceLink *sl, - const blender::bke::id::IDRemapper & /*mappings*/) +static void file_id_remap(ScrArea *area, SpaceLink *sl, const IDRemapper * /*mappings*/) { SpaceFile *sfile = (SpaceFile *)sl; diff --git a/source/blender/editors/space_graph/graph_buttons.cc b/source/blender/editors/space_graph/graph_buttons.cc index a3631661a82..4d433c7041b 100644 --- a/source/blender/editors/space_graph/graph_buttons.cc +++ b/source/blender/editors/space_graph/graph_buttons.cc @@ -23,14 +23,15 @@ #include "BLI_math_rotation.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_anim_data.h" #include "BKE_context.hh" #include "BKE_curve.hh" #include "BKE_fcurve.h" #include "BKE_fcurve_driver.h" -#include "BKE_global.hh" +#include "BKE_global.h" +#include "BKE_main.hh" #include "BKE_screen.hh" #include "BKE_unit.hh" @@ -45,6 +46,7 @@ #include "RNA_prototypes.h" #include "ED_anim_api.hh" +#include "ED_keyframing.hh" #include "ED_screen.hh" #include "ED_undo.hh" diff --git a/source/blender/editors/space_graph/graph_draw.cc b/source/blender/editors/space_graph/graph_draw.cc index aa96e29b295..87c44513267 100644 --- a/source/blender/editors/space_graph/graph_draw.cc +++ b/source/blender/editors/space_graph/graph_draw.cc @@ -11,6 +11,7 @@ #include #include +#include "BLI_blenlib.h" #include "BLI_math_vector_types.hh" #include "BLI_utildefines.h" #include "BLI_vector.hh" @@ -19,8 +20,11 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_userdef_types.h" +#include "DNA_windowmanager_types.h" +#include "BKE_action.h" #include "BKE_anim_data.h" +#include "BKE_context.hh" #include "BKE_curve.hh" #include "BKE_fcurve.h" #include "BKE_nla.h" diff --git a/source/blender/editors/space_graph/graph_edit.cc b/source/blender/editors/space_graph/graph_edit.cc index f92c9948931..a16a3f2a382 100644 --- a/source/blender/editors/space_graph/graph_edit.cc +++ b/source/blender/editors/space_graph/graph_edit.cc @@ -21,6 +21,7 @@ #include "BLI_blenlib.h" #include "BLI_math_rotation.h" +#include "BLI_math_vector.h" #include "BLI_utildefines.h" #include "DNA_anim_types.h" @@ -31,18 +32,19 @@ #include "RNA_enum_types.hh" #include "RNA_prototypes.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_animsys.h" #include "BKE_context.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_nla.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "DEG_depsgraph_build.hh" +#include "UI_interface.hh" #include "UI_view2d.hh" #include "ANIM_animdata.hh" diff --git a/source/blender/editors/space_graph/graph_ops.cc b/source/blender/editors/space_graph/graph_ops.cc index f205d144287..0b01c62e01e 100644 --- a/source/blender/editors/space_graph/graph_ops.cc +++ b/source/blender/editors/space_graph/graph_ops.cc @@ -11,16 +11,18 @@ #include "DNA_scene_types.h" +#include "BLI_blenlib.h" #include "BLI_math_base.h" #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "UI_view2d.hh" #include "ED_anim_api.hh" #include "ED_screen.hh" +#include "ED_transform.hh" #include "graph_intern.h" diff --git a/source/blender/editors/space_graph/graph_select.cc b/source/blender/editors/space_graph/graph_select.cc index 949ca4064ed..c8ec51e750b 100644 --- a/source/blender/editors/space_graph/graph_select.cc +++ b/source/blender/editors/space_graph/graph_select.cc @@ -13,6 +13,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_lasso_2d.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" @@ -25,6 +26,7 @@ #include "RNA_access.hh" #include "RNA_define.hh" +#include "BKE_context.hh" #include "BKE_fcurve.h" #include "BKE_nla.h" diff --git a/source/blender/editors/space_graph/graph_slider_ops.cc b/source/blender/editors/space_graph/graph_slider_ops.cc index 5b5bc3ab59c..363a882194b 100644 --- a/source/blender/editors/space_graph/graph_slider_ops.cc +++ b/source/blender/editors/space_graph/graph_slider_ops.cc @@ -27,7 +27,7 @@ #include "RNA_access.hh" #include "RNA_define.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" diff --git a/source/blender/editors/space_graph/graph_utils.cc b/source/blender/editors/space_graph/graph_utils.cc index 04a8d7bada1..40334123c67 100644 --- a/source/blender/editors/space_graph/graph_utils.cc +++ b/source/blender/editors/space_graph/graph_utils.cc @@ -17,6 +17,8 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" + #include "BKE_context.hh" #include "BKE_fcurve.h" #include "BKE_screen.hh" @@ -25,6 +27,7 @@ #include "ED_screen.hh" #include "UI_interface.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "graph_intern.h" /* own include */ diff --git a/source/blender/editors/space_graph/graph_view.cc b/source/blender/editors/space_graph/graph_view.cc index 7c7bc10dd5b..e7196038497 100644 --- a/source/blender/editors/space_graph/graph_view.cc +++ b/source/blender/editors/space_graph/graph_view.cc @@ -24,6 +24,7 @@ #include "BKE_fcurve.h" #include "BKE_nla.h" +#include "UI_interface.hh" #include "UI_view2d.hh" #include "ED_anim_api.hh" diff --git a/source/blender/editors/space_graph/space_graph.cc b/source/blender/editors/space_graph/space_graph.cc index 844704d6c83..e7196c14588 100644 --- a/source/blender/editors/space_graph/space_graph.cc +++ b/source/blender/editors/space_graph/space_graph.cc @@ -31,6 +31,7 @@ #include "ED_space_api.hh" #include "ED_time_scrub_ui.hh" +#include "GPU_framebuffer.h" #include "GPU_immediate.h" #include "GPU_state.h" @@ -796,17 +797,15 @@ static void graph_refresh(const bContext *C, ScrArea *area) graph_refresh_fcurve_colors(C); } -static void graph_id_remap(ScrArea * /*area*/, - SpaceLink *slink, - const blender::bke::id::IDRemapper &mappings) +static void graph_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings) { SpaceGraph *sgraph = (SpaceGraph *)slink; if (!sgraph->ads) { return; } - mappings.apply((ID **)&sgraph->ads->filter_grp, ID_REMAP_APPLY_DEFAULT); - mappings.apply((ID **)&sgraph->ads->source, ID_REMAP_APPLY_DEFAULT); + BKE_id_remapper_apply(mappings, (ID **)&sgraph->ads->filter_grp, ID_REMAP_APPLY_DEFAULT); + BKE_id_remapper_apply(mappings, (ID **)&sgraph->ads->source, ID_REMAP_APPLY_DEFAULT); } static void graph_foreach_id(SpaceLink *space_link, LibraryForeachIDData *data) diff --git a/source/blender/editors/space_image/image_buttons.cc b/source/blender/editors/space_image/image_buttons.cc index 13f1b491dae..3e0feb4a9ac 100644 --- a/source/blender/editors/space_image/image_buttons.cc +++ b/source/blender/editors/space_image/image_buttons.cc @@ -17,12 +17,13 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_image.h" #include "BKE_image_format.h" -#include "BKE_node.hh" +#include "BKE_node.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "RE_pipeline.h" @@ -31,6 +32,7 @@ #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" +#include "ED_gpencil_legacy.hh" #include "ED_image.hh" #include "ED_screen.hh" diff --git a/source/blender/editors/space_image/image_edit.cc b/source/blender/editors/space_image/image_edit.cc index 35b734510c2..7f39bb91ee4 100644 --- a/source/blender/editors/space_image/image_edit.cc +++ b/source/blender/editors/space_image/image_edit.cc @@ -17,15 +17,17 @@ #include "BKE_colortools.hh" #include "BKE_context.hh" #include "BKE_editmesh.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "IMB_imbuf_types.hh" +#include "DEG_depsgraph.hh" + #include "ED_image.hh" /* own include */ #include "ED_mesh.hh" #include "ED_screen.hh" diff --git a/source/blender/editors/space_image/image_ops.cc b/source/blender/editors/space_image/image_ops.cc index 74472c8f418..fbc1057e7f1 100644 --- a/source/blender/editors/space_image/image_ops.cc +++ b/source/blender/editors/space_image/image_ops.cc @@ -26,7 +26,7 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_camera_types.h" #include "DNA_node_types.h" @@ -36,23 +36,27 @@ #include "BKE_colortools.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_icons.h" #include "BKE_image.h" +#include "BKE_image_format.h" #include "BKE_image_save.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_packedFile.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" +#include "GPU_state.h" + #include "IMB_colormanagement.hh" #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" #include "IMB_moviecache.hh" +#include "IMB_openexr.hh" #include "RE_pipeline.h" @@ -66,6 +70,7 @@ #include "ED_paint.hh" #include "ED_render.hh" #include "ED_screen.hh" +#include "ED_space_api.hh" #include "ED_undo.hh" #include "ED_util.hh" #include "ED_util_imbuf.hh" @@ -536,7 +541,7 @@ static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *eve if (U.viewzoom == USER_ZOOM_CONTINUE) { /* needs a timer to continue redrawing */ vpd->timer = WM_event_timer_add(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f); - vpd->timer_lastdraw = BLI_time_now_seconds(); + vpd->timer_lastdraw = BLI_check_seconds_timer(); } vpd->sima = sima; @@ -646,7 +651,7 @@ static void image_zoom_apply(ViewZoomData *vpd, } if (viewzoom == USER_ZOOM_CONTINUE) { - double time = BLI_time_now_seconds(); + double time = BLI_check_seconds_timer(); float time_step = float(time - vpd->timer_lastdraw); float zfac; zfac = 1.0f + ((delta / 20.0f) * time_step); diff --git a/source/blender/editors/space_image/image_sequence.cc b/source/blender/editors/space_image/image_sequence.cc index c08c6501007..d2a8c8399fc 100644 --- a/source/blender/editors/space_image/image_sequence.cc +++ b/source/blender/editors/space_image/image_sequence.cc @@ -10,6 +10,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_fileops.h" #include "BLI_fileops_types.h" #include "BLI_listbase.h" #include "BLI_math_base.h" diff --git a/source/blender/editors/space_image/space_image.cc b/source/blender/editors/space_image/space_image.cc index 7c5beaafd27..06adb96a655 100644 --- a/source/blender/editors/space_image/space_image.cc +++ b/source/blender/editors/space_image/space_image.cc @@ -22,6 +22,7 @@ #include "BKE_context.hh" #include "BKE_image.h" #include "BKE_layer.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_lib_remap.hh" #include "BKE_screen.hh" @@ -30,6 +31,8 @@ #include "RNA_define.hh" #include "RNA_enum_types.hh" +#include "DEG_depsgraph.hh" + #include "IMB_imbuf_types.hh" #include "ED_image.hh" @@ -1006,19 +1009,19 @@ static void image_header_region_listener(const wmRegionListenerParams *params) } } -static void image_id_remap(ScrArea * /*area*/, - SpaceLink *slink, - const blender::bke::id::IDRemapper &mappings) +static void image_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings) { SpaceImage *simg = (SpaceImage *)slink; - if (!mappings.contains_mappings_for_any(FILTER_ID_IM | FILTER_ID_GD_LEGACY | FILTER_ID_MSK)) { + if (!BKE_id_remapper_has_mapping_for(mappings, + FILTER_ID_IM | FILTER_ID_GD_LEGACY | FILTER_ID_MSK)) + { return; } - mappings.apply((ID **)&simg->image, ID_REMAP_APPLY_ENSURE_REAL); - mappings.apply((ID **)&simg->gpd, ID_REMAP_APPLY_UPDATE_REFCOUNT); - mappings.apply((ID **)&simg->mask_info.mask, ID_REMAP_APPLY_ENSURE_REAL); + BKE_id_remapper_apply(mappings, (ID **)&simg->image, ID_REMAP_APPLY_ENSURE_REAL); + BKE_id_remapper_apply(mappings, (ID **)&simg->gpd, ID_REMAP_APPLY_UPDATE_REFCOUNT); + BKE_id_remapper_apply(mappings, (ID **)&simg->mask_info.mask, ID_REMAP_APPLY_ENSURE_REAL); } static void image_foreach_id(SpaceLink *space_link, LibraryForeachIDData *data) diff --git a/source/blender/editors/space_info/info_draw.cc b/source/blender/editors/space_info/info_draw.cc index 5ee03d5b2dc..b0312941bbe 100644 --- a/source/blender/editors/space_info/info_draw.cc +++ b/source/blender/editors/space_info/info_draw.cc @@ -12,8 +12,9 @@ #include "BLI_utildefines.h" #include "DNA_screen_types.h" +#include "DNA_space_types.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/editors/space_info/info_ops.cc b/source/blender/editors/space_info/info_ops.cc index f18544f9dc2..a23eb42a71c 100644 --- a/source/blender/editors/space_info/info_ops.cc +++ b/source/blender/editors/space_info/info_ops.cc @@ -15,18 +15,19 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" -#include "BKE_bpath.hh" +#include "BKE_bpath.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_packedFile.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "WM_api.hh" diff --git a/source/blender/editors/space_info/info_report.cc b/source/blender/editors/space_info/info_report.cc index 2aa3b256670..481f40df6ca 100644 --- a/source/blender/editors/space_info/info_report.cc +++ b/source/blender/editors/space_info/info_report.cc @@ -12,6 +12,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_dynstr.h" #include "BLI_utildefines.h" diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index e1ffa8588e1..adc48915562 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -12,6 +12,7 @@ #include "MEM_guardedalloc.h" #include "DNA_armature_types.h" +#include "DNA_collection_types.h" #include "DNA_curve_types.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_grease_pencil_types.h" @@ -32,13 +33,15 @@ #include "BLI_timecode.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" #include "BKE_armature.hh" #include "BKE_blender_version.h" +#include "BKE_context.hh" #include "BKE_curve.hh" #include "BKE_curves.hh" +#include "BKE_displist.h" #include "BKE_editmesh.hh" #include "BKE_gpencil_legacy.h" #include "BKE_grease_pencil.hh" @@ -48,8 +51,9 @@ #include "BKE_mesh.hh" #include "BKE_object.hh" #include "BKE_paint.hh" +#include "BKE_particle.h" #include "BKE_pbvh_api.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_subdiv_ccg.hh" #include "BKE_subdiv_modifier.hh" @@ -484,7 +488,7 @@ static bool format_stats( if (*stats_p == nullptr) { /* Don't access dependency graph if interface is marked as locked. */ wmWindowManager *wm = (wmWindowManager *)bmain->wm.first; - if (wm->runtime->is_interface_locked) { + if (wm->is_interface_locked) { return false; } Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer); diff --git a/source/blender/editors/space_info/space_info.cc b/source/blender/editors/space_info/space_info.cc index c3aa588f7dd..0adab579015 100644 --- a/source/blender/editors/space_info/space_info.cc +++ b/source/blender/editors/space_info/space_info.cc @@ -24,6 +24,8 @@ #include "WM_message.hh" #include "WM_types.hh" +#include "RNA_access.hh" + #include "UI_resources.hh" #include "UI_view2d.hh" diff --git a/source/blender/editors/space_nla/nla_buttons.cc b/source/blender/editors/space_nla/nla_buttons.cc index b1c92cace38..ede967654bf 100644 --- a/source/blender/editors/space_nla/nla_buttons.cc +++ b/source/blender/editors/space_nla/nla_buttons.cc @@ -19,7 +19,7 @@ #include "BLI_blenlib.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_fcurve.h" @@ -33,6 +33,7 @@ #include "RNA_prototypes.h" #include "ED_anim_api.hh" +#include "ED_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/editors/space_nla/nla_draw.cc b/source/blender/editors/space_nla/nla_draw.cc index 79e46f25141..794d4007b88 100644 --- a/source/blender/editors/space_nla/nla_draw.cc +++ b/source/blender/editors/space_nla/nla_draw.cc @@ -16,14 +16,18 @@ #include "DNA_node_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "DNA_windowmanager_types.h" #include "BLI_blenlib.h" +#include "BLI_dlrbTree.h" #include "BLI_range.h" #include "BLI_utildefines.h" #include "BKE_action.h" +#include "BKE_context.hh" #include "BKE_fcurve.h" #include "BKE_nla.h" +#include "BKE_screen.hh" #include "ED_anim_api.hh" #include "ED_keyframes_draw.hh" diff --git a/source/blender/editors/space_nla/nla_edit.cc b/source/blender/editors/space_nla/nla_edit.cc index 4f1b613c4fa..573866f225e 100644 --- a/source/blender/editors/space_nla/nla_edit.cc +++ b/source/blender/editors/space_nla/nla_edit.cc @@ -16,21 +16,25 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "BKE_action.h" #include "BKE_context.hh" #include "BKE_fcurve.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_nla.h" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BKE_screen.hh" #include "ED_anim_api.hh" #include "ED_keyframes_edit.hh" #include "ED_markers.hh" #include "ED_screen.hh" +#include "ED_transform.hh" #include "RNA_access.hh" #include "RNA_define.hh" @@ -42,6 +46,7 @@ #include "DEG_depsgraph_build.hh" +#include "UI_interface.hh" #include "UI_view2d.hh" #include "nla_intern.hh" diff --git a/source/blender/editors/space_nla/nla_ops.cc b/source/blender/editors/space_nla/nla_ops.cc index 2b52e9dd1be..c08657bd260 100644 --- a/source/blender/editors/space_nla/nla_ops.cc +++ b/source/blender/editors/space_nla/nla_ops.cc @@ -12,6 +12,7 @@ #include "DNA_scene_types.h" #include "BKE_context.hh" +#include "BKE_screen.hh" #include "ED_anim_api.hh" #include "ED_screen.hh" diff --git a/source/blender/editors/space_nla/nla_select.cc b/source/blender/editors/space_nla/nla_select.cc index 812d1b7e2e7..892c9282c31 100644 --- a/source/blender/editors/space_nla/nla_select.cc +++ b/source/blender/editors/space_nla/nla_select.cc @@ -14,9 +14,12 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_math_base.h" +#include "BKE_context.hh" #include "BKE_nla.h" +#include "BKE_screen.hh" #include "ED_anim_api.hh" #include "ED_keyframes_edit.hh" @@ -29,6 +32,7 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "UI_interface.hh" #include "UI_view2d.hh" #include "nla_intern.hh" /* own include */ diff --git a/source/blender/editors/space_nla/nla_tracks.cc b/source/blender/editors/space_nla/nla_tracks.cc index 8ca06b4231a..40aec83d92e 100644 --- a/source/blender/editors/space_nla/nla_tracks.cc +++ b/source/blender/editors/space_nla/nla_tracks.cc @@ -15,14 +15,17 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BKE_anim_data.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_nla.h" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "ED_anim_api.hh" #include "ED_keyframes_edit.hh" @@ -35,6 +38,8 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "UI_interface.hh" + #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" diff --git a/source/blender/editors/space_nla/space_nla.cc b/source/blender/editors/space_nla/space_nla.cc index aa6d1a22b52..b41d5b7271f 100644 --- a/source/blender/editors/space_nla/space_nla.cc +++ b/source/blender/editors/space_nla/space_nla.cc @@ -554,18 +554,17 @@ static void nla_listener(const wmSpaceTypeListenerParams *params) } } -static void nla_id_remap(ScrArea * /*area*/, - SpaceLink *slink, - const blender::bke::id::IDRemapper &mappings) +static void nla_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings) { SpaceNla *snla = reinterpret_cast(slink); if (snla->ads == nullptr) { return; } - - mappings.apply(reinterpret_cast(&snla->ads->filter_grp), ID_REMAP_APPLY_DEFAULT); - mappings.apply(reinterpret_cast(&snla->ads->source), ID_REMAP_APPLY_DEFAULT); + BKE_id_remapper_apply( + mappings, reinterpret_cast(&snla->ads->filter_grp), ID_REMAP_APPLY_DEFAULT); + BKE_id_remapper_apply( + mappings, reinterpret_cast(&snla->ads->source), ID_REMAP_APPLY_DEFAULT); } static void nla_foreach_id(SpaceLink *space_link, LibraryForeachIDData *data) diff --git a/source/blender/editors/space_node/add_menu_assets.cc b/source/blender/editors/space_node/add_menu_assets.cc index b09e6817f54..37af78d64c4 100644 --- a/source/blender/editors/space_node/add_menu_assets.cc +++ b/source/blender/editors/space_node/add_menu_assets.cc @@ -10,19 +10,21 @@ #include "BLI_multi_value_map.hh" #include "BLI_string.h" +#include "DNA_screen_types.h" #include "DNA_space_types.h" #include "BKE_asset.hh" #include "BKE_idprop.h" #include "BKE_screen.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "ED_asset.hh" #include "ED_asset_menu_utils.hh" #include "ED_node.hh" +#include "ED_screen.hh" #include "node_intern.hh" diff --git a/source/blender/editors/space_node/clipboard.cc b/source/blender/editors/space_node/clipboard.cc index 667c6a3b359..fdd76cb06d4 100644 --- a/source/blender/editors/space_node/clipboard.cc +++ b/source/blender/editors/space_node/clipboard.cc @@ -5,17 +5,20 @@ #include "DNA_space_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_node.hh" #include "BKE_node_runtime.hh" -#include "BKE_report.hh" +#include "BKE_node_tree_update.hh" +#include "BKE_report.h" #include "ED_node.hh" #include "ED_render.hh" #include "ED_screen.hh" +#include "NOD_socket.hh" + #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index 9f605c6f32d..4a3eec89921 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -26,11 +26,11 @@ #include "BKE_node_enum.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_tracking.h" #include "BLF_api.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BIF_glutil.hh" @@ -1201,7 +1201,6 @@ static const float std_node_socket_colors[][4] = { {0.92, 0.46, 0.51, 1.0}, /* SOCK_MATERIAL */ {0.65, 0.39, 0.78, 1.0}, /* SOCK_ROTATION */ {0.40, 0.40, 0.40, 1.0}, /* SOCK_MENU */ - {0.72, 0.20, 0.52, 1.0}, /* SOCK_MATRIX */ }; /* Callback for colors that does not depend on the socket pointer argument to get the type. */ @@ -1237,7 +1236,6 @@ static const SocketColorFn std_node_socket_color_funcs[] = { std_node_socket_color_fn, std_node_socket_color_fn, std_node_socket_color_fn, - std_node_socket_color_fn, }; /* draw function for file output node sockets, @@ -1352,10 +1350,6 @@ static void std_node_socket_draw( uiItemR(column, ptr, "default_value", DEFAULT_FLAGS, text, ICON_NONE); break; } - case SOCK_MATRIX: { - uiItemL(layout, text, ICON_NONE); - break; - } case SOCK_RGBA: { if (text[0] == '\0') { uiItemR(layout, ptr, "default_value", DEFAULT_FLAGS, "", ICON_NONE); @@ -1534,7 +1528,6 @@ static void std_node_socket_interface_draw(ID *id, } case SOCK_SHADER: case SOCK_GEOMETRY: - case SOCK_MATRIX: break; case SOCK_CUSTOM: diff --git a/source/blender/editors/space_node/link_drag_search.cc b/source/blender/editors/space_node/link_drag_search.cc index 19131068365..b97dc3390b4 100644 --- a/source/blender/editors/space_node/link_drag_search.cc +++ b/source/blender/editors/space_node/link_drag_search.cc @@ -21,7 +21,9 @@ #include "NOD_socket.hh" #include "NOD_socket_search_link.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" + +#include "RNA_access.hh" #include "WM_api.hh" diff --git a/source/blender/editors/space_node/node_add.cc b/source/blender/editors/space_node/node_add.cc index 2a1ee8955d0..df4267ea3ec 100644 --- a/source/blender/editors/space_node/node_add.cc +++ b/source/blender/editors/space_node/node_add.cc @@ -19,7 +19,7 @@ #include "BLI_listbase.h" #include "BLI_math_geom.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_image.h" @@ -28,8 +28,8 @@ #include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_texture.h" #include "DEG_depsgraph_build.hh" diff --git a/source/blender/editors/space_node/node_context_path.cc b/source/blender/editors/space_node/node_context_path.cc index 64bc5fd2f35..ee1b18d2d85 100644 --- a/source/blender/editors/space_node/node_context_path.cc +++ b/source/blender/editors/space_node/node_context_path.cc @@ -13,8 +13,12 @@ #include "BKE_context.hh" #include "BKE_material.h" +#include "BKE_modifier.hh" #include "BKE_object.hh" +#include "BKE_screen.hh" + +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "ED_screen.hh" diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 63dae4ff9ce..7d969882dbc 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -32,12 +32,12 @@ #include "BLI_string_ref.hh" #include "BLI_vector.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_compute_contexts.hh" #include "BKE_context.hh" #include "BKE_curves.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" @@ -46,8 +46,7 @@ #include "BKE_node_tree_update.hh" #include "BKE_node_tree_zones.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" -#include "BKE_scene_runtime.hh" +#include "BKE_scene.h" #include "BKE_type_conversions.hh" #include "IMB_imbuf.hh" @@ -93,8 +92,6 @@ #include "GEO_fillet_curves.hh" -#include "COM_profile.hh" - #include "node_intern.hh" /* own include */ #include @@ -129,9 +126,6 @@ struct TreeDrawContext { * True if there is an active realtime compositor using the node tree, false otherwise. */ bool used_by_realtime_compositor = false; - - blender::Map - *compositor_per_node_execution_time = nullptr; }; float ED_node_grid_size() @@ -614,36 +608,17 @@ static Vector node_build_item_data(bNode &node) if (const nodes::SocketDeclaration *socket_decl = dynamic_cast(item_decl->get())) { - if (socket_decl->align_with_previous_socket) { - NodeInterfaceItemData &last_item = result.last(); - switch (socket_decl->in_out) { - case SOCK_IN: - BLI_assert(input != input_end); - BLI_assert(last_item.input == nullptr); - last_item.input = *input; - ++input; - break; - case SOCK_OUT: - BLI_assert(output != output_end); - BLI_assert(last_item.output == nullptr); - last_item.output = *output; - ++output; - break; - } - } - else { - switch (socket_decl->in_out) { - case SOCK_IN: - BLI_assert(input != input_end); - result.append({socket_decl, *input, nullptr}); - ++input; - break; - case SOCK_OUT: - BLI_assert(output != output_end); - result.append({socket_decl, nullptr, *output}); - ++output; - break; - } + switch (socket_decl->in_out) { + case SOCK_IN: + BLI_assert(input != input_end); + result.append({socket_decl, *input, nullptr}); + ++input; + break; + case SOCK_OUT: + BLI_assert(output != output_end); + result.append({socket_decl, nullptr, *output}); + ++output; + break; } ++item_decl; } @@ -1322,14 +1297,6 @@ static void create_inspection_string_for_generic_value(const bNodeSocket &socket ss << fmt::format(TIP_("{} (Boolean)"), ((*static_cast(socket_value)) ? TIP_("True") : TIP_("False"))); } - else if (socket_type.is()) { - const float4x4 &value = *static_cast(socket_value); - ss << value[0] << ",\n"; - ss << value[1] << ",\n"; - ss << value[2] << ",\n"; - ss << value[3] << ",\n"; - ss << TIP_("(Matrix)"); - } } static void create_inspection_string_for_field_info(const bNodeSocket &socket, @@ -2441,11 +2408,9 @@ static void node_add_error_message_button(const TreeDrawContext &tree_draw_ctx, UI_block_emboss_set(&block, UI_EMBOSS); } -static std::optional geo_node_get_execution_time( - const TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node) +static std::optional node_get_execution_time( + const TreeDrawContext &tree_draw_ctx, const bNodeTree &ntree, const bNode &node) { - const bNodeTree &ntree = *snode.edittree; - geo_log::GeoTreeLog *tree_log = [&]() -> geo_log::GeoTreeLog * { const bNodeTreeZones *zones = ntree.zones(); if (!zones) { @@ -2468,8 +2433,8 @@ static std::optional geo_node_get_execution_time( for (const bNode *tnode : node.direct_children_in_frame()) { if (tnode->is_frame()) { - std::optional sub_frame_run_time = geo_node_get_execution_time( - tree_draw_ctx, snode, *tnode); + std::optional sub_frame_run_time = node_get_execution_time( + tree_draw_ctx, ntree, *tnode); if (sub_frame_run_time.has_value()) { run_time += *sub_frame_run_time; found_node = true; @@ -2494,87 +2459,12 @@ static std::optional geo_node_get_execution_time( return std::nullopt; } -/* Create node key instance, assuming the node comes from the currently edited node tree. */ -static bNodeInstanceKey current_node_instance_key(const SpaceNode &snode, const bNode &node) -{ - const bNodeTreePath *path = static_cast(snode.treepath.last); - - /* Some code in this file checks for the non-null elements of the tree path. However, if we did - * iterate into a node it is expected that there is a tree, and it should be in the path. - * Otherwise something else went wrong. */ - BLI_assert(path); - - /* Assume that the currently editing tree is the last in the path. */ - BLI_assert(snode.edittree == path->nodetree); - - return BKE_node_instance_key(path->parent_key, snode.edittree, &node); -} - -static std::optional compositor_accumulate_frame_node_execution_time( - const TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node) -{ - BLI_assert(tree_draw_ctx.compositor_per_node_execution_time); - - timeit::Nanoseconds frame_execution_time(0); - bool has_any_execution_time = false; - - for (const bNode *current_node : node.direct_children_in_frame()) { - const bNodeInstanceKey key = current_node_instance_key(snode, *current_node); - if (const timeit::Nanoseconds *node_execution_time = - tree_draw_ctx.compositor_per_node_execution_time->lookup_ptr(key)) - { - frame_execution_time += *node_execution_time; - has_any_execution_time = true; - } - } - - if (!has_any_execution_time) { - return std::nullopt; - } - - return frame_execution_time; -} - -static std::optional compositor_node_get_execution_time( - const TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node) -{ - BLI_assert(tree_draw_ctx.compositor_per_node_execution_time); - - /* For the frame nodes accumulate execution time of its children. */ - if (node.is_frame()) { - return compositor_accumulate_frame_node_execution_time(tree_draw_ctx, snode, node); - } - - /* For other nodes simply lookup execution time. - * The group node instances have their own entries in the execution times map. */ - const bNodeInstanceKey key = current_node_instance_key(snode, node); - if (const timeit::Nanoseconds *execution_time = - tree_draw_ctx.compositor_per_node_execution_time->lookup_ptr(key)) - { - return *execution_time; - } - - return std::nullopt; -} - -static std::optional node_get_execution_time( - const TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node) -{ - switch (snode.edittree->type) { - case NTREE_GEOMETRY: - return geo_node_get_execution_time(tree_draw_ctx, snode, node); - case NTREE_COMPOSIT: - return compositor_node_get_execution_time(tree_draw_ctx, snode, node); - } - return std::nullopt; -} - static std::string node_get_execution_time_label(TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node) { const std::optional exec_time = node_get_execution_time( - tree_draw_ctx, snode, node); + tree_draw_ctx, *snode.edittree, node); if (!exec_time.has_value()) { return std::string(""); @@ -2713,35 +2603,6 @@ static std::optional node_get_accessed_attributes_row( return row_from_used_named_attribute(node_log->used_named_attributes); } -static std::optional node_get_execution_time_label_row( - TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, const bNode &node) -{ - NodeExtraInfoRow row; - row.text = node_get_execution_time_label(tree_draw_ctx, snode, node); - if (row.text.empty()) { - return std::nullopt; - } - row.tooltip = TIP_( - "The execution time from the node tree's latest evaluation. For frame and group " - "nodes, the time for all sub-nodes"); - row.icon = ICON_PREVIEW_RANGE; - return row; -} - -static void node_get_compositor_extra_info(TreeDrawContext &tree_draw_ctx, - const SpaceNode &snode, - const bNode &node, - Vector &rows) -{ - if (snode.overlay.flag & SN_OVERLAY_SHOW_TIMINGS) { - std::optional row = node_get_execution_time_label_row( - tree_draw_ctx, snode, node); - if (row.has_value()) { - rows.append(std::move(*row)); - } - } -} - static Vector node_get_extra_info(const bContext &C, TreeDrawContext &tree_draw_ctx, const SpaceNode &snode, @@ -2762,13 +2623,8 @@ static Vector node_get_extra_info(const bContext &C, rows.append(std::move(row)); } - if (snode.edittree->type == NTREE_COMPOSIT) { - node_get_compositor_extra_info(tree_draw_ctx, snode, node, rows); - return rows; - } - if (!(snode.edittree->type == NTREE_GEOMETRY)) { - /* Currently geometry and compositor nodes are the only nodes to have extra info per nodes. */ + /* Currently geometry nodes are the only nodes to have extra infos per nodes. */ return rows; } @@ -2784,10 +2640,15 @@ static Vector node_get_extra_info(const bContext &C, (ELEM(node.typeinfo->nclass, NODE_CLASS_GEOMETRY, NODE_CLASS_GROUP, NODE_CLASS_ATTRIBUTE) || ELEM(node.type, NODE_FRAME, NODE_GROUP_OUTPUT))) { - std::optional row = node_get_execution_time_label_row( - tree_draw_ctx, snode, node); - if (row.has_value()) { - rows.append(std::move(*row)); + NodeExtraInfoRow row; + row.text = node_get_execution_time_label(tree_draw_ctx, snode, node); + if (!row.text.empty()) { + row.tooltip = TIP_( + "The execution time from the node tree's latest evaluation. For frame and group " + "nodes, " + "the time for all sub-nodes"); + row.icon = ICON_PREVIEW_RANGE; + rows.append(std::move(row)); } } @@ -4225,7 +4086,7 @@ static bool realtime_compositor_is_in_use(const bContext &context) } if (U.experimental.use_full_frame_compositor && - scene->nodetree->execution_mode == NTREE_EXECUTION_MODE_GPU) + scene->nodetree->execution_mode == NTREE_EXECUTION_MODE_REALTIME) { return true; } @@ -4279,10 +4140,7 @@ static void draw_nodetree(const bContext &C, workspace->viewer_path, *snode); } else if (ntree.type == NTREE_COMPOSIT) { - const Scene *scene = CTX_data_scene(&C); tree_draw_ctx.used_by_realtime_compositor = realtime_compositor_is_in_use(C); - tree_draw_ctx.compositor_per_node_execution_time = - &scene->runtime->compositor.per_node_execution_time; } else if (ntree.type == NTREE_SHADER && U.experimental.use_shader_node_previews && BKE_scene_uses_shader_previews(CTX_data_scene(&C)) && diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 029b18515f3..2bd944f7d01 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -10,29 +10,32 @@ #include "MEM_guardedalloc.h" +#include "DNA_light_types.h" #include "DNA_material_types.h" #include "DNA_node_types.h" #include "DNA_text_types.h" #include "DNA_world_types.h" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" +#include "BKE_image_format.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_material.h" #include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" -#include "BKE_scene_runtime.hh" +#include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_workspace.h" +#include "BLI_set.hh" #include "BLI_string.h" #include "BLI_string_utf8.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" @@ -46,10 +49,12 @@ #include "ED_node.hh" /* own include */ #include "ED_render.hh" #include "ED_screen.hh" +#include "ED_select_utils.hh" #include "ED_viewer_path.hh" #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "RNA_prototypes.h" #include "WM_api.hh" @@ -69,8 +74,6 @@ #include "NOD_texture.h" #include "node_intern.hh" /* own include */ -#include "COM_profile.hh" - namespace blender::ed::space_node { #define USE_ESC_COMPO @@ -101,8 +104,6 @@ struct CompoJob { bool *do_update; float *progress; bool cancelled; - - blender::compositor::ProfilerData profiler_data; }; float node_socket_calculate_height(const bNodeSocket &socket) @@ -222,8 +223,7 @@ static void compo_freejob(void *cjv) if (cj->compositor_depsgraph != nullptr) { DEG_graph_free(cj->compositor_depsgraph); } - - MEM_delete(cj); + MEM_freeN(cj); } /* Only now we copy the nodetree, so adding many jobs while @@ -296,23 +296,15 @@ static void compo_startjob(void *cjv, wmJobWorkerStatus *worker_status) BKE_callback_exec_id(cj->bmain, &scene->id, BKE_CB_EVT_COMPOSITE_PRE); if ((cj->scene->r.scemode & R_MULTIVIEW) == 0) { - ntreeCompositExecTree( - cj->re, cj->scene, ntree, &cj->scene->r, false, true, "", nullptr, cj->profiler_data); + ntreeCompositExecTree(cj->re, cj->scene, ntree, &cj->scene->r, false, true, "", nullptr); } else { LISTBASE_FOREACH (SceneRenderView *, srv, &scene->r.views) { if (BKE_scene_multiview_is_render_view_active(&scene->r, srv) == false) { continue; } - ntreeCompositExecTree(cj->re, - cj->scene, - ntree, - &cj->scene->r, - false, - true, - srv->name, - nullptr, - cj->profiler_data); + ntreeCompositExecTree( + cj->re, cj->scene, ntree, &cj->scene->r, false, true, srv->name, nullptr); } } @@ -328,8 +320,6 @@ static void compo_canceljob(void *cjv) Scene *scene = cj->scene; BKE_callback_exec_id(bmain, &scene->id, BKE_CB_EVT_COMPOSITE_CANCEL); cj->cancelled = true; - - scene->runtime->compositor.per_node_execution_time = cj->profiler_data.per_node_execution_time; } static void compo_completejob(void *cjv) @@ -338,8 +328,6 @@ static void compo_completejob(void *cjv) Main *bmain = cj->bmain; Scene *scene = cj->scene; BKE_callback_exec_id(bmain, &scene->id, BKE_CB_EVT_COMPOSITE_POST); - - scene->runtime->compositor.per_node_execution_time = cj->profiler_data.per_node_execution_time; } /** \} */ @@ -357,7 +345,7 @@ static bool is_compositing_possible(const bContext *C) Scene *scene = CTX_data_scene(C); /* CPU compositor can always run. */ if (!U.experimental.use_full_frame_compositor || - scene->nodetree->execution_mode != NTREE_EXECUTION_MODE_GPU) + scene->nodetree->execution_mode != NTREE_EXECUTION_MODE_REALTIME) { return true; } @@ -407,7 +395,7 @@ void ED_node_composite_job(const bContext *C, bNodeTree *nodetree, Scene *scene_ "Compositing", WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS, WM_JOB_TYPE_COMPOSITE); - CompoJob *cj = MEM_new("compo job"); + CompoJob *cj = MEM_cnew("compo job"); /* Custom data for preview thread. */ cj->bmain = bmain; @@ -633,6 +621,7 @@ void ED_node_composit_default(const bContext *C, Scene *sce) sce->nodetree = blender::bke::ntreeAddTreeEmbedded( nullptr, &sce->id, "Compositing Nodetree", ntreeType_Composite->idname); + sce->nodetree->chunksize = 256; sce->nodetree->edit_quality = NTREE_QUALITY_HIGH; sce->nodetree->render_quality = NTREE_QUALITY_HIGH; diff --git a/source/blender/editors/space_node/node_geometry_attribute_search.cc b/source/blender/editors/space_node/node_geometry_attribute_search.cc index 04b08a2474e..9b5cf5d4361 100644 --- a/source/blender/editors/space_node/node_geometry_attribute_search.cc +++ b/source/blender/editors/space_node/node_geometry_attribute_search.cc @@ -28,7 +28,7 @@ #include "ED_screen.hh" #include "ED_undo.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "UI_interface.hh" #include "UI_resources.hh" @@ -157,7 +157,6 @@ static eCustomDataType data_type_in_attribute_input_node(const eCustomDataType t case CD_PROP_COLOR: case CD_PROP_BOOL: case CD_PROP_QUATERNION: - case CD_PROP_FLOAT4X4: return type; case CD_PROP_BYTE_COLOR: return CD_PROP_COLOR; diff --git a/source/blender/editors/space_node/node_gizmo.cc b/source/blender/editors/space_node/node_gizmo.cc index 0cef20f33c2..47c7c0ab9d8 100644 --- a/source/blender/editors/space_node/node_gizmo.cc +++ b/source/blender/editors/space_node/node_gizmo.cc @@ -15,6 +15,7 @@ #include "BKE_context.hh" #include "BKE_image.h" +#include "BKE_main.hh" #include "ED_gizmo_library.hh" #include "ED_screen.hh" @@ -26,6 +27,7 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "WM_api.hh" #include "WM_types.hh" #include "node_intern.hh" diff --git a/source/blender/editors/space_node/node_group.cc b/source/blender/editors/space_node/node_group.cc index 824e01a5766..f97870b9427 100644 --- a/source/blender/editors/space_node/node_group.cc +++ b/source/blender/editors/space_node/node_group.cc @@ -22,7 +22,7 @@ #include "BLI_string.h" #include "BLI_vector.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" #include "BKE_animsys.h" @@ -31,7 +31,7 @@ #include "BKE_main.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph_build.hh" diff --git a/source/blender/editors/space_node/node_ops.cc b/source/blender/editors/space_node/node_ops.cc index 6f2970fe45a..89d9c940a41 100644 --- a/source/blender/editors/space_node/node_ops.cc +++ b/source/blender/editors/space_node/node_ops.cc @@ -8,6 +8,8 @@ #include "DNA_node_types.h" +#include "BKE_context.hh" + #include "ED_node.hh" /* own include */ #include "ED_screen.hh" diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc index 74cac434386..af83bec6b6b 100644 --- a/source/blender/editors/space_node/node_relationships.cc +++ b/source/blender/editors/space_node/node_relationships.cc @@ -8,38 +8,50 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_node_types.h" #include "BLI_easing.h" #include "BLI_math_geom.h" #include "BLI_stack.hh" +#include "BKE_anim_data.h" #include "BKE_context.hh" +#include "BKE_curve.hh" +#include "BKE_lib_id.hh" +#include "BKE_main.hh" #include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" +#include "BKE_screen.hh" #include "ED_node.hh" /* own include */ #include "ED_render.hh" #include "ED_screen.hh" #include "ED_space_api.hh" +#include "ED_util.hh" #include "ED_viewer_path.hh" #include "RNA_access.hh" #include "RNA_define.hh" #include "RNA_prototypes.h" +#include "DEG_depsgraph.hh" + #include "WM_api.hh" #include "WM_types.hh" +#include "GPU_state.h" + #include "UI_interface_icons.hh" #include "UI_resources.hh" #include "UI_view2d.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "NOD_node_declaration.hh" #include "NOD_socket.hh" +#include "NOD_socket_declarations.hh" #include "NOD_socket_declarations_geometry.hh" #include "node_intern.hh" /* own include */ @@ -2230,7 +2242,6 @@ static int get_main_socket_priority(const bNodeSocket *socket) case SOCK_OBJECT: case SOCK_IMAGE: case SOCK_ROTATION: - case SOCK_MATRIX: case SOCK_GEOMETRY: case SOCK_COLLECTION: case SOCK_TEXTURE: diff --git a/source/blender/editors/space_node/node_shader_preview.cc b/source/blender/editors/space_node/node_shader_preview.cc index 468236d539e..4dad85296c5 100644 --- a/source/blender/editors/space_node/node_shader_preview.cc +++ b/source/blender/editors/space_node/node_shader_preview.cc @@ -34,7 +34,7 @@ #include "BKE_colortools.hh" #include "BKE_compute_contexts.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" @@ -42,6 +42,7 @@ #include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" @@ -49,6 +50,7 @@ #include "WM_api.hh" +#include "ED_datafiles.h" #include "ED_node_preview.hh" #include "ED_render.hh" #include "ED_screen.hh" diff --git a/source/blender/editors/space_node/node_templates.cc b/source/blender/editors/space_node/node_templates.cc index 8ee502f00f5..6c6ec2b53d8 100644 --- a/source/blender/editors/space_node/node_templates.cc +++ b/source/blender/editors/space_node/node_templates.cc @@ -20,7 +20,7 @@ #include "BLI_string_utf8.h" #include "BLI_vector.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_lib_id.hh" @@ -391,9 +391,6 @@ static Vector ui_node_link_items(NodeLinkArg *arg, else if (dynamic_cast(&socket_decl)) { item.socket_type = SOCK_ROTATION; } - else if (dynamic_cast(&socket_decl)) { - item.socket_type = SOCK_MATRIX; - } else if (dynamic_cast(&socket_decl)) { item.socket_type = SOCK_STRING; } diff --git a/source/blender/editors/space_node/node_view.cc b/source/blender/editors/space_node/node_view.cc index c5711be4ddf..e2c689b2526 100644 --- a/source/blender/editors/space_node/node_view.cc +++ b/source/blender/editors/space_node/node_view.cc @@ -8,13 +8,17 @@ #include "DNA_node_types.h" +#include "BLI_listbase.h" #include "BLI_rect.h" #include "BLI_string_ref.hh" #include "BLI_utildefines.h" #include "BKE_context.hh" #include "BKE_image.h" +#include "BKE_main.hh" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" +#include "BKE_screen.hh" #include "ED_image.hh" #include "ED_node.hh" /* own include */ diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index 169a323b086..d8015fb8e26 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -12,7 +12,9 @@ #include "BLI_string.h" #include "DNA_ID.h" +#include "DNA_gpencil_legacy_types.h" #include "DNA_image_types.h" +#include "DNA_light_types.h" #include "DNA_material_types.h" #include "DNA_modifier_types.h" #include "DNA_node_types.h" @@ -20,6 +22,7 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_windowmanager_types.h" +#include "DNA_world_types.h" #include "MEM_guardedalloc.h" @@ -31,6 +34,7 @@ #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_lib_remap.hh" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_zones.hh" #include "BKE_screen.hh" @@ -38,6 +42,7 @@ #include "ED_image.hh" #include "ED_node.hh" #include "ED_node_preview.hh" +#include "ED_render.hh" #include "ED_screen.hh" #include "ED_space_api.hh" @@ -1223,9 +1228,7 @@ static void node_id_remap_cb(ID *old_id, ID *new_id, void *user_data) } } -static void node_id_remap(ScrArea * /*area*/, - SpaceLink *slink, - const blender::bke::id::IDRemapper &mappings) +static void node_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings) { /* Although we should be able to perform all the mappings in a single go this lead to issues when * running the python test cases. Somehow the nodetree/edittree weren't updated to the new @@ -1238,7 +1241,7 @@ static void node_id_remap(ScrArea * /*area*/, * We could also move a remap address at a time to use the IDRemapper as that should get closer * to cleaner code. See {D13615} for more information about this topic. */ - mappings.iter(node_id_remap_cb, slink); + BKE_id_remapper_iter(mappings, node_id_remap_cb, slink); } static void node_foreach_id(SpaceLink *space_link, LibraryForeachIDData *data) diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index cd45045e901..26df8082a1c 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -4,7 +4,6 @@ set(INC ../include - ../../blenfont ../../blenkernel ../../blenloader ../../blentranslation @@ -14,8 +13,6 @@ set(INC ../../sequencer ../../windowmanager - ../../../../extern/fmtlib/include - # RNA_prototypes.h ${CMAKE_BINARY_DIR}/source/blender/makesrna ) @@ -140,7 +137,6 @@ set(LIB bf_editor_undo PRIVATE bf::intern::clog PRIVATE bf::intern::guardedalloc - extern_fmtlib ) diff --git a/source/blender/editors/space_outliner/outliner_collections.cc b/source/blender/editors/space_outliner/outliner_collections.cc index 72b7b141372..f7b7265dc71 100644 --- a/source/blender/editors/space_outliner/outliner_collections.cc +++ b/source/blender/editors/space_outliner/outliner_collections.cc @@ -15,12 +15,13 @@ #include "DNA_collection_types.h" #include "DNA_object_types.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_context.hh" +#include "BKE_idtype.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" diff --git a/source/blender/editors/space_outliner/outliner_context.cc b/source/blender/editors/space_outliner/outliner_context.cc index 444f9832567..63c747fd656 100644 --- a/source/blender/editors/space_outliner/outliner_context.cc +++ b/source/blender/editors/space_outliner/outliner_context.cc @@ -6,6 +6,8 @@ * \ingroup spoutliner */ +#include "BLI_listbase.h" + #include "BKE_context.hh" #include "DNA_space_types.h" diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.cc b/source/blender/editors/space_outliner/outliner_dragdrop.cc index d8aa5673610..fcc210d7223 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.cc +++ b/source/blender/editors/space_outliner/outliner_dragdrop.cc @@ -18,16 +18,16 @@ #include "BLI_listbase.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_context.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_material.h" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" @@ -1453,7 +1453,7 @@ static int outliner_item_drag_drop_invoke(bContext *C, wmOperator * /*op*/, cons TSE_GPENCIL_EFFECT_BASE); const eWM_DragDataType wm_drag_type = use_datastack_drag ? WM_DRAG_DATASTACK : WM_DRAG_ID; - wmDrag *drag = WM_drag_data_create(C, data.icon, wm_drag_type, nullptr, WM_DRAG_NOP); + wmDrag *drag = WM_drag_data_create(C, data.icon, wm_drag_type, nullptr, 0.0, WM_DRAG_NOP); if (use_datastack_drag) { TreeElement *te_bone = nullptr; diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 95cf40b7c6a..60c8f3eee36 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -20,10 +20,11 @@ #include "DNA_text_types.h" #include "BLI_blenlib.h" +#include "BLI_mempool.h" #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_armature.hh" #include "BKE_context.hh" @@ -42,7 +43,7 @@ #include "BKE_node.hh" #include "BKE_object.hh" #include "BKE_particle.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "ANIM_bone_collections.hh" @@ -69,6 +70,7 @@ #include "RNA_access.hh" #include "outliner_intern.hh" +#include "tree/tree_display.hh" #include "tree/tree_element.hh" #include "tree/tree_element_grease_pencil_node.hh" #include "tree/tree_element_id.hh" @@ -1853,7 +1855,7 @@ static void outliner_draw_overrides_rna_buts(uiBlock *block, uiBut *but = uiDefBut(block, UI_BTYPE_LABEL, 0, - override_elem->rna_path, + override_elem->rna_path.c_str(), x + pad_x, te->ys + pad_y, item_max_width, @@ -1876,7 +1878,7 @@ static void outliner_draw_overrides_rna_buts(uiBlock *block, uiDefBut(block, UI_BTYPE_LABEL, 0, - op_label, + op_label.c_str(), x + pad_x, te->ys + pad_y, item_max_width, diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index 979f2f3a5d5..a9d3d0a1bb5 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -7,10 +7,6 @@ */ #include -#include -#include - -#include #include "MEM_guardedalloc.h" @@ -25,9 +21,7 @@ #include "BLI_path_util.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" - -#include "BLF_api.hh" +#include "BLT_translation.h" #include "BKE_action.h" #include "BKE_animsys.h" @@ -43,7 +37,7 @@ #include "BKE_lib_remap.hh" #include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_workspace.h" #include "DEG_depsgraph.hh" @@ -2130,92 +2124,51 @@ static bool ed_operator_outliner_id_orphans_active(bContext *C) return true; } -static void unused_message_gen(std::string &message, - const std::array &num_tagged) -{ - bool is_first = true; - if (num_tagged[INDEX_ID_NULL] == 0) { - message += IFACE_("None"); - return; - } - - /* NOTE: Index is looped in reversed order, since typically 'higher level' IDs (like Collections - * or Objects) have a higher index than 'lower level' ones like object data, materials, etc. - * - * It makes more sense to present to the user the deleted numbers of Collections or Objects - * before the ones for object data or Materials. */ - for (int i = INDEX_ID_MAX - 2; i >= 0; i--) { - if (num_tagged[i] != 0) { - message += fmt::format( - "{}{} {}", - (is_first) ? "" : ", ", - num_tagged[i], - (num_tagged[i] > 1) ? - IFACE_(BKE_idtype_idcode_to_name_plural(BKE_idtype_index_to_idcode(i))) : - IFACE_(BKE_idtype_idcode_to_name(BKE_idtype_index_to_idcode(i)))); - is_first = false; - } - } -} - -static int unused_message_popup_width_compute(bContext *C) -{ - /* Computation of unused data amounts, with all options ON. - * Used to estimate the maximum required width for the dialog. */ - Main *bmain = CTX_data_main(C); - LibQueryUnusedIDsData data = {true, true, true, {}, {}, {}}; - BKE_lib_query_unused_ids_amounts(bmain, data); - - std::string unused_message = ""; - const uiStyle *style = UI_style_get_dpi(); - unused_message_gen(unused_message, data.num_local); - float max_messages_width = BLF_width( - style->widget.uifont_id, unused_message.c_str(), BLF_DRAW_STR_DUMMY_MAX); - - unused_message = ""; - unused_message_gen(unused_message, data.num_linked); - max_messages_width = std::max( - max_messages_width, - BLF_width(style->widget.uifont_id, unused_message.c_str(), BLF_DRAW_STR_DUMMY_MAX)); - - return int(std::max(max_messages_width, 300.0f)); -} - -static void outliner_orphans_purge_cleanup(wmOperator *op) -{ - if (op->customdata) { - MEM_delete(static_cast(op->customdata)); - op->customdata = nullptr; - } -} - -static bool outliner_orphans_purge_check(bContext *C, wmOperator *op) -{ - Main *bmain = CTX_data_main(C); - LibQueryUnusedIDsData &data = *static_cast(op->customdata); - - data.do_local_ids = RNA_boolean_get(op->ptr, "do_local_ids"); - data.do_linked_ids = RNA_boolean_get(op->ptr, "do_linked_ids"); - data.do_recursive = RNA_boolean_get(op->ptr, "do_recursive"); - - BKE_lib_query_unused_ids_amounts(bmain, data); - - /* Always assume count changed, and request a redraw. */ - return true; -} - static int outliner_orphans_purge_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - op->customdata = MEM_new(__func__); + Main *bmain = CTX_data_main(C); + int num_tagged[INDEX_ID_MAX] = {0}; - /* Compute expected amounts of deleted IDs and store them in 'cached' operator properties. */ - outliner_orphans_purge_check(C, op); + const bool do_local_ids = RNA_boolean_get(op->ptr, "do_local_ids"); + const bool do_linked_ids = RNA_boolean_get(op->ptr, "do_linked_ids"); + const bool do_recursive_cleanup = RNA_boolean_get(op->ptr, "do_recursive"); - return WM_operator_props_dialog_popup(C, - op, - unused_message_popup_width_compute(C), - IFACE_("Purge Unused Data From This File"), - IFACE_("Delete")); + /* Tag all IDs to delete. */ + BKE_lib_query_unused_ids_tag( + bmain, LIB_TAG_DOIT, do_local_ids, do_linked_ids, do_recursive_cleanup, num_tagged); + + RNA_int_set(op->ptr, "num_deleted", num_tagged[INDEX_ID_NULL]); + + if (num_tagged[INDEX_ID_NULL] == 0) { + BKE_report(op->reports, RPT_INFO, "No orphaned data-blocks to purge"); + return OPERATOR_CANCELLED; + } + + DynStr *dyn_str = BLI_dynstr_new(); + BLI_dynstr_appendf(dyn_str, RPT_("Purging %d unused data-blocks ("), num_tagged[INDEX_ID_NULL]); + bool is_first = true; + for (int i = 0; i < INDEX_ID_MAX - 2; i++) { + if (num_tagged[i] != 0) { + if (!is_first) { + BLI_dynstr_append(dyn_str, ", "); + } + else { + is_first = false; + } + BLI_dynstr_appendf(dyn_str, + "%d %s", + num_tagged[i], + RPT_(BKE_idtype_idcode_to_name_plural(BKE_idtype_idcode_from_index(i)))); + } + } + BLI_dynstr_append(dyn_str, RPT_("). Click here to proceed...")); + + char *message = BLI_dynstr_get_cstring(dyn_str); + int ret = WM_operator_confirm_message(C, op, message); + + MEM_freeN(message); + BLI_dynstr_free(dyn_str); + return ret; } static int outliner_orphans_purge_exec(bContext *C, wmOperator *op) @@ -2223,27 +2176,26 @@ static int outliner_orphans_purge_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); ScrArea *area = CTX_wm_area(C); SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); + int num_tagged[INDEX_ID_MAX] = {0}; - if (!op->customdata) { - op->customdata = MEM_new(__func__); - } - LibQueryUnusedIDsData &data = *static_cast(op->customdata); + if ((num_tagged[INDEX_ID_NULL] = RNA_int_get(op->ptr, "num_deleted")) == 0) { + const bool do_local_ids = RNA_boolean_get(op->ptr, "do_local_ids"); + const bool do_linked_ids = RNA_boolean_get(op->ptr, "do_linked_ids"); + const bool do_recursive_cleanup = RNA_boolean_get(op->ptr, "do_recursive"); - data.do_local_ids = RNA_boolean_get(op->ptr, "do_local_ids"); - data.do_linked_ids = RNA_boolean_get(op->ptr, "do_linked_ids"); - data.do_recursive = RNA_boolean_get(op->ptr, "do_recursive"); + /* Tag all IDs to delete. */ + BKE_lib_query_unused_ids_tag( + bmain, LIB_TAG_DOIT, do_local_ids, do_linked_ids, do_recursive_cleanup, num_tagged); - /* Tag all IDs to delete. */ - BKE_lib_query_unused_ids_tag(bmain, LIB_TAG_DOIT, data); - - if (data.num_total[INDEX_ID_NULL] == 0) { - BKE_report(op->reports, RPT_INFO, "No orphaned data-blocks to purge"); - return OPERATOR_CANCELLED; + if (num_tagged[INDEX_ID_NULL] == 0) { + BKE_report(op->reports, RPT_INFO, "No orphaned data-blocks to purge"); + return OPERATOR_CANCELLED; + } } BKE_id_multi_tagged_delete(bmain); - BKE_reportf(op->reports, RPT_INFO, "Deleted %d data-block(s)", data.num_total[INDEX_ID_NULL]); + BKE_reportf(op->reports, RPT_INFO, "Deleted %d data-block(s)", num_tagged[INDEX_ID_NULL]); /* XXX: tree management normally happens from draw_outliner(), but when * you're clicking to fast on Delete object from context menu in @@ -2259,51 +2211,9 @@ static int outliner_orphans_purge_exec(bContext *C, wmOperator *op) /* Force full redraw of the UI. */ WM_main_add_notifier(NC_WINDOW, nullptr); - outliner_orphans_purge_cleanup(op); - return OPERATOR_FINISHED; } -static void outliner_orphans_purge_cancel(bContext * /*C*/, wmOperator *op) -{ - outliner_orphans_purge_cleanup(op); -} - -static void outliner_orphans_purge_ui(bContext * /*C*/, wmOperator *op) -{ - uiLayout *layout = op->layout; - PointerRNA *ptr = op->ptr; - if (!op->customdata) { - /* This should only happen on 'adjust last operation' case, since `invoke` will not have been - * called then before showing the UI (the 'redo panel' UI uses WM-stored operator properties - * and a newly-created operator). - * - * Since that operator is not 'registered' for adjusting from undo stack, this should never - * happen currently. */ - BLI_assert_unreachable(); - op->customdata = MEM_new(__func__); - } - LibQueryUnusedIDsData &data = *static_cast(op->customdata); - - std::string unused_message = ""; - unused_message_gen(unused_message, data.num_local); - uiLayout *column = uiLayoutColumn(layout, true); - uiItemR(column, ptr, "do_local_ids", UI_ITEM_NONE, nullptr, ICON_NONE); - uiLayout *row = uiLayoutRow(column, true); - uiItemS_ex(row, 2.67f); - uiItemL(row, unused_message.c_str(), ICON_NONE); - - unused_message = ""; - unused_message_gen(unused_message, data.num_linked); - column = uiLayoutColumn(layout, true); - uiItemR(column, ptr, "do_linked_ids", UI_ITEM_NONE, nullptr, ICON_NONE); - row = uiLayoutRow(column, true); - uiItemS_ex(row, 2.67f); - uiItemL(row, unused_message.c_str(), ICON_NONE); - - uiItemR(layout, ptr, "do_recursive", UI_ITEM_NONE, nullptr, ICON_NONE); -} - void OUTLINER_OT_orphans_purge(wmOperatorType *ot) { /* identifiers */ @@ -2314,17 +2224,15 @@ void OUTLINER_OT_orphans_purge(wmOperatorType *ot) /* callbacks */ ot->invoke = outliner_orphans_purge_invoke; ot->exec = outliner_orphans_purge_exec; - ot->cancel = outliner_orphans_purge_cancel; - ot->poll = ed_operator_outliner_id_orphans_active; - ot->check = outliner_orphans_purge_check; - ot->ui = outliner_orphans_purge_ui; /* flags */ - /* NOTE: No #OPTYPE_REGISTER, since this operator should not be 'adjustable'. */ - ot->flag = OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + PropertyRNA *prop = RNA_def_int(ot->srna, "num_deleted", 0, 0, INT_MAX, "", "", 0, INT_MAX); + RNA_def_property_flag(prop, (PropertyFlag)(PROP_SKIP_SAVE | PROP_HIDDEN)); - /* Actual user-visible settings. */ RNA_def_boolean(ot->srna, "do_local_ids", true, diff --git a/source/blender/editors/space_outliner/outliner_select.cc b/source/blender/editors/space_outliner/outliner_select.cc index 69e3d269fdc..cc9f7350a51 100644 --- a/source/blender/editors/space_outliner/outliner_select.cc +++ b/source/blender/editors/space_outliner/outliner_select.cc @@ -11,6 +11,7 @@ #include "MEM_guardedalloc.h" #include "DNA_armature_types.h" +#include "DNA_collection_types.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_modifier_types.h" @@ -18,12 +19,13 @@ #include "DNA_scene_types.h" #include "DNA_sequence_types.h" #include "DNA_shader_fx_types.h" +#include "DNA_text_types.h" #include "BLI_listbase.h" #include "BLI_utildefines.h" #include "BKE_armature.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_constraint.h" #include "BKE_context.hh" #include "BKE_deform.hh" @@ -36,7 +38,7 @@ #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_particle.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_shader_fx.h" #include "DEG_depsgraph.hh" @@ -68,6 +70,7 @@ #include "ANIM_bone_collections.hh" #include "outliner_intern.hh" +#include "tree/tree_display.hh" #include "tree/tree_element_grease_pencil_node.hh" #include "tree/tree_element_seq.hh" #include "tree/tree_iterator.hh" diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc index e6481bb8b88..95b656b5e9d 100644 --- a/source/blender/editors/space_outliner/outliner_tools.cc +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -40,11 +40,11 @@ #include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_armature.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_constraint.h" #include "BKE_context.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_grease_pencil.hh" #include "BKE_idtype.hh" #include "BKE_layer.hh" @@ -54,8 +54,8 @@ #include "BKE_lib_remap.hh" #include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "DEG_depsgraph.hh" @@ -77,7 +77,7 @@ #include "UI_resources.hh" #include "UI_view2d.hh" -#include "../../blender/blenloader/BLO_readfile.hh" +#include "../../blender/blenloader/BLO_readfile.h" #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/editors/space_outliner/outliner_utils.cc b/source/blender/editors/space_outliner/outliner_utils.cc index 78e58b639df..b20711237ad 100644 --- a/source/blender/editors/space_outliner/outliner_utils.cc +++ b/source/blender/editors/space_outliner/outliner_utils.cc @@ -16,9 +16,11 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "BKE_armature.hh" #include "BKE_context.hh" #include "BKE_layer.hh" #include "BKE_object.hh" +#include "BKE_outliner_treehash.hh" #include "ED_outliner.hh" #include "ED_screen.hh" @@ -28,6 +30,7 @@ #include "outliner_intern.hh" #include "tree/tree_display.hh" +#include "tree/tree_iterator.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/space_outliner.cc b/source/blender/editors/space_outliner/space_outliner.cc index 521b386df24..c68b1617164 100644 --- a/source/blender/editors/space_outliner/space_outliner.cc +++ b/source/blender/editors/space_outliner/space_outliner.cc @@ -31,6 +31,8 @@ #include "WM_message.hh" #include "WM_types.hh" +#include "RNA_access.hh" + #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -410,9 +412,7 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl) return (SpaceLink *)space_outliner_new; } -static void outliner_id_remap(ScrArea *area, - SpaceLink *slink, - const blender::bke::id::IDRemapper &mappings) +static void outliner_id_remap(ScrArea *area, SpaceLink *slink, const IDRemapper *mappings) { SpaceOutliner *space_outliner = (SpaceOutliner *)slink; @@ -427,7 +427,7 @@ static void outliner_id_remap(ScrArea *area, BLI_mempool_iternew(space_outliner->treestore, &iter); while ((tselem = static_cast(BLI_mempool_iterstep(&iter)))) { - switch (mappings.apply(&tselem->id, ID_REMAP_APPLY_DEFAULT)) { + switch (BKE_id_remapper_apply(mappings, &tselem->id, ID_REMAP_APPLY_DEFAULT)) { case ID_REMAP_RESULT_SOURCE_REMAPPED: changed = true; break; diff --git a/source/blender/editors/space_outliner/tree/common.cc b/source/blender/editors/space_outliner/tree/common.cc index 2c60444f7c1..0edca57e330 100644 --- a/source/blender/editors/space_outliner/tree/common.cc +++ b/source/blender/editors/space_outliner/tree/common.cc @@ -21,6 +21,7 @@ #include "../outliner_intern.hh" #include "common.hh" +#include "tree_display.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_display_data.cc b/source/blender/editors/space_outliner/tree/tree_display_data.cc index 6049670bb58..3103cf95c14 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_data.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_data.cc @@ -6,6 +6,7 @@ * \ingroup spoutliner */ +#include "BLI_listbase.h" #include "BLI_mempool.h" #include "DNA_space_types.h" @@ -14,6 +15,7 @@ #include "../outliner_intern.hh" #include "tree_display.hh" +#include "tree_element.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_display_libraries.cc b/source/blender/editors/space_outliner/tree/tree_display_libraries.cc index 78ce6df0cf3..3ae3db5a2c9 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_libraries.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_libraries.cc @@ -9,17 +9,18 @@ #include "BLI_listbase.h" #include "BLI_listbase_wrapper.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_main.hh" #include "DNA_collection_types.h" #include "DNA_space_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "../outliner_intern.hh" #include "common.hh" #include "tree_display.hh" +#include "tree_element.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_display_orphaned.cc b/source/blender/editors/space_outliner/tree/tree_display_orphaned.cc index cc769937279..f2878b8fe80 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_orphaned.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_orphaned.cc @@ -18,6 +18,7 @@ #include "../outliner_intern.hh" #include "common.hh" #include "tree_display.hh" +#include "tree_element.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_display_override_library_hierarchies.cc b/source/blender/editors/space_outliner/tree/tree_display_override_library_hierarchies.cc index df3878f64d8..e7293ce421f 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_override_library_hierarchies.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_override_library_hierarchies.cc @@ -6,6 +6,7 @@ * \ingroup spoutliner */ +#include "DNA_key_types.h" #include "DNA_space_types.h" #include "BLI_function_ref.hh" @@ -14,7 +15,7 @@ #include "BLI_set.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_lib_override.hh" #include "BKE_lib_query.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_display_override_library_properties.cc b/source/blender/editors/space_outliner/tree/tree_display_override_library_properties.cc index ef6cbb2cd19..fe29fa55f31 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_override_library_properties.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_override_library_properties.cc @@ -9,13 +9,18 @@ #include "BLI_listbase.h" #include "BLI_listbase_wrapper.hh" +#include "BKE_collection.h" #include "BKE_main.hh" +#include "DNA_collection_types.h" #include "DNA_space_types.h" +#include "BLT_translation.h" + #include "../outliner_intern.hh" #include "common.hh" #include "tree_display.hh" +#include "tree_element.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_display_scenes.cc b/source/blender/editors/space_outliner/tree/tree_display_scenes.cc index ed18c51c495..c9e1815798f 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_scenes.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_scenes.cc @@ -8,6 +8,7 @@ #include "DNA_space_types.h" +#include "BLI_listbase.h" #include "BLI_listbase_wrapper.hh" #include "BLI_mempool.h" @@ -16,6 +17,7 @@ #include "../outliner_intern.hh" #include "common.hh" #include "tree_display.hh" +#include "tree_element.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_display_sequencer.cc b/source/blender/editors/space_outliner/tree/tree_display_sequencer.cc index 712ffb187b5..d1ff5e8f525 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_sequencer.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_sequencer.cc @@ -19,6 +19,7 @@ #include "../outliner_intern.hh" #include "tree_display.hh" +#include "tree_element.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc index 58937a0ef2a..652baf55324 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc @@ -19,9 +19,12 @@ #include "BLI_map.hh" #include "BLI_vector.hh" +#include "BLT_translation.h" + #include "../outliner_intern.hh" #include "common.hh" #include "tree_display.hh" +#include "tree_element.hh" namespace blender::ed::outliner { diff --git a/source/blender/editors/space_outliner/tree/tree_element.cc b/source/blender/editors/space_outliner/tree/tree_element.cc index 133b3e02053..d8a583e321c 100644 --- a/source/blender/editors/space_outliner/tree/tree_element.cc +++ b/source/blender/editors/space_outliner/tree/tree_element.cc @@ -10,11 +10,14 @@ #include #include +#include "DNA_anim_types.h" #include "DNA_listBase.h" #include "DNA_space_types.h" #include "UI_resources.hh" +#include "BLT_translation.h" + #include "tree_display.hh" #include "tree_element_anim_data.hh" #include "tree_element_bone.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_anim_data.cc b/source/blender/editors/space_outliner/tree/tree_element_anim_data.cc index efa4f41be43..9fb42077db4 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_anim_data.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_anim_data.cc @@ -12,7 +12,7 @@ #include "DNA_listBase.h" #include "DNA_outliner_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "../outliner_intern.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_bone_collection.cc b/source/blender/editors/space_outliner/tree/tree_element_bone_collection.cc index 513f400e4af..f82f97d464d 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_bone_collection.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_bone_collection.cc @@ -7,9 +7,12 @@ */ #include "DNA_action_types.h" +#include "DNA_object_types.h" #include "DNA_outliner_types.h" -#include "BLT_translation.hh" +#include "BLI_listbase.h" + +#include "BLT_translation.h" #include "../outliner_intern.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_collection.cc b/source/blender/editors/space_outliner/tree/tree_element_collection.cc index 08c897352f1..ab60a4958b5 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_collection.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_collection.cc @@ -10,7 +10,7 @@ #include "DNA_outliner_types.h" #include "DNA_scene_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "../outliner_intern.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_constraint.cc b/source/blender/editors/space_outliner/tree/tree_element_constraint.cc index dd990a86393..a7108f2e7c8 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_constraint.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_constraint.cc @@ -7,9 +7,10 @@ */ #include "DNA_constraint_types.h" +#include "DNA_object_types.h" #include "DNA_outliner_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "../outliner_intern.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_defgroup.cc b/source/blender/editors/space_outliner/tree/tree_element_defgroup.cc index 1242dff5ca7..b7c8a3b3fa0 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_defgroup.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_defgroup.cc @@ -13,7 +13,7 @@ #include "BKE_deform.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "../outliner_intern.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_driver.cc b/source/blender/editors/space_outliner/tree/tree_element_driver.cc index 6483c07b79d..4d043b6a2f0 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_driver.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_driver.cc @@ -14,7 +14,7 @@ #include "DNA_listBase.h" #include "DNA_space_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "../outliner_intern.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_gpencil_effect.cc b/source/blender/editors/space_outliner/tree/tree_element_gpencil_effect.cc index 58bc4d03042..ef3ce1d668e 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_gpencil_effect.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_gpencil_effect.cc @@ -12,7 +12,7 @@ #include "BLI_listbase.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "../outliner_intern.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_id.cc b/source/blender/editors/space_outliner/tree/tree_element_id.cc index 38d2158786f..56d7c3226bf 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_id.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_id.cc @@ -9,9 +9,15 @@ #include "DNA_ID.h" #include "DNA_space_types.h" +#include "BLI_listbase_wrapper.hh" #include "BLI_utildefines.h" #include "BKE_anim_data.h" +#include "BKE_lib_override.hh" + +#include "BLT_translation.h" + +#include "RNA_access.hh" #include "../outliner_intern.hh" #include "common.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_id_library.cc b/source/blender/editors/space_outliner/tree/tree_element_id_library.cc index 5fab64aa51a..86db6746aa0 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_id_library.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_id_library.cc @@ -6,7 +6,7 @@ * \ingroup spoutliner */ -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_ID.h" #include "DNA_listBase.h" diff --git a/source/blender/editors/space_outliner/tree/tree_element_id_object.cc b/source/blender/editors/space_outliner/tree/tree_element_id_object.cc index cd46b229a55..1e713d0796d 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_id_object.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_id_object.cc @@ -11,11 +11,18 @@ #include "DNA_ID.h" #include "DNA_action_types.h" #include "DNA_armature_types.h" +#include "DNA_constraint_types.h" +#include "DNA_gpencil_modifier_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_outliner_types.h" +#include "DNA_particle_types.h" +#include "DNA_shader_fx_types.h" #include "BKE_deform.hh" +#include "BLT_translation.h" + #include "../outliner_intern.hh" #include "tree_element_id_object.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_modifier.cc b/source/blender/editors/space_outliner/tree/tree_element_modifier.cc index 54e065361a2..234aa98df29 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_modifier.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_modifier.cc @@ -13,7 +13,7 @@ #include "BLI_listbase.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "../outliner_intern.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_nla.cc b/source/blender/editors/space_outliner/tree/tree_element_nla.cc index 20a6ad0ce9c..f224f05963b 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_nla.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_nla.cc @@ -12,7 +12,7 @@ #include "DNA_listBase.h" #include "DNA_space_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "../outliner_intern.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc index 610a2310b67..145143ca52b 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc @@ -6,7 +6,7 @@ * \ingroup spoutliner */ -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_lib_override.hh" #include "BLI_function_ref.hh" @@ -14,7 +14,7 @@ #include "BLI_map.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_space_types.h" diff --git a/source/blender/editors/space_outliner/tree/tree_element_pose.cc b/source/blender/editors/space_outliner/tree/tree_element_pose.cc index 5c9e1d6649a..f3316eb8726 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_pose.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_pose.cc @@ -7,12 +7,13 @@ */ #include "DNA_armature_types.h" +#include "DNA_constraint_types.h" #include "DNA_object_types.h" #include "DNA_outliner_types.h" #include "BLI_listbase.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "../outliner_intern.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_rna.cc b/source/blender/editors/space_outliner/tree/tree_element_rna.cc index 622a6f66836..2737d13e94e 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_rna.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_rna.cc @@ -9,9 +9,10 @@ #include #include +#include "BLI_listbase.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_outliner_types.h" #include "DNA_space_types.h" diff --git a/source/blender/editors/space_outliner/tree/tree_element_scene_objects.cc b/source/blender/editors/space_outliner/tree/tree_element_scene_objects.cc index 55d6d7c93c7..56e77693ece 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_scene_objects.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_scene_objects.cc @@ -6,11 +6,11 @@ * \ingroup spoutliner */ -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_outliner_types.h" diff --git a/source/blender/editors/space_outliner/tree/tree_element_seq.cc b/source/blender/editors/space_outliner/tree/tree_element_seq.cc index 0358fa54fb1..da855aaafcd 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_seq.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_seq.cc @@ -11,7 +11,7 @@ #include "BLI_listbase.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "../outliner_intern.hh" #include "tree_element_seq.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_view_collection.cc b/source/blender/editors/space_outliner/tree/tree_element_view_collection.cc index 6f02753bf13..ba2632dc1f9 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_view_collection.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_view_collection.cc @@ -9,7 +9,7 @@ #include "DNA_outliner_types.h" #include "DNA_scene_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "../outliner_intern.hh" diff --git a/source/blender/editors/space_outliner/tree/tree_element_view_layer.cc b/source/blender/editors/space_outliner/tree/tree_element_view_layer.cc index 40ef16275e4..93a5efce2fd 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_view_layer.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_view_layer.cc @@ -12,7 +12,7 @@ #include "BLI_listbase_wrapper.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "../outliner_intern.hh" diff --git a/source/blender/editors/space_script/script_edit.cc b/source/blender/editors/space_script/script_edit.cc index 88e39f92592..18ee9f6a41d 100644 --- a/source/blender/editors/space_script/script_edit.cc +++ b/source/blender/editors/space_script/script_edit.cc @@ -13,9 +13,9 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_report.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "WM_api.hh" #include "WM_types.hh" diff --git a/source/blender/editors/space_sequencer/sequencer_add.cc b/source/blender/editors/space_sequencer/sequencer_add.cc index 10e38e5605c..d0d025fcfb0 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.cc +++ b/source/blender/editors/space_sequencer/sequencer_add.cc @@ -14,18 +14,25 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_ghash.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "DNA_mask_types.h" #include "DNA_scene_types.h" +#include "DNA_sound_types.h" #include "DNA_space_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" +#include "BKE_lib_id.hh" #include "BKE_main.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_mask.h" +#include "BKE_movieclip.h" +#include "BKE_report.h" +#include "BKE_scene.h" +#include "BKE_sound.h" #include "IMB_imbuf.hh" @@ -38,11 +45,15 @@ #include "SEQ_add.hh" #include "SEQ_effects.hh" +#include "SEQ_iterator.hh" #include "SEQ_proxy.hh" +#include "SEQ_relations.hh" +#include "SEQ_render.hh" #include "SEQ_select.hh" #include "SEQ_sequencer.hh" #include "SEQ_time.hh" #include "SEQ_transform.hh" +#include "SEQ_utils.hh" #include "ED_scene.hh" /* For menu, popup, icons, etc. */ diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.cc b/source/blender/editors/space_sequencer/sequencer_buttons.cc index bb691a4f142..a030d4ef78e 100644 --- a/source/blender/editors/space_sequencer/sequencer_buttons.cc +++ b/source/blender/editors/space_sequencer/sequencer_buttons.cc @@ -15,10 +15,10 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_screen.hh" #include "ED_screen.hh" diff --git a/source/blender/editors/space_sequencer/sequencer_channels_draw.cc b/source/blender/editors/space_sequencer/sequencer_channels_draw.cc index 46bd575a14a..d26e55ac398 100644 --- a/source/blender/editors/space_sequencer/sequencer_channels_draw.cc +++ b/source/blender/editors/space_sequencer/sequencer_channels_draw.cc @@ -19,9 +19,15 @@ #include "ED_screen.hh" +#include "GPU_framebuffer.h" +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "GPU_vertex_buffer.h" +#include "GPU_viewport.h" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "SEQ_channels.hh" diff --git a/source/blender/editors/space_sequencer/sequencer_channels_edit.cc b/source/blender/editors/space_sequencer/sequencer_channels_edit.cc index 2a101f20789..549711cfbc3 100644 --- a/source/blender/editors/space_sequencer/sequencer_channels_edit.cc +++ b/source/blender/editors/space_sequencer/sequencer_channels_edit.cc @@ -12,14 +12,22 @@ #include "BKE_context.hh" +#include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "ED_screen.hh" #include "UI_view2d.hh" +#include "SEQ_channels.hh" +#include "SEQ_sequencer.hh" +#include "SEQ_time.hh" + #include "WM_api.hh" +#include "RNA_define.hh" +#include "RNA_enum_types.hh" + /* Own include. */ #include "sequencer_intern.hh" diff --git a/source/blender/editors/space_sequencer/sequencer_clipboard.cc b/source/blender/editors/space_sequencer/sequencer_clipboard.cc index c2a280bf80e..784c7317716 100644 --- a/source/blender/editors/space_sequencer/sequencer_clipboard.cc +++ b/source/blender/editors/space_sequencer/sequencer_clipboard.cc @@ -10,9 +10,10 @@ #include -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "MEM_guardedalloc.h" +#include "ED_keyframing.hh" #include "ED_outliner.hh" #include "ED_sequencer.hh" @@ -35,8 +36,10 @@ #include "BKE_lib_query.hh" #include "BKE_lib_remap.hh" #include "BKE_main.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" + +#include "RNA_access.hh" #include "SEQ_animation.hh" #include "SEQ_select.hh" @@ -66,8 +69,7 @@ static int gather_strip_data_ids_to_null(LibraryIDLinkCallbackData *cb_data) { - blender::bke::id::IDRemapper &id_remapper = *static_cast( - cb_data->user_data); + IDRemapper *id_remapper = static_cast(cb_data->user_data); ID *id = *cb_data->id_pointer; /* We don't care about embedded, loop-back, or internal IDs. */ @@ -83,7 +85,7 @@ static int gather_strip_data_ids_to_null(LibraryIDLinkCallbackData *cb_data) /* Nullify everything that is not: * #bSound, #MovieClip, #Image, #Text, #VFont, #bAction, or #Collection IDs. */ if (!ELEM(id_type, ID_SO, ID_MC, ID_IM, ID_TXT, ID_VF, ID_AC)) { - id_remapper.add(id, nullptr); + BKE_id_remapper_add(id_remapper, id, nullptr); return IDWALK_RET_STOP_RECURSION; } } @@ -184,15 +186,16 @@ static bool sequencer_write_copy_paste_file(Main *bmain_src, * to copy whole scenes. We have to come up with a proper idea of how to copy and * paste scene strips. */ - blender::bke::id::IDRemapper id_remapper; + IDRemapper *id_remapper = BKE_id_remapper_create(); BKE_library_foreach_ID_link( - bmain_src, &scene_dst->id, gather_strip_data_ids_to_null, &id_remapper, IDWALK_RECURSE); + bmain_src, &scene_dst->id, gather_strip_data_ids_to_null, id_remapper, IDWALK_RECURSE); BKE_libblock_relink_multiple(bmain_src, {&scene_dst->id}, ID_REMAP_TYPE_REMAP, id_remapper, (ID_REMAP_SKIP_USER_CLEAR | ID_REMAP_SKIP_USER_REFCOUNT)); + BKE_id_remapper_free(id_remapper); /* Ensure that there are no old copy tags around */ BKE_blendfile_write_partial_begin(bmain_src); @@ -369,7 +372,7 @@ int sequencer_clipboard_paste_exec(bContext *C, wmOperator *op) nseqbase.first = iseq_first; LISTBASE_FOREACH (Sequence *, iseq, &nseqbase) { - if (iseq->name == active_seq_name) { + if (STREQ(iseq->name, active_seq_name.c_str())) { SEQ_select_active_set(scene_dst, iseq); } /* Make sure, that pasted strips have unique names. This has to be done after diff --git a/source/blender/editors/space_sequencer/sequencer_drag_drop.cc b/source/blender/editors/space_sequencer/sequencer_drag_drop.cc index fb1a9e35068..8db304c39dd 100644 --- a/source/blender/editors/space_sequencer/sequencer_drag_drop.cc +++ b/source/blender/editors/space_sequencer/sequencer_drag_drop.cc @@ -15,6 +15,7 @@ #include "BLI_string_utils.hh" #include "BKE_context.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_main.hh" diff --git a/source/blender/editors/space_sequencer/sequencer_edit.cc b/source/blender/editors/space_sequencer/sequencer_edit.cc index 0cfecb537e5..b8b7706ea6e 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.cc +++ b/source/blender/editors/space_sequencer/sequencer_edit.cc @@ -15,16 +15,17 @@ #include "BLI_timecode.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_anim_types.h" #include "DNA_scene_types.h" #include "DNA_sound_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_fcurve.h" +#include "BKE_global.h" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_sound.h" #include "SEQ_add.hh" diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.cc b/source/blender/editors/space_sequencer/sequencer_modifier.cc index eda9245d39c..ff1799eed96 100644 --- a/source/blender/editors/space_sequencer/sequencer_modifier.cc +++ b/source/blender/editors/space_sequencer/sequencer_modifier.cc @@ -6,6 +6,7 @@ * \ingroup spseq */ +#include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "DNA_scene_types.h" @@ -20,6 +21,7 @@ #include "RNA_define.hh" #include "RNA_enum_types.hh" +#include "SEQ_iterator.hh" #include "SEQ_modifier.hh" #include "SEQ_relations.hh" #include "SEQ_select.hh" diff --git a/source/blender/editors/space_sequencer/sequencer_preview.cc b/source/blender/editors/space_sequencer/sequencer_preview.cc index 9554ca1703f..f51622e7add 100644 --- a/source/blender/editors/space_sequencer/sequencer_preview.cc +++ b/source/blender/editors/space_sequencer/sequencer_preview.cc @@ -14,7 +14,7 @@ #include "BLI_threads.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_sound.h" #include "WM_api.hh" diff --git a/source/blender/editors/space_sequencer/sequencer_preview_draw.cc b/source/blender/editors/space_sequencer/sequencer_preview_draw.cc index 8791591dfeb..c175e464c92 100644 --- a/source/blender/editors/space_sequencer/sequencer_preview_draw.cc +++ b/source/blender/editors/space_sequencer/sequencer_preview_draw.cc @@ -22,8 +22,8 @@ #include "DNA_space_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" -#include "BKE_scene.hh" +#include "BKE_global.h" +#include "BKE_scene.h" #include "IMB_colormanagement.hh" #include "IMB_imbuf.hh" @@ -556,7 +556,8 @@ static void draw_histogram(ARegion *region, /* Label. */ char buf[10]; - const size_t buf_len = SNPRINTF_RLEN(buf, "%.2f", val); + BLI_snprintf(buf, sizeof(buf), "%.2f", val); + size_t buf_len = strlen(buf); float text_width, text_height; BLF_width_and_height(BLF_default(), buf, buf_len, &text_width, &text_height); diff --git a/source/blender/editors/space_sequencer/sequencer_proxy.cc b/source/blender/editors/space_sequencer/sequencer_proxy.cc index 77c122a60af..889cdb765c2 100644 --- a/source/blender/editors/space_sequencer/sequencer_proxy.cc +++ b/source/blender/editors/space_sequencer/sequencer_proxy.cc @@ -8,14 +8,17 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_ghash.h" #include "DNA_scene_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" -#include "BKE_report.hh" +#include "BKE_global.h" +#include "BKE_main.hh" +#include "BKE_report.h" +#include "SEQ_iterator.hh" #include "SEQ_proxy.hh" #include "SEQ_relations.hh" #include "SEQ_sequencer.hh" diff --git a/source/blender/editors/space_sequencer/sequencer_retiming.cc b/source/blender/editors/space_sequencer/sequencer_retiming.cc index 88b99f3260f..2f39fd3092f 100644 --- a/source/blender/editors/space_sequencer/sequencer_retiming.cc +++ b/source/blender/editors/space_sequencer/sequencer_retiming.cc @@ -8,14 +8,17 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_set.hh" +#include "DNA_anim_types.h" #include "DNA_scene_types.h" #include "DNA_space_types.h" +#include "DNA_workspace_types.h" #include "BKE_context.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "ED_select_utils.hh" #include "ED_sequencer.hh" @@ -29,11 +32,15 @@ #include "SEQ_transform.hh" #include "WM_api.hh" +#include "WM_toolsystem.hh" #include "RNA_define.hh" +#include "UI_interface.hh" #include "UI_view2d.hh" +#include "DEG_depsgraph.hh" + /* Own include. */ #include "sequencer_intern.hh" diff --git a/source/blender/editors/space_sequencer/sequencer_retiming_draw.cc b/source/blender/editors/space_sequencer/sequencer_retiming_draw.cc index 1900dc751b2..2a3987d304d 100644 --- a/source/blender/editors/space_sequencer/sequencer_retiming_draw.cc +++ b/source/blender/editors/space_sequencer/sequencer_retiming_draw.cc @@ -11,26 +11,42 @@ #include "BLI_blenlib.h" #include "BLI_span.hh" +#include "DNA_anim_types.h" #include "DNA_sequence_types.h" #include "BKE_context.hh" #include "BKE_fcurve.h" +#include "BKE_scene.h" #include "BLF_api.hh" #include "GPU_batch.h" +#include "GPU_batch_utils.h" #include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_matrix.h" +#include "GPU_select.hh" #include "GPU_state.h" +#include "RNA_access.hh" +#include "RNA_define.hh" +#include "RNA_enum_types.hh" + #include "WM_api.hh" #include "WM_types.hh" #include "ED_keyframes_draw.hh" #include "ED_keyframes_keylist.hh" #include "ED_screen.hh" +#include "ED_sequencer.hh" +#include "ED_view3d.hh" +#include "UI_interface.hh" +#include "UI_interface_icons.hh" +#include "UI_resources.hh" #include "UI_view2d.hh" +#include "SEQ_iterator.hh" #include "SEQ_retiming.hh" #include "SEQ_sequencer.hh" #include "SEQ_time.hh" diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.cc b/source/blender/editors/space_sequencer/sequencer_scopes.cc index 4e68ef464cb..188fcb42452 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.cc +++ b/source/blender/editors/space_sequencer/sequencer_scopes.cc @@ -10,6 +10,7 @@ #include #include "BLI_math_vector.hh" +#include "BLI_task.h" #include "BLI_task.hh" #include "BLI_utildefines.h" @@ -113,7 +114,7 @@ ImBuf *make_waveform_view_from_ibuf(const ImBuf *ibuf) #endif const int w = ibuf->x; const int h = 256; - ImBuf *rval = IMB_allocImBuf(w, h, 32, IB_rect | IB_uninitialized_pixels); + ImBuf *rval = IMB_allocImBuf(w, h, 32, IB_rect); uchar *tgt = rval->byte_buffer.data; uchar wtable[256]; @@ -172,7 +173,7 @@ ImBuf *make_sep_waveform_view_from_ibuf(const ImBuf *ibuf) #endif int w = ibuf->x; int h = 256; - ImBuf *rval = IMB_allocImBuf(w, h, 32, IB_rect | IB_uninitialized_pixels); + ImBuf *rval = IMB_allocImBuf(w, h, 32, IB_rect); uchar *tgt = rval->byte_buffer.data; int sw = ibuf->x / 3; @@ -222,7 +223,7 @@ ImBuf *make_zebra_view_from_ibuf(const ImBuf *ibuf, float perc) #ifdef DEBUG_TIME SCOPED_TIMER(__func__); #endif - ImBuf *res = IMB_allocImBuf(ibuf->x, ibuf->y, 32, IB_rect | IB_uninitialized_pixels); + ImBuf *res = IMB_allocImBuf(ibuf->x, ibuf->y, 32, IB_rect); threading::parallel_for(IndexRange(ibuf->y), 16, [&](IndexRange y_range) { if (ibuf->float_buffer.data) { @@ -346,7 +347,7 @@ ImBuf *make_vectorscope_view_from_ibuf(const ImBuf *ibuf) #endif const int size = 512; const float size_mul = size - 1.0f; - ImBuf *rval = IMB_allocImBuf(size, size, 32, IB_rect | IB_uninitialized_pixels); + ImBuf *rval = IMB_allocImBuf(size, size, 32, IB_rect); uchar *dst = rval->byte_buffer.data; float rgb[3]; diff --git a/source/blender/editors/space_sequencer/sequencer_select.cc b/source/blender/editors/space_sequencer/sequencer_select.cc index eb834b01dc6..cfd82a0b4d2 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.cc +++ b/source/blender/editors/space_sequencer/sequencer_select.cc @@ -21,9 +21,10 @@ #include "DNA_scene_types.h" #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "WM_api.hh" +#include "WM_toolsystem.hh" #include "WM_types.hh" #include "RNA_define.hh" @@ -36,6 +37,7 @@ #include "SEQ_sequencer.hh" #include "SEQ_time.hh" #include "SEQ_transform.hh" +#include "SEQ_utils.hh" /* For menu, popup, icons, etc. */ diff --git a/source/blender/editors/space_sequencer/sequencer_thumbnails.cc b/source/blender/editors/space_sequencer/sequencer_thumbnails.cc index eb4962b3681..1dd782586ae 100644 --- a/source/blender/editors/space_sequencer/sequencer_thumbnails.cc +++ b/source/blender/editors/space_sequencer/sequencer_thumbnails.cc @@ -10,8 +10,8 @@ #include "BLI_ghash.h" #include "BKE_context.hh" -#include "BKE_global.hh" -#include "BKE_scene.hh" +#include "BKE_global.h" +#include "BKE_scene.h" #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" diff --git a/source/blender/editors/space_sequencer/sequencer_timeline_draw.cc b/source/blender/editors/space_sequencer/sequencer_timeline_draw.cc index 3233002187e..1455d0b7e4d 100644 --- a/source/blender/editors/space_sequencer/sequencer_timeline_draw.cc +++ b/source/blender/editors/space_sequencer/sequencer_timeline_draw.cc @@ -22,23 +22,31 @@ #include "BKE_context.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" +#include "BKE_scene.h" #include "BKE_sound.h" +#include "IMB_imbuf.hh" + #include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_vertex_buffer.h" #include "GPU_viewport.h" #include "ED_anim_api.hh" #include "ED_markers.hh" #include "ED_mask.hh" +#include "ED_screen.hh" #include "ED_sequencer.hh" #include "ED_space_api.hh" #include "ED_time_scrub_ui.hh" +#include "ED_util.hh" #include "RNA_prototypes.h" #include "SEQ_channels.hh" #include "SEQ_effects.hh" +#include "SEQ_iterator.hh" #include "SEQ_prefetch.hh" #include "SEQ_relations.hh" #include "SEQ_render.hh" @@ -48,6 +56,7 @@ #include "SEQ_transform.hh" #include "SEQ_utils.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "UI_view2d.hh" @@ -1572,13 +1581,32 @@ struct CacheDrawData { float stripe_ofs_y; float stripe_ht; int cache_flag; - SeqQuadsBatch *quads; + GPUVertBuf *raw_vbo; + GPUVertBuf *preprocessed_vbo; + GPUVertBuf *composite_vbo; + GPUVertBuf *final_out_vbo; + size_t raw_vert_count; + size_t preprocessed_vert_count; + size_t composite_vert_count; + size_t final_out_vert_count; }; /* Called as a callback. */ -static bool draw_cache_view_init_fn(void * /*userdata*/, size_t item_count) +static bool draw_cache_view_init_fn(void *userdata, size_t item_count) { - return item_count == 0; + if (item_count == 0) { + return true; + } + + CacheDrawData *drawdata = static_cast(userdata); + /* We can not get item count per cache type, so using total item count is safe. */ + size_t max_vert_count = item_count * 6; + GPU_vertbuf_data_alloc(drawdata->raw_vbo, max_vert_count); + GPU_vertbuf_data_alloc(drawdata->preprocessed_vbo, max_vert_count); + GPU_vertbuf_data_alloc(drawdata->composite_vbo, max_vert_count); + GPU_vertbuf_data_alloc(drawdata->final_out_vbo, max_vert_count); + + return false; } /* Called as a callback */ @@ -1587,106 +1615,133 @@ static bool draw_cache_view_iter_fn(void *userdata, int timeline_frame, int cache_type) { - using blender::uchar4; CacheDrawData *drawdata = static_cast(userdata); - const View2D *v2d = drawdata->v2d; + View2D *v2d = drawdata->v2d; float stripe_bot; - - const uchar4 col_final{255, 102, 51, 100}; - const uchar4 col_raw{255, 25, 5, 100}; - const uchar4 col_preproc{25, 25, 191, 100}; - const uchar4 col_composite{255, 153, 0, 100}; - - uchar4 col{0, 0, 0, 0}; + GPUVertBuf *vbo; + size_t *vert_count; if ((cache_type & SEQ_CACHE_STORE_FINAL_OUT) && (drawdata->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT)) { stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HANDLE_HEIGHT); - col = col_final; + vbo = drawdata->final_out_vbo; + vert_count = &drawdata->final_out_vert_count; } else if ((cache_type & SEQ_CACHE_STORE_RAW) && (drawdata->cache_flag & SEQ_CACHE_VIEW_RAW)) { stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + drawdata->stripe_ofs_y; - col = col_raw; + vbo = drawdata->raw_vbo; + vert_count = &drawdata->raw_vert_count; } else if ((cache_type & SEQ_CACHE_STORE_PREPROCESSED) && (drawdata->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED)) { stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + drawdata->stripe_ht + drawdata->stripe_ofs_y * 2; - col = col_preproc; + vbo = drawdata->preprocessed_vbo; + vert_count = &drawdata->preprocessed_vert_count; } else if ((cache_type & SEQ_CACHE_STORE_COMPOSITE) && (drawdata->cache_flag & SEQ_CACHE_VIEW_COMPOSITE)) { stripe_bot = seq->machine + SEQ_STRIP_OFSTOP - drawdata->stripe_ofs_y - drawdata->stripe_ht; - col = col_composite; + vbo = drawdata->composite_vbo; + vert_count = &drawdata->composite_vert_count; } else { return false; } float stripe_top = stripe_bot + drawdata->stripe_ht; - drawdata->quads->add_quad(timeline_frame, stripe_bot, timeline_frame + 1, stripe_top, col); + float vert_pos[6][2]; + copy_v2_fl2(vert_pos[0], timeline_frame, stripe_bot); + copy_v2_fl2(vert_pos[1], timeline_frame, stripe_top); + copy_v2_fl2(vert_pos[2], timeline_frame + 1, stripe_top); + copy_v2_v2(vert_pos[3], vert_pos[2]); + copy_v2_v2(vert_pos[4], vert_pos[0]); + copy_v2_fl2(vert_pos[5], timeline_frame + 1, stripe_bot); + + for (int i = 0; i < 6; i++) { + GPU_vertbuf_vert_set(vbo, *vert_count + i, vert_pos[i]); + } + + *vert_count += 6; return false; } +static void draw_cache_view_batch( + GPUVertBuf *vbo, size_t vert_count, float col_r, float col_g, float col_b, float col_a) +{ + GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, nullptr, GPU_BATCH_OWNS_VBO); + if (vert_count > 0) { + GPU_vertbuf_data_len_set(vbo, vert_count); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR); + GPU_batch_uniform_4f(batch, "color", col_r, col_g, col_b, col_a); + GPU_batch_draw(batch); + } + GPU_batch_discard(batch); +} + static void draw_cache_stripe(const Scene *scene, const Sequence *seq, - SeqQuadsBatch &quads, + uint pos, const float stripe_bot, const float stripe_ht, - const uchar color[4]) + const float bg_color[4]) { - quads.add_quad(SEQ_time_left_handle_frame_get(scene, seq), - stripe_bot, - SEQ_time_right_handle_frame_get(scene, seq), - stripe_bot + stripe_ht, - color); + immUniformColor4fv(bg_color); + immRectf(pos, + SEQ_time_left_handle_frame_get(scene, seq), + stripe_bot, + SEQ_time_right_handle_frame_get(scene, seq), + stripe_bot + stripe_ht); } static void draw_cache_background(const bContext *C, CacheDrawData *draw_data) { - using blender::uchar4; Scene *scene = CTX_data_scene(C); View2D *v2d = UI_view2d_fromcontext(C); + float bg_colors[4][4]; + copy_v4_fl4(bg_colors[0], 1.0f, 0.4f, 0.2f, 0.1f); + copy_v4_fl4(bg_colors[1], 1.0f, 0.1f, 0.02f, 0.1f); + copy_v4_fl4(bg_colors[2], 0.1f, 0.1f, 0.75f, 0.1f); + copy_v4_fl4(bg_colors[3], 1.0f, 0.6f, 0.0f, 0.1f); - const uchar4 bg_final{255, 102, 51, 25}; - const uchar4 bg_raw{255, 25, 5, 25}; - const uchar4 bg_preproc{25, 25, 191, 25}; - const uchar4 bg_composite{255, 153, 0, 25}; + GPU_blend(GPU_BLEND_ALPHA); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); float stripe_bot; if (scene->ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) { stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HANDLE_HEIGHT); - draw_data->quads->add_quad( - scene->r.sfra, stripe_bot, scene->r.efra, stripe_bot + draw_data->stripe_ht, bg_final); + immUniformColor4fv(bg_colors[0]); + immRectf(pos, scene->r.sfra, stripe_bot, scene->r.efra, stripe_bot + draw_data->stripe_ht); } blender::Vector strips = sequencer_visible_strips_get(C); strips.remove_if([&](Sequence *seq) { return seq->type == SEQ_TYPE_SOUND_RAM; }); - for (const Sequence *seq : strips) { + for (Sequence *seq : strips) { stripe_bot = seq->machine + SEQ_STRIP_OFSBOTTOM + draw_data->stripe_ofs_y; if (scene->ed->cache_flag & SEQ_CACHE_VIEW_RAW) { - draw_cache_stripe(scene, seq, *draw_data->quads, stripe_bot, draw_data->stripe_ht, bg_raw); + draw_cache_stripe(scene, seq, pos, stripe_bot, draw_data->stripe_ht, bg_colors[1]); } if (scene->ed->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED) { stripe_bot += draw_data->stripe_ht + draw_data->stripe_ofs_y; - draw_cache_stripe( - scene, seq, *draw_data->quads, stripe_bot, draw_data->stripe_ht, bg_preproc); + draw_cache_stripe(scene, seq, pos, stripe_bot, draw_data->stripe_ht, bg_colors[2]); } if (scene->ed->cache_flag & SEQ_CACHE_VIEW_COMPOSITE) { stripe_bot = seq->machine + SEQ_STRIP_OFSTOP - draw_data->stripe_ofs_y - draw_data->stripe_ht; - draw_cache_stripe( - scene, seq, *draw_data->quads, stripe_bot, draw_data->stripe_ht, bg_composite); + draw_cache_stripe(scene, seq, pos, stripe_bot, draw_data->stripe_ht, bg_colors[3]); } } + + immUnbindProgram(); } static void draw_cache_view(const bContext *C) @@ -1705,20 +1760,34 @@ static void draw_cache_view(const bContext *C) CLAMP_MAX(stripe_ht, 0.2f); CLAMP_MIN(stripe_ofs_y, stripe_ht / 2); - SeqQuadsBatch quads; + GPUVertFormat format = {0}; + GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + CacheDrawData userdata; userdata.v2d = v2d; userdata.stripe_ofs_y = stripe_ofs_y; userdata.stripe_ht = stripe_ht; userdata.cache_flag = scene->ed->cache_flag; - userdata.quads = &quads; + userdata.raw_vert_count = 0; + userdata.preprocessed_vert_count = 0; + userdata.composite_vert_count = 0; + userdata.final_out_vert_count = 0; + userdata.raw_vbo = GPU_vertbuf_create_with_format(&format); + userdata.preprocessed_vbo = GPU_vertbuf_create_with_format(&format); + userdata.composite_vbo = GPU_vertbuf_create_with_format(&format); + userdata.final_out_vbo = GPU_vertbuf_create_with_format(&format); - GPU_blend(GPU_BLEND_ALPHA); - - draw_cache_background(C, &userdata); SEQ_cache_iterate(scene, &userdata, draw_cache_view_init_fn, draw_cache_view_iter_fn); - quads.draw(); + draw_cache_background(C, &userdata); + draw_cache_view_batch(userdata.raw_vbo, userdata.raw_vert_count, 1.0f, 0.1f, 0.02f, 0.4f); + draw_cache_view_batch( + userdata.preprocessed_vbo, userdata.preprocessed_vert_count, 0.1f, 0.1f, 0.75f, 0.4f); + draw_cache_view_batch( + userdata.composite_vbo, userdata.composite_vert_count, 1.0f, 0.6f, 0.0f, 0.4f); + draw_cache_view_batch( + userdata.final_out_vbo, userdata.final_out_vert_count, 1.0f, 0.4f, 0.2f, 0.4f); + GPU_blend(GPU_BLEND_NONE); } diff --git a/source/blender/editors/space_sequencer/sequencer_view.cc b/source/blender/editors/space_sequencer/sequencer_view.cc index 40d710a1e70..22d169ce7f0 100644 --- a/source/blender/editors/space_sequencer/sequencer_view.cc +++ b/source/blender/editors/space_sequencer/sequencer_view.cc @@ -6,12 +6,13 @@ * \ingroup spseq */ +#include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "DNA_scene_types.h" #include "BKE_context.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "WM_api.hh" #include "WM_types.hh" @@ -20,6 +21,8 @@ #include "UI_view2d.hh" +#include "SEQ_iterator.hh" +#include "SEQ_select.hh" #include "SEQ_sequencer.hh" #include "SEQ_time.hh" #include "SEQ_transform.hh" diff --git a/source/blender/editors/space_sequencer/space_sequencer.cc b/source/blender/editors/space_sequencer/space_sequencer.cc index a8c3f7c3a00..232f93da239 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.cc +++ b/source/blender/editors/space_sequencer/space_sequencer.cc @@ -20,7 +20,7 @@ #include "BLI_ghash.h" #include "BLI_math_base.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_query.hh" #include "BKE_lib_remap.hh" #include "BKE_screen.hh" @@ -49,6 +49,8 @@ #include "BLO_read_write.hh" +#include "IMB_imbuf.hh" + /* Only for cursor drawing. */ #include "DRW_engine.hh" @@ -910,12 +912,10 @@ static void sequencer_buttons_region_listener(const wmRegionListenerParams *para } } -static void sequencer_id_remap(ScrArea * /*area*/, - SpaceLink *slink, - const blender::bke::id::IDRemapper &mappings) +static void sequencer_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings) { SpaceSeq *sseq = (SpaceSeq *)slink; - mappings.apply((ID **)&sseq->gpd, ID_REMAP_APPLY_DEFAULT); + BKE_id_remapper_apply(mappings, (ID **)&sseq->gpd, ID_REMAP_APPLY_DEFAULT); } static void sequencer_foreach_id(SpaceLink *space_link, LibraryForeachIDData *data) diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc index a4f8c159d11..0735b724223 100644 --- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc +++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc @@ -7,6 +7,8 @@ #include "BLI_listbase.h" #include "BLI_string.h" +#include "BKE_global.h" +#include "BKE_lib_remap.hh" #include "BKE_screen.hh" #include "ED_screen.hh" @@ -28,14 +30,17 @@ #include "DEG_depsgraph_query.hh" +#include "RNA_access.hh" + #include "WM_api.hh" #include "WM_types.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLF_api.hh" #include "spreadsheet_data_source_geometry.hh" +#include "spreadsheet_dataset_draw.hh" #include "spreadsheet_intern.hh" #include "spreadsheet_layout.hh" #include "spreadsheet_row_filter.hh" @@ -152,9 +157,7 @@ static void spreadsheet_keymap(wmKeyConfig *keyconf) WM_keymap_ensure(keyconf, "Spreadsheet Generic", SPACE_SPREADSHEET, RGN_TYPE_WINDOW); } -static void spreadsheet_id_remap(ScrArea * /*area*/, - SpaceLink *slink, - const blender::bke::id::IDRemapper &mappings) +static void spreadsheet_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings) { SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)slink; BKE_viewer_path_id_remap(&sspreadsheet->viewer_path, mappings); @@ -341,7 +344,6 @@ static float get_default_column_width(const ColumnValues &values) static const float float_width = 3; switch (values.type()) { case SPREADSHEET_VALUE_TYPE_BOOL: - case SPREADSHEET_VALUE_TYPE_FLOAT4X4: return 2.0f; case SPREADSHEET_VALUE_TYPE_INT8: case SPREADSHEET_VALUE_TYPE_INT32: diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_column.cc b/source/blender/editors/space_spreadsheet/spreadsheet_column.cc index e0df52fdb5b..2bd2c596e99 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_column.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_column.cc @@ -60,9 +60,6 @@ eSpreadsheetColumnValueType cpp_type_to_column_type(const CPPType &type) if (type.is()) { return SPREADSHEET_VALUE_TYPE_QUATERNION; } - if (type.is()) { - return SPREADSHEET_VALUE_TYPE_FLOAT4X4; - } return SPREADSHEET_VALUE_TYPE_UNKNOWN; } diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc index ea429b64182..b8d29a00d62 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc @@ -12,7 +12,7 @@ #include "BKE_editmesh.hh" #include "BKE_geometry_fields.hh" #include "BKE_geometry_set.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_grease_pencil.hh" #include "BKE_instances.hh" #include "BKE_lib_id.hh" @@ -37,7 +37,7 @@ #include "NOD_geometry_nodes_lazy_function.hh" #include "NOD_geometry_nodes_log.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_enum_types.hh" diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc index bf18eb885b1..72076d0c219 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc @@ -20,9 +20,10 @@ #include "WM_types.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "spreadsheet_dataset_draw.hh" +#include "spreadsheet_draw.hh" #include "spreadsheet_intern.hh" namespace blender::ed::spreadsheet { diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc index 9225259d5d3..628e3ef9ee7 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc @@ -7,8 +7,10 @@ #include +#include "BLI_math_color.hh" #include "BLI_math_quaternion_types.hh" #include "BLI_math_vector_types.hh" +#include "BLI_string.h" #include "BKE_geometry_set.hh" #include "BKE_instances.hh" @@ -23,7 +25,9 @@ #include "UI_interface.hh" #include "UI_resources.hh" -#include "BLT_translation.hh" +#include "BLF_api.hh" + +#include "BLT_translation.h" namespace blender::ed::spreadsheet { @@ -47,7 +51,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { UI_BTYPE_LABEL, 0, ICON_NONE, - name, + name.c_str(), params.xmin, params.ymin, params.width, @@ -71,7 +75,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { UI_BTYPE_LABEL, 0, ICON_NONE, - index_str, + index_str.c_str(), params.xmin, params.ymin, params.width, @@ -104,7 +108,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { UI_BTYPE_LABEL, 0, ICON_NONE, - value_str, + value_str.c_str(), params.xmin, params.ymin, params.width, @@ -126,7 +130,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { UI_BTYPE_LABEL, 0, ICON_NONE, - value_str, + value_str.c_str(), params.xmin, params.ymin, params.width, @@ -154,7 +158,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { UI_BTYPE_LABEL, 0, ICON_NONE, - value_str, + value_str.c_str(), params.xmin, params.ymin, params.width, @@ -209,9 +213,6 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { const float4 value = float4(data.get(real_index)); this->draw_float_vector(params, Span(&value.x, 4)); } - else if (data.type().is()) { - this->draw_float4x4(params, data.get(real_index)); - } else if (data.type().is()) { const bke::InstanceReference value = data.get(real_index); switch (value.type()) { @@ -281,7 +282,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { UI_BTYPE_LABEL, 0, ICON_NONE, - data.get(real_index), + data.get(real_index).c_str(), params.xmin, params.ymin, params.width, @@ -308,7 +309,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { UI_BTYPE_LABEL, 0, ICON_NONE, - value_str, + value_str.c_str(), params.xmin + i * segment_width, params.ymin, segment_width, @@ -338,7 +339,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { UI_BTYPE_LABEL, 0, ICON_NONE, - value_str, + value_str.c_str(), params.xmin + i * segment_width, params.ymin, segment_width, @@ -369,7 +370,7 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { UI_BTYPE_LABEL, 0, ICON_NONE, - value_str, + value_str.c_str(), params.xmin + i * segment_width, params.ymin, segment_width, @@ -401,40 +402,6 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer { } } - void draw_float4x4(const CellDrawParams ¶ms, const float4x4 &value) const - { - uiBut *but = uiDefIconTextBut(params.block, - UI_BTYPE_LABEL, - 0, - ICON_NONE, - "...", - params.xmin, - params.ymin, - params.width, - params.height, - nullptr, - 0, - 0, - 0, - 0, - nullptr); - /* Center alignment. */ - UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); - UI_but_func_tooltip_set( - but, - [](bContext * /*C*/, void *argN, const char * /*tip*/) { - const float4x4 &value = *static_cast(argN); - std::stringstream ss; - ss << value[0] << ",\n"; - ss << value[1] << ",\n"; - ss << value[2] << ",\n"; - ss << value[3]; - return ss.str(); - }, - MEM_new(__func__, value), - MEM_freeN); - } - int column_width(int column_index) const final { return spreadsheet_layout_.columns[column_index].width; diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc b/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc index 2032a66cb7f..412e90a9e88 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc @@ -1,6 +1,7 @@ /* SPDX-FileCopyrightText: 2023 Blender Authors * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BKE_screen.hh" #include "DNA_space_types.h" diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_panels.cc b/source/blender/editors/space_spreadsheet/spreadsheet_panels.cc index 21d562acfdb..3efbc461dbe 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_panels.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_panels.cc @@ -7,7 +7,7 @@ #include "BKE_screen.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "spreadsheet_dataset_draw.hh" #include "spreadsheet_intern.hh" diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc index be101b66bcb..2df1091dd3e 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc @@ -19,7 +19,7 @@ #include "UI_interface.hh" #include "UI_resources.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "WM_api.hh" #include "WM_types.hh" @@ -109,7 +109,6 @@ static std::string value_string(const SpreadsheetRowFilter &row_filter, case SPREADSHEET_VALUE_TYPE_STRING: return row_filter.value_string; case SPREADSHEET_VALUE_TYPE_QUATERNION: - case SPREADSHEET_VALUE_TYPE_FLOAT4X4: case SPREADSHEET_VALUE_TYPE_UNKNOWN: return ""; } @@ -254,7 +253,6 @@ static void spreadsheet_filter_panel_draw(const bContext *C, Panel *panel) break; case SPREADSHEET_VALUE_TYPE_UNKNOWN: case SPREADSHEET_VALUE_TYPE_QUATERNION: - case SPREADSHEET_VALUE_TYPE_FLOAT4X4: uiItemL(layout, IFACE_("Unsupported column type"), ICON_ERROR); break; } diff --git a/source/blender/editors/space_statusbar/space_statusbar.cc b/source/blender/editors/space_statusbar/space_statusbar.cc index 811ded68566..e4c071c21da 100644 --- a/source/blender/editors/space_statusbar/space_statusbar.cc +++ b/source/blender/editors/space_statusbar/space_statusbar.cc @@ -19,10 +19,13 @@ #include "ED_screen.hh" #include "ED_space_api.hh" +#include "RNA_access.hh" + #include "UI_interface.hh" #include "BLO_read_write.hh" +#include "WM_api.hh" #include "WM_message.hh" #include "WM_types.hh" diff --git a/source/blender/editors/space_text/space_text.cc b/source/blender/editors/space_text/space_text.cc index d0241fe6939..bec54c4e3f7 100644 --- a/source/blender/editors/space_text/space_text.cc +++ b/source/blender/editors/space_text/space_text.cc @@ -15,6 +15,8 @@ #include "BLI_blenlib.h" #include "BKE_context.hh" +#include "BKE_global.h" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_lib_remap.hh" #include "BKE_screen.hh" @@ -301,7 +303,7 @@ static void text_cursor(wmWindow *win, ScrArea *area, ARegion *region) /* ************* dropboxes ************* */ -static bool text_drop_path_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/) +static bool text_drop_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/) { if (drag->type == WM_DRAG_PATH) { const eFileSel_File_Types file_type = eFileSel_File_Types(WM_drag_get_path_file_type(drag)); @@ -312,18 +314,18 @@ static bool text_drop_path_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * return false; } -static void text_drop_path_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop) +static void text_drop_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop) { /* copy drag path to properties */ RNA_string_set(drop->ptr, "filepath", WM_drag_get_single_path(drag)); } -static bool text_drop_id_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/) +static bool text_drop_paste_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/) { return (drag->type == WM_DRAG_ID); } -static void text_drop_id_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop) +static void text_drop_paste(bContext * /*C*/, wmDrag *drag, wmDropBox *drop) { ID *id = WM_drag_get_local_ID(drag, 0); @@ -332,26 +334,13 @@ static void text_drop_id_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop) RNA_string_set(drop->ptr, "text", text.c_str()); } -static bool text_drop_string_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/) -{ - return (drag->type == WM_DRAG_STRING); -} - -static void text_drop_string_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop) -{ - const std::string &str = WM_drag_get_string(drag); - RNA_string_set(drop->ptr, "text", str.c_str()); -} - /* this region dropbox definition */ static void text_dropboxes() { ListBase *lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW); - WM_dropbox_add(lb, "TEXT_OT_open", text_drop_path_poll, text_drop_path_copy, nullptr, nullptr); - WM_dropbox_add(lb, "TEXT_OT_insert", text_drop_id_poll, text_drop_id_copy, nullptr, nullptr); - WM_dropbox_add( - lb, "TEXT_OT_insert", text_drop_string_poll, text_drop_string_copy, nullptr, nullptr); + WM_dropbox_add(lb, "TEXT_OT_open", text_drop_poll, text_drop_copy, nullptr, nullptr); + WM_dropbox_add(lb, "TEXT_OT_insert", text_drop_paste_poll, text_drop_paste, nullptr, nullptr); } /* ************* end drop *********** */ @@ -389,12 +378,10 @@ static void text_properties_region_draw(const bContext *C, ARegion *region) ED_region_panels(C, region); } -static void text_id_remap(ScrArea * /*area*/, - SpaceLink *slink, - const blender::bke::id::IDRemapper &mappings) +static void text_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings) { SpaceText *stext = (SpaceText *)slink; - mappings.apply((ID **)&stext->text, ID_REMAP_APPLY_ENSURE_REAL); + BKE_id_remapper_apply(mappings, (ID **)&stext->text, ID_REMAP_APPLY_ENSURE_REAL); } static void text_foreach_id(SpaceLink *space_link, LibraryForeachIDData *data) diff --git a/source/blender/editors/space_text/text_autocomplete.cc b/source/blender/editors/space_text/text_autocomplete.cc index b7fe565415f..c38c5d83507 100644 --- a/source/blender/editors/space_text/text_autocomplete.cc +++ b/source/blender/editors/space_text/text_autocomplete.cc @@ -28,6 +28,8 @@ #include "ED_text.hh" #include "ED_undo.hh" +#include "UI_interface.hh" + #include "text_format.hh" #include "text_intern.hh" /* own include */ diff --git a/source/blender/editors/space_text/text_draw.cc b/source/blender/editors/space_text/text_draw.cc index effaa9954be..cad3ca78825 100644 --- a/source/blender/editors/space_text/text_draw.cc +++ b/source/blender/editors/space_text/text_draw.cc @@ -30,6 +30,7 @@ #include "UI_interface.hh" #include "UI_resources.hh" +#include "UI_view2d.hh" #include "text_format.hh" #include "text_intern.hh" diff --git a/source/blender/editors/space_text/text_ops.cc b/source/blender/editors/space_text/text_ops.cc index 01b3d13cb18..a7511fae3ff 100644 --- a/source/blender/editors/space_text/text_ops.cc +++ b/source/blender/editors/space_text/text_ops.cc @@ -22,12 +22,12 @@ #include "BLI_string_utf8.h" #include "BLI_time.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_text.h" #include "WM_api.hh" @@ -3520,7 +3520,7 @@ static int text_line_number_invoke(bContext *C, wmOperator * /*op*/, const wmEve return OPERATOR_PASS_THROUGH; } - time = BLI_time_now_seconds(); + time = BLI_check_seconds_timer(); if (last_jump < time - 1) { jump_to = 0; } diff --git a/source/blender/editors/space_text/text_undo.cc b/source/blender/editors/space_text/text_undo.cc index 2a57357da42..e9e2cab5932 100644 --- a/source/blender/editors/space_text/text_undo.cc +++ b/source/blender/editors/space_text/text_undo.cc @@ -14,20 +14,32 @@ #include "DNA_text_types.h" #include "BLI_array_store.h" -#include "BLI_array_utils.h" /* For `BLI_array_is_zeroed`. */ +#include "BLI_array_utils.h" +#include "BLI_time.h" + +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_main.hh" +#include "BKE_report.h" #include "BKE_text.h" #include "BKE_undo_system.hh" #include "WM_api.hh" #include "WM_types.hh" +#include "ED_curve.hh" #include "ED_screen.hh" #include "ED_text.hh" #include "ED_undo.hh" +#include "UI_interface.hh" +#include "UI_resources.hh" + +#include "RNA_access.hh" +#include "RNA_define.hh" + +#include "text_format.hh" #include "text_intern.hh" /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/space_topbar/space_topbar.cc b/source/blender/editors/space_topbar/space_topbar.cc index a9d290e771d..470a6c912f3 100644 --- a/source/blender/editors/space_topbar/space_topbar.cc +++ b/source/blender/editors/space_topbar/space_topbar.cc @@ -14,9 +14,11 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "BKE_blendfile.hh" #include "BKE_context.hh" +#include "BKE_global.h" #include "BKE_screen.hh" #include "BKE_undo_system.hh" diff --git a/source/blender/editors/space_userpref/space_userpref.cc b/source/blender/editors/space_userpref/space_userpref.cc index f078ae17e4c..3263fe894e1 100644 --- a/source/blender/editors/space_userpref/space_userpref.cc +++ b/source/blender/editors/space_userpref/space_userpref.cc @@ -23,6 +23,7 @@ #include "RNA_access.hh" #include "RNA_enum_types.hh" +#include "WM_api.hh" #include "WM_types.hh" #include "UI_interface.hh" diff --git a/source/blender/editors/space_userpref/userpref_ops.cc b/source/blender/editors/space_userpref/userpref_ops.cc index 9af0ad0c545..4af49972b50 100644 --- a/source/blender/editors/space_userpref/userpref_ops.cc +++ b/source/blender/editors/space_userpref/userpref_ops.cc @@ -19,14 +19,14 @@ #include "BLI_fileops.h" #include "BLI_path_util.h" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "BKE_context.hh" #include "BKE_main.hh" #include "BKE_preferences.h" -#include "BKE_report.hh" +#include "BKE_report.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/editors/space_view3d/drawobject.cc b/source/blender/editors/space_view3d/drawobject.cc index a46a6ce1a20..0a3bcb42e2a 100644 --- a/source/blender/editors/space_view3d/drawobject.cc +++ b/source/blender/editors/space_view3d/drawobject.cc @@ -6,8 +6,33 @@ * \ingroup spview3d */ +#include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_math_vector.h" + +#include "BKE_DerivedMesh.hh" +#include "BKE_customdata.hh" +#include "BKE_editmesh.hh" +#include "BKE_global.h" +#include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" +#include "BKE_object.hh" + +#include "DEG_depsgraph.hh" +#include "DEG_depsgraph_query.hh" + +#include "GPU_batch.h" +#include "GPU_immediate.h" +#include "GPU_shader.h" +#include "GPU_state.h" + +#include "ED_mesh.hh" + +#include "UI_resources.hh" + +#include "DRW_engine.hh" + #include "view3d_intern.h" /* bad level include */ #ifdef VIEW3D_CAMERA_BORDER_HACK diff --git a/source/blender/editors/space_view3d/space_view3d.cc b/source/blender/editors/space_view3d/space_view3d.cc index 138fe99c718..a1a8baaa69a 100644 --- a/source/blender/editors/space_view3d/space_view3d.cc +++ b/source/blender/editors/space_view3d/space_view3d.cc @@ -16,6 +16,7 @@ #include "DNA_collection_types.h" #include "DNA_defaults.h" +#include "DNA_gpencil_legacy_types.h" #include "DNA_lightprobe_types.h" #include "DNA_material_types.h" #include "DNA_object_types.h" @@ -30,22 +31,28 @@ #include "BLI_math_vector.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_asset.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_curve.hh" +#include "BKE_global.h" #include "BKE_gpencil_legacy.h" +#include "BKE_icons.h" #include "BKE_idprop.h" +#include "BKE_lattice.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_lib_remap.hh" #include "BKE_main.hh" +#include "BKE_mball.hh" +#include "BKE_mesh.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_viewer_path.hh" +#include "BKE_workspace.h" #include "ED_asset_shelf.hh" #include "ED_geometry.hh" @@ -56,6 +63,7 @@ #include "ED_space_api.hh" #include "ED_transform.hh" #include "ED_undo.hh" +#include "ED_viewer_path.hh" #include "GPU_matrix.h" @@ -66,6 +74,9 @@ #include "WM_toolsystem.hh" #include "WM_types.hh" +#include "RE_engine.h" +#include "RE_pipeline.h" + #include "RNA_access.hh" #include "UI_interface.hh" @@ -126,11 +137,11 @@ bool ED_view3d_area_user_region(const ScrArea *area, const View3D *v3d, ARegion void ED_view3d_init_mats_rv3d(const Object *ob, RegionView3D *rv3d) { /* local viewmat and persmat, to calculate projections */ - mul_m4_m4m4(rv3d->viewmatob, rv3d->viewmat, ob->object_to_world().ptr()); - mul_m4_m4m4(rv3d->persmatob, rv3d->persmat, ob->object_to_world().ptr()); + mul_m4_m4m4(rv3d->viewmatob, rv3d->viewmat, ob->object_to_world); + mul_m4_m4m4(rv3d->persmatob, rv3d->persmat, ob->object_to_world); /* initializes object space clipping, speeds up clip tests */ - ED_view3d_clipping_local(rv3d, ob->object_to_world().ptr()); + ED_view3d_clipping_local(rv3d, ob->object_to_world); } void ED_view3d_init_mats_rv3d_gl(const Object *ob, RegionView3D *rv3d) @@ -140,7 +151,7 @@ void ED_view3d_init_mats_rv3d_gl(const Object *ob, RegionView3D *rv3d) /* We have to multiply instead of loading `viewmatob` to make * it work with duplis using display-lists, otherwise it will * override the dupli-matrix. */ - GPU_matrix_mul(ob->object_to_world().ptr()); + GPU_matrix_mul(ob->object_to_world); } #ifndef NDEBUG @@ -737,7 +748,7 @@ static void view3d_ob_drop_matrix_from_snap(V3DSnapCursorState *snap_state, copy_v3_v3(obmat_final[3], snap_data->loc); float scale[3]; - mat4_to_size(scale, ob->object_to_world().ptr()); + mat4_to_size(scale, ob->object_to_world); rescale_m4(obmat_final, scale); if (const std::optional> bb = BKE_object_boundbox_get(ob)) { @@ -1991,10 +2002,9 @@ static void space_view3d_refresh(const bContext *C, ScrArea *area) MEM_SAFE_FREE(v3d->runtime.local_stats); } -static void view3d_id_remap_v3d_ob_centers(View3D *v3d, - const blender::bke::id::IDRemapper &mappings) +static void view3d_id_remap_v3d_ob_centers(View3D *v3d, const IDRemapper *mappings) { - if (mappings.apply((ID **)&v3d->ob_center, ID_REMAP_APPLY_DEFAULT) == + if (BKE_id_remapper_apply(mappings, (ID **)&v3d->ob_center, ID_REMAP_APPLY_DEFAULT) == ID_REMAP_RESULT_SOURCE_UNASSIGNED) { /* Otherwise, bone-name may remain valid... @@ -2003,13 +2013,10 @@ static void view3d_id_remap_v3d_ob_centers(View3D *v3d, } } -static void view3d_id_remap_v3d(ScrArea *area, - SpaceLink *slink, - View3D *v3d, - const blender::bke::id::IDRemapper &mappings, - const bool is_local) +static void view3d_id_remap_v3d( + ScrArea *area, SpaceLink *slink, View3D *v3d, const IDRemapper *mappings, const bool is_local) { - if (mappings.apply((ID **)&v3d->camera, ID_REMAP_APPLY_DEFAULT) == + if (BKE_id_remapper_apply(mappings, (ID **)&v3d->camera, ID_REMAP_APPLY_DEFAULT) == ID_REMAP_RESULT_SOURCE_UNASSIGNED) { /* 3D view might be inactive, in that case needs to use slink->regionbase */ @@ -2027,13 +2034,11 @@ static void view3d_id_remap_v3d(ScrArea *area, } } -static void view3d_id_remap(ScrArea *area, - SpaceLink *slink, - const blender::bke::id::IDRemapper &mappings) +static void view3d_id_remap(ScrArea *area, SpaceLink *slink, const IDRemapper *mappings) { - if (!mappings.contains_mappings_for_any(FILTER_ID_OB | FILTER_ID_MA | FILTER_ID_IM | - FILTER_ID_MC)) + if (!BKE_id_remapper_has_mapping_for(mappings, + FILTER_ID_OB | FILTER_ID_MA | FILTER_ID_IM | FILTER_ID_MC)) { return; } diff --git a/source/blender/editors/space_view3d/view3d_buttons.cc b/source/blender/editors/space_view3d/view3d_buttons.cc index 2a424afa035..31b23c310ee 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.cc +++ b/source/blender/editors/space_view3d/view3d_buttons.cc @@ -22,7 +22,7 @@ #include "MEM_guardedalloc.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLI_array_utils.h" #include "BLI_bitmap.h" @@ -42,8 +42,7 @@ #include "BKE_layer.hh" #include "BKE_object.hh" #include "BKE_object_deform.h" -#include "BKE_object_types.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "DEG_depsgraph.hh" @@ -490,7 +489,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float /* Location, X/Y/Z */ mul_v3_fl(median_basis.generic.location, 1.0f / float(tot)); if (v3d->flag & V3D_GLOBAL_STATS) { - mul_m4_v3(ob->object_to_world().ptr(), median_basis.generic.location); + mul_m4_v3(ob->object_to_world, median_basis.generic.location); } if (has_meshdata) { @@ -929,9 +928,9 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float memcpy(&ve_median_basis, &tfp->ve_median, sizeof(tfp->ve_median)); if (v3d->flag & V3D_GLOBAL_STATS) { - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); - mul_m4_v3(ob->world_to_object().ptr(), median_basis.generic.location); - mul_m4_v3(ob->world_to_object().ptr(), ve_median_basis.generic.location); + invert_m4_m4(ob->world_to_object, ob->object_to_world); + mul_m4_v3(ob->world_to_object, median_basis.generic.location); + mul_m4_v3(ob->world_to_object, ve_median_basis.generic.location); } sub_vn_vnvn((float *)&median_basis, (float *)&ve_median_basis, @@ -1202,7 +1201,7 @@ static void v3d_object_dimension_buts(bContext *C, uiLayout *layout, View3D *v3d BKE_object_dimensions_eval_cached_get(ob, tfp->ob_dims); copy_v3_v3(tfp->ob_dims_orig, tfp->ob_dims); copy_v3_v3(tfp->ob_scale_orig, ob->scale); - copy_m4_m4(tfp->ob_obmat_orig, ob->object_to_world().ptr()); + copy_m4_m4(tfp->ob_obmat_orig, ob->object_to_world); uiDefBut(block, UI_BTYPE_LABEL, diff --git a/source/blender/editors/space_view3d/view3d_camera_control.cc b/source/blender/editors/space_view3d/view3d_camera_control.cc index eb159e42ef4..5788419169d 100644 --- a/source/blender/editors/space_view3d/view3d_camera_control.cc +++ b/source/blender/editors/space_view3d/view3d_camera_control.cc @@ -152,7 +152,7 @@ View3DCameraControl *ED_view3d_cameracontrol_acquire(Depsgraph *depsgraph, vctrl->obtfm = BKE_object_tfm_backup(ob_back); BKE_object_where_is_calc(depsgraph, scene, v3d->camera); - negate_v3_v3(rv3d->ofs, v3d->camera->object_to_world().location()); + negate_v3_v3(rv3d->ofs, v3d->camera->object_to_world[3]); rv3d->dist = 0.0; } @@ -260,7 +260,7 @@ void ED_view3d_cameracontrol_update(View3DCameraControl *vctrl, /* args for keyf invert_m4_m4(prev_view_imat, vctrl->view_mat_prev); mul_m4_m4m4(diff_mat, view_mat, prev_view_imat); - mul_m4_m4m4(parent_mat, diff_mat, vctrl->root_parent->object_to_world().ptr()); + mul_m4_m4m4(parent_mat, diff_mat, vctrl->root_parent->object_to_world); if (object_apply_mat4_with_protect(vctrl->root_parent, parent_mat, false, rv3d, view_mat)) { /* Calculate again since the view locking changes the matrix. */ diff --git a/source/blender/editors/space_view3d/view3d_context.cc b/source/blender/editors/space_view3d/view3d_context.cc index 9040c610e81..18ff0924ec0 100644 --- a/source/blender/editors/space_view3d/view3d_context.cc +++ b/source/blender/editors/space_view3d/view3d_context.cc @@ -18,6 +18,8 @@ #include "ED_view3d.hh" +#include "RNA_types.hh" + #include "view3d_intern.h" /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/space_view3d/view3d_cursor_snap.cc b/source/blender/editors/space_view3d/view3d_cursor_snap.cc index 2a1909978cf..0610e4633de 100644 --- a/source/blender/editors/space_view3d/view3d_cursor_snap.cc +++ b/source/blender/editors/space_view3d/view3d_cursor_snap.cc @@ -18,11 +18,11 @@ #include "MEM_guardedalloc.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "GPU_immediate.h" diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index 258b9282c17..9f29cf18d7b 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -8,9 +8,11 @@ #include +#include "BLI_jitter_2d.h" #include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" +#include "BLI_math_vector.hh" #include "BLI_rect.h" #include "BLI_string.h" #include "BLI_string_utils.hh" @@ -18,26 +20,29 @@ #include "BKE_armature.hh" #include "BKE_camera.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_context.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_key.hh" #include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_object.hh" #include "BKE_paint.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" +#include "BKE_studiolight.h" #include "BKE_unit.hh" #include "BLF_api.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_armature_types.h" +#include "DNA_brush_types.h" #include "DNA_camera_types.h" #include "DNA_key_types.h" +#include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_view3d_types.h" #include "DNA_windowmanager_types.h" @@ -50,6 +55,8 @@ #include "ED_keyframing.hh" #include "ED_scene.hh" #include "ED_screen.hh" +#include "ED_screen_types.hh" +#include "ED_transform.hh" #include "ED_view3d_offscreen.hh" #include "ED_viewer_path.hh" @@ -58,6 +65,8 @@ #include "DEG_depsgraph_query.hh" #include "GPU_batch.h" +#include "GPU_batch_presets.h" +#include "GPU_capabilities.h" #include "GPU_framebuffer.h" #include "GPU_immediate.h" #include "GPU_immediate_util.h" @@ -76,6 +85,8 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "RNA_access.hh" + #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" @@ -2104,7 +2115,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph, rv3d.persp = RV3D_CAMOB; - copy_m4_m4(rv3d.viewinv, v3d.camera->object_to_world().ptr()); + copy_m4_m4(rv3d.viewinv, v3d.camera->object_to_world); normalize_m4(rv3d.viewinv); invert_m4_m4(rv3d.viewmat, rv3d.viewinv); diff --git a/source/blender/editors/space_view3d/view3d_edit.cc b/source/blender/editors/space_view3d/view3d_edit.cc index d409507446e..161e0a97b21 100644 --- a/source/blender/editors/space_view3d/view3d_edit.cc +++ b/source/blender/editors/space_view3d/view3d_edit.cc @@ -24,9 +24,10 @@ #include "BKE_armature.hh" #include "BKE_camera.h" #include "BKE_lib_id.hh" +#include "BKE_main.hh" #include "BKE_object.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/editors/space_view3d/view3d_gizmo_armature.cc b/source/blender/editors/space_view3d/view3d_gizmo_armature.cc index 23f8b3c4077..c6449006f45 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_armature.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_armature.cc @@ -6,11 +6,13 @@ * \ingroup spview3d */ +#include "BLI_blenlib.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" #include "BKE_action.h" +#include "BKE_armature.hh" #include "BKE_context.hh" #include "BKE_layer.hh" #include "BKE_object.hh" @@ -18,7 +20,9 @@ #include "DNA_armature_types.h" #include "DNA_object_types.h" +#include "ED_armature.hh" #include "ED_gizmo_library.hh" +#include "ED_screen.hh" #include "UI_resources.hh" @@ -26,6 +30,7 @@ #include "RNA_access.hh" +#include "WM_api.hh" #include "WM_types.hh" #include "view3d_intern.h" /* own include */ @@ -184,8 +189,7 @@ static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmGizmoGroup bspline_group->handles[i].index = i; float mat[4][4]; - mul_m4_m4m4( - mat, ob->object_to_world().ptr(), (i == 0) ? pchan->disp_mat : pchan->disp_tail_mat); + mul_m4_m4m4(mat, ob->object_to_world, (i == 0) ? pchan->disp_mat : pchan->disp_tail_mat); copy_m4_m4(gz->matrix_space, mat); /* need to set property here for undo. TODO: would prefer to do this in _init. */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.cc b/source/blender/editors/space_view3d/view3d_gizmo_camera.cc index 5daeab00a3a..9e0202751a5 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_camera.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.cc @@ -6,6 +6,7 @@ * \ingroup spview3d */ +#include "BLI_blenlib.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" @@ -18,6 +19,7 @@ #include "DNA_camera_types.h" #include "DNA_object_types.h" +#include "ED_armature.hh" #include "ED_gizmo_library.hh" #include "ED_screen.hh" @@ -27,6 +29,7 @@ #include "RNA_access.hh" +#include "WM_api.hh" #include "WM_message.hh" #include "WM_types.hh" @@ -87,7 +90,7 @@ static void WIDGETGROUP_camera_setup(const bContext *C, wmGizmoGroup *gzgroup) MEM_callocN(sizeof(CameraWidgetGroup), __func__)); gzgroup->customdata = cagzgroup; - negate_v3_v3(dir, ob->object_to_world().ptr()[2]); + negate_v3_v3(dir, ob->object_to_world[2]); /* dof distance */ { @@ -139,12 +142,11 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup) PointerRNA camera_ptr = RNA_pointer_create(&ca->id, &RNA_Camera, ca); - negate_v3_v3(dir, ob->object_to_world().ptr()[2]); + negate_v3_v3(dir, ob->object_to_world[2]); if ((ca->flag & CAM_SHOWLIMITS) && (v3d->gizmo_show_camera & V3D_GIZMO_SHOW_CAMERA_DOF_DIST)) { - WM_gizmo_set_matrix_location(cagzgroup->dop_dist, ob->object_to_world().location()); - WM_gizmo_set_matrix_rotation_from_yz_axis( - cagzgroup->dop_dist, ob->object_to_world().ptr()[1], dir); + WM_gizmo_set_matrix_location(cagzgroup->dop_dist, ob->object_to_world[3]); + WM_gizmo_set_matrix_rotation_from_yz_axis(cagzgroup->dop_dist, ob->object_to_world[1], dir); WM_gizmo_set_scale(cagzgroup->dop_dist, ca->drawsize); WM_gizmo_set_flag(cagzgroup->dop_dist, WM_GIZMO_HIDDEN, false); @@ -184,17 +186,17 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup) aspect[1] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? aspy / aspx : 1.0f; unit_m4(widget->matrix_basis); - WM_gizmo_set_matrix_location(widget, ob->object_to_world().location()); - WM_gizmo_set_matrix_rotation_from_yz_axis(widget, ob->object_to_world().ptr()[1], dir); + WM_gizmo_set_matrix_location(widget, ob->object_to_world[3]); + WM_gizmo_set_matrix_rotation_from_yz_axis(widget, ob->object_to_world[1], dir); if (is_ortho) { scale_matrix = ca->ortho_scale * 0.5f; } else { const float ob_scale_inv[3] = { - 1.0f / len_v3(ob->object_to_world().ptr()[0]), - 1.0f / len_v3(ob->object_to_world().ptr()[1]), - 1.0f / len_v3(ob->object_to_world().ptr()[2]), + 1.0f / len_v3(ob->object_to_world[0]), + 1.0f / len_v3(ob->object_to_world[1]), + 1.0f / len_v3(ob->object_to_world[2]), }; const float ob_scale_uniform_inv = (ob_scale_inv[0] + ob_scale_inv[1] + ob_scale_inv[2]) / 3.0f; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_empty.cc b/source/blender/editors/space_view3d/view3d_gizmo_empty.cc index db8cb670457..e860aea9dee 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_empty.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_empty.cc @@ -17,9 +17,11 @@ #include "DEG_depsgraph.hh" +#include "DNA_light_types.h" #include "DNA_object_types.h" #include "ED_gizmo_library.hh" +#include "ED_screen.hh" #include "UI_resources.hh" @@ -27,6 +29,7 @@ #include "RNA_access.hh" +#include "WM_api.hh" #include "WM_types.hh" #include "view3d_intern.h" /* own include */ @@ -141,7 +144,7 @@ static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmGizmoGroup *gzg BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); - copy_m4_m4(gz->matrix_basis, ob->object_to_world().ptr()); + copy_m4_m4(gz->matrix_basis, ob->object_to_world); RNA_enum_set(gz->ptr, "transform", diff --git a/source/blender/editors/space_view3d/view3d_gizmo_forcefield.cc b/source/blender/editors/space_view3d/view3d_gizmo_forcefield.cc index b78afae0857..ccb2adb1d98 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_forcefield.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_forcefield.cc @@ -15,6 +15,7 @@ #include "DNA_object_types.h" #include "ED_gizmo_library.hh" +#include "ED_screen.hh" #include "UI_resources.hh" @@ -23,6 +24,7 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "WM_api.hh" #include "WM_types.hh" #include "view3d_intern.h" /* own include */ @@ -87,8 +89,8 @@ static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmGizmoGroup *gzgr const float ofs[3] = {0.0f, -size, 0.0f}; PointerRNA field_ptr = RNA_pointer_create(&ob->id, &RNA_FieldSettings, pd); - WM_gizmo_set_matrix_location(gz, ob->object_to_world().location()); - WM_gizmo_set_matrix_rotation_from_z_axis(gz, ob->object_to_world().ptr()[2]); + WM_gizmo_set_matrix_location(gz, ob->object_to_world[3]); + WM_gizmo_set_matrix_rotation_from_z_axis(gz, ob->object_to_world[2]); WM_gizmo_set_matrix_offset_location(gz, ofs); WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false); WM_gizmo_target_property_def_rna(gz, "offset", &field_ptr, "strength", -1); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_light.cc b/source/blender/editors/space_view3d/view3d_gizmo_light.cc index da7d0c92bbd..503b0188bc9 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_light.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_light.cc @@ -13,6 +13,7 @@ #include "BKE_context.hh" #include "BKE_layer.hh" +#include "BKE_object.hh" #include "DEG_depsgraph.hh" @@ -20,6 +21,7 @@ #include "DNA_object_types.h" #include "ED_gizmo_library.hh" +#include "ED_screen.hh" #include "UI_resources.hh" @@ -231,9 +233,9 @@ static void WIDGETGROUP_light_spot_refresh(const bContext *C, wmGizmoGroup *gzgr wmGizmo *gz = ls_gzgroup->spot_angle; float dir[3]; - negate_v3_v3(dir, ob->object_to_world().ptr()[2]); + negate_v3_v3(dir, ob->object_to_world[2]); WM_gizmo_set_matrix_rotation_from_z_axis(gz, dir); - WM_gizmo_set_matrix_location(gz, ob->object_to_world().location()); + WM_gizmo_set_matrix_location(gz, ob->object_to_world[3]); const char *propname = "spot_size"; WM_gizmo_target_property_def_rna(gz, "offset", &lamp_ptr, propname, -1); @@ -243,11 +245,11 @@ static void WIDGETGROUP_light_spot_refresh(const bContext *C, wmGizmoGroup *gzgr { wmGizmo *gz = ls_gzgroup->spot_blend; - copy_m4_m4(gz->matrix_basis, ob->object_to_world().ptr()); + copy_m4_m4(gz->matrix_basis, ob->object_to_world); /* Move center to the cone base plane. */ float dir[3]; - negate_v3_v3(dir, ob->object_to_world().ptr()[2]); + negate_v3_v3(dir, ob->object_to_world[2]); mul_v3_fl(dir, CONE_SCALE * cosf(0.5f * la->spotsize)); add_v3_v3(gz->matrix_basis[3], dir); } @@ -267,7 +269,7 @@ static void WIDGETGROUP_light_spot_draw_prepare(const bContext *C, wmGizmoGroup RegionView3D *rv3d = static_cast(CTX_wm_region(C)->regiondata); WM_gizmo_set_matrix_rotation_from_z_axis(gz, rv3d->viewinv[2]); - WM_gizmo_set_matrix_location(gz, ob->object_to_world().location()); + WM_gizmo_set_matrix_location(gz, ob->object_to_world[3]); } void VIEW3D_GGT_light_spot(wmGizmoGroupType *gzgt) @@ -353,7 +355,7 @@ static void WIDGETGROUP_light_point_draw_prepare(const bContext *C, wmGizmoGroup const RegionView3D *rv3d = static_cast(CTX_wm_region(C)->regiondata); WM_gizmo_set_matrix_rotation_from_z_axis(gz, rv3d->viewinv[2]); - WM_gizmo_set_matrix_location(gz, ob->object_to_world().location()); + WM_gizmo_set_matrix_location(gz, ob->object_to_world[3]); } void VIEW3D_GGT_light_point(wmGizmoGroupType *gzgt) @@ -459,7 +461,7 @@ static void WIDGETGROUP_light_area_refresh(const bContext *C, wmGizmoGroup *gzgr Light *la = static_cast(ob->data); wmGizmo *gz = wwrapper->gizmo; - copy_m4_m4(gz->matrix_basis, ob->object_to_world().ptr()); + copy_m4_m4(gz->matrix_basis, ob->object_to_world); int flag = ED_GIZMO_CAGE_XFORM_FLAG_SCALE; if (ELEM(la->area_shape, LA_AREA_SQUARE, LA_AREA_DISK)) { @@ -555,7 +557,7 @@ static void WIDGETGROUP_light_target_draw_prepare(const bContext *C, wmGizmoGrou Object *ob = BKE_view_layer_active_object_get(view_layer); wmGizmo *gz = wwrapper->gizmo; - normalize_m4_m4(gz->matrix_basis, ob->object_to_world().ptr()); + normalize_m4_m4(gz->matrix_basis, ob->object_to_world); unit_m4(gz->matrix_offset); if (ob->type == OB_LAMP) { diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.cc b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.cc index 62f6970f520..d6d82414bac 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.cc @@ -25,18 +25,25 @@ #include "BKE_context.hh" #include "GPU_batch.h" +#include "GPU_batch_presets.h" #include "GPU_immediate.h" +#include "GPU_immediate_util.h" #include "GPU_matrix.h" #include "GPU_state.h" #include "BLF_api.hh" +#include "RNA_access.hh" +#include "RNA_define.hh" + #include "UI_interface.hh" #include "UI_resources.hh" #include "WM_api.hh" #include "WM_types.hh" +#include "ED_screen.hh" + #include "view3d_intern.h" /* Radius of the entire background. */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect.cc b/source/blender/editors/space_view3d/view3d_gizmo_preselect.cc index aff5ca88ba4..7c463ef72a2 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_preselect.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect.cc @@ -10,11 +10,14 @@ #include "BLI_utildefines.h" +#include "BKE_context.hh" + #include "ED_gizmo_utils.hh" #include "ED_screen.hh" #include "UI_resources.hh" +#include "WM_api.hh" #include "WM_types.hh" #include "view3d_intern.h" /* own include */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc index e2611bdb575..6d677d55a04 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc @@ -19,7 +19,7 @@ #include "BKE_context.hh" #include "BKE_editmesh.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_mesh.hh" #include "BKE_mesh_wrapper.hh" @@ -102,7 +102,7 @@ static void gizmo_preselect_elem_draw(const bContext *C, wmGizmo *gz) MeshElemGizmo3D *gz_ele = (MeshElemGizmo3D *)gz; if (gz_ele->base_index != -1) { Object *ob = gz_ele->bases[gz_ele->base_index]->object; - EDBM_preselect_elem_draw(gz_ele->psel, ob->object_to_world().ptr()); + EDBM_preselect_elem_draw(gz_ele->psel, ob->object_to_world); } } @@ -188,8 +188,7 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int BMVert *vert = (BMVert *)eve_test; float vert_p_co[2], vert_co[3]; const float mval_f[2] = {float(vc.mval[0]), float(vc.mval[1])}; - mul_v3_m4v3( - vert_co, gz_ele->bases[base_index_vert]->object->object_to_world().ptr(), vert->co); + mul_v3_m4v3(vert_co, gz_ele->bases[base_index_vert]->object->object_to_world, vert->co); ED_view3d_project_v2(vc.region, vert_co, vert_p_co); float len = len_v2v2(vert_p_co, mval_f); if (len < 35) { @@ -336,7 +335,7 @@ static void gizmo_preselect_edgering_draw(const bContext *C, wmGizmo *gz) MeshEdgeRingGizmo3D *gz_ring = (MeshEdgeRingGizmo3D *)gz; if (gz_ring->base_index != -1) { Object *ob = gz_ring->bases[gz_ring->base_index]->object; - EDBM_preselect_edgering_draw(gz_ring->psel, ob->object_to_world().ptr()); + EDBM_preselect_edgering_draw(gz_ring->psel, ob->object_to_world); } } diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc b/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc index 0b81b698980..b2733344845 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.cc @@ -11,15 +11,21 @@ #include "BLI_math_matrix_types.hh" #include "BLI_math_rotation.h" #include "BLI_math_vector_types.hh" +#include "BLI_rect.h" #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BLT_translation.h" + #include "BKE_context.hh" #include "BKE_gpencil_legacy.h" -#include "BKE_report.hh" +#include "BKE_main.hh" +#include "BKE_report.h" #include "BKE_layer.hh" -#include "BKE_scene.hh" +#include "BKE_material.h" +#include "BKE_object.hh" +#include "BKE_scene.h" #include "BKE_unit.hh" #include "DNA_gpencil_legacy_types.h" @@ -28,6 +34,7 @@ #include "ED_gizmo_library.hh" #include "ED_gizmo_utils.hh" +#include "ED_gpencil_legacy.hh" #include "ED_screen.hh" #include "ED_transform.hh" #include "ED_transform_snap_object_context.hh" diff --git a/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.cc b/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.cc index 952fee17026..a000564230f 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.cc @@ -11,7 +11,7 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "ED_gizmo_library.hh" #include "ED_gizmo_utils.hh" diff --git a/source/blender/editors/space_view3d/view3d_header.cc b/source/blender/editors/space_view3d/view3d_header.cc index 0b0e95e16e5..3e14ebb2259 100644 --- a/source/blender/editors/space_view3d/view3d_header.cc +++ b/source/blender/editors/space_view3d/view3d_header.cc @@ -14,8 +14,11 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_math_base.h" #include "BLI_utildefines.h" +#include "BLT_translation.h" + #include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" @@ -29,6 +32,9 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "ED_mesh.hh" +#include "ED_undo.hh" + #include "UI_interface.hh" #include "UI_resources.hh" @@ -121,9 +127,6 @@ static void uiTemplatePaintModeSelection(uiLayout *layout, bContext *C) ViewLayer *view_layer = CTX_data_view_layer(C); BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); - if (ob->type != OB_MESH) { - return; - } /* Gizmos aren't used in paint modes */ if (!ELEM(ob->mode, OB_MODE_SCULPT, OB_MODE_PARTICLE_EDIT)) { diff --git a/source/blender/editors/space_view3d/view3d_iterators.cc b/source/blender/editors/space_view3d/view3d_iterators.cc index 0de0efa3071..23a2bcab212 100644 --- a/source/blender/editors/space_view3d/view3d_iterators.cc +++ b/source/blender/editors/space_view3d/view3d_iterators.cc @@ -26,7 +26,9 @@ #include "BKE_editmesh.hh" #include "BKE_mesh.hh" #include "BKE_mesh_iterators.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_mesh_wrapper.hh" +#include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" @@ -308,7 +310,7 @@ void meshobject_foreachScreenVert(ViewContext *vc, data.hide_vert = *attributes.lookup(".hide_vert", bke::AttrDomain::Point); if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { - ED_view3d_clipping_local(vc->rv3d, vc->obact->object_to_world().ptr()); + ED_view3d_clipping_local(vc->rv3d, vc->obact->object_to_world); } BKE_mesh_foreach_mapped_vert( @@ -357,7 +359,7 @@ void mesh_foreachScreenVert( if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { ED_view3d_clipping_local(vc->rv3d, - vc->obedit->object_to_world().ptr()); /* for local clipping lookups */ + vc->obedit->object_to_world); /* for local clipping lookups */ } BM_mesh_elem_table_ensure(vc->em->bm, BM_VERT); @@ -428,7 +430,7 @@ void mesh_foreachScreenEdge(ViewContext *vc, if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { ED_view3d_clipping_local(vc->rv3d, - vc->obedit->object_to_world().ptr()); /* for local clipping lookups */ + vc->obedit->object_to_world); /* for local clipping lookups */ } if (clip_flag & V3D_PROJ_TEST_CLIP_CONTENT) { @@ -527,8 +529,8 @@ void mesh_foreachScreenEdge_clip_bb_segment(ViewContext *vc, BM_mesh_elem_table_ensure(vc->em->bm, BM_EDGE); if ((clip_flag & V3D_PROJ_TEST_CLIP_BB) && (vc->rv3d->clipbb != nullptr)) { - ED_view3d_clipping_local( - vc->rv3d, vc->obedit->object_to_world().ptr()); /* for local clipping lookups. */ + ED_view3d_clipping_local(vc->rv3d, + vc->obedit->object_to_world); /* for local clipping lookups. */ BKE_mesh_foreach_mapped_edge( mesh, vc->em->bm->totedge, mesh_foreachScreenEdge_clip_bb_segment__mapFunc, &data); } @@ -624,7 +626,7 @@ void nurbs_foreachScreenVert(ViewContext *vc, if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { ED_view3d_clipping_local(vc->rv3d, - vc->obedit->object_to_world().ptr()); /* for local clipping lookups */ + vc->obedit->object_to_world); /* for local clipping lookups */ } LISTBASE_FOREACH (Nurb *, nu, nurbs) { @@ -746,8 +748,7 @@ void lattice_foreachScreenVert(ViewContext *vc, ED_view3d_check_mats_rv3d(vc->rv3d); if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { - ED_view3d_clipping_local(vc->rv3d, - obedit->object_to_world().ptr()); /* for local clipping lookups */ + ED_view3d_clipping_local(vc->rv3d, obedit->object_to_world); /* for local clipping lookups */ } for (i = 0; i < N; i++, bp++, co += 3) { diff --git a/source/blender/editors/space_view3d/view3d_navigate.cc b/source/blender/editors/space_view3d/view3d_navigate.cc index b4e9e95cd82..155d15088f1 100644 --- a/source/blender/editors/space_view3d/view3d_navigate.cc +++ b/source/blender/editors/space_view3d/view3d_navigate.cc @@ -7,6 +7,7 @@ */ #include "DNA_curve_types.h" +#include "DNA_gpencil_legacy_types.h" #include "MEM_guardedalloc.h" @@ -17,23 +18,34 @@ #include "BLI_math_vector.hh" #include "BLI_rect.h" +#include "BLT_translation.h" + +#include "BKE_armature.hh" #include "BKE_context.hh" +#include "BKE_gpencil_geom_legacy.h" #include "BKE_layer.hh" #include "BKE_object.hh" #include "BKE_object_types.hh" #include "BKE_paint.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "BKE_vfont.hh" #include "DEG_depsgraph_query.hh" +#include "ED_mesh.hh" +#include "ED_particle.hh" #include "ED_screen.hh" #include "ED_transform.hh" #include "WM_api.hh" +#include "WM_message.hh" #include "RNA_access.hh" #include "RNA_define.hh" +#include "UI_resources.hh" + #include "view3d_intern.h" #include "view3d_navigate.hh" /* own include */ @@ -808,7 +820,7 @@ bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) } mul_v2_fl(lastofs, 1.0f / 4.0f); - mul_m4_v3(ob_act_eval->object_to_world().ptr(), lastofs); + mul_m4_v3(ob_act_eval->object_to_world, lastofs); is_set = true; } @@ -826,11 +838,11 @@ bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) if (ob_eval->runtime->bounds_eval) { blender::float3 cent = blender::math::midpoint(ob_eval->runtime->bounds_eval->min, ob_eval->runtime->bounds_eval->max); - mul_m4_v3(ob_eval->object_to_world().ptr(), cent); + mul_m4_v3(ob_eval->object_to_world, cent); add_v3_v3(select_center, cent); } else { - add_v3_v3(select_center, ob_eval->object_to_world().location()); + add_v3_v3(select_center, ob_eval->object_to_world[3]); } tot++; } diff --git a/source/blender/editors/space_view3d/view3d_navigate_fly.cc b/source/blender/editors/space_view3d/view3d_navigate_fly.cc index 2c8785f2084..31679d44d43 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_fly.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_fly.cc @@ -29,7 +29,9 @@ #include "BKE_context.hh" #include "BKE_lib_id.hh" -#include "BKE_report.hh" +#include "BKE_report.h" + +#include "BLT_translation.h" #include "WM_api.hh" #include "WM_types.hh" @@ -37,14 +39,17 @@ #include "ED_screen.hh" #include "ED_space_api.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "GPU_immediate.h" +#include "DEG_depsgraph.hh" + #include "view3d_intern.h" /* own include */ #include "view3d_navigate.hh" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* -------------------------------------------------------------------- */ /** \name Modal Key-map @@ -366,7 +371,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent fly->ndof = nullptr; #endif - fly->time_lastdraw = fly->time_lastwheel = BLI_time_now_seconds(); + fly->time_lastdraw = fly->time_lastwheel = BLI_check_seconds_timer(); fly->draw_handle_pixel = ED_region_draw_cb_activate( fly->region->type, drawFlyPixel, fly, REGION_DRAW_POST_PIXEL); @@ -513,7 +518,7 @@ static void flyEvent(FlyInfo *fly, const wmEvent *event) fly->ndof = nullptr; } /* Update the time else the view will jump when 2D mouse/timer resume. */ - fly->time_lastdraw = BLI_time_now_seconds(); + fly->time_lastdraw = BLI_check_seconds_timer(); break; } default: { @@ -561,7 +566,7 @@ static void flyEvent(FlyInfo *fly, const wmEvent *event) fly->speed = fabsf(fly->speed); } - time_currwheel = BLI_time_now_seconds(); + time_currwheel = BLI_check_seconds_timer(); time_wheel = float(time_currwheel - fly->time_lastwheel); fly->time_lastwheel = time_currwheel; /* Mouse wheel delays range from (0.5 == slow) to (0.01 == fast). */ @@ -586,7 +591,7 @@ static void flyEvent(FlyInfo *fly, const wmEvent *event) fly->speed = -fabsf(fly->speed); } - time_currwheel = BLI_time_now_seconds(); + time_currwheel = BLI_check_seconds_timer(); time_wheel = float(time_currwheel - fly->time_lastwheel); fly->time_lastwheel = time_currwheel; /* 0-0.5 -> 0-5.0 */ @@ -843,7 +848,7 @@ static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm) #ifdef NDOF_FLY_DRAW_TOOMUCH fly->redraw = 1; #endif - time_current = BLI_time_now_seconds(); + time_current = BLI_check_seconds_timer(); time_redraw = float(time_current - fly->time_lastdraw); /* Clamp redraw time to avoid jitter in roll correction. */ @@ -1017,7 +1022,7 @@ static int flyApply(bContext *C, FlyInfo *fly, bool is_confirm) } else { /* We're not redrawing but we need to update the time else the view will jump. */ - fly->time_lastdraw = BLI_time_now_seconds(); + fly->time_lastdraw = BLI_check_seconds_timer(); } /* End drawing. */ copy_v3_v3(fly->dvec_prev, dvec); diff --git a/source/blender/editors/space_view3d/view3d_navigate_smoothview.cc b/source/blender/editors/space_view3d/view3d_navigate_smoothview.cc index f488ca5b502..94ecacb1709 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_smoothview.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_smoothview.cc @@ -262,7 +262,7 @@ void ED_view3d_smooth_view_ex( Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera); if (sview->ofs != nullptr) { sms.dst.dist = ED_view3d_offset_distance( - ob_camera_eval->object_to_world().ptr(), sview->ofs, VIEW3D_DIST_FALLBACK); + ob_camera_eval->object_to_world, sview->ofs, VIEW3D_DIST_FALLBACK); } ED_view3d_from_object(ob_camera_eval, sms.dst.ofs, sms.dst.quat, &sms.dst.dist, &sms.dst.lens); sms.to_camera = true; /* restore view3d values in end */ @@ -287,7 +287,7 @@ void ED_view3d_smooth_view_ex( Object *ob_camera_old_eval = DEG_get_evaluated_object(depsgraph, sview->camera_old); if (sview->ofs != nullptr) { sms.src.dist = ED_view3d_offset_distance( - ob_camera_old_eval->object_to_world().ptr(), sview->ofs, 0.0f); + ob_camera_old_eval->object_to_world, sview->ofs, 0.0f); } ED_view3d_from_object( ob_camera_old_eval, sms.src.ofs, sms.src.quat, &sms.src.dist, &sms.src.lens); diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_all.cc b/source/blender/editors/space_view3d/view3d_navigate_view_all.cc index a6db2f9a77d..e357332d4d3 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_all.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_all.cc @@ -10,18 +10,21 @@ #include "BKE_armature.hh" #include "BKE_context.hh" +#include "BKE_crazyspace.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_layer.hh" #include "BKE_object.hh" #include "BKE_paint.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" +#include "BLI_bounds.hh" #include "BLI_bounds_types.hh" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" #include "DEG_depsgraph_query.hh" +#include "ED_curves.hh" #include "ED_mesh.hh" #include "ED_particle.hh" #include "ED_screen.hh" @@ -74,7 +77,7 @@ static void view3d_object_calc_minmax(Depsgraph *depsgraph, if (BKE_object_minmax_dupli(depsgraph, scene, ob_eval, min, max, false) == 0) { /* Use if duplis aren't found. */ if (only_center) { - minmax_v3v3_v3(min, max, ob_eval->object_to_world().location()); + minmax_v3v3_v3(min, max, ob_eval->object_to_world[3]); } else { BKE_object_minmax(ob_eval, min, max); @@ -379,8 +382,8 @@ static int viewselected_exec(bContext *C, wmOperator *op) CTX_DATA_END; if ((ob_eval) && (ok)) { - mul_m4_v3(ob_eval->object_to_world().ptr(), min); - mul_m4_v3(ob_eval->object_to_world().ptr(), max); + mul_m4_v3(ob_eval->object_to_world, min); + mul_m4_v3(ob_eval->object_to_world, max); } } else if (is_face_map) { diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_axis.cc b/source/blender/editors/space_view3d/view3d_navigate_view_axis.cc index 1240bf8d25a..db9b8d94bb4 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_axis.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_axis.cc @@ -6,17 +6,36 @@ * \ingroup spview3d */ +#include "DNA_curve_types.h" +#include "DNA_gpencil_legacy_types.h" + #include "MEM_guardedalloc.h" #include "BLI_math_rotation.h" +#include "BLI_math_vector.h" +#include "BLI_rect.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "BKE_armature.hh" #include "BKE_context.hh" +#include "BKE_gpencil_geom_legacy.h" +#include "BKE_layer.hh" +#include "BKE_object.hh" +#include "BKE_paint.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" +#include "BKE_vfont.hh" +#include "DEG_depsgraph_query.hh" + +#include "ED_mesh.hh" +#include "ED_particle.hh" +#include "ED_screen.hh" #include "ED_transform.hh" #include "WM_api.hh" +#include "WM_message.hh" #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_camera.cc b/source/blender/editors/space_view3d/view3d_navigate_view_camera.cc index 2407585b24b..aeb03ce0a0a 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_camera.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_camera.cc @@ -6,14 +6,39 @@ * \ingroup spview3d */ +#include "DNA_curve_types.h" +#include "DNA_gpencil_legacy_types.h" + #include "MEM_guardedalloc.h" +#include "BLI_rect.h" + +#include "BLT_translation.h" + +#include "BKE_armature.hh" #include "BKE_context.hh" +#include "BKE_gpencil_geom_legacy.h" #include "BKE_layer.hh" +#include "BKE_object.hh" +#include "BKE_paint.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" +#include "BKE_vfont.hh" #include "DEG_depsgraph_query.hh" +#include "ED_mesh.hh" +#include "ED_particle.hh" +#include "ED_screen.hh" +#include "ED_transform.hh" + #include "WM_api.hh" +#include "WM_message.hh" + +#include "RNA_access.hh" +#include "RNA_define.hh" + +#include "UI_resources.hh" #include "view3d_intern.h" diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_center_cursor.cc b/source/blender/editors/space_view3d/view3d_navigate_view_center_cursor.cc index 9c01c6fab97..67ceec73250 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_center_cursor.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_center_cursor.cc @@ -6,13 +6,40 @@ * \ingroup spview3d */ +#include "DNA_curve_types.h" +#include "DNA_gpencil_legacy_types.h" + #include "MEM_guardedalloc.h" #include "BLI_math_vector.h" +#include "BLI_rect.h" +#include "BLT_translation.h" + +#include "BKE_armature.hh" #include "BKE_context.hh" +#include "BKE_gpencil_geom_legacy.h" +#include "BKE_layer.hh" +#include "BKE_object.hh" +#include "BKE_paint.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" +#include "BKE_vfont.hh" + +#include "DEG_depsgraph_query.hh" + +#include "ED_mesh.hh" +#include "ED_particle.hh" +#include "ED_screen.hh" +#include "ED_transform.hh" #include "WM_api.hh" +#include "WM_message.hh" + +#include "RNA_access.hh" +#include "RNA_define.hh" + +#include "UI_resources.hh" #include "view3d_intern.h" diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_center_pick.cc b/source/blender/editors/space_view3d/view3d_navigate_view_center_pick.cc index 91c5f994b10..1a6bab521b2 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_center_pick.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_center_pick.cc @@ -6,13 +6,40 @@ * \ingroup spview3d */ +#include "DNA_curve_types.h" +#include "DNA_gpencil_legacy_types.h" + #include "MEM_guardedalloc.h" #include "BLI_math_vector.h" +#include "BLI_rect.h" +#include "BLT_translation.h" + +#include "BKE_armature.hh" #include "BKE_context.hh" +#include "BKE_gpencil_geom_legacy.h" +#include "BKE_layer.hh" +#include "BKE_object.hh" +#include "BKE_paint.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" +#include "BKE_vfont.hh" + +#include "DEG_depsgraph_query.hh" + +#include "ED_mesh.hh" +#include "ED_particle.hh" +#include "ED_screen.hh" +#include "ED_transform.hh" #include "WM_api.hh" +#include "WM_message.hh" + +#include "RNA_access.hh" +#include "RNA_define.hh" + +#include "UI_resources.hh" #include "view3d_intern.h" diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_dolly.cc b/source/blender/editors/space_view3d/view3d_navigate_view_dolly.cc index 59c56b0c982..4c8e68cd263 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_dolly.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_dolly.cc @@ -7,10 +7,12 @@ */ #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BLI_math_vector.h" +#include "DEG_depsgraph.hh" + #include "WM_api.hh" #include "RNA_access.hh" diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_move.cc b/source/blender/editors/space_view3d/view3d_navigate_view_move.cc index e69e4030315..76d64f7b761 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_move.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_move.cc @@ -6,10 +6,15 @@ * \ingroup spview3d */ +#include "BLI_math_vector.h" + #include "BKE_context.hh" #include "WM_api.hh" +#include "RNA_access.hh" +#include "RNA_define.hh" + #include "ED_screen.hh" #include "view3d_intern.h" diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_ndof.cc b/source/blender/editors/space_view3d/view3d_navigate_view_ndof.cc index 4bdebe782d3..109ac85dd9f 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_ndof.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_ndof.cc @@ -6,9 +6,13 @@ * \ingroup spview3d */ +#include "BKE_context.hh" + #include "BLI_math_rotation.h" #include "BLI_math_vector.h" +#include "DEG_depsgraph.hh" + #include "WM_api.hh" #include "ED_screen.hh" diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_orbit.cc b/source/blender/editors/space_view3d/view3d_navigate_view_orbit.cc index ef8a4ced0be..51aec20d595 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_orbit.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_orbit.cc @@ -6,15 +6,42 @@ * \ingroup spview3d */ +#include "DNA_curve_types.h" +#include "DNA_gpencil_legacy_types.h" + #include "MEM_guardedalloc.h" #include "BLI_math_rotation.h" +#include "BLI_math_vector.h" +#include "BLI_rect.h" + +#include "BLT_translation.h" + +#include "BKE_armature.hh" +#include "BKE_context.hh" +#include "BKE_gpencil_geom_legacy.h" +#include "BKE_layer.hh" +#include "BKE_object.hh" +#include "BKE_paint.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" +#include "BKE_vfont.hh" + +#include "DEG_depsgraph_query.hh" + +#include "ED_mesh.hh" +#include "ED_particle.hh" +#include "ED_screen.hh" +#include "ED_transform.hh" #include "WM_api.hh" +#include "WM_message.hh" #include "RNA_access.hh" #include "RNA_define.hh" +#include "UI_resources.hh" + #include "view3d_intern.h" #include "view3d_navigate.hh" /* own include */ diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_pan.cc b/source/blender/editors/space_view3d/view3d_navigate_view_pan.cc index 45402e83fed..15d218f6e22 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_pan.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_pan.cc @@ -6,13 +6,40 @@ * \ingroup spview3d */ +#include "DNA_curve_types.h" +#include "DNA_gpencil_legacy_types.h" + #include "MEM_guardedalloc.h" +#include "BLI_rect.h" + +#include "BLT_translation.h" + +#include "BKE_armature.hh" +#include "BKE_context.hh" +#include "BKE_gpencil_geom_legacy.h" +#include "BKE_layer.hh" +#include "BKE_object.hh" +#include "BKE_paint.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" +#include "BKE_vfont.hh" + +#include "DEG_depsgraph_query.hh" + +#include "ED_mesh.hh" +#include "ED_particle.hh" +#include "ED_screen.hh" +#include "ED_transform.hh" + #include "WM_api.hh" +#include "WM_message.hh" #include "RNA_access.hh" #include "RNA_define.hh" +#include "UI_resources.hh" + #include "view3d_intern.h" #include "view3d_navigate.hh" /* own include */ diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_roll.cc b/source/blender/editors/space_view3d/view3d_navigate_view_roll.cc index 16c975415bd..a886926b08d 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_roll.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_roll.cc @@ -18,6 +18,8 @@ #include "RNA_access.hh" #include "RNA_define.hh" +#include "DEG_depsgraph_query.hh" + #include "ED_screen.hh" #include "view3d_intern.h" diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_rotate.cc b/source/blender/editors/space_view3d/view3d_navigate_view_rotate.cc index 14b23b94291..b85c4d20325 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_rotate.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_rotate.cc @@ -14,6 +14,8 @@ #include "WM_api.hh" +#include "RNA_access.hh" + #include "ED_screen.hh" #include "view3d_intern.h" diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_zoom.cc b/source/blender/editors/space_view3d/view3d_navigate_view_zoom.cc index 6e49d9486c5..ff4feb5da89 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_zoom.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_zoom.cc @@ -13,6 +13,8 @@ #include "BKE_context.hh" #include "BKE_screen.hh" +#include "DEG_depsgraph_query.hh" + #include "WM_api.hh" #include "RNA_access.hh" @@ -160,7 +162,7 @@ static float viewzoom_scale_value(const rcti *winrct, float zfac; if (viewzoom == USER_ZOOM_CONTINUE) { - double time = BLI_time_now_seconds(); + double time = BLI_check_seconds_timer(); float time_step = float(time - *r_timer_lastdraw); float fac; @@ -513,7 +515,7 @@ static int viewzoom_invoke_impl(bContext *C, if (U.viewzoom == USER_ZOOM_CONTINUE) { /* needs a timer to continue redrawing */ vod->timer = WM_event_timer_add(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f); - vod->prev.time = BLI_time_now_seconds(); + vod->prev.time = BLI_check_seconds_timer(); } return OPERATOR_RUNNING_MODAL; diff --git a/source/blender/editors/space_view3d/view3d_navigate_walk.cc b/source/blender/editors/space_view3d/view3d_navigate_walk.cc index e71b8afb952..ddcd34623da 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_walk.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_walk.cc @@ -27,7 +27,10 @@ #include "BKE_context.hh" #include "BKE_lib_id.hh" -#include "BKE_report.hh" +#include "BKE_main.hh" +#include "BKE_report.h" + +#include "BLT_translation.h" #include "WM_api.hh" #include "WM_types.hh" @@ -36,14 +39,17 @@ #include "ED_space_api.hh" #include "ED_transform_snap_object_context.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "GPU_immediate.h" +#include "DEG_depsgraph.hh" + #include "view3d_intern.h" /* own include */ #include "view3d_navigate.hh" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" #ifdef WITH_INPUT_NDOF // # define NDOF_WALK_DEBUG @@ -617,7 +623,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op, const int walk->need_rotation_keyframe = false; walk->need_translation_keyframe = false; - walk->time_lastdraw = BLI_time_now_seconds(); + walk->time_lastdraw = BLI_check_seconds_timer(); walk->draw_handle_pixel = ED_region_draw_cb_activate( walk->region->type, drawWalkPixel, walk, REGION_DRAW_POST_PIXEL); @@ -758,7 +764,7 @@ static void walkEvent(WalkInfo *walk, const wmEvent *event) } /* Update the time else the view will jump when 2D mouse/timer resume. */ - walk->time_lastdraw = BLI_time_now_seconds(); + walk->time_lastdraw = BLI_check_seconds_timer(); break; } @@ -879,7 +885,7 @@ static void walkEvent(WalkInfo *walk, const wmEvent *event) float t; /* Delta time. */ - t = float(BLI_time_now_seconds() - walk->teleport.initial_time); + t = float(BLI_check_seconds_timer() - walk->teleport.initial_time); /* Reduce the velocity, if JUMP wasn't hold for long enough. */ t = min_ff(t, JUMP_TIME_MAX); @@ -904,7 +910,7 @@ static void walkEvent(WalkInfo *walk, const wmEvent *event) walk->gravity_state = WALK_GRAVITY_STATE_JUMP; walk->speed_jump = JUMP_SPEED_MAX; - walk->teleport.initial_time = BLI_time_now_seconds(); + walk->teleport.initial_time = BLI_check_seconds_timer(); copy_v3_v3(walk->teleport.origin, walk->rv3d->viewinv[3]); /* Using previous vector because WASD keys are not called when SPACE is. */ @@ -932,7 +938,7 @@ static void walkEvent(WalkInfo *walk, const wmEvent *event) teleport->navigation_mode = walk->navigation_mode; } teleport->state = WALK_TELEPORT_STATE_ON; - teleport->initial_time = BLI_time_now_seconds(); + teleport->initial_time = BLI_check_seconds_timer(); teleport->duration = U.walk_navigation.teleport_time; walk_navigation_mode_set(walk, WALK_MODE_FREE); @@ -1081,7 +1087,7 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm) #ifdef NDOF_WALK_DRAW_TOOMUCH walk->redraw = true; #endif - time_current = BLI_time_now_seconds(); + time_current = BLI_check_seconds_timer(); time_redraw = float(time_current - walk->time_lastdraw); /* Clamp redraw time to avoid jitter in roll correction. */ @@ -1324,7 +1330,7 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm) } else { /* Hijack the teleport variables. */ - walk->teleport.initial_time = BLI_time_now_seconds(); + walk->teleport.initial_time = BLI_check_seconds_timer(); walk->gravity_state = WALK_GRAVITY_STATE_ON; walk->teleport.duration = 0.0f; @@ -1337,7 +1343,7 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm) if (ELEM(walk->gravity_state, WALK_GRAVITY_STATE_ON, WALK_GRAVITY_STATE_JUMP)) { float ray_distance, difference = -100.0f; /* Delta time. */ - const float t = float(BLI_time_now_seconds() - walk->teleport.initial_time); + const float t = float(BLI_check_seconds_timer() - walk->teleport.initial_time); /* Keep moving if we were moving. */ copy_v2_v2(dvec, walk->teleport.direction); @@ -1380,7 +1386,7 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm) float cur_loc[3]; /* Linear interpolation. */ - t = float(BLI_time_now_seconds() - walk->teleport.initial_time); + t = float(BLI_check_seconds_timer() - walk->teleport.initial_time); t /= walk->teleport.duration; /* Clamp so we don't go past our limit. */ @@ -1411,7 +1417,7 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm) } else { /* We're not redrawing but we need to update the time else the view will jump. */ - walk->time_lastdraw = BLI_time_now_seconds(); + walk->time_lastdraw = BLI_check_seconds_timer(); } /* End drawing. */ copy_v3_v3(walk->dvec_prev, dvec); diff --git a/source/blender/editors/space_view3d/view3d_navigate_zoom_border.cc b/source/blender/editors/space_view3d/view3d_navigate_zoom_border.cc index 8e10312349c..7c97db0e627 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_zoom_border.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_zoom_border.cc @@ -14,7 +14,9 @@ #include "BLI_rect.h" #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_report.h" + +#include "DEG_depsgraph_query.hh" #include "WM_api.hh" diff --git a/source/blender/editors/space_view3d/view3d_ops.cc b/source/blender/editors/space_view3d/view3d_ops.cc index e182d8dd3ab..1bc6e5c0aee 100644 --- a/source/blender/editors/space_view3d/view3d_ops.cc +++ b/source/blender/editors/space_view3d/view3d_ops.cc @@ -20,7 +20,8 @@ #include "BKE_appdir.hh" #include "BKE_blender_copybuffer.hh" #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_main.hh" +#include "BKE_report.h" #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/editors/space_view3d/view3d_placement.cc b/source/blender/editors/space_view3d/view3d_placement.cc index df725272984..fe3ff7b6e30 100644 --- a/source/blender/editors/space_view3d/view3d_placement.cc +++ b/source/blender/editors/space_view3d/view3d_placement.cc @@ -20,6 +20,7 @@ #include "RNA_access.hh" #include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "WM_api.hh" #include "WM_toolsystem.hh" diff --git a/source/blender/editors/space_view3d/view3d_project.cc b/source/blender/editors/space_view3d/view3d_project.cc index d0d29f0e7e8..0f374a29781 100644 --- a/source/blender/editors/space_view3d/view3d_project.cc +++ b/source/blender/editors/space_view3d/view3d_project.cc @@ -18,6 +18,7 @@ #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" #include "BLI_math_vector.h" +#include "BLI_math_vector.hh" #include "BKE_camera.h" #include "BKE_screen.hh" @@ -83,7 +84,7 @@ void ED_view3d_project_float_v3_m4(const ARegion *region, eV3DProjStatus ED_view3d_project_base(const ARegion *region, Base *base, float r_co[2]) { eV3DProjStatus ret = ED_view3d_project_float_global( - region, base->object->object_to_world().location(), r_co, V3D_PROJ_TEST_CLIP_DEFAULT); + region, base->object->object_to_world[3], r_co, V3D_PROJ_TEST_CLIP_DEFAULT); /* Prevent uninitialized values when projection fails, * although the callers should check the return value. */ @@ -492,14 +493,17 @@ void ED_view3d_win_to_3d(const View3D *v3d, float lambda; if (rv3d->is_persp) { + float plane[4]; + copy_v3_v3(ray_origin, rv3d->viewinv[3]); ED_view3d_win_to_vector(region, mval, ray_direction); /* NOTE: we could use #isect_line_plane_v3() * however we want the intersection to be in front of the view no matter what, * so apply the unsigned factor instead. */ - isect_ray_plane_v3_factor(ray_origin, ray_direction, depth_pt, rv3d->viewinv[2], &lambda); + plane_from_point_normal_v3(plane, depth_pt, rv3d->viewinv[2]); + isect_ray_plane_v3(ray_origin, ray_direction, plane, &lambda, false); lambda = fabsf(lambda); } else { @@ -701,15 +705,19 @@ blender::float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const O float vmat[4][4]; blender::float4x4 r_pmat; - mul_m4_m4m4(vmat, rv3d->viewmat, ob->object_to_world().ptr()); + mul_m4_m4m4(vmat, rv3d->viewmat, ob->object_to_world); mul_m4_m4m4(r_pmat.ptr(), rv3d->winmat, vmat); return r_pmat; } -blender::float4x4 ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d, - const blender::float4x4 &obmat) +void ED_view3d_ob_project_mat_get_from_obmat(const RegionView3D *rv3d, + const float obmat[4][4], + float r_pmat[4][4]) { - return blender::float4x4_view(rv3d->winmat) * blender::float4x4_view(rv3d->viewmat) * obmat; + float vmat[4][4]; + + mul_m4_m4m4(vmat, rv3d->viewmat, obmat); + mul_m4_m4m4(r_pmat, rv3d->winmat, vmat); } void ED_view3d_project_v3(const ARegion *region, const float world[3], float r_region_co[3]) diff --git a/source/blender/editors/space_view3d/view3d_select.cc b/source/blender/editors/space_view3d/view3d_select.cc index e32faeac4b6..be15c8c667b 100644 --- a/source/blender/editors/space_view3d/view3d_select.cc +++ b/source/blender/editors/space_view3d/view3d_select.cc @@ -42,7 +42,7 @@ #endif /* vertex box select */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_main.hh" #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" @@ -61,7 +61,7 @@ #include "BKE_object.hh" #include "BKE_object_types.hh" #include "BKE_paint.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_tracking.h" #include "BKE_workspace.h" @@ -1194,10 +1194,9 @@ static bool do_lasso_select_grease_pencil(ViewContext *vc, vc->scene->toolsettings); bool changed = false; - const Vector drawings = + const Array drawings = ed::greasepencil::retrieve_editable_drawings(*vc->scene, grease_pencil); for (const ed::greasepencil::MutableDrawingInfo info : drawings) { - const bke::greasepencil::Layer &layer = *grease_pencil.layers()[info.layer_index]; bke::crazyspace::GeometryDeformation deformation = bke::crazyspace::get_evaluated_grease_pencil_drawing_deformation( ob_eval, *vc->obedit, info.layer_index, info.frame_number); @@ -1208,13 +1207,10 @@ static bool do_lasso_select_grease_pencil(ViewContext *vc, if (elements.is_empty()) { continue; } - const float4x4 layer_to_world = layer.to_world_space(*ob_eval); - const float4x4 projection = ED_view3d_ob_project_mat_get_from_obmat(vc->rv3d, layer_to_world); changed = ed::curves::select_lasso( *vc, info.drawing.strokes_for_write(), deformation.positions, - projection, elements, selection_domain, Span(reinterpret_cast(mcoords), mcoords_len), @@ -1436,12 +1432,10 @@ static bool view3d_lasso_select(bContext *C, bke::crazyspace::get_evaluated_curves_deformation(*vc->depsgraph, *vc->obedit); const bke::AttrDomain selection_domain = bke::AttrDomain(curves_id.selection_domain); const IndexRange elements(curves.attributes().domain_size(selection_domain)); - const float4x4 projection = ED_view3d_ob_project_mat_get(vc->rv3d, vc->obedit); changed = ed::curves::select_lasso( *vc, curves, deformation.positions, - projection, elements, selection_domain, Span(reinterpret_cast(mcoords), mcoords_len), @@ -2394,10 +2388,9 @@ static Base *mouse_select_object_center(ViewContext *vc, Base *startbase, const while (base) { if (BASE_SELECTABLE(v3d, base)) { float screen_co[2]; - if (ED_view3d_project_float_global(region, - base->object->object_to_world().location(), - screen_co, - V3D_PROJ_TEST_CLIP_DEFAULT) == V3D_PROJ_RET_OK) + if (ED_view3d_project_float_global( + region, base->object->object_to_world[3], screen_co, V3D_PROJ_TEST_CLIP_DEFAULT) == + V3D_PROJ_RET_OK) { float dist_test = len_manhattan_v2v2(mval_fl, screen_co); if (base == oldbasact) { @@ -3116,13 +3109,12 @@ static bool ed_curves_select_pick(bContext &C, const int mval[2], const SelectPi bke::crazyspace::GeometryDeformation deformation = bke::crazyspace::get_evaluated_curves_deformation(*vc.depsgraph, *vc.obedit); const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); - const float4x4 projection = ED_view3d_ob_project_mat_get(vc.rv3d, &curves_ob); const IndexRange elements(curves.attributes().domain_size(selection_domain)); std::optional new_closest_elem = ed::curves::closest_elem_find_screen_space(vc, + curves_ob, curves.points_by_curve(), deformation.positions, - projection, elements, selection_domain, mval, @@ -3201,7 +3193,7 @@ static bool ed_grease_pencil_select_pick(bContext *C, /* Collect editable drawings. */ const Object *ob_eval = DEG_get_evaluated_object(vc.depsgraph, const_cast(vc.obedit)); GreasePencil &grease_pencil = *static_cast(vc.obedit->data); - const Vector drawings = + const Array drawings = ed::greasepencil::retrieve_editable_drawings(*vc.scene, grease_pencil); /* Get selection domain from tool settings. */ @@ -3216,7 +3208,6 @@ static bool ed_grease_pencil_select_pick(bContext *C, ClosestGreasePencilDrawing new_closest = init; for (const int i : range) { ed::greasepencil::MutableDrawingInfo info = drawings[i]; - const bke::greasepencil::Layer &layer = *grease_pencil.layers()[info.layer_index]; /* Get deformation by modifiers. */ bke::crazyspace::GeometryDeformation deformation = bke::crazyspace::get_evaluated_grease_pencil_drawing_deformation( @@ -3228,14 +3219,11 @@ static bool ed_grease_pencil_select_pick(bContext *C, if (elements.is_empty()) { continue; } - const float4x4 layer_to_world = layer.to_world_space(*ob_eval); - const float4x4 projection = ED_view3d_ob_project_mat_get_from_obmat(vc.rv3d, - layer_to_world); std::optional new_closest_elem = ed::curves::closest_elem_find_screen_space(vc, + *vc.obedit, info.drawing.strokes().points_by_curve(), deformation.positions, - projection, elements, selection_domain, mval, @@ -4225,10 +4213,9 @@ static bool do_grease_pencil_box_select(ViewContext *vc, const rcti *rect, const scene->toolsettings); bool changed = false; - const Vector drawings = + const Array drawings = ed::greasepencil::retrieve_editable_drawings(*scene, grease_pencil); for (const ed::greasepencil::MutableDrawingInfo info : drawings) { - const bke::greasepencil::Layer &layer = *grease_pencil.layers()[info.layer_index]; bke::crazyspace::GeometryDeformation deformation = bke::crazyspace::get_evaluated_grease_pencil_drawing_deformation( ob_eval, *vc->obedit, info.layer_index, info.frame_number); @@ -4238,12 +4225,9 @@ static bool do_grease_pencil_box_select(ViewContext *vc, const rcti *rect, const if (elements.is_empty()) { continue; } - const float4x4 layer_to_world = layer.to_world_space(*ob_eval); - const float4x4 projection = ED_view3d_ob_project_mat_get_from_obmat(vc->rv3d, layer_to_world); changed |= ed::curves::select_box(*vc, info.drawing.strokes_for_write(), deformation.positions, - projection, elements, selection_domain, *rect, @@ -4329,16 +4313,9 @@ static int view3d_box_select_exec(bContext *C, wmOperator *op) bke::crazyspace::GeometryDeformation deformation = bke::crazyspace::get_evaluated_curves_deformation(*vc.depsgraph, *vc.obedit); const bke::AttrDomain selection_domain = bke::AttrDomain(curves_id.selection_domain); - const float4x4 projection = ED_view3d_ob_project_mat_get(vc.rv3d, vc.obedit); const IndexRange elements(curves.attributes().domain_size(selection_domain)); - changed = ed::curves::select_box(vc, - curves, - deformation.positions, - projection, - elements, - selection_domain, - rect, - sel_op); + changed = ed::curves::select_box( + vc, curves, deformation.positions, elements, selection_domain, rect, sel_op); if (changed) { /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a * generic attribute for now. */ @@ -5090,10 +5067,9 @@ static bool grease_pencil_circle_select(ViewContext *vc, vc->scene->toolsettings); bool changed = false; - const Vector drawings = + const Array drawings = ed::greasepencil::retrieve_editable_drawings(*vc->scene, grease_pencil); for (const ed::greasepencil::MutableDrawingInfo info : drawings) { - const bke::greasepencil::Layer &layer = *grease_pencil.layers()[info.layer_index]; bke::crazyspace::GeometryDeformation deformation = bke::crazyspace::get_evaluated_grease_pencil_drawing_deformation( ob_eval, *vc->obedit, info.layer_index, info.frame_number); @@ -5103,12 +5079,9 @@ static bool grease_pencil_circle_select(ViewContext *vc, if (elements.is_empty()) { continue; } - const float4x4 layer_to_world = layer.to_world_space(*ob_eval); - const float4x4 projection = ED_view3d_ob_project_mat_get_from_obmat(vc->rv3d, layer_to_world); changed = ed::curves::select_circle(*vc, info.drawing.strokes_for_write(), deformation.positions, - projection, elements, selection_domain, int2(mval), @@ -5165,17 +5138,9 @@ static bool obedit_circle_select(bContext *C, bke::crazyspace::GeometryDeformation deformation = bke::crazyspace::get_evaluated_curves_deformation(*vc->depsgraph, *vc->obedit); const bke::AttrDomain selection_domain = bke::AttrDomain(curves_id.selection_domain); - const float4x4 projection = ED_view3d_ob_project_mat_get(vc->rv3d, vc->obedit); const IndexRange elements(curves.attributes().domain_size(selection_domain)); - changed = ed::curves::select_circle(*vc, - curves, - deformation.positions, - projection, - elements, - selection_domain, - mval, - rad, - sel_op); + changed = ed::curves::select_circle( + *vc, curves, deformation.positions, elements, selection_domain, mval, rad, sel_op); if (changed) { /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a * generic attribute for now. */ @@ -5224,7 +5189,7 @@ static bool object_circle_select(ViewContext *vc, if (BASE_SELECTABLE(v3d, base) && ((base->flag & BASE_SELECTED) != select_flag)) { float screen_co[2]; if (ED_view3d_project_float_global(vc->region, - base->object->object_to_world().location(), + base->object->object_to_world[3], screen_co, V3D_PROJ_TEST_CLIP_DEFAULT) == V3D_PROJ_RET_OK) { diff --git a/source/blender/editors/space_view3d/view3d_snap.cc b/source/blender/editors/space_view3d/view3d_snap.cc index 5e60f422dda..40393abb555 100644 --- a/source/blender/editors/space_view3d/view3d_snap.cc +++ b/source/blender/editors/space_view3d/view3d_snap.cc @@ -28,8 +28,8 @@ #include "BKE_main.hh" #include "BKE_mball.hh" #include "BKE_object.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_tracking.h" #include "DEG_depsgraph.hh" @@ -99,18 +99,18 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *op) } if (tvs.transverts_tot != 0) { - copy_m3_m4(bmat, obedit->object_to_world().ptr()); + copy_m3_m4(bmat, obedit->object_to_world); invert_m3_m3(imat, bmat); tv = tvs.transverts; for (a = 0; a < tvs.transverts_tot; a++, tv++) { copy_v3_v3(vec, tv->loc); mul_m3_v3(bmat, vec); - add_v3_v3(vec, obedit->object_to_world().location()); + add_v3_v3(vec, obedit->object_to_world[3]); vec[0] = gridf * floorf(0.5f + vec[0] / gridf); vec[1] = gridf * floorf(0.5f + vec[1] / gridf); vec[2] = gridf * floorf(0.5f + vec[2] / gridf); - sub_v3_v3(vec, obedit->object_to_world().location()); + sub_v3_v3(vec, obedit->object_to_world[3]); mul_m3_v3(imat, vec); copy_v3_v3(tv->loc, vec); @@ -127,7 +127,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *op) Object *ob = DEG_get_original_object(ob_eval); bArmature *arm_eval = static_cast(ob_eval->data); - invert_m4_m4(ob_eval->runtime->world_to_object.ptr(), ob_eval->object_to_world().ptr()); + invert_m4_m4(ob_eval->world_to_object, ob_eval->object_to_world); LISTBASE_FOREACH (bPoseChannel *, pchan_eval, &ob_eval->pose->chanbase) { if (pchan_eval->bone->flag & BONE_SELECTED) { @@ -138,12 +138,12 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *op) /* get nearest grid point to snap to */ copy_v3_v3(nLoc, pchan_eval->pose_mat[3]); /* We must operate in world space! */ - mul_m4_v3(ob_eval->object_to_world().ptr(), nLoc); + mul_m4_v3(ob_eval->object_to_world, nLoc); vec[0] = gridf * floorf(0.5f + nLoc[0] / gridf); vec[1] = gridf * floorf(0.5f + nLoc[1] / gridf); vec[2] = gridf * floorf(0.5f + nLoc[2] / gridf); /* Back in object space... */ - mul_m4_v3(ob_eval->world_to_object().ptr(), vec); + mul_m4_v3(ob_eval->world_to_object, vec); /* Get location of grid point in pose space. */ BKE_armature_loc_pose_to_bone(pchan_eval, vec, vec); @@ -215,12 +215,12 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *op) for (Object *ob_eval : objects_eval) { Object *ob = DEG_get_original_object(ob_eval); - vec[0] = -ob_eval->object_to_world().location()[0] + - gridf * floorf(0.5f + ob_eval->object_to_world().location()[0] / gridf); - vec[1] = -ob_eval->object_to_world().location()[1] + - gridf * floorf(0.5f + ob_eval->object_to_world().location()[1] / gridf); - vec[2] = -ob_eval->object_to_world().location()[2] + - gridf * floorf(0.5f + ob_eval->object_to_world().location()[2] / gridf); + vec[0] = -ob_eval->object_to_world[3][0] + + gridf * floorf(0.5f + ob_eval->object_to_world[3][0] / gridf); + vec[1] = -ob_eval->object_to_world[3][1] + + gridf * floorf(0.5f + ob_eval->object_to_world[3][1] / gridf); + vec[2] = -ob_eval->object_to_world[3][2] + + gridf * floorf(0.5f + ob_eval->object_to_world[3][2] / gridf); if (ob->parent) { float originmat[3][3]; @@ -347,11 +347,11 @@ static bool snap_selected_to_location(bContext *C, } if (tvs.transverts_tot != 0) { - copy_m3_m4(bmat, obedit->object_to_world().ptr()); + copy_m3_m4(bmat, obedit->object_to_world); invert_m3_m3(imat, bmat); /* get the cursor in object space */ - sub_v3_v3v3(snap_target_local, snap_target_global, obedit->object_to_world().location()); + sub_v3_v3v3(snap_target_local, snap_target_global, obedit->object_to_world[3]); mul_m3_v3(imat, snap_target_local); if (use_offset) { @@ -384,8 +384,8 @@ static bool snap_selected_to_location(bContext *C, bArmature *arm = static_cast(ob->data); float snap_target_local[3]; - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); - mul_v3_m4v3(snap_target_local, ob->world_to_object().ptr(), snap_target_global); + invert_m4_m4(ob->world_to_object, ob->object_to_world); + mul_v3_m4v3(snap_target_local, ob->world_to_object, snap_target_global); LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { if ((pchan->bone->flag & BONE_SELECTED) && PBONE_VISIBLE(arm, pchan->bone) && @@ -411,10 +411,10 @@ static bool snap_selected_to_location(bContext *C, float cursor_pose[3]; if (use_offset) { - mul_v3_m4v3(cursor_pose, ob->object_to_world().ptr(), pchan->pose_mat[3]); + mul_v3_m4v3(cursor_pose, ob->object_to_world, pchan->pose_mat[3]); add_v3_v3(cursor_pose, offset_global); - mul_m4_v3(ob->world_to_object().ptr(), cursor_pose); + mul_m4_v3(ob->world_to_object, cursor_pose); BKE_armature_loc_pose_to_bone(pchan, cursor_pose, cursor_pose); } else { @@ -508,13 +508,13 @@ static bool snap_selected_to_location(bContext *C, float cursor_parent[3]; /* parent-relative */ if (use_offset) { - add_v3_v3v3(cursor_parent, ob->object_to_world().location(), offset_global); + add_v3_v3v3(cursor_parent, ob->object_to_world[3], offset_global); } else { copy_v3_v3(cursor_parent, snap_target_global); } - sub_v3_v3(cursor_parent, ob->object_to_world().location()); + sub_v3_v3(cursor_parent, ob->object_to_world[3]); if (ob->parent) { float originmat[3][3], parentmat[4][4]; @@ -723,7 +723,7 @@ static void bundle_midpoint(Scene *scene, Object *ob, float r_vec[3]) MovieTracking *tracking = &clip->tracking; - copy_m4_m4(cammat, ob->object_to_world().ptr()); + copy_m4_m4(cammat, ob->object_to_world); BKE_tracking_get_camera_object_matrix(ob, mat); @@ -798,13 +798,13 @@ static bool snap_curs_to_sel_ex(bContext *C, const int pivot_point, float r_curs count += tvs.transverts_tot; if (tvs.transverts_tot != 0) { Object *obedit_eval = DEG_get_evaluated_object(depsgraph, obedit); - copy_m3_m4(bmat, obedit_eval->object_to_world().ptr()); + copy_m3_m4(bmat, obedit_eval->object_to_world); tv = tvs.transverts; for (int i = 0; i < tvs.transverts_tot; i++, tv++) { copy_v3_v3(vec, tv->loc); mul_m3_v3(bmat, vec); - add_v3_v3(vec, obedit_eval->object_to_world().location()); + add_v3_v3(vec, obedit_eval->object_to_world[3]); add_v3_v3(centroid, vec); minmax_v3v3_v3(min, max, vec); } @@ -822,7 +822,7 @@ static bool snap_curs_to_sel_ex(bContext *C, const int pivot_point, float r_curs if (ANIM_bonecoll_is_visible_pchan(arm, pchan)) { if (pchan->bone->flag & BONE_SELECTED) { copy_v3_v3(vec, pchan->pose_head); - mul_m4_v3(obact_eval->object_to_world().ptr(), vec); + mul_m4_v3(obact_eval->object_to_world, vec); add_v3_v3(centroid, vec); minmax_v3v3_v3(min, max, vec); count++; @@ -832,7 +832,7 @@ static bool snap_curs_to_sel_ex(bContext *C, const int pivot_point, float r_curs } else { FOREACH_SELECTED_OBJECT_BEGIN (view_layer_eval, v3d, ob_eval) { - copy_v3_v3(vec, ob_eval->object_to_world().location()); + copy_v3_v3(vec, ob_eval->object_to_world[3]); /* special case for camera -- snap to bundles */ if (ob_eval->type == OB_CAMERA) { @@ -1022,7 +1022,7 @@ bool ED_view3d_minmax_verts(Object *obedit, float r_min[3], float r_max[3]) changed = BKE_mball_minmax_ex(static_cast(obedit->data), ob_min, ob_max, - obedit->object_to_world().ptr(), + obedit->object_to_world, SELECT); if (changed) { minmax_v3v3_v3(r_min, r_max, ob_min); @@ -1042,7 +1042,7 @@ bool ED_view3d_minmax_verts(Object *obedit, float r_min[3], float r_max[3]) bke::crazyspace::get_evaluated_curves_deformation(obedit, ob_orig); const std::optional> curves_bounds = bounds_min_max_with_transform( - obedit->object_to_world(), deformation.positions, mask); + float4x4(obedit->object_to_world), deformation.positions, mask); if (curves_bounds) { minmax_v3v3_v3(r_min, r_max, curves_bounds->min); @@ -1060,13 +1060,13 @@ bool ED_view3d_minmax_verts(Object *obedit, float r_min[3], float r_max[3]) return false; } - copy_m3_m4(bmat, obedit->object_to_world().ptr()); + copy_m3_m4(bmat, obedit->object_to_world); tv = tvs.transverts; for (int a = 0; a < tvs.transverts_tot; a++, tv++) { copy_v3_v3(vec, (tv->flag & TX_VERT_USE_MAPLOC) ? tv->maploc : tv->loc); mul_m3_v3(bmat, vec); - add_v3_v3(vec, obedit->object_to_world().location()); + add_v3_v3(vec, obedit->object_to_world[3]); add_v3_v3(centroid, vec); minmax_v3v3_v3(r_min, r_max, vec); } diff --git a/source/blender/editors/space_view3d/view3d_utils.cc b/source/blender/editors/space_view3d/view3d_utils.cc index 742487dd290..8a10d32e452 100644 --- a/source/blender/editors/space_view3d/view3d_utils.cc +++ b/source/blender/editors/space_view3d/view3d_utils.cc @@ -23,6 +23,7 @@ #include "BLI_array_utils.h" #include "BLI_bitmap_draw_2d.h" +#include "BLI_blenlib.h" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" @@ -32,12 +33,14 @@ #include "BKE_camera.h" #include "BKE_context.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" +#include "BIF_glutil.hh" + #include "GPU_matrix.h" #include "WM_api.hh" @@ -284,7 +287,7 @@ void ED_view3d_clipping_calc( /* optionally transform to object space */ if (ob) { float imat[4][4]; - invert_m4_m4(imat, ob->object_to_world().ptr()); + invert_m4_m4(imat, ob->object_to_world); for (int val = 0; val < 8; val++) { mul_m4_v3(imat, bb->vec[val]); @@ -294,7 +297,7 @@ void ED_view3d_clipping_calc( /* verify if we have negative scale. doing the transform before cross * product flips the sign of the vector compared to doing cross product * before transform then, so we correct for that. */ - int flip_sign = (ob) ? is_negative_m4(ob->object_to_world().ptr()) : false; + int flip_sign = (ob) ? is_negative_m4(ob->object_to_world) : false; ED_view3d_clipping_calc_from_boundbox(planes, bb, flip_sign); } @@ -472,7 +475,7 @@ void ED_view3d_persp_switch_from_camera(const Depsgraph *depsgraph, if (v3d->camera) { Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera); rv3d->dist = ED_view3d_offset_distance( - ob_camera_eval->object_to_world().ptr(), rv3d->ofs, VIEW3D_DIST_FALLBACK); + ob_camera_eval->object_to_world, rv3d->ofs, VIEW3D_DIST_FALLBACK); ED_view3d_from_object(ob_camera_eval, rv3d->ofs, rv3d->viewquat, &rv3d->dist, nullptr); } @@ -564,7 +567,7 @@ void ED_view3d_camera_lock_init_ex(const Depsgraph *depsgraph, if (calc_dist) { /* using a fallback dist is OK here since ED_view3d_from_object() compensates for it */ rv3d->dist = ED_view3d_offset_distance( - ob_camera_eval->object_to_world().ptr(), rv3d->ofs, VIEW3D_DIST_FALLBACK); + ob_camera_eval->object_to_world, rv3d->ofs, VIEW3D_DIST_FALLBACK); } ED_view3d_from_object(ob_camera_eval, rv3d->ofs, rv3d->viewquat, &rv3d->dist, nullptr); } @@ -599,12 +602,12 @@ bool ED_view3d_camera_lock_sync(const Depsgraph *depsgraph, View3D *v3d, RegionV ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); - normalize_m4_m4(tmat, ob_camera_eval->object_to_world().ptr()); + normalize_m4_m4(tmat, ob_camera_eval->object_to_world); invert_m4_m4(imat, tmat); mul_m4_m4m4(diff_mat, view_mat, imat); - mul_m4_m4m4(parent_mat, diff_mat, root_parent_eval->object_to_world().ptr()); + mul_m4_m4m4(parent_mat, diff_mat, root_parent_eval->object_to_world); BKE_object_tfm_protected_backup(root_parent, &obtfm); BKE_object_apply_mat4(root_parent, parent_mat, true, false); @@ -1579,7 +1582,7 @@ void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], c void ED_view3d_from_object(const Object *ob, float ofs[3], float quat[4], float *dist, float *lens) { - ED_view3d_from_m4(ob->object_to_world().ptr(), ofs, quat, dist); + ED_view3d_from_m4(ob->object_to_world, ofs, quat, dist); if (lens) { CameraParams params; @@ -1628,7 +1631,7 @@ static bool view3d_camera_to_view_selected_impl(Main *bmain, is_ortho_camera = true; } - copy_m4_m4(obmat_new, camera_ob_eval->object_to_world().ptr()); + copy_m4_m4(obmat_new, camera_ob_eval->object_to_world); copy_v3_v3(obmat_new[3], co); /* only touch location */ diff --git a/source/blender/editors/space_view3d/view3d_view.cc b/source/blender/editors/space_view3d/view3d_view.cc index b9763e0e087..8e604b53383 100644 --- a/source/blender/editors/space_view3d/view3d_view.cc +++ b/source/blender/editors/space_view3d/view3d_view.cc @@ -17,7 +17,7 @@ #include "BKE_action.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_idprop.h" #include "BKE_layer.hh" @@ -25,8 +25,8 @@ #include "BKE_main.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "DEG_depsgraph_query.hh" @@ -370,7 +370,7 @@ static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob) rv3d->view = RV3D_VIEW_USER; /* don't show the grid */ - normalize_m4_m4(bmat, ob->object_to_world().ptr()); + normalize_m4_m4(bmat, ob->object_to_world); invert_m4_m4(rv3d->viewmat, bmat); /* view quat calculation, needed for add object */ @@ -409,12 +409,12 @@ void view3d_viewmatrix_set(Depsgraph *depsgraph, Object *ob_eval = DEG_get_evaluated_object(depsgraph, v3d->ob_center); float vec[3]; - copy_v3_v3(vec, ob_eval->object_to_world().location()); + copy_v3_v3(vec, ob_eval->object_to_world[3]); if (ob_eval->type == OB_ARMATURE && v3d->ob_center_bone[0]) { bPoseChannel *pchan = BKE_pose_channel_find_name(ob_eval->pose, v3d->ob_center_bone); if (pchan) { copy_v3_v3(vec, pchan->pose_mat[3]); - mul_m4_v3(ob_eval->object_to_world().ptr(), vec); + mul_m4_v3(ob_eval->object_to_world, vec); } } translate_m4(rv3d->viewmat, -vec[0], -vec[1], -vec[2]); diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt index 039786d86a0..68490e2917e 100644 --- a/source/blender/editors/transform/CMakeLists.txt +++ b/source/blender/editors/transform/CMakeLists.txt @@ -117,7 +117,6 @@ set(SRC set(LIB PRIVATE bf::animrig PRIVATE bf::blenfont - PRIVATE bf::extern::fmtlib bf_blenkernel PRIVATE bf::blenlib bf_bmesh diff --git a/source/blender/editors/transform/transform.cc b/source/blender/editors/transform/transform.cc index 9640a9e8c21..d1bce428b2c 100644 --- a/source/blender/editors/transform/transform.cc +++ b/source/blender/editors/transform/transform.cc @@ -11,6 +11,8 @@ #include "MEM_guardedalloc.h" #include "DNA_gpencil_legacy_types.h" +#include "DNA_mask_types.h" +#include "DNA_mesh_types.h" #include "DNA_screen_types.h" #include "BLI_math_matrix.h" @@ -21,12 +23,14 @@ #include "BKE_editmesh.hh" #include "BKE_layer.hh" #include "BKE_mask.h" +#include "BKE_scene.h" #include "GPU_state.h" #include "ED_clip.hh" #include "ED_gpencil_legacy.hh" #include "ED_image.hh" +#include "ED_keyframing.hh" #include "ED_node.hh" #include "ED_screen.hh" #include "ED_space_api.hh" @@ -46,7 +50,7 @@ #include "RNA_access.hh" #include "BLF_api.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_constraints.hh" diff --git a/source/blender/editors/transform/transform.hh b/source/blender/editors/transform/transform.hh index dd496e1ca01..22b5a35f53c 100644 --- a/source/blender/editors/transform/transform.hh +++ b/source/blender/editors/transform/transform.hh @@ -474,8 +474,8 @@ struct TransDataContainer { /** * Store matrix, this avoids having to have duplicate check all over - * Typically: 'obedit->object_to_world().ptr()' or 'poseobj->object_to_world().ptr()', but may be - * used elsewhere too. + * Typically: 'obedit->object_to_world' or 'poseobj->object_to_world', but may be used elsewhere + * too. */ bool use_local_mat; diff --git a/source/blender/editors/transform/transform_constraints.cc b/source/blender/editors/transform/transform_constraints.cc index d124aa0bd64..c8e9b626b34 100644 --- a/source/blender/editors/transform/transform_constraints.cc +++ b/source/blender/editors/transform/transform_constraints.cc @@ -27,9 +27,11 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BKE_context.hh" + #include "ED_view3d.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "UI_resources.hh" #include "UI_view2d.hh" @@ -83,7 +85,7 @@ static void view_vector_calc(const TransInfo *t, const float focus[3], float r_v /* ************************** CONSTRAINTS ************************* */ #define CONSTRAIN_EPSILON 0.0001f -static void constraint_plane_normal_calc(const TransInfo *t, float r_plane_no[3]) +static void constraint_plane_calc(const TransInfo *t, float r_plane[4]) { const float *constraint_vector[2]; int n = 0; @@ -97,8 +99,9 @@ static void constraint_plane_normal_calc(const TransInfo *t, float r_plane_no[3] } BLI_assert(n == 2); - cross_v3_v3v3(r_plane_no, constraint_vector[0], constraint_vector[1]); - normalize_v3(r_plane_no); + cross_v3_v3v3(r_plane, constraint_vector[0], constraint_vector[1]); + normalize_v3(r_plane); + r_plane[3] = -dot_v3v3(r_plane, t->center_global); } void constraintNumInput(TransInfo *t, float vec[3]) @@ -268,16 +271,14 @@ static void axisProjection(const TransInfo *t, /** * Snap to the intersection between the edge direction and the constraint plane. */ -static void constraint_snap_plane_to_edge(const TransInfo *t, - const float plane_no[3], - float r_out[3]) +static void constraint_snap_plane_to_edge(const TransInfo *t, const float plane[4], float r_out[3]) { float lambda; const float *edge_snap_point = t->tsnap.snap_target; const float *edge_dir = t->tsnap.snapNormal; - bool is_aligned = fabsf(dot_v3v3(edge_dir, plane_no)) < CONSTRAIN_EPSILON; - if (!is_aligned && isect_ray_plane_v3_factor( - edge_snap_point, edge_dir, t->tsnap.snap_source, plane_no, &lambda)) + bool is_aligned = fabsf(dot_v3v3(edge_dir, plane)) < CONSTRAIN_EPSILON; + if (!is_aligned && + isect_ray_plane_v3_factor(edge_snap_point, edge_dir, t->tsnap.snap_source, plane, &lambda)) { madd_v3_v3v3fl(r_out, edge_snap_point, edge_dir, lambda); sub_v3_v3(r_out, t->tsnap.snap_source); @@ -319,12 +320,12 @@ void transform_constraint_snap_axis_to_face(const TransInfo *t, float r_out[3]) { float lambda; + float face_plane[4]; const float *face_snap_point = t->tsnap.snap_target; const float *face_normal = t->tsnap.snapNormal; - bool is_aligned = fabsf(dot_v3v3(axis, face_normal)) < CONSTRAIN_EPSILON; - if (!is_aligned && - isect_ray_plane_v3_factor(t->tsnap.snap_source, axis, face_snap_point, face_normal, &lambda)) - { + plane_from_point_normal_v3(face_plane, face_snap_point, face_normal); + bool is_aligned = fabsf(dot_v3v3(axis, face_plane)) < CONSTRAIN_EPSILON; + if (!is_aligned && isect_ray_plane_v3(t->tsnap.snap_source, axis, face_plane, &lambda, false)) { mul_v3_v3fl(r_out, axis, lambda); } } @@ -333,18 +334,18 @@ void transform_constraint_snap_axis_to_face(const TransInfo *t, * Return true if the 2x axis are both aligned when projected into the view. * In this case, we can't usefully project the cursor onto the plane. */ -static bool isPlaneProjectionViewAligned(const TransInfo *t, const float plane_no[3]) +static bool isPlaneProjectionViewAligned(const TransInfo *t, const float plane[4]) { const float eps = 0.001f; float view_to_plane[3]; view_vector_calc(t, t->center_global, view_to_plane); - float factor = dot_v3v3(plane_no, view_to_plane); + float factor = dot_v3v3(plane, view_to_plane); return fabsf(factor) < eps; } static void planeProjection(const TransInfo *t, - const float plane_no[3], + const float plane[4], const float in[3], float out[3]) { @@ -354,7 +355,7 @@ static void planeProjection(const TransInfo *t, add_v3_v3v3(pos, in, t->center_global); view_vector_calc(t, pos, view_vec); - if (isect_ray_plane_v3_factor(pos, view_vec, t->center_global, plane_no, &factor)) { + if (isect_ray_plane_v3(pos, view_vec, plane, &factor, false)) { madd_v3_v3v3fl(out, in, view_vec, factor); } } @@ -420,19 +421,19 @@ static void applyAxisConstraintVec(const TransInfo *t, const int dims = getConstraintSpaceDimension(t); if (dims == 2) { if (!is_zero_v3(out)) { - float plane_no[3]; - constraint_plane_normal_calc(t, plane_no); + float plane[4]; + constraint_plane_calc(t, plane); if (is_snap_to_edge) { - constraint_snap_plane_to_edge(t, plane_no, out); + constraint_snap_plane_to_edge(t, plane, out); } else if (is_snap_to_face) { /* Disabled, as it has not proven to be really useful. (See #82386). */ // constraint_snap_plane_to_face(t, plane, out); } - else if (!isPlaneProjectionViewAligned(t, plane_no)) { + else if (!isPlaneProjectionViewAligned(t, plane)) { /* View alignment correction. */ - planeProjection(t, plane_no, in, out); + planeProjection(t, plane, in, out); } } } diff --git a/source/blender/editors/transform/transform_convert.cc b/source/blender/editors/transform/transform_convert.cc index ad049113205..555d0a85281 100644 --- a/source/blender/editors/transform/transform_convert.cc +++ b/source/blender/editors/transform/transform_convert.cc @@ -22,13 +22,18 @@ #include "BKE_action.h" #include "BKE_anim_data.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_fcurve.h" +#include "BKE_global.h" +#include "BKE_image.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" #include "BKE_nla.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" +#include "ED_keyframes_edit.hh" +#include "ED_keyframing.hh" #include "ED_particle.hh" #include "ED_screen.hh" #include "ED_screen_types.hh" @@ -43,6 +48,7 @@ #include "DEG_depsgraph_build.hh" #include "transform.hh" +#include "transform_snap.hh" /* Own include. */ #include "transform_convert.hh" @@ -860,7 +866,7 @@ static void init_TransDataContainers(TransInfo *t, Object *obact, Span if (tc->use_local_mat) { BLI_assert((t->flag & T_2D_EDIT) == 0); - copy_m4_m4(tc->mat, objects[i]->object_to_world().ptr()); + copy_m4_m4(tc->mat, objects[i]->object_to_world); copy_m3_m4(tc->mat3, tc->mat); /* for non-invertible scale matrices, invert_m4_m4_fallback() * can still provide a valid pivot */ @@ -902,7 +908,7 @@ static TransConvertTypeInfo *convert_type_get(const TransInfo *t, Object **r_obj if (t->options & CTX_EDGE_DATA) { return &TransConvertType_MeshEdge; } - if (t->options & CTX_GPENCIL_STROKES) { + if ((t->options & CTX_GPENCIL_STROKES) && (t->spacetype == SPACE_VIEW3D)) { if (t->obedit_type == OB_GREASE_PENCIL) { return &TransConvertType_GreasePencil; } @@ -1113,8 +1119,8 @@ void transform_convert_clip_mirror_modifier_apply(TransDataContainer *tc) if (mmd->mirror_ob) { float obinv[4][4]; - invert_m4_m4(obinv, mmd->mirror_ob->object_to_world().ptr()); - mul_m4_m4m4(mtx, obinv, ob->object_to_world().ptr()); + invert_m4_m4(obinv, mmd->mirror_ob->object_to_world); + mul_m4_m4m4(mtx, obinv, ob->object_to_world); invert_m4_m4(imtx, mtx); } diff --git a/source/blender/editors/transform/transform_convert.hh b/source/blender/editors/transform/transform_convert.hh index ef1e990d104..b00da9e8774 100644 --- a/source/blender/editors/transform/transform_convert.hh +++ b/source/blender/editors/transform/transform_convert.hh @@ -117,7 +117,6 @@ void animrecord_check_state(TransInfo *t, ID *id); */ void curve_populate_trans_data_structs(TransDataContainer &tc, blender::bke::CurvesGeometry &curves, - const blender::float4x4 &matrix, std::optional> value_attribute, const blender::IndexMask &selected_indices, bool use_proportional_edit, diff --git a/source/blender/editors/transform/transform_convert_armature.cc b/source/blender/editors/transform/transform_convert_armature.cc index e79ddb25d8d..a67ae001fc8 100644 --- a/source/blender/editors/transform/transform_convert_armature.cc +++ b/source/blender/editors/transform/transform_convert_armature.cc @@ -18,18 +18,25 @@ #include "BLI_math_vector.h" #include "BKE_action.h" +#include "BKE_animsys.h" #include "BKE_armature.hh" #include "BKE_constraint.h" #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_main.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BIK_api.h" #include "ED_armature.hh" +#include "ED_keyframing.hh" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" +#include "RNA_access.hh" +#include "RNA_prototypes.h" + #include "ANIM_bone_collections.hh" #include "ANIM_keyframing.hh" #include "ANIM_rna.hh" @@ -436,7 +443,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr td->ext->rotOrder = pchan->rotmode; /* proper way to get parent transform + own transform + constraints transform */ - copy_m3_m4(omat, ob->object_to_world().ptr()); + copy_m3_m4(omat, ob->object_to_world); /* New code, using "generic" BKE_bone_parent_transform_calc_from_pchan(). */ { @@ -800,7 +807,7 @@ static void createTransArmatureVerts(bContext * /*C*/, TransInfo *t) bool mirror = ((arm->flag & ARM_MIRROR_EDIT) != 0); BoneInitData *bid = static_cast(tc->custom.type.data); - copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); + copy_m3_m4(mtx, tc->obedit->object_to_world); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); td = tc->data = static_cast( diff --git a/source/blender/editors/transform/transform_convert_cursor.cc b/source/blender/editors/transform/transform_convert_cursor.cc index 57a93f3267a..cb8cdae811c 100644 --- a/source/blender/editors/transform/transform_convert_cursor.cc +++ b/source/blender/editors/transform/transform_convert_cursor.cc @@ -16,8 +16,9 @@ #include "BLI_math_rotation.h" #include "BLI_math_vector.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_context.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_convert_curve.cc b/source/blender/editors/transform/transform_convert_curve.cc index 27e9676be57..a1b53936cde 100644 --- a/source/blender/editors/transform/transform_convert_curve.cc +++ b/source/blender/editors/transform/transform_convert_curve.cc @@ -15,6 +15,7 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" +#include "BKE_context.hh" #include "BKE_curve.hh" #include "ED_object.hh" @@ -177,7 +178,7 @@ static void createTransCurveVerts(bContext * /*C*/, TransInfo *t) transform_mode_use_local_origins(t)); float mtx[3][3], smtx[3][3]; - copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); + copy_m3_m4(mtx, tc->obedit->object_to_world); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); TransData *td = tc->data; diff --git a/source/blender/editors/transform/transform_convert_curves.cc b/source/blender/editors/transform/transform_convert_curves.cc index 06916da105b..ad9d4b1de79 100644 --- a/source/blender/editors/transform/transform_convert_curves.cc +++ b/source/blender/editors/transform/transform_convert_curves.cc @@ -95,8 +95,7 @@ static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t) if (tc.data_len == 0) { continue; } - Object *object = tc.obedit; - Curves *curves_id = static_cast(object->data); + Curves *curves_id = static_cast(tc.obedit->data); bke::CurvesGeometry &curves = curves_id->geometry.wrap(); std::optional> value_attribute; @@ -118,7 +117,6 @@ static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t) curve_populate_trans_data_structs(tc, curves, - object->object_to_world(), value_attribute, selection_per_object[i], use_proportional_edit, @@ -155,10 +153,9 @@ static void recalcData_curves(TransInfo *t) void curve_populate_trans_data_structs(TransDataContainer &tc, blender::bke::CurvesGeometry &curves, - const blender::float4x4 &transform, std::optional> value_attribute, const blender::IndexMask &selected_indices, - const bool use_proportional_edit, + bool use_proportional_edit, const blender::IndexMask &affected_curves, bool use_connected_only, int trans_data_offset) @@ -166,7 +163,7 @@ void curve_populate_trans_data_structs(TransDataContainer &tc, using namespace blender; float mtx[3][3], smtx[3][3]; - copy_m3_m4(mtx, transform.ptr()); + copy_m3_m4(mtx, tc.obedit->object_to_world); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); MutableSpan positions = curves.positions_for_write(); diff --git a/source/blender/editors/transform/transform_convert_graph.cc b/source/blender/editors/transform/transform_convert_graph.cc index d40c6a9b787..61c482b62eb 100644 --- a/source/blender/editors/transform/transform_convert_graph.cc +++ b/source/blender/editors/transform/transform_convert_graph.cc @@ -18,16 +18,18 @@ #include "BKE_fcurve.h" #include "BKE_layer.hh" #include "BKE_nla.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "ED_anim_api.hh" #include "ED_keyframes_edit.hh" +#include "ED_markers.hh" #include "UI_view2d.hh" #include "transform.hh" #include "transform_constraints.hh" #include "transform_convert.hh" +#include "transform_mode.hh" #include "transform_snap.hh" struct TransDataGraph { diff --git a/source/blender/editors/transform/transform_convert_grease_pencil.cc b/source/blender/editors/transform/transform_convert_grease_pencil.cc index ade9177c2b1..7736342306d 100644 --- a/source/blender/editors/transform/transform_convert_grease_pencil.cc +++ b/source/blender/editors/transform/transform_convert_grease_pencil.cc @@ -6,10 +6,11 @@ * \ingroup edtransform */ +#include "BLI_math_matrix.h" + #include "BKE_context.hh" -#include "DEG_depsgraph_query.hh" - +#include "ED_curves.hh" #include "ED_grease_pencil.hh" #include "transform.hh" @@ -23,7 +24,6 @@ namespace blender::ed::transform::greasepencil { static void createTransGreasePencilVerts(bContext *C, TransInfo *t) { - Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Scene *scene = CTX_data_scene(C); Object *object = CTX_data_active_object(C); MutableSpan trans_data_contrainers(t->data_container, t->data_container_len); @@ -31,13 +31,13 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t) const bool use_connected_only = (t->flag & T_PROP_CONNECTED) != 0; int total_number_of_drawings = 0; - Vector> all_drawings; + Vector> all_drawings; /* Count the number layers in all objects. */ for (const int i : trans_data_contrainers.index_range()) { TransDataContainer &tc = trans_data_contrainers[i]; GreasePencil &grease_pencil = *static_cast(tc.obedit->data); - const Vector drawings = + const Array drawings = ed::greasepencil::retrieve_editable_drawings(*scene, grease_pencil); all_drawings.append(drawings); total_number_of_drawings += drawings.size(); @@ -51,7 +51,7 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t) for (const int i : trans_data_contrainers.index_range()) { TransDataContainer &tc = trans_data_contrainers[i]; - const Vector drawings = all_drawings[i]; + const Array drawings = all_drawings[i]; for (ed::greasepencil::MutableDrawingInfo info : drawings) { if (use_proportional_edit) { points_per_layer_per_object[layer_offset] = ed::greasepencil::retrieve_editable_points( @@ -81,15 +81,15 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t) if (tc.data_len == 0) { continue; } - Object *object_eval = DEG_get_evaluated_object(depsgraph, tc.obedit); - GreasePencil &grease_pencil = *static_cast(object_eval->data); - Span layers = grease_pencil.layers(); + + float mtx[3][3], smtx[3][3]; + copy_m3_m4(mtx, tc.obedit->object_to_world); + pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); int layer_points_offset = 0; - const Vector drawings = all_drawings[i]; + + const Array drawings = all_drawings[i]; for (ed::greasepencil::MutableDrawingInfo info : drawings) { - const bke::greasepencil::Layer &layer = *layers[info.layer_index]; - const float4x4 layer_space_to_world_space = layer.to_world_space(*object_eval); bke::CurvesGeometry &curves = info.drawing.strokes_for_write(); const IndexMask points = points_per_layer_per_object[layer_offset]; @@ -108,7 +108,6 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t) *object, info.drawing, memory); curve_populate_trans_data_structs(tc, curves, - layer_space_to_world_space, value_attribute, points, true, @@ -119,7 +118,6 @@ static void createTransGreasePencilVerts(bContext *C, TransInfo *t) else { curve_populate_trans_data_structs(tc, curves, - layer_space_to_world_space, value_attribute, points, false, @@ -143,7 +141,7 @@ static void recalcData_grease_pencil(TransInfo *t) for (const TransDataContainer &tc : trans_data_contrainers) { GreasePencil &grease_pencil = *static_cast(tc.obedit->data); - const Vector drawings = + const Array drawings = ed::greasepencil::retrieve_editable_drawings(*scene, grease_pencil); for (ed::greasepencil::MutableDrawingInfo info : drawings) { bke::CurvesGeometry &curves = info.drawing.strokes_for_write(); diff --git a/source/blender/editors/transform/transform_convert_lattice.cc b/source/blender/editors/transform/transform_convert_lattice.cc index e0c232d2c7c..c18c94de6e9 100644 --- a/source/blender/editors/transform/transform_convert_lattice.cc +++ b/source/blender/editors/transform/transform_convert_lattice.cc @@ -14,6 +14,7 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" +#include "BKE_context.hh" #include "BKE_lattice.hh" #include "ED_object.hh" @@ -78,7 +79,7 @@ static void createTransLatticeVerts(bContext * /*C*/, TransInfo *t) tc->data = static_cast( MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Lattice EditMode)")); - copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); + copy_m3_m4(mtx, tc->obedit->object_to_world); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); td = tc->data; diff --git a/source/blender/editors/transform/transform_convert_mball.cc b/source/blender/editors/transform/transform_convert_mball.cc index 37cad7ad64d..ba692e15352 100644 --- a/source/blender/editors/transform/transform_convert_mball.cc +++ b/source/blender/editors/transform/transform_convert_mball.cc @@ -65,7 +65,7 @@ static void createTransMBallVerts(bContext * /*C*/, TransInfo *t) tx = tc->data_ext = static_cast( MEM_callocN(tc->data_len * sizeof(TransDataExtension), "MetaElement_TransExtension")); - copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); + copy_m3_m4(mtx, tc->obedit->object_to_world); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) { diff --git a/source/blender/editors/transform/transform_convert_mesh.cc b/source/blender/editors/transform/transform_convert_mesh.cc index f095106159f..b30c2cad4c4 100644 --- a/source/blender/editors/transform/transform_convert_mesh.cc +++ b/source/blender/editors/transform/transform_convert_mesh.cc @@ -24,7 +24,7 @@ #include "BKE_editmesh.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "ED_mesh.hh" #include "ED_object.hh" @@ -1566,7 +1566,7 @@ static void createTransEditVerts(bContext * /*C*/, TransInfo *t) em, calc_single_islands, calc_island_center, calc_island_axismtx, &island_data); } - copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); + copy_m3_m4(mtx, tc->obedit->object_to_world); /* we use a pseudo-inverse so that when one of the axes is scaled to 0, * matrix inversion still works and we can still moving along the other */ pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); diff --git a/source/blender/editors/transform/transform_convert_mesh_edge.cc b/source/blender/editors/transform/transform_convert_mesh_edge.cc index 74b16f44adc..13bf1c7fcb2 100644 --- a/source/blender/editors/transform/transform_convert_mesh_edge.cc +++ b/source/blender/editors/transform/transform_convert_mesh_edge.cc @@ -6,6 +6,8 @@ * \ingroup edtransform */ +#include "DNA_mesh_types.h" + #include "MEM_guardedalloc.h" #include "BLI_math_matrix.h" @@ -14,6 +16,7 @@ #include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_editmesh.hh" +#include "BKE_mesh.hh" #include "transform.hh" #include "transform_convert.hh" @@ -62,7 +65,7 @@ static void createTransEdge(bContext * /*C*/, TransInfo *t) td = tc->data = static_cast( MEM_callocN(tc->data_len * sizeof(TransData), "TransCrease")); - copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); + copy_m3_m4(mtx, tc->obedit->object_to_world); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); /* create data we need */ diff --git a/source/blender/editors/transform/transform_convert_mesh_skin.cc b/source/blender/editors/transform/transform_convert_mesh_skin.cc index 15d9963373d..f13cef865d8 100644 --- a/source/blender/editors/transform/transform_convert_mesh_skin.cc +++ b/source/blender/editors/transform/transform_convert_mesh_skin.cc @@ -15,7 +15,14 @@ #include "BLI_math_vector.h" #include "BKE_context.hh" +#include "BKE_crazyspace.hh" #include "BKE_editmesh.hh" +#include "BKE_modifier.hh" +#include "BKE_scene.h" + +#include "ED_mesh.hh" + +#include "DEG_depsgraph_query.hh" #include "transform.hh" #include "transform_orientations.hh" @@ -127,7 +134,7 @@ static void createTransMeshSkin(bContext * /*C*/, TransInfo *t) em, calc_single_islands, calc_island_center, calc_island_axismtx, &island_data); } - copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); + copy_m3_m4(mtx, tc->obedit->object_to_world); /* we use a pseudo-inverse so that when one of the axes is scaled to 0, * matrix inversion still works and we can still moving along the other */ pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); diff --git a/source/blender/editors/transform/transform_convert_mesh_uv.cc b/source/blender/editors/transform/transform_convert_mesh_uv.cc index a734ce3ff43..c9902dcc152 100644 --- a/source/blender/editors/transform/transform_convert_mesh_uv.cc +++ b/source/blender/editors/transform/transform_convert_mesh_uv.cc @@ -8,6 +8,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_bitmap.h" #include "BLI_linklist_stack.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" diff --git a/source/blender/editors/transform/transform_convert_mesh_vert_cdata.cc b/source/blender/editors/transform/transform_convert_mesh_vert_cdata.cc index b46a1d969ad..ec91c64f57f 100644 --- a/source/blender/editors/transform/transform_convert_mesh_vert_cdata.cc +++ b/source/blender/editors/transform/transform_convert_mesh_vert_cdata.cc @@ -122,7 +122,7 @@ static void createTransMeshVertCData(bContext * /*C*/, TransInfo *t) em, calc_single_islands, calc_island_center, calc_island_axismtx, &island_data); } - copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); + copy_m3_m4(mtx, tc->obedit->object_to_world); /* we use a pseudo-inverse so that when one of the axes is scaled to 0, * matrix inversion still works and we can still moving along the other */ pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); diff --git a/source/blender/editors/transform/transform_convert_nla.cc b/source/blender/editors/transform/transform_convert_nla.cc index 147b5e72650..ff882e32b0a 100644 --- a/source/blender/editors/transform/transform_convert_nla.cc +++ b/source/blender/editors/transform/transform_convert_nla.cc @@ -22,6 +22,7 @@ #include "BKE_nla.h" #include "ED_anim_api.hh" +#include "ED_markers.hh" #include "WM_api.hh" #include "WM_types.hh" @@ -31,6 +32,8 @@ #include "transform.hh" #include "transform_convert.hh" +#include "transform_mode.hh" +#include "transform_snap.hh" /** Used for NLA transform (stored in #TransData.extra pointer). */ struct TransDataNla { diff --git a/source/blender/editors/transform/transform_convert_node.cc b/source/blender/editors/transform/transform_convert_node.cc index 7e8bd93f26c..11081f9f82c 100644 --- a/source/blender/editors/transform/transform_convert_node.cc +++ b/source/blender/editors/transform/transform_convert_node.cc @@ -17,9 +17,13 @@ #include "BKE_context.hh" #include "BKE_node.hh" +#include "BKE_node_runtime.hh" +#include "BKE_node_tree_update.hh" +#include "BKE_report.h" #include "ED_node.hh" +#include "UI_interface.hh" #include "UI_view2d.hh" #include "transform.hh" diff --git a/source/blender/editors/transform/transform_convert_object.cc b/source/blender/editors/transform/transform_convert_object.cc index 77239c982bb..760a8830705 100644 --- a/source/blender/editors/transform/transform_convert_object.cc +++ b/source/blender/editors/transform/transform_convert_object.cc @@ -13,16 +13,20 @@ #include "BLI_math_rotation.h" #include "BLI_math_vector.h" +#include "BKE_animsys.h" #include "BKE_context.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" +#include "BKE_main.hh" #include "BKE_object.hh" #include "BKE_pointcache.h" +#include "BKE_report.h" #include "BKE_rigidbody.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "ANIM_keyframing.hh" #include "ANIM_rna.hh" +#include "ED_keyframing.hh" #include "ED_object.hh" #include "DEG_depsgraph_query.hh" @@ -158,14 +162,14 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) copy_qt_qt(td->ext->oquat, ob->quat); } /* update object's loc/rot to get current rigid body transform */ - mat4_to_loc_rot_size(ob->loc, rot, scale, ob->object_to_world().ptr()); + mat4_to_loc_rot_size(ob->loc, rot, scale, ob->object_to_world); sub_v3_v3(ob->loc, ob->dloc); BKE_object_mat3_to_rot(ob, rot, false); /* drot is already corrected here */ } } /* axismtx has the real orientation */ - transform_orientations_create_from_axis(td->axismtx, UNPACK3(ob->object_to_world().ptr())); + transform_orientations_create_from_axis(td->axismtx, UNPACK3(ob->object_to_world)); if (t->orient_type_mask & (1 << V3D_ORIENT_GIMBAL)) { if (!gimbal_axis_object(ob, td->ext->axismtx_gimbal)) { copy_m3_m3(td->ext->axismtx_gimbal, td->axismtx); @@ -192,7 +196,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) * More proper solution would be to make a shallow copy of the object and * evaluate that, and access matrix of that evaluated copy of the object. * Might be more tricky than it sounds, if some logic later on accesses the - * object matrix via td->ob->object_to_world().ptr(). */ + * object matrix via td->ob->object_to_world. */ Object *object_eval = DEG_get_evaluated_object(t->depsgraph, ob); if (skip_invert == false && constinv == false) { object_eval->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc checks this */ @@ -208,7 +212,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) } /* Copy newly evaluated fields to the original object, similar to how * active dependency graph will do it. */ - copy_m4_m4(ob->runtime->object_to_world.ptr(), object_eval->object_to_world().ptr()); + copy_m4_m4(ob->object_to_world, object_eval->object_to_world); /* Only copy negative scale flag, this is the only flag which is modified by * the BKE_object_where_is_calc(). The rest of the flags we need to keep, * otherwise we might lose dupli flags (see #61787). */ @@ -258,9 +262,9 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) copy_v3_v3(td->ext->isize, ob->scale); copy_v3_v3(td->ext->dscale, ob->dscale); - copy_v3_v3(td->center, ob->object_to_world().location()); + copy_v3_v3(td->center, ob->object_to_world[3]); - copy_m4_m4(td->ext->obmat, ob->object_to_world().ptr()); + copy_m4_m4(td->ext->obmat, ob->object_to_world); /* is there a need to set the global<->data space conversion matrices? */ if (ob->parent || constinv) { @@ -271,7 +275,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) * done, as it doesn't work well. */ BKE_object_to_mat3(ob, obmtx); - copy_m3_m4(totmat, ob->object_to_world().ptr()); + copy_m3_m4(totmat, ob->object_to_world); /* If the object scale is zero on any axis, this might result in a zero matrix. * In this case, the transformation would not do anything, see: #50103. */ diff --git a/source/blender/editors/transform/transform_convert_object_texspace.cc b/source/blender/editors/transform/transform_convert_object_texspace.cc index 5142e07efac..8c2c3e77ae9 100644 --- a/source/blender/editors/transform/transform_convert_object_texspace.cc +++ b/source/blender/editors/transform/transform_convert_object_texspace.cc @@ -11,9 +11,11 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" +#include "BKE_animsys.h" +#include "BKE_context.hh" #include "BKE_layer.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DNA_mesh_types.h" @@ -68,8 +70,8 @@ static void createTransTexspace(bContext * /*C*/, TransInfo *t) td->flag = TD_SELECTED; td->ob = ob; - copy_m3_m4(td->mtx, ob->object_to_world().ptr()); - copy_m3_m4(td->axismtx, ob->object_to_world().ptr()); + copy_m3_m4(td->mtx, ob->object_to_world); + copy_m3_m4(td->axismtx, ob->object_to_world); normalize_m3(td->axismtx); pseudoinverse_m3_m3(td->smtx, td->mtx, PSEUDOINVERSE_EPSILON); diff --git a/source/blender/editors/transform/transform_convert_paintcurve.cc b/source/blender/editors/transform/transform_convert_paintcurve.cc index d36e41ecf60..fb846d687cb 100644 --- a/source/blender/editors/transform/transform_convert_paintcurve.cc +++ b/source/blender/editors/transform/transform_convert_paintcurve.cc @@ -13,6 +13,7 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" +#include "BKE_context.hh" #include "BKE_paint.hh" #include "transform.hh" diff --git a/source/blender/editors/transform/transform_convert_particle.cc b/source/blender/editors/transform/transform_convert_particle.cc index 3129cade2a4..6f8cc4319f4 100644 --- a/source/blender/editors/transform/transform_convert_particle.cc +++ b/source/blender/editors/transform/transform_convert_particle.cc @@ -14,8 +14,8 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" +#include "BKE_context.hh" #include "BKE_layer.hh" -#include "BKE_object_types.hh" #include "BKE_particle.h" #include "BKE_pointcache.h" @@ -98,7 +98,7 @@ static void createTransParticleVerts(bContext * /*C*/, TransInfo *t) unit_m4(mat); - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) { TransData *head, *tail; diff --git a/source/blender/editors/transform/transform_convert_sculpt.cc b/source/blender/editors/transform/transform_convert_sculpt.cc index e6b3060071f..6094adbd249 100644 --- a/source/blender/editors/transform/transform_convert_sculpt.cc +++ b/source/blender/editors/transform/transform_convert_sculpt.cc @@ -16,7 +16,7 @@ #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_paint.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "ED_sculpt.hh" @@ -57,7 +57,7 @@ static void createTransSculpt(bContext *C, TransInfo *t) td->flag = TD_SELECTED; copy_v3_v3(td->center, ss->pivot_pos); - mul_m4_v3(ob->object_to_world().ptr(), td->center); + mul_m4_v3(ob->object_to_world, td->center); td->ob = ob; td->loc = ss->pivot_pos; @@ -68,16 +68,16 @@ static void createTransSculpt(bContext *C, TransInfo *t) } float obmat_inv[3][3]; - copy_m3_m4(obmat_inv, ob->object_to_world().ptr()); + copy_m3_m4(obmat_inv, ob->object_to_world); invert_m3(obmat_inv); td->ext->rot = nullptr; td->ext->rotAxis = nullptr; td->ext->rotAngle = nullptr; td->ext->quat = ss->pivot_rot; - copy_m4_m4(td->ext->obmat, ob->object_to_world().ptr()); + copy_m4_m4(td->ext->obmat, ob->object_to_world); copy_m3_m3(td->ext->l_smtx, obmat_inv); - copy_m3_m4(td->ext->r_mtx, ob->object_to_world().ptr()); + copy_m3_m4(td->ext->r_mtx, ob->object_to_world); copy_m3_m3(td->ext->r_smtx, obmat_inv); copy_qt_qt(td->ext->iquat, ss->pivot_rot); @@ -91,8 +91,8 @@ static void createTransSculpt(bContext *C, TransInfo *t) copy_v3_v3(td->ext->isize, ss->init_pivot_scale); copy_m3_m3(td->smtx, obmat_inv); - copy_m3_m4(td->mtx, ob->object_to_world().ptr()); - copy_m3_m4(td->axismtx, ob->object_to_world().ptr()); + copy_m3_m4(td->mtx, ob->object_to_world); + copy_m3_m4(td->axismtx, ob->object_to_world); BLI_assert(!(t->options & CTX_PAINT_CURVE)); ED_sculpt_init_transform(C, ob, t->mval, t->undo_name); diff --git a/source/blender/editors/transform/transform_convert_sequencer.cc b/source/blender/editors/transform/transform_convert_sequencer.cc index 22cadc51438..6113600eb1e 100644 --- a/source/blender/editors/transform/transform_convert_sequencer.cc +++ b/source/blender/editors/transform/transform_convert_sequencer.cc @@ -15,17 +15,23 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" -#include "BKE_report.hh" +#include "BKE_context.hh" +#include "BKE_main.hh" +#include "BKE_report.h" #include "ED_markers.hh" +#include "ED_time_scrub_ui.hh" #include "SEQ_animation.hh" #include "SEQ_channels.hh" +#include "SEQ_edit.hh" +#include "SEQ_effects.hh" #include "SEQ_iterator.hh" #include "SEQ_relations.hh" #include "SEQ_sequencer.hh" #include "SEQ_time.hh" #include "SEQ_transform.hh" +#include "SEQ_utils.hh" #include "UI_view2d.hh" diff --git a/source/blender/editors/transform/transform_convert_sequencer_image.cc b/source/blender/editors/transform/transform_convert_sequencer_image.cc index 71b5659fa18..05d38c5bcd7 100644 --- a/source/blender/editors/transform/transform_convert_sequencer_image.cc +++ b/source/blender/editors/transform/transform_convert_sequencer_image.cc @@ -11,20 +11,28 @@ #include "DNA_sequence_types.h" #include "DNA_space_types.h" +#include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" #include "BLI_math_vector.h" -#include "BKE_report.hh" +#include "BKE_context.hh" +#include "BKE_report.h" #include "SEQ_channels.hh" #include "SEQ_iterator.hh" #include "SEQ_relations.hh" #include "SEQ_sequencer.hh" +#include "SEQ_time.hh" #include "SEQ_transform.hh" +#include "SEQ_utils.hh" + +#include "ED_keyframing.hh" #include "ANIM_keyframing.hh" +#include "UI_view2d.hh" + #include "RNA_access.hh" #include "RNA_prototypes.h" diff --git a/source/blender/editors/transform/transform_convert_sequencer_retiming.cc b/source/blender/editors/transform/transform_convert_sequencer_retiming.cc index c52408cf66f..0734e72fe79 100644 --- a/source/blender/editors/transform/transform_convert_sequencer_retiming.cc +++ b/source/blender/editors/transform/transform_convert_sequencer_retiming.cc @@ -9,15 +9,26 @@ #include "MEM_guardedalloc.h" #include "DNA_sequence_types.h" +#include "DNA_space_types.h" +#include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" #include "BKE_context.hh" +#include "BKE_report.h" #include "SEQ_relations.hh" #include "SEQ_retiming.hh" #include "SEQ_sequencer.hh" +#include "SEQ_time.hh" + +#include "ED_keyframing.hh" + +#include "UI_view2d.hh" + +#include "RNA_access.hh" +#include "RNA_prototypes.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_convert_tracking.cc b/source/blender/editors/transform/transform_convert_tracking.cc index 453509b541e..63604118ba5 100644 --- a/source/blender/editors/transform/transform_convert_tracking.cc +++ b/source/blender/editors/transform/transform_convert_tracking.cc @@ -14,6 +14,7 @@ #include "BLI_math_vector.h" #include "BKE_context.hh" +#include "BKE_main.hh" #include "BKE_movieclip.h" #include "BKE_node_tree_update.hh" #include "BKE_tracking.h" diff --git a/source/blender/editors/transform/transform_convert_tracking_curves.cc b/source/blender/editors/transform/transform_convert_tracking_curves.cc index e48f66387cf..b2be1871e9b 100644 --- a/source/blender/editors/transform/transform_convert_tracking_curves.cc +++ b/source/blender/editors/transform/transform_convert_tracking_curves.cc @@ -13,6 +13,7 @@ #include "BLI_math_vector.h" #include "BKE_context.hh" +#include "BKE_main.hh" #include "BKE_movieclip.h" #include "BKE_node_tree_update.hh" #include "BKE_tracking.h" diff --git a/source/blender/editors/transform/transform_draw_cursors.cc b/source/blender/editors/transform/transform_draw_cursors.cc index ac0f740a936..86b9ed5fc33 100644 --- a/source/blender/editors/transform/transform_draw_cursors.cc +++ b/source/blender/editors/transform/transform_draw_cursors.cc @@ -17,6 +17,7 @@ #include "DNA_screen_types.h" #include "DNA_userdef_types.h" +#include "UI_interface.hh" #include "UI_resources.hh" #include "transform.hh" diff --git a/source/blender/editors/transform/transform_generics.cc b/source/blender/editors/transform/transform_generics.cc index 8a9a32876cd..87418eb67e1 100644 --- a/source/blender/editors/transform/transform_generics.cc +++ b/source/blender/editors/transform/transform_generics.cc @@ -18,10 +18,13 @@ #include "BLI_rand.h" #include "BLI_time.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" +#include "GPU_immediate.h" +#include "GPU_matrix.h" + #include "BKE_context.hh" #include "BKE_layer.hh" #include "BKE_mask.h" @@ -40,6 +43,7 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "UI_resources.hh" #include "UI_view2d.hh" #include "SEQ_sequencer.hh" @@ -47,6 +51,7 @@ #include "transform.hh" #include "transform_convert.hh" #include "transform_gizmo.hh" +#include "transform_mode.hh" #include "transform_orientations.hh" #include "transform_snap.hh" @@ -225,9 +230,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } /* Grease Pencil editing context */ - if (t->obedit_type == OB_GREASE_PENCIL && object_mode == OB_MODE_EDIT && - (area->spacetype == SPACE_VIEW3D)) - { + if (t->obedit_type == OB_GREASE_PENCIL && object_mode == OB_MODE_EDIT) { t->options |= CTX_GPENCIL_STROKES; } @@ -1093,7 +1096,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]) } if (tc->obedit) { if (ED_object_calc_active_center_for_editmode(tc->obedit, select_only, r_center)) { - mul_m4_v3(tc->obedit->object_to_world().ptr(), r_center); + mul_m4_v3(tc->obedit->object_to_world, r_center); return true; } } @@ -1101,7 +1104,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]) BKE_view_layer_synced_ensure(t->scene, t->view_layer); Object *ob = BKE_view_layer_active_object_get(t->view_layer); if (ED_object_calc_active_center_for_posemode(ob, select_only, r_center)) { - mul_m4_v3(ob->object_to_world().ptr(), r_center); + mul_m4_v3(ob->object_to_world, r_center); return true; } } @@ -1118,7 +1121,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]) BKE_view_layer_synced_ensure(t->scene, t->view_layer); Base *base = BKE_view_layer_active_base_get(t->view_layer); if (base && ((!select_only) || ((base->flag & BASE_SELECTED) != 0))) { - copy_v3_v3(r_center, base->object->object_to_world().location()); + copy_v3_v3(r_center, base->object->object_to_world[3]); return true; } } @@ -1325,7 +1328,7 @@ void calculatePropRatio(TransInfo *t) case PROP_RANDOM: if (t->rng == nullptr) { /* Lazy initialization. */ - uint rng_seed = uint(BLI_time_now_seconds_i() & UINT_MAX); + uint rng_seed = uint(BLI_check_seconds_timer_i() & UINT_MAX); t->rng = BLI_rng_new(rng_seed); } td->factor = BLI_rng_get_float(t->rng) * dist; diff --git a/source/blender/editors/transform/transform_gizmo_2d.cc b/source/blender/editors/transform/transform_gizmo_2d.cc index 98d11266f9b..50937a61779 100644 --- a/source/blender/editors/transform/transform_gizmo_2d.cc +++ b/source/blender/editors/transform/transform_gizmo_2d.cc @@ -24,7 +24,7 @@ #include "DNA_view3d_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "RNA_access.hh" @@ -45,6 +45,7 @@ #include "SEQ_channels.hh" #include "SEQ_iterator.hh" #include "SEQ_sequencer.hh" +#include "SEQ_time.hh" #include "SEQ_transform.hh" #include "transform.hh" diff --git a/source/blender/editors/transform/transform_gizmo_3d.cc b/source/blender/editors/transform/transform_gizmo_3d.cc index ed2597bbe43..2b2180c1b92 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.cc +++ b/source/blender/editors/transform/transform_gizmo_3d.cc @@ -25,15 +25,14 @@ #include "BKE_crazyspace.hh" #include "BKE_curve.hh" #include "BKE_editmesh.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_legacy.h" #include "BKE_grease_pencil.hh" #include "BKE_layer.hh" #include "BKE_object.hh" -#include "BKE_object_types.hh" #include "BKE_paint.hh" #include "BKE_pointcache.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "WM_api.hh" #include "WM_message.hh" @@ -607,7 +606,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, #define FOREACH_EDIT_OBJECT_BEGIN(ob_iter, use_mat_local) \ { \ - invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); \ + invert_m4_m4(obedit->world_to_object, obedit->object_to_world); \ Vector objects = BKE_view_layer_array_from_objects_in_edit_mode( \ scene, view_layer, CTX_wm_view3d(C)); \ for (Object * ob_iter : objects) { \ @@ -633,8 +632,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, float mat_local[4][4]; if (use_mat_local) { - mul_m4_m4m4( - mat_local, obedit->world_to_object().ptr(), ob_iter->object_to_world().ptr()); + mul_m4_m4m4(mat_local, obedit->world_to_object, ob_iter->object_to_world); } BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { @@ -654,8 +652,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, float mat_local[4][4]; if (use_mat_local) { - mul_m4_m4m4( - mat_local, obedit->world_to_object().ptr(), ob_iter->object_to_world().ptr()); + mul_m4_m4m4(mat_local, obedit->world_to_object, ob_iter->object_to_world); } LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) { if (EBONE_VISIBLE(arm, ebo)) { @@ -694,8 +691,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, float mat_local[4][4]; if (use_mat_local) { - mul_m4_m4m4( - mat_local, obedit->world_to_object().ptr(), ob_iter->object_to_world().ptr()); + mul_m4_m4m4(mat_local, obedit->world_to_object, ob_iter->object_to_world); } Nurb *nu = static_cast(nurbs->first); @@ -755,8 +751,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, float mat_local[4][4]; if (use_mat_local) { - mul_m4_m4m4( - mat_local, obedit->world_to_object().ptr(), ob_iter->object_to_world().ptr()); + mul_m4_m4m4(mat_local, obedit->world_to_object, ob_iter->object_to_world); } LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) { @@ -776,8 +771,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, float mat_local[4][4]; if (use_mat_local) { - mul_m4_m4m4( - mat_local, obedit->world_to_object().ptr(), ob_iter->object_to_world().ptr()); + mul_m4_m4m4(mat_local, obedit->world_to_object, ob_iter->object_to_world); } while (a--) { @@ -799,7 +793,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, float4x4 mat_local; if (use_mat_local) { - mat_local = obedit->world_to_object() * ob_iter->object_to_world(); + mat_local = float4x4(obedit->world_to_object) * float4x4(ob_iter->object_to_world); } IndexMaskMemory memory; @@ -818,10 +812,10 @@ static int gizmo_3d_foreach_selected(const bContext *C, float4x4 mat_local; if (use_mat_local) { - mat_local = obedit->world_to_object() * ob_iter->object_to_world(); + mat_local = float4x4(obedit->world_to_object) * float4x4(ob_iter->object_to_world); } - const Vector drawings = + const Array drawings = ed::greasepencil::retrieve_editable_drawings(*scene, grease_pencil); threading::parallel_for_each( drawings, [&](const ed::greasepencil::MutableDrawingInfo &info) { @@ -848,7 +842,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, #undef FOREACH_EDIT_OBJECT_END } else if (ob && (ob->mode & OB_MODE_POSE)) { - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); Vector objects = BKE_object_pose_array_get(scene, view_layer, v3d); @@ -861,7 +855,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, float mat_local[4][4]; if (use_mat_local) { - mul_m4_m4m4(mat_local, ob->world_to_object().ptr(), ob_iter->object_to_world().ptr()); + mul_m4_m4m4(mat_local, ob->world_to_object, ob_iter->object_to_world); } /* Use channels to get stats. */ @@ -885,7 +879,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) { if (ob->mode & OB_MODE_SCULPT) { totsel = 1; - run_coord_with_matrix(ob->sculpt->pivot_pos, false, ob->object_to_world().ptr()); + run_coord_with_matrix(ob->sculpt->pivot_pos, false, ob->object_to_world); } } else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) { @@ -940,12 +934,12 @@ static int gizmo_3d_foreach_selected(const bContext *C, } if (use_only_center || !bb) { - user_fn(base->object->object_to_world().location()); + user_fn(base->object->object_to_world[3]); } else { for (uint j = 0; j < 8; j++) { float co[3]; - mul_v3_m4v3(co, base->object->object_to_world().ptr(), bb->vec[j]); + mul_v3_m4v3(co, base->object->object_to_world, bb->vec[j]); user_fn(co); } } @@ -965,7 +959,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, } if (r_mat && ob) { - *r_mat = ob->object_to_world().ptr(); + *r_mat = ob->object_to_world; } return totsel; @@ -1012,14 +1006,14 @@ int ED_transform_calc_gizmo_stats(const bContext *C, if (params->use_local_axis && (ob && ob->mode & (OB_MODE_EDIT | OB_MODE_POSE))) { float diff_mat[3][3]; - copy_m3_m4(diff_mat, ob->object_to_world().ptr()); + copy_m3_m4(diff_mat, ob->object_to_world); normalize_m3(diff_mat); invert_m3(diff_mat); mul_m3_m3_pre(tbounds->axis, diff_mat); normalize_m3(tbounds->axis); tbounds->use_matrix_space = true; - copy_m4_m4(tbounds->matrix_space, ob->object_to_world().ptr()); + copy_m4_m4(tbounds->matrix_space, ob->object_to_world); } const auto gizmo_3d_tbounds_calc_fn = [&](const float3 &co) { calc_tw_center(tbounds, co); }; @@ -1039,11 +1033,11 @@ int ED_transform_calc_gizmo_stats(const bContext *C, const bool is_gp_edit = GPENCIL_ANY_MODE(gpd); if (!is_gp_edit && (obedit || (ob && (ob->mode & (OB_MODE_POSE | OB_MODE_SCULPT))))) { if (ob->mode & OB_MODE_POSE) { - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); } - mul_m4_v3(ob->object_to_world().ptr(), tbounds->center); - mul_m4_v3(ob->object_to_world().ptr(), tbounds->min); - mul_m4_v3(ob->object_to_world().ptr(), tbounds->max); + mul_m4_v3(ob->object_to_world, tbounds->center); + mul_m4_v3(ob->object_to_world, tbounds->min); + mul_m4_v3(ob->object_to_world, tbounds->max); } } diff --git a/source/blender/editors/transform/transform_gizmo_3d_cage.cc b/source/blender/editors/transform/transform_gizmo_3d_cage.cc index cbc14e96390..2f8a4c2801c 100644 --- a/source/blender/editors/transform/transform_gizmo_3d_cage.cc +++ b/source/blender/editors/transform/transform_gizmo_3d_cage.cc @@ -14,8 +14,8 @@ #include "BLI_math_vector.h" #include "BKE_context.hh" -#include "BKE_global.hh" -#include "BKE_scene.hh" +#include "BKE_global.h" +#include "BKE_scene.h" #include "ED_gizmo_library.hh" #include "ED_gizmo_utils.hh" diff --git a/source/blender/editors/transform/transform_gizmo_3d_shear.cc b/source/blender/editors/transform/transform_gizmo_3d_shear.cc index 2275ab61f37..0dbb1f1540d 100644 --- a/source/blender/editors/transform/transform_gizmo_3d_shear.cc +++ b/source/blender/editors/transform/transform_gizmo_3d_shear.cc @@ -14,7 +14,7 @@ #include "BLI_math_vector.h" #include "BKE_context.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "ED_gizmo_library.hh" #include "ED_gizmo_utils.hh" diff --git a/source/blender/editors/transform/transform_gizmo_extrude_3d.cc b/source/blender/editors/transform/transform_gizmo_extrude_3d.cc index 0b546ab33d5..8fe35885d2d 100644 --- a/source/blender/editors/transform/transform_gizmo_extrude_3d.cc +++ b/source/blender/editors/transform/transform_gizmo_extrude_3d.cc @@ -13,8 +13,8 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_global.hh" -#include "BKE_scene.hh" +#include "BKE_global.h" +#include "BKE_scene.h" #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/editors/transform/transform_input.cc b/source/blender/editors/transform/transform_input.cc index 45707ea5359..cab11ac1b7d 100644 --- a/source/blender/editors/transform/transform_input.cc +++ b/source/blender/editors/transform/transform_input.cc @@ -10,6 +10,7 @@ #include #include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "BKE_context.hh" diff --git a/source/blender/editors/transform/transform_mode.cc b/source/blender/editors/transform/transform_mode.cc index 02fafa27b2e..6352fccb820 100644 --- a/source/blender/editors/transform/transform_mode.cc +++ b/source/blender/editors/transform/transform_mode.cc @@ -8,6 +8,7 @@ #include +#include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_constraint_types.h" #include "DNA_gpencil_legacy_types.h" @@ -21,8 +22,13 @@ #include "BKE_constraint.h" #include "BKE_context.hh" +#include "BKE_nla.h" -#include "BLT_translation.hh" +#include "RNA_access.hh" + +#include "UI_interface.hh" + +#include "BLT_translation.h" #include "ED_sequencer.hh" @@ -1064,7 +1070,7 @@ void ElementResize(const TransInfo *t, if (t->options & CTX_POSE_BONE) { /* Without this, the resulting location of scaled bones aren't correct, * especially noticeable scaling root or disconnected bones around the cursor, see #92515. */ - mul_mat3_m4_v3(tc->poseobj->object_to_world().ptr(), vec); + mul_mat3_m4_v3(tc->poseobj->object_to_world, vec); } mul_m3_v3(td->smtx, vec); } diff --git a/source/blender/editors/transform/transform_mode_align.cc b/source/blender/editors/transform/transform_mode_align.cc index 6d92979fe4f..1d4ce84856f 100644 --- a/source/blender/editors/transform/transform_mode_align.cc +++ b/source/blender/editors/transform/transform_mode_align.cc @@ -8,12 +8,14 @@ #include +#include "BKE_context.hh" + #include "ED_screen.hh" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_baketime.cc b/source/blender/editors/transform/transform_mode_baketime.cc index 3d150131b60..69bcb7f4c92 100644 --- a/source/blender/editors/transform/transform_mode_baketime.cc +++ b/source/blender/editors/transform/transform_mode_baketime.cc @@ -11,13 +11,14 @@ #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_bbone_resize.cc b/source/blender/editors/transform/transform_mode_bbone_resize.cc index d2e294e2a58..3af6196346e 100644 --- a/source/blender/editors/transform/transform_mode_bbone_resize.cc +++ b/source/blender/editors/transform/transform_mode_bbone_resize.cc @@ -12,13 +12,14 @@ #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_constraints.hh" diff --git a/source/blender/editors/transform/transform_mode_bend.cc b/source/blender/editors/transform/transform_mode_bend.cc index 444620d1a4c..c7582e036ec 100644 --- a/source/blender/editors/transform/transform_mode_bend.cc +++ b/source/blender/editors/transform/transform_mode_bend.cc @@ -19,6 +19,7 @@ #include "BLI_string.h" #include "BLI_task.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" @@ -28,7 +29,7 @@ #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_boneenvelope.cc b/source/blender/editors/transform/transform_mode_boneenvelope.cc index f57ec5827b6..7ff1ab880ab 100644 --- a/source/blender/editors/transform/transform_mode_boneenvelope.cc +++ b/source/blender/editors/transform/transform_mode_boneenvelope.cc @@ -11,13 +11,14 @@ #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_boneroll.cc b/source/blender/editors/transform/transform_mode_boneroll.cc index ece49b7fff1..2507307be43 100644 --- a/source/blender/editors/transform/transform_mode_boneroll.cc +++ b/source/blender/editors/transform/transform_mode_boneroll.cc @@ -12,13 +12,14 @@ #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_curveshrinkfatten.cc b/source/blender/editors/transform/transform_mode_curveshrinkfatten.cc index f3a719c8ef2..5a0ed7cf536 100644 --- a/source/blender/editors/transform/transform_mode_curveshrinkfatten.cc +++ b/source/blender/editors/transform/transform_mode_curveshrinkfatten.cc @@ -12,13 +12,14 @@ #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_customdata.cc b/source/blender/editors/transform/transform_mode_customdata.cc index 8700f2ca8c5..64464171898 100644 --- a/source/blender/editors/transform/transform_mode_customdata.cc +++ b/source/blender/editors/transform/transform_mode_customdata.cc @@ -12,13 +12,14 @@ #include "BLI_string.h" #include "BLI_task.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_edge_rotate_normal.cc b/source/blender/editors/transform/transform_mode_edge_rotate_normal.cc index 19982f90f14..2a315548711 100644 --- a/source/blender/editors/transform/transform_mode_edge_rotate_normal.cc +++ b/source/blender/editors/transform/transform_mode_edge_rotate_normal.cc @@ -12,6 +12,7 @@ #include "BLI_math_rotation.h" #include "BLI_math_vector.h" +#include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_mesh.hh" #include "BKE_unit.hh" diff --git a/source/blender/editors/transform/transform_mode_edge_seq_slide.cc b/source/blender/editors/transform/transform_mode_edge_seq_slide.cc index edf159f5137..9bd3ab0f4be 100644 --- a/source/blender/editors/transform/transform_mode_edge_seq_slide.cc +++ b/source/blender/editors/transform/transform_mode_edge_seq_slide.cc @@ -13,6 +13,7 @@ #include "BLI_blenlib.h" #include "BLI_math_vector.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" @@ -21,8 +22,13 @@ #include "WM_types.hh" #include "UI_interface.hh" +#include "UI_view2d.hh" -#include "BLT_translation.hh" +#include "SEQ_iterator.hh" +#include "SEQ_sequencer.hh" +#include "SEQ_time.hh" + +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_edge_slide.cc b/source/blender/editors/transform/transform_mode_edge_slide.cc index a5ffa431660..3d41dff9a83 100644 --- a/source/blender/editors/transform/transform_mode_edge_slide.cc +++ b/source/blender/editors/transform/transform_mode_edge_slide.cc @@ -15,6 +15,7 @@ #include "BLI_string.h" #include "BLI_utildefines_stack.h" +#include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_editmesh_bvh.h" #include "BKE_unit.hh" @@ -34,7 +35,7 @@ #include "UI_interface.hh" #include "UI_resources.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_constraints.hh" @@ -1134,7 +1135,7 @@ static void drawEdgeSlide(TransInfo *t) GPU_blend(GPU_BLEND_ALPHA); GPU_matrix_push(); - GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world().ptr()); + GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world); uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); diff --git a/source/blender/editors/transform/transform_mode_gpopacity.cc b/source/blender/editors/transform/transform_mode_gpopacity.cc index 10289a0c9fb..483738e49f1 100644 --- a/source/blender/editors/transform/transform_mode_gpopacity.cc +++ b/source/blender/editors/transform/transform_mode_gpopacity.cc @@ -11,6 +11,7 @@ #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "DNA_gpencil_legacy_types.h" @@ -19,7 +20,7 @@ #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_gpshrinkfatten.cc b/source/blender/editors/transform/transform_mode_gpshrinkfatten.cc index be4f66e4c8c..6b59c279be9 100644 --- a/source/blender/editors/transform/transform_mode_gpshrinkfatten.cc +++ b/source/blender/editors/transform/transform_mode_gpshrinkfatten.cc @@ -11,6 +11,7 @@ #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "DNA_gpencil_legacy_types.h" @@ -19,7 +20,7 @@ #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_maskshrinkfatten.cc b/source/blender/editors/transform/transform_mode_maskshrinkfatten.cc index 87e18b62ea9..ab6922ddfce 100644 --- a/source/blender/editors/transform/transform_mode_maskshrinkfatten.cc +++ b/source/blender/editors/transform/transform_mode_maskshrinkfatten.cc @@ -11,13 +11,14 @@ #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_mirror.cc b/source/blender/editors/transform/transform_mode_mirror.cc index a39295241d5..8ac76511263 100644 --- a/source/blender/editors/transform/transform_mode_mirror.cc +++ b/source/blender/editors/transform/transform_mode_mirror.cc @@ -13,11 +13,14 @@ #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BKE_armature.hh" +#include "BKE_context.hh" + #include "ED_screen.hh" #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_push_pull.cc b/source/blender/editors/transform/transform_mode_push_pull.cc index 3674343c293..f5850d1c6d9 100644 --- a/source/blender/editors/transform/transform_mode_push_pull.cc +++ b/source/blender/editors/transform/transform_mode_push_pull.cc @@ -13,13 +13,14 @@ #include "BLI_string.h" #include "BLI_task.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_constraints.hh" diff --git a/source/blender/editors/transform/transform_mode_resize.cc b/source/blender/editors/transform/transform_mode_resize.cc index 356ceb2d663..f8cbc50dd6c 100644 --- a/source/blender/editors/transform/transform_mode_resize.cc +++ b/source/blender/editors/transform/transform_mode_resize.cc @@ -14,6 +14,7 @@ #include "BLI_math_vector.h" #include "BLI_task.h" +#include "BKE_context.hh" #include "BKE_image.h" #include "BKE_unit.hh" diff --git a/source/blender/editors/transform/transform_mode_rotate.cc b/source/blender/editors/transform/transform_mode_rotate.cc index 70cd1e7db97..f4b0a75b1db 100644 --- a/source/blender/editors/transform/transform_mode_rotate.cc +++ b/source/blender/editors/transform/transform_mode_rotate.cc @@ -13,7 +13,8 @@ #include "BLI_math_vector.h" #include "BLI_task.h" -#include "BKE_report.hh" +#include "BKE_context.hh" +#include "BKE_report.h" #include "BKE_unit.hh" #include "ED_screen.hh" diff --git a/source/blender/editors/transform/transform_mode_shear.cc b/source/blender/editors/transform/transform_mode_shear.cc index a42a2cb28b4..0eeabf2c2d7 100644 --- a/source/blender/editors/transform/transform_mode_shear.cc +++ b/source/blender/editors/transform/transform_mode_shear.cc @@ -15,6 +15,7 @@ #include "BLI_string.h" #include "BLI_task.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" @@ -23,7 +24,7 @@ #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_shrink_fatten.cc b/source/blender/editors/transform/transform_mode_shrink_fatten.cc index 9e241e1af94..2de9701c2fe 100644 --- a/source/blender/editors/transform/transform_mode_shrink_fatten.cc +++ b/source/blender/editors/transform/transform_mode_shrink_fatten.cc @@ -7,12 +7,13 @@ */ #include -#include #include "BLI_math_vector.h" +#include "BLI_string.h" #include "BLI_task.h" -#include "BKE_report.hh" +#include "BKE_context.hh" +#include "BKE_report.h" #include "BKE_unit.hh" #include "ED_screen.hh" @@ -20,7 +21,9 @@ #include "WM_api.hh" #include "WM_types.hh" -#include "BLT_translation.hh" +#include "UI_interface.hh" + +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" @@ -89,7 +92,8 @@ static void applyShrinkFatten(TransInfo *t) { float distance; int i; - fmt::memory_buffer str; + char str[UI_MAX_DRAW_STR]; + size_t ofs = 0; UnitSettings *unit = &t->scene->unit; distance = t->values[0] + t->values_modal_offset[0]; @@ -101,38 +105,42 @@ static void applyShrinkFatten(TransInfo *t) t->values_final[0] = distance; /* header print for NumInput */ - fmt::format_to(fmt::appender(str), IFACE_("Shrink/Fatten: ")); + ofs += BLI_strncpy_rlen(str + ofs, IFACE_("Shrink/Fatten: "), sizeof(str) - ofs); if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; outputNumInput(&(t->num), c, unit); - fmt::format_to(fmt::appender(str), c); + ofs += BLI_snprintf_rlen(str + ofs, sizeof(str) - ofs, "%s", c); } else { /* default header print */ if (unit != nullptr) { - char unit_str[64]; - BKE_unit_value_as_string( - unit_str, sizeof(unit_str), distance * unit->scale_length, 4, B_UNIT_LENGTH, unit, true); - fmt::format_to(fmt::appender(str), unit_str); + ofs += BKE_unit_value_as_string(str + ofs, + sizeof(str) - ofs, + distance * unit->scale_length, + 4, + B_UNIT_LENGTH, + unit, + true); } else { - fmt::format_to(fmt::appender(str), "{:.4f}", distance); + ofs += BLI_snprintf_rlen(str + ofs, sizeof(str) - ofs, "%.4f", distance); } } if (t->proptext[0]) { - fmt::format_to(fmt::appender(str), " {}", t->proptext); + ofs += BLI_snprintf_rlen(str + ofs, sizeof(str) - ofs, " %s", t->proptext); } - fmt::format_to(fmt::appender(str), ", ("); + ofs += BLI_strncpy_rlen(str + ofs, ", (", sizeof(str) - ofs); const wmKeyMapItem *kmi = static_cast(t->custom.mode.data); if (kmi) { - str.append(WM_keymap_item_to_string(kmi, false).value_or("")); + ofs += WM_keymap_item_to_string(kmi, false, str + ofs, sizeof(str) - ofs); } - fmt::format_to(fmt::appender(str), - IFACE_(" or Alt) Even Thickness {}"), - WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0)); + BLI_snprintf(str + ofs, + sizeof(str) - ofs, + IFACE_(" or Alt) Even Thickness %s"), + WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0)); /* done with header string */ FOREACH_TRANS_DATA_CONTAINER (t, tc) { @@ -158,7 +166,7 @@ static void applyShrinkFatten(TransInfo *t) recalc_data(t); - ED_area_status_text(t->area, fmt::to_string(str).c_str()); + ED_area_status_text(t->area, str); } static void initShrinkFatten(TransInfo *t, wmOperator * /*op*/) diff --git a/source/blender/editors/transform/transform_mode_skin_resize.cc b/source/blender/editors/transform/transform_mode_skin_resize.cc index f4a946295a3..d182f06a34d 100644 --- a/source/blender/editors/transform/transform_mode_skin_resize.cc +++ b/source/blender/editors/transform/transform_mode_skin_resize.cc @@ -12,6 +12,7 @@ #include "BLI_math_vector.h" #include "BLI_task.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" diff --git a/source/blender/editors/transform/transform_mode_tilt.cc b/source/blender/editors/transform/transform_mode_tilt.cc index 8cb5817090f..d81f6c1ee1c 100644 --- a/source/blender/editors/transform/transform_mode_tilt.cc +++ b/source/blender/editors/transform/transform_mode_tilt.cc @@ -12,13 +12,14 @@ #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_timescale.cc b/source/blender/editors/transform/transform_mode_timescale.cc index 8a08690df0e..2501da895de 100644 --- a/source/blender/editors/transform/transform_mode_timescale.cc +++ b/source/blender/editors/transform/transform_mode_timescale.cc @@ -8,9 +8,12 @@ #include +#include "DNA_anim_types.h" + #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BKE_context.hh" #include "BKE_nla.h" #include "BKE_unit.hh" @@ -18,7 +21,7 @@ #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_timeslide.cc b/source/blender/editors/transform/transform_mode_timeslide.cc index f43035a21fe..a689afc5143 100644 --- a/source/blender/editors/transform/transform_mode_timeslide.cc +++ b/source/blender/editors/transform/transform_mode_timeslide.cc @@ -11,9 +11,12 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" + #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BKE_context.hh" #include "BKE_nla.h" #include "BKE_unit.hh" @@ -22,7 +25,7 @@ #include "UI_interface.hh" #include "UI_view2d.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_timetranslate.cc b/source/blender/editors/transform/transform_mode_timetranslate.cc index 8b2c5bf9d34..26eff134c1d 100644 --- a/source/blender/editors/transform/transform_mode_timetranslate.cc +++ b/source/blender/editors/transform/transform_mode_timetranslate.cc @@ -8,9 +8,12 @@ #include +#include "DNA_anim_types.h" + #include "BLI_math_vector.h" #include "BLI_string.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" @@ -18,7 +21,7 @@ #include "UI_interface.hh" #include "UI_view2d.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_tosphere.cc b/source/blender/editors/transform/transform_mode_tosphere.cc index 043050f6c0a..e672a87268c 100644 --- a/source/blender/editors/transform/transform_mode_tosphere.cc +++ b/source/blender/editors/transform/transform_mode_tosphere.cc @@ -15,13 +15,14 @@ #include "MEM_guardedalloc.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_trackball.cc b/source/blender/editors/transform/transform_mode_trackball.cc index 7550b2e5e38..85dd1243cfd 100644 --- a/source/blender/editors/transform/transform_mode_trackball.cc +++ b/source/blender/editors/transform/transform_mode_trackball.cc @@ -14,13 +14,14 @@ #include "BLI_string.h" #include "BLI_task.h" +#include "BKE_context.hh" #include "BKE_unit.hh" #include "ED_screen.hh" #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_translate.cc b/source/blender/editors/transform/transform_mode_translate.cc index 1eff997028a..0ed9c54d0be 100644 --- a/source/blender/editors/transform/transform_mode_translate.cc +++ b/source/blender/editors/transform/transform_mode_translate.cc @@ -18,16 +18,19 @@ #include "BLI_string.h" #include "BLI_task.h" +#include "BKE_context.hh" #include "BKE_image.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_unit.hh" #include "ED_node.hh" #include "ED_screen.hh" +#include "WM_api.hh" + #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_convert.hh" diff --git a/source/blender/editors/transform/transform_mode_vert_slide.cc b/source/blender/editors/transform/transform_mode_vert_slide.cc index f6d8081fb17..ef8ebc556ab 100644 --- a/source/blender/editors/transform/transform_mode_vert_slide.cc +++ b/source/blender/editors/transform/transform_mode_vert_slide.cc @@ -13,8 +13,8 @@ #include "BLI_math_matrix.h" #include "BLI_string.h" +#include "BKE_context.hh" #include "BKE_editmesh.hh" -#include "BKE_object_types.hh" #include "BKE_unit.hh" #include "GPU_immediate.h" @@ -31,7 +31,7 @@ #include "UI_interface.hh" #include "UI_resources.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "transform.hh" #include "transform_constraints.hh" @@ -166,7 +166,7 @@ static void calcVertSlideMouseActiveEdges(TransInfo *t, const float2 &mval_fl) float dir_dot; sub_v3_v3v3(tdir, sv->co_orig_3d, sv->co_link_orig_3d[j]); - mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world().ptr(), tdir); + mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world, tdir); project_plane_v3_v3v3(tdir, tdir, t->viewinv[2]); normalize_v3(tdir); @@ -369,7 +369,7 @@ static void drawVertSlide(TransInfo *t) GPU_blend(GPU_BLEND_ALPHA); GPU_matrix_push(); - GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world().ptr()); + GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world); GPU_line_width(line_size); @@ -423,17 +423,16 @@ static void drawVertSlide(TransInfo *t) float2 xy_delta = t->mval - t->mouse.imval; mul_v3_m4v3(co_orig_3d, - TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world().ptr(), + TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world, curr_sv->co_orig_3d); zfac = ED_view3d_calc_zfac(static_cast(t->region->regiondata), co_orig_3d); ED_view3d_win_to_delta(t->region, xy_delta, zfac, co_dest_3d); - invert_m4_m4(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->runtime->world_to_object.ptr(), - TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world().ptr()); - mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->world_to_object().ptr(), - co_dest_3d); + invert_m4_m4(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->world_to_object, + TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world); + mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->world_to_object, co_dest_3d); add_v3_v3(co_dest_3d, curr_sv->co_orig_3d); diff --git a/source/blender/editors/transform/transform_ops.cc b/source/blender/editors/transform/transform_ops.cc index 0d6eb724ccf..a56d649b78b 100644 --- a/source/blender/editors/transform/transform_ops.cc +++ b/source/blender/editors/transform/transform_ops.cc @@ -15,12 +15,13 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" -#include "BKE_global.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_editmesh.hh" +#include "BKE_global.h" +#include "BKE_report.h" +#include "BKE_scene.h" #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/editors/transform/transform_orientations.cc b/source/blender/editors/transform/transform_orientations.cc index e3353a3105d..b72f612f9c6 100644 --- a/source/blender/editors/transform/transform_orientations.cc +++ b/source/blender/editors/transform/transform_orientations.cc @@ -37,10 +37,10 @@ #include "BKE_curve.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "ED_armature.hh" @@ -134,7 +134,7 @@ static TransformOrientation *createObjectSpace(bContext *C, ob = base->object; - copy_m3_m4(mat, ob->object_to_world().ptr()); + copy_m3_m4(mat, ob->object_to_world); normalize_m3(mat); /* use object name if no name is given */ @@ -299,12 +299,12 @@ bool gimbal_axis_pose(Object *ob, const bPoseChannel *pchan, float gmat[3][3]) mul_m3_m3m3(mat, parent_mat, tmat); /* needed if object transformation isn't identity */ - copy_m3_m4(obmat, ob->object_to_world().ptr()); + copy_m3_m4(obmat, ob->object_to_world); mul_m3_m3m3(gmat, obmat, mat); } else { /* needed if object transformation isn't identity */ - copy_m3_m4(obmat, ob->object_to_world().ptr()); + copy_m3_m4(obmat, ob->object_to_world); mul_m3_m3m3(gmat, obmat, tmat); } @@ -326,7 +326,7 @@ bool gimbal_axis_object(Object *ob, float gmat[3][3]) if (ob->parent) { float parent_mat[3][3]; - copy_m3_m4(parent_mat, ob->parent->object_to_world().ptr()); + copy_m3_m4(parent_mat, ob->parent->object_to_world); normalize_m3(parent_mat); mul_m3_m3m3(gmat, parent_mat, gmat); } @@ -597,21 +597,20 @@ static void handle_armature_parent_orientation(Object *ob, float r_mat[3][3]) /* For child, show parent local regardless if "local location" is set for parent bone. */ transform_orientations_create_from_axis(r_mat, UNPACK3(active_pchan->parent->pose_mat)); float ob_orientations_mat[3][3]; - transform_orientations_create_from_axis(ob_orientations_mat, - UNPACK3(ob->object_to_world().ptr())); + transform_orientations_create_from_axis(ob_orientations_mat, UNPACK3(ob->object_to_world)); mul_m3_m3_pre(r_mat, ob_orientations_mat); return; } /* For root, use local transform of armature object. */ - transform_orientations_create_from_axis(r_mat, UNPACK3(ob->object_to_world().ptr())); + transform_orientations_create_from_axis(r_mat, UNPACK3(ob->object_to_world)); } static void handle_object_parent_orientation(Object *ob, float r_mat[3][3]) { /* If object has parent, then orient to parent. */ if (ob->parent) { - transform_orientations_create_from_axis(r_mat, UNPACK3(ob->parent->object_to_world().ptr())); + transform_orientations_create_from_axis(r_mat, UNPACK3(ob->parent->object_to_world)); } else { /* If object doesn't have parent, then orient to world. */ @@ -678,7 +677,7 @@ short ED_transform_calc_orientation_from_type_ex(const Scene *scene, ED_getTransformOrientationMatrix(scene, view_layer, v3d, ob, obedit, pivot_point, r_mat); } else { - transform_orientations_create_from_axis(r_mat, UNPACK3(ob->object_to_world().ptr())); + transform_orientations_create_from_axis(r_mat, UNPACK3(ob->object_to_world)); } break; } @@ -911,7 +910,7 @@ int getTransformOrientation_ex(const Scene *scene, float imat[3][3], mat[3][3]; /* we need the transpose of the inverse for a normal... */ - copy_m3_m4(imat, ob->object_to_world().ptr()); + copy_m3_m4(imat, ob->object_to_world); invert_m3_m3(mat, imat); transpose_m3(mat); @@ -1341,8 +1340,8 @@ int getTransformOrientation_ex(const Scene *scene, if (result == ORIENTATION_EDGE) { float tvec[3]; - mul_mat3_m4_v3(ob->object_to_world().ptr(), normal); - mul_mat3_m4_v3(ob->object_to_world().ptr(), plane); + mul_mat3_m4_v3(ob->object_to_world, normal); + mul_mat3_m4_v3(ob->object_to_world, plane); /* align normal to edge direction (so normal is perpendicular to the plane). * 'ORIENTATION_EDGE' will do the other way around. @@ -1384,7 +1383,7 @@ int getTransformOrientation_ex(const Scene *scene, /* use for both active & all */ if (ok) { /* we need the transpose of the inverse for a normal... */ - copy_m3_m4(imat, ob->object_to_world().ptr()); + copy_m3_m4(imat, ob->object_to_world); invert_m3_m3(mat, imat); transpose_m3(mat); @@ -1416,8 +1415,8 @@ int getTransformOrientation_ex(const Scene *scene, } if (ok) { - copy_v3_v3(normal, ob->object_to_world().ptr()[2]); - copy_v3_v3(plane, ob->object_to_world().ptr()[1]); + copy_v3_v3(normal, ob->object_to_world[2]); + copy_v3_v3(plane, ob->object_to_world[1]); } } result = ORIENTATION_NORMAL; diff --git a/source/blender/editors/transform/transform_snap.cc b/source/blender/editors/transform/transform_snap.cc index 014cbf14897..70b30865f8b 100644 --- a/source/blender/editors/transform/transform_snap.cc +++ b/source/blender/editors/transform/transform_snap.cc @@ -10,6 +10,7 @@ #include "DNA_windowmanager_types.h" +#include "BLI_blenlib.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" #include "BLI_time.h" @@ -19,17 +20,20 @@ #include "GPU_matrix.h" #include "GPU_state.h" +#include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" #include "BKE_node_runtime.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "RNA_access.hh" #include "WM_api.hh" #include "WM_types.hh" +#include "ED_gizmo_library.hh" +#include "ED_markers.hh" #include "ED_node.hh" #include "ED_transform_snap_object_context.hh" #include "ED_uvedit.hh" @@ -38,7 +42,9 @@ #include "UI_resources.hh" #include "UI_view2d.hh" +#include "SEQ_iterator.hh" #include "SEQ_sequencer.hh" +#include "SEQ_time.hh" #include "MEM_guardedalloc.h" @@ -395,7 +401,7 @@ static bool applyFaceProject(TransInfo *t, TransDataContainer *tc, TransData *td } else if (t->options & CTX_OBJECT) { BKE_object_eval_transform_all(t->depsgraph, t->scene, td->ob); - copy_v3_v3(iloc, td->ob->object_to_world().location()); + copy_v3_v3(iloc, td->ob->object_to_world[3]); } if (ED_view3d_project_float_global(t->region, iloc, mval_fl, V3D_PROJ_TEST_NOP) != @@ -464,7 +470,7 @@ static void applyFaceNearest(TransInfo *t, TransDataContainer *tc, TransData *td } else if (t->options & CTX_OBJECT) { BKE_object_eval_transform_all(t->depsgraph, t->scene, td->ob); - copy_v3_v3(init_loc, td->ob->object_to_world().location()); + copy_v3_v3(init_loc, td->ob->object_to_world[3]); } SnapObjectParams snap_object_params{}; @@ -562,7 +568,7 @@ void transform_snap_mixed_apply(TransInfo *t, float *vec) } if (t->tsnap.mode & ~(SCE_SNAP_TO_INCREMENT | SCE_SNAP_TO_GRID)) { - double current = BLI_time_now_seconds(); + double current = BLI_check_seconds_timer(); /* Time base quirky code to go around find-nearest slowness. */ /* TODO: add exception for object mode, no need to slow it down then. */ diff --git a/source/blender/editors/transform/transform_snap_animation.cc b/source/blender/editors/transform/transform_snap_animation.cc index 63c77e7d903..0282dbfc2c5 100644 --- a/source/blender/editors/transform/transform_snap_animation.cc +++ b/source/blender/editors/transform/transform_snap_animation.cc @@ -6,12 +6,16 @@ * \ingroup edtransform */ +#include "DNA_anim_types.h" + #include "BLI_math_matrix_types.hh" #include "BLI_math_vector.h" +#include "BKE_context.hh" #include "BKE_nla.h" #include "ED_markers.hh" +#include "ED_screen.hh" #include "transform.hh" #include "transform_snap.hh" diff --git a/source/blender/editors/transform/transform_snap_object.cc b/source/blender/editors/transform/transform_snap_object.cc index 435230b4507..a32f23db0b9 100644 --- a/source/blender/editors/transform/transform_snap_object.cc +++ b/source/blender/editors/transform/transform_snap_object.cc @@ -13,7 +13,8 @@ #include "DNA_screen_types.h" #include "BKE_bvhutils.hh" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" +#include "BKE_editmesh.hh" #include "BKE_geometry_set_instances.hh" #include "BKE_layer.hh" #include "BKE_mesh.hh" @@ -28,7 +29,6 @@ #ifdef DEBUG_SNAP_TIME # include "BLI_timeit.hh" -# include # if WIN32 and NDEBUG # pragma optimize("t", on) @@ -374,17 +374,21 @@ static ID *data_for_snap(Object *ob_eval, eSnapEditType edit_mode_type, bool *r_ return nullptr; } - Mesh *editmesh_eval = (edit_mode_type == SNAP_GEOM_FINAL) ? - BKE_object_get_editmesh_eval_final(ob_eval) : - (edit_mode_type == SNAP_GEOM_CAGE) ? - BKE_object_get_editmesh_eval_cage(ob_eval) : - nullptr; + Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(ob_eval); + Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(ob_eval); - if (editmesh_eval) { - if (editmesh_eval->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) { + if ((edit_mode_type == SNAP_GEOM_FINAL) && editmesh_eval_final) { + if (editmesh_eval_final->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) { return nullptr; } - me_eval = editmesh_eval; + me_eval = editmesh_eval_final; + use_hide = true; + } + else if ((edit_mode_type == SNAP_GEOM_CAGE) && editmesh_eval_cage) { + if (editmesh_eval_cage->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) { + return nullptr; + } + me_eval = editmesh_eval_cage; use_hide = true; } } @@ -513,9 +517,12 @@ static eSnapMode iter_snap_objects(SnapObjectContext *sctx, IterSnapObjsCallback bool use_hide = false; ID *ob_data = data_for_snap(obj_eval, sctx->runtime.params.edit_mode_type, &use_hide); - if ((tmp = sob_callback( - sctx, obj_eval, ob_data, obj_eval->object_to_world(), is_object_active, use_hide)) != - SCE_SNAP_TO_NONE) + if ((tmp = sob_callback(sctx, + obj_eval, + ob_data, + float4x4(obj_eval->object_to_world), + is_object_active, + use_hide)) != SCE_SNAP_TO_NONE) { ret = tmp; } @@ -829,21 +836,39 @@ void cb_snap_edge(void *userdata, static eSnapMode snap_polygon(SnapObjectContext *sctx, eSnapMode snap_to_flag) { - if (sctx->ret.ob->type != OB_MESH || !sctx->ret.data || GS(sctx->ret.data->name) != ID_ME) { + if (sctx->ret.ob->type != OB_MESH) { return SCE_SNAP_TO_NONE; } - return snap_polygon_mesh( + if (sctx->ret.data && GS(sctx->ret.data->name) != ID_ME) { + return SCE_SNAP_TO_NONE; + } + + if (sctx->ret.data) { + return snap_polygon_mesh( + sctx, sctx->ret.ob, sctx->ret.data, sctx->ret.obmat, snap_to_flag, sctx->ret.index); + } + return snap_polygon_editmesh( sctx, sctx->ret.ob, sctx->ret.data, sctx->ret.obmat, snap_to_flag, sctx->ret.index); } static eSnapMode snap_edge_points(SnapObjectContext *sctx, const float dist_px_sq_orig) { - if (sctx->ret.ob->type != OB_MESH || !sctx->ret.data || GS(sctx->ret.data->name) != ID_ME) { - return SCE_SNAP_TO_EDGE; + eSnapMode elem = SCE_SNAP_TO_EDGE; + + if (sctx->ret.ob->type != OB_MESH) { + return elem; } - return snap_edge_points_mesh( + if (sctx->ret.data && GS(sctx->ret.data->name) != ID_ME) { + return elem; + } + + if (sctx->ret.data) { + return snap_edge_points_mesh( + sctx, sctx->ret.ob, sctx->ret.data, sctx->ret.obmat, dist_px_sq_orig, sctx->ret.index); + } + return snap_edge_points_editmesh( sctx, sctx->ret.ob, sctx->ret.data, sctx->ret.obmat, dist_px_sq_orig, sctx->ret.index); } diff --git a/source/blender/editors/transform/transform_snap_object.hh b/source/blender/editors/transform/transform_snap_object.hh index 813a7a1c229..d7ecec1adf2 100644 --- a/source/blender/editors/transform/transform_snap_object.hh +++ b/source/blender/editors/transform/transform_snap_object.hh @@ -210,6 +210,20 @@ eSnapMode snap_object_editmesh(SnapObjectContext *sctx, eSnapMode snap_to_flag, bool use_hide); +eSnapMode snap_polygon_editmesh(SnapObjectContext *sctx, + Object *ob_eval, + const ID *id, + const blender::float4x4 &obmat, + eSnapMode snap_to_flag, + int face); + +eSnapMode snap_edge_points_editmesh(SnapObjectContext *sctx, + Object *ob_eval, + const ID *id, + const blender::float4x4 &obmat, + float dist_px_sq_orig, + int edge); + /* transform_snap_object_mesh.cc */ eSnapMode snap_object_mesh(SnapObjectContext *sctx, diff --git a/source/blender/editors/transform/transform_snap_object_armature.cc b/source/blender/editors/transform/transform_snap_object_armature.cc index b4b2c8dd34d..34b2d104bcf 100644 --- a/source/blender/editors/transform/transform_snap_object_armature.cc +++ b/source/blender/editors/transform/transform_snap_object_armature.cc @@ -10,6 +10,7 @@ #include "BKE_armature.hh" #include "BKE_bvhutils.hh" +#include "BKE_mesh.hh" #include "DNA_armature_types.h" #include "ED_transform_snap_object_context.hh" diff --git a/source/blender/editors/transform/transform_snap_object_camera.cc b/source/blender/editors/transform/transform_snap_object_camera.cc index 57ea6335b95..29632c410b8 100644 --- a/source/blender/editors/transform/transform_snap_object_camera.cc +++ b/source/blender/editors/transform/transform_snap_object_camera.cc @@ -9,6 +9,7 @@ #include "BLI_math_matrix.hh" #include "BKE_bvhutils.hh" +#include "BKE_mesh.hh" #include "BKE_object.hh" #include "BKE_tracking.h" diff --git a/source/blender/editors/transform/transform_snap_object_curve.cc b/source/blender/editors/transform/transform_snap_object_curve.cc index ca851112053..dc041df0423 100644 --- a/source/blender/editors/transform/transform_snap_object_curve.cc +++ b/source/blender/editors/transform/transform_snap_object_curve.cc @@ -12,6 +12,7 @@ #include "BKE_bvhutils.hh" #include "BKE_curve.hh" +#include "BKE_mesh.hh" #include "BKE_object.hh" #include "ED_transform_snap_object_context.hh" diff --git a/source/blender/editors/transform/transform_snap_object_editmesh.cc b/source/blender/editors/transform/transform_snap_object_editmesh.cc index 1589e1b68f5..9c04253d329 100644 --- a/source/blender/editors/transform/transform_snap_object_editmesh.cc +++ b/source/blender/editors/transform/transform_snap_object_editmesh.cc @@ -6,17 +6,19 @@ * \ingroup edtransform */ -#include "BKE_attribute.hh" +#include "BLI_math_matrix.hh" +#include "BLI_math_vector.h" + #include "BKE_bvhutils.hh" #include "BKE_editmesh.hh" -#include "BKE_global.hh" -#include "BKE_lib_id.hh" +#include "BKE_global.h" #include "BKE_mesh.hh" #include "BKE_object.hh" #include "DEG_depsgraph_query.hh" #include "ED_transform_snap_object_context.hh" +#include "ED_view3d.hh" #include "transform_snap_object.hh" @@ -26,43 +28,27 @@ using namespace blender; /** \name Snap Object Data * \{ */ -static Mesh *get_mesh_ref(Object *ob_eval) -{ - if (Mesh *me = BKE_object_get_editmesh_eval_final(ob_eval)) { - return me; - } - - if (Mesh *me = BKE_object_get_editmesh_eval_cage(ob_eval)) { - return me; - } - - return static_cast(ob_eval->data); -} - struct SnapCache_EditMesh : public SnapObjectContext::SnapCache { - /* Mesh created from the edited mesh. */ - Mesh *mesh; + /* Loose Verts, Edges, Triangles. */ + BVHTree *bvhtree[3]; + bool cached[3]; - /* Reference to pointers that change when the mesh is changed. It is used to detect updates. */ - Mesh *mesh_ref; - bke::MeshRuntime *runtime_ref; - bke::EditMeshData *edit_data_ref; + BMEditMesh *em; - bool has_mesh_updated(Mesh *mesh) - { - if (mesh != this->mesh_ref || mesh->runtime != this->runtime_ref || - mesh->runtime->edit_data.get() != this->edit_data_ref) - { - return true; - } + /** Default callbacks to BVH nearest and ray-cast used only for triangles. */ + BVHTree_NearestPointCallback nearest_callback; + BVHTree_RayCastCallback raycast_callback; - return false; - } + bke::MeshRuntime *mesh_runtime; + float min[3], max[3]; void clear() { - if (this->mesh) { - BKE_id_free(nullptr, this->mesh); + for (int i = 0; i < ARRAY_SIZE(this->bvhtree); i++) { + if (!this->cached[i]) { + BLI_bvhtree_free(this->bvhtree[i]); + } + this->bvhtree[i] = nullptr; } } @@ -72,101 +58,98 @@ struct SnapCache_EditMesh : public SnapObjectContext::SnapCache { } #ifdef WITH_CXX_GUARDEDALLOC - MEM_CXX_CLASS_ALLOC_FUNCS("SnapCache_EditMesh") + MEM_CXX_CLASS_ALLOC_FUNCS("SnapData_EditMesh") #endif }; -static Mesh *create_mesh(SnapObjectContext *sctx, - Object *ob_eval, - eSnapEditType /*edit_mode_type*/) +/** + * Calculate the minimum and maximum coordinates of the box that encompasses this mesh. + */ +static void snap_editmesh_minmax(SnapObjectContext *sctx, + BMesh *bm, + float r_min[3], + float r_max[3]) { - Mesh *mesh = static_cast(BKE_id_new_nomain(ID_ME, nullptr)); - BMEditMesh *em = BKE_editmesh_from_object(ob_eval); - BMesh *bm = em->bm; - BM_mesh_bm_to_me_compact(*bm, *mesh, nullptr, false); + INIT_MINMAX(r_min, r_max); + BMIter iter; + BMVert *v; - bke::MutableAttributeAccessor attrs = mesh->attributes_for_write(); - bke::SpanAttributeWriter hide_vert = attrs.lookup_or_add_for_write_only_span( - ".hide_vert", bke::AttrDomain::Point); - bke::SpanAttributeWriter hide_edge = attrs.lookup_or_add_for_write_only_span( - ".hide_edge", bke::AttrDomain::Edge); - bke::SpanAttributeWriter hide_poly = attrs.lookup_or_add_for_write_only_span( - ".hide_poly", bke::AttrDomain::Face); + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + if (sctx->callbacks.edit_mesh.test_vert_fn && + !sctx->callbacks.edit_mesh.test_vert_fn(v, sctx->callbacks.edit_mesh.user_data)) + { + continue; + } + minmax_v3v3_v3(r_min, r_max, v->co); + } +} - /* Loop over all elements in parallel to choose which elements will participate in the snap. - * Hidden elements are ignored for snapping. */ - const bool use_threading = (mesh->faces_num + mesh->edges_num) > 1024; - threading::parallel_invoke( - use_threading, - [&]() { - BMIter iter; - BMVert *v; - int i; - BM_ITER_MESH_INDEX (v, &iter, bm, BM_VERTS_OF_MESH, i) { - if (sctx->callbacks.edit_mesh.test_vert_fn) { - hide_vert.span[i] = !sctx->callbacks.edit_mesh.test_vert_fn( - v, sctx->callbacks.edit_mesh.user_data); - } - else { - hide_vert.span[i] = BM_elem_flag_test_bool(v, BM_ELEM_HIDDEN); - } - } - }, - [&]() { - BMIter iter; - BMEdge *e; - int i; - BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) { - if (sctx->callbacks.edit_mesh.test_edge_fn) { - hide_edge.span[i] = !sctx->callbacks.edit_mesh.test_edge_fn( - e, sctx->callbacks.edit_mesh.user_data); - } - else { - hide_edge.span[i] = BM_elem_flag_test_bool(e, BM_ELEM_HIDDEN); - } - } - }, - [&]() { - BMIter iter; - BMFace *f; - int i; - BM_ITER_MESH_INDEX (f, &iter, bm, BM_FACES_OF_MESH, i) { - if (sctx->callbacks.edit_mesh.test_face_fn) { - hide_poly.span[i] = !sctx->callbacks.edit_mesh.test_face_fn( - f, sctx->callbacks.edit_mesh.user_data); - } - else { - hide_poly.span[i] = BM_elem_flag_test_bool(f, BM_ELEM_HIDDEN); - } - } - }); +/* Searches for the #Mesh_Runtime associated with the object that is most likely to be updated due + * to changes in the `edit_mesh`. */ +static blender::bke::MeshRuntime *snap_object_data_editmesh_runtime_get(Object *ob_eval) +{ + Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(ob_eval); + if (editmesh_eval_final) { + return editmesh_eval_final->runtime; + } - hide_vert.finish(); - hide_edge.finish(); - hide_poly.finish(); - return mesh; + Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(ob_eval); + if (editmesh_eval_cage) { + return editmesh_eval_cage->runtime; + } + + return ((Mesh *)ob_eval->data)->runtime; } static SnapCache_EditMesh *snap_object_data_editmesh_get(SnapObjectContext *sctx, Object *ob_eval, - bool create) + BMEditMesh *em, + const bool create) { SnapCache_EditMesh *em_cache = nullptr; - bool init = false; - Mesh *mesh_ref = (G.moving) ? /* WORKAROUND: - * Avoid updating while transforming. Do not check if the reference - * mesh has been updated. */ - nullptr : - get_mesh_ref(ob_eval); if (std::unique_ptr *em_cache_p = sctx->editmesh_caches.lookup_ptr( ob_eval->runtime->data_orig)) { em_cache = static_cast(em_cache_p->get()); - + bool is_dirty = false; /* Check if the geometry has changed. */ - if (mesh_ref && em_cache->has_mesh_updated(mesh_ref)) { + if (em_cache->em != em) { + is_dirty = true; + } + else if (em_cache->mesh_runtime) { + if (em_cache->mesh_runtime != snap_object_data_editmesh_runtime_get(ob_eval)) { + if (G.moving) { + /* WORKAROUND: avoid updating while transforming. */ + BLI_assert(!em_cache->cached[0] && !em_cache->cached[1] && !em_cache->cached[2]); + em_cache->mesh_runtime = snap_object_data_editmesh_runtime_get(ob_eval); + } + else { + is_dirty = true; + } + } + else if (em_cache->bvhtree[0] && em_cache->cached[0] && + !bvhcache_has_tree(em_cache->mesh_runtime->bvh_cache, em_cache->bvhtree[0])) + { + /* The tree is owned by the EditMesh and may have been freed since we last used! */ + is_dirty = true; + } + else if (em_cache->bvhtree[1] && em_cache->cached[1] && + !bvhcache_has_tree(em_cache->mesh_runtime->bvh_cache, em_cache->bvhtree[1])) + { + /* The tree is owned by the EditMesh and may have been freed since we last used! */ + is_dirty = true; + } + else if (em_cache->bvhtree[2] && em_cache->cached[2] && + !bvhcache_has_tree(em_cache->mesh_runtime->bvh_cache, em_cache->bvhtree[2])) + { + /* The tree is owned by the EditMesh and may have been freed since we last used! */ + is_dirty = true; + } + } + + if (is_dirty) { em_cache->clear(); init = true; } @@ -179,17 +162,54 @@ static SnapCache_EditMesh *snap_object_data_editmesh_get(SnapObjectContext *sctx } if (init) { - em_cache->mesh = create_mesh(sctx, ob_eval, sctx->runtime.params.edit_mode_type); - if (mesh_ref) { - em_cache->mesh_ref = mesh_ref; - em_cache->runtime_ref = mesh_ref->runtime; - em_cache->edit_data_ref = mesh_ref->runtime->edit_data.get(); - } + /* Operators only update the editmesh looptris of the original mesh. */ + BLI_assert(em == BKE_editmesh_from_object(DEG_get_original_object(ob_eval))); + + em_cache->em = em; + em_cache->mesh_runtime = snap_object_data_editmesh_runtime_get(ob_eval); + snap_editmesh_minmax(sctx, em->bm, em_cache->min, em_cache->max); } return em_cache; } +static void snap_cache_tri_ensure(SnapCache_EditMesh *em_cache, SnapObjectContext *sctx) +{ + if (em_cache->bvhtree[2] == nullptr) { + BVHTreeFromEditMesh treedata{}; + BMEditMesh *em = em_cache->em; + + if (sctx->callbacks.edit_mesh.test_face_fn) { + BMesh *bm = em->bm; + BLI_assert(poly_to_tri_count(bm->totface, bm->totloop) == em->tottri); + + blender::BitVector<> elem_mask(em->tottri); + int looptris_num_active = BM_iter_mesh_bitmap_from_filter_tessface( + bm, + elem_mask, + sctx->callbacks.edit_mesh.test_face_fn, + sctx->callbacks.edit_mesh.user_data); + + bvhtree_from_editmesh_looptris_ex(&treedata, em, elem_mask, looptris_num_active, 0.0f, 4, 6); + } + else { + /* Only cache if BVH-tree is created without a mask. + * This helps keep a standardized BVH-tree in cache. */ + BKE_bvhtree_from_editmesh_get(&treedata, + em, + 4, + BVHTREE_FROM_EM_LOOPTRIS, + /* WORKAROUND: avoid updating while transforming. */ + G.moving ? nullptr : &em_cache->mesh_runtime->bvh_cache, + &em_cache->mesh_runtime->eval_mutex); + } + em_cache->bvhtree[2] = treedata.tree; + em_cache->cached[2] = treedata.cached; + em_cache->nearest_callback = treedata.nearest_callback; + em_cache->raycast_callback = treedata.raycast_callback; + } +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -221,7 +241,7 @@ static SnapCache_EditMesh *editmesh_snapdata_init(SnapObjectContext *sctx, return nullptr; } - SnapCache_EditMesh *em_cache = snap_object_data_editmesh_get(sctx, ob_eval, false); + SnapCache_EditMesh *em_cache = snap_object_data_editmesh_get(sctx, ob_eval, em, false); if (em_cache != nullptr) { return em_cache; } @@ -231,7 +251,423 @@ static SnapCache_EditMesh *editmesh_snapdata_init(SnapObjectContext *sctx, return nullptr; } - return snap_object_data_editmesh_get(sctx, ob_eval, true); + return snap_object_data_editmesh_get(sctx, ob_eval, em, true); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Ray Cast Functions + * \{ */ + +/* Callback to ray-cast with back-face culling (#EditMesh). */ +static void editmesh_looptris_raycast_backface_culling_cb(void *userdata, + int index, + const BVHTreeRay *ray, + BVHTreeRayHit *hit) +{ + BMEditMesh *em = static_cast(userdata); + const BMLoop **ltri = const_cast(em->looptris[index]); + + const float *t0, *t1, *t2; + t0 = ltri[0]->v->co; + t1 = ltri[1]->v->co; + t2 = ltri[2]->v->co; + + { + float dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2); + + if (dist >= 0 && dist < hit->dist) { + float no[3]; + if (raycast_tri_backface_culling_test(ray->direction, t0, t1, t2, no)) { + hit->index = index; + hit->dist = dist; + madd_v3_v3v3fl(hit->co, ray->origin, ray->direction, dist); + normalize_v3_v3(hit->no, no); + } + } + } +} + +static bool raycastEditMesh(SnapCache_EditMesh *em_cache, + SnapObjectContext *sctx, + Object *ob_eval, + BMEditMesh *em, + const float4x4 &obmat, + const uint ob_index) +{ + bool retval = false; + + float4x4 imat = math::invert(obmat); + float3 ray_start_local = math::transform_point(imat, sctx->runtime.ray_start); + float3 ray_normal_local = math::transform_direction(imat, sctx->runtime.ray_dir); + float local_scale, local_depth, len_diff = 0.0f; + + /* local scale in normal direction */ + ray_normal_local = math::normalize_and_get_length(ray_normal_local, local_scale); + + const bool is_in_front = sctx->runtime.params.use_occlusion_test && + (ob_eval->dtx & OB_DRAW_IN_FRONT) != 0; + const float depth_max = is_in_front ? sctx->ret.ray_depth_max_in_front : sctx->ret.ray_depth_max; + local_depth = depth_max; + if (local_depth != BVH_RAYCAST_DIST_MAX) { + local_depth *= local_scale; + } + + /* Test bounding box */ + + /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */ + if (!isect_ray_aabb_v3_simple( + ray_start_local, ray_normal_local, em_cache->min, em_cache->max, &len_diff, nullptr)) + { + return retval; + } + + /* We pass a temp ray_start, set from object's bounding-box, to avoid precision issues with + * very far away ray_start values (as returned in case of ortho view3d), see #50486, #38358. */ + if (len_diff > 400.0f) { + len_diff -= local_scale; /* make temp start point a bit away from bounding-box hit point. */ + madd_v3_v3fl(ray_start_local, ray_normal_local, len_diff); + local_depth -= len_diff; + } + else { + len_diff = 0.0f; + } + + snap_cache_tri_ensure(em_cache, sctx); + if (em_cache->bvhtree[2] == nullptr) { + return retval; + } + + if (sctx->ret.hit_list) { + RayCastAll_Data data; + + data.bvhdata = em; + data.raycast_callback = em_cache->raycast_callback; + data.obmat = &obmat; + data.len_diff = len_diff; + data.local_scale = local_scale; + data.ob_uuid = ob_index; + data.hit_list = sctx->ret.hit_list; + + void *hit_last_prev = data.hit_list->last; + BLI_bvhtree_ray_cast_all(em_cache->bvhtree[2], + ray_start_local, + ray_normal_local, + 0.0f, + depth_max, + raycast_all_cb, + &data); + + retval = hit_last_prev != data.hit_list->last; + } + else { + BVHTreeRayHit hit{}; + hit.index = -1; + hit.dist = local_depth; + + if (BLI_bvhtree_ray_cast(em_cache->bvhtree[2], + ray_start_local, + ray_normal_local, + 0.0f, + &hit, + sctx->runtime.params.use_backface_culling ? + editmesh_looptris_raycast_backface_culling_cb : + em_cache->raycast_callback, + em) != -1) + { + hit.dist += len_diff; + hit.dist /= local_scale; + if (hit.dist <= depth_max) { + hit.index = BM_elem_index_get(em->looptris[hit.index][0]->f); + retval = true; + } + SnapData::register_result_raycast(sctx, ob_eval, nullptr, obmat, &hit, is_in_front); + } + } + + return retval; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Surface Snap Functions + * \{ */ + +static bool nearest_world_editmesh(SnapCache_EditMesh *em_cache, + SnapObjectContext *sctx, + Object *ob_eval, + BMEditMesh *em, + const float4x4 &obmat) +{ + snap_cache_tri_ensure(em_cache, sctx); + if (em_cache->bvhtree[2] == nullptr) { + return false; + } + + BVHTreeNearest nearest{}; + nearest.dist_sq = sctx->ret.dist_nearest_sq; + if (nearest_world_tree( + sctx, em_cache->bvhtree[2], em_cache->nearest_callback, obmat, em, &nearest)) + { + SnapData::register_result(sctx, ob_eval, nullptr, obmat, &nearest); + return true; + } + return false; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Subclass for Snapping to Edges or Points of an EditMesh + * \{ */ + +class SnapData_EditMesh : public SnapData { + public: + BMesh *bm; + + SnapData_EditMesh(SnapObjectContext *sctx, BMesh *bm, const float4x4 &obmat) + : SnapData(sctx, obmat), bm(bm){}; + + void get_vert_co(const int index, const float **r_co) override + { + BMVert *eve = BM_vert_at_index(this->bm, index); + *r_co = eve->co; + } + + void get_edge_verts_index(const int index, int r_v_index[2]) override + { + BMEdge *eed = BM_edge_at_index(this->bm, index); + r_v_index[0] = BM_elem_index_get(eed->v1); + r_v_index[1] = BM_elem_index_get(eed->v2); + } + + void copy_vert_no(const int index, float r_no[3]) override + { + BMVert *eve = BM_vert_at_index(this->bm, index); + copy_v3_v3(r_no, eve->no); + } +}; + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Internal Object Snapping API + * \{ */ + +eSnapMode snap_polygon_editmesh(SnapObjectContext *sctx, + Object *ob_eval, + const ID * /*id*/, + const float4x4 &obmat, + eSnapMode snap_to_flag, + int face) +{ + eSnapMode elem = SCE_SNAP_TO_NONE; + + BMEditMesh *em = BKE_editmesh_from_object(ob_eval); + SnapData_EditMesh nearest2d(sctx, em->bm, obmat); + nearest2d.clip_planes_enable(sctx, ob_eval); + + BVHTreeNearest nearest{}; + nearest.index = -1; + nearest.dist_sq = sctx->ret.dist_px_sq; + + BM_mesh_elem_table_ensure(em->bm, BM_FACE); + BMFace *f = BM_face_at_index(em->bm, face); + BMLoop *l_iter, *l_first; + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + if (snap_to_flag & SCE_SNAP_TO_EDGE) { + elem = SCE_SNAP_TO_EDGE; + BM_mesh_elem_index_ensure(em->bm, BM_VERT | BM_EDGE); + BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE); + do { + cb_snap_edge(&nearest2d, + BM_elem_index_get(l_iter->e), + &nearest2d.nearest_precalc, + reinterpret_cast(nearest2d.clip_planes.data()), + nearest2d.clip_planes.size(), + &nearest); + } while ((l_iter = l_iter->next) != l_first); + } + else { + elem = SCE_SNAP_TO_EDGE_ENDPOINT; + BM_mesh_elem_index_ensure(em->bm, BM_VERT); + BM_mesh_elem_table_ensure(em->bm, BM_VERT); + do { + cb_snap_vert(&nearest2d, + BM_elem_index_get(l_iter->v), + &nearest2d.nearest_precalc, + reinterpret_cast(nearest2d.clip_planes.data()), + nearest2d.clip_planes.size(), + &nearest); + } while ((l_iter = l_iter->next) != l_first); + } + + if (nearest.index != -1) { + nearest2d.nearest_point = nearest; + nearest2d.register_result(sctx, ob_eval, nullptr); + return elem; + } + + return SCE_SNAP_TO_NONE; +} + +eSnapMode snap_edge_points_editmesh(SnapObjectContext *sctx, + Object *ob_eval, + const ID * /*id*/, + const float4x4 &obmat, + float dist_pex_sq_orig, + int edge) +{ + BMEditMesh *em = BKE_editmesh_from_object(ob_eval); + SnapData_EditMesh nearest2d(sctx, em->bm, obmat); + eSnapMode elem = nearest2d.snap_edge_points_impl(sctx, edge, dist_pex_sq_orig); + if (nearest2d.nearest_point.index != -2) { + nearest2d.register_result(sctx, ob_eval, nullptr); + } + return elem; +} + +static eSnapMode snapEditMesh(SnapCache_EditMesh *em_cache, + SnapObjectContext *sctx, + Object *ob_eval, + BMEditMesh *em, + const float4x4 &obmat, + eSnapMode snap_to_flag) +{ + BLI_assert(snap_to_flag != SCE_SNAP_TO_FACE); + + SnapData_EditMesh nearest2d(sctx, em->bm, obmat); + + /* Was BKE_boundbox_ray_hit_check, see: cf6ca226fa58. */ + if (!nearest2d.snap_boundbox(em_cache->min, em_cache->max)) { + return SCE_SNAP_TO_NONE; + } + + if (snap_to_flag & SCE_SNAP_TO_POINT) { + BVHTreeFromEditMesh treedata{}; + treedata.tree = em_cache->bvhtree[0]; + + if (treedata.tree == nullptr) { + if (sctx->callbacks.edit_mesh.test_vert_fn) { + auto test_looseverts_fn = [](BMElem *elem, void *user_data) { + SnapObjectContext *sctx_ = static_cast(user_data); + BMVert *v = reinterpret_cast(elem); + if (v->e && (!sctx_->callbacks.edit_mesh.test_edge_fn || + sctx_->callbacks.edit_mesh.test_edge_fn( + v->e, sctx_->callbacks.edit_mesh.user_data))) + { + return false; + } + return sctx_->callbacks.edit_mesh.test_vert_fn(v, sctx_->callbacks.edit_mesh.user_data); + }; + blender::BitVector<> verts_mask(em->bm->totvert); + const int verts_num_active = BM_iter_mesh_bitmap_from_filter( + BM_VERTS_OF_MESH, em->bm, verts_mask, test_looseverts_fn, sctx); + + bvhtree_from_editmesh_verts_ex(&treedata, em, verts_mask, verts_num_active, 0.0f, 2, 6); + } + else { + BKE_bvhtree_from_editmesh_get(&treedata, + em, + 2, + BVHTREE_FROM_EM_LOOSEVERTS, + /* WORKAROUND: avoid updating while transforming. */ + G.moving ? nullptr : &em_cache->mesh_runtime->bvh_cache, + &em_cache->mesh_runtime->eval_mutex); + } + em_cache->bvhtree[0] = treedata.tree; + em_cache->cached[0] = treedata.cached; + } + } + + if (snap_to_flag & SNAP_TO_EDGE_ELEMENTS) { + BVHTreeFromEditMesh treedata{}; + treedata.tree = em_cache->bvhtree[1]; + + if (treedata.tree == nullptr) { + if (sctx->callbacks.edit_mesh.test_edge_fn) { + blender::BitVector<> edges_mask(em->bm->totedge); + const int edges_num_active = BM_iter_mesh_bitmap_from_filter( + BM_EDGES_OF_MESH, + em->bm, + edges_mask, + (bool (*)(BMElem *, void *))sctx->callbacks.edit_mesh.test_edge_fn, + sctx->callbacks.edit_mesh.user_data); + + bvhtree_from_editmesh_edges_ex(&treedata, em, edges_mask, edges_num_active, 0.0f, 2, 6); + } + else { + BKE_bvhtree_from_editmesh_get(&treedata, + em, + 2, + BVHTREE_FROM_EM_EDGES, + /* WORKAROUND: avoid updating while transforming. */ + G.moving ? nullptr : &em_cache->mesh_runtime->bvh_cache, + &em_cache->mesh_runtime->eval_mutex); + } + em_cache->bvhtree[1] = treedata.tree; + em_cache->cached[1] = treedata.cached; + } + } + + /* #XRAY_ENABLED can return false even with the XRAY flag enabled, this happens because the + * alpha is 1.0 in this case. But even with the alpha being 1.0, the edit mesh is still not + * occluded. */ + const bool skip_occlusion_plane = XRAY_FLAG_ENABLED(sctx->runtime.v3d); + nearest2d.clip_planes_enable(sctx, ob_eval, skip_occlusion_plane); + + BVHTreeNearest nearest{}; + nearest.index = -1; + nearest.dist_sq = sctx->ret.dist_px_sq; + + eSnapMode elem = SCE_SNAP_TO_POINT; + + if (em_cache->bvhtree[0] && (snap_to_flag & SCE_SNAP_TO_POINT)) { + BM_mesh_elem_table_ensure(em->bm, BM_VERT); + BM_mesh_elem_index_ensure(em->bm, BM_VERT); + BLI_bvhtree_find_nearest_projected(em_cache->bvhtree[0], + nearest2d.pmat_local.ptr(), + sctx->runtime.win_size, + sctx->runtime.mval, + reinterpret_cast(nearest2d.clip_planes.data()), + nearest2d.clip_planes.size(), + &nearest, + cb_snap_vert, + &nearest2d); + } + + if (em_cache->bvhtree[1] && (snap_to_flag & SNAP_TO_EDGE_ELEMENTS)) { + int last_index = nearest.index; + nearest.index = -1; + BM_mesh_elem_table_ensure(em->bm, BM_EDGE | BM_VERT); + BM_mesh_elem_index_ensure(em->bm, BM_EDGE | BM_VERT); + BLI_bvhtree_find_nearest_projected(em_cache->bvhtree[1], + nearest2d.pmat_local.ptr(), + sctx->runtime.win_size, + sctx->runtime.mval, + reinterpret_cast(nearest2d.clip_planes.data()), + nearest2d.clip_planes.size(), + &nearest, + cb_snap_edge, + &nearest2d); + + if (nearest.index != -1) { + elem = SCE_SNAP_TO_EDGE; + } + else { + nearest.index = last_index; + } + } + + if (nearest.index != -1) { + nearest2d.nearest_point = nearest; + nearest2d.register_result(sctx, ob_eval, nullptr); + return elem; + } + + return SCE_SNAP_TO_NONE; } /** \} */ @@ -243,9 +679,33 @@ eSnapMode snap_object_editmesh(SnapObjectContext *sctx, eSnapMode snap_to_flag, bool /*use_hide*/) { + eSnapMode elem = SCE_SNAP_TO_NONE; + SnapCache_EditMesh *em_cache = editmesh_snapdata_init(sctx, ob_eval, snap_to_flag); - if (em_cache && em_cache->mesh) { - return snap_object_mesh(sctx, ob_eval, &em_cache->mesh->id, obmat, snap_to_flag, true); + if (em_cache == nullptr) { + return elem; } + + BMEditMesh *em = em_cache->em; + eSnapMode snap_mode_used = snap_to_flag & editmesh_snap_mode_supported(em->bm); + if (snap_mode_used & (SNAP_TO_EDGE_ELEMENTS | SCE_SNAP_TO_POINT)) { + elem = snapEditMesh(em_cache, sctx, ob_eval, em, obmat, snap_mode_used); + if (elem) { + return elem; + } + } + + if (snap_mode_used & SCE_SNAP_TO_FACE) { + if (raycastEditMesh(em_cache, sctx, ob_eval, em, obmat, sctx->runtime.object_index++)) { + return SCE_SNAP_TO_FACE; + } + } + + if (snap_mode_used & SCE_SNAP_INDIVIDUAL_NEAREST) { + if (nearest_world_editmesh(em_cache, sctx, ob_eval, em, obmat)) { + return SCE_SNAP_INDIVIDUAL_NEAREST; + } + } + return SCE_SNAP_TO_NONE; } diff --git a/source/blender/editors/transform/transform_snap_object_mesh.cc b/source/blender/editors/transform/transform_snap_object_mesh.cc index e91cbad5d83..2aa8bb84e19 100644 --- a/source/blender/editors/transform/transform_snap_object_mesh.cc +++ b/source/blender/editors/transform/transform_snap_object_mesh.cc @@ -10,7 +10,9 @@ #include "BLI_math_vector.h" #include "BKE_bvhutils.hh" +#include "BKE_editmesh.hh" #include "BKE_mesh.hh" +#include "BKE_object.hh" #include "ED_transform_snap_object_context.hh" @@ -106,12 +108,14 @@ static bool raycastMesh(SnapObjectContext *sctx, } /* Test bounding box */ - const Bounds bounds = *me_eval->bounds_min_max(); - /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */ - if (!isect_ray_aabb_v3_simple( - ray_start_local, ray_normal_local, bounds.min, bounds.max, &len_diff, nullptr)) - { - return retval; + if (ob_eval->data == me_eval) { + const Bounds bounds = *me_eval->bounds_min_max(); + /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */ + if (!isect_ray_aabb_v3_simple( + ray_start_local, ray_normal_local, bounds.min, bounds.max, &len_diff, nullptr)) + { + return retval; + } } /* We pass a temp ray_start, set from object's boundbox, to avoid precision issues with diff --git a/source/blender/editors/transform/transform_snap_sequencer.cc b/source/blender/editors/transform/transform_snap_sequencer.cc index ec3d19d0f23..e17caa7f2fe 100644 --- a/source/blender/editors/transform/transform_snap_sequencer.cc +++ b/source/blender/editors/transform/transform_snap_sequencer.cc @@ -10,6 +10,10 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" + +#include "BKE_context.hh" + #include "DNA_sequence_types.h" #include "ED_screen.hh" diff --git a/source/blender/editors/undo/ed_undo.cc b/source/blender/editors/undo/ed_undo.cc index 96725d9febe..a515081c2ad 100644 --- a/source/blender/editors/undo/ed_undo.cc +++ b/source/blender/editors/undo/ed_undo.cc @@ -18,17 +18,17 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_blender_undo.hh" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_paint.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_undo_system.hh" #include "BKE_workspace.h" diff --git a/source/blender/editors/undo/memfile_undo.cc b/source/blender/editors/undo/memfile_undo.cc index 8fd69c8c8b8..afb361ef731 100644 --- a/source/blender/editors/undo/memfile_undo.cc +++ b/source/blender/editors/undo/memfile_undo.cc @@ -23,11 +23,12 @@ #include "BKE_blender_undo.hh" #include "BKE_context.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_main.hh" #include "BKE_node.hh" #include "BKE_preview_image.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_undo_system.hh" #include "../depsgraph/DEG_depsgraph.hh" @@ -35,6 +36,7 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "ED_object.hh" #include "ED_render.hh" #include "ED_undo.hh" #include "ED_util.hh" diff --git a/source/blender/editors/undo/undo_system_types.cc b/source/blender/editors/undo/undo_system_types.cc index eadbc4f6d52..f7fa4a345cf 100644 --- a/source/blender/editors/undo/undo_system_types.cc +++ b/source/blender/editors/undo/undo_system_types.cc @@ -13,7 +13,6 @@ #include "ED_armature.hh" #include "ED_curve.hh" #include "ED_curves.hh" -#include "ED_grease_pencil.hh" #include "ED_lattice.hh" #include "ED_mball.hh" #include "ED_mesh.hh" @@ -38,7 +37,6 @@ void ED_undosys_type_init() BKE_undosys_type_append(ED_mball_undosys_type); BKE_undosys_type_append(ED_mesh_undosys_type); BKE_undosys_type_append(ED_curves_undosys_type); - BKE_undosys_type_append(ED_undosys_type_grease_pencil); /* Paint Modes */ BKE_UNDOSYS_TYPE_IMAGE = BKE_undosys_type_append(ED_image_undosys_type); diff --git a/source/blender/editors/util/ed_draw.cc b/source/blender/editors/util/ed_draw.cc index b0eea9fcfe8..3741ca4b122 100644 --- a/source/blender/editors/util/ed_draw.cc +++ b/source/blender/editors/util/ed_draw.cc @@ -13,11 +13,12 @@ #include "MEM_guardedalloc.h" #include "BLI_listbase.h" +#include "BLI_path_util.h" #include "BLI_rect.h" #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_image.h" @@ -38,6 +39,7 @@ #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "WM_api.hh" #include "WM_types.hh" diff --git a/source/blender/editors/util/ed_transverts.cc b/source/blender/editors/util/ed_transverts.cc index 22b98b3294f..98766ba5306 100644 --- a/source/blender/editors/util/ed_transverts.cc +++ b/source/blender/editors/util/ed_transverts.cc @@ -16,8 +16,10 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_blenlib.h" #include "BLI_utildefines.h" +#include "BKE_DerivedMesh.hh" #include "BKE_armature.hh" #include "BKE_context.hh" #include "BKE_curve.hh" diff --git a/source/blender/editors/util/ed_util.cc b/source/blender/editors/util/ed_util.cc index fda7b179db7..2e80002f0d9 100644 --- a/source/blender/editors/util/ed_util.cc +++ b/source/blender/editors/util/ed_util.cc @@ -16,10 +16,10 @@ #include "BLI_path_util.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" -#include "BKE_collection.hh" -#include "BKE_global.hh" +#include "BKE_collection.h" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_lib_remap.hh" @@ -464,9 +464,7 @@ void unpack_menu(bContext *C, UI_popup_menu_end(C, pup); } -void ED_spacedata_id_remap(ScrArea *area, - SpaceLink *sl, - const blender::bke::id::IDRemapper &mappings) +void ED_spacedata_id_remap(ScrArea *area, SpaceLink *sl, const IDRemapper *mappings) { SpaceType *st = BKE_spacetype_from_id(sl->spacetype); if (st && st->id_remap) { @@ -479,8 +477,9 @@ void ED_spacedata_id_remap_single(ScrArea *area, SpaceLink *sl, ID *old_id, ID * SpaceType *st = BKE_spacetype_from_id(sl->spacetype); if (st && st->id_remap) { - blender::bke::id::IDRemapper mappings; - mappings.add(old_id, new_id); + IDRemapper *mappings = BKE_id_remapper_create(); + BKE_id_remapper_add(mappings, old_id, new_id); st->id_remap(area, sl, mappings); + BKE_id_remapper_free(mappings); } } diff --git a/source/blender/editors/util/ed_util_imbuf.cc b/source/blender/editors/util/ed_util_imbuf.cc index 6466ee93ff0..ff93cc357ea 100644 --- a/source/blender/editors/util/ed_util_imbuf.cc +++ b/source/blender/editors/util/ed_util_imbuf.cc @@ -16,6 +16,8 @@ #include "BKE_colortools.hh" #include "BKE_context.hh" #include "BKE_image.h" +#include "BKE_main.hh" +#include "BKE_screen.hh" #include "ED_image.hh" #include "ED_screen.hh" diff --git a/source/blender/editors/util/ed_util_ops.cc b/source/blender/editors/util/ed_util_ops.cc index 374cf19d093..819ee591d7b 100644 --- a/source/blender/editors/util/ed_util_ops.cc +++ b/source/blender/editors/util/ed_util_ops.cc @@ -19,8 +19,11 @@ #include "BKE_context.hh" #include "BKE_lib_id.hh" #include "BKE_lib_override.hh" +#include "BKE_main.hh" #include "BKE_preview_image.hh" -#include "BKE_report.hh" +#include "BKE_report.h" + +#include "BLT_translation.h" #include "ED_asset.hh" #include "ED_render.hh" diff --git a/source/blender/editors/util/numinput.cc b/source/blender/editors/util/numinput.cc index 53d06bf1306..680137c38ff 100644 --- a/source/blender/editors/util/numinput.cc +++ b/source/blender/editors/util/numinput.cc @@ -15,11 +15,11 @@ #include "BLI_string_utf8.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_unit.hh" #include "DNA_scene_types.h" diff --git a/source/blender/editors/util/select_utils.cc b/source/blender/editors/util/select_utils.cc index 1cb3d6bdfdc..8871dd31fdd 100644 --- a/source/blender/editors/util/select_utils.cc +++ b/source/blender/editors/util/select_utils.cc @@ -13,7 +13,7 @@ #include "BLI_kdtree.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_windowmanager_types.h" diff --git a/source/blender/editors/uvedit/uvedit_buttons.cc b/source/blender/editors/uvedit/uvedit_buttons.cc index 4614386b189..16d499ba594 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.cc +++ b/source/blender/editors/uvedit/uvedit_buttons.cc @@ -20,7 +20,7 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_customdata.hh" diff --git a/source/blender/editors/uvedit/uvedit_clipboard.cc b/source/blender/editors/uvedit/uvedit_clipboard.cc index da58b67ade0..0bb9079b50a 100644 --- a/source/blender/editors/uvedit/uvedit_clipboard.cc +++ b/source/blender/editors/uvedit/uvedit_clipboard.cc @@ -23,17 +23,18 @@ #include "BKE_editmesh.hh" #include "BKE_layer.hh" #include "BKE_mesh_mapping.hh" /* UvElementMap */ -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "ED_mesh.hh" #include "ED_screen.hh" +#include "ED_uvedit.hh" /* Own include. */ #include "WM_api.hh" #include "uvedit_clipboard_graph_iso.hh" -#include "uvedit_intern.hh" /* Own include. */ +#include "uvedit_intern.hh" /* linker, extern "C" */ using blender::Vector; diff --git a/source/blender/editors/uvedit/uvedit_draw.cc b/source/blender/editors/uvedit/uvedit_draw.cc index f229f8a20e7..f2434376075 100644 --- a/source/blender/editors/uvedit/uvedit_draw.cc +++ b/source/blender/editors/uvedit/uvedit_draw.cc @@ -8,12 +8,14 @@ #include "BLI_utildefines.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_userdef_types.h" #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "UI_interface.hh" #include "UI_view2d.hh" #include "ED_uvedit.hh" diff --git a/source/blender/editors/uvedit/uvedit_ops.cc b/source/blender/editors/uvedit/uvedit_ops.cc index be8823ad04b..bc48af908f0 100644 --- a/source/blender/editors/uvedit/uvedit_ops.cc +++ b/source/blender/editors/uvedit/uvedit_ops.cc @@ -25,15 +25,16 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" +#include "BKE_main.hh" #include "BKE_material.h" #include "BKE_mesh_mapping.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/editors/uvedit/uvedit_path.cc b/source/blender/editors/uvedit/uvedit_path.cc index cfb031ee3f6..abc23a223f3 100644 --- a/source/blender/editors/uvedit/uvedit_path.cc +++ b/source/blender/editors/uvedit/uvedit_path.cc @@ -17,6 +17,7 @@ #include "MEM_guardedalloc.h" #include "BLI_ghash.h" +#include "BLI_linklist_stack.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" @@ -32,13 +33,14 @@ #include "BKE_editmesh.hh" #include "BKE_layer.hh" #include "BKE_mesh.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" #include "ED_object.hh" #include "ED_screen.hh" +#include "ED_transform.hh" #include "ED_uvedit.hh" #include "RNA_access.hh" diff --git a/source/blender/editors/uvedit/uvedit_rip.cc b/source/blender/editors/uvedit/uvedit_rip.cc index 4c57e4a53ac..a46330e2359 100644 --- a/source/blender/editors/uvedit/uvedit_rip.cc +++ b/source/blender/editors/uvedit/uvedit_rip.cc @@ -28,7 +28,7 @@ #include "BKE_customdata.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/uvedit/uvedit_select.cc b/source/blender/editors/uvedit/uvedit_select.cc index 20091ab5cd1..6bdf5f63741 100644 --- a/source/blender/editors/uvedit/uvedit_select.cc +++ b/source/blender/editors/uvedit/uvedit_select.cc @@ -34,7 +34,7 @@ #include "BLI_polyfill_2d_beautify.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_customdata.hh" @@ -43,7 +43,7 @@ #include "BKE_material.h" #include "BKE_mesh.hh" #include "BKE_mesh_mapping.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" @@ -4712,7 +4712,7 @@ static int uv_select_similar_vert_exec(bContext *C, wmOperator *op) const BMUVOffsets offsets = BM_uv_map_get_offsets(bm); float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world().ptr()); + copy_m3_m4(ob_m3, ob->object_to_world); BMFace *face; BMIter iter; @@ -4748,7 +4748,7 @@ static int uv_select_similar_vert_exec(bContext *C, wmOperator *op) const BMUVOffsets offsets = BM_uv_map_get_offsets(bm); float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world().ptr()); + copy_m3_m4(ob_m3, ob->object_to_world); BMFace *face; BMIter iter; @@ -4819,7 +4819,7 @@ static int uv_select_similar_edge_exec(bContext *C, wmOperator *op) const BMUVOffsets offsets = BM_uv_map_get_offsets(bm); float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world().ptr()); + copy_m3_m4(ob_m3, ob->object_to_world); BMFace *face; BMIter iter; @@ -4857,7 +4857,7 @@ static int uv_select_similar_edge_exec(bContext *C, wmOperator *op) bool changed = false; const BMUVOffsets offsets = BM_uv_map_get_offsets(bm); float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world().ptr()); + copy_m3_m4(ob_m3, ob->object_to_world); BMFace *face; BMIter iter; @@ -4919,7 +4919,7 @@ static int uv_select_similar_face_exec(bContext *C, wmOperator *op) BMesh *bm = em->bm; float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world().ptr()); + copy_m3_m4(ob_m3, ob->object_to_world); const BMUVOffsets offsets = BM_uv_map_get_offsets(bm); @@ -4954,7 +4954,7 @@ static int uv_select_similar_face_exec(bContext *C, wmOperator *op) const BMUVOffsets offsets = BM_uv_map_get_offsets(bm); float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world().ptr()); + copy_m3_m4(ob_m3, ob->object_to_world); BMFace *face; BMIter iter; @@ -5037,7 +5037,7 @@ static int uv_select_similar_island_exec(bContext *C, wmOperator *op) } float ob_m3[3][3]; - copy_m3_m4(ob_m3, obedit->object_to_world().ptr()); + copy_m3_m4(ob_m3, obedit->object_to_world); int index; LISTBASE_FOREACH_INDEX (FaceIsland *, island, &island_list_ptr[ob_index], index) { @@ -5066,7 +5066,7 @@ static int uv_select_similar_island_exec(bContext *C, wmOperator *op) continue; } float ob_m3[3][3]; - copy_m3_m4(ob_m3, obedit->object_to_world().ptr()); + copy_m3_m4(ob_m3, obedit->object_to_world); bool changed = false; int index; diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.cc b/source/blender/editors/uvedit/uvedit_smart_stitch.cc index 165eab2cb67..8b878022d36 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.cc +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.cc @@ -23,14 +23,14 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" #include "BKE_mesh_mapping.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.cc b/source/blender/editors/uvedit/uvedit_unwrap_ops.cc index ab4f26bd65a..bbc1ae44d9b 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.cc +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.cc @@ -12,13 +12,15 @@ #include "MEM_guardedalloc.h" +#include "DNA_camera_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_array.hh" +#include "BLI_convexhull_2d.h" #include "BLI_linklist.h" #include "BLI_listbase.h" #include "BLI_math_geom.h" @@ -32,7 +34,7 @@ #include "BLI_uvproject.h" #include "BLI_vector.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_customdata.hh" @@ -40,9 +42,11 @@ #include "BKE_image.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" +#include "BKE_main.hh" +#include "BKE_material.h" #include "BKE_mesh.hh" -#include "BKE_object_types.hh" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_subdiv.hh" #include "BKE_subdiv_mesh.hh" #include "BKE_subdiv_modifier.hh" @@ -54,6 +58,7 @@ #include "UI_interface.hh" #include "UI_resources.hh" +#include "UI_view2d.hh" #include "ED_image.hh" #include "ED_mesh.hh" @@ -794,7 +799,7 @@ static bool minimize_stretch_init(bContext *C, wmOperator *op) ms->iterations = RNA_int_get(op->ptr, "iterations"); ms->i = 0; ms->handle = construct_param_handle_multi(scene, objects, &options); - ms->lasttime = BLI_time_now_seconds(); + ms->lasttime = BLI_check_seconds_timer(); blender::geometry::uv_parametrizer_stretch_begin(ms->handle); if (ms->blend != 0.0f) { @@ -820,7 +825,7 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interac ms->i++; RNA_int_set(op->ptr, "iterations", ms->i); - if (interactive && (BLI_time_now_seconds() - ms->lasttime > 0.5)) { + if (interactive && (BLI_check_seconds_timer() - ms->lasttime > 0.5)) { char str[UI_MAX_DRAW_STR]; blender::geometry::uv_parametrizer_flush(ms->handle); @@ -831,7 +836,7 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interac ED_workspace_status_text(C, IFACE_("Press + and -, or scroll wheel to set blending")); } - ms->lasttime = BLI_time_now_seconds(); + ms->lasttime = BLI_check_seconds_timer(); for (Object *obedit : ms->objects_edit) { BMEditMesh *em = BKE_editmesh_from_object(obedit); @@ -956,11 +961,11 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, const wmEvent *ev break; case TIMER: if (ms->timer == event->customdata) { - double start = BLI_time_now_seconds(); + double start = BLI_check_seconds_timer(); do { minimize_stretch_iteration(C, op, true); - } while (BLI_time_now_seconds() - start < 0.01); + } while (BLI_check_seconds_timer() - start < 0.01); } break; } @@ -1932,8 +1937,8 @@ static void uv_map_transform_center(const Scene *scene, } case V3D_AROUND_CURSOR: /* cursor center */ { - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); - mul_v3_m4v3(r_center, ob->world_to_object().ptr(), scene->cursor.location); + invert_m4_m4(ob->world_to_object, ob->object_to_world); + mul_v3_m4v3(r_center, ob->world_to_object, scene->cursor.location); break; } case V3D_AROUND_ACTIVE: { @@ -1983,7 +1988,7 @@ static void uv_map_rotation_matrix_ex(float result[4][4], zero_v3(viewmatrix[3]); /* get rotation of the current object matrix */ - copy_m4_m4(rotobj, ob->object_to_world().ptr()); + copy_m4_m4(rotobj, ob->object_to_world); zero_v3(rotobj[3]); /* but shifting */ @@ -2474,7 +2479,7 @@ static int unwrap_exec(bContext *C, wmOperator *op) continue; } - mat4_to_size(obsize, obedit->object_to_world().ptr()); + mat4_to_size(obsize, obedit->object_to_world); if (!(fabsf(obsize[0] - obsize[1]) < 1e-4f && fabsf(obsize[1] - obsize[2]) < 1e-4f)) { if ((reported_errors & UNWRAP_ERROR_NONUNIFORM) == 0) { BKE_report(op->reports, @@ -2484,7 +2489,7 @@ static int unwrap_exec(bContext *C, wmOperator *op) reported_errors |= UNWRAP_ERROR_NONUNIFORM; } } - else if (is_negative_m4(obedit->object_to_world().ptr())) { + else if (is_negative_m4(obedit->object_to_world)) { if ((reported_errors & UNWRAP_ERROR_NEGATIVE) == 0) { BKE_report( op->reports, @@ -3051,7 +3056,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) float objects_pos_avg[4] = {0}; for (Object *object : objects) { - add_v4_v4(objects_pos_avg, object->object_to_world().location()); + add_v4_v4(objects_pos_avg, object->object_to_world[3]); } mul_v4_fl(objects_pos_avg, 1.0f / objects.size()); @@ -3090,7 +3095,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) const bool camera_bounds = RNA_boolean_get(op->ptr, "camera_bounds"); ProjCameraInfo *uci = BLI_uvproject_camera_info( v3d->camera, - obedit->object_to_world().ptr(), + obedit->object_to_world, camera_bounds ? (scene->r.xsch * scene->r.xasp) : 1.0f, camera_bounds ? (scene->r.ysch * scene->r.yasp) : 1.0f); @@ -3111,7 +3116,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) } } else { - copy_m4_m4(rotmat, obedit->object_to_world().ptr()); + copy_m4_m4(rotmat, obedit->object_to_world); BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) { diff --git a/source/blender/freestyle/intern/application/AppView.cpp b/source/blender/freestyle/intern/application/AppView.cpp index 4d44b127534..469be2aa964 100644 --- a/source/blender/freestyle/intern/application/AppView.cpp +++ b/source/blender/freestyle/intern/application/AppView.cpp @@ -28,7 +28,7 @@ #include "IMB_imbuf_types.hh" #if 1 // FRS_antialiasing -# include "BKE_global.hh" +# include "BKE_global.h" # include "DNA_scene_types.h" #endif diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp index a2c33a0a0e0..2e7fa97db02 100644 --- a/source/blender/freestyle/intern/application/Controller.cpp +++ b/source/blender/freestyle/intern/application/Controller.cpp @@ -49,7 +49,7 @@ extern "C" { #include "../blender_interface/BlenderStrokeRenderer.h" #include "../blender_interface/BlenderStyleModule.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_path_util.h" #include "BLI_utildefines.h" diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp index 6079d410619..3d784afa4d1 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp @@ -17,7 +17,7 @@ #include "BKE_attribute.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_mesh.hh" #include "BKE_object.hh" @@ -444,7 +444,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *mesh, int id) // Compute matrix including camera transform float obmat[4][4], nmat[4][4]; - mul_m4_m4m4(obmat, viewmat, ob->object_to_world().ptr()); + mul_m4_m4m4(obmat, viewmat, ob->object_to_world); invert_m4_m4(nmat, obmat); transpose_m4(nmat); diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h index e7f27d3fdc7..ac765a797a1 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.h @@ -35,7 +35,7 @@ #include "BKE_lib_id.hh" #include "BKE_material.h" #include "BKE_mesh.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BLI_iterator.h" #include "BLI_listbase.h" diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index 1bdf2f6a948..817bd4be4f5 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -29,9 +29,9 @@ #include "DNA_screen_types.h" #include "BKE_attribute.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" /* free_libblock */ @@ -41,7 +41,7 @@ #include "BKE_node.hh" #include "BKE_node_tree_update.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BLI_ghash.h" #include "BLI_listbase.h" diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 5f83a58eb53..4668e8334fc 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -28,16 +28,16 @@ using namespace Freestyle; #include "DNA_material_types.h" #include "DNA_text_types.h" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "BKE_context.hh" #include "BKE_freestyle.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_linestyle.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_text.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLI_blenlib.h" #include "BLI_math_color_blend.h" diff --git a/source/blender/freestyle/intern/geometry/FastGrid.cpp b/source/blender/freestyle/intern/geometry/FastGrid.cpp index 6af6350eb7e..8b783e6b01e 100644 --- a/source/blender/freestyle/intern/geometry/FastGrid.cpp +++ b/source/blender/freestyle/intern/geometry/FastGrid.cpp @@ -11,7 +11,7 @@ #include "FastGrid.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_utildefines.h" namespace Freestyle { diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp index 5b96eedf2b1..fc32ebba1b7 100644 --- a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp +++ b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp @@ -25,7 +25,7 @@ #include "../system/TimeUtils.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_sys_types.h" diff --git a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp index 5d4925addad..04d7354d469 100644 --- a/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp +++ b/source/blender/freestyle/intern/stroke/BasicStrokeShaders.cpp @@ -23,7 +23,7 @@ #include "../view_map/Functions0D.h" #include "../view_map/Functions1D.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_sys_types.h" diff --git a/source/blender/freestyle/intern/stroke/Canvas.cpp b/source/blender/freestyle/intern/stroke/Canvas.cpp index 1b52be3d683..eb4d086d6bd 100644 --- a/source/blender/freestyle/intern/stroke/Canvas.cpp +++ b/source/blender/freestyle/intern/stroke/Canvas.cpp @@ -26,7 +26,7 @@ #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" // soc #include // soc #include diff --git a/source/blender/freestyle/intern/stroke/Curve.cpp b/source/blender/freestyle/intern/stroke/Curve.cpp index 23c4190a9a4..1d7c6cc7417 100644 --- a/source/blender/freestyle/intern/stroke/Curve.cpp +++ b/source/blender/freestyle/intern/stroke/Curve.cpp @@ -13,7 +13,7 @@ #include "CurveAdvancedIterators.h" #include "CurveIterators.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_utildefines.h" namespace Freestyle { diff --git a/source/blender/freestyle/intern/stroke/Operators.cpp b/source/blender/freestyle/intern/stroke/Operators.cpp index 05409e5c1fa..5d6ddc2b19f 100644 --- a/source/blender/freestyle/intern/stroke/Operators.cpp +++ b/source/blender/freestyle/intern/stroke/Operators.cpp @@ -18,7 +18,7 @@ #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" namespace Freestyle { diff --git a/source/blender/freestyle/intern/stroke/Stroke.cpp b/source/blender/freestyle/intern/stroke/Stroke.cpp index 3bc0e2c32c7..ca628f5888f 100644 --- a/source/blender/freestyle/intern/stroke/Stroke.cpp +++ b/source/blender/freestyle/intern/stroke/Stroke.cpp @@ -12,7 +12,7 @@ #include "StrokeIterators.h" #include "StrokeRenderer.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_node.hh" namespace Freestyle { diff --git a/source/blender/freestyle/intern/stroke/StrokeRep.cpp b/source/blender/freestyle/intern/stroke/StrokeRep.cpp index 95b53e24cf2..613dda1a431 100644 --- a/source/blender/freestyle/intern/stroke/StrokeRep.cpp +++ b/source/blender/freestyle/intern/stroke/StrokeRep.cpp @@ -15,7 +15,7 @@ #include "StrokeRenderer.h" #include "StrokeRep.h" -#include "BKE_global.hh" +#include "BKE_global.h" using namespace std; diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h index 49d37f2bd30..129e959b084 100644 --- a/source/blender/freestyle/intern/system/PythonInterpreter.h +++ b/source/blender/freestyle/intern/system/PythonInterpreter.h @@ -14,7 +14,7 @@ #include "Interpreter.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_text.h" diff --git a/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp b/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp index b7e1ae77689..f5cad712490 100644 --- a/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp +++ b/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp @@ -11,7 +11,7 @@ #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" namespace Freestyle { diff --git a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp index 01a36e20422..362a9fb78f8 100644 --- a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp +++ b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp @@ -11,7 +11,7 @@ #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" namespace Freestyle { diff --git a/source/blender/freestyle/intern/view_map/BoxGrid.cpp b/source/blender/freestyle/intern/view_map/BoxGrid.cpp index e0c9a8ebd56..92e30012d5d 100644 --- a/source/blender/freestyle/intern/view_map/BoxGrid.cpp +++ b/source/blender/freestyle/intern/view_map/BoxGrid.cpp @@ -14,7 +14,7 @@ #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" using namespace std; diff --git a/source/blender/freestyle/intern/view_map/BoxGrid.h b/source/blender/freestyle/intern/view_map/BoxGrid.h index 852b740ddaf..69a57861522 100644 --- a/source/blender/freestyle/intern/view_map/BoxGrid.h +++ b/source/blender/freestyle/intern/view_map/BoxGrid.h @@ -29,7 +29,7 @@ #include "../winged_edge/WEdge.h" -#include "BKE_global.hh" +#include "BKE_global.h" #ifdef WITH_CXX_GUARDEDALLOC # include "MEM_guardedalloc.h" diff --git a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp index 65e1a1a7065..f9017f662a3 100644 --- a/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp +++ b/source/blender/freestyle/intern/view_map/CulledOccluderSource.cpp @@ -13,7 +13,7 @@ #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" namespace Freestyle { diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp index a232a33bd7e..9426815e396 100644 --- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp +++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp @@ -16,7 +16,7 @@ #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" namespace Freestyle { diff --git a/source/blender/freestyle/intern/view_map/Functions0D.cpp b/source/blender/freestyle/intern/view_map/Functions0D.cpp index ed0a89a0ac5..f89edd0c4a3 100644 --- a/source/blender/freestyle/intern/view_map/Functions0D.cpp +++ b/source/blender/freestyle/intern/view_map/Functions0D.cpp @@ -12,7 +12,7 @@ #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" using namespace std; diff --git a/source/blender/freestyle/intern/view_map/GridDensityProvider.h b/source/blender/freestyle/intern/view_map/GridDensityProvider.h index 84815906fd5..d979f286520 100644 --- a/source/blender/freestyle/intern/view_map/GridDensityProvider.h +++ b/source/blender/freestyle/intern/view_map/GridDensityProvider.h @@ -18,7 +18,7 @@ #include "../geometry/BBox.h" -#include "BKE_global.hh" +#include "BKE_global.h" #ifdef WITH_CXX_GUARDEDALLOC # include "MEM_guardedalloc.h" diff --git a/source/blender/freestyle/intern/view_map/OccluderSource.cpp b/source/blender/freestyle/intern/view_map/OccluderSource.cpp index a1d7a298322..8a9ad783536 100644 --- a/source/blender/freestyle/intern/view_map/OccluderSource.cpp +++ b/source/blender/freestyle/intern/view_map/OccluderSource.cpp @@ -13,7 +13,7 @@ #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" namespace Freestyle { diff --git a/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp b/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp index ae2c3ad97c4..be34056f934 100644 --- a/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp +++ b/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp @@ -11,7 +11,7 @@ #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" namespace Freestyle { diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp index 17218327ff8..8ae5d5be0d1 100644 --- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp +++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp @@ -18,7 +18,7 @@ #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" using namespace std; diff --git a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp index 13cd96884da..76c8a3d65c1 100644 --- a/source/blender/freestyle/intern/view_map/SphericalGrid.cpp +++ b/source/blender/freestyle/intern/view_map/SphericalGrid.cpp @@ -14,7 +14,7 @@ #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" using namespace std; diff --git a/source/blender/freestyle/intern/view_map/SphericalGrid.h b/source/blender/freestyle/intern/view_map/SphericalGrid.h index fc265066dfc..5ab4dd85f80 100644 --- a/source/blender/freestyle/intern/view_map/SphericalGrid.h +++ b/source/blender/freestyle/intern/view_map/SphericalGrid.h @@ -29,7 +29,7 @@ #include "../winged_edge/WEdge.h" -#include "BKE_global.hh" +#include "BKE_global.h" #ifdef WITH_CXX_GUARDEDALLOC # include "MEM_guardedalloc.h" diff --git a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp index a3a71fb74f0..67bf9f00ee4 100644 --- a/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp +++ b/source/blender/freestyle/intern/view_map/SteerableViewMap.cpp @@ -21,7 +21,7 @@ #include "BLI_math_base.h" #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp index c1c86ee42bb..1b09fe95a3d 100644 --- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp @@ -28,7 +28,7 @@ #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" namespace Freestyle { diff --git a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp index b0cbd6283ce..df064e5354c 100644 --- a/source/blender/freestyle/intern/winged_edge/WXEdge.cpp +++ b/source/blender/freestyle/intern/winged_edge/WXEdge.cpp @@ -11,7 +11,7 @@ #include "BLI_sys_types.h" -#include "BKE_global.hh" +#include "BKE_global.h" namespace Freestyle { diff --git a/source/blender/functions/intern/multi_function.cc b/source/blender/functions/intern/multi_function.cc index f7c50050b07..ccbe3cdf63e 100644 --- a/source/blender/functions/intern/multi_function.cc +++ b/source/blender/functions/intern/multi_function.cc @@ -152,11 +152,11 @@ void MultiFunction::call_auto(const IndexMask &mask, Params params, Context cont IndexMaskMemory memory; const int64_t offset = -input_slice_start; - const IndexMask shifted_mask = mask.slice_and_shift(sub_range, offset, memory); + const IndexMask offset_mask = mask.slice_and_offset(sub_range, offset, memory); - ParamsBuilder sliced_params{*this, &shifted_mask}; + ParamsBuilder sliced_params{*this, &offset_mask}; add_sliced_parameters(*signature_ref_, params, input_slice_range, sliced_params); - this->call(shifted_mask, sliced_params, context); + this->call(offset_mask, sliced_params, context); }); } diff --git a/source/blender/geometry/CMakeLists.txt b/source/blender/geometry/CMakeLists.txt index 068e5d43d91..1aa4d1d0afa 100644 --- a/source/blender/geometry/CMakeLists.txt +++ b/source/blender/geometry/CMakeLists.txt @@ -17,7 +17,6 @@ set(INC_SYS set(SRC intern/add_curves_on_mesh.cc intern/curve_constraints.cc - intern/extend_curves.cc intern/fillet_curves.cc intern/join_geometries.cc intern/mesh_copy_selection.cc @@ -50,7 +49,6 @@ set(SRC GEO_add_curves_on_mesh.hh GEO_curve_constraints.hh - GEO_extend_curves.hh GEO_fillet_curves.hh GEO_join_geometries.hh GEO_mesh_copy_selection.hh diff --git a/source/blender/geometry/GEO_extend_curves.hh b/source/blender/geometry/GEO_extend_curves.hh deleted file mode 100644 index 9c0917eab41..00000000000 --- a/source/blender/geometry/GEO_extend_curves.hh +++ /dev/null @@ -1,33 +0,0 @@ -/* SPDX-FileCopyrightText: 2023 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#pragma once - -#include "BLI_span.hh" -#include "DNA_node_types.h" - -#include "BKE_curves.hh" -#include "BKE_curves_utils.hh" -#include "BKE_geometry_set.hh" - -namespace blender::geometry { - -/* - * Extend curves from their end-points, selectively allow curvature from the original curve to - * influence extended segments. - */ -bke::CurvesGeometry extend_curves(bke::CurvesGeometry &src_curves, - const IndexMask &selection, - const VArray &start_lengths, - const VArray &end_lengths, - float overshoot_fac, - bool follow_curvature, - float point_density, - float segment_influence, - float max_angle, - bool invert_curvature, - GeometryNodeCurveSampleMode sample_mode, - const bke::AnonymousAttributePropagationInfo &propagation_info); - -} // namespace blender::geometry diff --git a/source/blender/geometry/GEO_set_curve_type.hh b/source/blender/geometry/GEO_set_curve_type.hh index eec5c584d3d..31ac22cde12 100644 --- a/source/blender/geometry/GEO_set_curve_type.hh +++ b/source/blender/geometry/GEO_set_curve_type.hh @@ -11,6 +11,19 @@ namespace blender::geometry { +/** + * Try the conversion to the #dst_type-- avoiding the majority of the work done in + * #convert_curves by modifying an existing object in place rather than creating a new one. + * + * \note This function is necessary because attributes do not have proper support for CoW. + * + * \param get_writable_curves_fn: Should return the write-able curves to change directly if + * possible. This is a function in order to avoid the cost of retrieval when unnecessary. + */ +bool try_curves_conversion_in_place(const IndexMask &selection, + CurveType dst_type, + FunctionRef get_writable_curves_fn); + /** * Change the types of the selected curves, potentially changing the total point count. */ diff --git a/source/blender/geometry/intern/extend_curves.cc b/source/blender/geometry/intern/extend_curves.cc deleted file mode 100644 index d856a0aa95e..00000000000 --- a/source/blender/geometry/intern/extend_curves.cc +++ /dev/null @@ -1,358 +0,0 @@ -/* SPDX-FileCopyrightText: 2023 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup bke - */ - -#include "BLI_array_utils.hh" -#include "BLI_length_parameterize.hh" -#include "BLI_math_axis_angle.hh" -#include "BLI_math_matrix.hh" -#include "BLI_math_quaternion.hh" -#include "BLI_math_rotation.hh" -#include "BLI_math_vector.hh" - -#include "BKE_attribute.hh" -#include "BKE_attribute_math.hh" -#include "BKE_curves.hh" -#include "BKE_curves_utils.hh" -#include "BKE_geometry_set.hh" - -#include "GEO_extend_curves.hh" - -namespace blender::geometry { - -static void extend_curves_straight(const float used_percent_length, - const float new_size, - const Span start_points, - const Span end_points, - const int curve, - const IndexRange new_curve, - const Span use_start_lengths, - const Span use_end_lengths, - MutableSpan positions) -{ - float overshoot_point_param = used_percent_length * (new_size - 1); - if (start_points[curve]) { - /** Here we use the vector between two adjacent points around #overshoot_point_param as - * our reference for the direction of extension, however to have better tolerance for jitter, - * using the vector (a_few_points_back - end_point) might be a better solution in the future. - */ - int index1 = math::floor(overshoot_point_param); - int index2 = math::ceil(overshoot_point_param); - - /* When #overshoot_point_param is zero */ - if (index2 == 0) { - index2 = 1; - } - float3 result = math::interpolate(positions[new_curve[index1]], - positions[new_curve[index2]], - fmodf(overshoot_point_param, 1.0f)); - result -= positions[new_curve.first()]; - if (UNLIKELY(math::is_zero(result))) { - result = positions[new_curve[1]] - positions[new_curve[0]]; - } - positions[new_curve[0]] += result * (-use_start_lengths[curve] / math::length(result)); - } - - if (end_points[curve]) { - int index1 = new_size - 1 - math::floor(overshoot_point_param); - int index2 = new_size - 1 - math::ceil(overshoot_point_param); - float3 result = math::interpolate(positions[new_curve[index1]], - positions[new_curve[index2]], - fmodf(overshoot_point_param, 1.0f)); - result -= positions[new_curve.last()]; - if (UNLIKELY(math::is_zero(result))) { - result = positions[new_curve[new_size - 2]] - positions[new_curve[new_size - 1]]; - } - positions[new_curve[new_size - 1]] += result * - (-use_end_lengths[curve] / math::length(result)); - } -} - -static void extend_curves_curved(const float used_percent_length, - const Span start_points, - const Span end_points, - const OffsetIndices points_by_curve, - const int curve, - const IndexRange new_curve, - const Span use_start_lengths, - const Span use_end_lengths, - const float max_angle, - const float segment_influence, - const bool invert_curvature, - MutableSpan positions) -{ - /* Curvature calculation. */ - const int first_old_index = start_points[curve] ? start_points[curve] : 0; - const int last_old_index = points_by_curve[curve].size() - 1 + first_old_index; - const int orig_totpoints = points_by_curve[curve].size(); - - /* The fractional amount of points to query when calculating the average curvature of the - * strokes. */ - const float overshoot_parameter = used_percent_length * (orig_totpoints - 2); - int overshoot_pointcount = math::ceil(overshoot_parameter); - overshoot_pointcount = math::clamp(overshoot_pointcount, 1, orig_totpoints - 2); - - /* Do for both sides without code duplication. */ - float3 vec1, total_angle; - for (int k = 0; k < 2; k++) { - if ((k == 0 && !start_points[curve]) || (k == 1 && !end_points[curve])) { - continue; - } - - const int start_i = k == 0 ? first_old_index : last_old_index; - const int dir_i = 1 - k * 2; - - vec1 = positions[new_curve[start_i + dir_i]] - positions[new_curve[start_i]]; - total_angle = float3({0, 0, 0}); - - float segment_length; - vec1 = math::normalize_and_get_length(vec1, segment_length); - - float overshoot_length = 0.0f; - - /* Accumulate rotation angle and length. */ - int j = 0; - float3 no, vec2; - for (int i = start_i; j < overshoot_pointcount; i += dir_i, j++) { - /* Don't fully add last segment to get continuity in overshoot_fac. */ - float fac = math::min(overshoot_parameter - j, 1.0f); - - /* Read segments. */ - vec2 = vec1; - vec1 = positions[new_curve[i + dir_i * 2]] - positions[new_curve[i + dir_i]]; - - float len; - vec1 = math::normalize_and_get_length(vec1, len); - float angle = math::angle_between(vec1, vec2).radian() * fac; - - /* Add half of both adjacent legs of the current angle. */ - const float added_len = (segment_length + len) * 0.5f * fac; - overshoot_length += added_len; - segment_length = len; - - if (angle > max_angle) { - continue; - } - if (angle > M_PI * 0.995f) { - continue; - } - - angle *= math::pow(added_len, segment_influence); - - no = math::cross(vec1, vec2); - no = math::normalize(no) * angle; - total_angle += no; - } - - if (UNLIKELY(overshoot_length == 0.0f)) { - /* Don't do a proper extension if the used points are all in the same position. */ - continue; - } - - vec1 = positions[new_curve[start_i]] - positions[new_curve[start_i + dir_i]]; - /* In general curvature = 1/radius. For the case without the - * weights introduced by #segment_influence, the calculation is: - * `curvature = delta angle/delta arclength = len_v3(total_angle) / overshoot_length` */ - float curvature = normalize_v3(total_angle) / overshoot_length; - /* Compensate for the weights powf(added_len, segment_influence). */ - curvature /= math::pow(overshoot_length / math::min(overshoot_parameter, float(j)), - segment_influence); - if (invert_curvature) { - curvature = -curvature; - } - const float dist = k == 0 ? use_start_lengths[curve] : use_end_lengths[curve]; - const int extra_point_count = k == 0 ? start_points[curve] : end_points[curve]; - const float angle_step = curvature * dist / extra_point_count; - float step_length = dist / extra_point_count; - if (math::abs(angle_step) > FLT_EPSILON) { - /* Make a direct step length from the assigned arc step length. */ - step_length *= sin(angle_step * 0.5f) / (angle_step * 0.5f); - } - else { - total_angle = float3({0, 0, 0}); - } - float prev_length; - vec1 = math::normalize_and_get_length(vec1, prev_length); - vec1 *= step_length; - - /* Build rotation matrix here to get best performance. */ - math::AxisAngle axis_base(total_angle, angle_step); - math::Quaternion q = math::to_quaternion(axis_base); - float3x3 rot = math::from_rotation(q); - - /* Rotate the starting direction to account for change in edge lengths. */ - math::AxisAngle step_base(total_angle, - math::max(0.0f, 1.0f - math::abs(segment_influence)) * - (curvature * prev_length - angle_step) / 2.0f); - q = math::to_quaternion(step_base); - vec1 = math::transform_point(q, vec1); - - /* Now iteratively accumulate the segments with a rotating added direction. */ - for (int i = start_i - dir_i, j = 0; j < extra_point_count; i -= dir_i, j++) { - vec1 = rot * vec1; - positions[new_curve[i]] = vec1 + positions[new_curve[i + dir_i]]; - } - } -} - -bke::CurvesGeometry extend_curves(bke::CurvesGeometry &src_curves, - const IndexMask &selection, - const VArray &start_lengths, - const VArray &end_lengths, - const float overshoot_fac, - const bool follow_curvature, - const float point_density, - const float segment_influence, - const float max_angle, - const bool invert_curvature, - const GeometryNodeCurveSampleMode sample_mode, - const bke::AnonymousAttributePropagationInfo &propagation_info) -{ - if (src_curves.points_num() < 2) { - return src_curves; - } - - const int src_curves_num = src_curves.curves_num(); - Array start_points(src_curves_num); - Array end_points(src_curves_num); - Array use_start_lengths(src_curves_num); - Array use_end_lengths(src_curves_num); - - const OffsetIndices points_by_curve = src_curves.points_by_curve(); - - src_curves.ensure_evaluated_lengths(); - selection.foreach_index([&](const int curve) { - use_start_lengths[curve] = start_lengths[curve]; - use_end_lengths[curve] = end_lengths[curve]; - if (sample_mode == GEO_NODE_CURVE_SAMPLE_FACTOR) { - float total_length = src_curves.evaluated_length_total_for_curve(curve, false); - use_start_lengths[curve] *= total_length; - use_end_lengths[curve] *= total_length; - start_points[curve] = 1; - end_points[curve] = 1; - } - }); - - bke::CurvesGeometry dst_curves; - - /* Use the old curves when extending straight when no new points are added. */ - if (!follow_curvature) { - dst_curves = std::move(src_curves); - } - else { - /* Copy only curves domain since we are not changing the number of curves here. */ - dst_curves = bke::curves::copy_only_curve_domain(src_curves); - /* Count how many points we need. */ - MutableSpan dst_points_by_curve = dst_curves.offsets_for_write(); - selection.foreach_index([&](const int curve) { - int point_count = points_by_curve[curve].size(); - dst_points_by_curve[curve] = point_count; - /* Curve not suitable for stretching... */ - if (point_count <= 2) { - return; - } - - const int count_start = (use_start_lengths[curve] > 0) ? - (math::ceil(use_start_lengths[curve] * point_density)) : - 0; - const int count_end = (use_end_lengths[curve] > 0) ? - (math::ceil(use_end_lengths[curve] * point_density)) : - 0; - dst_points_by_curve[curve] += count_start; - dst_points_by_curve[curve] += count_end; - start_points[curve] = count_start; - end_points[curve] = count_end; - }); - - OffsetIndices dst_indices = offset_indices::accumulate_counts_to_offsets(dst_points_by_curve); - int target_point_count = dst_points_by_curve.last(); - - /* Make destination to source map for points. */ - Array dst_to_src_point(target_point_count); - for (const int curve : src_curves.curves_range()) { - const int point_count = points_by_curve[curve].size(); - int local_front = 0; - MutableSpan new_points_by_curve = dst_to_src_point.as_mutable_span().slice( - dst_indices[curve]); - if (start_points[curve]) { - MutableSpan starts = new_points_by_curve.slice(0, start_points[curve]); - starts.fill(points_by_curve[curve].first()); - local_front = start_points[curve]; - } - if (end_points[curve]) { - MutableSpan ends = new_points_by_curve.slice( - new_points_by_curve.size() - end_points[curve], end_points[curve]); - ends.fill(points_by_curve[curve].last()); - } - MutableSpan original_points = new_points_by_curve.slice(local_front, point_count); - for (const int point_i : original_points.index_range()) { - original_points[point_i] = points_by_curve[curve][point_i]; - } - } - - dst_curves.resize(target_point_count, src_curves_num); - - const bke::AttributeAccessor src_attributes = src_curves.attributes(); - bke::MutableAttributeAccessor dst_attributes = dst_curves.attributes_for_write(); - - /* Transfer point attributes. */ - gather_attributes(src_attributes, - bke::AttrDomain::Point, - propagation_info, - {}, - dst_to_src_point, - dst_attributes); - } - - MutableSpan positions = dst_curves.positions_for_write(); - - const OffsetIndices new_points_by_curve = dst_curves.points_by_curve(); - threading::parallel_for(dst_curves.curves_range(), 512, [&](const IndexRange curves_range) { - for (const int curve : curves_range) { - if (!start_points[curve] && !end_points[curve]) { - /* Curves should not be touched if they didn't generate extra points before. */ - return; - } - const IndexRange new_curve = new_points_by_curve[curve]; - int new_size = new_curve.size(); - - /* #used_percent_length must always be finite and non-zero. */ - const float used_percent_length = math::clamp( - isfinite(overshoot_fac) ? overshoot_fac : 0.1f, 1e-4f, 1.0f); - - if (!follow_curvature) { - extend_curves_straight(used_percent_length, - new_size, - start_points.as_span(), - end_points.as_span(), - curve, - new_curve, - use_start_lengths.as_span(), - use_end_lengths.as_span(), - positions); - } - else { - extend_curves_curved(used_percent_length, - start_points.as_span(), - end_points.as_span(), - points_by_curve, - curve, - new_curve, - use_start_lengths.as_span(), - use_end_lengths.as_span(), - max_angle, - segment_influence, - invert_curvature, - positions); - } - } - }); - - return dst_curves; -} - -} // namespace blender::geometry diff --git a/source/blender/geometry/intern/fillet_curves.cc b/source/blender/geometry/intern/fillet_curves.cc index fe40ab7e5a2..0066e57a6a4 100644 --- a/source/blender/geometry/intern/fillet_curves.cc +++ b/source/blender/geometry/intern/fillet_curves.cc @@ -5,7 +5,9 @@ #include "BKE_attribute_math.hh" #include "BKE_curves.hh" #include "BKE_curves_utils.hh" +#include "BKE_geometry_set.hh" +#include "BLI_math_geom.h" #include "BLI_math_rotation_legacy.hh" #include "BLI_task.hh" diff --git a/source/blender/geometry/intern/mesh_copy_selection.cc b/source/blender/geometry/intern/mesh_copy_selection.cc index af34d97f90c..c35f898a562 100644 --- a/source/blender/geometry/intern/mesh_copy_selection.cc +++ b/source/blender/geometry/intern/mesh_copy_selection.cc @@ -70,6 +70,25 @@ static void remap_edges(const OffsetIndices src_faces, }); } +/** Create a mesh with no built-in attributes. */ +static Mesh *create_mesh_no_attributes(const Mesh ¶ms_mesh, + const int verts_num, + const int edges_num, + const int faces_num, + const int corners_num) +{ + Mesh *mesh = BKE_mesh_new_nomain(0, 0, faces_num, 0); + mesh->verts_num = verts_num; + mesh->edges_num = edges_num; + mesh->corners_num = corners_num; + CustomData_free_layer_named(&mesh->vert_data, "position", 0); + CustomData_free_layer_named(&mesh->edge_data, ".edge_verts", 0); + CustomData_free_layer_named(&mesh->corner_data, ".corner_vert", 0); + CustomData_free_layer_named(&mesh->corner_data, ".corner_edge", 0); + BKE_mesh_copy_parameters_for_eval(mesh, ¶ms_mesh); + return mesh; +} + static void copy_loose_vert_hint(const Mesh &src, Mesh &dst) { const auto &src_cache = src.runtime->loose_verts_cache; @@ -199,9 +218,8 @@ std::optional mesh_copy_selection( return std::nullopt; } - Mesh *dst_mesh = bke::mesh_new_no_attributes( - vert_mask.size(), edge_mask.size(), face_mask.size(), 0); - BKE_mesh_copy_parameters_for_eval(dst_mesh, &src_mesh); + Mesh *dst_mesh = create_mesh_no_attributes( + src_mesh, vert_mask.size(), edge_mask.size(), face_mask.size(), 0); bke::MutableAttributeAccessor dst_attributes = dst_mesh->attributes_for_write(); dst_attributes.add(".edge_verts", bke::AttrDomain::Edge, bke::AttributeInitConstruct()); MutableSpan dst_edges = dst_mesh->edges_for_write(); @@ -333,9 +351,8 @@ std::optional mesh_copy_selection_keep_verts( return std::nullopt; } - Mesh *dst_mesh = bke::mesh_new_no_attributes( - src_mesh.verts_num, edge_mask.size(), face_mask.size(), 0); - BKE_mesh_copy_parameters_for_eval(dst_mesh, &src_mesh); + Mesh *dst_mesh = create_mesh_no_attributes( + src_mesh, src_mesh.verts_num, edge_mask.size(), face_mask.size(), 0); bke::MutableAttributeAccessor dst_attributes = dst_mesh->attributes_for_write(); const OffsetIndices dst_faces = offset_indices::gather_selected_offsets( @@ -426,9 +443,8 @@ std::optional mesh_copy_selection_keep_edges( return std::nullopt; } - Mesh *dst_mesh = bke::mesh_new_no_attributes( - src_mesh.verts_num, src_mesh.edges_num, face_mask.size(), 0); - BKE_mesh_copy_parameters_for_eval(dst_mesh, &src_mesh); + Mesh *dst_mesh = create_mesh_no_attributes( + src_mesh, src_mesh.verts_num, src_mesh.edges_num, face_mask.size(), 0); bke::MutableAttributeAccessor dst_attributes = dst_mesh->attributes_for_write(); const OffsetIndices dst_faces = offset_indices::gather_selected_offsets( diff --git a/source/blender/geometry/intern/mesh_merge_by_distance.cc b/source/blender/geometry/intern/mesh_merge_by_distance.cc index 161bfc09631..bb581b50f04 100644 --- a/source/blender/geometry/intern/mesh_merge_by_distance.cc +++ b/source/blender/geometry/intern/mesh_merge_by_distance.cc @@ -10,6 +10,7 @@ #include "BLI_index_mask.hh" #include "BLI_kdtree.h" #include "BLI_math_vector.h" +#include "BLI_math_vector.hh" #include "BLI_offset_indices.hh" #include "BLI_vector.hh" diff --git a/source/blender/geometry/intern/mesh_primitive_uv_sphere.cc b/source/blender/geometry/intern/mesh_primitive_uv_sphere.cc index 97401b77a51..edaaeb085d4 100644 --- a/source/blender/geometry/intern/mesh_primitive_uv_sphere.cc +++ b/source/blender/geometry/intern/mesh_primitive_uv_sphere.cc @@ -2,6 +2,8 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BLI_math_vector.hh" + #include "BKE_attribute.hh" #include "BKE_mesh.hh" diff --git a/source/blender/geometry/intern/mesh_to_curve_convert.cc b/source/blender/geometry/intern/mesh_to_curve_convert.cc index 4994bb6d791..b0bf1beb047 100644 --- a/source/blender/geometry/intern/mesh_to_curve_convert.cc +++ b/source/blender/geometry/intern/mesh_to_curve_convert.cc @@ -10,6 +10,7 @@ #include "BKE_attribute.hh" #include "BKE_attribute_math.hh" #include "BKE_curves.hh" +#include "BKE_geometry_set.hh" #include "BKE_mesh.hh" #include "GEO_mesh_to_curve.hh" diff --git a/source/blender/geometry/intern/mesh_to_volume.cc b/source/blender/geometry/intern/mesh_to_volume.cc index e1cddc547ea..cf137d347b3 100644 --- a/source/blender/geometry/intern/mesh_to_volume.cc +++ b/source/blender/geometry/intern/mesh_to_volume.cc @@ -6,6 +6,7 @@ #include "BLI_task.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_volume.hh" #include "BKE_volume_openvdb.hh" diff --git a/source/blender/geometry/intern/point_merge_by_distance.cc b/source/blender/geometry/intern/point_merge_by_distance.cc index 955ce52e120..85fa4b6c5de 100644 --- a/source/blender/geometry/intern/point_merge_by_distance.cc +++ b/source/blender/geometry/intern/point_merge_by_distance.cc @@ -10,6 +10,7 @@ #include "DNA_pointcloud_types.h" #include "BKE_attribute_math.hh" +#include "BKE_geometry_set.hh" #include "BKE_pointcloud.hh" #include "GEO_point_merge_by_distance.hh" diff --git a/source/blender/geometry/intern/randomize.cc b/source/blender/geometry/intern/randomize.cc index 6b5d85cb47b..77a516b806c 100644 --- a/source/blender/geometry/intern/randomize.cc +++ b/source/blender/geometry/intern/randomize.cc @@ -17,8 +17,9 @@ #include "BKE_curves.hh" #include "BKE_customdata.hh" #include "BKE_geometry_set.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_instances.hh" +#include "BKE_mesh.hh" #include "BLI_array.hh" diff --git a/source/blender/geometry/intern/realize_instances.cc b/source/blender/geometry/intern/realize_instances.cc index ca060082ef9..5b1fda25c57 100644 --- a/source/blender/geometry/intern/realize_instances.cc +++ b/source/blender/geometry/intern/realize_instances.cc @@ -15,7 +15,7 @@ #include "BLI_noise.hh" #include "BLI_task.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_curves.hh" #include "BKE_customdata.hh" #include "BKE_geometry_set_instances.hh" @@ -470,7 +470,8 @@ static void foreach_geometry_in_reference( int index = 0; FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (&collection, object) { const bke::GeometrySet object_geometry = bke::object_get_evaluated_geometry_set(*object); - const float4x4 matrix = base_transform * offset_matrix * object->object_to_world(); + const float4x4 matrix = base_transform * offset_matrix * + float4x4_view(object->object_to_world); const int sub_id = noise::hash(id, index); fn(object_geometry, matrix, sub_id); index++; diff --git a/source/blender/geometry/intern/reverse_uv_sampler.cc b/source/blender/geometry/intern/reverse_uv_sampler.cc index 23a6521239b..fe1bb93d77c 100644 --- a/source/blender/geometry/intern/reverse_uv_sampler.cc +++ b/source/blender/geometry/intern/reverse_uv_sampler.cc @@ -9,6 +9,7 @@ #include "BLI_math_geom.h" #include "BLI_math_vector.hh" #include "BLI_task.hh" +#include "BLI_timeit.hh" namespace blender::geometry { diff --git a/source/blender/geometry/intern/set_curve_type.cc b/source/blender/geometry/intern/set_curve_type.cc index 0ff551af276..499e66be2a8 100644 --- a/source/blender/geometry/intern/set_curve_type.cc +++ b/source/blender/geometry/intern/set_curve_type.cc @@ -28,6 +28,21 @@ static bool is_nurbs_to_bezier_one_to_one(const KnotsMode knots_mode) return false; } +/** + * As an optimization, just change the types on a mutable curves data-block when the conversion is + * simple. This could be expanded to more cases where the number of points doesn't change in the + * future, though that might require properly initializing some attributes, or removing others. + */ +static bool conversion_can_change_point_num(const CurveType dst_type) +{ + if (ELEM(dst_type, CURVE_TYPE_CATMULL_ROM, CURVE_TYPE_POLY)) { + /* The conversion to Catmull Rom or Poly should never change the number of points, no matter + * the source type (Bezier to Catmull Rom conversion cannot maintain the same shape anyway). */ + return false; + } + return true; +} + template static void scale_input_assign(const Span src, const int scale, @@ -647,4 +662,17 @@ bke::CurvesGeometry convert_curves(const bke::CurvesGeometry &src_curves, return {}; } +bool try_curves_conversion_in_place(const IndexMask &selection, + const CurveType dst_type, + FunctionRef get_writable_curves_fn) +{ + if (conversion_can_change_point_num(dst_type)) { + return false; + } + bke::CurvesGeometry &curves = get_writable_curves_fn(); + curves.fill_curve_types(selection, dst_type); + curves.remove_attributes_based_on_types(); + return true; +} + } // namespace blender::geometry diff --git a/source/blender/geometry/intern/subdivide_curves.cc b/source/blender/geometry/intern/subdivide_curves.cc index a4fb2c85db4..4d7854a94f6 100644 --- a/source/blender/geometry/intern/subdivide_curves.cc +++ b/source/blender/geometry/intern/subdivide_curves.cc @@ -5,6 +5,7 @@ #include "BKE_attribute_math.hh" #include "BKE_curves.hh" #include "BKE_curves_utils.hh" +#include "BKE_geometry_set.hh" #include "BLI_task.hh" diff --git a/source/blender/geometry/intern/transform.cc b/source/blender/geometry/intern/transform.cc index 1a4a1d2a41a..6eab95c7f05 100644 --- a/source/blender/geometry/intern/transform.cc +++ b/source/blender/geometry/intern/transform.cc @@ -10,12 +10,14 @@ #include "BLI_math_base.h" #include "BLI_math_matrix.h" +#include "BLI_math_rotation.hh" #include "BLI_math_vector.hh" #include "BLI_task.hh" #include "DNA_grease_pencil_types.h" #include "DNA_mesh_types.h" #include "DNA_pointcloud_types.h" +#include "DNA_volume_types.h" #include "BKE_attribute.hh" #include "BKE_curves.hh" diff --git a/source/blender/geometry/intern/trim_curves.cc b/source/blender/geometry/intern/trim_curves.cc index 5ff2e3b66d3..5a08fcb472a 100644 --- a/source/blender/geometry/intern/trim_curves.cc +++ b/source/blender/geometry/intern/trim_curves.cc @@ -13,6 +13,7 @@ #include "BKE_attribute_math.hh" #include "BKE_curves.hh" #include "BKE_curves_utils.hh" +#include "BKE_geometry_set.hh" #include "GEO_trim_curves.hh" diff --git a/source/blender/geometry/intern/uv_pack.cc b/source/blender/geometry/intern/uv_pack.cc index 39c6c895e75..90db9cccec4 100644 --- a/source/blender/geometry/intern/uv_pack.cc +++ b/source/blender/geometry/intern/uv_pack.cc @@ -8,7 +8,7 @@ #include "GEO_uv_pack.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_array.hh" #include "BLI_bounds.hh" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_armature.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_armature.cc index bbff7261ae7..02da264654d 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_armature.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_armature.cc @@ -8,24 +8,30 @@ #include +#include "BLI_listbase.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BKE_armature.hh" +#include "BKE_context.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "MEM_guardedalloc.h" @@ -34,10 +40,13 @@ #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" +#include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" +#include "DEG_depsgraph_query.hh" static void init_data(GpencilModifierData *md) { diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.cc index 06937979d59..d8429e6aa6a 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.cc @@ -18,7 +18,7 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" @@ -27,11 +27,15 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" +#include "BKE_object.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -42,6 +46,7 @@ #include "DEG_depsgraph_build.hh" #include "DEG_depsgraph_query.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" @@ -102,9 +107,9 @@ static void BKE_gpencil_instance_modifier_instance_tfm(Object *ob, if (mmd->flag & GP_ARRAY_USE_OFFSET) { add_v3_v3(mat_offset[3], mmd->offset); } - invert_m4_m4(obinv, ob->object_to_world().ptr()); + invert_m4_m4(obinv, ob->object_to_world); - mul_m4_series(r_offset, mat_offset, obinv, mmd->object->object_to_world().ptr()); + mul_m4_series(r_offset, mat_offset, obinv, mmd->object->object_to_world); copy_m4_m4(mat_offset, r_offset); /* clear r_mat locations to avoid double transform */ diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.cc index 797059210e4..4a09bf67fce 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.cc @@ -17,9 +17,10 @@ #include "BLI_math_base.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" +#include "BLI_sort.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" @@ -29,12 +30,14 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -44,6 +47,7 @@ #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" /* Two hard-coded values for GP_BUILD_MODE_ADDITIVE with GP_BUILD_TIMEMODE_DRAWSPEED. */ @@ -318,8 +322,8 @@ static void build_sequential(Object *ob, /* Compute distance to control object if set, and build according to that order. */ if (mmd->object) { float sv1[3], sv2[3]; - mul_v3_m4v3(sv1, ob->object_to_world().ptr(), &gps->points[0].x); - mul_v3_m4v3(sv2, ob->object_to_world().ptr(), &gps->points[gps->totpoints - 1].x); + mul_v3_m4v3(sv1, ob->object_to_world, &gps->points[0].x); + mul_v3_m4v3(sv2, ob->object_to_world, &gps->points[gps->totpoints - 1].x); float dist_l = len_v3v3(sv1, mmd->object->loc); float dist_r = len_v3v3(sv2, mmd->object->loc); if (dist_r < dist_l) { diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_color.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_color.cc index d7ebeadd35e..627f5cb452b 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_color.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_color.cc @@ -13,24 +13,31 @@ #include "BLI_math_color.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_material_types.h" +#include "DNA_object_types.h" #include "DNA_screen_types.h" #include "BKE_colortools.hh" +#include "BKE_context.hh" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_material.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" #include "BKE_modifier.hh" +#include "DEG_depsgraph.hh" + +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.cc index 9fa593cfa19..ba838550d5f 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.cc @@ -20,12 +20,14 @@ #include "DNA_gpencil_modifier_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" #include "BKE_screen.hh" @@ -37,8 +39,9 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_envelope.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_envelope.cc index 768231a6154..4dd62f7a50e 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_envelope.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_envelope.cc @@ -13,21 +13,24 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" @@ -38,6 +41,7 @@ #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.cc index 582c9cd6b72..42527f0dd08 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.cc @@ -9,12 +9,13 @@ #include #include +#include "BLI_listbase.h" #include "BLI_math_base.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" @@ -22,26 +23,33 @@ #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BKE_action.h" #include "BKE_colortools.hh" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" -#include "BKE_object_types.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" +#include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" +#include "DEG_depsgraph_query.hh" /* temp struct to hold data */ struct GPHookData_cb { @@ -228,14 +236,14 @@ static void deform_stroke(GpencilModifierData *md, /* get world-space matrix of target, corrected for the space the verts are in */ if (mmd->subtarget[0] && pchan) { /* bone target if there's a matching pose-channel */ - mul_m4_m4m4(dmat, mmd->object->object_to_world().ptr(), pchan->pose_mat); + mul_m4_m4m4(dmat, mmd->object->object_to_world, pchan->pose_mat); } else { /* just object target */ - copy_m4_m4(dmat, mmd->object->object_to_world().ptr()); + copy_m4_m4(dmat, mmd->object->object_to_world); } - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); - mul_m4_series(tData.mat, ob->world_to_object().ptr(), dmat, mmd->parentinv); + invert_m4_m4(ob->world_to_object, ob->object_to_world); + mul_m4_series(tData.mat, ob->world_to_object, dmat, mmd->parentinv); /* loop points and apply deform */ for (int i = 0; i < gps->totpoints; i++) { diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lattice.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lattice.cc index 22ace359dd6..b32410ce77b 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lattice.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lattice.cc @@ -12,7 +12,7 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" @@ -22,19 +22,23 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lattice.hh" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_length.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_length.cc index fa4dd23e062..228a6eb2b27 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_length.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_length.cc @@ -15,18 +15,22 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "MEM_guardedalloc.h" @@ -35,6 +39,7 @@ #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lineart.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lineart.cc index e26ef771d86..9b2afd8b0d0 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lineart.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_lineart.cc @@ -11,21 +11,25 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_collection_types.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_gpencil_modifier_types.h" +#include "DNA_material_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" -#include "BKE_collection.hh" -#include "BKE_global.hh" +#include "BKE_collection.h" +#include "BKE_context.hh" +#include "BKE_global.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" +#include "BKE_main.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -37,6 +41,7 @@ #include "DEG_depsgraph_query.hh" #include "MOD_gpencil_legacy_lineart.h" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "lineart/MOD_lineart.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.cc index bd4ce1bb6e1..c098563acb6 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.cc @@ -14,7 +14,7 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" @@ -23,16 +23,20 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" @@ -79,8 +83,8 @@ static void update_mirror_object(Object *ob, float tmp[4][4]; float itmp[4][4]; - invert_m4_m4(tmp, mmd->object->object_to_world().ptr()); - mul_m4_m4m4(tmp, tmp, ob->object_to_world().ptr()); + invert_m4_m4(tmp, mmd->object->object_to_world); + mul_m4_m4m4(tmp, tmp, ob->object_to_world); invert_m4_m4(itmp, tmp); mul_m4_series(mtx, itmp, mtx, tmp); diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.cc index d254a430922..68dce29d405 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.cc @@ -14,6 +14,7 @@ #include "DNA_gpencil_legacy_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BLI_listbase.h" @@ -21,13 +22,16 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "BKE_context.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" @@ -38,6 +42,7 @@ #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" @@ -106,7 +111,7 @@ static void duplicateStroke(Object *ob, float opacity_factor; /* Apply object scale to offset distance. */ - offset *= mat4_to_scale(ob->object_to_world().ptr()); + offset *= mat4_to_scale(ob->object_to_world); BKE_gpencil_stroke_normal(gps, stroke_normal); if (len_v3(stroke_normal) < FLT_EPSILON) { diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_noise.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_noise.cc index 5af7b61129b..b9e8f9c920d 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_noise.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_noise.cc @@ -13,7 +13,7 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "MEM_guardedalloc.h" @@ -25,12 +25,14 @@ #include "DNA_screen_types.h" #include "BKE_colortools.hh" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" @@ -40,6 +42,7 @@ #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_offset.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_offset.cc index fcec8dd4014..1d2042926a4 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_offset.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_offset.cc @@ -15,7 +15,7 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLI_hash.h" #include "BLI_rand.h" @@ -27,17 +27,22 @@ #include "DNA_screen_types.h" #include "RNA_access.hh" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" +#include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" +#include "DEG_depsgraph_query.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_opacity.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_opacity.cc index d32fd085b7a..cca736909a0 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_opacity.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_opacity.cc @@ -11,25 +11,32 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_meshdata_types.h" +#include "DNA_object_types.h" #include "DNA_screen_types.h" #include "BKE_colortools.hh" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" + +#include "DEG_depsgraph.hh" #include "UI_interface.hh" #include "UI_resources.hh" #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.cc index 93e35fcb068..36c4a20046d 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.cc @@ -14,7 +14,7 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" @@ -29,8 +29,10 @@ #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_material.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -40,6 +42,7 @@ #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" @@ -116,7 +119,7 @@ static void convert_stroke(GpencilModifierData *md, /* Apply layer thickness change. */ gps_duplicate->thickness += gpl->line_change; /* Apply object scale to thickness. */ - gps_duplicate->thickness *= mat4_to_scale(ob->object_to_world().ptr()); + gps_duplicate->thickness *= mat4_to_scale(ob->object_to_world); CLAMP_MIN(gps_duplicate->thickness, 1.0f); /* Stroke. */ @@ -197,7 +200,7 @@ static void generate_strokes(GpencilModifierData *md, Depsgraph *depsgraph, Obje } Object *cam_ob = scene->camera; float viewmat[4][4]; - invert_m4_m4(viewmat, cam_ob->object_to_world().ptr()); + invert_m4_m4(viewmat, cam_ob->object_to_world); LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { bGPDframe *gpf = BKE_gpencil_frame_retime_get(depsgraph, scene, ob, gpl); @@ -240,7 +243,7 @@ static void bake_modifier(Main * /*bmain*/, BKE_scene_graph_update_for_newframe(depsgraph); /* Ensure the camera is the right one. */ BKE_scene_camera_switch_update(scene); - invert_m4_m4(viewmat, cam_ob->object_to_world().ptr()); + invert_m4_m4(viewmat, cam_ob->object_to_world); /* Prepare transform matrix. */ float diff_mat[4][4]; diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_shrinkwrap.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_shrinkwrap.cc index 6406abad46a..9c46653871d 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_shrinkwrap.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_shrinkwrap.cc @@ -13,21 +13,25 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_gpencil_modifier_types.h" +#include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "BKE_shrinkwrap.hh" #include "MEM_guardedalloc.h" @@ -37,6 +41,7 @@ #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_simplify.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_simplify.cc index f4916a71494..4bbbef53e98 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_simplify.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_simplify.cc @@ -9,25 +9,32 @@ #include #include /* For #MEMCPY_STRUCT_AFTER. */ +#include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" +#include "DNA_gpencil_legacy_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" + +#include "DEG_depsgraph.hh" #include "UI_interface.hh" #include "UI_resources.hh" #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_smooth.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_smooth.cc index 42b4ab9e66f..eb1ec9b19c9 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_smooth.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_smooth.cc @@ -9,28 +9,35 @@ #include #include /* For #MEMCPY_STRUCT_AFTER. */ +#include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_meshdata_types.h" +#include "DNA_object_types.h" #include "DNA_screen_types.h" #include "BKE_colortools.hh" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" + +#include "DEG_depsgraph.hh" #include "UI_interface.hh" #include "UI_resources.hh" #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_subdiv.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_subdiv.cc index c4434b5a94f..e9dc918ba09 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_subdiv.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_subdiv.cc @@ -9,9 +9,10 @@ #include #include /* For #MEMCPY_STRUCT_AFTER. */ +#include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" @@ -19,14 +20,19 @@ #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" + +#include "DEG_depsgraph.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_texture.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_texture.cc index cecbbde39a0..b4d1f3cdcdf 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_texture.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_texture.cc @@ -8,10 +8,11 @@ #include +#include "BLI_listbase.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" @@ -20,17 +21,22 @@ #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" + +#include "DEG_depsgraph.hh" #include "UI_interface.hh" #include "UI_resources.hh" #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_thick.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_thick.cc index b1bee2bf888..1364df79618 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_thick.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_thick.cc @@ -8,28 +8,35 @@ #include +#include "BLI_listbase.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_meshdata_types.h" +#include "DNA_object_types.h" #include "DNA_screen_types.h" #include "BKE_colortools.hh" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" + +#include "DEG_depsgraph.hh" #include "UI_interface.hh" #include "UI_resources.hh" #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.cc index 99a1981126c..ca279e47f56 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.cc @@ -12,34 +12,43 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" #include "BLI_string.h" #include "BLI_string_utf8.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" #include "DNA_gpencil_modifier_types.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BKE_context.hh" +#include "BKE_gpencil_geom_legacy.h" +#include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_modifier.hh" #include "BKE_screen.hh" #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" +#include "MOD_gpencil_legacy_util.h" #include "UI_interface.hh" #include "UI_resources.hh" #include "WM_api.hh" +#include "DEG_depsgraph.hh" + static void init_data(GpencilModifierData *md) { TimeGpencilModifierData *gpmd = (TimeGpencilModifierData *)md; diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.cc index 01e8c34b164..2008041c873 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.cc @@ -10,10 +10,11 @@ #include "BLI_utildefines.h" +#include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" @@ -22,15 +23,20 @@ #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BKE_colorband.hh" #include "BKE_colortools.hh" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" +#include "BKE_main.hh" #include "BKE_material.h" #include "BKE_modifier.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "MEM_guardedalloc.h" @@ -39,9 +45,11 @@ #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" +#include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" static void init_data(GpencilModifierData *md) @@ -139,7 +147,7 @@ static void deform_stroke(GpencilModifierData *md, float coba_res[4]; float matrix[4][4]; if (is_gradient) { - mul_m4_m4m4(matrix, mmd->object->world_to_object().ptr(), ob->object_to_world().ptr()); + mul_m4_m4m4(matrix, mmd->object->world_to_object, ob->object_to_world); } /* loop points and apply color. */ diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_ui_common.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_ui_common.cc index eefa9af5084..8e62ec57a98 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_ui_common.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_ui_common.cc @@ -16,12 +16,13 @@ #include "BKE_material.h" #include "BKE_screen.hh" +#include "DNA_material_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" #include "ED_object.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_util.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_util.cc index b926cfd0fd3..96684c09866 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_util.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_util.cc @@ -9,6 +9,7 @@ #include #include "BLI_listbase.h" +#include "BLI_math_vector.h" #include "BLI_utildefines.h" #include "DNA_gpencil_legacy_types.h" @@ -21,7 +22,7 @@ #include "BKE_deform.hh" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_material.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_util.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.cc index 3de6bed8ef6..561f5b5fa47 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.cc @@ -8,11 +8,12 @@ #include +#include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" @@ -21,17 +22,23 @@ #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" + +#include "DEG_depsgraph.hh" +#include "DEG_depsgraph_build.hh" #include "UI_interface.hh" #include "UI_resources.hh" #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" @@ -93,7 +100,7 @@ static void deform_stroke(GpencilModifierData *md, /* Apply the rotation of the object. */ if (mmd->space == GP_SPACE_LOCAL) { - mul_mat3_m4_v3(ob->object_to_world().ptr(), vec_ref); + mul_mat3_m4_v3(ob->object_to_world, vec_ref); } /* Ensure there is a vertex group. */ @@ -118,8 +125,8 @@ static void deform_stroke(GpencilModifierData *md, bGPDspoint *pt1 = (i > 0) ? &gps->points[i] : &gps->points[i + 1]; bGPDspoint *pt2 = (i > 0) ? &gps->points[i - 1] : &gps->points[i]; float fpt1[3], fpt2[3]; - mul_v3_m4v3(fpt1, ob->object_to_world().ptr(), &pt1->x); - mul_v3_m4v3(fpt2, ob->object_to_world().ptr(), &pt2->x); + mul_v3_m4v3(fpt1, ob->object_to_world, &pt1->x); + mul_v3_m4v3(fpt2, ob->object_to_world, &pt2->x); float vec[3]; sub_v3_v3v3(vec, fpt1, fpt2); diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.cc index 4e5ad0db6d1..99841464447 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.cc @@ -8,11 +8,12 @@ #include +#include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_gpencil_legacy_types.h" @@ -21,12 +22,15 @@ #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" +#include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" #include "UI_interface.hh" @@ -34,6 +38,7 @@ #include "RNA_access.hh" +#include "MOD_gpencil_legacy_modifiertypes.h" #include "MOD_gpencil_legacy_ui_common.h" #include "MOD_gpencil_legacy_util.h" @@ -60,8 +65,8 @@ static float calc_point_weight_by_distance(Object *ob, { float weight; float gvert[3]; - mul_v3_m4v3(gvert, ob->object_to_world().ptr(), &pt->x); - float dist = len_v3v3(mmd->object->object_to_world().location(), gvert); + mul_v3_m4v3(gvert, ob->object_to_world, &pt->x); + float dist = len_v3v3(mmd->object->object_to_world[3], gvert); if (dist > dist_max) { weight = 1.0f; diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_chain.cc b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_chain.cc index 2d119fe4edb..7028b7bf092 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_chain.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_chain.cc @@ -6,6 +6,7 @@ * \ingroup editors */ +#include "BLI_linklist.h" #include "BLI_listbase.h" #include "BLI_math_geom.h" diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc index 0ca6294fac6..26ed3fdd067 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc @@ -11,6 +11,7 @@ #include "MOD_gpencil_legacy_lineart.h" #include "MOD_lineart.h" +#include "BLI_linklist.h" #include "BLI_listbase.h" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" @@ -23,18 +24,23 @@ #include "BKE_attribute.hh" #include "BKE_camera.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_customdata.hh" #include "BKE_deform.hh" -#include "BKE_global.hh" +#include "BKE_duplilist.h" +#include "BKE_editmesh.hh" +#include "BKE_global.h" #include "BKE_gpencil_geom_legacy.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_id.hh" #include "BKE_material.h" #include "BKE_mesh.hh" +#include "BKE_mesh_mapping.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_pointcache.h" +#include "BKE_scene.h" #include "DEG_depsgraph_query.hh" @@ -44,6 +50,7 @@ #include "DNA_light_types.h" #include "DNA_material_types.h" #include "DNA_meshdata_types.h" +#include "DNA_modifier_types.h" #include "DNA_scene_types.h" #include "MEM_guardedalloc.h" @@ -2454,7 +2461,7 @@ static void lineart_object_load_single_instance(LineartData *ld, Scene *scene, Object *ob, Object *ref_ob, - const float use_mat[4][4], + float use_mat[4][4], bool is_render, LineartObjectLoadTaskInfo *olti, int thread_count, @@ -2566,7 +2573,7 @@ void lineart_main_load_geometries(Depsgraph *depsgraph, double t_start; if (G.debug_value == 4000) { - t_start = BLI_time_now_seconds(); + t_start = BLI_check_seconds_timer(); } int thread_count = ld->thread_count; @@ -2616,7 +2623,7 @@ void lineart_main_load_geometries(Depsgraph *depsgraph, scene, eval_ob, eval_ob, - eval_ob->object_to_world().ptr(), + eval_ob->object_to_world, is_render, olti, thread_count, @@ -2676,7 +2683,7 @@ void lineart_main_load_geometries(Depsgraph *depsgraph, } if (G.debug_value == 4000) { - double t_elapsed = BLI_time_now_seconds() - t_start; + double t_elapsed = BLI_check_seconds_timer() - t_start; printf("Line art loading time: %lf\n", t_elapsed); printf("Discarded %d object from bound box check\n", bound_box_discard_count); } @@ -3592,11 +3599,11 @@ static LineartData *lineart_create_render_buffer(Scene *scene, clipping_offset = 0.0001; } - copy_v3db_v3fl(ld->conf.camera_pos, camera->object_to_world().location()); + copy_v3db_v3fl(ld->conf.camera_pos, camera->object_to_world[3]); if (active_camera) { - copy_v3db_v3fl(ld->conf.active_camera_pos, active_camera->object_to_world().location()); + copy_v3db_v3fl(ld->conf.active_camera_pos, active_camera->object_to_world[3]); } - copy_m4_m4(ld->conf.cam_obmat, camera->object_to_world().ptr()); + copy_m4_m4(ld->conf.cam_obmat, camera->object_to_world); /* Make sure none of the scaling factor makes in, line art expects no scaling on cameras and * lights. */ normalize_v3(ld->conf.cam_obmat[0]); @@ -3628,8 +3635,8 @@ static LineartData *lineart_create_render_buffer(Scene *scene, if (lmd->light_contour_object) { Object *light_obj = lmd->light_contour_object; - copy_v3db_v3fl(ld->conf.camera_pos_secondary, light_obj->object_to_world().location()); - copy_m4_m4(ld->conf.cam_obmat_secondary, light_obj->object_to_world().ptr()); + copy_v3db_v3fl(ld->conf.camera_pos_secondary, light_obj->object_to_world[3]); + copy_m4_m4(ld->conf.cam_obmat_secondary, light_obj->object_to_world); /* Make sure none of the scaling factor makes in, line art expects no scaling on cameras and * lights. */ normalize_v3(ld->conf.cam_obmat_secondary[0]); @@ -4711,7 +4718,7 @@ void lineart_main_add_triangles(LineartData *ld) { double t_start; if (G.debug_value == 4000) { - t_start = BLI_time_now_seconds(); + t_start = BLI_check_seconds_timer(); } /* Initialize per-thread data for thread task scheduling information and storing intersection @@ -4734,7 +4741,7 @@ void lineart_main_add_triangles(LineartData *ld) lineart_destroy_isec_thread(&d); if (G.debug_value == 4000) { - double t_elapsed = BLI_time_now_seconds() - t_start; + double t_elapsed = BLI_check_seconds_timer() - t_start; printf("Line art intersection time: %f\n", t_elapsed); } } @@ -5001,7 +5008,7 @@ bool MOD_lineart_compute_feature_lines(Depsgraph *depsgraph, double t_start; if (G.debug_value == 4000) { - t_start = BLI_time_now_seconds(); + t_start = BLI_check_seconds_timer(); } bool use_render_camera_override = false; @@ -5175,7 +5182,7 @@ bool MOD_lineart_compute_feature_lines(Depsgraph *depsgraph, if (G.debug_value == 4000) { lineart_count_and_print_render_buffer_memory(ld); - double t_elapsed = BLI_time_now_seconds() - t_start; + double t_elapsed = BLI_check_seconds_timer() - t_start; printf("Line art total time: %lf\n", t_elapsed); } @@ -5458,7 +5465,7 @@ void MOD_lineart_gpencil_generate(LineartCache *cache, } float gp_obmat_inverse[4][4]; - invert_m4_m4(gp_obmat_inverse, ob->object_to_world().ptr()); + invert_m4_m4(gp_obmat_inverse, ob->object_to_world); lineart_gpencil_generate(cache, depsgraph, ob, diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_ops.cc b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_ops.cc index 2084450ee66..b421fe3c233 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_ops.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_ops.cc @@ -14,11 +14,11 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_legacy.h" #include "BKE_gpencil_modifier_legacy.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.cc b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.cc index e2700dffc98..5f170840f4b 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.cc @@ -11,16 +11,26 @@ #include "lineart_intern.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_modifier_legacy.h" +#include "BKE_lib_id.hh" +#include "BKE_material.h" #include "BKE_object.hh" +#include "BKE_scene.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" #include "BLI_task.h" #include "BLI_time.h" +#include "DEG_depsgraph_query.hh" + +#include "DNA_collection_types.h" +#include "DNA_gpencil_legacy_types.h" #include "DNA_light_types.h" +#include "DNA_material_types.h" +#include "DNA_modifier_types.h" +#include "DNA_scene_types.h" #include "MEM_guardedalloc.h" @@ -1141,7 +1151,7 @@ bool lineart_main_try_generate_shadow(Depsgraph *depsgraph, double t_start; if (G.debug_value == 4000) { - t_start = BLI_time_now_seconds(); + t_start = BLI_check_seconds_timer(); } bool is_persp = true; @@ -1175,7 +1185,7 @@ bool lineart_main_try_generate_shadow(Depsgraph *depsgraph, copy_v3_v3_db(ld->conf.camera_pos_secondary, ld->conf.camera_pos); copy_m4_m4(ld->conf.cam_obmat_secondary, ld->conf.cam_obmat); - copy_m4_m4(ld->conf.cam_obmat, lmd->light_contour_object->object_to_world().ptr()); + copy_m4_m4(ld->conf.cam_obmat, lmd->light_contour_object->object_to_world); copy_v3db_v3fl(ld->conf.camera_pos, ld->conf.cam_obmat[3]); ld->conf.cam_is_persp_secondary = ld->conf.cam_is_persp; ld->conf.cam_is_persp = is_persp; @@ -1273,7 +1283,7 @@ bool lineart_main_try_generate_shadow(Depsgraph *depsgraph, } if (G.debug_value == 4000) { - double t_elapsed = BLI_time_now_seconds() - t_start; + double t_elapsed = BLI_check_seconds_timer() - t_start; printf("Line art shadow stage 1 time: %f\n", t_elapsed); } @@ -1357,7 +1367,7 @@ void lineart_main_make_enclosed_shapes(LineartData *ld, LineartData *shadow_ld) { double t_start; if (G.debug_value == 4000) { - t_start = BLI_time_now_seconds(); + t_start = BLI_check_seconds_timer(); } if (shadow_ld || ld->conf.shadow_use_silhouette) { @@ -1368,7 +1378,7 @@ void lineart_main_make_enclosed_shapes(LineartData *ld, LineartData *shadow_ld) } if (G.debug_value == 4000) { - double t_elapsed = BLI_time_now_seconds() - t_start; + double t_elapsed = BLI_check_seconds_timer() - t_start; printf("Line art shadow stage 2 cast and silhouette time: %f\n", t_elapsed); } @@ -1417,7 +1427,7 @@ void lineart_main_make_enclosed_shapes(LineartData *ld, LineartData *shadow_ld) lineart_shadow_register_enclosed_shapes(ld, shadow_ld); if (G.debug_value == 4000) { - double t_elapsed = BLI_time_now_seconds() - t_start; + double t_elapsed = BLI_check_seconds_timer() - t_start; printf("Line art shadow stage 2 total time: %f\n", t_elapsed); } } diff --git a/source/blender/gpu/GPU_material.hh b/source/blender/gpu/GPU_material.hh index c4451cef48b..e0d1d5ed169 100644 --- a/source/blender/gpu/GPU_material.hh +++ b/source/blender/gpu/GPU_material.hh @@ -8,8 +8,6 @@ #pragma once -#include - #include "DNA_customdata_types.h" /* for eCustomDataType */ #include "DNA_image_types.h" #include "DNA_listBase.h" @@ -132,14 +130,14 @@ enum eGPUDefaultValue { }; struct GPUCodegenOutput { - std::string attr_load; + char *attr_load; /* Node-tree functions calls. */ - std::string displacement; - std::string surface; - std::string volume; - std::string thickness; - std::string composite; - std::string material_functions; + char *displacement; + char *surface; + char *volume; + char *thickness; + char *composite; + char *material_functions; GPUShaderCreateInfo *create_info; }; diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 556513c25fa..1498542a084 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -333,13 +333,13 @@ typedef enum { int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin); /** - * Compile all statically defined shaders and print a report to the console. + * Compile all staticly defined shaders and print a report to the console. * * This is used for platform support, where bug reports can list all failing shaders. */ void GPU_shader_compile_static(); -/** DEPRECATED: Use hard-coded buffer location instead. */ +/** DEPRECATED: Use hardcoded buffer location instead. */ typedef enum { GPU_UNIFORM_BLOCK_VIEW = 0, /* viewBlock */ GPU_UNIFORM_BLOCK_MODEL, /* modelBlock */ @@ -353,7 +353,7 @@ typedef enum { GPU_NUM_UNIFORM_BLOCKS, /* Special value, denotes number of builtin uniforms block. */ } GPUUniformBlockBuiltin; -/** DEPRECATED: Use hard-coded buffer location instead. */ +/** DEPRECATED: Use hardcoded buffer location instead. */ int GPU_shader_get_builtin_block(GPUShader *shader, int builtin); /** DEPRECATED: Kept only because of Python GPU API. */ diff --git a/source/blender/gpu/GPU_storage_buffer.h b/source/blender/gpu/GPU_storage_buffer.h index 2f29333e45d..e9f6084b1cf 100644 --- a/source/blender/gpu/GPU_storage_buffer.h +++ b/source/blender/gpu/GPU_storage_buffer.h @@ -63,8 +63,9 @@ void GPU_storagebuf_sync_to_host(GPUStorageBuf *ssbo); * If pending GPU updates to the storage buffer are not yet visible to the host, the command will * stall until dependent GPU work has completed. * - * Otherwise, this command is synchronized against this call and will stall the CPU until the - * buffer content can be read by the host. + * Otherwise, this command is unsynchronized and will return current visible storage buffer + * contents immediately. + * Alternatively, use appropriate barrier or GPU_finish before reading. */ void GPU_storagebuf_read(GPUStorageBuf *ssbo, void *data); diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc index 8d0f1f5dd7d..0e386888ac0 100644 --- a/source/blender/gpu/intern/gpu_codegen.cc +++ b/source/blender/gpu/intern/gpu_codegen.cc @@ -288,6 +288,13 @@ class GPUCodegen { ~GPUCodegen() { + MEM_SAFE_FREE(output.attr_load); + MEM_SAFE_FREE(output.surface); + MEM_SAFE_FREE(output.volume); + MEM_SAFE_FREE(output.thickness); + MEM_SAFE_FREE(output.displacement); + MEM_SAFE_FREE(output.composite); + MEM_SAFE_FREE(output.material_functions); MEM_SAFE_FREE(cryptomatte_input_); delete create_info; BLI_freelistN(&ubo_inputs_); @@ -320,16 +327,22 @@ class GPUCodegen { void set_unique_ids(); void node_serialize(std::stringstream &eval_ss, const GPUNode *node); - std::string graph_serialize(eGPUNodeTag tree_tag, - GPUNodeLink *output_link, - const char *output_default = nullptr); - std::string graph_serialize(eGPUNodeTag tree_tag); + char *graph_serialize(eGPUNodeTag tree_tag, + GPUNodeLink *output_link, + const char *output_default = nullptr); + char *graph_serialize(eGPUNodeTag tree_tag); + + static char *extract_c_str(std::stringstream &stream) + { + auto string = stream.str(); + return BLI_strdup(string.c_str()); + } }; void GPUCodegen::generate_attribs() { if (BLI_listbase_is_empty(&graph.attributes)) { - output.attr_load.clear(); + output.attr_load = nullptr; return; } @@ -384,7 +397,7 @@ void GPUCodegen::generate_attribs() iface.smooth(to_type(iface_type), var_name); } - output.attr_load = load_ss.str(); + output.attr_load = extract_c_str(load_ss); } void GPUCodegen::generate_resources() @@ -571,12 +584,12 @@ void GPUCodegen::node_serialize(std::stringstream &eval_ss, const GPUNode *node) nodes_total_++; } -std::string GPUCodegen::graph_serialize(eGPUNodeTag tree_tag, - GPUNodeLink *output_link, - const char *output_default) +char *GPUCodegen::graph_serialize(eGPUNodeTag tree_tag, + GPUNodeLink *output_link, + const char *output_default) { if (output_link == nullptr && output_default == nullptr) { - return ""; + return nullptr; } std::stringstream eval_ss; @@ -592,7 +605,7 @@ std::string GPUCodegen::graph_serialize(eGPUNodeTag tree_tag, } if (!has_nodes) { - return ""; + return nullptr; } if (output_link) { @@ -603,12 +616,12 @@ std::string GPUCodegen::graph_serialize(eGPUNodeTag tree_tag, eval_ss << "return " << output_default << ";\n"; } - std::string str = eval_ss.str(); - BLI_hash_mm2a_add(&hm2a_, reinterpret_cast(str.c_str()), str.size()); - return str; + char *eval_c_str = extract_c_str(eval_ss); + BLI_hash_mm2a_add(&hm2a_, (uchar *)eval_c_str, eval_ss.str().size()); + return eval_c_str; } -std::string GPUCodegen::graph_serialize(eGPUNodeTag tree_tag) +char *GPUCodegen::graph_serialize(eGPUNodeTag tree_tag) { std::stringstream eval_ss; LISTBASE_FOREACH (GPUNode *, node, &graph.nodes) { @@ -616,9 +629,9 @@ std::string GPUCodegen::graph_serialize(eGPUNodeTag tree_tag) node_serialize(eval_ss, node); } } - std::string str = eval_ss.str(); - BLI_hash_mm2a_add(&hm2a_, reinterpret_cast(str.c_str()), str.size()); - return str; + char *eval_c_str = extract_c_str(eval_ss); + BLI_hash_mm2a_add(&hm2a_, (uchar *)eval_c_str, eval_ss.str().size()); + return eval_c_str; } void GPUCodegen::generate_cryptomatte() @@ -695,10 +708,11 @@ void GPUCodegen::generate_graphs() } /* Tag only the nodes needed for the current function */ gpu_nodes_tag(func_link->outlink, GPU_NODE_TAG_FUNCTION); - const std::string fn = graph_serialize(GPU_NODE_TAG_FUNCTION, func_link->outlink); + char *fn = graph_serialize(GPU_NODE_TAG_FUNCTION, func_link->outlink); eval_ss << "float " << func_link->name << "() {\n" << fn << "}\n\n"; + MEM_SAFE_FREE(fn); } - output.material_functions = eval_ss.str(); + output.material_functions = extract_c_str(eval_ss); /* Leave the function tags as they were before serialization */ LISTBASE_FOREACH (GPUNodeGraphFunctionLink *, funclink, &graph.material_functions) { gpu_nodes_tag(funclink->outlink, GPU_NODE_TAG_FUNCTION); @@ -938,7 +952,7 @@ void GPU_pass_release(GPUPass *pass) void GPU_pass_cache_garbage_collect() { const int shadercollectrate = 60; /* hardcoded for now. */ - int ctime = int(BLI_time_now_seconds()); + int ctime = int(BLI_check_seconds_timer()); BLI_spin_lock(&pass_cache_spin); GPUPass *next, **prev_pass = &pass_cache; diff --git a/source/blender/gpu/intern/gpu_debug.cc b/source/blender/gpu/intern/gpu_debug.cc index 5c2d25b292e..af565358bae 100644 --- a/source/blender/gpu/intern/gpu_debug.cc +++ b/source/blender/gpu/intern/gpu_debug.cc @@ -8,7 +8,7 @@ * Debug features of OpenGL. */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_string.h" diff --git a/source/blender/gpu/intern/gpu_debug_private.hh b/source/blender/gpu/intern/gpu_debug_private.hh index 76d8bd17941..231ccab0002 100644 --- a/source/blender/gpu/intern/gpu_debug_private.hh +++ b/source/blender/gpu/intern/gpu_debug_private.hh @@ -15,6 +15,6 @@ namespace blender::gpu { -using DebugStack = Vector; +typedef Vector DebugStack; } // namespace blender::gpu diff --git a/source/blender/gpu/intern/gpu_framebuffer_private.hh b/source/blender/gpu/intern/gpu_framebuffer_private.hh index 0fcad169308..f15c6c8cd81 100644 --- a/source/blender/gpu/intern/gpu_framebuffer_private.hh +++ b/source/blender/gpu/intern/gpu_framebuffer_private.hh @@ -19,7 +19,7 @@ struct GPUTexture; -enum GPUAttachmentType : int { +typedef enum GPUAttachmentType : int { GPU_FB_DEPTH_ATTACHMENT = 0, GPU_FB_DEPTH_STENCIL_ATTACHMENT, GPU_FB_COLOR_ATTACHMENT0, @@ -35,7 +35,7 @@ enum GPUAttachmentType : int { * the maximum number of COLOR attachments specified by glDrawBuffers. */ GPU_FB_MAX_ATTACHMENT, -}; +} GPUAttachmentType; #define GPU_FB_MAX_COLOR_ATTACHMENT (GPU_FB_MAX_ATTACHMENT - GPU_FB_COLOR_ATTACHMENT0) diff --git a/source/blender/gpu/intern/gpu_material.cc b/source/blender/gpu/intern/gpu_material.cc index db68f7c20c1..559dadfdfa2 100644 --- a/source/blender/gpu/intern/gpu_material.cc +++ b/source/blender/gpu/intern/gpu_material.cc @@ -26,7 +26,7 @@ #include "BKE_main.hh" #include "BKE_material.h" -#include "BKE_node.hh" +#include "BKE_node.h" #include "NOD_shader.h" @@ -747,7 +747,7 @@ void GPU_material_optimization_status_set(GPUMaterial *mat, eGPUMaterialOptimiza mat->optimization_status = status; if (mat->optimization_status == GPU_MAT_OPTIMIZATION_READY) { /* Reset creation timer to delay optimization pass. */ - mat->creation_time = BLI_time_now_seconds(); + mat->creation_time = BLI_check_seconds_timer(); } } @@ -761,7 +761,7 @@ bool GPU_material_optimization_ready(GPUMaterial *mat) * to do this quickly to avoid build-up and improve runtime performance. * The threshold just prevents compilations being queued frame after frame. */ const double optimization_time_threshold_s = 1.2; - return ((BLI_time_now_seconds() - mat->creation_time) >= optimization_time_threshold_s); + return ((BLI_check_seconds_timer() - mat->creation_time) >= optimization_time_threshold_s); } void GPU_material_set_default(GPUMaterial *material, GPUMaterial *default_material) diff --git a/source/blender/gpu/intern/gpu_select_pick.cc b/source/blender/gpu/intern/gpu_select_pick.cc index 8fe7b7649d2..ebe3ce3930f 100644 --- a/source/blender/gpu/intern/gpu_select_pick.cc +++ b/source/blender/gpu/intern/gpu_select_pick.cc @@ -25,7 +25,7 @@ #include "gpu_select_private.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* #define DEBUG_PRINT */ diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc index 837b4a8cedf..eefba01fe27 100644 --- a/source/blender/gpu/intern/gpu_shader.cc +++ b/source/blender/gpu/intern/gpu_shader.cc @@ -577,26 +577,29 @@ void GPU_shader_constant_int_ex(GPUShader *sh, int location, int value) { Shader &shader = *unwrap(sh); BLI_assert(shader.constants.types[location] == gpu::shader::Type::INT); - shader.constants.is_dirty |= assign_if_different(shader.constants.values[location].i, value); + shader.constants.values[location].i = value; + shader.constants.is_dirty = true; } void GPU_shader_constant_uint_ex(GPUShader *sh, int location, uint value) { Shader &shader = *unwrap(sh); BLI_assert(shader.constants.types[location] == gpu::shader::Type::UINT); - shader.constants.is_dirty |= assign_if_different(shader.constants.values[location].u, value); + shader.constants.values[location].u = value; + shader.constants.is_dirty = true; } void GPU_shader_constant_float_ex(GPUShader *sh, int location, float value) { Shader &shader = *unwrap(sh); BLI_assert(shader.constants.types[location] == gpu::shader::Type::FLOAT); - shader.constants.is_dirty |= assign_if_different(shader.constants.values[location].f, value); + shader.constants.values[location].f = value; + shader.constants.is_dirty = true; } void GPU_shader_constant_bool_ex(GPUShader *sh, int location, bool value) { Shader &shader = *unwrap(sh); BLI_assert(shader.constants.types[location] == gpu::shader::Type::BOOL); - shader.constants.is_dirty |= assign_if_different(shader.constants.values[location].u, - static_cast(value)); + shader.constants.values[location].u = value; + shader.constants.is_dirty = true; } void GPU_shader_constant_int(GPUShader *sh, const char *name, int value) diff --git a/source/blender/gpu/intern/gpu_shader_builder_stubs.cc b/source/blender/gpu/intern/gpu_shader_builder_stubs.cc index 6ac047d9746..0851c8b5b62 100644 --- a/source/blender/gpu/intern/gpu_shader_builder_stubs.cc +++ b/source/blender/gpu/intern/gpu_shader_builder_stubs.cc @@ -15,7 +15,7 @@ #include "BKE_attribute.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_material.h" #include "BKE_mesh.hh" #include "BKE_node.hh" @@ -33,7 +33,10 @@ #include "UI_resources.hh" +extern "C" { Global G; +} + UserDef U; /* -------------------------------------------------------------------- */ @@ -152,6 +155,13 @@ int CustomData_get_offset(const struct CustomData * /*data*/, eCustomDataType /* return 0; } +int CustomData_get_named_layer_index(const struct CustomData * /*data*/, + eCustomDataType /*type*/, + const char * /*name*/) +{ + return -1; +} + int CustomData_get_active_layer_index(const struct CustomData * /*data*/, eCustomDataType /*type*/) { return -1; diff --git a/source/blender/gpu/intern/gpu_shader_create_info.cc b/source/blender/gpu/intern/gpu_shader_create_info.cc index cab6f60225f..ad6ad7c84c4 100644 --- a/source/blender/gpu/intern/gpu_shader_create_info.cc +++ b/source/blender/gpu/intern/gpu_shader_create_info.cc @@ -12,8 +12,6 @@ #include "BLI_set.hh" #include "BLI_string_ref.hh" -#include "BKE_global.hh" - #include "GPU_capabilities.h" #include "GPU_context.h" #include "GPU_platform.h" @@ -272,16 +270,7 @@ std::string ShaderCreateInfo::check_error() const } } - if ((G.debug & G_DEBUG_GPU) == 0) { - return error; - } - - /* - * The next check has been disabled. 'eevee_legacy_surface_common_iface' is known to fail. - * The check was added to validate if shader would be able to compile on Vulkan. - * TODO(jbakker): Enable the check after EEVEE is replaced by EEVEE-Next. - */ -#if 0 +#ifndef NDEBUG if (bool(this->builtins_ & (BuiltinBits::BARYCENTRIC_COORD | BuiltinBits::VIEWPORT_INDEX | BuiltinBits::LAYER))) { @@ -293,7 +282,6 @@ std::string ShaderCreateInfo::check_error() const } } } -#endif if (!this->is_vulkan_compatible()) { error += this->name_ + @@ -310,6 +298,7 @@ std::string ShaderCreateInfo::check_error() const } } } +#endif return error; } diff --git a/source/blender/gpu/intern/gpu_texture_private.hh b/source/blender/gpu/intern/gpu_texture_private.hh index 1fdd7aea071..8129fd18be7 100644 --- a/source/blender/gpu/intern/gpu_texture_private.hh +++ b/source/blender/gpu/intern/gpu_texture_private.hh @@ -17,7 +17,7 @@ namespace blender { namespace gpu { -enum eGPUTextureFormatFlag { +typedef enum eGPUTextureFormatFlag { /* The format has a depth component and can be used as depth attachment. */ GPU_FORMAT_DEPTH = (1 << 0), /* The format has a stencil component and can be used as stencil attachment. */ @@ -36,7 +36,7 @@ enum eGPUTextureFormatFlag { GPU_FORMAT_SIGNED = (1 << 7), GPU_FORMAT_DEPTH_STENCIL = (GPU_FORMAT_DEPTH | GPU_FORMAT_STENCIL), -}; +} eGPUTextureFormatFlag; ENUM_OPERATORS(eGPUTextureFormatFlag, GPU_FORMAT_SIGNED) diff --git a/source/blender/gpu/metal/mtl_backend.mm b/source/blender/gpu/metal/mtl_backend.mm index aa7fa65f9b5..c7ee09c6785 100644 --- a/source/blender/gpu/metal/mtl_backend.mm +++ b/source/blender/gpu/metal/mtl_backend.mm @@ -6,7 +6,7 @@ * \ingroup gpu */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "gpu_backend.hh" #include "mtl_backend.hh" diff --git a/source/blender/gpu/metal/mtl_batch.mm b/source/blender/gpu/metal/mtl_batch.mm index 0d1f0c40e9b..ae32cd8e442 100644 --- a/source/blender/gpu/metal/mtl_batch.mm +++ b/source/blender/gpu/metal/mtl_batch.mm @@ -11,7 +11,7 @@ #include "BLI_assert.h" #include "BLI_span.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "GPU_common.h" #include "gpu_batch_private.hh" diff --git a/source/blender/gpu/metal/mtl_context.mm b/source/blender/gpu/metal/mtl_context.mm index 46f9e61919a..63f80822567 100644 --- a/source/blender/gpu/metal/mtl_context.mm +++ b/source/blender/gpu/metal/mtl_context.mm @@ -2678,7 +2678,7 @@ void present(MTLRenderPassDescriptor *blit_descriptor, } while (MTLContext::max_drawables_in_flight > min_ii(perf_max_drawables, MTL_MAX_DRAWABLES)) { - BLI_time_sleep_ms(1); + BLI_sleep_ms(1); } /* Present is submitted in its own CMD Buffer to ensure drawable reference released as early as diff --git a/source/blender/gpu/metal/mtl_debug.hh b/source/blender/gpu/metal/mtl_debug.hh index d6fad67dd18..4c4006be6aa 100644 --- a/source/blender/gpu/metal/mtl_debug.hh +++ b/source/blender/gpu/metal/mtl_debug.hh @@ -8,7 +8,7 @@ #pragma once -#include "BKE_global.hh" +#include "BKE_global.h" #include "CLG_log.h" /** Options for organizing Metal GPU debug captures. */ diff --git a/source/blender/gpu/metal/mtl_debug.mm b/source/blender/gpu/metal/mtl_debug.mm index 66804bffb99..4dcdb42a584 100644 --- a/source/blender/gpu/metal/mtl_debug.mm +++ b/source/blender/gpu/metal/mtl_debug.mm @@ -13,7 +13,7 @@ #include "BLI_system.h" #include "BLI_utildefines.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "GPU_debug.h" #include "GPU_platform.h" diff --git a/source/blender/gpu/metal/mtl_framebuffer.mm b/source/blender/gpu/metal/mtl_framebuffer.mm index c68789c73ab..8eb55792f59 100644 --- a/source/blender/gpu/metal/mtl_framebuffer.mm +++ b/source/blender/gpu/metal/mtl_framebuffer.mm @@ -8,7 +8,7 @@ #include "BLI_string.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "mtl_context.hh" #include "mtl_debug.hh" diff --git a/source/blender/gpu/metal/mtl_immediate.mm b/source/blender/gpu/metal/mtl_immediate.mm index b2baaa6ef01..c6558920e0a 100644 --- a/source/blender/gpu/metal/mtl_immediate.mm +++ b/source/blender/gpu/metal/mtl_immediate.mm @@ -8,7 +8,7 @@ * Mimics old style opengl immediate mode drawing. */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "GPU_vertex_format.h" #include "gpu_context_private.hh" diff --git a/source/blender/gpu/metal/mtl_memory.mm b/source/blender/gpu/metal/mtl_memory.mm index 9ac1a9b18e7..6bd5d57a9cd 100644 --- a/source/blender/gpu/metal/mtl_memory.mm +++ b/source/blender/gpu/metal/mtl_memory.mm @@ -2,7 +2,7 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "DNA_userdef_types.h" diff --git a/source/blender/gpu/metal/mtl_shader.mm b/source/blender/gpu/metal/mtl_shader.mm index 825ec97c640..f70a5d42a85 100644 --- a/source/blender/gpu/metal/mtl_shader.mm +++ b/source/blender/gpu/metal/mtl_shader.mm @@ -6,7 +6,7 @@ * \ingroup gpu */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_time.h" @@ -236,14 +236,6 @@ void MTLShader::compute_shader_from_glsl(MutableSpan sources) /* Consolidate GLSL compute sources. */ std::stringstream ss; for (int i = 0; i < sources.size(); i++) { - /* Output preprocessor directive to improve shader log. */ - StringRefNull name = shader::gpu_shader_dependency_get_filename_from_source_string(sources[i]); - if (name.is_empty()) { - ss << "#line 1 \"generated_code_" << i << "\"\n"; - } - else { - ss << "#line 1 \"" << name << "\"\n"; - } ss << sources[i] << std::endl; } shd_builder_->glsl_compute_source_ = ss.str(); diff --git a/source/blender/gpu/metal/mtl_shader_generator.mm b/source/blender/gpu/metal/mtl_shader_generator.mm index 02baab49be3..d33dfe60ef0 100644 --- a/source/blender/gpu/metal/mtl_shader_generator.mm +++ b/source/blender/gpu/metal/mtl_shader_generator.mm @@ -6,7 +6,7 @@ * \ingroup gpu */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_string.h" @@ -1535,7 +1535,6 @@ bool MTLShader::generate_msl_from_glsl_compute(const shader::ShaderCreateInfo *i /** Generate Compute shader stage. **/ std::stringstream ss_compute; - ss_compute << "#line 1 \"msl_wrapper_code\"\n"; ss_compute << "#define GPU_ARB_shader_draw_parameters 1\n"; if (bool(info->builtins_ & BuiltinBits::TEXTURE_ATOMIC) && diff --git a/source/blender/gpu/metal/mtl_storage_buffer.mm b/source/blender/gpu/metal/mtl_storage_buffer.mm index d550d65f287..b38a5610e57 100644 --- a/source/blender/gpu/metal/mtl_storage_buffer.mm +++ b/source/blender/gpu/metal/mtl_storage_buffer.mm @@ -430,7 +430,7 @@ void MTLStorageBuf::read(void *data) if (gpu_write_fence_ != nil) { /* Ensure the GPU updates are visible to the host before reading. */ while (gpu_write_fence_.signaledValue < host_read_signal_value_) { - BLI_time_sleep_ms(1); + BLI_sleep_ms(1); } } diff --git a/source/blender/gpu/metal/mtl_texture.mm b/source/blender/gpu/metal/mtl_texture.mm index ee14026bd5b..9c06bef954f 100644 --- a/source/blender/gpu/metal/mtl_texture.mm +++ b/source/blender/gpu/metal/mtl_texture.mm @@ -6,7 +6,7 @@ * \ingroup gpu */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "DNA_userdef_types.h" diff --git a/source/blender/gpu/metal/mtl_texture_util.mm b/source/blender/gpu/metal/mtl_texture_util.mm index a1d41b64e00..bcdbb6d9914 100644 --- a/source/blender/gpu/metal/mtl_texture_util.mm +++ b/source/blender/gpu/metal/mtl_texture_util.mm @@ -6,7 +6,7 @@ * \ingroup gpu */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "DNA_userdef_types.h" diff --git a/source/blender/gpu/metal/mtl_uniform_buffer.mm b/source/blender/gpu/metal/mtl_uniform_buffer.mm index e2eecb1ec23..21ef11bfdf5 100644 --- a/source/blender/gpu/metal/mtl_uniform_buffer.mm +++ b/source/blender/gpu/metal/mtl_uniform_buffer.mm @@ -6,7 +6,7 @@ * \ingroup gpu */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_string.h" diff --git a/source/blender/gpu/opengl/gl_backend.cc b/source/blender/gpu/opengl/gl_backend.cc index bedb1a708cb..8cad6fdbe06 100644 --- a/source/blender/gpu/opengl/gl_backend.cc +++ b/source/blender/gpu/opengl/gl_backend.cc @@ -6,7 +6,7 @@ * \ingroup gpu */ -#include "BKE_global.hh" +#include "BKE_global.h" #if defined(WIN32) # include "BLI_winstuff.h" #endif diff --git a/source/blender/gpu/opengl/gl_context.cc b/source/blender/gpu/opengl/gl_context.cc index ab4cf35b222..b1e1ceb6b52 100644 --- a/source/blender/gpu/opengl/gl_context.cc +++ b/source/blender/gpu/opengl/gl_context.cc @@ -9,7 +9,7 @@ #include "BLI_assert.h" #include "BLI_utildefines.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "GPU_framebuffer.h" diff --git a/source/blender/gpu/opengl/gl_debug.cc b/source/blender/gpu/opengl/gl_debug.cc index ce5d1a3e63f..687ad1feced 100644 --- a/source/blender/gpu/opengl/gl_debug.cc +++ b/source/blender/gpu/opengl/gl_debug.cc @@ -13,7 +13,7 @@ #include "BLI_system.h" #include "BLI_utildefines.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "GPU_debug.h" #include "GPU_platform.h" diff --git a/source/blender/gpu/opengl/gl_framebuffer.cc b/source/blender/gpu/opengl/gl_framebuffer.cc index e931af16020..6414d9b72ca 100644 --- a/source/blender/gpu/opengl/gl_framebuffer.cc +++ b/source/blender/gpu/opengl/gl_framebuffer.cc @@ -8,7 +8,7 @@ #include "BLI_string.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "gl_backend.hh" #include "gl_debug.hh" diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc index 9180056fb3c..311ba01443e 100644 --- a/source/blender/gpu/opengl/gl_shader.cc +++ b/source/blender/gpu/opengl/gl_shader.cc @@ -8,7 +8,7 @@ #include -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_string.h" #include "BLI_vector.hh" @@ -755,9 +755,9 @@ std::string GLShader::fragment_interface_declare(const ShaderCreateInfo &info) c std::string pre_main, post_main; ss << "\n/* Interfaces. */\n"; - const Span in_interfaces = info.geometry_source_.is_empty() ? - info.vertex_out_interfaces_ : - info.geometry_out_interfaces_; + const Vector &in_interfaces = info.geometry_source_.is_empty() ? + info.vertex_out_interfaces_ : + info.geometry_out_interfaces_; for (const StageInterfaceInfo *iface : in_interfaces) { print_interface(ss, "in", *iface); } @@ -909,7 +909,7 @@ std::string GLShader::geometry_layout_declare(const ShaderCreateInfo &info) cons return ss.str(); } -static StageInterfaceInfo *find_interface_by_name(const Span ifaces, +static StageInterfaceInfo *find_interface_by_name(const Vector &ifaces, const StringRefNull &name) { for (auto *iface : ifaces) { diff --git a/source/blender/gpu/opengl/gl_state.cc b/source/blender/gpu/opengl/gl_state.cc index 4e1ee86f97c..c67ee6e38d3 100644 --- a/source/blender/gpu/opengl/gl_state.cc +++ b/source/blender/gpu/opengl/gl_state.cc @@ -6,7 +6,7 @@ * \ingroup gpu */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_math_base.h" #include "BLI_math_bits.h" diff --git a/source/blender/gpu/opengl/gl_storage_buffer.cc b/source/blender/gpu/opengl/gl_storage_buffer.cc index 75958f9c153..85492228b81 100644 --- a/source/blender/gpu/opengl/gl_storage_buffer.cc +++ b/source/blender/gpu/opengl/gl_storage_buffer.cc @@ -33,25 +33,6 @@ GLStorageBuf::GLStorageBuf(size_t size, GPUUsageType usage, const char *name) GLStorageBuf::~GLStorageBuf() { - if (read_fence_) { - glDeleteSync(read_fence_); - } - - if (persistent_ptr_) { - if (GLContext::direct_state_access_support) { - glUnmapNamedBuffer(read_ssbo_id_); - } - else { - glBindBuffer(GL_SHADER_STORAGE_BUFFER, read_ssbo_id_); - glUnmapBuffer(GL_SHADER_STORAGE_BUFFER); - glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); - } - } - - if (read_ssbo_id_) { - GLContext::buf_free(read_ssbo_id_); - } - GLContext::buf_free(ssbo_id_); } @@ -77,7 +58,6 @@ void GLStorageBuf::update(const void *data) if (ssbo_id_ == 0) { this->init(); } - glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo_id_); glBufferSubData(GL_SHADER_STORAGE_BUFFER, 0, size_in_bytes_, data); glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); @@ -183,59 +163,24 @@ void GLStorageBuf::copy_sub(VertBuf *src_, uint dst_offset, uint src_offset, uin void GLStorageBuf::async_flush_to_host() { - if (ssbo_id_ == 0) { - this->init(); - } - - if (read_ssbo_id_ == 0) { - glGenBuffers(1, &read_ssbo_id_); - glBindBuffer(GL_SHADER_STORAGE_BUFFER, read_ssbo_id_); - glBufferStorage(GL_SHADER_STORAGE_BUFFER, - size_in_bytes_, - nullptr, - GL_MAP_PERSISTENT_BIT | GL_MAP_READ_BIT); - persistent_ptr_ = glMapBufferRange( - GL_SHADER_STORAGE_BUFFER, 0, size_in_bytes_, GL_MAP_PERSISTENT_BIT | GL_MAP_READ_BIT); - BLI_assert(persistent_ptr_); - debug::object_label(GL_SHADER_STORAGE_BUFFER, read_ssbo_id_, name_); - } - - if (GLContext::direct_state_access_support) { - glCopyNamedBufferSubData(ssbo_id_, read_ssbo_id_, 0, 0, size_in_bytes_); - } - else { - glBindBuffer(GL_COPY_READ_BUFFER, ssbo_id_); - glBindBuffer(GL_COPY_WRITE_BUFFER, read_ssbo_id_); - glCopyBufferSubData(GL_SHADER_STORAGE_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, size_in_bytes_); - glBindBuffer(GL_COPY_READ_BUFFER, 0); - glBindBuffer(GL_COPY_WRITE_BUFFER, 0); - } - - glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT); - - if (read_fence_) { - glDeleteSync(read_fence_); - } - read_fence_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + GPU_memory_barrier(GPU_BARRIER_BUFFER_UPDATE); } void GLStorageBuf::read(void *data) { - if (data == nullptr) { - return; + if (ssbo_id_ == 0) { + this->init(); } - if (!persistent_ptr_ || !read_fence_) { - this->async_flush_to_host(); + if (GLContext::direct_state_access_support) { + glGetNamedBufferSubData(ssbo_id_, 0, size_in_bytes_, data); } - - while (glClientWaitSync(read_fence_, GL_SYNC_FLUSH_COMMANDS_BIT, 1000) == GL_TIMEOUT_EXPIRED) { - /* Repeat until the data is ready.*/ + else { + /* This binds the buffer to GL_ARRAY_BUFFER and upload the data if any. */ + glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo_id_); + glGetBufferSubData(GL_SHADER_STORAGE_BUFFER, 0, size_in_bytes_, data); + glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); } - glDeleteSync(read_fence_); - read_fence_ = 0; - - memcpy(data, persistent_ptr_, size_in_bytes_); } void GLStorageBuf::sync_as_indirect_buffer() diff --git a/source/blender/gpu/opengl/gl_storage_buffer.hh b/source/blender/gpu/opengl/gl_storage_buffer.hh index be2eb3e8df2..af3fdacb7b2 100644 --- a/source/blender/gpu/opengl/gl_storage_buffer.hh +++ b/source/blender/gpu/opengl/gl_storage_buffer.hh @@ -26,10 +26,6 @@ class GLStorageBuf : public StorageBuf { GLuint ssbo_id_ = 0; /** Usage type. */ GPUUsageType usage_; - /* Read */ - GLuint read_ssbo_id_ = 0; - GLsync read_fence_ = 0; - void *persistent_ptr_ = nullptr; public: GLStorageBuf(size_t size, GPUUsageType usage, const char *name); diff --git a/source/blender/gpu/tests/gpu_testing.hh b/source/blender/gpu/tests/gpu_testing.hh index 44ba0dd1398..0d6104a2344 100644 --- a/source/blender/gpu/tests/gpu_testing.hh +++ b/source/blender/gpu/tests/gpu_testing.hh @@ -4,7 +4,7 @@ #include "testing/testing.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "GHOST_C-api.h" diff --git a/source/blender/gpu/vulkan/vk_debug.cc b/source/blender/gpu/vulkan/vk_debug.cc index 4cf4f51b861..3001aa5a084 100644 --- a/source/blender/gpu/vulkan/vk_debug.cc +++ b/source/blender/gpu/vulkan/vk_debug.cc @@ -8,7 +8,7 @@ #include -#include "BKE_global.hh" +#include "BKE_global.h" #include "CLG_log.h" #include "vk_backend.hh" diff --git a/source/blender/gpu/vulkan/vk_debug.hh b/source/blender/gpu/vulkan/vk_debug.hh index a7e017453b8..65e96e399b0 100644 --- a/source/blender/gpu/vulkan/vk_debug.hh +++ b/source/blender/gpu/vulkan/vk_debug.hh @@ -7,7 +7,7 @@ */ #pragma once -#include "BKE_global.hh" +#include "BKE_global.h" #include "BLI_compiler_attrs.h" #include "BLI_set.hh" #include "BLI_string.h" diff --git a/source/blender/gpu/vulkan/vk_device.cc b/source/blender/gpu/vulkan/vk_device.cc index 6d7e1c200ec..fd2129a68c5 100644 --- a/source/blender/gpu/vulkan/vk_device.cc +++ b/source/blender/gpu/vulkan/vk_device.cc @@ -316,7 +316,7 @@ void VKDevice::context_unregister(VKContext &context) { contexts_.remove(contexts_.first_index_of(std::reference_wrapper(context))); } -Span> VKDevice::contexts_get() const +const Vector> &VKDevice::contexts_get() const { return contexts_; }; diff --git a/source/blender/gpu/vulkan/vk_device.hh b/source/blender/gpu/vulkan/vk_device.hh index 04a6555173a..b1f7f9ce041 100644 --- a/source/blender/gpu/vulkan/vk_device.hh +++ b/source/blender/gpu/vulkan/vk_device.hh @@ -207,7 +207,7 @@ class VKDevice : public NonCopyable { void context_register(VKContext &context); void context_unregister(VKContext &context); - Span> contexts_get() const; + const Vector> &contexts_get() const; const VKBuffer &dummy_buffer_get() const { diff --git a/source/blender/gpu/vulkan/vk_framebuffer.cc b/source/blender/gpu/vulkan/vk_framebuffer.cc index de564227b9d..d2077acc2d3 100644 --- a/source/blender/gpu/vulkan/vk_framebuffer.cc +++ b/source/blender/gpu/vulkan/vk_framebuffer.cc @@ -135,7 +135,7 @@ void VKFrameBuffer::build_clear_attachments_color(const float (*clear_colors)[4] /** \name Clear * \{ */ -void VKFrameBuffer::clear(const Span attachments) const +void VKFrameBuffer::clear(const Vector &attachments) const { if (attachments.is_empty()) { return; diff --git a/source/blender/gpu/vulkan/vk_framebuffer.hh b/source/blender/gpu/vulkan/vk_framebuffer.hh index 401ff1e2a6e..5ee504bf6b8 100644 --- a/source/blender/gpu/vulkan/vk_framebuffer.hh +++ b/source/blender/gpu/vulkan/vk_framebuffer.hh @@ -139,7 +139,7 @@ class VKFrameBuffer : public FrameBuffer { void build_clear_attachments_color(const float (*clear_colors)[4], const bool multi_clear_colors, Vector &r_attachments) const; - void clear(Span attachments) const; + void clear(const Vector &attachments) const; }; static inline VKFrameBuffer *unwrap(FrameBuffer *framebuffer) diff --git a/source/blender/gpu/vulkan/vk_shader.cc b/source/blender/gpu/vulkan/vk_shader.cc index 19880b4077e..87d29dbc528 100644 --- a/source/blender/gpu/vulkan/vk_shader.cc +++ b/source/blender/gpu/vulkan/vk_shader.cc @@ -20,7 +20,7 @@ #include "BLI_string_utils.hh" #include "BLI_vector.hh" -#include "BKE_global.hh" +#include "BKE_global.h" using namespace blender::gpu::shader; @@ -869,7 +869,7 @@ static VkDescriptorSetLayoutBinding create_descriptor_set_layout_binding( static void add_descriptor_set_layout_bindings( const VKShaderInterface &interface, - const Span resources, + const Vector &resources, Vector &r_bindings, VkShaderStageFlags vk_shader_stages) { @@ -888,7 +888,7 @@ static void add_descriptor_set_layout_bindings( static VkDescriptorSetLayoutCreateInfo create_descriptor_set_layout( const VKShaderInterface &interface, - const Span resources, + const Vector &resources, Vector &r_bindings, VkShaderStageFlags vk_shader_stages) { @@ -1123,9 +1123,9 @@ std::string VKShader::fragment_interface_declare(const shader::ShaderCreateInfo const VKWorkarounds &workarounds = VKBackend::get().device_get().workarounds_get(); ss << "\n/* Interfaces. */\n"; - const Span in_interfaces = info.geometry_source_.is_empty() ? - info.vertex_out_interfaces_ : - info.geometry_out_interfaces_; + const Vector &in_interfaces = info.geometry_source_.is_empty() ? + info.vertex_out_interfaces_ : + info.geometry_out_interfaces_; int location = 0; for (const StageInterfaceInfo *iface : in_interfaces) { print_interface(ss, "in", *iface, location); @@ -1227,10 +1227,10 @@ std::string VKShader::geometry_interface_declare(const shader::ShaderCreateInfo return ss.str(); } -static StageInterfaceInfo *find_interface_by_name(const Span ifaces, - const StringRefNull name) +static StageInterfaceInfo *find_interface_by_name(const Vector &ifaces, + const StringRefNull &name) { - for (StageInterfaceInfo *iface : ifaces) { + for (auto *iface : ifaces) { if (iface->instance_name == name) { return iface; } diff --git a/source/blender/gpu/vulkan/vk_texture.cc b/source/blender/gpu/vulkan/vk_texture.cc index 3104d6e55b3..59d4205e4e9 100644 --- a/source/blender/gpu/vulkan/vk_texture.cc +++ b/source/blender/gpu/vulkan/vk_texture.cc @@ -19,7 +19,7 @@ #include "BLI_math_vector.hh" -#include "BKE_global.hh" +#include "BKE_global.h" namespace blender::gpu { diff --git a/source/blender/ikplugin/intern/iksolver_plugin.cc b/source/blender/ikplugin/intern/iksolver_plugin.cc index a490a8391a0..4a658cffa62 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.cc +++ b/source/blender/ikplugin/intern/iksolver_plugin.cc @@ -428,7 +428,7 @@ static void execute_posetree(Depsgraph *depsgraph, Scene *scene, Object *ob, Pos } copy_v3_v3(rootmat[3], pchan->pose_head); - mul_m4_m4m4(imat, ob->object_to_world().ptr(), rootmat); + mul_m4_m4m4(imat, ob->object_to_world, rootmat); invert_m4_m4(goalinv, imat); LISTBASE_FOREACH (PoseTarget *, target, &tree->targets) { @@ -487,7 +487,7 @@ static void execute_posetree(Depsgraph *depsgraph, Scene *scene, Object *ob, Pos /* end effector in world space */ copy_m4_m4(end_pose, pchan->pose_mat); copy_v3_v3(end_pose[3], pchan->pose_tail); - mul_m4_series(world_pose, goalinv, ob->object_to_world().ptr(), end_pose); + mul_m4_series(world_pose, goalinv, ob->object_to_world, end_pose); /* blend position */ goalpos[0] = fac * goalpos[0] + mfac * world_pose[3][0]; diff --git a/source/blender/ikplugin/intern/itasc_plugin.cc b/source/blender/ikplugin/intern/itasc_plugin.cc index 89217f2134b..545ddc379bc 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cc +++ b/source/blender/ikplugin/intern/itasc_plugin.cc @@ -36,7 +36,7 @@ #include "BKE_action.h" #include "BKE_armature.hh" #include "BKE_constraint.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_constraint_types.h" @@ -589,10 +589,10 @@ static bool target_callback(const iTaSC::Timestamp ×tamp, float chanmat[4][4]; copy_m4_m4(chanmat, pchan->pose_mat); copy_v3_v3(chanmat[3], pchan->pose_tail); - mul_m4_series(restmat, target->owner->object_to_world().ptr(), chanmat, target->eeRest); + mul_m4_series(restmat, target->owner->object_to_world, chanmat, target->eeRest); } else { - mul_m4_m4m4(restmat, target->owner->object_to_world().ptr(), target->eeRest); + mul_m4_m4m4(restmat, target->owner->object_to_world, target->eeRest); } /* blend the target */ blend_m4_m4m4(tarmat, restmat, tarmat, constraint->enforce); @@ -623,10 +623,10 @@ static bool base_callback(const iTaSC::Timestamp ×tamp, ikscene->baseFrame.setValue(&chanmat[0][0]); /* iTaSC armature is scaled to object scale, scale the base frame too */ ikscene->baseFrame.p *= ikscene->blScale; - mul_m4_m4m4(rootmat, ikscene->blArmature->object_to_world().ptr(), chanmat); + mul_m4_m4m4(rootmat, ikscene->blArmature->object_to_world, chanmat); } else { - copy_m4_m4(rootmat, ikscene->blArmature->object_to_world().ptr()); + copy_m4_m4(rootmat, ikscene->blArmature->object_to_world); ikscene->baseFrame = iTaSC::F_identity; } next.setValue(&rootmat[0][0]); @@ -1068,7 +1068,7 @@ static void convert_pose(IK_Scene *ikscene) int a, joint; /* assume uniform scaling and take Y scale as general scale for the armature */ - scale = len_v3(ikscene->blArmature->object_to_world().ptr()[1]); + scale = len_v3(ikscene->blArmature->object_to_world[1]); rot = ikscene->jointArray(0); for (joint = a = 0, ikchan = ikscene->channels; a < ikscene->numchan && joint < ikscene->numjoint; @@ -1109,7 +1109,7 @@ static void BKE_pose_rest(IK_Scene *ikscene) int a, joint; /* assume uniform scaling and take Y scale as general scale for the armature */ - scale = len_v3(ikscene->blArmature->object_to_world().ptr()[1]); + scale = len_v3(ikscene->blArmature->object_to_world[1]); /* rest pose is 0 */ SetToZero(ikscene->jointArray); /* except for transY joints */ @@ -1188,7 +1188,7 @@ static IK_Scene *convert_tree( } ikscene->blArmature = ob; /* assume uniform scaling and take Y scale as general scale for the armature */ - ikscene->blScale = len_v3(ob->object_to_world().ptr()[1]); + ikscene->blScale = len_v3(ob->object_to_world[1]); ikscene->blInvScale = (ikscene->blScale < KDL::epsilon) ? 0.0f : 1.0f / ikscene->blScale; std::string joint; @@ -1676,7 +1676,7 @@ static void create_scene(Depsgraph *depsgraph, Scene *scene, Object *ob, float c static int init_scene(Object *ob) { /* check also if scaling has changed */ - float scale = len_v3(ob->object_to_world().ptr()[1]); + float scale = len_v3(ob->object_to_world[1]); IK_Scene *scene; if (ob->pose->ikdata) { diff --git a/source/blender/imbuf/IMB_imbuf.hh b/source/blender/imbuf/IMB_imbuf.hh index 9a5881f2e19..b789eea51f0 100644 --- a/source/blender/imbuf/IMB_imbuf.hh +++ b/source/blender/imbuf/IMB_imbuf.hh @@ -595,18 +595,15 @@ void *imb_alloc_pixels(unsigned int x, unsigned int y, unsigned int channels, size_t typesize, - bool initialize_pixels, const char *alloc_name); -bool imb_addrectImBuf(ImBuf *ibuf, bool initialize_pixels = true); +bool imb_addrectImBuf(ImBuf *ibuf); /** * Any free `ibuf->rect` frees mipmaps to be sure, creation is in render on first request. */ void imb_freerectImBuf(ImBuf *ibuf); -bool imb_addrectfloatImBuf(ImBuf *ibuf, - const unsigned int channels, - bool initialize_pixels = true); +bool imb_addrectfloatImBuf(ImBuf *ibuf, const unsigned int channels); /** * Any free `ibuf->rect` frees mipmaps to be sure, creation is in render on first request. */ @@ -630,7 +627,7 @@ void IMB_processor_apply_threaded( void(init_handle)(void *handle, int start_line, int tot_line, void *customdata), void *(do_thread)(void *)); -using ScanlineThreadFunc = void (*)(void *custom_data, int scanline); +typedef void (*ScanlineThreadFunc)(void *custom_data, int scanline); void IMB_processor_apply_threaded_scanlines(int total_scanlines, ScanlineThreadFunc do_thread, void *custom_data); diff --git a/source/blender/imbuf/IMB_imbuf_types.hh b/source/blender/imbuf/IMB_imbuf_types.hh index bedaff03a26..fee5b79a8d2 100644 --- a/source/blender/imbuf/IMB_imbuf_types.hh +++ b/source/blender/imbuf/IMB_imbuf_types.hh @@ -106,11 +106,6 @@ enum eImBufFlags { IB_multilayer = 1 << 7, IB_metadata = 1 << 8, IB_animdeinterlace = 1 << 9, - /** Do not clear image pixel buffer to zero. Without this flag, allocating - * a new ImBuf does clear the pixel data to zero (transparent black). If - * whole pixel data is overwritten after allocation, then this flag can be - * faster since it avoids a memory clear. */ - IB_uninitialized_pixels = 1 << 10, /** indicates whether image on disk have premul alpha */ IB_alphamode_premul = 1 << 12, diff --git a/source/blender/imbuf/IMB_metadata.hh b/source/blender/imbuf/IMB_metadata.hh index f67a3ee06c1..1d501ca351e 100644 --- a/source/blender/imbuf/IMB_metadata.hh +++ b/source/blender/imbuf/IMB_metadata.hh @@ -58,5 +58,5 @@ void IMB_metadata_copy(ImBuf *dimb, ImBuf *simb); IDProperty *IMB_anim_load_metadata(ImBufAnim *anim); /* Invoke callback for every value stored in the metadata. */ -using IMBMetadataForeachCb = void (*)(const char *field, const char *value, void *userdata); +typedef void (*IMBMetadataForeachCb)(const char *field, const char *value, void *userdata); void IMB_metadata_foreach(ImBuf *ibuf, IMBMetadataForeachCb callback, void *userdata); diff --git a/source/blender/imbuf/IMB_moviecache.hh b/source/blender/imbuf/IMB_moviecache.hh index 5596ea4c9d3..aa542379c1a 100644 --- a/source/blender/imbuf/IMB_moviecache.hh +++ b/source/blender/imbuf/IMB_moviecache.hh @@ -18,14 +18,11 @@ struct ImBuf; struct MovieCache; -using MovieCacheGetKeyDataFP = void (*)(void *userkey, - int *framenr, - int *proxy, - int *render_flags); +typedef void (*MovieCacheGetKeyDataFP)(void *userkey, int *framenr, int *proxy, int *render_flags); -using MovieCacheGetPriorityDataFP = void *(*)(void *userkey); -using MovieCacheGetItemPriorityFP = int (*)(void *last_userkey, void *priority_data); -using MovieCachePriorityDeleterFP = void (*)(void *priority_data); +typedef void *(*MovieCacheGetPriorityDataFP)(void *userkey); +typedef int (*MovieCacheGetItemPriorityFP)(void *last_userkey, void *priority_data); +typedef void (*MovieCachePriorityDeleterFP)(void *priority_data); void IMB_moviecache_init(void); void IMB_moviecache_destruct(void); diff --git a/source/blender/imbuf/intern/allocimbuf.cc b/source/blender/imbuf/intern/allocimbuf.cc index fd4a2c48e73..ad70196a8c8 100644 --- a/source/blender/imbuf/intern/allocimbuf.cc +++ b/source/blender/imbuf/intern/allocimbuf.cc @@ -87,15 +87,11 @@ template static void imb_free_buffer(BufferType &buffer) /* Allocate pixel storage of the given buffer. The buffer owns the allocated memory. * Returns true of allocation succeeded, false otherwise. */ template -bool imb_alloc_buffer(BufferType &buffer, - const uint x, - const uint y, - const uint channels, - const size_t type_size, - bool initialize_pixels) +bool imb_alloc_buffer( + BufferType &buffer, const uint x, const uint y, const uint channels, const size_t type_size) { buffer.data = static_cast( - imb_alloc_pixels(x, y, channels, type_size, initialize_pixels, __func__)); + imb_alloc_pixels(x, y, channels, type_size, __func__)); if (!buffer.data) { return false; } @@ -301,9 +297,7 @@ bool imb_addencodedbufferImBuf(ImBuf *ibuf) ibuf->encoded_size = 0; - if (!imb_alloc_buffer( - ibuf->encoded_buffer, ibuf->encoded_buffer_size, 1, 1, sizeof(uint8_t), true)) - { + if (!imb_alloc_buffer(ibuf->encoded_buffer, ibuf->encoded_buffer_size, 1, 1, sizeof(uint8_t))) { return false; } @@ -329,7 +323,7 @@ bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf) } ImBufByteBuffer new_buffer; - if (!imb_alloc_buffer(new_buffer, newsize, 1, 1, sizeof(uint8_t), true)) { + if (!imb_alloc_buffer(new_buffer, newsize, 1, 1, sizeof(uint8_t))) { return false; } @@ -349,8 +343,7 @@ bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf) return true; } -void *imb_alloc_pixels( - uint x, uint y, uint channels, size_t typesize, bool initialize_pixels, const char *alloc_name) +void *imb_alloc_pixels(uint x, uint y, uint channels, size_t typesize, const char *alloc_name) { /* Protect against buffer overflow vulnerabilities from files specifying * a width and height that overflow and alloc too little memory. */ @@ -359,10 +352,10 @@ void *imb_alloc_pixels( } size_t size = size_t(x) * size_t(y) * size_t(channels) * typesize; - return initialize_pixels ? MEM_callocN(size, alloc_name) : MEM_mallocN(size, alloc_name); + return MEM_callocN(size, alloc_name); } -bool imb_addrectfloatImBuf(ImBuf *ibuf, const uint channels, bool initialize_pixels) +bool imb_addrectfloatImBuf(ImBuf *ibuf, const uint channels) { if (ibuf == nullptr) { return false; @@ -375,9 +368,7 @@ bool imb_addrectfloatImBuf(ImBuf *ibuf, const uint channels, bool initialize_pix imb_freerectfloatImBuf(ibuf); /* frees mipmap too, hrm */ } - if (!imb_alloc_buffer( - ibuf->float_buffer, ibuf->x, ibuf->y, channels, sizeof(float), initialize_pixels)) - { + if (!imb_alloc_buffer(ibuf->float_buffer, ibuf->x, ibuf->y, channels, sizeof(float))) { return false; } @@ -387,7 +378,7 @@ bool imb_addrectfloatImBuf(ImBuf *ibuf, const uint channels, bool initialize_pix return true; } -bool imb_addrectImBuf(ImBuf *ibuf, bool initialize_pixels) +bool imb_addrectImBuf(ImBuf *ibuf) { /* Question; why also add ZBUF (when `planes > 32`)? */ @@ -399,9 +390,7 @@ bool imb_addrectImBuf(ImBuf *ibuf, bool initialize_pixels) * this call is used only too give float buffers display. */ imb_free_buffer(ibuf->byte_buffer); - if (!imb_alloc_buffer( - ibuf->byte_buffer, ibuf->x, ibuf->y, 4, sizeof(uint8_t), initialize_pixels)) - { + if (!imb_alloc_buffer(ibuf->byte_buffer, ibuf->x, ibuf->y, 4, sizeof(uint8_t))) { return false; } @@ -516,13 +505,13 @@ ImBuf *IMB_allocFromBuffer( if (float_buffer) { /* TODO(sergey): The 4 channels is the historical code. Should probably be `channels`, but * needs a dedicated investigation. */ - imb_alloc_buffer(ibuf->float_buffer, w, h, 4, sizeof(float), false); + imb_alloc_buffer(ibuf->float_buffer, w, h, 4, sizeof(float)); memcpy(ibuf->float_buffer.data, float_buffer, sizeof(float[4]) * w * h); } if (byte_buffer) { - imb_alloc_buffer(ibuf->byte_buffer, w, h, 4, sizeof(uint8_t), false); + imb_alloc_buffer(ibuf->byte_buffer, w, h, 4, sizeof(uint8_t)); memcpy(ibuf->byte_buffer.data, byte_buffer, sizeof(uint8_t[4]) * w * h); } @@ -559,16 +548,14 @@ bool IMB_initImBuf(ImBuf *ibuf, uint x, uint y, uchar planes, uint flags) /* IMB_DPI_DEFAULT -> pixels-per-meter. */ ibuf->ppm[0] = ibuf->ppm[1] = IMB_DPI_DEFAULT / 0.0254; - const bool init_pixels = (flags & IB_uninitialized_pixels) == 0; - if (flags & IB_rect) { - if (imb_addrectImBuf(ibuf, init_pixels) == false) { + if (imb_addrectImBuf(ibuf) == false) { return false; } } if (flags & IB_rectfloat) { - if (imb_addrectfloatImBuf(ibuf, ibuf->channels, init_pixels) == false) { + if (imb_addrectfloatImBuf(ibuf, ibuf->channels) == false) { return false; } } @@ -582,7 +569,7 @@ bool IMB_initImBuf(ImBuf *ibuf, uint x, uint y, uchar planes, uint flags) ImBuf *IMB_dupImBuf(const ImBuf *ibuf1) { ImBuf *ibuf2, tbuf; - int flags = IB_uninitialized_pixels; + int flags = 0; int a, x, y; if (ibuf1 == nullptr) { diff --git a/source/blender/imbuf/intern/anim_movie.cc b/source/blender/imbuf/intern/anim_movie.cc index 7a12c078bc1..104076835b8 100644 --- a/source/blender/imbuf/intern/anim_movie.cc +++ b/source/blender/imbuf/intern/anim_movie.cc @@ -62,6 +62,7 @@ #include "IMB_metadata.hh" #ifdef WITH_FFMPEG +# include "BKE_global.h" /* ENDIAN_ORDER */ # include "BKE_writeffmpeg.hh" extern "C" { @@ -413,7 +414,7 @@ static ImBuf *avi_fetchibuf(ImBufAnim *anim, int position) else # endif { - ibuf = IMB_allocImBuf(anim->x, anim->y, 24, IB_rect | IB_uninitialized_pixels); + ibuf = IMB_allocImBuf(anim->x, anim->y, 24, IB_rect); tmp = static_cast(AVI_read_frame( anim->avi, AVI_FORMAT_RGB32, position, AVI_get_stream(anim->avi, AVIST_VIDEO, 0))); @@ -1469,7 +1470,8 @@ static void free_anim_ffmpeg(ImBufAnim *anim) av_frame_free(&anim->pFrame_backup); av_frame_free(&anim->pFrameRGB); av_frame_free(&anim->pFrameDeinterlaced); - BKE_ffmpeg_sws_release_context(anim->img_convert_ctx); + + sws_freeContext(anim->img_convert_ctx); } anim->duration_in_frames = 0; } diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.cc b/source/blender/imbuf/intern/cineon/cineon_dpx.cc index 05c150ac89f..8c98037a2f5 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.cc +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.cc @@ -16,7 +16,7 @@ #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/imbuf/intern/cineon/logImageCore.cc b/source/blender/imbuf/intern/cineon/logImageCore.cc index 594ed286899..8467ed1ecd6 100644 --- a/source/blender/imbuf/intern/cineon/logImageCore.cc +++ b/source/blender/imbuf/intern/cineon/logImageCore.cc @@ -237,7 +237,7 @@ int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB int returnValue; elementData = (float *)imb_alloc_pixels( - logImage->width, logImage->height, logImage->depth, sizeof(float), true, __func__); + logImage->width, logImage->height, logImage->depth, sizeof(float), __func__); if (elementData == nullptr) { return 1; } @@ -438,12 +438,8 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB /* descriptor_Depth and descriptor_Composite are not supported */ if (!ELEM(logImage->element[i].descriptor, descriptor_Depth, descriptor_Composite)) { /* Allocate memory */ - elementData[i] = static_cast(imb_alloc_pixels(logImage->width, - logImage->height, - logImage->element[i].depth, - sizeof(float), - true, - __func__)); + elementData[i] = static_cast(imb_alloc_pixels( + logImage->width, logImage->height, logImage->element[i].depth, sizeof(float), __func__)); if (elementData[i] == nullptr) { if (verbose) { printf("DPX/Cineon: Cannot allocate memory for elementData[%d]\n.", i); @@ -628,7 +624,7 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB } mergedData = (float *)imb_alloc_pixels( - logImage->width, logImage->height, mergedElement.depth, sizeof(float), true, __func__); + logImage->width, logImage->height, mergedElement.depth, sizeof(float), __func__); if (mergedData == nullptr) { if (verbose) { printf("DPX/Cineon: Cannot allocate mergedData.\n"); @@ -1711,7 +1707,7 @@ static int convertRGBAToLogElement( if (srcIsLinearRGB != 0) { /* we need to convert src to sRGB */ srgbSrc = (float *)imb_alloc_pixels( - logImage->width, logImage->height, 4, sizeof(float), false, __func__); + logImage->width, logImage->height, 4, sizeof(float), __func__); if (srgbSrc == nullptr) { return 1; } diff --git a/source/blender/imbuf/intern/colormanagement.cc b/source/blender/imbuf/intern/colormanagement.cc index 8744fdebf76..9e417882d95 100644 --- a/source/blender/imbuf/intern/colormanagement.cc +++ b/source/blender/imbuf/intern/colormanagement.cc @@ -39,6 +39,7 @@ #include "BKE_appdir.hh" #include "BKE_colortools.hh" #include "BKE_context.hh" +#include "BKE_image.h" #include "BKE_image_format.h" #include "BKE_main.hh" diff --git a/source/blender/imbuf/intern/divers.cc b/source/blender/imbuf/intern/divers.cc index 086ef1f9429..396dee05c07 100644 --- a/source/blender/imbuf/intern/divers.cc +++ b/source/blender/imbuf/intern/divers.cc @@ -702,7 +702,7 @@ void IMB_rect_from_float(ImBuf *ibuf) /* create byte rect if it didn't exist yet */ if (ibuf->byte_buffer.data == nullptr) { - if (imb_addrectImBuf(ibuf, false) == 0) { + if (imb_addrectImBuf(ibuf) == 0) { return; } } diff --git a/source/blender/imbuf/intern/format_svg.cc b/source/blender/imbuf/intern/format_svg.cc index 9483444d9cf..7f6e311dcfe 100644 --- a/source/blender/imbuf/intern/format_svg.cc +++ b/source/blender/imbuf/intern/format_svg.cc @@ -14,6 +14,7 @@ #include "IMB_colormanagement.hh" #include "IMB_filetype.hh" #include "IMB_imbuf_types.hh" +#include "nanosvg.h" #include "nanosvgrast.h" ImBuf *imb_load_filepath_thumbnail_svg(const char *filepath, diff --git a/source/blender/imbuf/intern/indexer.cc b/source/blender/imbuf/intern/indexer.cc index dda5c5c4c94..6286e7fd779 100644 --- a/source/blender/imbuf/intern/indexer.cc +++ b/source/blender/imbuf/intern/indexer.cc @@ -1129,7 +1129,7 @@ static int indexer_performance_get_decode_rate(FFmpegIndexBuilderContext *contex AVFrame *in_frame = av_frame_alloc(); AVPacket *packet = av_packet_alloc(); - const double start = BLI_time_now_seconds(); + const double start = BLI_check_seconds_timer(); int frames_decoded = 0; while (av_read_frame(context->iFormatCtx, packet) >= 0) { @@ -1155,7 +1155,7 @@ static int indexer_performance_get_decode_rate(FFmpegIndexBuilderContext *contex frames_decoded++; } - const double end = BLI_time_now_seconds(); + const double end = BLI_check_seconds_timer(); if (end > start + time_period) { break; diff --git a/source/blender/imbuf/intern/iris.cc b/source/blender/imbuf/intern/iris.cc index a5fef4e27a1..4975fdf2cff 100644 --- a/source/blender/imbuf/intern/iris.cc +++ b/source/blender/imbuf/intern/iris.cc @@ -17,6 +17,7 @@ #include "IMB_filetype.hh" #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" +#include "imbuf.hh" #define IMAGIC 0732 diff --git a/source/blender/imbuf/intern/jpeg.cc b/source/blender/imbuf/intern/jpeg.cc index e367380d514..61a4b91bcb2 100644 --- a/source/blender/imbuf/intern/jpeg.cc +++ b/source/blender/imbuf/intern/jpeg.cc @@ -27,6 +27,7 @@ #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" #include "IMB_metadata.hh" +#include "imbuf.hh" #include #include @@ -292,9 +293,7 @@ static ImBuf *ibJpegImageFromCinfo( jpeg_abort_decompress(cinfo); ibuf = IMB_allocImBuf(x, y, 8 * depth, 0); } - else if ((ibuf = IMB_allocImBuf(x, y, 8 * depth, IB_rect | IB_uninitialized_pixels)) == - nullptr) - { + else if ((ibuf = IMB_allocImBuf(x, y, 8 * depth, IB_rect)) == nullptr) { jpeg_abort_decompress(cinfo); } else { diff --git a/source/blender/imbuf/intern/metadata.cc b/source/blender/imbuf/intern/metadata.cc index eaa929ea1b9..8ce4bfe32bf 100644 --- a/source/blender/imbuf/intern/metadata.cc +++ b/source/blender/imbuf/intern/metadata.cc @@ -17,6 +17,9 @@ #include "DNA_ID.h" /* ID property definitions. */ +#include "MEM_guardedalloc.h" + +#include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" #include "IMB_metadata.hh" diff --git a/source/blender/imbuf/intern/moviecache.cc b/source/blender/imbuf/intern/moviecache.cc index 35b36b37de3..623e358165f 100644 --- a/source/blender/imbuf/intern/moviecache.cc +++ b/source/blender/imbuf/intern/moviecache.cc @@ -18,6 +18,7 @@ #include "BLI_ghash.h" #include "BLI_mempool.h" #include "BLI_string.h" +#include "BLI_threads.h" #include "BLI_utildefines.h" #include "IMB_moviecache.hh" diff --git a/source/blender/imbuf/intern/oiio/openimageio_support.cc b/source/blender/imbuf/intern/oiio/openimageio_support.cc index 1baa1b72d49..ce7a5c02b61 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_support.cc +++ b/source/blender/imbuf/intern/oiio/openimageio_support.cc @@ -100,7 +100,7 @@ static ImBuf *load_pixels( { /* Allocate the ImBuf for the image. */ constexpr bool is_float = sizeof(T) > 1; - const uint format_flag = (is_float ? IB_rectfloat : IB_rect) | IB_uninitialized_pixels; + const uint format_flag = is_float ? IB_rectfloat : IB_rect; const uint ibuf_flags = (flags & IB_test) ? 0 : format_flag; const int planes = use_all_planes ? 32 : 8 * channels; ImBuf *ibuf = IMB_allocImBuf(width, height, planes, ibuf_flags); diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 882a75d6ff6..e6f627c096c 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -79,6 +79,7 @@ #include "BLI_fileops.h" #include "BLI_math_color.h" #include "BLI_mmap.h" +#include "BLI_string_utils.hh" #include "BLI_threads.h" #include "BKE_idprop.h" diff --git a/source/blender/imbuf/intern/readimage.cc b/source/blender/imbuf/intern/readimage.cc index 3fdbce144a7..460472d2a6d 100644 --- a/source/blender/imbuf/intern/readimage.cc +++ b/source/blender/imbuf/intern/readimage.cc @@ -14,7 +14,7 @@ #include "BLI_fileops.h" #include "BLI_mmap.h" -#include "BLI_path_util.h" /* For assertions. */ +#include "BLI_path_util.h" #include "BLI_string.h" #include "BLI_utildefines.h" #include diff --git a/source/blender/imbuf/intern/scaling.cc b/source/blender/imbuf/intern/scaling.cc index 3a81292cbaa..1d5fcea2f42 100644 --- a/source/blender/imbuf/intern/scaling.cc +++ b/source/blender/imbuf/intern/scaling.cc @@ -8,6 +8,7 @@ #include +#include "BLI_math_color.h" #include "BLI_utildefines.h" #include "MEM_guardedalloc.h" @@ -15,6 +16,7 @@ #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" #include "IMB_interp.hh" +#include "imbuf.hh" #include "BLI_sys_types.h" /* for intptr_t support */ diff --git a/source/blender/imbuf/intern/stereoimbuf.cc b/source/blender/imbuf/intern/stereoimbuf.cc index 7f4b0cb14de..8aaf1b835ee 100644 --- a/source/blender/imbuf/intern/stereoimbuf.cc +++ b/source/blender/imbuf/intern/stereoimbuf.cc @@ -12,6 +12,11 @@ #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" +#include "IMB_allocimbuf.hh" +#include "IMB_colormanagement_intern.hh" +#include "IMB_filetype.hh" +#include "IMB_metadata.hh" + #include "imbuf.hh" #include "MEM_guardedalloc.h" diff --git a/source/blender/imbuf/intern/thumbs_blend.cc b/source/blender/imbuf/intern/thumbs_blend.cc index 7048a1850c3..172a34bf840 100644 --- a/source/blender/imbuf/intern/thumbs_blend.cc +++ b/source/blender/imbuf/intern/thumbs_blend.cc @@ -10,15 +10,20 @@ #include #include -#include "BLI_listbase.h" /* Needed due to import of BLO_readfile.hh */ +#include "BLI_linklist.h" +#include "BLI_listbase.h" /* Needed due to import of BLO_readfile.h */ #include "BLI_utildefines.h" -#include "BLO_readfile.hh" +#include "BLO_blend_defs.hh" +#include "BLO_readfile.h" #include "BKE_idtype.hh" #include "BKE_main.hh" #include "BKE_preview_image.hh" +#include "DNA_ID.h" /* For preview images... */ + +#include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" #include "IMB_thumbs.hh" diff --git a/source/blender/imbuf/intern/thumbs_font.cc b/source/blender/imbuf/intern/thumbs_font.cc index f9e40735912..b0cf587fdcc 100644 --- a/source/blender/imbuf/intern/thumbs_font.cc +++ b/source/blender/imbuf/intern/thumbs_font.cc @@ -6,6 +6,7 @@ * \ingroup imbuf */ +#include "BLI_fileops.h" #include "BLI_hash_md5.hh" #include "BLI_utildefines.h" diff --git a/source/blender/imbuf/intern/util.cc b/source/blender/imbuf/intern/util.cc index 77470f6274c..b6ce3832a5b 100644 --- a/source/blender/imbuf/intern/util.cc +++ b/source/blender/imbuf/intern/util.cc @@ -29,7 +29,7 @@ #ifdef WITH_FFMPEG # include "BLI_string.h" /* BLI_vsnprintf */ -# include "BKE_global.hh" /* G.debug */ +# include "BKE_global.h" /* G.debug */ extern "C" { # include @@ -37,7 +37,7 @@ extern "C" { # include # include -# include "ffmpeg_compat.h" /* Keep for compatibility. */ +# include "ffmpeg_compat.h" } #endif diff --git a/source/blender/imbuf/intern/util_gpu.cc b/source/blender/imbuf/intern/util_gpu.cc index 1cba6c9026d..776ca277741 100644 --- a/source/blender/imbuf/intern/util_gpu.cc +++ b/source/blender/imbuf/intern/util_gpu.cc @@ -6,10 +6,15 @@ * \ingroup imbuf */ +#include "imbuf.hh" + #include "BLI_utildefines.h" #include "MEM_guardedalloc.h" +#include "BKE_global.h" + #include "GPU_capabilities.h" +#include "GPU_state.h" #include "GPU_texture.h" #include "IMB_colormanagement.hh" diff --git a/source/blender/imbuf/intern/writeimage.cc b/source/blender/imbuf/intern/writeimage.cc index e058380c0f6..ccaa92d2ae9 100644 --- a/source/blender/imbuf/intern/writeimage.cc +++ b/source/blender/imbuf/intern/writeimage.cc @@ -10,7 +10,7 @@ #include #include -#include "BLI_path_util.h" /* For assertions. */ +#include "BLI_path_util.h" #include "BLI_utildefines.h" #include "IMB_colormanagement.hh" diff --git a/source/blender/io/alembic/exporter/abc_archive.cc b/source/blender/io/alembic/exporter/abc_archive.cc index 4cdb58fd1a9..368175a9bf5 100644 --- a/source/blender/io/alembic/exporter/abc_archive.cc +++ b/source/blender/io/alembic/exporter/abc_archive.cc @@ -6,7 +6,7 @@ #include "BKE_blender_version.h" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/io/alembic/exporter/abc_export_capi.cc b/source/blender/io/alembic/exporter/abc_export_capi.cc index ac38f16d669..f395cf86ee6 100644 --- a/source/blender/io/alembic/exporter/abc_export_capi.cc +++ b/source/blender/io/alembic/exporter/abc_export_capi.cc @@ -18,9 +18,9 @@ #include "BKE_blender_version.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BLI_fileops.h" #include "BLI_path_util.h" diff --git a/source/blender/io/alembic/exporter/abc_writer_camera.cc b/source/blender/io/alembic/exporter/abc_writer_camera.cc index 0040ed22d28..5f68c4a5e8f 100644 --- a/source/blender/io/alembic/exporter/abc_writer_camera.cc +++ b/source/blender/io/alembic/exporter/abc_writer_camera.cc @@ -10,7 +10,7 @@ #include "abc_hierarchy_iterator.h" #include "BKE_camera.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BLI_assert.h" diff --git a/source/blender/io/alembic/exporter/abc_writer_hair.cc b/source/blender/io/alembic/exporter/abc_writer_hair.cc index 12219898277..1e2ee7109d6 100644 --- a/source/blender/io/alembic/exporter/abc_writer_hair.cc +++ b/source/blender/io/alembic/exporter/abc_writer_hair.cc @@ -127,7 +127,7 @@ void ABCHairWriter::write_hair_sample(const HierarchyContext &context, { /* Get untransformed vertices, there's a xform under the hair. */ float inv_mat[4][4]; - invert_m4_m4_safe(inv_mat, context.object->object_to_world().ptr()); + invert_m4_m4_safe(inv_mat, context.object->object_to_world); MTFace *mtface = (MTFace *)CustomData_get_layer_for_write( &mesh->fdata_legacy, CD_MTFACE, mesh->totface_legacy); @@ -252,7 +252,7 @@ void ABCHairWriter::write_hair_child_sample(const HierarchyContext &context, { /* Get untransformed vertices, there's a xform under the hair. */ float inv_mat[4][4]; - invert_m4_m4_safe(inv_mat, context.object->object_to_world().ptr()); + invert_m4_m4_safe(inv_mat, context.object->object_to_world); const MFace *mface = (const MFace *)CustomData_get_layer(&mesh->fdata_legacy, CD_MFACE); MTFace *mtface = (MTFace *)CustomData_get_layer_for_write( diff --git a/source/blender/io/alembic/exporter/abc_writer_points.cc b/source/blender/io/alembic/exporter/abc_writer_points.cc index fca1bd78274..6d974ace7bf 100644 --- a/source/blender/io/alembic/exporter/abc_writer_points.cc +++ b/source/blender/io/alembic/exporter/abc_writer_points.cc @@ -101,7 +101,7 @@ void ABCPointsWriter::do_write(HierarchyContext &context) } /* location */ - mul_v3_m4v3(pos, context.object->world_to_object().ptr(), state.co); + mul_v3_m4v3(pos, context.object->world_to_object, state.co); /* velocity */ sub_v3_v3v3(vel, state.co, psys->particles[p].prev_state.co); diff --git a/source/blender/io/alembic/intern/abc_axis_conversion.cc b/source/blender/io/alembic/intern/abc_axis_conversion.cc index 3970f14f27b..e2be5b20632 100644 --- a/source/blender/io/alembic/intern/abc_axis_conversion.cc +++ b/source/blender/io/alembic/intern/abc_axis_conversion.cc @@ -14,8 +14,6 @@ #include "BLI_math_rotation.h" #include "BLI_math_vector.h" -#include "BKE_object_types.hh" - #include "DNA_object_types.h" namespace blender::io::alembic { @@ -141,16 +139,15 @@ void create_transform_matrix(Object *obj, if (mode == ABC_MATRIX_LOCAL && obj->parent) { /* Note that this produces another matrix than the local matrix, due to * constraints and modifiers as well as the obj->parentinv matrix. */ - invert_m4_m4(obj->parent->runtime->world_to_object.ptr(), - obj->parent->object_to_world().ptr()); - mul_m4_m4m4(zup_mat, obj->parent->world_to_object().ptr(), obj->object_to_world().ptr()); + invert_m4_m4(obj->parent->world_to_object, obj->parent->object_to_world); + mul_m4_m4m4(zup_mat, obj->parent->world_to_object, obj->object_to_world); } else { - copy_m4_m4(zup_mat, obj->object_to_world().ptr()); + copy_m4_m4(zup_mat, obj->object_to_world); } if (proxy_from) { - mul_m4_m4m4(zup_mat, proxy_from->object_to_world().ptr(), zup_mat); + mul_m4_m4m4(zup_mat, proxy_from->object_to_world, zup_mat); } copy_m44_axis_swap(r_yup_mat, zup_mat, ABC_YUP_FROM_ZUP); diff --git a/source/blender/io/alembic/intern/abc_reader_camera.cc b/source/blender/io/alembic/intern/abc_reader_camera.cc index 6fa16170ceb..cf4641ce126 100644 --- a/source/blender/io/alembic/intern/abc_reader_camera.cc +++ b/source/blender/io/alembic/intern/abc_reader_camera.cc @@ -18,7 +18,7 @@ #include "BKE_camera.h" #include "BKE_object.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" using Alembic::AbcGeom::CameraSample; using Alembic::AbcGeom::ICamera; diff --git a/source/blender/io/alembic/intern/abc_reader_curves.cc b/source/blender/io/alembic/intern/abc_reader_curves.cc index 28c5c338be7..d397fe73b57 100644 --- a/source/blender/io/alembic/intern/abc_reader_curves.cc +++ b/source/blender/io/alembic/intern/abc_reader_curves.cc @@ -20,7 +20,7 @@ #include "BLI_listbase.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_curve.hh" #include "BKE_mesh.hh" diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc index 83efc23dc56..f5cc7414dfd 100644 --- a/source/blender/io/alembic/intern/abc_reader_mesh.cc +++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc @@ -25,7 +25,7 @@ #include "BLI_math_geom.h" #include "BLI_ordered_edge.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_attribute.hh" #include "BKE_customdata.hh" diff --git a/source/blender/io/alembic/intern/abc_reader_nurbs.cc b/source/blender/io/alembic/intern/abc_reader_nurbs.cc index 5b703d11731..e558d7e626b 100644 --- a/source/blender/io/alembic/intern/abc_reader_nurbs.cc +++ b/source/blender/io/alembic/intern/abc_reader_nurbs.cc @@ -19,7 +19,7 @@ #include "BLI_listbase.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_curve.hh" #include "BKE_object.hh" diff --git a/source/blender/io/alembic/intern/abc_reader_object.cc b/source/blender/io/alembic/intern/abc_reader_object.cc index f412221d7a6..2aa79042356 100644 --- a/source/blender/io/alembic/intern/abc_reader_object.cc +++ b/source/blender/io/alembic/intern/abc_reader_object.cc @@ -19,7 +19,6 @@ #include "BKE_lib_id.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" -#include "BKE_object_types.hh" #include "BLI_listbase.h" #include "BLI_math_geom.h" @@ -175,7 +174,7 @@ void AbcObjectReader::setupObjectTransform(const chrono_t time) /* Apply the matrix to the object. */ BKE_object_apply_mat4(m_object, transform_from_alembic, true, false); - BKE_object_to_mat4(m_object, m_object->runtime->object_to_world.ptr()); + BKE_object_to_mat4(m_object, m_object->object_to_world); if (!is_constant || m_settings->always_add_cache_reader) { bConstraint *con = BKE_constraint_add_for_object( diff --git a/source/blender/io/alembic/intern/abc_reader_points.cc b/source/blender/io/alembic/intern/abc_reader_points.cc index 9d0cbdeba13..fd774f65e40 100644 --- a/source/blender/io/alembic/intern/abc_reader_points.cc +++ b/source/blender/io/alembic/intern/abc_reader_points.cc @@ -15,7 +15,7 @@ #include "DNA_modifier_types.h" #include "DNA_object_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_customdata.hh" #include "BKE_mesh.hh" diff --git a/source/blender/io/alembic/intern/abc_reader_transform.cc b/source/blender/io/alembic/intern/abc_reader_transform.cc index 514bba955b9..6918452c869 100644 --- a/source/blender/io/alembic/intern/abc_reader_transform.cc +++ b/source/blender/io/alembic/intern/abc_reader_transform.cc @@ -13,7 +13,7 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_object.hh" diff --git a/source/blender/io/alembic/intern/abc_util.cc b/source/blender/io/alembic/intern/abc_util.cc index 32eef8246a5..9042699d13b 100644 --- a/source/blender/io/alembic/intern/abc_util.cc +++ b/source/blender/io/alembic/intern/abc_util.cc @@ -241,13 +241,14 @@ AbcObjectReader *create_reader(const Alembic::AbcGeom::IObject &object, ImportSe /* ********************** */ -ScopeTimer::ScopeTimer(const char *message) : m_message(message), m_start(BLI_time_now_seconds()) +ScopeTimer::ScopeTimer(const char *message) + : m_message(message), m_start(BLI_check_seconds_timer()) { } ScopeTimer::~ScopeTimer() { - fprintf(stderr, "%s: %fs\n", m_message, BLI_time_now_seconds() - m_start); + fprintf(stderr, "%s: %fs\n", m_message, BLI_check_seconds_timer() - m_start); } /* ********************** */ diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc index c1fe115de55..6b8748bf477 100644 --- a/source/blender/io/alembic/intern/alembic_capi.cc +++ b/source/blender/io/alembic/intern/alembic_capi.cc @@ -30,14 +30,14 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BKE_cachefile.hh" +#include "BKE_cachefile.h" #include "BKE_context.hh" #include "BKE_curve.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "DEG_depsgraph.hh" @@ -54,7 +54,7 @@ #include "BLI_string.h" #include "BLI_timeit.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "WM_api.hh" #include "WM_types.hh" diff --git a/source/blender/io/avi/intern/avi_mjpeg.cc b/source/blender/io/avi/intern/avi_mjpeg.cc index 4265e287284..634a2e15854 100644 --- a/source/blender/io/avi/intern/avi_mjpeg.cc +++ b/source/blender/io/avi/intern/avi_mjpeg.cc @@ -369,7 +369,6 @@ void *avi_converter_from_mjpeg(AviMovie *movie, int stream, uchar *buffer, const movie->header->Width, 3, sizeof(uchar), - true, "avi.avi_converter_from_mjpeg 1")); if (!buf) { return nullptr; @@ -384,7 +383,6 @@ void *avi_converter_from_mjpeg(AviMovie *movie, int stream, uchar *buffer, const movie->header->Width, 3, sizeof(uchar), - true, "avi.avi_converter_from_mjpeg 2")); if (buffer) { interlace(buffer, buf, movie->header->Width, movie->header->Height); @@ -409,7 +407,6 @@ void *avi_converter_to_mjpeg(AviMovie *movie, int stream, uchar *buffer, size_t movie->header->Width, 3, sizeof(uchar), - true, "avi.avi_converter_to_mjpeg 1")); if (!buf) { return nullptr; @@ -433,7 +430,6 @@ void *avi_converter_to_mjpeg(AviMovie *movie, int stream, uchar *buffer, size_t movie->header->Width, 3, sizeof(uchar), - true, "avi.avi_converter_to_mjpeg 1")); if (buf) { diff --git a/source/blender/io/avi/intern/avi_rgb.cc b/source/blender/io/avi/intern/avi_rgb.cc index b68e0c31f3a..12acb6cedf8 100644 --- a/source/blender/io/avi/intern/avi_rgb.cc +++ b/source/blender/io/avi/intern/avi_rgb.cc @@ -43,7 +43,7 @@ void *avi_converter_from_avi_rgb(AviMovie *movie, int stream, uchar *buffer, con #endif buf = static_cast(imb_alloc_pixels( - movie->header->Height, movie->header->Width, 3, sizeof(uchar), false, "fromavirgbbuf")); + movie->header->Height, movie->header->Width, 3, sizeof(uchar), "fromavirgbbuf")); if (buf) { size_t y = movie->header->Height; @@ -80,7 +80,7 @@ void *avi_converter_from_avi_rgb(AviMovie *movie, int stream, uchar *buffer, con } buf = static_cast(imb_alloc_pixels( - movie->header->Height, movie->header->Width, 3, sizeof(uchar), false, "fromavirgbbuf")); + movie->header->Height, movie->header->Width, 3, sizeof(uchar), "fromavirgbbuf")); if (buf) { size_t rowstride = movie->header->Width * 3; diff --git a/source/blender/io/avi/intern/avi_rgb32.cc b/source/blender/io/avi/intern/avi_rgb32.cc index 6cfc2bd7279..cb2a708e02d 100644 --- a/source/blender/io/avi/intern/avi_rgb32.cc +++ b/source/blender/io/avi/intern/avi_rgb32.cc @@ -26,7 +26,7 @@ void *avi_converter_from_rgb32(AviMovie *movie, int stream, uchar *buffer, size_ *size = size_t(movie->header->Height) * size_t(movie->header->Width) * 3; buf = static_cast(imb_alloc_pixels( - movie->header->Height, movie->header->Width, 3, sizeof(uchar), false, "fromrgb32buf")); + movie->header->Height, movie->header->Width, 3, sizeof(uchar), "fromrgb32buf")); if (!buf) { return nullptr; } @@ -56,7 +56,7 @@ void *avi_converter_to_rgb32(AviMovie *movie, int stream, uchar *buffer, size_t *size = size_t(movie->header->Height) * size_t(movie->header->Width) * 4; buf = static_cast(imb_alloc_pixels( - movie->header->Height, movie->header->Width, 4, sizeof(uchar), false, "torgb32buf")); + movie->header->Height, movie->header->Width, 4, sizeof(uchar), "torgb32buf")); if (!buf) { return nullptr; } diff --git a/source/blender/io/collada/AnimationExporter.h b/source/blender/io/collada/AnimationExporter.h index e56791ea9a4..d8f5bb9d1a7 100644 --- a/source/blender/io/collada/AnimationExporter.h +++ b/source/blender/io/collada/AnimationExporter.h @@ -31,7 +31,7 @@ #include "BKE_constraint.h" #include "BKE_fcurve.h" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "ED_object.hh" #include "MEM_guardedalloc.h" diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp index 2ecae8b85b7..ce4db271f64 100644 --- a/source/blender/io/collada/AnimationImporter.cpp +++ b/source/blender/io/collada/AnimationImporter.cpp @@ -23,7 +23,7 @@ #include "BLI_string.h" #include "BLI_string_utils.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" #include "BKE_armature.hh" @@ -339,8 +339,8 @@ void AnimationImporter::read_node_transform(COLLADAFW::Node *node, Object *ob) float mat[4][4]; TransformReader::get_node_mat(mat, node, &uid_animated_map, ob); if (ob) { - copy_m4_m4(ob->runtime->object_to_world.ptr(), mat); - BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), false, false); + copy_m4_m4(ob->object_to_world, mat); + BKE_object_apply_mat4(ob, ob->object_to_world, false, false); } } @@ -2107,7 +2107,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, if (par_job) { float temp[4][4], ipar[4][4]; - invert_m4_m4(ipar, par_job->object_to_world().ptr()); + invert_m4_m4(ipar, par_job->object_to_world); copy_m4_m4(temp, mat); mul_m4_m4m4(mat, ipar, temp); } diff --git a/source/blender/io/collada/ArmatureExporter.cpp b/source/blender/io/collada/ArmatureExporter.cpp index 7c632c3c65a..815f34bb55b 100644 --- a/source/blender/io/collada/ArmatureExporter.cpp +++ b/source/blender/io/collada/ArmatureExporter.cpp @@ -16,7 +16,7 @@ #include "BKE_action.h" #include "BKE_armature.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_mesh.hh" #include "ED_armature.hh" diff --git a/source/blender/io/collada/ArmatureImporter.cpp b/source/blender/io/collada/ArmatureImporter.cpp index 05ef8f81566..51c2f4bb934 100644 --- a/source/blender/io/collada/ArmatureImporter.cpp +++ b/source/blender/io/collada/ArmatureImporter.cpp @@ -119,7 +119,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, Object *ob_arm = skin->BKE_armature_from_object(); if (ob_arm) { float invmat[4][4]; - invert_m4_m4(invmat, ob_arm->object_to_world().ptr()); + invert_m4_m4(invmat, ob_arm->object_to_world); mul_m4_m4m4(mat, invmat, mat); } @@ -715,7 +715,7 @@ void ArmatureImporter::set_pose(Object *ob_arm, copy_m4_m4(mat, obmat); float invObmat[4][4]; - invert_m4_m4(invObmat, ob_arm->object_to_world().ptr()); + invert_m4_m4(invObmat, ob_arm->object_to_world); mul_m4_m4m4(pchan->pose_mat, invObmat, mat); } diff --git a/source/blender/io/collada/BlenderContext.cpp b/source/blender/io/collada/BlenderContext.cpp index 2dc4e716cca..1b985a0b774 100644 --- a/source/blender/io/collada/BlenderContext.cpp +++ b/source/blender/io/collada/BlenderContext.cpp @@ -12,7 +12,7 @@ #include "ExportSettings.h" #include "BKE_layer.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BLI_listbase.h" diff --git a/source/blender/io/collada/ControllerExporter.cpp b/source/blender/io/collada/ControllerExporter.cpp index 8e7b5b4c05e..757e1958c45 100644 --- a/source/blender/io/collada/ControllerExporter.cpp +++ b/source/blender/io/collada/ControllerExporter.cpp @@ -18,7 +18,7 @@ #include "BKE_action.h" #include "BKE_armature.hh" #include "BKE_deform.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" @@ -408,7 +408,7 @@ void ControllerExporter::add_bind_shape_mat(Object *ob) bc_add_global_transform(f_obmat, export_settings.get_global_transform()); } - // UnitConverter::mat4_to_dae_double(bind_mat, ob->object_to_world().ptr()); + // UnitConverter::mat4_to_dae_double(bind_mat, ob->object_to_world); UnitConverter::mat4_to_dae_double(bind_mat, f_obmat); if (this->export_settings.get_limit_precision()) { BCMatrix::sanitize(bind_mat, LIMITTED_PRECISION); @@ -524,7 +524,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, } /* make world-space matrix (bind_mat is armature-space) */ - mul_m4_m4m4(world, ob_arm->object_to_world().ptr(), bind_mat); + mul_m4_m4m4(world, ob_arm->object_to_world, bind_mat); if (!has_bindmat) { if (export_settings.get_apply_global_orientation()) { diff --git a/source/blender/io/collada/DocumentExporter.cpp b/source/blender/io/collada/DocumentExporter.cpp index 5489b60c574..f2039a3d7aa 100644 --- a/source/blender/io/collada/DocumentExporter.cpp +++ b/source/blender/io/collada/DocumentExporter.cpp @@ -72,12 +72,12 @@ #include "BKE_blender_version.h" #include "BKE_customdata.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_main.hh" #include "BKE_material.h" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "ED_keyframing.hh" #ifdef WITH_BUILDINFO diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp index f066468ab7e..b292190c25b 100644 --- a/source/blender/io/collada/DocumentImporter.cpp +++ b/source/blender/io/collada/DocumentImporter.cpp @@ -40,15 +40,15 @@ #include "BLI_utildefines.h" #include "BKE_camera.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_light.h" #include "BKE_material.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BLI_path_util.h" @@ -412,8 +412,8 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, } } /* calc new matrix and apply */ - mul_m4_m4m4(obn->runtime->object_to_world.ptr(), obn->object_to_world().ptr(), mat); - BKE_object_apply_mat4(obn, obn->object_to_world().ptr(), false, false); + mul_m4_m4m4(obn->object_to_world, obn->object_to_world, mat); + BKE_object_apply_mat4(obn, obn->object_to_world, false, false); } } else { diff --git a/source/blender/io/collada/EffectExporter.cpp b/source/blender/io/collada/EffectExporter.cpp index 356f77be6df..728b68445f9 100644 --- a/source/blender/io/collada/EffectExporter.cpp +++ b/source/blender/io/collada/EffectExporter.cpp @@ -22,7 +22,7 @@ #include "DNA_mesh_types.h" #include "DNA_world_types.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_customdata.hh" #include "BKE_material.h" #include "BKE_mesh.hh" diff --git a/source/blender/io/collada/GeometryExporter.cpp b/source/blender/io/collada/GeometryExporter.cpp index 89c1fdad4e5..c92d01e2b81 100644 --- a/source/blender/io/collada/GeometryExporter.cpp +++ b/source/blender/io/collada/GeometryExporter.cpp @@ -22,7 +22,7 @@ #include "BKE_attribute.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_material.h" #include "BKE_mesh.hh" diff --git a/source/blender/io/collada/ImageExporter.cpp b/source/blender/io/collada/ImageExporter.cpp index 4508f21d73a..2f5c80ec174 100644 --- a/source/blender/io/collada/ImageExporter.cpp +++ b/source/blender/io/collada/ImageExporter.cpp @@ -13,7 +13,7 @@ #include "DNA_texture_types.h" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_image_format.h" #include "BKE_main.hh" diff --git a/source/blender/io/collada/Materials.h b/source/blender/io/collada/Materials.h index 5667fdcbd03..09b4f4a9bd2 100644 --- a/source/blender/io/collada/Materials.h +++ b/source/blender/io/collada/Materials.h @@ -8,7 +8,7 @@ #include #include "BKE_context.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BLI_listbase.h" #include "DNA_material_types.h" #include "DNA_node_types.h" diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp index 3991a3825a5..2db33f3e9de 100644 --- a/source/blender/io/collada/MeshImporter.cpp +++ b/source/blender/io/collada/MeshImporter.cpp @@ -21,7 +21,7 @@ #include "BKE_attribute.hh" #include "BKE_customdata.hh" #include "BKE_displist.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_material.h" #include "BKE_mesh.hh" @@ -476,7 +476,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *mesh) COLLADAFW::String &uvname = info->mName; /* Allocate space for UV_data */ CustomData_add_layer_named( - &mesh->corner_data, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->corners_num, uvname); + &mesh->corner_data, CD_PROP_FLOAT2, CD_SET_DEFAULT, mesh->corners_num, uvname.c_str()); } /* activate the first uv map */ CustomData_set_layer_active(&mesh->corner_data, CD_PROP_FLOAT2, 0); @@ -488,8 +488,11 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *mesh) COLLADAFW::MeshVertexData::InputInfos *info = collada_mesh->getColors().getInputInfosArray()[i]; COLLADAFW::String colname = extract_vcolname(info->mName); - CustomData_add_layer_named( - &mesh->corner_data, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, mesh->corners_num, colname); + CustomData_add_layer_named(&mesh->corner_data, + CD_PROP_BYTE_COLOR, + CD_SET_DEFAULT, + mesh->corners_num, + colname.c_str()); } BKE_id_attributes_active_color_set( &mesh->id, CustomData_get_layer_name(&mesh->corner_data, CD_PROP_BYTE_COLOR, 0)); @@ -723,8 +726,10 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, { COLLADAFW::IndexList &index_list = *index_list_array_uvcoord[uvset_index]; blender::float2 *mloopuv = static_cast( - CustomData_get_layer_named_for_write( - &mesh->corner_data, CD_PROP_FLOAT2, index_list.getName(), mesh->corners_num)); + CustomData_get_layer_named_for_write(&mesh->corner_data, + CD_PROP_FLOAT2, + index_list.getName().c_str(), + mesh->corners_num)); if (mloopuv == nullptr) { fprintf(stderr, "Collada import: Mesh [%s] : Unknown reference to TEXCOORD [#%s].\n", @@ -765,7 +770,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, COLLADAFW::IndexList &color_index_list = *mp->getColorIndices(vcolor_index); COLLADAFW::String colname = extract_vcolname(color_index_list.getName()); MLoopCol *mloopcol = (MLoopCol *)CustomData_get_layer_named_for_write( - &mesh->corner_data, CD_PROP_BYTE_COLOR, colname, mesh->corners_num); + &mesh->corner_data, CD_PROP_BYTE_COLOR, colname.c_str(), mesh->corners_num); if (mloopcol == nullptr) { fprintf(stderr, "Collada import: Mesh [%s] : Unknown reference to VCOLOR [#%s].\n", diff --git a/source/blender/io/collada/SceneExporter.cpp b/source/blender/io/collada/SceneExporter.cpp index 82451d38cf3..ee126e680c4 100644 --- a/source/blender/io/collada/SceneExporter.cpp +++ b/source/blender/io/collada/SceneExporter.cpp @@ -6,7 +6,7 @@ * \ingroup collada */ -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_lib_id.hh" #include "BKE_object.hh" #include "BLI_listbase.h" diff --git a/source/blender/io/collada/SkinInfo.cpp b/source/blender/io/collada/SkinInfo.cpp index fa696f60e3d..a884bfe2fb1 100644 --- a/source/blender/io/collada/SkinInfo.cpp +++ b/source/blender/io/collada/SkinInfo.cpp @@ -218,8 +218,8 @@ void SkinInfo::link_armature(bContext *C, DEG_id_tag_update(&obn->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); #endif - copy_m4_m4(ob->runtime->object_to_world.ptr(), bind_shape_matrix); - BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), false, false); + copy_m4_m4(ob->object_to_world, bind_shape_matrix); + BKE_object_apply_mat4(ob, ob->object_to_world, false, false); amd->deformflag = ARM_DEF_VGROUP; diff --git a/source/blender/io/collada/collada.cpp b/source/blender/io/collada/collada.cpp index 7dafa12f4de..045e6214ed9 100644 --- a/source/blender/io/collada/collada.cpp +++ b/source/blender/io/collada/collada.cpp @@ -16,7 +16,7 @@ #include "collada.h" #include "BKE_context.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp index 95c42990830..cf162ca6c7f 100644 --- a/source/blender/io/collada/collada_utils.cpp +++ b/source/blender/io/collada/collada_utils.cpp @@ -37,7 +37,7 @@ #include "BKE_constraint.h" #include "BKE_context.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_key.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" @@ -47,7 +47,7 @@ #include "BKE_mesh_runtime.hh" #include "BKE_node.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "ANIM_bone_collections.hh" @@ -135,9 +135,7 @@ bool bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) const bool keep_transform = false; if (par && is_parent_space) { - mul_m4_m4m4(ob->runtime->object_to_world.ptr(), - par->object_to_world().ptr(), - ob->object_to_world().ptr()); + mul_m4_m4m4(ob->object_to_world, par->object_to_world, ob->object_to_world); } bool ok = ED_object_parent_set( @@ -393,12 +391,10 @@ std::string bc_replace_string(std::string data, void bc_match_scale(Object *ob, UnitConverter &bc_unit, bool scale_to_scene) { if (scale_to_scene) { - mul_m4_m4m4( - ob->runtime->object_to_world.ptr(), bc_unit.get_scale(), ob->object_to_world().ptr()); + mul_m4_m4m4(ob->object_to_world, bc_unit.get_scale(), ob->object_to_world); } - mul_m4_m4m4( - ob->runtime->object_to_world.ptr(), bc_unit.get_rotation(), ob->object_to_world().ptr()); - BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), false, false); + mul_m4_m4m4(ob->object_to_world, bc_unit.get_rotation(), ob->object_to_world); + BKE_object_apply_mat4(ob, ob->object_to_world, false, false); } void bc_match_scale(std::vector *objects_done, diff --git a/source/blender/io/collada/collada_utils.h b/source/blender/io/collada/collada_utils.h index 88fd28908d3..714ca17cc76 100644 --- a/source/blender/io/collada/collada_utils.h +++ b/source/blender/io/collada/collada_utils.h @@ -40,9 +40,9 @@ #include "BKE_context.hh" #include "BKE_idprop.h" #include "BKE_main.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/io/common/IO_dupli_persistent_id.hh b/source/blender/io/common/IO_dupli_persistent_id.hh index 5da10b364eb..cf57f6498be 100644 --- a/source/blender/io/common/IO_dupli_persistent_id.hh +++ b/source/blender/io/common/IO_dupli_persistent_id.hh @@ -3,7 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "DNA_object_types.h" /* For MAX_DUPLI_RECUR */ diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc index 7187b450b1b..09ccf47f58f 100644 --- a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc +++ b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc @@ -11,7 +11,7 @@ #include #include "BKE_anim_data.h" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BKE_key.hh" #include "BKE_object.hh" #include "BKE_particle.h" @@ -413,7 +413,7 @@ void AbstractHierarchyIterator::visit_object(Object *object, context->original_export_path = ""; context->higher_up_export_path = ""; - copy_m4_m4(context->matrix_world, object->object_to_world().ptr()); + copy_m4_m4(context->matrix_world, object->object_to_world); ExportGraph::key_type graph_index = determine_graph_index_object(context); context_update_for_graph_index(context, graph_index); diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc index 6b7d174a14a..8637b200f83 100644 --- a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc +++ b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc @@ -5,9 +5,9 @@ #include "tests/blendfile_loading_base_test.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BLI_path_util.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" #include "DNA_object_types.h" diff --git a/source/blender/io/common/intern/dupli_parent_finder.hh b/source/blender/io/common/intern/dupli_parent_finder.hh index a94b3949b69..62737d0bfd1 100644 --- a/source/blender/io/common/intern/dupli_parent_finder.hh +++ b/source/blender/io/common/intern/dupli_parent_finder.hh @@ -5,7 +5,7 @@ #include "IO_dupli_persistent_id.hh" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include #include diff --git a/source/blender/io/common/intern/object_identifier.cc b/source/blender/io/common/intern/object_identifier.cc index cc81518e2ba..3855c0b2cb8 100644 --- a/source/blender/io/common/intern/object_identifier.cc +++ b/source/blender/io/common/intern/object_identifier.cc @@ -3,7 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "IO_abstract_hierarchy_iterator.h" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" extern "C" { #include /* For INT_MAX. */ diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.cc b/source/blender/io/gpencil/intern/gpencil_io_base.cc index d487c9045ef..db98b46a902 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_base.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_base.cc @@ -24,7 +24,7 @@ #include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_material.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "UI_view2d.hh" @@ -79,7 +79,7 @@ void GpencilIO::prepare_camera_params(Scene *scene, const GpencilIOParams *ipara BKE_camera_params_compute_viewplane(¶ms, rd->xsch, rd->ysch, rd->xasp, rd->yasp); BKE_camera_params_compute_matrix(¶ms); - float4x4 viewmat = math::invert(cam_ob->object_to_world()); + float4x4 viewmat = math::invert(float4x4(cam_ob->object_to_world)); persmat_ = float4x4(params.winmat) * viewmat; } @@ -149,7 +149,7 @@ void GpencilIO::create_object_list() continue; } - float3 object_position = float3(object->object_to_world().location()); + float3 object_position = float3(object->object_to_world[3]); /* Save z-depth from view to sort from back to front. */ if (is_camera_) { diff --git a/source/blender/io/gpencil/intern/gpencil_io_capi.cc b/source/blender/io/gpencil/intern/gpencil_io_capi.cc index 2622bcfdf17..fe73a5ba165 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_capi.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_capi.cc @@ -17,7 +17,7 @@ #include "BKE_context.hh" #include "BKE_gpencil_legacy.h" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc index 9dbce4e7664..93c28885af7 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc @@ -186,7 +186,7 @@ void GpencilExporterPDF::export_gpencil_layers() /* Apply layer thickness change. */ gps_duplicate->thickness += gpl->line_change; /* Apply object scale to thickness. */ - const float scalef = mat4_to_scale(ob->object_to_world().ptr()); + const float scalef = mat4_to_scale(ob->object_to_world); gps_duplicate->thickness = ceilf(float(gps_duplicate->thickness) * scalef); CLAMP_MIN(gps_duplicate->thickness, 1.0f); /* Fill. */ diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc index 6f7e41cdb3d..6ecb1c40167 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc @@ -202,7 +202,7 @@ void GpencilExporterSVG::export_gpencil_layers() /* Apply layer thickness change. */ gps_duplicate->thickness += gpl->line_change; /* Apply object scale to thickness. */ - const float scalef = mat4_to_scale(ob->object_to_world().ptr()); + const float scalef = mat4_to_scale(ob->object_to_world); gps_duplicate->thickness = ceilf(float(gps_duplicate->thickness) * scalef); CLAMP_MIN(gps_duplicate->thickness, 1.0f); diff --git a/source/blender/io/ply/exporter/ply_export_load_plydata.cc b/source/blender/io/ply/exporter/ply_export_load_plydata.cc index 10578fcd52c..fee0d99d35d 100644 --- a/source/blender/io/ply/exporter/ply_export_load_plydata.cc +++ b/source/blender/io/ply/exporter/ply_export_load_plydata.cc @@ -55,10 +55,10 @@ static void set_world_axes_transform(const Object &object, unit_m3(axes_transform); /* +Y-forward and +Z-up are the default Blender axis settings. */ mat3_from_axis_conversion(forward, up, IO_AXIS_Y, IO_AXIS_Z, axes_transform); - mul_m4_m3m4(r_world_and_axes_transform, axes_transform, object.object_to_world().ptr()); + mul_m4_m3m4(r_world_and_axes_transform, axes_transform, object.object_to_world); /* mul_m4_m3m4 does not transform last row of obmat, i.e. location data. */ - mul_v3_m3v3(r_world_and_axes_transform[3], axes_transform, object.object_to_world().location()); - r_world_and_axes_transform[3][3] = object.object_to_world()[3][3]; + mul_v3_m3v3(r_world_and_axes_transform[3], axes_transform, object.object_to_world[3]); + r_world_and_axes_transform[3][3] = object.object_to_world[3][3]; /* Normals need inverse transpose of the regular matrix to handle non-uniform scale. */ float normal_matrix[3][3]; @@ -167,7 +167,7 @@ static float *find_or_add_attribute(const StringRef name, } static void load_custom_attributes(const Mesh *mesh, - const Span ply_to_vertex, + const Vector &ply_to_vertex, uint32_t vertex_offset, Vector &r_attributes) { diff --git a/source/blender/io/ply/importer/ply_import.cc b/source/blender/io/ply/importer/ply_import.cc index 6d060700b63..75b202a9c90 100644 --- a/source/blender/io/ply/importer/ply_import.cc +++ b/source/blender/io/ply/importer/ply_import.cc @@ -10,7 +10,7 @@ #include "BKE_lib_id.hh" #include "BKE_mesh.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DNA_collection_types.h" #include "DNA_object_types.h" diff --git a/source/blender/io/stl/exporter/stl_export.cc b/source/blender/io/stl/exporter/stl_export.cc index 14242bc90a4..df2295fc168 100644 --- a/source/blender/io/stl/exporter/stl_export.cc +++ b/source/blender/io/stl/exporter/stl_export.cc @@ -85,10 +85,10 @@ void export_frame(Depsgraph *depsgraph, /* +Y-forward and +Z-up are the default Blender axis settings. */ mat3_from_axis_conversion( export_params.forward_axis, export_params.up_axis, IO_AXIS_Y, IO_AXIS_Z, axes_transform); - mul_m4_m3m4(xform, axes_transform, obj_eval->object_to_world().ptr()); + mul_m4_m3m4(xform, axes_transform, obj_eval->object_to_world); /* mul_m4_m3m4 does not transform last row of obmat, i.e. location data. */ - mul_v3_m3v3(xform[3], axes_transform, obj_eval->object_to_world().location()); - xform[3][3] = obj_eval->object_to_world().location()[3]; + mul_v3_m3v3(xform[3], axes_transform, obj_eval->object_to_world[3]); + xform[3][3] = obj_eval->object_to_world[3][3]; /* Write triangles. */ const Span positions = mesh->vert_positions(); diff --git a/source/blender/io/stl/tests/stl_exporter_tests.cc b/source/blender/io/stl/tests/stl_exporter_tests.cc index c009b4d019d..38068b83413 100644 --- a/source/blender/io/stl/tests/stl_exporter_tests.cc +++ b/source/blender/io/stl/tests/stl_exporter_tests.cc @@ -10,7 +10,7 @@ #include "BLI_fileops.h" #include "BLI_string.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/io/stl/tests/stl_importer_tests.cc b/source/blender/io/stl/tests/stl_importer_tests.cc index 17a31204445..b8682f1e59b 100644 --- a/source/blender/io/stl/tests/stl_importer_tests.cc +++ b/source/blender/io/stl/tests/stl_importer_tests.cc @@ -11,7 +11,7 @@ #include "BLI_math_vector_types.hh" #include "BLI_string.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/io/usd/hydra/curves.cc b/source/blender/io/usd/hydra/curves.cc index 5e10dcc3f8b..be9f39735e6 100644 --- a/source/blender/io/usd/hydra/curves.cc +++ b/source/blender/io/usd/hydra/curves.cc @@ -234,9 +234,9 @@ void HairData::write_curves() Object *object = (Object *)id; float scale = particle_system_->part->rad_scale * - (std::abs(object->object_to_world().ptr()[0][0]) + - std::abs(object->object_to_world().ptr()[1][1]) + - std::abs(object->object_to_world().ptr()[2][2])) / + (std::abs(object->object_to_world[0][0]) + + std::abs(object->object_to_world[1][1]) + + std::abs(object->object_to_world[2][2])) / 3; float root = scale * particle_system_->part->rad_root; float tip = scale * particle_system_->part->rad_tip; diff --git a/source/blender/io/usd/hydra/curves.hh b/source/blender/io/usd/hydra/curves.hh index bfac0316507..d04dec983be 100644 --- a/source/blender/io/usd/hydra/curves.hh +++ b/source/blender/io/usd/hydra/curves.hh @@ -9,7 +9,7 @@ #include "BLI_set.hh" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "DNA_curves_types.h" #include "DNA_particle_types.h" diff --git a/source/blender/io/usd/hydra/mesh.hh b/source/blender/io/usd/hydra/mesh.hh index 7d189ec27bf..5daf125a6ae 100644 --- a/source/blender/io/usd/hydra/mesh.hh +++ b/source/blender/io/usd/hydra/mesh.hh @@ -9,7 +9,7 @@ #include "BLI_set.hh" -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "material.hh" #include "object.hh" diff --git a/source/blender/io/usd/hydra/object.cc b/source/blender/io/usd/hydra/object.cc index a1b26796f34..5349022a219 100644 --- a/source/blender/io/usd/hydra/object.cc +++ b/source/blender/io/usd/hydra/object.cc @@ -121,7 +121,7 @@ void ObjectData::available_materials(Set & /*paths*/) const {} void ObjectData::write_transform() { - transform = gf_matrix_from_transform(((const Object *)id)->object_to_world().ptr()); + transform = gf_matrix_from_transform(((const Object *)id)->object_to_world); } void ObjectData::write_materials() {} diff --git a/source/blender/io/usd/hydra/usd_scene_delegate.cc b/source/blender/io/usd/hydra/usd_scene_delegate.cc index d96debf16a0..9b30a417352 100644 --- a/source/blender/io/usd/hydra/usd_scene_delegate.cc +++ b/source/blender/io/usd/hydra/usd_scene_delegate.cc @@ -9,7 +9,7 @@ #include "BLI_string.h" #include "BKE_appdir.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/io/usd/hydra/volume_modifier.cc b/source/blender/io/usd/hydra/volume_modifier.cc index 023b3dfcff0..04da4c78cce 100644 --- a/source/blender/io/usd/hydra/volume_modifier.cc +++ b/source/blender/io/usd/hydra/volume_modifier.cc @@ -120,7 +120,7 @@ void VolumeModifierData::write_transform() pxr::GfMatrix4d(1.0f).SetTranslate(pxr::GfVec3d(texspace_loc)); /* applying object transform */ - transform *= gf_matrix_from_transform(object->object_to_world().ptr()); + transform *= gf_matrix_from_transform(object->object_to_world); } std::string VolumeModifierData::get_cached_file_path(std::string directory, int frame) diff --git a/source/blender/io/usd/hydra/world.cc b/source/blender/io/usd/hydra/world.cc index 926435fe27f..b4a94ba7271 100644 --- a/source/blender/io/usd/hydra/world.cc +++ b/source/blender/io/usd/hydra/world.cc @@ -18,7 +18,7 @@ #include "BLI_math_rotation.h" #include "BLI_path_util.h" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BKE_node_runtime.hh" #include "BKE_studiolight.h" diff --git a/source/blender/io/usd/intern/usd_asset_utils.cc b/source/blender/io/usd/intern/usd_asset_utils.cc index 1968bec7a14..3ef3bd30321 100644 --- a/source/blender/io/usd/intern/usd_asset_utils.cc +++ b/source/blender/io/usd/intern/usd_asset_utils.cc @@ -10,7 +10,7 @@ #include #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BLI_fileops.h" #include "BLI_path_util.h" diff --git a/source/blender/io/usd/intern/usd_capi_export.cc b/source/blender/io/usd/intern/usd_capi_export.cc index bd3d2a528d8..b7aa774bebe 100644 --- a/source/blender/io/usd/intern/usd_capi_export.cc +++ b/source/blender/io/usd/intern/usd_capi_export.cc @@ -31,9 +31,9 @@ #include "BKE_appdir.hh" #include "BKE_blender_version.h" #include "BKE_context.hh" -#include "BKE_global.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_global.h" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BLI_fileops.h" #include "BLI_path_util.h" diff --git a/source/blender/io/usd/intern/usd_capi_import.cc b/source/blender/io/usd/intern/usd_capi_import.cc index 8cb66a64f34..f1358b05b80 100644 --- a/source/blender/io/usd/intern/usd_capi_import.cc +++ b/source/blender/io/usd/intern/usd_capi_import.cc @@ -12,18 +12,18 @@ #include "BKE_appdir.hh" #include "BKE_blender_version.h" -#include "BKE_cachefile.hh" +#include "BKE_cachefile.h" #include "BKE_cdderivedmesh.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_library.hh" #include "BKE_main.hh" #include "BKE_node.hh" #include "BKE_object.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_world.h" #include "BLI_fileops.h" @@ -34,7 +34,7 @@ #include "BLI_string.h" #include "BLI_timeit.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" diff --git a/source/blender/io/usd/intern/usd_hierarchy_iterator.cc b/source/blender/io/usd/intern/usd_hierarchy_iterator.cc index fe5720ca771..cac9bce0284 100644 --- a/source/blender/io/usd/intern/usd_hierarchy_iterator.cc +++ b/source/blender/io/usd/intern/usd_hierarchy_iterator.cc @@ -24,7 +24,7 @@ #include -#include "BKE_duplilist.hh" +#include "BKE_duplilist.h" #include "BLI_assert.h" #include "BLI_utildefines.h" diff --git a/source/blender/io/usd/intern/usd_hook.cc b/source/blender/io/usd/intern/usd_hook.cc index 5da5c425814..402163000a0 100644 --- a/source/blender/io/usd/intern/usd_hook.cc +++ b/source/blender/io/usd/intern/usd_hook.cc @@ -14,7 +14,7 @@ #include "BLI_utildefines.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "RNA_access.hh" #include "RNA_prototypes.h" diff --git a/source/blender/io/usd/intern/usd_reader_material.cc b/source/blender/io/usd/intern/usd_reader_material.cc index d782f7ad27b..1f0217583b0 100644 --- a/source/blender/io/usd/intern/usd_reader_material.cc +++ b/source/blender/io/usd/intern/usd_reader_material.cc @@ -13,7 +13,7 @@ #include "BKE_material.h" #include "BKE_node.hh" #include "BKE_node_tree_update.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BLI_fileops.h" #include "BLI_map.hh" diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index 308457af496..08f8ce93d7e 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -16,7 +16,7 @@ #include "BKE_material.h" #include "BKE_mesh.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BLI_map.hh" #include "BLI_math_color.hh" diff --git a/source/blender/io/usd/intern/usd_reader_shape.cc b/source/blender/io/usd/intern/usd_reader_shape.cc index 74af12c74c8..2af88b907b4 100644 --- a/source/blender/io/usd/intern/usd_reader_shape.cc +++ b/source/blender/io/usd/intern/usd_reader_shape.cc @@ -6,7 +6,7 @@ #include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DNA_cachefile_types.h" #include "DNA_object_types.h" diff --git a/source/blender/io/usd/intern/usd_reader_stage.cc b/source/blender/io/usd/intern/usd_reader_stage.cc index 005dc07b54a..3d4d5947ba3 100644 --- a/source/blender/io/usd/intern/usd_reader_stage.cc +++ b/source/blender/io/usd/intern/usd_reader_stage.cc @@ -45,10 +45,10 @@ #include "BLI_sort.hh" #include "BLI_string.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_lib_id.hh" #include "BKE_modifier.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "CLG_log.h" diff --git a/source/blender/io/usd/intern/usd_skel_convert.cc b/source/blender/io/usd/intern/usd_skel_convert.cc index 77d76327deb..1c5571dd46c 100644 --- a/source/blender/io/usd/intern/usd_skel_convert.cc +++ b/source/blender/io/usd/intern/usd_skel_convert.cc @@ -37,7 +37,7 @@ #include "BKE_modifier.hh" #include "BKE_object.hh" #include "BKE_object_deform.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BLI_map.hh" #include "BLI_math_vector.h" @@ -1247,7 +1247,7 @@ void shape_key_export_chaser(pxr::UsdStageRefPtr stage, void export_deform_verts(const Mesh *mesh, const pxr::UsdSkelBindingAPI &skel_api, - const Span bone_names) + const Vector &bone_names) { BLI_assert(mesh); BLI_assert(skel_api); @@ -1311,7 +1311,7 @@ void export_deform_verts(const Mesh *mesh, continue; } - int def_nr = int(vert.dw[j].def_nr); + int def_nr = static_cast(vert.dw[j].def_nr); if (def_nr >= joint_index.size()) { BLI_assert_unreachable(); diff --git a/source/blender/io/usd/intern/usd_skel_convert.hh b/source/blender/io/usd/intern/usd_skel_convert.hh index 60c2b3d01c1..73291bdd31a 100644 --- a/source/blender/io/usd/intern/usd_skel_convert.hh +++ b/source/blender/io/usd/intern/usd_skel_convert.hh @@ -143,6 +143,6 @@ void shape_key_export_chaser(pxr::UsdStageRefPtr stage, */ void export_deform_verts(const Mesh *mesh, const pxr::UsdSkelBindingAPI &skel_api, - Span bone_names); + const Vector &bone_names); } // namespace blender::io::usd diff --git a/source/blender/io/usd/intern/usd_skel_root_utils.cc b/source/blender/io/usd/intern/usd_skel_root_utils.cc index d579e95c138..dedbb8cfde2 100644 --- a/source/blender/io/usd/intern/usd_skel_root_utils.cc +++ b/source/blender/io/usd/intern/usd_skel_root_utils.cc @@ -9,7 +9,7 @@ #include #include -#include "BKE_report.hh" +#include "BKE_report.h" #include "WM_types.hh" diff --git a/source/blender/io/usd/intern/usd_writer_abstract.cc b/source/blender/io/usd/intern/usd_writer_abstract.cc index f9a7a9efb93..22e1a299027 100644 --- a/source/blender/io/usd/intern/usd_writer_abstract.cc +++ b/source/blender/io/usd/intern/usd_writer_abstract.cc @@ -9,7 +9,7 @@ #include #include "BKE_customdata.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BLI_assert.h" diff --git a/source/blender/io/usd/intern/usd_writer_curves.cc b/source/blender/io/usd/intern/usd_writer_curves.cc index 717d2bc1db4..6f871c2db97 100644 --- a/source/blender/io/usd/intern/usd_writer_curves.cc +++ b/source/blender/io/usd/intern/usd_writer_curves.cc @@ -19,10 +19,10 @@ #include "BKE_curves.hh" #include "BKE_lib_id.hh" #include "BKE_material.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BLI_math_geom.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_enum_types.hh" diff --git a/source/blender/io/usd/intern/usd_writer_material.cc b/source/blender/io/usd/intern/usd_writer_material.cc index c6a25042864..1c2127e65fc 100644 --- a/source/blender/io/usd/intern/usd_writer_material.cc +++ b/source/blender/io/usd/intern/usd_writer_material.cc @@ -13,7 +13,7 @@ #include "BKE_main.hh" #include "BKE_node.hh" #include "BKE_node_runtime.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "IMB_colormanagement.hh" diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc index 81fb15ddde8..93a5c958fe3 100644 --- a/source/blender/io/usd/intern/usd_writer_mesh.cc +++ b/source/blender/io/usd/intern/usd_writer_mesh.cc @@ -37,7 +37,7 @@ #include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/io/usd/intern/usd_writer_volume.cc b/source/blender/io/usd/intern/usd_writer_volume.cc index 2a9bb0c5d59..d6e80e6cfda 100644 --- a/source/blender/io/usd/intern/usd_writer_volume.cc +++ b/source/blender/io/usd/intern/usd_writer_volume.cc @@ -11,7 +11,7 @@ #include "DNA_volume_types.h" #include "DNA_windowmanager_types.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_volume.hh" #include "BLI_fileops.h" diff --git a/source/blender/io/usd/tests/usd_curves_test.cc b/source/blender/io/usd/tests/usd_curves_test.cc index ce44139887d..c1979c4fbca 100644 --- a/source/blender/io/usd/tests/usd_curves_test.cc +++ b/source/blender/io/usd/tests/usd_curves_test.cc @@ -27,11 +27,11 @@ #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_mesh.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BLI_fileops.h" #include "BLI_math_vector_types.hh" #include "BLI_path_util.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "BKE_node_runtime.hh" diff --git a/source/blender/io/usd/tests/usd_export_test.cc b/source/blender/io/usd/tests/usd_export_test.cc index 8711f8ad6c4..73b779dee4a 100644 --- a/source/blender/io/usd/tests/usd_export_test.cc +++ b/source/blender/io/usd/tests/usd_export_test.cc @@ -28,7 +28,7 @@ #include "BLI_fileops.h" #include "BLI_math_vector_types.hh" #include "BLI_path_util.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "BKE_node_runtime.hh" diff --git a/source/blender/io/usd/tests/usd_usdz_export_test.cc b/source/blender/io/usd/tests/usd_usdz_export_test.cc index a03ff00e75c..58c9debed37 100644 --- a/source/blender/io/usd/tests/usd_usdz_export_test.cc +++ b/source/blender/io/usd/tests/usd_usdz_export_test.cc @@ -13,7 +13,7 @@ #include "BKE_main.hh" #include "BLI_fileops.h" #include "BLI_path_util.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc index 6766031fb3c..c04cdbd1db6 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc @@ -676,8 +676,8 @@ void MTLWriter::write_materials(const char *blen_filepath, return; } - char blen_filedir[FILE_MAX]; - BLI_path_split_dir_part(blen_filepath, blen_filedir, sizeof(blen_filedir)); + char blen_filedir[PATH_MAX]; + BLI_path_split_dir_part(blen_filepath, blen_filedir, PATH_MAX); BLI_path_slash_native(blen_filedir); BLI_path_normalize(blen_filedir); diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc index e3e261fb331..2f552532909 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc @@ -154,7 +154,7 @@ void OBJMesh::set_world_axes_transform(const Object &obj_eval, /* +Y-forward and +Z-up are the default Blender axis settings. */ mat3_from_axis_conversion(forward, up, IO_AXIS_Y, IO_AXIS_Z, axes_transform.ptr()); - const float4x4 object_to_world = obj_eval.object_to_world(); + const float4x4 object_to_world(obj_eval.object_to_world); const float3x3 transform = axes_transform * float3x3(object_to_world); world_and_axes_transform_ = float4x4(transform); diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_nurbs.cc b/source/blender/io/wavefront_obj/exporter/obj_export_nurbs.cc index fc5bc8a346b..8c848a0da17 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_nurbs.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_nurbs.cc @@ -35,11 +35,10 @@ void OBJCurve::set_world_axes_transform(const eIOAxis forward, const eIOAxis up) unit_m3(axes_transform); /* +Y-forward and +Z-up are the Blender's default axis settings. */ mat3_from_axis_conversion(forward, up, IO_AXIS_Y, IO_AXIS_Z, axes_transform); - mul_m4_m3m4(world_axes_transform_, axes_transform, export_object_eval_->object_to_world().ptr()); + mul_m4_m3m4(world_axes_transform_, axes_transform, export_object_eval_->object_to_world); /* #mul_m4_m3m4 does not transform last row of #Object.object_to_world, i.e. location data. */ - mul_v3_m3v3( - world_axes_transform_[3], axes_transform, export_object_eval_->object_to_world().location()); - world_axes_transform_[3][3] = export_object_eval_->object_to_world().location()[3]; + mul_v3_m3v3(world_axes_transform_[3], axes_transform, export_object_eval_->object_to_world[3]); + world_axes_transform_[3][3] = export_object_eval_->object_to_world[3][3]; } const char *OBJCurve::get_curve_name() const diff --git a/source/blender/io/wavefront_obj/exporter/obj_exporter.cc b/source/blender/io/wavefront_obj/exporter/obj_exporter.cc index 17212c292ff..9bbc1a672f4 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_exporter.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_exporter.cc @@ -10,7 +10,7 @@ #include #include -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BLI_path_util.h" #include "BLI_string.h" @@ -283,9 +283,9 @@ void export_frame(Depsgraph *depsgraph, const OBJExportParams &export_params, co write_mesh_objects(exportable_as_mesh, *frame_writer, mtl_writer.get(), export_params); if (mtl_writer) { mtl_writer->write_header(export_params.blen_filepath); - char dest_dir[FILE_MAX]; + char dest_dir[PATH_MAX]; if (export_params.file_base_for_tests[0] == '\0') { - BLI_path_split_dir_part(export_params.filepath, dest_dir, sizeof(dest_dir)); + BLI_path_split_dir_part(export_params.filepath, dest_dir, PATH_MAX); } else { STRNCPY(dest_dir, export_params.file_base_for_tests); 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 b623d27083b..3fe70ab23e5 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 @@ -474,7 +474,7 @@ static bool parse_keyword(const char *&p, const char *end, StringRef keyword) /* Special case: if there were no faces/edges in any geometries, * treat all the vertices as a point cloud. */ static void use_all_vertices_if_no_faces(Geometry *geom, - const Span> all_geometries, + const Vector> &all_geometries, const GlobalVertices &global_vertices) { if (!global_vertices.vertices.is_empty() && geom && geom->geom_type_ == GEOM_MESH) { diff --git a/source/blender/io/wavefront_obj/importer/obj_importer.cc b/source/blender/io/wavefront_obj/importer/obj_importer.cc index a9ba56a8815..90fec71aedf 100644 --- a/source/blender/io/wavefront_obj/importer/obj_importer.cc +++ b/source/blender/io/wavefront_obj/importer/obj_importer.cc @@ -16,7 +16,7 @@ #include "BLI_string_ref.hh" #include "BKE_layer.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph_build.hh" diff --git a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc index ebb57085a8e..ce382e6d4c5 100644 --- a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc +++ b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc @@ -21,7 +21,7 @@ #include "BLI_string_utf8.h" #include "BLI_vector.hh" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "DEG_depsgraph.hh" 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 ae37dd68728..124acf6bf27 100644 --- a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc +++ b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc @@ -13,14 +13,14 @@ #include "BKE_material.h" #include "BKE_mesh.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BLI_listbase.h" #include "BLI_math_base.hh" #include "BLI_math_vector_types.hh" #include "BLI_string.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index f9c0fa667b3..78f84409ca6 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -1209,7 +1209,6 @@ typedef enum IDRecalcFlag { #define FILTER_ID_WM (1ULL << 38) #define FILTER_ID_LI (1ULL << 39) #define FILTER_ID_GP (1ULL << 40) -#define FILTER_ID_IP (1ULL << 41) #define FILTER_ID_ALL \ (FILTER_ID_AC | FILTER_ID_AR | FILTER_ID_BR | FILTER_ID_CA | FILTER_ID_CU_LEGACY | \ @@ -1218,8 +1217,7 @@ typedef enum IDRecalcFlag { FILTER_ID_NT | FILTER_ID_OB | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_SCE | \ FILTER_ID_SPK | FILTER_ID_SO | FILTER_ID_TE | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_WO | \ FILTER_ID_CF | FILTER_ID_WS | FILTER_ID_LP | FILTER_ID_CV | FILTER_ID_PT | FILTER_ID_VO | \ - FILTER_ID_SIM | FILTER_ID_KE | FILTER_ID_SCR | FILTER_ID_WM | FILTER_ID_LI | FILTER_ID_GP | \ - FILTER_ID_IP) + FILTER_ID_SIM | FILTER_ID_KE | FILTER_ID_SCR | FILTER_ID_WM | FILTER_ID_LI | FILTER_ID_GP) /** * This enum defines the index assigned to each type of IDs in the array returned by @@ -1329,7 +1327,7 @@ typedef enum eID_Index { INDEX_ID_WS, INDEX_ID_WM, - /* Special values, keep last. */ + /* Special values. */ INDEX_ID_NULL, } eID_Index; diff --git a/source/blender/makesdna/DNA_asset_types.h b/source/blender/makesdna/DNA_asset_types.h index 8bbf81ab2d5..0c6ba9fdcd9 100644 --- a/source/blender/makesdna/DNA_asset_types.h +++ b/source/blender/makesdna/DNA_asset_types.h @@ -50,6 +50,11 @@ typedef struct AssetFilterSettings { * more than that from the file. So pointers to other IDs or ID data are strictly forbidden. */ typedef struct AssetMetaData { +#ifdef __cplusplus + /** Enables use with `std::unique_ptr`. */ + ~AssetMetaData(); +#endif + /** Runtime type, to reference event callbacks. Only valid for local assets. */ struct AssetTypeInfo *local_type_info; @@ -91,11 +96,6 @@ typedef struct AssetMetaData { short tot_tags; char _pad[4]; - -#ifdef __cplusplus - /** Enables use with `std::unique_ptr`. */ - ~AssetMetaData(); -#endif } AssetMetaData; typedef enum eAssetLibraryType { @@ -182,9 +182,10 @@ typedef struct AssetWeakReference { ~AssetWeakReference(); /** - * See AssetRepresentation::make_weak_reference(). + * See AssetRepresentation::make_weak_reference(). Must be freed using + * #BKE_asset_weak_reference_free(). */ - static AssetWeakReference make_reference( + static AssetWeakReference *make_reference( const blender::asset_system::AssetLibrary &library, const blender::asset_system::AssetIdentifier &asset_identifier); #endif diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index d45abd3bcc6..f1c47c5e951 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -138,7 +138,7 @@ typedef enum eCustomDataType { CD_PROP_BYTE_COLOR = 17, CD_TANGENT = 18, CD_MDISPS = 19, - CD_PROP_FLOAT4X4 = 20, + /* CD_PREVIEW_MCOL = 20, */ /* UNUSED */ /* CD_ID_MCOL = 21, */ /* CD_TEXTURE_MLOOPCOL = 22, */ /* UNUSED */ CD_CLOTH_ORCO = 23, @@ -230,7 +230,6 @@ using eCustomDataMask = uint64_t; #define CD_MASK_PROP_INT8 (1ULL << CD_PROP_INT8) #define CD_MASK_PROP_INT32_2D (1ULL << CD_PROP_INT32_2D) #define CD_MASK_PROP_QUATERNION (1ULL << CD_PROP_QUATERNION) -#define CD_MASK_PROP_FLOAT4X4 (1ULL << CD_PROP_FLOAT4X4) /** Multi-resolution loop data. */ #define CD_MASK_MULTIRES_GRIDS (CD_MASK_MDISPS | CD_GRID_PAINT_MASK) @@ -242,7 +241,7 @@ using eCustomDataMask = uint64_t; #define CD_MASK_PROP_ALL \ (CD_MASK_PROP_FLOAT | CD_MASK_PROP_FLOAT2 | CD_MASK_PROP_FLOAT3 | CD_MASK_PROP_INT32 | \ CD_MASK_PROP_COLOR | CD_MASK_PROP_STRING | CD_MASK_PROP_BYTE_COLOR | CD_MASK_PROP_BOOL | \ - CD_MASK_PROP_INT8 | CD_MASK_PROP_INT32_2D | CD_MASK_PROP_QUATERNION | CD_MASK_PROP_FLOAT4X4) + CD_MASK_PROP_INT8 | CD_MASK_PROP_INT32_2D | CD_MASK_PROP_QUATERNION) /* All color attributes */ #define CD_MASK_COLOR_ALL (CD_MASK_PROP_COLOR | CD_MASK_PROP_BYTE_COLOR) diff --git a/source/blender/makesdna/DNA_gpencil_legacy_types.h b/source/blender/makesdna/DNA_gpencil_legacy_types.h index 6cfa3ab18f8..dfb7a7ed6d1 100644 --- a/source/blender/makesdna/DNA_gpencil_legacy_types.h +++ b/source/blender/makesdna/DNA_gpencil_legacy_types.h @@ -73,9 +73,9 @@ typedef struct bGPDspoint { /** Factor of uv along the stroke. */ float uv_fac; - /** UV rotation for dot mode. */ + /** Uv rotation for dot mode. */ float uv_rot; - /** UV for fill mode */ + /** Uv for fill mode */ float uv_fill[2]; /** Vertex Color RGBA (A=mix factor). */ @@ -186,9 +186,9 @@ typedef struct bGPDcurve_point { /** Factor of uv along the stroke. */ float uv_fac; - /** UV rotation for dot mode. */ + /** Uv rotation for dot mode. */ float uv_rot; - /** UV for fill mode. */ + /** Uv for fill mode. */ float uv_fill[2]; /** Vertex Color RGBA (A=mix factor). */ diff --git a/source/blender/makesdna/DNA_grease_pencil_types.h b/source/blender/makesdna/DNA_grease_pencil_types.h index 7baf8ed18f3..8b4e551649b 100644 --- a/source/blender/makesdna/DNA_grease_pencil_types.h +++ b/source/blender/makesdna/DNA_grease_pencil_types.h @@ -292,17 +292,6 @@ typedef struct GreasePencilLayer { * List of `GreasePencilLayerMask`. */ ListBase masks; - /** - * Layer parent object. Can be an armature in which case the `parsubstr` is the bone name. - */ - struct Object *parent; - char *parsubstr; - /** - * Layer transform UI settings. These should *not* be used to do any computation. - * Use the functions is the `bke::greasepencil::Layer` class instead. - */ - float translation[3], rotation[3], scale[3]; - char _pad2[4]; /** * Runtime struct pointer. */ @@ -334,7 +323,6 @@ typedef struct GreasePencilLayerTreeGroup { */ typedef enum GreasePencilFlag { GREASE_PENCIL_ANIM_CHANNEL_EXPANDED = (1 << 0), - GREASE_PENCIL_AUTOLOCK_LAYERS = (1 << 1), } GreasePencilFlag; /** @@ -489,7 +477,6 @@ typedef struct GreasePencil { blender::bke::greasepencil::Layer *get_active_layer(); void set_active_layer(const blender::bke::greasepencil::Layer *layer); bool is_layer_active(const blender::bke::greasepencil::Layer *layer) const; - void autolock_inactive_layers(); /* Adding layers and layer groups. */ /** Adds a new layer with the given name to the top of root group. */ @@ -531,13 +518,6 @@ typedef struct GreasePencil { void remove_layer(blender::bke::greasepencil::Layer &layer); /* Drawing API functions. */ - - /** - * Low-level resizing of drawings array. Only allocates new entries in the array, no drawings are - * created in case of size increase. In case of size decrease, the removed drawings are deleted. - */ - void resize_drawings(const int new_num); - /** Add `add_num` new empty geometry drawings. */ void add_empty_drawings(int add_num); void add_duplicate_drawings(int duplicate_num, const blender::bke::greasepencil::Drawing &drawing); diff --git a/source/blender/makesdna/DNA_layer_types.h b/source/blender/makesdna/DNA_layer_types.h index 661a7fde678..c7c431ceebe 100644 --- a/source/blender/makesdna/DNA_layer_types.h +++ b/source/blender/makesdna/DNA_layer_types.h @@ -178,7 +178,6 @@ typedef struct ViewLayer { int samples; struct Material *mat_override; - struct World *world_override; /** Equivalent to datablocks ID properties. */ struct IDProperty *id_properties; diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 725cca51cb5..6fd60796856 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -74,7 +74,7 @@ typedef struct MaterialGPencilStyle { /** Radius for radial gradients. */ float gradient_radius DNA_DEPRECATED; char _pad2[4]; - /** UV coordinates scale. */ + /** Uv coordinates scale. */ float gradient_scale[2] DNA_DEPRECATED; /** Factor to shift filling in 2d space. */ float gradient_shift[2] DNA_DEPRECATED; diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 10ccb0c9ee2..f2849b06f2f 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -74,7 +74,7 @@ typedef struct Mesh { int verts_num; /** The number of edges in the mesh, and the size of #edge_data. */ int edges_num; - /** The number of faces in the mesh, and the size of #face_data. */ + /** The number of polygons/faces in the mesh, and the size of #face_data. */ int faces_num; /** The number of face corners in the mesh, and the size of #corner_data. */ int corners_num; @@ -82,7 +82,7 @@ typedef struct Mesh { /** * Array owned by mesh. See #Mesh::faces() and #OffsetIndices. * - * This array is shared based on the bke::MeshRuntime::face_offsets_sharing_info. + * This array is shared based on the bke::MeshRuntime::poly_offsets_sharing_info. * Avoid accessing directly when possible. */ int *face_offset_indices; @@ -232,43 +232,43 @@ typedef struct Mesh { MeshRuntimeHandle *runtime; #ifdef __cplusplus /** - * Array of vertex positions. Edges and face corners are defined by indices into this array. + * Array of vertex positions. Edges and faces are defined by indices into this array. */ blender::Span vert_positions() const; /** Write access to vertex data. */ blender::MutableSpan vert_positions_for_write(); /** - * Array of edges, containing vertex indices, stored in the ".edge_verts" attribute. For simple - * triangle or quad meshes, edges could be calculated from the face and #corner_edge arrays. - * However, edges need to be stored explicitly for edge domain attributes and to support loose + * Array of edges, containing vertex indices, stored in the ".edge_verts" attributes. For simple + * triangle or quad meshes, edges could be calculated from the face and "corner edge" arrays, + * however, edges need to be stored explicitly to edge domain attributes and to support loose * edges that aren't connected to faces. */ blender::Span edges() const; /** Write access to edge data. */ blender::MutableSpan edges_for_write(); /** - * Face topology information (using the same internal data as #face_offsets()). Each face is a - * contiguous chunk of face corners represented as an #IndexRange. Each face can be used to slice - * the #corner_verts or #corner_edges arrays to find the vertices or edges that each face uses. + * Face topology storage of the offset of each face's section of the face corners. The size of + * each face is encoded using the next offset value. Can be used to slice the #corner_verts or + * #corner_edges arrays to find the vertices or edges that make up each face. */ blender::OffsetIndices faces() const; /** - * Return an array containing the first corner of each face. and the size of the face encoded as - * the next offset. The total number of corners is the final value, and the first value is always - * zero. May be empty if there are no faces. + * Index of the first corner of each face, and the size of the face encoded as the next + * offset. The total number of corners is the final value, and the first value is always zero. + * May be empty if there are no polygons. */ blender::Span face_offsets() const; - /** Write access to #face_offsets data. */ + /** Write access to #poly_offsets data. */ blender::MutableSpan face_offsets_for_write(); /** * Array of vertices for every face corner, stored in the ".corner_vert" integer attribute. * For example, the vertices in a face can be retrieved with the #slice method: * \code{.cc} - * const Span face_verts = corner_verts.slice(face); + * const Span poly_verts = corner_verts.slice(face); * \endcode - * This span can often be passed as an argument in lieu of a face and the entire corner verts - * array. + * Such a span can often be passed as an argument in lieu of a polygon or the entire corner + * verts array. */ blender::Span corner_verts() const; /** Write access to the #corner_verts data. */ @@ -385,7 +385,7 @@ typedef struct Mesh { */ blender::bke::MeshNormalDomain normals_domain(const bool support_sharp_face = false) const; /** - * Normal direction of faces, defined by positions and the winding direction of face corners. + * Normal direction of polygons, defined by positions and the winding direction of face corners. */ blender::Span face_normals() const; /** diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index 014e4ad4393..24dff6b3cc4 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -82,7 +82,9 @@ enum { * }; * * // Access all triangles in a given face. - * const Span corner_tris = corner_tris.slice(face_triangles_range(faces, i)); + * const IndexRange face = faces[i]; + * const Span corner_tris = corner_tris.slice(poly_to_tri_count(i, face.start()), + * bke::mesh::face_triangles_num(face.size())); * \endcode * * It may also be useful to check whether or not two vertices of a triangle form an edge in the diff --git a/source/blender/makesdna/DNA_modifier_defaults.h b/source/blender/makesdna/DNA_modifier_defaults.h index ccfce0057b0..5914c65ef93 100644 --- a/source/blender/makesdna/DNA_modifier_defaults.h +++ b/source/blender/makesdna/DNA_modifier_defaults.h @@ -812,7 +812,7 @@ { \ .level = 1, \ } - + #define _DNA_DEFAULT_GreasePencilColorModifierData \ { \ .color_mode = MOD_GREASE_PENCIL_COLOR_BOTH, \ @@ -859,7 +859,7 @@ .step = 4, \ .seed = 1, \ } - + #define _DNA_DEFAULT_GreasePencilMirrorModifierData \ { \ .flag = MOD_GREASE_PENCIL_MIRROR_AXIS_X, \ @@ -872,83 +872,4 @@ .thickness = 0.02, \ } -#define _DNA_DEFAULT_GreasePencilLatticeModifierData \ - { \ - .object = NULL, \ - .strength = 1.0f, \ - } - -#define _DNA_DEFAULT_GreasePencilDashModifierData \ - { \ - .dash_offset = 0, \ - .segments_array = NULL, \ - .segments_num = 0, \ - .segment_active_index = 0, \ - } - -#define _DNA_DEFAULT_GreasePencilDashModifierSegment \ - { \ - .name = "Segment", \ - .dash = 2, \ - .gap = 1, \ - .radius = 1.0f, \ - .opacity = 1.0f, \ - .mat_nr = -1, \ - } - -#define _DNA_DEFAULT_GreasePencilMultiModifierData \ - { \ - .flag = 0, \ - .duplications = 3, \ - .distance = 0.1f, \ - .offset = 0.0f, \ - .fading_center = 0.5f, \ - .fading_thickness = 0.5f, \ - .fading_opacity = 0.5f, \ - } - -#define _DNA_DEFAULT_GreasePencilLengthModifierData \ - { \ - .start_fac = 0.1f,\ - .end_fac = 0.1f,\ - .overshoot_fac = 0.1f,\ - .flag = GP_LENGTH_USE_CURVATURE,\ - .point_density = 30.0f,\ - .segment_influence = 0.0f,\ - .max_angle = DEG2RAD(170.0f),\ - .rand_start_fac = 0.0f,\ - .rand_end_fac = 0.0f,\ - .rand_offset = 0.0f,\ - .seed = 0,\ - .step = 4,\ - } - -#define _DNA_DEFAULT_GreasePencilWeightAngleModifierData \ - { \ - .flag = 0, \ - .axis = 1, \ - } - -#define _DNA_DEFAULT_GreasePencilArrayModifierData \ - { \ - .object = NULL, \ - .count = 2, \ - .flag = GP_ARRAY_USE_RELATIVE, \ - .offset = {0.0f, 0.0f, 0.0f}, \ - .shift = {1.0f, 0.0f, 0.0f}, \ - .rnd_offset = {0.0f, 0.0f, 0.0f}, \ - .rnd_rot = {0.0f, 0.0f, 0.0f}, \ - .rnd_scale = {0.0f, 0.0f, 0.0f}, \ - .seed = 1, \ - .mat_rpl = 0, \ - } - -#define _DNA_DEFAULT_GreasePencilWeightProximityModifierData \ - { \ - .target_vgname = "", \ - .flag = 0, \ - .dist_start = 0.0f, \ - .dist_end = 20.0f, \ - } - /* clang-format off */ diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index a94a2af2417..148e598e131 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -15,8 +15,6 @@ #include "DNA_session_uid_types.h" #ifdef __cplusplus -# include "BLI_span.hh" - namespace blender { struct NodesModifierRuntime; } @@ -104,13 +102,6 @@ typedef enum ModifierType { eModifierType_GreasePencilNoise = 67, eModifierType_GreasePencilMirror = 68, eModifierType_GreasePencilThickness = 69, - eModifierType_GreasePencilLattice = 70, - eModifierType_GreasePencilDash = 71, - eModifierType_GreasePencilMultiply = 72, - eModifierType_GreasePencilLength = 73, - eModifierType_GreasePencilWeightAngle = 74, - eModifierType_GreasePencilArray = 75, - eModifierType_GreasePencilWeightProximity = 76, NUM_MODIFIER_TYPES, } ModifierType; @@ -2668,7 +2659,6 @@ typedef enum GreasePencilTintModifierFlag { MOD_GREASE_PENCIL_TINT_USE_WEIGHT_AS_FACTOR = (1 << 0), } GreasePencilTintModifierFlag; -/* Enum definitions for length modifier stays in the old DNA for the moment. */ typedef struct GreasePencilSmoothModifierData { ModifierData modifier; GreasePencilModifierInfluenceData influence; @@ -2782,168 +2772,3 @@ typedef enum GreasePencilThicknessModifierFlag { MOD_GREASE_PENCIL_THICK_NORMALIZE = (1 << 0), MOD_GREASE_PENCIL_THICK_WEIGHT_FACTOR = (1 << 1), } GreasePencilThicknessModifierFlag; - -typedef struct GreasePencilLatticeModifierData { - ModifierData modifier; - GreasePencilModifierInfluenceData influence; - struct Object *object; - float strength; - char _pad[4]; -} GreasePencilLatticeModifierData; - -typedef struct GreasePencilDashModifierSegment { - char name[64]; - int dash; - int gap; - float radius; - float opacity; - int mat_nr; - /** #GreasePencilDashModifierFlag */ - int flag; -} GreasePencilDashModifierSegment; - -typedef struct GreasePencilDashModifierData { - ModifierData modifier; - GreasePencilModifierInfluenceData influence; - - GreasePencilDashModifierSegment *segments_array; - int segments_num; - int segment_active_index; - - int dash_offset; - char _pad[4]; - -#ifdef __cplusplus - blender::Span segments() const; - blender::MutableSpan segments(); -#endif -} GreasePencilDashModifierData; - -typedef enum GreasePencilDashModifierFlag { - MOD_GREASE_PENCIL_DASH_USE_CYCLIC = (1 << 0), -} GreasePencilDashModifierFlag; - -typedef struct GreasePencilMultiModifierData { - ModifierData modifier; - GreasePencilModifierInfluenceData influence; - - /* #GreasePencilMultiplyModifierFlag */ - int flag; - - int duplications; - float distance; - /* -1:inner 0:middle 1:outer */ - float offset; - - float fading_center; - float fading_thickness; - float fading_opacity; - - int _pad0; - - void *_pad; -} GreasePencilMultiModifierData; - -typedef enum GreasePencilMultiplyModifierFlag { - /* GP_MULTIPLY_ENABLE_ANGLE_SPLITTING = (1 << 1), Deprecated. */ - MOD_GREASE_PENCIL_MULTIPLY_ENABLE_FADING = (1 << 2), -} GreasePencilMultiplyModifierFlag; - -typedef struct GreasePencilLengthModifierData { - ModifierData modifier; - GreasePencilModifierInfluenceData influence; - int flag; - float start_fac, end_fac; - float rand_start_fac, rand_end_fac, rand_offset; - float overshoot_fac; - /** (first element is the index) random values. */ - int seed; - /** How many frames before recalculate randoms. */ - int step; - /** #eLengthGpencil_Type. */ - int mode; - char _pad[4]; - /* Curvature parameters. */ - float point_density; - float segment_influence; - float max_angle; - - void *_pad1; -} GreasePencilLengthModifierData; - -typedef struct GreasePencilWeightAngleModifierData { - ModifierData modifier; - GreasePencilModifierInfluenceData influence; - /** #GreasePencilWeightAngleModifierFlag */ - int flag; - float min_weight; - /** Axis. */ - int16_t axis; - /** #GreasePencilWeightAngleModifierSpace */ - int16_t space; - /** Angle */ - float angle; - /** Weights output to this vertex group, can be the same as source group. */ - char target_vgname[64]; - - void *_pad; -} GreasePencilWeightAngleModifierData; - -typedef enum GreasePencilWeightAngleModifierFlag { - MOD_GREASE_PENCIL_WEIGHT_ANGLE_MULTIPLY_DATA = (1 << 5), - MOD_GREASE_PENCIL_WEIGHT_ANGLE_INVERT_OUTPUT = (1 << 6), -} GreasePencilWeightAngleModifierFlag; - -typedef enum GreasePencilWeightAngleModifierSpace { - MOD_GREASE_PENCIL_WEIGHT_ANGLE_SPACE_LOCAL = 0, - MOD_GREASE_PENCIL_WEIGHT_ANGLE_SPACE_WORLD = 1, -} GreasePencilWeightAngleModifierSpace; - -typedef struct GreasePencilArrayModifierData { - ModifierData modifier; - GreasePencilModifierInfluenceData influence; - struct Object *object; - int count; - /** #GreasePencilArrayModifierFlag */ - int flag; - float offset[3]; - float shift[3]; - - float rnd_offset[3]; - float rnd_rot[3]; - float rnd_scale[3]; - - char _pad[4]; - /** (first element is the index) random values. (?) */ - int seed; - - /* Replacement material index. */ - int mat_rpl; -} GreasePencilArrayModifierData; - -typedef enum GreasePencilArrayModifierFlag { - MOD_GREASE_PENCIL_ARRAY_USE_OFFSET = (1 << 7), - MOD_GREASE_PENCIL_ARRAY_USE_RELATIVE = (1 << 8), - MOD_GREASE_PENCIL_ARRAY_USE_OB_OFFSET = (1 << 9), - MOD_GREASE_PENCIL_ARRAY_UNIFORM_RANDOM_SCALE = (1 << 10), -} GreasePencilArrayModifierFlag; - -typedef struct GreasePencilWeightProximityModifierData { - ModifierData modifier; - GreasePencilModifierInfluenceData influence; - - /* #GreasePencilWeightProximityFlag. */ - int flag; - char target_vgname[64]; - float min_weight; - - float dist_start; - float dist_end; - - struct Object *object; -} GreasePencilWeightProximityModifierData; - -typedef enum GreasePencilWeightProximityFlag { - MOD_GREASE_PENCIL_WEIGHT_PROXIMITY_INVERT_OUTPUT = (1 << 0), - MOD_GREASE_PENCIL_WEIGHT_PROXIMITY_MULTIPLY_DATA = (1 << 1), -} GreasePencilWeightProximityFlag; diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 36064a22db8..05852be43f1 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -263,7 +263,6 @@ typedef enum eNodeSocketDatatype { SOCK_MATERIAL = 13, SOCK_ROTATION = 14, SOCK_MENU = 15, - SOCK_MATRIX = 16, } eNodeSocketDatatype; /** Socket shape. */ @@ -540,22 +539,6 @@ enum { */ typedef struct bNodeInstanceKey { unsigned int value; - -#ifdef __cplusplus - inline bool operator==(const bNodeInstanceKey &other) const - { - return value == other.value; - } - inline bool operator!=(const bNodeInstanceKey &other) const - { - return !(*this == other); - } - - inline uint64_t hash() const - { - return value; - } -#endif } bNodeInstanceKey; /** @@ -619,6 +602,16 @@ enum { NTREE_QUALITY_LOW = 2, }; +/** #bNodeTree::chunksize */ +enum { + NTREE_CHUNKSIZE_32 = 32, + NTREE_CHUNKSIZE_64 = 64, + NTREE_CHUNKSIZE_128 = 128, + NTREE_CHUNKSIZE_256 = 256, + NTREE_CHUNKSIZE_512 = 512, + NTREE_CHUNKSIZE_1024 = 1024, +}; + typedef struct bNestedNodePath { /** ID of the node that is or contains the nested node. */ int32_t node_id; @@ -679,11 +672,15 @@ typedef struct bNodeTree { short edit_quality; /** Quality setting when rendering. */ short render_quality; + /** Tile size for compositor engine. */ + int chunksize; /** Execution mode to use for compositor engine. */ int execution_mode; /** Execution mode to use for compositor engine. */ int precision; + char _pad[4]; + rctf viewer_border; /** @@ -828,8 +825,12 @@ enum { enum { /** For animation editors. */ NTREE_DS_EXPAND = 1 << 0, + /** Use OPENCL. */ + NTREE_COM_OPENCL = 1 << 1, /** Two pass. */ NTREE_TWO_PASS = 1 << 2, + /** Use group-node buffers. */ + NTREE_COM_GROUPNODE_BUFFER = 1 << 3, /** Use a border for viewer nodes. */ NTREE_VIEWER_BORDER = 1 << 4, /** @@ -841,8 +842,9 @@ enum { /* tree->execution_mode */ typedef enum eNodeTreeExecutionMode { - NTREE_EXECUTION_MODE_CPU = 0, - NTREE_EXECUTION_MODE_GPU = 2, + NTREE_EXECUTION_MODE_TILED = 0, + NTREE_EXECUTION_MODE_FULL_FRAME = 1, + NTREE_EXECUTION_MODE_REALTIME = 2, } eNodeTreeExecutionMode; /* tree->precision */ diff --git a/source/blender/makesdna/DNA_object_defaults.h b/source/blender/makesdna/DNA_object_defaults.h index 878750b57ef..6797e76b2cf 100644 --- a/source/blender/makesdna/DNA_object_defaults.h +++ b/source/blender/makesdna/DNA_object_defaults.h @@ -25,6 +25,7 @@ \ .constinv = _DNA_DEFAULT_UNIT_M4, \ .parentinv = _DNA_DEFAULT_UNIT_M4, \ + .object_to_world = _DNA_DEFAULT_UNIT_M4, \ \ .scale = {1, 1, 1}, \ .dscale = {1, 1, 1}, \ diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 5af3f2f9e91..db110cbb2c0 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -24,10 +24,6 @@ #include "DNA_defs.h" #include "DNA_listBase.h" -#ifdef __cplusplus -# include "BLI_math_matrix_types.hh" -#endif - #ifdef __cplusplus namespace blender::bke { struct ObjectRuntime; @@ -278,6 +274,9 @@ typedef struct Object { float rotAxis[3], drotAxis[3]; /** Axis angle rotation - angle part. */ float rotAngle, drotAngle; + /** Final transformation matrices with constraints & animsys applied. */ + float object_to_world[4][4]; + float world_to_object[4][4]; /** Inverse result of parent, so that object doesn't 'stick' to parent. */ float parentinv[4][4]; /** Inverse result of constraints. @@ -400,11 +399,6 @@ typedef struct Object { struct LightProbeObjectCache *lightprobe_cache; ObjectRuntimeHandle *runtime; - -#ifdef __cplusplus - const blender::float4x4 &object_to_world() const; - const blender::float4x4 &world_to_object() const; -#endif } Object; /** DEPRECATED: this is not used anymore because hooks are now modifiers. */ diff --git a/source/blender/makesdna/DNA_scene_defaults.h b/source/blender/makesdna/DNA_scene_defaults.h index 7d94171a1d1..29661489c52 100644 --- a/source/blender/makesdna/DNA_scene_defaults.h +++ b/source/blender/makesdna/DNA_scene_defaults.h @@ -76,6 +76,7 @@ .framapto = 100, \ .images = 100, \ .framelen = 1.0, \ + .blurfac = 0.5, \ .frs_sec = 24, \ .frs_sec_base = 1, \ \ @@ -128,8 +129,6 @@ .unit_line_thickness = 1.0f, \ \ .ffcodecdata = _DNA_DEFAULT_FFMpegCodecData, \ - \ - .motion_blur_shutter = 0.5f, \ } #define _DNA_DEFAULT_AudioData \ @@ -227,6 +226,7 @@ .bloom_radius = 6.5f, \ .bloom_clamp = 0.0f, \ \ + .motion_blur_shutter = 0.5f, \ .motion_blur_depth_scale = 100.0f, \ .motion_blur_max = 32, \ .motion_blur_steps = 1, \ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 133de7bc78c..dc9e9d868f8 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -44,16 +44,6 @@ struct World; struct bGPdata; struct bNodeTree; -/** Workaround to forward-declare C++ type in C header. */ -#ifdef __cplusplus -namespace blender::bke { -class SceneRuntime; -} -using SceneRuntimeHandle = blender::bke::SceneRuntime; -#else // __cplusplus -typedef struct SceneRuntimeHandle SceneRuntimeHandle; -#endif // __cplusplus - /* -------------------------------------------------------------------- */ /** \name FFMPEG * \{ */ @@ -199,7 +189,6 @@ typedef struct SceneRenderLayer { /** Converted to ViewLayer setting. */ struct Material *mat_override DNA_DEPRECATED; - struct World *world_override DNA_DEPRECATED; /** Converted to LayerCollection cycles camera visibility override. */ unsigned int lay DNA_DEPRECATED; @@ -697,17 +686,21 @@ typedef struct RenderData { int images, framapto; short flag, threads; - float framelen; + float framelen, blurfac; /** Frames to jump during render/playback. */ int frame_step; + char _pad10[2]; + /** For the dimensions presets menu. */ short dimensionspreset; /** Size in %. */ short size; + char _pad6[2]; + /* From buttons: */ /** * The desired number of pixels in the x direction @@ -852,9 +845,7 @@ typedef struct RenderData { /* Hair Display. */ short hair_type, hair_subdiv; - /** Motion blur */ - float motion_blur_shutter; - int motion_blur_position; + /** Motion blur shutter. */ struct CurveMapping mblur_shutter_curve; } RenderData; @@ -869,13 +860,6 @@ typedef enum eHairType { SCE_HAIR_SHAPE_STRIP = 1, } eHairType; -/** #RenderData::motion_blur_position */ -enum { - SCE_MB_CENTER = 0, - SCE_MB_START = 1, - SCE_MB_END = 2, -}; - /** \} */ /* -------------------------------------------------------------------- */ @@ -1556,7 +1540,7 @@ typedef struct ToolSettings { /** Weight paint. */ VPaint *wpaint; Sculpt *sculpt; - /** UV smooth. */ + /** Uv smooth. */ UvSculpt *uvsculpt; /** Gpencil paint. */ GpPaint *gp_paint; @@ -1906,8 +1890,8 @@ typedef struct SceneEEVEE { int motion_blur_samples DNA_DEPRECATED; int motion_blur_max; int motion_blur_steps; - int motion_blur_position_deprecated DNA_DEPRECATED; - float motion_blur_shutter_deprecated DNA_DEPRECATED; + int motion_blur_position; + float motion_blur_shutter; float motion_blur_depth_scale; int shadow_method DNA_DEPRECATED; @@ -2097,9 +2081,6 @@ typedef struct Scene { struct SceneEEVEE eevee; struct SceneGpencil grease_pencil_settings; struct SceneHydra hydra; - - SceneRuntimeHandle *runtime; - void *_pad9; } Scene; /** \} */ @@ -2864,7 +2845,7 @@ enum { SCE_EEVEE_GTAO_BOUNCE = (1 << 6), // SCE_EEVEE_DOF_ENABLED = (1 << 7), /* Moved to camera->dof.flag */ SCE_EEVEE_BLOOM_ENABLED = (1 << 8), - SCE_EEVEE_MOTION_BLUR_ENABLED_DEPRECATED = (1 << 9), /* Moved to scene->r.mode */ + SCE_EEVEE_MOTION_BLUR_ENABLED = (1 << 9), SCE_EEVEE_SHADOW_HIGH_BITDEPTH = (1 << 10), SCE_EEVEE_TAA_REPROJECTION = (1 << 11), // SCE_EEVEE_SSS_ENABLED = (1 << 12), /* Unused */ @@ -2907,6 +2888,13 @@ enum { /* SHADOW_METHOD_MAX = 3, */ /* UNUSED */ }; +/** #SceneEEVEE::motion_blur_position */ +enum { + SCE_EEVEE_MB_CENTER = 0, + SCE_EEVEE_MB_START = 1, + SCE_EEVEE_MB_END = 2, +}; + /** #SceneDisplay->render_aa and #SceneDisplay->viewport_aa */ enum { SCE_DISPLAY_AA_OFF = 0, diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index aab7a64d142..2f9b3b1d01e 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -1033,7 +1033,7 @@ typedef enum eFileSelectType { /** * #FileSelectParams.flag / `sfile->params->flag`. * \note short flag, also used as 16 lower bits of flags in link/append code - * (WM and BLO code area, see #eBLOLibLinkFlags in BLO_readfile.hh). + * (WM and BLO code area, see #eBLOLibLinkFlags in BLO_readfile.h). */ typedef enum eFileSel_Params_Flag { FILE_PARAMS_FLAG_UNUSED_1 = (1 << 0), @@ -2037,7 +2037,6 @@ typedef enum eSpreadsheetColumnValueType { SPREADSHEET_VALUE_TYPE_INT8 = 9, SPREADSHEET_VALUE_TYPE_INT32_2D = 10, SPREADSHEET_VALUE_TYPE_QUATERNION = 11, - SPREADSHEET_VALUE_TYPE_FLOAT4X4 = 12, } eSpreadsheetColumnValueType; /** diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 098b6d8eb05..96977c5cd11 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -716,13 +716,12 @@ typedef struct UserDef_Experimental { char use_extended_asset_browser; char use_sculpt_texture_paint; char use_grease_pencil_version3; - char use_new_matrix_socket; char enable_overlay_next; char use_new_volume_nodes; char use_shader_node_previews; char use_extension_repos; - char _pad[3]; + char _pad[4]; /** `makesdna` does not allow empty structs. */ } UserDef_Experimental; @@ -1053,7 +1052,7 @@ typedef struct UserDef { UserDef_Runtime runtime; } UserDef; -/** From `source/blender/blenkernel/intern/blender.cc`. */ +/** From blenkernel `blender.cc`. */ extern UserDef U; /* ***************** USERDEF ****************** */ diff --git a/source/blender/makesdna/DNA_vec_types.h b/source/blender/makesdna/DNA_vec_types.h index ba98dadf16b..ea2063e1e4d 100644 --- a/source/blender/makesdna/DNA_vec_types.h +++ b/source/blender/makesdna/DNA_vec_types.h @@ -49,10 +49,6 @@ typedef struct vec4i { typedef struct vec4f { float x, y, z, w; } vec4f; - -typedef struct mat4x4f { - float value[4][4]; -} mat4x4f; /* typedef struct vec4d { double x, y, z, w; diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index cdf8166bc9f..e55911bd0bf 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -21,16 +21,6 @@ using std_mutex_type = std::mutex; # define std_mutex_type void #endif -/** Workaround to forward-declare C++ type in C header. */ -#ifdef __cplusplus -namespace blender::bke { -class WindowManagerRuntime; -} -using WindowManagerRuntimeHandle = blender::bke::WindowManagerRuntime; -#else // __cplusplus -typedef struct WindowManagerRuntimeHandle WindowManagerRuntimeHandle; -#endif // __cplusplus - /* Defined here: */ struct wmWindow; @@ -184,6 +174,9 @@ typedef struct wmWindowManager { struct GSet *notifier_queue_set; void *_pad1; + /** Information and error reports. */ + struct ReportList reports; + /** Threaded jobs manager. */ ListBase jobs; @@ -214,13 +207,15 @@ typedef struct wmWindowManager { /** All undo history (runtime only). */ struct UndoStack *undo_stack; + /** Indicates whether interface is locked for user interaction. */ + char is_interface_locked; + char _pad[7]; + struct wmMsgBus *message_bus; // #ifdef WITH_XR_OPENXR wmXrData xr; // #endif - - WindowManagerRuntimeHandle *runtime; } wmWindowManager; #define WM_KEYCONFIG_ARRAY_P(wm) &(wm)->defaultconf, &(wm)->addonconf, &(wm)->userconf diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c index 09135af33a7..4e363153c0e 100644 --- a/source/blender/makesdna/intern/dna_defaults.c +++ b/source/blender/makesdna/intern/dna_defaults.c @@ -294,7 +294,6 @@ SDNA_DEFAULT_DECL_STRUCT(WeldModifierData); SDNA_DEFAULT_DECL_STRUCT(WireframeModifierData); SDNA_DEFAULT_DECL_STRUCT(GreasePencilSubdivModifierData); SDNA_DEFAULT_DECL_STRUCT(GreasePencilNoiseModifierData); -SDNA_DEFAULT_DECL_STRUCT(GreasePencilLengthModifierData); /* Grease Pencil 3.0 modifiers. */ SDNA_DEFAULT_DECL_STRUCT(GreasePencilSmoothModifierData); @@ -334,13 +333,6 @@ SDNA_DEFAULT_DECL_STRUCT(GreasePencilTintModifierData); SDNA_DEFAULT_DECL_STRUCT(GreasePencilOffsetModifierData); SDNA_DEFAULT_DECL_STRUCT(GreasePencilMirrorModifierData); SDNA_DEFAULT_DECL_STRUCT(GreasePencilThickModifierData); -SDNA_DEFAULT_DECL_STRUCT(GreasePencilLatticeModifierData); -SDNA_DEFAULT_DECL_STRUCT(GreasePencilDashModifierSegment); -SDNA_DEFAULT_DECL_STRUCT(GreasePencilDashModifierData); -SDNA_DEFAULT_DECL_STRUCT(GreasePencilMultiModifierData); -SDNA_DEFAULT_DECL_STRUCT(GreasePencilWeightAngleModifierData); -SDNA_DEFAULT_DECL_STRUCT(GreasePencilArrayModifierData); -SDNA_DEFAULT_DECL_STRUCT(GreasePencilWeightProximityModifierData); #undef SDNA_DEFAULT_DECL_STRUCT @@ -557,8 +549,6 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = { SDNA_DEFAULT_DECL(WireframeModifierData), SDNA_DEFAULT_DECL(GreasePencilSubdivModifierData), SDNA_DEFAULT_DECL(GreasePencilNoiseModifierData), - SDNA_DEFAULT_DECL(GreasePencilLengthModifierData), - SDNA_DEFAULT_DECL(GreasePencilWeightAngleModifierData), /* Grease Pencil 3.0 defaults. */ SDNA_DEFAULT_DECL(GreasePencilSmoothModifierData), @@ -598,12 +588,6 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = { SDNA_DEFAULT_DECL(GreasePencilOffsetModifierData), SDNA_DEFAULT_DECL(GreasePencilMirrorModifierData), SDNA_DEFAULT_DECL(GreasePencilThickModifierData), - SDNA_DEFAULT_DECL(GreasePencilLatticeModifierData), - SDNA_DEFAULT_DECL(GreasePencilDashModifierSegment), - SDNA_DEFAULT_DECL(GreasePencilDashModifierData), - SDNA_DEFAULT_DECL(GreasePencilMultiModifierData), - SDNA_DEFAULT_DECL(GreasePencilArrayModifierData), - SDNA_DEFAULT_DECL(GreasePencilWeightProximityModifierData), }; #undef SDNA_DEFAULT_DECL #undef SDNA_DEFAULT_DECL_EX diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h index b5b2f845b8f..6af60ab0869 100644 --- a/source/blender/makesdna/intern/dna_rename_defs.h +++ b/source/blender/makesdna/intern/dna_rename_defs.h @@ -149,6 +149,8 @@ DNA_STRUCT_RENAME_ELEM(NodesModifierData, simulation_bake_directory, bake_direct DNA_STRUCT_RENAME_ELEM(Object, col, color) DNA_STRUCT_RENAME_ELEM(Object, dup_group, instance_collection) DNA_STRUCT_RENAME_ELEM(Object, dupfacesca, instance_faces_scale) +DNA_STRUCT_RENAME_ELEM(Object, imat, world_to_object) +DNA_STRUCT_RENAME_ELEM(Object, obmat, object_to_world) DNA_STRUCT_RENAME_ELEM(Object, restrictflag, visibility_flag) DNA_STRUCT_RENAME_ELEM(Object, size, scale) DNA_STRUCT_RENAME_ELEM(OpacityGpencilModifierData, hardeness, hardness) @@ -159,10 +161,7 @@ DNA_STRUCT_RENAME_ELEM(ParticleSettings, dup_ob, instance_object) DNA_STRUCT_RENAME_ELEM(ParticleSettings, dupliweights, instance_weights) DNA_STRUCT_RENAME_ELEM(ParticleSettings, ren_child_nbr, child_render_percent) DNA_STRUCT_RENAME_ELEM(RenderData, bake_filter, bake_margin) -DNA_STRUCT_RENAME_ELEM(RenderData, blurfac, motion_blur_shutter) DNA_STRUCT_RENAME_ELEM(RigidBodyWorld, steps_per_second, substeps_per_frame) -DNA_STRUCT_RENAME_ELEM(SceneEEVEE, motion_blur_position, motion_blur_position_deprecated) -DNA_STRUCT_RENAME_ELEM(SceneEEVEE, motion_blur_shutter, motion_blur_shutter_deprecated) DNA_STRUCT_RENAME_ELEM(SDefBind, numverts, verts_num) DNA_STRUCT_RENAME_ELEM(SDefVert, numbinds, binds_num) DNA_STRUCT_RENAME_ELEM(Sequence, retiming_handle_num, retiming_keys_num) diff --git a/source/blender/makesrna/RNA_access.hh b/source/blender/makesrna/RNA_access.hh index c62ce99572a..cee56f092ec 100644 --- a/source/blender/makesrna/RNA_access.hh +++ b/source/blender/makesrna/RNA_access.hh @@ -17,7 +17,6 @@ #include "RNA_types.hh" #include "BLI_compiler_attrs.h" -#include "BLI_function_ref.hh" struct ID; struct IDOverrideLibrary; @@ -379,15 +378,16 @@ void RNA_property_string_set_bytes(PointerRNA *ptr, PropertyRNA *prop, const cha eStringPropertySearchFlag RNA_property_string_search_flag(PropertyRNA *prop); /** * Search candidates for string `prop` by calling `visit_fn` with each string. + * Typically these strings are collected in `visit_user_data` in a format defined by the caller. * * See #PropStringSearchFunc for details. */ -void RNA_property_string_search( - const bContext *C, - PointerRNA *ptr, - PropertyRNA *prop, - const char *edit_text, - blender::FunctionRef visit_fn); +void RNA_property_string_search(const bContext *C, + PointerRNA *ptr, + PropertyRNA *prop, + const char *edit_text, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data); /** * \return the length without `\0` terminator. diff --git a/source/blender/makesrna/RNA_define.hh b/source/blender/makesrna/RNA_define.hh index df019c9d12d..92908757ea8 100644 --- a/source/blender/makesrna/RNA_define.hh +++ b/source/blender/makesrna/RNA_define.hh @@ -20,7 +20,7 @@ #ifdef UNIT_TEST # define RNA_MAX_ARRAY_LENGTH 64 #else -# define RNA_MAX_ARRAY_LENGTH 64 +# define RNA_MAX_ARRAY_LENGTH 32 #endif #define RNA_MAX_ARRAY_DIMENSION 3 @@ -451,10 +451,10 @@ void RNA_def_property_override_funcs(PropertyRNA *prop, const char *store, const char *apply); -using RNAPropertyUpdateFunc = void (*)(Main *, Scene *, PointerRNA *); -using RNAPropertyUpdateFuncWithContextAndProperty = void (*)(bContext *C, - PointerRNA *ptr, - PropertyRNA *prop); +typedef void (*RNAPropertyUpdateFunc)(Main *, Scene *, PointerRNA *); +typedef void (*RNAPropertyUpdateFuncWithContextAndProperty)(bContext *C, + PointerRNA *ptr, + PropertyRNA *prop); void RNA_def_property_update_runtime(PropertyRNA *prop, RNAPropertyUpdateFunc func); void RNA_def_property_update_runtime_with_context_and_property( diff --git a/source/blender/makesrna/RNA_types.hh b/source/blender/makesrna/RNA_types.hh index 6d2945778cd..a42b6c8169d 100644 --- a/source/blender/makesrna/RNA_types.hh +++ b/source/blender/makesrna/RNA_types.hh @@ -10,10 +10,6 @@ #ifndef __RNA_TYPES_H__ #define __RNA_TYPES_H__ -#include -#include - -#include "../blenlib/BLI_function_ref.hh" #include "../blenlib/BLI_sys_types.h" #include "../blenlib/BLI_utildefines.h" @@ -387,7 +383,7 @@ ENUM_OPERATORS(ParameterFlag, PARM_PYFUNC_OPTIONAL) struct CollectionPropertyIterator; struct Link; -using IteratorSkipFunc = int (*)(CollectionPropertyIterator *iter, void *data); +typedef int (*IteratorSkipFunc)(CollectionPropertyIterator *iter, void *data); struct ListBaseIterator { Link *link; @@ -517,35 +513,33 @@ struct EnumPropertyItem { #define RNA_ENUM_ITEM_SEPR_COLUMN RNA_ENUM_ITEM_HEADING("", NULL) /* extended versions with PropertyRNA argument */ -using BooleanPropertyGetFunc = bool (*)(PointerRNA *ptr, PropertyRNA *prop); -using BooleanPropertySetFunc = void (*)(PointerRNA *ptr, PropertyRNA *prop, bool value); -using BooleanArrayPropertyGetFunc = void (*)(PointerRNA *ptr, PropertyRNA *prop, bool *values); -using BooleanArrayPropertySetFunc = void (*)(PointerRNA *ptr, - PropertyRNA *prop, - const bool *values); -using IntPropertyGetFunc = int (*)(PointerRNA *ptr, PropertyRNA *prop); -using IntPropertySetFunc = void (*)(PointerRNA *ptr, PropertyRNA *prop, int value); -using IntArrayPropertyGetFunc = void (*)(PointerRNA *ptr, PropertyRNA *prop, int *values); -using IntArrayPropertySetFunc = void (*)(PointerRNA *ptr, PropertyRNA *prop, const int *values); -using IntPropertyRangeFunc = - void (*)(PointerRNA *ptr, PropertyRNA *prop, int *min, int *max, int *softmin, int *softmax); -using FloatPropertyGetFunc = float (*)(PointerRNA *ptr, PropertyRNA *prop); -using FloatPropertySetFunc = void (*)(PointerRNA *ptr, PropertyRNA *prop, float value); -using FloatArrayPropertyGetFunc = void (*)(PointerRNA *ptr, PropertyRNA *prop, float *values); -using FloatArrayPropertySetFunc = void (*)(PointerRNA *ptr, - PropertyRNA *prop, - const float *values); -using FloatPropertyRangeFunc = void (*)( +typedef bool (*BooleanPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop); +typedef void (*BooleanPropertySetFunc)(PointerRNA *ptr, PropertyRNA *prop, bool value); +typedef void (*BooleanArrayPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop, bool *values); +typedef void (*BooleanArrayPropertySetFunc)(PointerRNA *ptr, + PropertyRNA *prop, + const bool *values); +typedef int (*IntPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop); +typedef void (*IntPropertySetFunc)(PointerRNA *ptr, PropertyRNA *prop, int value); +typedef void (*IntArrayPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop, int *values); +typedef void (*IntArrayPropertySetFunc)(PointerRNA *ptr, PropertyRNA *prop, const int *values); +typedef void (*IntPropertyRangeFunc)( + PointerRNA *ptr, PropertyRNA *prop, int *min, int *max, int *softmin, int *softmax); +typedef float (*FloatPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop); +typedef void (*FloatPropertySetFunc)(PointerRNA *ptr, PropertyRNA *prop, float value); +typedef void (*FloatArrayPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop, float *values); +typedef void (*FloatArrayPropertySetFunc)(PointerRNA *ptr, PropertyRNA *prop, const float *values); +typedef void (*FloatPropertyRangeFunc)( PointerRNA *ptr, PropertyRNA *prop, float *min, float *max, float *softmin, float *softmax); -using StringPropertyGetFunc = void (*)(PointerRNA *ptr, PropertyRNA *prop, char *value); -using StringPropertyLengthFunc = int (*)(PointerRNA *ptr, PropertyRNA *prop); -using StringPropertySetFunc = void (*)(PointerRNA *ptr, PropertyRNA *prop, const char *value); +typedef void (*StringPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop, char *value); +typedef int (*StringPropertyLengthFunc)(PointerRNA *ptr, PropertyRNA *prop); +typedef void (*StringPropertySetFunc)(PointerRNA *ptr, PropertyRNA *prop, const char *value); struct StringPropertySearchVisitParams { - /** Text being searched for. */ - std::string text; - /** Additional information to display. */ - std::optional info; + /** Text being searched for (never NULL). */ + const char *text; + /** Additional information to display (optional, may be NULL). */ + const char *info; }; enum eStringPropertySearchFlag { @@ -566,6 +560,12 @@ enum eStringPropertySearchFlag { }; ENUM_OPERATORS(eStringPropertySearchFlag, PROP_STRING_SEARCH_SUGGESTION) +/** + * Visit string search candidates, `text` may be freed once this callback has finished, + * so references to it should not be held. + */ +typedef void (*StringPropertySearchVisitFunc)(void *visit_user_data, + const StringPropertySearchVisitParams *params); /** * \param C: context, may be NULL (in this case all available items should be shown). * \param ptr: RNA pointer. @@ -575,21 +575,22 @@ ENUM_OPERATORS(eStringPropertySearchFlag, PROP_STRING_SEARCH_SUGGESTION) * for the search results (auto-complete Python attributes for e.g.). * \param visit_fn: This function is called with every search candidate and is typically * responsible for storing the search results. + * \param visit_user_data: Caller defined data, passed to `visit_fn`. */ -using StringPropertySearchFunc = - void (*)(const bContext *C, - PointerRNA *ptr, - PropertyRNA *prop, - const char *edit_text, - blender::FunctionRef visit_fn); +typedef void (*StringPropertySearchFunc)(const bContext *C, + PointerRNA *ptr, + PropertyRNA *prop, + const char *edit_text, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data); -using EnumPropertyGetFunc = int (*)(PointerRNA *ptr, PropertyRNA *prop); -using EnumPropertySetFunc = void (*)(PointerRNA *ptr, PropertyRNA *prop, int value); +typedef int (*EnumPropertyGetFunc)(PointerRNA *ptr, PropertyRNA *prop); +typedef void (*EnumPropertySetFunc)(PointerRNA *ptr, PropertyRNA *prop, int value); /* same as PropEnumItemFunc */ -using EnumPropertyItemFunc = const EnumPropertyItem *(*)(bContext *C, - PointerRNA *ptr, - PropertyRNA *prop, - bool *r_free); +typedef const EnumPropertyItem *(*EnumPropertyItemFunc)(bContext *C, + PointerRNA *ptr, + PropertyRNA *prop, + bool *r_free); struct PropertyRNA; @@ -689,7 +690,7 @@ enum FunctionFlag { FUNC_FREE_POINTERS = (1 << 10), }; -using CallFunc = void (*)(bContext *C, ReportList *reports, PointerRNA *ptr, ParameterList *parms); +typedef void (*CallFunc)(bContext *C, ReportList *reports, PointerRNA *ptr, ParameterList *parms); struct FunctionRNA; @@ -724,22 +725,22 @@ enum StructFlag { STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID = (1 << 11), }; -using StructValidateFunc = int (*)(PointerRNA *ptr, void *data, bool *have_function); -using StructCallbackFunc = int (*)(bContext *C, - PointerRNA *ptr, - FunctionRNA *func, - ParameterList *list); -using StructFreeFunc = void (*)(void *data); -using StructRegisterFunc = StructRNA *(*)(Main *bmain, - ReportList *reports, - void *data, - const char *identifier, - StructValidateFunc validate, - StructCallbackFunc call, - StructFreeFunc free); +typedef int (*StructValidateFunc)(PointerRNA *ptr, void *data, bool *have_function); +typedef int (*StructCallbackFunc)(bContext *C, + PointerRNA *ptr, + FunctionRNA *func, + ParameterList *list); +typedef void (*StructFreeFunc)(void *data); +typedef StructRNA *(*StructRegisterFunc)(Main *bmain, + ReportList *reports, + void *data, + const char *identifier, + StructValidateFunc validate, + StructCallbackFunc call, + StructFreeFunc free); /** Return true when `type` was successfully unregistered & freed. */ -using StructUnregisterFunc = bool (*)(Main *bmain, StructRNA *type); -using StructInstanceFunc = void **(*)(PointerRNA *ptr); +typedef bool (*StructUnregisterFunc)(Main *bmain, StructRNA *type); +typedef void **(*StructInstanceFunc)(PointerRNA *ptr); struct StructRNA; diff --git a/source/blender/makesrna/intern/makesrna.cc b/source/blender/makesrna/intern/makesrna.cc index c9360b5689f..eca5d6301e0 100644 --- a/source/blender/makesrna/intern/makesrna.cc +++ b/source/blender/makesrna/intern/makesrna.cc @@ -1169,10 +1169,11 @@ static char *rna_def_property_search_func( "PointerRNA *ptr, " "PropertyRNA *prop, " "const char *edit_text, " - "blender::FunctionRef visit_fn)\n", + "StringPropertySearchVisitFunc visit_fn, " + "void *visit_user_data)\n", func); fprintf(f, "{\n"); - fprintf(f, "\n %s(C, ptr, prop, edit_text, visit_fn);\n", manualfunc); + fprintf(f, "\n %s(C, ptr, prop, edit_text, visit_fn, visit_user_data);\n", manualfunc); fprintf(f, "}\n\n"); return func; } @@ -4861,7 +4862,7 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const fprintf(f, "#include \"BKE_context.hh\"\n"); fprintf(f, "#include \"BKE_lib_id.hh\"\n"); fprintf(f, "#include \"BKE_main.hh\"\n"); - fprintf(f, "#include \"BKE_report.hh\"\n"); + fprintf(f, "#include \"BKE_report.h\"\n"); fprintf(f, "#include \"RNA_define.hh\"\n"); fprintf(f, "#include \"RNA_types.hh\"\n"); diff --git a/source/blender/makesrna/intern/rna_ID.cc b/source/blender/makesrna/intern/rna_ID.cc index 5b5b3c9e695..c2dac90ecef 100644 --- a/source/blender/makesrna/intern/rna_ID.cc +++ b/source/blender/makesrna/intern/rna_ID.cc @@ -213,12 +213,12 @@ const IDFilterEnumPropertyItem rna_enum_id_type_filter_items[] = { # include "BLI_listbase.h" # include "BLI_math_base.h" -# include "BLT_translation.hh" +# include "BLT_translation.h" -# include "BLO_readfile.hh" +# include "BLO_readfile.h" # include "BKE_anim_data.h" -# include "BKE_global.hh" /* XXX, remove me */ +# include "BKE_global.h" /* XXX, remove me */ # include "BKE_idprop.h" # include "BKE_idtype.hh" # include "BKE_lib_override.hh" diff --git a/source/blender/makesrna/intern/rna_access.cc b/source/blender/makesrna/intern/rna_access.cc index d95c7d01d4e..a707cee14c0 100644 --- a/source/blender/makesrna/intern/rna_access.cc +++ b/source/blender/makesrna/intern/rna_access.cc @@ -30,19 +30,19 @@ #include "BLI_utildefines.h" #include "BLF_api.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_anim_data.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_context.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_idtype.hh" #include "BKE_lib_override.hh" #include "BKE_main.hh" #include "BKE_node.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "CLG_log.h" @@ -3698,16 +3698,16 @@ eStringPropertySearchFlag RNA_property_string_search_flag(PropertyRNA *prop) return sprop->search_flag; } -void RNA_property_string_search( - const bContext *C, - PointerRNA *ptr, - PropertyRNA *prop, - const char *edit_text, - blender::FunctionRef visit_fn) +void RNA_property_string_search(const bContext *C, + PointerRNA *ptr, + PropertyRNA *prop, + const char *edit_text, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data) { BLI_assert(RNA_property_string_search_flag(prop) & PROP_STRING_SEARCH_SUPPORTED); StringPropertyRNA *sprop = (StringPropertyRNA *)rna_ensure_property(prop); - sprop->search(C, ptr, prop, edit_text, visit_fn); + sprop->search(C, ptr, prop, edit_text, visit_fn, visit_user_data); } int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop) diff --git a/source/blender/makesrna/intern/rna_access_compare_override.cc b/source/blender/makesrna/intern/rna_access_compare_override.cc index 17bcc4ced06..db14c9b5eab 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.cc +++ b/source/blender/makesrna/intern/rna_access_compare_override.cc @@ -658,7 +658,7 @@ bool RNA_struct_override_matches(Main *bmain, if (!root_path) { _delta_time_diffing = 0.0f; _num_delta_time_diffing = 0; - _timeit_time_global = BLI_time_now_seconds(); + _timeit_time_global = BLI_check_seconds_timer(); } #endif @@ -793,7 +793,7 @@ bool RNA_struct_override_matches(Main *bmain, #ifdef DEBUG_OVERRIDE_TIMEIT if (!root_path) { - _timeit_time_diffing = BLI_time_now_seconds(); + _timeit_time_diffing = BLI_check_seconds_timer(); } #endif @@ -810,7 +810,7 @@ bool RNA_struct_override_matches(Main *bmain, #ifdef DEBUG_OVERRIDE_TIMEIT if (!root_path) { - const float _delta_time = float(BLI_time_now_seconds() - _timeit_time_diffing); + const float _delta_time = float(BLI_check_seconds_timer() - _timeit_time_diffing); _delta_time_diffing += _delta_time; _num_delta_time_diffing++; } @@ -936,7 +936,7 @@ bool RNA_struct_override_matches(Main *bmain, #ifdef DEBUG_OVERRIDE_TIMEIT if (!root_path) { - const float _delta_time = float(BLI_time_now_seconds() - _timeit_time_global); + const float _delta_time = float(BLI_check_seconds_timer() - _timeit_time_global); _sum_time_global += _delta_time; _num_time_global++; _sum_time_diffing += _delta_time_diffing; diff --git a/source/blender/makesrna/intern/rna_action.cc b/source/blender/makesrna/intern/rna_action.cc index 0359f4d8bce..966c273d73b 100644 --- a/source/blender/makesrna/intern/rna_action.cc +++ b/source/blender/makesrna/intern/rna_action.cc @@ -16,7 +16,7 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" diff --git a/source/blender/makesrna/intern/rna_animation.cc b/source/blender/makesrna/intern/rna_animation.cc index eef69d337de..f7df7131a36 100644 --- a/source/blender/makesrna/intern/rna_animation.cc +++ b/source/blender/makesrna/intern/rna_animation.cc @@ -14,7 +14,7 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/makesrna/intern/rna_animation_api.cc b/source/blender/makesrna/intern/rna_animation_api.cc index 207a9409151..38406a9cbe5 100644 --- a/source/blender/makesrna/intern/rna_animation_api.cc +++ b/source/blender/makesrna/intern/rna_animation_api.cc @@ -22,7 +22,7 @@ # include "BKE_context.hh" # include "BKE_nla.h" -# include "BKE_report.hh" +# include "BKE_report.h" # include "ED_keyframing.hh" diff --git a/source/blender/makesrna/intern/rna_animviz.cc b/source/blender/makesrna/intern/rna_animviz.cc index 5954703a2b1..70a7072e3c2 100644 --- a/source/blender/makesrna/intern/rna_animviz.cc +++ b/source/blender/makesrna/intern/rna_animviz.cc @@ -314,7 +314,7 @@ static void rna_def_animviz_paths(BlenderRNA *brna) prop, "Has Motion Paths", "Are there any bone paths that will need updating (read-only)"); /* If enabled, bakes the motion paths into camera space. */ - prop = RNA_def_property(srna, "use_camera_space_bake", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "bake_in_camera_space", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "path_bakeflag", MOTIONPATH_BAKE_CAMERA_SPACE); RNA_def_property_ui_text( prop, diff --git a/source/blender/makesrna/intern/rna_armature.cc b/source/blender/makesrna/intern/rna_armature.cc index 745b10d2db5..53ad6539220 100644 --- a/source/blender/makesrna/intern/rna_armature.cc +++ b/source/blender/makesrna/intern/rna_armature.cc @@ -11,7 +11,7 @@ #include "BLI_math_base.h" #include "BLI_string_utf8_symbols.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -65,7 +65,7 @@ constexpr int COLOR_SETS_MAX_THEMED_INDEX = 20; # include "BKE_action.h" # include "BKE_context.hh" -# include "BKE_global.hh" +# include "BKE_global.h" # include "BKE_idprop.h" # include "BKE_main.hh" diff --git a/source/blender/makesrna/intern/rna_asset.cc b/source/blender/makesrna/intern/rna_asset.cc index 370f0e9848c..29274fed889 100644 --- a/source/blender/makesrna/intern/rna_asset.cc +++ b/source/blender/makesrna/intern/rna_asset.cc @@ -8,7 +8,7 @@ #include -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_define.hh" #include "RNA_enum_types.hh" @@ -364,7 +364,7 @@ void rna_AssetMetaData_catalog_id_update(bContext *C, PointerRNA *ptr) } AssetMetaData *asset_data = static_cast(ptr->data); - asset_library->refresh_catalog_simplename(asset_data); + AS_asset_library_refresh_catalog_simplename(asset_library, asset_data); } static PointerRNA rna_AssetHandle_file_data_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_attribute.cc b/source/blender/makesrna/intern/rna_attribute.cc index 2f5ec3bd8bb..1c222206710 100644 --- a/source/blender/makesrna/intern/rna_attribute.cc +++ b/source/blender/makesrna/intern/rna_attribute.cc @@ -25,7 +25,7 @@ #include "BKE_attribute.hh" #include "BKE_customdata.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "WM_types.hh" @@ -47,7 +47,6 @@ const EnumPropertyItem rna_enum_attribute_type_items[] = { {CD_PROP_INT8, "INT8", 0, "8-Bit Integer", "Smaller integer with a range from -128 to 127"}, {CD_PROP_INT32_2D, "INT32_2D", 0, "2D Integer Vector", "32-bit signed integer vector"}, {CD_PROP_QUATERNION, "QUATERNION", 0, "Quaternion", "Floating point quaternion rotation"}, - {CD_PROP_FLOAT4X4, "FLOAT4X4", 0, "4x4 Matrix", "Floating point matrix"}, {0, nullptr, 0, nullptr, nullptr}, }; @@ -77,7 +76,6 @@ const EnumPropertyItem rna_enum_attribute_type_with_auto_items[] = { {CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"}, {CD_PROP_INT32_2D, "INT32_2D", 0, "2D Integer Vector", "32-bit signed integer vector"}, {CD_PROP_QUATERNION, "QUATERNION", 0, "Quaternion", "Floating point quaternion rotation"}, - {CD_PROP_FLOAT4X4, "FLOAT4X4", 0, "4x4 Matrix", "Floating point matrix"}, {0, nullptr, 0, nullptr, nullptr}, }; @@ -170,7 +168,7 @@ const EnumPropertyItem rna_enum_attribute_curves_domain_items[] = { # include "DEG_depsgraph.hh" -# include "BLT_translation.hh" +# include "BLT_translation.h" # include "WM_api.hh" @@ -209,8 +207,6 @@ static StructRNA *srna_by_custom_data_layer_type(const eCustomDataType type) return &RNA_Int2Attribute; case CD_PROP_QUATERNION: return &RNA_QuaternionAttribute; - case CD_PROP_FLOAT4X4: - return &RNA_Float4x4Attribute; default: return nullptr; } @@ -1104,40 +1100,6 @@ static void rna_def_attribute_quaternion(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Attribute_update_data"); } -static void rna_def_attribute_float4x4(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "Float4x4Attribute", "Attribute"); - RNA_def_struct_sdna(srna, "CustomDataLayer"); - RNA_def_struct_ui_text( - srna, "4x4 Matrix Attribute", "Geometry attribute that stores a 4 by 4 float matrix"); - - prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "Float4x4AttributeValue"); - RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE); - RNA_def_property_collection_funcs(prop, - "rna_Attribute_data_begin", - "rna_iterator_array_next", - "rna_iterator_array_end", - "rna_iterator_array_get", - "rna_Attribute_data_length", - nullptr, - nullptr, - nullptr); - - srna = RNA_def_struct(brna, "Float4x4AttributeValue", nullptr); - RNA_def_struct_sdna(srna, "mat4x4f"); - RNA_def_struct_ui_text(srna, "Matrix Attribute Value", "Matrix value in geometry attribute"); - - prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_MATRIX); - RNA_def_property_ui_text(prop, "Value", "Matrix"); - RNA_def_property_float_sdna(prop, nullptr, "value"); - RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); - RNA_def_property_update(prop, 0, "rna_Attribute_update_data"); -} - static void rna_def_attribute_float2(BlenderRNA *brna) { StructRNA *srna; @@ -1224,7 +1186,6 @@ static void rna_def_attribute(BlenderRNA *brna) rna_def_attribute_int(brna); rna_def_attribute_int2(brna); rna_def_attribute_quaternion(brna); - rna_def_attribute_float4x4(brna); rna_def_attribute_string(brna); rna_def_attribute_bool(brna); rna_def_attribute_float2(brna); diff --git a/source/blender/makesrna/intern/rna_brush.cc b/source/blender/makesrna/intern/rna_brush.cc index ecfac291be6..22a1d676bc5 100644 --- a/source/blender/makesrna/intern/rna_brush.cc +++ b/source/blender/makesrna/intern/rna_brush.cc @@ -21,7 +21,7 @@ #include "BLI_math_base.h" #include "BLI_string_utf8_symbols.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_define.hh" #include "RNA_enum_types.hh" diff --git a/source/blender/makesrna/intern/rna_cachefile.cc b/source/blender/makesrna/intern/rna_cachefile.cc index f28dbc92428..cb67304444e 100644 --- a/source/blender/makesrna/intern/rna_cachefile.cc +++ b/source/blender/makesrna/intern/rna_cachefile.cc @@ -9,7 +9,7 @@ #include "DNA_cachefile_types.h" #include "DNA_scene_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -27,7 +27,7 @@ const EnumPropertyItem rna_enum_velocity_unit_items[] = { # include "BLI_string.h" -# include "BKE_cachefile.hh" +# include "BKE_cachefile.h" # include "DEG_depsgraph.hh" # include "DEG_depsgraph_build.hh" diff --git a/source/blender/makesrna/intern/rna_camera.cc b/source/blender/makesrna/intern/rna_camera.cc index dd8d1c0dc89..aec8c9a35e5 100644 --- a/source/blender/makesrna/intern/rna_camera.cc +++ b/source/blender/makesrna/intern/rna_camera.cc @@ -12,7 +12,7 @@ #include "BLI_math_rotation.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/makesrna/intern/rna_collection.cc b/source/blender/makesrna/intern/rna_collection.cc index fb38a371fba..f4507964ad0 100644 --- a/source/blender/makesrna/intern/rna_collection.cc +++ b/source/blender/makesrna/intern/rna_collection.cc @@ -48,8 +48,8 @@ BLI_STATIC_ASSERT(ARRAY_SIZE(rna_enum_collection_color_items) - 2 == COLLECTION_ # include "DEG_depsgraph_build.hh" # include "DEG_depsgraph_query.hh" -# include "BKE_collection.hh" -# include "BKE_global.hh" +# include "BKE_collection.h" +# include "BKE_global.h" # include "BKE_layer.hh" # include "WM_api.hh" diff --git a/source/blender/makesrna/intern/rna_color.cc b/source/blender/makesrna/intern/rna_color.cc index 47fd0e9fad4..14b3f3439bc 100644 --- a/source/blender/makesrna/intern/rna_color.cc +++ b/source/blender/makesrna/intern/rna_color.cc @@ -55,7 +55,7 @@ const EnumPropertyItem rna_enum_color_space_convert_default_items[] = { # include "BKE_image.h" # include "BKE_linestyle.h" # include "BKE_movieclip.h" -# include "BKE_node.hh" +# include "BKE_node.h" # include "DEG_depsgraph.hh" diff --git a/source/blender/makesrna/intern/rna_constraint.cc b/source/blender/makesrna/intern/rna_constraint.cc index c3c0e82ebf1..d729cc81f96 100644 --- a/source/blender/makesrna/intern/rna_constraint.cc +++ b/source/blender/makesrna/intern/rna_constraint.cc @@ -12,7 +12,7 @@ #include "BLI_math_rotation.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_action_types.h" #include "DNA_constraint_types.h" diff --git a/source/blender/makesrna/intern/rna_curve.cc b/source/blender/makesrna/intern/rna_curve.cc index 4e9b626d71f..1c0e5ee4aab 100644 --- a/source/blender/makesrna/intern/rna_curve.cc +++ b/source/blender/makesrna/intern/rna_curve.cc @@ -16,7 +16,7 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/makesrna/intern/rna_curveprofile.cc b/source/blender/makesrna/intern/rna_curveprofile.cc index 6f2db38fb26..d179312ad42 100644 --- a/source/blender/makesrna/intern/rna_curveprofile.cc +++ b/source/blender/makesrna/intern/rna_curveprofile.cc @@ -15,7 +15,7 @@ #include "RNA_define.hh" #include "rna_internal.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "WM_api.hh" #include "WM_types.hh" diff --git a/source/blender/makesrna/intern/rna_curves.cc b/source/blender/makesrna/intern/rna_curves.cc index f716d6ef21f..a7ceef96b1b 100644 --- a/source/blender/makesrna/intern/rna_curves.cc +++ b/source/blender/makesrna/intern/rna_curves.cc @@ -54,7 +54,7 @@ const EnumPropertyItem rna_enum_curve_normal_mode_items[] = { # include "BKE_attribute.hh" # include "BKE_curves.hh" -# include "BKE_report.hh" +# include "BKE_report.h" # include "DEG_depsgraph.hh" diff --git a/source/blender/makesrna/intern/rna_define.cc b/source/blender/makesrna/intern/rna_define.cc index 7af75e42a56..f496a87f81f 100644 --- a/source/blender/makesrna/intern/rna_define.cc +++ b/source/blender/makesrna/intern/rna_define.cc @@ -24,7 +24,7 @@ #include "BLI_ghash.h" #include "BLI_listbase.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "UI_interface.hh" /* For things like UI_PRECISION_FLOAT_MAX... */ diff --git a/source/blender/makesrna/intern/rna_depsgraph.cc b/source/blender/makesrna/intern/rna_depsgraph.cc index ece8db9ff9f..3eb420ed40e 100644 --- a/source/blender/makesrna/intern/rna_depsgraph.cc +++ b/source/blender/makesrna/intern/rna_depsgraph.cc @@ -35,9 +35,9 @@ # include "RNA_access.hh" -# include "BKE_duplilist.hh" +# include "BKE_duplilist.h" # include "BKE_object.hh" -# include "BKE_scene.hh" +# include "BKE_scene.h" # include "DEG_depsgraph_build.hh" # include "DEG_depsgraph_debug.hh" @@ -174,7 +174,7 @@ static void rna_DepsgraphObjectInstance_matrix_world_get(PointerRNA *ptr, float /* We can return actual object's matrix here, no reason to return identity matrix * when this is not actually an instance... */ Object *ob = (Object *)di->iter.current; - copy_m4_m4((float(*)[4])mat, ob->object_to_world().ptr()); + copy_m4_m4((float(*)[4])mat, ob->object_to_world); } } diff --git a/source/blender/makesrna/intern/rna_dynamicpaint.cc b/source/blender/makesrna/intern/rna_dynamicpaint.cc index bf39e553118..05bda7360ea 100644 --- a/source/blender/makesrna/intern/rna_dynamicpaint.cc +++ b/source/blender/makesrna/intern/rna_dynamicpaint.cc @@ -14,7 +14,7 @@ #include "BLI_string_utf8_symbols.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_dynamicpaint_types.h" #include "DNA_modifier_types.h" diff --git a/source/blender/makesrna/intern/rna_fcurve.cc b/source/blender/makesrna/intern/rna_fcurve.cc index 792ed433ce3..8534b0c9a01 100644 --- a/source/blender/makesrna/intern/rna_fcurve.cc +++ b/source/blender/makesrna/intern/rna_fcurve.cc @@ -15,7 +15,7 @@ #include "MEM_guardedalloc.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_action.h" diff --git a/source/blender/makesrna/intern/rna_fluid.cc b/source/blender/makesrna/intern/rna_fluid.cc index 6657581dbef..7e8f515ceea 100644 --- a/source/blender/makesrna/intern/rna_fluid.cc +++ b/source/blender/makesrna/intern/rna_fluid.cc @@ -23,7 +23,7 @@ #include "BKE_modifier.hh" #include "BKE_pointcache.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_fluid_types.h" #include "DNA_modifier_types.h" diff --git a/source/blender/makesrna/intern/rna_gpencil_legacy.cc b/source/blender/makesrna/intern/rna_gpencil_legacy.cc index 6c738c351f8..e453b3dc4fb 100644 --- a/source/blender/makesrna/intern/rna_gpencil_legacy.cc +++ b/source/blender/makesrna/intern/rna_gpencil_legacy.cc @@ -22,7 +22,7 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -340,13 +340,13 @@ static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr, const char ** static void set_parent(bGPDlayer *gpl, Object *par, const int type, const char *substr) { if (type == PAROBJECT) { - invert_m4_m4(gpl->inverse, par->object_to_world().ptr()); + invert_m4_m4(gpl->inverse, par->object_to_world); gpl->parent = par; gpl->partype |= PAROBJECT; gpl->parsubstr[0] = 0; } else if (type == PARSKEL) { - invert_m4_m4(gpl->inverse, par->object_to_world().ptr()); + invert_m4_m4(gpl->inverse, par->object_to_world); gpl->parent = par; gpl->partype |= PARSKEL; gpl->parsubstr[0] = 0; @@ -355,7 +355,7 @@ static void set_parent(bGPDlayer *gpl, Object *par, const int type, const char * bPoseChannel *pchan = BKE_pose_channel_find_name(par->pose, substr); if (pchan) { float tmp_mat[4][4]; - mul_m4_m4m4(tmp_mat, par->object_to_world().ptr(), pchan->pose_mat); + mul_m4_m4m4(tmp_mat, par->object_to_world, pchan->pose_mat); invert_m4_m4(gpl->inverse, tmp_mat); gpl->parent = par; @@ -363,7 +363,7 @@ static void set_parent(bGPDlayer *gpl, Object *par, const int type, const char * STRNCPY(gpl->parsubstr, substr); } else { - invert_m4_m4(gpl->inverse, par->object_to_world().ptr()); + invert_m4_m4(gpl->inverse, par->object_to_world); gpl->parent = par; gpl->partype |= PAROBJECT; gpl->parsubstr[0] = 0; diff --git a/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.cc b/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.cc index c2cd70f73ff..a83b3322947 100644 --- a/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.cc +++ b/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.cc @@ -24,7 +24,7 @@ #include "BLI_math_rotation.h" #include "BLI_string_utils.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_animsys.h" @@ -279,7 +279,7 @@ static const EnumPropertyItem modifier_noise_random_mode_items[] = { # include "DNA_material_types.h" # include "DNA_particle_types.h" -# include "BKE_cachefile.hh" +# include "BKE_cachefile.h" # include "BKE_context.hh" # include "BKE_gpencil_legacy.h" # include "BKE_gpencil_modifier_legacy.h" diff --git a/source/blender/makesrna/intern/rna_grease_pencil.cc b/source/blender/makesrna/intern/rna_grease_pencil.cc index a5070c650fa..c2adafef7c1 100644 --- a/source/blender/makesrna/intern/rna_grease_pencil.cc +++ b/source/blender/makesrna/intern/rna_grease_pencil.cc @@ -27,7 +27,6 @@ # include "BLI_span.hh" # include "DEG_depsgraph.hh" -# include "DEG_depsgraph_build.hh" static GreasePencil *rna_grease_pencil(const PointerRNA *ptr) { @@ -37,30 +36,7 @@ static GreasePencil *rna_grease_pencil(const PointerRNA *ptr) static void rna_grease_pencil_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr) { DEG_id_tag_update(&rna_grease_pencil(ptr)->id, ID_RECALC_GEOMETRY); - WM_main_add_notifier(NC_GPENCIL | NA_EDITED, rna_grease_pencil(ptr)); -} - -static void rna_grease_pencil_autolock(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr) -{ - using namespace blender::bke::greasepencil; - GreasePencil *grease_pencil = rna_grease_pencil(ptr); - if (grease_pencil->flag & GREASE_PENCIL_AUTOLOCK_LAYERS) { - grease_pencil->autolock_inactive_layers(); - } - else { - for (Layer *layer : grease_pencil->layers_for_write()) { - layer->set_locked(false); - } - } - - rna_grease_pencil_update(nullptr, nullptr, ptr); -} - -static void rna_grease_pencil_dependency_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr) -{ - DEG_id_tag_update(&rna_grease_pencil(ptr)->id, ID_RECALC_GEOMETRY); - DEG_relations_tag_update(bmain); - WM_main_add_notifier(NC_GPENCIL | NA_EDITED, rna_grease_pencil(ptr)); + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, nullptr); } static void rna_iterator_grease_pencil_layers_begin(CollectionPropertyIterator *iter, @@ -205,8 +181,6 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static const float scale_defaults[3] = {1.0f, 1.0f, 1.0f}; - srna = RNA_def_struct(brna, "GreasePencilLayer", nullptr); RNA_def_struct_sdna(srna, "GreasePencilLayer"); RNA_def_struct_ui_text(srna, "Grease Pencil Layer", "Collection of related drawings"); @@ -252,41 +226,6 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Onion Skinning", "Display onion skins before and after the current frame"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_update"); - - prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); - RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); - RNA_def_property_ui_text(prop, "Parent", "Parent object"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_dependency_update"); - - prop = RNA_def_property(srna, "parent_bone", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, nullptr, "parsubstr"); - RNA_def_property_ui_text( - prop, "Parent Bone", "Name of parent bone. Only used when the parent object is an armature"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_dependency_update"); - - prop = RNA_def_property(srna, "translation", PROP_FLOAT, PROP_TRANSLATION); - RNA_def_property_array(prop, 3); - RNA_def_property_float_sdna(prop, nullptr, "translation"); - RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); - RNA_def_property_ui_text(prop, "Translation", "Translation of the layer"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_update"); - - prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER); - RNA_def_property_array(prop, 3); - RNA_def_property_float_sdna(prop, nullptr, "rotation"); - RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); - RNA_def_property_ui_text(prop, "Rotation", "Euler rotation of the layer"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_update"); - - prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); - RNA_def_property_array(prop, 3); - RNA_def_property_float_sdna(prop, nullptr, "scale"); - RNA_def_property_float_array_default(prop, scale_defaults); - RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); - RNA_def_property_ui_text(prop, "Scale", "Scale of the layer"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_update"); } static void rna_def_grease_pencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop) @@ -409,14 +348,6 @@ static void rna_def_grease_pencil_data(BlenderRNA *brna) nullptr, /* TODO */ nullptr); RNA_def_property_ui_text(prop, "Layer Groups", "Grease Pencil layer groups"); - - prop = RNA_def_property(srna, "use_autolock_layers", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flag", GREASE_PENCIL_AUTOLOCK_LAYERS); - RNA_def_property_ui_text( - prop, - "Auto-Lock Layers", - "Automatically lock all layers except the active one to avoid accidental changes"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_autolock"); } void RNA_def_grease_pencil(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_image.cc b/source/blender/makesrna/intern/rna_image.cc index f93e234de7a..ec67020092a 100644 --- a/source/blender/makesrna/intern/rna_image.cc +++ b/source/blender/makesrna/intern/rna_image.cc @@ -58,7 +58,7 @@ static const EnumPropertyItem image_source_items[] = { # include "BLI_math_base.h" # include "BLI_math_vector.h" -# include "BKE_global.hh" +# include "BKE_global.h" # include "GPU_texture.h" diff --git a/source/blender/makesrna/intern/rna_image_api.cc b/source/blender/makesrna/intern/rna_image_api.cc index 2dc5e5bfcdd..9893287485a 100644 --- a/source/blender/makesrna/intern/rna_image_api.cc +++ b/source/blender/makesrna/intern/rna_image_api.cc @@ -30,7 +30,7 @@ # include "BKE_image_format.h" # include "BKE_image_save.h" # include "BKE_main.hh" -# include "BKE_scene.hh" +# include "BKE_scene.h" # include # include "IMB_imbuf.hh" diff --git a/source/blender/makesrna/intern/rna_internal.hh b/source/blender/makesrna/intern/rna_internal.hh index 50545609667..b8a9bde7e07 100644 --- a/source/blender/makesrna/intern/rna_internal.hh +++ b/source/blender/makesrna/intern/rna_internal.hh @@ -347,7 +347,7 @@ void rna_Scene_use_view_map_cache_update(Main *bmain, Scene *scene, PointerRNA * void rna_Scene_render_update(Main *bmain, Scene *scene, PointerRNA *ptr); void rna_Scene_freestyle_update(Main *bmain, Scene *scene, PointerRNA *ptr); void rna_ViewLayer_name_set(PointerRNA *ptr, const char *value); -void rna_ViewLayer_override_update(Main *bmain, Scene *activescene, PointerRNA *ptr); +void rna_ViewLayer_material_override_update(Main *bmain, Scene *activescene, PointerRNA *ptr); void rna_ViewLayer_pass_update(Main *bmain, Scene *activescene, PointerRNA *ptr); void rna_ViewLayer_active_aov_index_range( PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax); diff --git a/source/blender/makesrna/intern/rna_key.cc b/source/blender/makesrna/intern/rna_key.cc index 4257c1e98c0..4b512c98937 100644 --- a/source/blender/makesrna/intern/rna_key.cc +++ b/source/blender/makesrna/intern/rna_key.cc @@ -18,7 +18,7 @@ #include "BLI_math_rotation.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" diff --git a/source/blender/makesrna/intern/rna_layer.cc b/source/blender/makesrna/intern/rna_layer.cc index aaa6ec88116..31d0b91e5db 100644 --- a/source/blender/makesrna/intern/rna_layer.cc +++ b/source/blender/makesrna/intern/rna_layer.cc @@ -10,7 +10,7 @@ #include "DNA_scene_types.h" #include "DNA_view3d_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "ED_object.hh" #include "ED_render.hh" @@ -38,8 +38,8 @@ # include "BKE_idprop.h" # include "BKE_layer.hh" # include "BKE_mesh.hh" -# include "BKE_node.hh" -# include "BKE_scene.hh" +# include "BKE_node.h" +# include "BKE_scene.h" # include "NOD_composite.hh" diff --git a/source/blender/makesrna/intern/rna_light.cc b/source/blender/makesrna/intern/rna_light.cc index dc536181a0b..227881573ca 100644 --- a/source/blender/makesrna/intern/rna_light.cc +++ b/source/blender/makesrna/intern/rna_light.cc @@ -12,7 +12,7 @@ #include "BLI_math_rotation.h" #include "BLI_sys_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_define.hh" #include "RNA_enum_types.hh" diff --git a/source/blender/makesrna/intern/rna_linestyle.cc b/source/blender/makesrna/intern/rna_linestyle.cc index 44cabed816f..24a64a172cf 100644 --- a/source/blender/makesrna/intern/rna_linestyle.cc +++ b/source/blender/makesrna/intern/rna_linestyle.cc @@ -12,7 +12,7 @@ #include "BLI_math_rotation.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_define.hh" #include "RNA_enum_types.hh" diff --git a/source/blender/makesrna/intern/rna_main.cc b/source/blender/makesrna/intern/rna_main.cc index e02bc64bab1..a5684bc47c3 100644 --- a/source/blender/makesrna/intern/rna_main.cc +++ b/source/blender/makesrna/intern/rna_main.cc @@ -19,7 +19,7 @@ #ifdef RNA_RUNTIME -# include "BKE_global.hh" +# include "BKE_global.h" # include "BKE_main.hh" # include "BKE_mesh.hh" diff --git a/source/blender/makesrna/intern/rna_main_api.cc b/source/blender/makesrna/intern/rna_main_api.cc index acb1d52ff92..9c3cccb1dee 100644 --- a/source/blender/makesrna/intern/rna_main_api.cc +++ b/source/blender/makesrna/intern/rna_main_api.cc @@ -29,7 +29,7 @@ # include "BKE_armature.hh" # include "BKE_brush.hh" # include "BKE_camera.h" -# include "BKE_collection.hh" +# include "BKE_collection.h" # include "BKE_curve.hh" # include "BKE_curves.h" # include "BKE_displist.h" @@ -47,12 +47,12 @@ # include "BKE_mball.hh" # include "BKE_mesh.hh" # include "BKE_movieclip.h" -# include "BKE_node.hh" +# include "BKE_node.h" # include "BKE_object.hh" # include "BKE_paint.hh" # include "BKE_particle.h" # include "BKE_pointcloud.hh" -# include "BKE_scene.hh" +# include "BKE_scene.h" # include "BKE_sound.h" # include "BKE_speaker.h" # include "BKE_text.h" @@ -94,7 +94,7 @@ # include "ED_node.hh" # include "ED_screen.hh" -# include "BLT_translation.hh" +# include "BLT_translation.h" # ifdef WITH_PYTHON # include "BPY_extern.h" diff --git a/source/blender/makesrna/intern/rna_mask.cc b/source/blender/makesrna/intern/rna_mask.cc index 13a87a1d923..5f06cf10aa0 100644 --- a/source/blender/makesrna/intern/rna_mask.cc +++ b/source/blender/makesrna/intern/rna_mask.cc @@ -18,7 +18,7 @@ #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_movieclip.h" #include "BKE_tracking.h" diff --git a/source/blender/makesrna/intern/rna_material.cc b/source/blender/makesrna/intern/rna_material.cc index c439dd8e2c6..9b3fb084b3b 100644 --- a/source/blender/makesrna/intern/rna_material.cc +++ b/source/blender/makesrna/intern/rna_material.cc @@ -15,7 +15,7 @@ #include "BLI_math_rotation.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_customdata.hh" @@ -72,9 +72,9 @@ const EnumPropertyItem rna_enum_ramp_blend_items[] = { # include "BKE_grease_pencil.hh" # include "BKE_main.hh" # include "BKE_material.h" -# include "BKE_node.hh" +# include "BKE_node.h" # include "BKE_paint.hh" -# include "BKE_scene.hh" +# include "BKE_scene.h" # include "BKE_texture.h" # include "BKE_workspace.h" diff --git a/source/blender/makesrna/intern/rna_mesh.cc b/source/blender/makesrna/intern/rna_mesh.cc index c3da86eee7d..49b7c6e2a19 100644 --- a/source/blender/makesrna/intern/rna_mesh.cc +++ b/source/blender/makesrna/intern/rna_mesh.cc @@ -62,7 +62,7 @@ static const EnumPropertyItem rna_enum_mesh_remesh_mode_items[] = { # include "BKE_main.hh" # include "BKE_mesh.hh" # include "BKE_mesh_runtime.hh" -# include "BKE_report.hh" +# include "BKE_report.h" # include "DEG_depsgraph.hh" diff --git a/source/blender/makesrna/intern/rna_mesh_api.cc b/source/blender/makesrna/intern/rna_mesh_api.cc index 4e3d8b6a0cb..11e748a635b 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.cc +++ b/source/blender/makesrna/intern/rna_mesh_api.cc @@ -31,7 +31,7 @@ # include "BKE_mesh_mapping.hh" # include "BKE_mesh_runtime.hh" # include "BKE_mesh_tangent.hh" -# include "BKE_report.hh" +# include "BKE_report.h" # include "ED_mesh.hh" diff --git a/source/blender/makesrna/intern/rna_meta.cc b/source/blender/makesrna/intern/rna_meta.cc index 986239d3fca..5aa977ca8b2 100644 --- a/source/blender/makesrna/intern/rna_meta.cc +++ b/source/blender/makesrna/intern/rna_meta.cc @@ -32,7 +32,7 @@ # include "BKE_main.hh" # include "BKE_mball.hh" -# include "BKE_scene.hh" +# include "BKE_scene.h" # include "DEG_depsgraph.hh" diff --git a/source/blender/makesrna/intern/rna_modifier.cc b/source/blender/makesrna/intern/rna_modifier.cc index c65b70bc236..9cccaebd075 100644 --- a/source/blender/makesrna/intern/rna_modifier.cc +++ b/source/blender/makesrna/intern/rna_modifier.cc @@ -21,7 +21,7 @@ #include "MEM_guardedalloc.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_animsys.h" #include "BKE_attribute.hh" @@ -49,13 +49,6 @@ #include "MOD_nodes.hh" const EnumPropertyItem rna_enum_object_modifier_type_items[] = { - RNA_ENUM_ITEM_HEADING(N_("Modify"), nullptr), - {eModifierType_GreasePencilWeightProximity, - "GREASE_PENCIL_VERTEX_WEIGHT_PROXIMITY", - ICON_MOD_VERTEX_WEIGHT, - "Vertex Weight Proximity", - "Generate Vertex Weights base on distance to object"}, - RNA_ENUM_ITEM_HEADING(N_("Modify"), nullptr), {eModifierType_DataTransfer, "DATA_TRANSFER", @@ -123,11 +116,6 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = { ICON_MOD_OPACITY, "Opacity", "Change the opacity of the strokes"}, - {eModifierType_GreasePencilWeightAngle, - "GREASE_PENCIL_VERTEX_WEIGHT_ANGLE", - ICON_MOD_VERTEX_WEIGHT, - "Vertex Weight Angle", - "Generate vertex weights base on stroke angle"}, RNA_ENUM_ITEM_HEADING(N_("Generate"), nullptr), {eModifierType_Array, @@ -223,31 +211,16 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = { ICON_MOD_WIREFRAME, "Wireframe", "Convert faces into thickened edges"}, - {eModifierType_GreasePencilArray, - "GREASE_PENCIL_ARRAY", - ICON_MOD_ARRAY, - "Array strokes", - "Duplicate strokes into an array"}, - {eModifierType_GreasePencilLength, - "GREASE_PENCIL_LENGTH", - ICON_MOD_LENGTH, - "Length", - "Grease Pencil length modifier"}, - {eModifierType_GreasePencilMirror, - "GREASE_PENCIL_MIRROR", - ICON_MOD_MIRROR, - "Mirror strokes", - "Duplicate strokes like a mirror"}, - {eModifierType_GreasePencilMultiply, - "GREASE_PENCIL_MULTIPLY", - ICON_GP_MULTIFRAME_EDITING, - "Multiple Strokes", - "Generate multiple strokes around original strokes"}, {eModifierType_GreasePencilSubdiv, "GREASE_PENCIL_SUBDIV", ICON_MOD_SUBSURF, "Subdivide strokes", "Grease Pencil subdivide modifier"}, + {eModifierType_GreasePencilMirror, + "GREASE_PENCIL_MIRROR", + ICON_MOD_MIRROR, + "Mirror strokes", + "Duplicate strokes like a mirror"}, RNA_ENUM_ITEM_HEADING(N_("Deform"), nullptr), {eModifierType_Armature, @@ -348,16 +321,6 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = { ICON_MOD_THICKNESS, "Thickness", "Change stroke thickness"}, - {eModifierType_GreasePencilLattice, - "GREASE_PENCIL_LATTICE", - ICON_MOD_LATTICE, - "Lattice", - "Deform strokes using a lattice object"}, - {eModifierType_GreasePencilDash, - "GREASE_PENCIL_DASH", - ICON_MOD_DASH, - "Dot Dash", - "Generate dot-dash styled strokes"}, RNA_ENUM_ITEM_HEADING(N_("Physics"), nullptr), {eModifierType_Cloth, "CLOTH", ICON_MOD_CLOTH, "Cloth", ""}, @@ -758,7 +721,7 @@ const EnumPropertyItem rna_enum_subdivision_boundary_smooth_items[] = { # include "DNA_material_types.h" # include "DNA_particle_types.h" -# include "BKE_cachefile.hh" +# include "BKE_cachefile.h" # include "BKE_context.hh" # include "BKE_deform.hh" # include "BKE_material.h" @@ -768,7 +731,6 @@ const EnumPropertyItem rna_enum_subdivision_boundary_smooth_items[] = { # include "BKE_particle.h" # include "BLI_sort_utils.h" -# include "BLI_string_utils.hh" # include "DEG_depsgraph.hh" # include "DEG_depsgraph_build.hh" @@ -905,8 +867,6 @@ RNA_MOD_VGROUP_NAME_SET(WeightVGProximity, mask_defgrp_name); RNA_MOD_VGROUP_NAME_SET(WeightedNormal, defgrp_name); RNA_MOD_VGROUP_NAME_SET(Weld, defgrp_name); RNA_MOD_VGROUP_NAME_SET(Wireframe, defgrp_name); -RNA_MOD_VGROUP_NAME_SET(GreasePencilWeightAngle, target_vgname); -RNA_MOD_VGROUP_NAME_SET(GreasePencilWeightProximity, target_vgname); static void rna_ExplodeModifier_vgroup_get(PointerRNA *ptr, char *value) { @@ -983,10 +943,6 @@ RNA_MOD_OBJECT_SET(NormalEdit, target, OB_EMPTY); RNA_MOD_OBJECT_SET(Shrinkwrap, target, OB_MESH); RNA_MOD_OBJECT_SET(Shrinkwrap, auxTarget, OB_MESH); RNA_MOD_OBJECT_SET(SurfaceDeform, target, OB_MESH); -RNA_MOD_OBJECT_SET(GreasePencilMirror, object, OB_EMPTY); -RNA_MOD_OBJECT_SET(GreasePencilTint, object, OB_EMPTY); -RNA_MOD_OBJECT_SET(GreasePencilLattice, object, OB_LATTICE); -RNA_MOD_OBJECT_SET(GreasePencilWeightProximity, object, OB_EMPTY); static void rna_HookModifier_object_set(PointerRNA *ptr, PointerRNA value, @@ -1898,13 +1854,6 @@ RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET(GreasePencilTint); RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET(GreasePencilSmooth); RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET(GreasePencilNoise); RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET(GreasePencilThick); -RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET(GreasePencilLattice); -RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET(GreasePencilDash); -RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET(GreasePencilMulti); -RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET(GreasePencilLength); -RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET(GreasePencilWeightAngle); -RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET(GreasePencilArray); -RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET(GreasePencilWeightProximity); RNA_MOD_GREASE_PENCIL_VERTEX_GROUP_SET(GreasePencilOffset); RNA_MOD_GREASE_PENCIL_VERTEX_GROUP_SET(GreasePencilOpacity); @@ -1913,10 +1862,6 @@ RNA_MOD_GREASE_PENCIL_VERTEX_GROUP_SET(GreasePencilTint); RNA_MOD_GREASE_PENCIL_VERTEX_GROUP_SET(GreasePencilSmooth); RNA_MOD_GREASE_PENCIL_VERTEX_GROUP_SET(GreasePencilNoise); RNA_MOD_GREASE_PENCIL_VERTEX_GROUP_SET(GreasePencilThick); -RNA_MOD_GREASE_PENCIL_VERTEX_GROUP_SET(GreasePencilLattice); -RNA_MOD_GREASE_PENCIL_VERTEX_GROUP_SET(GreasePencilLength); -RNA_MOD_GREASE_PENCIL_VERTEX_GROUP_SET(GreasePencilWeightAngle); -RNA_MOD_GREASE_PENCIL_VERTEX_GROUP_SET(GreasePencilWeightProximity); static void rna_GreasePencilOpacityModifier_opacity_factor_range( PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax) @@ -1938,78 +1883,26 @@ static void rna_GreasePencilOpacityModifier_opacity_factor_max_set(PointerRNA *p value; } -static const GreasePencilDashModifierData *find_grease_pencil_dash_modifier_of_segment( - const Object &ob, const GreasePencilDashModifierSegment &dash_segment) +static void rna_GreasePencilTintModifier_object_set(PointerRNA *ptr, + PointerRNA value, + ReportList * /*reports*/) { - LISTBASE_FOREACH (const ModifierData *, md, &ob.modifiers) { - if (md->type == eModifierType_GreasePencilDash) { - const auto *dmd = reinterpret_cast(md); - if (dmd->segments().contains_ptr(&dash_segment)) { - return dmd; - } - } - } - return nullptr; + GreasePencilTintModifierData *tmd = static_cast(ptr->data); + Object *ob = static_cast(value.data); + + tmd->object = ob; + id_lib_extern(&ob->id); } -static std::optional rna_GreasePencilDashModifierSegment_path(const PointerRNA *ptr) - +static void rna_GreasePencilMirrorModifier_object_set(PointerRNA *ptr, + PointerRNA value, + ReportList * /*reports*/) { - const Object *ob = reinterpret_cast(ptr->owner_id); - const auto *dash_segment = static_cast(ptr->data); - const GreasePencilDashModifierData *dmd = find_grease_pencil_dash_modifier_of_segment( - *ob, *dash_segment); - BLI_assert(dmd != nullptr); + GreasePencilMirrorModifierData *mmd = static_cast(ptr->data); + Object *ob = static_cast(value.data); - char name_esc[sizeof(dmd->modifier.name) * 2]; - BLI_str_escape(name_esc, dmd->modifier.name, sizeof(name_esc)); - - char ds_name_esc[sizeof(dash_segment->name) * 2]; - BLI_str_escape(ds_name_esc, dash_segment->name, sizeof(ds_name_esc)); - - return fmt::format("modifiers[\"{}\"].segments[\"{}\"]", name_esc, ds_name_esc); -} - -static void rna_GreasePencilDashModifierSegment_name_set(PointerRNA *ptr, const char *value) -{ - const Object *ob = reinterpret_cast(ptr->owner_id); - auto *dash_segment = static_cast(ptr->data); - const GreasePencilDashModifierData *dmd = find_grease_pencil_dash_modifier_of_segment( - *ob, *dash_segment); - BLI_assert(dmd != nullptr); - - const std::string oldname = dash_segment->name; - STRNCPY_UTF8(dash_segment->name, value); - BLI_uniquename_cb( - [dmd, dash_segment](const blender::StringRef name) { - for (const GreasePencilDashModifierSegment &ds : dmd->segments()) { - if (&ds != dash_segment && ds.name == name) { - return true; - } - } - return false; - }, - '.', - dash_segment->name); - - /* Fix all the animation data which may link to this. */ - char name_esc[sizeof(dmd->modifier.name) * 2]; - BLI_str_escape(name_esc, dmd->modifier.name, sizeof(name_esc)); - char rna_path_prefix[36 + sizeof(name_esc) + 1]; - SNPRINTF(rna_path_prefix, "modifiers[\"%s\"].segments", name_esc); - BKE_animdata_fix_paths_rename_all(nullptr, rna_path_prefix, oldname.c_str(), dash_segment->name); -} - -static void rna_GreasePencilDashModifier_segments_begin(CollectionPropertyIterator *iter, - PointerRNA *ptr) -{ - auto *dmd = static_cast(ptr->data); - rna_iterator_array_begin(iter, - dmd->segments_array, - sizeof(GreasePencilDashModifierSegment), - dmd->segments_num, - false, - nullptr); + mmd->object = ob; + id_lib_extern(&ob->id); } #else @@ -7924,6 +7817,7 @@ static void rna_def_modifier_grease_pencil_opacity(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + static const EnumPropertyItem color_mode_items[] = { {MOD_GREASE_PENCIL_COLOR_BOTH, "BOTH", 0, "Stroke & Fill", "Modify fill and stroke colors"}, {MOD_GREASE_PENCIL_COLOR_STROKE, "STROKE", 0, "Stroke", "Modify stroke color only"}, @@ -8433,153 +8327,6 @@ static void rna_def_modifier_grease_pencil_noise(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, nullptr, "noise_mode"); RNA_def_property_enum_items(prop, modifier_noise_random_mode_items); RNA_def_property_ui_text(prop, "Mode", "Where to perform randomization"); - - RNA_define_lib_overridable(false); -} - -static void rna_def_modifier_grease_pencil_length(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - static const EnumPropertyItem gpencil_length_mode_items[] = { - {GP_LENGTH_RELATIVE, "RELATIVE", 0, "Relative", "Length in ratio to the stroke's length"}, - {GP_LENGTH_ABSOLUTE, "ABSOLUTE", 0, "Absolute", "Length in geometry space"}, - {0, nullptr, 0, nullptr, nullptr}, - }; - - srna = RNA_def_struct(brna, "GreasePencilLengthModifier", "Modifier"); - RNA_def_struct_ui_text(srna, "Length Modifier", "Stretch or shrink strokes"); - RNA_def_struct_sdna(srna, "GreasePencilLengthModifierData"); - RNA_def_struct_ui_icon(srna, ICON_MOD_LENGTH); - - rna_def_modifier_grease_pencil_layer_filter(srna); - rna_def_modifier_grease_pencil_material_filter( - srna, "rna_GreasePencilLengthModifier_material_filter_set"); - rna_def_modifier_grease_pencil_vertex_group( - srna, "rna_GreasePencilLengthModifier_vertex_group_name_set"); - - rna_def_modifier_panel_open_prop(srna, "open_random_panel", 0); - rna_def_modifier_panel_open_prop(srna, "open_curvature_panel", 1); - rna_def_modifier_panel_open_prop(srna, "open_influence_panel", 2); - - RNA_define_lib_overridable(true); - - prop = RNA_def_property(srna, "start_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, nullptr, "start_fac"); - RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1, 2); - RNA_def_property_ui_text( - prop, "Start Factor", "Added length to the start of each stroke relative to its length"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "end_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, nullptr, "end_fac"); - RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1, 2); - RNA_def_property_ui_text( - prop, "End Factor", "Added length to the end of each stroke relative to its length"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "start_length", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, nullptr, "start_fac"); - RNA_def_property_ui_range(prop, -100.0f, 100.0f, 0.1f, 3); - RNA_def_property_ui_text( - prop, "Start Factor", "Absolute added length to the start of each stroke"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "end_length", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, nullptr, "end_fac"); - RNA_def_property_ui_range(prop, -100.0f, 100.0f, 0.1f, 3); - RNA_def_property_ui_text(prop, "End Factor", "Absolute added length to the end of each stroke"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "random_start_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, nullptr, "rand_start_fac"); - RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1, 1); - RNA_def_property_ui_text( - prop, "Random Start Factor", "Size of random length added to the start of each stroke"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "random_end_factor", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, nullptr, "rand_end_fac"); - RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1, 1); - RNA_def_property_ui_text( - prop, "Random End Factor", "Size of random length added to the end of each stroke"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "random_offset", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, nullptr, "rand_offset"); - RNA_def_property_ui_range(prop, 0.0f, 100.0f, 0.1, 3); - RNA_def_property_ui_text( - prop, "Random Noise Offset", "Smoothly offset each stroke's random value"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "use_random", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flag", GP_LENGTH_USE_RANDOM); - RNA_def_property_ui_text(prop, "Random", "Use random values over time"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED); - RNA_def_property_ui_text(prop, "Seed", "Random seed"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "step", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, nullptr, "step"); - RNA_def_property_range(prop, 1, 100); - RNA_def_property_ui_text(prop, "Step", "Number of frames between randomization steps"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "overshoot_factor", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, nullptr, "overshoot_fac"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text( - prop, - "Used Length", - "Defines what portion of the stroke is used for the calculation of the extension"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, nullptr, "mode"); - RNA_def_property_enum_items(prop, gpencil_length_mode_items); - RNA_def_property_ui_text(prop, "Mode", "Mode to define length"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "use_curvature", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flag", GP_LENGTH_USE_CURVATURE); - RNA_def_property_ui_text(prop, "Use Curvature", "Follow the curvature of the stroke"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "invert_curvature", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flag", GP_LENGTH_INVERT_CURVATURE); - RNA_def_property_ui_text( - prop, "Invert Curvature", "Invert the curvature of the stroke's extension"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "point_density", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.1f, 1000.0f); - RNA_def_property_ui_range(prop, 0.1f, 1000.0f, 1.0f, 1); - RNA_def_property_ui_scale_type(prop, PROP_SCALE_CUBIC); - RNA_def_property_ui_text( - prop, "Point Density", "Multiplied by Start/End for the total added point count"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "segment_influence", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_range(prop, -2.0f, 3.0f); - RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 2); - RNA_def_property_ui_text(prop, - "Segment Influence", - "Factor to determine how much the length of the individual segments " - "should influence the final computed curvature. Higher factors makes " - "small segments influence the overall curvature less"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "max_angle", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_ui_text(prop, - "Filter Angle", - "Ignore points on the stroke that deviate from their neighbors by more " - "than this angle when determining the extrapolation shape"); - RNA_def_property_range(prop, 0.0f, DEG2RAD(180.0f)); - RNA_def_property_ui_range(prop, 0.0f, DEG2RAD(179.5f), 10.0f, 1); - RNA_def_property_update(prop, NC_SCENE, "rna_Modifier_update"); - RNA_define_lib_overridable(false); } @@ -8674,472 +8421,6 @@ static void rna_def_modifier_grease_pencil_thickness(BlenderRNA *brna) RNA_define_lib_overridable(false); } -static void rna_def_modifier_grease_pencil_array(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "GreasePencilArrayModifier", "Modifier"); - RNA_def_struct_ui_text(srna, "Instance Modifier", "Create grid of duplicate instances"); - RNA_def_struct_sdna(srna, "GreasePencilArrayModifierData"); - RNA_def_struct_ui_icon(srna, ICON_MOD_ARRAY); - - rna_def_modifier_grease_pencil_layer_filter(srna); - rna_def_modifier_grease_pencil_material_filter( - srna, "rna_GreasePencilArrayModifier_material_filter_set"); - - rna_def_modifier_panel_open_prop(srna, "open_constant_offset_panel", 0); - rna_def_modifier_panel_open_prop(srna, "open_relative_offset_panel", 1); - rna_def_modifier_panel_open_prop(srna, "open_object_offset_panel", 2); - rna_def_modifier_panel_open_prop(srna, "open_randomize_panel", 3); - rna_def_modifier_panel_open_prop(srna, "open_influence_panel", 4); - - RNA_define_lib_overridable(true); - - prop = RNA_def_property(srna, "count", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 1, SHRT_MAX); - RNA_def_property_ui_range(prop, 1, 50, 1, -1); - RNA_def_property_ui_text(prop, "Count", "Number of items"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - /* Offset parameters */ - prop = RNA_def_property(srna, "offset_object", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, nullptr, "object"); - RNA_def_property_ui_text( - prop, - "Offset Object", - "Use the location and rotation of another object to determine the distance and " - "rotational change between arrayed items"); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); - RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); - - prop = RNA_def_property(srna, "constant_offset", PROP_FLOAT, PROP_TRANSLATION); - RNA_def_property_float_sdna(prop, nullptr, "offset"); - RNA_def_property_ui_text(prop, "Constant Offset", "Value for the distance between items"); - RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "relative_offset", PROP_FLOAT, PROP_XYZ); - RNA_def_property_float_sdna(prop, nullptr, "shift"); - RNA_def_property_ui_text( - prop, - "Relative Offset", - "The size of the geometry will determine the distance between arrayed items"); - RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "random_offset", PROP_FLOAT, PROP_XYZ); - RNA_def_property_float_sdna(prop, nullptr, "rnd_offset"); - RNA_def_property_ui_text(prop, "Random Offset", "Value for changes in location"); - RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "random_rotation", PROP_FLOAT, PROP_EULER); - RNA_def_property_float_sdna(prop, nullptr, "rnd_rot"); - RNA_def_property_ui_text(prop, "Random Rotation", "Value for changes in rotation"); - RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 100, RNA_TRANSLATION_PREC_DEFAULT); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "random_scale", PROP_FLOAT, PROP_XYZ); - RNA_def_property_float_sdna(prop, nullptr, "rnd_scale"); - RNA_def_property_ui_text(prop, "Scale", "Value for changes in scale"); - RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED); - RNA_def_property_ui_text(prop, "Seed", "Random seed"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "replace_material", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, nullptr, "mat_rpl"); - RNA_def_property_range(prop, 0, SHRT_MAX); - RNA_def_property_ui_text( - prop, - "Material", - "Index of the material used for generated strokes (0 keep original material)"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "use_constant_offset", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flag", MOD_GREASE_PENCIL_ARRAY_USE_OFFSET); - RNA_def_property_ui_text(prop, "Offset", "Enable offset"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "use_object_offset", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flag", MOD_GREASE_PENCIL_ARRAY_USE_OB_OFFSET); - RNA_def_property_ui_text(prop, "Use Object Offset", "Enable object offset"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "use_relative_offset", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flag", MOD_GREASE_PENCIL_ARRAY_USE_RELATIVE); - RNA_def_property_ui_text(prop, "Shift", "Enable shift"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "use_uniform_random_scale", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna( - prop, nullptr, "flag", MOD_GREASE_PENCIL_ARRAY_UNIFORM_RANDOM_SCALE); - RNA_def_property_ui_text( - prop, "Uniform Scale", "Use the same random seed for each scale axis for a uniform scale"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - RNA_define_lib_overridable(false); -} - -static void rna_def_modifier_grease_pencil_lattice(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "GreasePencilLatticeModifier", "Modifier"); - RNA_def_struct_ui_text( - srna, "Grease Pencil Lattice Modifier", "Deform strokes using a lattice object"); - RNA_def_struct_sdna(srna, "GreasePencilLatticeModifierData"); - RNA_def_struct_ui_icon(srna, ICON_MOD_LATTICE); - - rna_def_modifier_grease_pencil_layer_filter(srna); - rna_def_modifier_grease_pencil_material_filter( - srna, "rna_GreasePencilLatticeModifier_material_filter_set"); - rna_def_modifier_grease_pencil_vertex_group( - srna, "rna_GreasePencilLatticeModifier_vertex_group_name_set"); - - rna_def_modifier_panel_open_prop(srna, "open_influence_panel", 0); - - RNA_define_lib_overridable(true); - - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_ui_text(prop, "Object", "Lattice object to deform with"); - RNA_def_property_pointer_funcs(prop, - nullptr, - "rna_GreasePencilLatticeModifier_object_set", - nullptr, - "rna_Lattice_object_poll"); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); - RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); - - prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); - RNA_def_property_ui_range(prop, 0, 1, 10, 2); - RNA_def_property_ui_text(prop, "Strength", "Strength of modifier effect"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - RNA_define_lib_overridable(false); -} - -static void rna_def_modifier_grease_pencil_dash_segment(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "GreasePencilDashModifierSegment", nullptr); - RNA_def_struct_ui_text(srna, "Dash Modifier Segment", "Configuration for a single dash segment"); - RNA_def_struct_sdna(srna, "GreasePencilDashModifierSegment"); - RNA_def_struct_path_func(srna, "rna_GreasePencilDashModifierSegment_path"); - - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_property_ui_text(prop, "Name", "Name of the dash segment"); - RNA_def_property_string_funcs( - prop, nullptr, nullptr, "rna_GreasePencilDashModifierSegment_name_set"); - RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER | NA_RENAME, nullptr); - RNA_def_struct_name_property(srna, prop); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "dash", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 1, INT16_MAX); - RNA_def_property_ui_text( - prop, - "Dash", - "The number of consecutive points from the original stroke to include in this segment"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "gap", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 0, INT16_MAX); - RNA_def_property_ui_text(prop, "Gap", "The number of points skipped after this segment"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_FACTOR | PROP_UNSIGNED); - RNA_def_property_ui_range(prop, 0, 1, 0.1, 2); - RNA_def_property_ui_text( - prop, "Radius", "The factor to apply to the original point's radius for the new points"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "opacity", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_ui_range(prop, 0, 1, 0.1, 2); - RNA_def_property_ui_text( - prop, "Opacity", "The factor to apply to the original point's opacity for the new points"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, nullptr, "mat_nr"); - RNA_def_property_range(prop, -1, INT16_MAX); - RNA_def_property_ui_text( - prop, - "Material Index", - "Use this index on generated segment. -1 means using the existing material"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flag", MOD_GREASE_PENCIL_DASH_USE_CYCLIC); - RNA_def_property_ui_text(prop, "Cyclic", "Enable cyclic on individual stroke dashes"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); -} - -static void rna_def_modifier_grease_pencil_dash(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "GreasePencilDashModifierData", "Modifier"); - RNA_def_struct_ui_text( - srna, "Grease Pencil Dash Modifier", "Create dot-dash effect for strokes"); - RNA_def_struct_sdna(srna, "GreasePencilDashModifierData"); - RNA_def_struct_ui_icon(srna, ICON_MOD_DASH); - - rna_def_modifier_grease_pencil_layer_filter(srna); - rna_def_modifier_grease_pencil_material_filter( - srna, "rna_GreasePencilDashModifier_material_filter_set"); - - rna_def_modifier_panel_open_prop(srna, "open_influence_panel", 0); - - RNA_define_lib_overridable(true); - - prop = RNA_def_property(srna, "segments", PROP_COLLECTION, PROP_NONE); - RNA_def_property_struct_type(prop, "GreasePencilDashModifierSegment"); - RNA_def_property_collection_sdna(prop, nullptr, "segments_array", nullptr); - RNA_def_property_collection_funcs(prop, - "rna_GreasePencilDashModifier_segments_begin", - "rna_iterator_array_next", - "rna_iterator_array_end", - "rna_iterator_array_get", - nullptr, - nullptr, - nullptr, - nullptr); - RNA_def_property_ui_text(prop, "Segments", ""); - - prop = RNA_def_property(srna, "segment_active_index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "Active Dash Segment Index", "Active index in the segment list"); - - prop = RNA_def_property(srna, "dash_offset", PROP_INT, PROP_NONE); - RNA_def_property_ui_text( - prop, - "Offset", - "Offset into each stroke before the beginning of the dashed segment generation"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - RNA_define_lib_overridable(false); -} - -static void rna_def_modifier_grease_pencil_weight_angle(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem axis_items[] = { - {0, "X", 0, "X", ""}, - {1, "Y", 0, "Y", ""}, - {2, "Z", 0, "Z", ""}, - {0, nullptr, 0, nullptr, nullptr}, - }; - - static const EnumPropertyItem space_items[] = { - {MOD_GREASE_PENCIL_WEIGHT_ANGLE_SPACE_LOCAL, "LOCAL", 0, "Local Space", ""}, - {MOD_GREASE_PENCIL_WEIGHT_ANGLE_SPACE_WORLD, "WORLD", 0, "World Space", ""}, - {0, nullptr, 0, nullptr, nullptr}, - }; - - srna = RNA_def_struct(brna, "GreasePencilWeightAngleModifier", "Modifier"); - RNA_def_struct_ui_text(srna, "Weight Modifier Angle", "Calculate Vertex Weight dynamically"); - RNA_def_struct_sdna(srna, "GreasePencilWeightAngleModifierData"); - RNA_def_struct_ui_icon(srna, ICON_MOD_VERTEX_WEIGHT); - - rna_def_modifier_grease_pencil_layer_filter(srna); - rna_def_modifier_grease_pencil_material_filter( - srna, "rna_GreasePencilWeightAngleModifier_material_filter_set"); - rna_def_modifier_grease_pencil_vertex_group( - srna, "rna_GreasePencilWeightAngleModifier_vertex_group_name_set"); - - rna_def_modifier_panel_open_prop(srna, "open_influence_panel", 0); - - RNA_define_lib_overridable(true); - - prop = RNA_def_property(srna, "target_vertex_group", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, nullptr, "target_vgname"); - RNA_def_property_ui_text(prop, "Vertex Group", "Output Vertex group"); - RNA_def_property_string_funcs( - prop, nullptr, nullptr, "rna_GreasePencilWeightAngleModifier_target_vgname_set"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "use_multiply", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flag", GP_WEIGHT_MULTIPLY_DATA); - RNA_def_property_ui_text( - prop, - "Multiply Weights", - "Multiply the calculated weights with the existing values in the vertex group"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "use_invert_output", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flag", GP_WEIGHT_INVERT_OUTPUT); - RNA_def_property_ui_text(prop, "Invert", "Invert output weight values"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_float_sdna(prop, nullptr, "angle"); - RNA_def_property_ui_text(prop, "Angle", "Angle"); - RNA_def_property_range(prop, 0.0f, DEG2RAD(180.0f)); - RNA_def_property_update(prop, NC_SCENE, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, nullptr, "axis"); - RNA_def_property_enum_items(prop, axis_items); - RNA_def_property_ui_text(prop, "Axis", ""); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, nullptr, "space"); - RNA_def_property_enum_items(prop, space_items); - RNA_def_property_ui_text(prop, "Space", "Coordinates space"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "minimum_weight", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, nullptr, "min_weight"); - RNA_def_property_ui_text(prop, "Minimum", "Minimum value for vertex weight"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - RNA_define_lib_overridable(false); -} - -static void rna_def_modifier_grease_pencil_multiply(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "GreasePencilMultiplyModifier", "Modifier"); - RNA_def_struct_ui_text(srna, "Multiply Modifier", "Generate multiple strokes from one stroke"); - RNA_def_struct_sdna(srna, "GreasePencilMultiModifierData"); - RNA_def_struct_ui_icon(srna, ICON_GP_MULTIFRAME_EDITING); - - rna_def_modifier_grease_pencil_layer_filter(srna); - rna_def_modifier_grease_pencil_material_filter( - srna, "rna_GreasePencilMultiModifier_material_filter_set"); - - rna_def_modifier_panel_open_prop(srna, "open_fading_panel", 1); - rna_def_modifier_panel_open_prop(srna, "open_influence_panel", 0); - - RNA_define_lib_overridable(true); - - prop = RNA_def_property(srna, "use_fade", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "flag", MOD_GREASE_PENCIL_MULTIPLY_ENABLE_FADING); - RNA_def_property_ui_text(prop, "Fade", "Fade the stroke thickness for each generated stroke"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "duplicates", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, nullptr, "duplications"); - RNA_def_property_range(prop, 0, 999); - RNA_def_property_ui_range(prop, 1, 10, 1, 1); - RNA_def_property_ui_text(prop, "duplicates", "How many copies of strokes be displayed"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); - RNA_def_property_ui_range(prop, 0.0, 1.0, 0.01, 3); - RNA_def_property_ui_text(prop, "Distance", "Distance of duplications"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_range(prop, -1, 1, 0.01, 3); - RNA_def_property_ui_text(prop, "Offset", "Offset of duplicates. -1 to 1: inner to outer"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "fading_thickness", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Thickness", "Fade influence of stroke's thickness"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "fading_opacity", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Opacity", "Fade influence of stroke's opacity"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "fading_center", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Center", "Fade center"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - RNA_define_lib_overridable(false); -} - -static void rna_def_modifier_grease_pencil_weight_proximity(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "GreasePencilWeightProximityModifier", "Modifier"); - RNA_def_struct_ui_text(srna, "Weight Modifier Proximity", "Calculate Vertex Weight dynamically"); - RNA_def_struct_sdna(srna, "GreasePencilWeightProximityModifierData"); - RNA_def_struct_ui_icon(srna, ICON_MOD_VERTEX_WEIGHT); - - rna_def_modifier_grease_pencil_layer_filter(srna); - rna_def_modifier_grease_pencil_material_filter( - srna, "rna_GreasePencilWeightProximityModifier_material_filter_set"); - rna_def_modifier_grease_pencil_vertex_group( - srna, "rna_GreasePencilWeightProximityModifier_vertex_group_name_set"); - - rna_def_modifier_panel_open_prop(srna, "open_influence_panel", 0); - - RNA_define_lib_overridable(true); - - prop = RNA_def_property(srna, "use_multiply", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna( - prop, nullptr, "flag", MOD_GREASE_PENCIL_WEIGHT_PROXIMITY_MULTIPLY_DATA); - RNA_def_property_ui_text( - prop, - "Multiply Weights", - "Multiply the calculated weights with the existing values in the vertex group"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "use_invert_output", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna( - prop, nullptr, "flag", MOD_GREASE_PENCIL_WEIGHT_PROXIMITY_INVERT_OUTPUT); - RNA_def_property_ui_text(prop, "Invert", "Invert output weight values"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "target_vertex_group", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, nullptr, "target_vgname"); - RNA_def_property_ui_text(prop, "Vertex Group", "Output Vertex group"); - RNA_def_property_string_funcs( - prop, nullptr, nullptr, "rna_GreasePencilWeightProximityModifier_target_vgname_set"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - /* Distance reference object */ - prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); - RNA_def_property_ui_text(prop, "Target Object", "Object used as distance reference"); - RNA_def_property_pointer_funcs( - prop, nullptr, "rna_GreasePencilWeightProximityModifier_object_set", nullptr, nullptr); - RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); - RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); - - prop = RNA_def_property(srna, "distance_start", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, nullptr, "dist_start"); - RNA_def_property_range(prop, 0.0, FLT_MAX); - RNA_def_property_ui_range(prop, 0.0, 1000.0, 1.0, 2); - RNA_def_property_ui_text(prop, "Lowest", "Distance mapping to 0.0 weight"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "minimum_weight", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, nullptr, "min_weight"); - RNA_def_property_ui_text(prop, "Minimum", "Minimum value for vertex weight"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "distance_end", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_float_sdna(prop, nullptr, "dist_end"); - RNA_def_property_range(prop, 0.0, FLT_MAX); - RNA_def_property_ui_range(prop, 0.0, 1000.0, 1.0, 2); - RNA_def_property_ui_text(prop, "Highest", "Distance mapping to 1.0 weight"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - RNA_define_lib_overridable(false); -} - void RNA_def_modifier(BlenderRNA *brna) { StructRNA *srna; @@ -9316,14 +8597,6 @@ void RNA_def_modifier(BlenderRNA *brna) rna_def_modifier_grease_pencil_noise(brna); rna_def_modifier_grease_pencil_mirror(brna); rna_def_modifier_grease_pencil_thickness(brna); - rna_def_modifier_grease_pencil_lattice(brna); - rna_def_modifier_grease_pencil_dash_segment(brna); - rna_def_modifier_grease_pencil_dash(brna); - rna_def_modifier_grease_pencil_multiply(brna); - rna_def_modifier_grease_pencil_length(brna); - rna_def_modifier_grease_pencil_weight_angle(brna); - rna_def_modifier_grease_pencil_array(brna); - rna_def_modifier_grease_pencil_weight_proximity(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_node_socket.cc b/source/blender/makesrna/intern/rna_node_socket.cc index 44fd6319cbe..592eed23752 100644 --- a/source/blender/makesrna/intern/rna_node_socket.cc +++ b/source/blender/makesrna/intern/rna_node_socket.cc @@ -25,7 +25,6 @@ const EnumPropertyItem rna_enum_node_socket_type_items[] = { {SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""}, {SOCK_VECTOR, "VECTOR", 0, "Vector", ""}, {SOCK_ROTATION, "ROTATION", 0, "Rotation", ""}, - {SOCK_MATRIX, "MATRIX", 0, "Matrix", ""}, {SOCK_STRING, "STRING", 0, "String", ""}, {SOCK_RGBA, "RGBA", 0, "RGBA", ""}, {SOCK_SHADER, "SHADER", 0, "Shader", ""}, @@ -45,7 +44,7 @@ const EnumPropertyItem rna_enum_node_socket_type_items[] = { # include "DNA_material_types.h" -# include "BKE_node.hh" +# include "BKE_node.h" # include "BKE_node_enum.hh" # include "BKE_node_runtime.hh" # include "BKE_node_tree_update.hh" @@ -1012,30 +1011,6 @@ static void rna_def_node_socket_interface_rotation(BlenderRNA *brna, const char rna_def_node_tree_interface_socket_builtin(srna); } -static void rna_def_node_socket_matrix(BlenderRNA *brna, const char *identifier) -{ - StructRNA *srna; - - srna = RNA_def_struct(brna, identifier, "NodeSocketStandard"); - RNA_def_struct_ui_text(srna, "Matrix Node Socket", "Matrix value socket of a node"); - RNA_def_struct_sdna(srna, "bNodeSocket"); - - RNA_def_struct_sdna_from(srna, "bNodeSocket", nullptr); -} - -static void rna_def_node_socket_interface_matrix(BlenderRNA *brna, const char *identifier) -{ - StructRNA *srna; - - srna = RNA_def_struct(brna, identifier, "NodeTreeInterfaceSocket"); - RNA_def_struct_ui_text(srna, "Matrix Node Socket Interface", "Matrix value socket of a node"); - RNA_def_struct_sdna(srna, "bNodeTreeInterfaceSocket"); - - RNA_def_struct_sdna_from(srna, "bNodeTreeInterfaceSocket", nullptr); - - rna_def_node_tree_interface_socket_builtin(srna); -} - static void rna_def_node_socket_vector(BlenderRNA *brna, const char *identifier, PropertySubType subtype) @@ -1553,7 +1528,6 @@ static const bNodeSocketStaticTypeInfo node_socket_subtypes[] = { {"NodeSocketIntFactor", "NodeTreeInterfaceSocketIntFactor", SOCK_INT, PROP_FACTOR}, {"NodeSocketBool", "NodeTreeInterfaceSocketBool", SOCK_BOOLEAN, PROP_NONE}, {"NodeSocketRotation", "NodeTreeInterfaceSocketRotation", SOCK_ROTATION, PROP_NONE}, - {"NodeSocketMatrix", "NodeTreeInterfaceSocketMatrix", SOCK_MATRIX, PROP_NONE}, {"NodeSocketVector", "NodeTreeInterfaceSocketVector", SOCK_VECTOR, PROP_NONE}, {"NodeSocketVectorTranslation", "NodeTreeInterfaceSocketVectorTranslation", @@ -1603,9 +1577,6 @@ static void rna_def_node_socket_subtypes(BlenderRNA *brna) case SOCK_ROTATION: rna_def_node_socket_rotation(brna, identifier); break; - case SOCK_MATRIX: - rna_def_node_socket_matrix(brna, identifier); - break; case SOCK_VECTOR: rna_def_node_socket_vector(brna, identifier, info.subtype); break; @@ -1669,9 +1640,6 @@ void rna_def_node_socket_interface_subtypes(BlenderRNA *brna) case SOCK_ROTATION: rna_def_node_socket_interface_rotation(brna, identifier); break; - case SOCK_MATRIX: - rna_def_node_socket_interface_matrix(brna, identifier); - break; case SOCK_VECTOR: rna_def_node_socket_interface_vector(brna, identifier, info.subtype); break; diff --git a/source/blender/makesrna/intern/rna_node_tree_interface.cc b/source/blender/makesrna/intern/rna_node_tree_interface.cc index b8fb2c698d8..63d951fd15b 100644 --- a/source/blender/makesrna/intern/rna_node_tree_interface.cc +++ b/source/blender/makesrna/intern/rna_node_tree_interface.cc @@ -31,7 +31,7 @@ static const EnumPropertyItem node_tree_interface_socket_in_out_items[] = { # include # include "BKE_attribute.hh" -# include "BKE_node.hh" +# include "BKE_node.h" # include "BKE_node_enum.hh" # include "BKE_node_runtime.hh" # include "BKE_node_tree_interface.hh" @@ -39,7 +39,7 @@ static const EnumPropertyItem node_tree_interface_socket_in_out_items[] = { # include "BLI_set.hh" -# include "BLT_translation.hh" +# include "BLT_translation.h" # include "DNA_material_types.h" # include "ED_node.hh" diff --git a/source/blender/makesrna/intern/rna_nodetree.cc b/source/blender/makesrna/intern/rna_nodetree.cc index 13fe66b60d2..e54a6a2405b 100644 --- a/source/blender/makesrna/intern/rna_nodetree.cc +++ b/source/blender/makesrna/intern/rna_nodetree.cc @@ -19,7 +19,7 @@ #include "BLF_api.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_curves_types.h" #include "DNA_material_types.h" @@ -36,7 +36,7 @@ #include "BKE_cryptomatte.h" #include "BKE_geometry_set.hh" #include "BKE_image.h" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" #include "BKE_texture.h" @@ -77,7 +77,6 @@ const EnumPropertyItem rna_enum_node_socket_data_type_items[] = { {SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""}, {SOCK_VECTOR, "VECTOR", 0, "Vector", ""}, {SOCK_ROTATION, "ROTATION", 0, "Rotation", ""}, - {SOCK_MATRIX, "MATRIX", 0, "Matrix", ""}, {SOCK_STRING, "STRING", 0, "String", ""}, {SOCK_MENU, "MENU", 0, "Menu", ""}, {SOCK_RGBA, "RGBA", 0, "Color", ""}, @@ -97,11 +96,58 @@ static const EnumPropertyItem node_quality_items[] = { {NTREE_QUALITY_LOW, "LOW", 0, "Low", "Low quality"}, {0, nullptr, 0, nullptr, nullptr}, }; + +static const EnumPropertyItem node_chunksize_items[] = { + {NTREE_CHUNKSIZE_32, + "32", + 0, + "32" BLI_STR_UTF8_MULTIPLICATION_SIGN "32", + "Chunksize of 32" BLI_STR_UTF8_MULTIPLICATION_SIGN "32"}, + {NTREE_CHUNKSIZE_64, + "64", + 0, + "64" BLI_STR_UTF8_MULTIPLICATION_SIGN "64", + "Chunksize of 64" BLI_STR_UTF8_MULTIPLICATION_SIGN "64"}, + {NTREE_CHUNKSIZE_128, + "128", + 0, + "128" BLI_STR_UTF8_MULTIPLICATION_SIGN "128", + "Chunksize of 128" BLI_STR_UTF8_MULTIPLICATION_SIGN "128"}, + {NTREE_CHUNKSIZE_256, + "256", + 0, + "256" BLI_STR_UTF8_MULTIPLICATION_SIGN "256", + "Chunksize of 256" BLI_STR_UTF8_MULTIPLICATION_SIGN "256"}, + {NTREE_CHUNKSIZE_512, + "512", + 0, + "512" BLI_STR_UTF8_MULTIPLICATION_SIGN "512", + "Chunksize of 512" BLI_STR_UTF8_MULTIPLICATION_SIGN "512"}, + {NTREE_CHUNKSIZE_1024, + "1024", + 0, + "1024" BLI_STR_UTF8_MULTIPLICATION_SIGN "1024", + "Chunksize of 1024" BLI_STR_UTF8_MULTIPLICATION_SIGN "1024"}, + {0, nullptr, 0, nullptr, nullptr}, +}; #endif static const EnumPropertyItem rna_enum_execution_mode_items[] = { - {NTREE_EXECUTION_MODE_CPU, "CPU", 0, "CPU", ""}, - {NTREE_EXECUTION_MODE_GPU, "GPU", 0, "GPU", ""}, + {NTREE_EXECUTION_MODE_TILED, + "TILED", + 0, + "Tiled", + "Compositing is tiled, having as priority to display first tiles as fast as possible"}, + {NTREE_EXECUTION_MODE_FULL_FRAME, + "FULL_FRAME", + 0, + "Full Frame", + "Composites full image result as fast as possible"}, + {NTREE_EXECUTION_MODE_REALTIME, + "REALTIME", + 0, + "GPU", + "Use GPU accelerated compositing with more limited functionality"}, {0, nullptr, 0, nullptr, nullptr}, }; @@ -549,7 +595,7 @@ static const EnumPropertyItem node_cryptomatte_layer_name_items[] = { # include "BKE_context.hh" # include "BKE_idprop.h" -# include "BKE_global.hh" +# include "BKE_global.h" # include "ED_node.hh" # include "ED_render.hh" @@ -1848,8 +1894,7 @@ static bool generic_attribute_type_supported(const EnumPropertyItem *item) CD_PROP_BOOL, CD_PROP_INT32, CD_PROP_BYTE_COLOR, - CD_PROP_QUATERNION, - CD_PROP_FLOAT4X4); + CD_PROP_QUATERNION); } static bool generic_attribute_type_supported_with_socket(const EnumPropertyItem *item) @@ -2187,8 +2232,7 @@ static bNodeSocket *rna_Node_inputs_new(ID *id, ReportList *reports, const char *type, const char *name, - const char *identifier, - const bool use_multi_input) + const char *identifier) { if (!allow_changing_sockets(node)) { BKE_report(reports, RPT_ERROR, "Cannot add socket to built-in node"); @@ -2202,9 +2246,6 @@ static bNodeSocket *rna_Node_inputs_new(ID *id, BKE_report(reports, RPT_ERROR, "Unable to create socket"); } else { - if (use_multi_input) { - sock->flag |= SOCK_MULTI_INPUT; - } ED_node_tree_propagate_change(nullptr, bmain, ntree); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); } @@ -2218,19 +2259,13 @@ static bNodeSocket *rna_Node_outputs_new(ID *id, ReportList *reports, const char *type, const char *name, - const char *identifier, - const bool use_multi_input) + const char *identifier) { if (!allow_changing_sockets(node)) { BKE_report(reports, RPT_ERROR, "Cannot add socket to built-in node"); return nullptr; } - if (use_multi_input) { - BKE_report(reports, RPT_ERROR, "Output sockets cannot be multi-input"); - return nullptr; - } - bNodeTree *ntree = reinterpret_cast(id); bNodeSocket *sock = nodeAddSocket(ntree, node, SOCK_OUT, type, identifier, name); @@ -9894,8 +9929,6 @@ static void rna_def_node_sockets_api(BlenderRNA *brna, PropertyRNA *cprop, int i parm = RNA_def_string(func, "name", nullptr, MAX_NAME, "Name", ""); RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED); RNA_def_string(func, "identifier", nullptr, MAX_NAME, "Identifier", "Unique socket identifier"); - RNA_def_boolean( - func, "use_multi_input", false, "", "Make the socket a multi-input. Only valid for inputs"); /* return value */ parm = RNA_def_pointer(func, "socket", "NodeSocket", "", "New socket"); RNA_def_function_return(func, parm); @@ -10577,6 +10610,22 @@ static void rna_def_composite_nodetree(BlenderRNA *brna) RNA_def_property_enum_items(prop, node_quality_items); RNA_def_property_ui_text(prop, "Edit Quality", "Quality when editing"); + prop = RNA_def_property(srna, "chunk_size", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, nullptr, "chunksize"); + RNA_def_property_enum_items(prop, node_chunksize_items); + RNA_def_property_ui_text(prop, + "Chunksize", + "Max size of a tile (smaller values gives better distribution " + "of multiple threads, but more overhead)"); + + prop = RNA_def_property(srna, "use_opencl", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, nullptr, "flag", NTREE_COM_OPENCL); + RNA_def_property_ui_text(prop, "OpenCL", "Enable GPU calculations"); + + prop = RNA_def_property(srna, "use_groupnode_buffer", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, nullptr, "flag", NTREE_COM_GROUPNODE_BUFFER); + RNA_def_property_ui_text(prop, "Buffer Groups", "Enable buffering of group nodes"); + prop = RNA_def_property(srna, "use_two_pass", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "flag", NTREE_TWO_PASS); RNA_def_property_ui_text(prop, diff --git a/source/blender/makesrna/intern/rna_object.cc b/source/blender/makesrna/intern/rna_object.cc index bc0f0a304bd..02f47bcb0f5 100644 --- a/source/blender/makesrna/intern/rna_object.cc +++ b/source/blender/makesrna/intern/rna_object.cc @@ -29,10 +29,10 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_camera.h" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_editlattice.h" #include "BKE_editmesh.hh" #include "BKE_layer.hh" @@ -332,7 +332,7 @@ const EnumPropertyItem rna_enum_object_axis_items[] = { # include "BKE_curve.hh" # include "BKE_deform.hh" # include "BKE_effect.h" -# include "BKE_global.hh" +# include "BKE_global.h" # include "BKE_gpencil_modifier_legacy.h" # include "BKE_key.hh" # include "BKE_light_linking.h" @@ -342,7 +342,7 @@ const EnumPropertyItem rna_enum_object_axis_items[] = { # include "BKE_modifier.hh" # include "BKE_object.hh" # include "BKE_particle.h" -# include "BKE_scene.hh" +# include "BKE_scene.h" # include "DEG_depsgraph.hh" # include "DEG_depsgraph_build.hh" @@ -367,7 +367,7 @@ static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA { /* Don't use compatibility so we get predictable rotation. */ Object *ob = reinterpret_cast(ptr->owner_id); - BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), false, true); + BKE_object_apply_mat4(ob, ob->object_to_world, false, true); rna_Object_internal_update(bmain, scene, ptr); } @@ -407,18 +407,6 @@ static void rna_GPencil_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA * } } -static void rna_Object_matrix_world_get(PointerRNA *ptr, float *values) -{ - Object *ob = static_cast(ptr->data); - std::copy_n(ob->object_to_world().base_ptr(), 16, values); -} - -static void rna_Object_matrix_world_set(PointerRNA *ptr, const float *values) -{ - Object *ob = static_cast(ptr->data); - ob->runtime->object_to_world = blender::float4x4(values); -} - static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) { Object *ob = reinterpret_cast(ptr->owner_id); @@ -3351,12 +3339,11 @@ static void rna_def_object(BlenderRNA *brna) /* matrix */ prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_float_sdna(prop, nullptr, "object_to_world"); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON); RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); - RNA_def_property_float_funcs( - prop, "rna_Object_matrix_world_get", "rna_Object_matrix_world_set", nullptr); RNA_def_property_ui_text(prop, "Matrix World", "Worldspace transformation matrix"); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_matrix_world_update"); diff --git a/source/blender/makesrna/intern/rna_object_api.cc b/source/blender/makesrna/intern/rna_object_api.cc index f669ee063d8..30b1f342908 100644 --- a/source/blender/makesrna/intern/rna_object_api.cc +++ b/source/blender/makesrna/intern/rna_object_api.cc @@ -56,7 +56,7 @@ static const EnumPropertyItem space_items[] = { # include "BKE_context.hh" # include "BKE_crazyspace.hh" # include "BKE_customdata.hh" -# include "BKE_global.hh" +# include "BKE_global.h" # include "BKE_layer.hh" # include "BKE_main.hh" # include "BKE_mball.hh" @@ -65,7 +65,7 @@ static const EnumPropertyItem space_items[] = { # include "BKE_modifier.hh" # include "BKE_object.hh" # include "BKE_object_types.hh" -# include "BKE_report.hh" +# include "BKE_report.h" # include "BKE_vfont.hh" # include "ED_object.hh" diff --git a/source/blender/makesrna/intern/rna_object_force.cc b/source/blender/makesrna/intern/rna_object_force.cc index bd668c2e38a..8416f518446 100644 --- a/source/blender/makesrna/intern/rna_object_force.cc +++ b/source/blender/makesrna/intern/rna_object_force.cc @@ -8,7 +8,7 @@ #include -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_cloth_types.h" #include "DNA_dynamicpaint_types.h" @@ -109,7 +109,7 @@ static const EnumPropertyItem empty_vortex_shape_items[] = { # include "DNA_modifier_types.h" # include "DNA_texture_types.h" -# include "BKE_collection.hh" +# include "BKE_collection.h" # include "BKE_context.hh" # include "BKE_modifier.hh" # include "BKE_pointcache.h" diff --git a/source/blender/makesrna/intern/rna_palette.cc b/source/blender/makesrna/intern/rna_palette.cc index d8d867dd6a5..bea16e515d7 100644 --- a/source/blender/makesrna/intern/rna_palette.cc +++ b/source/blender/makesrna/intern/rna_palette.cc @@ -22,7 +22,7 @@ # include "DNA_brush_types.h" # include "BKE_paint.hh" -# include "BKE_report.hh" +# include "BKE_report.h" static PaletteColor *rna_Palette_color_new(Palette *palette) { if (ID_IS_LINKED(palette) || ID_IS_OVERRIDE_LIBRARY(palette)) { diff --git a/source/blender/makesrna/intern/rna_particle.cc b/source/blender/makesrna/intern/rna_particle.cc index 88eb2b0e951..aa41fcf5cce 100644 --- a/source/blender/makesrna/intern/rna_particle.cc +++ b/source/blender/makesrna/intern/rna_particle.cc @@ -32,7 +32,7 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "rna_internal.hh" @@ -474,7 +474,7 @@ static void rna_ParticleSystem_co_hair( if (step >= 0 && step <= max_k) { copy_v3_v3(n_co, (cache + step)->co); mul_m4_v3(particlesystem->imat, n_co); - mul_m4_v3(object->object_to_world().ptr(), n_co); + mul_m4_v3(object->object_to_world, n_co); } } diff --git a/source/blender/makesrna/intern/rna_pose.cc b/source/blender/makesrna/intern/rna_pose.cc index 42e38349588..3eefc8ac1c3 100644 --- a/source/blender/makesrna/intern/rna_pose.cc +++ b/source/blender/makesrna/intern/rna_pose.cc @@ -24,7 +24,7 @@ #include "BLI_math_vector.h" #include "BLI_string_utf8_symbols.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "UI_resources.hh" @@ -74,7 +74,7 @@ const EnumPropertyItem rna_enum_color_sets_items[] = { # include "BKE_constraint.h" # include "BKE_context.hh" -# include "BKE_global.hh" +# include "BKE_global.h" # include "BKE_idprop.h" # include "DEG_depsgraph.hh" diff --git a/source/blender/makesrna/intern/rna_render.cc b/source/blender/makesrna/intern/rna_render.cc index e932b635160..d1aadd3c387 100644 --- a/source/blender/makesrna/intern/rna_render.cc +++ b/source/blender/makesrna/intern/rna_render.cc @@ -22,7 +22,7 @@ #include "DEG_depsgraph.hh" #include "BKE_image.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "RNA_define.hh" #include "RNA_enum_types.hh" @@ -88,7 +88,7 @@ const EnumPropertyItem rna_enum_bake_pass_type_items[] = { # include "BKE_appdir.hh" # include "BKE_context.hh" -# include "BKE_report.hh" +# include "BKE_report.h" # include "GPU_capabilities.h" # include "GPU_shader.h" diff --git a/source/blender/makesrna/intern/rna_rna.cc b/source/blender/makesrna/intern/rna_rna.cc index 5d0fee33965..21b559c06be 100644 --- a/source/blender/makesrna/intern/rna_rna.cc +++ b/source/blender/makesrna/intern/rna_rna.cc @@ -153,51 +153,33 @@ const EnumPropertyItem rna_enum_property_unit_items[] = { {0, nullptr, 0, nullptr, nullptr}, }; -/* Descriptions for rna_enum_property_flag_items and rna_enum_property_flag_enum_items. */ -static constexpr auto PROP_HIDDEN_DESCR = - "For operators: hide from places in the user interface where Blender would add the property " - "automatically, like Adjust Last Operation. Also this property is not written to presets"; -static constexpr auto PROP_SKIP_SAVE_DESCR = - "For operators: the value of this property will not be remembered between invocations of the " - "operator; instead, each invocation will start by using the default value. Also this " - "property is not written to presets"; -static constexpr auto PROP_SKIP_PRESET_DESCR = "Do not write in presets"; -static constexpr auto PROP_ANIMATABLE_DESCR = ""; -static constexpr auto PROP_LIB_EXCEPTION_DESCR = - "This property can be edited, even when it is used on linked data (which normally is " - "read-only). Note that edits to the property will not be saved to the blend file"; -static constexpr auto PROP_PROPORTIONAL_DESCR = ""; -static constexpr auto PROP_TEXTEDIT_UPDATE_DESCR = ""; -static constexpr auto PROP_PATH_OUTPUT_DESCR = ""; -static constexpr auto PROP_ENUM_FLAG_DESCR = ""; - const EnumPropertyItem rna_enum_property_flag_items[] = { - {PROP_HIDDEN, "HIDDEN", 0, "Hidden", PROP_HIDDEN_DESCR}, - {PROP_SKIP_SAVE, "SKIP_SAVE", 0, "Skip Save", PROP_SKIP_SAVE_DESCR}, - {PROP_SKIP_PRESET, "SKIP_PRESET", 0, "Skip Preset", PROP_SKIP_PRESET_DESCR}, - {PROP_ANIMATABLE, "ANIMATABLE", 0, "Animatable", PROP_ANIMATABLE_DESCR}, - {PROP_LIB_EXCEPTION, "LIBRARY_EDITABLE", 0, "Library Editable", PROP_LIB_EXCEPTION_DESCR}, - {PROP_PROPORTIONAL, - "PROPORTIONAL", + {PROP_HIDDEN, "HIDDEN", 0, "Hidden", "Hidden in the user interface. Inherits 'SKIP_PRESET'"}, + {PROP_SKIP_SAVE, + "SKIP_SAVE", 0, - "Adjust values proportionally to each other", - PROP_PROPORTIONAL_DESCR}, + "Skip Save", + "Do not use ghost values. Inherits 'SKIP_PRESET'"}, + {PROP_SKIP_PRESET, "SKIP_PRESET", 0, "Skip Preset", "Do not write in presets"}, + {PROP_ANIMATABLE, "ANIMATABLE", 0, "Animatable", ""}, + {PROP_LIB_EXCEPTION, "LIBRARY_EDITABLE", 0, "Library Editable", ""}, + {PROP_PROPORTIONAL, "PROPORTIONAL", 0, "Adjust values proportionally to each other", ""}, {int(PROP_TEXTEDIT_UPDATE), "TEXTEDIT_UPDATE", 0, "Update on every keystroke in textedit 'mode'", - PROP_TEXTEDIT_UPDATE_DESCR}, - {PROP_PATH_OUTPUT, "OUTPUT_PATH", 0, "Output Path", PROP_PATH_OUTPUT_DESCR}, + ""}, + {PROP_PATH_OUTPUT, "OUTPUT_PATH", 0, "Output Path", ""}, {0, nullptr, 0, nullptr, nullptr}, }; /** Only for enum type properties. */ const EnumPropertyItem rna_enum_property_flag_enum_items[] = { - {PROP_HIDDEN, "HIDDEN", 0, "Hidden", PROP_HIDDEN_DESCR}, - {PROP_SKIP_SAVE, "SKIP_SAVE", 0, "Skip Save", PROP_SKIP_SAVE_DESCR}, - {PROP_ANIMATABLE, "ANIMATABLE", 0, "Animatable", PROP_ANIMATABLE_DESCR}, - {PROP_LIB_EXCEPTION, "LIBRARY_EDITABLE", 0, "Library Editable", PROP_LIB_EXCEPTION_DESCR}, - {PROP_ENUM_FLAG, "ENUM_FLAG", 0, "Enum Flag", PROP_ENUM_FLAG_DESCR}, + {PROP_HIDDEN, "HIDDEN", 0, "Hidden", ""}, + {PROP_SKIP_SAVE, "SKIP_SAVE", 0, "Skip Save", ""}, + {PROP_ANIMATABLE, "ANIMATABLE", 0, "Animatable", ""}, + {PROP_LIB_EXCEPTION, "LIBRARY_EDITABLE", 0, "Library Editable", ""}, + {PROP_ENUM_FLAG, "ENUM_FLAG", 0, "Enum Flag", ""}, {0, nullptr, 0, nullptr, nullptr}, }; diff --git a/source/blender/makesrna/intern/rna_scene.cc b/source/blender/makesrna/intern/rna_scene.cc index 4c9be833143..bbe87c44ad1 100644 --- a/source/blender/makesrna/intern/rna_scene.cc +++ b/source/blender/makesrna/intern/rna_scene.cc @@ -31,7 +31,7 @@ #include "BLI_math_vector.h" #include "BLI_string_utf8_symbols.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_armature.hh" #include "BKE_editmesh.hh" @@ -729,10 +729,10 @@ const EnumPropertyItem rna_enum_grease_pencil_selectmode_items[] = { # include "BKE_animsys.h" # include "BKE_bake_geometry_nodes_modifier.hh" # include "BKE_brush.hh" -# include "BKE_collection.hh" +# include "BKE_collection.h" # include "BKE_context.hh" # include "BKE_freestyle.h" -# include "BKE_global.hh" +# include "BKE_global.h" # include "BKE_gpencil_legacy.h" # include "BKE_idprop.h" # include "BKE_image.h" @@ -740,9 +740,9 @@ const EnumPropertyItem rna_enum_grease_pencil_selectmode_items[] = { # include "BKE_layer.hh" # include "BKE_main.hh" # include "BKE_mesh.hh" -# include "BKE_node.hh" +# include "BKE_node.h" # include "BKE_pointcache.h" -# include "BKE_scene.hh" +# include "BKE_scene.h" # include "BKE_screen.hh" # include "BKE_unit.hh" @@ -1870,7 +1870,7 @@ static void rna_SceneRenderView_name_set(PointerRNA *ptr, const char *value) sizeof(rv->name)); } -void rna_ViewLayer_override_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr) +void rna_ViewLayer_material_override_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr) { Scene *scene = (Scene *)ptr->owner_id; rna_Scene_render_update(bmain, scene, ptr); @@ -4734,15 +4734,8 @@ void rna_def_view_layer_common(BlenderRNA *brna, StructRNA *srna, const bool sce RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_ui_text( prop, "Material Override", "Material to override all other materials in this view layer"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_override_update"); - - prop = RNA_def_property(srna, "world_override", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, nullptr, "world_override"); - RNA_def_property_struct_type(prop, "World"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); - RNA_def_property_ui_text(prop, "World Override", "Override world in this view layer"); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_override_update"); + RNA_def_property_update( + prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_ViewLayer_material_override_update"); prop = RNA_def_property(srna, "samples", PROP_INT, PROP_UNSIGNED); RNA_def_property_ui_text(prop, @@ -6032,6 +6025,7 @@ static void rna_def_image_format_stereo3d_format(BlenderRNA *brna) srna = RNA_def_struct(brna, "Stereo3dFormat", nullptr); RNA_def_struct_sdna(srna, "Stereo3dFormat"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Stereo Output", "Settings for stereo output"); prop = RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE); @@ -6612,17 +6606,6 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {0, nullptr, 0, nullptr, nullptr}, }; - static const EnumPropertyItem motion_blur_position_items[] = { - {SCE_MB_START, "START", 0, "Start on Frame", "The shutter opens at the current frame"}, - {SCE_MB_CENTER, - "CENTER", - 0, - "Center on Frame", - "The shutter is open during the current frame"}, - {SCE_MB_END, "END", 0, "End on Frame", "The shutter closes at the current frame"}, - {0, nullptr, 0, nullptr, nullptr}, - }; - static const EnumPropertyItem hair_shape_type_items[] = { {SCE_HAIR_SHAPE_STRAND, "STRAND", 0, "Strand", ""}, {SCE_HAIR_SHAPE_STRIP, "STRIP", 0, "Strip", ""}, @@ -6801,20 +6784,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_render_update"); prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, nullptr, "blurfac"); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_range(prop, 0.01f, 1.0f, 1, 2); RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_render_update"); - prop = RNA_def_property(srna, "motion_blur_position", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, motion_blur_position_items); - RNA_def_property_ui_text(prop, - "Motion Blur Position", - "Offset for the shutter's time interval, " - "allows to change the motion blur trails"); - RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr); - prop = RNA_def_property(srna, "motion_blur_shutter_curve", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, nullptr, "mblur_shutter_curve"); RNA_def_property_struct_type(prop, "CurveMapping"); @@ -7782,6 +7757,17 @@ static void rna_def_scene_eevee(BlenderRNA *brna) {0, nullptr, 0, nullptr, nullptr}, }; + static const EnumPropertyItem eevee_motion_blur_position_items[] = { + {SCE_EEVEE_MB_START, "START", 0, "Start on Frame", "The shutter opens at the current frame"}, + {SCE_EEVEE_MB_CENTER, + "CENTER", + 0, + "Center on Frame", + "The shutter is open during the current frame"}, + {SCE_EEVEE_MB_END, "END", 0, "End on Frame", "The shutter closes at the current frame"}, + {0, nullptr, 0, nullptr, nullptr}, + }; + static const EnumPropertyItem ray_tracing_method_items[] = { {RAYTRACE_EEVEE_METHOD_NONE, "NONE", 0, "None", "No intersection with scene geometry"}, {RAYTRACE_EEVEE_METHOD_SCREEN, @@ -8246,6 +8232,19 @@ static void rna_def_scene_eevee(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr); /* Motion blur */ + prop = RNA_def_property(srna, "use_motion_blur", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, nullptr, "flag", SCE_EEVEE_MOTION_BLUR_ENABLED); + RNA_def_property_ui_text(prop, "Motion Blur", "Enable motion blur effect (only in camera view)"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr); + + prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.01f, 1.0f, 1, 2); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr); + prop = RNA_def_property(srna, "motion_blur_depth_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_ui_text(prop, "Background Separation", @@ -8273,6 +8272,15 @@ static void rna_def_scene_eevee(BlenderRNA *brna) RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr); + prop = RNA_def_property(srna, "motion_blur_position", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, eevee_motion_blur_position_items); + RNA_def_property_ui_text(prop, + "Motion Blur Position", + "Offset for the shutter's time interval, " + "allows to change the motion blur trails"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr); + /* Shadows */ prop = RNA_def_property(srna, "use_shadows", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "flag", SCE_EEVEE_SHADOW_ENABLED); diff --git a/source/blender/makesrna/intern/rna_scene_api.cc b/source/blender/makesrna/intern/rna_scene_api.cc index 09707c29526..a75475d52a3 100644 --- a/source/blender/makesrna/intern/rna_scene_api.cc +++ b/source/blender/makesrna/intern/rna_scene_api.cc @@ -31,9 +31,9 @@ #ifdef RNA_RUNTIME # include "BKE_editmesh.hh" -# include "BKE_global.hh" +# include "BKE_global.h" # include "BKE_image.h" -# include "BKE_scene.hh" +# include "BKE_scene.h" # include "BKE_writeavi.h" # include "DEG_depsgraph_query.hh" diff --git a/source/blender/makesrna/intern/rna_screen.cc b/source/blender/makesrna/intern/rna_screen.cc index 28d63d47550..97c3f4e268d 100644 --- a/source/blender/makesrna/intern/rna_screen.cc +++ b/source/blender/makesrna/intern/rna_screen.cc @@ -56,7 +56,7 @@ static const EnumPropertyItem rna_enum_region_panel_category_items[] = { # include "RNA_access.hh" -# include "BKE_global.hh" +# include "BKE_global.h" # include "BKE_screen.hh" # include "BKE_workspace.h" @@ -64,7 +64,7 @@ static const EnumPropertyItem rna_enum_region_panel_category_items[] = { # include "UI_view2d.hh" -# include "BLT_translation.hh" +# include "BLT_translation.h" # ifdef WITH_PYTHON # include "BPY_extern.h" diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.cc b/source/blender/makesrna/intern/rna_sculpt_paint.cc index fde4a3e5c35..3392cf73cc5 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.cc +++ b/source/blender/makesrna/intern/rna_sculpt_paint.cc @@ -109,7 +109,7 @@ const EnumPropertyItem rna_enum_symmetrize_direction_items[] = { #ifdef RNA_RUNTIME # include "MEM_guardedalloc.h" -# include "BKE_collection.hh" +# include "BKE_collection.h" # include "BKE_context.hh" # include "BKE_gpencil_legacy.h" # include "BKE_object.hh" diff --git a/source/blender/makesrna/intern/rna_sequencer.cc b/source/blender/makesrna/intern/rna_sequencer.cc index 2246c614a28..8d86fe91b3d 100644 --- a/source/blender/makesrna/intern/rna_sequencer.cc +++ b/source/blender/makesrna/intern/rna_sequencer.cc @@ -22,7 +22,7 @@ #include "BLI_string_utf8_symbols.h" #include "BLI_string_utils.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_anim_data.h" #include "BKE_animsys.h" @@ -115,10 +115,10 @@ const EnumPropertyItem rna_enum_strip_color_items[] = { # include -# include "BKE_global.hh" +# include "BKE_global.h" # include "BKE_idprop.h" # include "BKE_movieclip.h" -# include "BKE_report.hh" +# include "BKE_report.h" # include "WM_api.hh" diff --git a/source/blender/makesrna/intern/rna_sequencer_api.cc b/source/blender/makesrna/intern/rna_sequencer_api.cc index 014f7270c56..501e366333b 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.cc +++ b/source/blender/makesrna/intern/rna_sequencer_api.cc @@ -35,7 +35,7 @@ # include "BKE_mask.h" # include "BKE_movieclip.h" -# include "BKE_report.hh" +# include "BKE_report.h" # include "BKE_sound.h" # include "IMB_imbuf.hh" diff --git a/source/blender/makesrna/intern/rna_shader_fx.cc b/source/blender/makesrna/intern/rna_shader_fx.cc index 59153d4ffa0..2933dbdd21c 100644 --- a/source/blender/makesrna/intern/rna_shader_fx.cc +++ b/source/blender/makesrna/intern/rna_shader_fx.cc @@ -19,7 +19,7 @@ #include "BLI_math_rotation.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_animsys.h" diff --git a/source/blender/makesrna/intern/rna_space.cc b/source/blender/makesrna/intern/rna_space.cc index 91c8f224d86..1152ab2f68e 100644 --- a/source/blender/makesrna/intern/rna_space.cc +++ b/source/blender/makesrna/intern/rna_space.cc @@ -11,7 +11,7 @@ #include "MEM_guardedalloc.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_attribute.hh" #include "BKE_context.hh" @@ -19,7 +19,7 @@ #include "BKE_image.h" #include "BKE_key.hh" #include "BKE_movieclip.h" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BKE_studiolight.h" #include "BKE_viewer_path.hh" @@ -554,14 +554,14 @@ static const EnumPropertyItem rna_enum_curve_display_handle_items[] = { # include "BKE_anim_data.h" # include "BKE_brush.hh" # include "BKE_context.hh" -# include "BKE_global.hh" +# include "BKE_global.h" # include "BKE_icons.h" # include "BKE_idprop.h" # include "BKE_layer.hh" # include "BKE_nla.h" # include "BKE_paint.hh" # include "BKE_preferences.h" -# include "BKE_scene.hh" +# include "BKE_scene.h" # include "BKE_screen.hh" # include "BKE_workspace.h" @@ -6422,7 +6422,7 @@ static void rna_def_space_graph(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Handles", "Show handles of Bézier control points"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, nullptr); - prop = RNA_def_property(srna, "use_auto_lock_translation_axis", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "autolock_translation_axis", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "flag", SIPO_AUTOLOCK_AXIS); RNA_def_property_ui_text(prop, "Auto-Lock Key Axis", diff --git a/source/blender/makesrna/intern/rna_space_api.cc b/source/blender/makesrna/intern/rna_space_api.cc index 258c31ee511..411711d9551 100644 --- a/source/blender/makesrna/intern/rna_space_api.cc +++ b/source/blender/makesrna/intern/rna_space_api.cc @@ -15,7 +15,7 @@ #ifdef RNA_RUNTIME -# include "BKE_global.hh" +# include "BKE_global.h" # include "ED_fileselect.hh" # include "ED_screen.hh" diff --git a/source/blender/makesrna/intern/rna_speaker.cc b/source/blender/makesrna/intern/rna_speaker.cc index d85ef59e62e..d553fd378f1 100644 --- a/source/blender/makesrna/intern/rna_speaker.cc +++ b/source/blender/makesrna/intern/rna_speaker.cc @@ -16,7 +16,7 @@ #include "DNA_sound_types.h" #include "DNA_speaker_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #ifdef RNA_RUNTIME diff --git a/source/blender/makesrna/intern/rna_text.cc b/source/blender/makesrna/intern/rna_text.cc index 96411a00b1f..2499f7f896d 100644 --- a/source/blender/makesrna/intern/rna_text.cc +++ b/source/blender/makesrna/intern/rna_text.cc @@ -11,7 +11,7 @@ #include "MEM_guardedalloc.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_text.h" diff --git a/source/blender/makesrna/intern/rna_texture.cc b/source/blender/makesrna/intern/rna_texture.cc index 208f87e7c31..e922e5557f4 100644 --- a/source/blender/makesrna/intern/rna_texture.cc +++ b/source/blender/makesrna/intern/rna_texture.cc @@ -22,11 +22,11 @@ #include "BLI_utildefines.h" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BKE_node_tree_update.hh" #include "BKE_paint.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_define.hh" #include "RNA_enum_types.hh" diff --git a/source/blender/makesrna/intern/rna_texture_api.cc b/source/blender/makesrna/intern/rna_texture_api.cc index b2033f3c2bc..4170dd38170 100644 --- a/source/blender/makesrna/intern/rna_texture_api.cc +++ b/source/blender/makesrna/intern/rna_texture_api.cc @@ -19,7 +19,7 @@ #ifdef RNA_RUNTIME # include "BKE_context.hh" -# include "BKE_global.hh" +# include "BKE_global.h" # include "BLI_math_vector.h" # include "DNA_scene_types.h" # include "IMB_imbuf.hh" diff --git a/source/blender/makesrna/intern/rna_timeline.cc b/source/blender/makesrna/intern/rna_timeline.cc index da67f2b0e79..cbb389f41b7 100644 --- a/source/blender/makesrna/intern/rna_timeline.cc +++ b/source/blender/makesrna/intern/rna_timeline.cc @@ -19,7 +19,7 @@ #ifdef RNA_RUNTIME # include "BKE_idprop.h" -# include "BKE_scene.hh" +# include "BKE_scene.h" # include "BKE_screen.hh" # include "WM_api.hh" diff --git a/source/blender/makesrna/intern/rna_tracking.cc b/source/blender/makesrna/intern/rna_tracking.cc index 04875ad1454..047cff98c35 100644 --- a/source/blender/makesrna/intern/rna_tracking.cc +++ b/source/blender/makesrna/intern/rna_tracking.cc @@ -15,7 +15,7 @@ #include "BKE_node_tree_update.hh" #include "BKE_tracking.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -37,8 +37,8 @@ # include "BKE_anim_data.h" # include "BKE_animsys.h" -# include "BKE_node.hh" -# include "BKE_report.hh" +# include "BKE_node.h" +# include "BKE_report.h" # include "DEG_depsgraph.hh" diff --git a/source/blender/makesrna/intern/rna_ui.cc b/source/blender/makesrna/intern/rna_ui.cc index 991c4fb4df3..085b4773937 100644 --- a/source/blender/makesrna/intern/rna_ui.cc +++ b/source/blender/makesrna/intern/rna_ui.cc @@ -11,7 +11,7 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_file_handler.hh" #include "BKE_idprop.h" @@ -63,7 +63,7 @@ const EnumPropertyItem rna_enum_uilist_layout_type_items[] = { # include "BKE_context.hh" # include "BKE_main.hh" -# include "BKE_report.hh" +# include "BKE_report.h" # include "BKE_screen.hh" # include "ED_asset_library.hh" diff --git a/source/blender/makesrna/intern/rna_ui_api.cc b/source/blender/makesrna/intern/rna_ui_api.cc index a138e3d24b9..4b8f45cc3e6 100644 --- a/source/blender/makesrna/intern/rna_ui_api.cc +++ b/source/blender/makesrna/intern/rna_ui_api.cc @@ -11,7 +11,7 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_define.hh" #include "RNA_enum_types.hh" @@ -516,11 +516,6 @@ static void rna_uiItemProgress(uiLayout *layout, uiItemProgressIndicator(layout, text, factor, eButProgressType(progress_type)); } -static void rna_uiItemSeparator(uiLayout *layout, float factor, int type) -{ - uiItemS_ex(layout, factor, LayoutSeparatorType(type)); -} - static void rna_uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, @@ -1076,25 +1071,6 @@ void RNA_api_ui_layout(StructRNA *srna) {0, nullptr, 0, nullptr, nullptr}, }; - static const EnumPropertyItem rna_enum_separator_type_items[] = { - {int(LayoutSeparatorType::Auto), - "AUTO", - 0, - "Auto", - "Best guess at what type of separator is needed."}, - {int(LayoutSeparatorType::Space), - "SPACE", - 0, - "Empty space", - "Horizontal or Vertical empty space, depending on layout direction."}, - {int(LayoutSeparatorType::Line), - "LINE", - 0, - "Line", - "Horizontal or Vertical line, depending on layout direction."}, - {0, nullptr, 0, nullptr, nullptr}, - }; - static float node_socket_color_default[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* simple layout specifiers */ @@ -1507,7 +1483,7 @@ void RNA_api_ui_layout(StructRNA *srna) parm = RNA_def_string(func, "category", nullptr, 0, "", "panel type category"); RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED); - func = RNA_def_function(srna, "separator", "rna_uiItemSeparator"); + func = RNA_def_function(srna, "separator", "uiItemS_ex"); RNA_def_function_ui_description(func, "Item. Inserts empty space into the layout between items"); RNA_def_float(func, "factor", @@ -1518,12 +1494,6 @@ void RNA_api_ui_layout(StructRNA *srna) "Percentage of width to space (leave unset for default space)", 0.0f, FLT_MAX); - RNA_def_enum(func, - "type", - rna_enum_separator_type_items, - int(LayoutSeparatorType::Auto), - "Type", - "The type of the separator"); func = RNA_def_function(srna, "separator_spacer", "uiItemSpacer"); RNA_def_function_ui_description( diff --git a/source/blender/makesrna/intern/rna_userdef.cc b/source/blender/makesrna/intern/rna_userdef.cc index 32f01bb72b2..9c5a5baf473 100644 --- a/source/blender/makesrna/intern/rna_userdef.cc +++ b/source/blender/makesrna/intern/rna_userdef.cc @@ -26,11 +26,11 @@ # include "BLI_winstuff.h" #endif -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_addon.h" #include "BKE_appdir.hh" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "BKE_sound.h" #include "BKE_studiolight.h" @@ -47,7 +47,7 @@ #include "WM_api.hh" #include "WM_types.hh" -#include "BLT_lang.hh" +#include "BLT_lang.h" const EnumPropertyItem rna_enum_preference_section_items[] = { {USER_SECTION_INTERFACE, "INTERFACE", 0, "Interface", ""}, @@ -173,8 +173,8 @@ static const EnumPropertyItem rna_enum_preference_gpu_backend_items[] = { # include "DNA_object_types.h" # include "DNA_screen_types.h" -# include "BKE_blender.hh" -# include "BKE_global.hh" +# include "BKE_blender.h" +# include "BKE_global.h" # include "BKE_idprop.h" # include "BKE_image.h" # include "BKE_main.hh" @@ -1340,6 +1340,7 @@ static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeFontStyle", nullptr); RNA_def_struct_sdna(srna, "uiFontStyle"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Font Style", "Theme settings for Font"); prop = RNA_def_property(srna, "points", PROP_FLOAT, PROP_UNSIGNED); @@ -1395,6 +1396,7 @@ static void rna_def_userdef_theme_ui_style(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeStyle", nullptr); RNA_def_struct_sdna(srna, "uiStyle"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Style", "Theme settings for style sets"); prop = RNA_def_property(srna, "panel_title", PROP_POINTER, PROP_NONE); @@ -1426,6 +1428,7 @@ static void rna_def_userdef_theme_ui_wcol(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeWidgetColors", nullptr); RNA_def_struct_sdna(srna, "uiWidgetColors"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Widget Color Set", "Theme settings for widget color sets"); prop = RNA_def_property(srna, "outline", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -1487,6 +1490,7 @@ static void rna_def_userdef_theme_ui_wcol_state(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeWidgetStateColors", nullptr); RNA_def_struct_sdna(srna, "uiWidgetStateColors"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text( srna, "Theme Widget State Color", "Theme settings for widget state colors"); @@ -1552,6 +1556,7 @@ static void rna_def_userdef_theme_ui_panel(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemePanelColors", nullptr); RNA_def_struct_sdna(srna, "uiPanelColors"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Panel Color", "Theme settings for panel colors"); prop = RNA_def_property(srna, "header", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -1594,6 +1599,7 @@ static void rna_def_userdef_theme_ui_gradient(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeGradientColors", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text( srna, "Theme Background Color", "Theme settings for background colors and gradient"); @@ -1628,6 +1634,7 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeUserInterface", nullptr); RNA_def_struct_sdna(srna, "ThemeUI"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text( srna, "Theme User Interface", "Theme settings for user interface elements"); @@ -2117,6 +2124,7 @@ static void rna_def_userdef_theme_asset_shelf(BlenderRNA *brna) PropertyRNA *prop; srna = RNA_def_struct(brna, "ThemeAssetShelf", nullptr); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Asset Shelf Color", "Theme settings for asset shelves"); prop = RNA_def_property(srna, "header_back", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -2441,6 +2449,7 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeView3D", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme 3D Viewport", "Theme settings for the 3D viewport"); rna_def_userdef_theme_spaces_gradient(srna); @@ -2670,6 +2679,7 @@ static void rna_def_userdef_theme_space_graph(BlenderRNA *brna) /* space_graph */ srna = RNA_def_struct(brna, "ThemeGraphEditor", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Graph Editor", "Theme settings for the graph editor"); rna_def_userdef_theme_spaces_main(srna); @@ -2756,6 +2766,7 @@ static void rna_def_userdef_theme_space_file(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeFileBrowser", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme File Browser", "Theme settings for the File Browser"); rna_def_userdef_theme_spaces_main(srna); @@ -2781,6 +2792,7 @@ static void rna_def_userdef_theme_space_outliner(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeOutliner", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Outliner", "Theme settings for the Outliner"); rna_def_userdef_theme_spaces_main(srna); @@ -2829,6 +2841,7 @@ static void rna_def_userdef_theme_space_userpref(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemePreferences", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Preferences", "Theme settings for the Blender Preferences"); rna_def_userdef_theme_spaces_main(srna); @@ -2843,6 +2856,7 @@ static void rna_def_userdef_theme_space_console(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeConsole", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Console", "Theme settings for the Console"); rna_def_userdef_theme_spaces_main(srna); @@ -2893,6 +2907,7 @@ static void rna_def_userdef_theme_space_info(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeInfo", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Info", "Theme settings for Info"); rna_def_userdef_theme_spaces_main(srna); @@ -2977,6 +2992,7 @@ static void rna_def_userdef_theme_space_text(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeTextEditor", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Text Editor", "Theme settings for the Text Editor"); rna_def_userdef_theme_spaces_main(srna); @@ -3072,6 +3088,7 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeNodeEditor", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Node Editor", "Theme settings for the Node Editor"); rna_def_userdef_theme_spaces_main(srna); @@ -3275,6 +3292,7 @@ static void rna_def_userdef_theme_space_buts(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeProperties", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Properties", "Theme settings for the Properties"); prop = RNA_def_property(srna, "match", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -3300,6 +3318,7 @@ static void rna_def_userdef_theme_space_image(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeImageEditor", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Image Editor", "Theme settings for the Image Editor"); rna_def_userdef_theme_spaces_main(srna); @@ -3412,6 +3431,7 @@ static void rna_def_userdef_theme_space_seq(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeSequenceEditor", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Sequence Editor", "Theme settings for the Sequence Editor"); rna_def_userdef_theme_spaces_main(srna); @@ -3618,6 +3638,7 @@ static void rna_def_userdef_theme_space_action(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeDopeSheet", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Dope Sheet", "Theme settings for the Dope Sheet"); rna_def_userdef_theme_spaces_main(srna); @@ -3827,6 +3848,7 @@ static void rna_def_userdef_theme_space_nla(BlenderRNA *brna) /* space_nla */ srna = RNA_def_struct(brna, "ThemeNLAEditor", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Nonlinear Animation", "Theme settings for the NLA Editor"); rna_def_userdef_theme_spaces_main(srna); @@ -3989,6 +4011,7 @@ static void rna_def_userdef_theme_colorset(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeBoneColorSet", nullptr); RNA_def_struct_sdna(srna, "ThemeWireColor"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Bone Color Set", "Theme settings for bone color sets"); prop = RNA_def_property(srna, "normal", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -4025,6 +4048,7 @@ static void rna_def_userdef_theme_collection_color(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeCollectionColor", nullptr); RNA_def_struct_sdna(srna, "ThemeCollectionColor"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Collection Color", "Theme settings for collection colors"); prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -4041,6 +4065,7 @@ static void rna_def_userdef_theme_strip_color(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeStripColor", nullptr); RNA_def_struct_sdna(srna, "ThemeStripColor"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Strip Color", "Theme settings for strip colors"); prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -4059,6 +4084,7 @@ static void rna_def_userdef_theme_space_clip(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeClipEditor", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Clip Editor", "Theme settings for the Movie Clip Editor"); rna_def_userdef_theme_spaces_main(srna); @@ -4183,6 +4209,7 @@ static void rna_def_userdef_theme_space_topbar(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeTopBar", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Top Bar", "Theme settings for the Top Bar"); rna_def_userdef_theme_spaces_main(srna); @@ -4196,6 +4223,7 @@ static void rna_def_userdef_theme_space_statusbar(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeStatusBar", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Status Bar", "Theme settings for the Status Bar"); rna_def_userdef_theme_spaces_main(srna); @@ -4210,6 +4238,7 @@ static void rna_def_userdef_theme_space_spreadsheet(BlenderRNA *brna) srna = RNA_def_struct(brna, "ThemeSpreadsheet", nullptr); RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme Spreadsheet", "Theme settings for the Spreadsheet"); prop = RNA_def_property(srna, "row_alternate", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -4253,6 +4282,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna) srna = RNA_def_struct(brna, "Theme", nullptr); RNA_def_struct_sdna(srna, "bTheme"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Theme", "User interface styling and color settings"); prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); @@ -4409,6 +4439,7 @@ static void rna_def_userdef_addon(BlenderRNA *brna) srna = RNA_def_struct(brna, "Addon", nullptr); RNA_def_struct_sdna(srna, "bAddon"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Add-on", "Python add-ons to be loaded automatically"); prop = RNA_def_property(srna, "module", PROP_STRING, PROP_NONE); @@ -4477,6 +4508,7 @@ static void rna_def_userdef_studiolight(BlenderRNA *brna) RNA_define_verify_sdna(false); srna = RNA_def_struct(brna, "StudioLight", nullptr); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Studio Light", "Studio light"); prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE); @@ -4552,6 +4584,7 @@ static void rna_def_userdef_pathcompare(BlenderRNA *brna) srna = RNA_def_struct(brna, "PathCompare", nullptr); RNA_def_struct_sdna(srna, "bPathCompare"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Path Compare", "Match paths against this value"); prop = RNA_def_property(srna, "path", PROP_STRING, PROP_DIRPATH); @@ -4635,6 +4668,7 @@ static void rna_def_userdef_solidlight(BlenderRNA *brna) srna = RNA_def_struct(brna, "UserSolidLight", nullptr); RNA_def_struct_sdna(srna, "SolidLight"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text( srna, "Solid Light", "Light used for Studio lighting in solid shading mode"); @@ -4680,6 +4714,7 @@ static void rna_def_userdef_walk_navigation(BlenderRNA *brna) srna = RNA_def_struct(brna, "WalkNavigation", nullptr); RNA_def_struct_sdna(srna, "WalkNavigation"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Walk Navigation", "Walk navigation settings"); prop = RNA_def_property(srna, "mouse_speed", PROP_FLOAT, PROP_NONE); @@ -4844,6 +4879,7 @@ static void rna_def_userdef_view(BlenderRNA *brna) srna = RNA_def_struct(brna, "PreferencesView", nullptr); RNA_def_struct_sdna(srna, "UserDef"); RNA_def_struct_nested(brna, srna, "Preferences"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "View & Controls", "Preferences related to viewing data"); /* View. */ @@ -5333,6 +5369,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna) srna = RNA_def_struct(brna, "PreferencesEdit", nullptr); RNA_def_struct_sdna(srna, "UserDef"); RNA_def_struct_nested(brna, srna, "Preferences"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Edit Methods", "Settings for interacting with Blender data"); /* Edit Methods */ @@ -5839,6 +5876,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) srna = RNA_def_struct(brna, "PreferencesSystem", nullptr); RNA_def_struct_sdna(srna, "UserDef"); RNA_def_struct_nested(brna, srna, "Preferences"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "System & OpenGL", "Graphics driver and operating system settings"); /* UI settings. */ @@ -6205,6 +6243,7 @@ static void rna_def_userdef_input(BlenderRNA *brna) srna = RNA_def_struct(brna, "PreferencesInput", nullptr); RNA_def_struct_sdna(srna, "UserDef"); RNA_def_struct_nested(brna, srna, "Preferences"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Input", "Settings for input devices"); prop = RNA_def_property(srna, "view_zoom_method", PROP_ENUM, PROP_NONE); @@ -6510,6 +6549,7 @@ static void rna_def_userdef_keymap(BlenderRNA *brna) StructRNA *srna = RNA_def_struct(brna, "PreferencesKeymap", nullptr); RNA_def_struct_sdna(srna, "UserDef"); RNA_def_struct_nested(brna, srna, "Preferences"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Keymap", "Shortcut setup for keyboards and other input devices"); prop = RNA_def_property(srna, "show_ui_keyconfig", PROP_BOOLEAN, PROP_NONE); @@ -6529,6 +6569,7 @@ static void rna_def_userdef_filepaths_asset_library(BlenderRNA *brna) srna = RNA_def_struct(brna, "UserAssetLibrary", nullptr); RNA_def_struct_sdna(srna, "bUserAssetLibrary"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text( srna, "Asset Library", "Settings to define a reusable library for Asset Browsers to use"); @@ -6585,6 +6626,7 @@ static void rna_def_userdef_filepaths_extension_repo(BlenderRNA *brna) srna = RNA_def_struct(brna, "UserExtensionRepo", nullptr); RNA_def_struct_sdna(srna, "bUserExtensionRepo"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text( srna, "Extension Repository", "Settings to define an extension repository"); @@ -6648,6 +6690,7 @@ static void rna_def_userdef_script_directory(BlenderRNA *brna) { StructRNA *srna = RNA_def_struct(brna, "ScriptDirectory", nullptr); RNA_def_struct_sdna(srna, "bUserScriptDirectory"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Python Scripts Directory", ""); PropertyRNA *prop; @@ -6691,6 +6734,7 @@ static void rna_def_userdef_script_directory_collection(BlenderRNA *brna, Proper RNA_def_property_srna(cprop, "ScriptDirectoryCollection"); srna = RNA_def_struct(brna, "ScriptDirectoryCollection", nullptr); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Python Scripts Directories", ""); func = RNA_def_function(srna, "new", "rna_userdef_script_directory_new"); @@ -6716,6 +6760,7 @@ static void rna_def_userdef_asset_library_collection(BlenderRNA *brna, PropertyR RNA_def_property_srna(cprop, "AssetLibraryCollection"); srna = RNA_def_struct(brna, "AssetLibraryCollection", nullptr); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "User Asset Libraries", "Collection of user asset libraries"); func = RNA_def_function(srna, "new", "rna_userdef_asset_library_new"); @@ -6743,6 +6788,7 @@ static void rna_def_userdef_extension_repos_collection(BlenderRNA *brna, Propert RNA_def_property_srna(cprop, "UserExtensionRepoCollection"); srna = RNA_def_struct(brna, "UserExtensionRepoCollection", nullptr); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text( srna, "User Extension Repositories", "Collection of user extension repositories"); @@ -6799,6 +6845,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna) srna = RNA_def_struct(brna, "PreferencesFilePaths", nullptr); RNA_def_struct_sdna(srna, "UserDef"); RNA_def_struct_nested(brna, srna, "Preferences"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "File Paths", "Default paths for external files"); prop = RNA_def_property(srna, "show_hidden_files_datablocks", PROP_BOOLEAN, PROP_NONE); @@ -7010,6 +7057,7 @@ static void rna_def_userdef_apps(BlenderRNA *brna) srna = RNA_def_struct(brna, "PreferencesApps", nullptr); RNA_def_struct_sdna(srna, "UserDef"); RNA_def_struct_nested(brna, srna, "Preferences"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Apps", "Preferences that work only for apps"); prop = RNA_def_property(srna, "show_corner_split", PROP_BOOLEAN, PROP_NONE); @@ -7038,6 +7086,7 @@ static void rna_def_userdef_experimental(BlenderRNA *brna) srna = RNA_def_struct(brna, "PreferencesExperimental", nullptr); RNA_def_struct_sdna(srna, "UserDef_Experimental"); RNA_def_struct_nested(brna, srna, "Preferences"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Experimental", "Experimental features"); prop = RNA_def_property(srna, "use_undo_legacy", PROP_BOOLEAN, PROP_NONE); @@ -7120,12 +7169,6 @@ static void rna_def_userdef_experimental(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_userdef_keyconfig_reload_update"); - prop = RNA_def_property(srna, "use_new_matrix_socket", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "use_new_matrix_socket", 1); - RNA_def_property_ui_text( - prop, "Matrix Socket", "Enable the matrix socket type for geometry nodes"); - RNA_def_property_update(prop, 0, "rna_userdef_ui_update"); - prop = RNA_def_property(srna, "use_viewport_debug", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "use_viewport_debug", 1); RNA_def_property_ui_text(prop, @@ -7156,10 +7199,13 @@ static void rna_def_userdef_experimental(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_userdef_ui_update"); prop = RNA_def_property(srna, "use_extension_repos", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_ui_text(prop, - "Extensions", - "Enables support for extensions, accessible from the \"Extensions\" " - "section of the preferences"); + RNA_def_property_ui_text( + prop, + "Extension Repositories", + "Enables extension repositories, " + "accessible from the \"Extension Repositories\" panel in the " + "\"File Paths\" section of the preferences. " + "These paths are exposed as add-ons, package management is not yet integrated"); RNA_def_property_boolean_funcs( prop, nullptr, "rna_PreferencesExperimental_use_extension_repos_set"); } @@ -7172,6 +7218,7 @@ static void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cpro RNA_def_property_srna(cprop, "Addons"); srna = RNA_def_struct(brna, "Addons", nullptr); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "User Add-ons", "Collection of add-ons"); func = RNA_def_function(srna, "new", "rna_userdef_addon_new"); @@ -7197,6 +7244,7 @@ static void rna_def_userdef_autoexec_path_collection(BlenderRNA *brna, PropertyR RNA_def_property_srna(cprop, "PathCompareCollection"); srna = RNA_def_struct(brna, "PathCompareCollection", nullptr); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Paths Compare", "Collection of paths"); func = RNA_def_function(srna, "new", "rna_userdef_pathcompare_new"); @@ -7227,6 +7275,7 @@ void RNA_def_userdef(BlenderRNA *brna) srna = RNA_def_struct(brna, "Preferences", nullptr); RNA_def_struct_sdna(srna, "UserDef"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Preferences", "Global preferences"); prop = RNA_def_property(srna, "active_section", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_volume.cc b/source/blender/makesrna/intern/rna_volume.cc index 8fb4254378c..b1118dbeb28 100644 --- a/source/blender/makesrna/intern/rna_volume.cc +++ b/source/blender/makesrna/intern/rna_volume.cc @@ -22,7 +22,7 @@ #include "BLI_math_base.h" #include "BLI_string_utf8_symbols.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" const EnumPropertyItem rna_enum_volume_grid_data_type_items[] = { {VOLUME_GRID_BOOLEAN, "BOOLEAN", 0, "Boolean", "Boolean"}, diff --git a/source/blender/makesrna/intern/rna_wm.cc b/source/blender/makesrna/intern/rna_wm.cc index f892ccf0bb3..fdfa9e95831 100644 --- a/source/blender/makesrna/intern/rna_wm.cc +++ b/source/blender/makesrna/intern/rna_wm.cc @@ -16,7 +16,7 @@ #include "BLI_string_utf8_symbols.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_keyconfig.h" #include "BKE_screen.hh" @@ -554,7 +554,7 @@ const EnumPropertyItem rna_enum_wm_report_items[] = { # include "UI_interface.hh" -# include "BKE_global.hh" +# include "BKE_global.h" # include "BKE_idprop.h" # include "MEM_guardedalloc.h" @@ -565,16 +565,14 @@ const EnumPropertyItem rna_enum_wm_report_items[] = { static wmOperator *rna_OperatorProperties_find_operator(PointerRNA *ptr) { - if (ptr->owner_id == nullptr || GS(ptr->owner_id->name) != ID_WM) { - return nullptr; - } - wmWindowManager *wm = (wmWindowManager *)ptr->owner_id; - IDProperty *properties = (IDProperty *)ptr->data; - for (wmOperator *op = static_cast(wm->operators.last); op; op = op->prev) { - if (op->properties == properties) { - return op; + if (wm) { + IDProperty *properties = (IDProperty *)ptr->data; + for (wmOperator *op = static_cast(wm->operators.last); op; op = op->prev) { + if (op->properties == properties) { + return op; + } } } @@ -2043,6 +2041,7 @@ static void rna_def_operator(BlenderRNA *brna) RNA_def_struct_idprops_func(srna, "rna_OperatorProperties_idprops"); RNA_def_struct_property_tags(srna, rna_enum_operator_property_tag_items); RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES | STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); } static void rna_def_macro_operator(BlenderRNA *brna) @@ -2379,6 +2378,7 @@ static void rna_def_window_stereo3d(BlenderRNA *brna) srna = RNA_def_struct(brna, "Stereo3dDisplay", nullptr); RNA_def_struct_sdna(srna, "Stereo3dFormat"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Stereo 3D Display", "Settings for stereo 3D display"); prop = RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_wm_api.cc b/source/blender/makesrna/intern/rna_wm_api.cc index 3c72d158c05..8b25313aad5 100644 --- a/source/blender/makesrna/intern/rna_wm_api.cc +++ b/source/blender/makesrna/intern/rna_wm_api.cc @@ -75,8 +75,7 @@ static bool rna_KeyMapItem_compare(wmKeyMapItem *k1, wmKeyMapItem *k2) static void rna_KeyMapItem_to_string(wmKeyMapItem *kmi, bool compact, char *result) { - BLI_strncpy( - result, WM_keymap_item_to_string(kmi, compact).value_or("").c_str(), UI_MAX_SHORTCUT_STR); + WM_keymap_item_to_string(kmi, compact, result, UI_MAX_SHORTCUT_STR); } static wmKeyMap *rna_keymap_active(wmKeyMap *km, bContext *C) @@ -123,10 +122,10 @@ static bool rna_event_modal_handler_add(bContext *C, ReportList *reports, wmOper return WM_event_add_modal_handler_ex(win, area, region, op) != nullptr; } +/* XXX, need a way for python to know event types, 0x0110 is hard coded */ static wmTimer *rna_event_timer_add(wmWindowManager *wm, float time_step, wmWindow *win) { - /* NOTE: we need a way for Python to know event types, `TIMER` is hard coded. */ - return WM_event_timer_add(wm, win, TIMER, time_step); + return WM_event_timer_add(wm, win, 0x0110, time_step); } static void rna_event_timer_remove(wmWindowManager *wm, wmTimer *timer) @@ -241,12 +240,7 @@ static int rna_Operator_props_dialog_popup(bContext *C, { title = RNA_translate_ui_text(title, text_ctxt, nullptr, nullptr, translate); confirm_text = RNA_translate_ui_text(confirm_text, text_ctxt, nullptr, nullptr, translate); - return WM_operator_props_dialog_popup( - C, - op, - width, - title ? std::make_optional(title) : std::nullopt, - confirm_text ? std::make_optional(confirm_text) : std::nullopt); + return WM_operator_props_dialog_popup(C, op, width, title, confirm_text); } static int keymap_item_modifier_flag_from_args(bool any, int shift, int ctrl, int alt, int oskey) @@ -1032,7 +1026,6 @@ void RNA_api_wm(StructRNA *srna) RNA_def_function_flag(func, FUNC_NO_SELF); parm = RNA_def_property(srna, "is_interface_locked", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(parm, nullptr, "runtime->is_interface_locked", 0); RNA_def_property_ui_text( parm, "Is Interface Locked", diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.cc b/source/blender/makesrna/intern/rna_wm_gizmo.cc index d2f49f95dd9..3a198973cac 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo.cc +++ b/source/blender/makesrna/intern/rna_wm_gizmo.cc @@ -17,7 +17,7 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_define.hh" @@ -43,7 +43,7 @@ # include "UI_interface.hh" -# include "BKE_global.hh" +# include "BKE_global.h" # include "BKE_idprop.h" # include "BKE_workspace.h" diff --git a/source/blender/makesrna/intern/rna_wm_gizmo_api.cc b/source/blender/makesrna/intern/rna_wm_gizmo_api.cc index 536608c7dff..274fbc6fdcd 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo_api.cc +++ b/source/blender/makesrna/intern/rna_wm_gizmo_api.cc @@ -11,9 +11,9 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" -#include "BKE_report.hh" +#include "BKE_report.h" #include "RNA_define.hh" #include "RNA_enum_types.hh" diff --git a/source/blender/makesrna/intern/rna_workspace.cc b/source/blender/makesrna/intern/rna_workspace.cc index 09c043ece8a..4fce2bf5739 100644 --- a/source/blender/makesrna/intern/rna_workspace.cc +++ b/source/blender/makesrna/intern/rna_workspace.cc @@ -27,7 +27,7 @@ # include "BLI_listbase.h" -# include "BKE_global.hh" +# include "BKE_global.h" # include "DNA_object_types.h" # include "DNA_screen_types.h" @@ -212,6 +212,7 @@ static void rna_def_workspace_owner(BlenderRNA *brna) srna = RNA_def_struct(brna, "wmOwnerID", nullptr); RNA_def_struct_sdna(srna, "wmOwnerID"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Work Space UI Tag", ""); prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); @@ -261,6 +262,7 @@ static void rna_def_workspace_tool(BlenderRNA *brna) srna = RNA_def_struct(brna, "WorkSpaceTool", nullptr); RNA_def_struct_sdna(srna, "bToolRef"); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Work Space Tool", ""); prop = RNA_def_property(srna, "idname", PROP_STRING, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_xr.cc b/source/blender/makesrna/intern/rna_xr.cc index 0ef0a97cc34..61b09109b5d 100644 --- a/source/blender/makesrna/intern/rna_xr.cc +++ b/source/blender/makesrna/intern/rna_xr.cc @@ -6,7 +6,7 @@ * \ingroup RNA */ -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_space_types.h" #include "DNA_view3d_types.h" @@ -2088,6 +2088,7 @@ static void rna_def_xr_session_state(BlenderRNA *brna) PropertyRNA *parm, *prop; srna = RNA_def_struct(brna, "XrSessionState", nullptr); + RNA_def_struct_clear_flag(srna, STRUCT_UNDO); RNA_def_struct_ui_text(srna, "Session State", "Runtime state information about the VR session"); func = RNA_def_function(srna, "is_running", "rna_XrSessionState_is_running"); diff --git a/source/blender/makesrna/rna_cleanup/rna_cleaner.py b/source/blender/makesrna/rna_cleanup/rna_cleaner.py index b5e41a82771..aee502ca3e6 100755 --- a/source/blender/makesrna/rna_cleanup/rna_cleaner.py +++ b/source/blender/makesrna/rna_cleanup/rna_cleaner.py @@ -11,7 +11,7 @@ Typical line in the input file (elements in [] are optional). [comment *] ToolSettings.snap_align_rotation -> use_snap_align_rotation: boolean [Align rotation with the snapping target] Geterate output format from blender run this: - ./blender.bin --background --python ./scripts/modules/rna_info.py 2> source/blender/makesrna/rna_cleanup/out.txt + ./blender.bin --background -noaudio --python ./scripts/modules/rna_info.py 2> source/blender/makesrna/rna_cleanup/out.txt """ diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index bb55360778a..a015a6f3962 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -44,13 +44,8 @@ set(SRC intern/MOD_edgesplit.cc intern/MOD_explode.cc intern/MOD_fluid.cc - intern/MOD_grease_pencil_array.cc intern/MOD_grease_pencil_color.cc - intern/MOD_grease_pencil_dash.cc - intern/MOD_grease_pencil_lattice.cc - intern/MOD_grease_pencil_length.cc intern/MOD_grease_pencil_mirror.cc - intern/MOD_grease_pencil_multiply.cc intern/MOD_grease_pencil_noise.cc intern/MOD_grease_pencil_offset.cc intern/MOD_grease_pencil_opacity.cc @@ -59,8 +54,6 @@ set(SRC intern/MOD_grease_pencil_thickness.cc intern/MOD_grease_pencil_tint.cc intern/MOD_grease_pencil_util.cc - intern/MOD_grease_pencil_weight_angle.cc - intern/MOD_grease_pencil_weight_proximity.cc intern/MOD_hook.cc intern/MOD_laplaciandeform.cc intern/MOD_laplaciansmooth.cc diff --git a/source/blender/modifiers/MOD_modifiertypes.hh b/source/blender/modifiers/MOD_modifiertypes.hh index d3d3f9313f9..351abe1a0bd 100644 --- a/source/blender/modifiers/MOD_modifiertypes.hh +++ b/source/blender/modifiers/MOD_modifiertypes.hh @@ -82,13 +82,6 @@ extern ModifierTypeInfo modifierType_GreasePencilOffset; extern ModifierTypeInfo modifierType_GreasePencilNoise; extern ModifierTypeInfo modifierType_GreasePencilMirror; extern ModifierTypeInfo modifierType_GreasePencilThickness; -extern ModifierTypeInfo modifierType_GreasePencilLattice; -extern ModifierTypeInfo modifierType_GreasePencilDash; -extern ModifierTypeInfo modifierType_GreasePencilMultiply; -extern ModifierTypeInfo modifierType_GreasePencilLength; -extern ModifierTypeInfo modifierType_GreasePencilWeightAngle; -extern ModifierTypeInfo modifierType_GreasePencilArray; -extern ModifierTypeInfo modifierType_GreasePencilWeightProximity; /* MOD_util.cc */ diff --git a/source/blender/modifiers/intern/MOD_armature.cc b/source/blender/modifiers/intern/MOD_armature.cc index 613d243fc26..9e4567a6a3a 100644 --- a/source/blender/modifiers/intern/MOD_armature.cc +++ b/source/blender/modifiers/intern/MOD_armature.cc @@ -11,7 +11,7 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_armature_types.h" #include "DNA_defaults.h" @@ -21,16 +21,26 @@ #include "BKE_action.h" #include "BKE_armature.hh" +#include "BKE_context.hh" #include "BKE_deform.hh" +#include "BKE_editmesh.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" +#include "BLO_read_write.hh" + +#include "DEG_depsgraph_query.hh" + #include "MEM_guardedalloc.h" #include "MOD_ui_common.hh" diff --git a/source/blender/modifiers/intern/MOD_array.cc b/source/blender/modifiers/intern/MOD_array.cc index da46104560f..a21b642eba6 100644 --- a/source/blender/modifiers/intern/MOD_array.cc +++ b/source/blender/modifiers/intern/MOD_array.cc @@ -16,17 +16,21 @@ #include "BLI_math_vector.h" #include "BLI_span.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "DNA_curve_types.h" #include "DNA_defaults.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BKE_anim_path.h" #include "BKE_attribute.hh" +#include "BKE_context.hh" #include "BKE_curve.hh" #include "BKE_customdata.hh" +#include "BKE_displist.h" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" @@ -34,6 +38,7 @@ #include "BKE_modifier.hh" #include "BKE_object_deform.h" #include "BKE_object_types.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -42,8 +47,10 @@ #include "RNA_prototypes.h" #include "MOD_ui_common.hh" +#include "MOD_util.hh" #include "DEG_depsgraph.hh" +#include "DEG_depsgraph_query.hh" #include "GEO_mesh_merge_by_distance.hh" @@ -479,13 +486,13 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd, float result_mat[4][4]; if (ctx->object) { - invert_m4_m4(obinv, ctx->object->object_to_world().ptr()); + invert_m4_m4(obinv, ctx->object->object_to_world); } else { unit_m4(obinv); } - mul_m4_series(result_mat, offset, obinv, amd->offset_ob->object_to_world().ptr()); + mul_m4_series(result_mat, offset, obinv, amd->offset_ob->object_to_world); copy_m4_m4(offset, result_mat); } @@ -497,7 +504,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd, Object *curve_ob = amd->curve_ob; CurveCache *curve_cache = curve_ob->runtime->curve_cache; if (curve_cache != nullptr && curve_cache->anim_path_accum_length != nullptr) { - float scale_fac = mat4_to_scale(curve_ob->object_to_world().ptr()); + float scale_fac = mat4_to_scale(curve_ob->object_to_world); length = scale_fac * BKE_anim_path_get_length(curve_cache); } } diff --git a/source/blender/modifiers/intern/MOD_bevel.cc b/source/blender/modifiers/intern/MOD_bevel.cc index 4aaf55fc31f..6ca9255a2ef 100644 --- a/source/blender/modifiers/intern/MOD_bevel.cc +++ b/source/blender/modifiers/intern/MOD_bevel.cc @@ -13,17 +13,22 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_curveprofile_types.h" #include "DNA_defaults.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_curveprofile.h" #include "BKE_deform.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -41,6 +46,8 @@ #include "bmesh.hh" #include "bmesh_tools.hh" +#include "DEG_depsgraph_query.hh" + static void init_data(ModifierData *md) { BevelModifierData *bmd = (BevelModifierData *)md; diff --git a/source/blender/modifiers/intern/MOD_boolean.cc b/source/blender/modifiers/intern/MOD_boolean.cc index ce3f53b68d4..6140eca3a25 100644 --- a/source/blender/modifiers/intern/MOD_boolean.cc +++ b/source/blender/modifiers/intern/MOD_boolean.cc @@ -17,16 +17,19 @@ #include "BLI_vector.hh" #include "BLI_vector_set.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "DNA_collection_types.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" -#include "BKE_collection.hh" -#include "BKE_global.hh" /* only to check G.debug */ +#include "BKE_collection.h" +#include "BKE_context.hh" +#include "BKE_global.h" /* only to check G.debug */ #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_material.h" @@ -42,12 +45,17 @@ #include "RNA_prototypes.h" #include "MOD_ui_common.hh" +#include "MOD_util.hh" + +#include "DEG_depsgraph_query.hh" #include "MEM_guardedalloc.h" #include "GEO_randomize.hh" #include "bmesh.hh" +#include "bmesh_tools.hh" +#include "tools/bmesh_boolean.hh" #include "tools/bmesh_intersect.hh" // #define DEBUG_TIME @@ -135,8 +143,8 @@ static Mesh *get_quick_mesh( float imat[4][4]; float omat[4][4]; - invert_m4_m4(imat, ob_self->object_to_world().ptr()); - mul_m4_m4m4(omat, imat, ob_operand_ob->object_to_world().ptr()); + invert_m4_m4(imat, ob_self->object_to_world); + mul_m4_m4m4(omat, imat, ob_operand_ob->object_to_world); MutableSpan positions = result->vert_positions_for_write(); for (const int i : positions.index_range()) { @@ -223,8 +231,8 @@ static BMesh *BMD_mesh_bm_create( SCOPED_TIMER(__func__); #endif - *r_is_flip = (is_negative_m4(object->object_to_world().ptr()) != - is_negative_m4(operand_ob->object_to_world().ptr())); + *r_is_flip = (is_negative_m4(object->object_to_world) != + is_negative_m4(operand_ob->object_to_world)); const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh, mesh_operand_ob); @@ -291,8 +299,8 @@ static void BMD_mesh_intersection(BMesh *bm, float imat[4][4]; float omat[4][4]; - invert_m4_m4(imat, object->object_to_world().ptr()); - mul_m4_m4m4(omat, imat, operand_ob->object_to_world().ptr()); + invert_m4_m4(imat, object->object_to_world); + mul_m4_m4m4(omat, imat, operand_ob->object_to_world); BMVert *eve; i = 0; @@ -420,7 +428,7 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd, } meshes.append(mesh); - obmats.append(ctx->object->object_to_world()); + obmats.append(float4x4(ctx->object->object_to_world)); material_remaps.append({}); const BooleanModifierMaterialMode material_mode = BooleanModifierMaterialMode( @@ -443,7 +451,7 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd, } BKE_mesh_wrapper_ensure_mdata(mesh_operand); meshes.append(mesh_operand); - obmats.append(bmd->object->object_to_world()); + obmats.append(float4x4(bmd->object->object_to_world)); if (material_mode == eBooleanModifierMaterialMode_Index) { material_remaps.append(get_material_remap_index_based(ctx->object, bmd->object)); } @@ -463,7 +471,7 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd, } BKE_mesh_wrapper_ensure_mdata(collection_mesh); meshes.append(collection_mesh); - obmats.append(ob->object_to_world()); + obmats.append(float4x4(ob->object_to_world)); if (material_mode == eBooleanModifierMaterialMode_Index) { material_remaps.append(get_material_remap_index_based(ctx->object, ob)); } @@ -478,14 +486,15 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd, const bool use_self = (bmd->flag & eBooleanModifierFlag_Self) != 0; const bool hole_tolerant = (bmd->flag & eBooleanModifierFlag_HoleTolerant) != 0; - Mesh *result = blender::meshintersect::direct_mesh_boolean(meshes, - obmats, - ctx->object->object_to_world(), - material_remaps, - use_self, - hole_tolerant, - bmd->operation, - nullptr); + Mesh *result = blender::meshintersect::direct_mesh_boolean( + meshes, + obmats, + float4x4(ctx->object->object_to_world), + material_remaps, + use_self, + hole_tolerant, + bmd->operation, + nullptr); if (material_mode == eBooleanModifierMaterialMode_Transfer) { MEM_SAFE_FREE(result->mat); diff --git a/source/blender/modifiers/intern/MOD_build.cc b/source/blender/modifiers/intern/MOD_build.cc index 83579b73832..31ebe971e1c 100644 --- a/source/blender/modifiers/intern/MOD_build.cc +++ b/source/blender/modifiers/intern/MOD_build.cc @@ -14,19 +14,23 @@ #include "BLI_math_vector.h" #include "BLI_rand.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" #include "DEG_depsgraph_query.hh" +#include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" -#include "BKE_scene.hh" +#include "BKE_particle.h" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -34,6 +38,7 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" static void init_data(ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_cast.cc b/source/blender/modifiers/intern/MOD_cast.cc index d065dd82735..ad0d2124b55 100644 --- a/source/blender/modifiers/intern/MOD_cast.cc +++ b/source/blender/modifiers/intern/MOD_cast.cc @@ -10,17 +10,24 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" +#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" +#include "BKE_editmesh.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" +#include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" -#include "BKE_object_types.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -28,6 +35,8 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "DEG_depsgraph_query.hh" + #include "MOD_ui_common.hh" #include "MOD_util.hh" @@ -115,13 +124,13 @@ static void sphere_do(CastModifierData *cmd, * we use its location, transformed to ob's local space. */ if (ctrl_ob) { if (flag & MOD_CAST_USE_OB_TRANSFORM) { - invert_m4_m4(imat, ctrl_ob->object_to_world().ptr()); - mul_m4_m4m4(mat, imat, ob->object_to_world().ptr()); + invert_m4_m4(imat, ctrl_ob->object_to_world); + mul_m4_m4m4(mat, imat, ob->object_to_world); invert_m4_m4(imat, mat); } - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); - mul_v3_m4v3(center, ob->world_to_object().ptr(), ctrl_ob->object_to_world().location()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); + mul_v3_m4v3(center, ob->world_to_object, ctrl_ob->object_to_world[3]); } /* now we check which options the user wants */ @@ -263,13 +272,13 @@ static void cuboid_do(CastModifierData *cmd, if (ctrl_ob) { if (flag & MOD_CAST_USE_OB_TRANSFORM) { - invert_m4_m4(imat, ctrl_ob->object_to_world().ptr()); - mul_m4_m4m4(mat, imat, ob->object_to_world().ptr()); + invert_m4_m4(imat, ctrl_ob->object_to_world); + mul_m4_m4m4(mat, imat, ob->object_to_world); invert_m4_m4(imat, mat); } - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); - mul_v3_m4v3(center, ob->world_to_object().ptr(), ctrl_ob->object_to_world().location()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); + mul_v3_m4v3(center, ob->world_to_object, ctrl_ob->object_to_world[3]); } if ((flag & MOD_CAST_SIZE_FROM_RADIUS) && has_radius) { diff --git a/source/blender/modifiers/intern/MOD_cloth.cc b/source/blender/modifiers/intern/MOD_cloth.cc index 4916fea50fc..979203a37c1 100644 --- a/source/blender/modifiers/intern/MOD_cloth.cc +++ b/source/blender/modifiers/intern/MOD_cloth.cc @@ -12,7 +12,7 @@ #include "BLI_listbase.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_cloth_types.h" #include "DNA_defaults.h" @@ -20,29 +20,35 @@ #include "DNA_mesh_types.h" #include "DNA_object_force_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "MEM_guardedalloc.h" #include "BKE_cloth.hh" +#include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_effect.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_key.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_pointcache.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "DEG_depsgraph_physics.hh" #include "DEG_depsgraph_query.hh" #include "MOD_ui_common.hh" +#include "MOD_util.hh" static void init_data(ModifierData *md) { diff --git a/source/blender/modifiers/intern/MOD_collision.cc b/source/blender/modifiers/intern/MOD_collision.cc index 5ad7d88c501..097c7b4981d 100644 --- a/source/blender/modifiers/intern/MOD_collision.cc +++ b/source/blender/modifiers/intern/MOD_collision.cc @@ -12,7 +12,7 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_object_force_types.h" @@ -22,16 +22,27 @@ #include "MEM_guardedalloc.h" #include "BKE_collision.h" -#include "BKE_global.hh" +#include "BKE_context.hh" +#include "BKE_global.h" +#include "BKE_lib_id.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_modifier.hh" +#include "BKE_pointcache.h" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" +#include "MOD_util.hh" + +#include "BLO_read_write.hh" #include "DEG_depsgraph_query.hh" @@ -131,7 +142,7 @@ static void deform_verts(ModifierData *md, for (uint i = 0; i < mvert_num; i++) { /* we save global positions */ - mul_m4_v3(ob->object_to_world().ptr(), collmd->x[i]); + mul_m4_v3(ob->object_to_world, collmd->x[i]); } collmd->xnew = static_cast(MEM_dupallocN(collmd->x)); /* Frame end position. */ @@ -176,7 +187,7 @@ static void deform_verts(ModifierData *md, for (uint i = 0; i < mvert_num; i++) { /* we save global positions */ - mul_m4_v3(ob->object_to_world().ptr(), collmd->xnew[i]); + mul_m4_v3(ob->object_to_world, collmd->xnew[i]); /* detect motion */ is_static = is_static && equals_v3v3(collmd->x[i], collmd->xnew[i]); diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.cc b/source/blender/modifiers/intern/MOD_correctivesmooth.cc index 28e0735254f..bb628e01b67 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.cc +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.cc @@ -13,18 +13,24 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "MEM_guardedalloc.h" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_editmesh.hh" +#include "BKE_lib_id.hh" +#include "BKE_mesh.hh" +#include "BKE_mesh_wrapper.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -45,9 +51,10 @@ #include "BLI_time.h" #ifdef DEBUG_TIME # include "BLI_time_utildefines.h" + #endif -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" static void init_data(ModifierData *md) { diff --git a/source/blender/modifiers/intern/MOD_curve.cc b/source/blender/modifiers/intern/MOD_curve.cc index 8a6de0d00e1..4f46ebe3f67 100644 --- a/source/blender/modifiers/intern/MOD_curve.cc +++ b/source/blender/modifiers/intern/MOD_curve.cc @@ -10,27 +10,36 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_curve.hh" #include "BKE_deform.hh" +#include "BKE_editmesh.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" +#include "DEG_depsgraph_query.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "MOD_util.hh" diff --git a/source/blender/modifiers/intern/MOD_datatransfer.cc b/source/blender/modifiers/intern/MOD_datatransfer.cc index 100d9fa7738..f8d9c32dd38 100644 --- a/source/blender/modifiers/intern/MOD_datatransfer.cc +++ b/source/blender/modifiers/intern/MOD_datatransfer.cc @@ -8,13 +8,15 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_data_transfer.h" #include "BKE_lib_id.hh" @@ -23,7 +25,8 @@ #include "BKE_mesh_mapping.hh" #include "BKE_mesh_remap.hh" #include "BKE_modifier.hh" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -31,9 +34,12 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "DEG_depsgraph_query.hh" + #include "MEM_guardedalloc.h" #include "MOD_ui_common.hh" +#include "MOD_util.hh" /************************************** * Modifiers functions. * diff --git a/source/blender/modifiers/intern/MOD_decimate.cc b/source/blender/modifiers/intern/MOD_decimate.cc index c17a4b2ab62..d9aad87d8c3 100644 --- a/source/blender/modifiers/intern/MOD_decimate.cc +++ b/source/blender/modifiers/intern/MOD_decimate.cc @@ -9,7 +9,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" @@ -19,8 +19,10 @@ #include "MEM_guardedalloc.h" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_mesh.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/modifiers/intern/MOD_displace.cc b/source/blender/modifiers/intern/MOD_displace.cc index 9ee636ed448..9c2b704474f 100644 --- a/source/blender/modifiers/intern/MOD_displace.cc +++ b/source/blender/modifiers/intern/MOD_displace.cc @@ -12,7 +12,7 @@ #include "BLI_math_vector.h" #include "BLI_task.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" @@ -20,12 +20,18 @@ #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_deform.hh" +#include "BKE_editmesh.hh" #include "BKE_image.h" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" +#include "BKE_object.hh" +#include "BKE_screen.hh" #include "BKE_texture.h" #include "UI_interface.hh" @@ -317,7 +323,7 @@ static void displaceModifier_do(DisplaceModifierData *dmd, else if (ELEM(direction, MOD_DISP_DIR_X, MOD_DISP_DIR_Y, MOD_DISP_DIR_Z, MOD_DISP_DIR_RGB_XYZ) && use_global_direction) { - copy_m4_m4(local_mat, ob->object_to_world().ptr()); + copy_m4_m4(local_mat, ob->object_to_world); } DisplaceUserdata data = {nullptr}; diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.cc b/source/blender/modifiers/intern/MOD_dynamicpaint.cc index 20e9d55325b..c03e1bbe36c 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.cc +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.cc @@ -12,21 +12,28 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_dynamicpaint_types.h" +#include "DNA_mesh_types.h" #include "DNA_object_force_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_dynamicpaint.h" +#include "BKE_layer.hh" #include "BKE_lib_query.hh" +#include "BKE_mesh.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "DEG_depsgraph.hh" @@ -34,6 +41,7 @@ #include "DEG_depsgraph_physics.hh" #include "DEG_depsgraph_query.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" static void init_data(ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_edgesplit.cc b/source/blender/modifiers/intern/MOD_edgesplit.cc index 8c9475bf80d..10341de358e 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.cc +++ b/source/blender/modifiers/intern/MOD_edgesplit.cc @@ -14,14 +14,17 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" +#include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -32,6 +35,7 @@ #include "bmesh.hh" #include "bmesh_tools.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "GEO_randomize.hh" diff --git a/source/blender/modifiers/intern/MOD_explode.cc b/source/blender/modifiers/intern/MOD_explode.cc index 2ed5cdca584..9dfc95e5e52 100644 --- a/source/blender/modifiers/intern/MOD_explode.cc +++ b/source/blender/modifiers/intern/MOD_explode.cc @@ -17,26 +17,32 @@ #include "BLI_math_vector.h" #include "BLI_rand.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_deform.hh" +#include "BKE_lattice.hh" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" #include "BKE_mesh_legacy_convert.hh" #include "BKE_modifier.hh" #include "BKE_particle.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "BLO_read_write.hh" + #include "RNA_access.hh" #include "RNA_prototypes.h" @@ -44,6 +50,7 @@ #include "MEM_guardedalloc.h" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" static void init_data(ModifierData *md) @@ -973,7 +980,7 @@ static Mesh *explodeMesh(ExplodeModifierData *emd, &explode->fdata_legacy, CD_MTFACE, emd->uvname, explode->totface_legacy)); /* getting back to object space */ - invert_m4_m4(imat, ctx->object->object_to_world().ptr()); + invert_m4_m4(imat, ctx->object->object_to_world); psys_sim_data_init(&sim); @@ -1001,7 +1008,7 @@ static Mesh *explodeMesh(ExplodeModifierData *emd, psys_get_particle_state(&sim, ed_v2, &state, true); vertco = explode_positions[v]; - mul_m4_v3(ctx->object->object_to_world().ptr(), vertco); + mul_m4_v3(ctx->object->object_to_world, vertco); sub_v3_v3(vertco, birth.co); diff --git a/source/blender/modifiers/intern/MOD_fluid.cc b/source/blender/modifiers/intern/MOD_fluid.cc index 5876f85b0ff..e9b3984343d 100644 --- a/source/blender/modifiers/intern/MOD_fluid.cc +++ b/source/blender/modifiers/intern/MOD_fluid.cc @@ -13,20 +13,27 @@ #include "BLI_task.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "DNA_collection_types.h" #include "DNA_fluid_types.h" +#include "DNA_mesh_types.h" #include "DNA_object_force_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_fluid.h" +#include "BKE_layer.hh" #include "BKE_lib_query.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "DEG_depsgraph.hh" @@ -34,6 +41,7 @@ #include "DEG_depsgraph_physics.hh" #include "DEG_depsgraph_query.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" static void init_data(ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_array.cc b/source/blender/modifiers/intern/MOD_grease_pencil_array.cc deleted file mode 100644 index 0f76945391f..00000000000 --- a/source/blender/modifiers/intern/MOD_grease_pencil_array.cc +++ /dev/null @@ -1,397 +0,0 @@ -/* SPDX-FileCopyrightText: 2024 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup modifiers - */ - -#include "DNA_defaults.h" -#include "DNA_modifier_types.h" - -#include "BKE_curves.hh" -#include "BKE_geometry_set.hh" -#include "BKE_grease_pencil.hh" -#include "BKE_instances.hh" -#include "BKE_lib_query.hh" -#include "BKE_material.h" -#include "BKE_modifier.hh" -#include "BKE_screen.hh" - -#include "BLO_read_write.hh" - -#include "GEO_realize_instances.hh" - -#include "UI_interface.hh" -#include "UI_resources.hh" - -#include "BLT_translation.hh" - -#include "BLI_bounds_types.hh" -#include "BLI_hash.h" -#include "BLI_math_matrix.hh" -#include "BLI_rand.h" - -#include "WM_types.hh" - -#include "RNA_access.hh" -#include "RNA_prototypes.h" - -#include "MOD_grease_pencil_util.hh" -#include "MOD_modifiertypes.hh" -#include "MOD_ui_common.hh" - -namespace blender { - -static void init_data(ModifierData *md) -{ - auto *mmd = reinterpret_cast(md); - - BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(mmd, modifier)); - - MEMCPY_STRUCT_AFTER(mmd, DNA_struct_default_get(GreasePencilArrayModifierData), modifier); - modifier::greasepencil::init_influence_data(&mmd->influence, false); -} - -static void copy_data(const ModifierData *md, ModifierData *target, const int flag) -{ - const auto *mmd = reinterpret_cast(md); - auto *tmmd = reinterpret_cast(target); - - modifier::greasepencil::free_influence_data(&tmmd->influence); - - BKE_modifier_copydata_generic(md, target, flag); - modifier::greasepencil::copy_influence_data(&mmd->influence, &tmmd->influence, flag); -} - -static void free_data(ModifierData *md) -{ - auto *mmd = reinterpret_cast(md); - modifier::greasepencil::free_influence_data(&mmd->influence); -} - -static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data) -{ - auto *mmd = reinterpret_cast(md); - walk(user_data, ob, (ID **)&mmd->object, IDWALK_CB_NOP); - modifier::greasepencil::foreach_influence_ID_link(&mmd->influence, ob, walk, user_data); -} - -static void update_depsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) -{ - auto *mmd = reinterpret_cast(md); - if (mmd->object != nullptr) { - DEG_add_object_relation( - ctx->node, mmd->object, DEG_OB_COMP_TRANSFORM, "Grease Pencil Array Modifier"); - DEG_add_depends_on_transform_relation(ctx->node, "Grease Pencil Array Modifier"); - } -} - -static float4x4 get_array_matrix(const Object &ob, - const GreasePencilArrayModifierData &mmd, - const int elem_idx, - const bool use_object_offset) -{ - - if (use_object_offset) { - float4x4 mat_offset = float4x4::identity(); - - if (mmd.flag & MOD_GREASE_PENCIL_ARRAY_USE_OFFSET) { - mat_offset[3] += mmd.offset; - } - const float4x4 obinv = ob.world_to_object(); - - return mat_offset * obinv * mmd.object->object_to_world(); - } - - const float3 offset = [&]() { - if (mmd.flag & MOD_GREASE_PENCIL_ARRAY_USE_OFFSET) { - return float3(mmd.offset) * elem_idx; - } - return float3(0.0f); - }(); - - return math::from_location(offset); -} - -static float4x4 get_rand_matrix(const GreasePencilArrayModifierData &mmd, - const Object &ob, - const int elem_id) -{ - int seed = mmd.seed; - seed += BLI_hash_string(ob.id.name + 2); - seed += BLI_hash_string(mmd.modifier.name); - const float rand_offset = BLI_hash_int_01(seed); - float3x3 rand; - for (int j = 0; j < 3; j++) { - const uint3 primes(2, 3, 7); - double3 offset(0.0); - double3 r; - /* To ensure a nice distribution, we use halton sequence and offset using the seed. */ - BLI_halton_3d(primes, offset, elem_id, r); - - if ((mmd.flag & MOD_GREASE_PENCIL_ARRAY_UNIFORM_RANDOM_SCALE) && j == 2) { - float rand_value; - rand_value = math::mod(r[0] * 2.0 - 1.0 + rand_offset, 1.0); - rand_value = math::mod(math::sin(rand_value * 12.9898 + j * 78.233) * 43758.5453, 1.0); - rand[j] = float3(rand_value); - } - else { - for (int i = 0; i < 3; i++) { - rand[j][i] = math::mod(r[i] * 2.0 - 1.0 + rand_offset, 1.0); - rand[j][i] = math::mod(math::sin(rand[j][i] * 12.9898 + j * 78.233) * 43758.5453, 1.0); - } - } - } - /* Calculate Random matrix. */ - return math::from_loc_rot_scale( - mmd.rnd_offset * rand[0], mmd.rnd_rot * rand[1], float3(1.0f) + mmd.rnd_scale * rand[2]); -}; - -static bke::CurvesGeometry create_array_copies(const Object &ob, - const GreasePencilArrayModifierData &mmd, - const bke::CurvesGeometry &base_curves, - bke::CurvesGeometry filtered_curves) -{ - /* Assign replacement material on filtered curves so all copies can have this material when later - * when they get instanced. */ - if (mmd.mat_rpl > 0) { - bke::MutableAttributeAccessor attributes = filtered_curves.attributes_for_write(); - bke::SpanAttributeWriter stroke_materials = attributes.lookup_or_add_for_write_span( - "material_index", bke::AttrDomain::Curve); - stroke_materials.span.fill(mmd.mat_rpl - 1); - stroke_materials.finish(); - } - - Curves *base_curves_id = bke::curves_new_nomain(base_curves); - Curves *filtered_curves_id = bke::curves_new_nomain(filtered_curves); - bke::GeometrySet base_geo = bke::GeometrySet::from_curves(base_curves_id); - bke::GeometrySet filtered_geo = bke::GeometrySet::from_curves(filtered_curves_id); - - std::unique_ptr instances = std::make_unique(); - const int base_handle = instances->add_reference(bke::InstanceReference{base_geo}); - const int filtered_handle = instances->add_reference(bke::InstanceReference{filtered_geo}); - - /* Always add untouched original curves. */ - instances->add_instance(base_handle, float4x4::identity()); - - float3 size(0.0f); - if (mmd.flag & MOD_GREASE_PENCIL_ARRAY_USE_RELATIVE) { - std::optional> bounds = filtered_curves.bounds_min_max(); - if (bounds.has_value()) { - size = bounds.value().max - bounds.value().min; - /* Need a minimum size (for flat drawings). */ - size = math::max(size, float3(0.01f)); - } - } - - float4x4 current_offset = float4x4::identity(); - for (const int elem_id : IndexRange(1, mmd.count - 1)) { - const bool use_object_offset = (mmd.flag & MOD_GREASE_PENCIL_ARRAY_USE_OB_OFFSET) && - (mmd.object); - const float4x4 mat = get_array_matrix(ob, mmd, elem_id, use_object_offset); - - if (use_object_offset) { - current_offset = current_offset * mat; - } - else { - current_offset = mat; - } - - /* Apply relative offset. */ - if (mmd.flag & MOD_GREASE_PENCIL_ARRAY_USE_RELATIVE) { - float3 relative = size * float3(mmd.shift); - float3 translate = relative * float3(float(elem_id)); - current_offset.w += float4(translate, 1.0f); - } - - current_offset *= get_rand_matrix(mmd, ob, elem_id); - - instances->add_instance(filtered_handle, current_offset); - } - - geometry::RealizeInstancesOptions options; - options.keep_original_ids = true; - options.realize_instance_attributes = false; /* Should this be true? */ - options.propagation_info = {}; - bke::GeometrySet result_geo = geometry::realize_instances( - bke::GeometrySet::from_instances(instances.release()), options); - return std::move(result_geo.get_curves_for_write()->geometry.wrap()); -} - -static void modify_drawing(const GreasePencilArrayModifierData &mmd, - const ModifierEvalContext &ctx, - bke::greasepencil::Drawing &drawing) -{ - const bke::CurvesGeometry &src_curves = drawing.strokes(); - if (src_curves.curve_num == 0) { - return; - } - - IndexMaskMemory curve_mask_memory; - const IndexMask curves_mask = modifier::greasepencil::get_filtered_stroke_mask( - ctx.object, src_curves, mmd.influence, curve_mask_memory); - - if (curves_mask.size() == src_curves.curve_num) { - /* Make a full copy so we can modify materials inside #create_array_copies before instancing. - */ - bke::CurvesGeometry copy = bke::CurvesGeometry(src_curves); - - drawing.strokes_for_write() = create_array_copies( - *ctx.object, mmd, src_curves, std::move(copy)); - } - else { - bke::CurvesGeometry masked_curves = bke::curves_copy_curve_selection( - src_curves, curves_mask, {}); - - drawing.strokes_for_write() = create_array_copies( - *ctx.object, mmd, src_curves, std::move(masked_curves)); - } - - drawing.tag_topology_changed(); -} - -static void modify_geometry_set(ModifierData *md, - const ModifierEvalContext *ctx, - bke::GeometrySet *geometry_set) -{ - using bke::greasepencil::Drawing; - - auto *mmd = reinterpret_cast(md); - - if (!geometry_set->has_grease_pencil()) { - return; - } - GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write(); - const int frame = grease_pencil.runtime->eval_frame; - - IndexMaskMemory mask_memory; - const IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask( - grease_pencil, mmd->influence, mask_memory); - - const Vector drawings = modifier::greasepencil::get_drawings_for_write( - grease_pencil, layer_mask, frame); - threading::parallel_for_each(drawings, - [&](Drawing *drawing) { modify_drawing(*mmd, *ctx, *drawing); }); -} - -static void panel_draw(const bContext *C, Panel *panel) -{ - uiLayout *layout = panel->layout; - - PointerRNA ob_ptr; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); - - uiLayoutSetPropSep(layout, true); - - uiItemR(layout, ptr, "count", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(layout, ptr, "replace_material", UI_ITEM_NONE, IFACE_("Material Override"), ICON_NONE); - - if (uiLayout *sub = uiLayoutPanelProp( - C, layout, ptr, "open_relative_offset_panel", "Relative Offset")) - { - uiLayoutSetPropSep(sub, true); - uiItemR(sub, ptr, "use_relative_offset", UI_ITEM_NONE, IFACE_("Enable"), ICON_NONE); - - uiLayout *col = uiLayoutColumn(sub, false); - uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_relative_offset")); - uiItemR(col, ptr, "relative_offset", UI_ITEM_NONE, IFACE_("Factor"), ICON_NONE); - } - - if (uiLayout *sub = uiLayoutPanelProp( - C, layout, ptr, "open_constant_offset_panel", "Constant Offset")) - { - uiLayoutSetPropSep(sub, true); - uiItemR(sub, ptr, "use_constant_offset", UI_ITEM_NONE, IFACE_("Enable"), ICON_NONE); - - uiLayout *col = uiLayoutColumn(sub, false); - uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_constant_offset")); - uiItemR(col, ptr, "constant_offset", UI_ITEM_NONE, IFACE_("Distance"), ICON_NONE); - } - - if (uiLayout *sub = uiLayoutPanelProp( - C, layout, ptr, "open_object_offset_panel", "Object Offset")) - { - uiLayoutSetPropSep(sub, true); - uiItemR(sub, ptr, "use_object_offset", UI_ITEM_NONE, IFACE_("Enable"), ICON_NONE); - - uiLayout *col = uiLayoutColumn(sub, false); - uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_object_offset")); - uiItemR(col, ptr, "offset_object", UI_ITEM_NONE, IFACE_("Object"), ICON_NONE); - } - - if (uiLayout *sub = uiLayoutPanelProp(C, layout, ptr, "open_randomize_panel", "Randomize")) { - uiLayoutSetPropSep(sub, true); - uiItemR(sub, ptr, "random_offset", UI_ITEM_NONE, IFACE_("Offset"), ICON_NONE); - uiItemR(sub, ptr, "random_rotation", UI_ITEM_NONE, IFACE_("Rotation"), ICON_NONE); - uiItemR(sub, ptr, "random_scale", UI_ITEM_NONE, IFACE_("Scale"), ICON_NONE); - uiItemR(sub, ptr, "use_uniform_random_scale", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(sub, ptr, "seed", UI_ITEM_NONE, nullptr, ICON_NONE); - } - - if (uiLayout *influence_panel = uiLayoutPanelProp( - C, layout, ptr, "open_influence_panel", "Influence")) - { - modifier::greasepencil::draw_layer_filter_settings(C, influence_panel, ptr); - modifier::greasepencil::draw_material_filter_settings(C, influence_panel, ptr); - } - - modifier_panel_end(layout, ptr); -} - -static void panel_register(ARegionType *region_type) -{ - modifier_panel_register(region_type, eModifierType_GreasePencilArray, panel_draw); -} - -static void blend_write(BlendWriter *writer, const ID * /*id_owner*/, const ModifierData *md) -{ - const auto *mmd = reinterpret_cast(md); - - BLO_write_struct(writer, GreasePencilArrayModifierData, mmd); - modifier::greasepencil::write_influence_data(writer, &mmd->influence); -} - -static void blend_read(BlendDataReader *reader, ModifierData *md) -{ - auto *mmd = reinterpret_cast(md); - - modifier::greasepencil::read_influence_data(reader, &mmd->influence); -} - -} // namespace blender - -ModifierTypeInfo modifierType_GreasePencilArray = { - /*idname*/ "GreasePencilArrayModifier", - /*name*/ N_("Array"), - /*struct_name*/ "GreasePencilArrayModifierData", - /*struct_size*/ sizeof(GreasePencilArrayModifierData), - /*srna*/ &RNA_GreasePencilArrayModifier, - /*type*/ ModifierTypeType::Constructive, - /*flags*/ eModifierTypeFlag_AcceptsGreasePencil | eModifierTypeFlag_SupportsEditmode | - eModifierTypeFlag_EnableInEditmode | eModifierTypeFlag_SupportsMapping, - /*icon*/ ICON_MOD_ARRAY, - - /*copy_data*/ blender::copy_data, - - /*deform_verts*/ nullptr, - /*deform_matrices*/ nullptr, - /*deform_verts_EM*/ nullptr, - /*deform_matrices_EM*/ nullptr, - /*modify_mesh*/ nullptr, - /*modify_geometry_set*/ blender::modify_geometry_set, - - /*init_data*/ blender::init_data, - /*required_data_mask*/ nullptr, - /*free_data*/ blender::free_data, - /*is_disabled*/ nullptr, - /*update_depsgraph*/ blender::update_depsgraph, - /*depends_on_time*/ nullptr, - /*depends_on_normals*/ nullptr, - /*foreach_ID_link*/ blender::foreach_ID_link, - /*foreach_tex_link*/ nullptr, - /*free_runtime_data*/ nullptr, - /*panel_register*/ blender::panel_register, - /*blend_write*/ blender::blend_write, - /*blend_read*/ blender::blend_read, -}; diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_color.cc b/source/blender/modifiers/intern/MOD_grease_pencil_color.cc index fa4f6b9a171..a276bbb5b31 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_color.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_color.cc @@ -30,7 +30,7 @@ #include "UI_interface.hh" #include "UI_resources.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "WM_types.hh" diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_dash.cc b/source/blender/modifiers/intern/MOD_grease_pencil_dash.cc deleted file mode 100644 index efa31ac125d..00000000000 --- a/source/blender/modifiers/intern/MOD_grease_pencil_dash.cc +++ /dev/null @@ -1,532 +0,0 @@ -/* SPDX-FileCopyrightText: 2024 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup modifiers - */ - -#include "BLI_index_range.hh" -#include "BLI_span.hh" -#include "BLI_string.h" -#include "BLI_string_utf8.h" - -#include "DNA_defaults.h" -#include "DNA_modifier_types.h" - -#include "BKE_curves.hh" -#include "BKE_geometry_set.hh" -#include "BKE_grease_pencil.hh" -#include "BKE_instances.hh" -#include "BKE_modifier.hh" -#include "BKE_screen.hh" - -#include "BLO_read_write.hh" - -#include "UI_interface.hh" -#include "UI_resources.hh" - -#include "BLT_translation.hh" - -#include "WM_api.hh" -#include "WM_types.hh" - -#include "RNA_access.hh" -#include "RNA_prototypes.h" - -#include "MOD_grease_pencil_util.hh" -#include "MOD_ui_common.hh" - -namespace blender { - -static void init_data(ModifierData *md) -{ - auto *dmd = reinterpret_cast(md); - - BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(dmd, modifier)); - - MEMCPY_STRUCT_AFTER(dmd, DNA_struct_default_get(GreasePencilDashModifierData), modifier); - modifier::greasepencil::init_influence_data(&dmd->influence, false); - - GreasePencilDashModifierSegment *ds = DNA_struct_default_alloc(GreasePencilDashModifierSegment); - STRNCPY_UTF8(ds->name, DATA_("Segment")); - dmd->segments_array = ds; - dmd->segments_num = 1; -} - -static void copy_data(const ModifierData *md, ModifierData *target, const int flag) -{ - const auto *dmd = reinterpret_cast(md); - auto *tmmd = reinterpret_cast(target); - - modifier::greasepencil::free_influence_data(&tmmd->influence); - - BKE_modifier_copydata_generic(md, target, flag); - modifier::greasepencil::copy_influence_data(&dmd->influence, &tmmd->influence, flag); - - tmmd->segments_array = static_cast( - MEM_dupallocN(dmd->segments_array)); -} - -static void free_data(ModifierData *md) -{ - auto *dmd = reinterpret_cast(md); - modifier::greasepencil::free_influence_data(&dmd->influence); - - MEM_SAFE_FREE(dmd->segments_array); -} - -static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data) -{ - auto *dmd = reinterpret_cast(md); - modifier::greasepencil::foreach_influence_ID_link(&dmd->influence, ob, walk, user_data); -} - -static bool is_disabled(const Scene * /*scene*/, ModifierData *md, bool /*use_render_params*/) -{ - const auto *dmd = reinterpret_cast(md); - /* Enable if at least one segment has non-zero length. */ - for (const GreasePencilDashModifierSegment &dash_segment : dmd->segments()) { - if (dash_segment.dash + dash_segment.gap - 1 > 0) { - return false; - } - } - return true; -} - -static int floored_modulo(const int a, const int b) -{ - return a - math::floor(float(a) / float(b)) * b; -} - -/* Combined segment info used by all strokes. */ -struct PatternInfo { - int offset = 0; - int length = 0; - Array segments; - Array cyclic; - Array material; - Array radius; - Array opacity; -}; - -static PatternInfo get_pattern_info(const GreasePencilDashModifierData &dmd) -{ - PatternInfo info; - for (const GreasePencilDashModifierSegment &dash_segment : dmd.segments()) { - info.length += dash_segment.dash + dash_segment.gap; - } - - info.segments.reinitialize(dmd.segments().size()); - info.cyclic.reinitialize(dmd.segments().size()); - info.material.reinitialize(dmd.segments().size()); - info.radius.reinitialize(dmd.segments().size()); - info.opacity.reinitialize(dmd.segments().size()); - info.offset = floored_modulo(dmd.dash_offset, info.length); - - /* Store segments as ranges. */ - IndexRange dash_range(0); - IndexRange gap_range(0); - for (const int i : dmd.segments().index_range()) { - const GreasePencilDashModifierSegment &dash_segment = dmd.segments()[i]; - dash_range = gap_range.after(dash_segment.dash); - gap_range = dash_range.after(dash_segment.gap); - info.segments[i] = dash_range; - info.cyclic[i] = dash_segment.flag & MOD_GREASE_PENCIL_DASH_USE_CYCLIC; - info.material[i] = dash_segment.mat_nr; - info.radius[i] = dash_segment.radius; - info.opacity[i] = dash_segment.opacity; - } - return info; -} - -/* Returns the segment covering the given index, including repetitions.*/ -static int find_dash_segment(const PatternInfo &pattern_info, const int index) -{ - const int repeat = index / pattern_info.length; - const int segments_num = pattern_info.segments.size(); - - const int local_index = index - repeat * pattern_info.length; - for (const int i : pattern_info.segments.index_range().drop_back(1)) { - const IndexRange segment = pattern_info.segments[i]; - const IndexRange next_segment = pattern_info.segments[i + 1]; - if (local_index >= segment.start() && local_index < next_segment.start()) { - return i + repeat * segments_num; - } - } - return segments_num - 1 + repeat * segments_num; -} - -/** - * Iterate over all dash curves. - * \param fn: Function taking an index range of source points describing new curves. - * \note Point range can be larger than the source point range in case of cyclic curves. - */ -static void foreach_dash(const PatternInfo &pattern_info, - const IndexRange src_points, - const bool cyclic, - FunctionRef fn) -{ - const int points_num = src_points.size(); - const int segments_num = pattern_info.segments.size(); - - const int first_segment = find_dash_segment(pattern_info, pattern_info.offset); - const int last_segment = find_dash_segment(pattern_info, pattern_info.offset + points_num - 1); - BLI_assert(first_segment < segments_num); - BLI_assert(last_segment >= first_segment); - - const IndexRange all_segments = IndexRange(first_segment, last_segment - first_segment + 1); - for (const int i : all_segments) { - const int repeat = i / segments_num; - const int segment_index = i - repeat * segments_num; - const IndexRange range = pattern_info.segments[segment_index].shift(repeat * - pattern_info.length); - - const int64_t point_shift = src_points.start() - pattern_info.offset; - const int64_t min_point = src_points.start(); - const int64_t max_point = cyclic ? src_points.one_after_last() : src_points.last(); - const int64_t start = std::clamp(range.start() + point_shift, min_point, max_point); - const int64_t end = std::clamp(range.one_after_last() + point_shift, min_point, max_point + 1); - - IndexRange points(start, end - start); - if (!points.is_empty()) { - fn(points, - pattern_info.cyclic[segment_index], - pattern_info.material[segment_index], - pattern_info.radius[segment_index], - pattern_info.opacity[segment_index]); - } - } -} - -static bke::CurvesGeometry create_dashes(const PatternInfo &pattern_info, - const bke::CurvesGeometry &src_curves, - const IndexMask &curves_mask) -{ - const bke::AttributeAccessor src_attributes = src_curves.attributes(); - const VArray src_cyclic = *src_attributes.lookup_or_default( - "cyclic", bke::AttrDomain::Curve, false); - const VArray src_material = *src_attributes.lookup_or_default( - "material_index", bke::AttrDomain::Curve, 0); - const VArray src_radius = *src_attributes.lookup("radius", bke::AttrDomain::Point); - const VArray src_opacity = *src_attributes.lookup("opacity", - bke::AttrDomain::Point); - - /* Count new curves and points. */ - int dst_point_num = 0; - int dst_curve_num = 0; - curves_mask.foreach_index([&](const int64_t src_curve_i) { - const IndexRange src_points = src_curves.points_by_curve()[src_curve_i]; - - foreach_dash(pattern_info, - src_points, - src_cyclic[src_curve_i], - [&](const IndexRange copy_points, - bool /*cyclic*/, - int /*material*/, - float /*radius*/, - float /*opacity*/) { - dst_point_num += copy_points.size(); - dst_curve_num += 1; - }); - }); - - bke::CurvesGeometry dst_curves(dst_point_num, dst_curve_num); - bke::MutableAttributeAccessor dst_attributes = dst_curves.attributes_for_write(); - bke::SpanAttributeWriter dst_cyclic = dst_attributes.lookup_or_add_for_write_span( - "cyclic", bke::AttrDomain::Curve); - bke::SpanAttributeWriter dst_material = dst_attributes.lookup_or_add_for_write_span( - "material_index", bke::AttrDomain::Curve); - bke::SpanAttributeWriter dst_radius = dst_attributes.lookup_or_add_for_write_span( - "radius", bke::AttrDomain::Point); - bke::SpanAttributeWriter dst_opacity = dst_attributes.lookup_or_add_for_write_span( - "opacity", bke::AttrDomain::Point); - /* Map each destination point and curve to its source. */ - Array src_point_indices(dst_point_num); - Array src_curve_indices(dst_curve_num); - - { - /* Start at curve offset and add points for each dash. */ - IndexRange dst_point_range(0); - int dst_curve_i = 0; - auto add_dash_curve = [&](const int src_curve, - const IndexRange src_points, - const IndexRange copy_points, - bool cyclic, - int material, - float radius, - float opacity) { - dst_point_range = dst_point_range.after(copy_points.size()); - dst_curves.offsets_for_write()[dst_curve_i] = dst_point_range.start(); - - if (src_points.contains(copy_points.last())) { - array_utils::fill_index_range(src_point_indices.as_mutable_span().slice(dst_point_range), - int(copy_points.start())); - } - else { - /* Cyclic curve. */ - array_utils::fill_index_range( - src_point_indices.as_mutable_span().slice(dst_point_range.drop_back(1)), - int(copy_points.start())); - src_point_indices[dst_point_range.last()] = src_points.first(); - } - src_curve_indices[dst_curve_i] = src_curve; - dst_cyclic.span[dst_curve_i] = cyclic; - dst_material.span[dst_curve_i] = material >= 0 ? material : src_material[src_curve]; - for (const int i : dst_point_range) { - dst_radius.span[i] = src_radius[src_point_indices[i]] * radius; - dst_opacity.span[i] = src_opacity[src_point_indices[i]] * opacity; - } - - ++dst_curve_i; - }; - - curves_mask.foreach_index([&](const int64_t src_curve_i) { - const IndexRange src_points = src_curves.points_by_curve()[src_curve_i]; - foreach_dash(pattern_info, - src_points, - src_cyclic[src_curve_i], - [&](const IndexRange copy_points, - bool cyclic, - int material, - float radius, - float opacity) { - add_dash_curve( - src_curve_i, src_points, copy_points, cyclic, material, radius, opacity); - }); - }); - if (dst_curve_i > 0) { - /* Last offset entry is total point count. */ - dst_curves.offsets_for_write()[dst_curve_i] = dst_point_range.one_after_last(); - } - } - - bke::gather_attributes(src_attributes, - bke::AttrDomain::Point, - {}, - {"radius", "opacity"}, - src_point_indices, - dst_attributes); - bke::gather_attributes(src_attributes, - bke::AttrDomain::Curve, - {}, - {"cyclic", "material_index"}, - src_curve_indices, - dst_attributes); - - dst_cyclic.finish(); - dst_material.finish(); - dst_radius.finish(); - dst_opacity.finish(); - dst_curves.update_curve_types(); - - return dst_curves; -} - -static void modify_drawing(const GreasePencilDashModifierData &dmd, - const ModifierEvalContext &ctx, - const PatternInfo &pattern_info, - bke::greasepencil::Drawing &drawing) -{ - const bke::CurvesGeometry &src_curves = drawing.strokes(); - if (src_curves.curve_num == 0) { - return; - } - /* Selected source curves. */ - IndexMaskMemory curve_mask_memory; - const IndexMask curves_mask = modifier::greasepencil::get_filtered_stroke_mask( - ctx.object, src_curves, dmd.influence, curve_mask_memory); - - drawing.strokes_for_write() = create_dashes(pattern_info, src_curves, curves_mask); - drawing.tag_topology_changed(); -} - -static void modify_geometry_set(ModifierData *md, - const ModifierEvalContext *ctx, - bke::GeometrySet *geometry_set) -{ - using bke::greasepencil::Drawing; - - auto *dmd = reinterpret_cast(md); - - if (!geometry_set->has_grease_pencil()) { - return; - } - GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write(); - const int frame = grease_pencil.runtime->eval_frame; - - const PatternInfo pattern_info = get_pattern_info(*dmd); - - IndexMaskMemory mask_memory; - const IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask( - grease_pencil, dmd->influence, mask_memory); - - const Vector drawings = modifier::greasepencil::get_drawings_for_write( - grease_pencil, layer_mask, frame); - threading::parallel_for_each( - drawings, [&](Drawing *drawing) { modify_drawing(*dmd, *ctx, pattern_info, *drawing); }); -} - -static void panel_draw(const bContext *C, Panel *panel) -{ - uiLayout *layout = panel->layout; - - PointerRNA ob_ptr; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); - auto *dmd = static_cast(ptr->data); - - uiLayoutSetPropSep(layout, true); - - uiItemR(layout, ptr, "dash_offset", UI_ITEM_NONE, nullptr, ICON_NONE); - - uiLayout *row = uiLayoutRow(layout, false); - uiLayoutSetPropSep(row, false); - - uiTemplateList(row, - (bContext *)C, - "MOD_UL_grease_pencil_dash_modifier_segments", - "", - ptr, - "segments", - ptr, - "segment_active_index", - nullptr, - 3, - 10, - 0, - 1, - UI_TEMPLATE_LIST_FLAG_NONE); - - uiLayout *col = uiLayoutColumn(row, false); - uiLayout *sub = uiLayoutColumn(col, true); - uiItemO(sub, "", ICON_ADD, "OBJECT_OT_grease_pencil_dash_modifier_segment_add"); - uiItemO(sub, "", ICON_REMOVE, "OBJECT_OT_grease_pencil_dash_modifier_segment_remove"); - uiItemS(col); - sub = uiLayoutColumn(col, true); - uiItemEnumO_string( - sub, "", ICON_TRIA_UP, "OBJECT_OT_grease_pencil_dash_modifier_segment_move", "type", "UP"); - uiItemEnumO_string(sub, - "", - ICON_TRIA_DOWN, - "OBJECT_OT_grease_pencil_dash_modifier_segment_move", - "type", - "DOWN"); - - if (dmd->segment_active_index >= 0 && dmd->segment_active_index < dmd->segments_num) { - PointerRNA ds_ptr = RNA_pointer_create(ptr->owner_id, - &RNA_GreasePencilDashModifierSegment, - &dmd->segments()[dmd->segment_active_index]); - - sub = uiLayoutColumn(layout, true); - uiItemR(sub, &ds_ptr, "dash", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(sub, &ds_ptr, "gap", UI_ITEM_NONE, nullptr, ICON_NONE); - - sub = uiLayoutColumn(layout, false); - uiItemR(sub, &ds_ptr, "radius", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(sub, &ds_ptr, "opacity", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(sub, &ds_ptr, "material_index", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(sub, &ds_ptr, "use_cyclic", UI_ITEM_NONE, nullptr, ICON_NONE); - } - - if (uiLayout *influence_panel = uiLayoutPanelProp( - C, layout, ptr, "open_influence_panel", "Influence")) - { - modifier::greasepencil::draw_layer_filter_settings(C, influence_panel, ptr); - modifier::greasepencil::draw_material_filter_settings(C, influence_panel, ptr); - } - - modifier_panel_end(layout, ptr); -} - -static void segment_list_item_draw(uiList * /*ui_list*/, - const bContext * /*C*/, - uiLayout *layout, - PointerRNA * /*idataptr*/, - PointerRNA *itemptr, - int /*icon*/, - PointerRNA * /*active_dataptr*/, - const char * /*active_propname*/, - int /*index*/, - int /*flt_flag*/) -{ - uiLayout *row = uiLayoutRow(layout, true); - uiItemR(row, itemptr, "name", UI_ITEM_R_NO_BG, "", ICON_NONE); -} - -static void panel_register(ARegionType *region_type) -{ - modifier_panel_register(region_type, eModifierType_GreasePencilDash, panel_draw); - - uiListType *list_type = static_cast( - MEM_callocN(sizeof(uiListType), "Grease Pencil Dash modifier segments")); - STRNCPY(list_type->idname, "MOD_UL_grease_pencil_dash_modifier_segments"); - list_type->draw_item = segment_list_item_draw; - WM_uilisttype_add(list_type); -} - -static void blend_write(BlendWriter *writer, const ID * /*id_owner*/, const ModifierData *md) -{ - const auto *dmd = reinterpret_cast(md); - - BLO_write_struct(writer, GreasePencilDashModifierData, dmd); - modifier::greasepencil::write_influence_data(writer, &dmd->influence); - - BLO_write_struct_array( - writer, GreasePencilDashModifierSegment, dmd->segments_num, dmd->segments_array); -} - -static void blend_read(BlendDataReader *reader, ModifierData *md) -{ - auto *dmd = reinterpret_cast(md); - - modifier::greasepencil::read_influence_data(reader, &dmd->influence); - - BLO_read_data_address(reader, &dmd->segments_array); -} - -} // namespace blender - -ModifierTypeInfo modifierType_GreasePencilDash = { - /*idname*/ "GreasePencilDash", - /*name*/ N_("Dot Dash"), - /*struct_name*/ "GreasePencilDashModifierData", - /*struct_size*/ sizeof(GreasePencilDashModifierData), - /*srna*/ &RNA_GreasePencilDashModifierData, - /*type*/ ModifierTypeType::Nonconstructive, - /*flags*/ eModifierTypeFlag_AcceptsGreasePencil | eModifierTypeFlag_SupportsEditmode | - eModifierTypeFlag_EnableInEditmode | eModifierTypeFlag_SupportsMapping, - /*icon*/ ICON_MOD_DASH, - - /*copy_data*/ blender::copy_data, - - /*deform_verts*/ nullptr, - /*deform_matrices*/ nullptr, - /*deform_verts_EM*/ nullptr, - /*deform_matrices_EM*/ nullptr, - /*modify_mesh*/ nullptr, - /*modify_geometry_set*/ blender::modify_geometry_set, - - /*init_data*/ blender::init_data, - /*required_data_mask*/ nullptr, - /*free_data*/ blender::free_data, - /*is_disabled*/ blender::is_disabled, - /*update_depsgraph*/ nullptr, - /*depends_on_time*/ nullptr, - /*depends_on_normals*/ nullptr, - /*foreach_ID_link*/ blender::foreach_ID_link, - /*foreach_tex_link*/ nullptr, - /*free_runtime_data*/ nullptr, - /*panel_register*/ blender::panel_register, - /*blend_write*/ blender::blend_write, - /*blend_read*/ blender::blend_read, -}; - -blender::Span GreasePencilDashModifierData::segments() const -{ - return {this->segments_array, this->segments_num}; -} - -blender::MutableSpan GreasePencilDashModifierData::segments() -{ - return {this->segments_array, this->segments_num}; -} diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_lattice.cc b/source/blender/modifiers/intern/MOD_grease_pencil_lattice.cc deleted file mode 100644 index 7098cf6c70b..00000000000 --- a/source/blender/modifiers/intern/MOD_grease_pencil_lattice.cc +++ /dev/null @@ -1,232 +0,0 @@ -/* SPDX-FileCopyrightText: 2024 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup modifiers - */ - -#include "DNA_defaults.h" -#include "DNA_modifier_types.h" - -#include "BKE_curves.hh" -#include "BKE_geometry_set.hh" -#include "BKE_grease_pencil.hh" -#include "BKE_lattice.hh" -#include "BKE_lib_query.hh" -#include "BKE_modifier.hh" - -#include "BLO_read_write.hh" - -#include "UI_interface.hh" -#include "UI_resources.hh" - -#include "BLT_translation.hh" - -#include "WM_types.hh" - -#include "RNA_prototypes.h" - -#include "MOD_grease_pencil_util.hh" -#include "MOD_ui_common.hh" - -namespace blender { - -using bke::greasepencil::Drawing; -using bke::greasepencil::FramesMapKey; -using bke::greasepencil::Layer; - -static void init_data(ModifierData *md) -{ - auto *lmd = reinterpret_cast(md); - - BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(lmd, modifier)); - - MEMCPY_STRUCT_AFTER(lmd, DNA_struct_default_get(GreasePencilLatticeModifierData), modifier); - modifier::greasepencil::init_influence_data(&lmd->influence, false); -} - -static void copy_data(const ModifierData *md, ModifierData *target, const int flag) -{ - const auto *lmd = reinterpret_cast(md); - auto *tlmd = reinterpret_cast(target); - - modifier::greasepencil::free_influence_data(&tlmd->influence); - - BKE_modifier_copydata_generic(md, target, flag); - modifier::greasepencil::copy_influence_data(&lmd->influence, &tlmd->influence, flag); -} - -static void free_data(ModifierData *md) -{ - auto *lmd = reinterpret_cast(md); - modifier::greasepencil::free_influence_data(&lmd->influence); -} - -static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data) -{ - auto *lmd = reinterpret_cast(md); - modifier::greasepencil::foreach_influence_ID_link(&lmd->influence, ob, walk, user_data); - - walk(user_data, ob, (ID **)&lmd->object, IDWALK_CB_NOP); -} - -static void update_depsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) -{ - auto *lmd = reinterpret_cast(md); - if (lmd->object != nullptr) { - DEG_add_object_relation( - ctx->node, lmd->object, DEG_OB_COMP_TRANSFORM, "Grease Pencil Lattice Modifier"); - DEG_add_object_relation( - ctx->node, lmd->object, DEG_OB_COMP_GEOMETRY, "Grease Pencil Lattice Modifier"); - } - DEG_add_depends_on_transform_relation(ctx->node, "Grease Pencil Lattice Modifier"); -} - -static bool is_disabled(const Scene * /*scene*/, ModifierData *md, bool /*use_render_params*/) -{ - auto *lmd = reinterpret_cast(md); - - /* The object type check is only needed here in case we have a placeholder - * object assigned (because the library containing the lattice is missing). - * - * In other cases it should be impossible to have a type mismatch. - */ - return lmd->object == nullptr || lmd->object->type != OB_LATTICE; -} - -static void modify_curves(ModifierData *md, - const ModifierEvalContext *ctx, - const LatticeDeformData &cache_data, - Drawing &drawing) -{ - const auto *lmd = reinterpret_cast(md); - bke::CurvesGeometry &curves = drawing.strokes_for_write(); - - IndexMaskMemory mask_memory; - const IndexMask curves_mask = modifier::greasepencil::get_filtered_stroke_mask( - ctx->object, curves, lmd->influence, mask_memory); - - const OffsetIndices points_by_curve = curves.points_by_curve(); - MutableSpan positions = curves.positions_for_write(); - const VArray vgroup_weights = modifier::greasepencil::get_influence_vertex_weights( - curves, lmd->influence); - - curves_mask.foreach_index(GrainSize(512), [&](const int64_t curve_i) { - const IndexRange points = points_by_curve[curve_i]; - for (const int64_t point_i : points) { - const float weight = vgroup_weights[point_i]; - BKE_lattice_deform_data_eval_co(const_cast(&cache_data), - positions[point_i], - lmd->strength * weight); - } - }); - - drawing.tag_positions_changed(); -} - -static void modify_geometry_set(ModifierData *md, - const ModifierEvalContext *ctx, - bke::GeometrySet *geometry_set) -{ - const auto *lmd = reinterpret_cast(md); - BLI_assert(lmd->object != nullptr && lmd->object->type == OB_LATTICE); - LatticeDeformData *cache_data = BKE_lattice_deform_data_create(lmd->object, ctx->object); - - if (!geometry_set->has_grease_pencil()) { - return; - } - GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write(); - - IndexMaskMemory mask_memory; - const IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask( - grease_pencil, lmd->influence, mask_memory); - const int frame = grease_pencil.runtime->eval_frame; - const Vector drawings = modifier::greasepencil::get_drawings_for_write( - grease_pencil, layer_mask, frame); - threading::parallel_for_each( - drawings, [&](Drawing *drawing) { modify_curves(md, ctx, *cache_data, *drawing); }); - - BKE_lattice_deform_data_destroy(cache_data); -} - -static void panel_draw(const bContext *C, Panel *panel) -{ - uiLayout *layout = panel->layout; - - PointerRNA ob_ptr; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); - - uiLayoutSetPropSep(layout, true); - - uiItemR(layout, ptr, "object", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(layout, ptr, "strength", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); - - if (uiLayout *influence_panel = uiLayoutPanelProp( - C, layout, ptr, "open_influence_panel", "Influence")) - { - modifier::greasepencil::draw_layer_filter_settings(C, influence_panel, ptr); - modifier::greasepencil::draw_material_filter_settings(C, influence_panel, ptr); - modifier::greasepencil::draw_vertex_group_settings(C, influence_panel, ptr); - } - - modifier_panel_end(layout, ptr); -} - -static void panel_register(ARegionType *region_type) -{ - modifier_panel_register(region_type, eModifierType_GreasePencilLattice, panel_draw); -} - -static void blend_write(BlendWriter *writer, const ID * /*id_owner*/, const ModifierData *md) -{ - const auto *lmd = reinterpret_cast(md); - - BLO_write_struct(writer, GreasePencilLatticeModifierData, lmd); - modifier::greasepencil::write_influence_data(writer, &lmd->influence); -} - -static void blend_read(BlendDataReader *reader, ModifierData *md) -{ - auto *lmd = reinterpret_cast(md); - - modifier::greasepencil::read_influence_data(reader, &lmd->influence); -} - -} // namespace blender - -ModifierTypeInfo modifierType_GreasePencilLattice = { - /*idname*/ "GreasePencilLattice", - /*name*/ N_("Lattice"), - /*struct_name*/ "GreasePencilLatticeModifierData", - /*struct_size*/ sizeof(GreasePencilLatticeModifierData), - /*srna*/ &RNA_GreasePencilLatticeModifier, - /*type*/ ModifierTypeType::OnlyDeform, - /*flags*/ eModifierTypeFlag_AcceptsGreasePencil | eModifierTypeFlag_SupportsEditmode | - eModifierTypeFlag_EnableInEditmode | eModifierTypeFlag_SupportsMapping, - /*icon*/ ICON_MOD_LATTICE, - - /*copy_data*/ blender::copy_data, - - /*deform_verts*/ nullptr, - /*deform_matrices*/ nullptr, - /*deform_verts_EM*/ nullptr, - /*deform_matrices_EM*/ nullptr, - /*modify_mesh*/ nullptr, - /*modify_geometry_set*/ blender::modify_geometry_set, - - /*init_data*/ blender::init_data, - /*required_data_mask*/ nullptr, - /*free_data*/ blender::free_data, - /*is_disabled*/ blender::is_disabled, - /*update_depsgraph*/ blender::update_depsgraph, - /*depends_on_time*/ nullptr, - /*depends_on_normals*/ nullptr, - /*foreach_ID_link*/ blender::foreach_ID_link, - /*foreach_tex_link*/ nullptr, - /*free_runtime_data*/ nullptr, - /*panel_register*/ blender::panel_register, - /*blend_write*/ blender::blend_write, - /*blend_read*/ blender::blend_read, - /*foreach_cache*/ nullptr, -}; diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_length.cc b/source/blender/modifiers/intern/MOD_grease_pencil_length.cc deleted file mode 100644 index 7a98ae38273..00000000000 --- a/source/blender/modifiers/intern/MOD_grease_pencil_length.cc +++ /dev/null @@ -1,375 +0,0 @@ -/* SPDX-FileCopyrightText: 2005 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup modifiers - */ - -#include "BLI_hash.h" -#include "BLI_rand.h" -#include "BLI_task.h" - -#include "BLT_translation.hh" - -#include "BLO_read_write.hh" - -#include "DNA_defaults.h" -#include "DNA_gpencil_modifier_types.h" -#include "DNA_node_types.h" /* For `GeometryNodeCurveSampleMode` */ -#include "DNA_object_types.h" - -#include "BKE_curves.hh" -#include "BKE_geometry_set.hh" -#include "BKE_grease_pencil.hh" -#include "BKE_lib_query.hh" -#include "BKE_modifier.hh" - -#include "UI_interface.hh" -#include "UI_resources.hh" - -#include "MOD_grease_pencil_util.hh" -#include "MOD_modifiertypes.hh" -#include "MOD_ui_common.hh" - -#include "RNA_access.hh" -#include "RNA_prototypes.h" - -#include "GEO_extend_curves.hh" -#include "GEO_trim_curves.hh" - -namespace blender { - -static void init_data(ModifierData *md) -{ - GreasePencilLengthModifierData *gpmd = reinterpret_cast(md); - - BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier)); - - MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(GreasePencilLengthModifierData), modifier); - modifier::greasepencil::init_influence_data(&gpmd->influence, true); -} - -static void copy_data(const ModifierData *md, ModifierData *target, int flags) -{ - const auto *omd = reinterpret_cast(md); - auto *tomd = reinterpret_cast(target); - - modifier::greasepencil::free_influence_data(&tomd->influence); - - BKE_modifier_copydata_generic(md, target, flags); - modifier::greasepencil::copy_influence_data(&omd->influence, &tomd->influence, flags); -} - -static void free_data(ModifierData *md) -{ - auto *omd = reinterpret_cast(md); - modifier::greasepencil::free_influence_data(&omd->influence); -} - -static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data) -{ - auto *omd = reinterpret_cast(md); - modifier::greasepencil::foreach_influence_ID_link(&omd->influence, ob, walk, user_data); -} - -static void blend_write(BlendWriter *writer, const ID * /*id_owner*/, const ModifierData *md) -{ - const GreasePencilLengthModifierData *mmd = - reinterpret_cast(md); - - BLO_write_struct(writer, GreasePencilLengthModifierData, mmd); - modifier::greasepencil::write_influence_data(writer, &mmd->influence); -} - -static void blend_read(BlendDataReader *reader, ModifierData *md) -{ - GreasePencilLengthModifierData *mmd = reinterpret_cast(md); - - modifier::greasepencil::read_influence_data(reader, &mmd->influence); -} - -static Array noise_table(int len, int offset, int seed) -{ - Array table(len); - for (const int i : table.index_range()) { - table[i] = BLI_hash_int_01(BLI_hash_int_2d(seed, i + offset + 1)); - } - return table; -} - -static float table_sample(MutableSpan table, float x) -{ - return math::interpolate(table[int(math::ceil(x))], table[int(math::floor(x))], math::fract(x)); -} - -static void deform_drawing(const ModifierData &md, - const Object &ob, - bke::greasepencil::Drawing &drawing, - const int current_time) -{ - const GreasePencilLengthModifierData &mmd = - reinterpret_cast(md); - bke::CurvesGeometry &curves = drawing.strokes_for_write(); - - if (curves.points_num() == 0) { - return; - } - - IndexMaskMemory memory; - const IndexMask selection = modifier::greasepencil::get_filtered_stroke_mask( - &ob, curves, mmd.influence, memory); - - const int curves_num = curves.curves_num(); - - /* Variable for tagging shrinking when values are adjusted after random. */ - std::atomic needs_additional_shrinking = false; - - VArray use_starts = VArray::ForSingle(mmd.start_fac, curves_num); - VArray use_ends = VArray::ForSingle(mmd.end_fac, curves_num); - - if (mmd.rand_start_fac != 0.0 || mmd.rand_end_fac != 0.0) { - /* Use random to modify start/end factors. Put the modified values outside the - * branch so it could be accessed in later stretching/shrinking stages. */ - Array modified_starts(curves.curves_num(), mmd.start_fac); - Array modified_ends(curves.curves_num(), mmd.end_fac); - use_starts = VArray::ForSpan(modified_starts.as_mutable_span()); - use_ends = VArray::ForSpan(modified_ends.as_mutable_span()); - - int seed = mmd.seed; - - /* Make sure different modifiers get different seeds. */ - seed += BLI_hash_string(ob.id.name + 2); - seed += BLI_hash_string(md.name); - - if (mmd.flag & GP_LENGTH_USE_RANDOM) { - seed += current_time / mmd.step; - } - - float rand_offset = BLI_hash_int_01(seed); - - Array noise_table_length = noise_table( - 4 + curves_num, int(math::floor(mmd.rand_offset)), seed + 2); - - threading::parallel_for(IndexRange(curves_num), 512, [&](const IndexRange parallel_range) { - for (const int i : parallel_range) { - /* To ensure a nice distribution, we use halton sequence and offset using the seed. */ - double r[2]; - const uint primes[2] = {2, 3}; - double offset[2] = {0.0f, 0.0f}; - BLI_halton_2d(primes, offset, i, r); - - float rand[2] = {0.0f, 0.0f}; - for (int j = 0; j < 2; j++) { - float noise = table_sample(noise_table_length, i + j * 2 + math::fract(mmd.rand_offset)); - - rand[j] = math::mod(float(r[j] + rand_offset), 1.0f); - rand[j] = math::abs( - math::mod(sin(rand[j] * 12.9898f + j * 78.233f) * 43758.5453f, 1.0f) + noise); - } - - modified_starts[i] = modified_starts[i] + rand[0] * mmd.rand_start_fac; - modified_ends[i] = modified_ends[i] + rand[1] * mmd.rand_end_fac; - - if (modified_starts[i] <= 0.0f || modified_ends[i] <= 0.0f) { - needs_additional_shrinking.store(true, std::memory_order_relaxed); - } - } - }); - } - - curves = geometry::extend_curves(curves, - selection, - use_starts, - use_ends, - mmd.overshoot_fac, - (mmd.flag & GP_LENGTH_USE_CURVATURE) != 0, - mmd.point_density, - mmd.segment_influence, - mmd.max_angle, - (mmd.flag & GP_LENGTH_INVERT_CURVATURE) != 0, - ((mmd.mode & GP_LENGTH_ABSOLUTE) != 0) ? - GEO_NODE_CURVE_SAMPLE_LENGTH : - GEO_NODE_CURVE_SAMPLE_FACTOR, - {}); - - /* Always do the stretching first since it might depend on points which could be deleted by the - * shrink. */ - if (mmd.start_fac < 0.0f || mmd.end_fac < 0.0f || needs_additional_shrinking) { - /* #trim_curves() accepts the `end` values if it's sampling from the beginning of the - * curve, so we need to get the lengths of the curves and subtract it from the back when the - * modifier is in Absolute mode. For convenience, we always call #trim_curves() in LENGTH - * mode since the function itself will need length to be sampled anyway. */ - Array starts(curves.curves_num()); - Array ends(curves.curves_num()); - Array needs_removal(curves.curves_num()); - needs_removal.fill(false); - - curves.ensure_evaluated_lengths(); - - threading::parallel_for(curves.curves_range(), 512, [&](const IndexRange parallel_range) { - for (const int curve : parallel_range) { - float length = curves.evaluated_length_total_for_curve(curve, false); - if (mmd.mode & GP_LENGTH_ABSOLUTE) { - starts[curve] = -math::min(use_starts[curve], 0.0f); - ends[curve] = length - (-math::min(use_ends[curve], 0.0f)); - } - else { - starts[curve] = -math::min(use_starts[curve], 0.0f) * length; - ends[curve] = (1 + math::min(use_ends[curve], 0.0f)) * length; - } - if (starts[curve] > ends[curve]) { - needs_removal[curve] = true; - } - } - }); - curves = geometry::trim_curves(curves, - selection, - VArray::ForSpan(starts.as_span()), - VArray::ForSpan(ends.as_span()), - GEO_NODE_CURVE_SAMPLE_LENGTH, - {}); - - /* #trim_curves() will leave the last segment there when trimmed length is greater than - * curve original length, thus we need to remove those curves afterwards. */ - IndexMaskMemory memory_remove; - const IndexMask to_remove = IndexMask::from_bools(needs_removal.as_span(), memory_remove); - if (!to_remove.is_empty()) { - curves.remove_curves(to_remove, {}); - } - } - - drawing.tag_topology_changed(); -} - -static void modify_geometry_set(ModifierData *md, - const ModifierEvalContext *ctx, - blender::bke::GeometrySet *geometry_set) -{ - GreasePencilLengthModifierData *mmd = reinterpret_cast(md); - - if (!geometry_set->has_grease_pencil()) { - return; - } - - GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write(); - - IndexMaskMemory mask_memory; - const IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask( - grease_pencil, mmd->influence, mask_memory); - const Vector drawings = - modifier::greasepencil::get_drawings_for_write( - grease_pencil, layer_mask, grease_pencil.runtime->eval_frame); - - threading::parallel_for_each(drawings, [&](bke::greasepencil::Drawing *drawing) { - deform_drawing(*md, *ctx->object, *drawing, grease_pencil.runtime->eval_frame); - }); -} - -static void panel_draw(const bContext *C, Panel *panel) -{ - uiLayout *layout = panel->layout; - - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); - - uiLayoutSetPropSep(layout, true); - uiItemR(layout, ptr, "mode", UI_ITEM_NONE, nullptr, ICON_NONE); - - uiLayout *col = uiLayoutColumn(layout, true); - - if (RNA_enum_get(ptr, "mode") == GP_LENGTH_RELATIVE) { - uiItemR(col, ptr, "start_factor", UI_ITEM_NONE, IFACE_("Start"), ICON_NONE); - uiItemR(col, ptr, "end_factor", UI_ITEM_NONE, IFACE_("End"), ICON_NONE); - } - else { - uiItemR(col, ptr, "start_length", UI_ITEM_NONE, IFACE_("Start"), ICON_NONE); - uiItemR(col, ptr, "end_length", UI_ITEM_NONE, IFACE_("End"), ICON_NONE); - } - - uiItemR(layout, ptr, "overshoot_factor", UI_ITEM_R_SLIDER, IFACE_("Used Length"), ICON_NONE); - - if (uiLayout *random_layout = uiLayoutPanelProp( - C, layout, ptr, "open_random_panel", "Randomize")) - { - uiItemR(random_layout, ptr, "use_random", UI_ITEM_NONE, IFACE_("Randomize"), ICON_NONE); - - uiLayout *subcol = uiLayoutColumn(random_layout, false); - uiLayoutSetPropSep(subcol, true); - uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "use_random")); - - uiItemR(subcol, ptr, "step", UI_ITEM_NONE, nullptr, ICON_NONE); - - uiItemR(subcol, ptr, "random_start_factor", UI_ITEM_NONE, IFACE_("Offset Start"), ICON_NONE); - uiItemR(subcol, ptr, "random_end_factor", UI_ITEM_NONE, IFACE_("End"), ICON_NONE); - uiItemR(subcol, ptr, "random_offset", UI_ITEM_NONE, IFACE_("Noise Offset"), ICON_NONE); - uiItemR(subcol, ptr, "seed", UI_ITEM_NONE, nullptr, ICON_NONE); - } - - if (uiLayout *curvature_layout = uiLayoutPanelProp( - C, layout, ptr, "open_curvature_panel", "Curvature")) - { - uiItemR(curvature_layout, ptr, "use_curvature", UI_ITEM_NONE, IFACE_("Curvature"), ICON_NONE); - - uiLayout *subcol = uiLayoutColumn(curvature_layout, false); - uiLayoutSetPropSep(subcol, true); - uiLayoutSetActive(subcol, RNA_boolean_get(ptr, "use_curvature")); - - uiItemR(subcol, ptr, "point_density", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(subcol, ptr, "segment_influence", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(subcol, ptr, "max_angle", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(subcol, ptr, "invert_curvature", UI_ITEM_NONE, IFACE_("Invert"), ICON_NONE); - } - - if (uiLayout *influence_panel = uiLayoutPanelProp( - C, layout, ptr, "open_influence_panel", "Influence")) - { - modifier::greasepencil::draw_layer_filter_settings(C, influence_panel, ptr); - modifier::greasepencil::draw_material_filter_settings(C, influence_panel, ptr); - modifier::greasepencil::draw_vertex_group_settings(C, influence_panel, ptr); - } - - modifier_panel_end(layout, ptr); -} - -static void panel_register(ARegionType *region_type) -{ - modifier_panel_register(region_type, eModifierType_GreasePencilLength, panel_draw); -} - -} // namespace blender - -ModifierTypeInfo modifierType_GreasePencilLength = { - /*idname*/ "GreasePencilLengthModifier", - /*name*/ N_("Length"), - /*struct_name*/ "GreasePencilLengthModifierData", - /*struct_size*/ sizeof(GreasePencilLengthModifierData), - /*srna*/ &RNA_GreasePencilLengthModifier, - /*type*/ ModifierTypeType::Nonconstructive, - /*flags*/ - eModifierTypeFlag_AcceptsGreasePencil | eModifierTypeFlag_EnableInEditmode | - eModifierTypeFlag_SupportsEditmode, - /*icon*/ ICON_MOD_LENGTH, - - /*copy_data*/ blender::copy_data, - - /*deform_verts*/ nullptr, - /*deform_matrices*/ nullptr, - /*deform_verts_EM*/ nullptr, - /*deform_matrices_EM*/ nullptr, - /*modify_mesh*/ nullptr, - /*modify_geometry_set*/ blender::modify_geometry_set, - - /*init_data*/ blender::init_data, - /*required_data_mask*/ nullptr, - /*free_data*/ blender::free_data, - /*is_disabled*/ nullptr, - /*update_depsgraph*/ nullptr, - /*depends_on_time*/ nullptr, - /*depends_on_normals*/ nullptr, - /*foreach_ID_link*/ blender::foreach_ID_link, - /*foreach_tex_link*/ nullptr, - /*free_runtime_data*/ nullptr, - /*panel_register*/ blender::panel_register, - /*blend_write*/ blender::blend_write, - /*blend_read*/ blender::blend_read, -}; diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_mirror.cc b/source/blender/modifiers/intern/MOD_grease_pencil_mirror.cc index ee29e1af183..e2d307ea6a0 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_mirror.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_mirror.cc @@ -14,7 +14,9 @@ #include "BKE_grease_pencil.hh" #include "BKE_instances.hh" #include "BKE_lib_query.hh" +#include "BKE_material.h" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "BLO_read_write.hh" @@ -23,13 +25,15 @@ #include "UI_interface.hh" #include "UI_resources.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "WM_types.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "MOD_grease_pencil_util.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" namespace blender { @@ -89,7 +93,8 @@ static float4x4 get_mirror_matrix(const Object &ob, if (mmd.object) { /* Transforms from parent object space to target object space. */ - const float4x4 to_target = math::invert(mmd.object->object_to_world()) * ob.object_to_world(); + const float4x4 to_target = math::invert(float4x4(mmd.object->object_to_world)) * + float4x4(ob.object_to_world); /* Mirror points in the target object space. */ matrix = math::invert(to_target) * matrix * to_target; } diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_multiply.cc b/source/blender/modifiers/intern/MOD_grease_pencil_multiply.cc deleted file mode 100644 index e5aa4445705..00000000000 --- a/source/blender/modifiers/intern/MOD_grease_pencil_multiply.cc +++ /dev/null @@ -1,329 +0,0 @@ -/* SPDX-FileCopyrightText: 2024 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup modifiers - */ - -#include "MEM_guardedalloc.h" - -#include "BLI_math_matrix.hh" - -#include "DNA_defaults.h" -#include "DNA_material_types.h" -#include "DNA_modifier_types.h" -#include "DNA_scene_types.h" - -#include "BKE_attribute.hh" -#include "BKE_curves.hh" -#include "BKE_geometry_set.hh" -#include "BKE_grease_pencil.hh" -#include "BKE_instances.hh" -#include "BKE_lib_query.hh" -#include "BKE_material.h" -#include "BKE_modifier.hh" -#include "BKE_screen.hh" - -#include "BLO_read_write.hh" - -#include "DEG_depsgraph_query.hh" - -#include "GEO_realize_instances.hh" - -#include "UI_interface.hh" -#include "UI_resources.hh" - -#include "BLT_translation.hh" - -#include "WM_types.hh" - -#include "RNA_access.hh" -#include "RNA_enum_types.hh" -#include "RNA_prototypes.h" - -#include "MOD_grease_pencil_util.hh" -#include "MOD_modifiertypes.hh" -#include "MOD_ui_common.hh" - -namespace blender { - -using bke::greasepencil::Drawing; - -static void init_data(ModifierData *md) -{ - auto *mmd = reinterpret_cast(md); - - BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(mmd, modifier)); - - MEMCPY_STRUCT_AFTER(mmd, DNA_struct_default_get(GreasePencilMultiModifierData), modifier); - modifier::greasepencil::init_influence_data(&mmd->influence, true); -} - -static void copy_data(const ModifierData *md, ModifierData *target, const int flag) -{ - const auto *mmd = reinterpret_cast(md); - auto *tmmd = reinterpret_cast(target); - - BKE_modifier_copydata_generic(md, target, flag); - modifier::greasepencil::copy_influence_data(&mmd->influence, &tmmd->influence, flag); -} - -static void free_data(ModifierData *md) -{ - auto *mmd = reinterpret_cast(md); - modifier::greasepencil::free_influence_data(&mmd->influence); -} - -static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data) -{ - auto *mmd = reinterpret_cast(md); - modifier::greasepencil::foreach_influence_ID_link(&mmd->influence, ob, walk, user_data); -} - -static bool is_disabled(const Scene * /*scene*/, ModifierData *md, bool /*use_render_params*/) -{ - auto *mmd = reinterpret_cast(md); - if (mmd->duplications <= 1) { - return true; - } - return false; -} - -static bke::CurvesGeometry duplicate_strokes(const bke::CurvesGeometry &curves, - const IndexMask curves_mask, - const IndexMask unselected_mask, - const int count, - int &r_original_point_count) -{ - bke::CurvesGeometry masked_curves = bke::curves_copy_curve_selection(curves, curves_mask, {}); - bke::CurvesGeometry unselected_curves = bke::curves_copy_curve_selection( - curves, unselected_mask, {}); - - r_original_point_count = masked_curves.points_num(); - - Curves *masked_curves_id = bke::curves_new_nomain(masked_curves); - Curves *unselected_curves_id = bke::curves_new_nomain(unselected_curves); - - bke::GeometrySet masked_geo = bke::GeometrySet::from_curves(masked_curves_id); - bke::GeometrySet unselected_geo = bke::GeometrySet::from_curves(unselected_curves_id); - - std::unique_ptr instances = std::make_unique(); - const int masked_handle = instances->add_reference(bke::InstanceReference{masked_geo}); - const int unselected_handle = instances->add_reference(bke::InstanceReference{unselected_geo}); - - for ([[maybe_unused]] const int i : IndexRange(count)) { - instances->add_instance(masked_handle, float4x4::identity()); - } - instances->add_instance(unselected_handle, float4x4::identity()); - - geometry::RealizeInstancesOptions options; - options.keep_original_ids = true; - options.realize_instance_attributes = true; - options.propagation_info = {}; - bke::GeometrySet result_geo = geometry::realize_instances( - bke::GeometrySet::from_instances(instances.release()), options); - return std::move(result_geo.get_curves_for_write()->geometry.wrap()); -} - -static void generate_curves(GreasePencilMultiModifierData &mmd, - const ModifierEvalContext &ctx, - Drawing &drawing) -{ - bke::CurvesGeometry &curves = drawing.strokes_for_write(); - - IndexMaskMemory mask_memory; - const IndexMask curves_mask = modifier::greasepencil::get_filtered_stroke_mask( - ctx.object, curves, mmd.influence, mask_memory); - - if (curves_mask.is_empty()) { - return; - } - - const IndexMask unselected_mask = curves_mask.complement(curves.curves_range(), mask_memory); - - int src_point_count; - bke::CurvesGeometry duplicated_strokes = duplicate_strokes( - curves, curves_mask, unselected_mask, mmd.duplications, src_point_count); - - const float offset = math::length(math::to_scale(ctx.object->object_to_world())) * mmd.offset; - const float distance = mmd.distance; - const bool use_fading = (mmd.flag & MOD_GREASE_PENCIL_MULTIPLY_ENABLE_FADING) != 0; - const float fading_thickness = mmd.fading_thickness; - const float fading_opacity = mmd.fading_opacity; - const float fading_center = mmd.fading_center; - - MutableSpan positions = duplicated_strokes.positions_for_write(); - const Span tangents = duplicated_strokes.evaluated_tangents(); - const Span normals = drawing.curve_plane_normals(); - - bke::MutableAttributeAccessor attributes = duplicated_strokes.attributes_for_write(); - bke::SpanAttributeWriter opacities = attributes.lookup_or_add_for_write_span( - "opacity", bke::AttrDomain::Point); - bke::SpanAttributeWriter radii = attributes.lookup_or_add_for_write_span( - "radius", bke::AttrDomain::Point); - - const OffsetIndices points_by_curve = curves.points_by_curve(); - - Array pos_l(src_point_count); - Array pos_r(src_point_count); - - threading::parallel_for(curves.curves_range(), 128, [&](const IndexRange range) { - for (const int curve : range) { - for (const int point : points_by_curve[curve]) { - const float3 miter = math::cross(normals[curve], tangents[point]) * distance; - pos_l[point] = positions[point] + miter; - pos_r[point] = positions[point] - miter; - } - } - }); - - const Span stroke_pos_l = pos_l.as_span(); - const Span stroke_pos_r = pos_r.as_span(); - - for (const int i : IndexRange(mmd.duplications)) { - using bke::attribute_math::mix2; - const IndexRange stroke = IndexRange(src_point_count * i, src_point_count); - MutableSpan instance_positions = positions.slice(stroke); - MutableSpan instance_opacity = opacities.span.slice(stroke); - MutableSpan instance_radii = radii.span.slice(stroke); - const float offset_fac = (mmd.duplications == 1) ? - 0.5f : - (1.0f - (float(i) / float(mmd.duplications - 1))); - const float fading_fac = fabsf(offset_fac - fading_center); - const float thickness_factor = use_fading ? mix2(fading_fac, 1.0f, 1.0f - fading_thickness) : - 1.0f; - const float opacity_factor = use_fading ? mix2(fading_fac, 1.0f, 1.0f - fading_opacity) : 1.0f; - threading::parallel_for(instance_positions.index_range(), 512, [&](const IndexRange range) { - for (const int point : range) { - const float fac = mix2(float(i) / float(mmd.duplications - 1), 1 + offset, offset); - const int old_point = point % src_point_count; - instance_positions[point] = mix2(fac, stroke_pos_l[old_point], stroke_pos_r[old_point]); - instance_radii[point] *= thickness_factor; - instance_opacity[point] *= opacity_factor; - } - }); - } - - radii.finish(); - opacities.finish(); - - curves = std::move(duplicated_strokes); - drawing.tag_topology_changed(); -} - -static void modify_geometry_set(ModifierData *md, - const ModifierEvalContext *ctx, - bke::GeometrySet *geometry_set) -{ - auto *mmd = reinterpret_cast(md); - - if (!geometry_set->has_grease_pencil()) { - return; - } - GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write(); - const int frame = grease_pencil.runtime->eval_frame; - - IndexMaskMemory memory; - const IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask( - grease_pencil, mmd->influence, memory); - const Vector drawings = modifier::greasepencil::get_drawings_for_write( - grease_pencil, layer_mask, frame); - threading::parallel_for_each(drawings, - [&](Drawing *drawing) { generate_curves(*mmd, *ctx, *drawing); }); -} - -static void panel_draw(const bContext *C, Panel *panel) -{ - uiLayout *layout = panel->layout; - - PointerRNA ob_ptr; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); - - uiLayoutSetPropSep(layout, true); - - uiItemR(layout, ptr, "duplicates", UI_ITEM_NONE, nullptr, ICON_NONE); - - uiLayout *col = uiLayoutColumn(layout, false); - uiLayoutSetActive(col, RNA_int_get(ptr, "duplicates") > 0); - uiItemR(col, ptr, "distance", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(col, ptr, "offset", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); - - if (uiLayout *fade_panel = uiLayoutPanelProp(C, layout, ptr, "open_fading_panel", "Fade")) { - uiLayoutSetPropSep(fade_panel, true); - uiItemR(fade_panel, ptr, "use_fade", UI_ITEM_NONE, nullptr, ICON_NONE); - - uiLayout *sub = uiLayoutColumn(fade_panel, false); - uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_fade")); - - uiItemR(sub, ptr, "fading_center", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(sub, ptr, "fading_thickness", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); - uiItemR(sub, ptr, "fading_opacity", UI_ITEM_R_SLIDER, nullptr, ICON_NONE); - } - - if (uiLayout *influence_panel = uiLayoutPanelProp( - C, layout, ptr, "open_influence_panel", "Influence")) - { - modifier::greasepencil::draw_layer_filter_settings(C, influence_panel, ptr); - modifier::greasepencil::draw_material_filter_settings(C, influence_panel, ptr); - } - - modifier_panel_end(layout, ptr); -} - -static void panel_register(ARegionType *region_type) -{ - modifier_panel_register(region_type, eModifierType_GreasePencilMultiply, panel_draw); -} - -static void blend_write(BlendWriter *writer, const ID * /*id_owner*/, const ModifierData *md) -{ - const auto *mmd = reinterpret_cast(md); - - BLO_write_struct(writer, GreasePencilMultiModifierData, mmd); - modifier::greasepencil::write_influence_data(writer, &mmd->influence); -} - -static void blend_read(BlendDataReader *reader, ModifierData *md) -{ - auto *mmd = reinterpret_cast(md); - - modifier::greasepencil::read_influence_data(reader, &mmd->influence); -} - -} // namespace blender - -ModifierTypeInfo modifierType_GreasePencilMultiply = { - /*idname*/ "GreasePencilMultiply", - /*name*/ N_("Multiple Strokes"), - /*struct_name*/ "GreasePencilMultiModifierData", - /*struct_size*/ sizeof(GreasePencilMultiModifierData), - /*srna*/ &RNA_GreasePencilMultiplyModifier, - /*type*/ ModifierTypeType::Constructive, - /*flags*/ eModifierTypeFlag_AcceptsGreasePencil | eModifierTypeFlag_SupportsEditmode | - eModifierTypeFlag_EnableInEditmode | eModifierTypeFlag_SupportsMapping, - /*icon*/ ICON_MOD_CURVE, - - /*copy_data*/ blender::copy_data, - - /*deform_verts*/ nullptr, - /*deform_matrices*/ nullptr, - /*deform_verts_EM*/ nullptr, - /*deform_matrices_EM*/ nullptr, - /*modify_mesh*/ nullptr, - /*modify_geometry_set*/ blender::modify_geometry_set, - - /*init_data*/ blender::init_data, - /*required_data_mask*/ nullptr, - /*free_data*/ blender::free_data, - /*is_disabled*/ blender::is_disabled, - /*update_depsgraph*/ nullptr, - /*depends_on_time*/ nullptr, - /*depends_on_normals*/ nullptr, - /*foreach_ID_link*/ blender::foreach_ID_link, - /*foreach_tex_link*/ nullptr, - /*free_runtime_data*/ nullptr, - /*panel_register*/ blender::panel_register, - /*blend_write*/ blender::blend_write, - /*blend_read*/ blender::blend_read, -}; diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_noise.cc b/source/blender/modifiers/intern/MOD_grease_pencil_noise.cc index 5850b3866bc..160a745279b 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_noise.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_noise.cc @@ -9,7 +9,7 @@ #include "BLI_hash.h" #include "BLI_math_vector.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLO_read_write.hh" @@ -25,6 +25,7 @@ #include "UI_resources.hh" #include "MOD_grease_pencil_util.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "RNA_access.hh" diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_offset.cc b/source/blender/modifiers/intern/MOD_grease_pencil_offset.cc index a5399231c21..2ab2cb495f0 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_offset.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_offset.cc @@ -25,7 +25,7 @@ #include "UI_interface.hh" #include "UI_resources.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "WM_types.hh" diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_opacity.cc b/source/blender/modifiers/intern/MOD_grease_pencil_opacity.cc index 74c1088e785..2879d271c5d 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_opacity.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_opacity.cc @@ -8,26 +8,30 @@ #include "DNA_defaults.h" #include "DNA_modifier_types.h" +#include "DNA_scene_types.h" #include "BKE_colortools.hh" #include "BKE_curves.hh" #include "BKE_geometry_set.hh" #include "BKE_grease_pencil.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "BLO_read_write.hh" #include "UI_interface.hh" #include "UI_resources.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "WM_types.hh" #include "RNA_access.hh" +#include "RNA_enum_types.hh" #include "RNA_prototypes.h" #include "MOD_grease_pencil_util.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" namespace blender { @@ -157,10 +161,10 @@ static void modify_hardness(const GreasePencilOpacityModifierData &omd, const IndexMask &curves_mask) { bke::MutableAttributeAccessor attributes = curves.attributes_for_write(); - bke::SpanAttributeWriter hardnesses = attributes.lookup_or_add_for_write_span( - "hardness", - bke::AttrDomain::Curve, - bke::AttributeInitVArray(VArray::ForSingle(1.0f, curves.curve_num))); + bke::SpanAttributeWriter hardnesses = attributes.lookup_for_write_span("hardness"); + if (!hardnesses) { + return; + } curves_mask.foreach_index(GrainSize(512), [&](int64_t curve_i) { hardnesses.span[curve_i] = std::clamp( diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_smooth.cc b/source/blender/modifiers/intern/MOD_grease_pencil_smooth.cc index 72671bd78c6..fdc3427730c 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_smooth.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_smooth.cc @@ -8,7 +8,7 @@ #include "BLI_index_mask.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLO_read_write.hh" @@ -21,6 +21,7 @@ #include "BKE_curves.hh" #include "BKE_geometry_set.hh" #include "BKE_grease_pencil.hh" +#include "BKE_lib_query.hh" #include "BKE_modifier.hh" #include "UI_interface.hh" @@ -29,6 +30,7 @@ #include "GEO_smooth_curves.hh" #include "MOD_grease_pencil_util.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "RNA_prototypes.h" diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_subdiv.cc b/source/blender/modifiers/intern/MOD_grease_pencil_subdiv.cc index 6431d4d7d48..0dc6209abf3 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_subdiv.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_subdiv.cc @@ -8,7 +8,7 @@ #include "BLI_index_mask.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLO_read_write.hh" @@ -26,6 +26,7 @@ #include "UI_resources.hh" #include "MOD_grease_pencil_util.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "RNA_prototypes.h" diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_thickness.cc b/source/blender/modifiers/intern/MOD_grease_pencil_thickness.cc index 6c669e60d42..cfff04dc4b2 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_thickness.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_thickness.cc @@ -8,7 +8,7 @@ #include "BLI_index_mask.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLO_read_write.hh" @@ -22,12 +22,14 @@ #include "BKE_curves.hh" #include "BKE_geometry_set.hh" #include "BKE_grease_pencil.hh" +#include "BKE_lib_query.hh" #include "BKE_modifier.hh" #include "UI_interface.hh" #include "UI_resources.hh" #include "MOD_grease_pencil_util.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "RNA_prototypes.h" diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc b/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc index 70d13bfcd9a..6dd6205bb0d 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc @@ -31,7 +31,7 @@ #include "UI_interface.hh" #include "UI_resources.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "WM_types.hh" @@ -217,7 +217,8 @@ static void modify_stroke_color(Object &ob, const OffsetIndices points_by_curve = curves.points_by_curve(); const Span positions = curves.positions(); /* Transforms points to the gradient object space. */ - const float4x4 matrix = tmd.object->world_to_object() * ob.object_to_world(); + const float4x4 matrix = float4x4_view(tmd.object->world_to_object) * + float4x4_view(ob.object_to_world); curves_mask.foreach_index(GrainSize(512), [&](const int64_t curve_i) { const ColorGeometry4f material_color = get_material_color(curve_i); @@ -296,7 +297,8 @@ static void modify_fill_color(Object &ob, const OffsetIndices points_by_curve = curves.points_by_curve(); const Span positions = curves.positions(); /* Transforms points to the gradient object space. */ - const float4x4 matrix = tmd.object->world_to_object() * ob.object_to_world(); + const float4x4 matrix = float4x4_view(tmd.object->world_to_object) * + float4x4_view(ob.object_to_world); curves_mask.foreach_index(GrainSize(512), [&](int64_t curve_i) { const ColorGeometry4f material_color = get_material_color(curve_i); diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_util.cc b/source/blender/modifiers/intern/MOD_grease_pencil_util.cc index e19633cda80..337e492a628 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_util.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_util.cc @@ -23,6 +23,12 @@ #include "BLO_read_write.hh" +#include "DNA_defaults.h" + +#include "DEG_depsgraph_query.hh" + +#include "MOD_ui_common.hh" + #include "RNA_access.hh" #include "RNA_prototypes.h" diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_weight_angle.cc b/source/blender/modifiers/intern/MOD_grease_pencil_weight_angle.cc deleted file mode 100644 index ccdd6e6fc8b..00000000000 --- a/source/blender/modifiers/intern/MOD_grease_pencil_weight_angle.cc +++ /dev/null @@ -1,310 +0,0 @@ -/* SPDX-FileCopyrightText: 2005 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup modifiers - */ - -#include "BLI_index_mask.hh" -#include "BLI_math_rotation.hh" -#include "BLI_string.h" /* For #STRNCPY. */ - -#include "BLT_translation.hh" - -#include "BLO_read_write.hh" - -#include "DNA_defaults.h" -#include "DNA_modifier_types.h" -#include "DNA_screen_types.h" - -#include "RNA_access.hh" - -#include "BKE_curves.hh" -#include "BKE_geometry_set.hh" -#include "BKE_grease_pencil.hh" -#include "BKE_lib_query.hh" -#include "BKE_modifier.hh" - -#include "UI_interface.hh" -#include "UI_resources.hh" - -#include "MOD_grease_pencil_util.hh" -#include "MOD_modifiertypes.hh" -#include "MOD_ui_common.hh" - -#include "RNA_prototypes.h" - -namespace blender { - -static void init_data(ModifierData *md) -{ - GreasePencilWeightAngleModifierData *gpmd = - reinterpret_cast(md); - - BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier)); - - MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(GreasePencilWeightAngleModifierData), modifier); - modifier::greasepencil::init_influence_data(&gpmd->influence, false); -} - -static void copy_data(const ModifierData *md, ModifierData *target, const int flag) -{ - const GreasePencilWeightAngleModifierData *gmd = - reinterpret_cast(md); - GreasePencilWeightAngleModifierData *tgmd = - reinterpret_cast(target); - - BKE_modifier_copydata_generic(md, target, flag); - modifier::greasepencil::copy_influence_data(&gmd->influence, &tgmd->influence, flag); -} - -static void free_data(ModifierData *md) -{ - GreasePencilWeightAngleModifierData *mmd = - reinterpret_cast(md); - - modifier::greasepencil::free_influence_data(&mmd->influence); -} - -static bool is_disabled(const Scene * /*scene*/, ModifierData *md, bool /*use_render_params*/) -{ - GreasePencilWeightAngleModifierData *mmd = (GreasePencilWeightAngleModifierData *)md; - - return (mmd->target_vgname[0] == '\0'); -} - -static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data) -{ - GreasePencilWeightAngleModifierData *mmd = - reinterpret_cast(md); - - modifier::greasepencil::foreach_influence_ID_link(&mmd->influence, ob, walk, user_data); -} - -static void blend_write(BlendWriter *writer, const ID * /*id_owner*/, const ModifierData *md) -{ - const GreasePencilWeightAngleModifierData *mmd = - reinterpret_cast(md); - - BLO_write_struct(writer, GreasePencilWeightAngleModifierData, mmd); - modifier::greasepencil::write_influence_data(writer, &mmd->influence); -} - -static void blend_read(BlendDataReader *reader, ModifierData *md) -{ - GreasePencilWeightAngleModifierData *mmd = - reinterpret_cast(md); - modifier::greasepencil::read_influence_data(reader, &mmd->influence); -} - -static int ensure_vertex_group(const StringRefNull name, ListBase &vertex_group_names) -{ - int def_nr = BLI_findstringindex( - &vertex_group_names, name.c_str(), offsetof(bDeformGroup, name)); - if (def_nr < 0) { - bDeformGroup *defgroup = MEM_cnew(__func__); - STRNCPY(defgroup->name, name.c_str()); - BLI_addtail(&vertex_group_names, defgroup); - def_nr = BLI_listbase_count(&vertex_group_names) - 1; - BLI_assert(def_nr >= 0); - } - return def_nr; -} - -static bool target_vertex_group_available(const StringRefNull name, - const ListBase &vertex_group_names) -{ - const int def_nr = BLI_findstringindex( - &vertex_group_names, name.c_str(), offsetof(bDeformGroup, name)); - if (def_nr < 0) { - return false; - } - return true; -} - -static void write_weights_for_drawing(const ModifierData &md, - const Object &ob, - bke::greasepencil::Drawing &drawing) -{ - const auto &mmd = reinterpret_cast(md); - bke::CurvesGeometry &curves = drawing.strokes_for_write(); - if (curves.points_num() == 0) { - return; - } - IndexMaskMemory memory; - const IndexMask strokes = modifier::greasepencil::get_filtered_stroke_mask( - &ob, curves, mmd.influence, memory); - if (strokes.is_empty()) { - return; - } - - /* Make sure that the target vertex group is added to this drawing so we can write to it. */ - ensure_vertex_group(mmd.target_vgname, curves.vertex_group_names); - - bke::MutableAttributeAccessor attributes = curves.attributes_for_write(); - bke::SpanAttributeWriter dst_weights = attributes.lookup_for_write_span( - mmd.target_vgname); - - BLI_assert(!dst_weights.span.is_empty()); - - const VArray input_weights = modifier::greasepencil::get_influence_vertex_weights( - curves, mmd.influence); - - /* Use default Z up. */ - const float3 z_up(0.0f, 0.0f, 1.0f); - float3 axis(0.0f); - axis[mmd.axis] = 1.0f; - float3 vec_ref; - /* Apply modifier rotation (sub 90 degrees for Y axis due Z-Up vector). */ - const float rot_angle = mmd.angle - ((mmd.axis == 1) ? M_PI_2 : 0.0f); - rotate_normalized_v3_v3v3fl(vec_ref, z_up, axis, rot_angle); - - const float3x3 obmat3x3(ob.object_to_world()); - - /* Apply the rotation of the object. */ - if (mmd.space == MOD_GREASE_PENCIL_WEIGHT_ANGLE_SPACE_LOCAL) { - vec_ref = math::transform_point(obmat3x3, vec_ref); - } - - const OffsetIndices points_by_curve = curves.points_by_curve(); - const Span positions = curves.positions(); - - strokes.foreach_index(GrainSize(512), [&](const int stroke) { - const IndexRange points = points_by_curve[stroke]; - if (points.size() == 1) { - dst_weights.span[points.start()] = 1.0f; - return; - } - for (const int point : points.drop_front(1)) { - const float3 p1 = math::transform_point(obmat3x3, positions[point]); - const float3 p2 = math::transform_point(obmat3x3, positions[point - 1]); - const float3 vec = p2 - p1; - const float angle = angle_on_axis_v3v3_v3(vec_ref, vec, axis); - float weight = 1.0f - math::sin(angle); - - if (mmd.flag & MOD_GREASE_PENCIL_WEIGHT_ANGLE_INVERT_OUTPUT) { - weight = 1.0f - weight; - } - - dst_weights.span[point] = (mmd.flag & MOD_GREASE_PENCIL_WEIGHT_ANGLE_MULTIPLY_DATA) ? - dst_weights.span[point] * weight : - weight; - dst_weights.span[point] = math::clamp(dst_weights.span[point], mmd.min_weight, 1.0f); - } - /* First point has the same weight as the second one. */ - dst_weights.span[points[0]] = dst_weights.span[points[1]]; - }); - - dst_weights.finish(); -} - -static void modify_geometry_set(ModifierData *md, - const ModifierEvalContext *ctx, - bke::GeometrySet *geometry_set) -{ - const GreasePencilWeightAngleModifierData *mmd = - reinterpret_cast(md); - - if (!geometry_set->has_grease_pencil()) { - return; - } - - GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write(); - - if (!target_vertex_group_available(mmd->target_vgname, grease_pencil.vertex_group_names)) { - return; - } - - const int current_frame = grease_pencil.runtime->eval_frame; - - IndexMaskMemory mask_memory; - const IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask( - grease_pencil, mmd->influence, mask_memory); - const Vector drawings = - modifier::greasepencil::get_drawings_for_write(grease_pencil, layer_mask, current_frame); - - threading::parallel_for_each(drawings, [&](bke::greasepencil::Drawing *drawing) { - write_weights_for_drawing(*md, *ctx->object, *drawing); - }); -} - -static void panel_draw(const bContext *C, Panel *panel) -{ - uiLayout *row, *sub; - uiLayout *layout = panel->layout; - - PointerRNA ob_ptr; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); - - uiLayoutSetPropSep(layout, true); - - row = uiLayoutRow(layout, true); - uiItemPointerR(row, ptr, "target_vertex_group", &ob_ptr, "vertex_groups", nullptr, ICON_NONE); - - sub = uiLayoutRow(row, true); - bool has_output = RNA_string_length(ptr, "target_vertex_group") != 0; - uiLayoutSetPropDecorate(sub, false); - uiLayoutSetActive(sub, has_output); - uiItemR(sub, ptr, "use_invert_output", UI_ITEM_NONE, "", ICON_ARROW_LEFTRIGHT); - - uiItemR(layout, ptr, "angle", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(layout, ptr, "axis", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(layout, ptr, "space", UI_ITEM_NONE, nullptr, ICON_NONE); - - uiItemR(layout, ptr, "minimum_weight", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(layout, ptr, "use_multiply", UI_ITEM_NONE, nullptr, ICON_NONE); - - if (uiLayout *influence_panel = uiLayoutPanelProp( - C, layout, ptr, "open_influence_panel", "Influence")) - { - modifier::greasepencil::draw_layer_filter_settings(C, influence_panel, ptr); - modifier::greasepencil::draw_material_filter_settings(C, influence_panel, ptr); - modifier::greasepencil::draw_vertex_group_settings(C, influence_panel, ptr); - } - - modifier_panel_end(layout, ptr); -} - -static void panel_register(ARegionType *region_type) -{ - modifier_panel_register(region_type, eModifierType_GreasePencilWeightAngle, panel_draw); -} - -} // namespace blender - -ModifierTypeInfo modifierType_GreasePencilWeightAngle = { - /*idname*/ "GreasePencilWeightAngleModifier", - /*name*/ N_("Weight Angle"), - /*struct_name*/ "GreasePencilWeightAngleModifierData", - /*struct_size*/ sizeof(GreasePencilWeightAngleModifierData), - /*srna*/ &RNA_GreasePencilWeightAngleModifier, - /*type*/ ModifierTypeType::NonGeometrical, - /*flags*/ - eModifierTypeFlag_AcceptsGreasePencil | eModifierTypeFlag_SupportsEditmode | - eModifierTypeFlag_EnableInEditmode | eModifierTypeFlag_SupportsMapping, - /*icon*/ ICON_MOD_VERTEX_WEIGHT, - - /*copy_data*/ blender::copy_data, - - /*deform_verts*/ nullptr, - /*deform_matrices*/ nullptr, - /*deform_verts_EM*/ nullptr, - /*deform_matrices_EM*/ nullptr, - /*modify_mesh*/ nullptr, - /*modify_geometry_set*/ blender::modify_geometry_set, - - /*init_data*/ blender::init_data, - /*required_data_mask*/ nullptr, - /*free_data*/ blender::free_data, - /*is_disabled*/ blender::is_disabled, - /*update_depsgraph*/ nullptr, - /*depends_on_time*/ nullptr, - /*depends_on_normals*/ nullptr, - /*foreach_ID_link*/ blender::foreach_ID_link, - /*foreach_tex_link*/ nullptr, - /*free_runtime_data*/ nullptr, - /*panel_register*/ blender::panel_register, - /*blend_write*/ blender::blend_write, - /*blend_read*/ blender::blend_read, -}; diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_weight_proximity.cc b/source/blender/modifiers/intern/MOD_grease_pencil_weight_proximity.cc deleted file mode 100644 index 0b573a3810e..00000000000 --- a/source/blender/modifiers/intern/MOD_grease_pencil_weight_proximity.cc +++ /dev/null @@ -1,321 +0,0 @@ -/* SPDX-FileCopyrightText: 2005 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -/** \file - * \ingroup modifiers - */ - -#include "BLI_index_mask.hh" -#include "BLI_math_matrix.hh" -#include "BLI_string.h" /* For #STRNCPY. */ - -#include "BLT_translation.hh" - -#include "BLO_read_write.hh" - -#include "DNA_defaults.h" -#include "DNA_modifier_types.h" -#include "DNA_screen_types.h" - -#include "RNA_access.hh" - -#include "BKE_curves.hh" -#include "BKE_geometry_set.hh" -#include "BKE_grease_pencil.hh" -#include "BKE_lib_query.hh" -#include "BKE_modifier.hh" - -#include "UI_interface.hh" -#include "UI_resources.hh" - -#include "MOD_grease_pencil_util.hh" -#include "MOD_modifiertypes.hh" -#include "MOD_ui_common.hh" - -#include "RNA_prototypes.h" - -namespace blender { - -static void init_data(ModifierData *md) -{ - auto *gpmd = reinterpret_cast(md); - - BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier)); - - MEMCPY_STRUCT_AFTER( - gpmd, DNA_struct_default_get(GreasePencilWeightProximityModifierData), modifier); - modifier::greasepencil::init_influence_data(&gpmd->influence, false); -} - -static void copy_data(const ModifierData *md, ModifierData *target, const int flag) -{ - const auto *gmd = reinterpret_cast(md); - auto *tgmd = reinterpret_cast(target); - - BKE_modifier_copydata_generic(md, target, flag); - modifier::greasepencil::copy_influence_data(&gmd->influence, &tgmd->influence, flag); -} - -static void free_data(ModifierData *md) -{ - auto *mmd = reinterpret_cast(md); - - modifier::greasepencil::free_influence_data(&mmd->influence); -} - -static bool is_disabled(const Scene * /*scene*/, ModifierData *md, bool /*use_render_params*/) -{ - auto *mmd = reinterpret_cast(md); - - return (mmd->target_vgname[0] == '\0' || mmd->object == nullptr); -} - -static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data) -{ - GreasePencilWeightProximityModifierData *mmd = - reinterpret_cast(md); - - modifier::greasepencil::foreach_influence_ID_link(&mmd->influence, ob, walk, user_data); - - walk(user_data, ob, (ID **)&mmd->object, IDWALK_CB_NOP); -} - -static void update_depsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) -{ - auto *mmd = reinterpret_cast(md); - if (mmd->object != nullptr) { - DEG_add_object_relation( - ctx->node, mmd->object, DEG_OB_COMP_TRANSFORM, "Grease Pencil Proximity Modifier"); - DEG_add_depends_on_transform_relation(ctx->node, "Grease Pencil Proximity Modifier"); - } -} - -static void blend_write(BlendWriter *writer, const ID * /*id_owner*/, const ModifierData *md) -{ - const GreasePencilWeightProximityModifierData *mmd = - reinterpret_cast(md); - - BLO_write_struct(writer, GreasePencilWeightProximityModifierData, mmd); - modifier::greasepencil::write_influence_data(writer, &mmd->influence); -} - -static void blend_read(BlendDataReader *reader, ModifierData *md) -{ - GreasePencilWeightProximityModifierData *mmd = - reinterpret_cast(md); - modifier::greasepencil::read_influence_data(reader, &mmd->influence); -} - -static float get_distance_factor( - float3 target_pos, float4x4 obmat, float3 pos, const float dist_min, const float dist_max) -{ - const float3 gvert = math::transform_point(obmat, pos); - const float dist = math::distance(target_pos, gvert); - - if (dist > dist_max) { - return 1.0f; - } - if (dist <= dist_max && dist > dist_min) { - return 1.0f - ((dist_max - dist) / math::max((dist_max - dist_min), 0.0001f)); - } - return 0.0f; -} - -static int ensure_vertex_group(const StringRefNull name, ListBase &vertex_group_names) -{ - int def_nr = BLI_findstringindex( - &vertex_group_names, name.c_str(), offsetof(bDeformGroup, name)); - if (def_nr < 0) { - bDeformGroup *defgroup = MEM_cnew(__func__); - STRNCPY(defgroup->name, name.c_str()); - BLI_addtail(&vertex_group_names, defgroup); - def_nr = BLI_listbase_count(&vertex_group_names) - 1; - BLI_assert(def_nr >= 0); - } - return def_nr; -} - -static bool target_vertex_group_available(const StringRefNull name, - const ListBase &vertex_group_names) -{ - const int def_nr = BLI_findstringindex( - &vertex_group_names, name.c_str(), offsetof(bDeformGroup, name)); - if (def_nr < 0) { - return false; - } - return true; -} - -static void write_weights_for_drawing(const ModifierData &md, - const Object &ob, - bke::greasepencil::Drawing &drawing) -{ - const auto &mmd = reinterpret_cast(md); - bke::CurvesGeometry &curves = drawing.strokes_for_write(); - if (curves.points_num() == 0) { - return; - } - IndexMaskMemory memory; - const IndexMask strokes = modifier::greasepencil::get_filtered_stroke_mask( - &ob, curves, mmd.influence, memory); - if (strokes.is_empty()) { - return; - } - - /* Make sure that the target vertex group is added to this drawing so we can write to it. */ - ensure_vertex_group(mmd.target_vgname, curves.vertex_group_names); - - bke::MutableAttributeAccessor attributes = curves.attributes_for_write(); - bke::SpanAttributeWriter dst_weights = attributes.lookup_for_write_span( - mmd.target_vgname); - - BLI_assert(!dst_weights.span.is_empty()); - - const VArray vgroup_weights = modifier::greasepencil::get_influence_vertex_weights( - curves, mmd.influence); - - const Span positions = curves.positions(); - const float4x4 obmat = ob.object_to_world(); - const float3 target_pos = mmd.object->object_to_world().location(); - const bool invert = (mmd.flag & MOD_GREASE_PENCIL_WEIGHT_PROXIMITY_INVERT_OUTPUT) != 0; - const bool do_multiply = (mmd.flag & MOD_GREASE_PENCIL_WEIGHT_PROXIMITY_MULTIPLY_DATA) != 0; - - threading::parallel_for(positions.index_range(), 1024, [&](const IndexRange range) { - for (const int point_i : range) { - const float weight = vgroup_weights[point_i]; - if (weight < 0.0f) { - continue; - } - - float dist_fac = get_distance_factor( - target_pos, obmat, positions[point_i], mmd.dist_start, mmd.dist_end); - - if (invert) { - dist_fac = 1.0f - dist_fac; - } - - dst_weights.span[point_i] = do_multiply ? dst_weights.span[point_i] * dist_fac : dist_fac; - - dst_weights.span[point_i] = math::clamp( - dst_weights.span[point_i], - /** Weight==0 will remove the point from the group, assign a sufficiently small value - * there to prevent the visual disconnect, and keep the behavior same as the old - * modifier. */ - math::max(mmd.min_weight, 1e-5f), - 1.0f); - } - }); - - dst_weights.finish(); -} - -static void modify_geometry_set(ModifierData *md, - const ModifierEvalContext *ctx, - bke::GeometrySet *geometry_set) -{ - const GreasePencilWeightProximityModifierData *mmd = - reinterpret_cast(md); - - if (!geometry_set->has_grease_pencil()) { - return; - } - - GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write(); - - if (!target_vertex_group_available(mmd->target_vgname, grease_pencil.vertex_group_names)) { - return; - } - - const int current_frame = grease_pencil.runtime->eval_frame; - - IndexMaskMemory mask_memory; - const IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask( - grease_pencil, mmd->influence, mask_memory); - const Vector drawings = - modifier::greasepencil::get_drawings_for_write(grease_pencil, layer_mask, current_frame); - - threading::parallel_for_each(drawings, [&](bke::greasepencil::Drawing *drawing) { - write_weights_for_drawing(*md, *ctx->object, *drawing); - }); -} - -static void panel_draw(const bContext *C, Panel *panel) -{ - uiLayout *row, *sub; - uiLayout *layout = panel->layout; - - PointerRNA ob_ptr; - PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); - - uiLayoutSetPropSep(layout, true); - row = uiLayoutRow(layout, true); - uiItemPointerR(row, ptr, "target_vertex_group", &ob_ptr, "vertex_groups", nullptr, ICON_NONE); - sub = uiLayoutRow(row, true); - bool has_output = RNA_string_length(ptr, "target_vertex_group") != 0; - uiLayoutSetPropDecorate(sub, false); - uiLayoutSetActive(sub, has_output); - uiItemR(sub, ptr, "use_invert_output", UI_ITEM_NONE, "", ICON_ARROW_LEFTRIGHT); - - uiItemR(layout, ptr, "object", UI_ITEM_NONE, nullptr, ICON_NONE); - - sub = uiLayoutColumn(layout, true); - uiItemR(sub, ptr, "distance_start", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(sub, ptr, "distance_end", UI_ITEM_NONE, nullptr, ICON_NONE); - - uiItemR(layout, ptr, "minimum_weight", UI_ITEM_NONE, nullptr, ICON_NONE); - uiItemR(layout, ptr, "use_multiply", UI_ITEM_NONE, nullptr, ICON_NONE); - - if (uiLayout *influence_panel = uiLayoutPanelProp( - C, layout, ptr, "open_influence_panel", "Influence")) - { - modifier::greasepencil::draw_layer_filter_settings(C, influence_panel, ptr); - modifier::greasepencil::draw_material_filter_settings(C, influence_panel, ptr); - modifier::greasepencil::draw_vertex_group_settings(C, influence_panel, ptr); - } - - modifier_panel_end(layout, ptr); -} - -static void panel_register(ARegionType *region_type) -{ - modifier_panel_register(region_type, eModifierType_GreasePencilWeightProximity, panel_draw); -} - -} // namespace blender - -ModifierTypeInfo modifierType_GreasePencilWeightProximity = { - /*idname*/ "GreasePencilWeightProximityModifier", - /*name*/ N_("Weight Proximity"), - /*struct_name*/ "GreasePencilWeightProximityModifierData", - /*struct_size*/ sizeof(GreasePencilWeightProximityModifierData), - /*srna*/ &RNA_GreasePencilWeightProximityModifier, - /*type*/ ModifierTypeType::NonGeometrical, - /*flags*/ - eModifierTypeFlag_AcceptsGreasePencil | eModifierTypeFlag_SupportsEditmode | - eModifierTypeFlag_EnableInEditmode | eModifierTypeFlag_SupportsMapping, - /*icon*/ ICON_MOD_VERTEX_WEIGHT, - - /*copy_data*/ blender::copy_data, - - /*deform_verts*/ nullptr, - /*deform_matrices*/ nullptr, - /*deform_verts_EM*/ nullptr, - /*deform_matrices_EM*/ nullptr, - /*modify_mesh*/ nullptr, - /*modify_geometry_set*/ blender::modify_geometry_set, - - /*init_data*/ blender::init_data, - /*required_data_mask*/ nullptr, - /*free_data*/ blender::free_data, - /*is_disabled*/ blender::is_disabled, - /*update_depsgraph*/ blender::update_depsgraph, - /*depends_on_time*/ nullptr, - /*depends_on_normals*/ nullptr, - /*foreach_ID_link*/ blender::foreach_ID_link, - /*foreach_tex_link*/ nullptr, - /*free_runtime_data*/ nullptr, - /*panel_register*/ blender::panel_register, - /*blend_write*/ blender::blend_write, - /*blend_read*/ blender::blend_read, -}; diff --git a/source/blender/modifiers/intern/MOD_hook.cc b/source/blender/modifiers/intern/MOD_hook.cc index a2d3ae6e45f..b1b4b2c72c8 100644 --- a/source/blender/modifiers/intern/MOD_hook.cc +++ b/source/blender/modifiers/intern/MOD_hook.cc @@ -12,7 +12,7 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" @@ -22,12 +22,15 @@ #include "BKE_action.h" #include "BKE_colortools.hh" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_editmesh.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" -#include "BKE_object_types.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -37,6 +40,8 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "DEG_depsgraph_query.hh" + #include "MEM_guardedalloc.h" #include "MOD_ui_common.hh" @@ -332,14 +337,14 @@ static void deformVerts_do(HookModifierData *hmd, /* get world-space matrix of target, corrected for the space the verts are in */ if (hmd->subtarget[0] && pchan) { /* bone target if there's a matching pose-channel */ - mul_m4_m4m4(dmat, ob_target->object_to_world().ptr(), pchan->pose_mat); + mul_m4_m4m4(dmat, ob_target->object_to_world, pchan->pose_mat); } else { /* just object target */ - copy_m4_m4(dmat, ob_target->object_to_world().ptr()); + copy_m4_m4(dmat, ob_target->object_to_world); } - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); - mul_m4_series(hd.mat, ob->world_to_object().ptr(), dmat, hmd->parentinv); + invert_m4_m4(ob->world_to_object, ob->object_to_world); + mul_m4_series(hd.mat, ob->world_to_object, dmat, hmd->parentinv); /* --- done with 'hd' init --- */ /* Regarding index range checking below. diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.cc b/source/blender/modifiers/intern/MOD_laplaciandeform.cc index ec3257998d8..a219afe9aac 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.cc +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.cc @@ -15,15 +15,23 @@ #include "MEM_guardedalloc.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" +#include "BKE_editmesh.hh" +#include "BKE_lib_id.hh" +#include "BKE_mesh.hh" #include "BKE_mesh_mapping.hh" +#include "BKE_mesh_runtime.hh" +#include "BKE_mesh_wrapper.hh" +#include "BKE_particle.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.cc b/source/blender/modifiers/intern/MOD_laplaciansmooth.cc index 1775ea7fc9f..fb56790beaa 100644 --- a/source/blender/modifiers/intern/MOD_laplaciansmooth.cc +++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.cc @@ -9,21 +9,29 @@ #include "BLI_math_geom.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" +#include "DNA_object_types.h" #include "DNA_screen_types.h" #include "MEM_guardedalloc.h" +#include "BKE_context.hh" #include "BKE_deform.hh" +#include "BKE_editmesh.hh" +#include "BKE_lib_id.hh" +#include "BKE_mesh.hh" +#include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "MOD_ui_common.hh" diff --git a/source/blender/modifiers/intern/MOD_lattice.cc b/source/blender/modifiers/intern/MOD_lattice.cc index 70eda8bd47e..d2a6b70c48d 100644 --- a/source/blender/modifiers/intern/MOD_lattice.cc +++ b/source/blender/modifiers/intern/MOD_lattice.cc @@ -10,22 +10,30 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" +#include "BKE_editmesh.hh" #include "BKE_lattice.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" +#include "DEG_depsgraph_query.hh" + #include "MEM_guardedalloc.h" #include "MOD_ui_common.hh" diff --git a/source/blender/modifiers/intern/MOD_mask.cc b/source/blender/modifiers/intern/MOD_mask.cc index 5dbeae92eac..588822cf599 100644 --- a/source/blender/modifiers/intern/MOD_mask.cc +++ b/source/blender/modifiers/intern/MOD_mask.cc @@ -11,9 +11,10 @@ #include "BLI_utildefines.h" #include "BLI_array_utils.hh" +#include "BLI_ghash.h" #include "BLI_listbase.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_armature_types.h" #include "DNA_defaults.h" @@ -24,11 +25,13 @@ #include "DNA_screen_types.h" #include "BKE_action.h" /* BKE_pose_channel_find_name */ +#include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_deform.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -37,7 +40,9 @@ #include "RNA_prototypes.h" #include "DEG_depsgraph_build.hh" +#include "DEG_depsgraph_query.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "BLI_array.hh" diff --git a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc index 831d41d5133..1dcc4d7f208 100644 --- a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc +++ b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc @@ -11,29 +11,39 @@ #include "BKE_geometry_set.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" +#include "BKE_object.hh" #include "BKE_volume.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "DNA_volume_types.h" + +#include "DEG_depsgraph.hh" #include "GEO_mesh_to_volume.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "BLO_read_write.hh" + #include "MEM_guardedalloc.h" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "BLI_index_range.hh" #include "BLI_math_matrix_types.hh" #include "BLI_span.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" static void init_data(ModifierData *md) @@ -122,8 +132,8 @@ static Volume *mesh_to_volume(ModifierData *md, return input_volume; } - const float4x4 mesh_to_own_object_space_transform = ctx->object->world_to_object() * - object_to_convert->object_to_world(); + const float4x4 mesh_to_own_object_space_transform = float4x4(ctx->object->world_to_object) * + float4x4(object_to_convert->object_to_world); geometry::MeshToVolumeResolution resolution; resolution.mode = (MeshToVolumeModifierResolutionMode)mvmd->resolution_mode; if (resolution.mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT) { diff --git a/source/blender/modifiers/intern/MOD_meshcache.cc b/source/blender/modifiers/intern/MOD_meshcache.cc index 85cce66ff3d..ef19f157b0a 100644 --- a/source/blender/modifiers/intern/MOD_meshcache.cc +++ b/source/blender/modifiers/intern/MOD_meshcache.cc @@ -16,7 +16,7 @@ #include "BLI_path_util.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" @@ -25,10 +25,14 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" +#include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_mesh.hh" -#include "BKE_scene.hh" +#include "BKE_mesh_wrapper.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/modifiers/intern/MOD_meshcache_mdd.cc b/source/blender/modifiers/intern/MOD_meshcache_mdd.cc index 14ccf5a9033..da81dae1180 100644 --- a/source/blender/modifiers/intern/MOD_meshcache_mdd.cc +++ b/source/blender/modifiers/intern/MOD_meshcache_mdd.cc @@ -22,7 +22,7 @@ # include "BLI_winstuff.h" #endif -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_modifier_types.h" diff --git a/source/blender/modifiers/intern/MOD_meshcache_pc2.cc b/source/blender/modifiers/intern/MOD_meshcache_pc2.cc index 03afbcb3497..4808489f19b 100644 --- a/source/blender/modifiers/intern/MOD_meshcache_pc2.cc +++ b/source/blender/modifiers/intern/MOD_meshcache_pc2.cc @@ -22,7 +22,7 @@ # include "BLI_winstuff.h" #endif -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_modifier_types.h" diff --git a/source/blender/modifiers/intern/MOD_meshdeform.cc b/source/blender/modifiers/intern/MOD_meshdeform.cc index 709d7e6a305..92c7e6ad882 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.cc +++ b/source/blender/modifiers/intern/MOD_meshdeform.cc @@ -13,17 +13,25 @@ #include "BLI_simd.h" #include "BLI_task.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" +#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" +#include "BKE_editmesh.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -36,6 +44,7 @@ #include "MEM_guardedalloc.h" #include "DEG_depsgraph.hh" +#include "DEG_depsgraph_query.hh" #include "MOD_ui_common.hh" #include "MOD_util.hh" @@ -349,8 +358,8 @@ static void meshdeformModifier_do(ModifierData *md, } /* compute matrices to go in and out of cage object space */ - invert_m4_m4(imat, ob_target->object_to_world().ptr()); - mul_m4_m4m4(cagemat, imat, ob->object_to_world().ptr()); + invert_m4_m4(imat, ob_target->object_to_world); + mul_m4_m4m4(cagemat, imat, ob->object_to_world); mul_m4_m4m4(cmat, mmd->bindmat, cagemat); invert_m4_m4(iobmat, cmat); copy_m3_m4(icagemat, iobmat); diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.cc b/source/blender/modifiers/intern/MOD_meshsequencecache.cc index 3c1e5a238fb..c99832cb041 100644 --- a/source/blender/modifiers/intern/MOD_meshsequencecache.cc +++ b/source/blender/modifiers/intern/MOD_meshsequencecache.cc @@ -13,7 +13,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_cachefile_types.h" #include "DNA_defaults.h" @@ -25,9 +25,13 @@ #include "MEM_guardedalloc.h" -#include "BKE_cachefile.hh" +#include "BKE_cachefile.h" +#include "BKE_context.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" +#include "BKE_object.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -35,6 +39,8 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "BLO_read_write.hh" + #include "DEG_depsgraph_build.hh" #include "DEG_depsgraph_query.hh" @@ -44,6 +50,7 @@ #include "MOD_ui_common.hh" #if defined(WITH_USD) || defined(WITH_ALEMBIC) +# include "BKE_global.h" # include "BKE_lib_id.hh" #endif diff --git a/source/blender/modifiers/intern/MOD_mirror.cc b/source/blender/modifiers/intern/MOD_mirror.cc index 2b0fd8a4680..26a9c3f3b9b 100644 --- a/source/blender/modifiers/intern/MOD_mirror.cc +++ b/source/blender/modifiers/intern/MOD_mirror.cc @@ -8,16 +8,19 @@ #include "BLI_span.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" +#include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_mesh_mirror.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -28,7 +31,9 @@ #include "MEM_guardedalloc.h" #include "DEG_depsgraph_build.hh" +#include "DEG_depsgraph_query.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "GEO_mesh_merge_by_distance.hh" diff --git a/source/blender/modifiers/intern/MOD_multires.cc b/source/blender/modifiers/intern/MOD_multires.cc index 15141e039bf..5356bb0d895 100644 --- a/source/blender/modifiers/intern/MOD_multires.cc +++ b/source/blender/modifiers/intern/MOD_multires.cc @@ -12,19 +12,22 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_cdderivedmesh.h" #include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_multires.hh" #include "BKE_paint.hh" +#include "BKE_screen.hh" #include "BKE_subdiv.hh" #include "BKE_subdiv_ccg.hh" #include "BKE_subdiv_deform.hh" @@ -41,6 +44,7 @@ #include "DEG_depsgraph_query.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" struct MultiresRuntimeData { diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index 48453880fae..47d58be84b7 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -47,7 +47,7 @@ #include "BKE_customdata.hh" #include "BKE_geometry_fields.hh" #include "BKE_geometry_set_instances.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" @@ -66,7 +66,7 @@ #include "UI_interface.hh" #include "UI_resources.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "WM_api.hh" #include "WM_types.hh" @@ -824,7 +824,7 @@ static void check_property_socket_sync(const Object *ob, ModifierData *md) IDProperty *property = IDP_GetPropertyFromGroup(nmd->settings.properties, socket->identifier); if (property == nullptr) { - if (ELEM(type, SOCK_GEOMETRY, SOCK_MATRIX)) { + if (type == SOCK_GEOMETRY) { geometry_socket_count++; } else { diff --git a/source/blender/modifiers/intern/MOD_normal_edit.cc b/source/blender/modifiers/intern/MOD_normal_edit.cc index fb8c8091b03..7bae49ed9d0 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.cc +++ b/source/blender/modifiers/intern/MOD_normal_edit.cc @@ -16,19 +16,22 @@ #include "BLI_math_matrix.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" #include "BKE_attribute.hh" +#include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_deform.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -36,6 +39,8 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "DEG_depsgraph_query.hh" + #include "MOD_ui_common.hh" #include "MOD_util.hh" @@ -95,8 +100,8 @@ static void generate_vert_coordinates(Mesh *mesh, /* Translate our coordinates so that center of ob_center is at (0, 0, 0). */ /* Get ob_center (world) coordinates in ob local coordinates. * No need to take into account ob_center's space here, see #44027. */ - invert_m4_m4(inv_obmat, ob->object_to_world().ptr()); - mul_v3_m4v3(diff, inv_obmat, ob_center->object_to_world().location()); + invert_m4_m4(inv_obmat, ob->object_to_world); + mul_v3_m4v3(diff, inv_obmat, ob_center->object_to_world[3]); negate_v3(diff); do_diff = true; @@ -369,8 +374,8 @@ static void normalEditModifier_do_directional(NormalEditModifierData *enmd, /* Get target's center coordinates in ob local coordinates. */ float mat[4][4]; - invert_m4_m4(mat, ob->object_to_world().ptr()); - mul_m4_m4m4(mat, mat, ob_target->object_to_world().ptr()); + invert_m4_m4(mat, ob->object_to_world); + mul_m4_m4m4(mat, mat, ob_target->object_to_world); copy_v3_v3(target_co, mat[3]); if (use_parallel_normals) { diff --git a/source/blender/modifiers/intern/MOD_ocean.cc b/source/blender/modifiers/intern/MOD_ocean.cc index 9217757b5dd..1fa775ebbcb 100644 --- a/source/blender/modifiers/intern/MOD_ocean.cc +++ b/source/blender/modifiers/intern/MOD_ocean.cc @@ -10,7 +10,7 @@ #include "BLI_task.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_customdata_types.h" #include "DNA_defaults.h" @@ -18,13 +18,16 @@ #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_ocean.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -32,10 +35,13 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "BLO_read_write.hh" + #include "WM_types.hh" /* For UI free bake operator. */ #include "DEG_depsgraph_query.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #ifdef WITH_OCEANSIM diff --git a/source/blender/modifiers/intern/MOD_particleinstance.cc b/source/blender/modifiers/intern/MOD_particleinstance.cc index ef1faeaeb17..d287a8a17b7 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.cc +++ b/source/blender/modifiers/intern/MOD_particleinstance.cc @@ -11,24 +11,30 @@ #include "BLI_utildefines.h" #include "BLI_listbase.h" +#include "BLI_math_base_safe.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" #include "BLI_math_vector.h" #include "BLI_rand.h" +#include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_customdata.hh" +#include "BKE_effect.h" +#include "BKE_lattice.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" #include "BKE_particle.h" #include "BKE_pointcache.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -39,6 +45,7 @@ #include "DEG_depsgraph_build.hh" #include "DEG_depsgraph_query.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" static void init_data(ModifierData *md) @@ -268,7 +275,7 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh break; case eParticleInstanceSpace_Local: /* get particle states in the particle object's local space */ - invert_m4_m4(spacemat, pimd->ob->object_to_world().ptr()); + invert_m4_m4(spacemat, pimd->ob->object_to_world); break; default: /* should not happen */ diff --git a/source/blender/modifiers/intern/MOD_particlesystem.cc b/source/blender/modifiers/intern/MOD_particlesystem.cc index a172e85ad4a..d774695d85f 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.cc +++ b/source/blender/modifiers/intern/MOD_particlesystem.cc @@ -11,22 +11,26 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" +#include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" #include "BKE_mesh_legacy_convert.hh" #include "BKE_modifier.hh" #include "BKE_particle.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "DEG_depsgraph_query.hh" @@ -34,6 +38,7 @@ #include "BLO_read_write.hh" #include "MOD_ui_common.hh" +#include "MOD_util.hh" static void init_data(ModifierData *md) { diff --git a/source/blender/modifiers/intern/MOD_remesh.cc b/source/blender/modifiers/intern/MOD_remesh.cc index bec3d171375..803e11022b5 100644 --- a/source/blender/modifiers/intern/MOD_remesh.cc +++ b/source/blender/modifiers/intern/MOD_remesh.cc @@ -12,15 +12,18 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_modifier_types.h" +#include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_mesh.hh" #include "BKE_mesh_remesh_voxel.hh" #include "BKE_mesh_runtime.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/modifiers/intern/MOD_screw.cc b/source/blender/modifiers/intern/MOD_screw.cc index 7410cbf280a..ccb772e3548 100644 --- a/source/blender/modifiers/intern/MOD_screw.cc +++ b/source/blender/modifiers/intern/MOD_screw.cc @@ -18,18 +18,21 @@ #include "BLI_math_vector.h" #include "BLI_span.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" #include "BKE_attribute.hh" +#include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -38,15 +41,16 @@ #include "RNA_prototypes.h" #include "DEG_depsgraph_build.hh" +#include "DEG_depsgraph_query.hh" #include "MEM_guardedalloc.h" #include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" -#include "GEO_mesh_merge_by_distance.hh" +#include "BLI_strict_flags.h" -#include "BLI_strict_flags.h" /* Keep last. */ +#include "GEO_mesh_merge_by_distance.hh" using namespace blender; @@ -286,8 +290,8 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh if (ob_axis != nullptr) { /* Calculate the matrix relative to the axis object. */ - invert_m4_m4(mtx_tmp_a, ctx->object->object_to_world().ptr()); - copy_m4_m4(mtx_tx_inv, ob_axis->object_to_world().ptr()); + invert_m4_m4(mtx_tmp_a, ctx->object->object_to_world); + copy_m4_m4(mtx_tx_inv, ob_axis->object_to_world); mul_m4_m4m4(mtx_tx, mtx_tmp_a, mtx_tx_inv); /* Calculate the axis vector. */ diff --git a/source/blender/modifiers/intern/MOD_shapekey.cc b/source/blender/modifiers/intern/MOD_shapekey.cc index 2c55b2cefd0..3d93ff8aa08 100644 --- a/source/blender/modifiers/intern/MOD_shapekey.cc +++ b/source/blender/modifiers/intern/MOD_shapekey.cc @@ -9,13 +9,16 @@ #include "BLI_math_matrix.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_key_types.h" +#include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "BKE_key.hh" +#include "BKE_particle.h" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "MOD_modifiertypes.hh" diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.cc b/source/blender/modifiers/intern/MOD_shrinkwrap.cc index 011a533abc5..73ae32f647a 100644 --- a/source/blender/modifiers/intern/MOD_shrinkwrap.cc +++ b/source/blender/modifiers/intern/MOD_shrinkwrap.cc @@ -10,14 +10,21 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" +#include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" +#include "BKE_editmesh.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_mesh.hh" +#include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "BKE_shrinkwrap.hh" #include "UI_interface.hh" diff --git a/source/blender/modifiers/intern/MOD_simpledeform.cc b/source/blender/modifiers/intern/MOD_simpledeform.cc index 7ed2e677ea0..668bb652ec1 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.cc +++ b/source/blender/modifiers/intern/MOD_simpledeform.cc @@ -10,15 +10,23 @@ #include "BLI_math_vector.h" #include "BLI_task.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" +#include "BKE_editmesh.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_mesh.hh" +#include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -26,6 +34,8 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "DEG_depsgraph_query.hh" + #include "MOD_ui_common.hh" #include "MOD_util.hh" diff --git a/source/blender/modifiers/intern/MOD_skin.cc b/source/blender/modifiers/intern/MOD_skin.cc index a002a9a7651..24e535db48e 100644 --- a/source/blender/modifiers/intern/MOD_skin.cc +++ b/source/blender/modifiers/intern/MOD_skin.cc @@ -50,19 +50,22 @@ #include "BLI_stack.h" #include "BLI_vector.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" +#include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" #include "BKE_mesh_mapping.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -72,6 +75,7 @@ #include "WM_types.hh" /* For skin mark clear operator UI. */ +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "bmesh.hh" diff --git a/source/blender/modifiers/intern/MOD_smooth.cc b/source/blender/modifiers/intern/MOD_smooth.cc index 5aea27baefb..9ca9d722f94 100644 --- a/source/blender/modifiers/intern/MOD_smooth.cc +++ b/source/blender/modifiers/intern/MOD_smooth.cc @@ -11,18 +11,27 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" +#include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" +#include "BKE_editmesh.hh" +#include "BKE_lib_id.hh" +#include "BKE_mesh.hh" +#include "BKE_mesh_wrapper.hh" +#include "BKE_particle.h" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "MOD_modifiertypes.hh" diff --git a/source/blender/modifiers/intern/MOD_softbody.cc b/source/blender/modifiers/intern/MOD_softbody.cc index 93b6f0f5156..f6ea575aef1 100644 --- a/source/blender/modifiers/intern/MOD_softbody.cc +++ b/source/blender/modifiers/intern/MOD_softbody.cc @@ -10,16 +10,23 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "DNA_mesh_types.h" #include "DNA_object_force_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" +#include "BKE_layer.hh" +#include "BKE_particle.h" +#include "BKE_screen.hh" #include "BKE_softbody.h" #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/modifiers/intern/MOD_solidify.cc b/source/blender/modifiers/intern/MOD_solidify.cc index db676a999d5..514e7ac0951 100644 --- a/source/blender/modifiers/intern/MOD_solidify.cc +++ b/source/blender/modifiers/intern/MOD_solidify.cc @@ -10,7 +10,7 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.cc b/source/blender/modifiers/intern/MOD_solidify_extrude.cc index 1e054ec07a8..4b7cfc2ca63 100644 --- a/source/blender/modifiers/intern/MOD_solidify_extrude.cc +++ b/source/blender/modifiers/intern/MOD_solidify_extrude.cc @@ -23,6 +23,7 @@ #include "BKE_customdata.hh" #include "BKE_deform.hh" #include "BKE_mesh.hh" +#include "BKE_particle.h" #include "MOD_modifiertypes.hh" #include "MOD_solidify_util.hh" /* own include */ diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc index de6d549d85b..7adfe6dc2a6 100644 --- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc +++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.cc @@ -20,6 +20,7 @@ #include "BKE_customdata.hh" #include "BKE_deform.hh" #include "BKE_mesh.hh" +#include "BKE_particle.h" #include "MOD_modifiertypes.hh" #include "MOD_solidify_util.hh" /* Own include. */ diff --git a/source/blender/modifiers/intern/MOD_subsurf.cc b/source/blender/modifiers/intern/MOD_subsurf.cc index b810fe605d9..66823b8a7f4 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.cc +++ b/source/blender/modifiers/intern/MOD_subsurf.cc @@ -15,7 +15,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" @@ -26,12 +26,14 @@ #include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_mesh.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "BKE_subdiv.hh" #include "BKE_subdiv_ccg.hh" #include "BKE_subdiv_deform.hh" #include "BKE_subdiv_mesh.hh" #include "BKE_subdiv_modifier.hh" +#include "BKE_subsurf.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -47,6 +49,8 @@ #include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" +#include "BLO_read_write.hh" + #include "intern/CCGSubSurf.h" static void init_data(ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_surface.cc b/source/blender/modifiers/intern/MOD_surface.cc index f553c3b9f44..ea5a854fc27 100644 --- a/source/blender/modifiers/intern/MOD_surface.cc +++ b/source/blender/modifiers/intern/MOD_surface.cc @@ -10,20 +10,25 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BKE_bvhutils.hh" +#include "BKE_context.hh" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "DEG_depsgraph.hh" @@ -31,6 +36,9 @@ #include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" +#include "MOD_util.hh" + +#include "BLO_read_write.hh" #include "MEM_guardedalloc.h" @@ -138,7 +146,7 @@ static void deform_verts(ModifierData *md, surmd->runtime.mesh->vert_positions_for_write(); for (i = 0; i < mesh_verts_num; i++) { float *vec = positions[i]; - mul_m4_v3(ctx->object->object_to_world().ptr(), vec); + mul_m4_v3(ctx->object->object_to_world, vec); if (init) { zero_v3(surmd->runtime.vert_velocities[i]); diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.cc b/source/blender/modifiers/intern/MOD_surfacedeform.cc index 72d9e957a78..a2bd6d1a0e0 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.cc +++ b/source/blender/modifiers/intern/MOD_surfacedeform.cc @@ -10,20 +10,26 @@ #include "BLI_math_matrix.h" #include "BLI_task.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "BKE_bvhutils.hh" +#include "BKE_context.hh" #include "BKE_deform.hh" +#include "BKE_editmesh.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -34,6 +40,7 @@ #include "RNA_prototypes.h" #include "DEG_depsgraph.hh" +#include "DEG_depsgraph_query.hh" #include "MEM_guardedalloc.h" @@ -1462,8 +1469,8 @@ static void surfacedeformModifier_do(ModifierData *md, ob, md); float tmp_mat[4][4]; - invert_m4_m4(tmp_mat, ob->object_to_world().ptr()); - mul_m4_m4m4(smd_orig->mat, tmp_mat, ob_target->object_to_world().ptr()); + invert_m4_m4(tmp_mat, ob->object_to_world); + mul_m4_m4m4(smd_orig->mat, tmp_mat, ob_target->object_to_world); /* Avoid converting edit-mesh data, binding is an exception. */ BKE_mesh_wrapper_ensure_mdata(target); diff --git a/source/blender/modifiers/intern/MOD_triangulate.cc b/source/blender/modifiers/intern/MOD_triangulate.cc index 52790c98aa2..b2781c91240 100644 --- a/source/blender/modifiers/intern/MOD_triangulate.cc +++ b/source/blender/modifiers/intern/MOD_triangulate.cc @@ -12,22 +12,27 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" +#include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "bmesh.hh" #include "bmesh_tools.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" static Mesh *triangulate_mesh(Mesh *mesh, diff --git a/source/blender/modifiers/intern/MOD_ui_common.cc b/source/blender/modifiers/intern/MOD_ui_common.cc index 8a6bd17ea5e..19ca73fdeab 100644 --- a/source/blender/modifiers/intern/MOD_ui_common.cc +++ b/source/blender/modifiers/intern/MOD_ui_common.cc @@ -13,15 +13,18 @@ #include "BKE_context.hh" #include "BKE_modifier.hh" +#include "BKE_object.hh" #include "BKE_screen.hh" +#include "DNA_object_force_types.h" #include "DNA_object_types.h" #include "DNA_particle_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "ED_object.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "UI_interface.hh" #include "UI_resources.hh" @@ -32,6 +35,7 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" /* Self include */ /** diff --git a/source/blender/modifiers/intern/MOD_util.cc b/source/blender/modifiers/intern/MOD_util.cc index d8b3345b763..a6fc875c5b0 100644 --- a/source/blender/modifiers/intern/MOD_util.cc +++ b/source/blender/modifiers/intern/MOD_util.cc @@ -16,8 +16,10 @@ #include "DNA_image_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BKE_action.h" /* BKE_pose_channel_find_name */ #include "BKE_attribute.hh" @@ -25,6 +27,10 @@ #include "BKE_editmesh.hh" #include "BKE_image.h" #include "BKE_lattice.hh" +#include "BKE_lib_id.hh" +#include "BKE_mesh.hh" +#include "BKE_mesh_wrapper.hh" +#include "BKE_object.hh" #include "BKE_modifier.hh" @@ -71,15 +77,15 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd, bPoseChannel *pchan = BKE_pose_channel_find_name(map_object->pose, dmd->map_bone); if (pchan) { float mat_bone_world[4][4]; - mul_m4_m4m4(mat_bone_world, map_object->object_to_world().ptr(), pchan->pose_mat); + mul_m4_m4m4(mat_bone_world, map_object->object_to_world, pchan->pose_mat); invert_m4_m4(mapref_imat, mat_bone_world); } else { - invert_m4_m4(mapref_imat, map_object->object_to_world().ptr()); + invert_m4_m4(mapref_imat, map_object->object_to_world); } } else { - invert_m4_m4(mapref_imat, map_object->object_to_world().ptr()); + invert_m4_m4(mapref_imat, map_object->object_to_world); } } else { /* if there is no map object, default to local */ @@ -129,10 +135,10 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd, copy_v3_v3(*r_texco, cos != nullptr ? *cos : positions[i]); break; case MOD_DISP_MAP_GLOBAL: - mul_v3_m4v3(*r_texco, ob->object_to_world().ptr(), cos != nullptr ? *cos : positions[i]); + mul_v3_m4v3(*r_texco, ob->object_to_world, cos != nullptr ? *cos : positions[i]); break; case MOD_DISP_MAP_OBJECT: - mul_v3_m4v3(*r_texco, ob->object_to_world().ptr(), cos != nullptr ? *cos : positions[i]); + mul_v3_m4v3(*r_texco, ob->object_to_world, cos != nullptr ? *cos : positions[i]); mul_m4_v3(mapref_imat, *r_texco); break; } @@ -273,12 +279,5 @@ void modifier_type_init(ModifierTypeInfo *types[]) INIT_TYPE(GreasePencilNoise); INIT_TYPE(GreasePencilMirror); INIT_TYPE(GreasePencilThickness); - INIT_TYPE(GreasePencilLattice); - INIT_TYPE(GreasePencilDash); - INIT_TYPE(GreasePencilMultiply); - INIT_TYPE(GreasePencilLength); - INIT_TYPE(GreasePencilWeightAngle); - INIT_TYPE(GreasePencilArray); - INIT_TYPE(GreasePencilWeightProximity); #undef INIT_TYPE } diff --git a/source/blender/modifiers/intern/MOD_uvproject.cc b/source/blender/modifiers/intern/MOD_uvproject.cc index 5d7363d5735..e31deb0cf1d 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.cc +++ b/source/blender/modifiers/intern/MOD_uvproject.cc @@ -14,19 +14,23 @@ #include "BLI_math_vector.h" #include "BLI_uvproject.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_camera_types.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" #include "BKE_attribute.hh" #include "BKE_camera.h" +#include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_lib_query.hh" +#include "BKE_material.h" #include "BKE_mesh.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -39,7 +43,9 @@ #include "MEM_guardedalloc.h" +#include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" +#include "DEG_depsgraph_query.hh" static void init_data(ModifierData *md) { @@ -141,7 +147,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, float offsetmat[4][4]; Camera *cam = nullptr; /* calculate projection matrix */ - invert_m4_m4(projectors[i].projmat, projectors[i].ob->object_to_world().ptr()); + invert_m4_m4(projectors[i].projmat, projectors[i].ob->object_to_world); projectors[i].uci = nullptr; @@ -187,7 +193,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, projectors[i].normal[0] = 0; projectors[i].normal[1] = 0; projectors[i].normal[2] = 1; - mul_mat3_m4_v3(projectors[i].ob->object_to_world().ptr(), projectors[i].normal); + mul_mat3_m4_v3(projectors[i].ob->object_to_world, projectors[i].normal); } const Span positions = mesh->vert_positions(); @@ -198,7 +204,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, /* Convert coords to world-space. */ Array coords(positions.size()); for (int64_t i = 0; i < positions.size(); i++) { - mul_v3_m4v3(coords[i], ob->object_to_world().ptr(), positions[i]); + mul_v3_m4v3(coords[i], ob->object_to_world, positions[i]); } /* if only one projector, project coords to UVs */ diff --git a/source/blender/modifiers/intern/MOD_uvwarp.cc b/source/blender/modifiers/intern/MOD_uvwarp.cc index ad021bba805..8a9c8b90f49 100644 --- a/source/blender/modifiers/intern/MOD_uvwarp.cc +++ b/source/blender/modifiers/intern/MOD_uvwarp.cc @@ -14,7 +14,7 @@ #include "BLI_math_vector.h" #include "BLI_task.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" @@ -23,11 +23,13 @@ #include "DNA_screen_types.h" #include "BKE_action.h" /* BKE_pose_channel_find_name */ +#include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_deform.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -35,6 +37,8 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "DEG_depsgraph_query.hh" + #include "MOD_ui_common.hh" #include "MOD_util.hh" @@ -72,10 +76,10 @@ static void matrix_from_obj_pchan(float mat[4][4], Object *ob, const char *bonen { bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bonename); if (pchan) { - mul_m4_m4m4(mat, ob->object_to_world().ptr(), pchan->pose_mat); + mul_m4_m4m4(mat, ob->object_to_world, pchan->pose_mat); } else { - copy_m4_m4(mat, ob->object_to_world().ptr()); + copy_m4_m4(mat, ob->object_to_world); } } diff --git a/source/blender/modifiers/intern/MOD_volume_displace.cc b/source/blender/modifiers/intern/MOD_volume_displace.cc index 11007234f54..702e2d97c92 100644 --- a/source/blender/modifiers/intern/MOD_volume_displace.cc +++ b/source/blender/modifiers/intern/MOD_volume_displace.cc @@ -8,17 +8,20 @@ #include "BKE_geometry_set.hh" #include "BKE_lib_query.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_modifier.hh" +#include "BKE_object.hh" #include "BKE_texture.h" #include "BKE_volume.hh" #include "BKE_volume_grid.hh" #include "BKE_volume_openvdb.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" #include "DNA_texture_types.h" +#include "DNA_volume_types.h" #include "DEG_depsgraph_build.hh" #include "DEG_depsgraph_query.hh" @@ -26,12 +29,16 @@ #include "UI_interface.hh" #include "UI_resources.hh" +#include "BLO_read_write.hh" + #include "MEM_guardedalloc.h" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "RE_texture.h" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "BLI_math_vector.h" @@ -119,12 +126,12 @@ static void panel_register(ARegionType *region_type) #ifdef WITH_OPENVDB -static openvdb::Mat4s matrix_to_openvdb(const blender::float4x4 &m) +static openvdb::Mat4s matrix_to_openvdb(const float m[4][4]) { /* OpenVDB matrices are transposed Blender matrices, i.e. the translation is in the last row * instead of in the last column. However, the layout in memory is the same, because OpenVDB * matrices are row major (compared to Blender's column major matrices). */ - openvdb::Mat4s new_matrix{m.base_ptr()}; + openvdb::Mat4s new_matrix{reinterpret_cast(m)}; return new_matrix; } @@ -250,16 +257,16 @@ struct DisplaceGridOp { return index_to_object; } case MOD_VOLUME_DISPLACE_MAP_GLOBAL: { - const openvdb::Mat4s object_to_world = matrix_to_openvdb(ctx.object->object_to_world()); + const openvdb::Mat4s object_to_world = matrix_to_openvdb(ctx.object->object_to_world); return index_to_object * object_to_world; } case MOD_VOLUME_DISPLACE_MAP_OBJECT: { if (vdmd.texture_map_object == nullptr) { return index_to_object; } - const openvdb::Mat4s object_to_world = matrix_to_openvdb(ctx.object->object_to_world()); + const openvdb::Mat4s object_to_world = matrix_to_openvdb(ctx.object->object_to_world); const openvdb::Mat4s world_to_texture = matrix_to_openvdb( - vdmd.texture_map_object->world_to_object()); + vdmd.texture_map_object->world_to_object); return index_to_object * object_to_world * world_to_texture; } } diff --git a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc index f3fae579511..a11dadf92a8 100644 --- a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc +++ b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc @@ -15,22 +15,27 @@ #include "BKE_volume_grid.hh" #include "BKE_volume_to_mesh.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "DNA_volume_types.h" #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "BLI_math_matrix_types.hh" +#include "BLI_math_vector.h" #include "BLI_span.hh" #include "BLI_string.h" +#include "BLI_timeit.hh" #include "DEG_depsgraph_query.hh" @@ -157,8 +162,8 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh const openvdb::GridBase &local_grid = volume_grid->grid(tree_token); openvdb::math::Transform::Ptr transform = local_grid.transform().copy(); - transform->postMult(openvdb::Mat4d(vmmd->object->object_to_world().base_ptr())); - openvdb::Mat4d imat = openvdb::Mat4d(ctx->object->world_to_object().base_ptr()); + transform->postMult(openvdb::Mat4d((float *)vmmd->object->object_to_world)); + openvdb::Mat4d imat = openvdb::Mat4d((float *)ctx->object->world_to_object); /* `imat` had floating point issues and wasn't affine. */ imat.setCol(3, openvdb::Vec4d(0, 0, 0, 1)); transform->postMult(imat); diff --git a/source/blender/modifiers/intern/MOD_warp.cc b/source/blender/modifiers/intern/MOD_warp.cc index 2ece8e61716..7a884e438cd 100644 --- a/source/blender/modifiers/intern/MOD_warp.cc +++ b/source/blender/modifiers/intern/MOD_warp.cc @@ -14,18 +14,25 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" +#include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" #include "BKE_action.h" /* BKE_pose_channel_find_name */ #include "BKE_colortools.hh" +#include "BKE_context.hh" #include "BKE_deform.hh" +#include "BKE_editmesh.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_mesh.hh" +#include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "BKE_texture.h" #include "UI_interface.hh" @@ -36,6 +43,9 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "DEG_depsgraph.hh" +#include "DEG_depsgraph_query.hh" + #include "RE_texture.h" #include "MOD_ui_common.hh" @@ -85,11 +95,11 @@ static void matrix_from_obj_pchan(float mat[4][4], bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bonename); if (pchan) { float mat_bone_world[4][4]; - mul_m4_m4m4(mat_bone_world, ob->object_to_world().ptr(), pchan->pose_mat); + mul_m4_m4m4(mat_bone_world, ob->object_to_world, pchan->pose_mat); mul_m4_m4m4(mat, obinv, mat_bone_world); } else { - mul_m4_m4m4(mat, obinv, ob->object_to_world().ptr()); + mul_m4_m4m4(mat, obinv, ob->object_to_world); } } @@ -205,7 +215,7 @@ static void warpModifier_do(WarpModifierData *wmd, BKE_curvemapping_init(wmd->curfalloff); } - invert_m4_m4(obinv, ob->object_to_world().ptr()); + invert_m4_m4(obinv, ob->object_to_world); /* Checks that the objects/bones are available. */ matrix_from_obj_pchan(mat_from, obinv, wmd->object_from, wmd->bone_from); diff --git a/source/blender/modifiers/intern/MOD_wave.cc b/source/blender/modifiers/intern/MOD_wave.cc index f540cefaaff..fbb2eb266b3 100644 --- a/source/blender/modifiers/intern/MOD_wave.cc +++ b/source/blender/modifiers/intern/MOD_wave.cc @@ -9,17 +9,25 @@ #include "BLI_math_matrix.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_editmesh.hh" +#include "BKE_editmesh_cache.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" +#include "BKE_mesh.hh" +#include "BKE_mesh_wrapper.hh" +#include "BKE_scene.h" +#include "BKE_screen.hh" #include "BKE_texture.h" #include "UI_interface.hh" @@ -144,8 +152,8 @@ static void waveModifier_do(WaveModifierData *md, if (wmd->objectcenter != nullptr) { float mat[4][4]; /* get the control object's location in local coordinates */ - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); - mul_m4_m4m4(mat, ob->world_to_object().ptr(), wmd->objectcenter->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); + mul_m4_m4m4(mat, ob->world_to_object, wmd->objectcenter->object_to_world); wmd->startx = mat[3][0]; wmd->starty = mat[3][1]; diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.cc b/source/blender/modifiers/intern/MOD_weighted_normal.cc index f3bcf7b7f45..17d13766522 100644 --- a/source/blender/modifiers/intern/MOD_weighted_normal.cc +++ b/source/blender/modifiers/intern/MOD_weighted_normal.cc @@ -13,7 +13,7 @@ #include "BLI_linklist.h" #include "BLI_math_vector.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.cc b/source/blender/modifiers/intern/MOD_weightvg_util.cc index 88d18f4ef6b..0e09cb31d32 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.cc +++ b/source/blender/modifiers/intern/MOD_weightvg_util.cc @@ -12,7 +12,7 @@ #include "BLI_rand.h" #include "BLI_string.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_color_types.h" /* CurveMapping. */ #include "DNA_mesh_types.h" @@ -26,7 +26,7 @@ #include "BKE_customdata.hh" #include "BKE_deform.hh" #include "BKE_modifier.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_texture.h" /* Texture masking. */ #include "UI_interface.hh" diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.cc b/source/blender/modifiers/intern/MOD_weightvgedit.cc index dd240c84021..dffc2d0266b 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.cc +++ b/source/blender/modifiers/intern/MOD_weightvgedit.cc @@ -14,7 +14,7 @@ #include "BLI_listbase.h" #include "BLI_rand.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_color_types.h" /* CurveMapping. */ #include "DNA_defaults.h" @@ -25,11 +25,13 @@ #include "DNA_screen_types.h" #include "BKE_colortools.hh" /* CurveMapping. */ +#include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_deform.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "BKE_texture.h" /* Texture masking. */ #include "UI_interface.hh" @@ -45,6 +47,7 @@ #include "MEM_guardedalloc.h" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "MOD_util.hh" #include "MOD_weightvg_util.hh" diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.cc b/source/blender/modifiers/intern/MOD_weightvgmix.cc index 204ae620e66..663c481b90d 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.cc +++ b/source/blender/modifiers/intern/MOD_weightvgmix.cc @@ -10,7 +10,7 @@ #include "BLI_listbase.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" @@ -19,16 +19,19 @@ #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_customdata.hh" #include "BKE_deform.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "BKE_texture.h" /* Texture masking. */ #include "UI_interface.hh" #include "UI_resources.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "DEG_depsgraph_build.hh" @@ -36,6 +39,7 @@ #include "MEM_guardedalloc.h" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "MOD_util.hh" #include "MOD_weightvg_util.hh" diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.cc b/source/blender/modifiers/intern/MOD_weightvgproximity.cc index 6e100634a5c..43501a3689e 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.cc +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.cc @@ -15,7 +15,7 @@ #include "BLI_rand.h" #include "BLI_task.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_color_types.h" /* CurveMapping. */ #include "DNA_defaults.h" @@ -27,12 +27,16 @@ #include "BKE_bvhutils.hh" #include "BKE_colortools.hh" /* CurveMapping. */ +#include "BKE_context.hh" +#include "BKE_curve.hh" #include "BKE_customdata.hh" #include "BKE_deform.hh" +#include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_mesh.hh" #include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" +#include "BKE_screen.hh" #include "BKE_texture.h" /* Texture masking. */ #include "UI_interface.hh" @@ -48,6 +52,7 @@ #include "MEM_guardedalloc.h" +#include "MOD_modifiertypes.hh" #include "MOD_ui_common.hh" #include "MOD_util.hh" #include "MOD_weightvg_util.hh" @@ -228,9 +233,9 @@ static void get_vert2ob_distance(int verts_num, while (i-- > 0) { /* Get world-coordinates of the vertex (constraints and anim included). */ - mul_v3_m4v3(v_wco, ob->object_to_world().ptr(), positions[indices ? indices[i] : i]); + mul_v3_m4v3(v_wco, ob->object_to_world, positions[indices ? indices[i] : i]); /* Return distance between both coordinates. */ - dist[i] = len_v3v3(v_wco, obr->object_to_world().location()); + dist[i] = len_v3v3(v_wco, obr->object_to_world[3]); } } @@ -240,7 +245,7 @@ static void get_vert2ob_distance(int verts_num, */ static float get_ob2ob_distance(const Object *ob, const Object *obr) { - return len_v3v3(ob->object_to_world().location(), obr->object_to_world().location()); + return len_v3v3(ob->object_to_world[3], obr->object_to_world[3]); } /** diff --git a/source/blender/modifiers/intern/MOD_weld.cc b/source/blender/modifiers/intern/MOD_weld.cc index 97a186ad7fc..1866de106f3 100644 --- a/source/blender/modifiers/intern/MOD_weld.cc +++ b/source/blender/modifiers/intern/MOD_weld.cc @@ -21,7 +21,7 @@ #include "BLI_span.hh" #include "BLI_vector.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" diff --git a/source/blender/modifiers/intern/MOD_wireframe.cc b/source/blender/modifiers/intern/MOD_wireframe.cc index eb84d61b178..b00e11b6f8c 100644 --- a/source/blender/modifiers/intern/MOD_wireframe.cc +++ b/source/blender/modifiers/intern/MOD_wireframe.cc @@ -10,15 +10,17 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_defaults.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" +#include "BKE_context.hh" #include "BKE_deform.hh" #include "BKE_mesh.hh" +#include "BKE_screen.hh" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/nodes/NOD_common.h b/source/blender/nodes/NOD_common.h index a8517f323a1..69cb7f60eb4 100644 --- a/source/blender/nodes/NOD_common.h +++ b/source/blender/nodes/NOD_common.h @@ -8,7 +8,7 @@ #pragma once -#include "BKE_node.hh" +#include "BKE_node.h" #ifdef __cplusplus extern "C" { diff --git a/source/blender/nodes/NOD_composite.hh b/source/blender/nodes/NOD_composite.hh index 4ceb90df1d3..4544c3a4fd0 100644 --- a/source/blender/nodes/NOD_composite.hh +++ b/source/blender/nodes/NOD_composite.hh @@ -8,14 +8,11 @@ #pragma once -#include "BKE_node.hh" +#include "BKE_node.h" namespace blender::realtime_compositor { class RenderContext; } -namespace blender::compositor { -class ProfilerData; -} struct bNodeTreeType; struct CryptomatteSession; @@ -44,8 +41,7 @@ void ntreeCompositExecTree(Render *render, bool rendering, int do_previews, const char *view_name, - blender::realtime_compositor::RenderContext *render_context, - blender::compositor::ProfilerData &profiler_data); + blender::realtime_compositor::RenderContext *render_context); /** * Called from render pipeline, to tag render input and output. diff --git a/source/blender/nodes/NOD_geometry.hh b/source/blender/nodes/NOD_geometry.hh index 081ef6eb15a..390592a5435 100644 --- a/source/blender/nodes/NOD_geometry.hh +++ b/source/blender/nodes/NOD_geometry.hh @@ -4,7 +4,7 @@ #pragma once -#include "BKE_node.hh" +#include "BKE_node.h" extern bNodeTreeType *ntreeType_Geometry; diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh index b176b701585..954f5b6c90a 100644 --- a/source/blender/nodes/NOD_geometry_exec.hh +++ b/source/blender/nodes/NOD_geometry_exec.hh @@ -87,15 +87,8 @@ class GeoNodeExecParams { } template - static inline constexpr bool is_field_base_type_v = is_same_any_v; + static inline constexpr bool is_field_base_type_v = + is_same_any_v; template static inline constexpr bool stored_as_SocketValueVariant_v = diff --git a/source/blender/nodes/NOD_geometry_nodes_execute.hh b/source/blender/nodes/NOD_geometry_nodes_execute.hh index f7c95cc5409..df57d3e39f5 100644 --- a/source/blender/nodes/NOD_geometry_nodes_execute.hh +++ b/source/blender/nodes/NOD_geometry_nodes_execute.hh @@ -10,7 +10,7 @@ #include "BLI_set.hh" #include "BKE_idprop.hh" -#include "BKE_node.hh" +#include "BKE_node.h" struct bNodeTree; struct bNodeSocket; diff --git a/source/blender/nodes/NOD_node_declaration.hh b/source/blender/nodes/NOD_node_declaration.hh index 643f156d6a4..861aa99c67b 100644 --- a/source/blender/nodes/NOD_node_declaration.hh +++ b/source/blender/nodes/NOD_node_declaration.hh @@ -12,7 +12,7 @@ #include "BLI_utildefines.h" #include "BLI_vector.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_node_types.h" @@ -179,8 +179,6 @@ class SocketDeclaration : public ItemDeclaration { bool is_unavailable = false; bool is_attribute_name = false; bool is_default_link_socket = false; - /** Puts this socket on the same line as the previous one in the UI. */ - bool align_with_previous_socket = false; InputSocketFieldType input_field_type = InputSocketFieldType::None; OutputFieldDependency output_field_dependency; @@ -358,12 +356,6 @@ class BaseSocketDeclarationBuilder { */ BaseSocketDeclarationBuilder &make_available(std::function fn); - /** - * Puts this socket on the same row as the previous socket. This only works when one of them is - * an input and the other is an output. - */ - BaseSocketDeclarationBuilder &align_with_previous(bool value = true); - int input_index() const { BLI_assert(decl_in_base_ != nullptr); @@ -467,10 +459,6 @@ class NodeDeclaration { * outputs | buttons | inputs order. Panels are only supported when using custom socket order. */ bool use_custom_socket_order = false; - /** Usually output sockets come before input sockets currently. Only some specific nodes are - * exempt from that rule for now. */ - bool allow_any_socket_order = false; - /** * True if any context was used to build this declaration. */ @@ -533,7 +521,6 @@ class NodeDeclarationBuilder { void finalize(); void use_custom_socket_order(bool enable = true); - void allow_any_socket_order(bool enable = true); template typename DeclType::Builder &add_input(StringRef name, StringRef identifier = ""); diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h index 6c41d1de260..c9d703fe28d 100644 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@ -8,7 +8,7 @@ #pragma once -#include "BKE_node.hh" +#include "BKE_node.h" #ifdef __cplusplus extern "C" { diff --git a/source/blender/nodes/NOD_socket.hh b/source/blender/nodes/NOD_socket.hh index c9a9b99e9fd..c77a1db05b5 100644 --- a/source/blender/nodes/NOD_socket.hh +++ b/source/blender/nodes/NOD_socket.hh @@ -8,7 +8,7 @@ #pragma once -#include "BKE_node.hh" +#include "BKE_node.h" struct bNode; struct bNodeTree; diff --git a/source/blender/nodes/NOD_socket_declarations.hh b/source/blender/nodes/NOD_socket_declarations.hh index 339cec813d4..033584c4fe2 100644 --- a/source/blender/nodes/NOD_socket_declarations.hh +++ b/source/blender/nodes/NOD_socket_declarations.hh @@ -158,22 +158,6 @@ class RotationBuilder : public SocketDeclarationBuilder { RotationBuilder &default_value(const math::EulerXYZ &value); }; -class MatrixBuilder; - -class Matrix : public SocketDeclaration { - public: - friend MatrixBuilder; - - using Builder = MatrixBuilder; - - bNodeSocket &build(bNodeTree &ntree, bNode &node) const override; - bool matches(const bNodeSocket &socket) const override; - bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const override; - bool can_connect(const bNodeSocket &socket) const override; -}; - -class MatrixBuilder : public SocketDeclarationBuilder {}; - class StringBuilder; class String : public SocketDeclaration { diff --git a/source/blender/nodes/NOD_socket_items.hh b/source/blender/nodes/NOD_socket_items.hh index e016452f39d..5119d5203ae 100644 --- a/source/blender/nodes/NOD_socket_items.hh +++ b/source/blender/nodes/NOD_socket_items.hh @@ -20,7 +20,7 @@ #include "BLI_string.h" #include "BLI_string_utils.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BKE_node_runtime.hh" #include "DNA_array_utils.hh" diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index 967861eee78..7bbdd2dbad1 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -267,7 +267,6 @@ DefNode(FunctionNode, FN_NODE_AXIS_ANGLE_TO_ROTATION, 0, "AXIS_ANGLE_TO_ROTATION DefNode(FunctionNode, FN_NODE_BOOLEAN_MATH, 0, "BOOLEAN_MATH", BooleanMath, "Boolean Math", "") DefNode(FunctionNode, FN_NODE_COMBINE_COLOR, 0, "COMBINE_COLOR", CombineColor, "Combine Color", "") DefNode(FunctionNode, FN_NODE_QUATERNION_TO_ROTATION, 0, "QUATERNION_TO_ROTATION", QuaternionToRotation, "Quaternion to Rotation", "") -DefNode(FunctionNode, FN_NODE_COMBINE_TRANSFORM, 0, "COMBINE_TRANSFORM", CombineTransform, "Combine Transform", "") DefNode(FunctionNode, FN_NODE_COMPARE, 0, "COMPARE", Compare, "Compare", "") DefNode(FunctionNode, FN_NODE_EULER_TO_ROTATION, 0, "EULER_TO_ROTATION", EulerToRotation, "Euler to Rotation", "") DefNode(FunctionNode, FN_NODE_FLOAT_TO_INT, def_float_to_int, "FLOAT_TO_INT", FloatToInt, "Float to Integer", "") @@ -277,9 +276,7 @@ DefNode(FunctionNode, FN_NODE_INPUT_INT, def_fn_input_int, "INPUT_INT", InputInt DefNode(FunctionNode, FN_NODE_INPUT_SPECIAL_CHARACTERS, 0, "INPUT_SPECIAL_CHARACTERS", InputSpecialCharacters, "Special Characters", "") DefNode(FunctionNode, FN_NODE_INPUT_STRING, def_fn_input_string, "INPUT_STRING", InputString, "String", "") DefNode(FunctionNode, FN_NODE_INPUT_VECTOR, def_fn_input_vector, "INPUT_VECTOR", InputVector, "Vector", "") -DefNode(FunctionNode, FN_NODE_INVERT_MATRIX, 0, "INVERT_MATRIX", InvertMatrix, "Invert Matrix", "") DefNode(FunctionNode, FN_NODE_INVERT_ROTATION, 0, "INVERT_ROTATION", InvertRotation, "Invert Rotation", "") -DefNode(FunctionNode, FN_NODE_MATRIX_MULTIPLY, 0, "MATRIX_MULTIPLY", MatrixMultiply, "Multiply Matrices", "") DefNode(FunctionNode, FN_NODE_RANDOM_VALUE, def_fn_random_value, "RANDOM_VALUE", RandomValue, "Random Value", "") DefNode(FunctionNode, FN_NODE_REPLACE_STRING, 0, "REPLACE_STRING", ReplaceString, "Replace String", "") DefNode(FunctionNode, FN_NODE_ROTATE_EULER, def_fn_rotate_euler, "ROTATE_EULER", RotateEuler, "Rotate Euler", "") @@ -289,12 +286,8 @@ DefNode(FunctionNode, FN_NODE_ROTATION_TO_AXIS_ANGLE, 0, "ROTATION_TO_AXIS_ANGLE DefNode(FunctionNode, FN_NODE_ROTATION_TO_EULER, 0, "ROTATION_TO_EULER", RotationToEuler, "Rotation to Euler", "") DefNode(FunctionNode, FN_NODE_SEPARATE_COLOR, 0, "SEPARATE_COLOR", SeparateColor, "Separate Color", "") DefNode(FunctionNode, FN_NODE_ROTATION_TO_QUATERNION, 0, "ROTATION_TO_QUATERNION", RotationToQuaternion, "Rotation to Quaternion", "") -DefNode(FunctionNode, FN_NODE_SEPARATE_TRANSFORM, 0, "SEPARATE_TRANSFORM", SeparateTransform, "Separate Transform", "") DefNode(FunctionNode, FN_NODE_SLICE_STRING, 0, "SLICE_STRING", SliceString, "Slice String", "") DefNode(FunctionNode, FN_NODE_STRING_LENGTH, 0, "STRING_LENGTH", StringLength, "String Length", "") -DefNode(FunctionNode, FN_NODE_TRANSFORM_DIRECTION, 0, "TRANSFORM_DIRECTION", TransformDirection, "Transform Direction", "") -DefNode(FunctionNode, FN_NODE_TRANSFORM_POINT, 0, "TRANSFORM_POINT", TransformPoint, "Transform Point", "") -DefNode(FunctionNode, FN_NODE_TRANSPOSE_MATRIX, 0, "TRANSPOSE_MATRIX", TransposeMatrix, "Transpose Matrix", "") DefNode(FunctionNode, FN_NODE_VALUE_TO_STRING, 0, "VALUE_TO_STRING", ValueToString, "Value to String", "") DefNode(GeometryNode, GEO_NODE_ACCUMULATE_FIELD, 0, "ACCUMULATE_FIELD", AccumulateField, "Accumulate Field", "Add the values of an evaluated field together and output the running total for each element") @@ -343,14 +336,12 @@ DefNode(GeometryNode, GEO_NODE_GEOMETRY_TO_INSTANCE, 0, "GEOMETRY_TO_INSTANCE", DefNode(GeometryNode, GEO_NODE_GET_NAMED_GRID, 0, "GET_NAMED_GRID", GetNamedGrid, "Get Named Grid", "Get volume grid from a volume geometry with the specified name") DefNode(GeometryNode, GEO_NODE_IMAGE_INFO, 0, "IMAGE_INFO", ImageInfo, "Image Info", "Retrieve information about an image") DefNode(GeometryNode, GEO_NODE_IMAGE_TEXTURE, def_geo_image_texture, "IMAGE_TEXTURE", ImageTexture, "Image Texture", "Sample values from an image texture") -DefNode(GeometryNode, GEO_NODE_IMAGE, def_geo_image, "IMAGE", InputImage, "Image", "Input image") DefNode(GeometryNode, GEO_NODE_INDEX_OF_NEAREST, 0, "INDEX_OF_NEAREST", IndexOfNearest, "Index of Nearest", "Find the nearest element in a group. Similar to the \"Sample Nearest\" node") DefNode(GeometryNode, GEO_NODE_INDEX_SWITCH, def_geo_index_switch, "INDEX_SWITCH", IndexSwitch, "Index Switch", "Choose between an arbitrary number of values with an index") +DefNode(GeometryNode, GEO_NODE_IMAGE, def_geo_image, "IMAGE", InputImage, "Image", "Input image") DefNode(GeometryNode, GEO_NODE_INPUT_ACTIVE_CAMERA, 0, "INPUT_ACTIVE_CAMERA", InputActiveCamera, "Active Camera", "Retrieve the scene's active camera") DefNode(GeometryNode, GEO_NODE_INPUT_CURVE_HANDLES, 0, "INPUT_CURVE_HANDLES", InputCurveHandlePositions, "Curve Handle Positions", "Retrieve the position of each Bézier control point's handles") DefNode(GeometryNode, GEO_NODE_INPUT_CURVE_TILT, 0, "INPUT_CURVE_TILT", InputCurveTilt, "Curve Tilt", "Retrieve the angle at each control point used to twist the curve's normal around its tangent") -DefNode(GeometryNode, GEO_NODE_INPUT_EDGE_SMOOTH, 0, "INPUT_EDGE_SMOOTH", InputEdgeSmooth, "Is Edge Smooth", "Retrieve whether each edge is marked for smooth or split normals") -DefNode(GeometryNode, GEO_NODE_INPUT_FACE_SMOOTH, 0, "INPUT_SHADE_SMOOTH", InputShadeSmooth, "Is Face Smooth", "Retrieve whether each face is marked for smooth or sharp normals") DefNode(GeometryNode, GEO_NODE_INPUT_ID, 0, "INPUT_ID", InputID, "ID", "Retrieve a stable random identifier value from the \"id\" attribute on the point domain, or the index if the attribute does not exist") DefNode(GeometryNode, GEO_NODE_INPUT_INDEX, 0, "INDEX", InputIndex, "Index", "Retrieve an integer value indicating the position of each element in the list, starting at zero") DefNode(GeometryNode, GEO_NODE_INPUT_INSTANCE_ROTATION, 0, "INPUT_INSTANCE_ROTATION", InputInstanceRotation, "Instance Rotation", "Retrieve the rotation of each instance in the geometry") @@ -371,6 +362,7 @@ DefNode(GeometryNode, GEO_NODE_INPUT_NORMAL, 0, "INPUT_NORMAL", InputNormal, "No DefNode(GeometryNode, GEO_NODE_INPUT_POSITION, 0, "POSITION", InputPosition, "Position", "Retrieve a vector indicating the location of each element") DefNode(GeometryNode, GEO_NODE_INPUT_RADIUS, 0, "INPUT_RADIUS", InputRadius, "Radius", "Retrieve the radius at each point on curve or point cloud geometry") DefNode(GeometryNode, GEO_NODE_INPUT_SCENE_TIME, 0, "INPUT_SCENE_TIME", InputSceneTime, "Scene Time", "Retrieve the current time in the scene's animation in units of seconds or frames") +DefNode(GeometryNode, GEO_NODE_INPUT_FACE_SMOOTH, 0, "INPUT_SHADE_SMOOTH", InputShadeSmooth, "Is Face Smooth", "Retrieve whether each face is marked for smooth or sharp normals") DefNode(GeometryNode, GEO_NODE_INPUT_SHORTEST_EDGE_PATHS, 0, "SHORTEST_EDGE_PATHS", InputShortestEdgePaths, "Shortest Edge Paths", "Find the shortest paths along mesh edges to selected end vertices, with customizable cost per edge") DefNode(GeometryNode, GEO_NODE_INPUT_SPLINE_CYCLIC, 0, "INPUT_SPLINE_CYCLIC",InputSplineCyclic, "Is Spline Cyclic", "Retrieve whether each spline endpoint connects to the beginning") DefNode(GeometryNode, GEO_NODE_INPUT_SPLINE_LENGTH, 0, "SPLINE_LENGTH", SplineLength, "Spline Length", "Retrieve the total length of each spline, as a distance or as a number of points") @@ -378,7 +370,6 @@ DefNode(GeometryNode, GEO_NODE_INPUT_SPLINE_RESOLUTION, 0, "INPUT_SPLINE_RESOLUT DefNode(GeometryNode, GEO_NODE_INPUT_TANGENT, 0, "INPUT_TANGENT", InputTangent, "Curve Tangent", "Retrieve the direction of curves at each control point") DefNode(GeometryNode, GEO_NODE_INSTANCE_ON_POINTS, 0, "INSTANCE_ON_POINTS", InstanceOnPoints, "Instance on Points", "Generate a reference to geometry at each of the input points, without duplicating its underlying data") DefNode(GeometryNode, GEO_NODE_INSTANCES_TO_POINTS, 0, "INSTANCES_TO_POINTS",InstancesToPoints, "Instances to Points", "Generate points at the origins of instances.\nNote: Nested instances are not affected by this node") -DefNode(GeometryNode, GEO_NODE_INTERPOLATE_CURVES, 0, "INTERPOLATE_CURVES", InterpolateCurves, "Interpolate Curves", "Generate new curves on points by interpolating between existing curves") DefNode(GeometryNode, GEO_NODE_IS_VIEWPORT, 0, "IS_VIEWPORT", IsViewport, "Is Viewport", "Retrieve whether the nodes are being evaluated for the viewport rather than the final render") DefNode(GeometryNode, GEO_NODE_JOIN_GEOMETRY, 0, "JOIN_GEOMETRY", JoinGeometry, "Join Geometry", "Merge separately generated geometries into a single one") DefNode(GeometryNode, GEO_NODE_MATERIAL_SELECTION, 0, "MATERIAL_SELECTION", MaterialSelection, "Material Selection", "Provide a selection of faces that use the specified material") @@ -407,7 +398,11 @@ DefNode(GeometryNode, GEO_NODE_MESH_TOPOLOGY_OFFSET_CORNER_IN_FACE, 0, "OFFSET_C DefNode(GeometryNode, GEO_NODE_MESH_TOPOLOGY_VERTEX_OF_CORNER, 0, "VERTEX_OF_CORNER", VertexOfCorner, "Vertex of Corner", "Retrieve the vertex each face corner is attached to") DefNode(GeometryNode, GEO_NODE_OBJECT_INFO, 0, "OBJECT_INFO", ObjectInfo, "Object Info", "Retrieve information from an object") DefNode(GeometryNode, GEO_NODE_OFFSET_POINT_IN_CURVE, 0, "OFFSET_POINT_IN_CURVE", OffsetPointInCurve, "Offset Point in Curve", "Offset a control point index within its curve") -DefNode(GeometryNode, GEO_NODE_POINTS_TO_CURVES, 0, "POINTS_TO_CURVES", PointsToCurves, "Points to Curves", "Split all points to curve by its group ID and reorder by weight") +DefNode(GeometryNode, GEO_NODE_TOOL_FACE_SET, 0, "TOOL_FACE_SET", ToolFaceSet, "Face Set", "Each face's sculpt face set value") +DefNode(GeometryNode, GEO_NODE_TOOL_3D_CURSOR, 0, "TOOL_3D_CURSOR", Tool3DCursor, "3D Cursor", "The scene's 3D cursor location and rotation") +DefNode(GeometryNode, GEO_NODE_TOOL_SELECTION, 0, "TOOL_SELECTION", ToolSelection, "Selection", "User selection of the edited geometry, for tool execution") +DefNode(GeometryNode, GEO_NODE_TOOL_SET_SELECTION, 0, "TOOL_SELECTION_SET", ToolSetSelection, "Set Selection", "Set selection of the edited geometry, for tool execution") +DefNode(GeometryNode, GEO_NODE_TOOL_SET_FACE_SET, 0, "TOOL_SET_FACE_SET", ToolSetFaceSet, "Set Face Set", "Set sculpt face set values for faces") DefNode(GeometryNode, GEO_NODE_POINTS_TO_VERTICES, 0, "POINTS_TO_VERTICES", PointsToVertices, "Points to Vertices", "Generate a mesh vertex for each point cloud point") DefNode(GeometryNode, GEO_NODE_POINTS_TO_VOLUME, 0, "POINTS_TO_VOLUME", PointsToVolume, "Points to Volume", "Generate a fog volume sphere around every point") DefNode(GeometryNode, GEO_NODE_POINTS, 0, "POINTS", Points, "Points", "Generate a point cloud with positions and radii defined by fields") @@ -446,8 +441,8 @@ DefNode(GeometryNode, GEO_NODE_SET_SPLINE_RESOLUTION, 0, "SET_SPLINE_RESOLUTION" DefNode(GeometryNode, GEO_NODE_SIMULATION_INPUT, def_geo_simulation_input, "SIMULATION_INPUT", SimulationInput, "Simulation Input", "Input data for the simulation zone") DefNode(GeometryNode, GEO_NODE_SIMULATION_OUTPUT, def_geo_simulation_output, "SIMULATION_OUTPUT", SimulationOutput, "Simulation Output", "Output data from the simulation zone") DefNode(GeometryNode, GEO_NODE_SORT_ELEMENTS, 0, "SORT_ELEMENTS", SortElements, "Sort Elements", "Rearrange geometry elements, changing their indices") -DefNode(GeometryNode, GEO_NODE_SPLIT_EDGES, 0, "SPLIT_EDGES", SplitEdges, "Split Edges", "Duplicate mesh edges and break connections with the surrounding faces") DefNode(GeometryNode, GEO_NODE_SPLIT_TO_INSTANCES, 0, "Split to Instances", SplitToInstances, "Split to Instances", "Create separate geometries containing the elements from the same group") +DefNode(GeometryNode, GEO_NODE_SPLIT_EDGES, 0, "SPLIT_EDGES", SplitEdges, "Split Edges", "Duplicate mesh edges and break connections with the surrounding faces") DefNode(GeometryNode, GEO_NODE_STORE_NAMED_ATTRIBUTE, 0, "STORE_NAMED_ATTRIBUTE", StoreNamedAttribute, "Store Named Attribute", "Store the result of a field on a geometry as an attribute with the specified name") DefNode(GeometryNode, GEO_NODE_STORE_NAMED_GRID, 0, "STORE_NAMED_GRID", StoreNamedGrid, "Store Named Grid", "Store grid data in a volume geometry with the specified name") DefNode(GeometryNode, GEO_NODE_STRING_JOIN, 0, "STRING_JOIN", StringJoin, "Join Strings", "Combine any number of input strings") @@ -456,11 +451,6 @@ DefNode(GeometryNode, GEO_NODE_SUBDIVIDE_CURVE, 0, "SUBDIVIDE_CURVE", SubdivideC DefNode(GeometryNode, GEO_NODE_SUBDIVIDE_MESH, 0, "SUBDIVIDE_MESH", SubdivideMesh, "Subdivide Mesh", "Divide mesh faces into smaller ones without changing the shape or volume, using linear interpolation to place the new vertices") DefNode(GeometryNode, GEO_NODE_SUBDIVISION_SURFACE, 0, "SUBDIVISION_SURFACE",SubdivisionSurface, "Subdivision Surface", "Divide mesh faces to form a smooth surface, using the Catmull-Clark subdivision method") DefNode(GeometryNode, GEO_NODE_SWITCH, 0, "SWITCH", Switch, "Switch", "Switch between two inputs") -DefNode(GeometryNode, GEO_NODE_TOOL_3D_CURSOR, 0, "TOOL_3D_CURSOR", Tool3DCursor, "3D Cursor", "The scene's 3D cursor location and rotation") -DefNode(GeometryNode, GEO_NODE_TOOL_FACE_SET, 0, "TOOL_FACE_SET", ToolFaceSet, "Face Set", "Each face's sculpt face set value") -DefNode(GeometryNode, GEO_NODE_TOOL_SELECTION, 0, "TOOL_SELECTION", ToolSelection, "Selection", "User selection of the edited geometry, for tool execution") -DefNode(GeometryNode, GEO_NODE_TOOL_SET_FACE_SET, 0, "TOOL_SET_FACE_SET", ToolSetFaceSet, "Set Face Set", "Set sculpt face set values for faces") -DefNode(GeometryNode, GEO_NODE_TOOL_SET_SELECTION, 0, "TOOL_SELECTION_SET", ToolSetSelection, "Set Selection", "Set selection of the edited geometry, for tool execution") DefNode(GeometryNode, GEO_NODE_TRANSFORM_GEOMETRY, 0, "TRANSFORM_GEOMETRY", Transform, "Transform Geometry", "Translate, rotate or scale the geometry") DefNode(GeometryNode, GEO_NODE_TRANSLATE_INSTANCES, 0, "TRANSLATE_INSTANCES",TranslateInstances, "Translate Instances", "Move top-level geometry instances in local or global space") DefNode(GeometryNode, GEO_NODE_TRIANGULATE, 0, "TRIANGULATE", Triangulate, "Triangulate", "Convert all faces in a mesh to triangular faces") @@ -471,6 +461,10 @@ DefNode(GeometryNode, GEO_NODE_VIEWER, 0, "VIEWER", Viewer, "Viewer", "Display t DefNode(GeometryNode, GEO_NODE_VOLUME_CUBE, 0, "VOLUME_CUBE", VolumeCube, "Volume Cube", "Generate a dense volume with a field that controls the density at each grid voxel based on its position") DefNode(GeometryNode, GEO_NODE_VOLUME_TO_MESH, 0, "VOLUME_TO_MESH", VolumeToMesh, "Volume to Mesh", "Generate a mesh on the \"surface\" of a volume") +DefNode(GeometryNode, GEO_NODE_INTERPOLATE_CURVES, 0, "INTERPOLATE_CURVES", InterpolateCurves, "Interpolate Curves", "Generate new curves on points by interpolating between existing curves") +DefNode(GeometryNode, GEO_NODE_POINTS_TO_CURVES, 0, "POINTS_TO_CURVES", PointsToCurves, "Points to Curves", "Split all points to curve by its group ID and reorder by weight") +DefNode(GeometryNode, GEO_NODE_INPUT_EDGE_SMOOTH, 0, "INPUT_EDGE_SMOOTH", InputEdgeSmooth, "Is Edge Smooth", "Retrieve whether each edge is marked for smooth or split normals") + /* undefine macros */ #undef DefNode diff --git a/source/blender/nodes/NOD_texture.h b/source/blender/nodes/NOD_texture.h index 976f0900850..b2ea0068753 100644 --- a/source/blender/nodes/NOD_texture.h +++ b/source/blender/nodes/NOD_texture.h @@ -8,7 +8,7 @@ #pragma once -#include "BKE_node.hh" +#include "BKE_node.h" #ifdef __cplusplus extern "C" { diff --git a/source/blender/nodes/NOD_zone_socket_items.hh b/source/blender/nodes/NOD_zone_socket_items.hh index 6c2dbf1fab4..bb66249ff1a 100644 --- a/source/blender/nodes/NOD_zone_socket_items.hh +++ b/source/blender/nodes/NOD_zone_socket_items.hh @@ -51,16 +51,12 @@ struct SimulationItemsAccessor { } static bool supports_socket_type(const eNodeSocketDatatype socket_type) { - if (socket_type == SOCK_MATRIX) { - return U.experimental.use_new_matrix_socket; - } return ELEM(socket_type, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA, SOCK_BOOLEAN, SOCK_ROTATION, - SOCK_MATRIX, SOCK_INT, SOCK_STRING, SOCK_GEOMETRY); @@ -119,16 +115,12 @@ struct RepeatItemsAccessor { } static bool supports_socket_type(const eNodeSocketDatatype socket_type) { - if (socket_type == SOCK_MATRIX) { - return U.experimental.use_new_matrix_socket; - } return ELEM(socket_type, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA, SOCK_BOOLEAN, SOCK_ROTATION, - SOCK_MATRIX, SOCK_INT, SOCK_STRING, SOCK_GEOMETRY, diff --git a/source/blender/nodes/composite/node_composite_tree.cc b/source/blender/nodes/composite/node_composite_tree.cc index ca07d3d92c7..022eafd75e3 100644 --- a/source/blender/nodes/composite/node_composite_tree.cc +++ b/source/blender/nodes/composite/node_composite_tree.cc @@ -15,7 +15,7 @@ #include "DNA_scene_types.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_main.hh" #include "BKE_node.hh" @@ -26,7 +26,9 @@ #include "UI_resources.hh" #include "node_common.h" +#include "node_util.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "NOD_composite.hh" @@ -178,13 +180,12 @@ void ntreeCompositExecTree(Render *render, bool rendering, int do_preview, const char *view_name, - blender::realtime_compositor::RenderContext *render_context, - blender::compositor::ProfilerData &profiler_data) + blender::realtime_compositor::RenderContext *render_context) { #ifdef WITH_COMPOSITOR_CPU - COM_execute(render, rd, scene, ntree, rendering, view_name, render_context, profiler_data); + COM_execute(render, rd, scene, ntree, rendering, view_name, render_context); #else - UNUSED_VARS(render, scene, ntree, rd, rendering, view_name, render_context, profiler_data); + UNUSED_VARS(render, scene, ntree, rd, rendering, view_name, render_context); #endif UNUSED_VARS(do_preview); diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.cc b/source/blender/nodes/composite/nodes/node_composite_blur.cc index 7b17db5dfc7..3ee31b3d5d0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_blur.cc @@ -17,6 +17,7 @@ #include "UI_resources.hh" #include "GPU_shader.h" +#include "GPU_state.h" #include "GPU_texture.h" #include "COM_algorithm_symmetric_separable_blur.hh" diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc b/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc index ed47c8a498b..59553de78b8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc @@ -14,7 +14,6 @@ #include "GPU_texture.h" -#include "COM_algorithm_parallel_reduction.hh" #include "COM_node_operation.hh" #include "COM_utilities.hh" @@ -118,13 +117,11 @@ class BokehBlurOperation : public NodeOperation { void execute_variable_size() { - const int search_radius = compute_variable_size_search_radius(); - GPUShader *shader = context().get_shader("compositor_bokeh_blur_variable_size"); GPU_shader_bind(shader); GPU_shader_uniform_1f(shader, "base_size", compute_blur_radius()); - GPU_shader_uniform_1i(shader, "search_radius", search_radius); + GPU_shader_uniform_1i(shader, "search_radius", get_max_size()); const Result &input_image = get_input("Image"); input_image.bind_as_texture(shader, "input_tx"); @@ -153,15 +150,6 @@ class BokehBlurOperation : public NodeOperation { input_mask.unbind_as_texture(); } - int compute_variable_size_search_radius() - { - const Result &input_size = get_input("Size"); - const float maximum_size = maximum_float(context(), input_size.texture()); - - const float base_size = compute_blur_radius(); - return math::clamp(int(maximum_size * base_size), 0, get_max_size()); - } - float compute_blur_radius() { const int2 image_size = get_input("Image").domain().size; diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc b/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc index 17eb50f03d1..436c49f6c1e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc +++ b/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc @@ -16,6 +16,7 @@ #include "COM_bokeh_kernel.hh" #include "COM_node_operation.hh" +#include "COM_utilities.hh" #include "node_composite_util.hh" diff --git a/source/blender/nodes/composite/nodes/node_composite_composite.cc b/source/blender/nodes/composite/nodes/node_composite_composite.cc index cac7a12e9df..1b5a455f0d6 100644 --- a/source/blender/nodes/composite/nodes/node_composite_composite.cc +++ b/source/blender/nodes/composite/nodes/node_composite_composite.cc @@ -12,6 +12,7 @@ #include "UI_resources.hh" #include "GPU_shader.h" +#include "GPU_state.h" #include "GPU_texture.h" #include "COM_node_operation.hh" @@ -91,9 +92,7 @@ class CompositeOperation : public NodeOperation { * that compositing region. */ const rcti compositing_region = context().get_compositing_region(); const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin); - const int2 upper_bound = int2(compositing_region.xmax, compositing_region.ymax); GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound); - GPU_shader_uniform_2iv(shader, "upper_bound", upper_bound); const Result &image = get_input("Image"); image.bind_as_texture(shader, "input_tx"); @@ -121,9 +120,7 @@ class CompositeOperation : public NodeOperation { * that compositing region. */ const rcti compositing_region = context().get_compositing_region(); const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin); - const int2 upper_bound = int2(compositing_region.xmax, compositing_region.ymax); GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound); - GPU_shader_uniform_2iv(shader, "upper_bound", upper_bound); const Result &image = get_input("Image"); image.bind_as_texture(shader, "input_tx"); @@ -151,9 +148,7 @@ class CompositeOperation : public NodeOperation { * that compositing region. */ const rcti compositing_region = context().get_compositing_region(); const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin); - const int2 upper_bound = int2(compositing_region.xmax, compositing_region.ymax); GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound); - GPU_shader_uniform_2iv(shader, "upper_bound", upper_bound); const Result &image = get_input("Image"); image.bind_as_texture(shader, "input_tx"); diff --git a/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc b/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc index fdbb4010913..9275c2eab34 100644 --- a/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc +++ b/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc @@ -6,6 +6,8 @@ * \ingroup cmpnodes */ +#include "RNA_access.hh" + #include "BLI_string.h" #include "UI_interface.hh" diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc index 21830dd28d3..baf8926e6a4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc @@ -30,7 +30,7 @@ #include "BKE_context.hh" #include "BKE_cryptomatte.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_lib_id.hh" #include "BKE_library.hh" diff --git a/source/blender/nodes/composite/nodes/node_composite_denoise.cc b/source/blender/nodes/composite/nodes/node_composite_denoise.cc index 7d9f689371a..9aae8fb1359 100644 --- a/source/blender/nodes/composite/nodes/node_composite_denoise.cc +++ b/source/blender/nodes/composite/nodes/node_composite_denoise.cc @@ -63,8 +63,8 @@ static void node_composit_buts_denoise(uiLayout *layout, bContext * /*C*/, Point #else /* Always supported through Accelerate framework BNNS on macOS. */ # ifndef __APPLE__ - if (!BLI_cpu_support_sse42()) { - uiItemL(layout, RPT_("Disabled, CPU with SSE4.2 is required"), ICON_ERROR); + if (!BLI_cpu_support_sse41()) { + uiItemL(layout, RPT_("Disabled, CPU with SSE4.1 is required"), ICON_ERROR); } # endif #endif @@ -76,17 +76,6 @@ static void node_composit_buts_denoise(uiLayout *layout, bContext * /*C*/, Point using namespace blender::realtime_compositor; -/* A callback to cancel the filter operations by evaluating the context's is_canceled method. The - * API specifies that true indicates the filter should continue, while false indicates it should - * stop, so invert the condition. This callback can also be used to track progress using the given - * n argument, but we currently don't make use of it. See OIDNProgressMonitorFunction in the API - * for more information. */ -[[maybe_unused]] static bool oidn_progress_monitor_function(void *user_ptr, double /*n*/) -{ - const Context *context = static_cast(user_ptr); - return !context->is_canceled(); -} - class DenoiseOperation : public NodeOperation { public: using NodeOperation::NodeOperation; @@ -119,7 +108,6 @@ class DenoiseOperation : public NodeOperation { filter.setImage("output", color, oidn::Format::Float3, width, height, 0, pixel_stride); filter.set("hdr", use_hdr()); filter.set("cleanAux", auxiliary_passes_are_clean()); - filter.setProgressMonitorFunction(oidn_progress_monitor_function, &context()); /* If the albedo input is not a single value input, download the albedo texture, denoise it * in-place if denoising auxiliary passes is needed, and set it to the main filter. */ @@ -134,7 +122,6 @@ class DenoiseOperation : public NodeOperation { "albedo", albedo, oidn::Format::Float3, width, height, 0, pixel_stride); albedoFilter.setImage( "output", albedo, oidn::Format::Float3, width, height, 0, pixel_stride); - albedoFilter.setProgressMonitorFunction(oidn_progress_monitor_function, &context()); albedoFilter.commit(); albedoFilter.execute(); } @@ -157,7 +144,6 @@ class DenoiseOperation : public NodeOperation { "normal", normal, oidn::Format::Float3, width, height, 0, pixel_stride); normalFilter.setImage( "output", normal, oidn::Format::Float3, width, height, 0, pixel_stride); - normalFilter.setProgressMonitorFunction(oidn_progress_monitor_function, &context()); normalFilter.commit(); normalFilter.execute(); } @@ -220,7 +206,7 @@ class DenoiseOperation : public NodeOperation { # ifdef __APPLE__ return true; # else - return BLI_cpu_support_sse42(); + return BLI_cpu_support_sse41(); # endif #endif } diff --git a/source/blender/nodes/composite/nodes/node_composite_file_output.cc b/source/blender/nodes/composite/nodes/node_composite_file_output.cc index 65eb35307c2..07bd4a9358c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_file_output.cc +++ b/source/blender/nodes/composite/nodes/node_composite_file_output.cc @@ -27,7 +27,7 @@ #include "BKE_image.h" #include "BKE_image_format.h" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "RNA_access.hh" #include "RNA_prototypes.h" diff --git a/source/blender/nodes/composite/nodes/node_composite_image.cc b/source/blender/nodes/composite/nodes/node_composite_image.cc index 034a81e72be..23089bbfc7a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.cc +++ b/source/blender/nodes/composite/nodes/node_composite_image.cc @@ -15,11 +15,11 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.cc b/source/blender/nodes/composite/nodes/node_composite_mask.cc index 27025322a38..6bc590b58f3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mask.cc +++ b/source/blender/nodes/composite/nodes/node_composite_mask.cc @@ -15,6 +15,7 @@ #include "COM_cached_mask.hh" #include "COM_node_operation.hh" +#include "COM_utilities.hh" #include "node_composite_util.hh" diff --git a/source/blender/nodes/composite/nodes/node_composite_split.cc b/source/blender/nodes/composite/nodes/node_composite_split.cc index 126cf40e2e5..e78959aaf35 100644 --- a/source/blender/nodes/composite/nodes/node_composite_split.cc +++ b/source/blender/nodes/composite/nodes/node_composite_split.cc @@ -6,6 +6,9 @@ * \ingroup cmpnodes */ +#include "BKE_global.h" +#include "BKE_image.h" + #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/nodes/composite/nodes/node_composite_texture.cc b/source/blender/nodes/composite/nodes/node_composite_texture.cc index 9e70f10ccac..da7a0ed20a2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_texture.cc +++ b/source/blender/nodes/composite/nodes/node_composite_texture.cc @@ -8,6 +8,7 @@ #include "COM_cached_texture.hh" #include "COM_node_operation.hh" +#include "COM_utilities.hh" #include "node_composite_util.hh" diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.cc b/source/blender/nodes/composite/nodes/node_composite_viewer.cc index 82b8fe32bc0..8edb27b8a85 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.cc +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.cc @@ -8,7 +8,7 @@ #include "BLI_math_vector_types.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "RNA_access.hh" @@ -17,6 +17,7 @@ #include "UI_resources.hh" #include "GPU_shader.h" +#include "GPU_state.h" #include "GPU_texture.h" #include "COM_node_operation.hh" @@ -123,9 +124,7 @@ class ViewerOperation : public NodeOperation { * write into that compositing region. */ const rcti compositing_region = context().get_compositing_region(); const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin); - const int2 upper_bound = int2(compositing_region.xmax, compositing_region.ymax); GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound); - GPU_shader_uniform_2iv(shader, "upper_bound", upper_bound); const Result &image = get_input("Image"); image.bind_as_texture(shader, "input_tx"); @@ -153,9 +152,7 @@ class ViewerOperation : public NodeOperation { * write into that compositing region. */ const rcti compositing_region = context().get_compositing_region(); const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin); - const int2 upper_bound = int2(compositing_region.xmax, compositing_region.ymax); GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound); - GPU_shader_uniform_2iv(shader, "upper_bound", upper_bound); const Result &image = get_input("Image"); image.bind_as_texture(shader, "input_tx"); @@ -183,9 +180,7 @@ class ViewerOperation : public NodeOperation { * write into that compositing region. */ const rcti compositing_region = context().get_compositing_region(); const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin); - const int2 upper_bound = int2(compositing_region.xmax, compositing_region.ymax); GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound); - GPU_shader_uniform_2iv(shader, "upper_bound", upper_bound); const Result &image = get_input("Image"); image.bind_as_texture(shader, "input_tx"); diff --git a/source/blender/nodes/function/CMakeLists.txt b/source/blender/nodes/function/CMakeLists.txt index f0f25ca2d2b..42571c4f057 100644 --- a/source/blender/nodes/function/CMakeLists.txt +++ b/source/blender/nodes/function/CMakeLists.txt @@ -31,10 +31,7 @@ set(SRC nodes/node_fn_input_special_characters.cc nodes/node_fn_input_string.cc nodes/node_fn_input_vector.cc - nodes/node_fn_invert_matrix.cc nodes/node_fn_invert_rotation.cc - nodes/node_fn_combine_transform.cc - nodes/node_fn_matrix_multiply.cc nodes/node_fn_quaternion_to_rotation.cc nodes/node_fn_random_value.cc nodes/node_fn_replace_string.cc @@ -45,12 +42,8 @@ set(SRC nodes/node_fn_rotation_to_euler.cc nodes/node_fn_rotation_to_quaternion.cc nodes/node_fn_separate_color.cc - nodes/node_fn_separate_transform.cc nodes/node_fn_slice_string.cc nodes/node_fn_string_length.cc - nodes/node_fn_transform_direction.cc - nodes/node_fn_transform_point.cc - nodes/node_fn_transpose_matrix.cc nodes/node_fn_value_to_string.cc node_function_util.cc diff --git a/source/blender/nodes/function/nodes/node_fn_align_euler_to_vector.cc b/source/blender/nodes/function/nodes/node_fn_align_euler_to_vector.cc index 09738288d88..339181bb4e4 100644 --- a/source/blender/nodes/function/nodes/node_fn_align_euler_to_vector.cc +++ b/source/blender/nodes/function/nodes/node_fn_align_euler_to_vector.cc @@ -6,6 +6,8 @@ #include "BLI_math_rotation.h" #include "BLI_math_vector.h" +#include "RNA_enum_types.hh" + #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/nodes/function/nodes/node_fn_axis_angle_to_rotation.cc b/source/blender/nodes/function/nodes/node_fn_axis_angle_to_rotation.cc index e4a95d61896..fd56f847f2d 100644 --- a/source/blender/nodes/function/nodes/node_fn_axis_angle_to_rotation.cc +++ b/source/blender/nodes/function/nodes/node_fn_axis_angle_to_rotation.cc @@ -3,6 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "BLI_math_axis_angle.hh" +#include "BLI_math_quaternion.hh" #include "node_function_util.hh" diff --git a/source/blender/nodes/function/nodes/node_fn_combine_transform.cc b/source/blender/nodes/function/nodes/node_fn_combine_transform.cc deleted file mode 100644 index 6ed6bccb258..00000000000 --- a/source/blender/nodes/function/nodes/node_fn_combine_transform.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* SPDX-FileCopyrightText: 2023 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#include "BLI_math_matrix.hh" -#include "BLI_math_rotation.hh" - -#include "NOD_socket_search_link.hh" - -#include "node_function_util.hh" - -namespace blender::nodes::node_fn_combine_transform_cc { - -static void node_declare(NodeDeclarationBuilder &b) -{ - b.is_function_node(); - b.add_input("Location").subtype(PROP_TRANSLATION); - b.add_input("Rotation"); - b.add_input("Scale").default_value(float3(1)).subtype(PROP_XYZ); - b.add_output("Transform"); -} - -static void search_link_ops(GatherLinkSearchOpParams ¶ms) -{ - if (U.experimental.use_new_matrix_socket) { - nodes::search_link_ops_for_basic_node(params); - } -} - -class CombineTransformFunction : public mf::MultiFunction { - public: - CombineTransformFunction() - { - static const mf::Signature signature = []() { - mf::Signature signature; - mf::SignatureBuilder builder{"Combine Transform", signature}; - builder.single_input("Location"); - builder.single_input("Rotation"); - builder.single_input("Scale"); - builder.single_output("Transform"); - return signature; - }(); - this->set_signature(&signature); - } - - void call(const IndexMask &mask, mf::Params params, mf::Context /*context*/) const override - { - const VArray location = params.readonly_single_input(0, "Location"); - const VArray rotation = params.readonly_single_input(1, "Rotation"); - const VArray scale = params.readonly_single_input(2, "Scale"); - MutableSpan transforms = params.uninitialized_single_output(3, "Transform"); - - const std::optional location_single = location.get_if_single(); - const std::optional rotation_single = rotation.get_if_single(); - const std::optional scale_single = scale.get_if_single(); - - const bool no_translation = location_single && math::is_zero(*location_single); - const bool no_rotation = rotation_single && math::angle_of(*rotation_single).radian() < 1e-7f; - const bool no_scale = scale_single && math::is_equal(*scale_single, float3(1), 1e-7f); - - if (no_rotation && no_scale) { - mask.foreach_index( - [&](const int64_t i) { transforms[i] = math::from_location(location[i]); }); - } - else if (no_translation && no_scale) { - mask.foreach_index( - [&](const int64_t i) { transforms[i] = math::from_rotation(rotation[i]); }); - } - else if (no_translation && no_rotation) { - mask.foreach_index( - [&](const int64_t i) { transforms[i] = math::from_scale(scale[i]); }); - } - else { - mask.foreach_index([&](const int64_t i) { - transforms[i] = math::from_loc_rot_scale(location[i], rotation[i], scale[i]); - }); - } - } -}; - -static void node_build_multi_function(NodeMultiFunctionBuilder &builder) -{ - static CombineTransformFunction fn; - builder.set_matching_fn(fn); -} - -static void node_register() -{ - static bNodeType ntype; - fn_node_type_base(&ntype, FN_NODE_COMBINE_TRANSFORM, "Combine Transform", NODE_CLASS_CONVERTER); - ntype.declare = node_declare; - ntype.gather_link_search_ops = search_link_ops; - ntype.build_multi_function = node_build_multi_function; - nodeRegisterType(&ntype); -} -NOD_REGISTER_NODE(node_register) - -} // namespace blender::nodes::node_fn_combine_transform_cc diff --git a/source/blender/nodes/function/nodes/node_fn_compare.cc b/source/blender/nodes/function/nodes/node_fn_compare.cc index 55f4210aaf9..71d03ac22fd 100644 --- a/source/blender/nodes/function/nodes/node_fn_compare.cc +++ b/source/blender/nodes/function/nodes/node_fn_compare.cc @@ -9,7 +9,7 @@ #include "BLI_string.h" #include "BLI_string_utf8.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/nodes/function/nodes/node_fn_input_bool.cc b/source/blender/nodes/function/nodes/node_fn_input_bool.cc index 4e1a3030c4d..e9848b61d78 100644 --- a/source/blender/nodes/function/nodes/node_fn_input_bool.cc +++ b/source/blender/nodes/function/nodes/node_fn_input_bool.cc @@ -4,6 +4,8 @@ #include "node_function_util.hh" +#include "BLI_hash.h" + #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/nodes/function/nodes/node_fn_input_int.cc b/source/blender/nodes/function/nodes/node_fn_input_int.cc index 993b66741ce..cf840a7dedf 100644 --- a/source/blender/nodes/function/nodes/node_fn_input_int.cc +++ b/source/blender/nodes/function/nodes/node_fn_input_int.cc @@ -4,6 +4,8 @@ #include "node_function_util.hh" +#include "BLI_hash.h" + #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/nodes/function/nodes/node_fn_input_vector.cc b/source/blender/nodes/function/nodes/node_fn_input_vector.cc index 44b00de2b20..f0fbc57af38 100644 --- a/source/blender/nodes/function/nodes/node_fn_input_vector.cc +++ b/source/blender/nodes/function/nodes/node_fn_input_vector.cc @@ -4,6 +4,8 @@ #include "node_function_util.hh" +#include "BLI_hash.h" + #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/nodes/function/nodes/node_fn_invert_matrix.cc b/source/blender/nodes/function/nodes/node_fn_invert_matrix.cc deleted file mode 100644 index a6a7f3413cc..00000000000 --- a/source/blender/nodes/function/nodes/node_fn_invert_matrix.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* SPDX-FileCopyrightText: 2023 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#include "BLI_math_matrix.hh" - -#include "NOD_socket_search_link.hh" - -#include "node_function_util.hh" - -namespace blender::nodes::node_fn_invert_matrix_cc { - -static void node_declare(NodeDeclarationBuilder &b) -{ - b.is_function_node(); - b.add_input("Matrix"); - b.add_output("Matrix"); -} - -static void search_link_ops(GatherLinkSearchOpParams ¶ms) -{ - if (U.experimental.use_new_matrix_socket) { - nodes::search_link_ops_for_basic_node(params); - } -} - -static void node_build_multi_function(NodeMultiFunctionBuilder &builder) -{ - static auto fn = mf::build::SI1_SO( - "Invert Matrix", [](float4x4 matrix) { return math::invert(matrix); }); - builder.set_matching_fn(fn); -} - -static void node_register() -{ - static bNodeType ntype; - fn_node_type_base(&ntype, FN_NODE_INVERT_MATRIX, "Invert Matrix", NODE_CLASS_CONVERTER); - ntype.declare = node_declare; - ntype.gather_link_search_ops = search_link_ops; - ntype.build_multi_function = node_build_multi_function; - nodeRegisterType(&ntype); -} -NOD_REGISTER_NODE(node_register) - -} // namespace blender::nodes::node_fn_invert_matrix_cc diff --git a/source/blender/nodes/function/nodes/node_fn_matrix_multiply.cc b/source/blender/nodes/function/nodes/node_fn_matrix_multiply.cc deleted file mode 100644 index 5d06b6dada3..00000000000 --- a/source/blender/nodes/function/nodes/node_fn_matrix_multiply.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* SPDX-FileCopyrightText: 2023 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#include "BLI_math_matrix.hh" - -#include "NOD_socket_search_link.hh" - -#include "node_function_util.hh" - -namespace blender::nodes::node_fn_matrix_multiply_cc { - -static void node_declare(NodeDeclarationBuilder &b) -{ - b.is_function_node(); - b.add_input("Matrix"); - b.add_input("Matrix", "Matrix_001"); - b.add_output("Matrix"); -} - -static void search_link_ops(GatherLinkSearchOpParams ¶ms) -{ - if (U.experimental.use_new_matrix_socket) { - nodes::search_link_ops_for_basic_node(params); - } -} - -static void node_build_multi_function(NodeMultiFunctionBuilder &builder) -{ - static auto fn = mf::build::SI2_SO( - "Multiply Matrices", [](float4x4 a, float4x4 b) { return a * b; }); - builder.set_matching_fn(fn); -} - -static void node_register() -{ - static bNodeType ntype; - fn_node_type_base(&ntype, FN_NODE_MATRIX_MULTIPLY, "Multiply Matrices", NODE_CLASS_CONVERTER); - ntype.declare = node_declare; - ntype.gather_link_search_ops = search_link_ops; - ntype.build_multi_function = node_build_multi_function; - nodeRegisterType(&ntype); -} -NOD_REGISTER_NODE(node_register) - -} // namespace blender::nodes::node_fn_matrix_multiply_cc diff --git a/source/blender/nodes/function/nodes/node_fn_replace_string.cc b/source/blender/nodes/function/nodes/node_fn_replace_string.cc index 54aa423e60b..7a6a8d194f0 100644 --- a/source/blender/nodes/function/nodes/node_fn_replace_string.cc +++ b/source/blender/nodes/function/nodes/node_fn_replace_string.cc @@ -2,6 +2,7 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BLI_string_utf8.h" #include "BLI_string_utils.hh" #include "node_function_util.hh" diff --git a/source/blender/nodes/function/nodes/node_fn_separate_transform.cc b/source/blender/nodes/function/nodes/node_fn_separate_transform.cc deleted file mode 100644 index 20bb5216ad1..00000000000 --- a/source/blender/nodes/function/nodes/node_fn_separate_transform.cc +++ /dev/null @@ -1,92 +0,0 @@ -/* SPDX-FileCopyrightText: 2023 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#include "BLI_math_matrix.hh" -#include "BLI_math_rotation.hh" - -#include "NOD_socket_search_link.hh" - -#include "node_function_util.hh" - -namespace blender::nodes::node_fn_separate_transform_cc { - -static void node_declare(NodeDeclarationBuilder &b) -{ - b.is_function_node(); - b.add_input("Transform"); - b.add_output("Location").subtype(PROP_TRANSLATION); - b.add_output("Rotation"); - b.add_output("Scale").subtype(PROP_XYZ); -}; - -static void search_link_ops(GatherLinkSearchOpParams ¶ms) -{ - if (U.experimental.use_new_matrix_socket) { - nodes::search_link_ops_for_basic_node(params); - } -} - -class SeparateTransformFunction : public mf::MultiFunction { - public: - SeparateTransformFunction() - { - static const mf::Signature signature = []() { - mf::Signature signature; - mf::SignatureBuilder builder{"Separate Transform", signature}; - builder.single_input("Transform"); - builder.single_output("Location", mf::ParamFlag::SupportsUnusedOutput); - builder.single_output("Rotation", mf::ParamFlag::SupportsUnusedOutput); - builder.single_output("Scale", mf::ParamFlag::SupportsUnusedOutput); - return signature; - }(); - this->set_signature(&signature); - } - - void call(const IndexMask &mask, mf::Params params, mf::Context /*context*/) const override - { - const VArraySpan transforms = params.readonly_single_input(0, "Transform"); - MutableSpan location = params.uninitialized_single_output_if_required(1, "Location"); - MutableSpan rotation = params.uninitialized_single_output_if_required( - 2, "Rotation"); - MutableSpan scale = params.uninitialized_single_output_if_required(3, "Scale"); - - if (!location.is_empty()) { - mask.foreach_index_optimized( - [&](const int64_t i) { location[i] = transforms[i].location(); }); - } - - if (rotation.is_empty() && !scale.is_empty()) { - mask.foreach_index([&](const int64_t i) { location[i] = math::to_scale(transforms[i]); }); - } - else if (!rotation.is_empty() && scale.is_empty()) { - mask.foreach_index( - [&](const int64_t i) { rotation[i] = math::to_quaternion(transforms[i]); }); - } - else if (!rotation.is_empty() && !scale.is_empty()) { - mask.foreach_index([&](const int64_t i) { - math::to_rot_scale(float3x3(transforms[i]), rotation[i], scale[i]); - }); - } - } -}; - -static void node_build_multi_function(NodeMultiFunctionBuilder &builder) -{ - static SeparateTransformFunction fn; - builder.set_matching_fn(fn); -} - -static void node_register() -{ - static bNodeType ntype; - fn_node_type_base( - &ntype, FN_NODE_SEPARATE_TRANSFORM, "Separate Transform", NODE_CLASS_CONVERTER); - ntype.declare = node_declare; - ntype.gather_link_search_ops = search_link_ops; - ntype.build_multi_function = node_build_multi_function; - nodeRegisterType(&ntype); -} -NOD_REGISTER_NODE(node_register) - -} // namespace blender::nodes::node_fn_separate_transform_cc diff --git a/source/blender/nodes/function/nodes/node_fn_transform_direction.cc b/source/blender/nodes/function/nodes/node_fn_transform_direction.cc deleted file mode 100644 index 952dcb66708..00000000000 --- a/source/blender/nodes/function/nodes/node_fn_transform_direction.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* SPDX-FileCopyrightText: 2023 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#include "BLI_math_matrix.hh" - -#include "NOD_socket_search_link.hh" - -#include "node_function_util.hh" - -namespace blender::nodes::node_fn_transform_direction_cc { - -static void node_declare(NodeDeclarationBuilder &b) -{ - b.is_function_node(); - b.add_input("Direction").subtype(PROP_XYZ); - b.add_input("Transform"); - b.add_output("Direction").subtype(PROP_XYZ); -} - -static void search_link_ops(GatherLinkSearchOpParams ¶ms) -{ - if (U.experimental.use_new_matrix_socket) { - nodes::search_link_ops_for_basic_node(params); - } -} - -static void node_build_multi_function(NodeMultiFunctionBuilder &builder) -{ - static auto fn = mf::build::SI2_SO( - "Transform Direction", [](float3 direction, float4x4 matrix) { - return math::transform_direction(matrix, direction); - }); - builder.set_matching_fn(fn); -} - -static void node_register() -{ - static bNodeType ntype; - fn_node_type_base( - &ntype, FN_NODE_TRANSFORM_DIRECTION, "Transform Direction", NODE_CLASS_CONVERTER); - ntype.declare = node_declare; - ntype.gather_link_search_ops = search_link_ops; - ntype.build_multi_function = node_build_multi_function; - nodeRegisterType(&ntype); -} -NOD_REGISTER_NODE(node_register) - -} // namespace blender::nodes::node_fn_transform_direction_cc diff --git a/source/blender/nodes/function/nodes/node_fn_transform_point.cc b/source/blender/nodes/function/nodes/node_fn_transform_point.cc deleted file mode 100644 index ef04cce0a62..00000000000 --- a/source/blender/nodes/function/nodes/node_fn_transform_point.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* SPDX-FileCopyrightText: 2023 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#include "BLI_math_matrix.hh" - -#include "NOD_socket_search_link.hh" - -#include "node_function_util.hh" - -namespace blender::nodes::node_fn_transform_point_cc { - -static void node_declare(NodeDeclarationBuilder &b) -{ - b.is_function_node(); - b.add_input("Vector").subtype(PROP_XYZ); - b.add_input("Transform"); - b.add_output("Vector").subtype(PROP_XYZ); -} - -static void search_link_ops(GatherLinkSearchOpParams ¶ms) -{ - if (U.experimental.use_new_matrix_socket) { - nodes::search_link_ops_for_basic_node(params); - } -} - -static void node_build_multi_function(NodeMultiFunctionBuilder &builder) -{ - static auto fn = mf::build::SI2_SO( - "Transform Point", - [](float3 point, float4x4 matrix) { return math::transform_point(matrix, point); }); - builder.set_matching_fn(fn); -} - -static void node_register() -{ - static bNodeType ntype; - fn_node_type_base(&ntype, FN_NODE_TRANSFORM_POINT, "Transform Point", NODE_CLASS_CONVERTER); - ntype.declare = node_declare; - ntype.gather_link_search_ops = search_link_ops; - ntype.build_multi_function = node_build_multi_function; - nodeRegisterType(&ntype); -} -NOD_REGISTER_NODE(node_register) - -} // namespace blender::nodes::node_fn_transform_point_cc diff --git a/source/blender/nodes/function/nodes/node_fn_transpose_matrix.cc b/source/blender/nodes/function/nodes/node_fn_transpose_matrix.cc deleted file mode 100644 index 31d46770be1..00000000000 --- a/source/blender/nodes/function/nodes/node_fn_transpose_matrix.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* SPDX-FileCopyrightText: 2023 Blender Authors - * - * SPDX-License-Identifier: GPL-2.0-or-later */ - -#include "BLI_math_matrix.hh" - -#include "NOD_socket_search_link.hh" - -#include "node_function_util.hh" - -namespace blender::nodes::node_fn_transpose_matrix_cc { - -static void node_declare(NodeDeclarationBuilder &b) -{ - b.is_function_node(); - b.add_input("Matrix"); - b.add_output("Matrix"); -} - -static void search_link_ops(GatherLinkSearchOpParams ¶ms) -{ - if (U.experimental.use_new_matrix_socket) { - nodes::search_link_ops_for_basic_node(params); - } -} - -static void node_build_multi_function(NodeMultiFunctionBuilder &builder) -{ - static auto fn = mf::build::SI1_SO( - "Transpose Matrix", [](float4x4 matrix) { return math::transpose(matrix); }); - builder.set_matching_fn(fn); -} - -static void node_register() -{ - static bNodeType ntype; - fn_node_type_base(&ntype, FN_NODE_TRANSPOSE_MATRIX, "Transpose Matrix", NODE_CLASS_CONVERTER); - ntype.declare = node_declare; - ntype.gather_link_search_ops = search_link_ops; - ntype.build_multi_function = node_build_multi_function; - nodeRegisterType(&ntype); -} -NOD_REGISTER_NODE(node_register) - -} // namespace blender::nodes::node_fn_transpose_matrix_cc diff --git a/source/blender/nodes/geometry/node_geometry_tree.cc b/source/blender/nodes/geometry/node_geometry_tree.cc index 6eba7e1490d..f2fbb363c55 100644 --- a/source/blender/nodes/geometry/node_geometry_tree.cc +++ b/source/blender/nodes/geometry/node_geometry_tree.cc @@ -19,11 +19,12 @@ #include "DNA_node_types.h" #include "DNA_space_types.h" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "UI_resources.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "node_common.h" @@ -96,15 +97,6 @@ static bool geometry_node_tree_validate_link(eNodeSocketDatatype type_a, /* Floats and vectors implicitly convert to rotations. */ return true; } - - /* Support implicit conversions between matrices and rotations. */ - if (type_a == SOCK_MATRIX && type_b == SOCK_ROTATION) { - return true; - } - if (type_a == SOCK_ROTATION && type_b == SOCK_MATRIX) { - return true; - } - if (type_a == SOCK_ROTATION && type_b == SOCK_VECTOR) { /* Rotations implicitly convert to vectors. */ return true; @@ -115,16 +107,12 @@ static bool geometry_node_tree_validate_link(eNodeSocketDatatype type_a, static bool geometry_node_tree_socket_type_valid(bNodeTreeType * /*treetype*/, bNodeSocketType *socket_type) { - if (socket_type->type == SOCK_MATRIX) { - return U.experimental.use_new_matrix_socket; - } return blender::bke::nodeIsStaticSocketType(socket_type) && ELEM(socket_type->type, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA, SOCK_BOOLEAN, SOCK_ROTATION, - SOCK_MATRIX, SOCK_INT, SOCK_STRING, SOCK_OBJECT, diff --git a/source/blender/nodes/geometry/node_geometry_util.cc b/source/blender/nodes/geometry/node_geometry_util.cc index 202daab6d58..7da1b446611 100644 --- a/source/blender/nodes/geometry/node_geometry_util.cc +++ b/source/blender/nodes/geometry/node_geometry_util.cc @@ -7,7 +7,11 @@ #include "DNA_space_types.h" +#include "BKE_context.hh" +#include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_node.hh" +#include "BKE_pointcloud.hh" #include "NOD_rna_define.hh" #include "NOD_socket_search_link.hh" @@ -50,9 +54,6 @@ const EnumPropertyItem *attribute_type_type_with_socket_fn(bContext * /*C*/, bool generic_attribute_type_supported(const EnumPropertyItem &item) { - if (item.value == SOCK_MATRIX) { - return U.experimental.use_new_matrix_socket; - } return ELEM(item.value, CD_PROP_FLOAT, CD_PROP_FLOAT2, @@ -61,8 +62,7 @@ bool generic_attribute_type_supported(const EnumPropertyItem &item) CD_PROP_BOOL, CD_PROP_INT32, CD_PROP_BYTE_COLOR, - CD_PROP_QUATERNION, - CD_PROP_FLOAT4X4); + CD_PROP_QUATERNION); } const EnumPropertyItem *domain_experimental_grease_pencil_version3_fn(bContext * /*C*/, diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc index 77f473ca155..1b5a8b4d453 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc @@ -7,6 +7,8 @@ #include "UI_interface.hh" #include "UI_resources.hh" +#include "BKE_attribute_math.hh" + #include "NOD_socket_search_link.hh" #include "RNA_enum_types.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc index 67fddcdb65c..b0010e2955a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc @@ -11,6 +11,7 @@ #include "UI_resources.hh" #include "BLI_array_utils.hh" +#include "BLI_math_base_safe.h" #include "NOD_socket_search_link.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_blur_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_blur_attribute.cc index 9084f84608c..add95916d7e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_blur_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_blur_attribute.cc @@ -88,10 +88,6 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) /* Don't implement quaternion blurring for now. */ return; } - if (fixed_data_type == CD_PROP_FLOAT4X4) { - /* Don't implement matrix blurring for now. */ - return; - } if (fixed_data_type == CD_PROP_BOOL) { /* This node does not support boolean sockets, use integer instead. */ fixed_data_type = CD_PROP_INT32; diff --git a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc index 78ffb9b705a..fd8288b2e59 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc @@ -2,6 +2,7 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BLI_math_matrix.h" #include "BLI_string.h" #include "DNA_collection_types.h" @@ -11,7 +12,7 @@ #include "UI_interface.hh" #include "UI_resources.hh" -#include "BKE_collection.hh" +#include "BKE_collection.h" #include "BKE_instances.hh" #include "node_geometry_util.hh" @@ -96,7 +97,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (!reset_children) { transform.location() += float3(child_collection->instance_offset); if (use_relative_transform) { - transform = self_object->world_to_object() * transform; + transform = float4x4(self_object->world_to_object) * transform; } else { transform.location() -= float3(collection->instance_offset); @@ -110,12 +111,12 @@ static void node_geo_exec(GeoNodeExecParams params) float4x4 transform = float4x4::identity(); if (!reset_children) { if (use_relative_transform) { - transform = self_object->world_to_object(); + transform = float4x4(self_object->world_to_object); } else { transform.location() -= float3(collection->instance_offset); } - transform *= child_object->object_to_world(); + transform *= float4x4(child_object->object_to_world); } entries.append({handle, &(child_object->id.name[2]), transform}); } @@ -133,7 +134,7 @@ static void node_geo_exec(GeoNodeExecParams params) float4x4 transform = float4x4::identity(); if (use_relative_transform) { transform.location() = collection->instance_offset; - transform = self_object->world_to_object() * transform; + transform = float4x4_view(self_object->world_to_object) * transform; } const int handle = instances->add_reference(*collection); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc index c5a1d645b83..dfbff4ee98b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc @@ -6,6 +6,7 @@ #include "BKE_curves.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "node_geometry_util.hh" @@ -64,7 +65,7 @@ class EndpointFieldInput final : public bke::CurvesFieldInput { Array selection(curves.points_num(), false); MutableSpan selection_span = selection.as_mutable_span(); const OffsetIndices points_by_curve = curves.points_by_curve(); - devirtualize_varray2(start_size, end_size, [&](const auto start_size, const auto end_size) { + devirtualize_varray2(start_size, end_size, [&](const auto &start_size, const auto &end_size) { threading::parallel_for(curves.curves_range(), 1024, [&](IndexRange curves_range) { for (const int i : curves_range) { const IndexRange points = points_by_curve[i]; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc index dd7176e3231..6ff5d3093d5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc @@ -4,6 +4,7 @@ #include +#include "BLI_math_base_safe.h" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc index bbed8a0f842..e1238035733 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc @@ -66,8 +66,17 @@ static void node_geo_exec(GeoNodeExecParams params) return; } + if (geometry::try_curves_conversion_in_place( + selection, dst_type, [&]() -> bke::CurvesGeometry & { + return geometry_set.get_curves_for_write()->geometry.wrap(); + })) + { + return; + } + bke::CurvesGeometry dst_curves = geometry::convert_curves( src_curves, selection, dst_type, params.get_output_propagation_info("Curve")); + Curves *dst_curves_id = bke::curves_new_nomain(std::move(dst_curves)); bke::curves_copy_parameters(src_curves_id, *dst_curves_id); geometry_set.replace_curves(dst_curves_id); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc index 24c16affb5e..13392b4e9df 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc @@ -7,6 +7,7 @@ #include "GEO_subdivide_curves.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "node_geometry_util.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc index a6ec69e35df..8bab6397de4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_mesh.cc @@ -8,6 +8,7 @@ #include "BKE_grease_pencil.hh" #include "BKE_instances.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "GEO_randomize.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index 0866ae5fc6e..88d0a2cbe98 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -5,6 +5,7 @@ #include "BLI_array.hh" #include "BLI_math_matrix.hh" #include "BLI_task.hh" +#include "BLI_timeit.hh" #include "DNA_pointcloud_types.h" diff --git a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc index ac727161288..1c7ae47d269 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc @@ -7,12 +7,19 @@ #include "BKE_editmesh.hh" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_mesh_wrapper.hh" #include "BKE_modifier.hh" +#include "BKE_type_conversions.hh" #include "BLI_math_matrix.hh" #include "BLI_task.hh" +#include "UI_interface.hh" +#include "UI_resources.hh" + +#include "NOD_socket_search_link.hh" + #include "GEO_reverse_uv_sampler.hh" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc index 22e713e43e1..6bcf9b16056 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc @@ -7,6 +7,16 @@ #include "UI_interface.hh" #include "UI_resources.hh" +#include "DNA_grease_pencil_types.h" +#include "DNA_pointcloud_types.h" + +#include "BKE_curves.hh" +#include "BKE_grease_pencil.hh" +#include "BKE_instances.hh" +#include "BKE_mesh.hh" +#include "BKE_pointcloud.hh" + +#include "GEO_mesh_copy_selection.hh" #include "GEO_separate_geometry.hh" #include "RNA_enum_types.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc index de3c9d5308e..f3676dff2f8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc @@ -5,14 +5,18 @@ #include "BLI_kdtree.h" #include "BLI_math_geom.h" #include "BLI_math_rotation.h" +#include "BLI_math_rotation.hh" #include "BLI_noise.hh" #include "BLI_rand.hh" #include "BLI_task.hh" +#include "BLI_timeit.hh" #include "DNA_pointcloud_types.h" #include "BKE_attribute_math.hh" +#include "BKE_bvhutils.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_mesh_sample.hh" #include "BKE_pointcloud.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc index 27b55191b34..5bf16e880a8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_edge_paths_to_selection.cc @@ -2,6 +2,7 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BKE_attribute_math.hh" #include "BKE_mesh.hh" #include "BLI_map.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc b/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc index 36935d0a7e5..d1d0f79177a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_evaluate_at_index.cc @@ -9,6 +9,8 @@ #include "UI_interface.hh" #include "UI_resources.hh" +#include "BKE_attribute_math.hh" + #include "BLI_task.hh" #include "RNA_enum_types.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_evaluate_on_domain.cc b/source/blender/nodes/geometry/nodes/node_geo_evaluate_on_domain.cc index eb46f020d4f..4086ff5fb3d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_evaluate_on_domain.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_evaluate_on_domain.cc @@ -9,7 +9,9 @@ #include "UI_interface.hh" #include "UI_resources.hh" +#include "BKE_attribute_math.hh" #include "BKE_geometry_fields.hh" +#include "BKE_grease_pencil.hh" #include "BLI_task.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_image_info.cc b/source/blender/nodes/geometry/nodes/node_geo_image_info.cc index afe777879e5..46a35356487 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_image_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_image_info.cc @@ -4,9 +4,12 @@ #include "BKE_image.h" +#include "BLI_path_util.h" + #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "node_geometry_util.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc index 56dd006b200..99d652df20c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc @@ -8,6 +8,7 @@ #include "BLI_math_vector_types.hh" #include "BLI_threads.h" +#include "BLI_timeit.hh" #include "IMB_colormanagement.hh" #include "IMB_imbuf.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc b/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc index bffee8b412b..cec273a8708 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_index_switch.cc @@ -4,6 +4,8 @@ #include "node_geometry_util.hh" +#include "BLI_array_utils.hh" + #include "UI_interface.hh" #include "UI_resources.hh" @@ -290,15 +292,11 @@ static void node_rna(StructRNA *srna) *r_free = true; return enum_items_filter(rna_enum_node_socket_data_type_items, [](const EnumPropertyItem &item) -> bool { - if (item.value == SOCK_MATRIX) { - return U.experimental.use_new_matrix_socket; - } return ELEM(item.value, SOCK_FLOAT, SOCK_INT, SOCK_BOOLEAN, SOCK_ROTATION, - SOCK_MATRIX, SOCK_VECTOR, SOCK_STRING, SOCK_RGBA, diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_active_camera.cc b/source/blender/nodes/geometry/nodes/node_geo_input_active_camera.cc index 9cf0c70f753..e93907f079c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_active_camera.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_active_camera.cc @@ -2,6 +2,8 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BKE_scene.h" + #include "DEG_depsgraph_query.hh" #include "node_geometry_util.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_scene_time.cc b/source/blender/nodes/geometry/nodes/node_geo_input_scene_time.cc index 092c9829963..e7a9fda657a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_scene_time.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_scene_time.cc @@ -2,7 +2,7 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc index e8ba55d91ba..d43059578e9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc @@ -2,11 +2,17 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "DNA_collection_types.h" + #include "BLI_array_utils.hh" +#include "BLI_hash.h" #include "BLI_math_matrix.h" #include "BLI_math_matrix.hh" #include "BLI_task.hh" +#include "UI_interface.hh" +#include "UI_resources.hh" + #include "BKE_attribute_math.hh" #include "BKE_curves.hh" #include "BKE_grease_pencil.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc index 8fd4a2779f6..0db334ca56e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_interpolate_curves.cc @@ -12,9 +12,12 @@ #include "BLI_task.hh" #include "BKE_curves.hh" +#include "BKE_curves_utils.hh" #include "GEO_randomize.hh" +#include "DNA_pointcloud_types.h" + namespace blender::nodes::node_geo_interpolate_curves_cc { static void node_declare(NodeDeclarationBuilder &b) diff --git a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc index 5b0f27de3ab..fe4a03d33a7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc @@ -4,6 +4,8 @@ #include "GEO_join_geometries.hh" +#include "BKE_instances.hh" + #include "node_geometry_util.hh" namespace blender::nodes::node_geo_join_geometry_cc { diff --git a/source/blender/nodes/geometry/nodes/node_geo_material_replace.cc b/source/blender/nodes/geometry/nodes/node_geo_material_replace.cc index f85fc5ce554..d95e76151a4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_material_replace.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_material_replace.cc @@ -7,6 +7,7 @@ #include "DNA_mesh_types.h" #include "BKE_grease_pencil.hh" +#include "BKE_material.h" namespace blender::nodes::node_geo_material_replace_cc { diff --git a/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc index 529037fdf42..88ead0b3cac 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_material_selection.cc @@ -4,12 +4,16 @@ #include "node_geometry_util.hh" +#include "UI_interface.hh" +#include "UI_resources.hh" + #include "DNA_mesh_types.h" #include "BLI_task.hh" #include "BKE_curves.hh" #include "BKE_grease_pencil.hh" +#include "BKE_material.h" namespace blender::nodes::node_geo_material_selection_cc { diff --git a/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc b/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc index 8f17319e67c..8f26387077c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_menu_switch.cc @@ -8,6 +8,7 @@ #include "DNA_node_types.h" +#include "BLI_array_utils.hh" #include "BLI_string.h" #include "FN_multi_function.hh" @@ -19,8 +20,11 @@ #include "NOD_socket.hh" #include "NOD_socket_search_link.hh" +#include "RNA_access.hh" #include "RNA_enum_types.hh" +#include "WM_api.hh" + namespace blender::nodes::node_geo_menu_switch_cc { NODE_STORAGE_FUNCS(NodeMenuSwitch) diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc index eaef793d424..1e3d0fc361c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_subdivide.cc @@ -2,9 +2,11 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BKE_mesh.hh" #include "BKE_subdiv.hh" #include "BKE_subdiv_mesh.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "GEO_randomize.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc index a59f6d97d58..b1213cf536a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc @@ -10,6 +10,7 @@ #include "BKE_attribute_math.hh" #include "BKE_customdata.hh" +#include "BKE_mesh.hh" #include "BKE_pointcloud.hh" #include "NOD_rna_define.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc index e9dbcac39a6..2a9a9fd398b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc @@ -2,10 +2,15 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "DEG_depsgraph_query.hh" #include "node_geometry_util.hh" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" +#include "BKE_mesh_wrapper.hh" +#include "BKE_object.hh" +#include "BKE_volume.hh" #include "GEO_mesh_to_volume.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc index fe55de16905..82eef5b7d1d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc @@ -3,6 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "BKE_mesh.hh" +#include "BKE_mesh_mapping.hh" #include "BLI_array_utils.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_corner.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_corner.cc index b54fbcf6abb..184a8f8069d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_corner.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_corner.cc @@ -3,6 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "BKE_mesh.hh" +#include "BKE_mesh_mapping.hh" #include "BLI_task.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_face_of_corner.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_face_of_corner.cc index dc169bbef2c..00214bb7b8a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_face_of_corner.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_face_of_corner.cc @@ -3,6 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "BKE_mesh.hh" +#include "BKE_mesh_mapping.hh" #include "node_geometry_util.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_offset_corner_in_face.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_offset_corner_in_face.cc index ed605494d28..f985febe525 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_offset_corner_in_face.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_offset_corner_in_face.cc @@ -3,6 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "BKE_mesh.hh" +#include "BKE_mesh_mapping.hh" #include "BLI_task.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_object_info.cc b/source/blender/nodes/geometry/nodes/node_geo_object_info.cc index 281c1e182ab..35bd7c607c2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_object_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_object_info.cc @@ -54,8 +54,8 @@ static void node_geo_exec(GeoNodeExecParams params) return; } - const float4x4 object_matrix = object->object_to_world(); - const float4x4 transform = self_object->world_to_object() * object_matrix; + const float4x4 object_matrix = float4x4(object->object_to_world); + const float4x4 transform = float4x4(self_object->world_to_object) * object_matrix; float3 location, scale; math::Quaternion rotation; diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc index fef2eddd429..c59db61737d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc @@ -6,6 +6,7 @@ #include "DNA_pointcloud_types.h" +#include "BKE_attribute_math.hh" #include "BKE_customdata.hh" #include "BKE_mesh.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_proximity.cc b/source/blender/nodes/geometry/nodes/node_geo_proximity.cc index d9efc1f1992..d7c52f761b4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_proximity.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_proximity.cc @@ -4,6 +4,9 @@ #include "BLI_math_vector.h" #include "BLI_task.hh" +#include "BLI_timeit.hh" + +#include "DNA_mesh_types.h" #include "BKE_bvhutils.hh" #include "BKE_geometry_set.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_realize_instances.cc b/source/blender/nodes/geometry/nodes/node_geo_realize_instances.cc index 3a2072cd17f..5ecb40cca9d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_realize_instances.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_realize_instances.cc @@ -6,6 +6,7 @@ #include "GEO_realize_instances.hh" +#include "UI_interface.hh" #include "UI_resources.hh" namespace blender::nodes::node_geo_realize_instances_cc { diff --git a/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc index f6e281d7260..22753b27ff9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc @@ -4,6 +4,8 @@ #include "node_geometry_util.hh" +#include "NOD_socket_search_link.hh" + #include namespace blender::nodes::node_geo_remove_attribute_cc { diff --git a/source/blender/nodes/geometry/nodes/node_geo_repeat.cc b/source/blender/nodes/geometry/nodes/node_geo_repeat.cc index ea64436aa18..09425cde30e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_repeat.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_repeat.cc @@ -5,6 +5,15 @@ #include "BLI_string.h" #include "BLI_string_utf8.h" +#include "BKE_compute_contexts.hh" +#include "BKE_scene.h" + +#include "DEG_depsgraph_query.hh" + +#include "UI_interface.hh" +#include "UI_resources.hh" + +#include "NOD_geometry.hh" #include "NOD_socket.hh" #include "NOD_zone_socket_items.hh" @@ -20,8 +29,6 @@ NODE_STORAGE_FUNCS(NodeGeometryRepeatInput); static void node_declare(NodeDeclarationBuilder &b) { - b.use_custom_socket_order(); - b.allow_any_socket_order(); b.add_input("Iterations").min(0).default_value(1); const bNode *node = b.node_or_null(); @@ -38,7 +45,7 @@ static void node_declare(NodeDeclarationBuilder &b) const StringRef name = item.name ? item.name : ""; const std::string identifier = RepeatItemsAccessor::socket_identifier_for_item(item); auto &input_decl = b.add_input(socket_type, name, identifier); - auto &output_decl = b.add_output(socket_type, name, identifier).align_with_previous(); + auto &output_decl = b.add_output(socket_type, name, identifier); if (socket_type_supports_fields(socket_type)) { input_decl.supports_field(); output_decl.dependent_field({input_decl.input_index()}); @@ -47,7 +54,7 @@ static void node_declare(NodeDeclarationBuilder &b) } } b.add_input("", "__extend__"); - b.add_output("", "__extend__").align_with_previous(); + b.add_output("", "__extend__"); } static void node_init(bNodeTree * /*tree*/, bNode *node) @@ -100,8 +107,6 @@ NODE_STORAGE_FUNCS(NodeGeometryRepeatOutput); static void node_declare(NodeDeclarationBuilder &b) { - b.use_custom_socket_order(); - b.allow_any_socket_order(); const bNode *node = b.node_or_null(); if (node) { const NodeGeometryRepeatOutput &storage = node_storage(*node); @@ -111,7 +116,7 @@ static void node_declare(NodeDeclarationBuilder &b) const StringRef name = item.name ? item.name : ""; const std::string identifier = RepeatItemsAccessor::socket_identifier_for_item(item); auto &input_decl = b.add_input(socket_type, name, identifier); - auto &output_decl = b.add_output(socket_type, name, identifier).align_with_previous(); + auto &output_decl = b.add_output(socket_type, name, identifier); if (socket_type_supports_fields(socket_type)) { input_decl.supports_field(); output_decl.dependent_field({input_decl.input_index()}); @@ -119,7 +124,7 @@ static void node_declare(NodeDeclarationBuilder &b) } } b.add_input("", "__extend__"); - b.add_output("", "__extend__").align_with_previous(); + b.add_output("", "__extend__"); } static void node_init(bNodeTree * /*tree*/, bNode *node) diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc index f6a21460a54..ecfda215b04 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc @@ -2,10 +2,13 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BLI_array_utils.hh" + #include "DNA_pointcloud_types.h" #include "BKE_bvhutils.hh" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "NOD_rna_define.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest_surface.cc index 54fc8c108f8..805efb40ff2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest_surface.cc @@ -14,8 +14,6 @@ #include "RNA_enum_types.hh" -#include "BLI_task.hh" - #include "node_geometry_util.hh" namespace blender::nodes::node_geo_sample_nearest_surface_cc { @@ -31,22 +29,12 @@ static void node_declare(NodeDeclarationBuilder &b) const eCustomDataType data_type = eCustomDataType(node->custom1); b.add_input(data_type, "Value").hide_value().field_on_all(); } - b.add_input("Group ID") - .hide_value() - .field_on_all() - .description( - "Splits the faces of the input mesh into groups which can be sampled individually"); b.add_input("Sample Position").implicit_field(implicit_field_inputs::position); - b.add_input("Sample Group ID").hide_value().supports_field(); if (node != nullptr) { const eCustomDataType data_type = eCustomDataType(node->custom1); - b.add_output(data_type, "Value").dependent_field({3, 4}); + b.add_output(data_type, "Value").dependent_field({2}); } - b.add_output("Is Valid") - .dependent_field({3, 4}) - .description( - "Whether the sampling was successfull. It can fail when the sampled group is empty"); } static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) @@ -76,105 +64,46 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) } } +static void get_closest_mesh_tris(const Mesh &mesh, + const VArray &positions, + const IndexMask &mask, + const MutableSpan r_tri_indices, + const MutableSpan r_distances_sq, + const MutableSpan r_positions) +{ + BLI_assert(mesh.faces_num > 0); + BVHTreeFromMesh tree_data; + BKE_bvhtree_from_mesh_get(&tree_data, &mesh, BVHTREE_FROM_CORNER_TRIS, 2); + get_closest_in_bvhtree(tree_data, positions, mask, r_tri_indices, r_distances_sq, r_positions); + free_bvhtree_from_mesh(&tree_data); +} + class SampleNearestSurfaceFunction : public mf::MultiFunction { - private: GeometrySet source_; - Array bvh_trees_; - VectorSet group_indices_; public: - SampleNearestSurfaceFunction(GeometrySet geometry, const Field &group_id_field) - : source_(std::move(geometry)) + SampleNearestSurfaceFunction(GeometrySet geometry) : source_(std::move(geometry)) { source_.ensure_owns_direct_data(); static const mf::Signature signature = []() { mf::Signature signature; mf::SignatureBuilder builder{"Sample Nearest Surface", signature}; builder.single_input("Position"); - builder.single_input("Sample ID"); builder.single_output("Triangle Index"); builder.single_output("Sample Position"); - builder.single_output("Is Valid", mf::ParamFlag::SupportsUnusedOutput); return signature; }(); this->set_signature(&signature); - - const Mesh &mesh = *source_.get_mesh(); - - /* Compute group ids on mesh. */ - bke::MeshFieldContext field_context{mesh, bke::AttrDomain::Face}; - FieldEvaluator field_evaluator{field_context, mesh.faces_num}; - field_evaluator.add(group_id_field); - field_evaluator.evaluate(); - VArraySpan group_ids_span = field_evaluator.get_evaluated(0); - - /* Compute an #IndexMask for every unique group id. */ - group_indices_.add_multiple(group_ids_span); - const int groups_num = group_indices_.size(); - IndexMaskMemory memory; - Array group_masks(groups_num); - IndexMask::from_groups( - IndexMask(mesh.faces_num), - memory, - [&](const int i) { return group_indices_.index_of(group_ids_span[i]); }, - group_masks); - - /* Construct BVH tree for each group. */ - bvh_trees_.reinitialize(groups_num); - threading::parallel_for(IndexRange(groups_num), 16, [&](const IndexRange range) { - for (const int group_i : range) { - const IndexMask &group_mask = group_masks[group_i]; - BVHTreeFromMesh &bvh = bvh_trees_[group_i]; - if (group_mask.size() == mesh.faces_num) { - BKE_bvhtree_from_mesh_get(&bvh, &mesh, BVHTREE_FROM_CORNER_TRIS, 2); - } - else { - BKE_bvhtree_from_mesh_tris_init(mesh, group_mask, bvh); - } - } - }); - } - - ~SampleNearestSurfaceFunction() - { - for (BVHTreeFromMesh &tree : bvh_trees_) { - free_bvhtree_from_mesh(&tree); - } } void call(const IndexMask &mask, mf::Params params, mf::Context /*context*/) const override { const VArray &positions = params.readonly_single_input(0, "Position"); - const VArray &sample_ids = params.readonly_single_input(1, "Sample ID"); - MutableSpan triangle_index = params.uninitialized_single_output(2, "Triangle Index"); + MutableSpan triangle_index = params.uninitialized_single_output(1, "Triangle Index"); MutableSpan sample_position = params.uninitialized_single_output( - 3, "Sample Position"); - MutableSpan is_valid_span = params.uninitialized_single_output_if_required( - 4, "Is Valid"); - - mask.foreach_index([&](const int i) { - const float3 position = positions[i]; - const int sample_id = sample_ids[i]; - const int group_index = group_indices_.index_of_try(sample_id); - if (group_index == -1) { - triangle_index[i] = -1; - sample_position[i] = float3(0, 0, 0); - if (!is_valid_span.is_empty()) { - is_valid_span[i] = false; - } - return; - } - const BVHTreeFromMesh &bvh = bvh_trees_[group_index]; - BVHTreeNearest nearest; - nearest.dist_sq = FLT_MAX; - BLI_bvhtree_find_nearest( - bvh.tree, position, &nearest, bvh.nearest_callback, const_cast(&bvh)); - triangle_index[i] = nearest.index; - sample_position[i] = nearest.co; - if (!is_valid_span.is_empty()) { - is_valid_span[i] = true; - } - }); + 2, "Sample Position"); + const Mesh &mesh = *source_.get_mesh(); + get_closest_mesh_tris(mesh, positions, mask, triangle_index, {}, sample_position); } ExecutionHints get_execution_hints() const override @@ -204,13 +133,10 @@ static void node_geo_exec(GeoNodeExecParams params) } auto nearest_op = FieldOperation::Create( - std::make_shared(geometry, - params.extract_input>("Group ID")), - {params.extract_input>("Sample Position"), - params.extract_input>("Sample Group ID")}); + std::make_shared(geometry), + {params.extract_input>("Sample Position")}); Field triangle_indices(nearest_op, 0); Field nearest_positions(nearest_op, 1); - Field is_valid(nearest_op, 2); Field bary_weights = Field(FieldOperation::Create( std::make_shared(geometry), @@ -222,7 +148,6 @@ static void node_geo_exec(GeoNodeExecParams params) {triangle_indices, bary_weights}); params.set_output("Value", GField(sample_op)); - params.set_output("Is Valid", is_valid); } static void node_rna(StructRNA *srna) diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_material.cc b/source/blender/nodes/geometry/nodes/node_geo_set_material.cc index 2ba91107df4..832015953d5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_material.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_material.cc @@ -4,6 +4,7 @@ #include "node_geometry_util.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "DNA_curves_types.h" diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc index 0869f61baf1..82c352ad001 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc @@ -2,10 +2,13 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "DEG_depsgraph_query.hh" + #include "BLI_task.hh" #include "BKE_curves.hh" #include "BKE_grease_pencil.hh" +#include "BKE_mesh.hh" #include "node_geometry_util.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_simulation.cc b/source/blender/nodes/geometry/nodes/node_geo_simulation.cc index c66d4400ac5..be79b582402 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_simulation.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_simulation.cc @@ -18,7 +18,7 @@ #include "BKE_modifier.hh" #include "BKE_node_socket_value.hh" #include "BKE_object.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph_query.hh" @@ -42,7 +42,7 @@ #include "MOD_nodes.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "GEO_mix_geometries.hh" @@ -341,8 +341,6 @@ class LazyFunctionForSimulationInputNode final : public LazyFunction { static void node_declare(NodeDeclarationBuilder &b) { - b.use_custom_socket_order(); - b.allow_any_socket_order(); b.add_output("Delta Time"); const bNode *node = b.node_or_null(); @@ -364,14 +362,14 @@ static void node_declare(NodeDeclarationBuilder &b) const StringRef name = item.name; const std::string identifier = SimulationItemsAccessor::socket_identifier_for_item(item); auto &input_decl = b.add_input(socket_type, name, identifier); - auto &output_decl = b.add_output(socket_type, name, identifier).align_with_previous(); + auto &output_decl = b.add_output(socket_type, name, identifier); if (socket_type_supports_fields(socket_type)) { input_decl.supports_field(); output_decl.dependent_field({input_decl.input_index()}); } } b.add_input("", "__extend__"); - b.add_output("", "__extend__").align_with_previous(); + b.add_output("", "__extend__"); } static void node_init(bNodeTree * /*tree*/, bNode *node) @@ -429,9 +427,9 @@ class LazyFunctionForSimulationOutputNode final : public LazyFunction { Span simulation_items_; int skip_input_index_; /** - * Start index of the simulation state inputs that are used when the simulation is skipped. - * Those inputs are linked directly to the simulation input node. Those inputs only exist - * internally, but not in the UI. + * Start index of the simulation state inputs that are used when the simulation is skipped. Those + * inputs are linked directly to the simulation input node. Those inputs only exist internally, + * but not in the UI. */ int skip_inputs_offset_; /** @@ -650,8 +648,8 @@ class LazyFunctionForSimulationOutputNode final : public LazyFunction { } const bool skip = skip_variant->get(); - /* Instead of outputting the values directly, convert them to a bake state and then back. - * This ensures that some geometry processing happens on the data consistently (e.g. removing + /* Instead of outputting the values directly, convert them to a bake state and then back. This + * ensures that some geometry processing happens on the data consistently (e.g. removing * anonymous attributes). */ std::optional bake_state = this->get_bake_state_from_inputs( params, data_block_map, skip); @@ -683,8 +681,6 @@ class LazyFunctionForSimulationOutputNode final : public LazyFunction { static void node_declare(NodeDeclarationBuilder &b) { - b.use_custom_socket_order(); - b.allow_any_socket_order(); b.add_input("Skip").description( "Forward the output of the simulation input node directly to the output node and ignore " "the nodes in the simulation zone"); @@ -702,14 +698,14 @@ static void node_declare(NodeDeclarationBuilder &b) const StringRef name = item.name; const std::string identifier = SimulationItemsAccessor::socket_identifier_for_item(item); auto &input_decl = b.add_input(socket_type, name, identifier); - auto &output_decl = b.add_output(socket_type, name, identifier).align_with_previous(); + auto &output_decl = b.add_output(socket_type, name, identifier); if (socket_type_supports_fields(socket_type)) { input_decl.supports_field(); output_decl.dependent_field({input_decl.input_index()}); } } b.add_input("", "__extend__"); - b.add_output("", "__extend__").align_with_previous(); + b.add_output("", "__extend__"); } static void node_init(bNodeTree * /*tree*/, bNode *node) @@ -949,8 +945,7 @@ void mix_baked_data_item(const eNodeSocketDatatype socket_type, case SOCK_INT: case SOCK_BOOLEAN: case SOCK_ROTATION: - case SOCK_RGBA: - case SOCK_MATRIX: { + case SOCK_RGBA: { const CPPType &type = node_geo_simulation_cc::get_simulation_item_cpp_type(socket_type); SocketValueVariant prev_value_variant = *static_cast(prev); SocketValueVariant next_value_variant = *static_cast(next); diff --git a/source/blender/nodes/geometry/nodes/node_geo_sort_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_sort_elements.cc index 039f1b5348e..e90235f9c6f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sort_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sort_elements.cc @@ -5,12 +5,15 @@ #include #include "BKE_attribute.hh" +#include "BKE_mesh.hh" #include "BLI_array_utils.hh" #include "BLI_index_mask.hh" #include "BLI_sort.hh" #include "BLI_task.hh" +#include "DNA_mesh_types.h" + #include "GEO_reorder.hh" #include "NOD_rna_define.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_split_to_instances.cc b/source/blender/nodes/geometry/nodes/node_geo_split_to_instances.cc index b8ecf31d983..2fd9da1203f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_split_to_instances.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_split_to_instances.cc @@ -9,6 +9,7 @@ #include "BKE_curves.hh" #include "BKE_instances.hh" +#include "BKE_mesh.hh" #include "BKE_pointcloud.hh" #include "NOD_rna_define.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc index fcc9a2ebcf2..730ce16a1d9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc @@ -3,6 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "DNA_curve_types.h" +#include "DNA_vfont_types.h" #include "BKE_curve.hh" #include "BKE_curve_legacy_convert.hh" @@ -11,6 +12,7 @@ #include "BKE_vfont.hh" #include "BLI_bounds.hh" +#include "BLI_hash.h" #include "BLI_math_matrix.hh" #include "BLI_string_utf8.h" #include "BLI_task.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc index 323c758f889..ca492517717 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc @@ -2,6 +2,7 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BLI_array_utils.hh" #include "BLI_task.hh" #include "DNA_modifier_types.h" diff --git a/source/blender/nodes/geometry/nodes/node_geo_switch.cc b/source/blender/nodes/geometry/nodes/node_geo_switch.cc index 4ac03e1af03..9fa89f0cc2b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_switch.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_switch.cc @@ -222,15 +222,11 @@ static void node_rna(StructRNA *srna) *r_free = true; return enum_items_filter(rna_enum_node_socket_data_type_items, [](const EnumPropertyItem &item) -> bool { - if (item.value == SOCK_MATRIX) { - return U.experimental.use_new_matrix_socket; - } return ELEM(item.value, SOCK_FLOAT, SOCK_INT, SOCK_BOOLEAN, SOCK_ROTATION, - SOCK_MATRIX, SOCK_VECTOR, SOCK_STRING, SOCK_RGBA, diff --git a/source/blender/nodes/geometry/nodes/node_geo_tool_3d_cursor.cc b/source/blender/nodes/geometry/nodes/node_geo_tool_3d_cursor.cc index 705386a919b..601ec21bf18 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_tool_3d_cursor.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_tool_3d_cursor.cc @@ -6,7 +6,7 @@ #include "BLI_math_matrix.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "node_geometry_util.hh" @@ -30,8 +30,8 @@ static void node_geo_exec(GeoNodeExecParams params) } const View3DCursor &cursor = params.user_data()->call_data->operator_data->scene->cursor; - const float4x4 world_to_object = - params.user_data()->call_data->operator_data->self_object->world_to_object(); + const float4x4 world_to_object( + params.user_data()->call_data->operator_data->self_object->world_to_object); const float3 location_global(cursor.location); params.set_output("Location", math::transform_point(world_to_object, location_global)); diff --git a/source/blender/nodes/geometry/nodes/node_geo_tool_set_face_set.cc b/source/blender/nodes/geometry/nodes/node_geo_tool_set_face_set.cc index 274d8eb54b1..c390af09eef 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_tool_set_face_set.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_tool_set_face_set.cc @@ -4,6 +4,7 @@ #include "BKE_mesh.hh" +#include "UI_interface.hh" #include "UI_resources.hh" #include "node_geometry_util.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc index 0c55a86b2db..d9780315b23 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_transform_geometry.cc @@ -2,10 +2,24 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "BLI_math_matrix.h" #include "BLI_math_matrix.hh" #include "BLI_math_rotation.hh" #include "BLI_task.hh" +#include "DNA_mesh_types.h" +#include "DNA_pointcloud_types.h" +#include "DNA_volume_types.h" + +#include "BKE_curves.hh" +#include "BKE_grease_pencil.hh" +#include "BKE_instances.hh" +#include "BKE_mesh.hh" +#include "BKE_pointcloud.hh" +#include "BKE_volume.hh" + +#include "DEG_depsgraph_query.hh" + #include "GEO_transform.hh" #include "node_geometry_util.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_volume_cube.cc b/source/blender/nodes/geometry/nodes/node_geo_volume_cube.cc index 44d865cd09f..9afce4b654e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_volume_cube.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_volume_cube.cc @@ -11,10 +11,13 @@ #include "node_geometry_util.hh" +#include "DNA_mesh_types.h" + #include "BLI_task.hh" #include "BKE_geometry_set.hh" #include "BKE_lib_id.hh" +#include "BKE_mesh.hh" #include "BKE_volume.hh" #include "BKE_volume_openvdb.hh" diff --git a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc index b88edcfc946..0426ab011e8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc @@ -10,8 +10,10 @@ #include "node_geometry_util.hh" +#include "BKE_lib_id.hh" #include "BKE_material.h" #include "BKE_mesh.hh" +#include "BKE_mesh_runtime.hh" #include "BKE_volume.hh" #include "BKE_volume_grid.hh" #include "BKE_volume_to_mesh.hh" diff --git a/source/blender/nodes/intern/derived_node_tree.cc b/source/blender/nodes/intern/derived_node_tree.cc index 216ecd020ff..7321e274fe9 100644 --- a/source/blender/nodes/intern/derived_node_tree.cc +++ b/source/blender/nodes/intern/derived_node_tree.cc @@ -4,6 +4,8 @@ #include "NOD_derived_node_tree.hh" +#include "BKE_node.hh" + #include "BLI_dot_export.hh" namespace blender::nodes { diff --git a/source/blender/nodes/intern/geometry_nodes_execute.cc b/source/blender/nodes/intern/geometry_nodes_execute.cc index c4aef9448d1..6f2e70b34da 100644 --- a/source/blender/nodes/intern/geometry_nodes_execute.cc +++ b/source/blender/nodes/intern/geometry_nodes_execute.cc @@ -93,6 +93,7 @@ static bool node_needs_own_transform_relation(const bNode &node) node.storage); return storage.transform_space == GEO_NODE_TRANSFORM_SPACE_RELATIVE; } + if (node.type == GEO_NODE_SELF_OBJECT) { return true; } @@ -345,7 +346,6 @@ std::unique_ptr id_property_create_f socket.socket_data); return bke::idprop::create(identifier, reinterpret_cast(value->value)); } - case SOCK_MATRIX: case SOCK_CUSTOM: case SOCK_GEOMETRY: case SOCK_SHADER: @@ -387,7 +387,6 @@ bool id_property_type_matches_socket(const bNodeTreeInterfaceSocket &socket, case SOCK_MATERIAL: return property.type == IDP_ID; case SOCK_CUSTOM: - case SOCK_MATRIX: case SOCK_GEOMETRY: case SOCK_SHADER: return false; @@ -675,15 +674,12 @@ static Vector compute_attributes_to_store( for (const OutputAttributeInfo &output_info : outputs_info) { const CPPType &type = output_info.field.cpp_type(); const bke::AttributeValidator validator = attributes.lookup_validator(output_info.name); - OutputAttributeToStore store{ component_type, domain, output_info.name, GMutableSpan{ - type, - MEM_mallocN_aligned(type.size() * domain_size, type.alignment(), __func__), - domain_size}}; + type, MEM_malloc_arrayN(domain_size, type.size(), __func__), domain_size}}; fn::GField field = validator.validate_field_if_necessary(output_info.field); field_evaluator.add_with_destination(std::move(field), store.data); attributes_to_store.append(store); @@ -872,7 +868,7 @@ void update_input_properties_from_node_tree(const bNodeTree &tree, if (new_prop == nullptr) { /* Out of the set of supported input sockets, only * geometry sockets aren't added to the modifier. */ - BLI_assert(ELEM(socket_type, SOCK_GEOMETRY, SOCK_MATRIX)); + BLI_assert(socket_type == SOCK_GEOMETRY); continue; } diff --git a/source/blender/nodes/intern/geometry_nodes_log.cc b/source/blender/nodes/intern/geometry_nodes_log.cc index 67ced8d6a52..25fabb0a00c 100644 --- a/source/blender/nodes/intern/geometry_nodes_log.cc +++ b/source/blender/nodes/intern/geometry_nodes_log.cc @@ -10,6 +10,7 @@ #include "BKE_node_enum.hh" #include "BKE_node_runtime.hh" #include "BKE_node_socket_value.hh" +#include "BKE_viewer_path.hh" #include "DNA_modifier_types.h" #include "DNA_space_types.h" diff --git a/source/blender/nodes/intern/node_common.cc b/source/blender/nodes/intern/node_common.cc index 4938695271f..8cb16a2d594 100644 --- a/source/blender/nodes/intern/node_common.cc +++ b/source/blender/nodes/intern/node_common.cc @@ -13,6 +13,7 @@ #include "BLI_listbase.h" #include "BLI_map.hh" +#include "BLI_math_euler.hh" #include "BLI_multi_value_map.hh" #include "BLI_set.hh" #include "BLI_stack.hh" @@ -20,11 +21,14 @@ #include "BLI_string_ref.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_interface.hh" +#include "BKE_node_tree_update.hh" + +#include "RNA_types.hh" #include "MEM_guardedalloc.h" @@ -245,11 +249,6 @@ static SocketDeclarationPtr declaration_for_interface_socket( dst = std::move(decl); break; } - case SOCK_MATRIX: { - std::unique_ptr decl = std::make_unique(); - dst = std::move(decl); - break; - } case SOCK_INT: { const auto &value = node_interface::get_socket_data_as(io_socket); std::unique_ptr decl = std::make_unique(); diff --git a/source/blender/nodes/intern/node_declaration.cc b/source/blender/nodes/intern/node_declaration.cc index b20d67746d2..0d8291cb0b8 100644 --- a/source/blender/nodes/intern/node_declaration.cc +++ b/source/blender/nodes/intern/node_declaration.cc @@ -123,12 +123,6 @@ void NodeDeclarationBuilder::use_custom_socket_order(bool enable) declaration_.use_custom_socket_order = enable; } -void NodeDeclarationBuilder::allow_any_socket_order(bool enable) -{ - BLI_assert(declaration_.use_custom_socket_order); - declaration_.allow_any_socket_order = enable; -} - Span NodeDeclaration::sockets(eNodeSocketInOut in_out) const { if (in_out == SOCK_IN) { @@ -209,7 +203,7 @@ bool NodeDeclaration::is_valid() const if (const SocketDeclaration *socket_decl = dynamic_cast( item_decl.get())) { - if (state.item_type != NODE_INTERFACE_SOCKET && !this->allow_any_socket_order) { + if (state.item_type != NODE_INTERFACE_SOCKET) { std::cout << "Socket added after panel" << std::endl; return false; } @@ -219,7 +213,7 @@ bool NodeDeclaration::is_valid() const /* Start of input sockets. */ state.socket_in_out = SOCK_IN; } - if (socket_decl->in_out != state.socket_in_out && !this->allow_any_socket_order) { + if (socket_decl->in_out != state.socket_in_out) { std::cout << "Output socket added after input socket" << std::endl; return false; } @@ -420,8 +414,6 @@ std::unique_ptr make_declaration_for_socket_type( return std::make_unique(); case SOCK_ROTATION: return std::make_unique(); - case SOCK_MATRIX: - return std::make_unique(); case SOCK_INT: return std::make_unique(); case SOCK_STRING: @@ -457,8 +449,6 @@ BaseSocketDeclarationBuilder &NodeDeclarationBuilder::add_input( return this->add_input(name, identifier); case SOCK_ROTATION: return this->add_input(name, identifier); - case SOCK_MATRIX: - return this->add_input(name, identifier); case SOCK_INT: return this->add_input(name, identifier); case SOCK_STRING: @@ -502,8 +492,6 @@ BaseSocketDeclarationBuilder &NodeDeclarationBuilder::add_output( return this->add_output(name, identifier); case SOCK_ROTATION: return this->add_output(name, identifier); - case SOCK_MATRIX: - return this->add_output(name, identifier); case SOCK_INT: return this->add_output(name, identifier); case SOCK_STRING: @@ -818,17 +806,6 @@ BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::make_available( return *this; } -BaseSocketDeclarationBuilder &BaseSocketDeclarationBuilder::align_with_previous(const bool value) -{ - if (decl_in_base_) { - decl_in_base_->align_with_previous_socket = value; - } - if (decl_out_base_) { - decl_out_base_->align_with_previous_socket = value; - } - return *this; -} - OutputFieldDependency OutputFieldDependency::ForFieldSource() { OutputFieldDependency field_dependency; diff --git a/source/blender/nodes/intern/node_exec.cc b/source/blender/nodes/intern/node_exec.cc index a6fae8661da..1bf26ced04b 100644 --- a/source/blender/nodes/intern/node_exec.cc +++ b/source/blender/nodes/intern/node_exec.cc @@ -11,7 +11,8 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" -#include "BKE_global.hh" +#include "BKE_global.h" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" diff --git a/source/blender/nodes/intern/node_geometry_exec.cc b/source/blender/nodes/intern/node_geometry_exec.cc index 488f6287aaa..d452ebcb37f 100644 --- a/source/blender/nodes/intern/node_geometry_exec.cc +++ b/source/blender/nodes/intern/node_geometry_exec.cc @@ -9,7 +9,7 @@ #include "BKE_curves.hh" #include "BKE_type_conversions.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "NOD_geometry_exec.hh" diff --git a/source/blender/nodes/intern/node_multi_function.cc b/source/blender/nodes/intern/node_multi_function.cc index f74a8a72b25..e9b309cfb63 100644 --- a/source/blender/nodes/intern/node_multi_function.cc +++ b/source/blender/nodes/intern/node_multi_function.cc @@ -4,6 +4,7 @@ #include "NOD_multi_function.hh" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" namespace blender::nodes { diff --git a/source/blender/nodes/intern/node_register.cc b/source/blender/nodes/intern/node_register.cc index 9631ec35696..406ffc34b89 100644 --- a/source/blender/nodes/intern/node_register.cc +++ b/source/blender/nodes/intern/node_register.cc @@ -10,7 +10,11 @@ #include "BKE_node.hh" -#include "BLT_translation.hh" +#include "ED_node.hh" + +#include "BLT_translation.h" + +#include "RNA_access.hh" #include "UI_resources.hh" diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index 4264ffc4f11..9f25624c3fd 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -13,8 +13,6 @@ #include "BLI_color.hh" #include "BLI_listbase.h" #include "BLI_math_euler.hh" -#include "BLI_math_matrix.h" -#include "BLI_math_matrix.hh" #include "BLI_math_quaternion_types.hh" #include "BLI_math_vector.h" #include "BLI_math_vector_types.hh" @@ -32,6 +30,7 @@ #include "DNA_material_types.h" #include "RNA_access.hh" +#include "RNA_types.hh" #include "MEM_guardedalloc.h" @@ -300,9 +299,6 @@ static std::optional decl_to_data_type(const SocketDeclarat else if (dynamic_cast(&socket_decl)) { return SOCK_ROTATION; } - else if (dynamic_cast(&socket_decl)) { - return SOCK_MATRIX; - } else if (dynamic_cast(&socket_decl)) { return SOCK_STRING; } @@ -559,8 +555,7 @@ bool socket_type_supports_fields(const eNodeSocketDatatype socket_type) SOCK_BOOLEAN, SOCK_INT, SOCK_ROTATION, - SOCK_MENU, - SOCK_MATRIX); + SOCK_MENU); } } // namespace blender::nodes @@ -705,7 +700,6 @@ void node_socket_init_default_value_data(eNodeSocketDatatype datatype, int subty case SOCK_CUSTOM: case SOCK_GEOMETRY: - case SOCK_MATRIX: case SOCK_SHADER: break; } @@ -804,7 +798,6 @@ void node_socket_copy_default_value_data(eNodeSocketDatatype datatype, void *to, case SOCK_CUSTOM: case SOCK_GEOMETRY: - case SOCK_MATRIX: case SOCK_SHADER: break; } @@ -986,22 +979,6 @@ static bNodeSocketType *make_socket_type_rotation() return socktype; } -static bNodeSocketType *make_socket_type_matrix() -{ - bNodeSocketType *socktype = make_standard_socket_type(SOCK_MATRIX, PROP_NONE); - socktype->base_cpp_type = &blender::CPPType::get(); - socktype->get_base_cpp_value = [](const void * /*socket_value*/, void *r_value) { - *static_cast(r_value) = float4x4::identity(); - }; - socktype->geometry_nodes_cpp_type = &blender::CPPType::get(); - socktype->get_geometry_nodes_cpp_value = [](const void * /*socket_value*/, void *r_value) { - new (r_value) SocketValueVariant(float4x4::identity()); - }; - static SocketValueVariant default_value{float4x4::identity()}; - socktype->geometry_nodes_default_cpp_value = &default_value; - return socktype; -} - static bNodeSocketType *make_socket_type_float(PropertySubType subtype) { bNodeSocketType *socktype = make_standard_socket_type(SOCK_FLOAT, subtype); @@ -1196,7 +1173,6 @@ void register_standard_node_socket_types() nodeRegisterSocketType(make_socket_type_bool()); nodeRegisterSocketType(make_socket_type_rotation()); - nodeRegisterSocketType(make_socket_type_matrix()); nodeRegisterSocketType(make_socket_type_vector(PROP_NONE)); nodeRegisterSocketType(make_socket_type_vector(PROP_TRANSLATION)); diff --git a/source/blender/nodes/intern/node_socket_declarations.cc b/source/blender/nodes/intern/node_socket_declarations.cc index c04cd4a2405..8c72b107971 100644 --- a/source/blender/nodes/intern/node_socket_declarations.cc +++ b/source/blender/nodes/intern/node_socket_declarations.cc @@ -8,6 +8,7 @@ #include "NOD_socket_declarations_geometry.hh" #include "BKE_lib_id.hh" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BLI_math_vector.h" @@ -417,9 +418,9 @@ bool Rotation::can_connect(const bNodeSocket &socket) const return false; } if (this->in_out == SOCK_IN) { - return ELEM(socket.type, SOCK_ROTATION, SOCK_FLOAT, SOCK_VECTOR, SOCK_MATRIX); + return ELEM(socket.type, SOCK_ROTATION, SOCK_FLOAT, SOCK_VECTOR); } - return ELEM(socket.type, SOCK_ROTATION, SOCK_VECTOR, SOCK_MATRIX); + return ELEM(socket.type, SOCK_ROTATION, SOCK_VECTOR); } bNodeSocket &Rotation::update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const @@ -434,57 +435,6 @@ bNodeSocket &Rotation::update_or_build(bNodeTree &ntree, bNode &node, bNodeSocke /** \} */ -/* -------------------------------------------------------------------- */ -/** \name #Matrix - * \{ */ - -bNodeSocket &Matrix::build(bNodeTree &ntree, bNode &node) const -{ - bNodeSocket &socket = *nodeAddStaticSocket(&ntree, - &node, - this->in_out, - SOCK_MATRIX, - PROP_NONE, - this->identifier.c_str(), - this->name.c_str()); - this->set_common_flags(socket); - return socket; -} - -bool Matrix::matches(const bNodeSocket &socket) const -{ - if (!this->matches_common_data(socket)) { - return false; - } - if (socket.type != SOCK_MATRIX) { - return false; - } - return true; -} - -bool Matrix::can_connect(const bNodeSocket &socket) const -{ - if (!sockets_can_connect(*this, socket)) { - return false; - } - if (this->in_out == SOCK_IN) { - return ELEM(socket.type, SOCK_MATRIX, SOCK_FLOAT, SOCK_VECTOR, SOCK_MATRIX); - } - return ELEM(socket.type, SOCK_MATRIX, SOCK_VECTOR, SOCK_MATRIX); -} - -bNodeSocket &Matrix::update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const -{ - if (socket.type != SOCK_MATRIX) { - BLI_assert(socket.in_out == this->in_out); - return this->build(ntree, node); - } - this->set_common_flags(socket); - return socket; -} - -/** \} */ - /* -------------------------------------------------------------------- */ /** \name #String * \{ */ diff --git a/source/blender/nodes/intern/node_util.cc b/source/blender/nodes/intern/node_util.cc index 4782cb65c25..f2d3458b9f0 100644 --- a/source/blender/nodes/intern/node_util.cc +++ b/source/blender/nodes/intern/node_util.cc @@ -17,7 +17,7 @@ #include "BLI_string_utf8.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_colortools.hh" #include "BKE_node.hh" diff --git a/source/blender/nodes/intern/node_zone_socket_items.cc b/source/blender/nodes/intern/node_zone_socket_items.cc index 3891cc90147..970ac272805 100644 --- a/source/blender/nodes/intern/node_zone_socket_items.cc +++ b/source/blender/nodes/intern/node_zone_socket_items.cc @@ -6,6 +6,8 @@ #include "NOD_zone_socket_items.hh" +#include "BKE_node.hh" + #include "BLO_read_write.hh" namespace blender::nodes { diff --git a/source/blender/nodes/intern/socket_search_link.cc b/source/blender/nodes/intern/socket_search_link.cc index 3889682cf5a..9e948d2cfa8 100644 --- a/source/blender/nodes/intern/socket_search_link.cc +++ b/source/blender/nodes/intern/socket_search_link.cc @@ -11,7 +11,7 @@ #include "UI_interface.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "NOD_node_declaration.hh" #include "NOD_socket_search_link.hh" diff --git a/source/blender/nodes/shader/materialx/group_nodes.cc b/source/blender/nodes/shader/materialx/group_nodes.cc index 297e328b50e..81ba769001e 100644 --- a/source/blender/nodes/shader/materialx/group_nodes.cc +++ b/source/blender/nodes/shader/materialx/group_nodes.cc @@ -7,7 +7,7 @@ #include "BLI_vector.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BKE_node_runtime.hh" namespace blender::nodes::materialx { diff --git a/source/blender/nodes/shader/node_shader_tree.cc b/source/blender/nodes/shader/node_shader_tree.cc index 3d0831dc113..a406a334e2b 100644 --- a/source/blender/nodes/shader/node_shader_tree.cc +++ b/source/blender/nodes/shader/node_shader_tree.cc @@ -14,20 +14,20 @@ #include "DNA_node_types.h" #include "DNA_scene_types.h" #include "DNA_space_types.h" +#include "DNA_workspace_types.h" #include "DNA_world_types.h" #include "BLI_array.hh" #include "BLI_linklist.h" #include "BLI_listbase.h" #include "BLI_math_vector.h" -#include "BLI_set.hh" #include "BLI_string.h" #include "BLI_threads.h" #include "BLI_utildefines.h" #include "BLI_vector.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_linestyle.h" @@ -35,12 +35,18 @@ #include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" +#include "RNA_access.hh" #include "RNA_prototypes.h" +#include "GPU_material.hh" + +#include "RE_texture.h" + #include "UI_resources.hh" +#include "NOD_common.h" #include "NOD_shader.h" #include "node_common.h" @@ -574,87 +580,69 @@ static bool ntree_branch_count_and_tag_nodes(bNode *fromnode, bNode *tonode, voi return true; } -/* Create a copy of a branch starting from a given node. */ -static void ntree_shader_copy_branch(bNodeTree *ntree, - bNode *start_node, - bool (*node_filter)(const bNode *node)) +/* Create a copy of a branch starting from a given node. + * callback is executed once for every copied node. + * Returns input node copy. */ +static bNode *ntree_shader_copy_branch(bNodeTree *ntree, + bNode *start_node, + bool (*node_filter)(const bNode *node), + void (*callback)(bNode *node, int user_data), + int user_data) { - auto gather_branch_nodes = [](bNode *fromnode, bNode * /*tonode*/, void *userdata) { - blender::Set *set = static_cast *>(userdata); - set->add(fromnode); - return true; - }; - blender::Set branch_nodes = {start_node}; - blender::bke::nodeChainIterBackwards(ntree, start_node, gather_branch_nodes, &branch_nodes, 0); - /* Initialize `runtime->tmp_flag`. */ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { node->runtime->tmp_flag = -1; } /* Count and tag all nodes inside the displacement branch of the tree. */ + start_node->runtime->tmp_flag = 0; branchIterData iter_data; iter_data.node_filter = node_filter; - iter_data.node_count = 0; + iter_data.node_count = 1; blender::bke::nodeChainIterBackwards( ntree, start_node, ntree_branch_count_and_tag_nodes, &iter_data, 1); - /* Copies of the non-filtered nodes on the branch. */ + /* Make a full copy of the branch */ Array nodes_copy(iter_data.node_count); - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { if (node->runtime->tmp_flag >= 0) { int id = node->runtime->tmp_flag; - /* Avoid creating unique names in the new tree, since it is very slow. - * The names on the new nodes will be invalid. */ + /* Avoid creating unique names in the new tree, since it is very slow. The names on the new + * nodes will be invalid. But identifiers must be created for the `bNodeTree::all_nodes()` + * vector, though they won't match the original. */ nodes_copy[id] = blender::bke::node_copy( ntree, *node, LIB_ID_CREATE_NO_USER_REFCOUNT | LIB_ID_CREATE_NO_MAIN, false); - /* But identifiers must be created for the `bNodeTree::all_nodes()` vector, - * so they won't match the original. */ nodeUniqueID(ntree, nodes_copy[id]); - bNode *copy = nodes_copy[id]; - copy->runtime->tmp_flag = -2; /* Copy */ - copy->runtime->original = node->runtime->original; + nodes_copy[id]->runtime->tmp_flag = -2; /* Copy */ + nodes_copy[id]->runtime->original = node->runtime->original; /* Make sure to clear all sockets links as they are invalid. */ - LISTBASE_FOREACH (bNodeSocket *, sock, ©->inputs) { + LISTBASE_FOREACH (bNodeSocket *, sock, &nodes_copy[id]->inputs) { sock->link = nullptr; } - LISTBASE_FOREACH (bNodeSocket *, sock, ©->outputs) { + LISTBASE_FOREACH (bNodeSocket *, sock, &nodes_copy[id]->outputs) { sock->link = nullptr; } } } - - /* Unlink the original nodes from this branch and link the copies. */ - LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { - bool from_copy = link->fromnode->runtime->tmp_flag >= 0; - bool to_copy = link->tonode->runtime->tmp_flag >= 0; - if (from_copy && to_copy) { - bNode *from_node = nodes_copy[link->fromnode->runtime->tmp_flag]; - bNode *to_node = nodes_copy[link->tonode->runtime->tmp_flag]; - nodeAddLink(ntree, - from_node, - ntree_shader_node_find_output(from_node, link->fromsock->identifier), - to_node, - ntree_shader_node_find_input(to_node, link->tosock->identifier)); - } - else if (to_copy) { - bNode *to_node = nodes_copy[link->tonode->runtime->tmp_flag]; - nodeAddLink(ntree, - link->fromnode, - link->fromsock, - to_node, - ntree_shader_node_find_input(to_node, link->tosock->identifier)); - } - else if (from_copy && branch_nodes.contains(link->tonode)) { - bNode *from_node = nodes_copy[link->fromnode->runtime->tmp_flag]; - nodeAddLink(ntree, - from_node, - ntree_shader_node_find_output(from_node, link->fromsock->identifier), - link->tonode, - link->tosock); - nodeRemLink(ntree, link); + /* Recreate links between copied nodes AND incoming links to the copied nodes. */ + LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { + if (link->tonode->runtime->tmp_flag >= 0) { + bool from_node_copied = link->fromnode->runtime->tmp_flag >= 0; + bNode *fromnode = from_node_copied ? nodes_copy[link->fromnode->runtime->tmp_flag] : + link->fromnode; + bNode *tonode = nodes_copy[link->tonode->runtime->tmp_flag]; + bNodeSocket *fromsock = ntree_shader_node_find_output(fromnode, link->fromsock->identifier); + bNodeSocket *tosock = ntree_shader_node_find_input(tonode, link->tosock->identifier); + nodeAddLink(ntree, fromnode, fromsock, tonode, tosock); } } + /* Per node callback. */ + if (callback) { + for (int i = 0; i < iter_data.node_count; i++) { + callback(nodes_copy[i], user_data); + } + } + bNode *start_node_copy = nodes_copy[start_node->runtime->tmp_flag]; + return start_node_copy; } /* Generate emission node to convert regular data to closure sockets. @@ -997,51 +985,47 @@ static bool closure_node_filter(const bNode *node) } } -/* Shader to rgba needs their associated closure duplicated and the weight tree generated for. */ -static void ntree_shader_shader_to_rgba_branches(bNodeTree *ntree) +static bool shader_to_rgba_node_gather(bNode * /*fromnode*/, bNode *tonode, void *userdata) { - Vector shader_to_rgba_nodes; - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - if (node->type == SH_NODE_SHADERTORGB) { - shader_to_rgba_nodes.append(node); - } + Vector &shader_to_rgba_nodes = *(Vector *)userdata; + if (tonode->runtime->tmp_flag == -1 && tonode->type == SH_NODE_SHADERTORGB) { + tonode->runtime->tmp_flag = 0; + shader_to_rgba_nodes.append(tonode); } + return true; +} + +/* Shader to rgba needs their associated closure duplicated and the weight tree generated for. */ +static void ntree_shader_shader_to_rgba_branch(bNodeTree *ntree, bNode *output_node) +{ + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + node->runtime->tmp_flag = -1; + } + /* First gather the shader_to_rgba nodes linked to the output. This is separate to avoid + * conflicting usage of the `node->runtime->tmp_flag`. */ + Vector shader_to_rgba_nodes; + blender::bke::nodeChainIterBackwards( + ntree, output_node, shader_to_rgba_node_gather, &shader_to_rgba_nodes, 0); for (bNode *shader_to_rgba : shader_to_rgba_nodes) { bNodeSocket *closure_input = ntree_shader_node_input_get(shader_to_rgba, 0); if (closure_input->link == nullptr) { continue; } - ntree_shader_copy_branch(ntree, shader_to_rgba, closure_node_filter); + bNode *start_node = closure_input->link->fromnode; + bNode *start_node_copy = ntree_shader_copy_branch( + ntree, start_node, closure_node_filter, nullptr, 0); + /* Replace node copy link. This assumes that every node possibly connected to the closure input + * has only one output. */ + bNodeSocket *closure_output = ntree_shader_node_output_get(start_node_copy, 0); + nodeRemLink(ntree, closure_input->link); + nodeAddLink(ntree, start_node_copy, closure_output, shader_to_rgba, closure_input); BKE_ntree_update_main_tree(G.main, ntree, nullptr); ntree_shader_weight_tree_invert(ntree, shader_to_rgba); } } -static void iter_shader_to_rgba_depth_count(bNode *node, - int16_t &max_depth, - int16_t depth_level = 0) -{ - if (node->type == SH_NODE_SHADERTORGB) { - depth_level++; - max_depth = std::max(max_depth, depth_level); - } - node->runtime->tmp_flag = std::max(node->runtime->tmp_flag, depth_level); - - LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) { - bNodeLink *link = sock->link; - if (link == nullptr) { - continue; - } - if ((link->flag & NODE_LINK_VALID) == 0) { - /* Skip links marked as cyclic. */ - continue; - } - iter_shader_to_rgba_depth_count(link->fromnode, max_depth, depth_level); - } -} - static void shader_node_disconnect_input(bNodeTree *ntree, bNode *node, int index) { bNodeLink *link = ntree_shader_node_input_get(node, index)->link; @@ -1190,32 +1174,16 @@ void ntreeGPUMaterialNodes(bNodeTree *localtree, GPUMaterial *mat) if (valid_tree) { ntree_shader_pruned_unused(localtree, output); if (output != nullptr) { - ntree_shader_shader_to_rgba_branches(localtree); + ntree_shader_shader_to_rgba_branch(localtree, output); ntree_shader_weight_tree_invert(localtree, output); } } exec = ntreeShaderBeginExecTree(localtree); - /* Execute nodes ordered by the number of ShaderToRGB nodes found in their path, - * so all closures can be properly evaluated. */ - int16_t max_depth = 0; - LISTBASE_FOREACH (bNode *, node, &localtree->nodes) { - node->runtime->tmp_flag = -1; - } - if (output != nullptr) { - iter_shader_to_rgba_depth_count(output, max_depth); - } + ntreeExecGPUNodes(exec, mat, output); LISTBASE_FOREACH (bNode *, node, &localtree->nodes) { if (node->type == SH_NODE_OUTPUT_AOV) { - iter_shader_to_rgba_depth_count(node, max_depth); - } - } - for (int depth = max_depth; depth >= 0; depth--) { - ntreeExecGPUNodes(exec, mat, output, &depth); - LISTBASE_FOREACH (bNode *, node, &localtree->nodes) { - if (node->type == SH_NODE_OUTPUT_AOV) { - ntreeExecGPUNodes(exec, mat, node, &depth); - } + ntreeExecGPUNodes(exec, mat, node); } } ntreeShaderEndExecTree(exec); diff --git a/source/blender/nodes/shader/node_shader_util.cc b/source/blender/nodes/shader/node_shader_util.cc index 884406fe1bb..6b13b1de6fe 100644 --- a/source/blender/nodes/shader/node_shader_util.cc +++ b/source/blender/nodes/shader/node_shader_util.cc @@ -305,7 +305,7 @@ bNode *nodeGetActivePaintCanvas(bNodeTree *ntree) } } // namespace blender::bke -void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node, int *depth_level) +void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node) { bNodeExec *nodeexec; bNode *node; @@ -321,10 +321,6 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; n++, nodeexec++) { node = nodeexec->node; - if (depth_level && node->runtime->tmp_flag != *depth_level) { - continue; - } - do_it = false; /* for groups, only execute outputs for edited group */ if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) { @@ -338,7 +334,6 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node } if (do_it) { - BLI_assert(!depth_level || node->runtime->tmp_flag >= 0); if (node->typeinfo->gpu_fn) { node_get_stack(node, stack, nsin, nsout); gpu_stack_from_data_list(gpuin, &node->inputs, nsin); diff --git a/source/blender/nodes/shader/node_shader_util.hh b/source/blender/nodes/shader/node_shader_util.hh index c53b4f3f834..928caafbe32 100644 --- a/source/blender/nodes/shader/node_shader_util.hh +++ b/source/blender/nodes/shader/node_shader_util.hh @@ -68,14 +68,7 @@ bNodeTreeExec *ntreeShaderBeginExecTree_internal(bNodeExecContext *context, bNodeInstanceKey parent_key); void ntreeShaderEndExecTree_internal(bNodeTreeExec *exec); -/* If depth_level is not null, only nodes where `node->runtime->tmp_flag == depth_level` will be - * executed. This allows finer control over node execution order without modifying the tree - * topology. */ -void ntreeExecGPUNodes(bNodeTreeExec *exec, - GPUMaterial *mat, - bNode *output_node, - int *depth_level = nullptr); - +void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node); void get_XYZ_to_RGB_for_gpu(XYZ_to_RGB *data); bool node_socket_not_zero(const GPUNodeStack &socket); diff --git a/source/blender/nodes/shader/nodes/node_shader_blackbody.cc b/source/blender/nodes/shader/nodes/node_shader_blackbody.cc index 26c1699a9a7..5719a8d476a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_blackbody.cc +++ b/source/blender/nodes/shader/nodes/node_shader_blackbody.cc @@ -5,6 +5,7 @@ #include "FN_multi_function_builder.hh" #include "NOD_multi_function.hh" #include "node_shader_util.hh" +#include "node_util.hh" #include "BLI_color.hh" #include "IMB_colormanagement.hh" diff --git a/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc index 6be99a77a78..8081aacb7cb 100644 --- a/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc +++ b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc @@ -12,6 +12,8 @@ #include "BLI_color.hh" +#include "FN_multi_function_builder.hh" + #include "NOD_multi_function.hh" #include "node_shader_util.hh" diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.cc b/source/blender/nodes/shader/nodes/node_shader_output_material.cc index 7e3c0aecaf4..0427c38788f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_material.cc +++ b/source/blender/nodes/shader/nodes/node_shader_output_material.cc @@ -4,6 +4,8 @@ #include "node_shader_util.hh" +#include "BKE_scene.h" + namespace blender::nodes::node_shader_output_material_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -11,7 +13,9 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_input("Surface"); b.add_input("Volume").translation_context(BLT_I18NCONTEXT_ID_ID); b.add_input("Displacement").hide_value(); - b.add_input("Thickness").hide_value(); + b.add_input("Thickness") + .hide_value() + .unavailable() /* EEVEE-Next only. Does nothing in 4.1. */; } static int node_shader_gpu_output_material(GPUMaterial *mat, diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.cc b/source/blender/nodes/shader/nodes/node_shader_particle_info.cc index 40e3153fd82..eda2183cd96 100644 --- a/source/blender/nodes/shader/nodes/node_shader_particle_info.cc +++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.cc @@ -4,6 +4,8 @@ #include "node_shader_util.hh" +#include "RE_texture.h" + namespace blender::nodes::node_shader_particle_info_cc { static void node_declare(NodeDeclarationBuilder &b) diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc b/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc index 841a5997750..17df7d14fa3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc @@ -39,7 +39,7 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat, /* Use special matrix to let the shader branch to using the render object's matrix. */ float dummy_matrix[4][4]; dummy_matrix[3][3] = 0.0f; - GPUNodeLink *inv_obmat = (ob != nullptr) ? GPU_uniform(&ob->world_to_object()[0][0]) : + GPUNodeLink *inv_obmat = (ob != nullptr) ? GPU_uniform(&ob->world_to_object[0][0]) : GPU_uniform(&dummy_matrix[0][0]); /* Optimization: don't request orco if not needed. */ diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc index 2e308b0de1f..159ce3747b4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc @@ -10,7 +10,7 @@ #include "BLI_task.hh" #include "BKE_context.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_texture.h" #include "RNA_access.hh" diff --git a/source/blender/nodes/shader/nodes/node_shader_wireframe.cc b/source/blender/nodes/shader/nodes/node_shader_wireframe.cc index 7d2a762fb08..1b7b475752a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_wireframe.cc +++ b/source/blender/nodes/shader/nodes/node_shader_wireframe.cc @@ -4,7 +4,7 @@ #include "node_shader_util.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "GPU_material.hh" diff --git a/source/blender/nodes/texture/node_texture_tree.cc b/source/blender/nodes/texture/node_texture_tree.cc index b05d5f2d4d5..da0f618f17b 100644 --- a/source/blender/nodes/texture/node_texture_tree.cc +++ b/source/blender/nodes/texture/node_texture_tree.cc @@ -31,8 +31,13 @@ #include "node_texture_util.hh" #include "node_util.hh" +#include "DEG_depsgraph.hh" + +#include "RNA_access.hh" #include "RNA_prototypes.h" +#include "RE_texture.h" + #include "UI_resources.hh" static void texture_get_from_context( diff --git a/source/blender/nodes/texture/node_texture_util.hh b/source/blender/nodes/texture/node_texture_util.hh index a77965af4d3..4d8c5b98bc6 100644 --- a/source/blender/nodes/texture/node_texture_util.hh +++ b/source/blender/nodes/texture/node_texture_util.hh @@ -12,7 +12,7 @@ #include "node_texture_register.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RE_texture.h" diff --git a/source/blender/nodes/texture/nodes/node_texture_at.cc b/source/blender/nodes/texture/nodes/node_texture_at.cc index 664a1f875d6..ca4f9f1c14f 100644 --- a/source/blender/nodes/texture/nodes/node_texture_at.cc +++ b/source/blender/nodes/texture/nodes/node_texture_at.cc @@ -6,6 +6,7 @@ * \ingroup texnodes */ +#include "NOD_texture.h" #include "node_texture_util.hh" static bNodeSocketTemplate inputs[] = { diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.cc b/source/blender/nodes/texture/nodes/node_texture_bricks.cc index 15511aa9a05..350c2e1332c 100644 --- a/source/blender/nodes/texture/nodes/node_texture_bricks.cc +++ b/source/blender/nodes/texture/nodes/node_texture_bricks.cc @@ -9,6 +9,7 @@ #include "BKE_material.h" #include "BLI_math_vector.h" #include "DNA_material_types.h" +#include "NOD_texture.h" #include "node_texture_util.hh" #include diff --git a/source/blender/nodes/texture/nodes/node_texture_checker.cc b/source/blender/nodes/texture/nodes/node_texture_checker.cc index 028f931c7b9..3c49ce3d654 100644 --- a/source/blender/nodes/texture/nodes/node_texture_checker.cc +++ b/source/blender/nodes/texture/nodes/node_texture_checker.cc @@ -6,6 +6,7 @@ * \ingroup texnodes */ +#include "NOD_texture.h" #include "node_texture_util.hh" #include diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.cc b/source/blender/nodes/texture/nodes/node_texture_compose.cc index 9966c3d640b..f52148b858a 100644 --- a/source/blender/nodes/texture/nodes/node_texture_compose.cc +++ b/source/blender/nodes/texture/nodes/node_texture_compose.cc @@ -6,6 +6,7 @@ * \ingroup texnodes */ +#include "NOD_texture.h" #include "node_texture_util.hh" static bNodeSocketTemplate inputs[] = { diff --git a/source/blender/nodes/texture/nodes/node_texture_coord.cc b/source/blender/nodes/texture/nodes/node_texture_coord.cc index 85b21222c59..48fff37d107 100644 --- a/source/blender/nodes/texture/nodes/node_texture_coord.cc +++ b/source/blender/nodes/texture/nodes/node_texture_coord.cc @@ -7,6 +7,7 @@ */ #include "BLI_math_vector.h" +#include "NOD_texture.h" #include "node_texture_util.hh" static bNodeSocketTemplate outputs[] = { diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.cc b/source/blender/nodes/texture/nodes/node_texture_curves.cc index 4cb5f4258d6..d31d2265416 100644 --- a/source/blender/nodes/texture/nodes/node_texture_curves.cc +++ b/source/blender/nodes/texture/nodes/node_texture_curves.cc @@ -9,6 +9,7 @@ #include #include "BKE_colortools.hh" +#include "NOD_texture.h" #include "node_texture_util.hh" #include "node_util.hh" diff --git a/source/blender/nodes/texture/nodes/node_texture_decompose.cc b/source/blender/nodes/texture/nodes/node_texture_decompose.cc index 9ac27c0e5ee..ee34ceba20a 100644 --- a/source/blender/nodes/texture/nodes/node_texture_decompose.cc +++ b/source/blender/nodes/texture/nodes/node_texture_decompose.cc @@ -6,6 +6,7 @@ * \ingroup texnodes */ +#include "NOD_texture.h" #include "node_texture_util.hh" #include diff --git a/source/blender/nodes/texture/nodes/node_texture_distance.cc b/source/blender/nodes/texture/nodes/node_texture_distance.cc index be1a5c83dd3..3afd97c0594 100644 --- a/source/blender/nodes/texture/nodes/node_texture_distance.cc +++ b/source/blender/nodes/texture/nodes/node_texture_distance.cc @@ -7,6 +7,7 @@ */ #include "BLI_math_vector.h" +#include "NOD_texture.h" #include "node_texture_util.hh" #include diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.cc b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.cc index 250dd5f317e..405f8e6713e 100644 --- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.cc +++ b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.cc @@ -8,6 +8,7 @@ #include "BLI_math_color.h" #include "BLI_math_vector.h" +#include "NOD_texture.h" #include "node_texture_util.hh" static bNodeSocketTemplate inputs[] = { diff --git a/source/blender/nodes/texture/nodes/node_texture_image.cc b/source/blender/nodes/texture/nodes/node_texture_image.cc index f40dfc8cfa4..ede1c92c501 100644 --- a/source/blender/nodes/texture/nodes/node_texture_image.cc +++ b/source/blender/nodes/texture/nodes/node_texture_image.cc @@ -10,6 +10,7 @@ #include "BLI_math_vector.h" #include "BLI_threads.h" #include "IMB_imbuf.hh" +#include "NOD_texture.h" #include "node_texture_util.hh" #include "node_util.hh" diff --git a/source/blender/nodes/texture/nodes/node_texture_invert.cc b/source/blender/nodes/texture/nodes/node_texture_invert.cc index 5b515cfb06d..8a1e12cff70 100644 --- a/source/blender/nodes/texture/nodes/node_texture_invert.cc +++ b/source/blender/nodes/texture/nodes/node_texture_invert.cc @@ -7,6 +7,7 @@ */ #include "BLI_math_vector.h" +#include "NOD_texture.h" #include "node_texture_util.hh" /* **************** INVERT ******************** */ diff --git a/source/blender/nodes/texture/nodes/node_texture_math.cc b/source/blender/nodes/texture/nodes/node_texture_math.cc index ee9517d415f..3a9992254a6 100644 --- a/source/blender/nodes/texture/nodes/node_texture_math.cc +++ b/source/blender/nodes/texture/nodes/node_texture_math.cc @@ -7,6 +7,7 @@ */ #include "BLI_math_rotation.h" +#include "NOD_texture.h" #include "node_texture_util.hh" #include "node_util.hh" diff --git a/source/blender/nodes/texture/nodes/node_texture_mixRgb.cc b/source/blender/nodes/texture/nodes/node_texture_mixRgb.cc index 13ffeb367df..7c49382caf1 100644 --- a/source/blender/nodes/texture/nodes/node_texture_mixRgb.cc +++ b/source/blender/nodes/texture/nodes/node_texture_mixRgb.cc @@ -6,6 +6,7 @@ * \ingroup texnodes */ +#include "NOD_texture.h" #include "node_texture_util.hh" #include "node_util.hh" diff --git a/source/blender/nodes/texture/nodes/node_texture_output.cc b/source/blender/nodes/texture/nodes/node_texture_output.cc index 3edac7e58b9..3c4c4806ae2 100644 --- a/source/blender/nodes/texture/nodes/node_texture_output.cc +++ b/source/blender/nodes/texture/nodes/node_texture_output.cc @@ -8,6 +8,7 @@ #include "BLI_string.h" +#include "NOD_texture.h" #include "node_texture_util.hh" #include "node_util.hh" diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.cc b/source/blender/nodes/texture/nodes/node_texture_proc.cc index cf447adf189..84bbbb94aca 100644 --- a/source/blender/nodes/texture/nodes/node_texture_proc.cc +++ b/source/blender/nodes/texture/nodes/node_texture_proc.cc @@ -10,6 +10,7 @@ #include "BKE_texture.h" #include "BLI_math_vector.h" #include "DNA_material_types.h" +#include "NOD_texture.h" #include "node_texture_util.hh" #include "node_util.hh" diff --git a/source/blender/nodes/texture/nodes/node_texture_rotate.cc b/source/blender/nodes/texture/nodes/node_texture_rotate.cc index 46dcd973a20..b00218862dd 100644 --- a/source/blender/nodes/texture/nodes/node_texture_rotate.cc +++ b/source/blender/nodes/texture/nodes/node_texture_rotate.cc @@ -10,6 +10,7 @@ #include "BLI_math_vector.h" +#include "NOD_texture.h" #include "node_texture_util.hh" static bNodeSocketTemplate inputs[] = { diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.cc b/source/blender/nodes/texture/nodes/node_texture_texture.cc index 03e3a938e80..be7480400f7 100644 --- a/source/blender/nodes/texture/nodes/node_texture_texture.cc +++ b/source/blender/nodes/texture/nodes/node_texture_texture.cc @@ -6,7 +6,9 @@ * \ingroup texnodes */ +#include "NOD_texture.h" #include "node_texture_util.hh" +#include "node_util.hh" #include "BKE_material.h" #include "BKE_node_runtime.hh" diff --git a/source/blender/nodes/texture/nodes/node_texture_translate.cc b/source/blender/nodes/texture/nodes/node_texture_translate.cc index 37365d8cb1e..6cd130fd7fc 100644 --- a/source/blender/nodes/texture/nodes/node_texture_translate.cc +++ b/source/blender/nodes/texture/nodes/node_texture_translate.cc @@ -6,6 +6,7 @@ * \ingroup texnodes */ +#include "NOD_texture.h" #include "node_texture_util.hh" #include diff --git a/source/blender/nodes/texture/nodes/node_texture_valToNor.cc b/source/blender/nodes/texture/nodes/node_texture_valToNor.cc index 9ac411af933..0887b7529f2 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToNor.cc +++ b/source/blender/nodes/texture/nodes/node_texture_valToNor.cc @@ -6,6 +6,7 @@ * \ingroup texnodes */ +#include "NOD_texture.h" #include "node_texture_util.hh" static bNodeSocketTemplate inputs[] = { diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.cc b/source/blender/nodes/texture/nodes/node_texture_valToRgb.cc index a6ac96fdfbd..30e28543bb4 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.cc +++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.cc @@ -8,6 +8,7 @@ #include "BKE_colorband.hh" #include "IMB_colormanagement.hh" +#include "NOD_texture.h" #include "node_texture_util.hh" #include "node_util.hh" diff --git a/source/blender/nodes/texture/nodes/node_texture_viewer.cc b/source/blender/nodes/texture/nodes/node_texture_viewer.cc index b4e3f2f32f5..56e73741311 100644 --- a/source/blender/nodes/texture/nodes/node_texture_viewer.cc +++ b/source/blender/nodes/texture/nodes/node_texture_viewer.cc @@ -6,6 +6,7 @@ * \ingroup texnodes */ +#include "NOD_texture.h" #include "node_texture_util.hh" #include diff --git a/source/blender/python/bmesh/bmesh_py_types.cc b/source/blender/python/bmesh/bmesh_py_types.cc index fd9669efc24..57c3fea6c19 100644 --- a/source/blender/python/bmesh/bmesh_py_types.cc +++ b/source/blender/python/bmesh/bmesh_py_types.cc @@ -18,7 +18,7 @@ #include "DNA_object_types.h" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" #include "BKE_mesh_runtime.hh" diff --git a/source/blender/python/bmesh/bmesh_py_types_meshdata.cc b/source/blender/python/bmesh/bmesh_py_types_meshdata.cc index 2e16a0eced8..f7e1e114f83 100644 --- a/source/blender/python/bmesh/bmesh_py_types_meshdata.cc +++ b/source/blender/python/bmesh/bmesh_py_types_meshdata.cc @@ -22,6 +22,7 @@ #include "../mathutils/mathutils.h" #include "DNA_meshdata_types.h" +#include "DNA_object_types.h" #include "BKE_customdata.hh" diff --git a/source/blender/python/bmesh/bmesh_py_types_select.cc b/source/blender/python/bmesh/bmesh_py_types_select.cc index df4ac8fe2cd..cea2048135f 100644 --- a/source/blender/python/bmesh/bmesh_py_types_select.cc +++ b/source/blender/python/bmesh/bmesh_py_types_select.cc @@ -22,6 +22,7 @@ #include "bmesh_py_types.h" #include "bmesh_py_types_select.h" +#include "../generic/py_capi_utils.h" #include "../generic/python_utildefines.h" PyDoc_STRVAR( diff --git a/source/blender/python/generic/bgl.cc b/source/blender/python/generic/bgl.cc index b3b5be7af8c..fb3e214e19b 100644 --- a/source/blender/python/generic/bgl.cc +++ b/source/blender/python/generic/bgl.cc @@ -24,7 +24,7 @@ #include "py_capi_utils.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "../generic/py_capi_utils.h" diff --git a/source/blender/python/generic/bl_math_py_api.cc b/source/blender/python/generic/bl_math_py_api.cc index f208b02a3ab..6a2556e231e 100644 --- a/source/blender/python/generic/bl_math_py_api.cc +++ b/source/blender/python/generic/bl_math_py_api.cc @@ -13,6 +13,8 @@ #include "BLI_utildefines.h" +#include "py_capi_utils.h" + #include "bl_math_py_api.h" /* -------------------------------------------------------------------- */ diff --git a/source/blender/python/generic/bpy_threads.cc b/source/blender/python/generic/bpy_threads.cc index 031079834e6..118244d7f37 100644 --- a/source/blender/python/generic/bpy_threads.cc +++ b/source/blender/python/generic/bpy_threads.cc @@ -12,6 +12,7 @@ #include #include "../BPY_extern.h" +#include "BLI_utildefines.h" BPy_ThreadStatePtr BPY_thread_save() { diff --git a/source/blender/python/gpu/gpu_py_compute.cc b/source/blender/python/gpu/gpu_py_compute.cc index 6c7d7914d09..62662242485 100644 --- a/source/blender/python/gpu/gpu_py_compute.cc +++ b/source/blender/python/gpu/gpu_py_compute.cc @@ -15,13 +15,23 @@ #include "GPU_capabilities.h" #include "GPU_compute.h" +#include "GPU_shader.h" #include "GPU_state.h" +#include "GPU_texture.h" +#include "GPU_uniform_buffer.h" +#include "../generic/py_capi_utils.h" #include "../generic/python_compat.h" +#include "../generic/python_utildefines.h" + +#include "../mathutils/mathutils.h" #include "gpu_py.h" #include "gpu_py_compute.h" /* own include */ #include "gpu_py_shader.h" +#include "gpu_py_texture.h" +#include "gpu_py_uniformbuffer.h" +#include "gpu_py_vertex_format.h" PyDoc_STRVAR( /* Wrap. */ diff --git a/source/blender/python/gpu/gpu_py_element.cc b/source/blender/python/gpu/gpu_py_element.cc index 3ef5cae0506..4e19649e544 100644 --- a/source/blender/python/gpu/gpu_py_element.cc +++ b/source/blender/python/gpu/gpu_py_element.cc @@ -17,6 +17,7 @@ #include "../generic/py_capi_utils.h" #include "../generic/python_compat.h" +#include "../generic/python_utildefines.h" #include "gpu_py.h" #include "gpu_py_element.h" /* own include */ diff --git a/source/blender/python/gpu/gpu_py_offscreen.cc b/source/blender/python/gpu/gpu_py_offscreen.cc index cda5085594e..fc79873387f 100644 --- a/source/blender/python/gpu/gpu_py_offscreen.cc +++ b/source/blender/python/gpu/gpu_py_offscreen.cc @@ -17,10 +17,12 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BKE_global.hh" -#include "BKE_lib_id.hh" /* For #BKE_id_is_in_global_main. */ -#include "BKE_scene.hh" +#include "BKE_global.h" +#include "BKE_lib_id.hh" +#include "BKE_scene.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" #include "DNA_view3d_types.h" #include "GPU_context.h" @@ -35,6 +37,7 @@ #include "../generic/py_capi_utils.h" #include "../generic/python_compat.h" +#include "gpu_py.h" #include "gpu_py_texture.h" #include "gpu_py_offscreen.h" /* own include */ diff --git a/source/blender/python/gpu/gpu_py_types.cc b/source/blender/python/gpu/gpu_py_types.cc index c1a7ddb4e1c..7860a796be7 100644 --- a/source/blender/python/gpu/gpu_py_types.cc +++ b/source/blender/python/gpu/gpu_py_types.cc @@ -11,6 +11,8 @@ #include +#include "../generic/py_capi_utils.h" + #include "gpu_py.h" #include "gpu_py_types.h" /* own include */ diff --git a/source/blender/python/gpu/gpu_py_uniformbuffer.cc b/source/blender/python/gpu/gpu_py_uniformbuffer.cc index 1c3be53d5e8..e683be6778b 100644 --- a/source/blender/python/gpu/gpu_py_uniformbuffer.cc +++ b/source/blender/python/gpu/gpu_py_uniformbuffer.cc @@ -18,8 +18,11 @@ #include "GPU_context.h" #include "GPU_uniform_buffer.h" +#include "../generic/py_capi_utils.h" #include "../generic/python_compat.h" +#include "gpu_py.h" + #include "gpu_py_uniformbuffer.h" /* own include */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/python/gpu/gpu_py_vertex_format.cc b/source/blender/python/gpu/gpu_py_vertex_format.cc index c6f204f5a72..53d6b27e4de 100644 --- a/source/blender/python/gpu/gpu_py_vertex_format.cc +++ b/source/blender/python/gpu/gpu_py_vertex_format.cc @@ -13,6 +13,7 @@ #include "../generic/py_capi_utils.h" #include "../generic/python_compat.h" +#include "../generic/python_utildefines.h" #include "gpu_py_vertex_format.h" /* own include */ diff --git a/source/blender/python/intern/bpy.cc b/source/blender/python/intern/bpy.cc index 93cf175b5aa..aa0d505148d 100644 --- a/source/blender/python/intern/bpy.cc +++ b/source/blender/python/intern/bpy.cc @@ -21,12 +21,13 @@ #include "BKE_appdir.hh" #include "BKE_blender_version.h" -#include "BKE_bpath.hh" -#include "BKE_global.hh" /* XXX, G_MAIN only */ +#include "BKE_bpath.h" +#include "BKE_global.h" /* XXX, G_MAIN only */ #include "RNA_access.hh" #include "RNA_enum_types.hh" #include "RNA_prototypes.h" +#include "RNA_types.hh" #include "GPU_state.h" @@ -34,6 +35,7 @@ #include "bpy.h" #include "bpy_app.h" +#include "bpy_capi_utils.h" #include "bpy_driver.h" #include "bpy_library.h" #include "bpy_operator.h" @@ -41,6 +43,7 @@ #include "bpy_rna.h" #include "bpy_rna_data.h" #include "bpy_rna_gizmo.h" +#include "bpy_rna_id_collection.h" #include "bpy_rna_types_capi.h" #include "bpy_utils_previews.h" #include "bpy_utils_units.h" @@ -75,11 +78,11 @@ static PyObject *bpy_script_paths(PyObject * /*self*/) PyObject *item; std::optional path = BKE_appdir_folder_id(BLENDER_SYSTEM_SCRIPTS, nullptr); - item = PyC_UnicodeFromStdStr(path.value_or("")); + item = PyC_UnicodeFromStdStr(path.has_value() ? path.value() : ""); BLI_assert(item != nullptr); PyTuple_SET_ITEM(ret, 0, item); path = BKE_appdir_folder_id(BLENDER_USER_SCRIPTS, nullptr); - item = PyC_UnicodeFromStdStr(path.value_or("")); + item = PyC_UnicodeFromStdStr(path.has_value() ? path.value() : ""); BLI_assert(item != nullptr); PyTuple_SET_ITEM(ret, 1, item); @@ -255,7 +258,7 @@ static PyObject *bpy_user_resource(PyObject * /*self*/, PyObject *args, PyObject subdir_data.value); Py_XDECREF(subdir_data.value_coerce); - return PyC_UnicodeFromStdStr(path.value_or("")); + return PyC_UnicodeFromStdStr(path.has_value() ? path.value() : ""); } PyDoc_STRVAR( @@ -305,7 +308,7 @@ static PyObject *bpy_system_resource(PyObject * /*self*/, PyObject *args, PyObje std::optional path = BKE_appdir_folder_id(type.value_found, subdir_data.value); Py_XDECREF(subdir_data.value_coerce); - return PyC_UnicodeFromStdStr(path.value_or("")); + return PyC_UnicodeFromStdStr(path.has_value() ? path.value() : ""); } PyDoc_STRVAR( @@ -355,7 +358,7 @@ static PyObject *bpy_resource_path(PyObject * /*self*/, PyObject *args, PyObject const std::optional path = BKE_appdir_resource_path_id_with_version( type.value_found, false, (major * 100) + minor); - return PyC_UnicodeFromStdStr(path.value_or("")); + return PyC_UnicodeFromStdStr(path.has_value() ? path.value() : ""); } /* This is only exposed for tests, see: `tests/python/bl_pyapi_bpy_driver_secure_eval.py`. */ diff --git a/source/blender/python/intern/bpy_app.cc b/source/blender/python/intern/bpy_app.cc index 581062d4a5a..14c6178bd48 100644 --- a/source/blender/python/intern/bpy_app.cc +++ b/source/blender/python/intern/bpy_app.cc @@ -39,7 +39,7 @@ #include "BKE_appdir.hh" #include "BKE_blender_version.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_main.hh" #include "DNA_ID.h" diff --git a/source/blender/python/intern/bpy_app_handlers.cc b/source/blender/python/intern/bpy_app_handlers.cc index 121bbb2f391..d44ba399e89 100644 --- a/source/blender/python/intern/bpy_app_handlers.cc +++ b/source/blender/python/intern/bpy_app_handlers.cc @@ -13,9 +13,11 @@ #include "BLI_utildefines.h" #include -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "RNA_access.hh" +#include "RNA_prototypes.h" +#include "RNA_types.hh" #include "bpy_app_handlers.h" #include "bpy_rna.h" @@ -39,7 +41,7 @@ static PyTypeObject BlenderAppCbType; "the file being loaded, an empty string for the startup-file." /** - * See `BKE_callbacks.hh` #eCbEvent declaration for the policy on naming. + * See `BKE_callbacks.h` #eCbEvent declaration for the policy on naming. */ static PyStructSequence_Field app_cb_info_fields[] = { {"frame_change_pre", diff --git a/source/blender/python/intern/bpy_app_timers.cc b/source/blender/python/intern/bpy_app_timers.cc index 4f2074f0e39..094b563902b 100644 --- a/source/blender/python/intern/bpy_app_timers.cc +++ b/source/blender/python/intern/bpy_app_timers.cc @@ -6,13 +6,18 @@ * \ingroup pythonintern */ +#include "BLI_time.h" #include "BLI_timer.h" +#include "BLI_utildefines.h" #include +#include "BPY_extern.h" #include "bpy_app_timers.h" +#include "../generic/py_capi_utils.h" #include "../generic/python_compat.h" +#include "../generic/python_utildefines.h" static double handle_returned_value(PyObject *function, PyObject *ret) { diff --git a/source/blender/python/intern/bpy_app_translations.cc b/source/blender/python/intern/bpy_app_translations.cc index 958c3c8b33b..b51746b295f 100644 --- a/source/blender/python/intern/bpy_app_translations.cc +++ b/source/blender/python/intern/bpy_app_translations.cc @@ -21,8 +21,8 @@ #include "MEM_guardedalloc.h" -#include "BLT_lang.hh" -#include "BLT_translation.hh" +#include "BLT_lang.h" +#include "BLT_translation.h" #include "RNA_types.hh" @@ -416,7 +416,7 @@ static BLT_i18n_contexts_descriptor _contexts[] = BLT_I18NCONTEXTS_DESC; /* These fields are just empty placeholders, actual values get set in app_translations_struct(). * This allows us to avoid many handwriting, and above all, - * to keep all context definition stuff in BLT_translation.hh! */ + * to keep all context definition stuff in BLT_translation.h! */ static PyStructSequence_Field app_translations_contexts_fields[ARRAY_SIZE(_contexts)] = { {nullptr}}; diff --git a/source/blender/python/intern/bpy_capi_utils.cc b/source/blender/python/intern/bpy_capi_utils.cc index 90934a5e841..46dae3f5bd2 100644 --- a/source/blender/python/intern/bpy_capi_utils.cc +++ b/source/blender/python/intern/bpy_capi_utils.cc @@ -11,6 +11,7 @@ #include +#include "BLI_dynstr.h" #include "BLI_listbase.h" #include "BLI_utildefines.h" @@ -18,7 +19,10 @@ #include "MEM_guardedalloc.h" -#include "BKE_report.hh" +#include "BKE_context.hh" +#include "BKE_report.h" + +#include "BLT_translation.h" #include "../generic/py_capi_utils.h" diff --git a/source/blender/python/intern/bpy_driver.cc b/source/blender/python/intern/bpy_driver.cc index 6ebca1096d9..55fb2d54c81 100644 --- a/source/blender/python/intern/bpy_driver.cc +++ b/source/blender/python/intern/bpy_driver.cc @@ -20,11 +20,12 @@ #include "BKE_animsys.h" #include "BKE_fcurve_driver.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "RNA_types.hh" #include "bpy_rna_driver.h" /* For #pyrna_driver_get_variable_value. */ diff --git a/source/blender/python/intern/bpy_gizmo_wrap.cc b/source/blender/python/intern/bpy_gizmo_wrap.cc index a3c0c59f211..6d3c2b69d77 100644 --- a/source/blender/python/intern/bpy_gizmo_wrap.cc +++ b/source/blender/python/intern/bpy_gizmo_wrap.cc @@ -18,6 +18,7 @@ #include "BLI_utildefines.h" +#include "WM_api.hh" #include "WM_types.hh" #include "RNA_access.hh" diff --git a/source/blender/python/intern/bpy_interface.cc b/source/blender/python/intern/bpy_interface.cc index 740f4e5fa4a..415aaacde15 100644 --- a/source/blender/python/intern/bpy_interface.cc +++ b/source/blender/python/intern/bpy_interface.cc @@ -29,7 +29,7 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_types.hh" @@ -47,7 +47,7 @@ #include "BKE_appdir.hh" #include "BKE_context.hh" -#include "BKE_global.hh" /* Only for script checking. */ +#include "BKE_global.h" /* Only for script checking. */ #include "BKE_main.hh" #include "BKE_text.h" @@ -128,10 +128,10 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate) #ifdef TIME_PY_RUN if (bpy_timer_count == 0) { /* Record time from the beginning. */ - bpy_timer = BLI_time_now_seconds(); + bpy_timer = BLI_check_seconds_timer(); bpy_timer_run = bpy_timer_run_tot = 0.0; } - bpy_timer_run = BLI_time_now_seconds(); + bpy_timer_run = BLI_check_seconds_timer(); bpy_timer_count++; #endif @@ -157,7 +157,7 @@ void bpy_context_clear(bContext * /*C*/, const PyGILState_STATE *gilstate) #endif #ifdef TIME_PY_RUN - bpy_timer_run_tot += BLI_time_now_seconds() - bpy_timer_run; + bpy_timer_run_tot += BLI_check_seconds_timer() - bpy_timer_run; bpy_timer_count++; #endif } @@ -593,7 +593,7 @@ void BPY_python_end(const bool do_python_exit) #ifdef TIME_PY_RUN /* Measure time since Python started. */ - bpy_timer = BLI_time_now_seconds() - bpy_timer; + bpy_timer = BLI_check_seconds_timer() - bpy_timer; printf("*bpy stats* - "); printf("tot exec: %d, ", bpy_timer_count); diff --git a/source/blender/python/intern/bpy_interface_run.cc b/source/blender/python/intern/bpy_interface_run.cc index 9fe79457411..b74ad667d52 100644 --- a/source/blender/python/intern/bpy_interface_run.cc +++ b/source/blender/python/intern/bpy_interface_run.cc @@ -19,11 +19,12 @@ #include "BKE_context.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_text.h" #include "DNA_text_types.h" +#include "BPY_extern.h" #include "BPY_extern_run.h" #include "bpy_capi_utils.h" diff --git a/source/blender/python/intern/bpy_library_load.cc b/source/blender/python/intern/bpy_library_load.cc index ec09ade9c4b..db14d2ed321 100644 --- a/source/blender/python/intern/bpy_library_load.cc +++ b/source/blender/python/intern/bpy_library_load.cc @@ -16,6 +16,7 @@ #include #include +#include "BLI_ghash.h" #include "BLI_linklist.h" #include "BLI_path_util.h" #include "BLI_string.h" @@ -26,11 +27,11 @@ #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "DNA_space_types.h" /* FILE_LINK, FILE_RELPATH */ -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/python/intern/bpy_library_write.cc b/source/blender/python/intern/bpy_library_write.cc index 3dfe973fd2a..073bf1d59fb 100644 --- a/source/blender/python/intern/bpy_library_write.cc +++ b/source/blender/python/intern/bpy_library_write.cc @@ -19,16 +19,16 @@ #include "BLI_utildefines.h" #include "BKE_blendfile.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BLO_writefile.hh" #include "RNA_types.hh" #include "bpy_capi_utils.h" -#include "bpy_library.h" /* Declaration for #BPY_library_load_method_def */ +#include "bpy_library.h" #include "bpy_rna.h" #include "../generic/py_capi_utils.h" diff --git a/source/blender/python/intern/bpy_msgbus.cc b/source/blender/python/intern/bpy_msgbus.cc index a5677df770b..d4cec2cba1c 100644 --- a/source/blender/python/intern/bpy_msgbus.cc +++ b/source/blender/python/intern/bpy_msgbus.cc @@ -20,11 +20,17 @@ #include "BKE_context.hh" +#include "WM_api.hh" #include "WM_message.hh" +#include "WM_types.hh" #include "RNA_access.hh" +#include "RNA_define.hh" +#include "RNA_enum_types.hh" #include "bpy_capi_utils.h" +#include "bpy_gizmo_wrap.h" /* own include */ +#include "bpy_intern_string.h" #include "bpy_rna.h" #include "bpy_msgbus.h" /* own include */ diff --git a/source/blender/python/intern/bpy_operator.cc b/source/blender/python/intern/bpy_operator.cc index 497dbb5db3f..4c66122ea06 100644 --- a/source/blender/python/intern/bpy_operator.cc +++ b/source/blender/python/intern/bpy_operator.cc @@ -43,7 +43,7 @@ #include "BLI_ghash.h" #include "BKE_context.hh" -#include "BKE_report.hh" +#include "BKE_report.h" /* so operators called can spawn threads which acquire the GIL */ #define BPY_RELEASE_GIL diff --git a/source/blender/python/intern/bpy_props.cc b/source/blender/python/intern/bpy_props.cc index ba5974d1a6a..f758051469e 100644 --- a/source/blender/python/intern/bpy_props.cc +++ b/source/blender/python/intern/bpy_props.cc @@ -27,6 +27,8 @@ #include "bpy_props.h" #include "bpy_rna.h" +#include "BKE_idprop.h" + #include "RNA_access.hh" #include "RNA_define.hh" /* for defining our own rna */ #include "RNA_enum_types.hh" @@ -1597,10 +1599,10 @@ static void bpy_prop_string_set_fn(PointerRNA *ptr, PropertyRNA *prop, const cha } } -static bool bpy_prop_string_visit_fn_call( - PyObject *py_func, - PyObject *item, - blender::FunctionRef visit_fn) +static bool bpy_prop_string_visit_fn_call(PyObject *py_func, + PyObject *item, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data) { const char *text; const char *info = nullptr; @@ -1637,19 +1639,19 @@ static bool bpy_prop_string_visit_fn_call( } } - StringPropertySearchVisitParams visit_params{}; + StringPropertySearchVisitParams visit_params = {nullptr}; visit_params.text = text; - visit_params.info = info ? info : ""; - visit_fn(visit_params); + visit_params.info = info; + visit_fn(visit_user_data, &visit_params); return true; } -static void bpy_prop_string_visit_for_search_fn( - const bContext *C, - PointerRNA *ptr, - PropertyRNA *prop, - const char *edit_text, - blender::FunctionRef visit_fn) +static void bpy_prop_string_visit_for_search_fn(const bContext *C, + PointerRNA *ptr, + PropertyRNA *prop, + const char *edit_text, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data) { BPyPropStore *prop_store = static_cast(RNA_property_py_data_get(prop)); PyObject *py_func; @@ -1703,7 +1705,8 @@ static void bpy_prop_string_visit_for_search_fn( if (py_text == nullptr) { break; } - const bool ok = bpy_prop_string_visit_fn_call(py_func, py_text, visit_fn); + const bool ok = bpy_prop_string_visit_fn_call( + py_func, py_text, visit_fn, visit_user_data); Py_DECREF(py_text); if (!ok) { break; @@ -1733,7 +1736,8 @@ static void bpy_prop_string_visit_for_search_fn( const Py_ssize_t ret_num = PySequence_Fast_GET_SIZE(ret_fast); PyObject **ret_fast_items = PySequence_Fast_ITEMS(ret_fast); for (Py_ssize_t i = 0; i < ret_num; i++) { - const bool ok = bpy_prop_string_visit_fn_call(py_func, ret_fast_items[i], visit_fn); + const bool ok = bpy_prop_string_visit_fn_call( + py_func, ret_fast_items[i], visit_fn, visit_user_data); if (!ok) { break; } diff --git a/source/blender/python/intern/bpy_rna.cc b/source/blender/python/intern/bpy_rna.cc index 4458a378216..4af762aa089 100644 --- a/source/blender/python/intern/bpy_rna.cc +++ b/source/blender/python/intern/bpy_rna.cc @@ -51,14 +51,14 @@ #include "MEM_guardedalloc.h" #include "BKE_context.hh" -#include "BKE_global.hh" /* evil G.* */ +#include "BKE_global.h" /* evil G.* */ #include "BKE_idprop.h" #include "BKE_idtype.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" /* Only for types. */ -#include "BKE_node.hh" +#include "BKE_node.h" #include "DEG_depsgraph_query.hh" diff --git a/source/blender/python/intern/bpy_rna_anim.cc b/source/blender/python/intern/bpy_rna_anim.cc index 3d971ad25c0..9d3e0801b1f 100644 --- a/source/blender/python/intern/bpy_rna_anim.cc +++ b/source/blender/python/intern/bpy_rna_anim.cc @@ -20,6 +20,7 @@ #include "DNA_anim_types.h" #include "DNA_scene_types.h" +#include "ED_keyframes_edit.hh" #include "ED_keyframing.hh" #include "ANIM_keyframing.hh" @@ -28,10 +29,10 @@ #include "BKE_animsys.h" #include "BKE_context.hh" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "RNA_access.hh" #include "RNA_enum_types.hh" diff --git a/source/blender/python/intern/bpy_rna_data.cc b/source/blender/python/intern/bpy_rna_data.cc index f0b9a68ad32..a6b54efa1b2 100644 --- a/source/blender/python/intern/bpy_rna_data.cc +++ b/source/blender/python/intern/bpy_rna_data.cc @@ -22,7 +22,7 @@ #include "BLI_string.h" #include "BLI_utildefines.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_main.hh" #include "RNA_access.hh" diff --git a/source/blender/python/intern/bpy_rna_gizmo.cc b/source/blender/python/intern/bpy_rna_gizmo.cc index 45e354d878a..9a04bf307d8 100644 --- a/source/blender/python/intern/bpy_rna_gizmo.cc +++ b/source/blender/python/intern/bpy_rna_gizmo.cc @@ -16,6 +16,7 @@ #include "BLI_alloca.h" #include "BLI_utildefines.h" +#include "WM_api.hh" #include "WM_types.hh" #include "bpy_capi_utils.h" @@ -23,9 +24,12 @@ #include "../generic/py_capi_utils.h" #include "../generic/python_compat.h" +#include "../generic/python_utildefines.h" #include "RNA_access.hh" +#include "RNA_enum_types.hh" #include "RNA_prototypes.h" +#include "RNA_types.hh" #include "bpy_rna.h" diff --git a/source/blender/python/intern/bpy_rna_id_collection.cc b/source/blender/python/intern/bpy_rna_id_collection.cc index a8051141506..c72e002bdb6 100644 --- a/source/blender/python/intern/bpy_rna_id_collection.cc +++ b/source/blender/python/intern/bpy_rna_id_collection.cc @@ -16,7 +16,7 @@ #include "BLI_bitmap.h" #include "BLI_utildefines.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_main.hh" @@ -24,17 +24,23 @@ #include "DNA_ID.h" /* Those following are only to support hack of not listing some internal * 'backward' pointers in generated user_map. */ +#include "DNA_key_types.h" +#include "DNA_object_types.h" #include "WM_api.hh" #include "WM_types.hh" +#include "bpy_capi_utils.h" #include "bpy_rna_id_collection.h" #include "../generic/py_capi_rna.h" #include "../generic/py_capi_utils.h" #include "../generic/python_compat.h" +#include "../generic/python_utildefines.h" +#include "RNA_access.hh" #include "RNA_enum_types.hh" +#include "RNA_types.hh" #include "bpy_rna.h" @@ -377,10 +383,11 @@ static PyObject *bpy_orphans_purge(PyObject * /*self*/, PyObject *args, PyObject Main *bmain = G_MAIN; /* XXX Ugly, but should work! */ #endif - LibQueryUnusedIDsData unused_ids_data; - unused_ids_data.do_local_ids = true; - unused_ids_data.do_linked_ids = true; - unused_ids_data.do_recursive = false; + int num_tagged[INDEX_ID_MAX] = {0}; + + bool do_local_ids = true; + bool do_linked_ids = true; + bool do_recursive_cleanup = false; static const char *_keywords[] = {"do_local_ids", "do_linked_ids", "do_recursive", nullptr}; static _PyArg_Parser _parser = { @@ -397,19 +404,20 @@ static PyObject *bpy_orphans_purge(PyObject * /*self*/, PyObject *args, PyObject kwds, &_parser, PyC_ParseBool, - &unused_ids_data.do_local_ids, + &do_local_ids, PyC_ParseBool, - &unused_ids_data.do_linked_ids, + &do_linked_ids, PyC_ParseBool, - &unused_ids_data.do_recursive)) + &do_recursive_cleanup)) { return nullptr; } /* Tag all IDs to delete. */ - BKE_lib_query_unused_ids_tag(bmain, LIB_TAG_DOIT, unused_ids_data); + BKE_lib_query_unused_ids_tag( + bmain, LIB_TAG_DOIT, do_local_ids, do_linked_ids, do_recursive_cleanup, num_tagged); - if (unused_ids_data.num_total[INDEX_ID_NULL] == 0) { + if (num_tagged[INDEX_ID_NULL] == 0) { return PyLong_FromSize_t(0); } diff --git a/source/blender/python/intern/bpy_rna_operator.cc b/source/blender/python/intern/bpy_rna_operator.cc index 21f5d840666..7f15ea5fc88 100644 --- a/source/blender/python/intern/bpy_rna_operator.cc +++ b/source/blender/python/intern/bpy_rna_operator.cc @@ -19,7 +19,7 @@ #include "BPY_extern.h" #include "bpy_capi_utils.h" -#include "bpy_rna_operator.h" /* Own include, #BPY_rna_operator_poll_message_set_method_def. */ +#include "bpy_rna_operator.h" /* Own include. */ /* -------------------------------------------------------------------- */ /** \name Operator `poll_message_set` Method diff --git a/source/blender/python/intern/bpy_rna_text.cc b/source/blender/python/intern/bpy_rna_text.cc index 6fe476964c8..a7054f557c2 100644 --- a/source/blender/python/intern/bpy_rna_text.cc +++ b/source/blender/python/intern/bpy_rna_text.cc @@ -12,6 +12,8 @@ #include +#include "DNA_text_types.h" + #include "MEM_guardedalloc.h" #include "WM_api.hh" @@ -20,8 +22,9 @@ #include "../generic/python_compat.h" +#include "bpy_capi_utils.h" #include "bpy_rna.h" -#include "bpy_rna_text.h" /* Declare #BPY_rna_region_as_string_method_def. */ +#include "bpy_rna_text.h" /* -------------------------------------------------------------------- */ /** \name Data structures. diff --git a/source/blender/python/intern/bpy_rna_types_capi.cc b/source/blender/python/intern/bpy_rna_types_capi.cc index aab00b8cd70..f68f1427b20 100644 --- a/source/blender/python/intern/bpy_rna_types_capi.cc +++ b/source/blender/python/intern/bpy_rna_types_capi.cc @@ -35,6 +35,7 @@ #include "../generic/py_capi_utils.h" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/python/intern/bpy_rna_ui.cc b/source/blender/python/intern/bpy_rna_ui.cc index a7579231c4b..6d8f3898840 100644 --- a/source/blender/python/intern/bpy_rna_ui.cc +++ b/source/blender/python/intern/bpy_rna_ui.cc @@ -16,8 +16,10 @@ #include "UI_interface.hh" +#include "RNA_types.hh" + #include "bpy_rna.h" -#include "bpy_rna_ui.h" /* Declare #BPY_rna_uilayout_introspect_method_def. */ +#include "bpy_rna_ui.h" PyDoc_STRVAR( /* Wrap. */ diff --git a/source/blender/python/intern/bpy_utils_previews.cc b/source/blender/python/intern/bpy_utils_previews.cc index 076a2de6b52..61673ae058f 100644 --- a/source/blender/python/intern/bpy_utils_previews.cc +++ b/source/blender/python/intern/bpy_utils_previews.cc @@ -18,7 +18,9 @@ #include "RNA_access.hh" #include "RNA_prototypes.h" +#include "RNA_types.hh" +#include "BPY_extern.h" #include "bpy_rna.h" #include "bpy_utils_previews.h" @@ -26,10 +28,16 @@ #include "MEM_guardedalloc.h" +#include "IMB_imbuf.hh" +#include "IMB_imbuf_types.hh" #include "IMB_thumbs.hh" #include "BKE_preview_image.hh" +#include "DNA_ID.h" + +#include "../generic/python_utildefines.h" + #define STR_SOURCE_TYPES "'IMAGE', 'MOVIE', 'BLEND', 'FONT'" PyDoc_STRVAR( diff --git a/source/blender/python/mathutils/mathutils_bvhtree.cc b/source/blender/python/mathutils/mathutils_bvhtree.cc index 570d50a5df0..c9d8f28afb6 100644 --- a/source/blender/python/mathutils/mathutils_bvhtree.cc +++ b/source/blender/python/mathutils/mathutils_bvhtree.cc @@ -35,6 +35,7 @@ # include "DNA_object_types.h" # include "BKE_customdata.hh" +# include "BKE_editmesh_bvh.h" # include "BKE_lib_id.hh" # include "BKE_mesh.hh" # include "BKE_mesh_runtime.hh" @@ -47,7 +48,7 @@ # include "../bmesh/bmesh_py_types.h" #endif /* MATH_STANDALONE */ -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" /* -------------------------------------------------------------------- */ /** \name Documentation String (snippets) diff --git a/source/blender/python/mathutils/mathutils_kdtree.cc b/source/blender/python/mathutils/mathutils_kdtree.cc index 580035341cd..d23bd1548c6 100644 --- a/source/blender/python/mathutils/mathutils_kdtree.cc +++ b/source/blender/python/mathutils/mathutils_kdtree.cc @@ -22,7 +22,7 @@ #include "mathutils.h" #include "mathutils_kdtree.h" /* own include */ -#include "BLI_strict_flags.h" /* Keep last. */ +#include "BLI_strict_flags.h" struct PyKDTree { PyObject_HEAD diff --git a/source/blender/render/CMakeLists.txt b/source/blender/render/CMakeLists.txt index 0439f9b2755..f7b39a0a9f6 100644 --- a/source/blender/render/CMakeLists.txt +++ b/source/blender/render/CMakeLists.txt @@ -8,7 +8,6 @@ set(INC intern ../blenkernel ../blentranslation - ../compositor ../compositor/realtime_compositor ../compositor/realtime_compositor/cached_resources ../draw diff --git a/source/blender/render/RE_bake.h b/source/blender/render/RE_bake.h index 9670ff0d017..47c8810dda2 100644 --- a/source/blender/render/RE_bake.h +++ b/source/blender/render/RE_bake.h @@ -94,8 +94,8 @@ bool RE_bake_pixels_populate_from_objects(struct Mesh *me_low, bool is_custom_cage, float cage_extrusion, float max_ray_distance, - const float mat_low[4][4], - const float mat_cage[4][4], + float mat_low[4][4], + float mat_cage[4][4], struct Mesh *me_cage); void RE_bake_pixels_populate(struct Mesh *mesh, @@ -130,7 +130,7 @@ void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[], float result[], struct Mesh *mesh, const eBakeNormalSwizzle normal_swizzle[3], - const float mat[4][4]); + float mat[4][4]); void RE_bake_normal_world_to_world(const BakePixel pixel_array[], size_t pixels_num, int depth, diff --git a/source/blender/render/hydra/camera.cc b/source/blender/render/hydra/camera.cc index a62319461b0..0fcf2c88c63 100644 --- a/source/blender/render/hydra/camera.cc +++ b/source/blender/render/hydra/camera.cc @@ -80,7 +80,7 @@ pxr::GfCamera gf_camera(const Object *camera_obj, BKE_camera_params_from_object(¶ms, camera_obj); pxr::GfCamera camera = gf_camera(params, res, border); - camera.SetTransform(io::hydra::gf_matrix_from_transform(camera_obj->object_to_world().ptr())); + camera.SetTransform(io::hydra::gf_matrix_from_transform(camera_obj->object_to_world)); return camera; } diff --git a/source/blender/render/hydra/final_engine.cc b/source/blender/render/hydra/final_engine.cc index 2f5584bf065..13648148df6 100644 --- a/source/blender/render/hydra/final_engine.cc +++ b/source/blender/render/hydra/final_engine.cc @@ -72,7 +72,7 @@ void FinalEngine::render() engine_->Execute(render_index_.get(), &t); char elapsed_time[32]; - double time_begin = BLI_time_now_seconds(); + double time_begin = BLI_check_seconds_timer(); float percent_done = 0.0; while (true) { @@ -82,7 +82,7 @@ void FinalEngine::render() percent_done = renderer_percent_done(); BLI_timecode_string_from_time_simple( - elapsed_time, sizeof(elapsed_time), BLI_time_now_seconds() - time_begin); + elapsed_time, sizeof(elapsed_time), BLI_check_seconds_timer() - time_begin); notify_status(percent_done / 100.0, std::string(scene_name) + ": " + view_layer->name, std::string("Render Time: ") + elapsed_time + diff --git a/source/blender/render/hydra/viewport_engine.cc b/source/blender/render/hydra/viewport_engine.cc index 180fe054b8c..3bb6afcff92 100644 --- a/source/blender/render/hydra/viewport_engine.cc +++ b/source/blender/render/hydra/viewport_engine.cc @@ -9,6 +9,7 @@ #include #include +#include "DNA_camera_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_vec_types.h" /* This include must be before `BKE_camera.h` due to `rctf` type. */ @@ -21,6 +22,9 @@ #include "BKE_camera.h" #include "BKE_context.hh" +#include "DEG_depsgraph_query.hh" + +#include "GPU_context.h" #include "GPU_matrix.h" #include "RE_engine.h" @@ -65,7 +69,7 @@ ViewSettings::ViewSettings(bContext *context) for (int i = 0; i < 4; i++) { float world_location[] = { camera_points[i][0], camera_points[i][1], camera_points[i][2], 1.0f}; - mul_m4_v4(camera_obj->object_to_world().ptr(), world_location); + mul_m4_v4(camera_obj->object_to_world, world_location); mul_m4_v4(region_data->persmat, world_location); if (world_location[3] > 0.0) { @@ -247,13 +251,13 @@ void ViewportEngine::render() GPU_shader_unbind(); if (renderer_percent_done() == 0.0f) { - time_begin_ = BLI_time_now_seconds(); + time_begin_ = BLI_check_seconds_timer(); } char elapsed_time[32]; BLI_timecode_string_from_time_simple( - elapsed_time, sizeof(elapsed_time), BLI_time_now_seconds() - time_begin_); + elapsed_time, sizeof(elapsed_time), BLI_check_seconds_timer() - time_begin_); float percent_done = renderer_percent_done(); if (!render_task_delegate_->is_converged()) { diff --git a/source/blender/render/intern/bake.cc b/source/blender/render/intern/bake.cc index 1e818968781..5466b60680d 100644 --- a/source/blender/render/intern/bake.cc +++ b/source/blender/render/intern/bake.cc @@ -550,8 +550,8 @@ bool RE_bake_pixels_populate_from_objects(Mesh *me_low, const bool is_custom_cage, const float cage_extrusion, const float max_ray_distance, - const float mat_low[4][4], - const float mat_cage[4][4], + float mat_low[4][4], + float mat_cage[4][4], Mesh *me_cage) { size_t i; @@ -855,7 +855,7 @@ void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[], float result[], Mesh *mesh, const eBakeNormalSwizzle normal_swizzle[3], - const float mat[4][4]) + float mat[4][4]) { size_t i; @@ -984,7 +984,7 @@ void RE_bake_normal_world_to_object(const BakePixel pixel_array[], size_t i; float iobmat[4][4]; - invert_m4_m4(iobmat, ob->object_to_world().ptr()); + invert_m4_m4(iobmat, ob->object_to_world); for (i = 0; i < pixels_num; i++) { size_t offset; diff --git a/source/blender/render/intern/compositor.cc b/source/blender/render/intern/compositor.cc index a9b9a92930b..ae1d54872a2 100644 --- a/source/blender/render/intern/compositor.cc +++ b/source/blender/render/intern/compositor.cc @@ -13,10 +13,10 @@ #include "DNA_ID.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_node.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DRW_engine.hh" #include "DRW_render.hh" @@ -33,10 +33,6 @@ #include "RE_compositor.hh" #include "RE_pipeline.h" -#include "WM_api.hh" - -#include "GPU_context.h" - #include "render_types.h" namespace blender::render { @@ -210,7 +206,7 @@ class Context : public realtime_compositor::Context { int2 get_render_size() const override { int width, height; - BKE_render_resolution(input_data_.render_data, true, &width, &height); + BKE_render_resolution(input_data_.render_data, false, &width, &height); return int2(width, height); } @@ -508,23 +504,7 @@ class RealtimeCompositor { * to avoid them blocking each other. */ BLI_assert(!BLI_thread_is_main() || G.background); - /* The realtime compositor uses GPU module and does not rely on the draw manager, or its global - * state. This means that activation of GPU context does not require lock of the main thread. - * - * However, while this has been tested on Linux and works well, on macOS it causes to - * spontaneous invalid colors in the composite output. The Windows has not been extensively - * tested yet. */ -#if defined(__linux__) - void *re_system_gpu_context = RE_system_gpu_context_get(&render_); - void *re_blender_gpu_context = RE_blender_gpu_context_ensure(&render_); - - GPU_render_begin(); - WM_system_gpu_context_activate(re_system_gpu_context); - GPU_context_active_set(static_cast(re_blender_gpu_context)); -#else DRW_render_context_enable(&render_); -#endif - context_->update_input_data(input_data); /* Always recreate the evaluator, as this only runs on compositing node changes and @@ -537,15 +517,7 @@ class RealtimeCompositor { context_->output_to_render_result(); context_->viewer_output_to_viewer_image(); texture_pool_->free_unused_and_reset(); - -#if defined(__linux__) - GPU_flush(); - GPU_render_end(); - GPU_context_active_set(nullptr); - WM_system_gpu_context_release(re_system_gpu_context); -#else DRW_render_context_disable(&render_); -#endif } }; diff --git a/source/blender/render/intern/engine.cc b/source/blender/render/intern/engine.cc index 9756d081867..aa0ee392248 100644 --- a/source/blender/render/intern/engine.cc +++ b/source/blender/render/intern/engine.cc @@ -12,19 +12,23 @@ #include "MEM_guardedalloc.h" +#include "BLT_translation.h" + #include "BLI_ghash.h" #include "BLI_listbase.h" #include "BLI_math_bits.h" +#include "BLI_rect.h" #include "BLI_string.h" #include "BLI_utildefines.h" #include "DNA_object_types.h" #include "BKE_camera.h" -#include "BKE_global.hh" +#include "BKE_global.h" +#include "BKE_layer.hh" #include "BKE_node.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_debug.hh" @@ -32,6 +36,8 @@ #include "GPU_context.h" +#include "RNA_access.hh" + #ifdef WITH_PYTHON # include "BPY_extern.h" #endif diff --git a/source/blender/render/intern/initrender.cc b/source/blender/render/intern/initrender.cc index 963ac6f7238..3abb219f154 100644 --- a/source/blender/render/intern/initrender.cc +++ b/source/blender/render/intern/initrender.cc @@ -15,13 +15,18 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" +#include "BLI_ghash.h" #include "BLI_math_base.h" #include "BLI_math_matrix.h" #include "BLI_utildefines.h" +#include "DNA_camera_types.h" + #include "BKE_camera.h" /* this module */ +#include "pipeline.hh" #include "render_types.h" /* ****************** MASKS and LUTS **************** */ diff --git a/source/blender/render/intern/multires_bake.cc b/source/blender/render/intern/multires_bake.cc index 0064d639785..0f8bff2345b 100644 --- a/source/blender/render/intern/multires_bake.cc +++ b/source/blender/render/intern/multires_bake.cc @@ -10,6 +10,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "BLI_listbase.h" @@ -21,9 +22,10 @@ #include "BKE_DerivedMesh.hh" #include "BKE_ccg.h" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_lib_id.hh" +#include "BKE_material.h" #include "BKE_mesh.hh" #include "BKE_mesh_tangent.hh" #include "BKE_modifier.hh" @@ -34,6 +36,7 @@ #include "RE_multires_bake.h" #include "RE_pipeline.h" +#include "RE_texture.h" #include "RE_texture_margin.h" #include "IMB_imbuf.hh" diff --git a/source/blender/render/intern/pipeline.cc b/source/blender/render/intern/pipeline.cc index baa0df32d9e..ebe4a65c13d 100644 --- a/source/blender/render/intern/pipeline.cc +++ b/source/blender/render/intern/pipeline.cc @@ -29,7 +29,9 @@ #include "MEM_guardedalloc.h" #include "BLI_fileops.h" +#include "BLI_implicit_sharing.hh" #include "BLI_listbase.h" +#include "BLI_path_util.h" #include "BLI_rect.h" #include "BLI_string.h" #include "BLI_threads.h" @@ -37,14 +39,14 @@ #include "BLI_timecode.h" #include "BLI_vector.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_anim_data.h" #include "BKE_animsys.h" /* <------ should this be here?, needed for sequencer update */ -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "BKE_camera.h" #include "BKE_colortools.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_image_format.h" #include "BKE_image_save.h" @@ -54,16 +56,17 @@ #include "BKE_main.hh" #include "BKE_mask.h" #include "BKE_modifier.hh" +#include "BKE_node.hh" #include "BKE_node_runtime.hh" +#include "BKE_object.hh" #include "BKE_pointcache.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_sound.h" #include "BKE_writeavi.h" /* <------ should be replaced once with generic movie module */ #include "NOD_composite.hh" -#include "COM_profile.hh" #include "COM_render_context.hh" #include "DEG_depsgraph.hh" @@ -199,7 +202,7 @@ static void stats_background(void * /*arg*/, RenderStats *rs) megs_peak_memory = (peak_memory) / (1024.0 * 1024.0); BLI_timecode_string_from_time_simple( - info_time_str, sizeof(info_time_str), BLI_time_now_seconds() - rs->starttime); + info_time_str, sizeof(info_time_str), BLI_check_seconds_timer() - rs->starttime); /* Compositor calls this from multiple threads, mutex lock to ensure we don't * get garbled output. */ @@ -663,10 +666,10 @@ void RE_FreeUnusedGPUResources() break; } - /* Detect if scene is using GPU compositing, and if either a node editor is + /* Detect if scene is using realtime compositing, and if either a node editor is * showing the nodes, or an image editor is showing the render result or viewer. */ if (!(scene->use_nodes && scene->nodetree && - scene->nodetree->execution_mode == NTREE_EXECUTION_MODE_GPU)) + scene->nodetree->execution_mode == NTREE_EXECUTION_MODE_REALTIME)) { continue; } @@ -788,7 +791,7 @@ void RE_InitState(Render *re, re->ok = true; /* maybe flag */ - re->i.starttime = BLI_time_now_seconds(); + re->i.starttime = BLI_check_seconds_timer(); /* copy render data and render layers for thread safety */ render_copy_renderdata(&re->r, rd); @@ -1298,7 +1301,6 @@ static void do_render_compositor(Render *re) } blender::realtime_compositor::RenderContext compositor_render_context; - blender::compositor::ProfilerData profiler_data; LISTBASE_FOREACH (RenderView *, rv, &re->result->views) { ntreeCompositExecTree(re, re->pipeline_scene_eval, @@ -1307,8 +1309,7 @@ static void do_render_compositor(Render *re) true, G.background == 0, rv->name, - &compositor_render_context, - profiler_data); + &compositor_render_context); } compositor_render_context.save_file_outputs(re->pipeline_scene_eval); @@ -1489,7 +1490,7 @@ static void do_render_full_pipeline(Render *re) BKE_scene_camera_switch_update(re->scene); - re->i.starttime = BLI_time_now_seconds(); + re->i.starttime = BLI_check_seconds_timer(); /* ensure no images are in memory from previous animated sequences */ BKE_image_all_free_anim_ibufs(re->main, re->r.cfra); @@ -1512,7 +1513,7 @@ static void do_render_full_pipeline(Render *re) do_render_compositor(re); } - re->i.lastframetime = BLI_time_now_seconds() - re->i.starttime; + re->i.lastframetime = BLI_check_seconds_timer() - re->i.starttime; re->stats_draw(&re->i); @@ -1675,7 +1676,7 @@ static bool is_compositing_possible_on_gpu(Scene *scene, ReportList *reports) { /* CPU compositor can always run. */ if (!U.experimental.use_full_frame_compositor || - scene->nodetree->execution_mode != NTREE_EXECUTION_MODE_GPU) + scene->nodetree->execution_mode != NTREE_EXECUTION_MODE_REALTIME) { return true; } @@ -2194,7 +2195,7 @@ static bool do_write_image_or_movie(Render *re, } render_time = re->i.lastframetime; - re->i.lastframetime = BLI_time_now_seconds() - re->i.starttime; + re->i.lastframetime = BLI_check_seconds_timer() - re->i.starttime; BLI_timecode_string_from_time_simple(filepath, sizeof(filepath), re->i.lastframetime); printf("Time: %s", filepath); diff --git a/source/blender/render/intern/render_result.cc b/source/blender/render/intern/render_result.cc index 69ab8ff1b23..c9fb2a5ef84 100644 --- a/source/blender/render/intern/render_result.cc +++ b/source/blender/render/intern/render_result.cc @@ -13,7 +13,9 @@ #include "MEM_guardedalloc.h" +#include "BLI_ghash.h" #include "BLI_hash_md5.hh" +#include "BLI_implicit_sharing.hh" #include "BLI_listbase.h" #include "BLI_path_util.h" #include "BLI_rect.h" @@ -23,13 +25,14 @@ #include "BLI_utildefines.h" #include "BKE_appdir.hh" -#include "BKE_global.hh" +#include "BKE_camera.h" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_image_format.h" #include "BKE_image_save.h" #include "BKE_main.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "IMB_colormanagement.hh" #include "IMB_imbuf.hh" @@ -38,6 +41,8 @@ #include "GPU_texture.h" +#include "RE_engine.h" + #include "render_result.h" #include "render_types.h" diff --git a/source/blender/render/intern/render_types.cc b/source/blender/render/intern/render_types.cc index bdcfbcdc9bc..690bfc65c15 100644 --- a/source/blender/render/intern/render_types.cc +++ b/source/blender/render/intern/render_types.cc @@ -8,6 +8,8 @@ #include "render_types.h" +#include "BLI_ghash.h" + #include "BKE_colortools.hh" #include "RE_compositor.hh" diff --git a/source/blender/render/intern/texture_image.cc b/source/blender/render/intern/texture_image.cc index 3c933458f01..d3de063eb69 100644 --- a/source/blender/render/intern/texture_image.cc +++ b/source/blender/render/intern/texture_image.cc @@ -22,8 +22,10 @@ #include "IMB_imbuf_types.hh" #include "DNA_image_types.h" +#include "DNA_scene_types.h" #include "DNA_texture_types.h" +#include "BLI_blenlib.h" #include "BLI_math_color.h" #include "BLI_math_interp.hh" #include "BLI_math_vector.h" diff --git a/source/blender/render/intern/texture_pointdensity.cc b/source/blender/render/intern/texture_pointdensity.cc index 903fa01f108..783e07dc205 100644 --- a/source/blender/render/intern/texture_pointdensity.cc +++ b/source/blender/render/intern/texture_pointdensity.cc @@ -21,23 +21,29 @@ #include "BLI_task.h" #include "BLI_utildefines.h" +#include "BLT_translation.h" + #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_particle_types.h" +#include "DNA_scene_types.h" #include "DNA_texture_types.h" #include "BKE_colorband.hh" #include "BKE_colortools.hh" #include "BKE_customdata.hh" #include "BKE_deform.hh" +#include "BKE_lattice.hh" #include "BKE_mesh.hh" #include "BKE_object.hh" #include "BKE_particle.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_query.hh" +#include "texture_common.h" + #include "RE_texture.h" static ThreadMutex sample_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -181,7 +187,7 @@ static void pointdensity_cache_psys( sim.psmd = psys_get_modifier(ob, psys); /* in case ob->world_to_object isn't up-to-date */ - invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ob->world_to_object, ob->object_to_world); total_particles = psys->totpart + psys->totchild; psys_sim_data_init(&sim); @@ -241,7 +247,7 @@ static void pointdensity_cache_psys( copy_v3_v3(partco, state.co); if (pd->psys_cache_space == TEX_PD_OBJECTSPACE) { - mul_m4_v3(ob->world_to_object().ptr(), partco); + mul_m4_v3(ob->world_to_object, partco); } else if (pd->psys_cache_space == TEX_PD_OBJECTLOC) { sub_v3_v3(partco, ob->loc); @@ -404,12 +410,12 @@ static void pointdensity_cache_object(PointDensity *pd, Object *ob) case TEX_PD_OBJECTSPACE: break; case TEX_PD_OBJECTLOC: - mul_m4_v3(ob->object_to_world().ptr(), co); + mul_m4_v3(ob->object_to_world, co); sub_v3_v3(co, ob->loc); break; case TEX_PD_WORLDSPACE: default: - mul_m4_v3(ob->object_to_world().ptr(), co); + mul_m4_v3(ob->object_to_world, co); break; } @@ -785,7 +791,7 @@ static void particle_system_minmax(Depsgraph *depsgraph, sim.psys = psys; sim.psmd = psys_get_modifier(object, psys); - invert_m4_m4(imat, object->object_to_world().ptr()); + invert_m4_m4(imat, object->object_to_world); total_particles = psys->totpart + psys->totchild; psys_sim_data_init(&sim); diff --git a/source/blender/render/intern/texture_procedural.cc b/source/blender/render/intern/texture_procedural.cc index 39a31106287..70be01fce83 100644 --- a/source/blender/render/intern/texture_procedural.cc +++ b/source/blender/render/intern/texture_procedural.cc @@ -16,9 +16,12 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" +#include "DNA_anim_types.h" #include "DNA_image_types.h" +#include "DNA_light_types.h" #include "DNA_material_types.h" #include "DNA_node_types.h" +#include "DNA_object_types.h" #include "DNA_texture_types.h" #include "IMB_colormanagement.hh" @@ -26,6 +29,10 @@ #include "BKE_colorband.hh" #include "BKE_image.h" +#include "BKE_material.h" +#include "BKE_node.h" +#include "BKE_scene.h" +#include "BKE_texture.h" #include "NOD_texture.h" diff --git a/source/blender/render/intern/tile_highlight.cc b/source/blender/render/intern/tile_highlight.cc index 6f34079bce9..85b640c5721 100644 --- a/source/blender/render/intern/tile_highlight.cc +++ b/source/blender/render/intern/tile_highlight.cc @@ -10,6 +10,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_ghash.h" #include "BLI_hash.hh" #include "RE_pipeline.h" diff --git a/source/blender/sequencer/intern/animation.cc b/source/blender/sequencer/intern/animation.cc index 985535b7fcf..1174d93665e 100644 --- a/source/blender/sequencer/intern/animation.cc +++ b/source/blender/sequencer/intern/animation.cc @@ -12,6 +12,7 @@ #include "DNA_scene_types.h" #include "DNA_sequence_types.h" +#include "BKE_animsys.h" #include "BKE_fcurve.h" #include "BLI_ghash.h" diff --git a/source/blender/sequencer/intern/channels.cc b/source/blender/sequencer/intern/channels.cc index 55fa661a1e6..851854c1d5e 100644 --- a/source/blender/sequencer/intern/channels.cc +++ b/source/blender/sequencer/intern/channels.cc @@ -11,11 +11,15 @@ #include "MEM_guardedalloc.h" #include "DNA_listBase.h" +#include "DNA_scene_types.h" #include "DNA_sequence_types.h" #include "BLI_blenlib.h" #include "SEQ_channels.hh" +#include "SEQ_iterator.hh" +#include "SEQ_relations.hh" +#include "SEQ_sequencer.hh" ListBase *SEQ_channels_displayed_get(Editing *ed) { diff --git a/source/blender/sequencer/intern/disk_cache.cc b/source/blender/sequencer/intern/disk_cache.cc index 3566b963c54..fb16e84be58 100644 --- a/source/blender/sequencer/intern/disk_cache.cc +++ b/source/blender/sequencer/intern/disk_cache.cc @@ -14,6 +14,7 @@ #include "DNA_scene_types.h" #include "DNA_sequence_types.h" +#include "DNA_space_types.h" /* for FILE_MAX. */ #include "IMB_colormanagement.hh" #include "IMB_imbuf.hh" @@ -24,17 +25,25 @@ #include "BLI_endian_switch.h" #include "BLI_fileops.h" #include "BLI_fileops_types.h" +#include "BLI_ghash.h" #include "BLI_listbase.h" +#include "BLI_mempool.h" #include "BLI_path_util.h" #include "BLI_threads.h" #include "BKE_main.hh" +#include "BKE_scene.h" +#include "SEQ_prefetch.hh" +#include "SEQ_relations.hh" #include "SEQ_render.hh" +#include "SEQ_sequencer.hh" #include "SEQ_time.hh" #include "disk_cache.hh" #include "image_cache.hh" +#include "prefetch.hh" +#include "strip_time.hh" /** * Disk Cache Design Notes @@ -632,14 +641,12 @@ ImBuf *seq_disk_cache_read_file(SeqDiskCache *disk_cache, SeqCacheKey *key) if (header.entry[entry_index].size_raw == size_char) { expected_size = size_char; - ibuf = IMB_allocImBuf( - key->context.rectx, key->context.recty, 32, IB_rect | IB_uninitialized_pixels); + ibuf = IMB_allocImBuf(key->context.rectx, key->context.recty, 32, IB_rect); IMB_colormanagement_assign_byte_colorspace(ibuf, header.entry[entry_index].colorspace_name); } else if (header.entry[entry_index].size_raw == size_float) { expected_size = size_float; - ibuf = IMB_allocImBuf( - key->context.rectx, key->context.recty, 32, IB_rectfloat | IB_uninitialized_pixels); + ibuf = IMB_allocImBuf(key->context.rectx, key->context.recty, 32, IB_rectfloat); IMB_colormanagement_assign_float_colorspace(ibuf, header.entry[entry_index].colorspace_name); } else { diff --git a/source/blender/sequencer/intern/effects.cc b/source/blender/sequencer/intern/effects.cc index a8dc33a506e..c0cb43a7913 100644 --- a/source/blender/sequencer/intern/effects.cc +++ b/source/blender/sequencer/intern/effects.cc @@ -15,6 +15,7 @@ #include "MEM_guardedalloc.h" #include "BLI_array.hh" +#include "BLI_listbase.h" #include "BLI_math_rotation.h" #include "BLI_math_vector.hh" #include "BLI_math_vector_types.hh" @@ -25,6 +26,7 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" +#include "DNA_anim_types.h" #include "DNA_packedFile_types.h" #include "DNA_scene_types.h" #include "DNA_sequence_types.h" @@ -43,6 +45,7 @@ #include "BLI_math_color_blend.h" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "RE_pipeline.h" @@ -59,6 +62,8 @@ #include "effects.hh" #include "render.hh" +#include "strip_time.hh" +#include "utils.hh" using namespace blender; @@ -165,28 +170,26 @@ static void store_opaque_black_pixel(float *dst) static ImBuf *prepare_effect_imbufs(const SeqRenderData *context, ImBuf *ibuf1, ImBuf *ibuf2, - ImBuf *ibuf3, - bool uninitialized_pixels = true) + ImBuf *ibuf3) { ImBuf *out; Scene *scene = context->scene; int x = context->rectx; int y = context->recty; - int base_flags = uninitialized_pixels ? IB_uninitialized_pixels : 0; if (!ibuf1 && !ibuf2 && !ibuf3) { /* hmmm, global float option ? */ - out = IMB_allocImBuf(x, y, 32, IB_rect | base_flags); + out = IMB_allocImBuf(x, y, 32, IB_rect); } else if ((ibuf1 && ibuf1->float_buffer.data) || (ibuf2 && ibuf2->float_buffer.data) || (ibuf3 && ibuf3->float_buffer.data)) { /* if any inputs are rectfloat, output is float too */ - out = IMB_allocImBuf(x, y, 32, IB_rectfloat | base_flags); + out = IMB_allocImBuf(x, y, 32, IB_rectfloat); } else { - out = IMB_allocImBuf(x, y, 32, IB_rect | base_flags); + out = IMB_allocImBuf(x, y, 32, IB_rect); } if (out->float_buffer.data) { @@ -2710,9 +2713,7 @@ static ImBuf *do_text_effect(const SeqRenderData *context, ImBuf *ibuf2, ImBuf *ibuf3) { - /* Note: text rasterization only fills in part of output image, - * need to clear it. */ - ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3, false); + ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); TextVars *data = static_cast(seq->effectdata); int width = out->x; int height = out->y; @@ -2898,7 +2899,6 @@ static void get_default_fac_fade(const Scene *scene, { *fac = float(timeline_frame - SEQ_time_left_handle_frame_get(scene, seq)); *fac /= SEQ_time_strip_length_get(scene, seq); - *fac = blender::math::clamp(*fac, 0.0f, 1.0f); } static ImBuf *init_execution(const SeqRenderData *context, diff --git a/source/blender/sequencer/intern/image_cache.cc b/source/blender/sequencer/intern/image_cache.cc index 5a8173096f5..3571849ad1d 100644 --- a/source/blender/sequencer/intern/image_cache.cc +++ b/source/blender/sequencer/intern/image_cache.cc @@ -19,21 +19,30 @@ #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" +#include "BLI_blenlib.h" +#include "BLI_endian_defines.h" +#include "BLI_endian_switch.h" +#include "BLI_fileops.h" #include "BLI_fileops_types.h" #include "BLI_ghash.h" +#include "BLI_listbase.h" #include "BLI_mempool.h" +#include "BLI_path_util.h" #include "BLI_threads.h" #include "BKE_main.hh" +#include "BKE_scene.h" #include "SEQ_prefetch.hh" #include "SEQ_relations.hh" #include "SEQ_render.hh" +#include "SEQ_sequencer.hh" #include "SEQ_time.hh" #include "disk_cache.hh" #include "image_cache.hh" #include "prefetch.hh" +#include "strip_time.hh" /** * Sequencer Cache Design Notes diff --git a/source/blender/sequencer/intern/iterator.cc b/source/blender/sequencer/intern/iterator.cc index 2663e06e84c..41bc66b4763 100644 --- a/source/blender/sequencer/intern/iterator.cc +++ b/source/blender/sequencer/intern/iterator.cc @@ -12,15 +12,21 @@ #include "MEM_guardedalloc.h" +#include "DNA_scene_types.h" #include "DNA_sequence_types.h" +#include "BLI_ghash.h" #include "BLI_listbase.h" +#include "BLI_set.hh" + +#include "BKE_scene.h" #include "SEQ_effects.hh" #include "SEQ_iterator.hh" #include "SEQ_relations.hh" #include "SEQ_render.hh" #include "SEQ_time.hh" +#include "render.hh" using blender::VectorSet; diff --git a/source/blender/sequencer/intern/modifier.cc b/source/blender/sequencer/intern/modifier.cc index b1f479f369c..be3854c89bb 100644 --- a/source/blender/sequencer/intern/modifier.cc +++ b/source/blender/sequencer/intern/modifier.cc @@ -16,7 +16,7 @@ #include "BLI_string_utils.hh" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_mask_types.h" #include "DNA_scene_types.h" diff --git a/source/blender/sequencer/intern/multiview.cc b/source/blender/sequencer/intern/multiview.cc index aacc0e5d358..a724e04a90e 100644 --- a/source/blender/sequencer/intern/multiview.cc +++ b/source/blender/sequencer/intern/multiview.cc @@ -12,7 +12,7 @@ #include "BLI_string.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "IMB_imbuf.hh" diff --git a/source/blender/sequencer/intern/prefetch.cc b/source/blender/sequencer/intern/prefetch.cc index 5b6b256d1b2..f8ece7006a0 100644 --- a/source/blender/sequencer/intern/prefetch.cc +++ b/source/blender/sequencer/intern/prefetch.cc @@ -12,9 +12,11 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_sequence_types.h" +#include "DNA_windowmanager_types.h" #include "BLI_listbase.h" #include "BLI_threads.h" @@ -24,9 +26,12 @@ #include "BKE_anim_data.h" #include "BKE_animsys.h" -#include "BKE_global.hh" +#include "BKE_context.hh" +#include "BKE_global.h" #include "BKE_layer.hh" +#include "BKE_lib_id.hh" #include "BKE_main.hh" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" diff --git a/source/blender/sequencer/intern/proxy.cc b/source/blender/sequencer/intern/proxy.cc index fe771f3c9fd..3f86dca3310 100644 --- a/source/blender/sequencer/intern/proxy.cc +++ b/source/blender/sequencer/intern/proxy.cc @@ -10,6 +10,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_scene_types.h" #include "DNA_sequence_types.h" #include "DNA_space_types.h" @@ -17,6 +18,7 @@ #include "BLI_fileops.h" #include "BLI_listbase.h" #include "BLI_path_util.h" +#include "BLI_session_uid.h" #include "BLI_string.h" #ifdef WIN32 @@ -25,10 +27,12 @@ # include #endif -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" + +#include "DEG_depsgraph.hh" #include "WM_types.hh" @@ -36,6 +40,7 @@ #include "IMB_imbuf_types.hh" #include "IMB_metadata.hh" +#include "SEQ_iterator.hh" #include "SEQ_proxy.hh" #include "SEQ_relations.hh" #include "SEQ_render.hh" @@ -46,6 +51,7 @@ #include "proxy.hh" #include "render.hh" #include "sequencer.hh" +#include "strip_time.hh" #include "utils.hh" struct SeqIndexBuildContext { diff --git a/source/blender/sequencer/intern/proxy_job.cc b/source/blender/sequencer/intern/proxy_job.cc index 54a1aac1235..a076679d697 100644 --- a/source/blender/sequencer/intern/proxy_job.cc +++ b/source/blender/sequencer/intern/proxy_job.cc @@ -10,11 +10,19 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" +#include "BLI_ghash.h" +#include "BLI_timecode.h" + #include "DNA_scene_types.h" #include "DNA_sequence_types.h" #include "BKE_context.hh" +#include "BKE_global.h" +#include "BKE_main.hh" +#include "BKE_report.h" +#include "SEQ_iterator.hh" #include "SEQ_proxy.hh" #include "SEQ_relations.hh" #include "SEQ_sequencer.hh" @@ -22,6 +30,8 @@ #include "WM_api.hh" #include "WM_types.hh" +#include "RNA_define.hh" + static void proxy_freejob(void *pjv) { ProxyJob *pj = static_cast(pjv); diff --git a/source/blender/sequencer/intern/render.cc b/source/blender/sequencer/intern/render.cc index b8e490d9e9e..ea8d7c6e933 100644 --- a/source/blender/sequencer/intern/render.cc +++ b/source/blender/sequencer/intern/render.cc @@ -12,6 +12,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_defaults.h" #include "DNA_mask_types.h" #include "DNA_scene_types.h" @@ -29,14 +30,14 @@ #include "BKE_anim_data.h" #include "BKE_animsys.h" #include "BKE_fcurve.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_image.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_mask.h" #include "BKE_movieclip.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_sequencer_offscreen.h" #include "DEG_depsgraph.hh" @@ -47,6 +48,7 @@ #include "IMB_imbuf_types.hh" #include "IMB_metadata.hh" +#include "RNA_access.hh" #include "RNA_prototypes.h" #include "RE_engine.h" @@ -70,6 +72,7 @@ #include "prefetch.hh" #include "proxy.hh" #include "render.hh" +#include "strip_time.hh" #include "utils.hh" #include @@ -139,7 +142,7 @@ void seq_imbuf_to_sequencer_space(const Scene *scene, ImBuf *ibuf, bool make_flo /* We perform conversion to a float buffer so we don't worry about * precision loss. */ - imb_addrectfloatImBuf(ibuf, 4, false); + imb_addrectfloatImBuf(ibuf, 4); IMB_colormanagement_transform_from_byte_threaded(ibuf->float_buffer.data, ibuf->byte_buffer.data, ibuf->x, @@ -1342,8 +1345,7 @@ ImBuf *seq_render_mask(const SeqRenderData *context, const float *fp_src; float *fp_dst; - ibuf = IMB_allocImBuf( - context->rectx, context->recty, 32, IB_rectfloat | IB_uninitialized_pixels); + ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rectfloat); fp_src = maskbuf; fp_dst = ibuf->float_buffer.data; @@ -1361,7 +1363,7 @@ ImBuf *seq_render_mask(const SeqRenderData *context, const float *fp_src; uchar *ub_dst; - ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect | IB_uninitialized_pixels); + ibuf = IMB_allocImBuf(context->rectx, context->recty, 32, IB_rect); fp_src = maskbuf; ub_dst = ibuf->byte_buffer.data; diff --git a/source/blender/sequencer/intern/sequence_lookup.cc b/source/blender/sequencer/intern/sequence_lookup.cc index 4fca9d97e62..3ddc4129426 100644 --- a/source/blender/sequencer/intern/sequence_lookup.cc +++ b/source/blender/sequencer/intern/sequence_lookup.cc @@ -13,9 +13,12 @@ #include "DNA_scene_types.h" #include "DNA_sequence_types.h" +#include "SEQ_iterator.hh" + #include "BLI_ghash.h" #include "BLI_listbase.h" #include "BLI_map.hh" +#include "BLI_string.h" #include "BLI_sys_types.h" #include "BLI_threads.h" #include "BLI_vector_set.hh" diff --git a/source/blender/sequencer/intern/sequencer.cc b/source/blender/sequencer/intern/sequencer.cc index 002084d8ae3..3aedd7dbe83 100644 --- a/source/blender/sequencer/intern/sequencer.cc +++ b/source/blender/sequencer/intern/sequencer.cc @@ -24,7 +24,7 @@ #include "BKE_idprop.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_sound.h" #include "DEG_depsgraph.hh" diff --git a/source/blender/sequencer/intern/sound.cc b/source/blender/sequencer/intern/sound.cc index c76d4716a45..b551551aa76 100644 --- a/source/blender/sequencer/intern/sound.cc +++ b/source/blender/sequencer/intern/sound.cc @@ -22,7 +22,11 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" +#include "BLO_read_write.hh" + #include "BKE_colortools.hh" +#include "BKE_main.hh" +#include "BKE_scene.h" #include "BKE_sound.h" #ifdef WITH_CONVOLUTION diff --git a/source/blender/sequencer/intern/strip_add.cc b/source/blender/sequencer/intern/strip_add.cc index d2b749465cd..5f11a0e718d 100644 --- a/source/blender/sequencer/intern/strip_add.cc +++ b/source/blender/sequencer/intern/strip_add.cc @@ -22,13 +22,15 @@ #include "BLI_listbase.h" #include "BLI_path_util.h" #include "BLI_string.h" +#include "BLI_string_utf8.h" +#include "BKE_context.hh" #include "BKE_image.h" #include "BKE_lib_id.hh" #include "BKE_main.hh" #include "BKE_mask.h" #include "BKE_movieclip.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_sound.h" #include "DEG_depsgraph_query.hh" @@ -43,6 +45,7 @@ #include "SEQ_effects.hh" #include "SEQ_relations.hh" #include "SEQ_render.hh" +#include "SEQ_select.hh" #include "SEQ_sequencer.hh" #include "SEQ_time.hh" #include "SEQ_transform.hh" @@ -52,6 +55,7 @@ #include "proxy.hh" #include "sequencer.hh" #include "strip_time.hh" +#include "utils.hh" void SEQ_add_load_data_init(SeqLoadData *load_data, const char *name, diff --git a/source/blender/sequencer/intern/strip_edit.cc b/source/blender/sequencer/intern/strip_edit.cc index 4a2fc80db80..c352c9e413d 100644 --- a/source/blender/sequencer/intern/strip_edit.cc +++ b/source/blender/sequencer/intern/strip_edit.cc @@ -16,11 +16,15 @@ #include "BLI_string.h" #include "BLI_string_utf8.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" +#include "BKE_main.hh" +#include "BKE_movieclip.h" +#include "BKE_scene.h" #include "BKE_sound.h" #include "strip_time.hh" +#include "utils.hh" #include "SEQ_add.hh" #include "SEQ_animation.hh" diff --git a/source/blender/sequencer/intern/strip_relations.cc b/source/blender/sequencer/intern/strip_relations.cc index a5ca653b80c..58d0c1d5415 100644 --- a/source/blender/sequencer/intern/strip_relations.cc +++ b/source/blender/sequencer/intern/strip_relations.cc @@ -17,9 +17,11 @@ #include "BLI_session_uid.h" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "DEG_depsgraph.hh" +#include "DEG_depsgraph_query.hh" #include "IMB_imbuf.hh" @@ -28,6 +30,7 @@ #include "SEQ_relations.hh" #include "SEQ_sequencer.hh" #include "SEQ_time.hh" +#include "SEQ_transform.hh" #include "effects.hh" #include "image_cache.hh" diff --git a/source/blender/sequencer/intern/strip_retiming.cc b/source/blender/sequencer/intern/strip_retiming.cc index 3a063e300f6..3db1924dc0b 100644 --- a/source/blender/sequencer/intern/strip_retiming.cc +++ b/source/blender/sequencer/intern/strip_retiming.cc @@ -18,14 +18,30 @@ #include "BLI_span.hh" #include "BLI_vector.hh" +#include "BKE_fcurve.h" +#include "BKE_movieclip.h" +#include "BKE_scene.h" #include "BKE_sound.h" +#include "DNA_anim_types.h" +#include "DNA_sound_types.h" + +#include "IMB_imbuf.hh" + +#include "RNA_prototypes.h" + +#include "SEQ_channels.hh" +#include "SEQ_iterator.hh" +#include "SEQ_relations.hh" +#include "SEQ_render.hh" #include "SEQ_retiming.hh" #include "SEQ_sequencer.hh" #include "SEQ_time.hh" +#include "SEQ_transform.hh" #include "sequencer.hh" #include "strip_time.hh" +#include "utils.hh" using blender::MutableSpan; diff --git a/source/blender/sequencer/intern/strip_select.cc b/source/blender/sequencer/intern/strip_select.cc index 808511a00b0..d08cfa7771c 100644 --- a/source/blender/sequencer/intern/strip_select.cc +++ b/source/blender/sequencer/intern/strip_select.cc @@ -11,6 +11,8 @@ #include "DNA_scene_types.h" #include "DNA_sequence_types.h" +#include "BKE_scene.h" + #include "SEQ_select.hh" #include "SEQ_sequencer.hh" diff --git a/source/blender/sequencer/intern/strip_time.cc b/source/blender/sequencer/intern/strip_time.cc index a566e5acf17..05c929883ff 100644 --- a/source/blender/sequencer/intern/strip_time.cc +++ b/source/blender/sequencer/intern/strip_time.cc @@ -16,15 +16,21 @@ #include "BLI_listbase.h" #include "BLI_math_base.h" +#include "BKE_fcurve.h" #include "BKE_movieclip.h" +#include "BKE_scene.h" #include "BKE_sound.h" +#include "DNA_anim_types.h" #include "DNA_sound_types.h" #include "IMB_imbuf.hh" +#include "RNA_prototypes.h" + #include "SEQ_channels.hh" #include "SEQ_iterator.hh" +#include "SEQ_relations.hh" #include "SEQ_render.hh" #include "SEQ_retiming.hh" #include "SEQ_sequencer.hh" diff --git a/source/blender/sequencer/intern/strip_transform.cc b/source/blender/sequencer/intern/strip_transform.cc index 0edc52a8ae0..b9426c68246 100644 --- a/source/blender/sequencer/intern/strip_transform.cc +++ b/source/blender/sequencer/intern/strip_transform.cc @@ -17,6 +17,10 @@ #include "BLI_math_vector.h" #include "BLI_math_vector_types.hh" +#include "BKE_main.hh" +#include "BKE_scene.h" +#include "BKE_sound.h" + #include "SEQ_animation.hh" #include "SEQ_channels.hh" #include "SEQ_edit.hh" @@ -30,6 +34,8 @@ #include "sequencer.hh" #include "strip_time.hh" +#include "CLG_log.h" + bool SEQ_transform_single_image_check(Sequence *seq) { return (seq->flag & SEQ_SINGLE_FRAME_CONTENT) != 0; diff --git a/source/blender/sequencer/intern/utils.cc b/source/blender/sequencer/intern/utils.cc index 456e2a0c2f8..c72c86fe515 100644 --- a/source/blender/sequencer/intern/utils.cc +++ b/source/blender/sequencer/intern/utils.cc @@ -14,19 +14,21 @@ #include "MEM_guardedalloc.h" +#include "DNA_mask_types.h" #include "DNA_scene_types.h" #include "DNA_sequence_types.h" #include "BLI_blenlib.h" #include "BLI_vector_set.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_animsys.h" #include "BKE_image.h" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" +#include "SEQ_animation.hh" #include "SEQ_channels.hh" #include "SEQ_edit.hh" #include "SEQ_iterator.hh" diff --git a/source/blender/shader_fx/intern/FX_shader_blur.cc b/source/blender/shader_fx/intern/FX_shader_blur.cc index cee71c6b8c2..1df72d69159 100644 --- a/source/blender/shader_fx/intern/FX_shader_blur.cc +++ b/source/blender/shader_fx/intern/FX_shader_blur.cc @@ -11,7 +11,7 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_screen.hh" diff --git a/source/blender/shader_fx/intern/FX_shader_colorize.cc b/source/blender/shader_fx/intern/FX_shader_colorize.cc index 1b490bc733c..b7f205e0ad3 100644 --- a/source/blender/shader_fx/intern/FX_shader_colorize.cc +++ b/source/blender/shader_fx/intern/FX_shader_colorize.cc @@ -13,7 +13,7 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "DNA_screen_types.h" #include "DNA_shader_fx_types.h" diff --git a/source/blender/shader_fx/intern/FX_shader_flip.cc b/source/blender/shader_fx/intern/FX_shader_flip.cc index ad9872b57b9..bca7b560fc9 100644 --- a/source/blender/shader_fx/intern/FX_shader_flip.cc +++ b/source/blender/shader_fx/intern/FX_shader_flip.cc @@ -15,7 +15,7 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_screen.hh" diff --git a/source/blender/shader_fx/intern/FX_shader_glow.cc b/source/blender/shader_fx/intern/FX_shader_glow.cc index ea363c7194f..16a6ef57e3c 100644 --- a/source/blender/shader_fx/intern/FX_shader_glow.cc +++ b/source/blender/shader_fx/intern/FX_shader_glow.cc @@ -16,7 +16,7 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_modifier.hh" diff --git a/source/blender/shader_fx/intern/FX_shader_pixel.cc b/source/blender/shader_fx/intern/FX_shader_pixel.cc index b72903b72e2..b8e91d84b2a 100644 --- a/source/blender/shader_fx/intern/FX_shader_pixel.cc +++ b/source/blender/shader_fx/intern/FX_shader_pixel.cc @@ -10,7 +10,7 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_screen.hh" diff --git a/source/blender/shader_fx/intern/FX_shader_rim.cc b/source/blender/shader_fx/intern/FX_shader_rim.cc index d949309a558..4f7f4f17a58 100644 --- a/source/blender/shader_fx/intern/FX_shader_rim.cc +++ b/source/blender/shader_fx/intern/FX_shader_rim.cc @@ -13,7 +13,7 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_screen.hh" diff --git a/source/blender/shader_fx/intern/FX_shader_shadow.cc b/source/blender/shader_fx/intern/FX_shader_shadow.cc index baecb8e711c..cb68f85867b 100644 --- a/source/blender/shader_fx/intern/FX_shader_shadow.cc +++ b/source/blender/shader_fx/intern/FX_shader_shadow.cc @@ -15,7 +15,7 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_lib_query.hh" diff --git a/source/blender/shader_fx/intern/FX_shader_swirl.cc b/source/blender/shader_fx/intern/FX_shader_swirl.cc index b342d76981a..55e80ef3c31 100644 --- a/source/blender/shader_fx/intern/FX_shader_swirl.cc +++ b/source/blender/shader_fx/intern/FX_shader_swirl.cc @@ -16,7 +16,7 @@ #include "BLI_math_base.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" #include "BKE_lib_query.hh" diff --git a/source/blender/shader_fx/intern/FX_shader_wave.cc b/source/blender/shader_fx/intern/FX_shader_wave.cc index f5145d61acd..d5a3823ee4e 100644 --- a/source/blender/shader_fx/intern/FX_shader_wave.cc +++ b/source/blender/shader_fx/intern/FX_shader_wave.cc @@ -18,7 +18,7 @@ #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/shader_fx/intern/FX_ui_common.cc b/source/blender/shader_fx/intern/FX_ui_common.cc index 1517d9376f5..941c2703df2 100644 --- a/source/blender/shader_fx/intern/FX_ui_common.cc +++ b/source/blender/shader_fx/intern/FX_ui_common.cc @@ -23,7 +23,7 @@ #include "ED_object.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/simulation/intern/implicit_blender.cc b/source/blender/simulation/intern/implicit_blender.cc index a53a15676bf..613e12ab0b4 100644 --- a/source/blender/simulation/intern/implicit_blender.cc +++ b/source/blender/simulation/intern/implicit_blender.cc @@ -964,7 +964,7 @@ static int cg_filtered_pre(lfVector *dv, delta0 = deltaNew * sqrt(conjgrad_epsilon); # ifdef DEBUG_TIME - double start = BLI_time_now_seconds(); + double start = BLI_check_seconds_timer(); # endif while ((deltaNew > delta0) && (iterations < conjgrad_looplimit)) { @@ -992,7 +992,7 @@ static int cg_filtered_pre(lfVector *dv, } # ifdef DEBUG_TIME - double end = BLI_time_now_seconds(); + double end = BLI_check_seconds_timer(); printf("cg_filtered_pre time: %f\n", float(end - start)); # endif @@ -1073,7 +1073,7 @@ static int cg_filtered_pre(lfVector *dv, # endif # ifdef DEBUG_TIME - double start = BLI_time_now_seconds(); + double start = BLI_check_seconds_timer(); # endif tol = (0.01 * 0.2); @@ -1103,7 +1103,7 @@ static int cg_filtered_pre(lfVector *dv, } # ifdef DEBUG_TIME - double end = BLI_time_now_seconds(); + double end = BLI_check_seconds_timer(); printf("cg_filtered_pre time: %f\n", float(end - start)); # endif @@ -1136,7 +1136,7 @@ bool SIM_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol add_lfvectorS_lfvectorS(data->B, data->F, dt, dFdXmV, (dt * dt), numverts); # ifdef DEBUG_TIME - double start = BLI_time_now_seconds(); + double start = BLI_check_seconds_timer(); # endif /* Conjugate gradient algorithm to solve Ax=b. */ @@ -1145,7 +1145,7 @@ bool SIM_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol // cg_filtered_pre(id->dV, id->A, id->B, id->z, id->S, id->P, id->Pinv, id->bigI); # ifdef DEBUG_TIME - double end = BLI_time_now_seconds(); + double end = BLI_check_seconds_timer(); printf("cg_filtered calc time: %f\n", float(end - start)); # endif diff --git a/source/blender/simulation/intern/implicit_eigen.cc b/source/blender/simulation/intern/implicit_eigen.cc index 728bfaac861..6bf489d53cd 100644 --- a/source/blender/simulation/intern/implicit_eigen.cc +++ b/source/blender/simulation/intern/implicit_eigen.cc @@ -59,7 +59,7 @@ extern "C" { # include "BKE_cloth.hh" # include "BKE_collision.h" # include "BKE_effect.h" -# include "BKE_global.hh" +# include "BKE_global.h" # include "SIM_mass_spring.h" } diff --git a/source/blender/windowmanager/WM_api.hh b/source/blender/windowmanager/WM_api.hh index b1350bcf643..de219642cb5 100644 --- a/source/blender/windowmanager/WM_api.hh +++ b/source/blender/windowmanager/WM_api.hh @@ -17,12 +17,9 @@ #include #include -#include "DNA_windowmanager_types.h" - #include "BLI_compiler_attrs.h" -#include "BLI_function_ref.hh" #include "BLI_sys_types.h" - +#include "DNA_windowmanager_types.h" #include "WM_keymap.hh" #include "WM_types.hh" @@ -31,6 +28,7 @@ struct GHashIterator; struct GPUViewport; struct ID; struct IDProperty; +struct IDRemapper; struct ImBuf; struct ImageFormatData; struct Main; @@ -73,10 +71,6 @@ struct wmXrRuntimeData; struct wmXrSessionState; #endif -namespace blender::bke::id { -class IDRemapper; -} - namespace blender::asset_system { class AssetRepresentation; } @@ -591,7 +585,7 @@ void WM_main_add_notifier(unsigned int type, void *reference); * Clear notifiers by reference, Used so listeners don't act on freed data. */ void WM_main_remove_notifier_reference(const void *reference); -void WM_main_remap_editor_id_reference(const blender::bke::id::IDRemapper &mappings); +void WM_main_remap_editor_id_reference(const IDRemapper *mappings); /* reports */ /** @@ -628,14 +622,12 @@ wmEvent *wm_event_add(wmWindow *win, const wmEvent *event_to_add) ATTR_NONNULL(1 void wm_event_init_from_window(wmWindow *win, wmEvent *event); -/** - * At maximum, every time_step seconds it triggers `event_type` events. - */ -wmTimer *WM_event_timer_add(wmWindowManager *wm, wmWindow *win, int event_type, double time_step); +/* at maximum, every timestep seconds it triggers event_type events */ +wmTimer *WM_event_timer_add(wmWindowManager *wm, wmWindow *win, int event_type, double timestep); wmTimer *WM_event_timer_add_notifier(wmWindowManager *wm, wmWindow *win, unsigned int type, - double time_step); + double timestep); void WM_event_timer_free_data(wmTimer *timer); /** @@ -736,8 +728,8 @@ int WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *event); int WM_operator_props_dialog_popup(bContext *C, wmOperator *op, int width, - std::optional title = std::nullopt, - std::optional confirm_text = std::nullopt); + const char *title = nullptr, + const char *confirm_text = nullptr); int WM_operator_redo_popup(bContext *C, wmOperator *op); int WM_operator_ui_popup(bContext *C, wmOperator *op, int width); @@ -1114,11 +1106,9 @@ wmOperatorType *WM_operatortype_find(const char *idname, bool quiet); * \note Caller must free. */ void WM_operatortype_iter(GHashIterator *ghi); -void WM_operatortype_append(void (*opfunc)(wmOperatorType *ot)); -void WM_operatortype_append_ptr(void (*opfunc)(wmOperatorType *ot, void *userdata), - void *userdata); -void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *ot, void *userdata), - void *userdata); +void WM_operatortype_append(void (*opfunc)(wmOperatorType *)); +void WM_operatortype_append_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata); +void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata); /** * Called on initialize WM_exit(). */ @@ -1129,12 +1119,12 @@ bool WM_operatortype_remove(const char *idname); */ void WM_operatortype_last_properties_clear_all(); -void WM_operatortype_idname_visit_for_search( - const bContext *C, - PointerRNA *ptr, - PropertyRNA *prop, - const char *edit_text, - blender::FunctionRef visit_fn); +void WM_operatortype_idname_visit_for_search(const bContext *C, + PointerRNA *ptr, + PropertyRNA *prop, + const char *edit_text, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data); /** * Tag all operator-properties of \a ot defined after calling this, until @@ -1236,12 +1226,12 @@ void WM_menutype_freelink(MenuType *mt); void WM_menutype_free(); bool WM_menutype_poll(bContext *C, MenuType *mt); -void WM_menutype_idname_visit_for_search( - const bContext *C, - PointerRNA *ptr, - PropertyRNA *prop, - const char *edit_text, - blender::FunctionRef visit_fn); +void WM_menutype_idname_visit_for_search(const bContext *C, + PointerRNA *ptr, + PropertyRNA *prop, + const char *edit_text, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data); /* `wm_panel_type.cc` */ @@ -1254,12 +1244,12 @@ PanelType *WM_paneltype_find(const char *idname, bool quiet); bool WM_paneltype_add(PanelType *pt); void WM_paneltype_remove(PanelType *pt); -void WM_paneltype_idname_visit_for_search( - const bContext *C, - PointerRNA *ptr, - PropertyRNA *prop, - const char *edit_text, - blender::FunctionRef visit_fn); +void WM_paneltype_idname_visit_for_search(const bContext *C, + PointerRNA *ptr, + PropertyRNA *prop, + const char *edit_text, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data); /* `wm_gesture_ops.cc` */ @@ -1373,7 +1363,7 @@ int WM_operator_flag_only_pass_through_on_press(int retval, const wmEvent *event * Note that \a poin should be valid allocated and not on stack. */ void WM_event_start_drag( - bContext *C, int icon, eWM_DragDataType type, void *poin, unsigned int flags); + bContext *C, int icon, eWM_DragDataType type, void *poin, double value, unsigned int flags); /** * Create and fill the dragging data, but don't start dragging just yet (unlike * #WM_event_start_drag()). Must be followed up by #WM_event_start_prepared_drag(), otherwise the @@ -1382,20 +1372,20 @@ void WM_event_start_drag( * Note that \a poin should be valid allocated and not on stack. */ wmDrag *WM_drag_data_create( - bContext *C, int icon, eWM_DragDataType type, void *poin, unsigned int flags); + bContext *C, int icon, eWM_DragDataType type, void *poin, double value, unsigned int flags); /** * Invoke dragging using the given \a drag data. */ void WM_event_start_prepared_drag(bContext *C, wmDrag *drag); -void WM_event_drag_image(wmDrag *drag, const ImBuf *imb, float scale); +void WM_event_drag_image(wmDrag *, const ImBuf *, float scale); void WM_drag_free(wmDrag *drag); void WM_drag_data_free(eWM_DragDataType dragtype, void *poin); void WM_drag_free_list(ListBase *lb); wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, - bool (*poll)(bContext *C, wmDrag *drag, const wmEvent *event), - void (*copy)(bContext *C, wmDrag *drag, wmDropBox *drop), - void (*cancel)(Main *bmain, wmDrag *drag, wmDropBox *drop), + bool (*poll)(bContext *, wmDrag *, const wmEvent *event), + void (*copy)(bContext *, wmDrag *, wmDropBox *), + void (*cancel)(Main *, wmDrag *, wmDropBox *), WMDropboxTooltipFunc tooltip); /** * Ensure operator pointers & properties are valid after operators have been added/removed. @@ -1496,9 +1486,6 @@ bool WM_drag_has_path_file_type(const wmDrag *drag, int file_type); */ int /* #eFileSel_File_Types */ WM_drag_get_path_file_type(const wmDrag *drag); -const std::string &WM_drag_get_string(const wmDrag *drag); -std::string WM_drag_get_string_firstline(const wmDrag *drag); - /* Set OpenGL viewport and scissor */ void wmViewport(const rcti *winrct); void wmPartialViewport(rcti *drawrct, const rcti *winrct, const rcti *partialrct); @@ -1592,13 +1579,13 @@ void *WM_jobs_customdata_from_type(wmWindowManager *wm, const void *owner, int j bool WM_jobs_is_running(const wmJob *wm_job); bool WM_jobs_is_stopped(const wmWindowManager *wm, const void *owner); -void *WM_jobs_customdata_get(wmJob *wm_job); -void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void (*free)(void *)); -void WM_jobs_timer(wmJob *wm_job, double time_step, unsigned int note, unsigned int endnote); -void WM_jobs_delay_start(wmJob *wm_job, double delay_time); +void *WM_jobs_customdata_get(wmJob *); +void WM_jobs_customdata_set(wmJob *, void *customdata, void (*free)(void *)); +void WM_jobs_timer(wmJob *, double timestep, unsigned int note, unsigned int endnote); +void WM_jobs_delay_start(wmJob *, double delay_time); using wm_jobs_start_callback = void (*)(void *custom_data, wmJobWorkerStatus *worker_status); -void WM_jobs_callbacks(wmJob *wm_job, +void WM_jobs_callbacks(wmJob *, wm_jobs_start_callback startjob, void (*initjob)(void *), void (*update)(void *), @@ -1616,7 +1603,7 @@ void WM_jobs_callbacks_ex(wmJob *wm_job, * If job running, the same owner gave it a new job. * if different owner starts existing #wmJob::startjob, it suspends itself. */ -void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job); +void WM_jobs_start(wmWindowManager *wm, wmJob *); /** * Signal job(s) from this owner or callback to stop, timer is required to get handled. */ @@ -1638,8 +1625,8 @@ void WM_jobs_kill_type(wmWindowManager *wm, const void *owner, int job_type); bool WM_jobs_has_running(const wmWindowManager *wm); bool WM_jobs_has_running_type(const wmWindowManager *wm, int job_type); -void WM_job_main_thread_lock_acquire(wmJob *wm_job); -void WM_job_main_thread_lock_release(wmJob *wm_job); +void WM_job_main_thread_lock_acquire(wmJob *job); +void WM_job_main_thread_lock_release(wmJob *job); /* Clipboard. */ @@ -1681,9 +1668,7 @@ void WM_progress_clear(wmWindow *win); /* Draw (for screenshot) */ -void *WM_draw_cb_activate(wmWindow *win, - void (*draw)(const wmWindow *win, void *customdata), - void *customdata); +void *WM_draw_cb_activate(wmWindow *win, void (*draw)(const wmWindow *, void *), void *customdata); void WM_draw_cb_exit(wmWindow *win, void *handle); /** * High level function to redraw windows. diff --git a/source/blender/windowmanager/WM_keymap.hh b/source/blender/windowmanager/WM_keymap.hh index 4c0003d0902..fea3f9c5f20 100644 --- a/source/blender/windowmanager/WM_keymap.hh +++ b/source/blender/windowmanager/WM_keymap.hh @@ -8,9 +8,6 @@ * \ingroup wm */ -#include -#include - #include "BLI_utildefines.h" #include "DNA_windowmanager_types.h" #include "WM_types.hh" @@ -73,7 +70,10 @@ wmKeyMapItem *WM_keymap_add_item(wmKeyMap *keymap, wmKeyMapItem *WM_keymap_add_item_copy(wmKeyMap *keymap, wmKeyMapItem *kmi_src); void WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi); -std::optional WM_keymap_item_to_string(const wmKeyMapItem *kmi, bool compact); +int WM_keymap_item_to_string(const wmKeyMapItem *kmi, + bool compact, + char *result, + int result_maxncpy); wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid); wmKeyMap *WM_keymap_list_find_spaceid_or_empty(ListBase *lb, @@ -137,12 +137,16 @@ void WM_keymap_fix_linking(); /* Modal Keymap */ -std::optional WM_modalkeymap_items_to_string(const wmKeyMap *km, - int propvalue, - bool compact); -std::optional WM_modalkeymap_operator_items_to_string(wmOperatorType *ot, - int propvalue, - bool compact); +int WM_modalkeymap_items_to_string( + const wmKeyMap *km, int propvalue, bool compact, char *result, int result_maxncpy); +int WM_modalkeymap_operator_items_to_string( + wmOperatorType *ot, int propvalue, bool compact, char *result, int result_maxncpy); +char *WM_modalkeymap_operator_items_to_string_buf(wmOperatorType *ot, + int propvalue, + bool compact, + int result_maxncpy, + int *r_available_len, + char **r_result); wmKeyMap *WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, @@ -168,14 +172,16 @@ int WM_keymap_item_map_type_get(const wmKeyMapItem *kmi); /* Key Event */ const char *WM_key_event_string(short type, bool compact); -std::optional WM_keymap_item_raw_to_string(short shift, - short ctrl, - short alt, - short oskey, - short keymodifier, - short val, - short type, - bool compact); +int WM_keymap_item_raw_to_string(short shift, + short ctrl, + short alt, + short oskey, + short keymodifier, + short val, + short type, + bool compact, + char *result, + int result_maxncpy); /** * \param include_mask, exclude_mask: * Event types to include/exclude when looking up keys (#eEventType_Mask). @@ -187,11 +193,13 @@ wmKeyMapItem *WM_key_event_operator(const bContext *C, short include_mask, short exclude_mask, wmKeyMap **r_keymap); -std::optional WM_key_event_operator_string(const bContext *C, - const char *opname, - wmOperatorCallContext opcontext, - IDProperty *properties, - bool is_strict); +char *WM_key_event_operator_string(const bContext *C, + const char *opname, + wmOperatorCallContext opcontext, + IDProperty *properties, + bool is_strict, + char *result, + int result_maxncpy); wmKeyMapItem *WM_key_event_operator_from_keymap(wmKeyMap *keymap, const char *opname, diff --git a/source/blender/windowmanager/WM_types.hh b/source/blender/windowmanager/WM_types.hh index 8f6dd622b10..3bd132a83ec 100644 --- a/source/blender/windowmanager/WM_types.hh +++ b/source/blender/windowmanager/WM_types.hh @@ -112,14 +112,10 @@ struct wmWindowManager; #include "BLI_compiler_attrs.h" #include "BLI_utildefines.h" #include "BLI_vector.hh" - #include "DNA_listBase.h" #include "DNA_uuid_types.h" #include "DNA_vec_types.h" #include "DNA_xr_types.h" - -#include "BKE_wm_runtime.hh" - #include "RNA_types.hh" /* exported types for WM */ @@ -1143,14 +1139,7 @@ enum eWM_DragDataType { WM_DRAG_RNA, WM_DRAG_PATH, WM_DRAG_NAME, - /** - * Arbitrary text such as dragging from a text editor, - * this is also used when dragging a URL from a browser. - * - * An #std::string expected to be UTF8 encoded. - * Callers that require valid UTF8 sequences must validate the text. - */ - WM_DRAG_STRING, + WM_DRAG_VALUE, WM_DRAG_COLOR, WM_DRAG_DATASTACK, WM_DRAG_ASSET_CATALOG, @@ -1262,6 +1251,7 @@ struct wmDrag { int icon; eWM_DragDataType type; void *poin; + double value; /** If no icon but imbuf should be drawn around cursor. */ const ImBuf *imb; diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo.cc b/source/blender/windowmanager/gizmo/intern/wm_gizmo.cc index fc019c33370..db95b043a9a 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo.cc +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo.cc @@ -19,7 +19,7 @@ #include "RNA_define.hh" #include "RNA_prototypes.h" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_main.hh" @@ -30,10 +30,15 @@ #include "ED_screen.hh" #include "ED_view3d.hh" +#include "UI_interface.hh" + #ifdef WITH_PYTHON # include "BPY_extern.h" #endif +/* only for own init/exit calls (wm_gizmotype_init/wm_gizmotype_free) */ +#include "wm.hh" + /* own includes */ #include "wm_gizmo_intern.hh" #include "wm_gizmo_wmapi.hh" diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.cc b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.cc index 4be4cf3a8f7..6e60a128c60 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.cc +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.cc @@ -23,7 +23,7 @@ #include "BKE_context.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_workspace.h" #include "RNA_access.hh" diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.cc b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.cc index 76f8f578a22..30448debd32 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.cc +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group_type.cc @@ -11,14 +11,20 @@ #include "BLI_ghash.h" #include "BLI_utildefines.h" +#include "BKE_context.hh" + #include "MEM_guardedalloc.h" #include "RNA_access.hh" #include "RNA_define.hh" #include "RNA_prototypes.h" +#include "WM_api.hh" #include "WM_types.hh" +/* only for own init/exit calls (wm_gizmogrouptype_init/wm_gizmogrouptype_free) */ +#include "wm.hh" + /* own includes */ #include "wm_gizmo_intern.hh" #include "wm_gizmo_wmapi.hh" diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.cc b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.cc index 6f20d33f2bf..67be2f92839 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.cc +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.cc @@ -17,7 +17,7 @@ #include "BLI_rect.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_main.hh" #include "ED_screen.hh" diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.cc b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.cc index 58e7c94961e..30a6923c9eb 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.cc +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_target_props.cc @@ -14,14 +14,21 @@ #include "RNA_access.hh" +#include "WM_api.hh" #include "WM_message.hh" #include "WM_types.hh" +#include "wm.hh" + +#include "ED_keyframing.hh" #include "ED_screen.hh" +#include "ED_view3d.hh" #include "ANIM_keyframing.hh" /* own includes */ +#include "wm_gizmo_intern.hh" +#include "wm_gizmo_wmapi.hh" /* -------------------------------------------------------------------- */ /** \name Property Definition diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.cc b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.cc index 95fd3644506..e33b2130112 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.cc +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.cc @@ -12,6 +12,7 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" +#include "BKE_context.hh" #include "BKE_main.hh" #include "DNA_screen_types.h" @@ -23,10 +24,14 @@ #include "RNA_define.hh" #include "RNA_prototypes.h" +#include "WM_api.hh" #include "WM_types.hh" #include "ED_screen.hh" +/* only for own init/exit calls (wm_gizmotype_init/wm_gizmotype_free) */ +#include "wm.hh" + /* own includes */ #include "wm_gizmo_intern.hh" #include "wm_gizmo_wmapi.hh" diff --git a/source/blender/windowmanager/intern/wm.cc b/source/blender/windowmanager/intern/wm.cc index 60d5b9bc0e6..6288be426b4 100644 --- a/source/blender/windowmanager/intern/wm.cc +++ b/source/blender/windowmanager/intern/wm.cc @@ -26,16 +26,16 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" #include "BKE_lib_query.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "BKE_workspace.h" @@ -113,8 +113,6 @@ static void window_manager_blend_write(BlendWriter *writer, ID *id, const void * { wmWindowManager *wm = (wmWindowManager *)id; - wm->runtime = nullptr; - BLO_write_id_struct(writer, wmWindowManager, id_address, &wm->id); BKE_id_blend_write(writer, &wm->id); write_wm_xr_data(writer, &wm->xr); @@ -210,6 +208,7 @@ static void window_manager_blend_read_data(BlendDataReader *reader, ID *id) BLI_listbase_clear(&wm->paintcursors); BLI_listbase_clear(&wm->notifier_queue); wm->notifier_queue_set = nullptr; + BKE_reports_init(&wm->reports, RPT_STORE); BLI_listbase_clear(&wm->keyconfigs); wm->defaultconf = nullptr; @@ -228,9 +227,7 @@ static void window_manager_blend_read_data(BlendDataReader *reader, ID *id) wm->winactive = nullptr; wm->init_flag = 0; wm->op_undo_depth = 0; - - BLI_assert(wm->runtime == nullptr); - wm->runtime = MEM_new(__func__); + wm->is_interface_locked = 0; } static void window_manager_blend_read_after_liblink(BlendLibReader *reader, ID *id) @@ -247,7 +244,6 @@ static void window_manager_blend_read_after_liblink(BlendLibReader *reader, ID * IDTypeInfo IDType_ID_WM = { /*id_code*/ ID_WM, /*id_filter*/ FILTER_ID_WM, - /*dependencies_id_types*/ FILTER_ID_SCE | FILTER_ID_WS, /*main_listbase_index*/ INDEX_ID_WM, /*struct_size*/ sizeof(wmWindowManager), /*name*/ "WindowManager", @@ -348,7 +344,8 @@ void WM_operator_type_set(wmOperator *op, wmOperatorType *ot) static void wm_reports_free(wmWindowManager *wm) { - WM_event_timer_remove(wm, nullptr, wm->runtime->reports.reporttimer); + BKE_reports_free(&wm->reports); + WM_event_timer_remove(wm, nullptr, wm->reports.reporttimer); } void wm_operator_register(bContext *C, wmOperator *op) @@ -527,7 +524,7 @@ void wm_add_default(Main *bmain, bContext *C) WorkSpace *workspace; WorkSpaceLayout *layout = BKE_workspace_layout_find_global(bmain, screen, &workspace); - BKE_reports_init(&wm->runtime->reports, RPT_STORE); + BKE_reports_init(&wm->reports, RPT_STORE); CTX_wm_manager_set(C, wm); win = wm_window_new(bmain, wm, nullptr, false); @@ -539,7 +536,6 @@ void wm_add_default(Main *bmain, bContext *C) wm->winactive = win; wm->file_saved = 1; - wm->runtime = MEM_new(__func__); wm_window_make_drawable(wm, win); } @@ -600,8 +596,6 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm) if (C && CTX_wm_manager(C) == wm) { CTX_wm_manager_set(C, nullptr); } - - MEM_delete(wm->runtime); } void WM_main(bContext *C) diff --git a/source/blender/windowmanager/intern/wm_cursors.cc b/source/blender/windowmanager/intern/wm_cursors.cc index 0742b2d61f0..48529de8fef 100644 --- a/source/blender/windowmanager/intern/wm_cursors.cc +++ b/source/blender/windowmanager/intern/wm_cursors.cc @@ -15,11 +15,14 @@ #include "BLI_utildefines.h" +#include "BLI_sys_types.h" + #include "DNA_listBase.h" #include "DNA_userdef_types.h" #include "DNA_workspace_types.h" -#include "BKE_global.hh" +#include "BKE_context.hh" +#include "BKE_global.h" #include "BKE_main.hh" #include "WM_api.hh" diff --git a/source/blender/windowmanager/intern/wm_dragdrop.cc b/source/blender/windowmanager/intern/wm_dragdrop.cc index 4bf890c5f23..2c6b3296862 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.cc +++ b/source/blender/windowmanager/intern/wm_dragdrop.cc @@ -19,7 +19,7 @@ #include "MEM_guardedalloc.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLI_bitmap.h" #include "BLI_blenlib.h" @@ -28,7 +28,7 @@ #include "BIF_glutil.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_idtype.hh" #include "BKE_lib_id.hh" @@ -37,7 +37,7 @@ #include "GHOST_C-api.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "ED_asset.hh" #include "ED_fileselect.hh" @@ -107,9 +107,9 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid) wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, - bool (*poll)(bContext *C, wmDrag *drag, const wmEvent *event), - void (*copy)(bContext *C, wmDrag *drag, wmDropBox *drop), - void (*cancel)(Main *bmain, wmDrag *drag, wmDropBox *drop), + bool (*poll)(bContext *, wmDrag *, const wmEvent *), + void (*copy)(bContext *, wmDrag *, wmDropBox *), + void (*cancel)(Main *, wmDrag *, wmDropBox *), WMDropboxTooltipFunc tooltip) { wmOperatorType *ot = WM_operatortype_find(idname, true); @@ -258,7 +258,8 @@ static void wm_dropbox_invoke(bContext *C, wmDrag *drag) } } -wmDrag *WM_drag_data_create(bContext *C, int icon, eWM_DragDataType type, void *poin, uint flags) +wmDrag *WM_drag_data_create( + bContext *C, int icon, eWM_DragDataType type, void *poin, double value, uint flags) { wmDrag *drag = MEM_new(__func__); @@ -301,6 +302,7 @@ wmDrag *WM_drag_data_create(bContext *C, int icon, eWM_DragDataType type, void * drag->poin = poin; break; } + drag->value = value; return drag; } @@ -313,9 +315,10 @@ void WM_event_start_prepared_drag(bContext *C, wmDrag *drag) wm_dropbox_invoke(C, drag); } -void WM_event_start_drag(bContext *C, int icon, eWM_DragDataType type, void *poin, uint flags) +void WM_event_start_drag( + bContext *C, int icon, eWM_DragDataType type, void *poin, double value, uint flags) { - wmDrag *drag = WM_drag_data_create(C, icon, type, poin, flags); + wmDrag *drag = WM_drag_data_create(C, icon, type, poin, value, flags); WM_event_start_prepared_drag(C, drag); } @@ -379,11 +382,6 @@ void WM_drag_data_free(eWM_DragDataType dragtype, void *poin) wm_drag_free_path_data(&path_data); break; } - case WM_DRAG_STRING: { - std::string *str = static_cast(poin); - MEM_delete(str); - break; - } default: MEM_freeN(poin); break; @@ -922,24 +920,6 @@ int WM_drag_get_path_file_type(const wmDrag *drag) return path_data->file_types[0]; } -const std::string &WM_drag_get_string(const wmDrag *drag) -{ - BLI_assert(drag->type == WM_DRAG_STRING); - const std::string *str = static_cast(drag->poin); - return *str; -} - -std::string WM_drag_get_string_firstline(const wmDrag *drag) -{ - BLI_assert(drag->type == WM_DRAG_STRING); - const std::string *str = static_cast(drag->poin); - const size_t str_eol = str->find('\n'); - if (str_eol != std::string::npos) { - return str->substr(0, str_eol); - } - return *str; -} - /* ************** draw ***************** */ static void wm_drop_operator_draw(const blender::StringRef name, int x, int y) diff --git a/source/blender/windowmanager/intern/wm_draw.cc b/source/blender/windowmanager/intern/wm_draw.cc index f1f617f4c90..a64dd81ef03 100644 --- a/source/blender/windowmanager/intern/wm_draw.cc +++ b/source/blender/windowmanager/intern/wm_draw.cc @@ -21,13 +21,16 @@ #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" #include "BLI_math_matrix.h" #include "BLI_math_vector_types.hh" #include "BLI_utildefines.h" #include "BKE_context.hh" +#include "BKE_global.h" #include "BKE_image.h" -#include "BKE_scene.hh" +#include "BKE_main.hh" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "GHOST_C-api.h" @@ -105,7 +108,7 @@ static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region) /* Don't draw paint cursors with locked interface. Painting is not possible * then, and cursor drawing can use scene data that another thread may be * modifying. */ - if (wm->runtime->is_interface_locked) { + if (wm->is_interface_locked) { return; } @@ -600,13 +603,11 @@ static const char *wm_area_name(ScrArea *area) struct WindowDrawCB { WindowDrawCB *next, *prev; - void (*draw)(const wmWindow *win, void *customdata); + void (*draw)(const wmWindow *, void *); void *customdata; }; -void *WM_draw_cb_activate(wmWindow *win, - void (*draw)(const wmWindow *win, void *customdata), - void *customdata) +void *WM_draw_cb_activate(wmWindow *win, void (*draw)(const wmWindow *, void *), void *customdata) { WindowDrawCB *wdc = static_cast(MEM_callocN(sizeof(*wdc), "WindowDrawCB")); diff --git a/source/blender/windowmanager/intern/wm_event_query.cc b/source/blender/windowmanager/intern/wm_event_query.cc index bec98b5a071..b5b3cb6ceee 100644 --- a/source/blender/windowmanager/intern/wm_event_query.cc +++ b/source/blender/windowmanager/intern/wm_event_query.cc @@ -12,6 +12,7 @@ #include #include "DNA_listBase.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" @@ -21,6 +22,8 @@ #include "BLI_math_vector.h" #include "BLI_utildefines.h" +#include "BKE_context.hh" + #include "RNA_access.hh" #include "WM_api.hh" @@ -31,6 +34,8 @@ #include "RNA_enum_types.hh" +#include "DEG_depsgraph.hh" + /* -------------------------------------------------------------------- */ /** \name Event Printing * \{ */ diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 04ab29eb55c..04ece0b0e8d 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -13,7 +13,6 @@ #include #include #include -#include #include "AS_asset_library.hh" @@ -36,19 +35,19 @@ #include "BKE_context.hh" #include "BKE_customdata.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_lib_remap.hh" #include "BKE_main.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_undo_system.hh" #include "BKE_workspace.h" #include "BKE_sound.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "ED_asset.hh" #include "ED_fileselect.hh" @@ -412,7 +411,7 @@ static void wm_main_remap_msgbus_notify(ID *old_id, ID *new_id, void *user_data) } } -void WM_main_remap_editor_id_reference(const blender::bke::id::IDRemapper &mappings) +void WM_main_remap_editor_id_reference(const IDRemapper *mappings) { Main *bmain = G_MAIN; @@ -424,11 +423,11 @@ void WM_main_remap_editor_id_reference(const blender::bke::id::IDRemapper &mappi } } - mappings.iter(wm_main_remap_assetlist, nullptr); + BKE_id_remapper_iter(mappings, wm_main_remap_assetlist, nullptr); wmWindowManager *wm = static_cast(bmain->wm.first); if (wm && wm->message_bus) { - mappings.iter(wm_main_remap_msgbus_notify, wm->message_bus); + BKE_id_remapper_iter(mappings, wm_main_remap_msgbus_notify, wm->message_bus); } AS_asset_library_remap_ids(mappings); @@ -451,7 +450,7 @@ void wm_event_do_depsgraph(bContext *C, bool is_after_open_file) wmWindowManager *wm = CTX_wm_manager(C); /* The whole idea of locked interface is to prevent viewport and whatever thread from * modifying the same data. Because of this, we can not perform dependency graph update. */ - if (wm->runtime->is_interface_locked) { + if (wm->is_interface_locked) { return; } /* Combine data-masks so one window doesn't disable UVs in another #26448. */ @@ -874,7 +873,7 @@ void wm_event_handler_ui_cancel_ex(bContext *C, wmEvent event; wm_event_init_from_window(win, &event); event.type = EVT_BUT_CANCEL; - event.val = reactivate_button ? KM_NOTHING : KM_PRESS; + event.val = reactivate_button ? 0 : 1; event.flag = (eWM_EventFlag)0; handler->handle_fn(C, &event, handler->user_data); } @@ -905,7 +904,7 @@ void WM_report_banner_show(wmWindowManager *wm, wmWindow *win) } } - ReportList *wm_reports = &wm->runtime->reports; + ReportList *wm_reports = &wm->reports; /* After adding reports to the global list, reset the report timer. */ WM_event_timer_remove(wm, nullptr, wm_reports->reporttimer); @@ -920,8 +919,8 @@ void WM_report_banner_show(wmWindowManager *wm, wmWindow *win) void WM_report_banners_cancel(Main *bmain) { wmWindowManager *wm = static_cast(bmain->wm.first); - BKE_reports_clear(&wm->runtime->reports); - WM_event_timer_remove(wm, nullptr, wm->runtime->reports.reporttimer); + BKE_reports_clear(&wm->reports); + WM_event_timer_remove(wm, nullptr, wm->reports.reporttimer); } #ifdef WITH_INPUT_NDOF @@ -943,7 +942,7 @@ void WM_reports_from_reports_move(wmWindowManager *wm, ReportList *reports) } /* Add reports to the global list, otherwise they are not seen. */ - BKE_reports_move_to_reports(&wm->runtime->reports, reports); + BKE_reports_move_to_reports(&wm->reports, reports); WM_report_banner_show(wm, nullptr); } @@ -2695,7 +2694,7 @@ static eHandlerActionFlag wm_handler_fileselect_do(bContext *C, ED_fileselect_set_params_from_userdef(sfile); } else { - BKE_report(&wm->runtime->reports, RPT_ERROR, "Failed to open window!"); + BKE_report(&wm->reports, RPT_ERROR, "Failed to open window!"); return WM_HANDLER_BREAK; } @@ -2914,15 +2913,21 @@ static const char *keymap_handler_log_action_str(const eHandlerActionFlag action return "un-handled"; } -static std::optional keymap_handler_log_kmi_event_str(const wmKeyMapItem *kmi) +static const char *keymap_handler_log_kmi_event_str(const wmKeyMapItem *kmi, + char *buf, + size_t buf_maxncpy) { /* Short representation of the key that was pressed, * include this since it may differ from the event in minor details * which can help looking up the key-map definition. */ - return WM_keymap_item_to_string(kmi, false); + WM_keymap_item_to_string(kmi, false, buf, buf_maxncpy); + return buf; } -static std::string keymap_handler_log_kmi_op_str(bContext *C, const wmKeyMapItem *kmi) +static const char *keymap_handler_log_kmi_op_str(bContext *C, + const wmKeyMapItem *kmi, + char *buf, + size_t buf_maxncpy) { /* The key-map item properties can further help distinguish this item from others. */ std::optional kmi_props; @@ -2932,12 +2937,11 @@ static std::string keymap_handler_log_kmi_op_str(bContext *C, const wmKeyMapItem kmi_props = RNA_pointer_as_string_keywords(C, kmi->ptr, false, false, true, 512); } else { /* Fallback. */ - char *c_str = IDP_reprN(kmi->properties, nullptr); - kmi_props = c_str; - MEM_freeN(c_str); + kmi_props = IDP_reprN(kmi->properties, nullptr); } } - return fmt::format("{}({})", kmi->idname, kmi_props.value_or("")); + BLI_snprintf(buf, buf_maxncpy, "%s(%s)", kmi->idname, kmi_props.value_or("").c_str()); + return buf; } #define PRINT \ @@ -2974,13 +2978,15 @@ static eHandlerActionFlag wm_handlers_do_keymap_with_keymap_handler( action |= wm_handler_operator_call( C, handlers, &handler->head, event, kmi->ptr, kmi->idname); + char op_buf[512]; + char kmi_buf[128]; CLOG_INFO(WM_LOG_HANDLERS, 2, "keymap '%s', %s, %s, event: %s", keymap->idname, - keymap_handler_log_kmi_op_str(C, kmi).c_str(), + keymap_handler_log_kmi_op_str(C, kmi, op_buf, sizeof(op_buf)), keymap_handler_log_action_str(action), - keymap_handler_log_kmi_event_str(kmi).value_or("").c_str()); + keymap_handler_log_kmi_event_str(kmi, kmi_buf, sizeof(kmi_buf))); if (action & WM_HANDLER_BREAK) { /* Not always_pass here, it denotes removed handler_base. */ @@ -3321,13 +3327,13 @@ static eHandlerActionFlag wm_handlers_do_intern(bContext *C, else if (handler_base->type == WM_HANDLER_TYPE_UI) { wmEventHandler_UI *handler = (wmEventHandler_UI *)handler_base; BLI_assert(handler->handle_fn != nullptr); - if (!wm->runtime->is_interface_locked) { + if (!wm->is_interface_locked) { action |= wm_handler_ui_call(C, handler, event, always_pass); } } else if (handler_base->type == WM_HANDLER_TYPE_DROPBOX) { wmEventHandler_Dropbox *handler = (wmEventHandler_Dropbox *)handler_base; - if (!wm->runtime->is_interface_locked && event->type == EVT_DROP) { + if (!wm->is_interface_locked && event->type == EVT_DROP) { LISTBASE_FOREACH (wmDropBox *, drop, handler->dropboxes) { /* Other drop custom types allowed. */ if (event->custom == EVT_DATA_DRAGDROP) { @@ -3385,7 +3391,7 @@ static eHandlerActionFlag wm_handlers_do_intern(bContext *C, else if (handler_base->type == WM_HANDLER_TYPE_OP) { wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base; if (handler->is_fileselect) { - if (!wm->runtime->is_interface_locked) { + if (!wm->is_interface_locked) { /* Screen context changes here. */ action |= wm_handler_fileselect_call(C, handlers, handler, event); } @@ -4888,7 +4894,7 @@ void WM_event_add_mousemove(wmWindow *win) /** * \return The WM enum for key or #EVENT_NONE (which should be ignored). */ -static int wm_event_type_from_ghost_key(GHOST_TKey key) +static int convert_key(GHOST_TKey key) { if (key >= GHOST_kKeyA && key <= GHOST_kKeyZ) { return (EVT_AKEY + (int(key) - GHOST_kKeyA)); @@ -5683,7 +5689,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, case GHOST_kEventKeyDown: case GHOST_kEventKeyUp: { const GHOST_TEventKeyData *kd = static_cast(customdata); - event.type = wm_event_type_from_ghost_key(kd->key); + event.type = convert_key(kd->key); if (UNLIKELY(event.type == EVENT_NONE)) { break; } @@ -5978,7 +5984,7 @@ static bool wm_operator_check_locked_interface(bContext *C, wmOperatorType *ot) { wmWindowManager *wm = CTX_wm_manager(C); - if (wm->runtime->is_interface_locked) { + if (wm->is_interface_locked) { if ((ot->flag & OPTYPE_LOCK_BYPASS) == 0) { return false; } @@ -5996,7 +6002,7 @@ void WM_set_locked_interface(wmWindowManager *wm, bool lock) * wouldn't be useful anywhere outside of window manager, so let's not * pollute global context with such an information for now). */ - wm->runtime->is_interface_locked = lock; + wm->is_interface_locked = lock ? 1 : 0; /* This will prevent drawing regions which uses non-thread-safe data. * Currently it'll be just a 3D viewport. @@ -6373,10 +6379,15 @@ bool WM_window_modal_keymap_status_draw(bContext *C, wmWindow *win, uiLayout *la } } if (show_text) { - if (std::optional str = WM_modalkeymap_operator_items_to_string( - op->type, items[i].value, true)) - { - uiItemL(row, fmt::format("{}: {}", *str, items[i].name).c_str(), ICON_NONE); + char buf[UI_MAX_DRAW_STR]; + int available_len = sizeof(buf); + char *p = buf; + WM_modalkeymap_operator_items_to_string_buf( + op->type, items[i].value, true, UI_MAX_SHORTCUT_STR, &available_len, &p); + p -= 1; + if (p > buf) { + BLI_snprintf(p, available_len, ": %s", items[i].name); + uiItemL(row, buf, ICON_NONE); } } } diff --git a/source/blender/windowmanager/intern/wm_files.cc b/source/blender/windowmanager/intern/wm_files.cc index 7b4b1f70d84..124ead6167e 100644 --- a/source/blender/windowmanager/intern/wm_files.cc +++ b/source/blender/windowmanager/intern/wm_files.cc @@ -45,8 +45,8 @@ #include "BLI_utildefines.h" #include BLI_SYSTEM_PID_H -#include "BLO_readfile.hh" -#include "BLT_translation.hh" +#include "BLO_readfile.h" +#include "BLT_translation.h" #include "BLF_api.hh" @@ -64,12 +64,12 @@ #include "BKE_addon.h" #include "BKE_appdir.hh" #include "BKE_autoexec.hh" -#include "BKE_blender.hh" +#include "BKE_blender.h" #include "BKE_blender_version.h" #include "BKE_blendfile.hh" -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_lib_id.hh" #include "BKE_lib_override.hh" @@ -77,8 +77,8 @@ #include "BKE_main.hh" #include "BKE_main_namemap.hh" #include "BKE_packedFile.h" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_sound.h" #include "BKE_undo_system.hh" @@ -610,7 +610,7 @@ void WM_file_autoexec_init(const char *filepath) void wm_file_read_report(Main *bmain, wmWindow *win) { wmWindowManager *wm = static_cast(bmain->wm.first); - ReportList *reports = &wm->runtime->reports; + ReportList *reports = &wm->reports; bool found = false; LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { if (scene->r.engine[0] && @@ -1022,7 +1022,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) BlendFileReadReport bf_reports{}; bf_reports.reports = reports; - bf_reports.duration.whole = BLI_time_now_seconds(); + bf_reports.duration.whole = BLI_check_seconds_timer(); BlendFileData *bfd = BKE_blendfile_read(filepath, ¶ms, &bf_reports); if (bfd != nullptr) { wm_file_read_pre(use_data, use_userdef); @@ -1069,7 +1069,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) read_file_post_params.is_alloc = false; wm_file_read_post(C, filepath, &read_file_post_params); - bf_reports.duration.whole = BLI_time_now_seconds() - bf_reports.duration.whole; + bf_reports.duration.whole = BLI_check_seconds_timer() - bf_reports.duration.whole; file_read_reports_finalize(&bf_reports); success = true; diff --git a/source/blender/windowmanager/intern/wm_files_link.cc b/source/blender/windowmanager/intern/wm_files_link.cc index 99c6afab2b0..7bf1fb3a523 100644 --- a/source/blender/windowmanager/intern/wm_files_link.cc +++ b/source/blender/windowmanager/intern/wm_files_link.cc @@ -34,13 +34,13 @@ #include "BLI_memarena.h" #include "BLI_utildefines.h" -#include "BLO_readfile.hh" +#include "BLO_readfile.h" #include "BKE_armature.hh" #include "BKE_blendfile.hh" #include "BKE_blendfile_link_append.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_key.hh" #include "BKE_layer.hh" #include "BKE_lib_id.hh" @@ -50,9 +50,9 @@ #include "BKE_main.hh" #include "BKE_material.h" #include "BKE_object.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_rigidbody.h" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_idtype.hh" diff --git a/source/blender/windowmanager/intern/wm_gesture.cc b/source/blender/windowmanager/intern/wm_gesture.cc index c4d2c24efeb..e1c3005b2f2 100644 --- a/source/blender/windowmanager/intern/wm_gesture.cc +++ b/source/blender/windowmanager/intern/wm_gesture.cc @@ -20,10 +20,13 @@ #include "BLI_lasso_2d.h" #include "BLI_utildefines.h" +#include "BKE_context.hh" + #include "WM_api.hh" #include "WM_types.hh" #include "wm.hh" +#include "wm_draw.hh" #include "GPU_immediate.h" #include "GPU_immediate_util.h" diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.cc b/source/blender/windowmanager/intern/wm_gesture_ops.cc index 3e6b5dd2fb1..012e2c8441a 100644 --- a/source/blender/windowmanager/intern/wm_gesture_ops.cc +++ b/source/blender/windowmanager/intern/wm_gesture_ops.cc @@ -26,12 +26,16 @@ #include "WM_types.hh" #include "wm.hh" +#include "wm_event_system.hh" #include "wm_event_types.hh" #include "ED_screen.hh" #include "ED_select_utils.hh" +#include "UI_interface.hh" + #include "RNA_access.hh" +#include "RNA_define.hh" /* -------------------------------------------------------------------- */ /** \name Internal Gesture Utilities diff --git a/source/blender/windowmanager/intern/wm_init_exit.cc b/source/blender/windowmanager/intern/wm_init_exit.cc index d52c6e7d905..47b01ca75c0 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.cc +++ b/source/blender/windowmanager/intern/wm_init_exit.cc @@ -33,18 +33,21 @@ #include "BLO_undofile.hh" #include "BLO_writefile.hh" -#include "BKE_blender.hh" +#include "BKE_blender.h" #include "BKE_blendfile.hh" +#include "BKE_callbacks.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_icons.h" #include "BKE_image.h" #include "BKE_keyconfig.h" #include "BKE_lib_remap.hh" #include "BKE_main.hh" #include "BKE_mball_tessellate.hh" +#include "BKE_node.hh" #include "BKE_preview_image.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BKE_sound.h" #include "BKE_vfont.hh" @@ -60,7 +63,10 @@ #include "RE_engine.h" #include "RE_pipeline.h" /* RE_ free stuff */ +#include "IMB_thumbs.hh" + #ifdef WITH_PYTHON +# include "BPY_extern.h" # include "BPY_extern_python.h" # include "BPY_extern_run.h" #endif @@ -83,6 +89,7 @@ #include "wm_window.hh" #include "ED_anim_api.hh" +#include "ED_armature.hh" #include "ED_asset.hh" #include "ED_gpencil_legacy.hh" #include "ED_keyframes_edit.hh" @@ -93,9 +100,10 @@ #include "ED_space_api.hh" #include "ED_undo.hh" #include "ED_util.hh" +#include "ED_view3d.hh" #include "BLF_api.hh" -#include "BLT_lang.hh" +#include "BLT_lang.h" #include "UI_interface.hh" #include "UI_resources.hh" diff --git a/source/blender/windowmanager/intern/wm_jobs.cc b/source/blender/windowmanager/intern/wm_jobs.cc index 6237fdd51c2..9a201383c44 100644 --- a/source/blender/windowmanager/intern/wm_jobs.cc +++ b/source/blender/windowmanager/intern/wm_jobs.cc @@ -19,8 +19,9 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BKE_global.hh" -#include "BKE_report.hh" +#include "BKE_context.hh" +#include "BKE_global.h" +#include "BKE_report.h" #include "SEQ_prefetch.hh" @@ -331,7 +332,7 @@ void *WM_jobs_customdata_get(wmJob *wm_job) return wm_job->customdata; } -void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void (*free)(void *customdata)) +void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void (*free)(void *)) { /* pending job? just free */ if (wm_job->customdata) { @@ -496,7 +497,7 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job) wm_job->wt = WM_event_timer_add(wm, wm_job->win, TIMERJOBS, time_step); } - wm_job->start_time = BLI_time_now_seconds(); + wm_job->start_time = BLI_check_seconds_timer(); } else { printf("job fails, not initialized\n"); @@ -678,7 +679,7 @@ void wm_jobs_timer(wmWindowManager *wm, wmTimer *wt) if (G.debug & G_DEBUG_JOBS) { printf("Job '%s' finished in %f seconds\n", wm_job->name, - BLI_time_now_seconds() - wm_job->start_time); + BLI_check_seconds_timer() - wm_job->start_time); } wm_job->running = false; diff --git a/source/blender/windowmanager/intern/wm_keymap.cc b/source/blender/windowmanager/intern/wm_keymap.cc index 200dd8953a0..747e8461fcd 100644 --- a/source/blender/windowmanager/intern/wm_keymap.cc +++ b/source/blender/windowmanager/intern/wm_keymap.cc @@ -9,7 +9,6 @@ */ #include -#include #include "DNA_object_types.h" #include "DNA_screen_types.h" @@ -30,13 +29,13 @@ #include "UI_interface.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_main.hh" #include "BKE_screen.hh" #include "BKE_workspace.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "RNA_access.hh" #include "RNA_enum_types.hh" @@ -1193,17 +1192,20 @@ const char *WM_key_event_string(const short type, const bool compact) return CTX_IFACE_(BLT_I18NCONTEXT_UI_EVENTS, it->name); } -std::optional WM_keymap_item_raw_to_string(const short shift, - const short ctrl, - const short alt, - const short oskey, - const short keymodifier, - const short val, - const short type, - const bool compact) +int WM_keymap_item_raw_to_string(const short shift, + const short ctrl, + const short alt, + const short oskey, + const short keymodifier, + const short val, + const short type, + const bool compact, + char *result, + const int result_maxncpy) { /* TODO: also support (some) value, like e.g. double-click? */ - blender::Vector result_array; + const char *result_array[12]; + int i = 0; const char *space = " "; @@ -1212,80 +1214,136 @@ std::optional WM_keymap_item_raw_to_string(const short shift, } else { if (shift) { - result_array.append(WM_key_event_string(EVT_LEFTSHIFTKEY, true)); - result_array.append(space); + result_array[i++] = WM_key_event_string(EVT_LEFTSHIFTKEY, true); + result_array[i++] = space; } if (ctrl) { - result_array.append(WM_key_event_string(EVT_LEFTCTRLKEY, true)); - result_array.append(space); + result_array[i++] = WM_key_event_string(EVT_LEFTCTRLKEY, true); + result_array[i++] = space; } if (alt) { - result_array.append(WM_key_event_string(EVT_LEFTALTKEY, true)); - result_array.append(space); + result_array[i++] = WM_key_event_string(EVT_LEFTALTKEY, true); + result_array[i++] = space; } if (oskey) { - result_array.append(WM_key_event_string(EVT_OSKEY, true)); - result_array.append(space); + result_array[i++] = WM_key_event_string(EVT_OSKEY, true); + result_array[i++] = space; } } if (keymodifier) { - result_array.append(WM_key_event_string(keymodifier, compact)); - result_array.append(space); + result_array[i++] = WM_key_event_string(keymodifier, compact); + result_array[i++] = space; } if (type) { if (val == KM_DBL_CLICK) { - result_array.append(IFACE_("dbl-")); + result_array[i++] = IFACE_("dbl-"); } else if (val == KM_CLICK_DRAG) { - result_array.append(IFACE_("drag-")); + result_array[i++] = IFACE_("drag-"); } - result_array.append(WM_key_event_string(type, compact)); + result_array[i++] = WM_key_event_string(type, compact); } - if (result_array.last() == space) { - result_array.remove_last(); + /* We assume size of buf is enough to always store any possible shortcut, + * but let's add a debug check about it! */ + BLI_assert(i < ARRAY_SIZE(result_array)); + + if (i > 0 && result_array[i - 1] == space) { + i--; } - return fmt::to_string(fmt::join(result_array, "")); + return BLI_string_join_array(result, result_maxncpy, result_array, i); } -std::optional WM_keymap_item_to_string(const wmKeyMapItem *kmi, const bool compact) +int WM_keymap_item_to_string(const wmKeyMapItem *kmi, + const bool compact, + char *result, + const int result_maxncpy) { - return WM_keymap_item_raw_to_string( - kmi->shift, kmi->ctrl, kmi->alt, kmi->oskey, kmi->keymodifier, kmi->val, kmi->type, compact); + return WM_keymap_item_raw_to_string(kmi->shift, + kmi->ctrl, + kmi->alt, + kmi->oskey, + kmi->keymodifier, + kmi->val, + kmi->type, + compact, + result, + result_maxncpy); } -std::optional WM_modalkeymap_items_to_string(const wmKeyMap *km, - const int propvalue, - const bool compact) +int WM_modalkeymap_items_to_string(const wmKeyMap *km, + const int propvalue, + const bool compact, + char *result, + const int result_maxncpy) { + BLI_string_debug_size(result, result_maxncpy); + BLI_assert(result_maxncpy > 0); + const wmKeyMapItem *kmi; if (km == nullptr || (kmi = WM_modalkeymap_find_propvalue(km, propvalue)) == nullptr) { - return std::nullopt; + *result = '\0'; + return 0; } - std::string result; + int totlen = 0; do { - result += WM_keymap_item_to_string(kmi, compact).value_or(""); + totlen += WM_keymap_item_to_string(kmi, compact, &result[totlen], result_maxncpy - totlen); - if ((kmi = wm_modalkeymap_find_propvalue_iter(km, kmi, propvalue)) == nullptr) { + if ((kmi = wm_modalkeymap_find_propvalue_iter(km, kmi, propvalue)) == nullptr || + totlen >= (result_maxncpy - 2)) + { break; } - result += '/'; + + result[totlen++] = '/'; + result[totlen] = '\0'; } while (true); - return result; + return totlen; } -std::optional WM_modalkeymap_operator_items_to_string(wmOperatorType *ot, - const int propvalue, - const bool compact) +int WM_modalkeymap_operator_items_to_string(wmOperatorType *ot, + const int propvalue, + const bool compact, + char *result, + const int result_maxncpy) { + BLI_string_debug_size_after_nil(result, result_maxncpy); wmWindowManager *wm = static_cast(G_MAIN->wm.first); wmKeyMap *keymap = WM_keymap_active(wm, ot->modalkeymap); - return WM_modalkeymap_items_to_string(keymap, propvalue, compact); + return WM_modalkeymap_items_to_string(keymap, propvalue, compact, result, result_maxncpy); +} + +char *WM_modalkeymap_operator_items_to_string_buf(wmOperatorType *ot, + const int propvalue, + const bool compact, + const int result_maxncpy, + int *r_available_len, + char **r_result) +{ + BLI_string_debug_size(*r_result, result_maxncpy); + char *ret = *r_result; + + if (*r_available_len > 1) { + int used_len = WM_modalkeymap_operator_items_to_string( + ot, propvalue, compact, ret, min_ii(*r_available_len, result_maxncpy)) + + 1; + + *r_available_len -= used_len; + *r_result += used_len; + if (*r_available_len == 0) { + (*r_result)--; /* So that *result keeps pointing on a valid char, we'll stay on it anyway. */ + } + } + else { + *ret = '\0'; + } + + return ret; } /** \} */ @@ -1341,13 +1399,14 @@ static wmKeyMapItem *wm_keymap_item_find_in_keymap(wmKeyMap *keymap, WM_operator_properties_default(&opptr, true); if (IDP_EqualsProperties_ex(properties, properties_default, is_strict)) { - std::string kmi_str = WM_keymap_item_to_string(kmi, false).value_or(""); + char kmi_str[128]; + WM_keymap_item_to_string(kmi, false, kmi_str, sizeof(kmi_str)); /* NOTE: given properties could come from other things than menu entry. */ printf( "%s: Some set values in menu entry match default op values, " "this might not be desired!\n", opname); - printf("\tkm: '%s', kmi: '%s'\n", keymap->idname, kmi_str.c_str()); + printf("\tkm: '%s', kmi: '%s'\n", keymap->idname, kmi_str); #ifndef NDEBUG # ifdef WITH_PYTHON printf("OPERATOR\n"); @@ -1592,12 +1651,13 @@ static wmKeyMapItem *wm_keymap_item_find(const bContext *C, wmKeyMapItem *kmi = wm_keymap_item_find_props( C, opname, opcontext, properties_default, is_strict, params, &km); if (kmi) { - std::string kmi_str = WM_keymap_item_to_string(kmi, false).value_or(""); + char kmi_str[128]; + WM_keymap_item_to_string(kmi, false, kmi_str, sizeof(kmi_str)); printf( "%s: Some set values in keymap entry match default op values, " "this might not be desired!\n", opname); - printf("\tkm: '%s', kmi: '%s'\n", km->idname, kmi_str.c_str()); + printf("\tkm: '%s', kmi: '%s'\n", km->idname, kmi_str); #ifndef NDEBUG # ifdef WITH_PYTHON printf("OPERATOR\n"); @@ -1625,11 +1685,13 @@ static bool kmi_filter_is_visible(const wmKeyMap * /*km*/, (IS_EVENT_ACTIONZONE(kmi->type) == false)); } -std::optional WM_key_event_operator_string(const bContext *C, - const char *opname, - wmOperatorCallContext opcontext, - IDProperty *properties, - const bool is_strict) +char *WM_key_event_operator_string(const bContext *C, + const char *opname, + wmOperatorCallContext opcontext, + IDProperty *properties, + const bool is_strict, + char *result, + const int result_maxncpy) { wmKeyMapItemFind_Params params{}; params.filter_fn = kmi_filter_is_visible; @@ -1637,17 +1699,16 @@ std::optional WM_key_event_operator_string(const bContext *C, wmKeyMapItem *kmi = wm_keymap_item_find( C, opname, opcontext, properties, is_strict, ¶ms, nullptr); if (kmi) { - return WM_keymap_item_to_string(kmi, false); - } - - /* Check UI state (non key-map actions for UI regions). */ - if (std::optional result = UI_key_event_operator_string( - C, opname, properties, is_strict)) - { + WM_keymap_item_to_string(kmi, false, result, result_maxncpy); return result; } - return std::nullopt; + /* Check UI state (non key-map actions for UI regions). */ + if (UI_key_event_operator_string(C, opname, properties, is_strict, result, result_maxncpy)) { + return result; + } + + return nullptr; } static bool kmi_filter_is_visible_type_mask(const wmKeyMap *km, diff --git a/source/blender/windowmanager/intern/wm_menu_type.cc b/source/blender/windowmanager/intern/wm_menu_type.cc index 8b3bdfb91f0..970757cb6c6 100644 --- a/source/blender/windowmanager/intern/wm_menu_type.cc +++ b/source/blender/windowmanager/intern/wm_menu_type.cc @@ -13,6 +13,7 @@ #include "BLI_sys_types.h" #include "DNA_windowmanager_types.h" +#include "DNA_workspace_types.h" #include "MEM_guardedalloc.h" @@ -101,20 +102,20 @@ bool WM_menutype_poll(bContext *C, MenuType *mt) return true; } -void WM_menutype_idname_visit_for_search( - const bContext * /*C*/, - PointerRNA * /*ptr*/, - PropertyRNA * /*prop*/, - const char * /*edit_text*/, - blender::FunctionRef visit_fn) +void WM_menutype_idname_visit_for_search(const bContext * /*C*/, + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, + const char * /*edit_text*/, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data) { GHashIterator gh_iter; GHASH_ITER (gh_iter, menutypes_hash) { MenuType *mt = static_cast(BLI_ghashIterator_getValue(&gh_iter)); - StringPropertySearchVisitParams visit_params{}; + StringPropertySearchVisitParams visit_params = {nullptr}; visit_params.text = mt->idname; visit_params.info = mt->label; - visit_fn(visit_params); + visit_fn(visit_user_data, &visit_params); } } diff --git a/source/blender/windowmanager/intern/wm_operator_type.cc b/source/blender/windowmanager/intern/wm_operator_type.cc index 752750b7cc1..7eb647d0a92 100644 --- a/source/blender/windowmanager/intern/wm_operator_type.cc +++ b/source/blender/windowmanager/intern/wm_operator_type.cc @@ -18,7 +18,7 @@ #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLI_blenlib.h" #include "BLI_ghash.h" @@ -249,12 +249,12 @@ void WM_operatortype_last_properties_clear_all() } } -void WM_operatortype_idname_visit_for_search( - const bContext * /*C*/, - PointerRNA * /*ptr*/, - PropertyRNA * /*prop*/, - const char * /*edit_text*/, - blender::FunctionRef visit_fn) +void WM_operatortype_idname_visit_for_search(const bContext * /*C*/, + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, + const char * /*edit_text*/, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data) { GHashIterator gh_iter; GHASH_ITER (gh_iter, global_ops_hash) { @@ -263,10 +263,10 @@ void WM_operatortype_idname_visit_for_search( char idname_py[OP_MAX_TYPENAME]; WM_operator_py_idname(idname_py, ot->idname); - StringPropertySearchVisitParams visit_params{}; + StringPropertySearchVisitParams visit_params = {nullptr}; visit_params.text = idname_py; visit_params.info = ot->name; - visit_fn(visit_params); + visit_fn(visit_user_data, &visit_params); } } @@ -509,8 +509,7 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, return ot; } -void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *ot, void *userdata), - void *userdata) +void WM_operatortype_append_macro_ptr(void (*opfunc)(wmOperatorType *, void *), void *userdata) { wmOperatorType *ot; diff --git a/source/blender/windowmanager/intern/wm_operator_utils.cc b/source/blender/windowmanager/intern/wm_operator_utils.cc index d73d1135a98..7ea11470c43 100644 --- a/source/blender/windowmanager/intern/wm_operator_utils.cc +++ b/source/blender/windowmanager/intern/wm_operator_utils.cc @@ -15,7 +15,7 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_layer.hh" #include "RNA_access.hh" diff --git a/source/blender/windowmanager/intern/wm_operators.cc b/source/blender/windowmanager/intern/wm_operators.cc index 976376222a6..e6d35b00ad5 100644 --- a/source/blender/windowmanager/intern/wm_operators.cc +++ b/source/blender/windowmanager/intern/wm_operators.cc @@ -38,7 +38,7 @@ #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BLI_blenlib.h" #include "BLI_dial_2d.h" @@ -52,7 +52,7 @@ #include "BKE_brush.hh" #include "BKE_colortools.hh" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_image.h" #include "BKE_image_format.h" @@ -61,8 +61,8 @@ #include "BKE_main.hh" #include "BKE_material.h" #include "BKE_preview_image.hh" -#include "BKE_report.hh" -#include "BKE_scene.hh" +#include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_screen.hh" /* BKE_ST_MAXNAME */ #include "BKE_unit.hh" @@ -1543,11 +1543,6 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *region, void *user_ /* Title. */ if (!data->title.empty()) { uiItemL_ex(layout, data->title.c_str(), ICON_NONE, true, false); - - /* Line under the title if there are properties but no message body. */ - if (data->include_properties && message_lines.size() == 0) { - uiItemS_ex(layout, 0.2f, LayoutSeparatorType::Line); - }; } /* Message lines. */ @@ -1556,7 +1551,6 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *region, void *user_ } if (data->include_properties) { - uiItemS_ex(layout, 0.5f); uiTemplateOperatorPropertyButs(C, layout, op, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN, 0); } @@ -1792,19 +1786,16 @@ int WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent * /*event return wm_operator_props_popup_ex(C, op, false, true); } -int WM_operator_props_dialog_popup(bContext *C, - wmOperator *op, - int width, - std::optional title, - std::optional confirm_text) +int WM_operator_props_dialog_popup( + bContext *C, wmOperator *op, int width, const char *title, const char *confirm_text) { wmOpPopUp *data = MEM_new(__func__); data->op = op; data->width = int(float(width) * UI_SCALE_FAC * UI_style_get()->widgetlabel.points / UI_DEFAULT_TEXT_POINTS); data->free_op = true; /* if this runs and gets registered we may want not to free it */ - data->title = title ? std::move(*title) : WM_operatortype_name(op->type, op->ptr); - data->confirm_text = confirm_text ? std::move(*confirm_text) : IFACE_("OK"); + data->title = (title == nullptr) ? WM_operatortype_name(op->type, op->ptr) : title; + data->confirm_text = (confirm_text == nullptr) ? IFACE_("OK") : confirm_text; data->icon = ALERT_ICON_NONE; data->size = WM_POPUP_SIZE_SMALL; data->position = WM_POPUP_POSITION_MOUSE; @@ -1812,7 +1803,7 @@ int WM_operator_props_dialog_popup(bContext *C, data->mouse_move_quit = false; data->include_properties = true; - /* The operator is not executed until popup OK button is clicked. */ + /* op is not executed until popup OK but is clicked */ UI_popup_block_ex( C, wm_block_dialog_create, wm_operator_ui_popup_ok, wm_operator_ui_popup_cancel, data, op); @@ -3612,7 +3603,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) WM_cursor_wait(true); - double time_start = BLI_time_now_seconds(); + double time_start = BLI_check_seconds_timer(); wm_window_make_drawable(wm, win); @@ -3622,14 +3613,14 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) iter_steps += 1; if (time_limit != 0.0) { - if ((BLI_time_now_seconds() - time_start) > time_limit) { + if ((BLI_check_seconds_timer() - time_start) > time_limit) { break; } a = 0; } } - double time_delta = (BLI_time_now_seconds() - time_start) * 1000; + double time_delta = (BLI_check_seconds_timer() - time_start) * 1000; RNA_enum_description(redraw_timer_type_items, type, &infostr); @@ -3940,11 +3931,12 @@ static void WM_OT_previews_clear(wmOperatorType *ot) static int doc_view_manual_ui_context_exec(bContext *C, wmOperator * /*op*/) { PointerRNA ptr_props; + char buf[512]; short retval = OPERATOR_CANCELLED; - if (std::optional manual_id = UI_but_online_manual_id_from_active(C)) { + if (UI_but_online_manual_id_from_active(C, buf, sizeof(buf))) { WM_operator_properties_create(&ptr_props, "WM_OT_doc_view_manual"); - RNA_string_set(&ptr_props, "doc_id", manual_id.value().c_str()); + RNA_string_set(&ptr_props, "doc_id", buf); retval = WM_operator_name_call_ptr(C, WM_operatortype_find("WM_OT_doc_view_manual", false), diff --git a/source/blender/windowmanager/intern/wm_panel_type.cc b/source/blender/windowmanager/intern/wm_panel_type.cc index 826a2b53680..ac7c0e7115e 100644 --- a/source/blender/windowmanager/intern/wm_panel_type.cc +++ b/source/blender/windowmanager/intern/wm_panel_type.cc @@ -68,20 +68,20 @@ void WM_paneltype_clear() BLI_ghash_free(g_paneltypes_hash, nullptr, nullptr); } -void WM_paneltype_idname_visit_for_search( - const bContext * /*C*/, - PointerRNA * /*ptr*/, - PropertyRNA * /*prop*/, - const char * /*edit_text*/, - blender::FunctionRef visit_fn) +void WM_paneltype_idname_visit_for_search(const bContext * /*C*/, + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, + const char * /*edit_text*/, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data) { GHashIterator gh_iter; GHASH_ITER (gh_iter, g_paneltypes_hash) { PanelType *pt = static_cast(BLI_ghashIterator_getValue(&gh_iter)); - StringPropertySearchVisitParams visit_params{}; + StringPropertySearchVisitParams visit_params = {nullptr}; visit_params.text = pt->idname; visit_params.info = pt->label; - visit_fn(visit_params); + visit_fn(visit_user_data, &visit_params); } } diff --git a/source/blender/windowmanager/intern/wm_platform_support.cc b/source/blender/windowmanager/intern/wm_platform_support.cc index d7ca2dc1ab9..fd49aa21481 100644 --- a/source/blender/windowmanager/intern/wm_platform_support.cc +++ b/source/blender/windowmanager/intern/wm_platform_support.cc @@ -15,14 +15,17 @@ #include "BLI_linklist.h" #include "BLI_path_util.h" #include "BLI_string.h" +#include "BLI_sys_types.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_appdir.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "GPU_platform.h" +#include "GHOST_C-api.h" + #define WM_PLATFORM_SUPPORT_TEXT_SIZE 1024 /** diff --git a/source/blender/windowmanager/intern/wm_playanim.cc b/source/blender/windowmanager/intern/wm_playanim.cc index 355595278f4..0c1e302e432 100644 --- a/source/blender/windowmanager/intern/wm_playanim.cc +++ b/source/blender/windowmanager/intern/wm_playanim.cc @@ -486,7 +486,7 @@ static int pupdate_time() { static double time_last; - double time = BLI_time_now_seconds(); + double time = BLI_check_seconds_timer(); g_playanim.total_time += (time - time_last); time_last = time; @@ -2022,7 +2022,7 @@ static bool wm_main_playanim_intern(int argc, const char **argv, PlayArgs *args_ #endif while (pupdate_time()) { - BLI_time_sleep_ms(1); + BLI_sleep_ms(1); } g_playanim.total_time -= g_playanim.swap_time; playanim_toscreen(&ps, ps.picture, ibuf); @@ -2053,7 +2053,7 @@ static bool wm_main_playanim_intern(int argc, const char **argv, PlayArgs *args_ } playanim_change_frame(&ps); if (!has_event) { - BLI_time_sleep_ms(1); + BLI_sleep_ms(1); } if (ps.wait) { continue; diff --git a/source/blender/windowmanager/intern/wm_splash_screen.cc b/source/blender/windowmanager/intern/wm_splash_screen.cc index f66ba255742..92475e26e9a 100644 --- a/source/blender/windowmanager/intern/wm_splash_screen.cc +++ b/source/blender/windowmanager/intern/wm_splash_screen.cc @@ -17,6 +17,8 @@ #include #include +#include "CLG_log.h" + #include "DNA_ID.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" @@ -29,8 +31,11 @@ #include "BKE_appdir.hh" #include "BKE_blender_version.h" #include "BKE_context.hh" +#include "BKE_screen.hh" -#include "BLT_translation.hh" +#include "BLT_translation.h" + +#include "BLF_api.hh" #include "IMB_imbuf.hh" #include "IMB_imbuf_types.hh" diff --git a/source/blender/windowmanager/intern/wm_stereo.cc b/source/blender/windowmanager/intern/wm_stereo.cc index 1a8f8aaa0c5..d1b295dea19 100644 --- a/source/blender/windowmanager/intern/wm_stereo.cc +++ b/source/blender/windowmanager/intern/wm_stereo.cc @@ -19,8 +19,8 @@ #include "BLI_utildefines.h" #include "BKE_context.hh" -#include "BKE_global.hh" -#include "BKE_report.hh" +#include "BKE_global.h" +#include "BKE_report.h" #include "GHOST_C-api.h" @@ -34,6 +34,7 @@ #include "WM_api.hh" #include "WM_types.hh" #include "wm.hh" +#include "wm_draw.hh" #include "wm_window.hh" #include "UI_interface.hh" diff --git a/source/blender/windowmanager/intern/wm_surface.cc b/source/blender/windowmanager/intern/wm_surface.cc index ac56a682b8f..881efa52896 100644 --- a/source/blender/windowmanager/intern/wm_surface.cc +++ b/source/blender/windowmanager/intern/wm_surface.cc @@ -6,20 +6,25 @@ * \ingroup wm */ +#include "BKE_context.hh" + +#include "BLF_api.hh" + #include "BLI_listbase.h" -#ifndef NDEBUG -# include "BLI_threads.h" -#endif +#include "BLI_threads.h" #include "GHOST_C-api.h" +#include "GPU_batch_presets.h" #include "GPU_context.h" #include "GPU_framebuffer.h" +#include "GPU_immediate.h" #include "MEM_guardedalloc.h" #include "WM_api.hh" #include "WM_types.hh" +#include "wm.hh" #include "wm_surface.hh" diff --git a/source/blender/windowmanager/intern/wm_tooltip.cc b/source/blender/windowmanager/intern/wm_tooltip.cc index e19a58c64d4..8f0605a8543 100644 --- a/source/blender/windowmanager/intern/wm_tooltip.cc +++ b/source/blender/windowmanager/intern/wm_tooltip.cc @@ -16,6 +16,8 @@ #include "BKE_context.hh" +#include "ED_screen.hh" + #include "UI_interface.hh" #include "WM_api.hh" @@ -86,7 +88,7 @@ void WM_tooltip_clear(bContext *C, wmWindow *win) if (screen->tool_tip->region) { UI_tooltip_free(C, screen, screen->tool_tip->region); screen->tool_tip->region = nullptr; - g_tooltip_time_closed = BLI_time_now_seconds(); + g_tooltip_time_closed = BLI_check_seconds_timer(); } MEM_freeN(screen->tool_tip); screen->tool_tip = nullptr; diff --git a/source/blender/windowmanager/intern/wm_window.cc b/source/blender/windowmanager/intern/wm_window.cc index 0c4feedc7c1..c467e8ad634 100644 --- a/source/blender/windowmanager/intern/wm_window.cc +++ b/source/blender/windowmanager/intern/wm_window.cc @@ -31,15 +31,15 @@ #include "BLI_time.h" #include "BLI_utildefines.h" -#include "BLT_translation.hh" +#include "BLT_translation.h" #include "BKE_blender_version.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_icons.h" #include "BKE_layer.hh" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" #include "BKE_screen.hh" #include "BKE_workspace.h" @@ -1663,15 +1663,10 @@ static bool ghost_event_proc(GHOST_EventHandle ghost_event, GHOST_TUserDataPtr C int icon = ED_file_extension_icon((char *)stra->strings[0]); wmDragPath *path_data = WM_drag_create_path_data( blender::Span((char **)stra->strings, stra->count)); - WM_event_start_drag(C, icon, WM_DRAG_PATH, path_data, WM_DRAG_NOP); + WM_event_start_drag(C, icon, WM_DRAG_PATH, path_data, 0.0, WM_DRAG_NOP); /* Void pointer should point to string, it makes a copy. */ } } - else if (ddd->dataType == GHOST_kDragnDropTypeString) { - /* Drop an arbitrary string. */ - std::string *str = MEM_new(__func__, static_cast(ddd->data)); - WM_event_start_drag(C, ICON_NONE, WM_DRAG_STRING, str, WM_DRAG_FREE_DATA); - } break; } @@ -1731,7 +1726,7 @@ static bool wm_window_timers_process(const bContext *C, int *sleep_us_p) { Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); - const double time = BLI_time_now_seconds(); + const double time = BLI_check_seconds_timer(); bool has_event = false; const int sleep_us = *sleep_us_p; @@ -1838,11 +1833,11 @@ void wm_window_events_process(const bContext *C) * events are typically generated from a timer that runs in the main loop. */ if ((has_event == false) && (sleep_us != 0) && !(G.f & G_FLAG_EVENT_SIMULATE)) { if (sleep_us == sleep_us_default) { - /* NOTE(@ideasman42): prefer #BLI_time_sleep_ms over `sleep_for(..)` in the common case + /* NOTE(@ideasman42): prefer #BLI_sleep_ms over `sleep_for(..)` in the common case * because this function uses lower resolution (millisecond) resolution sleep timers * which are tried & true for the idle loop. We could move to C++ `sleep_for(..)` * if this works well on all platforms but this needs further testing. */ - BLI_time_sleep_ms(sleep_us_default / 1000); + BLI_sleep_ms(sleep_us_default / 1000); } else { /* The time was shortened to resume for the upcoming timer, use a high resolution sleep. @@ -2028,7 +2023,7 @@ void wm_test_opengl_deprecation_warning(bContext *C) wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = static_cast((wm->winactive) ? wm->winactive : wm->windows.first); - BKE_report(&wm->runtime->reports, + BKE_report(&wm->reports, RPT_ERROR, "One of the add-ons or scripts is using OpenGL and will not work correct on Metal. " "Please contact the developer of the add-on to migrate to use 'gpu' module"); @@ -2097,18 +2092,13 @@ void WM_event_timer_sleep(wmWindowManager *wm, wmWindow * /*win*/, wmTimer *time timer->sleep = do_sleep; } -wmTimer *WM_event_timer_add(wmWindowManager *wm, - wmWindow *win, - const int event_type, - const double time_step) +wmTimer *WM_event_timer_add(wmWindowManager *wm, wmWindow *win, int event_type, double time_step) { - BLI_assert(ISTIMER(event_type)); - wmTimer *wt = static_cast(MEM_callocN(sizeof(wmTimer), "window timer")); BLI_assert(time_step >= 0.0f); wt->event_type = event_type; - wt->time_last = BLI_time_now_seconds(); + wt->time_last = BLI_check_seconds_timer(); wt->time_next = wt->time_last + time_step; wt->time_start = wt->time_last; wt->time_step = time_step; @@ -2121,14 +2111,14 @@ wmTimer *WM_event_timer_add(wmWindowManager *wm, wmTimer *WM_event_timer_add_notifier(wmWindowManager *wm, wmWindow *win, - const uint type, - const double time_step) + uint type, + double time_step) { wmTimer *wt = static_cast(MEM_callocN(sizeof(wmTimer), "window timer")); BLI_assert(time_step >= 0.0f); wt->event_type = TIMERNOTIFIER; - wt->time_last = BLI_time_now_seconds(); + wt->time_last = BLI_check_seconds_timer(); wt->time_next = wt->time_last + time_step; wt->time_start = wt->time_last; wt->time_step = time_step; @@ -2182,8 +2172,8 @@ void WM_event_timer_remove(wmWindowManager *wm, wmWindow * /*win*/, wmTimer *tim timer->flags |= WM_TIMER_TAGGED_FOR_REMOVAL; /* Clear existing references to the timer. */ - if (wm->runtime->reports.reporttimer == timer) { - wm->runtime->reports.reporttimer = nullptr; + if (wm->reports.reporttimer == timer) { + wm->reports.reporttimer = nullptr; } /* There might be events in queue with this timer as customdata. */ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { diff --git a/source/blender/windowmanager/xr/intern/wm_xr.cc b/source/blender/windowmanager/xr/intern/wm_xr.cc index 7925f5177a8..62fd0c8cb30 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr.cc +++ b/source/blender/windowmanager/xr/intern/wm_xr.cc @@ -10,10 +10,12 @@ * representation of the OpenXR runtime connection within the application. */ -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_main.hh" -#include "BKE_report.hh" +#include "BKE_report.h" + +#include "DEG_depsgraph.hh" #include "DNA_scene_types.h" #include "DNA_windowmanager_types.h" @@ -22,14 +24,13 @@ #include "GHOST_C-api.h" -#ifdef WIN32 -# include "GPU_platform.h" -#endif +#include "GPU_platform.h" #include "MEM_guardedalloc.h" #include "WM_api.hh" +#include "wm_surface.hh" #include "wm_xr_intern.hh" struct wmXrErrorHandlerData { @@ -44,7 +45,7 @@ static void wm_xr_error_handler(const GHOST_XrError *error) wmWindowManager *wm = handler_data->wm; wmWindow *root_win = wm->xr.runtime ? wm->xr.runtime->session_root_win : nullptr; - BKE_reports_clear(&wm->runtime->reports); + BKE_reports_clear(&wm->reports); WM_report(RPT_ERROR, error->user_message); /* Rely on the fallback when `root_win` is nullptr. */ WM_report_banner_show(wm, root_win); diff --git a/source/blender/windowmanager/xr/intern/wm_xr_actionmap.cc b/source/blender/windowmanager/xr/intern/wm_xr_actionmap.cc index 7179f5b2cac..218dcc00487 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_actionmap.cc +++ b/source/blender/windowmanager/xr/intern/wm_xr_actionmap.cc @@ -13,11 +13,14 @@ #include #include +#include "BKE_context.hh" #include "BKE_idprop.h" #include "BLI_listbase.h" #include "BLI_string.h" +#include "GHOST_Types.h" + #include "MEM_guardedalloc.h" #include "WM_api.hh" diff --git a/source/blender/windowmanager/xr/intern/wm_xr_draw.cc b/source/blender/windowmanager/xr/intern/wm_xr_draw.cc index 15653108b46..16376818806 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_draw.cc +++ b/source/blender/windowmanager/xr/intern/wm_xr_draw.cc @@ -12,6 +12,8 @@ #include +#include "BKE_context.hh" + #include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" @@ -28,6 +30,7 @@ #include "WM_api.hh" +#include "wm_surface.hh" #include "wm_xr_intern.hh" void wm_xr_pose_to_mat(const GHOST_XrPose *pose, float r_mat[4][4]) diff --git a/source/blender/windowmanager/xr/intern/wm_xr_operators.cc b/source/blender/windowmanager/xr/intern/wm_xr_operators.cc index fd8d29a67eb..a10251a2f6b 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_operators.cc +++ b/source/blender/windowmanager/xr/intern/wm_xr_operators.cc @@ -18,7 +18,7 @@ #include "BLI_time.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_main.hh" #include "BKE_screen.hh" @@ -798,7 +798,7 @@ static void wm_xr_fly_init(wmOperator *op, const wmXrData *xr) op->customdata = MEM_callocN(sizeof(XrFlyData), __func__)); WM_xr_session_state_viewer_pose_rotation_get(xr, data->viewer_rot); - data->time_prev = BLI_time_now_seconds(); + data->time_prev = BLI_check_seconds_timer(); } static void wm_xr_fly_uninit(wmOperator *op) @@ -952,7 +952,7 @@ static int wm_xr_navigation_fly_modal(bContext *C, wmOperator *op, const wmEvent GHOST_XrPose nav_pose; float nav_mat[4][4], delta[4][4], out[4][4]; - const double time_now = BLI_time_now_seconds(); + const double time_now = BLI_check_seconds_timer(); mode = (eXrFlyMode)RNA_enum_get(op->ptr, "mode"); turn = ELEM(mode, XR_FLY_TURNLEFT, XR_FLY_TURNRIGHT); diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.cc b/source/blender/windowmanager/xr/intern/wm_xr_session.cc index f9089128e3f..fac8484085b 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_session.cc +++ b/source/blender/windowmanager/xr/intern/wm_xr_session.cc @@ -6,12 +6,12 @@ * \ingroup wm */ -#include "BKE_callbacks.hh" +#include "BKE_callbacks.h" #include "BKE_context.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_idprop.h" #include "BKE_main.hh" -#include "BKE_scene.hh" +#include "BKE_scene.h" #include "BKE_screen.hh" #include "BLI_listbase.h" @@ -180,7 +180,7 @@ static void wm_xr_session_base_pose_calc(const Scene *scene, float tmp_quat[4]; float tmp_eul[3]; - mat4_to_loc_quat(r_base_pose->position, tmp_quat, base_pose_object->object_to_world().ptr()); + mat4_to_loc_quat(r_base_pose->position, tmp_quat, base_pose_object->object_to_world); /* Only use rotation around Z-axis to align view with floor. */ quat_to_eul(tmp_eul, tmp_quat); @@ -1114,7 +1114,7 @@ static void wm_xr_session_events_dispatch(wmXrData *xr, return; } - const int64_t time_now = int64_t(BLI_time_now_seconds() * 1000); + const int64_t time_now = int64_t(BLI_check_seconds_timer() * 1000); ListBase *active_modal_actions = &action_set->active_modal_actions; ListBase *active_haptic_actions = &action_set->active_haptic_actions; diff --git a/source/creator/creator.cc b/source/creator/creator.cc index 0ebb77ba640..9390581a6f2 100644 --- a/source/creator/creator.cc +++ b/source/creator/creator.cc @@ -33,18 +33,18 @@ /* Mostly initialization functions. */ #include "BKE_appdir.hh" -#include "BKE_blender.hh" +#include "BKE_blender.h" #include "BKE_brush.hh" -#include "BKE_cachefile.hh" -#include "BKE_callbacks.hh" +#include "BKE_cachefile.h" +#include "BKE_callbacks.h" #include "BKE_context.hh" #include "BKE_cpp_types.hh" -#include "BKE_global.hh" +#include "BKE_global.h" #include "BKE_gpencil_modifier_legacy.h" #include "BKE_idtype.hh" #include "BKE_material.h" #include "BKE_modifier.hh" -#include "BKE_node.hh" +#include "BKE_node.h" #include "BKE_particle.h" #include "BKE_shader_fx.h" #include "BKE_sound.h" @@ -65,6 +65,7 @@ #include "ED_datafiles.h" #include "WM_api.hh" +#include "WM_toolsystem.hh" #include "RNA_define.hh" diff --git a/source/creator/creator_args.cc b/source/creator/creator_args.cc index 1b41ebe5cdb..eec0bc7073c 100644 --- a/source/creator/creator_args.cc +++ b/source/creator/creator_args.cc @@ -24,31 +24,33 @@ # include "BLI_dynstr.h" # include "BLI_fileops.h" # include "BLI_listbase.h" +# include "BLI_mempool.h" # include "BLI_path_util.h" # include "BLI_string.h" # include "BLI_string_utf8.h" # include "BLI_system.h" # include "BLI_threads.h" # include "BLI_utildefines.h" -# ifndef NDEBUG -# include "BLI_mempool.h" -# endif # include "BKE_appdir.hh" # include "BKE_blender_version.h" # include "BKE_blendfile.hh" # include "BKE_context.hh" -# include "BKE_global.hh" +# include "BKE_global.h" # include "BKE_image_format.h" # include "BKE_lib_id.hh" # include "BKE_main.hh" -# include "BKE_report.hh" -# include "BKE_scene.hh" +# include "BKE_report.h" +# include "BKE_scene.h" # include "BKE_sound.h" # include "GPU_context.h" +# ifdef WITH_FFMPEG +# include "IMB_imbuf.hh" +# endif + # ifdef WITH_PYTHON # include "BPY_extern_python.h" # include "BPY_extern_run.h" @@ -57,6 +59,8 @@ # include "RE_engine.h" # include "RE_pipeline.h" +# include "ED_datafiles.h" + # include "WM_api.hh" # ifdef WITH_LIBMV @@ -68,6 +72,8 @@ # endif # include "DEG_depsgraph.hh" +# include "DEG_depsgraph_build.hh" +# include "DEG_depsgraph_debug.hh" # include "WM_types.hh" @@ -890,33 +896,12 @@ static int arg_handle_debug_exit_on_error(int /*argc*/, const char ** /*argv*/, } static const char arg_handle_background_mode_set_doc[] = - "\n" - "\tRun in background (often used for UI-less rendering).\n" - "\n" - "\tThe audio device is disabled in background-mode by default\n" - "\tand can be re-enabled by passing in '-setaudo Default' afterwards."; + "\n\t" + "Run in background (often used for UI-less rendering)."; static int arg_handle_background_mode_set(int /*argc*/, const char ** /*argv*/, void * /*data*/) { print_version_short(); G.background = true; - - /* Background Mode Defaults: - * - * In general background mode should strive to match the behavior of running - * Blender inside a graphical session, any exception to this should have a well - * justified reason and be noted in the doc-string. */ - - /* NOTE(@ideasman42): While there is no requirement for sound to be disabled in background-mode, - * the use case for playing audio in background mode is enough of a special-case - * that users who wish to do this can explicitly enable audio in background mode. - * While the down sides for connecting to an audio device aren't terrible they include: - * - Listing Blender as an active application which may output audio. - * - Unnecessary overhead running an operation in background mode or ... - * - Having to remember to include `-noaudio` with batch operations. - * - A quiet but audible click when Blender starts & configures its audio device. - */ - BKE_sound_force_device("None"); - return 0; } @@ -1227,7 +1212,7 @@ static int arg_handle_debug_gpu_set(int /*argc*/, const char ** /*argv*/, void * static const char arg_handle_debug_gpu_compile_shaders_set_doc[] = "\n" - "\tCompile all statically defined shaders to test platform compatibility."; + "\tCompile all staticly defined shaders to test platform compatibility."; static int arg_handle_debug_gpu_compile_shaders_set(int /*argc*/, const char ** /*argv*/, void * /*data*/) @@ -1571,8 +1556,9 @@ static int arg_handle_audio_disable(int /*argc*/, const char ** /*argv*/, void * static const char arg_handle_audio_set_doc[] = "\n\t" - "Force sound system to a specific device.\n" - "\t'None' 'Default' 'SDL' 'OpenAL' 'CoreAudio' 'JACK' 'PulseAudio' 'WASAPI'."; + "Force sound system to a specific device." + "\n\t" + "'None' 'SDL' 'OpenAL' 'CoreAudio' 'JACK' 'PulseAudio' 'WASAPI'."; static int arg_handle_audio_set(int argc, const char **argv, void * /*data*/) { if (argc < 1) { @@ -1580,13 +1566,7 @@ static int arg_handle_audio_set(int argc, const char **argv, void * /*data*/) exit(1); } - const char *device = argv[1]; - if (STREQ(device, "Default")) { - /* Unset any forced device. */ - device = nullptr; - } - - BKE_sound_force_device(device); + BKE_sound_force_device(argv[1]); return 1; } diff --git a/source/creator/creator_signals.cc b/source/creator/creator_signals.cc index ac28c0deb5e..6dfaea1e5a1 100644 --- a/source/creator/creator_signals.cc +++ b/source/creator/creator_signals.cc @@ -29,6 +29,8 @@ # include # include +# include "BLI_sys_types.h" + # ifdef WIN32 # include "BLI_winstuff.h" # endif @@ -41,10 +43,9 @@ # include "BKE_appdir.hh" /* BKE_tempdir_base */ # include "BKE_blender_version.h" -# include "BKE_global.hh" +# include "BKE_global.h" # include "BKE_main.hh" -# include "BKE_report.hh" -# include "BKE_wm_runtime.hh" +# include "BKE_report.h" # include @@ -158,7 +159,7 @@ static void sig_handle_crash(int signum) } else { if (wm) { - BKE_report_write_file_fp(fp, &wm->runtime->reports, header); + BKE_report_write_file_fp(fp, &wm->reports, header); } sig_handle_crash_backtrace(fp); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ca76889ffd2..f8dd0c73c0f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -53,7 +53,7 @@ endif() # Standard Blender arguments for running tests. # Specify exit code so that if a Python script error happens, the test fails. -set(TEST_BLENDER_EXE_PARAMS --background --factory-startup --debug-memory --debug-exit-on-error --python-exit-code 1) +set(TEST_BLENDER_EXE_PARAMS --background -noaudio --factory-startup --debug-memory --debug-exit-on-error --python-exit-code 1) # Python CTests if(WITH_BLENDER AND WITH_PYTHON AND NOT WITH_PYTHON_MODULE) diff --git a/tests/performance/api/config.py b/tests/performance/api/config.py index ce113074a4c..132c3db03db 100644 --- a/tests/performance/api/config.py +++ b/tests/performance/api/config.py @@ -121,8 +121,7 @@ class TestConfig: config = TestConfig._read_config_module(self.base_dir) self.tests = TestCollection(env, getattr(config, 'tests', ['*']), - getattr(config, 'categories', ['*']), - getattr(config, 'background', False)) + getattr(config, 'categories', ['*'])) self.revisions = getattr(config, 'revisions', {}) self.builds = getattr(config, 'builds', {}) self.queue = TestQueue(self.base_dir / 'results.json') @@ -244,9 +243,6 @@ class TestConfig: test_category = test.category() for device in self.devices: - if not (test.use_device() or device.type == "CPU"): - continue - entry = self.queue.find(revision_name, test_name, test_category, device.id) if entry: # Test if revision hash or executable changed. diff --git a/tests/performance/api/test.py b/tests/performance/api/test.py index 8c08d3158a7..dfffe4b6c7a 100644 --- a/tests/performance/api/test.py +++ b/tests/performance/api/test.py @@ -26,12 +26,6 @@ class Test: """ return False - def use_background(self) -> bool: - """ - Test runs in background mode and requires no display. - """ - return True - @abc.abstractmethod def run(self, env, device_id: str) -> Dict: """ @@ -40,7 +34,7 @@ class Test: class TestCollection: - def __init__(self, env, names_filter: List = ['*'], categories_filter: List = ['*'], background: bool = False): + def __init__(self, env, names_filter: List = ['*'], categories_filter: List = ['*']): import importlib import pkgutil import tests @@ -54,9 +48,6 @@ class TestCollection: tests = module.generate(env) for test in tests: - if background and not test.use_background(): - continue - test_category = test.category() found = False for category_filter in categories_filter: diff --git a/tests/performance/benchmark.py b/tests/performance/benchmark.py index e2fac612afc..08ce9fa0db2 100755 --- a/tests/performance/benchmark.py +++ b/tests/performance/benchmark.py @@ -61,10 +61,7 @@ def print_row(config: api.TestConfig, entries: List, end='\n') -> None: row += f"{revision: <15} " if config.queue.has_multiple_categories: - category_name = entries[0].category - if entries[0].device_type != "CPU": - category_name += " " + entries[0].device_type - row += f"{category_name: <15} " + row += f"{entries[0].category: <15} " row += f"{entries[0].test: <40} " for entry in entries: @@ -102,13 +99,10 @@ def run_entry(env: api.TestEnvironment, row: List, entry: api.TestEntry, update_only: bool): - updated = False - failed = False - # Check if entry needs to be run. if update_only and entry.status not in ('queued', 'outdated'): print_row(config, row, end='\r') - return updated, failed + return False # Run test entry. revision = entry.revision @@ -121,9 +115,7 @@ def run_entry(env: api.TestEnvironment, test = config.tests.find(testname, testcategory) if not test: - return updated, failed - - updated = True + return False # Log all output to dedicated log file. logname = testcategory + '_' + testname + '_' + revision @@ -136,13 +128,12 @@ def run_entry(env: api.TestEnvironment, entry.error_msg = '' # Build revision, or just set path to existing executable. + entry.status = 'building' + print_row(config, row, end='\r') executable_ok = True if len(entry.executable): env.set_blender_executable(pathlib.Path(entry.executable), environment) else: - entry.status = 'building' - print_row(config, row, end='\r') - if config.benchmark_type == "comparison": install_dir = config.builds_dir / revision else: @@ -152,7 +143,6 @@ def run_entry(env: api.TestEnvironment, if not executable_ok: entry.status = 'failed' entry.error_msg = 'Failed to build' - failed = True else: env.set_blender_executable(install_dir, environment) @@ -169,7 +159,6 @@ def run_entry(env: api.TestEnvironment, except KeyboardInterrupt as e: raise e except Exception as e: - failed = True entry.status = 'failed' entry.error_msg = str(e) @@ -182,7 +171,7 @@ def run_entry(env: api.TestEnvironment, env.unset_log_file() env.set_default_blender_executable() - return updated, failed + return True def cmd_init(env: api.TestEnvironment, argv: List): @@ -269,8 +258,6 @@ def cmd_run(env: api.TestEnvironment, argv: List, update_only: bool): parser.add_argument('test', nargs='?', default='*') args = parser.parse_args(argv) - exit_code = 0 - configs = env.get_configs(args.config) for config in configs: updated = False @@ -280,14 +267,11 @@ def cmd_run(env: api.TestEnvironment, argv: List, update_only: bool): if match_entry(row[0], args): for entry in row: try: - test_updated, test_failed = run_entry(env, config, row, entry, update_only) - if test_updated: + if run_entry(env, config, row, entry, update_only): updated = True # Write queue every time in case running gets interrupted, # so it can be resumed. config.queue.write() - if test_failed: - exit_code = 1 except KeyboardInterrupt as e: cancel = True break @@ -306,8 +290,6 @@ def cmd_run(env: api.TestEnvironment, argv: List, update_only: bool): print("\nfile://" + str(html_filepath)) - sys.exit(exit_code) - def cmd_graph(argv: List): # Create graph from a given JSON results file. diff --git a/tests/performance/tests/eevee.py b/tests/performance/tests/eevee.py index e1e969d45b8..bc233decb07 100644 --- a/tests/performance/tests/eevee.py +++ b/tests/performance/tests/eevee.py @@ -114,9 +114,6 @@ else: def category(self): return "eevee" - def use_background(self): - return False - def run(self, env, device_id): args = {} _, log = env.run_in_blender(_run, args, [self.filepath], foreground=True) diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt index 42682ccc1b7..9c2f4ace034 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -1009,9 +1009,8 @@ if(NOT OPENIMAGEIO_TOOL) message(STATUS "Disabling sequencer render tests because OIIO oiiotool does not exist") else() set(render_tests - effects - filter transform + filter ) foreach(render_test ${render_tests}) diff --git a/tests/python/bl_alembic_io_test.py b/tests/python/bl_alembic_io_test.py index dc9d5f7e092..dc8e596fb84 100644 --- a/tests/python/bl_alembic_io_test.py +++ b/tests/python/bl_alembic_io_test.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later """ -./blender.bin --background --factory-startup --python tests/python/bl_alembic_io_test.py -- --testdir /path/to/lib/tests/alembic +./blender.bin --background -noaudio --factory-startup --python tests/python/bl_alembic_io_test.py -- --testdir /path/to/lib/tests/alembic """ import math diff --git a/tests/python/bl_animation_armature.py b/tests/python/bl_animation_armature.py index ce71aef4ed4..53bcbe4a9db 100644 --- a/tests/python/bl_animation_armature.py +++ b/tests/python/bl_animation_armature.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later """ -blender -b --factory-startup --python tests/python/bl_animation_armature.py +blender -b -noaudio --factory-startup --python tests/python/bl_animation_armature.py """ import unittest diff --git a/tests/python/bl_animation_drivers.py b/tests/python/bl_animation_drivers.py index f47c3f20620..caca840f194 100644 --- a/tests/python/bl_animation_drivers.py +++ b/tests/python/bl_animation_drivers.py @@ -9,7 +9,7 @@ import sys from rna_prop_ui import rna_idprop_quote_path """ -blender -b --factory-startup --python tests/python/bl_animation_drivers.py -- --testdir /path/to/lib/tests/animation +blender -b -noaudio --factory-startup --python tests/python/bl_animation_drivers.py -- --testdir /path/to/lib/tests/animation """ diff --git a/tests/python/bl_animation_fcurves.py b/tests/python/bl_animation_fcurves.py index d4370bccc34..0febdd48c06 100644 --- a/tests/python/bl_animation_fcurves.py +++ b/tests/python/bl_animation_fcurves.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later """ -blender -b --factory-startup --python tests/python/bl_animation_fcurves.py -- --testdir /path/to/lib/tests/animation +blender -b -noaudio --factory-startup --python tests/python/bl_animation_fcurves.py -- --testdir /path/to/lib/tests/animation """ import pathlib diff --git a/tests/python/bl_animation_keyframing.py b/tests/python/bl_animation_keyframing.py index c09f8a07c37..d696f6fa0e0 100644 --- a/tests/python/bl_animation_keyframing.py +++ b/tests/python/bl_animation_keyframing.py @@ -9,7 +9,7 @@ import sys from math import radians """ -blender -b --factory-startup --python tests/python/bl_animation_keyframing.py -- --testdir /path/to/lib/tests/animation +blender -b -noaudio --factory-startup --python tests/python/bl_animation_keyframing.py -- --testdir /path/to/lib/tests/animation """ diff --git a/tests/python/bl_blendfile_io.py b/tests/python/bl_blendfile_io.py index 0f1a738b702..32de9a4da14 100644 --- a/tests/python/bl_blendfile_io.py +++ b/tests/python/bl_blendfile_io.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -# ./blender.bin --background --python tests/python/bl_blendfile_io.py +# ./blender.bin --background -noaudio --python tests/python/bl_blendfile_io.py import bpy import os import sys diff --git a/tests/python/bl_blendfile_liblink.py b/tests/python/bl_blendfile_liblink.py index 9b8efe4fccf..6f058155c33 100644 --- a/tests/python/bl_blendfile_liblink.py +++ b/tests/python/bl_blendfile_liblink.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -# ./blender.bin --background --python tests/python/bl_blendfile_liblink.py +# ./blender.bin --background -noaudio --python tests/python/bl_blendfile_liblink.py import bpy import os import sys diff --git a/tests/python/bl_blendfile_library_overrides.py b/tests/python/bl_blendfile_library_overrides.py index d3f987d39e6..26ccacd6259 100644 --- a/tests/python/bl_blendfile_library_overrides.py +++ b/tests/python/bl_blendfile_library_overrides.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -# ./blender.bin --background --python tests/python/bl_blendfile_library_overrides.py -- --output-dir=/tmp/ +# ./blender.bin --background -noaudio --python tests/python/bl_blendfile_library_overrides.py -- --output-dir=/tmp/ import pathlib import bpy import sys diff --git a/tests/python/bl_blendfile_versioning.py b/tests/python/bl_blendfile_versioning.py index 85eb2343ddc..d704f8c7cb8 100644 --- a/tests/python/bl_blendfile_versioning.py +++ b/tests/python/bl_blendfile_versioning.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -# ./blender.bin --background --python tests/python/bl_blendfile_versioning.py .. +# ./blender.bin --background -noaudio --python tests/python/bl_blendfile_versioning.py .. import bpy import os import sys diff --git a/tests/python/bl_constraints.py b/tests/python/bl_constraints.py index 59d227e4fc7..92f2548c4cb 100644 --- a/tests/python/bl_constraints.py +++ b/tests/python/bl_constraints.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later """ -./blender.bin --background --factory-startup --python tests/python/bl_constraints.py -- --testdir /path/to/lib/tests/constraints +./blender.bin --background -noaudio --factory-startup --python tests/python/bl_constraints.py -- --testdir /path/to/lib/tests/constraints """ import pathlib diff --git a/tests/python/bl_id_management.py b/tests/python/bl_id_management.py index 4f57dcb3796..f7f436c7338 100644 --- a/tests/python/bl_id_management.py +++ b/tests/python/bl_id_management.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -# ./blender.bin --background --python tests/python/bl_id_management.py -- --verbose +# ./blender.bin --background -noaudio --python tests/python/bl_id_management.py -- --verbose import bpy import unittest import random diff --git a/tests/python/bl_io_curve_svg_test.py b/tests/python/bl_io_curve_svg_test.py index 461829db049..f0f89cfb263 100644 --- a/tests/python/bl_io_curve_svg_test.py +++ b/tests/python/bl_io_curve_svg_test.py @@ -15,6 +15,7 @@ def get_arguments(filepath, output_filepath): args = [ "--background", + "-noaudio", "--factory-startup", "--enable-autoexec", "--debug-memory", diff --git a/tests/python/bl_keymap_validate.py b/tests/python/bl_keymap_validate.py index 3b31a730a1b..9d85a8a7db4 100644 --- a/tests/python/bl_keymap_validate.py +++ b/tests/python/bl_keymap_validate.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: GPL-2.0-or-later -# ./blender.bin --background --factory-startup --python tests/python/bl_keymap_validate.py +# ./blender.bin --background -noaudio --factory-startup --python tests/python/bl_keymap_validate.py # """ diff --git a/tests/python/bl_load_addons.py b/tests/python/bl_load_addons.py index 1980e9354a6..8517c799511 100644 --- a/tests/python/bl_load_addons.py +++ b/tests/python/bl_load_addons.py @@ -5,7 +5,7 @@ # simple script to enable all addons, and disable """ -./blender.bin --background --factory-startup --python tests/python/bl_load_addons.py +./blender.bin --background -noaudio --factory-startup --python tests/python/bl_load_addons.py """ import bpy diff --git a/tests/python/bl_load_py_modules.py b/tests/python/bl_load_py_modules.py index 6162c4264b5..4521e35fcaf 100644 --- a/tests/python/bl_load_py_modules.py +++ b/tests/python/bl_load_py_modules.py @@ -5,7 +5,7 @@ # simple script to enable all addons, and disable """ -./blender.bin --background --factory-startup --python tests/python/bl_load_py_modules.py +./blender.bin --background -noaudio --factory-startup --python tests/python/bl_load_py_modules.py """ import bpy diff --git a/tests/python/bl_pyapi_bpy_driver_secure_eval.py b/tests/python/bl_pyapi_bpy_driver_secure_eval.py index 79d460e7b2a..b6c84eb2f35 100644 --- a/tests/python/bl_pyapi_bpy_driver_secure_eval.py +++ b/tests/python/bl_pyapi_bpy_driver_secure_eval.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: GPL-2.0-or-later -# ./blender.bin --background --python tests/python/bl_pyapi_bpy_driver_secure_eval.py -- --verbose +# ./blender.bin --background -noaudio --python tests/python/bl_pyapi_bpy_driver_secure_eval.py -- --verbose import bpy import unittest import builtins diff --git a/tests/python/bl_pyapi_bpy_path.py b/tests/python/bl_pyapi_bpy_path.py index 3611641bd1e..ac969fb5d10 100644 --- a/tests/python/bl_pyapi_bpy_path.py +++ b/tests/python/bl_pyapi_bpy_path.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -# ./blender.bin --background --python tests/python/bl_pyapi_bpy_path.py -- --verbose +# ./blender.bin --background -noaudio --python tests/python/bl_pyapi_bpy_path.py -- --verbose import unittest diff --git a/tests/python/bl_pyapi_bpy_utils_units.py b/tests/python/bl_pyapi_bpy_utils_units.py index 71e00a23982..ab86b22fab9 100644 --- a/tests/python/bl_pyapi_bpy_utils_units.py +++ b/tests/python/bl_pyapi_bpy_utils_units.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -# ./blender.bin --background --python tests/python/bl_pyapi_bpy_utils_units.py -- --verbose +# ./blender.bin --background -noaudio --python tests/python/bl_pyapi_bpy_utils_units.py -- --verbose import unittest from bpy.utils import units diff --git a/tests/python/bl_pyapi_idprop.py b/tests/python/bl_pyapi_idprop.py index 9f6b2216770..41881884cc2 100644 --- a/tests/python/bl_pyapi_idprop.py +++ b/tests/python/bl_pyapi_idprop.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -# ./blender.bin --background --python tests/python/bl_pyapi_idprop.py -- --verbose +# ./blender.bin --background -noaudio --python tests/python/bl_pyapi_idprop.py -- --verbose import bpy import idprop import unittest diff --git a/tests/python/bl_pyapi_idprop_datablock.py b/tests/python/bl_pyapi_idprop_datablock.py index 8f3072988d9..2f333c76df3 100644 --- a/tests/python/bl_pyapi_idprop_datablock.py +++ b/tests/python/bl_pyapi_idprop_datablock.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: GPL-2.0-or-later -# ./blender.bin --background --python tests/python/bl_pyapi_idprop_datablock.py -- --verbose +# ./blender.bin --background -noaudio --python tests/python/bl_pyapi_idprop_datablock.py -- --verbose import contextlib import inspect diff --git a/tests/python/bl_pyapi_mathutils.py b/tests/python/bl_pyapi_mathutils.py index d6bbe1ff0a4..be75e57ef44 100644 --- a/tests/python/bl_pyapi_mathutils.py +++ b/tests/python/bl_pyapi_mathutils.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -# ./blender.bin --background --python tests/python/bl_pyapi_mathutils.py -- --verbose +# ./blender.bin --background -noaudio --python tests/python/bl_pyapi_mathutils.py -- --verbose import unittest from mathutils import Matrix, Vector, Quaternion, Euler from mathutils import kdtree, geometry diff --git a/tests/python/bl_pyapi_prop_array.py b/tests/python/bl_pyapi_prop_array.py index 30262ae16bc..d91fd8bbaac 100644 --- a/tests/python/bl_pyapi_prop_array.py +++ b/tests/python/bl_pyapi_prop_array.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -# ./blender.bin --background --python tests/python/bl_pyapi_prop_array.py -- --verbose +# ./blender.bin --background -noaudio --python tests/python/bl_pyapi_prop_array.py -- --verbose import bpy from bpy.props import ( BoolVectorProperty, diff --git a/tests/python/bl_pyapi_text.py b/tests/python/bl_pyapi_text.py index c2d05be48e3..f67b267ecb6 100644 --- a/tests/python/bl_pyapi_text.py +++ b/tests/python/bl_pyapi_text.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -# ./blender.bin --background --python tests/python/bl_pyapi_text.py -- --verbose +# ./blender.bin --background -noaudio --python tests/python/bl_pyapi_text.py -- --verbose import bpy import unittest diff --git a/tests/python/bl_rigging_symmetrize.py b/tests/python/bl_rigging_symmetrize.py index 4070136a505..ea0202caa1b 100644 --- a/tests/python/bl_rigging_symmetrize.py +++ b/tests/python/bl_rigging_symmetrize.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later """ -blender -b --factory-startup --python tests/python/bl_rigging_symmetrize.py -- --testdir /path/to/lib/tests/animation +blender -b -noaudio --factory-startup --python tests/python/bl_rigging_symmetrize.py -- --testdir /path/to/lib/tests/animation """ import pathlib diff --git a/tests/python/bl_rna_defaults.py b/tests/python/bl_rna_defaults.py index b027b3d0871..94663c7be08 100644 --- a/tests/python/bl_rna_defaults.py +++ b/tests/python/bl_rna_defaults.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -# ./blender.bin --background --factory-startup --python tests/python/bl_rna_defaults.py +# ./blender.bin --background -noaudio --factory-startup --python tests/python/bl_rna_defaults.py import bpy diff --git a/tests/python/bl_rna_manual_reference.py b/tests/python/bl_rna_manual_reference.py index 9641e30da8a..c384a63f1b4 100644 --- a/tests/python/bl_rna_manual_reference.py +++ b/tests/python/bl_rna_manual_reference.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Use for validating our manual interlinking. -# ./blender.bin --background --python tests/python/bl_rna_manual_reference.py +# ./blender.bin --background -noaudio --python tests/python/bl_rna_manual_reference.py # # 1) test_data() -- ensure the data we have is correct format # 2) test_lookup_coverage() -- ensure that we have lookups for _every_ RNA path and all patterns are used. diff --git a/tests/python/bl_rst_completeness.py b/tests/python/bl_rst_completeness.py index cb4406bae51..c6153011429 100644 --- a/tests/python/bl_rst_completeness.py +++ b/tests/python/bl_rst_completeness.py @@ -4,7 +4,7 @@ # run this script in the game engine. # or on the command line with... -# ./blender.bin --background --python tests/python/bl_rst_completeness.py +# ./blender.bin --background -noaudio --python tests/python/bl_rst_completeness.py ''' filepath = "/src/blender/tests/python/bl_rst_completeness.py" exec(compile(open(filepath).read(), filepath, 'exec')) diff --git a/tests/python/collada/CMakeLists.txt b/tests/python/collada/CMakeLists.txt index d20be3d7b54..17c85f730d2 100644 --- a/tests/python/collada/CMakeLists.txt +++ b/tests/python/collada/CMakeLists.txt @@ -23,12 +23,12 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_OUT_DIR}) # all calls to blender use this if(APPLE) if(${CMAKE_GENERATOR} MATCHES "Xcode") - set(TEST_BLENDER_EXE_PARAMS --background --factory-startup --debug-memory --debug-exit-on-error) + set(TEST_BLENDER_EXE_PARAMS --background -noaudio --factory-startup --debug-memory --debug-exit-on-error) else() - set(TEST_BLENDER_EXE_PARAMS --background --factory-startup --debug-memory --debug-exit-on-error --env-system-scripts ${CMAKE_SOURCE_DIR}/scripts) + set(TEST_BLENDER_EXE_PARAMS --background -noaudio --factory-startup --debug-memory --debug-exit-on-error --env-system-scripts ${CMAKE_SOURCE_DIR}/scripts) endif() else() - set(TEST_BLENDER_EXE_PARAMS --background --factory-startup --debug-memory --debug-exit-on-error --env-system-scripts ${CMAKE_SOURCE_DIR}/scripts) + set(TEST_BLENDER_EXE_PARAMS --background -noaudio --factory-startup --debug-memory --debug-exit-on-error --env-system-scripts ${CMAKE_SOURCE_DIR}/scripts) endif() # for testing with valgrind prefix: valgrind --track-origins=yes --error-limit=no diff --git a/tests/python/compositor_cpu_render_tests.py b/tests/python/compositor_cpu_render_tests.py index d9abae801fd..55501eafcad 100644 --- a/tests/python/compositor_cpu_render_tests.py +++ b/tests/python/compositor_cpu_render_tests.py @@ -19,6 +19,7 @@ except ImportError: def get_arguments(filepath, output_filepath): return [ "--background", + "-noaudio", "--factory-startup", "--enable-autoexec", "--debug-memory", diff --git a/tests/python/compositor_realtime_render_tests.py b/tests/python/compositor_realtime_render_tests.py index 2b187bb0ac7..d244cbe39ab 100644 --- a/tests/python/compositor_realtime_render_tests.py +++ b/tests/python/compositor_realtime_render_tests.py @@ -17,12 +17,13 @@ except ImportError: ENABLE_REALTIME_COMPOSITOR_SCRIPT = "import bpy; " \ "bpy.context.preferences.experimental.use_experimental_compositors = True; " \ - "bpy.data.scenes[0].node_tree.execution_mode = 'GPU'" + "bpy.data.scenes[0].node_tree.execution_mode = 'REALTIME'" def get_arguments(filepath, output_filepath): return [ "--background", + "-noaudio", "--factory-startup", "--enable-autoexec", "--debug-memory", diff --git a/tests/python/cycles_render_tests.py b/tests/python/cycles_render_tests.py index 47c02e4e40b..043c9494c21 100644 --- a/tests/python/cycles_render_tests.py +++ b/tests/python/cycles_render_tests.py @@ -68,6 +68,7 @@ def get_arguments(filepath, output_filepath): args = [ "--background", + "-noaudio", "--factory-startup", "--enable-autoexec", "--debug-memory", diff --git a/tests/python/eevee_next_render_tests.py b/tests/python/eevee_next_render_tests.py index d487c5f41ec..c19b5e24917 100644 --- a/tests/python/eevee_next_render_tests.py +++ b/tests/python/eevee_next_render_tests.py @@ -17,69 +17,52 @@ def setup(): for scene in bpy.data.scenes: scene.render.engine = 'BLENDER_EEVEE_NEXT' - # Enable Eevee features - eevee = scene.eevee + # Enable Eevee features + scene = bpy.context.scene + eevee = scene.eevee + ray_tracing = eevee.ray_tracing_options - # Overscan of 50 will doesn't offset the final image, and adds more information for screen based ray tracing. - eevee.use_overscan = True - eevee.overscan_size = 50.0 + eevee.gtao_distance = 1 + eevee.use_volumetric_shadows = True + eevee.volumetric_tile_size = '2' + eevee.use_motion_blur = True + # Overscan of 50 will doesn't offset the final image, and adds more information for screen based ray tracing. + eevee.use_overscan = True + eevee.overscan_size = 50.0 + eevee.use_raytracing = True + eevee.ray_tracing_method = 'SCREEN' + ray_tracing.resolution_scale = "1" + ray_tracing.screen_trace_quality = 1.0 + ray_tracing.screen_trace_thickness = 1.0 + # Due to an issue in HiZ-buffer set the probe resolution to 256. When the + # probe resolution is to high it will be corrupted as the HiZ buffer isn't + # large enough + eevee.gi_cubemap_resolution = '256' - # Ambient Occlusion Pass - eevee.gtao_distance = 1 + # Does not work in edit mode + try: + # Simple probe setup + bpy.ops.object.lightprobe_add(type='SPHERE', location=(0.0, 0.0, 0.0)) + cubemap = bpy.context.selected_objects[0] + cubemap.scale = (1.0, 1.0, 1.0) + cubemap.data.falloff = 0.0 + cubemap.data.clip_start = 0.8 + cubemap.data.influence_distance = 1.2 - # Hair - scene.render.hair_type = 'STRIP' + bpy.ops.object.lightprobe_add(type='VOLUME', location=(0.0, 0.0, 0.0)) + grid = bpy.context.selected_objects[0] + grid.scale = (1.735, 1.735, 1.735) + grid.data.bake_samples = 256 + bpy.ops.object.lightprobe_cache_bake(subset='ACTIVE') + except: + pass - # Volumetric - eevee.volumetric_tile_size = '2' - eevee.volumetric_start = 1.0 - eevee.volumetric_end = 50.0 - eevee.volumetric_samples = 128 - eevee.use_volumetric_shadows = True - - # Motion Blur - if scene.render.use_motion_blur: - eevee.motion_blur_steps = 10 - - # Ray-tracing - eevee.use_raytracing = True - eevee.ray_tracing_method = 'SCREEN' - ray_tracing = eevee.ray_tracing_options - ray_tracing.resolution_scale = "1" - ray_tracing.screen_trace_quality = 1.0 - ray_tracing.screen_trace_thickness = 1.0 - - # Light-probes - eevee.gi_cubemap_resolution = '256' - - # Only include the plane in probes - for ob in scene.objects: - if ob.name != 'Plane' and ob.type != 'LIGHT': - ob.hide_probe_volume = True - ob.hide_probe_sphere = True - ob.hide_probe_plane = True - - # Does not work in edit mode - if bpy.context.mode == 'OBJECT': - # Simple probe setup - bpy.ops.object.lightprobe_add(type='SPHERE', location=(0.0, 0.0, 1.0)) - cubemap = bpy.context.selected_objects[0] - cubemap.scale = (5.0, 5.0, 2.0) - cubemap.data.falloff = 0.0 - cubemap.data.clip_start = 0.8 - cubemap.data.influence_distance = 1.2 - - bpy.ops.object.lightprobe_add(type='VOLUME', location=(0.0, 0.0, 2.0)) - grid = bpy.context.selected_objects[0] - grid.scale = (8.0, 4.5, 4.5) - grid.data.grid_resolution_x = 32 - grid.data.grid_resolution_y = 16 - grid.data.grid_resolution_z = 8 - grid.data.grid_bake_samples = 128 - grid.data.grid_capture_world = True - # Make lighting smoother for most of the case. - grid.data.grid_dilation_threshold = 1.0 - bpy.ops.object.lightprobe_cache_bake(subset='ACTIVE') + # Only include the plane in probes + for ob in scene.objects: + if ob.name != 'Plane' and ob.type != 'LIGHT': + ob.hide_probe_volume = True + ob.hide_probe_sphere = True + ob.hide_probe_plane = True # When run from inside Blender, render and exit. @@ -101,6 +84,7 @@ def get_gpu_device_type(blender): # TODO: This always fails. command = [ blender, + "-noaudio", "--background", "--factory-startup", "--python", @@ -120,6 +104,7 @@ def get_gpu_device_type(blender): def get_arguments(filepath, output_filepath): return [ "--background", + "-noaudio", "--factory-startup", "--enable-autoexec", "--debug-memory", diff --git a/tests/python/eevee_render_tests.py b/tests/python/eevee_render_tests.py index bb37cb96e22..9b1c65f0c47 100644 --- a/tests/python/eevee_render_tests.py +++ b/tests/python/eevee_render_tests.py @@ -103,6 +103,7 @@ if inside_blender: def get_gpu_device_type(blender): command = [ blender, + "-noaudio", "--background", "--factory-startup", "--python", @@ -122,6 +123,7 @@ def get_gpu_device_type(blender): def get_arguments(filepath, output_filepath): return [ "--background", + "-noaudio", "--factory-startup", "--enable-autoexec", "--debug-memory", diff --git a/tests/python/modules/test_utils.py b/tests/python/modules/test_utils.py index 32c9102120e..fa7b3a26f19 100755 --- a/tests/python/modules/test_utils.py +++ b/tests/python/modules/test_utils.py @@ -60,6 +60,7 @@ class AbstractBlenderRunnerTest(unittest.TestCase): command = [ self.blender, '--background', + '-noaudio', '--factory-startup', '--enable-autoexec', '--debug-memory', diff --git a/tests/python/rna_info_dump.py b/tests/python/rna_info_dump.py index 2d1482a8c45..02aba6c864b 100644 --- a/tests/python/rna_info_dump.py +++ b/tests/python/rna_info_dump.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Used for generating API diffs between releases -# ./blender.bin --background --python tests/python/rna_info_dump.py +# ./blender.bin --background -noaudio --python tests/python/rna_info_dump.py import bpy diff --git a/tests/python/sequencer_render_tests.py b/tests/python/sequencer_render_tests.py index aeab204a5c0..35583d2c358 100644 --- a/tests/python/sequencer_render_tests.py +++ b/tests/python/sequencer_render_tests.py @@ -15,6 +15,7 @@ def get_arguments(filepath, output_filepath): args = [ "--background", + "-noaudio", "--factory-startup", "--enable-autoexec", "--debug-memory", diff --git a/tests/python/storm_render_tests.py b/tests/python/storm_render_tests.py index a058268adee..642626a48a5 100644 --- a/tests/python/storm_render_tests.py +++ b/tests/python/storm_render_tests.py @@ -38,6 +38,7 @@ if inside_blender: def get_arguments(filepath, output_filepath): return [ "--background", + "-noaudio", "--factory-startup", "--enable-autoexec", "--debug-memory", diff --git a/tests/python/view_layer/CMakeLists.txt b/tests/python/view_layer/CMakeLists.txt index bcfafdbee0c..67eb9f4ee15 100644 --- a/tests/python/view_layer/CMakeLists.txt +++ b/tests/python/view_layer/CMakeLists.txt @@ -17,7 +17,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_OUT_DIR}) # endif() # for testing with valgrind prefix: valgrind --track-origins=yes --error-limit=no -set(TEST_BLENDER_EXE $ --background --factory-startup --debug-memory --debug-exit-on-error --env-system-scripts ${CMAKE_SOURCE_DIR}/scripts) +set(TEST_BLENDER_EXE $ --background -noaudio --factory-startup --debug-memory --debug-exit-on-error --env-system-scripts ${CMAKE_SOURCE_DIR}/scripts) # ------------------------------------------------------------------------------ diff --git a/tests/python/workbench_render_tests.py b/tests/python/workbench_render_tests.py index 03950b09b0f..a9a90492649 100644 --- a/tests/python/workbench_render_tests.py +++ b/tests/python/workbench_render_tests.py @@ -37,6 +37,7 @@ if inside_blender: def get_arguments(filepath, output_filepath): return [ "--background", + "-noaudio", "--factory-startup", "--enable-autoexec", "--debug-memory", diff --git a/tools/check_source/check_descriptions.py b/tools/check_source/check_descriptions.py index e83d1a48515..5569e0d1597 100644 --- a/tools/check_source/check_descriptions.py +++ b/tools/check_source/check_descriptions.py @@ -6,7 +6,7 @@ """ this script updates XML themes once new settings are added - ./blender.bin --background --python tools/check_source/check_descriptions.py + ./blender.bin --background -noaudio --python tools/check_source/check_descriptions.py """ import bpy diff --git a/tools/modules/blendfile.py b/tools/modules/blendfile.py index e6c22dc0b68..aecbf2632e6 100644 --- a/tools/modules/blendfile.py +++ b/tools/modules/blendfile.py @@ -25,6 +25,54 @@ class BlendFileError(Exception): """Raised when there was an error reading/parsing a blend file.""" +# ----------------------------------------------------------------------------- +# module global routines +# +# read routines +# open a filename +# determine if the file is compressed +# and returns a handle +def open_blend(filename, access="rb"): + """Opens a blend file for reading or writing pending on the access + supports 2 kind of blend files. Uncompressed and compressed. + Known issue: does not support packaged blend files + """ + handle = open(filename, access) + magic_test = b"BLENDER" + magic = handle.read(len(magic_test)) + if magic == magic_test: + log.debug("normal blendfile detected") + handle.seek(0, os.SEEK_SET) + bfile = BlendFile(handle) + bfile.is_compressed = False + bfile.filepath_orig = filename + return bfile + elif magic[:2] == b'\x1f\x8b': + log.debug("gzip blendfile detected") + handle.close() + log.debug("decompressing started") + fs = gzip.open(filename, "rb") + data = fs.read(FILE_BUFFER_SIZE) + magic = data[:len(magic_test)] + if magic == magic_test: + handle = tempfile.TemporaryFile() + while data: + handle.write(data) + data = fs.read(FILE_BUFFER_SIZE) + log.debug("decompressing finished") + fs.close() + log.debug("resetting decompressed file") + handle.seek(os.SEEK_SET, 0) + bfile = BlendFile(handle) + bfile.is_compressed = True + bfile.filepath_orig = filename + return bfile + else: + raise BlendFileError("filetype inside gzip not a blend") + else: + raise BlendFileError("filetype not a blend or a gzip blend") + + def pad_up_4(offset): return (offset + 3) & ~3 @@ -445,7 +493,7 @@ class BlendFileBlock: for k in self.keys(): yield from self.get_recursive_iter(k, use_nil=use_nil, use_str=False) - def get_data_hash(self, seed=1): + def get_data_hash(self): """ Generates a 'hash' that can be used instead of addr_old as block id, and that should be 'stable' across .blend file load & save (i.e. it does not changes due to pointer addresses variations). @@ -458,7 +506,7 @@ class BlendFileBlock: return self.file.structs[self.sdna_index].field_from_path( self.file.header, self.file.handle, k).dna_name.is_pointer - hsh = seed + hsh = 1 for k, v in self.items_recursive_iter(): if not _is_pointer(self, k): hsh = zlib.adler32(str(v).encode(), hsh) @@ -538,198 +586,6 @@ class BlendFileBlock: yield (k, "<%s>" % dna_type.dna_type_id.decode('ascii')) -######################################################################################################################## -# Way more basic access to blendfile data, without any DNA handling. - -class BlendFileRaw: - """ - Blend file, at a very low-level (only a collection of blocks). Can survive opening e.g. blendfiles withou DNA info. - """ - __slots__ = ( - # file (result of open()) - "handle", - # str (original name of the file path) - "filepath_orig", - # BlendFileHeader - "header", - # struct.Struct - "block_header_struct", - # BlendFileBlock - "blocks", - # dict {addr_old: block} - "block_from_offset", - # int - "code_index", - # bool (did we make a change) - "is_modified", - # bool (is file gzipped) - "is_compressed", - ) - - def __init__(self, handle): - log.debug("initializing reading blend-file") - self.handle = handle - self.header = BlendFileHeader(handle) - self.block_header_struct = self.header.create_block_header_struct() - self.blocks = [] - self.code_index = {} - - block = BlendFileBlockRaw(handle, self) - while block.code != b'ENDB': - handle.seek(block.size, os.SEEK_CUR) - self.blocks.append(block) - self.code_index.setdefault(block.code, []).append(block) - - block = BlendFileBlockRaw(handle, self) - self.is_modified = False - self.blocks.append(block) - - # Cache (could lazy init, in case we never use?). - self.block_from_offset = {block.addr_old: block for block in self.blocks if block.code != b'ENDB'} - - def __repr__(self): - return '<%s %r>' % (self.__class__.__qualname__, self.handle) - - def __enter__(self): - return self - - def __exit__(self, type, value, traceback): - self.close() - - def find_blocks_from_code(self, code): - assert type(code) == bytes - if code not in self.code_index: - return [] - return self.code_index[code] - - def find_block_from_offset(self, offset): - # same as looking looping over all blocks, - # then checking `block.addr_old == offset`. - assert type(offset) is int - return self.block_from_offset.get(offset) - - def close(self): - """ - Close the blend file - writes the blend file to disk if changes has happened - """ - handle = self.handle - - if self.is_modified: - if self.is_compressed: - log.debug("close compressed blend file") - handle.seek(os.SEEK_SET, 0) - log.debug("compressing started") - fs = gzip.open(self.filepath_orig, "wb") - data = handle.read(FILE_BUFFER_SIZE) - while data: - fs.write(data) - data = handle.read(FILE_BUFFER_SIZE) - fs.close() - log.debug("compressing finished") - - handle.close() - - def ensure_subtype_smaller(self, sdna_index_curr, sdna_index_next): - # never refine to a smaller type - if (self.structs[sdna_index_curr].size > - self.structs[sdna_index_next].size): - - raise RuntimeError("cant refine to smaller type (%s -> %s)" % - (self.structs[sdna_index_curr].dna_type_id.decode('ascii'), - self.structs[sdna_index_next].dna_type_id.decode('ascii'))) - - -class BlendFileBlockRaw: - """ - Instance of a raw blendfile block (only contains its header currently). - """ - __slots__ = ( - # BlendFile - "file", - "code", - "size", - "addr_old", - "sdna_index", - "count", - "file_offset", - "user_data", - ) - - def __str__(self): - return ("<%s.%s (%s), size=%d at %s>" % - # fields=[%s] - (self.__class__.__name__, - self.dna_type_name, - self.code.decode(), - self.size, - # b", ".join(f.dna_name.name_only for f in self.dna_type.fields).decode('ascii'), - hex(self.addr_old), - )) - - def __init__(self, handle, bfile): - OLDBLOCK = struct.Struct(b'4sI') - - self.file = bfile - self.user_data = None - - data = handle.read(bfile.block_header_struct.size) - - if len(data) != bfile.block_header_struct.size: - print("WARNING! Blend file seems to be badly truncated!") - self.code = b'ENDB' - self.size = 0 - self.addr_old = 0 - self.sdna_index = 0 - self.count = 0 - self.file_offset = 0 - return - # header size can be 8, 20, or 24 bytes long - # 8: old blend files ENDB block (exception) - # 20: normal headers 32 bit platform - # 24: normal headers 64 bit platform - if len(data) > 15: - blockheader = bfile.block_header_struct.unpack(data) - self.code = blockheader[0].partition(b'\0')[0] - if self.code != b'ENDB': - self.size = blockheader[1] - self.addr_old = blockheader[2] - self.sdna_index = blockheader[3] - self.count = blockheader[4] - self.file_offset = handle.tell() - else: - self.size = 0 - self.addr_old = 0 - self.sdna_index = 0 - self.count = 0 - self.file_offset = 0 - else: - blockheader = OLDBLOCK.unpack(data) - self.code = blockheader[0].partition(b'\0')[0] - self.code = DNA_IO.read_data0(blockheader[0]) - self.size = 0 - self.addr_old = 0 - self.sdna_index = 0 - self.count = 0 - self.file_offset = 0 - - def get_data_hash(self, seed=1): - """ - Generates a 'hash' that can be used instead of addr_old as block id, and that should be 'stable' across .blend - file load & save (i.e. it does not changes due to pointer addresses variations). - """ - # TODO This implementation is most likely far from optimal... and CRC32 is not renown as the best hashing - # algorithm either. But for now does the job! - import zlib - - hsh = seed - hsh = zlib.adler32(str(self.code).encode(), hsh) - hsh = zlib.adler32(str(self.size).encode(), hsh) - hsh = zlib.adler32(str(self.sdna_index).encode(), hsh) - hsh = zlib.adler32(str(self.count).encode(), hsh) - return hsh - - # ----------------------------------------------------------------------------- # Read Magic # @@ -1166,51 +1022,3 @@ class DNA_IO: if header.pointer_size == 8: st = DNA_IO.ULONG[header.endian_index] return st.unpack(handle.read(st.size))[0] - - -# ----------------------------------------------------------------------------- -# module global routines -# -# read routines -# open a filename -# determine if the file is compressed -# and returns a handle -def open_blend(filename, access="rb", wrapper_type=BlendFile): - """Opens a blend file for reading or writing pending on the access - supports 2 kind of blend files. Uncompressed and compressed. - Known issue: does not support packaged blend files - """ - handle = open(filename, access) - magic_test = b"BLENDER" - magic = handle.read(len(magic_test)) - if magic == magic_test: - log.debug("normal blendfile detected") - handle.seek(0, os.SEEK_SET) - bfile = wrapper_type(handle) - bfile.is_compressed = False - bfile.filepath_orig = filename - return bfile - elif magic[:2] == b'\x1f\x8b': - log.debug("gzip blendfile detected") - handle.close() - log.debug("decompressing started") - fs = gzip.open(filename, "rb") - data = fs.read(FILE_BUFFER_SIZE) - magic = data[:len(magic_test)] - if magic == magic_test: - handle = tempfile.TemporaryFile() - while data: - handle.write(data) - data = fs.read(FILE_BUFFER_SIZE) - log.debug("decompressing finished") - fs.close() - log.debug("resetting decompressed file") - handle.seek(os.SEEK_SET, 0) - bfile = wrapper_type(handle) - bfile.is_compressed = True - bfile.filepath_orig = filename - return bfile - else: - raise BlendFileError("filetype inside gzip not a blend") - else: - raise BlendFileError("filetype not a blend or a gzip blend") diff --git a/tools/utils/blend2json.py b/tools/utils/blend2json.py index 4f84e5445ab..5204f7d69e5 100755 --- a/tools/utils/blend2json.py +++ b/tools/utils/blend2json.py @@ -91,7 +91,7 @@ def keyval_to_json(kvs, indent, indent_step, compact_output=False): else: return ('{%s' % indent_step[:-1] + (',\n%s%s' % (indent, indent_step)).join( - ('"%s":\n%s%s%s' % (k, indent, indent_step, v) if (v and v[0] in {'[', '{'}) else + ('"%s":\n%s%s%s' % (k, indent, indent_step, v) if (v[0] in {'[', '{'}) else '"%s": %s' % (k, v)) for k, v in kvs) + '\n%s}' % indent) @@ -114,17 +114,14 @@ def gen_fake_addresses(args, blend): if args.use_fake_address: hashes = set() ret = {} - hash_seed = 1 for block in blend.blocks: if not block.addr_old: continue - hsh = block.get_data_hash(hash_seed) + hsh = block.get_data_hash() while hsh in hashes: hsh += 1 hashes.add(hsh) ret[block.addr_old] = hsh - if (args.raw_bblock): - hash_seed +=1 return ret return {} @@ -212,7 +209,6 @@ def do_bblock_filter(filters, blend, block, meta_keyval, data_keyval): def bblocks_to_json(args, fw, blend, address_map, indent, indent_step): - raw_bblock = args.raw_bblock no_address = args.no_address full_data = args.full_data filter_data = args.filter_data @@ -221,20 +217,16 @@ def bblocks_to_json(args, fw, blend, address_map, indent, indent_step): keyval = [ ("code", json_dumps(block.code)), ("size", json_dumps(block.size)), - ("file_offset", json_dumps(block.file_offset)), ] if not no_address: keyval += [("addr_old", json_dumps(address_map.get(block.addr_old, block.addr_old)))] - if raw_bblock: - keyval += [("dna_index", json_dumps(block.sdna_index))] - else: - keyval += [("dna_type_id", json_dumps(blend.structs[block.sdna_index].dna_type_id))] - keyval += [("count", json_dumps(block.count))] + keyval += [ + ("dna_type_id", json_dumps(blend.structs[block.sdna_index].dna_type_id)), + ("count", json_dumps(block.count)), + ] return keyval def gen_data_keyval(blend, block, key_filter=None): - if raw_bblock: - return [] def _is_pointer(k): return blend.structs[block.sdna_index].field_from_path(blend.header, blend.handle, k).dna_name.is_pointer if key_filter is not None: @@ -314,9 +306,8 @@ def blend_to_json(args, f, blend, address_map): bheader_to_json(args, fw, blend, indent, indent_step) fw(',\n') bblocks_to_json(args, fw, blend, address_map, indent, indent_step) - if not args.raw_bblock: - fw(',\n') - bdna_to_json(args, fw, blend, indent, indent_step) + fw(',\n') + bdna_to_json(args, fw, blend, indent, indent_step) fw('\n}\n') @@ -382,12 +373,6 @@ def argparse_create(): "--full-dna", dest="full_dna", default=False, action='store_true', required=False, help=("Also put in JSon file dna properties description (ignored when --compact-output is used)")) - parser.add_argument( - "--raw-bblock", dest="raw_bblock", - default=False, action='store_true', required=False, - help=("Do not attempt to open and parse the Blendfile at a high level, but only handles its basic data layout " - "(usable when the given files are not valid blendfiles - e.g. corrupted ones)")) - group = parser.add_argument_group("Filters", FILTER_DOC) group.add_argument( "--filter-block", dest="block_filters", nargs=3, action='append', @@ -421,15 +406,6 @@ def main(): args.filter_data = {n.encode() for n in args.filter_data.split(',')} for infile, outfile in zip(args.input, args.output): - if args.raw_bblock: - with blendfile.open_blend(infile, wrapper_type=blendfile.BlendFileRaw) as blend: - address_map = gen_fake_addresses(args, blend) - - if outfile: - with open(outfile, 'w', encoding="ascii", errors='xmlcharrefreplace') as f: - blend_to_json(args, f, blend, address_map) - continue - with blendfile.open_blend(infile) as blend: address_map = gen_fake_addresses(args, blend) diff --git a/tools/utils/blender_theme_as_c.py b/tools/utils/blender_theme_as_c.py index 06bba5da238..ce0b1106f7b 100755 --- a/tools/utils/blender_theme_as_c.py +++ b/tools/utils/blender_theme_as_c.py @@ -29,7 +29,7 @@ C_SOURCE_HEADER = r'''/* SPDX-FileCopyrightText: 2018 Blender Authors #include "DNA_userdef_types.h" -#include "BLO_userdef_default.h" +#include "BLO_readfile.h" /* clang-format off */ diff --git a/tools/utils/cycles_timeit.py b/tools/utils/cycles_timeit.py index 1ca4daa8f16..3dfc64acc63 100755 --- a/tools/utils/cycles_timeit.py +++ b/tools/utils/cycles_timeit.py @@ -136,6 +136,7 @@ def benchmarkFile(blender, blendfile, stats): # Configure command for the current file. command = (blender, "--background", + "-noaudio", "--factory-startup", blendfile, "--engine", "CYCLES", diff --git a/tools/utils_maintenance/code_clean.py b/tools/utils_maintenance/code_clean.py index 7d926c2b92f..42b486e5f1d 100755 --- a/tools/utils_maintenance/code_clean.py +++ b/tools/utils_maintenance/code_clean.py @@ -1455,24 +1455,14 @@ class edit_generators: """ Clean headers, ensuring that the headers removed are not used directly or indirectly. - Note that the `CFLAGS` should be set so missing prototypes error instead of warn. - With GCC: - CMAKE_C_FLAGS=-Werror=missing-prototypes -Werror=undef - CMAKE_CXX_FLAGS=-Werror=missing-declarations -Werror=undef + Note that the `CFLAGS` should be set so missing prototypes error instead of warn: + With GCC: `-Werror=missing-prototypes` """ # Non-default because changes to headers may cause breakage on other platforms. # Before committing these changes all supported platforms should be tested to compile without problems. is_default = False - @staticmethod - def _header_exclude(f_basename: str) -> str: - # This header only exists to add additional warnings, removing it doesn't impact generated output. - # Skip this file. - if f_basename == "BLI_strict_flags.h": - return True - return False - @staticmethod def _header_guard_from_filename(f: str) -> str: return '__%s__' % os.path.basename(f).replace('.', '_').upper() @@ -1489,10 +1479,6 @@ class edit_generators: os.path.join(SOURCE_DIR, 'source'), ('.h', '.hh', '.inl', '.hpp', '.hxx'), ): - f_basename = os.path.basename(f) - if cls._header_exclude(f_basename): - continue - with open(f, 'r', encoding='utf-8') as fh: data = fh.read() @@ -1533,12 +1519,7 @@ class edit_generators: # Remove include. for match in re.finditer(r"^(([ \t]*#\s*include\s+\")([^\"]+)(\"[^\n]*\n))", data, flags=re.MULTILINE): header_name = match.group(3) - # Use in case the include has a leading path. - header_basename = os.path.basename(header_name) - if cls._header_exclude(header_basename): - continue - - header_guard = cls._header_guard_from_filename(header_basename) + header_guard = cls._header_guard_from_filename(header_name) edits.append(Edit( span=match.span(), content='', # Remove the header. @@ -1665,9 +1646,6 @@ def test_edit( if os.path.exists(output): os.remove(output) - # Useful when inspecting failure to compile files, so it's possible to run the command manually. - # `print("COMMAND: {:s}\nCMD: {:s}\nOUTPUT: {:s}\n".format(" ".join(build_args), str(build_cwd), output))` - with open(source, 'w', encoding='utf-8') as fh: fh.write(data_test) @@ -1838,7 +1816,7 @@ def wash_source_with_edit( build_args_for_edit = build_args if extra_build_args: # Add directly after the compile command. - build_args_for_edit = tuple(list(build_args[:1]) + list(extra_build_args) + list(build_args[1:])) + build_args_for_edit = build_args[:1] + extra_build_args + build_args[1:] data_test = apply_edit(source_relative, data, text, start, end, verbose=verbose_edit_actions) if test_edit(